Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CLI / React / Windows + macOS Desktop / loopback API
| 模型与上下文 | Mock、Anthropic-compatible、OpenAI-compatible 与 loopback-only Ollama Provider、模型路由、资格校验、能力探测、流式响应、上下文压缩、层级项目指令、显式 user/project 长期记忆与 Session 恢复树 |
| 计划与协作 | Plan/Delivery、Plan item(兼容 identity 为 `WorkItem`/`work_item`)、备注、最多两个核心 child、`batch-delivery.v1` 独立 Worktree/分支/邮箱/交付复核/顺序合并,以及 1/2/4/6 档只读 Fan-out |
| 工具与权限 | Tool Gateway、JSON Schema 校验、Policy、Scope、人工审批、五档 Run 权限上限、受控固定命令、普通模式 Run-owned 命令运行时、逐条审批 PowerShell/Git Bash,以及限时 Debug 终端输入 |
| 代码工作流 | 系统目录选择与 Workspace 导入、工作区浏览、仓库状态、提交历史、Diff 审阅、文件编辑提案、只读 `code-intel-lsp.v1` 语义工具、事务化 Workspace Checkpoint、Run-owned Drydock、稳定 hunk、stash/rebase/cherry-pick/bisect、受管 worktree、GitHub App PR/CI 证据与审批回写、Undo/Redo/Rewind、独立 Fork、验证计划、Code Journey 与 Handoff |
| 代码工作流 | 系统目录选择与 Workspace 导入、工作区浏览、仓库状态、提交历史、Diff 审阅、文件编辑提案、只读 `code-intel-lsp.v1` 语义工具、事务化 Workspace Checkpoint、Run-owned Drydock、稳定 hunk、stash/rebase/cherry-pick/bisect、受管 worktree、GitHub App PR/CI 证据与审批回写、Undo/Redo/Rewind、独立 Fork、验证计划、`standard_code_delivery.v1` 交付真实性、Code Journey 与 Handoff |
| 可观测性 | 追加式 Run 事件、Live Activity、公开模型进度、Harness 事实、Artifact、Finding/Evidence/Report、SARIF、持久化有界计划任务与脱敏结构化诊断包 |
| 扩展 | 模式感知的惰性 Skill 包、生成候选人工审查、两阶段 MCP Client、签名 `plugin.v1`、受限生命周期 Hooks、Provider/Tool 接口、Go/Rust JSON 协议、内嵌 WASI Analyzer、Sandbox 合同与默认关闭的 network-none Docker 产品执行 |
| 客户端 | `cyberagent` CLI、Bubble Tea TUI、认证 HTTP/OpenAPI、React/Vite、Windows/macOS Desktop 便携预览 |
Expand Down Expand Up @@ -96,6 +96,8 @@ Schema v135 与 #137 在同一 `RunSupervisor` 内加入 `standard_code_supervis

Schema v136 与 #138 为 `workspace_access` Standard Code 增加 `risk_escalation.v1`。网络、凭据种类、宿主路径、Policy 拒绝、非白名单工具或其他高风险需求只能形成绑定精确命令、Run/Supervisor call、权限快照、Workspace root 与资源上限的持久提案;模型不能批准或选择授权范围。操作者可拒绝、批准一次,或向当前 Run 授予最多 15 分钟、8 次的精确 scope;每次使用均有不可变消费记录。Supervisor 在等待时释放 lease,重启后恢复同一未执行 call;write-ahead intent 后结果不确定时绝不自动重试,任何权限、Profile、Workspace、root 或 capability 漂移都会失效。详见[高风险升级协议](docs/risk-escalation.md)与 [ADR 0140](docs/adr/0140-durable-risk-escalation.md)。

