interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

Import the offline DAG evaluator from closed PR #590

merged d5174d1e1bd1c04c #936 · opened 2026-10-30 11:29 UTC · closed 2026-10-30 12:48 UTC · merged 2026-10-30 12:48 UTC

Imported from GitHub aien-dev/omega-mv#936, by drakestapleton

Base 089e5b05350ee61cc1439f17d3d3052a18a3e0a5 · Head 1b2f725b5188a0f3e1d78eb069d70518dfa67b9f

Merged on GitHub as 62d1d0d668f897386a0e311374f8dbcc5c32dde8; reachable from main c7acd2607139eedfabeac16b6042cefe8ede431f (observed 2026-11-18T16:35:43Z)

drakestapleton wrote on 2026-10-30 11:29 UTC

This imports tools/dagsim as new code. It does not claim validated costs.

The sources are verbatim from closed, unmerged PR #590 at 3bd56731c5517e2a9c8f195955c71e73dc6f9269 (research/cost-sim-583, which is no longer on origin). That includes dagsim.c, dagsim.h, dagsim_cli.c, the analytical unit tests, the CLI fixtures, and the frozen OEV1 schema those files implement. It does not include that PR's held-out receipts, measure.sh, heldout_memcpy.sh, or memcpy_probe.c. Those rounds were FAIL or INCONCLUSIVE and are not evidence for this import.

make test-dagsim checks that the evaluator's arithmetic matches numbers written in the fixtures. A passing run is not a calibrated cost, not a hardware measurement, and not a qualification of any machine. Host only. No GPU.

On AArch64 the binary links src/omega_om_units.c for SHA-256. On other hosts it links tests/dagsim/sha256_host.c, a stub that aborts if a blob digest is requested. dagsim --model is NOT_RUN on this x86_64 VM. The analytical suite does not hash.

The dagsim.o recipe keeps the forbidden-symbol list from 3bd56731: rx_gen_|aienos_cap_|rx_caproot_|rx_capadmin_|rx_world_|mmap|mprotect|fork|exec|dlopen|system. The first import commit had narrowed that to cuda|nvrm|gpu_. The restored list is what stops the offline evaluator from referencing the generation store, authority, the world, or a call that maps or runs code.

Seeded .om replacement of this evaluator is still #599. This C is the imported checker, not that replacement.

Test

make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-dagsim on Linux x86_64, Ubuntu clang 18.1.3:

  • dagsim_unit: 171 checks, 0 failed
  • tests/dagsim/run_cli.sh: every existing CLI check ok
  • clean dagsim.o: nm -u matches none of the forbidden symbols, and the recipe passes
  • planted mmap reference in a throwaway copy of dagsim.c: the recipe prints U mmap, removes build/dagsim.o, and make exits 1 with dagsim.o references an operation an offline evaluator must not have
  • crumb verify (crumb-compile/1 from crumb.lock d0f0b95d): OK

Head 52a82f392fa513ebbc2d9d719a0f14c385289b06. Chip qualification: NOT_RUN. Measured performance: NOT_RUN.

— Grokbot

<div><a href="https://cursor.com/agents/bc-99790e19-c8d7-50bf-b089-7f168b3944c6?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-99790e19-c8d7-50bf-b089-7f168b3944c6&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>

drakestapleton reviewed (COMMENTED) on 2026-10-30 12:47 UTC

Review at head 1b2f725b (main 089e5b05 merged in, 0 behind).

  • The Makefile change only adds lines (dagsim and test-dagsim), and the full nm guard is kept.
  • test-dagsim is a standalone target. It isn't part of the main SRCS or any gate, so the main build is unchanged.
  • Coverage gap: CI doesn't build or run test-dagsim. The only evidence of a pass is the authoring agent's x86 run (171 checks plus run_cli), and that log isn't attached. The aarch64 link path through src/omega_om_units.c has never been run. It's added to the next Spark run, and wiring test-dagsim into CI is tracked as a follow-up.

Accepted for merge on that basis, with no hardware or performance claim.

— Grokbot

Fetch it

A git bundle of the pull request's head, 46588 bytes.

curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/d5174d1e1bd1c04c.bundle -o d5174d1e1bd1c04c.bundle
git fetch d5174d1e1bd1c04c.bundle refs/pull/936/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-mv
936
1b2f725b5188a0f3e1d78eb069d70518dfa67b9f
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":936,"url":"https://github.com/aien-dev/omega-mv/pull/936","export_sha256":"7319147b350ad908bf0b731068ec3be7b8dee848041dc862f71455e8e4680140","imported_utc":"2026-11-18T16:35:43Z"}

Changes

diff --git a/.crumb b/.crumb
index 83cad2ea8..f3e51fe46 100644
--- a/.crumb
+++ b/.crumb
@@ -48,7 +48,7 @@
         },
         {
           "digest": "7ef7796693f23ad68d9a5bcaaee0f635018f4371139a040ba202d4ce7083ede8",
-          "last_commit": "dcccc0211",
+          "last_commit": "dd39bf71f",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
@@ -71,39 +71,39 @@
           "purpose": "Directory research. Purpose not yet described by a human."
         },
         {
-          "digest": "1cef97c8f2d852990d04fe5e791e877015c74a751648a020033a2459e02c5148",
-          "last_commit": "d94a503f7",
+          "digest": "f765ad87fdddd9b47f690b07298c951a0f7e7675dc5de4ffe44e33a0c14b1986",
+          "last_commit": "a8a6a3d3c",
           "name": "spec",
           "purpose": "Directory spec. Purpose not yet described by a human."
         },
         {
           "digest": "aaf5acb82fd4c720cd60c85fd6087f636c72a98e2f3740c9295dcfa525dc64d7",
-          "last_commit": "0575763e9",
+          "last_commit": "bf54b19fa",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "060352a843d719e700640477499fdc17ea661c3966abf9e059aedf8d90583e04",
-          "last_commit": "0575763e9",
+          "digest": "5395ff8ff9afceebe8e453788f80a3064b831513cc4cb92fd55869115e06b874",
+          "last_commit": "a8a6a3d3c",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
         {
-          "digest": "4e83dea21da137c30076c2dc0ca4f3a488f576f30a94e334558ad5ea523f3a6b",
-          "last_commit": "a50c3bd41",
+          "digest": "308db0e6cf45c0a48f01f5f5f228450f191389de68006915b9ecf9c65b9a2e29",
+          "last_commit": "a8a6a3d3c",
           "name": "tools",
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:0155c6fbf48664fa60e0b0660eb15d452aa15146443cedcbb5e028cbc18a612f",
-      "compiled_at": "2026-10-30T11:52:02Z",
+      "children_root": "sha256:07bf1706dcffbad66c0353871ff67a6749055da03cee8d8ebdf9a4c91e36bddc",
+      "compiled_at": "2026-10-30T12:31:50Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ac4b586178a485a5dcb8225803246ac14c3ab2feccdc3dd859790e30e837d40e",
+      "digest": "sha256:904fca8c0e0cf3e3a5e5adb73393e01c7018b920bb542d289904240f70e400d6",
       "evidence_files": 12622,
       "evidence_root": "sha256:b1a08e2ce56e6feada0d8a31f06fbd7adee57adc1c1ad8dec220293ee5d439f9",
-      "files": 17835,
-      "generated_at_commit": "0575763e91a5ada8d7c0102dafb6c966481f16d4",
-      "source_tree": "sha256:16a46ad0b18e168de8438ba8cb887a9bd2cae920be463892ff905c665fbcc3d5"
+      "files": 17849,
+      "generated_at_commit": "52a82f392fa513ebbc2d9d719a0f14c385289b06",
+      "source_tree": "sha256:75458da6553a0ee5ea2af95f46afb658e8a3f6e53cca6e3b4b9874035f78c2ed"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 4993e6fa3..dda6d20b5 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -5,6 +5,9 @@ Every model below did real work. A model is listed only for work it did. The orc
 
 | Model | What it did |
 |---|---|
+| Grok 4.7 | Merged current main (`089e5b053`) into #936. Conflicts were generated crumbs (`.crumb`, `tests/.crumb`); regenerated them with the crumb.lock tool (`d0f0b95d`). |
+| Grok 4.7 | Restored the offline DAG evaluator's forbidden-symbol guard from #590 (`3bd56731`): generation store, authority, world, and calls that map or run code. |
+| Grok 4.7 | Imported the offline DAG evaluator `tools/dagsim` verbatim from closed PR #590 (`3bd56731`) and wired a host `test-dagsim` target. Analytical fixture checks only. No validated cost claim. |
 | Codex (GPT-6.1 Sol) | FR-9 x86-64 Linux backend integration from historical 7eca2ac3f, full-language lowering, contract-loop/output-capacity/dead-branch repairs, division/shift proof-aware diagnostics, original-conductor and historical-mutant qualification repair, independent disassembly and cross-architecture qualification; orphaned-lane recovery, current mutation re-anchoring and x86 OM-2 emitted-storage bound |
 | Codex (GPT-6.1 Sol) | TileLab decimal-overflow and malformed-register-budget refusal repair, host regression fixtures and semantic negative controls (TL907-01) |
 | Codex (GPT-6.1 Sol) | Corrected qty prefix-query types and capacity-only diagnostic repairability, with exact-record regression controls (#911) |
diff --git a/Makefile b/Makefile
index a42b2b1f4..6b53cd124 100644
--- a/Makefile
+++ b/Makefile
@@ -1249,6 +1249,39 @@ $(RX_CM_UNIT): tests/runtime/rx_costmodel_unit.c $(RX_CM_OBJ) src/omega_om_units
 test-costmodel: $(RX_CM_UNIT)
 	./$(RX_CM_UNIT)
 
+# Offline resource-DAG evaluator, imported verbatim from closed PR #590
+# (commit 3bd56731). Host arithmetic on the numbers written in the fixtures.
+# Not a validated cost model and not a hardware measurement.
+# The seeded SHA-256 unit is AArch64 machine code; other hosts link
+# tests/dagsim/sha256_host.c, which aborts if a blob digest is requested.
+# dagsim.o keeps the #590 (3bd56731) nm guard: no generation store, authority,
+# world, or a call that maps or runs code.
+.PHONY: test-dagsim
+DS_OBJ = $(OUT_DIR)/dagsim.o
+DS_UNIT = $(OUT_DIR)/dagsim_unit
+DS_CLI = $(OUT_DIR)/dagsim
+ifeq ($(shell uname -m),aarch64)
+DS_SHA_SRC = src/omega_om_units.c
+else
+DS_SHA_SRC = tests/dagsim/sha256_host.c
+endif
+
+$(DS_OBJ): tools/dagsim/dagsim.c tools/dagsim/dagsim.h src/runtime/rx_costmodel.h | $(OUT_DIR)
+	$(CC) $(CFLAGS) -Itools/dagsim -c -o $@ tools/dagsim/dagsim.c
+	@if nm -u $@ | grep -E 'rx_gen_|aienos_cap_|rx_caproot_|rx_capadmin_|rx_world_|mmap|mprotect|fork|exec|dlopen|system' ; then \
+		echo "dagsim.o references an operation an offline evaluator must not have"; \
+		rm -f $@; exit 1; fi
+
+$(DS_UNIT): tests/dagsim/dagsim_unit.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) | $(OUT_DIR)
+	$(CC) $(CFLAGS) -Itools/dagsim -o $@ tests/dagsim/dagsim_unit.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) -lm
+
+$(DS_CLI): tools/dagsim/dagsim_cli.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) | $(OUT_DIR)
+	$(CC) $(CFLAGS) -Itools/dagsim -o $@ tools/dagsim/dagsim_cli.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) -lm
+
+test-dagsim: $(DS_UNIT) $(DS_CLI)
+	./$(DS_UNIT)
+	sh tests/dagsim/run_cli.sh $(DS_CLI) $(OUT_DIR)/dagsim-cli-out
+
 # AArch64 hosts: the gate. Real realizations, training, promotion through the
 # R9 barrier on the native authority, held-out workloads.
 RX_EMP_SRCS = src/runtime/rx_generation.c src/omega_om_units.c src/omega_evidence.c \
diff --git a/spec/.crumb b/spec/.crumb
index 0873a59ca..a226ce192 100644
--- a/spec/.crumb
+++ b/spec/.crumb
@@ -20,14 +20,14 @@
         }
       ],
       "children_root": "sha256:6834a3241647d3a098283d4eafedbdb1428dfa4d834f9ed5f22025b6d2303093",
-      "compiled_at": "2026-10-28T11:13:00Z",
+      "compiled_at": "2026-10-30T11:28:28Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:1cef97c8f2d852990d04fe5e791e877015c74a751648a020033a2459e02c5148",
+      "digest": "sha256:f765ad87fdddd9b47f690b07298c951a0f7e7675dc5de4ffe44e33a0c14b1986",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 62,
-      "generated_at_commit": "6999fa9e6dae4847c155ef4eacaece74f491d3ca",
-      "source_tree": "sha256:1ae5a611958d41bbaf64f47825a1a8bc3484e1cb954bcc622ed912ec7c330eb6"
+      "files": 63,
+      "generated_at_commit": "a8a6a3d3c47ce797430f045edc5eae11594ba36d",
+      "source_tree": "sha256:4cb3bb1977c84caacc34366f814d6fe403a2eda7b89b916948d29541675c59bb"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/spec/offline-evidence-v1.md b/spec/offline-evidence-v1.md
new file mode 100644
index 000000000..e468163e3
--- /dev/null
+++ b/spec/offline-evidence-v1.md
@@ -0,0 +1,131 @@
+# Offline evidence schema v1 (OEV1) for the resource-DAG cost simulator
+
+Status: FROZEN 2026-10-19 (omega-mv#583, implement item 1). Consumers: omega-mv#583
+(`tools/dagsim`), omega-mv#584 (candidate screening), aien-architecture#246 (lifecycle
+ledgers). A change to a frozen field is a v2, never an edit of v1.
+
+Purpose: one text file describes a machine, the build and calibration it was measured
+with, the resources, an operation DAG with demands, buffer lifetimes, dependencies,
+synchronization and the energy instrument, so that an offline evaluator (no GPU, no
+execution) can compose existing per-operation estimates into whole-DAG costs and bounds.
+The file never carries a number without saying where it came from.
+
+## File form
+
+Plain text, UTF-8, one record per line, fields separated by whitespace, `key=value`
+pairs after the record keyword, `#` to end of line is a comment. Unknown keywords are
+errors (a parser that silently ignores a field would let a fabricated or misspelled
+number through). Line numbers are reported on every error. No value may contain
+whitespace. Maximum 256 operations, 32 resources, 256 buffers, 1024 dependencies
+(static limits; a larger DAG is refused with `REFUSED_UNSUPPORTED`, not truncated).
+
+Units are fixed by the schema and never per record: time `ns`, bytes `B`,
+bandwidth `B/s`, power `W`, energy `J`, capacity `B`. Dates are `YYYY-MM-DD`.
+Integers are decimal; reals accept `1.5e9`.
+
+## Provenance (mandatory wherever a number appears)
+
+`prov=` takes exactly one of:
+
+| value | meaning |
+|---|---|
+| `specified` | a vendor or design ceiling (datasheet). Never attainable by itself. |
+| `measured` | read from an instrument on the named machine; `src=` names the receipt. |
+| `fitted` | produced by a model fitted on measurements (e.g. `rx_costmodel`); `src=` names the model blob or the fit receipt. |
+| `synthetic` | made up for a sensitivity study; results that depend on it are labelled synthetic and never ranked as real. |
+| `unknown` | nobody knows. The evaluator refuses to turn this into a number. |
+
+`lo=` and `hi=` give the interval that the source supports (for `measured`: the repeat
+spread of the receipt; for `fitted`: the model's predictive interval). Missing `lo`/`hi`
+on a `measured` or `fitted` value means "no interval known" and the evaluator reports
+the result without interval coverage.
+
+## Records
+
+```
+oev version=1
+machine id=<host> soc=<name> cores=<n> mem_bytes=<B> prov=specified src=<where>
+build repo=<name> sha=<40 hex> [physics=<sha>]
+calibration id=<name> taken=<YYYY-MM-DD> valid_days=<n> load1=<x> src=<receipt dir or file> [model=<path to rx_costmodel blob>]
+resource id=<name> kind=compute slots=<n> prov=<p> src=<s>
+resource id=<name> kind=bandwidth cap=<B/s> [lo=<B/s> hi=<B/s>] prov=<p> src=<s>
+resource id=<name> kind=capacity cap=<B> prov=<p> src=<s>
+resource id=<name> kind=launch prov=<p> src=<s>
+op id=<name> kind=<compute|copy|matvec|barrier|storage|persist> [engine=<compute res>] [t_ns=<x> lo=<x> hi=<x> prov=<p> src=<s>] [bytes=<B> bw=<bandwidth res>] [launch_ns=<x> launcher=<launch res>] [M=<n> N=<n> core=<0|1|2> arm=<n>]
+dep <from op> <to op>
+buffer id=<name> bytes=<B> cap=<capacity res> [first=<op>] [last=<op>]
+sync id=<name> ops=<op,op,...>
+energy instrument=<none|name> [boundary=<wall|gpu_module|soc>] [joules=<J> prov=measured src=<receipt>] [power_w=<W> prov=synthetic]
+removed op=<id> reason=<eliminated|reused|unchanged_dep|deferred|moved|shared|lookup> [ref=<op or result identity>] [proof=<src>]
+```
+
+Semantics the evaluator is allowed to rely on:
+
+- `machine`, `build`, `calibration` appear once. Every `measured` or `fitted` value is
+  valid only inside the calibration's validity envelope: the evaluator takes an
+  `asof` date and refuses (`REFUSED_STALE`) when `asof > taken + valid_days`, and refuses
+  (`REFUSED_NO_CALIBRATION`) when a measured or fitted value appears without a
+  `calibration` record. `load1` is the host load during the measurement; it travels with
+  every result so a loaded-box number is never quoted as a quiet-box number.
+- `resource kind=compute slots=n`: n operations may run at once on this engine. A
+  compute resource is a CPU core pool or the GPU; the schema does not model SM-level
+  occupancy.
+- `resource kind=bandwidth cap=B`: a shared fluid pipe. k operations streaming at once
+  each get `cap/k` (processor sharing). This is the only contention rule in v1; it is
+  what makes "sum of concurrent full-bandwidth claims" impossible by construction.
+- `resource kind=capacity`: a byte ledger. CPU and GPU unified memory are ONE capacity
+  resource on the Spark; a file that declares two for the same DRAM is wrong, not refused
+  (the evaluator cannot know), so the convention is one `unified_mem` resource.
+- `resource kind=launch`: a serial queue. Launch cost is paid once per op, one op at a
+  time per launch resource, before the op's own work. It is additive only when serialized;
+  two engines with two launch resources overlap their launches.
+- `op`: `t_ns` is the operation's own busy time on its engine (compute floor, `F/P`).
+  `bytes`/`bw` is its traffic on a bandwidth resource (traffic floor, `Q/B`). The op's
+  ideal floor is `launch + max(t_ns, bytes/cap)`; v1 assumes perfect overlap of its own
+  compute and traffic inside one op (the issue's stated floor). `kind=barrier` has no
+  cost and only orders. `kind=matvec` with `M`,`N`,`core`,`arm` and no `t_ns` gets its
+  `t_ns`, `lo`, `hi` from `rx_costmodel` (`rx_cm_predict`) using the blob named by
+  `calibration model=`; if that cell is not `known`, the op is `unknown` and the DAG is
+  refused. `kind=storage` and `kind=persist` are ops whose `bw` is a storage resource.
+- `dep a b`: b starts after a ends. Cycles are refused.
+- `buffer`: live from the start of `first` to the end of `last`. Missing `first` means
+  live from t=0 (resident state); missing `last` means live until the end. Peak live bytes
+  per capacity resource must not exceed `cap`, else `REFUSED_CAPACITY` naming the time
+  and the buffers.
+- `sync id=X ops=a,b,...`: declares a barrier op `X` (no cost, no engine) that completes
+  when every listed op has completed. Order later work after it with `dep X y`. A barrier
+  with a measured cost is written as `op id=X kind=barrier t_ns=... prov=...` plus `dep` lines.
+- `energy`: `instrument=none` makes every energy figure `UNMEASURED`. A named instrument
+  with `joules` and a receipt is a measured whole-run figure for the named boundary; the
+  evaluator never splits it per op. `power_w` with `prov=synthetic` allows a labelled
+  sensitivity figure `E = P * T` that is never ranked as real energy. `TDP` is not an
+  instrument.
+- `removed`: minimum-work accounting (parent clarification). An op listed here is absent
+  from the transformed DAG; the record keeps why. `reused`/`lookup` need `ref=`; a
+  remaining op that depends on a removed op whose reason is not `reused`/`lookup` is a
+  refusal (`REFUSED_REMOVED_REQUIRED`: required work cannot be removed by assertion).
+
+## What a result must carry
+
+Every evaluator output names: schema version, `machine.id`, `build.sha`,
+`calibration.id` and `load1`, `asof`, the status (`OK`, `REFUSED_*`), the set of
+provenances that fed the result, makespan nominal/lo/hi, the critical-path bound and each
+resource-work bound (both must be <= makespan), peak live bytes, energy status, the
+attribution ledger (compute, bandwidth, contention, launch, serialization, sync,
+residual), and the counterfactual sensitivities. A result whose inputs include
+`synthetic` is marked `synthetic=1`. A result never contains a number for an `unknown`
+input.
+
+## Pinned sources for v1 fixtures
+
+- Spark host `spark-b87b`, GB10, 20 cores, 128 GiB unified memory (specified), DRAM
+  273 GB/s (specified).
+- M1 hardware passport, omega-mv#578, receipts `~/yardsticks/aien-model/M1/` (measured,
+  load 15 to 29, omega f4a9849f): block1 realization call path 19.4 to 22.8 us per call;
+  block2 GPU submit lifecycle 36.8 to 41.6 ms per job (fixed, size independent); block4
+  CPU memcpy 1 thread 17.1 to 18.5 GB/s read+write at 1 GB, 8 threads 60.8 to 69.8 GB/s
+  at 1 GB; GPU weight stream 218.6 GB/s from handoff 2026-10-19-qwen38-decode-speed.md
+  (not re-measured in M1).
+- Not available on 2026-10-19 and therefore `unknown` in every fixture: aien-architecture
+  #244 traces, #252 clock calibration, #253 hardware atlas, #274 lifetime maps (all
+  NOT_RUN at the time of freezing). Fixtures that need them refuse.
diff --git a/tests/.crumb b/tests/.crumb
index d7afac0d1..5fbfcb29c 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -302,14 +302,14 @@
         }
       ],
       "children_root": "sha256:0c57282ff8cf1d34e5685e2729755f2978917e66debb5423961033be9d25c902",
