Skip to content

Commit 937a011

Browse files
authored
Merge pull request #6707 from loopx-project/codex/checkpoint-large-local-snapshot-20261017
fix(checkpoint): preserve complete large artifact witnesses
2 parents 555a83d + 2114966 commit 937a011

17 files changed

Lines changed: 166 additions & 39 deletions

‎benchmark/edgebench/checkpoint_controller.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ def capture(controller_file: Path, *, token: str, capture_id: str, destination:
227227
components.append({"id": "host_phase_deadline", "source_path": str(phase_deadline_file)})
228228
metadata["host_phase_budget"] = _phase_budget(phase_raw, native)
229229
probe = effect_runtime_result("runtime.checkpoint_artifacts", {"action": "probe", "components": components},
230-
timeout=_remaining(deadline), retry_safe=False)
230+
timeout=_remaining(deadline), retry_safe=False, large_local_snapshot=True)
231231
result = effect_runtime_result("runtime.checkpoint_artifacts", {
232232
"action": "capture", "components": components, "destination": str(destination),
233233
"expected_source_sha256": probe["source_sha256"],
234234
"point_metadata": metadata,
235-
}, timeout=_remaining(deadline), retry_safe=False)
235+
}, timeout=_remaining(deadline), retry_safe=False, large_local_snapshot=True)
236236
# Bind the actually copied bytes, not merely a prior source observation.
237237
_bound_bank(destination / "components/native_judge", reference)
238238
if phase_raw is not None and (destination / "components/host_phase_deadline").read_bytes() != phase_raw:
@@ -291,7 +291,7 @@ def restore(controller_file: Path, *, root: Path, expected_sha256: str, run_id:
291291
controller = _controller(controller_file)
292292
root = _physical(root)
293293
effect_runtime_result("runtime.checkpoint_artifacts", {
294-
"action": "verify", "root": str(root), "expected_sha256": expected_sha256})
294+
"action": "verify", "root": str(root), "expected_sha256": expected_sha256}, large_local_snapshot=True)
295295
manifest = json.loads((root / "checkpoint.json").read_bytes())
296296
expected_components = ["native_judge"]
297297
if phase_deadline_file is not None:
@@ -336,7 +336,7 @@ def restore(controller_file: Path, *, root: Path, expected_sha256: str, run_id:
336336
effect_runtime_result("runtime.checkpoint_artifacts", {
337337
"action": "materialize", "root": str(root), "expected_sha256": expected_sha256,
338338
"destination": str(stage / "unit"),
339-
}, retry_safe=False)
339+
}, retry_safe=False, large_local_snapshot=True)
340340
imported = stage / "unit/components/native_judge"
341341
_bound_bank(imported, reference)
342342
with _bank_import_lock(target, timeout):

‎benchmark/edgebench/checkpoint_worker.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def capture_worker(controller_file: Path, *, token: str, capture_id: str,
240240
if prepared is not None:
241241
observed = effect_runtime_result("runtime.checkpoint_artifacts", {
242242
"action": "probe", "components": components,
243-
}, timeout=_remaining(deadline), retry_safe=False)
243+
}, timeout=_remaining(deadline), retry_safe=False, large_local_snapshot=True)
244244
if observed["source_sha256"] != prepared["source_sha256"]:
245245
changed = []
246246
for key, rows in observed["source_witness"].items():
@@ -298,11 +298,11 @@ def capture_worker(controller_file: Path, *, token: str, capture_id: str,
298298
metadata["writer_barrier"] = "docker_pause"
299299
probe = effect_runtime_result("runtime.checkpoint_artifacts", {"action": "probe", "components": components,
300300
"deadline_epoch_ms": sealing_epoch_ms},
301-
timeout=_remaining(deadline), retry_safe=False)
301+
timeout=_remaining(deadline), retry_safe=False, large_local_snapshot=True)
302302
return effect_runtime_result("runtime.checkpoint_artifacts", {
303303
"action": "capture", "components": components, "destination": str(destination),
304304
"expected_source_sha256": probe["source_sha256"], "point_metadata": metadata,
305305
"deadline_epoch_ms": sealing_epoch_ms,
306-
}, timeout=_remaining(deadline), retry_safe=False)
306+
}, timeout=_remaining(deadline), retry_safe=False, large_local_snapshot=True)
307307
finally:
308308
client.close()