Schema v137 与 #139 新增 `standard_code_delivery.v1` 交付真实性门。最终 Checkpoint、base/head、真实 committed/index/worktree/untracked/conflict Diff、Command Runtime 终态/exit/tree-reaped、输出摘要与 Artifact、重试、permission/backend generation 和未覆盖项进入同一不可变 receipt;只有当前 Workspace revision 的完整终态成功可为 `passed/verified`。修改、权限或后端漂移会在读取时把旧 receipt 投影为 `stale`,而不改写历史;失败、截断、取消、超时、审批拒绝与无测试均有明确状态。Desktop、CLI/HTTP、Code Handoff、GitHub Review 与最终回复消费同一投影,并链接文件、测试输出及 Checkpoint/Undo/Rewind/Fork。记录不会自动 commit、push、merge、覆盖来源或删除无法证明归属的文件。详见[交付真实性门](docs/standard-code-delivery.md)与 [ADR 0142](docs/adr/0142-standard-code-delivery-truth-gate.md)。

### 模型与工具的 item 级流式事件

Schema v130 与 `llm.item_stream.v1` 将 OpenAI 的交错 tool-call delta、Anthropic content block、Ollama/Mock 的完整 item,以及旧 `ChatChunk` 统一为有序的 response/item/call 生命周期。参数增量只在有界内存中拼接;Provider 只能声明调用已准备,不能签发 authority 或执行工具。Go 在完整 JSON 通过大小、敏感数据、Policy、预算与幂等检查后才记录执行开始/完成,并以稳定 response/item/call ID 对齐临时 UI 卡片与持久工具账本。
Expand Down Expand Up @@ -575,6 +577,7 @@ Get-AuthenticodeSignature .\PrayuDesktop.msix | Format-List Status, StatusMessag
| v134 | 增加 Run 级 Web Search/Fetch/Citation 来源、不可变快照与幂等操作账本 | add Run-scoped Web Search/Fetch/Citation sources, immutable snapshots, and idempotent operation ledger |
| v135 | 持久化 Standard Code root Supervisor 的有界 Inspect→Edit→Execute→Verify 状态、预算、拒绝和结构化证据,并补全 Code Intel 调用账本约束 | persist bounded Inspect→Edit→Execute→Verify state, budgets, denials, and structural evidence for the Standard Code root Supervisor and complete the Code Intel call-ledger constraints |
| v136 | 增加精确高风险提案、有界 Run grant 消费、持久等待/恢复、write-ahead 不确定性与漂移失效账本 | add exact risk proposals, bounded Run-grant consumption, durable wait/resume, write-ahead uncertainty, and drift invalidation ledgers |
| v137 | 增加 Standard Code 最终 Checkpoint、Diff/Command Artifact 对齐、不可变完成收据与动态 stale 投影 | add the Standard Code final Checkpoint, aligned Diff/Command Artifacts, immutable completion receipts, and dynamic stale projection |

</details>

Expand Down
14 changes: 14 additions & 0 deletions docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ Last updated: 2026-08-26

## Resume Context

当前检查点是 issue #139 / SQLite schema v137。`standard_code_delivery.v1` 将最终
Checkpoint、base/head、真实 committed/index/worktree/untracked/conflict Diff、Command Runtime
终态/exit/tree-reaped、输出摘要与 Artifact、重试次数、permission/backend generation 及未覆盖项
收敛为同一不可变 receipt。只有全部验证对应当前 Drydock Workspace revision 且证据完整时才为
`passed/verified`;失败、截断、取消、超时、审批拒绝、无测试和用户跳过分别投影为封闭状态。

读取时重新核对 Workspace、Drydock generation、权限/能力/后端绑定和 Supervisor mutation epoch;
漂移把旧 receipt 动态显示为 `stale`,不改写历史。Standard Code finish 和 Run complete 都要求当前
passed receipt。Desktop Delivery、CLI/HTTP、Code Handoff/export、GitHub Review 与最终回复复用同一
Go 投影,并可进入相对文件、Artifact 与 Checkpoint/Undo/Rewind/Fork。公共内容不含控制字符、
secret-like 值、绝对宿主路径、raw environment/output 或 private reasoning。记录不自动 commit、
push、merge、覆盖来源或删除无法证明归属的文件;Checkpoint 不承诺回滚 Workspace 外副作用。
操作与边界见 `docs/standard-code-delivery.md` 与 ADR 0142。