-      "compiled_at": "2026-10-30T02:49:13Z",
+      "compiled_at": "2026-10-30T12:31:50Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:060352a843d719e700640477499fdc17ea661c3966abf9e059aedf8d90583e04",
+      "digest": "sha256:5395ff8ff9afceebe8e453788f80a3064b831513cc4cb92fd55869115e06b874",
       "evidence_files": 16,
       "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a",
-      "files": 1376,
-      "generated_at_commit": "2cb1ccb5d3c1a1ce1cb94a7a3dd3c221395c4e15",
-      "source_tree": "sha256:f37c9d192be40869a5ecb5658bf71a29e79db786899e4b94ecf241a49369974b"
+      "files": 1386,
+      "generated_at_commit": "52a82f392fa513ebbc2d9d719a0f14c385289b06",
+      "source_tree": "sha256:a3b853bb9c0edfc5f1413ccaa2698cc6ea920f2e8795756121667cc9d37f6679"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/dagsim/dagsim_unit.c b/tests/dagsim/dagsim_unit.c
new file mode 100644
index 000000000..f9c6c089e
--- /dev/null
+++ b/tests/dagsim/dagsim_unit.c
@@ -0,0 +1,502 @@
+/*
+ * dagsim_unit -- analytical tests for the offline resource-DAG evaluator
+ * (omega-mv#583 acceptance, first box). Any host, no GPU.
+ *
+ * Every case is a DAG whose answer is known by hand. The evaluator must
+ * produce exactly that number (to 1 ns), the same number twice, and never a
+ * makespan below its own bounds.
+ */
+#include "dagsim.h"
+#include "runtime/rx_costmodel.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int g_checks, g_fail;
+#define CHECK(cond, ...) do {                                            \
+        g_checks++;                                                      \
+        if (!(cond)) {                                                   \
+            g_fail++;                                                    \
+            fprintf(stderr, "  FAIL %s:%d ", __FILE__, __LINE__);        \
+            fprintf(stderr, __VA_ARGS__);                                \
+            fputc('\n', stderr);                                         \
+        }                                                                \
+    } while (0)
+#define NEAR(a, b, tol) (fabs((a) - (b)) <= (tol))
+
+static const char *HDR =
+    "oev version=1\n"
+    "machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test\n"
+    "build repo=omega-mv sha=0000000000000000000000000000000000000000\n"
+    "calibration id=c1 taken=2026-10-19 valid_days=30 load1=1.0 src=test\n"
+    "resource id=mem kind=capacity cap=1000 prov=specified src=test\n"
+    "energy instrument=none\n";
+
+static int eval_text(const char *body, ds_model *m, ds_result *r, const ds_opts *o) {
+    char text[8192], err[256];
+    snprintf(text, sizeof text, "%s%s", HDR, body);
+    int rc = ds_parse_text(text, m, err, sizeof err);
+    if (rc != DS_OK) { fprintf(stderr, "  parse: %s\n", err); r->status = rc; return rc; }
+    ds_opts def; memset(&def, 0, sizeof def);
+    def.asof_day = ds_day_from_date("2026-10-20");
+    def.interval_q = 0.9;
+    rc = ds_eval(m, o ? o : &def, r);
+    /* invariants every OK result must satisfy */
+    if (rc == DS_OK) {
+        CHECK(r->makespan_ns + 1e-6 >= r->bound_ns, "makespan %.1f below bound %.1f", r->makespan_ns, r->bound_ns);
+        CHECK(r->makespan_ns + 1e-6 >= r->bound_critical_path_ns, "below critical path bound");
+        double s = 0; for (int i = 0; i < DS_ATTR_N; i++) s += r->attr_ns[i];
+        CHECK(NEAR(s, r->makespan_ns, 1e-6), "attribution %.3f does not sum to makespan %.3f", s, r->makespan_ns);
+        ds_result r2; ds_eval(m, o ? o : &def, &r2);
+        CHECK(memcmp(&r2, r, sizeof r2) == 0, "not deterministic");
+    }
+    return rc;
+}
+
+static void test_serial_chain(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=20 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A B\ndep B C\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "serial chain status %s: %s", ds_status_name(r.status), r.reason);
+    CHECK(NEAR(r.makespan_ns, 60, 1e-9), "serial makespan %.3f", r.makespan_ns);
+    CHECK(NEAR(r.bound_critical_path_ns, 60, 1e-9), "critical path bound %.3f", r.bound_critical_path_ns);
+    CHECK(r.n_critical == 3, "critical path length %d", r.n_critical);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_COMPUTE], 60, 1e-9), "compute attribution %.3f", r.attr_ns[DS_ATTR_COMPUTE]);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_RESIDUAL], 0, 1e-9), "residual %.3f", r.attr_ns[DS_ATTR_RESIDUAL]);
+    CHECK(NEAR(r.start_ns[2], 30, 1e-9) && NEAR(r.end_ns[2], 60, 1e-9), "C window");
+    CHECK(r.prov_mask == (1u << DS_PROV_MEASURED | 1u << DS_PROV_SPECIFIED), "prov mask %x", r.prov_mask);
+    CHECK(r.n_ops == 3 && NEAR(r.total_busy_ns, 60, 1e-9), "conservation");
+}
+
+static void test_perfect_overlap(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=4 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=20 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "overlap status %s", ds_status_name(r.status));
+    CHECK(NEAR(r.makespan_ns, 30, 1e-9), "independent overlap makespan %.3f", r.makespan_ns);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_SERIALIZATION], 0, 1e-9), "no serialization when slots suffice");
+    /* same DAG, one slot: work bound 60 binds and the wait is serialization */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=20 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "one slot status");
+    CHECK(NEAR(r.makespan_ns, 60, 1e-9), "one-slot makespan %.3f", r.makespan_ns);
+    CHECK(NEAR(r.bound_critical_path_ns, 30, 1e-9), "critical path stays 30");
+    CHECK(NEAR(r.bound_ns, 60, 1e-9), "resource bound 60, got %.3f", r.bound_ns);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_SERIALIZATION], 30, 1e-9), "serialization %.3f", r.attr_ns[DS_ATTR_SERIALIZATION]);
+}
+
+static void test_shared_bandwidth(void) {
+    ds_model m; ds_result r;
+    /* two 1 GB copies on a 1 GB/s pipe, both slots free: each gets half, both end at 2 s */
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n"
+        "op id=B kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "bw status %s: %s", ds_status_name(r.status), r.reason);
+    CHECK(NEAR(r.makespan_ns, 2e9, 1e-3), "two concurrent full-bandwidth claims must not sum: %.0f", r.makespan_ns);
+    CHECK(NEAR(r.end_ns[0], 2e9, 1e-3) && NEAR(r.end_ns[1], 2e9, 1e-3), "both end at 2 s");
+    CHECK(NEAR(r.op_contention_ns[0], 1e9, 1e-3), "A contention %.0f", r.op_contention_ns[0]);
+    CHECK(NEAR(r.bound_critical_path_ns, 1e9, 1e-3), "cp bound 1 s");
+    CHECK(NEAR(r.bound_ns, 2e9, 1e-3), "pipe work bound 2 s, got %.0f", r.bound_ns);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_BANDWIDTH] + r.attr_ns[DS_ATTR_CONTENTION], 2e9, 1e-3), "bw+contention = 2 s");
+    CHECK(NEAR(r.attr_ns[DS_ATTR_CONTENTION], 1e9, 1e-3), "contention attributed 1 s, got %.0f", r.attr_ns[DS_ATTR_CONTENTION]);
+    /* unequal: B is half the size; it finishes at 1 s, A at 1.5 s */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n"
+        "op id=B kind=copy engine=cpu bytes=5e8 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "bw2 status");
+    CHECK(NEAR(r.end_ns[1], 1e9, 1e-3), "B ends at 1 s, got %.0f", r.end_ns[1]);
+    CHECK(NEAR(r.end_ns[0], 1.5e9, 1e-3), "A ends at 1.5 s, got %.0f", r.end_ns[0]);
+    /* compute and traffic inside one op overlap: floor is max(F/P, Q/B) */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=compute engine=cpu t_ns=5e8 bytes=1e9 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 1e9, 1e-3), "max(F/P,Q/B) floor, got %.0f", r.makespan_ns);
+    CHECK(NEAR(r.op_floor_ns[0], 1e9, 1e-3), "op floor");
+    /* a compute-bound op streaming alone has no contention, whatever its busy time */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=compute engine=cpu t_ns=4e9 bytes=1e9 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 4e9, 1e-3) && NEAR(r.op_contention_ns[0], 0, 1e-3),
+          "compute-bound op alone: contention %.0f (want 0)", r.op_contention_ns[0]);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_COMPUTE], 4e9, 1e-3), "attributed as compute");
+    /* serialized sharing: one slot, so no contention and makespan = sum */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n"
+        "op id=B kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 2e9, 1e-3) && NEAR(r.attr_ns[DS_ATTR_CONTENTION], 0, 1e-3),
+          "serialized copies: no contention, makespan %.0f contention %.0f", r.makespan_ns, r.attr_ns[DS_ATTR_CONTENTION]);
+}
+
+static void test_capacity_refusal(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "buffer id=x bytes=600 cap=mem first=A last=A\n"
+        "buffer id=y bytes=600 cap=mem first=A last=A\n", &m, &r, NULL);
+    CHECK(rc == DS_REFUSED_CAPACITY, "1200 live bytes in 1000 must refuse, got %s", ds_status_name(rc));
+    CHECK(strstr(r.reason, "x") && strstr(r.reason, "y"), "reason names the buffers: %s", r.reason);
+    /* same buffers, disjoint lifetimes: fits */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "dep A B\n"
+        "buffer id=x bytes=600 cap=mem first=A last=A\n"
+        "buffer id=y bytes=600 cap=mem first=B last=B\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "disjoint lifetimes fit, got %s: %s", ds_status_name(rc), r.reason);
+    CHECK(NEAR(r.peak_live_bytes[0], 600, 1e-9), "peak 600, got %.0f", r.peak_live_bytes[0]);
+    /* a single buffer larger than the ledger refuses before any scheduling */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "buffer id=big bytes=2000 cap=mem\n", &m, &r, NULL);
+    CHECK(rc == DS_REFUSED_CAPACITY, "oversized resident buffer refuses");
+}
+
+static void test_lifetimes(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "dep A B\ndep B C\n"
+        "buffer id=resident bytes=100 cap=mem\n"
+        "buffer id=x bytes=300 cap=mem first=A last=B\n"
+        "buffer id=y bytes=400 cap=mem first=B last=C\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "lifetimes status %s: %s", ds_status_name(rc), r.reason);
+    CHECK(NEAR(r.peak_live_bytes[0], 800, 1e-9), "peak = resident + x + y during B, got %.0f", r.peak_live_bytes[0]);
+    CHECK(NEAR(r.peak_live_at_ns[0], 10, 1e-9), "peak reached when B starts, got %.1f", r.peak_live_at_ns[0]);
+}
+
+static void test_sync(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=5 prov=measured src=t\n"
+        "sync id=s ops=A,B\n"
+        "dep s C\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "sync status %s: %s", ds_status_name(rc), r.reason);
+    int c = ds_find_op(&m, "C");
+    CHECK(c >= 0 && NEAR(r.start_ns[c], 30, 1e-9), "C waits for the slower of A,B: start %.1f", c >= 0 ? r.start_ns[c] : -1);
+    CHECK(NEAR(r.makespan_ns, 35, 1e-9), "sync makespan %.1f", r.makespan_ns);
+    /* a barrier with a declared cost is attributed as sync */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "op id=fence kind=barrier t_ns=7 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=5 prov=measured src=t\n"
+        "dep A fence\ndep B fence\ndep fence C\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 42, 1e-9), "costed barrier makespan %.1f", r.makespan_ns);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_SYNC], 7, 1e-9), "sync attribution %.1f", r.attr_ns[DS_ATTR_SYNC]);
+}
+
+static void test_launch(void) {
+    ds_model m; ds_result r;
+    /* two jobs, one launcher, one slot: launches serialize, 80 ms */
+    int rc = eval_text(
+        "resource id=gpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=L kind=launch prov=measured src=t\n"
+        "op id=A kind=compute engine=gpu t_ns=0 launch_ns=40e6 launcher=L prov=measured src=t\n"
+        "op id=B kind=compute engine=gpu t_ns=0 launch_ns=40e6 launcher=L prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 80e6, 1e-3), "serialized launches add: %.0f", r.makespan_ns);
+    CHECK(NEAR(r.attr_ns[DS_ATTR_LAUNCH] + r.attr_ns[DS_ATTR_SERIALIZATION], 80e6, 1e-3), "launch+serialization");
+    /* two engines, two launchers: launches overlap, 40 ms */
+    rc = eval_text(
+        "resource id=gpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "resource id=L1 kind=launch prov=measured src=t\n"
+        "resource id=L2 kind=launch prov=measured src=t\n"
+        "op id=A kind=compute engine=gpu t_ns=0 launch_ns=40e6 launcher=L1 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=0 launch_ns=40e6 launcher=L2 prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && NEAR(r.makespan_ns, 40e6, 1e-3), "independent launches overlap: %.0f", r.makespan_ns);
+}
+
+static void test_calibration(void) {
+    ds_model m; ds_result r; char text[4096], err[256];
+    const char *body =
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n";
+    /* stale: asof past taken + valid_days */
+    ds_opts o; memset(&o, 0, sizeof o); o.interval_q = 0.9;
+    o.asof_day = ds_day_from_date("2026-11-19");
+    int rc = eval_text(body, &m, &r, &o);
+    CHECK(rc == DS_REFUSED_STALE, "31 days after a 30-day calibration refuses, got %s", ds_status_name(rc));
+    o.asof_day = ds_day_from_date("2026-11-18");
+    rc = eval_text(body, &m, &r, &o);
+    CHECK(rc == DS_OK, "last valid day is fine, got %s", ds_status_name(rc));
+    /* missing: measured value without a calibration record */
+    snprintf(text, sizeof text,
+        "oev version=1\n"
+        "machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test\n"
+        "build repo=omega-mv sha=0000000000000000000000000000000000000000\n"
+        "energy instrument=none\n%s", body);
+    rc = ds_parse_text(text, &m, err, sizeof err);
+    CHECK(rc == DS_OK, "parse without calibration: %s", err);
+    o.asof_day = ds_day_from_date("2026-10-20");
+    rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_REFUSED_NO_CALIBRATION, "measured without calibration refuses, got %s", ds_status_name(rc));
+    /* unknown provenance never becomes a number */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu prov=unknown src=arch-244-not-run\n"
+        "dep A B\n", &m, &r, NULL);
+    CHECK(rc == DS_REFUSED_UNKNOWN, "unknown op refuses, got %s", ds_status_name(rc));
+    CHECK(strstr(r.reason, "B") != NULL, "reason names the op: %s", r.reason);
+    CHECK(r.makespan_ns == 0, "no makespan on refusal");
+    /* synthetic input marks the result */
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=synthetic src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && r.synthetic == 1, "synthetic flag");
+}
+
+static void test_intervals(void) {
+    ds_model m; ds_result r; double lo, hi;
+    char text[8192];
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 lo=0.5e9 hi=2e9 prov=measured src=t\n"
+        "op id=A kind=compute engine=cpu t_ns=100 lo=80 hi=150 prov=measured src=t\n"
+        "op id=B kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n"
+        "dep A B\n");
+    char err[256];
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_OK, "parse: %s", err);
+    ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+    int rc = ds_eval_interval(&m, &o, &r, &lo, &hi);
+    CHECK(rc == DS_OK, "interval status");
+    CHECK(NEAR(r.makespan_ns, 100 + 1e9, 1e-3), "nominal %.0f", r.makespan_ns);
+    CHECK(NEAR(lo, 80 + 0.5e9, 1e-3), "optimistic %.0f", lo);
+    CHECK(NEAR(hi, 150 + 2e9, 1e-3), "pessimistic %.0f", hi);
+}
+
+static void test_energy(void) {
+    ds_model m; ds_result r; char text[4096], err[256];
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=1e9 prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK && !r.energy_measured && !r.energy_synthetic, "instrument=none means UNMEASURED");
+    snprintf(text, sizeof text,
+        "oev version=1\n"
+        "machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test\n"
+        "build repo=omega-mv sha=0000000000000000000000000000000000000000\n"
+        "calibration id=c1 taken=2026-10-19 valid_days=30 load1=1.0 src=test\n"
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=1e9 prov=measured src=t\n"
+        "energy instrument=tdp-guess boundary=soc power_w=100 prov=synthetic\n");
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_OK, "parse: %s", err);
+    ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+    rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_OK && r.energy_synthetic == 1 && !r.energy_measured && NEAR(r.energy_j, 100.0, 1e-9) && r.synthetic,
+          "synthetic power gives a labelled E=P*T (100 J), got %.3f syn=%d", r.energy_j, r.energy_synthetic);
+    snprintf(text, sizeof text,
+        "oev version=1\n"
+        "machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test\n"
+        "build repo=omega-mv sha=0000000000000000000000000000000000000000\n"
+        "calibration id=c1 taken=2026-10-19 valid_days=30 load1=1.0 src=test\n"
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=1e9 prov=measured src=t\n"
+        "energy instrument=cyberpower-ups-nut boundary=wall joules=42.5 prov=measured src=receipt.json\n");
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_OK, "parse: %s", err);
+    rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_OK && r.energy_measured == 1 && NEAR(r.energy_j, 42.5, 1e-9) && !r.synthetic, "measured joules pass through");
+    /* a measured joules figure with no instrument name is a parse error */
+    snprintf(text, sizeof text,
+        "oev version=1\n"
+        "machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test\n"
+        "build repo=omega-mv sha=0000000000000000000000000000000000000000\n"
+        "energy instrument=none joules=42.5 prov=measured src=x\n");
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_PARSE_ERROR, "joules without an instrument is refused at parse");
+}
+
+static void test_parse_and_cycles(void) {
+    ds_model m; ds_result r; char text[4096], err[256];
+    snprintf(text, sizeof text, "%s%s", HDR, "resource id=cpu kind=compute slots=1 prov=specified src=test\nbogus x=1\n");
+    int rc = ds_parse_text(text, &m, err, sizeof err);
+    CHECK(rc == DS_PARSE_ERROR && strstr(err, "line 8"), "unknown keyword is an error with its line: %s", err);
+    snprintf(text, sizeof text, "%s%s", HDR, "resource id=cpu kind=compute slots=1 prov=specified src=test\nop id=A kind=compute engine=cpu t_ns=1 prov=measured src=t typo=3\n");
+    rc = ds_parse_text(text, &m, err, sizeof err);
+    CHECK(rc == DS_PARSE_ERROR, "unknown field is an error: %s", err);
+    snprintf(text, sizeof text, "%s%s", HDR, "resource id=cpu kind=compute slots=1 prov=specified src=test\nop id=A kind=compute engine=cpu t_ns=1 src=t\n");
+    rc = ds_parse_text(text, &m, err, sizeof err);
+    CHECK(rc == DS_PARSE_ERROR, "a number without prov is an error: %s", err);
+    rc = eval_text(
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=1 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=1 prov=measured src=t\n"
+        "dep A B\ndep B A\n", &m, &r, NULL);
+    CHECK(rc == DS_REFUSED_CYCLE, "cycle refuses, got %s", ds_status_name(rc));
+    /* the pinned fixture parses and evaluates */
+    rc = ds_parse_file("tests/dagsim/fixtures/m1_spark_subset.oev", &m, err, sizeof err);
+    CHECK(rc == DS_OK, "fixture parses: %s", err);
+    if (rc == DS_OK) {
+        ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+        rc = ds_eval(&m, &o, &r);
+        CHECK(rc == DS_OK, "fixture evaluates: %s", r.reason);
+        CHECK(NEAR(r.makespan_ns, 20000 + 40736700 + 111000000, 1e-3), "fixture serial makespan %.0f", r.makespan_ns);
+        CHECK(!r.energy_measured && !r.energy_synthetic, "fixture energy UNMEASURED");
+    }
+}
+
+/* rx_costmodel integration: a matvec op with a fitted blob gets its time from
+ * rx_cm_predict; an unknown cell refuses. Synthetic observations, so the blob is
+ * labelled fitted on synthetic data and the result is marked synthetic. */
+static void test_costmodel_reuse(void) {
+    RxCostModel cm; rx_cm_init(&cm, 2);
+    uint64_t rng = 0x9E3779B97F4A7C15ull;
+    for (int i = 0; i < 200; i++) {
+        rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17;
+        uint32_t M = 8 + (uint32_t)(rng % 120), N = 4 + (uint32_t)((rng >> 20) % 60);
+        RxCmFeatures f; memset(&f, 0, sizeof f);
+        f.op = RX_CM_OP_MATVEC; f.M = M; f.N = N; f.state_bytes = ((uint64_t)M * N + M + N) * 8u;
+        f.cache_bytes = 1u << 20; f.core = RX_CM_CORE_X925; f.eligible = 3;
+        double l2 = 10.0 + 0.95 * (log2((double)M) + log2((double)N));
+        RxCmObservation o; o.failed = 0; o.ps_per_call = (uint64_t)pow(2.0, l2);
+        rx_cm_observe(&cm, &f, 0, &o);
+    }
+    ds_model m; ds_result r; char text[4096], err[256];
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=mv kind=matvec engine=cpu M=64 N=16 core=0 arm=0 prov=fitted src=rx_costmodel\n");
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_OK, "parse: %s", err);
+    ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+    int rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_REFUSED_UNKNOWN, "matvec with no model refuses, got %s", ds_status_name(rc));
+    o.costmodel = &cm;
+    rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_OK, "matvec with model: %s %s", ds_status_name(rc), r.reason);
+    RxCmFeatures f; memset(&f, 0, sizeof f);
+    f.op = RX_CM_OP_MATVEC; f.M = 64; f.N = 16; f.state_bytes = (64u * 16u + 64u + 16u) * 8u; f.cache_bytes = 1u << 20; f.core = 0;
+    RxCmPrediction p; rx_cm_predict(&cm, &f, 0, &p);
+    CHECK(p.known, "cell known");
+    CHECK(NEAR(r.makespan_ns, pow(2.0, p.mean_log2_ps) / 1000.0, 1e-6), "time comes from rx_cm_predict: %.3f vs %.3f", r.makespan_ns, pow(2.0, p.mean_log2_ps) / 1000.0);
+    CHECK(r.prov_mask & (1u << DS_PROV_FITTED), "fitted provenance recorded");
+    /* arm 1 was never observed: unknown, refuse */
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=mv kind=matvec engine=cpu M=64 N=16 core=0 arm=1 prov=fitted src=rx_costmodel\n");
+    CHECK(ds_parse_text(text, &m, err, sizeof err) == DS_OK, "parse: %s", err);
+    rc = ds_eval(&m, &o, &r);
+    CHECK(rc == DS_REFUSED_UNKNOWN, "unobserved arm refuses, got %s", ds_status_name(rc));
+}
+
+static void test_counterfactual(void) {
+    ds_model m; ds_result r;
+    int rc = eval_text(
+        "resource id=cpu kind=compute slots=2 prov=specified src=test\n"
+        "resource id=pipe kind=bandwidth cap=1e9 prov=measured src=t\n"
+        "op id=A kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n"
+        "op id=B kind=copy engine=cpu bytes=1e9 bw=pipe prov=measured src=t\n", &m, &r, NULL);
+    CHECK(rc == DS_OK, "cf status");
+    ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+    double d = ds_counterfactual(&m, &o, ds_find_res(&m, "pipe"));
+    CHECK(NEAR(d, 1e9, 1e-3), "doubling the pipe halves the bandwidth-bound DAG: %.0f", d);
+    d = ds_counterfactual(&m, &o, ds_find_res(&m, "cpu"));
+    CHECK(NEAR(d, 2e9, 1e-3), "doubling slots changes nothing when the pipe binds: %.0f", d);
+}
+
+static void test_minimum_work_diff(void) {
+    ds_model base, tr; ds_diff d; char text[8192], err[256];
+    const char *base_body =
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B kind=compute engine=cpu t_ns=20 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A B\ndep B C\n";
+    snprintf(text, sizeof text, "%s%s", HDR, base_body);
+    CHECK(ds_parse_text(text, &base, err, sizeof err) == DS_OK, "base: %s", err);
+    ds_opts o; memset(&o, 0, sizeof o); o.asof_day = ds_day_from_date("2026-10-20"); o.interval_q = 0.9;
+    /* no change: identical transformed DAG adds no nodes and removes none */
+    CHECK(ds_parse_text(text, &tr, err, sizeof err) == DS_OK, "tr: %s", err);
+    CHECK(ds_diff_models(&base, &tr, &o, &d) == DS_OK && d.n_removed == 0 && d.n_added == 0 && d.n_kept == 3, "no-change fixture: removed %d added %d kept %d", d.n_removed, d.n_added, d.n_kept);
+    /* B reused from a lookup: valid, 20 ns of work moves to the reused ledger */
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=B_lookup kind=compute engine=cpu t_ns=2 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A B_lookup\ndep B_lookup C\n"
+        "removed op=B reason=reused ref=B_lookup proof=rx_plan:digest\n");
+    CHECK(ds_parse_text(text, &tr, err, sizeof err) == DS_OK, "tr2: %s", err);
+    int rc = ds_diff_models(&base, &tr, &o, &d);
+    CHECK(rc == DS_OK && NEAR(d.removed_ns[DS_RM_REUSED], 20, 1e-9) && d.n_added == 1, "reuse accounted: %s rc=%s", d.reason, ds_status_name(rc));
+    /* eliminated with no proof while C still consumed it: required work cannot vanish by assertion */
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A C\n"
+        "removed op=B reason=eliminated\n");
+    CHECK(ds_parse_text(text, &tr, err, sizeof err) == DS_OK, "tr3: %s", err);
+    rc = ds_diff_models(&base, &tr, &o, &d);
+    CHECK(rc == DS_REFUSED_REMOVED_REQUIRED && d.required_removed, "unproven elimination of consumed work refuses, got %s", ds_status_name(rc));
+    /* unchanged_dep on A, but A changed: the consumer is invalidated */
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A C\n"
+        "removed op=B reason=unchanged_dep ref=A\n");
+    CHECK(ds_parse_text(text, &tr, err, sizeof err) == DS_OK, "tr4: %s", err);
+    rc = ds_diff_models(&base, &tr, &o, &d);
+    CHECK(rc == DS_OK && NEAR(d.removed_ns[DS_RM_UNCHANGED_DEP], 20, 1e-9), "unchanged dependency allows skipping B");
+    o.changed = "A";
+    rc = ds_diff_models(&base, &tr, &o, &d);
+    CHECK(rc == DS_REFUSED_REMOVED_REQUIRED, "changed A invalidates the skip of B, got %s", ds_status_name(rc));
+    o.changed = NULL;
+    /* shared work counted twice is detected */
+    snprintf(text, sizeof text, "%s%s", HDR,
+        "resource id=cpu kind=compute slots=1 prov=specified src=test\n"
+        "op id=A kind=compute engine=cpu t_ns=10 prov=measured src=t\n"
+        "op id=C kind=compute engine=cpu t_ns=30 prov=measured src=t\n"
+        "dep A C\n"
+        "removed op=B reason=shared ref=A\n"
+        "removed op=B reason=shared ref=C\n");
+    CHECK(ds_parse_text(text, &tr, err, sizeof err) == DS_OK, "tr5: %s", err);
+    rc = ds_diff_models(&base, &tr, &o, &d);
+    CHECK(rc != DS_OK && d.double_counted, "double-counted shared work detected");
+}
+
+int main(void) {
+    test_serial_chain();
+    test_perfect_overlap();
+    test_shared_bandwidth();
+    test_capacity_refusal();
+    test_lifetimes();
+    test_sync();
+    test_launch();
+    test_calibration();
+    test_intervals();
+    test_energy();
+    test_parse_and_cycles();
+    test_costmodel_reuse();
+    test_counterfactual();
+    test_minimum_work_diff();
+    printf("dagsim_unit: %d checks, %d failed\n", g_checks, g_fail);
+    return g_fail ? 1 : 0;
+}
diff --git a/tests/dagsim/fixtures/m1_spark_overlap.oev b/tests/dagsim/fixtures/m1_spark_overlap.oev
new file mode 100644
index 000000000..249980f17
--- /dev/null
+++ b/tests/dagsim/fixtures/m1_spark_overlap.oev
@@ -0,0 +1,34 @@
+# OEV1 fixture: Spark M1 hardware passport subset (omega-mv#578), pinned 2026-10-19.
+# Every number below is a loaded-machine measurement (load1 15 to 29) or a datasheet
+# ceiling, and says which. Nothing here was produced by running a GPU in this harness.
+oev version=1
+machine id=spark-b87b soc=GB10 cores=20 mem_bytes=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+build repo=omega-mv sha=f4a9849f00000000000000000000000000000000 physics=6d7cf0d4
+calibration id=M1-20261019 taken=2026-10-19 valid_days=30 load1=24.2 src=~/yardsticks/aien-model/M1/
+
+# Resources. One capacity ledger for CPU and GPU (unified memory).
+resource id=cpu kind=compute slots=20 prov=specified src=nproc
+resource id=gpu kind=compute slots=1 prov=specified src=one-job-at-a-time-engine
+resource id=dram_spec kind=bandwidth cap=273e9 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=dram_gpu kind=bandwidth cap=218.6e9 lo=218.6e9 hi=219e9 prov=measured src=handoff-2026-10-19-qwen38-decode-speed.md:calc:e726ff77
+resource id=dram_cpu kind=bandwidth cap=65.4e9 lo=60.8e9 hi=69.8e9 prov=measured src=M1/block4.csv:gb=1,threads=8
+resource id=unified_mem kind=capacity cap=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=gpu_launch kind=launch prov=measured src=M1/block2.csv
+
+# Ops. Same work as m1_spark_subset.oev, but the 1 GB copy is split into two
+# concurrent halves on two CPU slots. They share dram_cpu (processor sharing).
+# At two threads the per-thread busy time (55.5 ms) still binds and the shared
+# pipe does not (2 GB of traffic at 65.4 GB/s is 30.6 ms), which is what block4
+# shows at 4 threads (50 to 61 GB/s). More halves would hit the pipe.
+op id=realize kind=compute engine=cpu t_ns=20000 lo=19400 hi=22800 prov=measured src=M1/block1.csv:path_ns_per_call
+op id=gpu_job kind=compute engine=gpu t_ns=0 prov=measured src=M1/block2.csv:vecadd_65 launch_ns=40736700 launcher=gpu_launch
+op id=copyA kind=copy engine=cpu t_ns=55500000 lo=53950000 hi=58300000 prov=measured src=M1/block4.csv:gb=1,threads=1,half bytes=1000000000 bw=dram_cpu
+op id=copyB kind=copy engine=cpu t_ns=55500000 lo=53950000 hi=58300000 prov=measured src=M1/block4.csv:gb=1,threads=1,half bytes=1000000000 bw=dram_cpu
+dep realize gpu_job
+dep gpu_job copyA
+dep gpu_job copyB
+
+buffer id=src1g bytes=1000000000 cap=unified_mem first=copyA last=copyB
+buffer id=dst1g bytes=1000000000 cap=unified_mem first=copyA last=copyB
+
+energy instrument=none
diff --git a/tests/dagsim/fixtures/m1_spark_subset.oev b/tests/dagsim/fixtures/m1_spark_subset.oev
new file mode 100644
index 000000000..34fdf7364
--- /dev/null
+++ b/tests/dagsim/fixtures/m1_spark_subset.oev
@@ -0,0 +1,32 @@
+# OEV1 fixture: Spark M1 hardware passport subset (omega-mv#578), pinned 2026-10-19.
+# Every number below is a loaded-machine measurement (load1 15 to 29) or a datasheet
+# ceiling, and says which. Nothing here was produced by running a GPU in this harness.
+oev version=1
+machine id=spark-b87b soc=GB10 cores=20 mem_bytes=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+build repo=omega-mv sha=f4a9849f00000000000000000000000000000000 physics=6d7cf0d4
+calibration id=M1-20261019 taken=2026-10-19 valid_days=30 load1=24.2 src=~/yardsticks/aien-model/M1/
+
+# Resources. One capacity ledger for CPU and GPU (unified memory).
+resource id=cpu kind=compute slots=20 prov=specified src=nproc
+resource id=gpu kind=compute slots=1 prov=specified src=one-job-at-a-time-engine
+resource id=dram_spec kind=bandwidth cap=273e9 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=dram_gpu kind=bandwidth cap=218.6e9 lo=218.6e9 hi=219e9 prov=measured src=handoff-2026-10-19-qwen38-decode-speed.md:calc:e726ff77
+resource id=dram_cpu kind=bandwidth cap=65.4e9 lo=60.8e9 hi=69.8e9 prov=measured src=M1/block4.csv:gb=1,threads=8
+resource id=unified_mem kind=capacity cap=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=gpu_launch kind=launch prov=measured src=M1/block2.csv
+
+# Ops. A CPU realization call (block1 path) feeding one GPU job (block2) whose
+# fixed submit lifecycle dominates, then a CPU memcpy of 1 GB (block4, 1 thread).
+op id=realize kind=compute engine=cpu t_ns=20000 lo=19400 hi=22800 prov=measured src=M1/block1.csv:path_ns_per_call
+op id=gpu_job kind=compute engine=gpu t_ns=0 prov=measured src=M1/block2.csv:vecadd_65 launch_ns=40736700 launcher=gpu_launch
+op id=copy1g kind=copy engine=cpu t_ns=111000000 lo=107900000 hi=116600000 prov=measured src=M1/block4.csv:gb=1,threads=1 bytes=2000000000 bw=dram_cpu
+dep realize gpu_job
+dep gpu_job copy1g
+
+# Buffers.
+buffer id=src1g bytes=1000000000 cap=unified_mem first=copy1g last=copy1g
+buffer id=dst1g bytes=1000000000 cap=unified_mem first=copy1g last=copy1g
+
+# Energy: no wall instrument on this box; nvidia-smi is GPU module only and was not
+# integrated over this DAG. UNMEASURED.
+energy instrument=none
diff --git a/tests/dagsim/fixtures/m1_synthetic_power.oev b/tests/dagsim/fixtures/m1_synthetic_power.oev
new file mode 100644
index 000000000..3087178ea
--- /dev/null
+++ b/tests/dagsim/fixtures/m1_synthetic_power.oev
@@ -0,0 +1,31 @@
+# OEV1 fixture: Spark M1 hardware passport subset (omega-mv#578), pinned 2026-10-19.
+# Every number below is a loaded-machine measurement (load1 15 to 29) or a datasheet
+# ceiling, and says which. Nothing here was produced by running a GPU in this harness.
+oev version=1
+machine id=spark-b87b soc=GB10 cores=20 mem_bytes=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+build repo=omega-mv sha=f4a9849f00000000000000000000000000000000 physics=6d7cf0d4
+calibration id=M1-20261019 taken=2026-10-19 valid_days=30 load1=24.2 src=~/yardsticks/aien-model/M1/
+
+# Resources. One capacity ledger for CPU and GPU (unified memory).
+resource id=cpu kind=compute slots=20 prov=specified src=nproc
+resource id=gpu kind=compute slots=1 prov=specified src=one-job-at-a-time-engine
+resource id=dram_spec kind=bandwidth cap=273e9 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=dram_gpu kind=bandwidth cap=218.6e9 lo=218.6e9 hi=219e9 prov=measured src=handoff-2026-10-19-qwen38-decode-speed.md:calc:e726ff77
+resource id=dram_cpu kind=bandwidth cap=65.4e9 lo=60.8e9 hi=69.8e9 prov=measured src=M1/block4.csv:gb=1,threads=8
+resource id=unified_mem kind=capacity cap=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=gpu_launch kind=launch prov=measured src=M1/block2.csv
+
+# Ops. A CPU realization call (block1 path) feeding one GPU job (block2) whose
+# fixed submit lifecycle dominates, then a CPU memcpy of 1 GB (block4, 1 thread).
+op id=realize kind=compute engine=cpu t_ns=20000 lo=19400 hi=22800 prov=measured src=M1/block1.csv:path_ns_per_call
+op id=gpu_job kind=compute engine=gpu t_ns=0 prov=measured src=M1/block2.csv:vecadd_65 launch_ns=40736700 launcher=gpu_launch
+op id=copy1g kind=copy engine=cpu t_ns=111000000 lo=107900000 hi=116600000 prov=measured src=M1/block4.csv:gb=1,threads=1 bytes=2000000000 bw=dram_cpu
+dep realize gpu_job
+dep gpu_job copy1g
+
+# Buffers.
+buffer id=src1g bytes=1000000000 cap=unified_mem first=copy1g last=copy1g
+buffer id=dst1g bytes=1000000000 cap=unified_mem first=copy1g last=copy1g
+
+# Labelled sensitivity only: 100 W is a made-up figure, not an instrument.
+energy instrument=what-if-100W boundary=wall power_w=100 prov=synthetic
diff --git a/tests/dagsim/fixtures/mw_bad_elimination.oev b/tests/dagsim/fixtures/mw_bad_elimination.oev
new file mode 100644
index 000000000..cc9e2a480
--- /dev/null
+++ b/tests/dagsim/fixtures/mw_bad_elimination.oev
@@ -0,0 +1,14 @@
+# Minimum-work accounting fixtures (parent #276 clarification). Synthetic
+# numbers, labelled so; the point is the ledger, not the magnitudes.
+oev version=1
+machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test
+build repo=omega-mv sha=0000000000000000000000000000000000000000
+calibration id=mw taken=2026-10-19 valid_days=3650 load1=0 src=synthetic
+resource id=cpu kind=compute slots=1 prov=specified src=test
+resource id=mem kind=capacity cap=1000 prov=specified src=test
+energy instrument=none
+op id=parse kind=compute engine=cpu t_ns=10 prov=synthetic src=t
+op id=execute kind=compute engine=cpu t_ns=50 prov=synthetic src=t
+dep parse execute
+removed op=search reason=eliminated
+removed op=check reason=eliminated
diff --git a/tests/dagsim/fixtures/mw_baseline.oev b/tests/dagsim/fixtures/mw_baseline.oev
new file mode 100644
index 000000000..e2eaf36f8
--- /dev/null
+++ b/tests/dagsim/fixtures/mw_baseline.oev
@@ -0,0 +1,16 @@
+# Minimum-work accounting fixtures (parent #276 clarification). Synthetic
+# numbers, labelled so; the point is the ledger, not the magnitudes.
+oev version=1
+machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test
+build repo=omega-mv sha=0000000000000000000000000000000000000000
+calibration id=mw taken=2026-10-19 valid_days=3650 load1=0 src=synthetic
+resource id=cpu kind=compute slots=1 prov=specified src=test
+resource id=mem kind=capacity cap=1000 prov=specified src=test
+energy instrument=none
+op id=parse kind=compute engine=cpu t_ns=10 prov=synthetic src=t
+op id=search kind=compute engine=cpu t_ns=200 prov=synthetic src=t
+op id=check kind=compute engine=cpu t_ns=20 prov=synthetic src=t
+op id=execute kind=compute engine=cpu t_ns=50 prov=synthetic src=t
+dep parse search
+dep search check
+dep check execute
diff --git a/tests/dagsim/fixtures/mw_reuse.oev b/tests/dagsim/fixtures/mw_reuse.oev
new file mode 100644
index 000000000..9e24750f3
--- /dev/null
+++ b/tests/dagsim/fixtures/mw_reuse.oev
@@ -0,0 +1,17 @@
+# Minimum-work accounting fixtures (parent #276 clarification). Synthetic
+# numbers, labelled so; the point is the ledger, not the magnitudes.
+oev version=1
+machine id=t soc=t cores=4 mem_bytes=1000 prov=specified src=test
+build repo=omega-mv sha=0000000000000000000000000000000000000000
+calibration id=mw taken=2026-10-19 valid_days=3650 load1=0 src=synthetic
+resource id=cpu kind=compute slots=1 prov=specified src=test
+resource id=mem kind=capacity cap=1000 prov=specified src=test
+energy instrument=none
+op id=parse kind=compute engine=cpu t_ns=10 prov=synthetic src=t
+op id=lookup kind=compute engine=cpu t_ns=5 prov=synthetic src=t
+op id=check kind=compute engine=cpu t_ns=20 prov=synthetic src=t
+op id=execute kind=compute engine=cpu t_ns=50 prov=synthetic src=t
+dep parse lookup
+dep lookup check
+dep check execute
+removed op=search reason=reused ref=lookup proof=rx_plan:verified-plan-digest
diff --git a/tests/dagsim/fixtures/needs_arch244_trace.oev b/tests/dagsim/fixtures/needs_arch244_trace.oev
new file mode 100644
index 000000000..671165072
--- /dev/null
+++ b/tests/dagsim/fixtures/needs_arch244_trace.oev
@@ -0,0 +1,24 @@
+# OEV1 fixture: Spark M1 hardware passport subset (omega-mv#578), pinned 2026-10-19.
+# Every number below is a loaded-machine measurement (load1 15 to 29) or a datasheet
+# ceiling, and says which. Nothing here was produced by running a GPU in this harness.
+oev version=1
+machine id=spark-b87b soc=GB10 cores=20 mem_bytes=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+build repo=omega-mv sha=f4a9849f00000000000000000000000000000000 physics=6d7cf0d4
+calibration id=M1-20261019 taken=2026-10-19 valid_days=30 load1=24.2 src=~/yardsticks/aien-model/M1/
+
+# Resources. One capacity ledger for CPU and GPU (unified memory).
+resource id=cpu kind=compute slots=20 prov=specified src=nproc
+resource id=gpu kind=compute slots=1 prov=specified src=one-job-at-a-time-engine
+resource id=dram_spec kind=bandwidth cap=273e9 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=dram_gpu kind=bandwidth cap=218.6e9 lo=218.6e9 hi=219e9 prov=measured src=handoff-2026-10-19-qwen38-decode-speed.md:calc:e726ff77
+resource id=dram_cpu kind=bandwidth cap=65.4e9 lo=60.8e9 hi=69.8e9 prov=measured src=M1/block4.csv:gb=1,threads=8
+resource id=unified_mem kind=capacity cap=137438953472 prov=specified src=nvidia-dgx-spark-datasheet
+resource id=gpu_launch kind=launch prov=measured src=M1/block2.csv
+
+# Ops. The second op needs the aien-architecture#244 objective trace, which was
+# NOT_RUN on 2026-10-19. Unknown stays unknown: this fixture must be refused.
+op id=realize kind=compute engine=cpu t_ns=20000 lo=19400 hi=22800 prov=measured src=M1/block1.csv:path_ns_per_call
+op id=objective_replay kind=compute engine=cpu prov=unknown src=aien-architecture#244:NOT_RUN
+dep realize objective_replay
+
+energy instrument=none
diff --git a/tests/dagsim/run_cli.sh b/tests/dagsim/run_cli.sh
new file mode 100644
index 000000000..5b22297de
--- /dev/null
+++ b/tests/dagsim/run_cli.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# run_cli.sh DAGSIM_BIN [OUT_DIR]
+# Reproducible CLI example for omega-mv#583: pinned fixtures in, JSON and a
+# Pareto table out, byte-identical on a second run, no GPU touched.
+set -u
+BIN=${1:?dagsim binary}
+OUT=${2:-/tmp/dagsim-cli-$$}
+F=tests/dagsim/fixtures
+ASOF=2026-10-20
+mkdir -p "$OUT"
+fail=0
+say() { echo "run_cli: $*"; }
+check() { if [ "$1" -ne 0 ]; then say "FAIL $2"; fail=1; else say "ok   $2"; fi; }
+
+"$BIN" eval $F/m1_spark_subset.oev --asof $ASOF > "$OUT/subset.json"; rc=$?
+check $rc "eval exits 0 on the pinned M1 subset"
+grep -q '"status": "OK"' "$OUT/subset.json"; check $? "status OK"
+grep -q '"makespan_ns": {"nominal": 151756700,' "$OUT/subset.json"; check $? "serial makespan 20000 + 40736700 + 111000000 ns"
+grep -q '"makespan_ge_bounds": true' "$OUT/subset.json"; check $? "makespan is above its bounds"
+grep -q '"status": "UNMEASURED"' "$OUT/subset.json"; check $? "energy UNMEASURED without an instrument"
+grep -q '"gpu_executed": false' "$OUT/subset.json"; check $? "offline: no GPU execution"
+grep -q '"provenance": \["measured", "specified"\]' "$OUT/subset.json"; check $? "provenance list names measured and specified only"
+"$BIN" eval $F/m1_spark_subset.oev --asof $ASOF > "$OUT/subset2.json"
+cmp -s "$OUT/subset.json" "$OUT/subset2.json"; check $? "second run byte-identical"
+
+"$BIN" eval $F/needs_arch244_trace.oev --asof $ASOF > "$OUT/unknown.json"; rc=$?
+[ $rc -eq 1 ] ; check $? "unknown-trace fixture exits 1"
+grep -q '"status": "REFUSED_UNKNOWN"' "$OUT/unknown.json"; check $? "unknown stays unknown (REFUSED_UNKNOWN)"
+grep -q 'makespan' "$OUT/unknown.json"; [ $? -ne 0 ]; check $? "no makespan printed on refusal"
+
+"$BIN" eval $F/m1_spark_subset.oev --asof 2026-12-01 > "$OUT/stale.json"
+grep -q '"status": "REFUSED_STALE"' "$OUT/stale.json"; check $? "30-day calibration refused at 43 days"
+
+"$BIN" eval $F/m1_synthetic_power.oev --asof $ASOF > "$OUT/syn.json"
+grep -q '"status": "SYNTHETIC_SENSITIVITY_ONLY"' "$OUT/syn.json"; check $? "synthetic power is labelled, not ranked"
+grep -q '"ranking_valid": false' "$OUT/syn.json"; check $? "energy ranking invalid on synthetic power"
+
+"$BIN" eval $F/m1_spark_overlap.oev --asof $ASOF > "$OUT/overlap.json"
+grep -q '"status": "OK"' "$OUT/overlap.json"; check $? "overlap fixture evaluates"
+# two halves sharing a 65.4 GB/s pipe: 2 GB of traffic is 30.58 ms, each half's own busy
+# time is 55.5 ms, so busy time binds and both halves end together at 40.7567 + 55.5 ms.
+grep -q '"makespan_ns": {"nominal": 96256700,' "$OUT/overlap.json"; check $? "split copy: busy time binds, 40756700 + 55500000 ns"
+
+"$BIN" pareto $F/m1_spark_subset.oev $F/m1_spark_overlap.oev $F/m1_synthetic_power.oev $F/needs_arch244_trace.oev --asof $ASOF > "$OUT/pareto.txt"; rc=$?
+check $rc "pareto exits 0"
+grep -q 'needs_arch244_trace.oev *REFUSED_UNKNOWN' "$OUT/pareto.txt"; check $? "refused candidate shown as refused in the table"
+grep -q 'm1_spark_overlap.oev *OK .* yes$' "$OUT/pareto.txt"; check $? "faster candidate is on the front"
+grep -q 'm1_spark_subset.oev *OK .* no$' "$OUT/pareto.txt"; check $? "dominated candidate is off the front"
+grep -q 'Energy not measured on every row' "$OUT/pareto.txt"; check $? "pareto says energy is not ranked"
+
+"$BIN" diff $F/mw_baseline.oev $F/mw_reuse.oev --asof $ASOF > "$OUT/diff_reuse.json"; rc=$?
+check $rc "reuse diff OK"
+grep -q '"reused": 200' "$OUT/diff_reuse.json"; check $? "200 ns of search moved to the reused ledger"
+"$BIN" diff $F/mw_baseline.oev $F/mw_bad_elimination.oev --asof $ASOF > "$OUT/diff_bad.json"; rc=$?
+[ $rc -eq 1 ]; check $? "unproven elimination exits 1"
+grep -q '"status": "REFUSED_REMOVED_REQUIRED"' "$OUT/diff_bad.json"; check $? "unproven elimination refused"
+"$BIN" diff $F/mw_baseline.oev $F/mw_baseline.oev --asof $ASOF > "$OUT/diff_same.json"
+grep -q '"kept": 4, "added": 0, "removed": 0' "$OUT/diff_same.json"; check $? "no-change fixture adds no nodes"
+
+say "outputs in $OUT"
+exit $fail
diff --git a/tests/dagsim/sha256_host.c b/tests/dagsim/sha256_host.c
new file mode 100644
index 000000000..64ffdf4e5
--- /dev/null
+++ b/tests/dagsim/sha256_host.c
@@ -0,0 +1,19 @@
+/* Link stub for the imported dagsim binary on hosts that are not AArch64.
+ * src/omega_om_units.c is AArch64 machine code. rx_costmodel.o references
+ * sha256_hash from serialize/digest only. The analytical dagsim tests do not
+ * call it. On AArch64 the Makefile links src/omega_om_units.c instead, and
+ * this file is not built. dagsim --model is NOT_RUN on this stub: a blob
+ * digest would abort rather than return a made-up hash.
+ */
+#if !defined(__aarch64__)
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+
+void sha256_hash(const uint8_t *d, size_t n, uint8_t out[32]) {
+    (void)d; (void)n; (void)out;
+    fprintf(stderr, "sha256_hash: host stub; dagsim --model is NOT_RUN off AArch64\n");
+    abort();
+}
+#endif
diff --git a/tools/.crumb b/tools/.crumb
index 5f1a7214f..e9e4932b5 100644
--- a/tools/.crumb
+++ b/tools/.crumb
@@ -62,14 +62,14 @@
         }
       ],
       "children_root": "sha256:8d3d3b952374b3b72e667521f07bf028c4c02bcefff772ad1a71cfff3e5266f2",
