agentmeasure 0.4.0__py3-none-any.whl

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 (36) hide show
  1. agentmeasure-0.4.0.dist-info/METADATA +247 -0
  2. agentmeasure-0.4.0.dist-info/RECORD +36 -0
  3. agentmeasure-0.4.0.dist-info/WHEEL +5 -0
  4. agentmeasure-0.4.0.dist-info/entry_points.txt +2 -0
  5. agentmeasure-0.4.0.dist-info/top_level.txt +1 -0
  6. am_healthcheck/__init__.py +17 -0
  7. am_healthcheck/checks.py +953 -0
  8. am_healthcheck/claude.py +286 -0
  9. am_healthcheck/cli.py +851 -0
  10. am_healthcheck/codex.py +424 -0
  11. am_healthcheck/demo/demo-codex.jsonl +26 -0
  12. am_healthcheck/discover.py +186 -0
  13. am_healthcheck/fixtures/claude-duplicates.jsonl +4 -0
  14. am_healthcheck/fixtures/claude-empty.jsonl +0 -0
  15. am_healthcheck/fixtures/claude-ok.jsonl +9 -0
  16. am_healthcheck/fixtures/claude-retries.jsonl +10 -0
  17. am_healthcheck/fixtures/codex-cache.jsonl +11 -0
  18. am_healthcheck/fixtures/codex-corrupt.jsonl +10 -0
  19. am_healthcheck/fixtures/codex-duplicates.jsonl +9 -0
  20. am_healthcheck/fixtures/codex-empty.jsonl +0 -0
  21. am_healthcheck/fixtures/codex-ok.jsonl +13 -0
  22. am_healthcheck/fixtures/codex-resolution.jsonl +13 -0
  23. am_healthcheck/fixtures/codex-retries.jsonl +15 -0
  24. am_healthcheck/fixtures/codex-stability.jsonl +10 -0
  25. am_healthcheck/history.py +55 -0
  26. am_healthcheck/jsonl.py +53 -0
  27. am_healthcheck/lab/schemas/funnel-event.schema.json +69 -0
  28. am_healthcheck/model.py +187 -0
  29. am_healthcheck/pack.py +350 -0
  30. am_healthcheck/pack_invariants.json +52 -0
  31. am_healthcheck/report_html.py +282 -0
  32. am_healthcheck/report_text.py +99 -0
  33. am_healthcheck/schema.py +184 -0
  34. am_healthcheck/sdk_events.py +85 -0
  35. am_healthcheck/share.py +128 -0
  36. am_healthcheck/snapshot.py +250 -0
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentmeasure
3
+ Version: 0.4.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
+ ```bash
43
+ # 1) once v0.3.0 is published (planned this week)
44
+ pipx install agentmeasure
45
+
46
+ # 2) today, from git (no account, no PyPI needed)
47
+ pipx install "git+https://github.com/roy-tong/AgentMeasure#subdirectory=healthcheck"
48
+ # without pipx: python3 -m pip install --user "git+https://github.com/roy-tong/AgentMeasure#subdirectory=healthcheck"
49
+
50
+ # 3) zero install, straight from a repository checkout
51
+ python3 healthcheck/agentmeasure demo
52
+ ```
53
+
54
+ Python 3.9+ standard library only; zero runtime dependencies; no network code
55
+ (a test enforces both).
56
+
57
+ ## Quick start
58
+
59
+ ```bash
60
+ agentmeasure demo # synthetic session — see it work, no data needed
61
+ agentmeasure check # your agent logs, last 7 days (Codex or Claude Code)
62
+ agentmeasure check --all # every local session
63
+ agentmeasure check --runtime claude # force the Claude Code adapter
64
+ agentmeasure check --dir ~/.codex/sessions/2026/09/05
65
+ agentmeasure selftest # adapters + checks on bundled fixtures
66
+ agentmeasure validate export.json # check an export against its schema
67
+ agentmeasure share run.json # PREVIEW the sanitized summary (writes nothing)
68
+ agentmeasure share run.json --out summary.md # export after review
69
+ agentmeasure --version
70
+ ```
71
+
72
+ (Without installing, prefix the commands with `python3 healthcheck/agentmeasure`.)
73
+
74
+ Options for `check` / `demo`: `--html PATH` (default `agentmeasure-report.html`),
75
+ `--json PATH` (full machine-readable export), `--share PATH` (sanitized summary,
76
+ `.md` or `.json`), `--days N`, `--save-snapshot [PATH]`, `--no-history`.
77
+ `demo` accepts the same output paths and `--no-history`.
78
+
79
+ Input filters for `check` and `compare`:
80
+
81
+ ```bash
82
+ --since 2026-09-01 --until 2026-09-05 # date range (overrides --days)
83
+ --project myrepo # keep sessions whose project matches
84
+ # (project = cwd basename, case-insensitive)
85
+ ```
86
+
87
+ ## Sharing results: preview first, export second
88
+
89
+ The recommended flow never writes a shareable file until you have read it:
90
+
91
+ ```bash
92
+ agentmeasure check --json run.json # the report export embeds the summary
93
+ agentmeasure share run.json # terminal PREVIEW — nothing is written
94
+ agentmeasure share run.json --out summary.md # export only after you reviewed it
95
+ ```
96
+
97
+ `share` re-checks the summary against its whitelist before showing or writing
98
+ anything, so a tampered or future-format export is refused rather than leaked.
99
+ `check --share PATH` remains available as the one-step explicit alternative.
100
+
101
+ ## Snapshots & compare — did the change help?
102
+
103
+ The re-run preview: save a snapshot, change something (a prompt, a Skill, a
104
+ dependency), run the agent again, compare.
105
+
106
+ ```bash
107
+ python3 healthcheck/agentmeasure check --save-snapshot before.json
108
+ # …make your change and run the agent…
109
+ python3 healthcheck/agentmeasure check --save-snapshot after.json
110
+ python3 healthcheck/agentmeasure compare before.json after.json
111
+ # or skip the second snapshot: compare runs a fresh check as side B
112
+ python3 healthcheck/agentmeasure compare --all before.json
113
+ ```
114
+
115
+ `compare` prints metric deltas (failed executions, retry chains, …), check
116
+ verdict transitions (`HC-02 OK → FINDING`), and honest caveats: token totals
117
+ are differenced only when **both** sides are provable, and version / window /
118
+ mode mismatches are disclosed because they change what a delta is allowed to
119
+ mean. Snapshots are local artifacts (they contain project names and session
120
+ short-ids); the snapshot schema is versioned and validated on load.
121
+
122
+ ## Versioned export schemas — how other tools integrate (R8)
123
+
124
+ Everything a third party needs is a JSON document with a version on it:
125
+
126
+ | document | written by | schema |
127
+ | --- | --- | --- |
128
+ | report export | `check --json PATH` / `demo --json PATH` | `report-v1` |
129
+ | snapshot | `--save-snapshot PATH` | `snapshot-v1` (schema field = 1) |
130
+ | comparison | `compare --json PATH` | `compare-v1` |
131
+
132
+ Reference schemas live in [`schemas/`](schemas/). Compatibility policy:
133
+ **within a schema version, fields are only added — never renamed, retyped, or
134
+ removed**; a consumer that meets an unknown newer version must stop and say so.
135
+ `agentmeasure validate FILE…` checks any export against its schema, and
136
+ [`examples/track-weekly.py`](examples/track-weekly.py) is a complete external
137
+ consumer: it reads snapshots through the schema only, imports nothing from the
138
+ package, and refuses future schema versions. MCP-style servers can wrap the
139
+ same exports later; the exports, not internal modules, are the integration
140
+ surface.
141
+
142
+ ## What it checks
143
+
144
+ | id | check | question it answers | verdict basis |
145
+ | --- | --- | --- | --- |
146
+ | 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 |
147
+ | 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 |
148
+ | HC-03 | Tool error runs | ≥3 back-to-back failures of the same tool with no success between | consecutive failed executions, same tool kind |
149
+
150
+ Plus a coverage overview: sessions, turns, executions by outcome, token
151
+ consumption (with subset discipline), compactions, sub-agent activity, corrupt
152
+ lines, and a **per-project breakdown** (project = cwd basename, canonical
153
+ deduplicated counts). Every finding carries evidence — file, line number, exit
154
+ codes — and a concrete next step.
155
+
156
+ ## Honest-number rules (the part most tools get wrong)
157
+
158
+ - **Executions are counted from exactly one stream.** Codex Desktop can write a
159
+ tool call as both a `response_item` record and an `item_completed` event.
160
+ Summing both — or grepping the file — double-counts when both are present.
161
+ HC-01 discloses the observed ratio instead of hiding it.
162
+ - **Token subsets are never added into totals.** `cached_input` ⊆ input,
163
+ `reasoning_output` ⊆ output in Codex logs. The report shows subsets
164
+ alongside, never inside, totals.
165
+ - **Token totals use the last cumulative snapshot per session**, not sums of
166
+ per-event deltas (which double-count after context compaction). The aggregate
167
+ is marked UNPROVABLE unless every logical session has one valid snapshot;
168
+ missing or malformed snapshots are reported separately.
169
+ - **Corrupt or truncated input lowers every count.** All numbers are lower bounds
170
+ where lines failed to parse or a file hit the safety cap; the limitation is
171
+ reported, never dropped.
172
+ - **UNPROVABLE, not zero.** Sessions whose format lacks outcome events make
173
+ HC-02/HC-03 UNPROVABLE for that part — reported as such.
174
+
175
+ ## Statistics definitions (for support and accounting)
176
+
177
+ | term | definition |
178
+ | --- | --- |
179
+ | execution | one `CommandExecution` / `McpToolCall` event; its outcome is `ok`, `failed`, or `unknown` |
180
+ | retry chain | a maximal block of consecutive executions of the same command whose first attempt failed; one chain = one logical operation executed N times |
181
+ | resolved chain | a chain whose last attempt succeeded |
182
+ | tool error run | ≥3 consecutive failed executions of the same tool kind with no success or unknown in between |
183
+ | token total | last cumulative `total_token_usage` snapshot per session, summed only when every session has a valid snapshot; otherwise UNPROVABLE |
184
+ | 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 |
185
+ | snapshot | versioned JSON record of one run's window, verdicts, and aggregate counters (schema 1); local artifact |
186
+ | comparison delta | `B − A` per metric; tokens are differenced only when provable on both sides, and version/window/mode mismatches are disclosed as caveats |
187
+ | demo run | executed on the bundled synthetic session; counted separately (`synthetic-demo`) |
188
+ | own-data run | executed on real local logs (`own-data`) |
189
+ | run number | local run history at `~/.agentmeasure/history.jsonl` distinguishes first vs repeated runs; delete the file to reset |
190
+
191
+ ## Privacy
192
+
193
+ - **No network.** The package contains no network code; a test enforces this by
194
+ scanning every module for network imports.
195
+ - **Raw data stays local.** Prompts, message text, and reasoning content are
196
+ never read into the model (only envelope types, ids, exit codes, durations,
197
+ and token counters).
198
+ - **Two artifacts, two levels.** The HTML report is personal (local paths and
199
+ evidence metadata — raw commands are represented by hashes, and the banner
200
+ says so). The `--share` summary
201
+ is built from a fixed whitelist of aggregate counts: no prompts, paths,
202
+ commands, repo names, or session ids can appear in it, and a planted-string
203
+ test enforces this.
204
+ - **Run history** (`~/.agentmeasure/history.jsonl`) stays on the machine and is
205
+ deletable.
206
+
207
+ ## Verified runtime support
208
+
209
+ | runtime | status | verified against |
210
+ | --- | --- | --- |
211
+ | 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. |
212
+ | Codex CLI (`codex_cli_rs` originator) | expected compatible, **not yet verified** — no local samples | pending real samples |
213
+ | Claude Code (`~/.claude/projects`) | detected, **not yet supported** | adapter ships after validation against real samples |
214
+
215
+ New cli versions are handled defensively: unknown event types are accounted
216
+ (`unknown type` counts), never silently dropped.
217
+
218
+ ## Exit codes
219
+
220
+ | code | meaning |
221
+ | --- | --- |
222
+ | 0 | the check ran and produced a report (findings or not) |
223
+ | 1 | selftest fixture mismatch (development only) |
224
+ | 2 | input/output error: no readable logs in the window, bad `--dir`/arguments, or an output path cannot be written |
225
+
226
+ ## Development
227
+
228
+ ```bash
229
+ python3 -m unittest discover -s healthcheck/tests # 109 tests
230
+ python3 healthcheck/agentmeasure selftest # fixtures + redaction + compare + schemas
231
+ bash healthcheck/scripts/smoke_install.sh # clean-venv install smoke (packaged artifact)
232
+ ```
233
+
234
+ The install smoke is also a CI job (Python 3.9/3.11): it builds the package,
235
+ installs it into a fresh venv, and runs `selftest`, `demo`, `validate`, and the
236
+ external example from the installed artifact — the repository checkout is not
237
+ used.
238
+
239
+ Python 3.9+ standard library only. Zero dependencies, by policy: if any step
240
+ asks you to register, connect to a network, or pay — that is a bug.
241
+
242
+ ## Feedback
243
+
244
+ - [Open an issue](https://github.com/roy-tong/AgentMeasure/issues) — include
245
+ the `--json` export (it contains local paths; strip them first if the log
246
+ location is sensitive).
247
+ - [Email](mailto:tongroy18@gmail.com?subject=AgentMeasure%20Healthcheck%20feedback)
@@ -0,0 +1,36 @@
1
+ am_healthcheck/__init__.py,sha256=OYgj8GQdRmxO3ivrUKoB24DZZwimgzh6k0yOoX6k9Sk,689
2
+ am_healthcheck/checks.py,sha256=zPjWTYBUuAjzF2yhgjcYLiLPsHdEWDd6De1w7MZYOQQ,44441
3
+ am_healthcheck/claude.py,sha256=rXJDJeOLjSX9Uhng3u3v_kcxtesF-Tbhx5ClULAT13w,12400
4
+ am_healthcheck/cli.py,sha256=Yx5VxSGaPN37Kv7_1ZlxYweVdnObBRZqafpHoNr7yGs,38585
5
+ am_healthcheck/codex.py,sha256=C-oDH7d9Vhcvzx-uGE30yuvEVtPTFOkPrPqnhi1MPys,19188
6
+ am_healthcheck/discover.py,sha256=cal3eSBRl8UUdiFd9x9XMoAnzZM7zhJWoYF10OhJc8o,6831
7
+ am_healthcheck/history.py,sha256=TOA-0iyBEi9801CkqxcozWstDXZabPf1BGzNux1gSnY,1830
8
+ am_healthcheck/jsonl.py,sha256=kvgzv_-5JOBJjsqrSfnB1JlWJJ4QPLZNU32JYbUmCmI,2002
9
+ am_healthcheck/model.py,sha256=19zdeWR2uYXF5aGAyPYOkBXTd3VnxX03vCP-JAR7OSI,5451
10
+ am_healthcheck/pack.py,sha256=nF0YkDpMq_IUPTHlfOeErFOrNYBO8VXSwuUdpLZ12uA,15585
11
+ am_healthcheck/pack_invariants.json,sha256=zAKbimURSE_NZ7oKlCM_pPYOzBCyjH0_G7dtn9_mlog,2387
12
+ am_healthcheck/report_html.py,sha256=yMF_MkW0OZJE5erEsWqTNsWriGEjxBg0n_ZeXLErcS0,14163
13
+ am_healthcheck/report_text.py,sha256=ewg3T6fmjee4Udg4TKLHtdFbZfTgvXE9h1aOQFe-QRo,4219
14
+ am_healthcheck/schema.py,sha256=74XqIiql7Ann3r2MVxIRsVSOfYIRjcFA3fk5Rxn3QmU,7559
15
+ am_healthcheck/sdk_events.py,sha256=a3OltZPDJWJ1UePF5QFlWwBK7MYauarKgOqsNYa7bHo,2994
16
+ am_healthcheck/share.py,sha256=Mv7inOB3FNJi8xuYVw9f3BxubjldLpy7cNj7uIEW6js,5050
17
+ am_healthcheck/snapshot.py,sha256=eBSx3JQH-0smDhU9Ll0lZH39yg4QYXNFtIrBdmCVmp8,10696
18
+ am_healthcheck/demo/demo-codex.jsonl,sha256=NEGPq3w0GdYNSzKvqnVPHcDmACsl9997aVuhYNwvr4o,5256
19
+ am_healthcheck/fixtures/claude-duplicates.jsonl,sha256=pqJJ3xEzDMzZTkBCnX3jR1pBPqUUb89WBEMDH6XLXsE,1261
20
+ am_healthcheck/fixtures/claude-empty.jsonl,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ am_healthcheck/fixtures/claude-ok.jsonl,sha256=aS_3dLEZNoxSZdC2kpisOMca5bwnflgdtM9V3VWXA7Y,2827
22
+ am_healthcheck/fixtures/claude-retries.jsonl,sha256=mWv6s4TLkJoWAzOFB4I4z8xKUCkJdMdMEis3rxHEeK4,3479
23
+ am_healthcheck/fixtures/codex-cache.jsonl,sha256=Jb8GIftm2zmb-a8nfRPxZwM-YNIZLoafk1nxav-ijbk,2369
24
+ am_healthcheck/fixtures/codex-corrupt.jsonl,sha256=QB7ja5rb1_yaVtOib1wOMDIri_UBjF-7NIc7sXUFBHQ,1209
25
+ am_healthcheck/fixtures/codex-duplicates.jsonl,sha256=PBVcDMqsjo1KCCQK5UnmKSzPozrhu8FZhYh3IcCLWLk,1638
26
+ am_healthcheck/fixtures/codex-empty.jsonl,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ am_healthcheck/fixtures/codex-ok.jsonl,sha256=j8mDsPgJzd7biJYpqk_nfRgf5HoWldCVM-Gd3I3E740,2908
28
+ am_healthcheck/fixtures/codex-resolution.jsonl,sha256=Gs5UcYjcxZISwp_B5SYUkmM23SIeE5xOb9Gubi-zaI8,2698
29
+ am_healthcheck/fixtures/codex-retries.jsonl,sha256=uWomf2cD4Fi_363VxtiJJCCW7LyilpoZ8uK9iEimdQU,3190
30
+ am_healthcheck/fixtures/codex-stability.jsonl,sha256=5YuYQzZE7BiSnURwJF9dkHLBioH_92YKT5Hk7eRtUZo,2154
31
+ am_healthcheck/lab/schemas/funnel-event.schema.json,sha256=9Lo6l-gDu7YFoNIoxJxocC5zzhsr3fv47Q7TklANC8c,2680
32
+ agentmeasure-0.4.0.dist-info/METADATA,sha256=XweqPCNKiSN2B5jCSqGQG8_cBI3zK0TFMoGM6qWu7a4,12942
33
+ agentmeasure-0.4.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
34
+ agentmeasure-0.4.0.dist-info/entry_points.txt,sha256=YoNClX_D-GVT4nWjlGx8S--yKz1qOnTPBSX8pKKa6LQ,57
35
+ agentmeasure-0.4.0.dist-info/top_level.txt,sha256=n8SEHQFMaF7eQnjYX4rO7Ub2G3xcWa0VTXfjr3hq4bI,15
36
+ agentmeasure-0.4.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agentmeasure = am_healthcheck.cli:main
@@ -0,0 +1 @@
1
+ am_healthcheck
@@ -0,0 +1,17 @@
1
+ """AgentMeasure Healthcheck — a local check-up report for your coding agent runs.
2
+
3
+ Reads local agent runtime logs (Codex rollout JSONL first), computes a small
4
+ set of deterministic checks (duplicate records, retry amplification, tool-error
5
+ runs), and renders a terminal summary plus a local HTML report.
6
+
7
+ Honesty rules inherited from the conformance pack:
8
+ - PASS / FINDING / UNPROVABLE are the only verdicts; UNPROVABLE is first-class.
9
+ - Raw data never leaves the machine; there is no network code in this package.
10
+ - Sub-token fields (cached, reasoning) are subsets, never added into totals.
11
+
12
+ Python 3.9+ standard library only.
13
+ """
14
+
15
+ __version__ = "0.4.0"
16
+
17
+ RUNTIME_NAME = "codex-rollout"