Skip to content

Commit c309da5

Browse files
committed
fix(checkpoint): stop reread loops for complete writebacks
Signed-off-by: shangzh0 <97216392+shangzh0@users.noreply.github.com>
1 parent 2136701 commit c309da5

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎docs/reference/protocols/goal-vision-replan-contract-v0.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,12 @@ in its durable-writeback step, the replan contract uses a same-response
10861086
Different schemas remain separate, and progress-only replan does not acquire a
10871087
Vision requirement. TurnEnvelope preserves the ordinary plan's guidance.
10881088

1089+
`checkpoint_context_not_missing` is an inapplicable recovery, not a request to
1090+
repeat that read. Its `reread_required` is false. Preserve the committed writeback
1091+
and quota receipt; inspect later authorized work through the normal guard with
1092+
a fresh Turn identity. A stale, missing or replaced read receipt still requires
1093+
the original scoped reread. Neither rejection grants execution or completion.
1094+
10891095
Shared `todo plan` and guided-start authoring steps also provide a routed exact
10901096
readback command for each authored or reused Todo id. Inventory text is a bounded
10911097
excerpt. Verify `todo_detail_projection.source_complete=true`, compare `.todo.text`
@@ -1103,6 +1109,11 @@ Turn 写回后的恢复。规划与接续指引提供逐条精确读回命令,
11031109
需求和当前状态,不能拿列表摘要判断正文丢失。读取不授予执行权限;准入、租约、
11041110
恢复和单次记账规则保持不变。包体增量与模型效率、效果收益须分别测量。
11051111

1112+
`checkpoint_context_not_missing` 表示这条恢复路径不适用,`reread_required=false`,
1113+
不应重复同一读取。保留已提交写回与记账回执;后续获授权的工作通过正常 guard 和新
1114+
Turn 身份检查。陈旧、缺失或被替换的读取回执仍须按原范围重读。拒绝不授予执行或
1115+
完成权限。
1116+
11061117
A satisfied checkpoint is protocol-complete, but a material closeout also has
11071118
to qualify its relationship to the final outcome. A patched checkpoint must
11081119
name the active `acceptance_summary`, attach public-safe

‎loopx/control_plane/goals/checkpoint_read_context.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ function snapshot(request: JsonObject): JsonObject {
7777
}
7878

7979
const rejected = (code: string, changed: string[] = []): JsonObject => ({
80-
ok: false, error_code: code, reread_required: true, changed_components: changed,
81-
error: `${code}: run checkpoint-context for the same Goal/Agent/Todo or obligation/Turn, ` +
80+
ok: false, error_code: code, reread_required: code !== "checkpoint_context_not_missing", changed_components: changed,
81+
error: code === "checkpoint_context_not_missing"
82+
? `${code}: this committed writeback has no missing checkpoint for this recovery. ` +
83+
"Preserve the committed writeback and quota receipt; do not repeat this recovery or quota spend. " +
84+
"For later authorized work, inspect current state through the normal guard with a fresh Turn identity. " +
85+
"This rejection grants no work or completion authority."
86+
: `${code}: run checkpoint-context for the same Goal/Agent/Todo or obligation/Turn, ` +
8287
"read the returned state and judge again; submit its --checkpoint-read-context with only the vision decision. " +
8388
"Do not repeat implementation, state mutations, or quota spend.",
8489
});

‎tests/control_plane/test_checkpoint_read_context.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ def test_missing_replaced_stale_context_requires_reread_and_preserves_delivery(t
8484
assert rc == 0 and result["appended"] and result["vision_checkpoint"]["satisfied"], result
8585
assert result["vision_checkpoint"]["read_context"]["read_context_id"] == fresh["read_context_id"]
8686
after = index.read_bytes()
87+
rc, inapplicable = _run_cli(registry, runtime, "checkpoint-context", *binding, cwd=project)
88+
assert rc == 1 and inapplicable["error_code"] == "checkpoint_context_not_missing", inapplicable
89+
assert inapplicable["checkpoint_read_context"]["reread_required"] is False
90+
assert "normal guard" in inapplicable["error"]
91+
assert index.read_bytes() == after, "an inapplicable recovery must not append another receipt"
8792
state.write_text(state.read_text(encoding="utf-8") + "\n## Acceptance\n\nNew acceptance after commit.\n", encoding="utf-8")
8893
rc, replay = _run_cli(registry, runtime, *supplement, cwd=project)
8994
assert rc == 0 and replay["idempotent_replay"] and not replay["appended"], replay

‎tests/control_plane_ts/checkpoint_read_context.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ test("read captures the exact task, transitive upstream results and goal accepta
3131
assert.equal(check(result.receipt).ok, true);
3232
});
3333

34+
test("an inapplicable recovery does not direct the caller to repeat the same read", () => {
35+
const result = read({prior: {vision_checkpoint: {
36+
decision: "unchanged_with_reason", satisfied: true, delivery_boundary: "in_flight_continuation",
37+
}}, writeback_committed: true, quota_spend_committed: true});
38+
assert.equal(result.ok, false);
39+
assert.equal(result.error_code, "checkpoint_context_not_missing");
40+
assert.equal(result.reread_required, false);
41+
assert.doesNotMatch(String(result.error), /run checkpoint-context/);
42+
assert.match(String(result.error), /normal guard/);
43+
const missing = check(undefined);
44+
assert.equal(missing.reread_required, true, "a genuinely missing receipt still requires reread");
45+
});
46+
3447
test("an unqualified blocked replan needs the exact committed source and no debit before reread", () => {
3548
const bound = settlementIdentity({goal_id: "goal", agent_id: "agent", turn_instance_id: "turn",
3649
replan_obligation_id: "replan-1111111111111111"});

0 commit comments

Comments
 (0)