open-standards/joulehook
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science 94597bc668
All checks were successful
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 29s
repository checks / lockfiles, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Successful in 3m3s
standards workspaces build + test / jcp-rs (jcp-conformance, jcp/jcp-rs, -p jcp-energy --features nvml, jcp-rs, linux) (pull_request) Successful in 2m46s
standards workspaces build + test / joule-ui-rs (joule-ui/joule-ui-rs, joule-ui-rs, linux) (pull_request) Successful in 1m17s
standards workspaces build + test / joulehook-rs (joulehook/joulehook-rs, joulehook-rs, linux) (pull_request) Successful in 1m35s
standards workspaces build + test / proof-rs (proof-conformance, proof/proof-rs, proof-rs, linux, true) (pull_request) Successful in 1m39s
standards workspaces build + test / sandbox-rs (sandbox-conformance, sandbox/sandbox-rs, sandbox-rs, linux) (pull_request) Successful in 2m51s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 9m1s
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 6m29s
standards workspaces build + test / joule-code-rs (joule-code/joule-code-rs, joule-code-rs, linux-arm64, true) (pull_request) Successful in 2m39s
standards workspaces build + test / joulecontract-rs (joulecontract/joulecontract-rs, joulecontract-rs, linux-arm64, true) (pull_request) Successful in 1m33s
standards workspaces build + test / jouledesk-rs (jouledesk/jouledesk-rs, jouledesk-rs, macos) (pull_request) Successful in 2m3s
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 1m26s
jcp-efficiency: carry the Option through its cross-workspace consumers
CI caught what the previous commit's verification could not: `jcp-efficiency`
is a **path dependency of three other workspaces**, and
`cargo test --workspace` inside `jcp/jcp-rs` never compiles them. The
jouledesk-rs, sandbox-rs and joulehook-rs legs all failed to build.

The consumers are:

    jouledesk/.../jouledesk/Cargo.toml
    jouledesk/.../jouledesk-livekit/Cargo.toml
    jouledesk/.../jouledesk-github/Cargo.toml
    sandbox/.../sandbox-tee/Cargo.toml
    joulehook/.../joulehook-meter/Cargo.toml

Five call sites read a figure that is now an `Option`:

- `jouledesk/src/lib.rs` — the assertion that waste inflates
  joules-per-completed-unit. Two units completed there, so the ratio is
  defined; `.expect` now records that rather than hiding it.
- `jouledesk/examples/channel.rs`, `examples/room.rs` and
  `sandbox-tee/examples/attested_efficiency.rs` — `println!` of the figure.
  Each prints "—" when undefined, for the same reason `session.rs` does:
  0 is the optimum of a cost-per-result figure, so printing it would name
  the cheapest possible cost for work that delivered none.
- `joulehook-meter` — `assert_eq!` on a receipt field; 900 tokens were
  accepted, so the figure is present and the assertion takes `Some`.

`Efficiency`'s own fields did not change, so the `Efficiency { .. }`
literals in all four consumers are untouched; only reads of
`EfficiencyReceipt::uj_per_accepted_token` and `Totals::uj_per_completed_unit`
needed work.

Verified by building and testing **each** of the four workspaces that
compile this crate — jcp-rs, jouledesk-rs, sandbox-rs, joulehook-rs — rather
than only the one holding the edit: `cargo check --workspace --all-targets`
and `cargo test --workspace` exit 0 in all four, with 0 failed suites.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-10-17 09:29:59 -04:00
..
conformance/v1 joulehook: refresh the published deny receipt to jcp/2, and hold it byte for byte 2026-09-30 14:16:01 -04:00
joulehook-rs jcp-efficiency: carry the Option through its cross-workspace consumers 2026-10-17 09:29:59 -04:00
LICENSE joulehook: new open standard v0.1.0-draft.1 — metered/gated/attested agent work in any host 2026-07-04 05:42:45 -04:00
LICENSE-SPEC joulehook: new open standard v0.1.0-draft.1 — metered/gated/attested agent work in any host 2026-07-04 05:42:45 -04:00
README.md joulehook: the deployable meter — joulehook-proxy (OpenAI-shaped base_url proxy) 2026-07-04 20:38:32 -04:00
SPEC.md joulehook: new open standard v0.1.0-draft.1 — metered/gated/attested agent work in any host 2026-07-04 05:42:45 -04:00

