Key a node on the code it reaches, not on the repository around it
Docs / docs (push) Successful in 21s
Playwright Tests / test-playwright (1, 2) (push) Successful in 2m13s
Playwright Tests / test-playwright (2, 2) (push) Successful in 1m52s
pre-commit / pre-commit (push) Failing after 2m6s
Test Backend / test-backend (push) Successful in 2m30s
Compose Smoke Test / test-compose (push) Successful in 32s
Playwright Tests / merge-reports (push) Successful in 1m53s

`sync` follows each node function's imports through the project's own modules
— stopping at the standard library, at anything installed, and at Fluksio
itself, whose checkout would otherwise be most of every digest — and records
the file list with what it hashed to. The engine hashes those files again when
the run is claimed, so the fingerprint is live rather than a snapshot, and
falls back to what sync recorded when it cannot see them: a remote worker's
runs used to share one empty digest, and therefore one key.

Three things follow. Editing a helper a node calls into re-runs that node, as
before. Editing something the node never reaches no longer re-runs anything —
a notebook two directories away was invalidating every arm. And
`Run.code_digest` is now the hash of its nodes' digests, so it is neither
looser nor tighter than "the code behind these numbers", which is what makes
it worth joining an exported table on.

`sync` says so too: it compares the per-node digest against the stored one, so
a helper edit prints `train: updated (flow, fit)` instead of `unchanged`. The
digest is read when the document is built rather than when the flow is
declared, so a second `sync()` in one process sees an edit between them.

Also: `fluksio runs` shows only the inputs that differ from what the flow
declares, fitted to the terminal, so a flow taking a few kB of json no longer
wraps every line.

Every existing cache entry misses once — the fingerprint changed shape.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A9Hdrmf2cwNABCnE5x9UJa
This commit is contained in:
2026-08-27 22:35:23 +02:00
co-authored by Claude Opus 5
parent 4479eeb726
commit 91ef2bbe9a
12 changed files with 530 additions and 36 deletions
+31 -2
View File
@@ -726,13 +726,19 @@ def _sync_one(
if not force:
known = _refuse_on_drift(client, target, definition)
saved = client.put_flow(target.document(origin) | {"version": version})
document = target.document(origin)
moved = _moved_code(stored, document)
saved = client.put_flow(document | {"version": version})
stored_version = int((saved.get("definition") or {}).get("version") or version)
if report.created or stored_version != version:
# The store bumps the version only when the content actually changed,
# so this is its own no-op detection rather than a second guess at it.
report.changed.append("flow")
version = stored_version
# Named before the shims are compared, because this is the case a shim
# comparison cannot see: the function is unchanged and something it calls
# into is not.
report.changed.extend(moved)
for node_id, code in target.shims().items():
if not report.created:
@@ -742,7 +748,8 @@ def _sync_one(
if stored_code == code:
continue
client.put_source(target.name, node_id, code)
report.changed.append(node_id)
if node_id not in report.changed:
report.changed.append(node_id)
if publish and (client.get_flow(target.name) or {}).get("has_draft"):
client.publish(target.name, version)
@@ -750,6 +757,28 @@ def _sync_one(
return report
def _moved_code(stored: dict[str, Any] | None, document: dict[str, Any]) -> list[str]:
"""The nodes whose reachable code changed since the last sync.
A node is otherwise named only when its generated shim text changes, and
the shim reflects the declared ports rather than what the function calls
into — so editing a helper printed as nothing at all, which reads as
"there was nothing to do".
"""
if stored is None:
return []
before = {
node.get("id"): node.get("code_digest") or ""
for node in (stored.get("definition") or {}).get("nodes") or []
}
return [
node_id
for node in document.get("nodes") or []
if (node_id := node.get("id")) in before
and before[node_id] != (node.get("code_digest") or "")
]
def _refuse_on_drift(
client: Client, target: Flow, definition: dict[str, Any]
) -> dict[str, str]: