Expose loop transfers through versioned public observations
This commit is contained in:
1 parent
69c5dc8d20
commit
71d29261a8
21 files changed
+486
-35
No files matched your search
@@ -118,7 +118,7 @@ Required payload fields: `entry`, `mode`, `source`; optional
|
||||
```
|
||||
|
||||
`source.analysis_digest` is `sha256:` plus the SHA-256 of the **exact bytes**
|
||||
of the Analysis v2 file produced for the same project and projection
|
||||
of the [Analysis file](analysis-v3.md) produced for the same project and projection
|
||||
configuration (not a re-serialization of the in-memory IR). If the source
|
||||
changes, existing events become stale; consumers must not render them onto the
|
||||
new source.
|
||||
@@ -152,6 +152,7 @@ Required payload fields:
|
||||
| `return` | `frame_id`, `value_type`, `module_id`, `span` |
|
||||
| `branch.eval` | `frame_id`, `result`, `module_id`, `span` |
|
||||
| `loop.iteration` | `frame_id`, `decision`, `module_id`, `span` |
|
||||
| `control.break`, `control.continue` | `frame_id`, `module_id`, non-null `span` |
|
||||
| `effect` | `operation`, `result_code`, `module_id`, `span` |
|
||||
|
||||
* `frame_id` is an opaque run-unique string (`f1`, `f2`, ...). It identifies
|
||||
@@ -166,6 +167,10 @@ Required payload fields:
|
||||
* `branch.eval.result` is a JSON boolean. `loop.iteration.decision` is
|
||||
`continue` (body will execute) or `exit` (condition was false). The event is
|
||||
emitted once per condition evaluation; iteration indices are not part of v1.
|
||||
* `control.break` and `control.continue` report an executed transfer at
|
||||
its carrier span. The frame stays active. A continue precedes the next
|
||||
condition check, and a break skips further checks of the loop it exits.
|
||||
The structural event budget applies to both events.
|
||||
* `effect.result_code` is a non-sensitive result summary (for example `ok` or a
|
||||
stable error code). It never carries effect arguments or file contents.
|
||||
* `module_id` is a logical package module id; `span` is
|
||||
@@ -291,7 +296,7 @@ authorization are unchanged.
|
||||
* Program stdout/stderr may contain secrets by the program's own intent; the
|
||||
protocol preserves bytes and does not promise automatic redaction of program
|
||||
output.
|
||||
* Trace v2 and Analysis v2 never gain argument/local values, handles, memory
|
||||
* Trace v2 and Analysis never gain argument/local values, handles, memory
|
||||
bytes or new secret-bearing fields through this protocol.
|
||||
* A third-party extension's raw OS stdout/stderr must not pollute the JSONL
|
||||
channel. Such output remains external process data: it is either captured by
|
||||
@@ -303,11 +308,11 @@ authorization are unchanged.
|
||||
* Tests use synthetic sentinel values and assert that unselected values never
|
||||
appear in the stream, Trace or `--json`.
|
||||
|
||||
## 6. Relation to Analysis v2 and Trace v2
|
||||
## 6. Relation to Analysis and Trace v2
|
||||
|
||||
| Artifact | Relation |
|
||||
|---|---|
|
||||
| Analysis v2 | Static only. `run.started.source` binds to its exact bytes via `analysis_digest`. Events never replace it. |
|
||||
| Analysis v2/v3 | Static only. `run.started.source` binds to its exact bytes via `analysis_digest`. Events never replace it. |
|
||||
| Trace v2 | Unchanged schema/version and privacy promise. In a combined run both writers share the CLI-generated `run_id`; Trace v2 gains no frame/value fields and is still published atomically after the run. |
|
||||
| Tool Protocol v1 | Unchanged. A consumer invokes the released binary via `MARQDO_BIN` and negotiates by reading `stream.opened`; `tool.json` does not implicitly advertise an `events` field. |
|
||||
| View SSE | Implemented by the View repository by adapting this JSONL stream. The CLI implements no HTTP/SSE. |
|
||||
|
||||
@@ -154,6 +154,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {"required": ["kind"], "properties": {"kind": {"enum": ["control.break", "control.continue"]}}},
|
||||
"then": {
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"required": ["frame_id", "module_id", "span"],
|
||||
"properties": {
|
||||
"frame_id": {"type": "string", "pattern": "^f[0-9]+$"},
|
||||
"module_id": {"type": "string", "minLength": 1},
|
||||
"span": {"type": "object", "$ref": "#/$defs/span"}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {"required": ["kind"], "properties": {"kind": {"enum": ["variable.assigned", "parameter.observed"]}}},
|
||||
"then": {
|
||||
|
||||
+4
-3
@@ -29,7 +29,7 @@
|
||||
}
|
||||
```
|
||||
|
||||
类型:`schema` 固定字符串,`schema_version` 正整数(首版仅 1),`name`/`version`/`command`/`entrypoint` 非空字符串,`version` 必须是合法 SemVer,`compatibility.marqdo` 必须是可解析的 SemVer 范围,`analysis`、`trace` 为可选的非空正整数数组;仅当工具使用该数据协议时声明。当前核心提供 Analysis v2 与 Trace v2,因此声明 `[1]`(或与 `[2]` 无交集)会在安装/分发时被拒绝。未来可以增加可选字段,但不得改变现有字段含义。
|
||||
类型:`schema` 固定字符串,`schema_version` 正整数(首版仅 1),`name`/`version`/`command`/`entrypoint` 非空字符串,`version` 必须是合法 SemVer,`compatibility.marqdo` 必须是可解析的 SemVer 范围,`analysis`、`trace` 为可选的非空正整数数组;仅当工具使用该数据协议时声明。当前开发分支提供 Analysis v2/v3 与 Trace v2。声明与对应版本集合无交集时,安装和分发会拒绝。未来可以增加可选字段,但不得改变现有字段含义。
|
||||
|
||||
`command`:建议 `^[a-z][a-z0-9-]*$`,不得与任何内置命令或保留参数冲突;同一注册表中命令唯一,名字冲突拒绝且不覆盖。`entrypoint`:包内受控相对路径,不能是绝对路径、`.`/`..` 跳出根目录、符号链接逃逸或可直接解释的任意 shell 片段。真实文件应可执行并与目标平台匹配;若扩展名或平台格式与 OS 不兼容应显式失败。
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
|
||||
工具负责自己的命令层级与帮助,如 `marqdo benchmark run .`、`marqdo benchmark --help`。CLI 不读取或修改工具业务选项。Rust `clap` 可通过单一 `external_subcommand` 捕获未知子命令,但必须保留 `OsString` 原样传参;不能让工具要求 CLI 添加 `Command::View` 等专门枚举项。不要求工具在处理 `--help` 时调用核心。未知命令时报错;即使 PATH 中存在 `marqdo-<first>`,**没有显式注册也不能执行它**。
|
||||
|
||||
可选辅助环境:`MARQDO_BIN`(当前核心 CLI 的绝对路径),`MARQDO_TOOL_PROTOCOL=1`;仅当工具声明并协商了对应协议时,额外设置 `MARQDO_PROTOCOL_ANALYSIS=2` 与/或 `MARQDO_PROTOCOL_TRACE=2`。工具通过此路径运行 `marqdo check ... --emit ...` 和 `marqdo run ... --trace-file ...`,不拥有额外宿主内部 API。不得自动将密钥、项目能力授予记录、ABI 插件加载句柄或用户外联会话传给工具。
|
||||
可选辅助环境:`MARQDO_BIN`(当前核心 CLI 的绝对路径),`MARQDO_TOOL_PROTOCOL=1`;仅当工具声明并协商了对应协议时,额外设置 `MARQDO_PROTOCOL_ANALYSIS` 与/或 `MARQDO_PROTOCOL_TRACE`,值是双方支持的最高版本。
|
||||
Analysis 写入器按项目内容选择版本。工具应先检查输出的 `schema_version`,支持两版的工具声明 `analysis: [2, 3]`。工具通过此路径运行 `marqdo check ... --emit ...` 和 `marqdo run ... --trace-file ...`,不拥有额外宿主内部 API。不得自动将密钥、项目能力授予记录、ABI 插件加载句柄或用户外联会话传给工具。
|
||||
|
||||
## 5. 三个独立安全域
|
||||
|
||||
@@ -57,7 +58,7 @@
|
||||
|
||||
## 6. 向后兼容
|
||||
|
||||
`schema_version` 不支持、`marqdo` 范围不匹配、工具版本不是合法 SemVer,或声明的 Analysis/Trace 列表与核心支持集(当前 `analysis: [2]`、`trace: [2]`)无交集时,安装与分发都必须以稳定错误拒绝;错误信息包含 `tool.protocol_incompatible`。可忽略的未知扩展字段允许透传,但不能被视为隐含授权。没有声明数据协议的工具不受该检查约束,也不会收到协议环境变量。
|
||||
`schema_version` 不支持、`marqdo` 范围不匹配、工具版本不是合法 SemVer,或声明的 Analysis/Trace 列表与核心支持集(当前 `analysis: [2, 3]`、`trace: [2]`)无交集时,安装与分发都必须以稳定错误拒绝;错误信息包含 `tool.protocol_incompatible`。可忽略的未知扩展字段允许透传,但不能被视为隐含授权。没有声明数据协议的工具不受该检查约束,也不会收到协议环境变量。
|
||||
|
||||
原生命令集合是保留命名空间;未来新增与社区工具冲突的新核心顶层命令属于破坏性变化,必须经过 ADR、迁移期诊断和工具冲突统计,不能静默覆盖已有已注册工具。
|
||||
|
||||
|
||||
+10
-3
@@ -8,7 +8,7 @@ Supersedes Trace v1; v1 was never released and is kept as history.
|
||||
* Tracing is observation, not execution. Only `run`/`call` produce a trace;
|
||||
`check`, `inspect` and `tool list` never execute a document.
|
||||
* Events come from the interpreter (`call.*`, `branch.eval`,
|
||||
`loop.iteration`, `return`) and the host (`effect`). Both share one sequence.
|
||||
`loop.iteration`, `control.break`, `control.continue`, `return`) and the host (`effect`). Both share one sequence.
|
||||
* The writer is atomic; an error run still records its terminal status.
|
||||
* No argument values, secrets, handles or file contents are recorded.
|
||||
* Trace capacity is a bounded observation budget. Reaching it truncates the
|
||||
@@ -41,10 +41,11 @@ code. Every span-bearing event has a `module_id`; the span is a UTF-8 byte
|
||||
offset range in that module. `source` only carries project identity and the
|
||||
Analysis digest; it does not identify the span owner.
|
||||
|
||||
`source.root_id` is the Analysis v2 `project.root_id`
|
||||
`source.root_id` is the emitted Analysis `project.root_id`
|
||||
(`root:<name>@<version>` or `sha256:<workspace snapshot>`).
|
||||
`source.analysis_digest` is `sha256:` plus the SHA-256 of the exact Analysis
|
||||
v2 bytes produced for the same project with the same projection configuration.
|
||||
bytes produced for the same project with the same projection configuration.
|
||||
The [Analysis writer](analysis-v3.md) selects v2 or v3 from the project.
|
||||
A consumer verifies it by hashing the Analysis file.
|
||||
|
||||
`truncated` is `null` or:
|
||||
@@ -66,9 +67,15 @@ event is `{"kind":"trace.truncated","detail":<reason>,"module_id":null,
|
||||
| `return` | value type name | current function’s module |
|
||||
| `branch.eval` | `true` / `false` | current function’s module |
|
||||
| `loop.iteration` | `continue` / `exit` | current function’s module |
|
||||
| `control.break` | null | current function’s module |
|
||||
| `control.continue` | null | current function’s module |
|
||||
| `effect` | result summary | module from `ExecutionContext` |
|
||||
| `trace.truncated` | `event_budget` / `byte_budget` | null |
|
||||
|
||||
The explicit transfer events carry the keyword carrier span. `control.continue`
|
||||
precedes the next evaluation of the enclosing loop condition. `control.break`
|
||||
leaves that loop without a further condition evaluation.
|
||||
|
||||
`function_id` is always the canonical callee function id. Future kinds are
|
||||
additive; consumers must ignore unknown kinds. `effect.operation` names the
|
||||
`HostOp` (`print`, `fs.read`, ...).
|
||||
|
||||
Reference in new issue
Block a user