|
| 1 | +# C4.3 adapter partial-step characterization |
| 2 | + |
| 3 | +- Parent: [controller/executor RFC, C4.3](2026-10-27-refactor-handoff.md#c43-settlement-adapters-over-existing-primitives). |
| 4 | +- Baseline: `8caaf678e`, 2026-10-29. The settlement owners are unchanged at `1e3401591`. |
| 5 | +- Status: characterization only. No runtime, schema, wire or default change. |
| 6 | +- Follows: [C4.3 settlement obligation comparison](2026-10-29-c4-3-settlement-obligation-comparison.md). |
| 7 | +- [Chinese mirror](2026-10-29-c4-3-adapter-partial-step-characterization.zh-CN.md). |
| 8 | + |
| 9 | +## Why this entry exists |
| 10 | + |
| 11 | +The comparison entry recorded the adapter's lack of a local journal as a fact |
| 12 | +about the adapter, and left the adapter's own behavior when a step succeeds and |
| 13 | +a later step fails uncharacterized, together with the place where the recovery |
| 14 | +boundary between the adapter and the CLI receipts sits. A consolidation slice |
| 15 | +that moved this path would otherwise have had to assume both. |
| 16 | + |
| 17 | +This entry pins that behavior with executable cases, so a later recovery change |
| 18 | +starts from measured behavior rather than from the comparison's wording. |
| 19 | + |
| 20 | +## What is characterized now |
| 21 | + |
| 22 | +| Surface | Adapter behavior | Owner behavior | |
| 23 | +| --- | --- | --- | |
| 24 | +| A step returns output the adapter cannot read | `_provider_condition_matches` treats a non-JSON output as a condition that did not match, so the plan stops after that step | The finalize phase still runs and the owner classifies the stop: `blocked`, `failed_stage: guard`, reason `quota guard returned malformed JSON` | |
| 25 | +| A step raises | The exception propagates out of the adapter. The finalize phase never runs, so the transaction is never classified. The adapter keeps no record of the step that already succeeded | Nothing is classified, because the owner is never asked | |
| 26 | +| A retry after a raise | The adapter re-enters the plan at its first step and never resumes mid-plan | The identity is re-derived from the same intent, so the same settlement identity is used | |
| 27 | +| A step raises before the lifecycle completion | Nothing is spent and the Todo stays open | The guard already ran, so the `validation` receipt is committed. The readback is `open` with progress `writeback_required`; there is no lifecycle completion, writeback or spend receipt to replay | |
| 28 | +| A step raises after the lifecycle completion | The adapter leaves nothing behind; the CLI's canonical receipt store holds the committed receipt | The readback is `settlement_pending` with progress `writeback_required`: `validation` is committed, the writeback and spend receipts are missing | |
| 29 | +| A step raises after the durable writeback | The adapter leaves nothing behind; the CLI's canonical receipt store holds the committed receipt | The readback is `settlement_pending` with progress `spend_required`: `validation` and `durable_writeback` are committed, the spend receipt is missing | |
| 30 | +| A step raises after the quota spend | The adapter leaves nothing behind; the CLI's canonical receipt store holds the committed receipt | The readback is `settled`; the retry replays that receipt (`idempotent_replay`), spends no second slot and reports the same settlement identity | |
| 31 | + |
| 32 | +Three findings follow from these cases. |
| 33 | + |
| 34 | +1. **The adapter makes no classification decision.** A stopped plan is |
| 35 | + classified by the TypeScript owner; a raised step is not classified at all, |
| 36 | + because the owner is never asked. The adapter is transport in both cases. |
| 37 | +2. **The recovery boundary is the CLI receipt, not adapter state.** After a |
| 38 | + raise, the only durable evidence is what the CLI already committed. The |
| 39 | + retry succeeds because that receipt replays, and the adapter contributes |
| 40 | + nothing but a re-execution of the plan. |
| 41 | +3. **The outstanding work is named by the owner, stage by stage.** The |
| 42 | + readback distinguishes an open settlement from a pending one and names the |
| 43 | + step still owed — `writeback_required` after the lifecycle completion, |
| 44 | + `spend_required` after the durable writeback, `settled` after the spend. |
| 45 | + A raise is therefore not a single undifferentiated failure state, and the |
| 46 | + committed receipt kinds tell which stage a retry would resume from. |
| 47 | + |
| 48 | +## Evidence |
| 49 | + |
| 50 | +`tests/control_plane/test_host_adapter_settlement_partial_steps.py`: |
| 51 | + |
| 52 | +- `test_an_unreadable_step_output_stops_the_plan_and_the_owner_classifies_it` |
| 53 | +- `test_a_raising_step_leaves_no_finalize_and_no_adapter_local_resume` |
| 54 | +- `test_a_raised_step_after_a_durable_commit_leaves_only_that_stage_pending` |
| 55 | + (real CLI, real quota store; parametrized over the guard, lifecycle |
| 56 | + completion, durable writeback and quota spend stages, reading back the |
| 57 | + committed receipt kinds, the replay phase and the settlement progress) |
| 58 | +- `test_a_raising_step_after_a_durable_commit_recovers_through_the_cli_receipt` |
| 59 | + (real CLI, real quota store) |
| 60 | +- `test_a_raised_step_before_completion_commits_no_settlement` (real CLI) |
| 61 | + |
| 62 | +The existing end-to-end recovery case stays where it was: |
| 63 | +`tests/test_goal_mode_mcp_settlement.py::test_real_mcp_completion_recovers_a_lost_mutation_response` |
| 64 | +covers a lost response after a commit; the new case covers the same recovery |
| 65 | +through a raised transport instead. |
| 66 | + |
| 67 | +## What this does not establish |
| 68 | + |
| 69 | +- No equivalence proof, no deletion authorization, no runtime qualification, no |
| 70 | + benefit measurement, and no claim that either settlement path is redundant. |
| 71 | +- The characterization covers the shipped MCP host path through |
| 72 | + `settle_host_todo_completion`. It does not characterize other callers of the |
| 73 | + adapter, and it does not describe the TypeScript-only Turn settlement path, |
| 74 | + which recovers per provider step inside its own transaction. |
| 75 | +- It adds no journal, retry policy or resume capability to the adapter. Adding |
| 76 | + one is a new design decision with its own acceptance, not a characterization. |
| 77 | +- The observed recovery depends on the CLI's canonical receipt store. Source |
| 78 | + facts were read at the baseline above and may drift. |
| 79 | + |
| 80 | +## Next slices |
| 81 | + |
| 82 | +Unchanged by this entry, with one correction to how the remaining work is |
| 83 | +described. A deletion of the adapter-side interpreter still needs the |
| 84 | +preconditions recorded in the comparison entry. The vocabulary candidate that |
| 85 | +the confirmation entry withdrew — one typed owner for `guard`, |
| 86 | +`lifecycle_completion` and `validation` — is not reopened here: that entry |
| 87 | +already identified the shipped caller that adopts both paths and recorded the |
| 88 | +candidate as withdrawn. The independent registry slice — the shared owner for |
| 89 | +the ordered host-adapter step kinds — is completed in |
| 90 | +[#7619](https://github.com/loopx-project/loopx/pull/7619). That slice was a |
| 91 | +registry change, not a continuation of the withdrawn unification. The work |
| 92 | +that remains open is the deletion and adoption preconditions recorded in the |
| 93 | +comparison entry. |
0 commit comments