当前检查点是 issue #138 / SQLite schema v136。`risk_escalation.v1` 把
`workspace_access` Standard Code 的网络目标/用途、凭据种类、宿主路径、Policy 拒绝、
非白名单工具和其他高风险需求收敛为精确、不可变的宿主命令提案。提案绑定完整
Expand Down
67 changes: 67 additions & 0 deletions docs/adr/0142-standard-code-delivery-truth-gate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ADR 0142: Standard Code delivery truth gate

- Status: Accepted
- Date: 2026-08-26

## Context

Standard Code already had Diff, Command Runtime, Artifact, Workspace
Checkpoint, Code Handoff, GitHub Review, and operation receipts. Those facts
were projected independently, so an Agent could present a successful narrative
without one machine contract proving that the commands were terminal, the
output was complete, and the tested revision was still current.

Completion also needs explicit negative outcomes. No applicable tests, user
skip, budget exhaustion, truncation, missing dependency, approval denial,
cancel, timeout, and post-test mutation must not collapse into a generic
success or failure label.

## Decision

Introduce the externally durable `standard_code_delivery.v1` family and schema
v137 immutable ledger.

The Application captures a final Checkpoint, a combined base-to-live Git Diff,
and a second Workspace observation in a bounded retry loop. It records only
when HEAD, branch, index and Checkpoint revision align. Verification facts come
from selected durable Command Runtime Jobs and their after-Checkpoints and
Artifacts. A passed verification requires terminal `completed`, exit code zero,
a reaped process tree, complete bounded output evidence, the current final
revision, and unchanged permission/backend binding.

The status set is closed to `passed`, `failed`, `partial`, `not_run`, `blocked`,
and `stale`; only `passed` is verified. Explicit declarations represent no
tests, user skip, budget, dependency, or approval outcomes. Agent text and CI
status names are never evidence inputs.

The stored receipt is immutable. Freshness is a read-time observation excluded
from its digest. Workspace, Drydock, permission, backend, capability or
Supervisor mutation drift projects the old receipt as stale without rewriting
history.

Desktop, CLI, HTTP, Code Handoff/export, GitHub Review and the final Standard
Code reply consume the same Go `Report`. Standard Code finish and lifecycle
completion require its current passed projection. The report provides
navigable relative files, Artifact references, the exact final Checkpoint and
Undo/Rewind/Fork entry points.

Public validation rejects control text, secret-like material, absolute host
paths, raw environment/output, private reasoning and mutation-grant flags.
Unsafe relative paths are omitted while hashes retain provenance.

## Consequences

