@agentguard-run/burn 0.3.27 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +48 -0
  3. package/dist/src/adapters/codex.d.ts +4 -2
  4. package/dist/src/adapters/codex.js +55 -9
  5. package/dist/src/cli.js +43 -5
  6. package/dist/src/history/claude-transcript.d.ts +0 -13
  7. package/dist/src/history/claude-transcript.js +11 -10
  8. package/dist/src/hook/pre-tool-use.d.ts +0 -16
  9. package/dist/src/hook/pre-tool-use.js +15 -10
  10. package/dist/src/index.d.ts +4 -1
  11. package/dist/src/index.js +18 -1
  12. package/dist/src/insights/commits.d.ts +84 -0
  13. package/dist/src/insights/commits.js +379 -0
  14. package/dist/src/insights/i18n.d.ts +12 -1
  15. package/dist/src/insights/i18n.js +78 -0
  16. package/dist/src/insights/launch-evidence.d.ts +25 -0
  17. package/dist/src/insights/launch-evidence.js +54 -0
  18. package/dist/src/insights/price-shadow.js +2 -1
  19. package/dist/src/insights/render.d.ts +36 -2
  20. package/dist/src/insights/render.js +43 -1
  21. package/dist/src/insights/tally.d.ts +45 -0
  22. package/dist/src/insights/tally.js +266 -0
  23. package/dist/src/insights/transcript.js +9 -1
  24. package/dist/src/insights/tree.d.ts +36 -0
  25. package/dist/src/insights/tree.js +285 -0
  26. package/dist/src/insights/types.d.ts +25 -0
  27. package/dist/src/insights/types.js +5 -1
  28. package/dist/src/receipt.d.ts +10 -0
  29. package/dist/src/receipt.js +53 -2
  30. package/dist/src/tool-names.d.ts +6 -0
  31. package/dist/src/tool-names.js +10 -0
  32. package/dist/src/upgrade-moments.js +2 -1
  33. package/docs/OCT5_VERIFICATION.md +118 -0
  34. package/docs/TREE_AND_TALLY.md +70 -0
  35. package/docs/launch-tree-local-oct5.txt +7 -0
  36. package/docs/oct5-followup/REPORT.md +105 -0
  37. package/docs/oct5-followup/checks.json +20 -0
  38. package/docs/oct5-followup/free-plugin-fixture-output.txt +12 -0
  39. package/docs/oct5-followup/tally-after.json +5 -0
  40. package/docs/oct5-followup/tally-after.txt +1 -0
  41. package/docs/oct5-followup/tree-after.json +40 -0
  42. package/docs/oct5-followup/tree-after.txt +7 -0
  43. package/docs/oct5-followup/tree-before.txt +7 -0
  44. package/docs/oct5-followup/verify-free-receipts.cjs +81 -0
  45. package/docs/session-tally-local-oct5.txt +1 -0
  46. package/package.json +7 -3
