目录文档-技术白皮书(V5.05)51-管线卡 Template v1.0

第11章 接口与实现绑定(API/函数原型)


I. 目的与范围(Purpose & Scope)


II. 前置条件与输入(Prerequisites & Inputs)


III. 错误语义与返回约定(Error Model & Return Envelope)

{

"status": "OK|ERROR",

"code": 0,

"error": { "type": "E_*", "message": "...", "details": {...} },

"payload": {...},

"metrics": {"latency_ms":123,"retries":0},

"anchors": ["EFT.WP.Core.Equations v1.1:S20-1"],

"version": "1.0.0",

"checksum": "sha256:..."

}


IV. 幂等、重试与审计(Idempotency, Retry & Audit)


V. 核心函数原型(Implementation Bindings, I60–I69)

  1. I60-stage_exec(ctx, x) -> y | err
    • in:ctx{idempotency_key,retry_policy,window,partition};x 为阶段输入(与 TARR 对齐)。
    • out:阶段输出 y 与指标 metrics{latency,throughput}。
    • errors:E_INPUT/E_DIM/E_GATE/E_SYNC/E_UQ/E_INTERNAL。
    • see:EFT.WP.Core.Equations v1.1:S20-1、EFT.WP.Core.Metrology v1.0:check_dim。
  2. I61-validate_gate(card, gates[]) -> report.json
    • in:阶段或管线描述 card、门集合 ["G1".."G8"]。
    • out:{gates:{G1:true|0.93,...},stops_triggered:[],links{check_dim_report,audit}}。
    • see:本卷第9章。
  3. I62-export_artifacts(fmt) -> {manifest, checksums}
    • in:fmt ∈ {zip, tgz};
    • out:report_manifest.yaml、checksums[]。
  4. I63-path_align(path,inplace=false) -> path'
    • in:path{gamma_ell[],d_ell[],n_eff[],delta_form}。
    • out:对齐/补齐后的路径;保证 len(gamma_ell)=len(d_ell)=len(n_eff)。
    • see:第5/6章。
  5. I64-derive_arrival(path,c_ref) -> T_arr
    • form:T_arr = ( ∫ ( n_eff / c_ref ) d ell );或 T_arr = ( 1 / c_ref ) * ( ∫ n_eff d ell )。
    • req:正文显式 gamma(ell)、d ell;数据记录 delta_form;p_dim = 1.0。
  6. I65-derive_phase(path,lambda_ref) -> Phi
    form:Phi = ( 2π / λ_ref ) * ( ∫ n_eff d ell )。
  7. I66-uq_delta(J, Sigma) -> {u, u_c, U}
    • in:J=∂f/∂x|_{x̂}、Σ=Cov(x);
    • out:标准不确定度与扩展不确定度;与第10章口径一致。
  8. I67-cov_blocks_merge(blocks[]) -> Σ
    功能:块协方差拼接;验证 PD(必要时加抖动)。
  9. I68-stage_replay(subgraph, checkpoint) -> report
    约束:拓扑倒序回放;通过 G1–G8;一致性校核输出哈希。
  10. I69-emit_audit(event) -> OK
    event:{ts,event,stage_id,idempotency_key,input_hashes,attempt,...}。

VI. OpenAPI(REST)契约(节选)

openapi: 3.0.3

info: { title: "Pipeline API", version: "1.0.0" }

servers: [{ url: "https://api.example.com/v1" }]

components:

securitySchemes: { bearerAuth: { type: http, scheme: bearer } }

schemas:

StageExecRequest:

type: object

required: [ctx, x]

properties:

ctx:

type: object

properties:

idempotency_key: { type: string }

retry_policy: { type: object }

window: { type: string }

partition: { type: string }

x: { $ref: "#/components/schemas/StageInput" }

StageExecResponse:

type: object

properties:

status: { type: string }

code: { type: integer }

payload: { $ref: "#/components/schemas/StageOutput" }

metrics: { type: object }

anchors: { type: array, items: { type: string } }

version: { type: string }

checksum: { type: string }

paths:

/stages/{id}/exec:

post:

security: [{ bearerAuth: [] }]

