agentmeasure 0.5.0__tar.gz

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 (92) hide show
  1. agentmeasure-0.5.0/PKG-INFO +389 -0
  2. agentmeasure-0.5.0/README.md +372 -0
  3. agentmeasure-0.5.0/agentmeasure.egg-info/PKG-INFO +389 -0
  4. agentmeasure-0.5.0/agentmeasure.egg-info/SOURCES.txt +90 -0
  5. agentmeasure-0.5.0/agentmeasure.egg-info/dependency_links.txt +1 -0
  6. agentmeasure-0.5.0/agentmeasure.egg-info/entry_points.txt +2 -0
  7. agentmeasure-0.5.0/agentmeasure.egg-info/top_level.txt +1 -0
  8. agentmeasure-0.5.0/am_healthcheck/__init__.py +17 -0
  9. agentmeasure-0.5.0/am_healthcheck/audit.py +148 -0
  10. agentmeasure-0.5.0/am_healthcheck/benchmark.py +156 -0
  11. agentmeasure-0.5.0/am_healthcheck/certify.py +140 -0
  12. agentmeasure-0.5.0/am_healthcheck/checks.py +953 -0
  13. agentmeasure-0.5.0/am_healthcheck/claude.py +286 -0
  14. agentmeasure-0.5.0/am_healthcheck/cli.py +2064 -0
  15. agentmeasure-0.5.0/am_healthcheck/codex.py +424 -0
  16. agentmeasure-0.5.0/am_healthcheck/commerce.py +439 -0
  17. agentmeasure-0.5.0/am_healthcheck/console.py +929 -0
  18. agentmeasure-0.5.0/am_healthcheck/crm.py +137 -0
  19. agentmeasure-0.5.0/am_healthcheck/crosscheck.py +208 -0
  20. agentmeasure-0.5.0/am_healthcheck/dashboard.py +394 -0
  21. agentmeasure-0.5.0/am_healthcheck/delivery.py +186 -0
  22. agentmeasure-0.5.0/am_healthcheck/demo/demo-codex.jsonl +26 -0
  23. agentmeasure-0.5.0/am_healthcheck/discover.py +186 -0
  24. agentmeasure-0.5.0/am_healthcheck/dispute.py +388 -0
  25. agentmeasure-0.5.0/am_healthcheck/export.py +500 -0
  26. agentmeasure-0.5.0/am_healthcheck/fixtures/claude-duplicates.jsonl +4 -0
  27. agentmeasure-0.5.0/am_healthcheck/fixtures/claude-empty.jsonl +0 -0
  28. agentmeasure-0.5.0/am_healthcheck/fixtures/claude-ok.jsonl +9 -0
  29. agentmeasure-0.5.0/am_healthcheck/fixtures/claude-retries.jsonl +10 -0
  30. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-cache.jsonl +11 -0
  31. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-corrupt.jsonl +10 -0
  32. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-duplicates.jsonl +9 -0
  33. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-empty.jsonl +0 -0
  34. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-ok.jsonl +13 -0
  35. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-resolution.jsonl +13 -0
  36. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-retries.jsonl +15 -0
  37. agentmeasure-0.5.0/am_healthcheck/fixtures/codex-stability.jsonl +10 -0
  38. agentmeasure-0.5.0/am_healthcheck/fixtures/vendor-export-intercom.csv +11 -0
  39. agentmeasure-0.5.0/am_healthcheck/history.py +182 -0
  40. agentmeasure-0.5.0/am_healthcheck/incrementality.py +149 -0
  41. agentmeasure-0.5.0/am_healthcheck/jsonl.py +53 -0
  42. agentmeasure-0.5.0/am_healthcheck/lab/schemas/funnel-event.schema.json +69 -0
  43. agentmeasure-0.5.0/am_healthcheck/ledger.py +247 -0
  44. agentmeasure-0.5.0/am_healthcheck/model.py +187 -0
  45. agentmeasure-0.5.0/am_healthcheck/narrative.py +130 -0
  46. agentmeasure-0.5.0/am_healthcheck/outcomes.py +231 -0
  47. agentmeasure-0.5.0/am_healthcheck/pack.py +350 -0
  48. agentmeasure-0.5.0/am_healthcheck/pack_invariants.json +52 -0
  49. agentmeasure-0.5.0/am_healthcheck/periods.py +118 -0
  50. agentmeasure-0.5.0/am_healthcheck/pnl.py +280 -0
  51. agentmeasure-0.5.0/am_healthcheck/policy.py +184 -0
  52. agentmeasure-0.5.0/am_healthcheck/prepare.py +190 -0
  53. agentmeasure-0.5.0/am_healthcheck/recovery.py +240 -0
  54. agentmeasure-0.5.0/am_healthcheck/report_html.py +282 -0
  55. agentmeasure-0.5.0/am_healthcheck/report_text.py +99 -0
  56. agentmeasure-0.5.0/am_healthcheck/rulesdiff.py +117 -0
  57. agentmeasure-0.5.0/am_healthcheck/schema.py +184 -0
  58. agentmeasure-0.5.0/am_healthcheck/sdk_events.py +89 -0
  59. agentmeasure-0.5.0/am_healthcheck/settle.py +854 -0
  60. agentmeasure-0.5.0/am_healthcheck/share.py +128 -0
  61. agentmeasure-0.5.0/am_healthcheck/snapshot.py +250 -0
  62. agentmeasure-0.5.0/am_healthcheck/taxonomy.py +170 -0
  63. agentmeasure-0.5.0/am_healthcheck/templates.py +128 -0
  64. agentmeasure-0.5.0/am_healthcheck/vendor-rules.json +209 -0
  65. agentmeasure-0.5.0/am_healthcheck/vendors.py +486 -0
  66. agentmeasure-0.5.0/pyproject.toml +43 -0
  67. agentmeasure-0.5.0/setup.cfg +4 -0
  68. agentmeasure-0.5.0/tests/test_checks.py +289 -0
  69. agentmeasure-0.5.0/tests/test_claude_adapter.py +120 -0
  70. agentmeasure-0.5.0/tests/test_cli.py +115 -0
  71. agentmeasure-0.5.0/tests/test_codex_adapter.py +103 -0
  72. agentmeasure-0.5.0/tests/test_commerce.py +357 -0
  73. agentmeasure-0.5.0/tests/test_commerce_v2.py +410 -0
  74. agentmeasure-0.5.0/tests/test_console.py +252 -0
  75. agentmeasure-0.5.0/tests/test_contract_lane.py +195 -0
  76. agentmeasure-0.5.0/tests/test_dispute.py +146 -0
  77. agentmeasure-0.5.0/tests/test_export.py +127 -0
  78. agentmeasure-0.5.0/tests/test_history.py +160 -0
  79. agentmeasure-0.5.0/tests/test_outcome_schema.py +123 -0
  80. agentmeasure-0.5.0/tests/test_parity.py +103 -0
  81. agentmeasure-0.5.0/tests/test_pipeline_edges.py +262 -0
  82. agentmeasure-0.5.0/tests/test_prepare.py +223 -0
  83. agentmeasure-0.5.0/tests/test_productwave.py +420 -0
  84. agentmeasure-0.5.0/tests/test_recovery.py +187 -0
  85. agentmeasure-0.5.0/tests/test_review_regressions.py +295 -0
  86. agentmeasure-0.5.0/tests/test_schema_and_example.py +226 -0
  87. agentmeasure-0.5.0/tests/test_sdk_events.py +107 -0
  88. agentmeasure-0.5.0/tests/test_settle.py +490 -0
  89. agentmeasure-0.5.0/tests/test_share.py +82 -0
  90. agentmeasure-0.5.0/tests/test_snapshot_and_filters.py +223 -0
  91. agentmeasure-0.5.0/tests/test_vendors.py +267 -0
  92. agentmeasure-0.5.0/tests/test_verify_pipeline.py +369 -0