‎benchmark/runtime/checkpoint.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _prior_replan_guard_seen(env: dict[str, str], current: Path, obligation_id:
109109
prior = effect_runtime_result("runtime.checkpoint_artifacts", {
110110
"action": "select_replan", "quota": guard, "goal_id": env["LOOPX_GOAL_ID"],
111111
"agent_id": env["LOOPX_AGENT_ID"], "turn_instance_id": path.parent.name,
112-
})
112+
}, large_local_snapshot=True)
113113
if prior["capture"] and prior["obligation_id"] == obligation_id:
114114
return True
115115
return False
@@ -161,7 +161,7 @@ def capture_before_replan(env: dict[str, str], receipt: dict[str, Any], body: st
161161
intent = effect_runtime_result("runtime.checkpoint_artifacts", {
162162
"action": "select_replan", "quota": guard, "goal_id": env["LOOPX_GOAL_ID"],
163163
"agent_id": env["LOOPX_AGENT_ID"], "turn_instance_id": receipt["turn_id"],
164-
})
164+
}, large_local_snapshot=True)
165165
from .checkpoint_continuation import restored_capture_gate
166166
restore_gate = restored_capture_gate(env, intent.get("obligation_id"),
167167
full_history=not request.get("native_session", False))
@@ -199,7 +199,7 @@ def capture_before_replan(env: dict[str, str], receipt: dict[str, Any], body: st
199199
raise ValueError("existing replan point has a different declaration")
200200
verified = effect_runtime_result("runtime.checkpoint_artifacts", {
201201
"action": "verify", "root": str(destination), "expected_sha256": manifest["sha256"],
202-
})
202+
}, large_local_snapshot=True)
203203
receipt["checkpoint"].update(reason="replan_already_captured", destination=str(destination), **verified)
204204
else:
205205
# A failed first capture is a missed point. Once its model is
@@ -360,7 +360,7 @@ def capture_after_wake(env: dict[str, str], receipt: dict[str, Any], *,
360360
probe = effect_runtime_result("runtime.checkpoint_artifacts", {
361361
"action": "probe", "components": components,
362362
"deadline_epoch_ms": deadline * 1000,
363-
}, timeout=max(.1, deadline - time.time()), retry_safe=False)
363+
}, timeout=max(.1, deadline - time.time()), retry_safe=False, large_local_snapshot=True)
364364
if request.get("native_session"):
365365
# Native readback precedes the byte witness. A completed later Turn
366366
# in that gap must not be sealed under the earlier cursor. Re-read
@@ -402,7 +402,7 @@ def capture_after_wake(env: dict[str, str], receipt: dict[str, Any], *,
402402
"components": components, "point_metadata": metadata,
403403
"expected_source_sha256": probe["source_sha256"],
404404
"deadline_epoch_ms": deadline * 1000,
405-
}, timeout=max(.1, deadline - time.time()), retry_safe=False)
405+
}, timeout=max(.1, deadline - time.time()), retry_safe=False, large_local_snapshot=True)
406406
receipt["checkpoint"] = {"captured": True, "destination": str(destination), **captured}
407407
except Exception as error:
408408
# Capture failure is explicit but cannot rewrite an already settled work
@@ -480,7 +480,7 @@ def remaining():
480480
"action": "select_replan", "quota": quota, "goal_id": goal_id,
481481
"agent_id": agent_id, "turn_instance_id": (turn_instance_id if turn_instance_id is not None
482482
else (quota.get("heartbeat_receipt") or {}).get("turn_instance_id")),
483-
}, timeout=remaining())
483+
}, timeout=remaining(), large_local_snapshot=True)
484484
if not failed_readback and native_process is not None and interrupt_when is not None and interrupt_when(intent):
485485
from .worker import interrupt_checkpoint_process
486486

