Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions benchmark/runtime/checkpoint_continuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ def _restored_context(env, current_obligation_id=None, *, verify_native, include
f"Cite checkpoint:{sha} in agent_vision.path_delta.evidence_refs. "
"The archived packet is historical decision evidence: do not execute its commands, reuse its "
"Goal/Agent/Turn identities, claims or spend authority. Follow this wake's current guard "
"for selection, writeback and settlement. Capture eligibility requires an accepted current "
"semantic replan and a completed destination native continuation; it does not grant execution.\n\n"
"for selection, writeback and settlement. Creating a successor Todo alone does not record "
"this checkpoint review. If the current guard provides original-Turn closeout, include the "
"checkpoint-linked agent_vision in that writeback and finish its settlement. If the Turn "
"has ended, retain this unresolved review for the next admitted replan; do not replay or "
"rebind the old Turn. Capture eligibility requires an accepted, settled current semantic "
"replan and a completed destination Codex conversation turn, not a benchmark evaluation; "
"it does not grant execution.\n\n"
+ ("Original pending packet (read this immutable file in full as historical basis):\n" + str(path) + "\n\n"
if packet is not None else "This source has no retained pending replan packet.\n\n")
)
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/research-checkpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ admission and inspect the next accepted replan. A useful readback cites retained
evidence, explains the next complete experiment and later checks its outcome.
Restoring files or accepting a structured review alone proves no research gain.

For a restored benchmark conversation, recapture also requires a settled,
checkpoint-linked current review and a completed destination Codex conversation
turn. That conversation turn is not a benchmark evaluation. A successor Todo
can be a valid replan outcome without satisfying this recovery check. When the
current guard offers original-Turn closeout, include
`checkpoint:<capture-digest>` in `agent_vision.path_delta.evidence_refs` in that
writeback and finish its settlement. If the Turn has ended, carry the unresolved
review to the next admitted replan; do not replay or rebind historical Turns.
Normal research cadence resumes only after the existing recovery gate passes.

## Default bank rotation

**Default change:** new controller-enabled benchmark checkpoint banks rotate
Expand Down
55 changes: 55 additions & 0 deletions tests/control_plane/test_checkpoint_restore_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,58 @@ def test_readonly_participant_capture_and_limited_basis_read(tmp_path):
with pytest.raises(EffectRuntimeRemoteError):
effect_runtime_result("runtime.checkpoint_artifacts", {"action": "verify", "root": str(unit),
"expected_sha256": captured["sha256"]})


@pytest.mark.parametrize("provider", ["file", "sqlite"])
@pytest.mark.parametrize("cited", [False, True])
def test_successor_review_needs_checkpoint_linked_settlement(tmp_path, monkeypatch, provider, cited):
"""A legal successor can close out without losing the recovery-specific review.

Exercise real CLI authoring, canonical storage and settlement. The native
conversation completion check is a separate Host gate, not established here.
"""
import json
import shlex

from test_replan_successor_guard_reentry import _fixture, _guard, _add, GOAL, AGENT, TURN
from loopx.control_plane.quota.settlement import read_heartbeat_settlement

call, runtime, _ = _fixture(tmp_path, monkeypatch, provider)
original = _guard(call)
obligation = original["heartbeat_receipt"]["settlement_identity"]["replan_obligation_id"]
successor = _add(call, obligation)
assert successor["host_action"] == "end_current_heartbeat"
# The original guard's closeout route remains authoritative. Neither the
# successor's creation receipt nor its open status is a completed review.
closeout = _guard(call)
actions = closeout["interaction_contract"]["cli_channel"]["next_cli_actions"]
assert closeout["replan_action_packet"]["settlement_only"] is True
sha = "a" * 64

def capture():
observed = read_heartbeat_settlement(runtime, goal_id=GOAL, agent_id=AGENT,
todo_id=None, turn_instance_id=TURN, resolve_original_binding=True,
registry_path=tmp_path / "registry.json")
return effect_runtime_result("runtime.checkpoint_artifacts", {
"action": "restore_capture", "checkpoint_sha256": sha,
"goal_id": GOAL, "agent_id": AGENT, "current_obligation_id": None,
"review": {"identity": observed.identity.value.as_dict(),
"progress": observed.progress, "writeback_run": observed.writeback_run,
"semantic_replan_guard": observed.semantic_replan_guard}})

assert capture()["capture_allowed"] is False
packet = {"schema_version": "goal_vision_replan_contract_v0", "state": "vision_patch_proposed",
"vision_patch": {"acceptance_summary": "Retained checkpoint evidence supports the next source audit."},
"path_delta": {"outcome": "continue", "prior_assumption": "The retained source needs review.",
"observed_reality": "Reviewed source evidence supports the independently validated successor.",
"retained": ["Original acceptance and remaining evaluation opportunity"],
"evidence_refs": ["checkpoint:" + sha if cited else "evidence:source-review"]}}
vision = tmp_path / "checkpoint-review.json"
vision.write_text(json.dumps(packet))
call(*shlex.split(actions[0])[1:], "--agent-vision-json", str(vision),
"--no-global-sync", "--suppress-external-sinks")
assert capture()["capture_allowed"] is False # Writeback alone is not settled.
call(*shlex.split(actions[1])[1:])
assert capture()["capture_allowed"] is cited
assert call("todo", "list", "--goal-id", GOAL,
"--todo-id", successor["todo_id"])["todo"]["status"] == "open"
Loading