Skip to content

Commit 230c4e4

Browse files
committed
Integrate current main before planning performance qualification
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
2 parents b29baed + 0a9a3a3 commit 230c4e4

43 files changed

Lines changed: 1955 additions & 1260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/architecture/rfcs/STATUS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ appendix may keep dated history, but no dated log heading may precede it.
3131
| [RFC: Capable Agent Manager and Semantic Work Handoff (v0)](capable-manager-semantic-handoff-v0.md) | Accepted | [Personal Follow-through independent proposal](personal-follow-through-v0.md) | [2 entries](ledger/capable-manager-semantic-handoff-v0/) |
3232
| [RFC: Complete State Recovery and Controlled Reactivation (v0)](complete-state-recovery-v0.md) | Accepted | none | — |
3333
| [RFC: Composable State Machines and Recovery Verification (v0)](composable-state-machines-recovery-verification-v0.md) | Accepted | none | — |
34-
| [RFC: Controller / Executor Sessions and One Governed Work Contract (v0)](controller-executor-unified-contract-v0.md) | Accepted | none | [1 entry](ledger/controller-executor-unified-contract-v0/) |
34+
| [RFC: Controller / Executor Sessions and One Governed Work Contract (v0)](controller-executor-unified-contract-v0.md) | Accepted | none | [2 entries](ledger/controller-executor-unified-contract-v0/) |
3535
| [Explicit Todo continuation: Stage A](cross-session-memory-substrate-v0.md) | Accepted | none | — |
3636
| [RFC: LoopX Desktop Execution Frontends v0](desktop-execution-frontends-v0.md) | Accepted | none | — |
3737
| [RFC: External Evidence Research Capability v0](external-evidence-research-capability-v0.md) | Accepted | none | [3 entries](ledger/external-evidence-research-capability-v0/) |

‎docs/architecture/rfcs/STATUS.zh-CN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
| [RFC:强能力 Agent 管家与语义工作交接(v0)](capable-manager-semantic-handoff-v0.zh-CN.md) | 已接受 | [个人事项持续跟进独立提案](personal-follow-through-v0.zh-CN.md) | [2 条](ledger/capable-manager-semantic-handoff-v0/) |
2929
| [RFC:完整状态恢复与受控重新激活(v0)](complete-state-recovery-v0.zh-CN.md) | 已接受 | 无 | — |
3030
| [RFC:可组合状态机与恢复验证(v0)](composable-state-machines-recovery-verification-v0.zh-CN.md) | 已接受 | 无 | — |
31-
| [RFC:Controller / Executor 会话与统一受治理工作契约(v0)](controller-executor-unified-contract-v0.zh-CN.md) | 已接受 | 无 | [1 条](ledger/controller-executor-unified-contract-v0/) |
31+
| [RFC:Controller / Executor 会话与统一受治理工作契约(v0)](controller-executor-unified-contract-v0.zh-CN.md) | 已接受 | 无 | [2 条](ledger/controller-executor-unified-contract-v0/) |
3232
| [显式 Todo 接续:阶段 A](cross-session-memory-substrate-v0.zh-CN.md) | 已接受 | 无 | — |
3333
| [RFC:LoopX 桌面执行前端 v0](desktop-execution-frontends-v0.zh-CN.md) | 已接受 | 无 | — |
3434
| [RFC:外部证据研究能力 v0](external-evidence-research-capability-v0.zh-CN.md) | 已接受 | 无 | [3 条](ledger/external-evidence-research-capability-v0/) |

‎docs/architecture/rfcs/ledger/controller-executor-unified-contract-v0/2026-10-27-refactor-handoff.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,54 @@ different questions; their proximity is not proof they should be one state.
132132
benefit experiments. Replace real consumers in the delivery slice; preserve
133133
historical decoding and original effect readback across code rollback.
134134

