efficiency/1: a partial energy figure is sealed as partial and never headlines as a task total #369

Merged
dcharlot merged 1 commit from fix/efficiency-keeps-coverage into main 2026-10-20 16:05:30 -04:00
Owner

What was open

An efficiency/1 receipt sealed energy_uj and provenance, and no coverage. A GPU-only reading, a hardware counter that sees the accelerator but not the CPU work driving it, reached a verifier as the whole unit's energy. The receipt also sealed a uj_per_accepted_token over that reading, which presented it as what the work cost per token.

jcp SPEC §5.2 already said a Partial figure MUST NOT be presented as a task total, and named the receipts that carry coverage. efficiency/1 was not among them.

aggregate() summed energy across receipts with no coverage and no provenance, so the per-unit figure it produced looked as clean as one built from whole figures. §5.3 says aggregation takes the floor of both, and that aggregating must never improve a grade.

What this changes

  • Coverage is sealed.

    • The receipt carries energy_coverage: "Partial" for a partial figure and omits it for a whole one.
    • Whole receipts, and every receipt sealed before this change, keep their bytes.
  • A partial receipt has no headline.

    • It seals no uj_per_accepted_token.
    • A partial figure divided by tokens is neither the per-token cost nor a bound on it, because a partial figure can fall short of the work or exceed it.
  • The reader refuses non-conformant receipts. read_payload is split out of verify so that its rules can be replayed without a signature. It refuses:

    • a partial receipt carrying the headline;
    • any energy_coverage value other than "Partial", including "Whole" (an absent field means Whole);
    • a provenance label that is not one of the three.
  • Totals take the floor.

    • Totals carries provenance_floor and coverage.
    • A total over any partial receipt is partial and gives no per-unit energy.
    • Its value-per-joule falls back to the worst value, 0.0.
  • SPEC §5.2 lists efficiency/1 with these rules.

  • Conformance pack. conformance/v1/efficiency.json, emitted by gen_efficiency_vectors, holds:

    • payloads that must read as recorded;
    • payloads that must be refused, and why;
    • sets of receipts with the totals they must sum to.

    tests/efficiency_pack.rs replays the pack from disk, as the energy-trace pack test does.

Who sees it

  • jouledesk builds only whole figures, so it is unaffected.
  • A consumer reading uj_per_accepted_token or uj_per_completed_unit now gets None for partial figures. The types are unchanged.

Verification (build host)

  • Tests. cargo test -p jcp-efficiency passes: 57 lib tests (3 new) and the 4 pack replays.

  • Mutations. All 9 mutations of the new rules are killed:

    • coverage not sealed;
    • a headline left on a partial figure;
    • "Whole" accepted;
    • a partial receipt with a headline accepted;
    • any provenance label accepted;
    • no coverage floor;
    • no provenance floor;
    • a per-unit figure for a partial total;
    • value-per-joule for a partial total.

    The pack replay alone also catches the headline, coverage-floor and provenance-floor mutations.

  • Wider checks. The full jcp-rs workspace, the jcp conformance suite and the jouledesk workspace pass. jcp-efficiency is clippy-clean.

  • Repo checks. tests-in-ci, spec-refs, orphan-sources, vanity-metrics and comparative-prose pass.

Not in this PR

Sweep item #3's other half, a declared uncertainty on jcp-schema energy figures (WAI's on-chip-counter versus calibrated-instrument split), is a schema change of its own.

🤖 Generated with Claude Code