@@ -0,0 +1,70 @@
1
+ # Launch tree and approval tally
2
+
3
+ Both commands run locally. They do not upload transcripts, receipt rows or counts. Optional Team count sharing is a separate plugin setting, off by default.
4
+
5
+ ## Recorded launch tree
6
+
7
+ Run `agentguard-burn tree [session]`, optionally with `--json`. The selector accepts a local transcript path or a session ID and follows the same current-session selection as `why`. Claude Code child files and inline sidechain markers, matched Agent or Task call results, and Codex rollout metadata or matched spawn results supply the evidence. A directory alone never supplies an edge. Missing or conflicting parent links appear under `parent not recorded`. Anonymous inline sidechain records form a separate group without an invented agent identity.
8
+
9
+ Each node reports:
10
+
11
+ | Field | Meaning |
12
+ | --- | --- |
13
+ | Name and models | Host agent type or name and recorded model identifiers. Requested model aliases can appear beside the concrete model. Prompts and descriptions are not retained. |
14
+ | Own tokens | Input, output, cache read and cache write tokens attributed to this node. Copied provider response IDs count once. |
15
+ | Subtree tokens | Own tokens plus descendants connected by recorded edges. Orphans remain outside the main subtree. |
16
+ | Share | Own tokens divided by all observed session and descendant tokens, including orphan nodes. This is a share of tokens, not waste or savings. |
17
+ | Active time | Sum of gaps between this node's recorded timestamps, with each gap capped at Burn's existing five-minute idle threshold. A multi-day pause contributes at most five minutes. This is an activity estimate, not measured compute time. JSON calls this `durationMs`. |
18
+ | Span | First to last recorded timestamp, including idle gaps. JSON calls this `spanMs`; text shows it only when it differs from active time. |
19
+ | Ended without finishing | Burn's existing positive unfinished signal. False means that signal was not recorded; it does not prove successful completion. |
20
+
21
+ Missing child transcripts, malformed records and unknown fork-history ownership produce unknown token totals (`null` in JSON and `?` in text). Token shares remain unknown when the session total is incomplete. Unrecorded active time, span and model fields stay unknown. Unrelated Codex rollouts do not become children. Codex discovery inspects at most the first megabyte for each rollout's session metadata; an unreadable or oversized header cannot establish a new child relationship.
22
+
23
+ Text durations use human units, for example `active 24h 55m · span 14d 23h`. Short activity is `<1m`, never raw seconds. JSON keeps numeric milliseconds. Verified plugin receipts also supply explicit caller identity, type, depth and parent links, or a child link from a successful launch outcome.
24
+
25
+ The text view fits 80 columns and shows at most six siblings per parent, followed by `+ N more like this`. The short `why` section shows at most five nodes. JSON keeps all nodes and parent evidence. The tree prints no currency amounts.
26
+
27
+ ## Verified tally
28
+
29
+ Run `agentguard-burn tally [session]`, optionally with `--json`. An explicit session ID still works after its transcript is removed. A transcript path supplies only the session identity; its content never supplies tally counts.
30
+
31
+ The tally reads the plugin's physical `ledger/decisions.ndjson` and local `public-key.hex`. It uses Spend's Ed25519 verification, signature fingerprints, genesis hash, sequence numbers and hash links before selecting a session. If present, the worker's durable-head checkpoint must agree. No malformed row is skipped. Pending unsigned decisions, pending session summaries, recorded lost receipt data and durability errors prevent a complete tally. A valid signed session summary must end the session's records. A resumed session without a fresh final receipt stays unavailable.
32
+
33
+ The default directories are `PLUGIN_DATA`, `CLAUDE_PLUGIN_DATA`, or `AGENTGUARD_HOME/codex-plugin`, plus the plugin ledger registry under `AGENTGUARD_HOME/plugin-ledgers`. Without `AGENTGUARD_HOME`, the home is `~/.agentguard`. A session spread across multiple ledgers is unavailable rather than partially counted. Standalone Burn admission receipts do not record the full plugin approval lifecycle and cannot supply this tally.
34
+
35
+ Discovery skips and removes registry entries whose target folder no longer exists. It keeps entries for existing empty folders and leaves unreadable or malformed entries alone while continuing to other entries. It never removes a receipt folder or changes a ledger.
36
+
37
+ The Free plugin writes these signed rows without a license key, in enforce and shadow modes. A completed session needs its signed `session_receipt` before a tally is available. Installing only the standalone Burn hook writes a different receipt format in `receipts.ndjson`; installing the plugin later cannot reconstruct past approval outcomes. The October 5 [receipt investigation](oct5-followup/REPORT.md) records the writer paths, the real local installation, and the original resumed-session limitation, fixed by plugin 0.4.0 with fresh linked summaries. When a standalone Burn 0.4.0 hook owns admission, the plugin verifies its signed call ID, public key, session chain and persisted head before recording the governing verdict. Older standalone schemas stay unavailable; unsigned decision logs never supply approvals.
38
+
39
+ | Display word | Signed evidence |
40
+ | --- | --- |
41
+ | launches | Distinct Agent, Task or spawn_agent tool-call IDs with a governing Burn decision. Includes attempts that were stopped. Retries of the same call use the last governing decision. |
42
+ | allowed | Decision action `allow` or `downgrade`, without an ask. |
43
+ | asked | Claude Code decision metadata `asked: true` or `approvalRuleId`. Codex does not ask. |
44
+ | you approved | Receipt name `saidYes`: an ask followed by a signed outcome whose `originalDecisionId` links to that decision. It proves that the held tool ran, not that the task succeeded. |
45
+ | refused | Receipt name `stopped`: `block` or `fail_closed` without an ask. This is a policy refusal. |
46
+ | shadow | Action `shadow`, shown separately from allowed. |
47
+ | fail open | Signed event `fail_open`, stored as `unrecorded`. The admission verdict was unavailable. |
48
+ | approval outcome not recorded | `unresolvedAsked`: asked minus saidYes. No human refusal is inferred from a missing outcome. |
49
+
50
+ The arithmetic is `launches = allowed + asked + stopped + shadow + unrecorded` and `asked = saidYes + unresolvedAsked`. Do not add approvals to launches again. The existing receipt's `saidNo` cannot identify which launch a person refused, so this reader never guesses that number.
51
+
52
+ Example from a signed synthetic ledger:
53
+
54
+ ```text
55
+ 4 launches · 1 allowed · 2 asked · 1 you approved · 1 refused · 1 approval outcome not recorded
56
+ ```
57
+
58
+ Missing evidence prints `Signed session receipts are missing.` or another specific reason, without counts. A failed signature, sequence, hash chain or checkpoint prints `Receipt signature or hash chain verification failed.` and exits with status 1. JSON uses `verified`, `missing` or `verification_failed`; only `verified` includes `counts`.
59
+
60
+ Signatures attest integrity under the local key, not an external identity or a trusted execution environment. Replacing both a ledger and all its local key and checkpoint material is outside this check's trust boundary. Older ledgers without a durable checkpoint cannot prove that a complete signed suffix was never removed.
61
+
62
+ ## Last-session tip and Team counts
63
+
64
+ The plugin's detached tip task verifies the last session's tally, waits up to five seconds for SessionEnd's signed summary, and caches one bounded display line. The next new session shows it once alongside the existing coaching tip. Quiet mode hides it. A missing transcript does not prevent a tally when a local ledger exists. No transcript or ledger is read on the SessionStart path.
65
+
66
+ Installed-host checks on October 5, 2026: Claude Code 2.1.289 displayed a SessionStart `systemMessage` in its terminal. Codex 0.160.0's interactive terminal displayed it as `↳ Hook · ...` after the first prompt was submitted, before model execution. Codex `exec`, in both text and JSON modes, did not display the same message even though SessionStart completed. The CLI tally works independently of startup display. The probes stopped before any model turn.
67
+
68
+ The optional counts-sync module signs only a daily aggregate with the existing receipt key. A valid Team license, registered seat, local feature flag and explicit local opt-in are required. Daily tokens belong to the UTC date the signed session summary completed, including sessions crossing midnight. The site documentation at `/docs/team-counts/` lists every outgoing field. The plugin worker schedules it after durable receipt completion, outside the hook reply. Separate locally opted-in host directories for the same license share a machine lock and existing pinned receipt signer. Resumed days contribute only increments over earlier completed days; conflicting or already-sent revised counts require review.
69
+
70
+ Codex 0.160.0 under Node 22 also suppressed the numeric `systemMessage` emitted by a real SessionEnd canary in `exec`. Use `agentguard-burn tally SESSION_ID` after unattended execution. The signed Codex usage is marked estimated and can omit child threads that tree discovers separately.
@@ -0,0 +1,7 @@
1
+ Launch tree
2
+ Own / subtree tokens | share of session tokens | recorded duration
3
+ main session [321cfac5-66b] claude-fable-5-1, claude-opus-5-5
4
+ 661.8M / 668.1M | 99.0% | 1292819s
5
+ general-purpose [a20b05bb4d19] claude-opus-5-5
6
+ 6.4M / 6.4M | 1.0% | 631s
7
+ Session tokens: 668.1M. Shares use each node's own tokens.
@@ -0,0 +1,105 @@
1
+ # October 5 duration fix and receipt investigation
2
+
3
+ Work remains on `burn/launch-tree-tally-oct5`. The site branch `site/team-view-oct5` remains at `a3a168752f98d2fbe4292b65f649828fb9a7f73f` without new changes. No merge, push, publish, deployment, production configuration change or external message was performed. Future worktrees belong under `~/dev`. Existing committed worktrees were retained.
4
+
5
+ ## Active time
6
+
7
+ The tree now sums gaps between each node's recorded timestamps, capping each gap at `ACTIVE_GAP_CAP_MS`, the same five-minute cap used by Burn's session state. Timestamps for the same node are merged, deduplicated and sorted first. JSON `durationMs` now means active time; `spanMs` preserves the first-to-last elapsed span. Text labels both and omits the span when it equals active time.
8
+
9
+ Implementation: `src/insights/tree.ts:78`, `src/insights/launch-evidence.ts:24`. Existing threshold and calculation: `src/defaults.ts:74`, `src/state/session.ts:34`. Regression tests in `tests/launch-tree.test.ts:23` cover a three-day pause contributing five minutes, separate child activity and duplicate records read in either order.
10
+
11
+ The real Claude Code session is `321cfac5-66b0-4e36-ada5-01dcf3f0ba17`. Before, rerun before editing:
12
+
13
+ ```text
14
+ Launch tree
15
+ Own / subtree tokens | share of session tokens | recorded duration
16
+ main session [321cfac5-66b] claude-fable-5-1, claude-opus-5-5
17
+ 661.8M / 668.1M | 99.0% | 1292819s
18
+ general-purpose [a20b05bb4d19] claude-opus-5-5
19
+ 6.4M / 6.4M | 1.0% | 631s
20
+ Session tokens: 668.1M. Shares use each node's own tokens.
21
+ ```
22
+
23
+ After, with the same transcript and child transcript:
24
+
25
+ ```text
26
+ Launch tree
27
+ Own / subtree tokens | share of session tokens | active time
28
+ main session [321cfac5-66b] claude-fable-5-1, claude-opus-5-5
29
+ 661.8M / 668.1M | 99.0% | active 89728s | span 1292819s
30
+ general-purpose [a20b05bb4d19] claude-opus-5-5
31
+ 6.4M / 6.4M | 1.0% | active 631s
32
+ Session tokens: 668.1M. Shares use each node's own tokens.
33
+ ```
34
+
35
+ Exact JSON: main active 89,727,652 ms, span 1,292,818,503 ms; child active and span both 630,740 ms. Token totals and ancestry are unchanged. The text fits 80 columns. This is an estimate from activity records, not measured compute time.
36
+
37
+ Evidence files: [before](tree-before.txt), [after](tree-after.txt), [JSON](tree-after.json). Transcript SHA-256: `78805417d0d24b8474a708fc04ae14f9223710816301129cc1010b273529a2d3`; child transcript SHA-256: `6a37229d1747145dfbb52315489c37af43c49f01f83057c8a322cdb1ac960dc6`. No transcript content is copied into these files.
38
+
39
+ ## Where current main writes receipts
40
+
41
+ Source checked read-only first: fetched monorepo `origin/main`, `efa4bcf`, and public plugin main `62b84034b06831c7cdc52dee4a76d0889a9bd6b0`, version 0.3.18. A read-only remote ref lookup confirmed that public main still named this commit. The writer, license, common, registry and SessionEnd files are byte-identical between these mains and this worktree. The original monorepo checkout's local main is older and is not the authority here.
42
+
43
+ All following plugin paths start at `packages/agentguard-codex-plugin/`:
44
+
45
+ | Host | Receipt data directory |
46
+ | --- | --- |
47
+ | Claude Code | `CLAUDE_PLUGIN_DATA`, unless an explicit `PLUGIN_DATA` takes precedence. |
48
+ | Codex | `PLUGIN_DATA`. The legacy MCP adapter derives `~/.codex/plugins/data/agentguard-agentguard` for the standard marketplace cache layout when the host variable is absent. |
49
+ | Either host without a data variable | `~/.agentguard/codex-plugin`. This fallback uses the OS home, not `AGENTGUARD_HOME`. |
50
+
51
+ Path resolution: `runtime/common.cjs:7` and `:18`; legacy MCP derivation: `runtime/mcp-legacy.cjs:6` and `:22`. Hook data directories are provided by their host environment; the reader need not guess a Claude cache layout.
52
+
53
+ The worker writes **`<data>/ledger/decisions.ndjson`**. Its Ed25519 seed is `<data>/signing-key.hex`, and the verification key is `<data>/public-key.hex`. Creation and ledger recovery are at `runtime/engine.cjs:87`; signing every appended row is at `:228`. The signed end-of-session row has `plugin.event = session_receipt`, `plugin.receipt.version = 1`, written at `:246`. This is a row in the same chain, not a separate receipt file.
54
+
55
+ The Claude and Codex manifests both register SessionEnd at `hooks/hooks.json:46` and `hooks/codex-hooks.json:43`. The hook at `hooks/session-end.cjs:19` calls `runtime/work-receipt.cjs:199`. It waits for the running worker to sign the summary. If the worker is unavailable, an unsigned request is queued in `<data>/session-receipts-pending.ndjson` at `runtime/work-receipt.cjs:214`; `runtime/engine.cjs:261` signs it when the worker drains the queue. Pending requests are not verified receipts.
56
+
57
+ **Free is eligible.** No key resolves to local Free, enforcing by default, at `runtime/license.cjs:81` and `:107`. Signing and session summary writing have no paid-tier gate. Both enforce and shadow sessions get signed rows. They are not limited to sessions that attempted a launch: a valid SessionEnd can create a zero-launch summary, immediately with a running worker or later from the queue. A disabled hook, invalid session ID, process death or unwritable storage can prevent it. An active session without a signed ending does not yet have a complete tally.
58
+
59
+ ## Where tally reads, and why this real session has no number
60
+
61
+ `packages/agentguard-burn/src/insights/tally.ts:71` searches the active host data variable, or its default `AGENTGUARD_HOME/codex-plugin`, plus entries in `AGENTGUARD_HOME/plugin-ledgers`. Without an override, that home is `~/.agentguard`. The plugin registers its actual data directory at `runtime/engine.cjs:89` through `runtime/upgrade-moments.cjs:94`; this also covers a writer fallback outside a custom Burn home. `tally.ts:83` opens each physical ledger and public key, verifies signatures and chain, and checks the durable head before counting. `:24` requires a final signed session summary and links approvals to signed outcomes.
62
+
63
+ The lookup matches the current plugin writer. The isolated checks also run the CLI with both plugin data variables removed; discovery still succeeds through the writer's registry. No lookup change was needed for the investigated installation.
64
+
65
+ This machine's Claude installation is different from the default Free plugin install linked by pricing. `~/.claude/settings.json:101` configures only the standalone Burn PreToolUse hook for Agent and Task, with its command at `:107`. AgentGuard is absent from `~/.claude/plugins/installed_plugins.json` and the enabled-plugin map. The Codex user hook also calls standalone Burn. No real AgentGuard plugin installation was changed during this investigation.
66
+
67
+ The local fallback plugin ledger contains six old spend rows for synthetic session `s1`, and no session summaries or rows for the real session. No registered alternate directory contains an extant ledger. The real session has one unsigned admission-log row in `~/.agentguard/decisions.ndjson` and one independently signed Burn admission receipt in `~/.agentguard/receipts.ndjson`, selected by its hashed session ID. That receipt's signature and per-session chain verify. It says `OK`, `blocked: false`. Its schema is `agentguard.burn.decision.v1`.
68
+
69
+ Standalone writing is at `packages/agentguard-burn/src/hook/pre-tool-use.ts:241`; its signed schema is at `src/receipt.ts:22`. This schema has no signed tool-call ID, linked approval outcome or session-end summary. The matching tool-call ID in `decisions.ndjson` is unsigned. Reading that other file cannot establish the signed approval lifecycle or completeness required by this tally. No past decisions were manufactured or resigned.
70
+
71
+ Real CLI output remains:
72
+
73
+ ```text
74
+ Signed session receipts are missing.
75
+ ```
76
+
77
+ Evidence: [text](tally-after.txt), [JSON](tally-after.json).
78
+
79
+ **Yes:** a default Free plugin install on current main writes compatible receipts that this branch's tally can count after SessionEnd, without a license key. **No:** this real session from the standalone-only install cannot supply a complete numeric tally. The tally command itself is still an unreleased branch feature; published Burn 0.3.28 does not expose it.
80
+
81
+ The [reproducible synthetic probe](verify-free-receipts.cjs) uses the unchanged plugin Engine, default license resolution, signing, SessionEnd receipt helper and branch CLI. It creates isolated data below `~/dev`, makes no model calls or network requests, and removes its generated keys afterward. It covers both hosts, both modes, no-launch sessions, registry discovery and resumed sessions. [Actual probe output](free-plugin-fixture-output.txt) includes:
82
+
83
+ ```text
84
+ SYNTHETIC Free claude-code enforce: 1 launches · 1 allowed · 0 asked · 0 you approved · 0 refused
85
+ SYNTHETIC Free codex enforce: 1 launches · 1 allowed · 0 refused
86
+ ```
87
+
88
+ UNVERIFIED: a numeric tally from an actual Free plugin host session with a real sub-agent launch. The synthetic probe is not presented as such a session.
89
+
90
+ ## Handoff to the plugin owner
91
+
92
+ 1. Resumed sessions need a fresh signed closing summary after new decisions. `runtime/work-receipt.cjs:80` permanently marks a session receipted and `:82` ignores later rows. `runtime/engine.cjs:249` returns `duplicate` forever for that ID. Preserve cumulative launch decisions and outcomes across resumes, and append a new final summary after activity added since the previous summary. Repeated SessionEnd without new activity should stay idempotent. The probe reproduces the current missing-tally result on both hosts in both modes; the reader correctly refuses the stale summary.
93
+ 2. An existing standalone Claude hook needs an explicit integration path if those users should get the complete tally. `runtime/common.cjs:130` detects that hook; `runtime/engine.cjs:378` then writes only a `burn_external_hook` mirror and delegates admission. That mirror is not the governing verdict. Arrange one admission owner and signed, call-correlated verdicts and outcomes before the final summary. Any receipt ingestion must verify the external signature and chain; the current standalone schema lacks a signed tool-call ID and outcomes, so this requires coordinated writer changes or a deliberate migration to plugin-owned admission. Do not count the mirror as an allowed launch or backfill approvals from unsigned logs.
94
+
95
+ Neither plugin path was edited. A fresh plugin-only Free install needs no new admission change to write compatible receipts.
96
+
97
+ ## Checks
98
+
99
+ - Burn `npm test`: 579 tests, 578 passed, 1 skipped, 0 failed.
100
+ - Focused tree and tally tests: 19 passed, including the new multi-day resume test and existing tampered-receipt failure test.
101
+ - Unchanged plugin receipt and licensing suites: 32 passed, 0 failed.
102
+ - Synthetic probe: all four host/mode combinations passed, including registry discovery, zero-launch sessions and the reproduced resume limitation.
103
+ - Real tree and tally commands: text and JSON completed successfully; tree text stays within 80 columns.
104
+
105
+ Only the Burn package changed in this follow-up. The site and plugin were not edited. Proposed release versions from the prior report are unchanged; no version was published.
@@ -0,0 +1,20 @@
1
+ {
2
+ "burn": {
3
+ "tests": 579,
4
+ "pass": 578,
5
+ "fail": 0,
6
+ "skipped": 1
7
+ },
8
+ "plugin_receipts": {
9
+ "tests": 32,
10
+ "pass": 32,
11
+ "fail": 0,
12
+ "skipped": 0
13
+ },
14
+ "tree_max_columns": 61,
15
+ "real_tally": {
16
+ "status": "missing",
17
+ "session": "321cfac5-66b0-4e36-ada5-01dcf3f0ba17",
18
+ "reason": "Signed session receipts are missing."
19
+ }
20
+ }
@@ -0,0 +1,12 @@
1
+ SYNTHETIC Free claude-code enforce: 1 launches · 1 allowed · 0 asked · 0 you approved · 0 refused
2
+ SYNTHETIC no-tools claude-code enforce: 0 launches · 0 allowed · 0 asked · 0 you approved · 0 refused
3
+ SYNTHETIC resumed claude-code enforce: Signed receipts for the resumed session are incomplete.
4
+ SYNTHETIC Free claude-code shadow: 1 launches · 0 allowed · 0 asked · 0 you approved · 0 refused · 1 shadow
5
+ SYNTHETIC no-tools claude-code shadow: 0 launches · 0 allowed · 0 asked · 0 you approved · 0 refused
6
+ SYNTHETIC resumed claude-code shadow: Signed receipts for the resumed session are incomplete.
7
+ SYNTHETIC Free codex enforce: 1 launches · 1 allowed · 0 refused
8
+ SYNTHETIC no-tools codex enforce: 0 launches · 0 allowed · 0 refused
9
+ SYNTHETIC resumed codex enforce: Signed receipts for the resumed session are incomplete.
10
+ SYNTHETIC Free codex shadow: 1 launches · 0 allowed · 0 refused · 1 shadow
11
+ SYNTHETIC no-tools codex shadow: 0 launches · 0 allowed · 0 refused
12
+ SYNTHETIC resumed codex shadow: Signed receipts for the resumed session are incomplete.
@@ -0,0 +1,5 @@
1
+ {
2
+ "status": "missing",
3
+ "session": "321cfac5-66b0-4e36-ada5-01dcf3f0ba17",
4
+ "reason": "Signed session receipts are missing."
5
+ }
@@ -0,0 +1 @@
1
+ Signed session receipts are missing.
@@ -0,0 +1,40 @@
1
+ {
2
+ "session": "321cfac5-66b0-4e36-ada5-01dcf3f0ba17",
3
+ "totalTokens": 668141484,
4
+ "root": {
5
+ "id": "321cfac5-66b0-4e36-ada5-01dcf3f0ba17",
6
+ "parent": null,
7
+ "parentEvidence": null,
8
+ "name": "main session",
9
+ "models": [
10
+ "claude-fable-5-1",
11
+ "claude-opus-5-5"
12
+ ],
13
+ "ownTokens": 661764670,
14
+ "subtreeTokens": 668141484,
15
+ "tokenShare": 0.9904558927222666,
16
+ "durationMs": 89727652,
17
+ "spanMs": 1292818503,
18
+ "endedWithoutFinishing": false,
19
+ "children": [
20
+ {
21
+ "id": "a20b05bb4d1940a8d",
22
+ "parent": "321cfac5-66b0-4e36-ada5-01dcf3f0ba17",
23
+ "parentEvidence": "launch tool result",
24
+ "name": "general-purpose",
25
+ "models": [
26
+ "claude-opus-5-5"
27
+ ],
28
+ "ownTokens": 6376814,
29
+ "subtreeTokens": 6376814,
30
+ "tokenShare": 0.009544107277733409,
31
+ "durationMs": 630740,
32
+ "spanMs": 630740,
33
+ "endedWithoutFinishing": false,
34
+ "children": []
35
+ }
36
+ ]
37
+ },
38
+ "unlinked": [],
39
+ "notes": []
40
+ }
@@ -0,0 +1,7 @@
1
+ Launch tree
2
+ Own / subtree tokens | share of session tokens | active time
3
+ main session [321cfac5-66b] claude-fable-5-1, claude-opus-5-5
4
+ 661.8M / 668.1M | 99.0% | active 89728s | span 1292819s
5
+ general-purpose [a20b05bb4d19] claude-opus-5-5
6
+ 6.4M / 6.4M | 1.0% | active 631s
7
+ Session tokens: 668.1M. Shares use each node's own tokens.
@@ -0,0 +1,7 @@
1
+ Launch tree
2
+ Own / subtree tokens | share of session tokens | recorded duration
3
+ main session [321cfac5-66b] claude-fable-5-1, claude-opus-5-5
4
+ 661.8M / 668.1M | 99.0% | 1292819s
5
+ general-purpose [a20b05bb4d19] claude-opus-5-5
6
+ 6.4M / 6.4M | 1.0% | 631s
7
+ Session tokens: 668.1M. Shares use each node's own tokens.
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+ // Synthetic lifecycle checks against the unchanged plugin writer and this
3
+ // branch's tally reader. No host session, model call, license or upload.
4
+ const assert = require('node:assert/strict');
5
+ const fs = require('node:fs');
6
+ const os = require('node:os');
7
+ const path = require('node:path');
8
+ const {execFileSync} = require('node:child_process');
9
+ const burnRoot = path.resolve(__dirname, '../..');
10
+ const pluginRoot = path.resolve(burnRoot, '../agentguard-codex-plugin');
11
+ const {sessionTally, renderSessionTally} = require(path.join(burnRoot, 'dist/src/insights/tally.js'));
12
+ const {Engine} = require(path.join(pluginRoot, 'runtime/engine.cjs'));
13
+ const {metadata} = require(path.join(pluginRoot, 'runtime/common.cjs'));
14
+ const receipt = require(path.join(pluginRoot, 'runtime/work-receipt.cjs'));
15
+ const scratch = fs.mkdtempSync(path.join(os.homedir(), 'dev', 'agentguard-free-receipt-fixture-'));
16
+ const originalEnv = {...process.env};
17
+ const hostKeys = ['PLUGIN_ROOT', 'PLUGIN_DATA', 'CLAUDE_PLUGIN_ROOT', 'CLAUDE_PLUGIN_DATA', 'CLAUDE_SESSION_ID', 'CODEX_THREAD_ID', 'AGENTGUARD_SESSION_ID', 'AGENTGUARD_PLUGIN_POLICY'];
18
+
19
+ (async () => {
20
+ try {
21
+ for (const host of ['claude-code', 'codex']) for (const mode of ['enforce', 'shadow']) {
22
+ for (const key of hostKeys) delete process.env[key];
23
+ const base = path.join(scratch, host, mode), data = path.join(base, 'data');
24
+ const home = path.join(base, 'burn'), config = path.join(base, 'claude');
25
+ for (const directory of [data, home, config]) fs.mkdirSync(directory, {recursive: true});
26
+ Object.assign(process.env, {AGENTGUARD_HOME: home, CLAUDE_CONFIG_DIR: config, CLAUDE_PROJECT_DIR: base,
27
+ AGENTGUARD_LICENSE_KEY: '', AGENTGUARD_NOTIFY_SUPPRESS: '1'}, host === 'claude-code'
28
+ ? {CLAUDE_PLUGIN_DATA: data, CLAUDE_PLUGIN_ROOT: pluginRoot} : {PLUGIN_DATA: data, PLUGIN_ROOT: pluginRoot});
29
+ // Enforce uses the shipped defaults, with no local policy and no key.
30
+ if (mode === 'shadow') fs.writeFileSync(path.join(data, 'policy.json'), JSON.stringify({version: 1, mode}));
31
+ const session = 'synthetic-free-' + host + '-' + mode;
32
+ const transcript = path.join(base, session + '.jsonl');
33
+ fs.writeFileSync(transcript, JSON.stringify({type: 'assistant', timestamp: new Date().toISOString(),
34
+ message: {id: 'synthetic-usage', model: 'claude-opus-5-5', usage: {input_tokens: 10, output_tokens: 2}}}) + '\n');
35
+ const engine = new Engine();
36
+ try {
37
+ await engine.init();
38
+ const {license} = engine.context({sessionId: session});
39
+ assert.equal(license.paid, false); assert.equal(license.tier, 'free'); assert.equal(license.mode, mode);
40
+ const launch = async id => {
41
+ const raw = {session_id: session, tool_use_id: id, tool_name: host === 'claude-code' ? 'Agent' : 'spawn_agent',
42
+ tool_input: {}, cwd: base, transcript_path: transcript, permission_mode: 'default'};
43
+ const meta = {...metadata(raw, 'burn'), permissionMode: 'default'};
44
+ await engine.handle({meta, workingDirectory: base, transcriptPath: transcript});
45
+ await engine.handle({meta: metadata({...raw, hook_event_name: 'PostToolUse', tool_response: {status: 'completed'}}, 'receipt')});
46
+ };
47
+ await launch('synthetic-launch-one');
48
+ assert.equal((await sessionTally(session, {data})).status, 'missing');
49
+ const ended = await receipt.sessionEnd({sessionId: session, transcriptPath: transcript, data,
50
+ request: message => engine.sessionReceipt({sessionId: message.sessionId, transcriptPath: message.receipt?.transcriptPath})});
51
+ assert.equal(ended, 'appended');
52
+ await engine.flush();
53
+ const tally = await sessionTally(session, {data});
54
+ assert.equal(tally.status, 'verified'); assert.equal(tally.counts.launches, 1);
55
+ assert.equal(tally.counts[mode === 'enforce' ? 'allowed' : 'shadow'], 1);
56
+ // Shell discovery has no host plugin variables. Only the writer's
57
+ // registry points it at the real data directory in this fixture.
58
+ const env = {...process.env}; for (const key of hostKeys) delete env[key];
59
+ const output = execFileSync(process.execPath, [path.join(burnRoot, 'dist/src/cli.js'), 'tally', session], {env, encoding: 'utf8'}).trim();
60
+ assert.equal(output, renderSessionTally(tally));
61
+ console.log(`SYNTHETIC Free ${host} ${mode}: ${output}`);
62
+ const empty = session + '-no-tools';
63
+ await engine.sessionReceipt({sessionId: empty}); await engine.flush();
64
+ const zero = await sessionTally(empty, {data});
65
+ assert.equal(zero.status, 'verified'); assert.equal(zero.counts.launches, 0);
66
+ console.log(`SYNTHETIC no-tools ${host} ${mode}: ${renderSessionTally(zero)}`);
67
+ await launch('synthetic-launch-after-resume');
68
+ assert.equal((await engine.sessionReceipt({sessionId: session, transcriptPath: transcript})).receipt, 'duplicate');
69
+ await engine.flush();
70
+ const resumed = await sessionTally(session, {data});
71
+ assert.equal(resumed.status, 'missing');
72
+ assert.equal(resumed.reason, 'Signed receipts for the resumed session are incomplete.');
73
+ console.log(`SYNTHETIC resumed ${host} ${mode}: ${renderSessionTally(resumed)}`);
74
+ } finally { await engine.close(); }
75
+ }
76
+ } finally {
77
+ for (const key of Object.keys(process.env)) if (!(key in originalEnv)) delete process.env[key];
78
+ Object.assign(process.env, originalEnv);
79
+ fs.rmSync(scratch, {recursive: true, force: true});
80
+ }
81
+ })().catch(error => { console.error(error); process.exitCode = 1; });
@@ -0,0 +1 @@
1
+ Signed session receipts are missing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentguard-run/burn",
3
- "version": "0.3.27",
3
+ "version": "0.4.0",
4
4
  "description": "Local session usage and runaway-agent circuit breaker. Explain tokens, cache rewrites and API list cost, track pace, warn on heavy turns, and gate agent fan-out with signed receipts. Developer command ranking requires explicit --rank.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://agentguard.run/burn",
@@ -31,7 +31,11 @@
31
31
  "types": "./dist/src/adapters/codex.d.ts",
32
32
  "default": "./dist/src/adapters/codex.js"
33
33
  },
34
- "./package.json": "./package.json"
34
+ "./package.json": "./package.json",
35
+ "./tool-names": {
36
+ "types": "./dist/src/tool-names.d.ts",
37
+ "default": "./dist/src/tool-names.js"
38
+ }
35
39
  },
36
40
  "bin": {
37
41
  "agentguard-burn": "dist/src/cli.js"
@@ -58,7 +62,7 @@
58
62
  },
59
63
  "dependencies": {
60
64
  "@napi-rs/canvas": "^1.0.9",
61
- "@agentguard-run/spend": "0.20.0",
65
+ "@agentguard-run/spend": "0.21.0",
62
66
  "ajv": "8.17.1"
63
67
  },
64
68
  "devDependencies": {