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:
2026-08-26 21:27:10 +02:00
co-authored by Claude Opus 5
parent 1f7c6646f1
commit 4a38c6ed31
15 changed files with 422 additions and 28 deletions
+14 -2
View File
@@ -695,6 +695,19 @@ def cmd_status(args: argparse.Namespace) -> int:
PARAMS_WIDTH = 80
def _stamp(row: dict[str, Any]) -> str:
"""What code a run ran: the commit, whether it was dirty, and the digest.
The digest is the part that separates two runs of one uncommitted tree —
the commit says `-dirty` for both, however much changed in between.
"""
commit, dirty, _ = (row.get("origin_commit") or "").partition("-dirty")
digest = row.get("code_digest") or ""
return (
commit[:7] + ("-dirty" if dirty else "") + (f"+{digest[:7]}" if digest else "")
)
def cmd_runs(args: argparse.Namespace) -> int:
try:
with _client_for(args) as client:
@@ -704,13 +717,12 @@ def cmd_runs(args: argparse.Namespace) -> int:
except httpx.HTTPError as exc:
return _unreachable(exc)
for row in rows:
commit = (row.get("origin_commit") or "")[:7]
params = json.dumps(row["params"])
if len(params) > PARAMS_WIDTH:
params = params[: PARAMS_WIDTH - 3] + "..."
_say(
f"{row['id']} {_status(row['status'], 9)} {row['flow']:<16} "
f"{row['duration_ms'] / 1000:7.1f}s {commit:<8} {params}"
f"{row['duration_ms'] / 1000:7.1f}s {_stamp(row):<22} {params}"
)
return 0