135+
**Source proposal (2026-10-28).** The existing Effect runtime now composes
136+
journal receipt qualification and ordered continuation in the typed Turn owner.
137+
`managed_step.py` sends one complete journal/decision request instead of rebuilding
138+
an execution payload; the driver uses the same route classifier. The registered
139+
ordered contract, historical journal decoder and independent recovery decision
140+
remain. Public Python receipt/budget value objects keep their API, including exact
141+
integer transport. Native File/SQLite retry, saved-result replay and lost-spend
142+
response tests retain the original Turn and one debit. Rule mutations exercise
143+
the actual TS evaluator. This is a single-session source proposal, not C1 cutover,
144+
C4.2/C4.3 adoption, installed qualification or long-horizon benefit. Reconcile
145+
original receipts before rollback; no journal or settlement schema changes.
146+
The same inventory measures 43 maintained Python/TS pairs on the base and 45 on
147+
this proposal: the new controller and host-failure pairs retain the Python API
148+
and native failure producer while sharing TS decisions. The pair budget records
149+
that maintenance cost (43 → 45); generated exclusions and the over-budget
150+
negative check remain. Deleted Python decisions, rather than the pair count,
151+
establish convergence. Added bridge traffic is disclosed without a speedup claim.
152+
153+
Review repair rebases this proposal onto the current shared
154+
`turnEnvelopeRoute` owner and retains `TurnControllerInput` at the Python API.
155+
It does not restore the former route table or Python policy partitions.
156+
Receipt qualification rejects empty legacy lineage values before creating a
157+
validated receipt. Historical Mapping callers retain Python scalar spelling
158+
through the existing route text codec, including `1.0` and `1e-07`; mismatched
159+
signatures still fail. The same public API regressions reproduce six empty
160+
container admissions and two numeric-route refusals at the original proposal
161+
head, and pass after repair. This corrects compatibility; it does not qualify
162+
numeric hashes as canonical producer output or close the remaining C4 work.
163+
164+
A subsequent review reproduced a transport regression with a complete 2,420,000-
165+
character Goal: both Mapping and producer-qualified controller inputs failed
166+
before dispatch, although the existing envelope/plan accepted them. The pure
167+
`turn.controller` operation now reuses the envelope's bounded local snapshot
168+
fallback after a pre-send size rejection, with explicit client/server allowlist
169+
entries. Full facts and the original 2 MiB wire / 64 MiB snapshot bounds remain;
170+
signature rejection, private-file/hash/length checks and ambiguous-response
171+
non-retry behavior are retained. Real transport tests cover both input forms,
172+
small controls, escaped Unicode and the actual snapshot limit. This repairs the
173+
source proposal's large-input path; independent review, installed adoption and
174+
long-horizon cost/benefit remain separate qualification.
175+
176+
Integration with the current ordinary-request caller retains its explicit
177+
`SettlementIdentity` at the public Python boundary. The typed controller reuses
178+
the existing identity decoder to require the exact request subject and effect;
179+
it does not invent Todo lineage or weaken ordered material-settlement checks.
180+
Real File/SQLite original-message execution and replay qualify this source
181+
combination, while formal App adoption and complete outcome cost remain open.
182+
135183
## C4.2 — Thin outer-worker semantic adoption
136184

137185
**Candidate for bounded policy convergence.**

