artdag: Phase 4 Execute — content-addressed memo + incremental recompute + 15 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s

execute.sx folds a plan, runs each node via an injected runner (perform in
prod, op-table in tests), and memoizes results in a lib/persist kv backend
keyed by content-id. Incremental recompute falls out of content addressing:
a leaf change reassigns ids across its dirty closure, so re-running hits the
unchanged nodes and recomputes only the closure (cold 5 -> rerun 0 -> change 3).
Cross-dag subgraph sharing verified. execute 15/15, total 69/69.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 12:00:50 +00:00
parent 9a0f3d872c
commit a2f4fb5e89
6 changed files with 300 additions and 10 deletions

View File

@@ -30,7 +30,7 @@ edges.
## Status (rolling)
`bash lib/artdag/conformance.sh`**54/54** (3 suites: dag, analyze, plan)
`bash lib/artdag/conformance.sh`**69/69** (4 suites: dag, analyze, plan, execute)
## Ground rules
@@ -105,13 +105,13 @@ lib/artdag/optimize.sx lib/artdag/federation.sx
## Phase 4 — Execute (incremental + memoized)
- [ ] `lib/artdag/execute.sx` — interpret a plan: each node op runs via `perform`
- [x] `lib/artdag/execute.sx` — interpret a plan: each node op runs via `perform`
(mocked op in tests); results keyed by content-id
- [ ] **content-addressed memo cache** backed by `lib/persist/`: a node whose
- [x] **content-addressed memo cache** backed by `lib/persist/`: a node whose
content-id already has a stored result is skipped (cache hit)
- [ ] **incremental execute:** re-running after a leaf change recomputes only the
- [x] **incremental execute:** re-running after a leaf change recomputes only the
dirty closure; everything else is a cache hit
- [ ] `lib/artdag/tests/execute.sx` — full run, cache-hit on re-run, incremental
- [x] `lib/artdag/tests/execute.sx` — full run, cache-hit on re-run, incremental
recompute touches only dirty nodes (assert recompute count)
## Phase 5 — Effect-pipeline optimization
@@ -136,6 +136,18 @@ lib/artdag/optimize.sx lib/artdag/federation.sx
## Progress log
- **Phase 4 — Execute (incremental + memoized)** (execute suite 15/15, total 69/69).
`lib/artdag/execute.sx`: `artdag/execute` folds a plan, computing each node via an
injected `runner (op params input-results)` (production = `perform` to JAX/IPFS
adapter; tests = a pure op-table) and memoizing the result in a `lib/persist/` kv
backend keyed by **content-id**. A node whose content-id is already cached is a hit
(skipped). The keystone falls out of content addressing: changing a leaf changes the
ids of its whole dirty closure, so re-running the full plan against a warm cache
recomputes exactly those nodes and hits the rest — verified by recompute/hit counts
(5 cold → 0 on rerun → 3 after one leaf change, sibling reused). Cross-DAG sharing
verified: a different DAG containing a shared subgraph cache-hits it. `run`/`run-dirty`
helpers; `result-of`/`recompute-count`/`hit-count`/`recomputed` inspection.
- **Phase 3 — Plan** (plan suite 18/18, total 54/54). `lib/artdag/plan.sx`:
`artdag/plan` schedules a dag into Kahn-wave topological batches — each batch's
nodes have all in-scope deps satisfied by earlier batches, so they run in parallel.