@sema-ai/core 1.277.0 → 1.278.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +97 -21
- package/NOTICE.md +1 -1
- package/README.md +2 -5
- package/README.new.md +150 -0
- package/README.zh-CN.new.md +145 -0
- package/dist/bench/metrics.js +1 -1
- package/dist/bench/metrics.js.map +1 -1
- package/dist/core/cache-break-detector.js +0 -0
- package/dist/core/cache-break-detector.js.map +1 -1
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/core/tools.js +3 -1
- package/dist/core/tools.js.map +1 -1
- package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -1
- package/dist/engine/execution-env/node-execution-env.js +8 -0
- package/dist/engine/execution-env/node-execution-env.js.map +1 -1
- package/dist/engine/harness/types.d.ts +9 -1
- package/dist/engine/harness/types.d.ts.map +1 -1
- package/dist/engine/harness/types.js.map +1 -1
- package/dist/tools/fs/index.d.ts.map +1 -1
- package/dist/tools/fs/index.js +94 -3
- package/dist/tools/fs/index.js.map +1 -1
- package/dist/tools/gitea-issue.d.ts +1 -1
- package/dist/tools/gitea-issue.d.ts.map +1 -1
- package/package.json +2 -7
- package/CHANGELOG.md +0 -5455
- package/docs/A1-ATTRIBUTION-ROUND1-2026-07-09.md +0 -181
- package/docs/AB-ORACLE-GATE-VERDICT-2026-07-10.md +0 -100
- package/docs/ANCHOR-GAP-INVENTORY-2026-07-09.md +0 -143
- package/docs/ARCHITECTURE.md +0 -125
- package/docs/BUGHUNT-2026-07-05-NIGHT.md +0 -98
- package/docs/BUILD.md +0 -63
- package/docs/CANCEL-ASYNC-ATTRIBUTION-2026-07-09.md +0 -98
- package/docs/CC-198-VS-201-DRIFT-2026-07-09.md +0 -70
- package/docs/CC-BASELINE-FAKE-ZERO-AUDIT-2026-07-09.md +0 -51
- package/docs/CC-DRIFT-198-206-AGENT-TYPES-2026-07-10.md +0 -82
- package/docs/CC-DRIFT-198-206-CHANGELOG-2026-07-10.md +0 -82
- package/docs/CC-DRIFT-198-206-REMINDERS-2026-07-10.md +0 -96
- package/docs/CC-DRIFT-198-206-ROADMAP-2026-07-10.md +0 -110
- package/docs/CC-DRIFT-198-206-TOOL-INVENTORY-2026-07-10.md +0 -53
- package/docs/CC-DRIFT-198-206-USAGE-CONSTANTS-2026-07-10.md +0 -64
- package/docs/CC-DRIFT-198-206-WORKFLOW-2026-07-10.md +0 -83
- package/docs/CC-PARITY-CHECKLIST.md +0 -220
- package/docs/CC-PARITY-DEEP-SWEEP-2026-07-07.md +0 -149
- package/docs/CC-SUBAGENT-PROMPT-STUDY-2026-07-09.md +0 -219
- package/docs/CC-TASK-REMINDER-CADENCE-STUDY-2026-07-09.md +0 -396
- package/docs/CC-TOOL-PARITY-SWEEP-2026-07.md +0 -56
- package/docs/CC-TOOL-PROMPT-DEEP-DIFF-2026-07-08.md +0 -274
- package/docs/CC-TOOLSURFACE-DEEP-DIVE-2026-07-07.md +0 -197
- package/docs/CC206-OBSERVER-ANCHORS-2026-07-11.md +0 -463
- package/docs/CC207-CORE-SWEEP-BACKLOG-2026-07-12.md +0 -155
- package/docs/CENTER-CONTROL-PLANE-SEAM.md +0 -86
- package/docs/CLEANUP-CONTRACT-ANCHOR-2026-07-09.md +0 -83
- package/docs/COLD-START-RSI-2026-07-09.md +0 -72
- package/docs/COMPACTION-LIVE-AUDIT-2026-07-09.md +0 -114
- package/docs/CONTEXT-lifecycle-extension-points-and-stop-attribution.md +0 -71
- package/docs/COREWARS-POLYGLOT-TRIAGE-2026-07-09.md +0 -85
- package/docs/DEADTARGET-OVERFULL-HBOX-2026-07-10.md +0 -92
- package/docs/DEADTARGET-PATH-TRACING-REVERSE-2026-07-10.md +0 -87
- package/docs/DEADTARGET-WINNING-AVG-COREWARS-2026-07-10.md +0 -96
- package/docs/DEEPSEEK-API-LIMITS-PROBE-2026-07-09.md +0 -118
- package/docs/DESIGN-140-MOCK-VERIFY-2026-07-11.md +0 -79
- package/docs/DESIGN-140-VERIFICATION-2026-07-11.md +0 -43
- package/docs/DESIGN-DRAFT-workflow-collab-2026-07-11.md +0 -56
- package/docs/DESIGN-ORACLE-GROUNDING-GATE-2026-07-10.md +0 -167
- package/docs/DESIGN-TFRAG-RECONCILE-SCAFFOLD-2026-07-09.md +0 -102
- package/docs/EXP-PA2-PE-DESIGN-2026-07-11.md +0 -220
- package/docs/EXT-DOGFOOD-2026-07-12.md +0 -50
- package/docs/FINAL-VERIFY-SURFACE-AUDIT-2026-07-09.md +0 -44
- package/docs/FRAG-RECON-INVESTIGATION-2026-07-09.md +0 -183
- package/docs/HANDOFF.md +0 -121
- package/docs/KNOWN-ISSUES.md +0 -96
- package/docs/LEGW-WINDOW-TAX-2026-07-10.md +0 -82
- package/docs/LIVE-PROBE-BATCH-2026-07-11.md +0 -207
- package/docs/M2-CERT-ATTRIBUTION-2026-07-10.md +0 -61
- package/docs/M25-LEG-VARIANCE-ATTRIBUTION-2026-07-10.md +0 -81
- package/docs/MAILMAN-TIMEOUT-ATTRIBUTION-2026-07-10.md +0 -88
- package/docs/MEMORY-BACKEND-DIALECT-NOTES.md +0 -69
- package/docs/MTEB-ESCAPE-HATCH-ATTRIBUTION-2026-07-09.md +0 -57
- package/docs/MTEB-LEADERBOARD-ATTRIBUTION-2026-07-10.md +0 -134
- package/docs/ORACLE-GATE-NEGATIVE-SAMPLE-2026-07-11.md +0 -28
- package/docs/PARITY-CONTEXT-TRANSACTIONS-2026-07-10.md +0 -67
- package/docs/PARITY-PROGRESS-MATRIX-2026-07-10.md +0 -37
- package/docs/PARITY-SPOT-AGENT-TYPES-2026-07-10.md +0 -70
- package/docs/PARITY-SPOT-REMINDERS-2026-07-10.md +0 -144
- package/docs/PARITY-SPOT-TOOL-INVENTORY-2026-07-10.md +0 -61
- package/docs/PARITY-SPOT-USAGE-CONSTANTS-2026-07-10.md +0 -95
- package/docs/PARITY-SPOT-WORKFLOW-2026-07-10.md +0 -93
- package/docs/PASSWORD-RECOVERY-PANEL-VERDICT-2026-07-10.md +0 -62
- package/docs/R8-R9-FINALIZE-COORDINATION-2026-07-09.md +0 -124
- package/docs/REPL-CODE-MODE-EVALUATION-2026-07-10.md +0 -187
- package/docs/REPORT-1249-TARGETED.md +0 -48
- package/docs/RESEARCH-3P-MEMORY-SWAP-2026-07-12.md +0 -273
- package/docs/ROADMAP.md +0 -111
- package/docs/RSI-CLOUD-DEPLOY-2026-07-06.md +0 -289
- package/docs/RSI-PROCESS-AI-COLDSTART-2026-07-11.md +0 -68
- package/docs/S18-THOROUGHNESS-AUDIT-2026-07-09.md +0 -113
- package/docs/SERVICE-INTEGRATION-GUIDE.md +0 -298
- package/docs/SUBAGENT-STREAM-RESILIENCE-PARITY-2026-07-10.md +0 -118
- package/docs/SWEBENCH-PRO-RECON-2026-07-11.md +0 -31
- package/docs/TB-EFFICIENCY-TELEMETRY-2026-07-08.md +0 -114
- package/docs/TB-FAILURE-AUTOPSY-2026-07-05-RERUN.md +0 -67
- package/docs/TB-FAIRNESS-AUDIT-2026-07-08.md +0 -141
- package/docs/TB-FULL-1257-2026-07-08.md +0 -77
- package/docs/TB-LEG-GAP-ATTRIBUTION-1261-1263-2026-07-11.md +0 -154
- package/docs/TB-REGRESSION-DAEMON-KILL-2026-07-08.md +0 -58
- package/docs/TB-RSI-CROSSCHECK-2026-07-06.md +0 -68
- package/docs/TB-RSI-LEDGER.md +0 -30
- package/docs/TB-STABLE-SET-2026-07-08.md +0 -127
- package/docs/TB21-RECON-2026-07-11.md +0 -28
- package/docs/TEST-DESIGN-BATCH-1-2-3.md +0 -97
- package/docs/THIRD-PARTY-INTEGRATION.md +0 -45
- package/docs/TOKEN-ESTIMATE-CALIBRATION-LIVE-2026-07-09.md +0 -102
- package/docs/audit-2026-06-10-/347/254/254/344/272/214/350/275/256-/347/251/272/347/231/275/345/214/272/344/270/216/345/277/230/346/216/245/347/272/277.md +0 -147
- package/docs/audit-2026-06-10-/350/256/241/347/256/227bug/346/211/253/346/217/217.md +0 -163
- package/docs/audit-2026-06-11-/344/277/256/345/244/215/345/244/215/345/256/241/344/270/216/345/233/236/345/275/222/344/270/223/346/211/253.md +0 -95
- package/docs/audit-2026-06-12-design71-P1/346/275/234/344/274/217/351/235/242/350/243/201/345/206/263/344/270/216/345/220/236/351/224/231/345/256/241/350/256/241.md +0 -45
- package/docs/audit-2026-06-12-/345/205/254/345/274/200/346/227/213/351/222/256/346/264/273/346/200/247/344/270/216vendored/346/255/273/350/267/257.md +0 -63
- package/docs/audit-2026-06-15/ADDENDUM-second-pass.md +0 -88
- package/docs/audit-2026-06-15/ARCHITECTURE-AND-ROADMAP.md +0 -187
- package/docs/audit-2026-06-15/DOC-CORRECTIONS.md +0 -105
- package/docs/audit-2026-06-15/INDEX.md +0 -49
- package/docs/audit-2026-06-15/ORCHESTRATION-STATUS.md +0 -98
- package/docs/audit-2026-06-15/PRODUCTION-ISSUES.md +0 -189
- package/docs/audit-2026-06-15/REFERENCES-literature.md +0 -139
- package/docs/audit-2026-06-15/VENDOR-REFACTOR-PLAN.md +0 -96
- package/docs/cc-probe-198/README.md +0 -72
- package/docs/cc-probe-198/STABILITY-AUDIT.md +0 -118
- package/docs/cc-probe-198/live-schema-monitor-worktree-2026-07-09.json +0 -56
- package/docs/cc-probe-198/mount-variants.json +0 -536
- package/docs/cc-probe-198/plan-mode-run.json +0 -1
- package/docs/cc-probe-198/probe-bash-bg.json +0 -224
- package/docs/cc-probe-198/probe-edit-mismatch.json +0 -120
- package/docs/cc-probe-198/probe-read-missing.json +0 -62
- package/docs/cc-probe-198/probe-search-empty.json +0 -127
- package/docs/cc-probe-198/probe-task-family.json +0 -227
- package/docs/cc-probe-198/probes.status +0 -6
- package/docs/cc-probe-198/raw-capture-interactive.json +0 -948
- package/docs/cc-probe-198/raw-capture-print.json +0 -787
- package/docs/cc-probe-198/raw-capture2-interactive.json +0 -948
- package/docs/cc-probe-198/raw-capture2-print.json +0 -787
- package/docs/cc-probe-198/system-prompt.txt +0 -135
- package/docs/cc-probe-198/tools-array.json +0 -962
- package/docs/durability-boundary.md +0 -63
- package/docs/fix-2026-06-10-/350/256/241/347/256/227bug/344/277/256/345/244/215-search/346/211/271.md +0 -75
- package/docs/fix-2026-06-11-/347/254/254/344/272/214/350/275/256-/344/277/256/345/244/215-search/346/211/271.md +0 -62
- package/docs/parity-sweep/REPORT-DYNAMIC.md +0 -97
- package/docs/parity-sweep/REPORT-STATIC-GGB.md +0 -127
- package/docs/parity-sweep/REPORT-STATIC-RWE.md +0 -133
- package/docs/vendor-history.md +0 -385
- package/docs/vendored-upstream-diff-2026-07.md +0 -83
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# S18 ORCHESTRATION_AWARENESS 审计(2026-07-09)
|
|
2
|
-
|
|
3
|
-
> 派单:审计 S18 `ORCHESTRATION_AWARENESS`(`src/prompts/supervisor.ts:158`,高推理档注入的 thoroughness/self-verify nudge,手写无 CC 逐字锚)。
|
|
4
|
-
> 背景:`docs/ANCHOR-GAP-INVENTORY-2026-07-09.md` A 部分 top3 第 3 项 + `docs/FINAL-VERIFY-SURFACE-AUDIT-2026-07-09.md`(9 题失败形态=情形③「注入了+真验了+验错面」=自一致陷阱)。
|
|
5
|
-
> 疑点:S18 措辞若「鼓励更多自证」而不带「验证面选择」约束,在高推理档上会放大自一致陷阱。
|
|
6
|
-
>
|
|
7
|
-
> **坐标订正**:派单写 `supervisor.ts:158` / `runtask.ts:1980`;实际 S18 = `src/prompts/supervisor.ts:158`,R9 = `src/core/runner/runtask.ts:1979-2011`,S18 挂载判据 = `src/core/runner/prepare-task.ts:2056-2061`(`awarenessEnabled`)。
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 定谳:S18 **无罪(TB 未暴露)**;记档即可,不需修文案,与 R9 无冲突
|
|
12
|
-
|
|
13
|
-
三条独立证据链,任一即足以脱责:
|
|
14
|
-
|
|
15
|
-
1. **CC 对照**:CC 无「按推理档注入 prose thoroughness 段」的对等面——S18 确认 SEMA-only,但这不是缺陷(是诚实的能力补全,非 teaching-to-the-test)。
|
|
16
|
-
2. **语义叠加**:S18 与 R9 内容**正交**——S18=「推理认真度 + 自设 refute」(纯推理姿态,不触验证面),R9=「验证面选择 + 持久态 + 硬约束对账」(验收面纪律)。S18 无「鼓励自证但不约束验证面」的句子,不是自一致陷阱放大器。
|
|
17
|
-
3. **TB 暴露(决定性)**:full-89 @1.258.5 的 9 题早死现场,S18 **根本没挂载**——TB 跑 DeepSeek-v4-pro 不在 ultra 档(xhigh/max),`awarenessEnabled=false`,S18 从未进 prompt。9 题失败与 S18 无因果。**嫌疑解除。**
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Q1 — CC 对照:CC 按推理档注入的是什么?
|
|
22
|
-
|
|
23
|
-
**结论:CC 无「prose thoroughness 段」对等面。S18 确认 SEMA-only。**(cc-88 源 + cc-probe-198 双语料穷举确认)
|
|
24
|
-
|
|
25
|
-
CC 的 ultrathink/effort 机制(逐字取证):
|
|
26
|
-
- 触发:`collection-claude-code-source-code/original-source-code/src/utils/attachments.ts:1446-1452` — `getUltrathinkEffortAttachment()`,用户输入含 `ultrathink` 关键字 → `{ type: 'ultrathink_effort', level: 'high' }`。
|
|
27
|
-
- 注入:`.../src/utils/messages.ts:4170-4177` — 包成 `<system-reminder>` meta user message,**逐字**:
|
|
28
|
-
> `The user has requested reasoning effort level: ${attachment.level}. Apply this to the current turn.`
|
|
29
|
-
- 真正的强度控制走 API `effort` 参数(`.../src/utils/effort.ts`;工具 desc 里 `opts.effort: 'low'|'medium'|'high'|'xhigh'|'max'`,cc-probe-198 raw-capture 见 Workflow agent() 选项)。
|
|
30
|
-
|
|
31
|
-
关键区分:CC 那句是**提示性**(告知模型「已选高 effort,本回合应用」)+ API 参数配置,**不是**一段散文式「如何更认真推理/如何自检」的纪律指导。S18 的「break into distinct parts / actively try to REFUTE / check edge cases / prefer evidence over assertion」这类 prose discipline,CC 侧无对等文本。
|
|
32
|
-
|
|
33
|
-
→ 与 ANCHOR-GAP-INVENTORY 的预判一致(「CC 无按推理档注入的 thoroughness 段」)。S18 的自我注释(`supervisor.ts:148-156`)已诚实标注它是「CC ultracode nudge 的诚实类比,但只讲推理认真度不讲工具」——**这个自述准确**:CC 的 ultrathink 确实不给工具(不像 ultracode/Workflow),S18 也确实只讲推理姿态。SEMA-only 成立,但属「诚实的能力补全」非「缺锚风险」——因为它注入的是通用推理姿态(refute/edge-case/evidence),不是伪造某个 CC 行为。
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Q2 — 语义叠加审计:S18 全文 vs R9 逐句对照
|
|
38
|
-
|
|
39
|
-
### S18 全文(`supervisor.ts:158-164`)
|
|
40
|
-
> This is a high-intensity task — invest the extra rigor it warrants. For a substantial problem that decomposes, work through it systematically: break it into its distinct parts, address each carefully, and integrate the results. Be confident, not just fast: for any conclusion that must be right, actively try to REFUTE it before committing — check the edge cases, look for the failure mode you'd be embarrassed to miss, and prefer evidence over assertion. Scale the effort to the task; don't over-elaborate a simple ask. (This is about how thoroughly YOU reason and verify — you are not being given an orchestration tool here.)
|
|
41
|
-
|
|
42
|
-
### R9 全文要点(`runtask.ts:1979-2011`,含 A/B/C/E 四原则)
|
|
43
|
-
- 前置:re-verify FINAL deliverable through its REAL entry point / execute directly / read ACTUAL output+exit code / 不靠 earlier self-tests。
|
|
44
|
-
- 第三方契约:check the usage contract the object declares(docstring/metadata)/ METHOD 匹配需求。
|
|
45
|
-
- **A**(面选择):check against the reference data, oracle, or evaluation tooling the task provides。
|
|
46
|
-
- **B/E**(自一致≠正确 + 独立第二路径):re-running your own implementation and getting the same answer is self-consistency, not correctness / cross-check through an independent second path(checksums, runtime artifacts)。
|
|
47
|
-
- **C**(持久态 + 硬约束对账):Verify the PERSISTED artifact — re-read what is on disk/committed, not in-memory — against every hard constraint(numeric bounds, allowed-value lists, naming semantics, required files)/ whole-set completeness。
|
|
48
|
-
|
|
49
|
-
### ① 重复表述(稀释税)审计 — **无重复**
|
|
50
|
-
两段的动词表面看似都提「verify」,但语义层不重叠:
|
|
51
|
-
|
|
52
|
-
| 维度 | S18 | R9 |
|
|
53
|
-
|---|---|---|
|
|
54
|
-
| 谈的对象 | 模型自身的**推理过程**(结论前自我 refute) | **交付物验收面**(entry point / oracle / 持久态) |
|
|
55
|
-
| refute 的靶子 | 「a conclusion that must be right」— 抽象结论 | 「the FINAL deliverable」— 具体产物 |
|
|
56
|
-
| 验证姿态 | 「check edge cases / failure mode」(内省) | 「fresh entry point / independent second path / persisted state」(外部对齐) |
|
|
57
|
-
| 收尾锚 | 「(不是给你编排工具)」自我澄清 | 「no executable deliverable → 简短确认收工」 |
|
|
58
|
-
|
|
59
|
-
S18 是**推理时**的自省纪律(内省),R9 是**收尾时**的验收纪律(对外)。二者是「怎么想」vs「怎么验收」两个正交阶段,不构成同一指令两处说的稀释税。
|
|
60
|
-
|
|
61
|
-
### ② S18 有没有「鼓励更多自证但不带验证面选择」的句子? — **没有**
|
|
62
|
-
这是审计的核心疑点。逐句核 S18:
|
|
63
|
-
- 「actively try to REFUTE it before committing」— 是**证伪**倾向(找反例),**不是**自证倾向(重跑自己证自己对)。方向与自一致陷阱**相反**。
|
|
64
|
-
- 「prefer evidence over assertion」— 要求外部证据,反自证。
|
|
65
|
-
- 「look for the failure mode you'd be embarrassed to miss」— 找失败,非确认成功。
|
|
66
|
-
- 「Scale the effort... don't over-elaborate」— 反过度。
|
|
67
|
-
|
|
68
|
-
**S18 的措辞全是「证伪/找失败/要证据」,恰是自一致陷阱的解药而非放大器。** 它没有任何一句诱导「多跑自己的实现来自证」。诚实标注:S18 也**没有** R9 那种「面选择」的精确约束(不点名 oracle/白名单/持久态)——但它给的是**证伪方向**(refute/edge-case),在方向上与 R9 一致、不冲突;S18 缺的是 R9 的**精确验收面清单**,而这正是 R9 的职责分工,不是 S18 的缺陷。
|
|
69
|
-
|
|
70
|
-
### ③ S18 与 R9 会不会同 task 同时在场? — **理论上会,但触发条件正交,且实测未同场**
|
|
71
|
-
- **挂载条件不同**:
|
|
72
|
-
- S18(`awarenessEnabled`,`prepare-task.ts:2061`)= `thinking !== undefined && ULTRA_REASONING_TIERS.has(thinking)`,`ULTRA_REASONING_TIERS = {"xhigh","max"}`(`prepare-task.ts:135`)。**静态挂 system prompt**,仅当调用方声明 ultra 推理档。
|
|
73
|
-
- R9(`finalVerificationOn`,`runtask.ts:1957`)= `spec.finalVerification === true`。**运行时注入**,收尾且 `wroteThisRun` 时一次性 latch。
|
|
74
|
-
- **是否必然同场**:**否**。派单假设「S18 静态挂 system,R9 运行时注入→必然同场」不成立——S18 门是 ultra 推理档,R9 门是 finalVerification 开关,两门独立。一个 task 可以 finalVerification=true 但推理档非 ultra(=R9 在场、S18 不在场),这正是 TB full-89 的实况(见 Q3)。反之 ultra 档但 finalVerification=false 则 S18 在场、R9 不在场。**只有「ultra 档 AND finalVerification 开」才同场**。
|
|
75
|
-
- **同场时冲突?** 即便同场,② 已证内容正交、方向一致(都反自证):S18 证伪推理 + R9 验收面选择 = 互补,不稀释。
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Q3 — TB 暴露核实(决定性):9 题早死现场 S18 挂载了吗?
|
|
80
|
-
|
|
81
|
-
**结论:S18 在 3/3 抽样早死题中均**未挂载**;R9 均已注入。S18 不在 9 题失败现场。**
|
|
82
|
-
|
|
83
|
-
海外机 `ubuntu@91.199.82.197`,`~/sema-tb/jobs/full-1258.5-fb/full89/`。抽 3 题(count-dataset-tokens / bn-fit-modify / overfull-hbox,均属 FINAL-VERIFY-SURFACE-AUDIT 9 题早死集)查 `agent/events.jsonl` 的 `prompt.assembled` 事件 block 清单:
|
|
84
|
-
|
|
85
|
-
| 题 | assembled block ids | `mode.awareness`(S18) | `finalVerifyInjected`(R9) |
|
|
86
|
-
|---|---|---|---|
|
|
87
|
-
| count-dataset-tokens | role.base / env.context / harness.context | **无** | **true** |
|
|
88
|
-
| bn-fit-modify | role.base / env.context / harness.context | **无** | **true** |
|
|
89
|
-
| overfull-hbox | role.base / env.context / harness.context | **无** | **true** |
|
|
90
|
-
|
|
91
|
-
根因:full-89 跑 `deepseek/deepseek-v4-pro`(`config.json`:`model_name`),job 配置未声明 ultra 推理档(config.json / summary.json 无 thinking/effort/xhigh 字段)。→ `thinking` 未落到 xhigh/max → `awarenessEnabled=false` → S18 从不进 prompt。而 R9 由 `finalVerification=true` 独立触发,`finalVerifyInjected: true` 落 `done.stats.mechanisms`。
|
|
92
|
-
|
|
93
|
-
**S18 根本不在 9 题现场,不可能是共犯。** FINAL-VERIFY-SURFACE-AUDIT 的情形③(自一致陷阱)完全由 R9 在场时的验证面缺陷解释,与 S18 无关。
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 终判 + 若需修的措辞方向
|
|
98
|
-
|
|
99
|
-
**终判:S18 = 无罪记档。** 三条脱责链:
|
|
100
|
-
1. TB 未暴露(决定性)——9 题现场 S18 未挂载,非共犯。
|
|
101
|
-
2. 语义不重复——与 R9 正交(推理姿态 vs 验收面),无稀释税。
|
|
102
|
-
3. 措辞不放大自证——S18 全文是「证伪/找失败/要证据」,是自一致陷阱的解药方向,非放大器。
|
|
103
|
-
|
|
104
|
-
**不需修文案。不需与 R9 协调。** S18 与 R9 是互补的两阶段纪律,不冲突。
|
|
105
|
-
|
|
106
|
-
**遗留观察(非缺陷,记档待场景)**:
|
|
107
|
-
- S18 SEMA-only(Q1 确认无 CC prose 锚),但属「诚实的通用推理姿态补全」,注入的是 refute/edge-case/evidence 这类不依赖具体行为的普适纪律,非伪造 CC 行为——**不构成 teaching-to-the-test,不需补锚**。其自注释(`supervisor.ts:148-156`)已准确记档 SEMA-only 属性 + 与 S8/S16 ORCHESTRATION_GUIDANCE 的刻意区分。
|
|
108
|
-
- **若未来 TB 增设 ultra 推理档腿**(S18 会真挂载),再评 S18×R9 同场行为——但届时 ② 的正交性分析预测互补,风险低。可作那条腿的定向观察项:同场时是否出现「S18 证伪 + R9 验收面」双纪律叠加的正增益或过度自省副作用。
|
|
109
|
-
- **优先级重排建议(回写盘点档)**:ANCHOR-GAP-INVENTORY top3 把 S18 列「TB 暴露=可能」;本审计实测证「TB 暴露=否(当前跑面)」——S18 应从 top3 降级,让位给 R8/R9 收尾-验证面(那才是唯一碰 9 题失败桶的面)。
|
|
110
|
-
|
|
111
|
-
**若将来必须动 S18(仅当 ultra 档腿暴露问题),通用措辞方向**(非现在动):
|
|
112
|
-
- 保持 S18 纯「推理姿态」定位,不侵入 R9 的验收面清单(避免制造真正的稀释税)。
|
|
113
|
-
- 若要加强,方向是**强化证伪**(如「列出这个结论若错会怎样被 test 抓到」),而非加自证——始终与 R9 的面选择同向。
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# 给 service AI 的对外使用文档 + 重点分析(活文档)
|
|
2
|
-
|
|
3
|
-
> 入口见 [`HANDOFF.md`](HANDOFF.md)。面向 **ai-agent-service 仓**(profile 层:leader 编排 / E2B·Kata 沙箱 / TiDB 后端 / config-center / 多租户 / 部署)。
|
|
4
|
-
> README 是通用消费者文档;**本文是 service-specific**:你要实现哪些 seam、契约边界在哪、会**直接影响 service** 的 gotcha、以及最近建造线 **workflow-parity(design/97,§14)/ sema-shell 主权契约(design/99,§13)/ 2c session-sync(§14)** 与已封顶基座 **CC-parity 编排(design/96/97/98,§12)/ design/80 Supervisor(§11)** 的协调点。
|
|
5
|
-
> 全部基于 `src/index.ts` 实际导出 + 子系统验证。深证据在 `audit-2026-06-15/`。
|
|
6
|
-
>
|
|
7
|
-
> **当前状态(2026-06-27):core 在 `1.150.0`(已发版+打 tag `v1.150.0`),service pin `^1.150.0`。** 最近建造线 = **sema-shell 数据契约**(MF-*,1.146→1.150,引擎↔sema-shell `/workflows` monitor↔service 的可观测数据契约,与 service 协调,见 §15)。**已封顶降为基座**:workflow-parity(design/97,CORE-1~9 × SVC-1~5 全 SHIPPED,见 §14B)/ 2c session-sync(云↔本地,见 §14A)/ sema-shell 主权契约(design/99 E1–E25,见 §13)/ CC-parity 编排 + 推理强度 + goal + S8(design/96/97/98,见 §12)· design/80 Supervisor(价值判决 GOAL 达成,见 §11)。当前焦点(快速移动)= sema-shell 数据契约 loop(MF-*/MF-Fleet)+ P2 design-review,与 service 协调。Beatsep/leader 编码跑是 make-real 测试场,非主线本身。
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 0. 心智模型:core 给原语,service 给 profile
|
|
12
|
-
|
|
13
|
-
| core(本仓,你 `import`) | service(你实现/注入) |
|
|
14
|
-
|---|---|
|
|
15
|
-
| `Runner` / `runTask` / `runTaskStream` / `resume` / `resumeStream` | leader 编排循环(调 runTaskStream fan-out + suspended-cancel) |
|
|
16
|
-
| `Brain` 契约 + OpenAI/Anthropic 适配 + failover/routing/degrade | DeepSeek pro/flash 网关接线 + router 策略(JSON-mode 防跑飞,见 §7) |
|
|
17
|
-
| `ExecutionEnv` / `RemoteExecutionEnv` **接口** | E2B/Kata 沙箱 adapter(实现接口) |
|
|
18
|
-
| `SessionStore`/`SessionRepo` + CAS + PG 参照 | TiDB 会话中心 adapter |
|
|
19
|
-
| `CheckpointStore` + InMemory + **PG 参照** | TiDB checkpoint adapter(⚠️ 见 §5 P-9/C-12) |
|
|
20
|
-
| `MemoryStore` + InMemory + PgMemory(三档召回) | TiDB/pgvector 记忆后端 + per-user scope |
|
|
21
|
-
| `ToolResultStore` + InMemory + PG/TiDb 参照 | durable offload 后端 |
|
|
22
|
-
| `ToolPolicy`(3 态)+ `Hooks` + `createSensitivePathPolicy` | HITL 审批接线 + 部署敏感路径表 |
|
|
23
|
-
| `ToolCallRequest.budget`(只读 durable 预算读上下文,见 §11) | 无状态 policy 据它自限(resume 拿不回的额度) |
|
|
24
|
-
| `CheckpointGate`(`human`/`irreversible_ask`+`safetyAxis`/`plan_review`/…)+ `riskDescriptor` | supervisor 收件箱:据 `riskDescriptor.severity` 排序/分诊 |
|
|
25
|
-
| `pendingSteer` durable steering + `createAskUserQuestionTool`(AskUserQuestion) | client 的 steer-box / 结构化提问 UI |
|
|
26
|
-
| `Checkpoint.deadline` + `gate.kind`(§D-D 契约,core 只写) | **reaper-loop + `terminalAt` + gate.kind 策略=service 自有**(见 §10) |
|
|
27
|
-
| `createTaskServer`(HTTP+SSE 参照) | 生产入站 API(⚠️ 见 §5 P-2 断连不取消) |
|
|
28
|
-
| `createTaskServer` 的 `resolveSpec`(服务端注入 tools/model) | 你的 tool/model 注入逻辑 |
|
|
29
|
-
| 编排原语:subagent/team/cascade/teacher/verify | leader profile(用这些原语组装) |
|
|
30
|
-
| 自修复回路:`runWithTeacher`(运行中监控)/`runWithVerification`(事后验-修)/`runRepairLoop`(带非单调进度门的验-修) | leader 接 objective-oracle;无 oracle 时走 design/80 HITL 升级 |
|
|
31
|
-
| 验证栈:exec-gate(L2)/verify(L3)/property-harness | objective-oracle / 验证门接线 |
|
|
32
|
-
|
|
33
|
-
宪法红线(design/43):**core 不内置场景**。leader、E2B、TiDB 都是 service 的 profile。core 只保证 seam 正确 + 行为诚实。
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 1. 任务入口契约(必读)
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import { Runner, createOpenAIBrain, type TaskSpec, type TaskResult } from "@sema-ai/core";
|
|
41
|
-
|
|
42
|
-
const runner = new Runner({
|
|
43
|
-
brain, // 你的网关(可 routing/failover/degrade 组合)
|
|
44
|
-
models, roles, // 模型目录 + 角色→模型默认表
|
|
45
|
-
sessionStore, // TiDB 会话中心(durable)
|
|
46
|
-
checkpointStore, // TiDB checkpoint(durable suspend/resume)
|
|
47
|
-
toolResultStore, // durable offload
|
|
48
|
-
memoryStore, // 记忆后端
|
|
49
|
-
executionEnvFactory, // per-task 远端沙箱工厂(E2B/Kata)
|
|
50
|
-
toolPolicy, onError, // 审批门 + 监控
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**TaskResult.status 多态**(switch on it):`completed` / `blocked`(模型调 report_blocked)/ `failed` / `timeout` / **`suspended`**(durable 挂起,带 `checkpointToken` + `checkpointGate`)/ **`needs_review`**(design/80 D-B 计划评审挂起,见下)。
|
|
55
|
-
|
|
56
|
-
> **design/80 新增的 durable-pause 家族(1.101→1.104)**:`CheckpointGate.kind` 现含 `human`、**`irreversible_ask`(带 `safetyAxis`,D-2)**、**`plan_review`(D-B,PRE-action 计划门→`status:"needs_review"`,resume 走 `plan_review` 臂)**;`human`/`irreversible_ask` 升级门额外挂 **`riskDescriptor`**(供 supervisor 收件箱分诊,见 §11)。`ResumeOutcome` 现含 `plan_review` 臂(`decision: "approve"|"edit"|"reject"`)。`approval`/`irreversible_ask`/`plan_review` 三条 resume 臂必须各自匹配对应 gate.kind(`gateMatch` 守卫防混淆),不可错臂 resume。
|
|
57
|
-
|
|
58
|
-
**errorCode 优先级链是公开契约**(`assemble-result.ts`,勿依赖顺序之外的行为):
|
|
59
|
-
`output.invalid` → `output.degenerate` → `budget.precall/exceeded` → `suspend.loop` → `limit.timeout` → `limit.max_turns` → `conflict` → (threw code) → blocked → **suspended** → abortedLive → (no final=failed) → (brain `[code]`) → completed。
|
|
60
|
-
|
|
61
|
-
> **prepare 期 throw 走 `(threw code)` 槽 → `status:"failed"` + `errorCode`**(非异常上抛)。已知 prepare-throw 码:`config.egress_requires_write_effect`(配置面);design/99 §E18 resume-at 面 `resume_at.no_session`(给了 resumeAt 但无 sessionId)/`resume_at.conflicts_resume`(resumeAt 撞 durable resume)/`resume_at.not_found`(目标 entry 不在 session)/`resume_at.not_a_message`(目标非 message 边界,或落在未结的 tool-call 中);design/101 §E19 rewind 面 `rewind.restore_failed`(真 restore 失败=半收敛树,fail-closed 不跑 agent;`not_found` 反而是**非致命**经 onError(phase:"rewind") 上报"文件未变")。service 若 `switch(errorCode)`,把这些当配置错误(4xx),非重试。
|
|
62
|
-
|
|
63
|
-
> 编排器**必须**显式处理 durable-pause:别把它当 failed。各编排器(cascade/teacher/verify/team/subagent + repair-loop)已把意外的挂起映射成 `failed + unexpected.suspended + checkpointToken`,守卫现统一走 `isDurablePause(status)`(`src/agents/suspend-guard.ts:30`,**覆盖 `suspended` 和 `needs_review` 两态**——design/80 D-B codex 抓到旧守卫只判 `status==="suspended"`、嵌套 `needs_review` 挂起会孤立 checkpoint/丢 resume token,已用 `isDurablePause` 收口)。守卫点:cascade.ts:191 / teacher.ts:495 / verify.ts:292,317 / team / subagent。**注意 `isDurablePause` 是 `src/agents/` 内部 helper、不在 `src/index.ts` 公开导出**;你若要在 service 侧自己判 durable-pause,直接对 `status ∈ {"suspended","needs_review"}` 判即可。
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## 2. Durable suspend/resume(F4 人审门)——你的主力 seam
|
|
68
|
-
|
|
69
|
-
**保证**(`durability-boundary.md`,诚实边界):
|
|
70
|
-
- durable suspend 仅在 **`policy:"ask"` 门**(gated call 尚未执行)。
|
|
71
|
-
- 跨副本 resume:别的进程可从持久 checkpoint resume(带 per-task 正确性态 + 远端 `WorkspaceHandle`)。
|
|
72
|
-
- **exactly-once continuation**:resume 经单 token CAS(`resolve`,与 `expire` 互斥),两个竞速 resume 不会都执行。
|
|
73
|
-
- 正确性态从**显式白名单**恢复;不可序列化字段=suspend 时 fail-fast,**绝不**resume 时静默丢(编译期守卫强制白名单覆盖)。
|
|
74
|
-
|
|
75
|
-
**不保证**:非确定性重放、非任意点 durable、非 mid-tool 重放(中断的工具按 effect class 标 `[INTERRUPTED]`、**绝不自动重做**)、非通用 workflow 引擎。
|
|
76
|
-
|
|
77
|
-
**resume 授权**:token 是**单因子 bearer**(token-as-auth)。高风险部署在 `resume` 外**包你自己的授权**(把 token 绑 principal/scope)。持久化的 token 当 secret(at-rest 加密 + TTL + 审计读路径)。
|
|
78
|
-
|
|
79
|
-
**实现 `CheckpointStore`**:逐方法可落(approval-store=HITL / run-store profile;`resolve` 原子 CAS=once-only 地基)。**⚠️ 必须实现 `reopen`**(可选接口方法但**载重**)——见 §5 P-9:PG 参照适配漏了它,你的 TiDB 实现别学。`reopen` = `UPDATE status='pending' WHERE status='resolved'`(post-CAS env-restore 失败的补偿,长自治任务命脉)。
|
|
80
|
-
|
|
81
|
-
**PG 参照适配前向兼容**:`PgCheckpointStore` 把整个 `Checkpoint` 存成 jsonb blob,get 时只覆盖 `status` 列——所以 design/74 给 `Checkpoint` 加的 `version`/`resourceLedger` **自动 round-trip,无需 schema/adapter 改动**(C-13 验证)。你的 TiDB adapter 同理设计即可前向兼容 design/74。
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 3. 远端 ExecutionEnv(design/48)——你的 E2B/Kata adapter
|
|
86
|
-
|
|
87
|
-
实现 `RemoteExecutionEnv`(type-only 契约,`src/core/remote-env.ts`):
|
|
88
|
-
- `execStream` yields stdout/stderr 然后**恰好一个**typed `exit` chunk(无 `exec` 重载)。
|
|
89
|
-
- abort → iterator 抛 `RemoteExecutionError('aborted')`(无 exit chunk)。
|
|
90
|
-
- suspend×in-flight:error 变体拒 `command_in_flight`,abort 变体杀 in-flight 流(iterator 抛 `suspended`)然后 suspend 成功。
|
|
91
|
-
- connect/resumeVM/reconnect/postResumeInit 返回 `Result`;destroy 拆除。
|
|
92
|
-
- 通过 `RunnerDeps.executionEnvFactory`(`{sessionId, taskId}` → env)注入;Runner 在任务结束 `destroy()` 它。
|
|
93
|
-
- **typed retryable 错误**:`RemoteExecutionError`/`FileError` 的 `timeout`(mod #6)+ `transport_lost`(mod #9)——RPC hang / SSH channel death / ADB offline 用这些 typed code,别编码成消息前缀;用 `withRetry`(消费侧)对幂等建连 op 重试。
|
|
94
|
-
|
|
95
|
-
> v1=E2B managed(memory 说当前跑面=本地 Kata k3s8,非 E2B——以 mission 锚为准)。
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 4. 长自治跑:design/74 资源分片 suspend(✅ 已落地 + LIVE 验过)
|
|
100
|
-
|
|
101
|
-
**现状(2026-06-22,已不在飞)**:design/74 LIVE durable suspend/resume **已 make-real 验证通过**(真 Dart→Kotlin 迁移、11 次真挂起/resume、before/after trace 证进度存活)。core 侧:`TaskSpec.resourceSuspend?:{scope}` opt-in + `suspendForResource` 闭包 + `requestStopAfterTurn` 干净停 + turn/budget cap→suspended + ResourceLedger(frozen-total/prior-wins)全 ship。**旧 "design/74 在飞、别碰 runtask.ts/checkpoint-store.ts" 的警告已过时**——design/74 已落、design/80 也改过这些文件且已发版。
|
|
102
|
-
|
|
103
|
-
**资源分片模型(仍是 service 接线)**:leader 持总预算,每 slice `maxCostUsd=min(窗口, ledger 剩余)`,撞边界 turn_boundary 干净 suspend,resume 拨下一 slice,**agent 全程不见钱**(resume 用无金钱 `<system-reminder>`,工作区权威)。其中"resume 拿不回的额度"现在通过 **`ToolCallRequest.budget` 只读读上下文**暴露给无状态 policy(见 §11),使部署策略能据 durable ledger 自限。spec=`../design/74-v4-resource-slice-suspend-code-level.md`。
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## 5. 🔴 会直接影响 service 的审计 gotcha(详证见 `KNOWN-ISSUES.md` + `audit-2026-06-15/PRODUCTION-ISSUES.md`)
|
|
108
|
-
|
|
109
|
-
| # | 影响 service 的什么 | 你要做什么 |
|
|
110
|
-
|---|---|---|
|
|
111
|
-
| **P-3** | `TiDbSessionRepo.delete()` 先删 entries 后删 session row + open 用 `&&` → 崩溃/并发中间态返回**空历史 Session**(静默)。这是 reference adapter,**会复制进你的会话中心**。 | 对齐 `PgSessionRepo`:先删 session row,或 open 的 not_found 判据改成"session row 不在"单条件。 |
|
|
112
|
-
| **P-9 / C-12** | PG 参照 `PgCheckpointStore` **缺 `reopen`** + TiDB 参照适配**根本没有 CheckpointStore** → durable 部署上 post-CAS env-restore 失败=**静默丢挂起工作**。 | 你的 TiDB CheckpointStore **必须**实现 `reopen`;别照搬缺口。 |
|
|
113
|
-
| **P-1** | MCP 工具丢 `isError` → 失败的 MCP 调用全链路当**成功**(断路器不跳、onError 不告警、trace `ok:true`)。若 leader 依赖 MCP 工具结果做决策,失败被掩盖。 | 知悉;core 修前,你的 MCP server 失败要靠 content 文本自陈(模型看得到,但引擎信号失效)。 |
|
|
114
|
-
| **P-2** | `createTaskServer` SSE 客户端断连**不取消** eager run → 任务烧到底 + 持有 env/MCP + 无界缓冲。 | 你的生产入站 API **别直接用** `createTaskServer` 的 SSE 分支;接 `req.on('close', () => stream.destroy())` + `res.write` 背压。 |
|
|
115
|
-
| **P-6** | `web_fetch` 无 allowlist 时零 SSRF 防护 + 即使有 allowlist 也无 IP/私网/metadata 拦截;模型描述谎称"仅 allowlist"。 | 给 worker 的 `web_fetch` **必传紧 allowlist**,且在沙箱网络层(E2B egress 策略)兜底拦私网/metadata。 |
|
|
116
|
-
| **P-20** 🔴 | 连 image 的 `isPrivateHost`(我原建议 web_fetch 复用的那道防线)**本身**被 IPv4-mapped/IPv6 字面量(`[::ffff:169.254.169.254]`)绕过。 | 沙箱网络层(E2B/Kata egress)是**唯一可靠**的 SSRF 边界——别只依赖 core 的 host 字符串检查;若复用 `isPrivateHost` 务必先用 `net.isIP()` 硬化(详见 `audit-2026-06-15/ADDENDUM-second-pass.md` §B P-20)。 |
|
|
117
|
-
| **P-7** | resume 时若 `taskConfig.tools` 漏了已批准工具 → 烧掉 checkpoint + 静默丢 + run 报 completed + 假"已执行"。 | resume 时**保证重传的 taskConfig.tools 含 pendingAction.toolName**(service[15] satisfiability precheck 要看 hand band,不止 spec.tools——用导出的 `HAND_TOOL_EFFECTS` 权威判定)。 |
|
|
118
|
-
|
|
119
|
-
> egress 受控(design/70):给 worker 的 git/网络工具标 `ToolSpec.egress`,prepare-task 会把 allow→ask 收紧(经 gate)。注意 `web_fetch` 是 `effect:"read"` **非 egress-marked**,egress gate 不覆盖它(见 P-6)。
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## 6. 重点分析:你拿到的真实保证 vs 需自己兜底
|
|
124
|
-
|
|
125
|
-
**真保证(core 已正确)**:
|
|
126
|
-
- session CAS 乐观锁(F2):跨副本 wake 同 session 不静默分叉,输家抛 `SessionError("conflict")`(`isSessionConflict` 捕获重试)。
|
|
127
|
-
- wake 对账(`reconcileInterruptedSession`):悬空 tool_call 合成 `[INTERRUPTED]` isError 结果、**绝不重放**,把"是否重做"交模型。给工具标 `effect: read/write/idempotent` 让提示更精准。
|
|
128
|
-
- 前缀缓存纪律:用 `stableSystem`(别手工 `system()` 拼序),core 自动把 memory 放尾;`assertPromptCacheFriendly` 进 CI。`stats.cacheHitRate` 是成本命脉(多轮+大提示+命中<15% 经 `onError(phase:"prompt-cache")` 告警)。
|
|
129
|
-
- 成本:`computeCostMicroUsd`(整数 micro-USD,从注入定价 + token 数)。**别用 brain 的 `Usage.cost`**(non-authoritative,`stats.costUsd` 已 @deprecated,见 C-7)。
|
|
130
|
-
- 任务内压缩(turn-boundary,1.88+):长任务不再只靠 context guard;熔断 + anti-thrash 地板(但见 P-13:code-dense 真模型上地板坐标可能虚高、压死任务内压缩——监控长 code 任务的压缩是否触发)。
|
|
131
|
-
|
|
132
|
-
**需你自己兜底(core 诚实声明边界)**:
|
|
133
|
-
- 沙箱隔离(microVM):core 给 ExecutionEnv 接口,真隔离是你的 E2B/Kata(design/53 §2.E,CVE-2025-59528 教训)。
|
|
134
|
-
- 凭据 scoping / 网络 egress / secrets 防外泄:service E2B/k8s adapter(design/53 GAP3)。
|
|
135
|
-
- resume token at-rest 加密:你的 TiDB store(GAP4)。
|
|
136
|
-
- 压缩保真:模型限制非流程 bug(Qwen int4 激进压缩会丢早期单提及事实);用真 256K 窗 + 调大 keepRecentTokens + 强 compactionModel + 关键事实复述。
|
|
137
|
-
- **oracle 失败自修复**(旧"头号闭环命门",现已 by-design 收口):core 现给 `runWithTeacher`(运行中监控)/ `runWithVerification`(事后验-修)/ **`runRepairLoop`(带非单调进度门的验-修,`src/agents/repair-loop.ts`)** 三条自修复回路;**无真 oracle 时**走 design/80 HITL 升级路径(durable approval + plan_review + steering),诚实把"对/错"交人。你在 leader 把 objective-oracle 接进 `runWithVerification`/`runRepairLoop`、并在无 oracle 时挂 supervisor 升级即可——不必再从零建闭环。
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## 7. router / 模型(实战教训)
|
|
142
|
-
|
|
143
|
-
- 模型=**DeepSeek pro+flash,非 Qwen**;思考默认开(design/46 thinkingFormat 分发已处理)。
|
|
144
|
-
- **router planner collapse=flaky 非系统**(service 实测:A/B 各 12 次 temp=0 复现,引号句假设被证伪)。真因疑似**逼近 32k max_tokens 跑飞**(design/46 推理吃满 max_tokens 陷阱)。修法候选:router 调用加 **JSON-mode/structured-output 约束 + 收紧 max_tokens**;或先靠 rawSample 观测攒证据。
|
|
145
|
-
- `max_tokens` 陷阱:推理模型思考会吃满 max_tokens 导致无答案(给数千别给 512);Anthropic 路自动钳思考预算。
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## 8. 最小接入清单(service)
|
|
150
|
-
```
|
|
151
|
-
[ ] Brain:DeepSeek pro/flash 网关(routing by provider + failover + degrade)
|
|
152
|
-
[ ] SessionStore:TiDB 会话中心(CAS=(session_id,seq) 唯一键;delete 先删 session row=避 P-3)
|
|
153
|
-
[ ] CheckpointStore:TiDB(原子 CAS resolve + 实现 reopen=避 P-9)
|
|
154
|
-
[ ] ToolResultStore + MemoryStore:TiDB/pgvector(三档召回同 cosine 契约)
|
|
155
|
-
[ ] executionEnvFactory:E2B/Kata adapter(实现 RemoteExecutionEnv,typed timeout/transport_lost)
|
|
156
|
-
[ ] 入站 API:别裸用 createTaskServer SSE(接 req close→destroy + 背压);resolveSpec 服务端注入 tools/model
|
|
157
|
-
[ ] HITL:toolPolicy(createApprovalPolicy)+ durableApproval + CheckpointStore = 审批挂起
|
|
158
|
-
[ ] leader:runTaskStream fan-out + 显式处理 suspended + HAND_TOOL_EFFECTS 做 resume satisfiability
|
|
159
|
-
[ ] 安全:沙箱网络层兜底 web_fetch SSRF(P-6/P-20)+ sensitive-path policy(部署敏感路径表)+ resume token at-rest 加密
|
|
160
|
-
[ ] 观测:onError 接 trace seam→OTel;cacheHitRate/computeCostMicroUsd 进成本看板
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## 9. leader 骨架(最小可跑示意——你最该建的那段)
|
|
164
|
-
> leader = 编排循环:fan-out 子任务 → 各自跑 → **显式分流 suspended** → 验证门 → 收敛。core 给原语,这段控制流是你的 profile。
|
|
165
|
-
```ts
|
|
166
|
-
import { Runner, type TaskResult } from "@sema-ai/core";
|
|
167
|
-
|
|
168
|
-
async function leader(runner: Runner, subtasks: TaskSpec[]): Promise<void> {
|
|
169
|
-
// 1) fan-out:每个子任务一个 stream(eager,立即并行开跑)
|
|
170
|
-
const streams = subtasks.map((s) => runner.runTaskStream(s));
|
|
171
|
-
const results = await Promise.all(streams.map((st) => st.result()));
|
|
172
|
-
|
|
173
|
-
for (const r of results) {
|
|
174
|
-
switch (r.status) {
|
|
175
|
-
case "completed":
|
|
176
|
-
// 2) 验证门:对真 oracle 验(exec-gate L2 机械门 / runWithVerification L3 去相关判)
|
|
177
|
-
// 🔴 D1 命门:验失败要在这里建"自动修复回路"(再派一轮带 oracle 反馈),core 不替你建
|
|
178
|
-
break;
|
|
179
|
-
case "suspended":
|
|
180
|
-
// 3) 🔴 必须显式处理:r.checkpointToken + r.checkpointGate 在;不是 failure
|
|
181
|
-
// resume 时重传的 taskConfig.tools 必须含被批准的工具(用 HAND_TOOL_EFFECTS 判 hand band)否则丢工作(P-7)
|
|
182
|
-
// 人审/加额度后:await runner.resume(r.checkpointToken!, { gate:"policy_ask", decision:"allow" }, taskConfig)
|
|
183
|
-
break;
|
|
184
|
-
case "blocked": /* 模型 report_blocked:缺信息/权限,回灌或升级 */ break;
|
|
185
|
-
case "failed":
|
|
186
|
-
case "timeout": /* 看 r.errorCode(limit.max_turns/budget.exceeded/conflict/...);
|
|
187
|
-
failed worker 的本地 commit 默认不 salvage=D4,belt-diff 要你建 */ break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
- **取消**:fan-out 中途要砍 → `streams.map(st => st.destroy())`(abort + reap env);别指望 break early 自动停(eager,P-2 同源)。
|
|
193
|
-
- **中途纠偏**:`st.steer(text, {trusted})` 注入下一回合(design/47);`st.interrupt()` 硬停。
|
|
194
|
-
- v2 LLM-Planner(Router+Decomposer+replan-lite)的 spec 见 `../design/68-llm-planner-spec.md`(**注意 design/68 有两个文件,planner spec 是 `68-llm-planner-spec.md` 非 `68-e2e-drill-checklist.md`**);它 by-design 全在你的 profile、core 零新增。
|
|
195
|
-
|
|
196
|
-
## 10. TiDB CheckpointStore 参照(core 没给,你要建——别照搬 PG 的缺口)
|
|
197
|
-
core 的 `PgCheckpointStore`(`src/stores/pg.ts:348`)是**最接近的模板**,但**故意漏了 `reopen`(P-9)**——你的 TiDB 版**必须**实现它:
|
|
198
|
-
- 5 必需方法:`put`(撞 token 抛 AlreadyExists)/ `get` / `resolve`(原子 CAS:`UPDATE … SET status='resolved' WHERE token=? AND status='pending'`,affected=1 才算赢=exactly-once)/ `expire`(同 CAS 与 resolve 互斥)/ `reap`(扫过期)。
|
|
199
|
-
- **`reopen`**(P-9 必加):`UPDATE … SET status='pending' WHERE token=? AND status='resolved'`(post-CAS env-restore 失败补偿,长自治命脉;runner 经 `store.reopen ? … : undefined` 探测,缺它=静默丢挂起工作)。
|
|
200
|
-
- 整个 `Checkpoint` 存 jsonb blob + 只覆盖 `status` 列(PgCheckpointStore 做法)→ design/74 给 Checkpoint 加的 `version`/`resourceLedger`、design/80 加的 `state.pendingSteer`/`gate.riskDescriptor` **全自动前向兼容,无需 schema 改**。
|
|
201
|
-
|
|
202
|
-
### §D-D 过期语义契约(reaper = service 自有;core 只写 `deadline`+`gate.kind`)
|
|
203
|
-
design/80 §D-D 把 reaper 所有权**定在 service 侧**(channel [135]/[136],ownership=A)。`Checkpoint.deadline`(epoch-ms,`src/core/checkpoint-store.ts:729`)+ 持久化的 `gate.kind` 是 **core 唯一保证的两个 durable 字段**(由一条 field-contract 测试钉住:InMemory + Pg round-trip)。**reaper-loop 本身、gate.kind 策略、以及 `terminalAt` abandonment backstop 的铸造,全是 deployment 的活——core 不跑 reaper、不铸 `terminalAt`、不改 `reap` 逻辑。** 你的 reaper-loop 按 gate.kind 分两 FACET:
|
|
204
|
-
- **FACET A — approval 门**(`human` / `irreversible_ask`):`deadline` = SLA **resolve-deny** 时间(快路径:到点 `resolve(token, {gate:"policy_ask", decision:"deny"}, …)` 让挂起 run 干净结束),外加一个**更晚的 `terminalAt` abandonment backstop**(loop 也尊重它)。
|
|
205
|
-
- **FACET B — 资源分片 + 评审挂起家族**(`resource_limit` / `needs_review` / `plan_review`):`deadline` = abandonment-TTL → **只 `expire`/`reap`,绝不 resolve-deny**(对这些 kind 做 resolve-deny 会 `gate_mismatch`)。
|
|
206
|
-
- service 已确认这套 gate.kind-aware reap + `terminalAt` 在 service 侧 **BUILT + live**;core 1.116.0 仍只保留契约文档 + 钉死 durable 字段(reaper 所有权不变)。**避免双 reaper**:别让 core 这边再起一个。
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## 11. design/80 Supervisor 新 seam(1.101→1.104,人在环监督式编排;已封顶降为基座)
|
|
211
|
-
|
|
212
|
-
> core 半边**全部 ship 完**(D-1~D-F + riskDescriptor + §D-D 文档)+ 价值判决 GOAL 达成 → **降为基座**(仍是已 shipped 的耐久能力,只是不再是前向焦点;当前主线见 §12)。每片=subagent 实现 + 我审 + 独立 codex 复审。下面是**新增公开 API 表面 + 你(service/client)要消费/实现的契约**。除 D-G 外都 INERT 或纯 additive seam——profile/client 激活,core 单独不改行为。
|
|
213
|
-
|
|
214
|
-
**新公开 API(README 同步)**:
|
|
215
|
-
- **`ToolCallRequest.budget`**(`src/core/tool-policy.ts:16`,只读 durable 预算读上下文):`{ resourceRemainingMicroUsd?, resourceSpentMicroUsd, suspendCount }`,来自 durable/frozen-total/prior-wins 的 ResourceLedger。**用途**:无状态部署 policy 据它自限——因为 resume 拿不回这笔额度。(D-E-core,1.103.0;codex 抓到 4 个 cross-kind-resume 计账 bug 已修。)
|
|
216
|
-
- **`TaskResult.stats.costBreakdown`**(`src/core/types.ts:747`,可选):`{ llmRootMicroUsd, nestedSubagentMicroUsd, memoryConsolidationMicroUsd, compactionMicroUsd }`,**仅 LLM 派生**;基建轴(infra)是 service 的(finance taxonomy item-3,未建)。恒等式:`llmRoot + nestedSubagent + compaction === costMicroUsd`(`memoryConsolidation` 是预算外独立项)。**⚠️ v1 局限**:多片资源 resume 下 `compactionMicroUsd` 会少报先前片的 compaction(已在公开 type JSDoc 标注)。
|
|
217
|
-
- **`CheckpointGate.riskDescriptor`**(`src/core/checkpoint-store.ts`,可选):`{ severity: 1..5 (ToolEmu 风格), axes{egress?,irreversible?,shell?}, toolName, summary?, touchedPaths? }`,在 `human`/`irreversible_ask` 升级门铸造时**确定性派生**(从 D-2 safetyAxis + shell-gate 上下文 + SHOWN 工具 args)。**用途=supervisor 收件箱按真实严重度排序/分诊**。**INERT(trace 验过)**:core 绝不读它来 gate/budget/suppress——结构性 ask 仍严格胜出。`summary`/`touchedPaths` 经 redaction 硬化(所有模型可控值过 `inlineUntrusted` + code-point 上限,只摘顶层 DATA 标量;`buildRiskDescriptor` **by-construction TOTAL**=对抗性/hook 改写的 args 也不能让铸造崩或变更显示)。(D-E,supervisor 封顶版;3 轮 codex 复审收口 totality+security。)
|
|
218
|
-
- **`CheckpointGate.kind`**:现含 `irreversible_ask`(带 `safetyAxis`,D-2/1.102.0,mint-site 不可逆轴→`irreversible_ask` + egress predicate)、`plan_review`(D-B/1.103.0,与 `needs_review`/`human` DISJOINT 的 PRE-action 计划门)。`ResumeOutcome` 含 `plan_review` 臂(`approve`/`edit`/`reject` + `editedPlan?`)。
|
|
219
|
-
- **`pendingSteer`**(`Checkpoint.state.pendingSteer`,D-A/1.103.0):`{ text, trusted }`——supervisor 给已暂停 checkpoint 挂 steering,resume 时拼进单条 continuation prompt(trusted→hook-feedback;untrusted→`delimitUntrusted`),set 时按 break-out tags + 控制字符校验(last-writer-wins on still-pending row)。
|
|
220
|
-
- **AskUserQuestion**(`createAskUserQuestionTool` + `OnQuestion` 类型,均在 `src/index.ts`;保留工具名常量 `"AskUserQuestion"`,D-F/1.103.0):first-party 结构化提问工具;无 live human 时 durable 挂起,resume answer 经 fence 校验(`selected ⊆ options` / header 唯一 / multiSelect / off-list 经 `inlineUntrusted` 中和)。(注:名字常量 `ASK_USER_QUESTION_TOOL_NAME` 定义在 `src/core/ask-question.ts:9` 但**未在 `src/index.ts` 公开导出**;消费侧用字面量 `"AskUserQuestion"`。)
|
|
221
|
-
- **`TaskSpec.shellGate`**(`"off"|"always"|"classify"`,`src/core/types.ts:488`):粗粒度 shell 门;`classify` 用分类器,无分类器时部署应 fail-closed 标 `always`。resume 时与 `toolPolicy`/`tools`/`durableApproval` 同样**必须重供**。
|
|
222
|
-
- **导出 helper**:`riskSeverity`、`buildRiskDescriptor`、`RiskDescriptor` type、`SafetyAxis` type、`createAskUserQuestionTool`、`OnQuestion` type(均在 `src/index.ts`)。
|
|
223
|
-
- ⚠️**`isDurablePause` 不在 `src/index.ts` 公开导出**(它是 `src/agents/suspend-guard.ts` 内部 helper)——service 侧自判用 `status ∈ {"suspended","needs_review"}`。
|
|
224
|
-
|
|
225
|
-
**§5 序列剩余(NOT core)**:
|
|
226
|
-
- **D-G(直连客户端 principal 加密绑定)**:**SERVICE 半边**——server 端已 BUILT + 双 council + canary e2e 通过;**激活待 M2**(config-center trust-domain 锁 + client BFF signer)。
|
|
227
|
-
- **D-C(leader 监督视图)**= 一条 seam note,非实现切片。
|
|
228
|
-
|
|
229
|
-
**你(service/client)的前向工作(core 已封顶)**:
|
|
230
|
-
- **(a) SERVICE**:D-G M2 激活;assistant-scheduler(N 个 durable task + 单收件箱);leader 采纳 supervisor 回路;finance taxonomy item-3(infra 轴);打开 conflict-resolver canary。
|
|
231
|
-
- **(b) CLIENT(自建 supervisor UI)**:steer-box / 计划评审 / 带 token 的决策 / `riskDescriptor` 收件箱渲染。
|
|
232
|
-
- **(c) MAKE-REAL**:把真编码任务跑过**完整 supervisor 回路**(无 oracle 时诚实升级、wedged→进度门停、关键节点上报够用不噪);随后里程碑序:make-real 正确性+安全 → 价值判决(多 agent 值不值,门控在 cost-per-correct 数据)→(LLM-Planner,价值判决倾向"别建")→ scale → 开源。
|
|
233
|
-
|
|
234
|
-
> **leader fan-out 冲突解决器("AI 冲突解决器")已在 service 仓建成**(`leader/merge.ts` `resolveApplyConflict` + `wire.ts` `mkConflictResolver`,commit 46e1852)——**零 core 工作、非 core TODO**;剩 = service 侧打开 canary + make-real 验。
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## 12. CC-parity 编排 + 推理强度新 seam(1.114→1.118,已封顶基座;最新 workflow seam 见 §14)
|
|
239
|
-
|
|
240
|
-
> design/80 封顶后主线转 **CC-parity 编排 + 推理强度(design/96/97/98)**。下面是 1.114–1.116 新增、**你(service)要消费/实现**的公开面。导出件全在 `src/index.ts`。
|
|
241
|
-
|
|
242
|
-
- **Workflow 模式(`src/orchestration/workflow.ts`,design/97 S1)**:`runWorkflow(script, deps, opts?)` 跑一个 `(ctx: WorkflowRunContext) => …` 的**确定性脚本编排** thin helper(**NOT** LLM 动态 planner)。`WorkflowRunContext`:`agent`(记录在案的 agent-run,任何终态都不 throw)/ `parallel`(**有 barrier**)/ `pipeline`(**无 barrier**)/ `phase` / `log` + 只读 `runId`/`budget`。`opts.budget`(token 上限)耗尽 → `WorkflowBudgetExceededError`;`MAX_WORKFLOW_ITEMS` = 单次 `parallel`/`pipeline` 项数上限。
|
|
243
|
-
- **`/workflows` 可观测(`src/core/workflow-run-store.ts` + `src/orchestration/workflow-observe.ts`,S1b/S1c)**:`WorkflowRunStore` 接口 + `InMemoryWorkflowRunStore` + `FileWorkflowRunStore`(`src/stores/file/workflow-run-store.ts`)。**⚠️ PG `WorkflowRunStore` 归 service**(=部署 persist 轴,和 PgCheckpointStore/PgSessionStore 同性质,core 不提供)——按 `workflowRunStoreContract` 实现 + 跑跨后端等价测。读取面 `listWorkflowRuns`/`getWorkflowRun`/`subscribeWorkflow` + `summarizeWorkflowRun`(投影 `WorkflowRunSummary`)。持久化 **opt-in + best-effort**(owner 单写 rev CAS;store throw 绝不破坏 workflow)。
|
|
244
|
-
- **推理强度(`src/brain/reasoning.ts`,design/96 S3/S5/S6)**:`ReasoningIntensity` 复用 vendor 7 档 `ThinkingLevel`;`resolveReasoning(requested, endpoint)`→`ResolvedReasoning`(runner 在 task 启动调,发 `reasoning.resolved` TraceEvent 携 `effective`/`graded`/`clamped`/`format`,让部署看到 tier 为何降级/被夹而非静默吞)+ `resolveEffort` per-endpoint clamp。service 可据 `reasoning.resolved` trace 观测每 worker 端点实际生效强度。
|
|
245
|
-
- **`CheckpointSummary` 新字段(`src/core/checkpoint-store.ts`,S1e)** —— **service inbox 去 N+1**:一次 `summarize` 即拿:
|
|
246
|
-
- `createdAt?`(epoch-ms 标量,从 `Checkpoint.createdAt` 投影)。
|
|
247
|
-
- `toolInput?`:`tool_approval` 工具 args 的 **bounded raw 预览**(超过 `MAX_TOOL_INPUT_PREVIEW_CHARS=512` 字符截断 + `…`)。**ECHO-ONLY**(无 gate/CAS/resume 读它,同 `riskDescriptor` 的 INERT 不变量);**脱敏归 consumer**——core 只做长度上限,service inbox 渲染前自行 redaction。
|
|
248
|
-
- **`tightenTaskSpec`(`src/core/tighten-task-spec.ts`,config-center §10,1.114.0)**:**tighten-only** TaskSpec merge 治理原语——把 `overrides` 层叠到 `base`,**放松任何安全字段**(如 `handsReadOnly` 从 `true` 降 `false`、或两边冲突的不可合成字段)即 `throw TaskSpecTightenError`。config-center 据此把 fleet 级策略**只收紧不放松**地下发到 per-worker spec(配合 `createCoarseCommandNamePolicy` commandPolicy)。
|
|
249
|
-
|
|
250
|
-
## 13. sema-shell backlog 新 seam(1.127→1.128.1,你要消费/实现)
|
|
251
|
-
|
|
252
|
-
> design/99 主权契约 core 半场全收口。下面是 **E14/E18/E12/E19** 新增、**你(service)要消费或实现 durable/remote 后端**的公开面。pin `^1.128.1`。
|
|
253
|
-
|
|
254
|
-
- **§E18 resume-at(`TaskSpec.resumeAt`,design/99)**:取**持久 `SessionTreeEntry.id`(非 live eventId)**。**你建 eventId→entryId 映射**(读 session entries),把壳的 "rewind 到这条消息" 路由成 `resumeAt=entryId`。4 个 prepare-throw 错误码(`status:"failed"`+errorCode)当 **4xx 配置错不重试**:`resume_at.no_session`/`.conflicts_resume`(撞 durable resume)/`.not_found`/`.not_a_message`(目标非已结 message 边界,或落在未结 tool-call 的 assistant 消息)。分支非破坏(追加 `leaf`,可反复 re-resume)。
|
|
255
|
-
|
|
256
|
-
- **§E12 prompt 建议(`TaskSpec.suggestNextPrompts` → `TaskStream.suggestions()`)**:`await stream.result()` **后** `await stream.suggestions(): Promise<string[]>`(resolve `[]` 当关/未完成/空/失败,**never rejects**)。wire 给壳 = **UNTRUSTED 仅 UI 渲染、绝不回喂模型**(同 `tool_end.output` 的 consumer-redaction 契约)。仅 `status==="completed"` 回合产;budget-excluded `stats.suggestions`。
|
|
257
|
-
|
|
258
|
-
- **🔴 §E19 FileSnapshotStore(rewind-files durable/remote 后端 = 你实现)** —— 与 §3 远端 env / §10 CheckpointStore 同 **portable-reference vs durable-backend split**:core 给 `InMemoryFileSnapshotStore`(本地 v1),**remote(E2B/k8s)+ 跨副本 durable = 你**。core 在 `!isRemoteExecutionEnv` 时**跳过** snapshot/restore 留给你(`RunnerDeps.fileSnapshotStore` seam)。
|
|
259
|
-
- **seam 契约**(`src/core/file-snapshot-store.ts`,4 方法全 **never-throw 返 `FileSnapshotResult`**):`snapshot/restore/has/reap`,**scope=sessionId,key=`SessionTreeEntry.id`**(与 E18 同锚 → rewind 组合)。
|
|
260
|
-
- **必须逐字匹配的语义**:① **create-once** per `(scope,key)`——entry 不可变故其树态也不可变,重复 snapshot 同 key = no-op `{ok:true}`;② **restore 是 CONVERGE 不是 overlay**——写下快照文件 **+ 删快照后新建的文件**,使树**等于**快照(非超集);③ **`not_found` 是合法预期**(core 经 `onError(phase:"rewind")` 上报 "文件未变",**别当 error**);④ core **只在 `result.status==="completed"` 回合调 snapshot()**(1.128.1 gate);你后端同此谓词、别自行在非完成回合拍。
|
|
261
|
-
- **🔴 若你做 FILE-LEVEL durable 后端(非整 VM snapshot),双审踩出的坑直接拿走别重新踩**:① **symlink-ancestor 路径逃逸**——快照后某目录被换成 `dir -> /outside` 符号链接,restore 的 writeFile 会**跟随它写出 root** → 必须 **remove-before-write**(先删当前所有 symlink 中和祖先,再写);② **file↔dir 翻转**(`rm x; mkdir x`)——写前删占位目录否则 EISDIR;③ **fail-CLOSED**——超 bound/枚举失败**绝不存半快照**(部分 manifest = restore 数据丢失);④ symlink 不保真(restore 删之 = 逃逸防护)。**整 VM-snapshot 后端**则这些 file-level 坑不适用(VM 快照抓全树),但 ①②③④ 的 **create-once/converge/key/gate 语义仍要匹配**。
|
|
262
|
-
- **🔴 必拍给你(VM-snapshot 成本)**:core 在**每个 completed 回合** awaited 调 snapshot()。整 VM 快照 per-turn = O(VM) 很贵(本地 ref 是 content-addressed、边际 O(changed));你 VM 后端可能要不同策略(CoW FS 层 / lazy 仅 on-rewind 拍 / 增量快照)——**snapshot() 的"每回合拍"语义你能否承受、还是要核心给你一个 "lazy/on-demand" 变体?这条单发找我对齐再定。**
|
|
263
|
-
- **reap / E18 分支放大**:runner **不自动 reap**;每 completed 回合加一份,E18 分支乘可达 leaf。`reap(scope, keepKeys)` GC 不可达 leaf 的快照 = 你的 reaper 职责(同 CheckpointStore reaper 模型)。
|
|
264
|
-
|
|
265
|
-
- **§E6 durable `SessionPolicyStore`(你接,TiDB+PG 孪生)**:逐字匹配 core 语义——CAS `expectedRev` / **tighten-only 直接复用导出的 `loosenReasons`**(别重写方向判定)/ allowDirs 写前 `posix.normalize`(防 `/work/../etc` 绕过,双审逮的 blocker)/ operator flag 从 **verified principal** 算(镜像 `steer.trusted`)。
|
|
266
|
-
|
|
267
|
-
## 14. 2c session-sync + workflow-parity 新 seam(1.135→1.145,你已消费 SVC-1~5)
|
|
268
|
-
|
|
269
|
-
> 两批新 seam。**workflow-parity SVC-1~5 你已全 ship**(channel [295],service `67a5dd5`)——本节是 fresh service-AI 的 cold-start 索引。pin `^1.145.0`。
|
|
270
|
-
|
|
271
|
-
**A. 2c session-sync(1.135→1.143,云↔本地会话同步)**
|
|
272
|
-
- **`SessionRepo.export/importEntries`**(1.137):durable session 内容跨副本/云↔本地搬运。`FileSessionRepo` 半场已闭(1.142,entries byte-equal 落地 + owner re-stamp)。
|
|
273
|
-
- **`FileSnapshotStore` 导出/导入闭环**(1.140/1.141):`export` + `importManifest`(import 侧 store 写)+ **`putBlob` 返 `FileSnapshotResult`**(1.142,契约变更已吸收)。**BLOB 走对象存储**:你侧已搬 MinIO(`BlobBackend` seam:`SqlBlobBackend` 默认 / `MinioBlobBackend` 复用 s3-presign);blob 出 TiDB(大行 perf),SQL 只留 bytes-NULL 索引行 + manifest。**MinIO 删除纯异步**(reap/E21-purge 删 SQL manifest → orphan → 异步 sweep 删对象,error-tolerant 最终一致,**绝不同步删外部存储**)。core 接口不变、你换 impl。
|
|
274
|
-
- **`SessionPolicyStore.listBySession`**(1.140):policy 块导出侧。
|
|
275
|
-
- **`StreamingImportValidator`**(1.143,NDJSON 流式导入):成本闸 `DEFAULT_SNAPSHOT_BOUNDS`= **maxFiles 10000 / maxBytes 256MiB**(**整树 per-turn 成本闸,非单文件非行限**)。转录仍 DB ≤20KB 行不变。⚠️ **maxFileBytes per-row cap 整套作废**——clay 拍快照走对象存储是根因解,per-row 是 DB 问题非引擎(别再提议给单文件/单行加 cap)。
|
|
276
|
-
|
|
277
|
-
**B. workflow-parity CORE-1~9(1.144→1.145,CC Workflow 工具平价)**
|
|
278
|
-
- **🔴 `WorkflowJournalStore`(你接,PG+TiDB 孪生 = SVC-2)**:tool-launched workflow 的跨副本 durable resume journal。**1.145.0 BREAKING +scope**:`load(runId, scope)` / `append(runId, scope, entry)`——**scope load-bearing,必须进 WHERE/INSERT**(跨租户隔离:A append → B load **必须空**;这正是审计逮的 BLOCKER)。`(runId, ordinal)` PK = **OVERWRITE last-write-wins**(非 first-write、非 append-only),`callKeyOrdinal` + load ASC + `deleteByRun`。wire:`RunnerDeps.workflowJournalStore`(= `workflowRunStore` 孪生)+ tool 路径喂 `RunWorkflowOptions.journalStore` + `resumeFromRunId`(1.145 CORE-9 Part A 接好)。
|
|
279
|
-
- **`onWorkflowAgentSpawn` sink(CORE-9 Part B = SVC-5 steer 路由)**:opt-in `RunnerDeps.onWorkflowAgentSpawn(handle)` → 你 `registry.register(handle)`(按 `runId+label`);`handle.result()` settle 时 unregister(stale 仅 409 不泄漏)。steer 链:`human → 你 HTTP → registry 查 → handle.steer(content)`;steer-in 过 redaction 门(**复用顶层导出 `untrustedEgressForHuman`**)+ owner-gate + 跨副本 409。脚本永不拿 handle(sink 未设=零开销,安全 + no-stopgap)。⚠️ **steered agent 不进 journal**(CORE-9.1 限制,文档化);端到端真 steer = live-only(on-box 验,同 E23)。
|
|
280
|
-
- **worktree 隔离(CORE-6 = SVC-3)**:`addWorktree`/`pruneWorktrees`,经 trusted `RunInternals` 穿入(非 spec)。**isolate-only 零 merge**(clay 拍死:runtime = 隔离原语,verify+merge 全在编排脚本 userland)。你提供 env + isolation 净化信任门(`ExecutionEnvFactoryContext.isolation`);⚠️ **worktree 隔离与 durable suspend 不兼容**——隔离 agent 必须跑到完成(per-repoRoot mutex 防并发 git-worktree-remove 竞争 orphan)。
|
|
281
|
-
- **per-agent 投影(CORE-8 = SVC-4 v2)**:`summarizeWorkflowDetail` agent 投影含 `model`/`toolCalls`/`activity`(`ToolActivity[]` last-N);SSE verbatim 转发 `agent_activity`。
|
|
282
|
-
- **顶层导出(承诺给你的,1.144 一起出)**:`untrustedEgressForHuman` / `redactHostLeaks` / `boundedRedactedSummary`(跨仓 import 别锚 vendor 内部路径,同 `scrubSecretEnv`/`RollingTailBuffer` 纪律)。
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
## 15. sema-shell 数据契约 seam(MF-*,1.146→1.150,你已消费 MF-Fleet)
|
|
287
|
-
|
|
288
|
-
> 引擎↔sema-shell `/workflows` monitor↔service 的**可观测数据契约**。core 只产 **fact/signal**;聚合是 service 的(见 MF-Fleet)。下面是 1.146→1.150 新增、**你(service)要消费**的公开面。pin `^1.150.0`。
|
|
289
|
-
|
|
290
|
-
- **🔴 `TaskResult.stats.humanReview.gates[]`(MF-24,1.148)= 权限门/denial 账本**:每条 `{ kind, decision, toolName, toolArg }`——decision 含 deny;`toolArg` 经**共享脱敏边界 `src/core/arg-summary.ts`**(secret-scrubbed),你渲染前不必再脱敏 core 已摘的标量、但跨仓 import 别锚 vendor 路径。supervisor inbox / 审计回放据此列出真实 HITL 决策轨迹。
|
|
291
|
-
- **`TaskEvent.task_progress`(MF-10,1.147)= subagent usage tick**:`{ totalTokens, toolUses, durationMs }`,**ephemeral**(仅 subagent、不进 durable journal),供 monitor live 渲染子 agent 进度;别当 durable 真相源(用 `summarizeWorkflowDetail` 取 durable 投影)。
|
|
292
|
-
- **`TaskResult.model`(MF-25,1.148)= effective(resolved)model id 回声**:任务实际生效(经 role→model 解析后)的模型 id,monitor header 显示。
|
|
293
|
-
- **`CheckpointSummary.contentKind`(MF-14,1.150)+ `compacted.trigger`(MF-18,1.149)**:checkpoint 内容类别投影 + 压缩触发因(turn-boundary/context-guard 等),supervisor inbox 分诊用。
|
|
294
|
-
- **WorkflowRun monitor(MF-W,1.147→1.150)**:`/workflows` monitor header / 活动 arg(经 arg-summary 脱敏)/ `deriveAgentDisplayStatus`(把内部态映射成壳显示态);SSE verbatim 转发同 §14B per-agent 投影。
|
|
295
|
-
- **🔴 MF-Fleet = service 进程内 live 聚合(replica-local + ephemeral)**:core **只产 fact/signal**(透传 `parentToolCallId` 等),**不建 durable 父系血缘**——service 确认 in-process 聚合够用(YAGNI + design/99 §0)。你侧据 core 的 fact/signal 在副本内做 fleet 视图聚合,别期望 core 给跨副本 durable 父子关系。
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
*活文档。最后核实 **2026-06-27**(seam 契约不依赖具体 HEAD;core `1.150.0`/tag `v1.150.0`,service `^1.150.0`)。**session-sync + workflow-parity seam 重验(§14)**:`grep -n 'workflowJournalStore\|onWorkflowAgentSpawn\|addWorktree\|pruneWorktrees\|importEntries\|importManifest\|putBlob\|StreamingImportValidator\|untrustedEgressForHuman' src/index.ts`、`sed -n '1,80p' src/core/workflow-journal-store.ts`(scope-keyed OVERWRITE 语义)、`head -40 CHANGELOG.md`(1.144/1.145 段)。**sema-shell backlog seam 重验**:`grep -n 'FileSnapshotStore\|suggestNextPrompts\|resumeAt\|rewindFiles\|sessionPolicyStore' src/index.ts src/core/types.ts`、`sed -n '1,210p' src/core/file-snapshot-store.ts`(E19 ref impl + trap 修复)、`grep -n 'resume_at\|rewind.restore_failed' docs/SERVICE-INTEGRATION-GUIDE.md`(错误码)、`cat design/99-sovereign-shell-contract.md design/100-prompt-suggestions.md design/101-rewind-files.md`。早期 seam(1.101→1.116)见上文 §11/§12。**sema-shell 数据契约 seam 重验(§15,MF-*)**:`grep -n 'humanReview\|task_progress\|contentKind\|deriveAgentDisplayStatus\|parentToolCallId' src/core/types.ts src/orchestration/workflow-observe.ts`、`sed -n '1,80p' src/core/arg-summary.ts`(共享脱敏边界)、`grep -n 'compacted\|trigger' src/core/checkpoint-store.ts`、`head -40 CHANGELOG.md`(1.146→1.150 段)。**如何重验**:`grep -n 'export' src/index.ts`(seam 导出)、`grep -n 'class PgCheckpointStore' src/stores/pg.ts`、`sed -n '108,130p' src/core/runner/assemble-result.ts`(status/errorCode 契约)、`cat docs/durability-boundary.md`(保证边界)、`grep -n 'riskDescriptor\|plan_review\|pendingSteer\|terminalAt\|budget?' src/core/checkpoint-store.ts src/core/tool-policy.ts src/core/types.ts`(design/80 seam)、`grep -n 'runWorkflow\|WorkflowRunStore\|resolveReasoning\|tightenTaskSpec\|toolInput' src/index.ts src/core/checkpoint-store.ts`(CC-parity seam)、`head -80 CHANGELOG.md`(1.101→1.116 发版记录)。*
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# 子代断流韧性 parity 三件核实档(黑板 [550] 飞轮→core)
|
|
2
|
-
|
|
3
|
-
> 日期 2026-07-10 · 分支 devendor · 证据收集 subagent · CC 锚 = cc-2.1.198 pretty.js(先 88 机制后 198 漂移,本档直接落 198 因这几件 198 有精确坐标)
|
|
4
|
-
> 结论一句话:飞轮的三件里 ② **确已有等价机制且是 CC 逐字端口(飞轮"零命中"是误判——命中在 brain 层不在 subagent 层)**;③ **确已有完整等价(SendMessage + design/122 resume 面,CC `dfe` 逐字端口)**;④ **部分等价,同步路径足够、异步残局粒度有可量化 gap**。**没有一件是"裸抛/挂死/确缺"**。
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## ② 子代 API 断流终局化 —— 判决:✅ 已有等价(CC 逐字端口),飞轮"零命中"系搜错层
|
|
9
|
-
|
|
10
|
-
### CC 锚(198)
|
|
11
|
-
断流终局化不在 subagent/Task 层,而在 **brain 流引擎层**(`queryModelStreaming`,所有 agent 含子代共用):
|
|
12
|
-
|
|
13
|
-
- **话术族构造点** `pretty.js:593291`
|
|
14
|
-
`oa = fs ? Error(rn.length > 0 ? "Stream idle timeout - partial response received" : "Stream idle timeout - no chunks received") : Qe;`
|
|
15
|
-
- **partial 终局化 + CC 逐字警告** `pretty.js:593348-593371`(三层 tier):
|
|
16
|
-
- 有实质内容 → `${Vy}: Response stalled mid-stream. The response above may be incomplete.`(watchdog)/ `Connection closed mid-response. The response above may be incomplete.`(断连);`Vy = "API Error"`(:232621),`synthesized_stop_reason` = tool_use / end_turn(:593343-593346),`tengu_streaming_partial_finalized` 埋点(:593356)
|
|
17
|
-
- 仅思考 → 重试(`retrying streaming ${Mn}/${ao}`,:593301,backoff `100*Kn`,:593339)
|
|
18
|
-
- 零事件 → `Response stalled while thinking… Try again.` server_error(:593370)
|
|
19
|
-
- **话术归类** `pretty.js:232438` `e.message.startsWith("Stream idle timeout") → "api_timeout"`
|
|
20
|
-
- 这些是 **provider 流循环** 的产物;子代(Task)本身不产生这族话术,它只是**消费** brain 已终局化的 partial 结果字符串——所以在 subagent.ts 里 grep "Stream idle timeout" 命中 0 是**预期**,不是缺失。
|
|
21
|
-
|
|
22
|
-
### 我方现状(代码坐标)
|
|
23
|
-
`src/brain/stream-engine.ts`(design/124 mid-stream recovery,`docs/124-midstream-recovery.md`)—— **逐点对齐 CC 三 tier**:
|
|
24
|
-
- **idle/first-token watchdog** `stream-engine.ts:281`(idle timer)/`:266`(first-token)→ `:410` `stream idle timeout after ${config.idleTimeoutMs}ms`、`:407` first-token timeout(我方话术=CC 的 lower-case 变体,归类见下)
|
|
25
|
-
- **Tier A(有实质内容/已完成 tool call)→ partial 终局化** `:426-437`:`midstreamWarning = "Response stalled mid-stream. The response above may be incomplete."`(`:434`,**与 CC 593367 逐字同**)/ `"Connection closed mid-response. The response above may be incomplete."`(`:435`,**与 CC 593368 逐字同**);`msg.partialFinalized = true`(`:323`)
|
|
26
|
-
- **Tier B(仅思考)→ seal + 整轮重试** `:451-465`(budget ≤2,backoff `100*n`——**与 CC 593339 同参数**)
|
|
27
|
-
- **Tier C(零事件/悬空 tool call)→ 复用 connect 重试预算** `:467-477`
|
|
28
|
-
- **in-band overload 帧(529/overloaded)→ 降 tier A** `:353` `"API overloaded mid-response. The response above may be incomplete."`(CC 2.1.199 rebaseline)
|
|
29
|
-
- **归类**:`extractErrorCode`/`classifyHttp`(brain/errors.ts)把 timeout→`network`+"timeout" 串;子代侧 `classifySubagentError`(subagent.ts:195)再折成 `error_kind: timeout`(`:208`)
|
|
30
|
-
|
|
31
|
-
### 断流最终以什么形态到父代
|
|
32
|
-
**不是裸抛,不是挂死** —— 三段接力:
|
|
33
|
-
1. brain 层把 partial **终局化为正常 AssistantMessage**(`partialFinalized:true` + 警告文本进 content,`stream-engine.ts:320-331` facade 盖章),`runStreamingBrain` **永不 throw**(`:130` "never throws — errors pushed as error events")
|
|
34
|
-
2. agent-loop 层给自主子代补 continue nudge(`agent-loop.ts:925-937` `midstream_partial_recovery`,bounded ≤3)——因为子代没有真人看"may be incomplete"再追问,这是 CC 缺的一条 **正向增益**
|
|
35
|
-
3. assemble-result 把它组装成 `TaskResult`(`assemble-result.ts:337` stopReason error→lift `[code]`;或正常 completed 带 partialFinalized 文本),子代工具 **把整份 result 作为工具结果字符串交回父代**(`subagent.ts:1893-1922`:`status/error_kind/stats/result:` fenced),父代据 `error_kind`(rate_limit/overloaded/timeout/network/logic)+`retryable` 决定续命(`subagent.ts:195-214`,**CC 2.1.201 parity**)
|
|
36
|
-
|
|
37
|
-
### 判决 & gap
|
|
38
|
-
**✅ 已有等价,且是 CC 逐字端口**。已构成飞轮说的"终局化为结果字符串交回父代 + 父代据此续命"。errorKind 契约(1.214.0 提到的)= `classifySubagentError` 已落。**唯一 cosmetic delta**:我方 tier-A 警告 **丢了 `API Error: ` 前缀**(CC `Vy` = "API Error");我方 idle 串是 `stream idle timeout after Nms`(lower-case)而非 CC 的 `Stream idle timeout - partial response received`——但这两处都**只进日志/internal error message,不是模型可见的终局化文本**(模型看到的是 tier-A 那条逐字对齐的 "Response stalled/Connection closed" 警告)。若要 100% 字节对齐前缀 = **S(小)**,纯字符串,几乎无行为价值。
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## ③ SendMessage 死代复活 —— 判决:✅ 已有完整等价(CC `dfe` 逐字端口)
|
|
43
|
-
|
|
44
|
-
### CC 锚(198)
|
|
45
|
-
- **stopped→resumed 路径** `pretty.js:465332-465353`(`case "agent-stopped"`):调 `dfe({agentId, prompt, promptOrigin, toolUseContext, …})`= resumeAgentBackground,返回
|
|
46
|
-
`Agent "${a.agentName}" was stopped (${a.status}); resumed it in the background with your message. You'll be notified when it finishes. Output: ${d.outputFile}`(:465353)
|
|
47
|
-
- **stopped-by-user 拒复活** `:465325-465330`(`"…was stopped by the user and was not resumed. Treat its work as cancelled…"`)
|
|
48
|
-
- **同步变体** `:465350` `resumed it with your message and ran to completion. Result:\n\n${d.finalText}`
|
|
49
|
-
- 复活 = **同 agentId 带全上下文续跑**(`dfe` 内部;prompt 作为新 user turn)
|
|
50
|
-
|
|
51
|
-
### 我方现状(代码坐标)
|
|
52
|
-
`src/agents/subagent.ts` —— **design/122 D2 resume 面 + SendMessage 工具**,注释明写 "CC `dfe` resumeAgentBackground parity"(`:244`):
|
|
53
|
-
- **SendMessage 工具** `createSendMessageTool` `:1968`(`SEND_MESSAGE_TOOL_NAME = "SendMessage"` `:1934`,CC schema `{to, summary(maxLength:200), message}` `:1978-1984`,cc-probe-198 对齐)
|
|
54
|
-
- **复活执行** `makeSubagentResume` `:532-691`:冻结 spawn 快照 tighten-only(`:609`)+ `requireExistingSession`(`:614`)→ **同 session 加一个 fenced follow-up user turn,从全上下文续跑**(`makeResumePrompt` `:485` "Your previous conversation above is your context — continue from it; do not start over")
|
|
55
|
-
- **成功文案** `:2054-2056` `Message sent — agent ${to} resumed in the background with its prior context intact (correlation marker [${marker}])`(**语义等价 CC 465353**)
|
|
56
|
-
- **stopped-by-user 拒复活** `:2018-2026`(S5 killed → `"…was stopped${by} — a stopped agent is not resumable. Launch a new agent…"`,**等价 CC 465325**)
|
|
57
|
-
- **会话持久化**:retain 账本(`SubagentRetainLedger` `:303`,`retainSubagentSessions` opt-in)按 session id 跨轮存活(session-scoped `:436`),cap=8(`:258`)、TTL 30min(`:260`)、并发/eviction/parent-terminal 全护栏
|
|
58
|
-
- **design/45/49 durable suspend/resume 覆盖子代**:子代 durable-pause 有 guard(`isDurablePause` `:1862`,audit B-6,注"unreachable today: durableApproval 未 forward 给子代"——即 durable checkpoint 面**故意不对子代开**,复活走的是 retain-ledger resume 而非 durable checkpoint,这是设计选择不是缺口)
|
|
59
|
-
- **SendMessage 是 core 面**:工具在 core(subagent.ts)定义,harness 只是 mount。
|
|
60
|
-
|
|
61
|
-
### 判决 & gap
|
|
62
|
-
**✅ 已有完整等价**。CC `dfe` 的三条分支(bg 复活 / 同步复活 / stopped-by-user 拒绝)我方全覆盖。**唯一 posture 差**:CC 复活默认可**同步等到完成**(`awaitCompletion` `:465342`,受 `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` 控);我方 resume **永远异步**(`:245` "ALWAYS ASYNC…completion announced ONLY through deployment-level background-notify sink")——这是**有意的租户隔离决策**(r1-M5:不走 parent-model 通知 lane),非缺失。若要补同步 await 变体 = **M(中)**,但飞轮没提这条,**不建议排**。
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## ④ 子代残局可观测 —— 判决:🟡 部分等价(同步足够,异步残局粒度有 gap)
|
|
67
|
-
|
|
68
|
-
### CC 锚(198)
|
|
69
|
-
- **journal.jsonl 全返回值** `pretty.js:340215` `Per-agent results: ${p}/journal.jsonl — one {"type":"result",...} line per completed agent with its full return value`
|
|
70
|
-
- **停止残局** = `outputFile`(`:465353`)+ `finalText`(`:465350`);workflow 面 `:448159` "Read <transcriptDir>/journal.jsonl — it records each agent's actual return value"
|
|
71
|
-
- **完成通知** `tengu_agent_tool_completed`(`:408615`)/`subagent_completed`(`:408630`)
|
|
72
|
-
- CC 的"精确残局"= 父代可 Read 子代的 `agent-<id>.jsonl` / journal 拿到**逐步 transcript**(停在哪个文件哪一步)
|
|
73
|
-
|
|
74
|
-
### 我方现状(代码坐标)
|
|
75
|
-
- **同步子代**:父代拿到**完整 report** —— `subagent.ts:1893-1922`:`[Sub-agent report]` + `status` + `blocked_reason` + `error` + `error_kind(retryable)` + `stats: turns=N tokens=N` + fenced `result:`(全 final text)+ "Verify this result before concluding"。**这已是 final text + 状态 + 诊断三合一**。
|
|
76
|
-
- **异步子代**:完成 fire task-notification,`result: child.result.slice(0, 2_000/4_000)`(`:1370/:1395/:1684/:1716`)+ status(completed/killed/failed)+ usage;停止归因 `getStopAttribution`(`:2021`,谁 stop 的)
|
|
77
|
-
- **进度可观测**:design/129-B `BackgroundChildEvent` tick 流(`:1624-1634` `task_progress` → sink,带 usage/name),父代/deployment 能看子代**逐 turn 推进**
|
|
78
|
-
- **durable-pause 残局**:`:1866-1872` 报 `unexpected durable pause (${status}, checkpoint ${token})`
|
|
79
|
-
|
|
80
|
-
### 判决 & gap
|
|
81
|
-
**🟡 部分等价**:
|
|
82
|
-
- 同步路径:**已有等价甚至更结构化**(status+error_kind+stats+fenced result,机器可读)。
|
|
83
|
-
- 异步路径:父代拿到的是 **final text(截断 2-4K)+ 终态 + usage + tick 进度**,**不是** CC 那种"逐步 jsonl transcript / 停在哪个文件哪一行"的**精确逐步残局**。gap = 我方无"子代 per-step transcript 回读"面(等价 CC 的 `agent-<id>.jsonl` Read)。
|
|
84
|
-
- **是否真差距**:对**父代 model 决策**够用(它要的是"成没成/剩什么/可不可 retry",这些全有);"停在哪个文件哪一步"的逐步取证更多是 **operator/debug 面**,CC 也是靠 Read journal 文件(harness/文件面)而非 model 上下文注入拿的。core 侧 transcript 已在 session store(可回读),缺的是把它**暴露成 model 可见的残局摘要工具**。
|
|
85
|
-
- **最小闭环**:一个 `AgentTranscript(to)` / 在 report 末尾附"last N steps 摘要(文件/工具/最后动作)"= **S~M**。**优先级低**(飞轮把 ② 排最高,④ 是 nice-to-have)。
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## 回帖草稿(→ [550] 飞轮,横向团队,结论式)
|
|
90
|
-
|
|
91
|
-
> **re [550] 子代断流韧性 parity 三件 —— core 侧核实完毕,逐条结论(CC 198 锚已核)**
|
|
92
|
-
>
|
|
93
|
-
> **② 子代 API 断流终局化:证伪"零命中/裸抛/挂死",✅ 已是 CC 逐字端口。** 你们在 subagent dist grep 命中 0 是**搜错层**——终局化不在 Task 层,在 **brain 流引擎**(CC `queryModelStreaming` pretty.js:593291/593348-593371,所有 agent 共用)。我方对应 `src/brain/stream-engine.ts`(design/124):tier-A partial 终局化警告 `"Response stalled mid-stream. The response above may be incomplete."` / `"Connection closed mid-response…"` **与 CC 593367-593368 逐字同**,`partialFinalized:true`,子代把整份 result **作为工具结果字符串交回父代**(subagent.ts:1893-1922),父代据 `error_kind(rate_limit/overloaded/timeout/network/logic)+retryable`(CC 2.1.201 parity,subagent.ts:195)续命。`runStreamingBrain` 永不 throw。**唯一 delta = cosmetic**:tier-A 警告丢了 `API Error:` 前缀、idle 内部串是 lower-case(都只进日志/internal error,非模型可见文本)。**字节对齐 = S,几乎无行为价值**。**结论:此件无需排期,已达标;若坚持前缀对齐可捎带一个 S。**
|
|
94
|
-
>
|
|
95
|
-
> **③ SendMessage 死代复活:✅ 已有完整等价(CC `dfe` 端口)。** `createSendMessageTool`(subagent.ts:1968,schema `{to,summary,message}` cc-probe-198 对齐)走 design/122 `makeSubagentResume`:同 session + fenced follow-up + `requireExistingSession`,**全上下文续跑**;成功文案 "resumed in the background with its prior context intact"(语义等价 CC 465353);stopped-by-user 拒复活(S5 killed,等价 CC 465325)。retain 账本(cap8/TTL30min/session-scoped 跨轮)。**唯一 posture 差**:我方 resume 恒异步(有意租户隔离,r1-M5),CC 有同步 await 变体——**不建议补,你们没提这条**。**结论:达标,无需排期。**
|
|
96
|
-
>
|
|
97
|
-
> **④ 子代残局可观测:🟡 部分,同步够、异步有粒度 gap。** 同步子代父代拿全 report(status+error_kind+stats+fenced result,比 CC 更结构化);异步拿 final text(截 2-4K)+终态+usage+design/129-B tick 进度+stop 归因。**gap = 无"子代逐步 jsonl transcript 回读"面**(CC 的 `agent-<id>.jsonl`/journal Read),但那是 operator/debug 面(CC 也靠 Read 文件拿,非 model 注入);core transcript 已在 session store 可回读,缺的是暴露成 model 可见残局摘要工具。**最小闭环 = `AgentTranscript(to)` 或 report 末尾附 last-N-step 摘要,S~M,优先级低。**
|
|
98
|
-
>
|
|
99
|
-
> **排期建议**:② **无需 core 改动**(已达标,飞轮把它排最高但实际是误判——除非要 cosmetic 前缀对齐=S);③ **无需改动**;④ **可选 S~M**,不阻塞。**三件里没有一件是"确缺/裸抛/挂死"**——core 的断流韧性已 CC-parity,请飞轮据 brain 层(stream-engine.ts)而非 subagent 层复核 dist。
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### 锚坐标速查表
|
|
104
|
-
|
|
105
|
-
| 件 | CC 198 锚(pretty.js:行) | 我方锚(src:行) |
|
|
106
|
-
|---|---|---|
|
|
107
|
-
| ② 话术族 | 593291(构造)/232438(归类) | brain/stream-engine.ts:410 |
|
|
108
|
-
| ② partial 终局化 | 593348-593371(tier)/232621(`Vy`) | brain/stream-engine.ts:426-437 |
|
|
109
|
-
| ② 逐字警告 | 593367-593368 | brain/stream-engine.ts:434-435 |
|
|
110
|
-
| ② error_kind | (CC 2.1.201) | agents/subagent.ts:195-214 |
|
|
111
|
-
| ② 交回父代 | — | agents/subagent.ts:1893-1922 |
|
|
112
|
-
| ② continue nudge(增益) | — | engine/loop/agent-loop.ts:925-937 |
|
|
113
|
-
| ③ resumed it in the background | 465353(`dfe`) | agents/subagent.ts:2054-2056 |
|
|
114
|
-
| ③ stopped-by-user 拒复活 | 465325-465330 | agents/subagent.ts:2018-2026 |
|
|
115
|
-
| ③ resume 执行 | 465332-465350(`dfe`) | agents/subagent.ts:532-691 / 1968 |
|
|
116
|
-
| ④ journal 全返回值 | 340215 / 448159 | agents/subagent.ts:1893-1922(同步) |
|
|
117
|
-
| ④ 停止残局 outputFile/finalText | 465350/465353 | agents/subagent.ts:1370/1395(异步 slice) |
|
|
118
|
-
| ④ 进度 tick | 408615/408630 | agents/subagent.ts:1624-1634(design/129-B) |
|