- Schema v137 adds an append-only receipt table bound by foreign keys and
insertion/immutability triggers.
- Mutating after verification requires re-running verification and recording a
new receipt; reverting bytes does not revive a receipt after the Supervisor
mutation epoch changed.
- Output truncation or missing Artifacts cannot be displayed as verified.
- Repositories choose their own verification commands; the protocol records
exact Jobs rather than prescribing a universal test command.
- Recording creates a final Workspace Checkpoint but does not commit, push,
merge, overwrite the source Workspace, or delete unattributed files.
- Checkpoint recovery is limited to captured Workspace and index content; it
does not claim to undo external side effects.
- A Run-owned Drydock/worktree remains an ownership and recovery mechanism,
not a process-isolation claim.
36 changes: 34 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ approval.requested / approval.decided
approval.grant_created / approval.grant_revoked
finding.changed
artifact.created
standard_code.delivery_recorded
policy.decided
budget.changed
supervisor.action_committed
Expand All @@ -785,8 +786,39 @@ The same Go adapter owns read projections for the bounded Agent graph, operator-
SQLite remains the local source of truth. Schema migration `v1` records the legacy baseline, `v2`-`v18` establish the Run/Supervisor/memory/tool/Artifact/lease control plane, `v19`-`v38` add bounded Agent coordination, reviewed delegation, read-only Fan-out, Findings, and operator scheduling, and `v39`-`v47` add immutable Skill selection/context, Run modes, Plan/Delivery, provenance, checkpoints, steering, and Specialist minimization. Schemas `v48`-`v63` build the still-disabled Sandbox evidence and recovery chain; `v64`-`v68` add non-authorizing execution-profile and Docker production-evidence decisions; `v69`-`v71` add the inert user Skill Registry, exact Run selection/context, and read-only provenance; `v72`-`v113` continue the audited Run, Desktop, Provider, browser, Analyzer, Docker, dependency, MCP, project-config, Git, external-Skill, and Debug-terminal control planes; `v114` adds explicit long-term memory plus immutable instruction/continuity ledgers without authority restoration; `v115` adds model-callable workspace tools and hash-guarded file mutations; `v116` adds the Run-owned ordinary command runtime and its Supervisor call ledger; `v117` adds content-addressed transactional Workspace Checkpoints; `v118` adds isolated batch delivery; `v119` adds source-bound real-browser UI-evidence attempts, steps, and artifacts; `v120` adds the reviewed MCP Client ledger; `v121` adds inert Plugin installation, publisher trust, rollback, and restricted-Hook audits; `v122` adds durable bounded scheduled monitoring and structured-diagnostics records; `v123` adds immutable advanced-Git operations/sequences plus the managed-worktree registry; `v124` adds generation-CAS GitHub connections, immutable PR/CI snapshots and local evidence graphs, plus Approval-bound remote-write recovery receipts; `v125` repairs one pinned preview migration history; `v126` adds Workspace Access; `v127` adds Run-owned Drydocks; `v128` admits fixed Docker Standard Code under Workspace Access; `v129` adds stable Thread identity and Run succession; `v130` adds item-level streamed tool reconciliation identities; `v131` binds Command Runtime jobs and advertisements to exact sandboxed/host adapter identities while projecting legacy rows as non-executable evidence; `v132` fences process-local Docker stdin attachment; and `v133` adds atomic Standard Code preset and pause-intent receipts. Non-schema D1-B1 exposes the existing v69 Registry through inert HTTP/Desktop confirmation and adds no migration. Migrations are ordered, checksummed, transactional, and safe to apply repeatedly; legacy databases are upgraded without deleting their data or fabricating new operator decisions.

Schema `v134` adds Run-scoped Web search, fetched snapshots, and citations.
Schema `v135` adds the bounded Standard Code root completion ledger;
it preserves every earlier migration and does not fabricate completion history.
Schema `v135` adds the bounded Standard Code root completion ledger; `v136` adds
durable risk escalation, grants, consumption and uncertain-execution recovery;
and `v137` adds immutable Standard Code delivery truth receipts. Every migration
preserves earlier history and fabricates no completion, approval, or verification fact.

## Standard Code delivery truth gate

`standard_code_delivery.v1` is the sole Standard Code completion projection.
The Application captures a final Run-owned Drydock Checkpoint, renders one
combined committed/index/worktree/untracked/conflict Diff from the exact base,
and re-observes the Workspace before sealing. Each verification binds a durable
Command Runtime Job, terminal state and exit, tree-reaped fact, executable and
environment digests, permission and backend generation, post-command
Checkpoint revision, bounded output digests and Artifact references. Store
foreign keys and triggers align the Run/Mission/Session/Workspace/Drydock,
event sequence, final Checkpoint, Diff and receipt hashes and make the row
immutable.

