Name the code a run ran, and let an interrupted sync finish
Three faults with one root: the stored body of a code-defined node is an import shim, and nothing that mattered was ever read from the code itself. - The run stamp could not identify what ran. The shim imports whatever is on disk when the worker starts, and an uncommitted tree stamps <commit>-dirty for every run it ever produces. Run.code_digest hashes the repository's .py files, memoized on their stat state, and it is read again when the run is actually claimed -- so a sweep queued for hours records the code each of its runs executed, not the code that was there when it was submitted. - The stage cache adopted code that was too new. The fingerprint hashed the shim, which is invariant under any edit to the imported function or anything it calls into, so a re-run was served from cache and answered without the outputs the edit added. It now carries the repo digest and the node's declared ports. Every fingerprint changes once, which invalidates the existing cache; a canvas flow has no repository and keys as before. - An interrupted sync looked like a hand-edited canvas. The engine answers a new-node template for a node with no stored body, and the template carries no marker, so the drift check read "somebody edited this" and demanded --force -- for the one state that re-running the sync is the fix for. NodeSource.missing states the fact, and sync skips those and reuses the bodies it read instead of asking for each one twice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,31 @@ def test_sync_refuses_to_overwrite_a_canvas_edit(api, flows):
|
||||
assert api.get_source("train", "evaluate").startswith(MARKER)
|
||||
|
||||
|
||||
def test_an_interrupted_sync_finishes_on_the_next_one(api, flows):
|
||||
"""A sync that died between the document and the bodies must be resumable.
|
||||
|
||||
That state — nodes named by a stored flow, with no source written for them
|
||||
yet — used to read as a canvas edit, because the engine answers a new-node
|
||||
template for a node with no body and the template carries no marker. The
|
||||
advice was `--force`, for a canvas nobody had touched.
|
||||
"""
|
||||
target = flows["train"]
|
||||
target.name = "resumed"
|
||||
try:
|
||||
# Exactly what the document PUT leaves behind before any body is written.
|
||||
api.put_flow(target.document(ORIGIN) | {"version": 1})
|
||||
assert api.get_source_entry("resumed", "fit")["missing"]
|
||||
|
||||
reports = sync([target], api, origin=ORIGIN)
|
||||
|
||||
assert "fit" in reports[0].changed
|
||||
assert api.get_source("resumed", "fit").startswith(MARKER)
|
||||
assert not api.get_source_entry("resumed", "fit")["missing"]
|
||||
assert not api.get_flow("resumed")["has_draft"]
|
||||
finally:
|
||||
target.name = "train"
|
||||
|
||||
|
||||
def test_sync_refuses_a_flow_it_did_not_create(api, flows):
|
||||
api.put_flow({"name": "drawn", "version": 1, "nodes": [], "mode": "batch"})
|
||||
api.publish("drawn", 1)
|
||||
|
||||
Reference in New Issue
Block a user