## What was open An `efficiency/1` receipt sealed `energy_uj` and `provenance`, and no coverage. A GPU-only reading, a hardware counter that sees the accelerator but not the CPU work driving it, reached a verifier as the whole unit's energy. The receipt also sealed a `uj_per_accepted_token` over that reading, which presented it as what the work cost per token. jcp SPEC §5.2 already said a `Partial` figure MUST NOT be presented as a task total, and named the receipts that carry coverage. efficiency/1 was not among them. `aggregate()` summed energy across receipts with no coverage and no provenance, so the per-unit figure it produced looked as clean as one built from whole figures. §5.3 says aggregation takes the floor of both, and that aggregating must never improve a grade. ## What this changes - **Coverage is sealed.** - The receipt carries `energy_coverage: "Partial"` for a partial figure and omits it for a whole one. - Whole receipts, and every receipt sealed before this change, keep their bytes. - **A partial receipt has no headline.** - It seals no `uj_per_accepted_token`. - A partial figure divided by tokens is neither the per-token cost nor a bound on it, because a partial figure can fall short of the work or exceed it. - **The reader refuses non-conformant receipts.** `read_payload` is split out of `verify` so that its rules can be replayed without a signature. It refuses: - a partial receipt carrying the headline; - any `energy_coverage` value other than `"Partial"`, including `"Whole"` (an absent field means Whole); - a provenance label that is not one of the three. - **Totals take the floor.** - `Totals` carries `provenance_floor` and `coverage`. - A total over any partial receipt is partial and gives no per-unit energy. - Its value-per-joule falls back to the worst value, 0.0. - **SPEC §5.2** lists efficiency/1 with these rules. - **Conformance pack.** `conformance/v1/efficiency.json`, emitted by `gen_efficiency_vectors`, holds: - payloads that must read as recorded; - payloads that must be refused, and why; - sets of receipts with the totals they must sum to. `tests/efficiency_pack.rs` replays the pack from disk, as the energy-trace pack test does. ## Who sees it - jouledesk builds only whole figures, so it is unaffected. - A consumer reading `uj_per_accepted_token` or `uj_per_completed_unit` now gets `None` for partial figures. The types are unchanged. ## Verification (build host) - **Tests.** `cargo test -p jcp-efficiency` passes: 57 lib tests (3 new) and the 4 pack replays. - **Mutations.** All 9 mutations of the new rules are killed: - coverage not sealed; - a headline left on a partial figure; - `"Whole"` accepted; - a partial receipt with a headline accepted; - any provenance label accepted; - no coverage floor; - no provenance floor; - a per-unit figure for a partial total; - value-per-joule for a partial total. The pack replay alone also catches the headline, coverage-floor and provenance-floor mutations. - **Wider checks.** The full jcp-rs workspace, the jcp conformance suite and the jouledesk workspace pass. jcp-efficiency is clippy-clean. - **Repo checks.** tests-in-ci, spec-refs, orphan-sources, vanity-metrics and comparative-prose pass. ## Not in this PR Sweep item #3's other half, a declared uncertainty on `jcp-schema` energy figures (WAI's on-chip-counter versus calibrated-instrument split), is a schema change of its own. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
efficiency/1: a partial energy figure is sealed as partial and never headlines as a task total
All checks were successful
repository checks / lockfiles, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Successful in 55s
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 17s
standards workspaces build + test / mesh-rs (mesh/mesh-rs, -p mesh-engine-gguf -p mesh-openai --features mesh-engine-gguf/gguf,mesh-openai/server, mesh-rs, linux-arm64) (pull_request) Successful in 1m12s
standards workspaces build + test / jouleclaw-rs (-nodebug, jouleclaw/jouleclaw-rs, -p jouleclaw-energy --features rapl,nvml, jouleclaw-rs, linux-arm64, -C target-feature=+fp16) (pull_request) Successful in 3m18s
standards workspaces build + test / joule-code-rs (joule-code/joule-code-rs, joule-code-rs, linux-arm64, true) (pull_request) Successful in 4m14s
standards workspaces build + test / jcp-rs (jcp-conformance, jcp/jcp-rs, -p jcp-energy --features nvml, jcp-rs, linux) (pull_request) Successful in 1m37s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 7m41s
standards workspaces build + test / joulehook-rs (joulehook/joulehook-rs, joulehook-rs, linux) (pull_request) Successful in 1m10s
standards workspaces build + test / jouledesk-rs (jouledesk/jouledesk-rs, jouledesk-rs, macos) (pull_request) Successful in 2m50s
standards workspaces build + test / sandbox-rs (sandbox-conformance, sandbox/sandbox-rs, sandbox-rs, linux) (pull_request) Successful in 2m16s
standards workspaces build + test / joule-ui-rs (joule-ui/joule-ui-rs, joule-ui-rs, linux) (pull_request) Successful in 8m12s
9b57b96816
`Efficiency::wire()` sealed `energy_uj` and `provenance` and nothing about
coverage. So a GPU-only reading (a hardware counter that reads the
accelerator and not the CPU work that drove it) reached a verifier as the
whole unit's energy. The receipt also sealed a `uj_per_accepted_token` over
that reading, which presented it as what the work cost per token. jcp SPEC
§5.2 already said a `Partial` figure MUST NOT be presented as a task total,
and listed the receipts that carry coverage. efficiency/1 was not among them.

`aggregate()` then summed energy across receipts with no coverage and no
provenance, and its per-unit figure came out as clean as a whole one. §5.3
says aggregation takes the floor of both and is never a step at which a
grade improves.

Now:
- The receipt carries `energy_coverage: "Partial"` when the figure is
  partial, and omits it when the figure is whole. A whole receipt, and every
  receipt sealed before the field existed, keeps its bytes.
- A partial receipt seals no `uj_per_accepted_token`. A partial figure
  divided by tokens is not what the work cost per token, nor a bound on it,
  since a partial figure can fall short of the work or exceed it.
- `read_payload`, split out of `verify` so the payload rules can be replayed
  without a signature, refuses:
  - a partial receipt carrying the headline;
  - any `energy_coverage` but "Partial" ("Whole" included; absence is Whole);
  - a provenance label that is not one of the three.
- `Totals` carries `provenance_floor` and `coverage`. A total over any partial
  receipt is partial, gives no per-unit energy, and reports value per joule
  as its worst value (0.0).

SPEC §5.2 now lists efficiency/1 with these rules. A published pack,
`conformance/v1/efficiency.json` (from `gen_efficiency_vectors`), carries the
readings and refusals and the totals sets must sum to. `tests/efficiency_pack.rs`
replays it from disk.

Tests: 3 new unit tests and 4 pack replays. All 9 mutations of the new rules
are killed. The pack alone catches the headline, coverage-floor and
provenance-floor mutations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!369
No description provided.