The closed public states are `passed|failed|partial|not_run|blocked|stale`.
Only complete terminal success for the current revision is verified. Freshness
is re-evaluated on every read against Workspace content, Drydock generation,
permission/capability/backend bindings and Supervisor mutation epoch; a mismatch
adds a stale observation without rewriting the historical receipt. Agent prose
and CI check names do not participate in evaluation.

Desktop Delivery, CLI/HTTP, Code Handoff/export, GitHub Review and the final
Standard Code response all consume the same Go model. Relative changed files,
Artifact output and Checkpoint/Undo/Rewind/Fork are navigable. Public projection
validation excludes control characters, secrets, absolute host paths, raw
environment/output and private reasoning. Recording does not commit, push,
merge, overwrite source files, or claim that Checkpoint can reverse effects
outside the Workspace. See [Standard Code Delivery Truth Gate](standard-code-delivery.md)
and [ADR 0142](adr/0142-standard-code-delivery-truth-gate.md).

## Go-Owned GitHub Review Provider

Expand Down
29 changes: 29 additions & 0 deletions docs/convergence/protocol-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This document is generated from [`protocols/registry.json`](../../protocols/regi
| [release-and-packaging-contracts](#release-and-packaging-contracts) | `external-durable` | Desktop release and packaging maintainers | 3 | true |
| [report-summary-projections](#report-summary-projections) | `projection` | Finding, repository, and summary maintainers | 5 | true |
| [sandbox-docker-lifecycle](#sandbox-docker-lifecycle) | `internal-durable` | Sandbox and Docker lifecycle maintainers | 196 | true |
| [standard-code-delivery-ledger](#standard-code-delivery-ledger) | `external-durable` | Standard Code delivery and public projection maintainers | 8 | true |
| [thread-run-session-ledgers](#thread-run-session-ledgers) | `internal-durable` | Thread, Run, Session, context, and message maintainers | 25 | true |
| [thread-transcript-projection](#thread-transcript-projection) | `projection` | Thread transcript maintainers | 1 | true |
| [tool-mutation-ledgers](#tool-mutation-ledgers) | `internal-durable` | Tool gateway, file edit, Git, and mutation maintainers | 31 | true |
Expand Down Expand Up @@ -1252,6 +1253,34 @@ This document is generated from [`protocols/registry.json`](../../protocols/regi

</details>

### standard-code-delivery-ledger

- Class: `external-durable`
- Owner: Standard Code delivery and public projection maintainers
- Source of truth: `internal/application`, `internal/standardcodedelivery`, `internal/store`
- Persistence/export boundary: SQLite retains immutable metadata-only receipts; HTTP, CLI, Desktop, Code Handoff, GitHub Review, and final completion export the same freshness-aware projection.
- Compatibility rule: Retain old readers and exact receipt, revision, Diff, Checkpoint, Artifact, binding, redaction, and stale semantics until every stored receipt is migrated or indefinitely supported.
- Retirement gate (`migration-or-retention`): ADR-backed retirement decision and rollback path; Old-version fixtures remain until every stored receipt and exported consumer is migrated or retained; Receipt hashes and historical conclusions remain independently verifiable
- Writers:
- `standard-code-delivery-ledger-writer` (`v1`, write-current) at `internal/store`
- Readers:
- `standard-code-delivery-go-reader` (`v1`, active) at `internal/standardcodedelivery`
- `standard-code-delivery-http-reader` (`v1`, active) at `internal/httpapi`
- `standard-code-delivery-web-reader` (`v1`, active) at `web/src`

<details><summary>8 active identifiers</summary>

- `command-runtime-backend-generation.v1`
- `standard-code-backend.v1`
- `standard-code-delivery-reason.v1`
- `standard-code-workspace-revision.v1`
- `standard_code_delivery.v1`
- `standard_code_delivery_record.v1`
- `standard_code_delivery_request.v1`
- `standard_code_supervisor_finish.v1`

</details>

### thread-run-session-ledgers

- Class: `internal-durable`
Expand Down
Loading