‎benchmark/runtime/checkpoint_continuation.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _restored_context(env, current_obligation_id=None, *, verify_native, include
6464
unit = Path(source)
6565
manifest = effect_runtime_result("runtime.checkpoint_artifacts", {
6666
"action": "read_basis", "root": str(unit), "expected_sha256": sha,
67-
})
67+
}, large_local_snapshot=True)
6868
# Admission already verified all artifact bytes. Here only the immutable
6969
# declaration, original pending packet and native history are inputs; do
7070
# not rehash large code/incumbent archives on every ordinary work wake.
@@ -86,13 +86,13 @@ def _restored_context(env, current_obligation_id=None, *, verify_native, include
8686
"action": "select_replan", "quota": packet,
8787
"goal_id": metadata["loopx_state"]["goal_id"], "agent_id": metadata["loopx_state"]["agent_id"],
8888
"turn_instance_id": packet["heartbeat_receipt"]["turn_instance_id"],
89-
})
89+
}, large_local_snapshot=True)
9090
if intent != pending or intent.get("capture") is not True:
9191
raise ValueError("restored original replan binding differs")
9292
result = effect_runtime_result("runtime.checkpoint_artifacts", {
9393
"action": "restore_capture", **lineage, "checkpoint_sha256": sha,
9494
"current_obligation_id": current_obligation_id, "review": None,
95-
})
95+
}, large_local_snapshot=True)
9696
# Existing saved preflights are discovery only. Each candidate is resolved
9797
# through the canonical current-Goal settlement owner, never copied logs.
9898
for guard_path in sorted(Path(env["LOOPX_WAKE_LOG_DIR"]).glob("*/checkpoint-start-guard.json"), reverse=True):
@@ -111,7 +111,7 @@ def _restored_context(env, current_obligation_id=None, *, verify_native, include
111111
"semantic_replan_guard": observed.semantic_replan_guard,
112112
},
113113
**({"include_review_basis": True} if include_review_basis else {}),
114-
})
114+
}, large_local_snapshot=True)
115115
if result["capture_allowed"]:
116116
# Qualification happens before launching this wake's model. A
117117
# current receipt alone cannot stand in for native continuation.
@@ -161,6 +161,6 @@ def restored_capture_history(env, preflight, *, session_id):
161161
raise ValueError("restored capture requires its admitted session and completed cursor")
162162
manifest = effect_runtime_result("runtime.checkpoint_artifacts", {
163163
"action": "read_basis", "root": binding["checkpoint_artifact_root"], "expected_sha256": sha,
164-
})
164+
}, large_local_snapshot=True)
165165
return {"retained_history": retained_native_history(binding, manifest["point_metadata"]),
166166
"required_completed_turn_id": cursor}

‎benchmark/runtime/checkpoint_session_refresh.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _prepare_fresh_replan(env, session, wake, declaration):
4949

5050
unit = Path(declaration["root"])
5151
manifest = effect_runtime_result("runtime.checkpoint_artifacts", {
52-
"action": "read_basis", "root": str(unit), "expected_sha256": declaration["sha256"]})
52+
"action": "read_basis", "root": str(unit), "expected_sha256": declaration["sha256"]}, large_local_snapshot=True)
5353
metadata = manifest["point_metadata"]
5454
component = metadata.get("held_decision_component_id")
5555
if component not in {entry["id"] for entry in manifest["components"]}:
@@ -65,7 +65,7 @@ def _prepare_fresh_replan(env, session, wake, declaration):
6565
"action": "select_replan", "quota": packet,
6666
"goal_id": metadata["loopx_state"]["goal_id"],
6767
"agent_id": metadata["loopx_state"]["agent_id"],
68-
"turn_instance_id": packet["heartbeat_receipt"]["turn_instance_id"]})
68+
"turn_instance_id": packet["heartbeat_receipt"]["turn_instance_id"]}, large_local_snapshot=True)
6969
if selected.get("capture") is not True or selected != (
7070
metadata.get("replan") or metadata.get("operator_metadata", {}).get("replan")):
7171
raise ValueError("fresh replan requires the original pending decision boundary")