summary: "Execute a stage (idempotent)"

parameters: [{ in: path, name: id, required: true, schema: { type: string } }]

requestBody:

required: true

content: { application/json: { schema: { $ref: "#/components/schemas/StageExecRequest" } } }

responses:

"200": { description: "OK", content: { application/json: { schema: { $ref: "#/components/schemas/StageExecResponse" } } } }

"409": { description: "Idempotency conflict" }

/validate:

post:

summary: "Validate gates"

requestBody: { required: true, content: { application/json: { schema: { type: object, properties: { gates: { type: array, items: { type: string } } } } } } }

responses: { "200": { description: "Validation report" } }

/artifacts/export:

post:

summary: "Export artifacts"

responses: { "200": { description: "Manifest & checksums" } }


VII. gRPC 接口(节选,proto)

syntax = "proto3";

package pipeline.v1;

message Ctx {

string idempotency_key = 1;

string window = 2;

string partition = 3;

}

message StageExecRequest {

Ctx ctx = 1;

bytes x = 2; // Avro/Parquet/JSON payload

}

message StageExecResponse {

string status = 1;

int32 code = 2;

bytes payload = 3;

map<string,string> metrics = 4;

repeated string anchors = 5;

string version = 6;

string checksum = 7;

}

service StageService {

rpc Exec(StageExecRequest) returns (StageExecResponse);

rpc Validate(ValidateRequest) returns (ValidateResponse);

rpc ExportArtifacts(ExportRequest) returns (ExportResponse);

}


VIII. CLI 约定(节选)

# 幂等执行

pipeline stage exec stage-30-arrival \

--ctx.idempotency_key run42+p010+win001 \

--in path.gamma_ell=@gamma.npy --in path.d_ell=@d_ell.npy \

--in medium.n_eff_profile=@n.npy --in ref.c_ref=2.9979e8

# 门校验

pipeline validate --gates G1 G2 G3 G4 G5 G6 G7 G8 --out reports/validate_report.json

# 导出制品

pipeline artifacts export --fmt tgz --out PTN_EXPORT/artifacts.tgz


IX. 安全与访问控制(Security & Access Control)


X. 路径阶段专属规范(Path-Specific Rules)


XI. 机读示例与反例(Machine-Readable Examples / Anti-Patterns)
A. 正例:阶段执行请求/响应

{"ctx":{"idempotency_key":"run42+p010+win001"},"x":{"path":{"gamma_ell":[...],"d_ell":[...],"delta_form":"general"},"ref":{"c_ref":2.9979e8},"medium":{"n_eff_profile":[...]}}}

{"status":"OK","code":0,"payload":{"obs":{"T_arr":1.23e-8}},"metrics":{"latency_ms":87},"anchors":["EFT.WP.Core.Equations v1.1:S20-1"],"version":"1.0.0","checksum":"sha256:..."}

B. 反例:缺少 d ell 与括号

{"x":{"path":{"gamma_ell":[...]}, "control":{"form":"T_arr = ∫ n_eff / c_ref d ell"}}} // 应拒绝


XII. 发布与目录结构(Release & Layout)

PTN_EXPORT/

api/

openapi.yaml

grpc.proto

bindings/

stage-30-arrival.yaml

stage-40-phase.yaml

reports/

check_dim_report.json

validate_report.json

audit.jsonl

figs/

api_topology.svg

report_manifest.yaml

SIGNATURE.asc


XIII. 执行勾选清单(Checklist)


版权与许可:除另有说明外,《能量丝理论》(含文本、图表、插图、符号与公式)的著作权由作者(屠广林)享有。
许可方式(CC BY 4.0):在注明作者与来源的前提下,允许复制、转载、节选、改编与再分发。
署名格式(建议):作者:屠广林|作品:《能量丝理论》|来源:energyfilament.org|许可证:CC BY 4.0
验证召集: 作者独立自费、无雇主无资助;下一阶段将优先在最愿意公开讨论、公开复现、公开挑错的环境中推进落地,不限国家。欢迎各国媒体与同行抓住窗口组织验证,并与我们联系。
版本信息: 首次发布:2025-11-11 | 当前版本:v6.0+5.05