@@ -0,0 +1,389 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmeasure
3
+ Version: 0.5.0
4
+ Summary: AgentMeasure — check-up report for coding agent runs + conformance pack for telemetry fixture verification. Zero external dependencies.
5
+ License: MIT
6
+ Keywords: agent,codex,claude,observability,measurement,healthcheck,conformance
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+
18
+ # AgentMeasure Healthcheck (pre-release)
19
+
20
+ **A local check-up report for your coding agent runs.**
21
+ Point it at the logs your agent runtime already writes. It answers three
22
+ questions with evidence — *which records are duplicated, where did the agent
23
+ pay retries for one logical operation, and where did the same tool fail over
24
+ and over* — and writes a terminal summary plus a local HTML report.
25
+
26
+ Same honesty rules as the [conformance pack](../conformance/pack/README.md):
27
+ every verdict is `OK / FINDING / UNPROVABLE`, and UNPROVABLE is a first-class
28
+ result — when the logs cannot decide, that is disclosed, never zeroed.
29
+
30
+ > Status: engineering preview (v0.3.0). Adapters: **Codex rollout logs** and
31
+ > **Claude Code session logs** (`--runtime claude`; auto-detected when Codex is
32
+ > absent). Claude v1 scope: duplicate / retry / error-run checks fully supported;
33
+ > session token accounting is honestly **UNPROVABLE** — Claude transcripts carry
34
+ > per-request usage only, no cumulative counter, and per-request sums are never
35
+ > presented as session totals.
36
+ > Distribution name decided: **`agentmeasure`** on PyPI (command of the same
37
+ > name). PyPI publish is armed and goes live with tag `v0.3.0` once the PyPI
38
+ > account/trusted publisher is configured — until then use the git install.
39
+
40
+ ## Install
41
+
42
+ > **Note (2026-09-21):** PyPI still serves **0.4.0**, which crashes on the
43
+ > first command (`NameError` in `_run_check`; `demo` / `check` / `compare`
44
+ > all affected). The fix is in 0.4.1 and already on main. Until the 0.4.1
45
+ > wheel lands on the index, install from git instead (option 3 below) —
46
+ > that path runs clean.
47
+
48
+ ```bash
49
+ # 1) from PyPI (live since v0.4.0 — see note above; 0.4.1 pending upload)
50
+ pipx run agentmeasure demo
51
+
52
+ # 2) install the command
53
+ pipx install agentmeasure
54
+
55
+ # 3) from git (tracks main)
56
+ pipx install "git+https://github.com/roy-tong/AgentMeasure#subdirectory=healthcheck"
57
+
58
+ # 4) zero install, straight from a repository checkout
59
+ python3 healthcheck/agentmeasure demo
60
+ ```
61
+
62
+ Python 3.9+ standard library only; zero runtime dependencies; no network code
63
+ (a test enforces both).
64
+
65
+ ## Quick start
66
+
67
+ ```bash
68
+ agentmeasure demo # synthetic session — see it work, no data needed
69
+ agentmeasure check # your agent logs, last 7 days (Codex or Claude Code)
70
+ agentmeasure check --all # every local session
71
+ agentmeasure check --runtime claude # force the Claude Code adapter
72
+ agentmeasure check --dir ~/.codex/sessions/2026/09/05
73
+ agentmeasure selftest # adapters + checks on bundled fixtures
74
+ agentmeasure validate export.json # check an export against its schema
75
+ agentmeasure share run.json # PREVIEW the sanitized summary (writes nothing)
76
+ agentmeasure share run.json --out summary.md # export after review
77
+ agentmeasure --version
78
+ ```
79
+
80
+ (Without installing, prefix the commands with `python3 healthcheck/agentmeasure`.)
81
+
82
+ Options for `check` / `demo`: `--html PATH` (default `agentmeasure-report.html`),
83
+ `--json PATH` (full machine-readable export), `--share PATH` (sanitized summary,
84
+ `.md` or `.json`), `--days N`, `--save-snapshot [PATH]`, `--no-history`.
85
+ `demo` accepts the same output paths and `--no-history`.
86
+
87
+ Input filters for `check` and `compare`:
88
+
89
+ ```bash
90
+ --since 2026-09-01 --until 2026-09-05 # date range (overrides --days)
91
+ --project myrepo # keep sessions whose project matches
92
+ # (project = cwd basename, case-insensitive)
93
+ ```
94
+
95
+ ## Outcome-billing verification: prepare → recount → dispute → recovery
96
+
97
+ The buyer-side bill check for per-resolution vendors (Intercom Fin, Zendesk AI
98
+ Agents, …). Rules live in the [vendor-rules registry](../registry/vendor-rules.json)
99
+ (single source of truth, each rule cited and confidence-graded). Four commands,
100
+ one pipeline:
101
+
102
+ ```bash
103
+ agentmeasure prepare --export native-export.csv --vendor zendesk --inspect
104
+ agentmeasure prepare --export native-export.csv --vendor zendesk --out prepared.csv
105
+ # native Intercom/Zendesk export -> canonical skeleton. Judgement columns
106
+ # stay EMPTY for human review; native signal columns travel as hint_*
107
+ # cells; prov_* cells record where every value came from. No verdicts.
108
+
109
+ agentmeasure recount --export prepared.csv --vendor zendesk --inspect
110
+ agentmeasure recount --export prepared.csv --vendor zendesk --json recount.json
111
+ agentmeasure recount --export prepared.csv --vendor zendesk --contract contract.json
112
+ # Tier 1: the vendor's own published rules, line by line. Findings in BOTH
113
+ # directions; absent evidence is UNPROVABLE, never guessed. --contract adds
114
+ # the buyer's outcome standard (e.g. reopen_window_hours: 72) as a separate
115
+ # outcome lane — renewal leverage, never netted into the claim.
116
+
117
+ agentmeasure dispute --export prepared.csv --vendor zendesk --contract contract.json
118
+ # the negotiable pack: cover letter citing the vendor's own rule per
119
+ # finding + appendix + (optionally) Tier 2 under the AMS-1 standard.
120
+
121
+ agentmeasure recovery --pack pack/dispute-pack.json --confirmations confirmations.csv
122
+ # what the vendor actually conceded: credited/paid per disputed line, with
123
+ # confirmation dates and evidence refs. Realized value is counted
124
+ # separately from the claim — an argument won is not cash.
125
+ ```
126
+
127
+ `agentmeasure recount --list-vendors` shows the registry with each rule's
128
+ source and confidence (P = primary/official, S = secondary, U = unverified).
129
+ The browser-local recount at [the website](../website/) runs the same Tier 1
130
+ with no upload; a cross-language parity test keeps the two from drifting.
131
+
132
+ ### The whole story in one artifact
133
+
134
+ ```bash
135
+ agentmeasure crosscheck --export prepared.csv --vendor zendesk --ledger billing.csv
136
+ # your billing ledger (计费流水) against the export: charges the export
137
+ # doesn't flag, billed flags the ledger doesn't confirm, amounts off the
138
+ # published price. Disagreements are named, never resolved.
139
+
140
+ agentmeasure verify --export prepared.csv --vendor zendesk --contract contract.json \
141
+ --ledger billing.csv --confirmations confirmations.csv --out vledger
142
+ # the Verified Ledger: Tier 1 + outcome lane + ledger cross-check +
143
+ # realized recovery in ONE document (json + md), each lane labelled
144
+ # claim / leverage / realized and never summed across.
145
+
146
+ agentmeasure dashboard --pack vledger/verified-ledger.json --out dashboard.html
147
+ # offline single-file HTML: cards, tables, recovery bar. No JS, no
148
+ # network, printable — renders, never recomputes.
149
+
150
+ agentmeasure rules-diff last-month-registry.json
151
+ # the monthly ritual: diff last period's rules snapshot against the
152
+ # packaged registry. Exit 1 = a material change (trigger, price, reopen
153
+ # rule) — re-verify the period under the new rule and disclose it.
154
+
155
+ agentmeasure narrative --pack pack/dispute-pack.json --audience vendor \
156
+ --emit-prompt prompt.txt
157
+ # step 1 of two: the drafting prompt, built from the pack. Run YOUR OWN
158
+ # model on it, then:
159
+ agentmeasure narrative --pack pack/dispute-pack.json --check-draft draft.txt --out letter.md
160
+ # step 2: every number in the draft is checked against the pack; any
161
+ # invented or rounded number refuses the draft and the rule-based
162
+ # template ships. The model never touches the numbers. No model? The
163
+ # template is the default.
164
+
165
+ agentmeasure delivery --log delivery.jsonl --log-event \
166
+ --engagement ACME --vendor zendesk --period-index 1 --phase mapping --minutes 45
167
+ agentmeasure delivery --log delivery.jsonl
168
+ # appendix-E metrics from logged phases: first look ≤10h, third period
169
+ # ≤1h, repeat-period reuse ≥70%. Use the mapping fingerprint `prepare`
170
+ # prints to track which engagements share the reusable mapping.
171
+ ```
172
+
173
+ Outcome pricing beyond per-resolution support (qualified lead, completed
174
+ case) is defined — schema first, per the BP — at
175
+ [schemas/outcome-unit.schema.json](../schemas/outcome-unit.schema.json) with
176
+ worked examples. The outcome **engine** now ships too:
177
+ `agentmeasure outcomes --units units.jsonl` verifies them fail-closed, and the
178
+ schema covers action and usage-aggregate units — one evidence plane across the
179
+ BP's three stages.
180
+
181
+ ```bash
182
+ agentmeasure crm-join --export prepared.csv --crm crm.csv --out joined.csv
183
+ agentmeasure outcomes --units outcome-units.jsonl --json outcome-ledger.json
184
+ agentmeasure period-compare last-month/verified-ledger.json vledger/verified-ledger.json
185
+ agentmeasure template --export --vendor intercom --fingerprint <fp> --contract contract.json
186
+ agentmeasure certify --pack vledger/verified-ledger.json --digest-out digest.txt
187
+ agentmeasure incrementality --events treatment-holdout.csv
188
+ ```
189
+
190
+ ### Agent commerce: the receipt where the click disappears
191
+
192
+ Traditional attribution starts at the click; agent commerce has none. The
193
+ merchant-side measurement receipt (F2.1-F2.9):
194
+
195
+ ```bash
196
+ agentmeasure commerce-ledger \
197
+ --events agent-events.jsonl --orders merchant-orders.csv \
198
+ --payments merchant-payments.csv --policy-version 1.0.0
199
+ # metric + value + evidence table; retries reconcile to 1 Operation /
200
+ # 2 Attempts / 1 verified order; net GMV is strong; incremental is
201
+ # UNPROVABLE (no holdout, no claim); materiality prints the discrepancy
202
+ # vs the naive dashboard in currency AND percent.
203
+ ```
204
+
205
+ live / replay / synthetic never mix inside one aggregation (error, not a
206
+ blend); metric names carry their strength prefix and are linted against the
207
+ evidence that backs them; every input is sha256-anchored. The operating layer on top:
208
+
209
+ ```bash
210
+ agentmeasure pnl-trees --orders orders.csv --campaigns campaigns.csv # Organic / Paid, ROAS in Paid only
211
+ agentmeasure cm-ledger --orders orders.csv --costs costs.csv --period 2026-09
212
+ agentmeasure demand-audit --measurements m.csv --thresholds t.json # Launch / Watch / Not ready
213
+ agentmeasure intent-taxonomy --file clusters.json # Operating Cell health
214
+ agentmeasure decision-audit --policy policy.json --executions log.jsonl
215
+ agentmeasure benchmark-export --rows brand-rows.csv --min-brands 5 # aggregates only, ever
216
+ ```
217
+
218
+ Schema:
219
+ [schemas/commerce-profile.schema.json](../schemas/commerce-profile.schema.json);
220
+ canonical retry vector pinned in CI at
221
+ `conformance/vectors/commerce-retry-baseline/`.
222
+
223
+ `certify` grades the artifact on the AMS-1 adoption ladder (Stage 0..3) and
224
+ emits the deterministic digest; hand the digest to your own signing tool —
225
+ this package never runs one. `incrementality` produces statistics about a
226
+ difference, never a verdict: the BP's line between rule judgement and causal
227
+ inference stays visible in the output itself.
228
+
229
+ ## Sharing results: preview first, export second
230
+
231
+ The recommended flow never writes a shareable file until you have read it:
232
+
233
+ ```bash
234
+ agentmeasure check --json run.json # the report export embeds the summary
235
+ agentmeasure share run.json # terminal PREVIEW — nothing is written
236
+ agentmeasure share run.json --out summary.md # export only after you reviewed it
237
+ ```
238
+
239
+ `share` re-checks the summary against its whitelist before showing or writing
240
+ anything, so a tampered or future-format export is refused rather than leaked.
241
+ `check --share PATH` remains available as the one-step explicit alternative.
242
+
243
+ ## Snapshots & compare — did the change help?
244
+
245
+ The re-run preview: save a snapshot, change something (a prompt, a Skill, a
246
+ dependency), run the agent again, compare.
247
+
248
+ ```bash
249
+ python3 healthcheck/agentmeasure check --save-snapshot before.json
250
+ # …make your change and run the agent…
251
+ python3 healthcheck/agentmeasure check --save-snapshot after.json
252
+ python3 healthcheck/agentmeasure compare before.json after.json
253
+ # or skip the second snapshot: compare runs a fresh check as side B
254
+ python3 healthcheck/agentmeasure compare --all before.json
255
+ ```
256
+
257
+ `compare` prints metric deltas (failed executions, retry chains, …), check
258
+ verdict transitions (`HC-02 OK → FINDING`), and honest caveats: token totals
259
+ are differenced only when **both** sides are provable, and version / window /
260
+ mode mismatches are disclosed because they change what a delta is allowed to
261
+ mean. Snapshots are local artifacts (they contain project names and session
262
+ short-ids); the snapshot schema is versioned and validated on load.
263
+
264
+ ## Versioned export schemas — how other tools integrate (R8)
265
+
266
+ Everything a third party needs is a JSON document with a version on it:
267
+
268
+ | document | written by | schema |
269
+ | --- | --- | --- |
270
+ | report export | `check --json PATH` / `demo --json PATH` | `report-v1` |
271
+ | snapshot | `--save-snapshot PATH` | `snapshot-v1` (schema field = 1) |
272
+ | comparison | `compare --json PATH` | `compare-v1` |
273
+
274
+ Reference schemas live in [`schemas/`](schemas/). Compatibility policy:
275
+ **within a schema version, fields are only added — never renamed, retyped, or
276
+ removed**; a consumer that meets an unknown newer version must stop and say so.
277
+ `agentmeasure validate FILE…` checks any export against its schema, and
278
+ [`examples/track-weekly.py`](examples/track-weekly.py) is a complete external
279
+ consumer: it reads snapshots through the schema only, imports nothing from the
280
+ package, and refuses future schema versions. MCP-style servers can wrap the
281
+ same exports later; the exports, not internal modules, are the integration
282
+ surface.
283
+
284
+ ## What it checks
285
+
286
+ | id | check | question it answers | verdict basis |
287
+ | --- | --- | --- | --- |
288
+ | HC-01 | Duplicate records | byte-identical lines, repeated call/execution ids, sessions split across files, and the format's **by-design dual recording** when model-side calls and command events are both present | exact line hashes, id counts |
289
+ | HC-02 | Retry amplification | same command failed then re-run: how many executions carried one logical operation | consecutive same-command blocks whose first attempt failed |
290
+ | HC-03 | Tool error runs | ≥3 back-to-back failures of the same tool with no success between | consecutive failed executions, same tool kind |
291
+
292
+ Plus a coverage overview: sessions, turns, executions by outcome, token
293
+ consumption (with subset discipline), compactions, sub-agent activity, corrupt
294
+ lines, and a **per-project breakdown** (project = cwd basename, canonical
295
+ deduplicated counts). Every finding carries evidence — file, line number, exit
296
+ codes — and a concrete next step.
297
+
298
+ ## Honest-number rules (the part most tools get wrong)
299
+
300
+ - **Executions are counted from exactly one stream.** Codex Desktop can write a
301
+ tool call as both a `response_item` record and an `item_completed` event.
302
+ Summing both — or grepping the file — double-counts when both are present.
303
+ HC-01 discloses the observed ratio instead of hiding it.
304
+ - **Token subsets are never added into totals.** `cached_input` ⊆ input,
305
+ `reasoning_output` ⊆ output in Codex logs. The report shows subsets
306
+ alongside, never inside, totals.
307
+ - **Token totals use the last cumulative snapshot per session**, not sums of
308
+ per-event deltas (which double-count after context compaction). The aggregate
309
+ is marked UNPROVABLE unless every logical session has one valid snapshot;
310
+ missing or malformed snapshots are reported separately.
311
+ - **Corrupt or truncated input lowers every count.** All numbers are lower bounds
312
+ where lines failed to parse or a file hit the safety cap; the limitation is
313
+ reported, never dropped.
314
+ - **UNPROVABLE, not zero.** Sessions whose format lacks outcome events make
315
+ HC-02/HC-03 UNPROVABLE for that part — reported as such.
316
+
317
+ ## Statistics definitions (for support and accounting)
318
+
319
+ | term | definition |
320
+ | --- | --- |
321
+ | execution | one `CommandExecution` / `McpToolCall` event; its outcome is `ok`, `failed`, or `unknown` |
322
+ | retry chain | a maximal block of consecutive executions of the same command whose first attempt failed; one chain = one logical operation executed N times |
323
+ | resolved chain | a chain whose last attempt succeeded |
324
+ | tool error run | ≥3 consecutive failed executions of the same tool kind with no success or unknown in between |
325
+ | token total | last cumulative `total_token_usage` snapshot per session, summed only when every session has a valid snapshot; otherwise UNPROVABLE |
326
+ | project | basename of the session's recorded working directory (`session_meta.cwd`); used for the breakdown, `--project` filtering, and snapshots — never included in the share summary |
327
+ | snapshot | versioned JSON record of one run's window, verdicts, and aggregate counters (schema 1); local artifact |
328
+ | comparison delta | `B − A` per metric; tokens are differenced only when provable on both sides, and version/window/mode mismatches are disclosed as caveats |
329
+ | demo run | executed on the bundled synthetic session; counted separately (`synthetic-demo`) |
330
+ | own-data run | executed on real local logs (`own-data`) |
331
+ | run number | local run history at `~/.agentmeasure/history.jsonl` distinguishes first vs repeated runs; delete the file to reset |
332
+
333
+ ## Privacy
334
+
335
+ - **No network.** The package contains no network code; a test enforces this by
336
+ scanning every module for network imports.
337
+ - **Raw data stays local.** Prompts, message text, and reasoning content are
338
+ never read into the model (only envelope types, ids, exit codes, durations,
339
+ and token counters).
340
+ - **Two artifacts, two levels.** The HTML report is personal (local paths and
341
+ evidence metadata — raw commands are represented by hashes, and the banner
342
+ says so). The `--share` summary
343
+ is built from a fixed whitelist of aggregate counts: no prompts, paths,
344
+ commands, repo names, or session ids can appear in it, and a planted-string
345
+ test enforces this.
346
+ - **Run history** (`~/.agentmeasure/history.jsonl`) stays on the machine and is
347
+ deletable.
348
+
349
+ ## Verified runtime support
350
+
351
+ | runtime | status | verified against |
352
+ | --- | --- | --- |
353
+ | Codex rollout JSONL (Desktop originator) | supported | cli 0.142.3 – 0.153.0; review snapshot 54 local files, 48 sessions, ~83k lines (2026-06-30 → 2026-09-05). Sessions without `CommandExecution` events (older format) run with HC-02/HC-03 UNPROVABLE, disclosed. |
354
+ | Codex CLI (`codex_cli_rs` originator) | expected compatible, **not yet verified** — no local samples | pending real samples |
355
+ | Claude Code (`~/.claude/projects`) | detected, **not yet supported** | adapter ships after validation against real samples |
356
+
357
+ New cli versions are handled defensively: unknown event types are accounted
358
+ (`unknown type` counts), never silently dropped.
359
+
360
+ ## Exit codes
361
+
362
+ | code | meaning |
363
+ | --- | --- |
364
+ | 0 | the check ran and produced a report (findings or not) |
365
+ | 1 | selftest fixture mismatch (development only) |
366
+ | 2 | input/output error: no readable logs in the window, bad `--dir`/arguments, or an output path cannot be written |
367
+
368
+ ## Development
369
+
370
+ ```bash
371
+ python3 -m unittest discover -s healthcheck/tests # 248 tests
372
+ python3 healthcheck/agentmeasure selftest # fixtures + redaction + compare + schemas
373
+ bash healthcheck/scripts/smoke_install.sh # clean-venv install smoke (packaged artifact)
374
+ ```
375
+
376
+ The install smoke is also a CI job (Python 3.9/3.11): it builds the package,
377
+ installs it into a fresh venv, and runs `selftest`, `demo`, `validate`, and the
378
+ external example from the installed artifact — the repository checkout is not
379
+ used.
380
+
381
+ Python 3.9+ standard library only. Zero dependencies, by policy: if any step
382
+ asks you to register, connect to a network, or pay — that is a bug.
383
+
384
+ ## Feedback
385
+
386
+ - [Open an issue](https://github.com/roy-tong/AgentMeasure/issues) — include
387
+ the `--json` export (it contains local paths; strip them first if the log
388
+ location is sensitive).
389
+ - [Email](mailto:tongroy18@gmail.com?subject=AgentMeasure%20Healthcheck%20feedback)