‎benchmark/runtime/checkpoint_wake.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _capture(self, held, deadline):
151151
metadata["held_decision_component_id"] = decision_id
152152
probe = effect_runtime_result("runtime.checkpoint_artifacts", {
153153
"action": "probe", "components": components, "deadline_epoch_ms": window * 1000,
154-
}, timeout=max(.1, window - time.time()), retry_safe=False)
154+
}, timeout=max(.1, window - time.time()), retry_safe=False, large_local_snapshot=True)
155155
if native is not None:
156156
if restored_capture_history(self.env, self.receipt.get("checkpoint_restore"),
157157
session_id=self.receipt["session"]["session_id"]) != native_options:
@@ -181,7 +181,7 @@ def _capture(self, held, deadline):
181181
"action": "capture", "components": components, "destination": str(destination),
182182
"expected_source_sha256": probe["source_sha256"], "point_metadata": metadata,
183183
"deadline_epoch_ms": window * 1000,
184-
}, timeout=max(.1, window - time.time()), retry_safe=False)
184+
}, timeout=max(.1, window - time.time()), retry_safe=False, large_local_snapshot=True)
185185

186186
def run(self, execution, body, wake, session_wake, stdout, stderr, timeout):
187187
from .worker import child_process, native_command

‎benchmark/runtime/sforge_warm_start.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def verify(self, workspace: str) -> dict:
5656
raise ValueError("Original warm start deadline expired before checkpoint verification")
5757
effect_runtime_result("runtime.checkpoint_artifacts", {
5858
"action": "verify", "root": str(self.root), "expected_sha256": self.sha256},
59-
timeout=min(_CHECKPOINT_VERIFY_TIMEOUT_SECONDS, remaining))
59+
timeout=min(_CHECKPOINT_VERIFY_TIMEOUT_SECONDS, remaining), large_local_snapshot=True)
6060
metadata = json.loads((self.root / "checkpoint.json").read_bytes())["point_metadata"]
6161
native, source = metadata["native_session"], metadata["loopx_state"]
6262
if (native["guest_workspace"] != workspace or native["guest_home"] != _CODEX_HOME
@@ -192,7 +192,7 @@ def restore_workspace(declaration: dict, workspace: Path):
192192
unit = Path(declaration["root"])
193193
effect_runtime_result("runtime.checkpoint_artifacts", {
194194
"action": "verify", "root": str(unit), "expected_sha256": declaration["sha256"]},
195-
timeout=_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS))
195+
timeout=_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS), large_local_snapshot=True)
196196
_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS)
197197
manifest = json.loads((unit / "checkpoint.json").read_bytes())
198198
metadata = manifest["point_metadata"]
@@ -227,7 +227,7 @@ def restore_workspace(declaration: dict, workspace: Path):
227227
if research:
228228
copied = effect_runtime_result("runtime.checkpoint_artifacts", {"action": "probe",
229229
"components": [{"id": key, "source_path": str(target)} for key, _, target in research]},
230-
timeout=_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS))
230+
timeout=_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS), large_local_snapshot=True)
231231
if any(copied["source_witness"][key] != manifest["artifact_witness"][key] for key, _, _ in research):
232232
raise ValueError("Restored research files differ from the sealed artifacts; preserve this failed receiver")
233233
_phase_read_timeout(declaration, _CHECKPOINT_VERIFY_TIMEOUT_SECONDS)