JouleHook — Metered, Gated, Attested Agent Work in Any Host

Provisional name — the steward may rename; the profile string joulehook/1 and the seam names are the stable surface.

The energy-accounting and methodology-gating you build for one coding agent is worth little if it's trapped in that one agent. JouleHook carries it into the editors developers already use — Claude Code, Cursor, Windsurf, Antigravity, Zed, JetBrains, OpenCode — without forking any of them.

It rests on one finding: no host lets an extension observe its agent's tokens or intercept its native tools — but every host exposes the same three seams, and JouleHook is the normative contract over them:

A per-action gate, a model-call meter, and a receipt surface. Bind those three to a decide-outside-the-model grant check, an honest energy meter, and a sealed receipt, and any agent's work becomes a metered, gated transaction — from one core.

JouleHook does not replace the host's agent. It is the host-binding layer for the sibling standards: JCP decides and grants, Mesh meters at the model front door, jcp-efficiency is the receipt. JouleHook adds the seam contract and the per-host conformance profiles that make them portable.

  • Licence: Apache-2.0 for reference code (LICENSE); CC-BY-4.0 for specification text (LICENSE-SPEC).
  • Status: v0.1.0 draft. Specification published (SPEC.md); reference workspace joulehook-rs/ ships the gate binding (joulehook-hook) for the claude-code and hooks-family profiles — one PreToolUse hook that gates by JCP capability (decided outside the model, every decision sealed) and speaks the native decision format of Claude Code, Cursor, Windsurf, and Antigravity behind a --host selector; joulehook-statusline, the in-editor joule meter (honest est from Claude Code's own tokens); and joulehook-mcp, an MCP server that surfaces the sealed decisions as verified, human-readable resources in any MCP-speaking editor. The claude-code full profile installs today (joulehook-rs/INSTALL.md); the enforcing Mesh-proxy meter + a site land next.

The three seams

Seam Host mechanisms What rides it
Gate PreToolUse-hook family; ACP request_permission allow / deny / rewrite, decided outside the model, sealed
Meter base_url proxy; OTel gen_ai.* tokens→joules, honest provenance, enforceable joule ceiling
Receipt MCP resources; status line; panel hash-chained, verifiable efficiency/1 + decision receipts

Conformance profiles

claude-code (reference) · hooks-family (Cursor / Windsurf / Antigravity) · acp (Zed / JetBrains / Neovim) · opencode · cline · vscode (Open-VSX) · meter-only (Continue, any OTel host). See SPEC.md §6.

The honest limit

A host-side adapter alone cannot meter the host agent's own tokens; a complete energy figure requires the Meter seam (proxy or OTel). An adapter that claims whole-session energy without a bound meter is non-conformant (SPEC.md §7).

What's here

joulehook/
├── SPEC.md          — the normative standard (§1–§9)
├── README.md        — this file
├── joulehook-rs/    — reference implementation
│   └── crates/
│       ├── joulehook-hook      — ✅ the PreToolUse gate CLI for the hook family
│       │                          (Claude Code / Cursor / Windsurf / Antigravity via --host;
│       │                          wraps jcp-bridge::LocalToolGate for the JCP check + seal)
│       │                          + joulehook-statusline — ✅ the in-editor joule meter
│       ├── joulehook-mcp       — ✅ the receipt-surface MCP server (sealed decisions →
│       │                          verified MCP resources, any MCP-speaking editor)
│       ├── joulehook-meter     — ✅ the meter-seam binding: inject a grant's budget as
│       │                          the Mesh joule ceiling (enforce) + bridge Mesh's
│       │                          usage.energy into an efficiency/1 receipt
│       └── joulehook-proxy     — ✅ the deployable meter: an OpenAI-shaped base_url
│                                  proxy that caps + seals every model call
└── conformance/v1/  — ✅ reproducible vectors: per-host decision encodings
                        (decisions.json) + a byte-deterministic sealed deny receipt
                        (deny-receipt.hex + receipt.json, verified-decode)

JouleHook is one of the Transaction Science open standards. Transaction Science is the steward, not the proprietor.