open-standards/joule-code/examples/l3-jouleclaw/tests/common
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science f521fb17be
Some checks failed
joule-code conformance gate / Build + round-trip C1-C4 vectors (pull_request) Has been cancelled
jouleclaw public surface must stay documented / Public-surface audit (jouleclaw-rs) (pull_request) Has been cancelled
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Has been cancelled
standards workspaces build + test / jouleclaw-rs (pull_request) Has been cancelled
standards workspaces build + test / aac-rs (pull_request) Has been cancelled
standards workspaces build + test / arl-rs (pull_request) Has been cancelled
standards workspaces build + test / eoc-rs (pull_request) Has been cancelled
standards workspaces build + test / jcp-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-code-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-ui-rs (pull_request) Has been cancelled
standards workspaces build + test / joulecontract-rs (pull_request) Has been cancelled
standards workspaces build + test / jouledesk-rs (pull_request) Has been cancelled
standards workspaces build + test / joulehook-rs (pull_request) Has been cancelled
standards workspaces build + test / map-rs (pull_request) Has been cancelled
standards workspaces build + test / mesh-rs (pull_request) Has been cancelled
standards workspaces build + test / openpay (pull_request) Has been cancelled
standards workspaces build + test / proof-rs (pull_request) Has been cancelled
standards workspaces build + test / sandbox-rs (pull_request) Has been cancelled
standards workspaces build + test / sense-rs (pull_request) Has been cancelled
standards workspaces build + test / smart-byte-rs (pull_request) Has been cancelled
standards workspaces build + test / macOS energy backend (jcp-energy) (pull_request) Has been cancelled
l3-jouleclaw: a fabric-priced projection is graded by its weakest input
The L3 stage tagged every per-call figure a backend reported as ModelBased, on
the premise that it was "priced by THIS machine's IOReport calibration". It is
priced by whatever matmul figure each fabric member loaded: a calibration row at
the grade its writer declared, or a seeded figure, and the seeded GPU figures are
`Estimated` (a coarse model). A projection priced from an estimate was sealed as
a calibrated per-operation model. Joule-code SPEC §6 keeps those apart:
ModelBased is "computed from a calibrated per-operation model", Estimator "a
coarse constant estimator".

The fix needs each input's grade, which the ledger did not carry.

- jouleclaw-loader-gguf: `LedgerEntry` gains `projected_grade`, the
  `EnergyProvenance` of the cost row that priced `projected_uj`, taken from the
  same row, so the two are present or absent together. Additive; nothing else
  constructs the struct.
- l3-jouleclaw: `projection_grade(window)` grades a projection by its weakest
  input. ModelBased only when every member that ran was priced by a `Measured`
  or `Benchmarked` figure; Estimator when any was priced by an `Estimated`
  figure, when any ran unpriced (its work is missing from the sum), or when the
  window is empty (a figure no priced input accounts for). A projection is never
  a reading, so it is never HwShunt. The stage now opens the attribution window
  around the call itself (reset before, snapshot after), so a figure is graded
  by this call's inputs and not by entries an earlier call left behind.

Tests. The grading table covers Measured, Benchmarked, both, Estimated alone and
beside each calibrated grade, an unpriced member, and no input. In the stage, a
backend that runs a real matmul through the dispatcher with the fabric off, and
one that runs nothing, both report 0.25 J and get Estimator (main: ModelBased).
Two integration tests, each its own process, switch the fabric on with
`JOULECLAW_FABRIC=1` and point `JOULECLAW_FABRIC_CALIBRATION` at a file they
write, pricing `local/cpu-neon`'s matmul at 2.5e8 µJ/GFLOP: declared `Measured`,
the window carries `Measured` and the receipt says ModelBased, 1024 µJ;
declared `Estimated`, the window carries `Estimated` and the receipt says
Estimator, 1024 µJ. The machine's own ~/.jouleclaw/fabric-calibration.json is
neither read nor written by these tests.

Ran: `cargo test` in l3-jouleclaw (the model-backed tests stay #[ignore], no
model was loaded), `cargo test -p jouleclaw-loader-gguf --features fabric-meter
--lib` (304 passed), loader-gguf examples checked; clippy reports nothing new.

Not done: a projection under 1 µJ still truncates to a 0 µJ receipt figure, as
before; real hybrid-model calls are far above that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-30 20:48:47 -04:00
..
mod.rs l3-jouleclaw: a fabric-priced projection is graded by its weakest input 2026-09-30 20:48:47 -04:00