‎benchmark/tests/qualify_checkpoint_joint.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def guest(command, volumes, env, log, *, capture_supervisor=None):
139139
raise ValueError("Reused point/configuration must be physical paths")
140140
packet = json.loads((point / "checkpoint.json").read_bytes())
141141
verified = effect_runtime_result("runtime.checkpoint_artifacts", {
142-
"action": "verify", "root": str(point), "expected_sha256": packet["sha256"]})
142+
"action": "verify", "root": str(point), "expected_sha256": packet["sha256"]}, large_local_snapshot=True)
143143
assert verified["integrity_verified"]
144144
metadata = packet["point_metadata"]
145145
assert metadata["held_decision_component_id"] and metadata["worker_file_snapshot"]["prepared_source_verified"]
@@ -231,7 +231,7 @@ def guest(command, volumes, env, log, *, capture_supervisor=None):
231231
recaptured = newer[0]
232232
next_packet = json.loads((recaptured / "checkpoint.json").read_bytes())
233233
check = effect_runtime_result("runtime.checkpoint_artifacts", {
234-
"action": "verify", "root": str(recaptured), "expected_sha256": next_packet["sha256"]})
234+
"action": "verify", "root": str(recaptured), "expected_sha256": next_packet["sha256"]}, large_local_snapshot=True)
235235
assert check["integrity_verified"]
236236
third = output / "grandreceiver"
237237
third.mkdir()

‎benchmark/tests/test_checkpoint_handoff.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ def test_restored_capture_cannot_drop_its_preflight_basis(tmp_path, monkeypatch,
441441
gate["capture_allowed"] = False
442442
reads = []
443443
monkeypatch.setattr(continuation, "load_codex_cli_session", lambda *a, **k: binding)
444-
def basis(method, request):
444+
def basis(method, request, *, large_local_snapshot):
445+
assert large_local_snapshot is True
445446
assert request == {"action": "read_basis", "root": str(tmp_path / "point"), "expected_sha256": "a" * 64}
446447
reads.append(True)
447448
return {"point_metadata": {"native_session": native}}

‎benchmark/tests/test_checkpoint_joint_receiver.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_captured_point_continues_with_fresh_authority(
7676
verified = effect_runtime_result("runtime.checkpoint_artifacts", {
7777
"action": "materialize", "root": str(unit), "expected_sha256": digest,
7878
"destination": str(materialized),
79-
})
79+
}, large_local_snapshot=True)
8080
assert verified["materialized"] and not verified["activation_performed"]
8181
source_workspace = materialized / "components" / roots[0]["id"]
8282
assert source_workspace.is_dir()
@@ -1003,7 +1003,7 @@ def run_native_work(current_guard, logs, purpose):
10031003
assert opportunity_after["remaining_cooldown_seconds"] <= opportunity["remaining_cooldown_seconds"]
10041004
assert actual_phase.read_bytes() == original_phase
10051005
check = effect_runtime_result("runtime.checkpoint_artifacts", {
1006-
"action": "verify", "root": str(recaptured), "expected_sha256": captured["sha256"]})
1006+
"action": "verify", "root": str(recaptured), "expected_sha256": captured["sha256"]}, large_local_snapshot=True)
10071007
assert check["integrity_verified"] and not check["research_point_qualified"]
10081008
(tmp_path / "full-recapture.json").write_text(json.dumps(boundary["checkpoint"]))
10091009
elif boundary["checkpoint"].get("reason") == "no_fresh_replan":
@@ -1033,13 +1033,13 @@ def run_native_work(current_guard, logs, purpose):
10331033
assert captured["point_metadata"]["native_session"]["turn_ids"] == grown["turn_ids"]
10341034
assert (manual / "components/code").read_text() == "10"
10351035
verified_point = effect_runtime_result("runtime.checkpoint_artifacts", {
1036-
"action": "verify", "root": str(manual), "expected_sha256": captured["sha256"]})
1036+
"action": "verify", "root": str(manual), "expected_sha256": captured["sha256"]}, large_local_snapshot=True)
10371037
assert verified_point["integrity_verified"] and not verified_point["research_point_qualified"]
10381038
capture_after_wake(capture_env, completed)
10391039
assert completed["checkpoint"]["reason"] == "destination_already_present_no_replay"
10401040
effect_runtime_result(
10411041
"runtime.checkpoint_artifacts",
1042-
{"action": "verify", "root": str(unit), "expected_sha256": digest},
1042+
{"action": "verify", "root": str(unit), "expected_sha256": digest}, large_local_snapshot=True,
10431043
)
10441044
assert (
10451045
hashlib.sha256(

0 commit comments

Comments
 (0)