-      "compiled_at": "2026-10-28T02:06:07Z",
+      "compiled_at": "2026-10-30T11:28:28Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:4e83dea21da137c30076c2dc0ca4f3a488f576f30a94e334558ad5ea523f3a6b",
+      "digest": "sha256:308db0e6cf45c0a48f01f5f5f228450f191389de68006915b9ecf9c65b9a2e29",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 295,
-      "generated_at_commit": "82509c4f949504dc63f13371607b211c14cdee74",
-      "source_tree": "sha256:319916f06e7ad69219b50ea9df5420b8baec42170d0ba675632059208dda0949"
+      "files": 298,
+      "generated_at_commit": "a8a6a3d3c47ce797430f045edc5eae11594ba36d",
+      "source_tree": "sha256:acd1f1b0080968db950791b4eb2dce39bb0289dc0c2e8794bfc7449023446105"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tools/dagsim/dagsim.c b/tools/dagsim/dagsim.c
new file mode 100644
index 000000000..b7187d445
--- /dev/null
+++ b/tools/dagsim/dagsim.c
@@ -0,0 +1,751 @@
+/*
+ * dagsim.c -- offline resource-DAG cost evaluator (omega-mv#583).
+ *
+ * See dagsim.h and spec/offline-evidence-v1.md. The scheduler is a
+ * deterministic fluid simulation: compute engines have slots, bandwidth
+ * resources are shared equally among the ops streaming on them at any
+ * instant, launches are serialized per launch resource, and an op finishes
+ * when both its own busy time and its traffic are done (perfect overlap
+ * inside one op, which is the issue's stated floor max(F/P, Q/B)). Ops are
+ * dispatched in file order, so the same file always gives the same bytes.
+ */
+#include "dagsim.h"
+#include "runtime/rx_costmodel.h"
+
+#include <ctype.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+/* ---------------------------------------------------------------- names */
+
+const char *ds_status_name(int s) {
+    switch (s) {
+    case DS_OK: return "OK";
+    case DS_REFUSED_UNKNOWN: return "REFUSED_UNKNOWN";
+    case DS_REFUSED_STALE: return "REFUSED_STALE";
+    case DS_REFUSED_NO_CALIBRATION: return "REFUSED_NO_CALIBRATION";
+    case DS_REFUSED_CAPACITY: return "REFUSED_CAPACITY";
+    case DS_REFUSED_CYCLE: return "REFUSED_CYCLE";
+    case DS_REFUSED_UNSUPPORTED: return "REFUSED_UNSUPPORTED";
+    case DS_REFUSED_REMOVED_REQUIRED: return "REFUSED_REMOVED_REQUIRED";
+    case DS_PARSE_ERROR: return "PARSE_ERROR";
+    default: return "?";
+    }
+}
+
+const char *ds_prov_name(int p) {
+    switch (p) {
+    case DS_PROV_UNKNOWN: return "unknown";
+    case DS_PROV_SYNTHETIC: return "synthetic";
+    case DS_PROV_FITTED: return "fitted";
+    case DS_PROV_MEASURED: return "measured";
+    case DS_PROV_SPECIFIED: return "specified";
+    default: return "?";
+    }
+}
+
+static int prov_from_name(const char *s) {
+    if (!strcmp(s, "unknown")) return DS_PROV_UNKNOWN;
+    if (!strcmp(s, "synthetic")) return DS_PROV_SYNTHETIC;
+    if (!strcmp(s, "fitted")) return DS_PROV_FITTED;
+    if (!strcmp(s, "measured")) return DS_PROV_MEASURED;
+    if (!strcmp(s, "specified")) return DS_PROV_SPECIFIED;
+    return -1;
+}
+
+/* days since 1970-01-01 for a civil date (Howard Hinnant's days_from_civil) */
+int ds_day_from_date(const char *s) {
+    int y, m, d;
+    if (!s || sscanf(s, "%d-%d-%d", &y, &m, &d) != 3) return -1;
+    y -= m <= 2;
+    int era = (y >= 0 ? y : y - 399) / 400;
+    unsigned yoe = (unsigned)(y - era * 400);
+    unsigned doy = (153u * (unsigned)(m + (m > 2 ? -3 : 9)) + 2u) / 5u + (unsigned)d - 1u;
+    unsigned doe = yoe * 365u + yoe / 4u - yoe / 100u + doy;
+    return era * 146097 + (int)doe - 719468;
+}
+
+int ds_find_op(const ds_model *m, const char *id) {
+    for (int i = 0; i < m->n_ops; i++) if (!strcmp(m->ops[i].id, id)) return i;
+    return -1;
+}
+int ds_find_res(const ds_model *m, const char *id) {
+    for (int i = 0; i < m->n_res; i++) if (!strcmp(m->res[i].id, id)) return i;
+    return -1;
+}
+
+/* ---------------------------------------------------------------- parse */
+/* bounded string copy; ids and sources are truncated, never overflowed */
+static void sset(char *dst, size_t cap, const char *src) {
+    size_t n = strlen(src);
+    if (n >= cap) n = cap - 1;
+    memcpy(dst, src, n); dst[n] = 0;
+}
+
+
+typedef struct { char key[32]; char val[DS_SRC]; int used; } kv;
+
+static int split_kv(char *line, char *keyword, size_t kwcap, kv *kvs, int maxkv, char *positional[], int *npos) {
+    int n = 0; *npos = 0; keyword[0] = 0;
+    char *p = strchr(line, '#'); if (p) *p = 0;
+    char *save = NULL;
+    char *tok = strtok_r(line, " \t\r\n", &save);
+    if (!tok) return -1;   /* empty */
+    snprintf(keyword, kwcap, "%s", tok);
+    while ((tok = strtok_r(NULL, " \t\r\n", &save))) {
+        char *eq = strchr(tok, '=');
+        if (!eq) { if (*npos < 8) positional[(*npos)++] = tok; continue; }
+        if (n >= maxkv) return -2;
+        *eq = 0;
+        sset(kvs[n].key, sizeof kvs[n].key, tok);
+        sset(kvs[n].val, sizeof kvs[n].val, eq + 1);
+        kvs[n].used = 0;
+        n++;
+    }
+    return n;
+}
+
+static const char *get(kv *kvs, int n, const char *key) {
+    for (int i = 0; i < n; i++) if (!strcmp(kvs[i].key, key)) { kvs[i].used = 1; return kvs[i].val; }
+    return NULL;
+}
+
+static int unused_key(kv *kvs, int n, char *out, size_t cap) {
+    for (int i = 0; i < n; i++) if (!kvs[i].used) { snprintf(out, cap, "%s", kvs[i].key); return 1; }
+    return 0;
+}
+
+static int parse_real(const char *s, double *out) {
+    if (!s) return 0;
+    char *end; double v = strtod(s, &end);
+    if (end == s || *end) return 0;
+    if (!(v == v) || v < 0) return 0;
+    *out = v; return 1;
+}
+
+#define PERR(...) do { snprintf(err, errcap, "line %d: ", lineno); size_t _l = strlen(err); snprintf(err + _l, errcap - _l, __VA_ARGS__); return DS_PARSE_ERROR; } while (0)
+
+static int parse_prov_src(kv *kvs, int n, int *prov, char *src, size_t srccap, int required, char *err, size_t errcap, int lineno) {
+    const char *p = get(kvs, n, "prov");
+    const char *s = get(kvs, n, "src");
+    if (!p) { if (required) PERR("prov= is required wherever a number appears"); *prov = -1; return DS_OK; }
+    int v = prov_from_name(p);
+    if (v < 0) PERR("prov=%s is not one of specified|measured|fitted|synthetic|unknown", p);
+    *prov = v;
+    if ((v == DS_PROV_MEASURED || v == DS_PROV_FITTED) && !s) PERR("prov=%s needs src=", p);
+    snprintf(src, srccap, "%s", s ? s : "");
+    return DS_OK;
+}
+
+int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap) {
+    memset(m, 0, sizeof *m);
+    err[0] = 0;
+    int lineno = 0;
+    const char *cur = text;
+    int seen_oev = 0, seen_machine = 0, seen_build = 0;
+    /* two-pass is not needed: ops before deps/buffers is the convention; we
+     * resolve references at use and require definition before use. */
+    while (*cur) {
+        const char *nl = strchr(cur, '\n');
+        size_t len = nl ? (size_t)(nl - cur) : strlen(cur);
+        char line[1024];
+        lineno++;
+        if (len >= sizeof line) PERR("line too long");
+        memcpy(line, cur, len); line[len] = 0;
+        cur = nl ? nl + 1 : cur + len;
+        char keyword[32]; kv kvs[24]; char *pos[8]; int npos;
+        int n = split_kv(line, keyword, sizeof keyword, kvs, 24, pos, &npos);
+        if (n == -1) continue;
+        if (n == -2) PERR("too many fields");
+        if (!strcmp(keyword, "oev")) {
+            const char *v = get(kvs, n, "version");
+            if (!v || strcmp(v, "1")) PERR("oev version=1 required");
+            m->version = 1; seen_oev = 1;
+        } else if (!strcmp(keyword, "machine")) {
+            const char *v;
+            if (!(v = get(kvs, n, "id"))) PERR("machine needs id=");
+            sset(m->machine_id, sizeof m->machine_id, v);
+            if ((v = get(kvs, n, "soc"))) sset(m->soc, sizeof m->soc, v);
+            if ((v = get(kvs, n, "cores"))) m->cores = atoi(v);
+            if ((v = get(kvs, n, "mem_bytes")) && !parse_real(v, &m->mem_bytes)) PERR("bad mem_bytes");
+            int prov; char src[DS_SRC];
+            int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, 1, err, errcap, lineno); if (rc) return rc;
+            seen_machine = 1;
+        } else if (!strcmp(keyword, "build")) {
+            const char *v;
+            if ((v = get(kvs, n, "repo"))) sset(m->repo, sizeof m->repo, v);
+            if (!(v = get(kvs, n, "sha")) || strlen(v) != 40) PERR("build needs sha=<40 hex>");
+            sset(m->build_sha, sizeof m->build_sha, v);
+            if ((v = get(kvs, n, "physics"))) sset(m->physics, sizeof m->physics, v);
+            seen_build = 1;
+        } else if (!strcmp(keyword, "calibration")) {
+            const char *v;
+            if (m->has_calibration) PERR("one calibration record only");
+            if (!(v = get(kvs, n, "id"))) PERR("calibration needs id=");
+            sset(m->cal_id, sizeof m->cal_id, v);
+            if (!(v = get(kvs, n, "taken")) || (m->cal_taken_day = ds_day_from_date(v)) < 0) PERR("calibration needs taken=YYYY-MM-DD");
+            if (!(v = get(kvs, n, "valid_days"))) PERR("calibration needs valid_days=");
+            m->cal_valid_days = atoi(v);
+            if (!(v = get(kvs, n, "load1")) || !parse_real(v, &m->cal_load1)) PERR("calibration needs load1=");
+            if (!(v = get(kvs, n, "src"))) PERR("calibration needs src=");
+            sset(m->cal_src, sizeof m->cal_src, v);
+            if ((v = get(kvs, n, "model"))) sset(m->cal_model, sizeof m->cal_model, v);
+            m->has_calibration = 1;
+        } else if (!strcmp(keyword, "resource")) {
+            if (m->n_res >= DS_MAX_RES) PERR("too many resources (max %d)", DS_MAX_RES);
+            ds_resource *r = &m->res[m->n_res];
+            memset(r, 0, sizeof *r);
+            const char *v;
+            if (!(v = get(kvs, n, "id"))) PERR("resource needs id=");
+            if (ds_find_res(m, v) >= 0) PERR("duplicate resource %s", v);
+            sset(r->id, sizeof r->id, v);
+            if (!(v = get(kvs, n, "kind"))) PERR("resource needs kind=");
+            if (!strcmp(v, "compute")) {
+                r->kind = DS_RES_COMPUTE;
+                if (!(v = get(kvs, n, "slots")) || (r->slots = atoi(v)) < 1) PERR("compute resource needs slots>=1");
+            } else if (!strcmp(v, "bandwidth")) {
+                r->kind = DS_RES_BANDWIDTH;
+                if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("bandwidth resource needs cap>0");
+                r->lo = r->hi = r->cap;
+                if ((v = get(kvs, n, "lo")) && !parse_real(v, &r->lo)) PERR("bad lo");
+                if ((v = get(kvs, n, "hi")) && !parse_real(v, &r->hi)) PERR("bad hi");
+                if (r->lo > r->cap || r->hi < r->cap) PERR("need lo <= cap <= hi");
+            } else if (!strcmp(v, "capacity")) {
+                r->kind = DS_RES_CAPACITY;
+                if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("capacity resource needs cap>0");
+            } else if (!strcmp(v, "launch")) {
+                r->kind = DS_RES_LAUNCH;
+            } else PERR("resource kind=%s unknown", v);
+            int rc = parse_prov_src(kvs, n, &r->prov, r->src, sizeof r->src, 1, err, errcap, lineno); if (rc) return rc;
+            m->n_res++;
+        } else if (!strcmp(keyword, "op")) {
+            if (m->n_ops >= DS_MAX_OPS) PERR("too many ops (max %d)", DS_MAX_OPS);
+            ds_op *o = &m->ops[m->n_ops];
+            memset(o, 0, sizeof *o);
+            o->engine = o->bw = o->launcher = -1;
+            const char *v;
+            if (!(v = get(kvs, n, "id"))) PERR("op needs id=");
+            if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
+            sset(o->id, sizeof o->id, v);
+            if (!(v = get(kvs, n, "kind"))) PERR("op needs kind=");
+            if (!strcmp(v, "compute")) o->kind = DS_OP_COMPUTE;
+            else if (!strcmp(v, "copy")) o->kind = DS_OP_COPY;
+            else if (!strcmp(v, "matvec")) o->kind = DS_OP_MATVEC;
+            else if (!strcmp(v, "barrier")) o->kind = DS_OP_BARRIER;
+            else if (!strcmp(v, "storage")) o->kind = DS_OP_STORAGE;
+            else if (!strcmp(v, "persist")) o->kind = DS_OP_PERSIST;
+            else PERR("op kind=%s unknown", v);
+            if ((v = get(kvs, n, "engine"))) {
+                o->engine = ds_find_res(m, v);
+                if (o->engine < 0 || m->res[o->engine].kind != DS_RES_COMPUTE) PERR("engine=%s is not a compute resource defined above", v);
+            }
+            if ((v = get(kvs, n, "t_ns"))) { if (!parse_real(v, &o->t_ns)) PERR("bad t_ns"); o->has_t = 1; o->lo = o->hi = o->t_ns; }
+            if ((v = get(kvs, n, "lo"))) { if (!o->has_t || !parse_real(v, &o->lo) || o->lo > o->t_ns) PERR("lo needs t_ns and lo <= t_ns"); }
+            if ((v = get(kvs, n, "hi"))) { if (!o->has_t || !parse_real(v, &o->hi) || o->hi < o->t_ns) PERR("hi needs t_ns and hi >= t_ns"); }
+            if ((v = get(kvs, n, "bytes"))) {
+                if (!parse_real(v, &o->bytes)) PERR("bad bytes");
+                const char *b = get(kvs, n, "bw");
+                if (!b || (o->bw = ds_find_res(m, b)) < 0 || m->res[o->bw].kind != DS_RES_BANDWIDTH) PERR("bytes= needs bw=<bandwidth resource defined above>");
+            }
+            if ((v = get(kvs, n, "launch_ns"))) {
+                if (!parse_real(v, &o->launch_ns)) PERR("bad launch_ns");
+                const char *l = get(kvs, n, "launcher");
+                if (!l || (o->launcher = ds_find_res(m, l)) < 0 || m->res[o->launcher].kind != DS_RES_LAUNCH) PERR("launch_ns= needs launcher=<launch resource defined above>");
+            }
+            if ((v = get(kvs, n, "M"))) o->M = (uint32_t)strtoul(v, NULL, 10);
+            if ((v = get(kvs, n, "N"))) o->N = (uint32_t)strtoul(v, NULL, 10);
+            if ((v = get(kvs, n, "core"))) o->core = (uint32_t)strtoul(v, NULL, 10);
+            if ((v = get(kvs, n, "arm"))) o->arm = (uint32_t)strtoul(v, NULL, 10);
+            if (o->kind == DS_OP_MATVEC && !o->has_t && (o->M == 0 || o->N == 0)) PERR("matvec needs M= and N= (or t_ns=)");
+            if (o->kind != DS_OP_BARRIER && o->engine < 0) PERR("op %s needs engine=", o->id);
+            int required = o->has_t || o->bytes > 0 || o->launch_ns > 0 || o->kind == DS_OP_MATVEC;
+            int rc = parse_prov_src(kvs, n, &o->t_prov, o->src, sizeof o->src, required, err, errcap, lineno); if (rc) return rc;
+            if (o->t_prov < 0) o->t_prov = DS_PROV_SPECIFIED;   /* a costless barrier: ordering only */
+            if (!o->has_t && o->kind != DS_OP_MATVEC && o->t_prov == DS_PROV_UNKNOWN) { /* fine: explicitly unknown */ }
+            m->n_ops++;
+        } else if (!strcmp(keyword, "dep")) {
+            if (npos != 2 || n != 0) PERR("dep <from> <to>");
+            if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
+            int a = ds_find_op(m, pos[0]), b = ds_find_op(m, pos[1]);
+            if (a < 0 || b < 0) PERR("dep names an op not defined above: %s %s", pos[0], pos[1]);
+            m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = b; m->n_deps++;
+        } else if (!strcmp(keyword, "buffer")) {
+            if (m->n_buf >= DS_MAX_BUF) PERR("too many buffers");
+            ds_buffer *b = &m->buf[m->n_buf];
+            memset(b, 0, sizeof *b); b->first = b->last = -1;
+            const char *v;
+            if (!(v = get(kvs, n, "id"))) PERR("buffer needs id=");
+            sset(b->id, sizeof b->id, v);
+            if (!parse_real(get(kvs, n, "bytes"), &b->bytes)) PERR("buffer needs bytes=");
+            if (!(v = get(kvs, n, "cap")) || (b->cap = ds_find_res(m, v)) < 0 || m->res[b->cap].kind != DS_RES_CAPACITY) PERR("buffer needs cap=<capacity resource>");
+            if ((v = get(kvs, n, "first")) && (b->first = ds_find_op(m, v)) < 0) PERR("first=%s not an op", v);
+            if ((v = get(kvs, n, "last")) && (b->last = ds_find_op(m, v)) < 0) PERR("last=%s not an op", v);
+            m->n_buf++;
+        } else if (!strcmp(keyword, "sync")) {
+            /* a barrier op that depends on every listed op */
+            if (m->n_ops >= DS_MAX_OPS) PERR("too many ops");
+            const char *v, *list;
+            if (!(v = get(kvs, n, "id"))) PERR("sync needs id=");
+            if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
+            if (!(list = get(kvs, n, "ops"))) PERR("sync needs ops=a,b,...");
+            ds_op *o = &m->ops[m->n_ops];
+            memset(o, 0, sizeof *o);
+            o->engine = o->bw = o->launcher = -1; o->kind = DS_OP_BARRIER; o->t_prov = DS_PROV_SPECIFIED;
+            sset(o->id, sizeof o->id, v);
+            int self = m->n_ops++;
+            char tmp[DS_SRC]; sset(tmp, sizeof tmp, list);
+            char *save = NULL;
+            for (char *t = strtok_r(tmp, ",", &save); t; t = strtok_r(NULL, ",", &save)) {
+                int a = ds_find_op(m, t);
+                if (a < 0 || a == self) PERR("sync lists unknown op %s", t);
+                if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
+                m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = self; m->n_deps++;
+            }
+        } else if (!strcmp(keyword, "energy")) {
+            const char *v;
+            if (m->has_energy) PERR("one energy record only");
+            if (!(v = get(kvs, n, "instrument"))) PERR("energy needs instrument=");
+            sset(m->instrument, sizeof m->instrument, v);
+            if ((v = get(kvs, n, "boundary"))) sset(m->boundary, sizeof m->boundary, v);
+            const char *j = get(kvs, n, "joules"), *pw = get(kvs, n, "power_w");
+            int prov = -1; char src[DS_SRC];
+            int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, j || pw ? 1 : 0, err, errcap, lineno); if (rc) return rc;
+            m->energy_prov = prov;
+            if (j) {
+                if (!strcmp(m->instrument, "none") || !m->boundary[0]) PERR("joules= needs a named instrument and boundary=");
+                if (prov != DS_PROV_MEASURED) PERR("joules= must be prov=measured with src=");
+                if (!parse_real(j, &m->joules)) PERR("bad joules");
+            }
+            if (pw) {
+                if (prov != DS_PROV_SYNTHETIC) PERR("power_w= is allowed only as prov=synthetic (a sensitivity figure); measured power must be integrated into joules= by the instrument");
+                if (!parse_real(pw, &m->power_w)) PERR("bad power_w");
+            }
+            m->has_energy = 1;
+        } else if (!strcmp(keyword, "removed")) {
+            if (m->n_removed >= DS_MAX_REMOVED) PERR("too many removed records");
+            ds_removed *r = &m->removed[m->n_removed];
+            memset(r, 0, sizeof *r);
+            const char *v;
+            if (!(v = get(kvs, n, "op"))) PERR("removed needs op=");
+            sset(r->op, sizeof r->op, v);
+            if (ds_find_op(m, v) >= 0) PERR("removed op %s is still present in this DAG", v);
+            if (!(v = get(kvs, n, "reason"))) PERR("removed needs reason=");
+            if (!strcmp(v, "eliminated")) r->reason = DS_RM_ELIMINATED;
+            else if (!strcmp(v, "reused")) r->reason = DS_RM_REUSED;
+            else if (!strcmp(v, "unchanged_dep")) r->reason = DS_RM_UNCHANGED_DEP;
+            else if (!strcmp(v, "deferred")) r->reason = DS_RM_DEFERRED;
+            else if (!strcmp(v, "moved")) r->reason = DS_RM_MOVED;
+            else if (!strcmp(v, "shared")) r->reason = DS_RM_SHARED;
+            else if (!strcmp(v, "lookup")) r->reason = DS_RM_LOOKUP;
+            else PERR("removed reason=%s unknown", v);
+            if ((v = get(kvs, n, "ref"))) sset(r->ref, sizeof r->ref, v);
+            if ((v = get(kvs, n, "proof"))) sset(r->proof, sizeof r->proof, v);
+            m->n_removed++;
+        } else PERR("unknown record '%s'", keyword);
+        char bad[32];
+        if (unused_key(kvs, n, bad, sizeof bad)) PERR("unknown field %s= on '%s'", bad, keyword);
+    }
+    lineno = 0;
+    if (!seen_oev) PERR("missing 'oev version=1'");
+    if (!seen_machine) PERR("missing machine record");
+    if (!seen_build) PERR("missing build record");
+    if (!m->has_energy) PERR("missing energy record (use instrument=none for UNMEASURED)");
+    return DS_OK;
+}
+
+int ds_parse_file(const char *path, ds_model *m, char *err, size_t errcap) {
+    FILE *fp = fopen(path, "r");
+    if (!fp) { snprintf(err, errcap, "cannot open %s", path); return DS_PARSE_ERROR; }
+    fseek(fp, 0, SEEK_END); long n = ftell(fp); fseek(fp, 0, SEEK_SET);
+    if (n < 0 || n > (1 << 20)) { fclose(fp); snprintf(err, errcap, "file size out of range"); return DS_PARSE_ERROR; }
+    char *buf = malloc((size_t)n + 1);
+    if (!buf) { fclose(fp); snprintf(err, errcap, "out of memory"); return DS_PARSE_ERROR; }
+    size_t got = fread(buf, 1, (size_t)n, fp); buf[got] = 0; fclose(fp);
+    int rc = ds_parse_text(buf, m, err, errcap);
+    free(buf);
+    return rc;
+}
+
+/* ---------------------------------------------------------------- evaluate */
+
+/* resolved per-op numbers for one evaluation mode */
+typedef struct { double t, launch, bytes, cap; int prov; } ds_num;   /* cap in B/ns */
+
+static double res_cap(const ds_resource *r, int mode) {
+    if (mode < 0) return r->lo;
+    if (mode > 0) return r->hi;
+    return r->cap;
+}
+
+static int refuse(ds_result *r, int status, const char *fmt, const char *a, const char *b) {
+    memset(r, 0, sizeof *r);
+    r->status = status;
+    snprintf(r->reason, sizeof r->reason, fmt, a ? a : "", b ? b : "");
+    return status;
+}
+
+static int resolve(const ds_model *m, const ds_opts *o, ds_num *num, ds_result *r) {
+    int any_cal = 0;
+    for (int i = 0; i < m->n_res; i++) {
+        if (m->res[i].prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "resource %s has prov=unknown; unknown stays unknown%s", m->res[i].id, "");
+        if (m->res[i].prov == DS_PROV_MEASURED || m->res[i].prov == DS_PROV_FITTED) any_cal = 1;
+    }
+    for (int i = 0; i < m->n_ops; i++) {
+        const ds_op *op = &m->ops[i];
+        ds_num *x = &num[i];
+        memset(x, 0, sizeof *x);
+        x->prov = op->t_prov;
+        x->launch = op->launch_ns;
+        x->bytes = op->bytes;
+        x->cap = op->bw >= 0 ? res_cap(&m->res[op->bw], o->mode) * 1e-9 : 0;   /* B/s -> B/ns */
+        if (op->kind == DS_OP_MATVEC && !op->has_t) {
+            const RxCostModel *cm = (const RxCostModel *)o->costmodel;
+            if (!cm) return refuse(r, DS_REFUSED_UNKNOWN, "op %s is a matvec with no rx_costmodel blob supplied (calibration model=)%s", op->id, "");
+            RxCmFeatures f; memset(&f, 0, sizeof f);
+            f.op = RX_CM_OP_MATVEC; f.M = op->M; f.N = op->N;
+            f.state_bytes = ((uint64_t)op->M * op->N + op->M + op->N) * 8u;
+            f.cache_bytes = 1u << 20; f.core = op->core; f.eligible = 1u << op->arm; f.current_arm = op->arm;
+            RxCmPrediction p; rx_cm_predict(cm, &f, op->arm, &p);
+            if (!p.known || p.n == 0) return refuse(r, DS_REFUSED_UNKNOWN, "op %s: rx_costmodel has no known cell for this (op, core, pressure) and arm; measure it first%s", op->id, "");
+            double q = o->interval_q > 0 && o->interval_q < 1 ? o->interval_q : 0.9;
+            double k = rx_cm_t_quantile(q, p.dof);
+            double l2 = p.mean_log2_ps + (o->mode < 0 ? k * p.sd_log2 : o->mode > 0 ? -k * p.sd_log2 : 0);
+            x->t = pow(2.0, l2) / 1000.0;   /* ps -> ns */
+            x->prov = DS_PROV_FITTED;
+            any_cal = 1;
+        } else {
+            if (op->t_prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "op %s has prov=unknown (%s); unknown stays unknown", op->id, op->src[0] ? op->src : "no source");
+            x->t = o->mode < 0 ? op->hi : o->mode > 0 ? op->lo : op->t_ns;
+            if (op->t_prov == DS_PROV_MEASURED || op->t_prov == DS_PROV_FITTED) any_cal = 1;
+        }
+        if (op->engine < 0 && op->kind != DS_OP_BARRIER) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s has no engine%s", op->id, "");
+        if (op->launcher >= 0 && op->engine < 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s: launch without an engine%s", op->id, "");
+    }
+    if (any_cal) {
+        if (!m->has_calibration) return refuse(r, DS_REFUSED_NO_CALIBRATION, "measured or fitted values need a calibration record naming when and under what load they were taken%s%s", "", "");
+        int asof = o->asof_day;
+        if (asof <= 0) asof = (int)(time(NULL) / 86400);
+        if (asof > m->cal_taken_day + m->cal_valid_days) {
+            char d[64]; snprintf(d, sizeof d, "asof is %d day(s) past the validity envelope", asof - m->cal_taken_day - m->cal_valid_days);
+            return refuse(r, DS_REFUSED_STALE, "calibration %s is stale: %s", m->cal_id, d);
+        }
+    }
+    return DS_OK;
+}
+
+/* Kahn topological order; returns 0 on a cycle */
+static int topo(const ds_model *m, int *order) {
+    int indeg[DS_MAX_OPS] = {0};
+    for (int i = 0; i < m->n_deps; i++) indeg[m->deps[i].to]++;
+    int n = 0, head = 0;
+    for (int i = 0; i < m->n_ops; i++) if (indeg[i] == 0) order[n++] = i;
+    while (head < n) {
+        int u = order[head++];
+        for (int i = 0; i < m->n_deps; i++) if (m->deps[i].from == u && --indeg[m->deps[i].to] == 0) order[n++] = m->deps[i].to;
+    }
+    return n == m->n_ops;
+}
+
+enum { ST_WAIT = 0, ST_READY, ST_LAUNCH, ST_RUN, ST_DONE };
+enum { BLK_NONE = 0, BLK_SLOT, BLK_LAUNCHER };
+
+int ds_eval(const ds_model *m, const ds_opts *o, ds_result *r) {
+    memset(r, 0, sizeof *r);
+    if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", "");
+    ds_num num[DS_MAX_OPS];
+    int rc = resolve(m, o, num, r);
+    if (rc) return rc;
+    int order[DS_MAX_OPS];
+    if (!topo(m, order)) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", "");
+    /* a buffer that never fits */
+    for (int i = 0; i < m->n_buf; i++)
+        if (m->buf[i].bytes > m->res[m->buf[i].cap].cap)
+            return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[i].id, m->res[m->buf[i].cap].id);
+
+    /* provenance mask */
+    for (int i = 0; i < m->n_ops; i++) r->prov_mask |= 1u << num[i].prov;
+    for (int i = 0; i < m->n_res; i++) {
+        int used = 0;
+        for (int j = 0; j < m->n_ops; j++) if (m->ops[j].engine == i || m->ops[j].bw == i || m->ops[j].launcher == i) used = 1;
+        for (int j = 0; j < m->n_buf; j++) if (m->buf[j].cap == i) used = 1;
+        if (used) r->prov_mask |= 1u << m->res[i].prov;
+    }
+
+    /* ---- fluid simulation ---- */
+    int state[DS_MAX_OPS] = {0}, blocked[DS_MAX_OPS] = {0}, npred[DS_MAX_OPS] = {0}, done_pred[DS_MAX_OPS] = {0};
+    double rem_t[DS_MAX_OPS], rem_b[DS_MAX_OPS], rem_l[DS_MAX_OPS], run_start[DS_MAX_OPS], bytes_end[DS_MAX_OPS];
+    int free_slots[DS_MAX_RES], launcher_busy[DS_MAX_RES] = {0};
+    for (int i = 0; i < m->n_res; i++) free_slots[i] = m->res[i].slots;
+    for (int i = 0; i < m->n_deps; i++) npred[m->deps[i].to]++;
+    for (int i = 0; i < m->n_ops; i++) {
+        rem_t[i] = num[i].t; rem_b[i] = num[i].bytes; rem_l[i] = num[i].launch;
+        run_start[i] = bytes_end[i] = -1;
+        r->n_ops++;
+        r->total_bytes += num[i].bytes; r->total_busy_ns += num[i].t; r->total_launch_ns += num[i].launch;
+    }
+    double t = 0;
+    int remaining = m->n_ops, guard = 0;
+    while (remaining > 0) {
+        if (++guard > 8 * DS_MAX_OPS + 16) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", "");
+        /* deps satisfied -> ready */
+        for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_WAIT && done_pred[i] == npred[i]) { state[i] = ST_READY; r->ready_ns[i] = t; }
+        /* dispatch in file order */
+        for (int i = 0; i < m->n_ops; i++) {
+            if (state[i] != ST_READY) continue;
+            const ds_op *op = &m->ops[i];
+            if (op->engine >= 0 && free_slots[op->engine] <= 0) { blocked[i] = BLK_SLOT; continue; }
+            if (op->launcher >= 0 && rem_l[i] > 0 && launcher_busy[op->launcher]) { blocked[i] = BLK_LAUNCHER; continue; }
+            if (op->engine >= 0) free_slots[op->engine]--;
+            r->start_ns[i] = t;
+            if (op->launcher >= 0 && rem_l[i] > 0) { launcher_busy[op->launcher] = 1; state[i] = ST_LAUNCH; }
+            else { state[i] = ST_RUN; run_start[i] = t; }
+        }
+        /* next event */
+        int active[DS_MAX_RES] = {0};
+        for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_RUN && rem_b[i] > 0) active[m->ops[i].bw]++;
+        double dt = -1; int any = 0;
+        for (int i = 0; i < m->n_ops; i++) {
+            if (state[i] == ST_LAUNCH) { any = 1; if (dt < 0 || rem_l[i] < dt) dt = rem_l[i]; }
+            else if (state[i] == ST_RUN) {
+                any = 1;
+                /* next event for this op: the earlier of its two progress bars */
+                double d = -1;
+                if (rem_t[i] > 0) d = rem_t[i];
+                if (rem_b[i] > 0) {
+                    double share = num[i].cap / active[m->ops[i].bw];
+                    double db = rem_b[i] / share;
+                    if (d < 0 || db < d) d = db;
+                }
+                if (d < 0) d = 0;
+                if (dt < 0 || d < dt) dt = d;
+            }
+        }
+        if (!any) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", "");
+        if (dt < 0) dt = 0;
+        t += dt;
+        const double eps = 1e-9;
+        for (int i = 0; i < m->n_ops; i++) {
+            if (state[i] == ST_LAUNCH) {
+                rem_l[i] -= dt;
+                if (rem_l[i] <= eps) { rem_l[i] = 0; launcher_busy[m->ops[i].launcher] = 0; state[i] = ST_RUN; run_start[i] = t; }
+            } else if (state[i] == ST_RUN) {
+                if (rem_t[i] > 0) { rem_t[i] -= dt; if (rem_t[i] <= eps) rem_t[i] = 0; }
+                if (rem_b[i] > 0) {
+                    double share = num[i].cap / active[m->ops[i].bw];
+                    rem_b[i] -= share * dt;
+                    if (rem_b[i] <= eps * (num[i].bytes > 1 ? num[i].bytes : 1)) { rem_b[i] = 0; bytes_end[i] = t; }
+                }
+                if (rem_t[i] <= 0 && rem_b[i] <= 0) {
+                    state[i] = ST_DONE; r->end_ns[i] = t; remaining--;
+                    if (m->ops[i].engine >= 0) free_slots[m->ops[i].engine]++;
+                    for (int d = 0; d < m->n_deps; d++) if (m->deps[d].from == i) done_pred[m->deps[d].to]++;
+                    if (num[i].bytes > 0) {
+                        double ideal = num[i].bytes / num[i].cap;
+                        double actual = (bytes_end[i] >= 0 ? bytes_end[i] : t) - run_start[i];
+                        r->op_contention_ns[i] = actual - ideal > 0 ? actual - ideal : 0;
+                    }
+                }
+            }
+        }
+        if (t > r->makespan_ns) r->makespan_ns = t;
+    }
+
+    /* ---- bounds ---- */
+    double cp[DS_MAX_OPS];
+    for (int k = 0; k < m->n_ops; k++) {
+        int i = order[k];
+        double floor_ = num[i].t;
+        if (num[i].bytes > 0 && num[i].bytes / num[i].cap > floor_) floor_ = num[i].bytes / num[i].cap;
+        floor_ += num[i].launch;
+        r->op_floor_ns[i] = floor_;
+        double best = 0;
+        for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == i && cp[m->deps[d].from] > best) best = cp[m->deps[d].from];
+        cp[i] = best + floor_;
+        if (cp[i] > r->bound_critical_path_ns) r->bound_critical_path_ns = cp[i];
+    }
+    r->bound_ns = r->bound_critical_path_ns;
+    for (int i = 0; i < m->n_res; i++) {
+        double w = 0;
+        for (int j = 0; j < m->n_ops; j++) {
+            if (m->res[i].kind == DS_RES_BANDWIDTH && m->ops[j].bw == i) w += num[j].bytes / num[j].cap;
+            if (m->res[i].kind == DS_RES_COMPUTE && m->ops[j].engine == i) w += (num[j].t + num[j].launch) / m->res[i].slots;
+            if (m->res[i].kind == DS_RES_LAUNCH && m->ops[j].launcher == i) w += num[j].launch;
+        }
+        r->bound_resource_ns[i] = w;
+        if (w > r->bound_ns) r->bound_ns = w;
+    }
+
+    /* ---- capacity ledger: frees before allocations at the same instant ---- */
+    for (int c = 0; c < m->n_res; c++) {
+        if (m->res[c].kind != DS_RES_CAPACITY) continue;
+        double live = 0, peak = 0, peak_at = 0;
+        /* event list */
+        double et[2 * DS_MAX_BUF]; double ev[2 * DS_MAX_BUF]; int en = 0;
+        for (int b = 0; b < m->n_buf; b++) {
+            if (m->buf[b].cap != c) continue;
+            double s = m->buf[b].first >= 0 ? r->start_ns[m->buf[b].first] : 0;
+            double e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns;
+            et[en] = s; ev[en] = m->buf[b].bytes; en++;
+            et[en] = e; ev[en] = -m->buf[b].bytes; en++;
+        }
+        /* insertion sort by time, frees (negative) first on ties; stable */
+        for (int i = 1; i < en; i++) {
+            double kt = et[i], kv_ = ev[i]; int j = i - 1;
+            while (j >= 0 && (et[j] > kt || (et[j] == kt && ev[j] > 0 && kv_ < 0))) { et[j + 1] = et[j]; ev[j + 1] = ev[j]; j--; }
+            et[j + 1] = kt; ev[j + 1] = kv_;
+        }
+        for (int i = 0; i < en; i++) { live += ev[i]; if (live > peak) { peak = live; peak_at = et[i]; } }
+        r->peak_live_bytes[c] = peak; r->peak_live_at_ns[c] = peak_at;
+        if (peak > m->res[c].cap + 1e-9) {
+            char names[160] = ""; size_t L = 0;
+            for (int b = 0; b < m->n_buf && L < sizeof names - 8; b++) {
+                if (m->buf[b].cap != c) continue;
+                double s = m->buf[b].first >= 0 ? r->start_ns[m->buf[b].first] : 0;
+                double e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns;
+                if (s <= peak_at && e > peak_at) { snprintf(names + L, sizeof names - L, "%s%s", L ? "," : "", m->buf[b].id); L = strlen(names); }
+            }
+            char what[200]; snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", peak, peak_at, names);
+            int st = refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[c].id);
+            return st;
+        }
+    }
+
+    /* ---- attribution along the schedule's critical chain ---- */
+    int cur = 0;
+    for (int i = 1; i < m->n_ops; i++) if (r->end_ns[i] > r->end_ns[cur]) cur = i;
+    double accounted = 0;
+    int chain[DS_MAX_OPS]; int nc = 0;
+    while (cur >= 0 && nc < DS_MAX_OPS) {
+        chain[nc++] = cur;
+        const ds_op *op = &m->ops[cur];
+        double runtime = r->end_ns[cur] - (run_start[cur] >= 0 ? run_start[cur] : r->start_ns[cur]);
+        r->attr_ns[DS_ATTR_LAUNCH] += num[cur].launch;
+        accounted += num[cur].launch;
+        if (op->kind == DS_OP_BARRIER) r->attr_ns[DS_ATTR_SYNC] += runtime;
+        else if (num[cur].bytes > 0) {
+            double ideal = num[cur].bytes / num[cur].cap;
+            double actual = ideal + r->op_contention_ns[cur];
+            if (num[cur].t >= actual) r->attr_ns[DS_ATTR_COMPUTE] += runtime;
+            else { r->attr_ns[DS_ATTR_BANDWIDTH] += ideal; r->attr_ns[DS_ATTR_CONTENTION] += r->op_contention_ns[cur]; if (runtime > actual) r->attr_ns[DS_ATTR_RESIDUAL] += runtime - actual; }
+        } else r->attr_ns[DS_ATTR_COMPUTE] += runtime;
+        accounted += runtime;
+        /* predecessor: the dep that finished last */
+        int pred = -1;
+        for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == cur && (pred < 0 || r->end_ns[m->deps[d].from] > r->end_ns[pred])) pred = m->deps[d].from;
+        double gap = r->start_ns[cur] - (pred >= 0 ? r->end_ns[pred] : 0);
+        if (gap > 0) {
+            if (blocked[cur] == BLK_SLOT) r->attr_ns[DS_ATTR_SERIALIZATION] += gap;
+            else if (blocked[cur] == BLK_LAUNCHER) r->attr_ns[DS_ATTR_LAUNCH] += gap;
+            else r->attr_ns[DS_ATTR_RESIDUAL] += gap;
+            accounted += gap;
+        }
+        cur = pred;
+    }
+    for (int i = 0; i < nc; i++) r->critical_path[i] = chain[nc - 1 - i];
+    r->n_critical = nc;
+    double leftover = r->makespan_ns - accounted;
+    if (fabs(leftover) > 1e-6) r->attr_ns[DS_ATTR_RESIDUAL] += leftover;
+
+    /* ---- energy ---- */
+    if (m->has_energy && m->joules > 0 && strcmp(m->instrument, "none")) { r->energy_measured = 1; r->energy_j = m->joules; }
+    else if (m->has_energy && m->power_w > 0 && m->energy_prov == DS_PROV_SYNTHETIC) { r->energy_synthetic = 1; r->energy_j = m->power_w * r->makespan_ns * 1e-9; r->prov_mask |= 1u << DS_PROV_SYNTHETIC; }
+    r->synthetic = (r->prov_mask & (1u << DS_PROV_SYNTHETIC)) ? 1 : 0;
+    r->status = DS_OK;
+    return DS_OK;
+}
+
+int ds_eval_interval(const ds_model *m, const ds_opts *o, ds_result *nominal, double *lo_ns, double *hi_ns) {
+    ds_opts x = *o; x.mode = 0;
+    int rc = ds_eval(m, &x, nominal);
+    *lo_ns = *hi_ns = 0;
+    if (rc) return rc;
+    ds_result tmp;
+    x.mode = +1; if (ds_eval(m, &x, &tmp) == DS_OK) *lo_ns = tmp.makespan_ns;
+    x.mode = -1; if (ds_eval(m, &x, &tmp) == DS_OK) *hi_ns = tmp.makespan_ns;
+    return rc;
+}
+
+double ds_counterfactual(const ds_model *m, const ds_opts *o, int res_index) {
+    if (res_index < 0 || res_index >= m->n_res) return -DS_REFUSED_UNSUPPORTED;
+    ds_model *c = malloc(sizeof *c);
+    if (!c) return -DS_REFUSED_UNSUPPORTED;
+    *c = *m;
+    ds_resource *r = &c->res[res_index];
+    switch (r->kind) {
+    case DS_RES_BANDWIDTH: r->cap *= 2; r->lo *= 2; r->hi *= 2; break;
+    case DS_RES_COMPUTE: r->slots *= 2; break;
+    case DS_RES_LAUNCH: for (int i = 0; i < c->n_ops; i++) if (c->ops[i].launcher == res_index) c->ops[i].launch_ns = 0; break;
+    case DS_RES_CAPACITY: r->cap *= 2; break;
+    }
+    ds_result res; ds_opts x = *o; x.mode = 0;
+    int rc = ds_eval(c, &x, &res);
+    free(c);
+    return rc == DS_OK ? res.makespan_ns : -(double)rc;
+}
+
+/* ---------------------------------------------------------------- diff */
+
+static int in_changed(const char *list, const char *id) {
+    if (!list) return 0;
+    const char *p = list; size_t L = strlen(id);
+    while (*p) {
+        const char *q = strchr(p, ','); size_t n = q ? (size_t)(q - p) : strlen(p);
+        if (n == L && !strncmp(p, id, L)) return 1;
+        if (!q) break;
+        p = q + 1;
+    }
+    return 0;
+}
+
+int ds_diff_models(const ds_model *b, const ds_model *t, const ds_opts *o, ds_diff *d) {
+    memset(d, 0, sizeof *d);
+    for (int i = 0; i < t->n_ops; i++) if (ds_find_op(b, t->ops[i].id) < 0) d->n_added++;
+    for (int i = 0; i < b->n_ops; i++) {
+        int j = ds_find_op(t, b->ops[i].id);
+        if (j >= 0) {
+            d->n_kept++;
+            if (b->ops[i].t_ns != t->ops[j].t_ns || b->ops[i].bytes != t->ops[j].bytes)
+                snprintf(d->reason, sizeof d->reason, "op %s kept but its demand changed; trace conservation broken", b->ops[i].id);
+            continue;
+        }
+        d->n_removed++;
+        /* find its removed record(s) */
+        int found = 0; const ds_removed *rec = NULL;
+        for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, b->ops[i].id)) { found++; rec = &t->removed[k]; }
+        if (found == 0) { d->required_removed = 1; snprintf(d->reason, sizeof d->reason, "op %s vanished without a removed record", b->ops[i].id); return DS_REFUSED_REMOVED_REQUIRED; }
+        if (found > 1) { d->double_counted = 1; snprintf(d->reason, sizeof d->reason, "op %s removed %d times (double counted)", b->ops[i].id, found); return DS_REFUSED_REMOVED_REQUIRED; }
+        /* consumers of the removed op in the baseline that still exist */
+        int has_consumer = 0;
+        for (int k = 0; k < b->n_deps; k++) if (b->deps[k].from == i && ds_find_op(t, b->ops[b->deps[k].to].id) >= 0) has_consumer = 1;
+        int ok = 1;
+        switch (rec->reason) {
+        case DS_RM_ELIMINATED: if (has_consumer && !rec->proof[0]) ok = 0; break;
+        case DS_RM_REUSED: case DS_RM_LOOKUP: case DS_RM_MOVED: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0; break;
+        case DS_RM_UNCHANGED_DEP: if (!rec->ref[0] || ds_find_op(b, rec->ref) < 0 || in_changed(o ? o->changed : NULL, rec->ref)) ok = 0; break;
+        case DS_RM_DEFERRED: if (has_consumer) ok = 0; break;
+        case DS_RM_SHARED:
+            if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0;
+            for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, rec->ref)) { d->double_counted = 1; ok = 0; }
+            break;
+        }
+        if (!ok) {
+            d->required_removed = 1;
+            snprintf(d->reason, sizeof d->reason, "op %s: removal reason %d not supported by its evidence (ref=%s proof=%s changed=%s)",
+                     b->ops[i].id, rec->reason, rec->ref, rec->proof, o && o->changed ? o->changed : "");
+            return DS_REFUSED_REMOVED_REQUIRED;
+        }
+        double w = b->ops[i].t_ns + b->ops[i].launch_ns;
+        if (b->ops[i].bytes > 0 && b->ops[i].bw >= 0) { double tb = b->ops[i].bytes / (b->res[b->ops[i].bw].cap * 1e-9); if (tb > b->ops[i].t_ns) w = tb + b->ops[i].launch_ns; }
+        d->removed_ns[rec->reason] += w;
+    }
+    /* removed records that name ops never in the baseline are fabricated savings */
+    for (int k = 0; k < t->n_removed; k++) if (ds_find_op(b, t->removed[k].op) < 0) {
+        d->double_counted = 1;
+        snprintf(d->reason, sizeof d->reason, "removed record for %s, which was never in the baseline", t->removed[k].op);
+        return DS_REFUSED_REMOVED_REQUIRED;
+    }
+    return DS_OK;
+}
diff --git a/tools/dagsim/dagsim.h b/tools/dagsim/dagsim.h
new file mode 100644
index 000000000..a409b588b
--- /dev/null
+++ b/tools/dagsim/dagsim.h
@@ -0,0 +1,166 @@
+/*
+ * dagsim.h -- offline resource-DAG cost evaluator (omega-mv#583).
+ *
+ * Reads an OEV1 file (spec/offline-evidence-v1.md) and composes the per-op
+ * costs it carries, or that rx_costmodel predicts for matvec ops, into a
+ * whole-DAG schedule under finite resources: compute slots, shared
+ * bandwidth (processor sharing), serialized launches, one capacity ledger,
+ * dependencies and barriers. It never executes anything. It refuses rather
+ * than guess: unknown provenance, stale calibration, capacity overflow,
+ * unsupported constructs and cycles are all refusals with a reason.
+ *
+ * Host only. No GPU, no authority, no generation store.
+ */
+#ifndef DAGSIM_H
+#define DAGSIM_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define DS_MAX_OPS   256
+#define DS_MAX_RES   32
+#define DS_MAX_BUF   256
+#define DS_MAX_DEPS  1024
+#define DS_MAX_REMOVED 256
+#define DS_ID        40
+#define DS_SRC       128
+
+enum ds_prov { DS_PROV_UNKNOWN = 0, DS_PROV_SYNTHETIC, DS_PROV_FITTED, DS_PROV_MEASURED, DS_PROV_SPECIFIED };
+enum ds_res_kind { DS_RES_COMPUTE = 1, DS_RES_BANDWIDTH, DS_RES_CAPACITY, DS_RES_LAUNCH };
+enum ds_op_kind { DS_OP_COMPUTE = 1, DS_OP_COPY, DS_OP_MATVEC, DS_OP_BARRIER, DS_OP_STORAGE, DS_OP_PERSIST };
+enum ds_removed_reason { DS_RM_ELIMINATED = 1, DS_RM_REUSED, DS_RM_UNCHANGED_DEP, DS_RM_DEFERRED, DS_RM_MOVED, DS_RM_SHARED, DS_RM_LOOKUP };
+
+enum ds_status {
+    DS_OK = 0,
+    DS_REFUSED_UNKNOWN,          /* an op or resource with prov=unknown feeds the result */
+    DS_REFUSED_STALE,            /* asof is past calibration taken + valid_days */
+    DS_REFUSED_NO_CALIBRATION,   /* measured/fitted values but no calibration record */
+    DS_REFUSED_CAPACITY,         /* peak live bytes exceed a capacity resource */
+    DS_REFUSED_CYCLE,
+    DS_REFUSED_UNSUPPORTED,      /* construct the evaluator does not model */
+    DS_REFUSED_REMOVED_REQUIRED, /* a remaining op depends on removed work without a valid derivation */
+    DS_PARSE_ERROR
+};
+
+typedef struct {
+    char id[DS_ID];
+    int kind;
+    int slots;                   /* compute */
+    double cap, lo, hi;          /* bandwidth (B/s) or capacity (B) */
+    int prov;
+    char src[DS_SRC];
+} ds_resource;
+
+typedef struct {
+    char id[DS_ID];
+    int kind;
+    int engine;                  /* resource index or -1 */
+    double t_ns, lo, hi;         /* own busy time */
+    int t_prov;
+    int has_t;
+    double bytes;
+    int bw;                      /* bandwidth resource index or -1 */
+    double launch_ns;
+    int launcher;                /* launch resource index or -1 */
+    uint32_t M, N, core, arm;    /* matvec */
+    char src[DS_SRC];
+} ds_op;
+
+typedef struct { char id[DS_ID]; double bytes; int cap; int first, last; } ds_buffer;
+typedef struct { int from, to; } ds_dep;
+typedef struct { char op[DS_ID]; int reason; char ref[DS_ID]; char proof[DS_SRC]; } ds_removed;
+
+typedef struct {
+    int version;
+    char machine_id[DS_ID], soc[DS_ID];
+    int cores;
+    double mem_bytes;
+    char build_sha[48], physics[48], repo[DS_ID];
+    int has_calibration;
+    char cal_id[DS_ID];
+    int cal_taken_day;           /* days since 1970-01-01 */
+    int cal_valid_days;
+    double cal_load1;
+    char cal_src[DS_SRC], cal_model[DS_SRC];
+    int n_res, n_ops, n_buf, n_deps, n_removed;
+    ds_resource res[DS_MAX_RES];
+    ds_op ops[DS_MAX_OPS];
+    ds_buffer buf[DS_MAX_BUF];
+    ds_dep deps[DS_MAX_DEPS];
+    ds_removed removed[DS_MAX_REMOVED];
+    /* energy */
+    char instrument[DS_ID], boundary[DS_ID];
+    int energy_prov;
+    double joules, power_w;
+    int has_energy;
+} ds_model;
+
+typedef struct {
+    int asof_day;                /* days since epoch; 0 = today */
+    int mode;                    /* 0 nominal, -1 pessimistic (lo bandwidth, hi time), +1 optimistic */
+    const void *costmodel;       /* const RxCostModel* or NULL */
+    double interval_q;           /* for rx_costmodel intervals, e.g. 0.9 */
+    const char *changed;         /* diff only: comma list of baseline ops whose inputs changed */
+} ds_opts;
+
+enum { DS_ATTR_COMPUTE = 0, DS_ATTR_BANDWIDTH, DS_ATTR_CONTENTION, DS_ATTR_LAUNCH, DS_ATTR_SERIALIZATION, DS_ATTR_SYNC, DS_ATTR_RESIDUAL, DS_ATTR_N };
+
+typedef struct {
+    int status;
+    char reason[256];
+    double makespan_ns;
+    double start_ns[DS_MAX_OPS], end_ns[DS_MAX_OPS], ready_ns[DS_MAX_OPS];
+    double op_contention_ns[DS_MAX_OPS];   /* extra traffic time due to sharing */
+    double op_floor_ns[DS_MAX_OPS];        /* launch + max(t, bytes/cap) */
+    double bound_critical_path_ns;
+    double bound_resource_ns[DS_MAX_RES];  /* per resource work bound */
+    double bound_ns;                       /* max of all bounds */
+    double peak_live_bytes[DS_MAX_RES];    /* per capacity resource */
+    double peak_live_at_ns[DS_MAX_RES];
+    double attr_ns[DS_ATTR_N];
+    int critical_path[DS_MAX_OPS], n_critical;
+    uint32_t prov_mask;                    /* bit per ds_prov that fed the result */
+    int synthetic;
+    /* conservation: what went in is what was scheduled */
+    int n_ops;
+    double total_bytes, total_busy_ns, total_launch_ns;
+    /* energy */
+    int energy_measured;                   /* 1: joules from a named instrument */
+    int energy_synthetic;                  /* 1: E = P*T from a synthetic power figure */
+    double energy_j;
+} ds_result;
+
+/* Parse. Returns DS_OK or DS_PARSE_ERROR with the line and reason in `err`. */
+int ds_parse_file(const char *path, ds_model *m, char *err, size_t errcap);
+int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap);
+
+/* Evaluate deterministically. Fills every field of `r` or sets a refusal. */
+int ds_eval(const ds_model *m, const ds_opts *o, ds_result *r);
+
+/* Three-point interval: nominal, lo (optimistic) and hi (pessimistic) makespan.
+ * Returns the nominal status; lo/hi are 0 when any point refused. */
+int ds_eval_interval(const ds_model *m, const ds_opts *o, ds_result *nominal, double *lo_ns, double *hi_ns);
+
+/* Counterfactual sensitivity: makespan with one resource doubled (bandwidth cap x2,
+ * compute slots x2, launch cost 0). Returns the new makespan or a negative status. */
+double ds_counterfactual(const ds_model *m, const ds_opts *o, int res_index);
+
+/* Minimum-work accounting: compare a baseline and a transformed model by stable op
+ * ids. Sums removed work by reason and detects double-counted shared work and removal
+ * of required work. */
+typedef struct {
+    double removed_ns[8];        /* by ds_removed_reason */
+    int n_removed, n_added, n_kept;
+    int double_counted;          /* an op removed with reason=shared appears twice or refs a missing op */
+    int required_removed;        /* a removed op without a valid derivation still has consumers */
+    char reason[256];
+} ds_diff;
+int ds_diff_models(const ds_model *baseline, const ds_model *transformed, const ds_opts *o, ds_diff *d);
+
+const char *ds_status_name(int s);
+const char *ds_prov_name(int p);
+int ds_day_from_date(const char *yyyy_mm_dd);
+int ds_find_op(const ds_model *m, const char *id);
+int ds_find_res(const ds_model *m, const char *id);
+
+#endif /* DAGSIM_H */
diff --git a/tools/dagsim/dagsim_cli.c b/tools/dagsim/dagsim_cli.c
new file mode 100644
index 000000000..fb279f904
--- /dev/null
+++ b/tools/dagsim/dagsim_cli.c
@@ -0,0 +1,222 @@
+/*
+ * dagsim_cli -- reproducible command line for the offline resource-DAG
+ * evaluator (omega-mv#583). No GPU, no execution: it reads OEV1 files and
+ * prints JSON. Every number it prints names the provenance it came from.
+ *
+ *   dagsim eval FILE [--asof YYYY-MM-DD] [--model BLOB]
+ *   dagsim pareto FILE... [--asof YYYY-MM-DD] [--model BLOB]
+ *   dagsim diff BASELINE TRANSFORMED [--changed a,b,...]
+ */
+#include "dagsim.h"
+#include "runtime/rx_costmodel.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void jstr(const char *s) {
+    putchar('"');
+    for (; *s; s++) {
+        if (*s == '"' || *s == '\\') { putchar('\\'); putchar(*s); }
+        else if ((unsigned char)*s < 0x20) printf("\\u%04x", *s);
+        else putchar(*s);
+    }
+    putchar('"');
+}
+static void jnum(double v) { if (v == floor(v) && fabs(v) < 1e15) printf("%.0f", v); else printf("%.6g", v); }
+
+static int load_model(const char *path, RxCostModel *cm) {
+    FILE *fp = fopen(path, "rb");
+    if (!fp) return 0;
+    size_t cap = rx_cm_blob_size();
+    uint8_t *buf = malloc(cap);
+    if (!buf) { fclose(fp); return 0; }
+    size_t got = fread(buf, 1, cap, fp);
+    fclose(fp);
+    int ok = rx_cm_deserialize(cm, buf, got) == RX_CM_OK;
+    free(buf);
+    return ok;
+}
+
+static const char *attr_name[DS_ATTR_N] = { "compute", "bandwidth", "contention", "launch", "serialization", "sync", "residual" };
+static const char *res_kind_name(int k) {
+    switch (k) { case DS_RES_COMPUTE: return "compute"; case DS_RES_BANDWIDTH: return "bandwidth"; case DS_RES_CAPACITY: return "capacity"; case DS_RES_LAUNCH: return "launch"; default: return "?"; }
+}
+
+static void emit_result_json(const char *path, const ds_model *m, const ds_opts *o, const ds_result *r, double lo, double hi) {
+    printf("{\n  \"schema\": \"oev1\", \"tool\": \"dagsim\", \"file\": "); jstr(path);
+    printf(",\n  \"machine\": "); jstr(m->machine_id);
+    printf(", \"build_sha\": "); jstr(m->build_sha);
+    printf(",\n  \"calibration\": {\"id\": "); jstr(m->has_calibration ? m->cal_id : "");
+    printf(", \"taken_day\": %d, \"valid_days\": %d, \"load1\": ", m->cal_taken_day, m->cal_valid_days); jnum(m->cal_load1);
+    printf(", \"src\": "); jstr(m->cal_src); printf("},\n  \"asof_day\": %d,\n", o->asof_day);
+    printf("  \"status\": "); jstr(ds_status_name(r->status)); printf(", \"reason\": "); jstr(r->reason);
+    printf(",\n  \"provenance\": ["); int first = 1;
+    for (int p = 0; p <= DS_PROV_SPECIFIED; p++) if (r->prov_mask & (1u << p)) { if (!first) printf(", "); jstr(ds_prov_name(p)); first = 0; }
+    printf("], \"synthetic\": %d, \"offline\": true, \"gpu_executed\": false", r->synthetic);
+    if (r->status != DS_OK) { printf("\n}\n"); return; }
+    printf(",\n  \"makespan_ns\": {\"nominal\": "); jnum(r->makespan_ns); printf(", \"lo\": "); jnum(lo); printf(", \"hi\": "); jnum(hi);
+    printf(", \"interval_known\": %s}", (lo > 0 && hi > 0) ? "true" : "false");
+    printf(",\n  \"bounds_ns\": {\"critical_path\": "); jnum(r->bound_critical_path_ns); printf(", \"max\": "); jnum(r->bound_ns); printf(", \"resources\": {");
+    for (int i = 0; i < m->n_res; i++) { if (i) printf(", "); jstr(m->res[i].id); printf(": "); jnum(r->bound_resource_ns[i]); }
+    printf("}, \"makespan_ge_bounds\": %s}", r->makespan_ns + 1e-6 >= r->bound_ns ? "true" : "false");
+    printf(",\n  \"ops\": [");
+    for (int i = 0; i < m->n_ops; i++) {
+        printf("%s\n    {\"id\": ", i ? "," : ""); jstr(m->ops[i].id);
+        printf(", \"start_ns\": "); jnum(r->start_ns[i]); printf(", \"end_ns\": "); jnum(r->end_ns[i]);
+        printf(", \"floor_ns\": "); jnum(r->op_floor_ns[i]); printf(", \"contention_ns\": "); jnum(r->op_contention_ns[i]);
+        printf(", \"prov\": "); jstr(ds_prov_name(m->ops[i].kind == DS_OP_MATVEC && !m->ops[i].has_t ? DS_PROV_FITTED : m->ops[i].t_prov));
+        printf(", \"src\": "); jstr(m->ops[i].src); printf("}");
+    }
+    printf("\n  ],\n  \"critical_path\": [");
+    for (int i = 0; i < r->n_critical; i++) { if (i) printf(", "); jstr(m->ops[r->critical_path[i]].id); }
+    printf("],\n  \"peak_live_bytes\": {");
+    first = 1;
+    for (int i = 0; i < m->n_res; i++) if (m->res[i].kind == DS_RES_CAPACITY) {
+        if (!first) printf(", ");
+        first = 0;
+        jstr(m->res[i].id); printf(": {\"bytes\": "); jnum(r->peak_live_bytes[i]); printf(", \"at_ns\": "); jnum(r->peak_live_at_ns[i]); printf(", \"cap\": "); jnum(m->res[i].cap); printf("}");
+    }
+    printf("},\n  \"attribution_ns\": {");
+    for (int i = 0; i < DS_ATTR_N; i++) { if (i) printf(", "); jstr(attr_name[i]); printf(": "); jnum(r->attr_ns[i]); }
+    printf("},\n  \"energy\": {\"status\": ");
+    jstr(r->energy_measured ? "MEASURED" : r->energy_synthetic ? "SYNTHETIC_SENSITIVITY_ONLY" : "UNMEASURED");
+    printf(", \"joules\": "); if (r->energy_measured || r->energy_synthetic) jnum(r->energy_j); else printf("null");
+    printf(", \"instrument\": "); jstr(m->instrument); printf(", \"boundary\": "); jstr(m->boundary);
+    printf(", \"ranking_valid\": %s}", r->energy_measured ? "true" : "false");
+    printf(",\n  \"conservation\": {\"n_ops\": %d, \"total_bytes\": ", r->n_ops); jnum(r->total_bytes);
+    printf(", \"total_busy_ns\": "); jnum(r->total_busy_ns); printf(", \"total_launch_ns\": "); jnum(r->total_launch_ns);
+    printf(", \"instrument_overhead_ns\": null}");
+    /* counterfactual sensitivities, ranked by how much they could move the makespan,
+     * weighted by how uncertain the resource's own figure is */
+    printf(",\n  \"sensitivities\": [");
+    double score[DS_MAX_RES]; int idx[DS_MAX_RES]; double cf[DS_MAX_RES]; double width[DS_MAX_RES];
+    for (int i = 0; i < m->n_res; i++) {
+        cf[i] = ds_counterfactual(m, o, i);
+        width[i] = m->res[i].kind == DS_RES_BANDWIDTH && m->res[i].cap > 0 ? (m->res[i].hi - m->res[i].lo) / m->res[i].cap : 0;
+        if (m->res[i].prov == DS_PROV_SPECIFIED) width[i] = 1.0;    /* a datasheet number is not a measurement */
+        score[i] = cf[i] >= 0 ? fabs(r->makespan_ns - cf[i]) * (width[i] > 0 ? width[i] : 0.05) : 0;
+        idx[i] = i;
+    }
+    for (int a = 1; a < m->n_res; a++) {
+        int k = idx[a]; int b = a - 1;
+        while (b >= 0 && score[idx[b]] < score[k]) { idx[b + 1] = idx[b]; b--; }
+        idx[b + 1] = k;
+    }
+    for (int a = 0; a < m->n_res; a++) {
+        int i = idx[a];
+        printf("%s\n    {\"resource\": ", a ? "," : ""); jstr(m->res[i].id);
+        printf(", \"kind\": "); jstr(res_kind_name(m->res[i].kind));
+        printf(", \"makespan_if_doubled_ns\": "); if (cf[i] >= 0) jnum(cf[i]); else printf("null");
+        printf(", \"delta_ns\": "); if (cf[i] >= 0) jnum(r->makespan_ns - cf[i]); else printf("null");
+        printf(", \"interval_width_frac\": "); jnum(width[i]);
+        printf(", \"decision_score\": "); jnum(score[i]);
+        printf(", \"next_experiment\": ");
+        if (m->res[i].kind == DS_RES_BANDWIDTH) jstr(m->res[i].prov == DS_PROV_SPECIFIED ? "measure this bandwidth on this DAG's shapes (datasheet figure, never attained)" : "repeat the bandwidth receipt on a quiet box to tighten lo/hi");
+        else if (m->res[i].kind == DS_RES_LAUNCH) jstr("measure launch with the device context held open (M1 block2 follow-up)");
+        else if (m->res[i].kind == DS_RES_COMPUTE) jstr("measure the critical op at the next larger shape");
+        else jstr("none: capacity is a ledger, not a rate");
+        printf("}");
+    }
+    printf("\n  ],\n  \"unresolved_residual_ns\": "); jnum(r->attr_ns[DS_ATTR_RESIDUAL]);
+    printf(",\n  \"note\": \"loaded-box calibration (load1 above); bounds are floors, not predictions; no performance claim from this simulation alone\"\n}\n");
+}
+
+static int cmd_eval(const char *path, const ds_opts *o) {
+    ds_model *m = malloc(sizeof *m); char err[256];
+    if (!m) return 2;
+    if (ds_parse_file(path, m, err, sizeof err) != DS_OK) {
+        printf("{\"schema\": \"oev1\", \"tool\": \"dagsim\", \"file\": "); jstr(path); printf(", \"status\": \"PARSE_ERROR\", \"reason\": "); jstr(err); printf("}\n");
+        free(m); return 1;
+    }
+    ds_result *r = malloc(sizeof *r); double lo, hi;
+    if (!r) { free(m); return 2; }
+    int rc = ds_eval_interval(m, o, r, &lo, &hi);
+    emit_result_json(path, m, o, r, lo, hi);
+    free(r); free(m);
+    return rc == DS_OK ? 0 : 1;
+}
+
+typedef struct { const char *path; int status; double t, lo, hi, peak, e; int e_meas, e_syn, front; char reason[256]; } prow;
+
+static int cmd_pareto(int n, const char **paths, const ds_opts *o) {
+    prow rows[64]; if (n > 64) n = 64;
+    int all_energy = 1;
+    for (int k = 0; k < n; k++) {
+        prow *p = &rows[k]; memset(p, 0, sizeof *p); p->path = paths[k];
+        ds_model *m = malloc(sizeof *m); ds_result *r = malloc(sizeof *r); char err[256];
+        if (!m || !r) return 2;
+        if (ds_parse_file(paths[k], m, err, sizeof err) != DS_OK) { p->status = DS_PARSE_ERROR; snprintf(p->reason, sizeof p->reason, "%s", err); free(m); free(r); all_energy = 0; continue; }
+        p->status = ds_eval_interval(m, o, r, &p->lo, &p->hi);
+        snprintf(p->reason, sizeof p->reason, "%s", r->reason);
+        if (p->status == DS_OK) {
+            p->t = r->makespan_ns;
+            for (int i = 0; i < m->n_res; i++) if (m->res[i].kind == DS_RES_CAPACITY && r->peak_live_bytes[i] > p->peak) p->peak = r->peak_live_bytes[i];
+            p->e = r->energy_j; p->e_meas = r->energy_measured; p->e_syn = r->energy_synthetic;
+            if (!p->e_meas) all_energy = 0;
+        } else all_energy = 0;
+        free(m); free(r);
+    }
+    /* non-dominated on (time, peak bytes[, measured joules]) among OK rows */
+    for (int a = 0; a < n; a++) {
+        if (rows[a].status != DS_OK) continue;
+        rows[a].front = 1;
+        for (int b = 0; b < n; b++) {
+            if (a == b || rows[b].status != DS_OK) continue;
+            int le = rows[b].t <= rows[a].t && rows[b].peak <= rows[a].peak && (!all_energy || rows[b].e <= rows[a].e);
+            int lt = rows[b].t < rows[a].t || rows[b].peak < rows[a].peak || (all_energy && rows[b].e < rows[a].e);
+            if (le && lt) { rows[a].front = 0; break; }
+        }
+    }
+    printf("# dagsim pareto: objectives = seconds, peak bytes%s. Energy %s.\n", all_energy ? ", joules" : "",
+           all_energy ? "measured on every row and part of the dominance test" : "not measured on every row: shown, never ranked");
+    printf("# %-36s %-24s %14s %14s %14s %12s %-14s %s\n", "file", "status", "seconds", "lo_s", "hi_s", "peak_bytes", "energy", "front");
+    for (int k = 0; k < n; k++) {
+        prow *p = &rows[k];
+        char e[32];
+        if (p->e_meas) snprintf(e, sizeof e, "%.3f J", p->e); else if (p->e_syn) snprintf(e, sizeof e, "syn %.3f J", p->e); else snprintf(e, sizeof e, "UNMEASURED");
+        if (p->status == DS_OK)
+            printf("  %-36s %-24s %14.6f %14.6f %14.6f %12.0f %-14s %s\n", p->path, "OK", p->t * 1e-9, p->lo * 1e-9, p->hi * 1e-9, p->peak, e, p->front ? "yes" : "no");
+        else
+            printf("  %-36s %-24s %14s %14s %14s %12s %-14s %s   # %s\n", p->path, ds_status_name(p->status), "-", "-", "-", "-", "-", "refused", p->reason);
+    }
+    return 0;
+}
+
+static int cmd_diff(const char *a, const char *b, const ds_opts *o) {
+    ds_model *ma = malloc(sizeof *ma), *mb = malloc(sizeof *mb); char err[256]; ds_diff d;
+    if (!ma || !mb) return 2;
+    if (ds_parse_file(a, ma, err, sizeof err) != DS_OK) { fprintf(stderr, "%s: %s\n", a, err); return 1; }
+    if (ds_parse_file(b, mb, err, sizeof err) != DS_OK) { fprintf(stderr, "%s: %s\n", b, err); return 1; }
+    int rc = ds_diff_models(ma, mb, o, &d);
+    static const char *rn[8] = { "", "eliminated", "reused", "unchanged_dep", "deferred", "moved", "shared", "lookup" };
+    printf("{\"tool\": \"dagsim diff\", \"baseline\": "); jstr(a); printf(", \"transformed\": "); jstr(b);
+    printf(", \"status\": "); jstr(ds_status_name(rc)); printf(", \"reason\": "); jstr(d.reason);
+    printf(", \"kept\": %d, \"added\": %d, \"removed\": %d, \"double_counted\": %d, \"required_removed\": %d, \"removed_ns\": {", d.n_kept, d.n_added, d.n_removed, d.double_counted, d.required_removed);
+    for (int i = 1; i < 8; i++) { if (i > 1) printf(", "); jstr(rn[i]); printf(": "); jnum(d.removed_ns[i]); }
+    printf("}, \"changed\": "); jstr(o->changed ? o->changed : ""); printf("}\n");
+    free(ma); free(mb);
+    return rc == DS_OK ? 0 : 1;
+}
+
+int main(int argc, char **argv) {
+    if (argc < 3) { fprintf(stderr, "usage: dagsim eval FILE | pareto FILE... | diff BASE TRANSFORMED  [--asof YYYY-MM-DD] [--model BLOB] [--changed a,b]\n"); return 2; }
+    ds_opts o; memset(&o, 0, sizeof o); o.interval_q = 0.9;
+    RxCostModel *cm = NULL;
+    const char *files[64]; int nf = 0;
+    for (int i = 2; i < argc; i++) {
+        if (!strcmp(argv[i], "--asof") && i + 1 < argc) { o.asof_day = ds_day_from_date(argv[++i]); if (o.asof_day < 0) { fprintf(stderr, "bad --asof\n"); return 2; } }
+        else if (!strcmp(argv[i], "--model") && i + 1 < argc) { cm = malloc(sizeof *cm); if (!cm || !load_model(argv[++i], cm)) { fprintf(stderr, "cannot load rx_costmodel blob %s\n", argv[i]); return 2; } o.costmodel = cm; }
+        else if (!strcmp(argv[i], "--changed") && i + 1 < argc) o.changed = argv[++i];
+        else if (nf < 64) files[nf++] = argv[i];
+    }
+    if (o.asof_day == 0) { fprintf(stderr, "dagsim: --asof YYYY-MM-DD is required so the run is reproducible (calibration validity is checked against it)\n"); return 2; }
+    int rc;
+    if (!strcmp(argv[1], "eval") && nf == 1) rc = cmd_eval(files[0], &o);
+    else if (!strcmp(argv[1], "pareto") && nf >= 1) rc = cmd_pareto(nf, files, &o);
+    else if (!strcmp(argv[1], "diff") && nf == 2) rc = cmd_diff(files[0], files[1], &o);
+    else { fprintf(stderr, "usage: dagsim eval FILE | pareto FILE... | diff BASE TRANSFORMED\n"); rc = 2; }
+    free(cm);
+    return rc;
+}