‎docs/architecture/rfcs/ledger/controller-executor-unified-contract-v0/2026-10-27-refactor-handoff.zh-CN.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,38 @@ execution 形状的回执,同时调用 `turn_journal.ts` 检查一致性。`re
104104
等待完整 C1 收益实验。在交付切片中替换真实消费者;代码回退时保留历史解码与原
105105
effect readback。
106106

107+
**源码提案(2026-10-28)。** 既有 Effect runtime 在 typed Turn owner 内组合 journal
108+
回执资格与有序继续判定。`managed_step.py` 一次传入完整 journal/decision,不再重建
109+
execution 载荷;driver 复用同一路由分类器。原注册有序契约、历史 journal decoder 和
110+
独立恢复判定保持。公开 Python 回执/预算值对象保留 API,整数通过精确编码传递。
111+
真实 File/SQLite 重试、已存结果重放和扣额丢响应测试保留原 Turn 与单次扣额;规则
112+
mutation 直接验证实际 TS evaluator。本项仅为单会话源码提案,不代表 C1 切换、
113+
C4.2/C4.3 采用、已安装资格或长程收益。回滚前核对原回执;journal 和结算 schema 不变。
114+
同一 inventory 在 base 测得 43 对独立维护的 Python/TS 模块,本提案为 45 对:新增
115+
controller 与 host-failure 配对保留 Python API 和原生失败 producer,同时共享 TS
116+
决策。配对预算据此记录维护成本(43 → 45);生成排除规则和超预算负例保持。
117+
收敛依据是删除了 Python 决策,不是配对计数;额外 bridge 传输如实披露,不宣称提速。
118+
119+
评审修复将本提案重基到当前共享的 `turnEnvelopeRoute` owner,并保留 Python API 的
120+
`TurnControllerInput`,不恢复旧路由表或 Python 策略分区。回执资格在创建 validated
121+
receipt 前拒绝历史空身份值;历史 Mapping 调用方通过既有 route text codec 保留
122+
Python 标量文本,包括 `1.0` 和 `1e-07`,签名不一致仍拒绝。同一组公开 API 回归在
123+
原提案 head 复现六个空容器误准入和两个数字路由误拒绝,修复后通过。这是兼容修复,
124+
不表示 canonical producer 会生成数字 hash,也不关闭其余 C4 工作。
125+
126+
后续评审用包含 2,420,000 字符完整 Goal 的输入复现传输回归:既有 envelope/plan
127+
可以接受,Mapping 与 producer-qualified 两种 controller 输入却都在派发前失败。
128+
纯 `turn.controller` 操作现于预发送大小拒绝后复用 envelope 的有界本地 snapshot
129+
回退,并显式加入客户端/服务端白名单。完整事实及原 2 MiB wire / 64 MiB snapshot
130+
限制保持;签名拒绝、私有文件/hash/长度校验和响应不确定时不重试的行为保持。
131+
真实传输测试覆盖两种输入、小输入控制、转义 Unicode 和实际 snapshot 上限。
132+
这修复源码提案的大输入路径;独立复审、安装采用和长程完整成本/收益仍分别验收。
133+
134+
与当前普通原始请求调用方整合后,公开 Python 边界保留其显式 `SettlementIdentity`。
135+
typed controller 复用既有 identity decoder,要求请求主体与 effect 精确匹配,
136+
不伪造 Todo lineage,也不弱化有序 material settlement 检查。真实 File/SQLite
137+
原始消息执行与重放验证了该源码组合;正式 App 采用及完整成果成本仍待验收。
138+
107139
## C4.2 — 外层 worker 的薄语义采用
108140

109141
**有界策略收敛候选。** `scripts/external_scheduler_worker.py` 的 `_host_attempt`、
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# C4.3 settlement obligation comparison
2+
3+
- Parent: [controller/executor RFC, C4.3](2026-10-27-refactor-handoff.md#c43--settlement-adapters-over-existing-primitives).
4+
- Baseline: `e19d94ca0`, 2026-10-29. The settlement owners are unchanged at `fb331f45`.
5+
- Status: reading-only comparison. No deletion, runtime, schema, wire or default change.
6+
- Correction: an earlier revision of this entry read the adapter's lack of a
7+
local journal as a lack of recovery on the whole MCP path. That was wrong.
8+
The recovery baseline is corrected below, in both mirrors.
9+
- [Chinese mirror](2026-10-29-c4-3-settlement-obligation-comparison.zh-CN.md).
10+
11+
## Why this entry exists
12+
13+
C4.3 requires comparing `host_adapter_settlement.py`, `turn_driver/host_todo_completion.ts`
14+
and `turn_driver/settlement.py` obligation by obligation *before* deleting a
15+
supposedly duplicated condition/step interpreter. No such comparison was
16+
recorded. This entry supplies it so the next PR can be decided rather than
17+
guessed.
18+
19+
An **obligation** here is a decision or durable effect that must occur exactly
20+
once per transaction, and whose owner must reject, replay or recover it.
21+
22+
## The three owners at this baseline
23+
24+
| Where | Entry | Decision owner | Python role |
25+
| --- | --- | --- | --- |
26+
| A — Host Todo completion | `settle_host_todo_completion` | `host_todo_completion.ts` via `turn.host_todo_completion.evaluate` | Materializes authored vision JSON, decodes the emitted plan, runs CLI steps, evaluates `continue_when` |
27+
| B — Turn settlement | `execute_turn_driver_settlement` | `settlement.ts` via `turn.settlement.reduce` | Invokes provider effects, writes checkpoints, returns observations |
28+
| C — MCP host facade | `goal_mode_mcp.py` | A end-to-end | Loads A's request from the host |
29+
30+
## Obligation matrix
31+
32+
| Obligation | A decides | B decides | Equivalent? |
33+
| --- | --- | --- | --- |
34+
| Transaction identity | TS `turnInstanceId` / `expectedIdentity`, surfaced as `SettlementIdentity` | TS identity plus per-step receipt matching | Same vocabulary, different derivation inputs |
35+
| Request validation | TS `decodeRequest`, `TODO_ID_PATTERN` | TS decode plus `receipt_missing` / `identity_mismatch` | Not equivalent: A validates shape, B validates committed receipts |
36+
| Pre-write admission | `guard` step runs the real `quota should-run` CLI with the turn instance id | `validation` is a pre-committed phase; B throws if it would have to execute it | **Not equivalent** — different obligations sharing no code |
37+
| Lifecycle completion | `lifecycle_completion` step with completion args | No counterpart; completion is part of writeback | A-only |
38+
| Durable writeback | `durable_writeback` step, condition guarded | `durable_writeback` provider effect through the reducer | Same kind, different execution and recovery |
39+
| Quota spend | `quota_spend` step | `quota_spend` provider effect | Same kind, different execution and recovery |
40+
| Terminal closeout | `terminal_closeout` step, emitted last with `continue_when: null` | `terminal_closeout` provider effect plus `terminal_closeout_requirement` | Same kind, B owns the requirement rule |
41+
| Replay / recovery | The adapter keeps no journal of its own. The call chain still recovers: `turnInstanceId` derives a stable identity from the same intent, the CLI persists canonical settlement receipts, and the continue-when conditions accept `idempotent_replay` / `receipt_repaired`, so re-entering the same intent succeeds and spends exactly one slot | Checkpoint per step, `resolve_prepared`, receipt replay, retry ceiling | **Different owner and granularity** — not "recovery versus none" |
42+
| Persistence | The adapter writes only a temporary vision file; the durable settlement receipts live in the canonical CLI/quota store, owned by the CLI | Durable checkpoint plus source journal | Different owners: CLI receipts versus transaction journal |
43+
44+
## Findings
45+
46+
1. **Neither path is a second policy owner.** Both delegate every decision to a
47+
TypeScript owner and keep Python as transport. `host_adapter_settlement.py`
48+
carries no lifecycle policy of its own.
49+
50+
2. **The step vocabularies overlap only partially.** A emits
51+
`guard / lifecycle_completion / durable_writeback / quota_spend /
52+
terminal_closeout`; B's `SettlementStepKind` is
53+
`validation / durable_writeback / quota_spend / terminal_closeout`. `guard`
54+
and `lifecycle_completion` have no B counterpart, and B's `validation` is a
55+
phase marker it refuses to execute rather than A's admission call.
56+
57+
3. **Recovery differs in owner and granularity, not in existence.** The adapter
58+
keeps no journal, but the MCP path is not recovery-free.
59+
`turnInstanceId` derives a stable identity from the same intent, the CLI
60+
persists canonical settlement receipts, and `spendContinueWhen` accepts
61+
`idempotent_replay` / `receipt_repaired`. A response lost after the real
62+
commit therefore recovers by re-entering the same intent: the durable
63+
readback reports `settlement_pending` or `settled`, a premature terminal
64+
completion is blocked, the retry succeeds, and the slot is spent exactly
65+
once — `tests/test_goal_mode_mcp_settlement.py::test_real_mcp_completion_recovers_a_lost_mutation_response`,
66+
parametrized over `lifecycle`, `writeback` and `spend`. B recovers at
67+
provider-step granularity inside one transaction, through its own checkpoint
68+
and `resolve_prepared`. A consolidation must preserve the CLI-receipt replay
69+
path; it must neither assume the MCP host needs a new journal nor assume the
70+
CLI receipts disappear with the adapter.
71+
72+
4. **At the shipped capability call site they already compose.**
73+
`extensions/governed_capability_execution.py` calls A's
74+
`classify_host_guard_snapshot` for admission and then
75+
`execute_turn_driver_settlement` for the transaction with its own journal.
76+
The suspicion that these are competing settlement transactions is not
77+
supported by this call site.
78+
79+
5. **The only Python-side interpreter is small and transport-necessary.**
80+
`_condition_matches` supports `all`, `any`, `equals`, `nullish`, `object`,
81+
`not_object` and `normalized_string_equals`; `_decode_provider_steps`
82+
validates that the plan has four or five steps in the fixed order. TypeScript
83+
still authors every condition. Evaluating them in TypeScript instead needs
84+
one runtime call per step, which the RFC explicitly says is not automatically
85+
an improvement.
86+
87+
## What a deletion would require
88+
89+
None of these is established today:
90+
91+
- the consolidation preserving the CLI's canonical receipt replay and the
92+
stable turn instance id that let a re-entry of the same intent succeed
93+
without paying twice, together with an adapter-local journal *or* an
94+
equivalent effect receiver for A's steps; or
95+
- B accepting `ordered_cli_sequence` plans with `continue_when` plus A's `guard`
96+
and `lifecycle_completion` kinds without a per-step runtime call, and
97+
adopting the CLI-receipt replay that A's path relies on today; or
98+
- evidence that no shipped caller uses A end-to-end.
99+
100+
## Candidate next slices
101+
102+
1. **Vocabulary unification (small).** If any caller adopts both paths, give
103+
`guard`, `lifecycle_completion` and `validation` one typed owner instead of
104+
three names in two files. Do not unify names that describe different
105+
obligations.
106+
2. **Characterization of A's adapter-local behavior (medium).** Pin what the
107+
adapter itself does when a step succeeds and a later step raises, before any
108+
recovery change touches it. The end-to-end response-loss case is already
109+
characterized by `test_real_mcp_completion_recovers_a_lost_mutation_response`;
110+
what is not characterized is the adapter's own partial-step behavior and
111+
where the recovery boundary between the adapter and the CLI receipts sits.
112+
3. **Not recommended now.** Merging A and B, or adding a third plan format,
113+
would add a transaction boundary without deleting an obligation.
114+
115+
## Coordination
116+
117+
Active or recently merged work touching these obligations:
118+
[#3412](https://github.com/loopx-project/loopx/pull/3412) (ambiguous settlement
119+
recovery), [#5677](https://github.com/loopx-project/loopx/pull/5677) (caller-authored
120+
first delivery), [#7580](https://github.com/loopx-project/loopx/pull/7580) (failed
121+
journal with an unresolved prepared effect), [#7523](https://github.com/loopx-project/loopx/pull/7523)
122+
(typed receipts and continuation). Any implementation slice must reconcile those
123+
diffs first.
124+
125+
## What this does not establish
126+
127+
No equivalence proof, no deletion authorization, no runtime qualification, no
128+
benefit measurement, and no claim that either path is redundant. The recovery
129+
baseline is the CLI-receipt replay that exists today; the adapter-local
130+
partial-step behavior is not characterized here. Source facts are read at the
131+
baseline above and may drift.

0 commit comments

Comments
 (0)