jcp-trace: an undefined wedge metric is not zero #292
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/jcp-trace-undefined-ratio-is-not-zero"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The sibling instance I flagged in #291, now fixed. Same defect, different sealed receipt (
eval/1).The defect
uj_per_accepted_tokenis a cost-per-result figure, so0is its optimum. A run that burned prompt tokens and accepted no output has no such figure — the division is undefined — and reporting0ranked it as the cheapest entry in the ledger.As in
jcp-efficiency, this is not a convenience accessor:eval_wireseals the figure into the signed core andverify()reads it straight back out rather than recomputing it, so the conflation was sealed and consumed as the headline.The fix
mesh/SPEC.md§6 states the family convention — the figure is "omitted when no tokens were accepted" — andMeshReceiptalready implements it. This bringseval/1onto the same shape:Totals::uj_per_accepted_tokenandEvalReceipt::uj_per_accepted_token→Option<u64>;DefaultisNone.eval_wireomits the key when the figure is undefined instead of sealing0. Canonical CBOR sorts keys, so the conditional insert does not change the wire of a receipt that has one.verify()reads it as optional, so an older receipt carrying the figure still round-trips.examples/ingest.rsprints—rather than a number.Tests
a_run_that_accepted_nothing_seals_no_wedge_metric— a trace with 800 prompt tokens and no accepted output: 8 000 µJ of real spend, no figure, the key absent from the signed core, and the envelope still verifying with the spend on it.Falsification
0fallback on the computationOptionbut seal.unwrap_or(0)T2 matters: it shows the wire half is load-bearing independently of the type change — an
Optionthat gets flattened at seal time fixes nothing. In both runs the gatedserver::tests::http_roundtrip_returns_sealed_eval_receiptkept passing, so the normal path is untouched.A test CI does not compile
server.rs:292asserts on this exact wire field (v["uj_per_accepted_token"] == 76), butpub mod serveris behind a non-default feature, socargo test --workspacenever compiles it — and the jcp row'sfeature_testsinstandards-build.ymlnames only-p jcp-energy --features nvml.I therefore ran it explicitly rather than assuming: it passes (the field is present there, since
output_tokens = 120). Flagging it because CI would not have told us either way. Widening that matrix entry is a separate change and I have not made it here.Verification
On the build host (aarch64):
cargo check --workspace --all-targets— exit 0cargo test --workspace— exit 0, 0 failed suites, 64 passing suitescargo test -p jcp-trace --features server --all-targets— exit 0, 15 passing (the gated path above)Scope
No
eval/1conformance vector exists, so no sealed vector pins the field.🤖 Generated with Claude Code
The sibling of the jcp-efficiency fix, in the `eval/1` receipt: t.uj_per_accepted_token = t.uj_total.checked_div(t.output_tokens).unwrap_or(0); `uj_per_accepted_token` is a cost-per-result figure, so 0 is its optimum. A run that burned prompt tokens and accepted no output has no such figure — the division is undefined — and reporting 0 ranked it as the cheapest entry in the ledger. Like the efficiency receipt, this one seals the figure into the signed core (`eval_wire`) and reads it straight back out in `verify()` rather than recomputing it, so the conflation was sealed and consumed as the headline. `mesh/SPEC.md` §6 states the family convention — the figure is "omitted when no tokens were accepted" — and `MeshReceipt` already implements it. This brings `eval/1` onto the same shape: - `Totals::uj_per_accepted_token` and `EvalReceipt::uj_per_accepted_token` become `Option<u64>`; `Default` is `None`. - `eval_wire` omits the key when the figure is undefined instead of sealing 0. Canonical CBOR sorts keys, so the conditional insert does not change the wire of a receipt that has one. - `verify()` reads it as optional, so an older receipt that carries the figure still round-trips. - `examples/ingest.rs` prints "—" rather than a number. `a_run_that_accepted_nothing_seals_no_wedge_metric` builds a trace with 800 prompt tokens and no accepted output: 8 000 µJ of real spend, no figure, the key absent from the signed core, and the envelope still verifying with the spend on it. Verified with `--features server` as well as the default build. The `server` module is behind a non-default feature, so `cargo test --workspace` never compiles it, and `server::tests::http_roundtrip_returns_sealed_eval_receipt` asserts on this exact wire field — it passes, but CI would not have told us: the jcp row's `feature_tests` in standards-build.yml names only `-p jcp-energy --features nvml`. Co-Authored-By: Claude Opus 5 <[email protected]>