优势、代价与设计取舍
哪些复杂度换来了真正的可组合性,哪些仍在偿债
结论:只有把边界变成可执行约束,复杂度才物有所值
DeepSeek Harness 把复杂度投入显式组合、生命周期所有权、持久事实、提交点、分层策略和可独立替换的产品面。只有当这些复杂度产生了可检查的性质时,它们才成立:候选状态在有效之前不会发布,不可逆副作用在执行前已有持久意图,替换会撤销自己拥有的贡献,replay 能重新推导出相同的模型可见历史。如果 operator 需要理解额外一层,却没有换来更强的权威归属、失败归因、恢复边界或互操作 seam,同一套机制就会变成债务。
已验证章节不支持“模块越多越好”之类单一结论;它们描述的是一组相互耦合的选择。本章用四个问题评价每项选择:它让什么成为可能,它持续制造什么代价,它的前提被破坏时如何失败,以及在什么运行条件下这笔交换合理。
1. 决策矩阵:每一层买来了什么,又要求什么持续成立
| 取舍 | 优势 | 持续代价 | 失败方式 | 适用条件 |
|---|---|---|---|---|
| 由配置编程的插件树 | 产品、provider 与 session capability 可以变化,而不必 fork 一个中央应用 | 有效拓扑分散在 patch、service dependency、scope 和 module resolution 中 | 错误 identity、缺失 service 或不完整 disposer 让替换只完成一半,或令 activation 失败 | 存在多个产品 profile、需要 live replacement、且由 operator 控制的部署 |
| 小 Loop 加事件化策略 | 同一 Turn/Step 协议承载 prompt、provider、retry、planning 与 tool policy | 行为必须沿有序 waterfall 与 scoped registration 追踪 | listener 使用错误 event mode,或越过 commit boundary 后才突变,导致重建行为与 live 行为分叉 | 许多独立所有者的策略必须共享一条执行路径 |
| append-only 事实加 projection | resume、replay、history 与多个 client 可从同一持久事实流推导 | 更多 event、显式 provenance、checkpoint、repair 与兼容工作 | cache 或 UI window 被误当权威,或副作用发生在其持久前缀之前 | 重视审计性和 crash recovery 的长生命周期 session |
| 专门化 capability contract | 每个 surface 都能把稳定性放在真正拥有语义的层 | 外观相近的功能具有不同 lifetime、authority 与 replay 规则 | 把 “planning”“tool” 或 “memory” 这样的共同标签误当成共同保证 | 同时集成本地、远端、模型面向与用户面向的异构 capability |
| 事务化 tool 与有界重叠 | 安全的外部工作可重叠,policy 和持久 commit 仍保持顺序 | 队首阻塞、分类 metadata、两种 scheduler scope 与更多 cancellation 状态 | tool 夸大并发安全性、定义在分类后变化,或局部 cap 被误认为全局准入控制 | 外部 I/O 占主导、且权威 history 必须确定的 tool batch |
| 分层 approval、guard 与文件策略 | one-shot escalation 和单调 veto 约束选定 mutation,而不硬编码单一 UI | operator 必须区分 visibility、standing policy、approval、guard、runner 与 filesystem observation | 把便利 preset 当成执行边界,或把 file-effect confinement 描述成通用隔离 | 显式选择 capability、审阅 escalation 的可信本地运行 |
| 把 compaction 作为有日志的 Surface replacement | 在不删除 canonical event history 的前提下降低 context 成本 | 额外 token accounting、一次 summarizer 调用、合法 cut 规则与可能的语义损失 | 绕过 validation owner 后非法 cut 或陈旧 summary 进入 commit、close 失败留下可检测锁,或 summary 被误当成持久知识 | 同时要求有界模型 context 与精确审计 history 的长对话 |
| 分层 recovery protocol | retry、cancellation、crash repair 与 DeepSeek provider 的 last-good configuration 显式保留不确定性 | 更多 barrier、错误词汇、drain 阶段与副作用前延迟 | 未知外部结果被改写成成功,或不合作的 body 在 cancellation 后继续存活 | 错误确定性比延迟完成更危险的有状态执行 |
| 可组合 delegation 与 workflow | one-shot、continuable、fork、script 和 iterative 工作可复用 Agent/Session primitive | 多种 ownership、settlement、result 与 persistence model 并存 | 把 delegation 误当成全局 scheduler、持久 job queue、共享 team state 或自动 reducer | 任务可分解、parent 能显式聚合、child budget 有界的工作 |
| typed API 与第二棵浏览器插件树 | carrier、business object、UI slot 和 React binding 可在独立 seam 上演进 | reconnect generation、lazy residency、gap repair、scope pruning 与 client boot 都必须一致 | 把 transport reachability 当成 authentication,或一个卡死 dependency 阻止强一致的整页 boot | 与 Host 一同发布、由可 replay session 支撑的 first-party 产品面 |
| 多种 observability plane | 持久事实、运维日志、projection、query 与 opt-in telemetry 分别回答不同问题 | 不存在单一通用 trace;privacy、retention 与 correlation 必须逐 plane 决定 | 用局部 UI window 得出全 session 结论,或假设上传内容会自动 redact | 愿意标注 evidence scope,并主动配置 disclosure 的部署 |
只有当一个抽象的 owner、commit point、failure vocabulary 与 replacement boundary 都能被明确指出时,才把它计为资产。package 数量与 interface 数量本身不是收益。
2. 插件组合:一种变化语言,也是一块更大的运维表面
有效树由有序的 bundle、profile、home、命令行、launcher 与 telemetry layer 组合;决定替换的是稳定 row identity,而不是文本距离。Boot 先准备 Host、挂载树、等待 Loader settle、审计 activation,并在失败时 dispose partial root。PROFILE-COMPOSEBOOT-TRANSACTION
live update 会重新读取可变 layer,并在防止引用污染的同时替换 generation。scope layer 让 registration context 同时决定谁能看到贡献,以及哪个 fiber 必须撤销它。PROFILE-LIVEDESIGN-SCOPED-LAYERS
优势是真正的部署级替换,而不是包裹固定产品的编译期 interface。代价是配置本身成为可执行架构。当 profile 与 session capability 确实会变化时,这笔投入合理;如果组成永远固定,而 operator 又无法查看 effective tree 或诊断 activation/disposal,它就过重。
3. 稳定 Loop:策略模块化把复杂度转移到了顺序语义
默认 Loop 拥有 Turn/Step boundary、claim 时机、request dispatch、tool continuation、cancellation 与最终 closure。它的 runtime invariant 会在带标记的 request 离开进程之前,独立重建 messages 与 request header。LOOP-TURN-STATELOOP-REQUEST-INVARIANT
prompt assembly 合并 scope、variable、tool、section、context 与最终 waterfall,随后重新施加 completeness 和 suppression 约束。provider route 使用 all-or-nothing registry,而 adapter selection 与 iteration failure 会成为终止协议 chunk,不是任意 throw shape。PROMPT-ASSEMBLY-PIPELINELLM-ADAPTER-REGISTRYLLM-FAILURE-BOUNDARY
小 Loop 减少的是互相竞争的 orchestration path,不是总语义表面。正确性迁移到了 event mode、listener order、scope 以及“在 next 之前还是之后”的 contract。策略所有者需要独立发布和 teardown 时,这种设计有价值;如果没有 generated map 或 composition test 展示哪些 listener 能改变一次 request,它就很难运维。
4. 持久事实与派生状态:replayability 要用持续记账来购买
Session append 会 snapshot 并 freeze candidate、验证其 Surface effect、同步运行 precommit dispatch,并把插入 log 视为 commit point;之后的 observer failure 被隔离。projection checkpoint 明确声明自己只是 fold shortcut,不是 authority。SESSION-APPEND-COMMITPROJ-AUTHORITY-LAYERS
checkpoint policy 在每个 agent/pre-step flush 前一个 Step,并包装 llm/stream,使完整 request prefix 在下游 model-stream construction 与 adapter dispatch 前落盘;每个 top-level tool body 前也会 flush。projection-cache restore 使用 watermark;identity 或范围声明不安全时回退到 full read。LOG-CHECKPOINT-POLICYPROJ-CACHE-LADDER
架构买来了可解释的模型 history、cold resume 与多个派生 view,也把每次模型可见 mutation 都变成兼容工作:event vocabulary、provenance、cut 语义、checkpoint 与 client stitching 必须共同演进。决定性的失败方式是权威倒置——让更快的 cache、projection 或 resident object 覆盖它本应概括的持久事实。
5. 专门化 contract:拒绝通用 facade,才能保留真实含义
没有 open Turn 时,Plan selection 立即提交;open Turn 期间,它等待下一次 accepted in-turn pre-Step。Goal mutation 检查精确 live reference,同步把 goal/change 提交到 log、同步 cache,之后才发布 goal/changed。Todo 拥有更窄的 list invariant。它们都使用 Session event,却不共享同一种 lifetime、authority 或 driver。PLANSTATE-PLAN-BOUNDARYPLANSTATE-GOAL-COMMITPLANSTATE-TODO-INVARIANT
同一模式也存在于 extension surface。MCP 只桥接选定的外部 tool 语义,并明确记录有损或 provider-owned boundary;native、code 与 both mode 改变模型呈现,却没有创造三个等价 execution engine。CAP-MCP-LIMITSCODEMODE-MODES
保留不同 contract,能防止 lowest-common-denominator abstraction 掩盖 authority 与 durability。代价是认知负担:用户必须理解为什么两个相似对象不会以同样方式 resume、authorize、schedule 或呈现 result。差异会影响安全或重建时,这笔成本合理;如果差异只剩名称与 package boundary,它就是债务。
6. Tool 执行与并行:让 body 重叠,让权威串行
ToolRuntime 是一条有序事务:从 pre-policy、monotonic guard、around execution、post-policy,一直到 normalization、finalization 与 immutable result。TOOL-PIPELINELoop 按 model order 分组,把 exclusive call 当成完整 barrier,并运行 rolling pool;body 可以重叠,finalization 与持久 commit 只能沿连续的 model-order prefix 推进。PARALLEL-GROUPINGPARALLEL-ROLLING-POOL
每个已提交的 tool/result 都回指对应已启动 call 的精确 sequence;如果 scheduler 自身失败,已启动 call 也可能没有 result。PARALLEL-DURABLE-PAIRINGPARALLEL-SCHEDULER-FAILURE live registry replacement 可重新分类未启动 call。PARALLEL-RECLASS-TESTS 源码控制流还暴露了一个独立前提:classification、有序 prepare 与之后的 body dispatch 发生在不同时间点。PARALLEL-GROUPINGPARALLEL-PREPAREPARALLEL-DISPATCH
它优先保证确定的 policy 与 replay,而不是最短 tail latency。较快的后续 result 可能等待较慢的前序 call;一元的“可与任意 sibling 并行”声明也不能表达 resource relationship。它适合大多独立的 I/O-heavy call;mutating tool、共享 quota 与 definition hot-swap 需要保守分类,或在这个局部 scheduler 之外增加 admission control。
7. Authorization 与 sandbox:只有精确描述,分层 veto 才有价值
guard 只能 deny 或 abstain,不能 allow,因此后续策略不能通过 guard layer 反转先前 veto。approval request 收敛到封闭的 one-shot outcome vocabulary,不会变成可复用 ambient grant。APPROVAL-GUARD-CONTRACTAPPROVAL-OUTCOMES
sandbox contract 明确只治理 file effect,不治理 network、process、syscall、device 或 credential isolation。filesystem observation 保护特定 tool read 的 freshness,但它不会跨 resume 存活,不观察直接 filesystem service read,也不证明完整文件已被阅读。SANDBOX-DOC-BOUNDARYSANDBOX-OBSERVATION-LIMITS
优势是针对选定 mutation path 的可组合 least authority。失败方式则是语义夸大:不说明哪些内容仍受信任,就把 preset 称为“安全”,或把文件策略称为“sandbox”。该设计适合可信 operator 治理模型发起的 action;它不是对所有 code path、plugin、process 或 external service 的隔离证明。
8. Compaction 与 memory:降低模型成本,但不改写 canonical history
range selector 会保留已计价 tail,并且只移动到 tool-pair-balanced cut;head 无法安全压缩时返回空范围。compaction 写入 start lock、概括 snapshot、重新检查稳定性,然后提交严格更小的 replacement;若不能提交,则尝试一次 error close,而 close 自身失败会留下可检测的 unmatched start。COMPACT-RANGECOMPACT-TRANSACTIONCOMPACT-COMMIT
token-meter shadow pricing 有意保持有界;缺少历史 context 时可以降级为零。外部 memory 示例是 opt-in integration,其 provider 自己拥有 storage、model、embedding 与 recall semantics。COMPACT-SHADOW-PRICEMEMORY-MCP-BOUNDARY
把 replacement event 放在原始 log 旁边,清楚分离了 canonical history 与模型当前 Surface。代价是另一次模型调用,以及一个只保证结构有效、不保证语义完备的有损 artifact。它适合需要保留审计的长 session;它不会把 summary 变成已验证 memory,也不保证外部 memory provider 保留相同 provenance。
9. Recovery:保留不确定性,而不是制造成功
request header 与必要 context 会在 frozen provider request 返回前 append。crash repair 区分从未启动的 tool 与结果未知的 tool,并在不虚构成功 effect 的前提下关闭不完整协议 bracket。FAILURE-CHECKPOINT-REQUEST-PREFIXFAILURE-CRASH-REPAIR
retry 会在等待前记录 decision,并在 disposal 时 drain active recovery。tool-batch abort 停止 replenishment、等待已启动工作、按顺序提交可归因 outcome,并且只为已知未启动的 call 合成 result。FAILURE-RETRY-EXECUTORFAILURE-TOOL-DRAIN
完整 candidate 无效时,DeepSeek provider configuration 会阻止首次 registration;后续 live snapshot 无效时则保留完整 last-good generation,而不是混用不同 generation 的字段。FAILURE-CONFIG-RESOLUTION
收益是诚实收敛:replay 能区分 failed、cancelled、not started 与 outcome unknown。代价是延迟,以及把不确定性继续交给上层 compensation 或 idempotency 的义务。只要 external effect 重要,这种设计就有价值;对可丢弃的 stateless 工作,同样深的协议可能比重启整个 operation 更昂贵。
10. Orchestration:可复用 child lifecycle 不等于完整 team runtime
continuable child 只有在 identity、descriptor、policy、seed、child materialization 与 inbox acceptance 全部成功后才发布。每个 one-shot run 或 continuable residency epoch 都用独立 run identity 发出成对 lifecycle edge,而 cold inspection 使用有界读取并发。MULTIAGENT-CONTINUABLE-STARTMULTIAGENT-LIFECYCLEMULTIAGENT-LIST-CONCURRENCY
Workflow 在发布前验证,让 terminal event 与 result settlement 成对,并分别暴露 concurrent child、total child、combinator size、synchronous slice 与 disposal grace ceiling。Ralph 随后在 TypeScript boundary 再验证一次 terminal claim。WORKFLOW-LIFECYCLEWORKFLOW-CAPSRALPH-DOUBLE-VALIDATION
系统提供了有明确 ownership 与 settlement 的可信 delegation building block,同时有意把 aggregation policy 留给 parent,把 capacity 留给多个局部 owner。当 task 可分解、caller 能定义成功时,它很合适;如果期待的是隐式 global scheduler、持久 distributed queue、共享 mutable team memory 或自动 consensus,它就不合适。
11. API 与 Web UI:独立 seam 改善替换,也成倍增加一致性工作
browser RPC layer 先验证外层 message envelope,再由每个 method 验证 payload。它的 Host/Origin fence 会拒绝不匹配的 browser request,但明确不声称提供 user authentication。API-RPC-SCHEMASAPI-TRUST-FENCE
browser manifest 分离 module delivery 与 plugin activation。Connection 使用 generation 与 shared backoff,但无界 describe call 可能阻塞收敛;Session repair 会 buffer forward gap 并重新拉取 history,而不是接纳不连续序列。Slot disposal 则递归撤销 entry 声明的 subtree。WEBUI-MANIFEST-CONTRACTWEBUI-CONNECTION-GENERATIONWEBUI-SESSION-GAP-REPAIRWEBUI-SLOT-CASCADE
分离 carrier、business object、UI composition 与 React binding,避免 component tree 变成 runtime。持续代价是 Host fact、resident client object、projection 与 render scope 之间的 state reconciliation。它适合 first-party 可扩展产品面;一个不需要 live plugin replacement 或 session replay 的小型单页 client 不需要同样深的协议。
12. Observability:更丰富的 evidence 同时消耗 disclosure 与解释预算
telemetry 默认 disabled;full capture 与 feedback-triggered release 有不同 admission rule。已记录的 upload surface 包括 prompt、message、tool、file/command content、compaction、feedback 与 working-directory context,且没有内建 redaction rule。OBS-TELEMETRY-MODESOBS-PRIVACY-BOUNDARY
current-session query 会有意把一种 search range 截到最新 Step boundary 之前,并重新授权结果。browser 只维护一个连续的 loaded window,遇到不连续时 drop 或 repair,而不声称自己持有整个 log。OBS-QUERY-CURRENT-BOUNDARYOBS-HISTORY-CLIENT
该设计提供多个精确 view,而不是一个误导性的“trace”。只有当每个答案都标出自己的 plane 与 cut 时,它才支持诊断。失败方式包括 privacy overreach 与 evidence overreach:上传超出意图的内容,或从有界 projection 推导全 session 结论。operator 能治理 retention 与 disclosure 时才使用更丰富的 plane;否则应保持收集范围窄且本地。
13. 交互效应:这些选择不能被彼此独立地评价
| 组合 | 正向作用 | 叠加风险 |
|---|---|---|
| plugin effect × scoped registry | hot replacement 与 per-session composition 能撤销精确贡献 | 一个 ownership 错误的 listener 或 provider 泄漏进新 generation |
| durable log × checkpoint policy | replay 在 model 与 top-level tool effect 之前拥有 intent prefix | 额外 flush boundary 增加延迟,却仍无法证明 external outcome |
| parallel tool × ordered commit | external latency 可以重叠而不改变 model-visible order | 队首阻塞与隐藏的 shared-resource race 被转移给 metadata 和 provider |
| compaction × immutable history | context 缩小,audit history 仍然可用 | consumer 可能把有损 Surface replacement 误解成删除或知识 |
| delegation × Session persistence | continuable child 能跨 residency change 存活 | one-shot provider 与 Job 仍有不同 durability/result contract |
| rich log × telemetry | failure 可从 request 关联到 tool 与产品 projection | 同样的 fidelity 会放大 retention 与 disclosure 影响 |
该架构的价值来自对齐的组合,而非孤立机制:plugin 需要 effect ownership,replay 需要 commit point,并发需要 ordered authority lane,telemetry 需要显式 disclosure。去掉其中一半,往往只剩另一半的成本,而失去它原本要提供的保证。
14. 哪些复杂度已经挣到回报,哪些仍是债务
| 已挣到回报的信号 | 债务信号 |
|---|---|
| 一个具名 authority 与一个可观察 commit point | 两个 mutable copy 靠时序或约定 reconcile |
| replacement 撤销自己发布的精确 resource | reload 依赖 process restart 或泄漏的 global mutation |
| failure 保留 machine-routable uncertainty | 通用 success/error string 擦掉工作是否开始或提交 |
| boundary 验证自己拥有的完整 value | 把 schema visibility、UI filtering 或 documentation 当成 enforcement |
| 局部 limit 标明真实 scope | 把 per-Step 或 per-run pool 宣称成全局 capacity control |
| generated map 与 invariant 暴露分布式语义 | operator 只能在失败后反向推理 listener order 与 configuration closure |
| provider 差异在改变含义时保持显式 | 通用 facade 掩盖不对称 error、usage、durability 或 trust |
DeepSeek Harness 最强的部分,把变化转成带 commit、teardown 与 replay 语义的显式 protocol。最弱的模式不是 modularity 本身,而是没有闭合的 seam:live definition 被读取两次,局部 cap 被误当全局值,局部 policy 被描述得过宽,或 projection 在不带 cut 的情况下被消费。因此最有价值的下一步通常是闭合并测试一个具名 boundary,而不是再在外面增加一个通用 manager。
15. 采用建议:必须把义务与能力一起选择
当部署确实会随 provider 与产品面变化、session 必须 resume 且保持可解释、tool 需要分层 policy 与持久 outcome,并且 operator 有能力维护 configuration closure、lifecycle test、projection repair 和 evidence-scoped diagnostics 时,采用这种架构风格。
当工作短暂且 stateless、provider 和 UI 固定、不需要 hot replacement,并且整个 operation 可以安全重启时,应该选择更小、更直接的架构。如果没有 replacement 或 recovery 需求,却照搬 plugin、event、projection 与 workflow layer,只会保留认知成本,同时丢掉它们存在的理由。
本章验证清单
- 只使用 public catalog 中已经存在、且被已验证第 01–32 章引用的 evidence。
- 没有新增 evidence record;第 31、32 章通过审计后,增加了 sandbox 范围和证明层级的直接对齐引用。
- 区分源码支持的事实、跨章推导与设计评价。
- 对每一项具名取舍都写明优势、持续代价、失败方式与成立条件。
- 让 local scheduler、sandbox、projection、transport 与 telemetry 保证保持在已验证范围内。
- 已在第 31、32 章通过审计后完成第二次对齐。
我的学习体会
内容仅自动保存到当前浏览器,不上传、不进入仓库。你可以导出 Markdown 自行归档。