open-standards/jouleclaw/jouleclaw-rs/crates/jouleclaw-stack/examples/AGENTS.md
Transaction Science 899ca0b97c jouleclaw: cross-standard composition demo (JouleClaw → JCR-1 → OpenPay)
The open-standards quintet's commercial pitch made real. Before
this commit the README claimed JouleClaw + JCR-1 + OpenPay + WAI
+ ARL + Sandbox + Smart Byte + AAC compose into one stack, but
nothing in the workspace ran a multi-standard pipeline end-to-end.

The new example, openpay_per_joule_billing.rs, runs three
standards in one binary:

  1. JouleClaw cascade walk through JouleClawStack::with_defaults
     — counts every joule actually spent (one L3 + one L0-cache
     hit, ~2 J total).
  2. JCR-1 receipt minted over the session via the wave-7
     canonical det-CBOR + COSE_Sign1 path (335 B core / 456 B
     envelope, signed by the published test steward key).
  3. OpenPay settlement Transaction emitted in op-ledger v1's
     serde shape (status, ledger_id, entries[] with proper
     Money/Currency/Direction encoding, metadata pinning the
     JCR-1 receipt id) — consumable by any conforming OpenPay
     ledger via serde_json::from_value::<Transaction>.

Plus a binding document linking the receipt id to the Transaction
id by an explicit, verifiable invariant: receipt.joules_uj /
100_000 == settlement.amount_minor_units (1 ¢ per 100 mJ = $0.0001
per J pricing). An auditor verifies the JCR-1 signature, runs the
binding invariant, and the OpenPay Transaction is provably grounded
in measured energy.

Why no op-ledger import: OpenPay lives in a sibling Cargo
workspace; cross-workspace path deps don't carry workspace.package
inheritance, so direct cross-linking fails. The DEEPER reason for
NOT importing is that this proves the right kind of composition —
standards compose at the WIRE LAYER (serde_json), not at the
crate-graph layer. Standards in different language ecosystems
compose this way by construction.

Three artifacts written to /tmp/:
  openpay-per-joule-receipt.json    — JCR-1 signed receipt
  openpay-per-joule-entry.json      — OpenPay Transaction
  openpay-per-joule-binding.json    — receipt ↔ entry binding

Self-checks the invariant on exit; aborts if it doesn't hold.

WAI / ARL / Sandbox compositions are roadmap, not part of this
commit — same pattern (wire-layer serde_json), different
standards. Adding them is mechanical.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-06-04 03:58:20 -04:00

1.8 KiB
Raw Permalink Blame History

jouleclaw-stack — starter cascades

This directory exists because the five-lens wave-7/8 cross-talk audit (Phillip / Rafie / Bloom / Hyper-Agent / Priscilla) independently flagged the same on-ramp gap: a multi-crate workspace, one end-to-end example. Small runnable cascades give a new operator a working starting point per use case.

Each example is self-contained and runs with:

cargo run -p jouleclaw-stack --example <name>
Example What it shows Audit lens
minimal_cache_only The smallest cascade walk; L0 cache vs L3 echo. Phillip — text-is-state
rag_with_retrieval Retrieve → enrich → rerank → read over a seeded index. Bloom — verifiable zone
comprehend_demo Stack::comprehend — L0–L2 only, with intent tagging. Priscilla — understand before you generate
agent_with_skill_induction Register a skill, watch a query class resolve at L0.5. Phillip — agent-ready APIs
save_memory_and_promote Manual save_memory + auto-learned NotifyPromotedFact events. Hyper-Agent — three modes of memory
ledger_breakdown A workload, a ledger, a CostSummary rendered with intent shares. Rafie — breakdown at the top
full_cascade_with_triangle Cascade walk + triangle (elicitor → cone → conservation → oracle) + JCR-1 receipt — in one run. The consolidated end-to-end stake.
openpay_per_joule_billing Cross-standard composition: JouleClaw → JCR-1 → OpenPay. Pay-per-joule pitch made real, three artifacts emitted. Open-standards quartet — composing at the wire layer, not the crate-graph layer.

Doctrine in one line

"Inference is the last resort, not the entry point." — SPEC §1.1

Read the comprehend_demo example first if you want to feel why that sentence is the project's centre of gravity.