tokenblame 2.1.2__tar.gz → 2.2.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 (22) hide show
  1. {tokenblame-2.1.2 → tokenblame-2.2.0}/PKG-INFO +7 -7
  2. {tokenblame-2.1.2 → tokenblame-2.2.0}/README.md +6 -6
  3. {tokenblame-2.1.2 → tokenblame-2.2.0}/pyproject.toml +1 -1
  4. {tokenblame-2.1.2 → tokenblame-2.2.0}/tests/test_observatory.py +113 -0
  5. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/harvesters.py +101 -9
  6. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/joiner.py +50 -9
  7. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/render.py +14 -2
  8. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/survival.py +57 -0
  9. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame.egg-info/PKG-INFO +7 -7
  10. {tokenblame-2.1.2 → tokenblame-2.2.0}/LICENSE +0 -0
  11. {tokenblame-2.1.2 → tokenblame-2.2.0}/setup.cfg +0 -0
  12. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/__init__.py +0 -0
  13. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/cli.py +0 -0
  14. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/hooks.py +0 -0
  15. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/provenance.py +0 -0
  16. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/redact.py +0 -0
  17. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/schema.py +0 -0
  18. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame/store.py +0 -0
  19. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame.egg-info/SOURCES.txt +0 -0
  20. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame.egg-info/dependency_links.txt +0 -0
  21. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame.egg-info/entry_points.txt +0 -0
  22. {tokenblame-2.1.2 → tokenblame-2.2.0}/tokenblame.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenblame
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Offline AI coding token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics
5
5
  Author: espressolee
6
6
  License-Expression: Apache-2.0
@@ -23,10 +23,10 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  Dynamic: license-file
25
25
 
26
- # TokenBlame (`v2.1`)
26
+ # TokenBlame (`v2.2`)
27
27
 
28
28
  **Don't just count AI coding tokens — blame them.**
29
- *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics.*
29
+ *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, fixed-horizon (`t+30/60/90d`) & Squash-Merge-resilient line retention, and exit-code-aware burn forensics.*
30
30
 
31
31
  ![TokenBlame Overview — Shareable Redacted Edition](docs/assets/tokenblame-overview.png)
32
32
 
@@ -42,12 +42,12 @@ Token accounting, commit attribution, and code survival each have strong existin
42
42
  | **`Git AI` (OSS / Teams)** | Line-level AI authorship + Teams PR cost, rework & churn analytics | Yes (spec covers buckets & 90d DB; team analytics in Teams tier) | Line-level authorship + PR cost/churn | Git notes / metadata | Rust / Cloud |
43
43
  | **`Entire`** | Session checkpoints & token hotspot diagnostics | Yes (`fresh` / `cache` / `output` / `subagent`) | Session checkpoints linked to commits | Checkpoint metadata | Go |
44
44
  | **`survived`** | Fixed-horizon `t+30/60/90d` code survival (with `notYet` cohort separation) | No | Fixed-horizon commit survival | None | TypeScript |
45
- | **`TokenBlame` (`v2.1`)** | **Local offline multi-agent cost + commit provenance + HEAD retention + burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert & HEAD line retention** | **None** | **Python 3.11+ stdlib only** |
45
+ | **`TokenBlame` (`v2.2`)** | **Local offline multi-agent cost + commit provenance + `t+30/60/90d` cohorts & HEAD retention + exit-code burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert, HEAD retention & matured cohorts (`notYet` separated)** | **None** | **Python 3.11+ stdlib only** |
46
46
 
47
47
  > **Honest measurement scope:**
48
- > - **HEAD Line Retention (`line_survival_30d_pct`):** Measures what fraction of sampled lines added by AI-attributed commits from the **recent 30-day window** remain at `HEAD` (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate when `git blame` fails). It is **not** yet a fixed-horizon `t+30d` matured cohort score.
48
+ > - **HEAD Line Retention vs. Fixed-Horizon Cohorts (`t+30/60/90d`):** `line_survival_30d_pct` tracks HEAD retention of lines from the recent 30-day window (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate on `git blame` errors). Alongside it, `durability.cohorts` (`t30d`, `t60d`, `t90d`) measures **matured** fixed-horizon cohorts explicitly separated from immature `notYet` commits.
49
49
  > - **Pre-Indexed Query Latency (`3.5ms`):** Refers specifically to filtered `tokenblame summary` reads against an already-built `observatory.sqlite`, not cold full-history harvesting or `git blame` scans.
50
- > - **Diagnostic Signals ≠ Causal Proof:** `RETRY_LOOP`, uncommitted high-burn sessions, and HEAD line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
50
+ > - **Diagnostic Signals ≠ Causal Proof:** `FAILURE_LOOP` (nonzero exit/error streaks), `ITERATION_LOOP` (zero-error verification repeats), uncommitted high-burn sessions, and line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
51
51
 
52
52
  ---
53
53
 
@@ -55,7 +55,7 @@ Token accounting, commit attribution, and code survival each have strong existin
55
55
 
56
56
  ![TokenBlame Heatmap and High-Burn Forensics Radar](docs/assets/tokenblame-radar.png)
57
57
 
58
- - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and automatic loop warnings (`RETRY_LOOP(Edit x132)`, `RETRY_LOOP(Bash:pytest x9)`) using an allowlist of tool/command basenames — **never** storing command arguments, file paths, or prompts.
58
+ - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and exit-code-aware loop classifications (`FAILURE_LOOP(Bash:pytest x6, err=4)` vs normal `ITERATION_LOOP(Bash:pytest x4)`) using an allowlist of tool/command basenames — **never** storing command arguments, stdout/stderr, file paths, or prompts.
59
59
  - **Privacy-Sealed `--shareable` Mode:** `tokenblame build --shareable` produces a standalone offline HTML dashboard (`shareable-observatory.html`) with salted SHA-256 aliases (`repo-01`, `c-9a4f1b2c`) and **zero** local paths, usernames, or commit subjects.
60
60
 
61
61
  ---
@@ -1,7 +1,7 @@
1
- # TokenBlame (`v2.1`)
1
+ # TokenBlame (`v2.2`)
2
2
 
3
3
  **Don't just count AI coding tokens — blame them.**
4
- *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics.*
4
+ *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, fixed-horizon (`t+30/60/90d`) & Squash-Merge-resilient line retention, and exit-code-aware burn forensics.*
5
5
 
6
6
  ![TokenBlame Overview — Shareable Redacted Edition](docs/assets/tokenblame-overview.png)
7
7
 
@@ -17,12 +17,12 @@ Token accounting, commit attribution, and code survival each have strong existin
17
17
  | **`Git AI` (OSS / Teams)** | Line-level AI authorship + Teams PR cost, rework & churn analytics | Yes (spec covers buckets & 90d DB; team analytics in Teams tier) | Line-level authorship + PR cost/churn | Git notes / metadata | Rust / Cloud |
18
18
  | **`Entire`** | Session checkpoints & token hotspot diagnostics | Yes (`fresh` / `cache` / `output` / `subagent`) | Session checkpoints linked to commits | Checkpoint metadata | Go |
19
19
  | **`survived`** | Fixed-horizon `t+30/60/90d` code survival (with `notYet` cohort separation) | No | Fixed-horizon commit survival | None | TypeScript |
20
- | **`TokenBlame` (`v2.1`)** | **Local offline multi-agent cost + commit provenance + HEAD retention + burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert & HEAD line retention** | **None** | **Python 3.11+ stdlib only** |
20
+ | **`TokenBlame` (`v2.2`)** | **Local offline multi-agent cost + commit provenance + `t+30/60/90d` cohorts & HEAD retention + exit-code burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert, HEAD retention & matured cohorts (`notYet` separated)** | **None** | **Python 3.11+ stdlib only** |
21
21
 
22
22
  > **Honest measurement scope:**
23
- > - **HEAD Line Retention (`line_survival_30d_pct`):** Measures what fraction of sampled lines added by AI-attributed commits from the **recent 30-day window** remain at `HEAD` (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate when `git blame` fails). It is **not** yet a fixed-horizon `t+30d` matured cohort score.
23
+ > - **HEAD Line Retention vs. Fixed-Horizon Cohorts (`t+30/60/90d`):** `line_survival_30d_pct` tracks HEAD retention of lines from the recent 30-day window (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate on `git blame` errors). Alongside it, `durability.cohorts` (`t30d`, `t60d`, `t90d`) measures **matured** fixed-horizon cohorts explicitly separated from immature `notYet` commits.
24
24
  > - **Pre-Indexed Query Latency (`3.5ms`):** Refers specifically to filtered `tokenblame summary` reads against an already-built `observatory.sqlite`, not cold full-history harvesting or `git blame` scans.
25
- > - **Diagnostic Signals ≠ Causal Proof:** `RETRY_LOOP`, uncommitted high-burn sessions, and HEAD line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
25
+ > - **Diagnostic Signals ≠ Causal Proof:** `FAILURE_LOOP` (nonzero exit/error streaks), `ITERATION_LOOP` (zero-error verification repeats), uncommitted high-burn sessions, and line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
26
26
 
27
27
  ---
28
28
 
@@ -30,7 +30,7 @@ Token accounting, commit attribution, and code survival each have strong existin
30
30
 
31
31
  ![TokenBlame Heatmap and High-Burn Forensics Radar](docs/assets/tokenblame-radar.png)
32
32
 
33
- - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and automatic loop warnings (`RETRY_LOOP(Edit x132)`, `RETRY_LOOP(Bash:pytest x9)`) using an allowlist of tool/command basenames — **never** storing command arguments, file paths, or prompts.
33
+ - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and exit-code-aware loop classifications (`FAILURE_LOOP(Bash:pytest x6, err=4)` vs normal `ITERATION_LOOP(Bash:pytest x4)`) using an allowlist of tool/command basenames — **never** storing command arguments, stdout/stderr, file paths, or prompts.
34
34
  - **Privacy-Sealed `--shareable` Mode:** `tokenblame build --shareable` produces a standalone offline HTML dashboard (`shareable-observatory.html`) with salted SHA-256 aliases (`repo-01`, `c-9a4f1b2c`) and **zero** local paths, usernames, or commit subjects.
35
35
 
36
36
  ---
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tokenblame"
7
- version = "2.1.2"
7
+ version = "2.2.0"
8
8
  description = "Offline AI coding token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -1319,6 +1319,119 @@ class TestObservatoryAdversarial(unittest.TestCase):
1319
1319
  self.assertEqual(res["unobserved_lines"], 3)
1320
1320
  self.assertEqual(res["unobserved_files"], ["mod.py"])
1321
1321
 
1322
+ def test_fixed_horizon_cohort_survival_t30_t60_t90_and_not_yet(self):
1323
+ import subprocess
1324
+ from tokenblame.survival import measure_cohort_line_survival
1325
+
1326
+ with tempfile.TemporaryDirectory() as td:
1327
+ repo = Path(td) / "cohort-repo"
1328
+ repo.mkdir()
1329
+ def git(*args: str) -> str:
1330
+ return subprocess.run(
1331
+ ["git", "-C", str(repo), *args],
1332
+ check=True, capture_output=True, text=True,
1333
+ ).stdout.strip()
1334
+
1335
+ git("init", "-b", "main")
1336
+ git("config", "user.name", "Dev")
1337
+ git("config", "user.email", "dev@example.com")
1338
+
1339
+ now_ep = 1_800_000_000.0
1340
+ (repo / "a.py").write_text("line_95d_1 = 1\nline_95d_2 = 2\n", encoding="utf-8")
1341
+ git("add", ".")
1342
+ git("commit", "-m", "c95")
1343
+ oid_95 = git("rev-parse", "HEAD")
1344
+
1345
+ (repo / "b.py").write_text("line_65d_1 = 1\nline_65d_2 = 2\n", encoding="utf-8")
1346
+ git("add", ".")
1347
+ git("commit", "-m", "c65")
1348
+ oid_65 = git("rev-parse", "HEAD")
1349
+
1350
+ # Overwrite b.py 35d ago -> oid_65 has 0 surviving lines, oid_35 has 2 surviving lines
1351
+ (repo / "b.py").write_text("line_35d_1 = 10\nline_35d_2 = 20\n", encoding="utf-8")
1352
+ git("add", ".")
1353
+ git("commit", "-m", "c35")
1354
+ oid_35 = git("rev-parse", "HEAD")
1355
+
1356
+ (repo / "c.py").write_text("line_5d_1 = 99\n", encoding="utf-8")
1357
+ git("add", ".")
1358
+ git("commit", "-m", "c5")
1359
+ oid_5 = git("rev-parse", "HEAD")
1360
+
1361
+ records = [
1362
+ {"oid": oid_95, "epoch_sec": now_ep - 95 * 86400},
1363
+ {"oid": oid_65, "epoch_sec": now_ep - 65 * 86400},
1364
+ {"oid": oid_35, "epoch_sec": now_ep - 35 * 86400},
1365
+ {"oid": oid_5, "epoch_sec": now_ep - 5 * 86400},
1366
+ ]
1367
+ cohorts = measure_cohort_line_survival(str(repo), records, as_of_epoch=now_ep)
1368
+ self.assertEqual(cohorts["t30d"]["matured_commits"], 3)
1369
+ self.assertEqual(cohorts["t30d"]["not_yet_commits"], 1)
1370
+ self.assertEqual(cohorts["t30d"]["added_lines"], 6)
1371
+ self.assertEqual(cohorts["t30d"]["surviving_lines"], 4)
1372
+ self.assertEqual(cohorts["t60d"]["matured_commits"], 2)
1373
+ self.assertEqual(cohorts["t60d"]["not_yet_commits"], 2)
1374
+ self.assertEqual(cohorts["t60d"]["retention_pct"], 50.0)
1375
+ self.assertEqual(cohorts["t90d"]["matured_commits"], 1)
1376
+ self.assertEqual(cohorts["t90d"]["not_yet_commits"], 3)
1377
+ self.assertEqual(cohorts["t90d"]["retention_pct"], 100.0)
1378
+
1379
+ def test_exit_code_aware_failure_loop_vs_iteration_loop_without_arg_leaks(self):
1380
+ from tokenblame.harvesters import parse_claude_jsonl
1381
+
1382
+ def _write_claude(path: Path, is_error_flags: list[bool]) -> None:
1383
+ lines = []
1384
+ for idx, is_err in enumerate(is_error_flags, start=1):
1385
+ tid = f"toolu_{idx}"
1386
+ lines.append(json.dumps({
1387
+ "sessionId": path.stem,
1388
+ "requestId": f"req_{idx}",
1389
+ "timestamp": f"2026-11-26T05:0{idx}:00Z",
1390
+ "cwd": "/tmp/demo",
1391
+ "message": {
1392
+ "model": "claude-opus-5-5",
1393
+ "content": [{
1394
+ "type": "tool_use",
1395
+ "id": tid,
1396
+ "name": "Bash",
1397
+ "input": {"command": "pytest tests/secret_case.py --token=SUPER_SECRET_ARG"},
1398
+ }],
1399
+ "usage": {"input_tokens": 500, "cache_read_input_tokens": 2000, "output_tokens": 1200},
1400
+ },
1401
+ }))
1402
+ lines.append(json.dumps({
1403
+ "sessionId": path.stem,
1404
+ "timestamp": f"2026-11-26T05:0{idx}:05Z",
1405
+ "message": {
1406
+ "role": "user",
1407
+ "content": [{
1408
+ "type": "tool_result",
1409
+ "tool_use_id": tid,
1410
+ "is_error": is_err,
1411
+ "content": "SECRET_STDOUT_LEAK_CANARY exit code 1" if is_err else "ok",
1412
+ }],
1413
+ },
1414
+ }))
1415
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8")
1416
+
1417
+ with tempfile.TemporaryDirectory() as td:
1418
+ fail_p = Path(td) / "sess-fail.jsonl"
1419
+ ok_p = Path(td) / "sess-iter.jsonl"
1420
+ _write_claude(fail_p, [True, True, True, True, True, False])
1421
+ _write_claude(ok_p, [False, False, False, False, False, False])
1422
+
1423
+ rec_fail = parse_claude_jsonl(fail_p)[0]
1424
+ rec_iter = parse_claude_jsonl(ok_p)[0]
1425
+
1426
+ self.assertEqual(rec_fail.forensics["loop_kind"], "failure")
1427
+ self.assertIn("FAILURE_LOOP(Bash:pytest x6, err=5)", rec_fail.forensics["loop_warning"])
1428
+ self.assertEqual(rec_fail.forensics["tool_errors"]["Bash:pytest"], 5)
1429
+ self.assertNotIn("SUPER_SECRET_ARG", json.dumps(rec_fail.forensics))
1430
+ self.assertNotIn("SECRET_STDOUT_LEAK_CANARY", json.dumps(rec_fail.forensics))
1431
+
1432
+ self.assertEqual(rec_iter.forensics["loop_kind"], "iteration")
1433
+ self.assertIn("ITERATION_LOOP(Bash:pytest x6)", rec_iter.forensics["loop_warning"])
1434
+
1322
1435
 
1323
1436
  if __name__ == "__main__":
1324
1437
  unittest.main()
@@ -117,11 +117,38 @@ def _safe_tool_label(raw_name: Any, raw_input: Any = None) -> Optional[str]:
117
117
  return f"{prefix}:{verb}" if verb else prefix
118
118
 
119
119
 
120
+ _EXIT_CODE_RE = re.compile(r"(?:exit(?:ed with)? code|exit_code|returncode)\s*[:=]?\s*(-?\d+)", re.IGNORECASE)
121
+
122
+
123
+ def _extract_nonzero_exit(text_or_obj: Any) -> bool:
124
+ """Return True iff tool output indicates a non-zero exit / error without storing content."""
125
+ if isinstance(text_or_obj, dict):
126
+ if text_or_obj.get("is_error") is True or text_or_obj.get("isError") is True:
127
+ return True
128
+ if str(text_or_obj.get("status") or "").lower() in ("error", "failed", "failure"):
129
+ return True
130
+ for k in ("exitCode", "exit_code", "returncode"):
131
+ v = text_or_obj.get(k)
132
+ if isinstance(v, int) and v != 0:
133
+ return True
134
+ return False
135
+ if isinstance(text_or_obj, str):
136
+ m = _EXIT_CODE_RE.search(text_or_obj[:400])
137
+ if m:
138
+ try:
139
+ return int(m.group(1)) != 0
140
+ except ValueError:
141
+ return False
142
+ return False
143
+
144
+
120
145
  def _build_forensics(
121
146
  turns: list[tuple[int, int, int, int, list[str]]],
122
147
  rec: SessionRecord,
148
+ tool_errors: Optional[Counter[str]] = None,
149
+ observed_results: int = 0,
123
150
  ) -> Optional[dict[str, Any]]:
124
- """Summarize top 3 turn spikes, safe tool-basename counts, and retry-loop warnings."""
151
+ """Summarize top 3 turn spikes, safe tool-basename counts, and exit-code-aware loop warnings."""
125
152
  if not turns:
126
153
  return None
127
154
  tool_counter: Counter[str] = Counter()
@@ -141,6 +168,7 @@ def _build_forensics(
141
168
  max_streak[lbl] = cur_streak[lbl]
142
169
 
143
170
  loop_warning: Optional[str] = None
171
+ loop_kind: Optional[str] = None
144
172
  best_loop: Optional[tuple[int, str]] = None
145
173
  for lbl, cnt in tool_counter.items():
146
174
  streak = max_streak[lbl]
@@ -150,7 +178,18 @@ def _build_forensics(
150
178
  if best_loop is None or cand_score > best_loop[0]:
151
179
  best_loop = (cand_score, lbl)
152
180
  if best_loop is not None:
153
- loop_warning = f"RETRY_LOOP({best_loop[1]} x{best_loop[0]})"
181
+ lbl = best_loop[1]
182
+ err_cnt = int((tool_errors or {}).get(lbl, 0))
183
+ tot_cnt = max(1, tool_counter[lbl])
184
+ if err_cnt >= 3 and (err_cnt / tot_cnt) >= 0.4:
185
+ loop_kind = "failure"
186
+ loop_warning = f"FAILURE_LOOP({lbl} x{best_loop[0]}, err={err_cnt})"
187
+ elif observed_results > 0:
188
+ loop_kind = "iteration"
189
+ loop_warning = f"ITERATION_LOOP({lbl} x{best_loop[0]})"
190
+ else:
191
+ loop_kind = "unclassified"
192
+ loop_warning = f"RETRY_LOOP({lbl} x{best_loop[0]})"
154
193
 
155
194
  ranked = sorted(turns, key=lambda t: (t[3], t[1]), reverse=True)[:3]
156
195
  top_spikes = [
@@ -164,11 +203,17 @@ def _build_forensics(
164
203
  for t_idx, f_in, c_rd, out_t, t_list in ranked
165
204
  ]
166
205
  top_tools = dict(tool_counter.most_common(6))
167
- return {
206
+ err_summary = {k: int(v) for k, v in (tool_errors or Counter()).most_common(6) if v > 0}
207
+ out_fx: dict[str, Any] = {
168
208
  "top_spikes": top_spikes,
169
209
  "tool_counts": top_tools,
170
210
  "loop_warning": loop_warning,
171
211
  }
212
+ if loop_kind is not None:
213
+ out_fx["loop_kind"] = loop_kind
214
+ if err_summary:
215
+ out_fx["tool_errors"] = err_summary
216
+ return out_fx
172
217
 
173
218
 
174
219
  def extract_commit_oids_from_text(text: str) -> list[str]:
@@ -459,6 +504,9 @@ def parse_claude_jsonl(path: Path) -> list[SessionRecord]:
459
504
  dedup: dict[str, tuple[str, str, dict[str, Any], str, Optional[str], Optional[str], bool, list[str]]] = {}
460
505
  session_id = path.stem
461
506
  transcript_oids: list[str] = []
507
+ tool_id_to_label: dict[str, str] = {}
508
+ tool_errors: Counter[str] = Counter()
509
+ observed_results = 0
462
510
 
463
511
  try:
464
512
  with path.open("r", encoding="utf-8", errors="replace") as f:
@@ -467,7 +515,9 @@ def parse_claude_jsonl(path: Path) -> list[SessionRecord]:
467
515
  for oid in extract_commit_oids_from_text(line):
468
516
  if oid not in transcript_oids:
469
517
  transcript_oids.append(oid)
470
- if '"usage"' not in line:
518
+ has_usage = '"usage"' in line
519
+ has_tool_res = '"tool_result"' in line
520
+ if not has_usage and not has_tool_res:
471
521
  continue
472
522
  try:
473
523
  d = json.loads(line)
@@ -476,6 +526,18 @@ def parse_claude_jsonl(path: Path) -> list[SessionRecord]:
476
526
  msg = d.get("message")
477
527
  if not isinstance(msg, dict):
478
528
  continue
529
+ if has_tool_res:
530
+ content = msg.get("content")
531
+ if isinstance(content, list):
532
+ for blk in content:
533
+ if isinstance(blk, dict) and blk.get("type") == "tool_result":
534
+ observed_results += 1
535
+ tid = str(blk.get("tool_use_id") or "")
536
+ lbl = tool_id_to_label.get(tid)
537
+ if lbl and (blk.get("is_error") is True or _extract_nonzero_exit(blk.get("content"))):
538
+ tool_errors[lbl] += 1
539
+ if not has_usage:
540
+ continue
479
541
  model = msg.get("model")
480
542
  usage = msg.get("usage")
481
543
  if not model or model == "<synthetic>" or not isinstance(usage, dict):
@@ -491,8 +553,12 @@ def parse_claude_jsonl(path: Path) -> list[SessionRecord]:
491
553
  for blk in content:
492
554
  if isinstance(blk, dict) and blk.get("type") == "tool_use":
493
555
  lbl = _safe_tool_label(blk.get("name"), blk.get("input"))
494
- if lbl and lbl not in cur_tools:
495
- cur_tools.append(lbl)
556
+ if lbl:
557
+ tid = str(blk.get("id") or "")
558
+ if tid:
559
+ tool_id_to_label[tid] = lbl
560
+ if lbl not in cur_tools:
561
+ cur_tools.append(lbl)
496
562
  dedup[req_id] = (
497
563
  model,
498
564
  speed_tier,
@@ -555,7 +621,9 @@ def parse_claude_jsonl(path: Path) -> list[SessionRecord]:
555
621
  rec.git_branch = branch
556
622
 
557
623
  for key, rec in grouped.items():
558
- rec.forensics = _build_forensics(turns_by_key[key], rec)
624
+ rec.forensics = _build_forensics(
625
+ turns_by_key[key], rec, tool_errors=tool_errors, observed_results=observed_results
626
+ )
559
627
  out_recs = list(grouped.values())
560
628
  if out_recs and transcript_oids:
561
629
  out_recs[-1].transcript_oids = transcript_oids
@@ -575,6 +643,9 @@ def parse_codex_rollout(path: Path) -> list[SessionRecord]:
575
643
  grouped: dict[tuple[str, str], SessionRecord] = {}
576
644
  turns_by_key: dict[tuple[str, str], list[tuple[int, int, int, int, list[str]]]] = {}
577
645
  pending_tools: list[str] = []
646
+ call_id_to_label: dict[str, str] = {}
647
+ tool_errors: Counter[str] = Counter()
648
+ observed_results = 0
578
649
  transcript_oids: list[str] = []
579
650
 
580
651
  try:
@@ -608,6 +679,15 @@ def parse_codex_rollout(path: Path) -> list[SessionRecord]:
608
679
  lbl = _safe_tool_label(payload.get("name"), payload.get("arguments") or payload.get("input"))
609
680
  if lbl:
610
681
  pending_tools.append(lbl)
682
+ cid = str(payload.get("call_id") or payload.get("id") or "")
683
+ if cid:
684
+ call_id_to_label[cid] = lbl
685
+ elif ev_type == "response_item" and payload.get("type") in ("function_call_output", "custom_tool_call_output"):
686
+ observed_results += 1
687
+ cid = str(payload.get("call_id") or "")
688
+ lbl = call_id_to_label.get(cid)
689
+ if lbl and (_extract_nonzero_exit(payload) or _extract_nonzero_exit(payload.get("output"))):
690
+ tool_errors[lbl] += 1
611
691
  elif ev_type == "event_msg" and payload.get("type") == "token_count":
612
692
  info = payload.get("info")
613
693
  if not isinstance(info, dict):
@@ -669,7 +749,9 @@ def parse_codex_rollout(path: Path) -> list[SessionRecord]:
669
749
  return []
670
750
 
671
751
  for key, rec in grouped.items():
672
- rec.forensics = _build_forensics(turns_by_key[key], rec)
752
+ rec.forensics = _build_forensics(
753
+ turns_by_key[key], rec, tool_errors=tool_errors, observed_results=observed_results
754
+ )
673
755
  out_recs = list(grouped.values())
674
756
  if out_recs and transcript_oids:
675
757
  out_recs[-1].transcript_oids = transcript_oids
@@ -688,6 +770,8 @@ def parse_gemini_cli_chat(path: Path) -> list[SessionRecord]:
688
770
  session_id = d.get("sessionId") or path.stem
689
771
  grouped: dict[tuple[str, str], SessionRecord] = {}
690
772
  turns_by_key: dict[tuple[str, str], list[tuple[int, int, int, int, list[str]]]] = {}
773
+ tool_errors: Counter[str] = Counter()
774
+ observed_results = 0
691
775
  transcript_oids: list[str] = []
692
776
 
693
777
  for m in d.get("messages", []):
@@ -739,10 +823,16 @@ def parse_gemini_cli_chat(path: Path) -> list[SessionRecord]:
739
823
  lbl = _safe_tool_label(tc.get("name"), tc.get("args"))
740
824
  if lbl and lbl not in t_labels:
741
825
  t_labels.append(lbl)
826
+ if "status" in tc or "result" in tc:
827
+ observed_results += 1
828
+ if lbl and (_extract_nonzero_exit(tc) or _extract_nonzero_exit(tc.get("result"))):
829
+ tool_errors[lbl] += 1
742
830
  turns_by_key[key].append((rec.request_count, u_in, cached, gen_out, t_labels))
743
831
 
744
832
  for key, rec in grouped.items():
745
- rec.forensics = _build_forensics(turns_by_key[key], rec)
833
+ rec.forensics = _build_forensics(
834
+ turns_by_key[key], rec, tool_errors=tool_errors, observed_results=observed_results
835
+ )
746
836
  out_recs = list(grouped.values())
747
837
  if out_recs and transcript_oids:
748
838
  out_recs[-1].transcript_oids = transcript_oids
@@ -840,6 +930,8 @@ def parse_antigravity_transcript(
840
930
  seen_tok_steps: set[tuple[Any, Any, int, int, int]] = set()
841
931
  grouped: dict[tuple[str, str], SessionRecord] = {}
842
932
  turns_by_key: dict[tuple[str, str], list[tuple[int, int, int, int, list[str]]]] = {}
933
+ tool_errors: Counter[str] = Counter()
934
+ observed_results = 0
843
935
  transcript_oids: list[str] = []
844
936
 
845
937
  try:
@@ -16,7 +16,12 @@ from zoneinfo import ZoneInfo
16
16
  from tokenblame.harvesters import IncrementalCache
17
17
  from tokenblame.provenance import resolve_main_from_git_file as _resolve_main_from_git_file
18
18
  from tokenblame.schema import SCHEMA_VERSION, SessionRecord, TokenBuckets, resolve_local_tz
19
- from tokenblame.survival import REVERT_SUBJ_RE, measure_30d_line_survival, scan_repo_reverts
19
+ from tokenblame.survival import (
20
+ REVERT_SUBJ_RE,
21
+ measure_30d_line_survival,
22
+ measure_cohort_line_survival,
23
+ scan_repo_reverts,
24
+ )
20
25
 
21
26
  SHA_RE = re.compile(r"\b[0-9a-f]{7,40}\b")
22
27
 
@@ -738,6 +743,7 @@ def build_observatory_ir(
738
743
 
739
744
  ai_oids_all: set[str] = set()
740
745
  ai_oids_by_repo: dict[str, list[str]] = {}
746
+ ai_commits_all_by_repo: dict[str, list[dict[str, Any]]] = {}
741
747
  max_commit_ep = max((float(c.get("epoch_sec") or 0.0) for c in all_commits), default=0.0)
742
748
  cutoff_30d_ep = max_commit_ep - (30.0 * 86400.0) if max_commit_ep > 0 else 0.0
743
749
 
@@ -746,15 +752,31 @@ def build_observatory_ir(
746
752
  for oid in s.linked_oids:
747
753
  ai_oids_all.add(oid)
748
754
  c_obj = commits_by_oid.get(oid)
749
- if c_obj and c_obj.get("repo_root") and float(c_obj.get("epoch_sec") or 0.0) >= cutoff_30d_ep:
750
- r_list = ai_oids_by_repo.setdefault(c_obj["repo_root"], [])
751
- if oid not in r_list:
752
- r_list.append(oid)
755
+ if c_obj and c_obj.get("repo_root"):
756
+ all_list = ai_commits_all_by_repo.setdefault(c_obj["repo_root"], [])
757
+ if not any(x["oid"] == oid for x in all_list):
758
+ all_list.append(c_obj)
759
+ if float(c_obj.get("epoch_sec") or 0.0) >= cutoff_30d_ep:
760
+ r_list = ai_oids_by_repo.setdefault(c_obj["repo_root"], [])
761
+ if oid not in r_list:
762
+ r_list.append(oid)
753
763
 
754
764
  sampled_30d_added = 0
755
765
  sampled_30d_surviving = 0
756
766
  sampled_30d_unobserved = 0
757
767
  per_repo_line_surv: dict[str, tuple[int, int]] = {}
768
+ cohort_agg: dict[str, dict[str, Any]] = {
769
+ f"t{h}d": {
770
+ "horizon_days": h,
771
+ "matured_commits": 0,
772
+ "not_yet_commits": 0,
773
+ "added_lines": 0,
774
+ "surviving_lines": 0,
775
+ "unobserved_lines": 0,
776
+ "retention_pct": None,
777
+ }
778
+ for h in (30, 60, 90)
779
+ }
758
780
 
759
781
  if eff_survival and all_repos:
760
782
  commits_grouped_by_repo: dict[str, list[dict[str, Any]]] = {}
@@ -785,11 +807,18 @@ def build_observatory_ir(
785
807
  if not head_oid:
786
808
  continue
787
809
  cached_surv = scache.get_repo_survival(rroot, head_oid) if scache else None
788
- if cached_surv is None:
789
- rev_map = scan_repo_reverts(rroot, commits_grouped_by_repo[rroot])
810
+ if cached_surv is None or "cohorts" not in cached_surv:
811
+ rev_map = (cached_surv or {}).get("reverts") if cached_surv else scan_repo_reverts(rroot, commits_grouped_by_repo[rroot])
790
812
  recent_ai = ai_oids_by_repo.get(rroot, [])
791
- lsurv = measure_30d_line_survival(rroot, recent_ai) if recent_ai else {"added_lines": 0, "surviving_lines": 0}
792
- cached_surv = {"reverts": rev_map, "line_survival": lsurv}
813
+ lsurv = (
814
+ cached_surv["line_survival"]
815
+ if (cached_surv and "line_survival" in cached_surv)
816
+ else (measure_30d_line_survival(rroot, recent_ai) if recent_ai else {"added_lines": 0, "surviving_lines": 0, "unobserved_lines": 0})
817
+ )
818
+ cohorts_r = measure_cohort_line_survival(
819
+ rroot, ai_commits_all_by_repo.get(rroot, []), as_of_epoch=max_commit_ep
820
+ )
821
+ cached_surv = {"reverts": rev_map, "line_survival": lsurv, "cohorts": cohorts_r}
793
822
  if scache is not None:
794
823
  scache.put_repo_survival(rroot, head_oid, cached_surv)
795
824
  global_reverts.update(cached_surv.get("reverts") or {})
@@ -802,6 +831,13 @@ def build_observatory_ir(
802
831
  sampled_30d_added += r_add
803
832
  sampled_30d_surviving += r_surv
804
833
  sampled_30d_unobserved += r_unobs
834
+ for ck, cv in (cached_surv.get("cohorts") or {}).items():
835
+ if ck in cohort_agg and isinstance(cv, dict):
836
+ cohort_agg[ck]["matured_commits"] += int(cv.get("matured_commits") or 0)
837
+ cohort_agg[ck]["not_yet_commits"] += int(cv.get("not_yet_commits") or 0)
838
+ cohort_agg[ck]["added_lines"] += int(cv.get("added_lines") or 0)
839
+ cohort_agg[ck]["surviving_lines"] += int(cv.get("surviving_lines") or 0)
840
+ cohort_agg[ck]["unobserved_lines"] += int(cv.get("unobserved_lines") or 0)
805
841
  finally:
806
842
  if scache:
807
843
  scache.close()
@@ -822,6 +858,10 @@ def build_observatory_ir(
822
858
  else:
823
859
  s.outcome_durability = "ACTIVE"
824
860
 
861
+ for ck, cv in cohort_agg.items():
862
+ if cv["added_lines"] > 0:
863
+ cv["retention_pct"] = round(100.0 * cv["surviving_lines"] / cv["added_lines"], 2)
864
+
825
865
  ai_reverted_cnt = sum(1 for oid in ai_oids_all if oid in global_reverts)
826
866
  durability_summary = {
827
867
  "total_commits": len(all_commits),
@@ -834,6 +874,7 @@ def build_observatory_ir(
834
874
  "sampled_30d_unobserved_lines": sampled_30d_unobserved,
835
875
  "line_survival_30d_pct": round(100.0 * sampled_30d_surviving / sampled_30d_added, 2) if sampled_30d_added > 0 else None,
836
876
  "line_retention_metric_scope": "current_head_retention_of_recent_30d_commits",
877
+ "cohorts": cohort_agg,
837
878
  }
838
879
 
839
880
  # Aggregate 4-Bucket metrics + 4-Category Conservation Check + Separated Side Ledgers
@@ -416,7 +416,8 @@ def render_observatory_html(ir: dict[str, Any], *, view_mode: str = "auto") -> s
416
416
  cs_pct = rrow.get("commit_survival_pct", 100.0)
417
417
  surv_badge = f'<span class="badge {"ok" if cs_pct >= 90 else "warn"}">{cs_pct}% commit surv</span>'
418
418
  surv_detail = f'AI commits: <b>{int(rrow.get("ai_commits") or 0)}</b> ({int(rrow.get("ai_reverted") or 0)} reverted)'
419
- wl_badge = f' <span class="badge warn">{_esc(rrow["worst_loop"])}</span>' if rrow.get("worst_loop") else ""
419
+ wl_cls = "commit" if str(rrow.get("worst_loop") or "").startswith("ITERATION_LOOP") else "warn"
420
+ wl_badge = f' <span class="badge {wl_cls}">{_esc(rrow["worst_loop"])}</span>' if rrow.get("worst_loop") else ""
420
421
  repo_cards.append(
421
422
  '<div class="mini-card">'
422
423
  f'<div class="mini-top"><code>{_esc(rrow["repo_name"])}</code><span>{surv_badge}{wl_badge}</span></div>'
@@ -537,8 +538,19 @@ def render_observatory_html(ir: dict[str, Any], *, view_mode: str = "auto") -> s
537
538
 
538
539
  dur = totals.get("durability") or {}
539
540
  commit_surv = dur.get("commit_survival_pct", 100.0)
541
+ cohorts = dur.get("cohorts") or {}
542
+ t30 = cohorts.get("t30d") or {}
540
543
  line_surv = dur.get("line_survival_30d_pct")
541
- line_surv_txt = f"{line_surv}% HEAD line retention (recent 30d commits)" if line_surv is not None else "HEAD revert check"
544
+ if t30.get("retention_pct") is not None:
545
+ line_surv_txt = (
546
+ f"t+30d matured: {t30['retention_pct']}% ({t30.get('matured_commits', 0)} matured, {t30.get('not_yet_commits', 0)} notYet)"
547
+ )
548
+ elif line_surv is not None:
549
+ ny = int(t30.get("not_yet_commits") or 0)
550
+ ny_s = f" · {ny} notYet" if ny else ""
551
+ line_surv_txt = f"{line_surv}% HEAD line retention (recent 30d commits{ny_s})"
552
+ else:
553
+ line_surv_txt = "HEAD revert check"
542
554
  eyebrow_txt = (
543
555
  "TokenBlame · Multi-Agent Token & Patch Survival Observatory · Shareable Redacted Edition · Zero Private Paths"
544
556
  if ir.get("shareable_redacted")
@@ -361,3 +361,60 @@ def measure_30d_line_survival(
361
361
  "per_oid": dict(per_oid),
362
362
  "squash_fallback_oids": sorted(squash_fallback_oids),
363
363
  }
364
+
365
+
366
+ def measure_cohort_line_survival(
367
+ repo_root: str,
368
+ commit_records: list[dict[str, Any]],
369
+ as_of_epoch: float,
370
+ horizons_days: tuple[int, ...] = (30, 60, 90),
371
+ max_commits: int = 30,
372
+ max_files: int = 18,
373
+ ) -> dict[str, dict[str, Any]]:
374
+ """Measure fixed-horizon matured cohort HEAD line retention (`t+30/60/90d`) with explicit `notYet` separation."""
375
+ out: dict[str, dict[str, Any]] = {}
376
+ if not commit_records or not os.path.isdir(repo_root) or as_of_epoch <= 0:
377
+ for h in horizons_days:
378
+ out[f"t{h}d"] = {
379
+ "horizon_days": h,
380
+ "matured_commits": 0,
381
+ "not_yet_commits": 0,
382
+ "added_lines": 0,
383
+ "surviving_lines": 0,
384
+ "unobserved_lines": 0,
385
+ "retention_pct": None,
386
+ }
387
+ return out
388
+
389
+ seen: dict[str, float] = {}
390
+ for c in commit_records:
391
+ oid = str(c.get("oid") or "")
392
+ ep = float(c.get("epoch_sec") or 0.0)
393
+ if oid and ep > 0 and oid not in seen:
394
+ seen[oid] = ep
395
+
396
+ # Evaluate matured commits once per unique matured set (most recent matured first)
397
+ ordered = sorted(seen.items(), key=lambda kv: kv[1], reverse=True)
398
+ for h in horizons_days:
399
+ min_age = float(h) * 86400.0
400
+ matured = [oid for oid, ep in ordered if (as_of_epoch - ep) >= min_age]
401
+ not_yet = [oid for oid, ep in ordered if (as_of_epoch - ep) < min_age]
402
+ if matured:
403
+ res = measure_30d_line_survival(
404
+ repo_root, matured, max_commits=max_commits, max_files=max_files
405
+ )
406
+ add_n = int(res.get("added_lines") or 0)
407
+ surv_n = int(res.get("surviving_lines") or 0)
408
+ unobs_n = int(res.get("unobserved_lines") or 0)
409
+ else:
410
+ add_n = surv_n = unobs_n = 0
411
+ out[f"t{h}d"] = {
412
+ "horizon_days": h,
413
+ "matured_commits": len(matured),
414
+ "not_yet_commits": len(not_yet),
415
+ "added_lines": add_n,
416
+ "surviving_lines": surv_n,
417
+ "unobserved_lines": unobs_n,
418
+ "retention_pct": round(100.0 * surv_n / add_n, 2) if add_n > 0 else None,
419
+ }
420
+ return out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tokenblame
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Offline AI coding token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics
5
5
  Author: espressolee
6
6
  License-Expression: Apache-2.0
@@ -23,10 +23,10 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  Dynamic: license-file
25
25
 
26
- # TokenBlame (`v2.1`)
26
+ # TokenBlame (`v2.2`)
27
27
 
28
28
  **Don't just count AI coding tokens — blame them.**
29
- *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, Squash-Merge-resilient HEAD line retention, and allowlisted burn forensics.*
29
+ *Zero-config, 100% offline multi-agent token ledger with out-of-repo Git commit provenance, fixed-horizon (`t+30/60/90d`) & Squash-Merge-resilient line retention, and exit-code-aware burn forensics.*
30
30
 
31
31
  ![TokenBlame Overview — Shareable Redacted Edition](docs/assets/tokenblame-overview.png)
32
32
 
@@ -42,12 +42,12 @@ Token accounting, commit attribution, and code survival each have strong existin
42
42
  | **`Git AI` (OSS / Teams)** | Line-level AI authorship + Teams PR cost, rework & churn analytics | Yes (spec covers buckets & 90d DB; team analytics in Teams tier) | Line-level authorship + PR cost/churn | Git notes / metadata | Rust / Cloud |
43
43
  | **`Entire`** | Session checkpoints & token hotspot diagnostics | Yes (`fresh` / `cache` / `output` / `subagent`) | Session checkpoints linked to commits | Checkpoint metadata | Go |
44
44
  | **`survived`** | Fixed-horizon `t+30/60/90d` code survival (with `notYet` cohort separation) | No | Fixed-horizon commit survival | None | TypeScript |
45
- | **`TokenBlame` (`v2.1`)** | **Local offline multi-agent cost + commit provenance + HEAD retention + burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert & HEAD line retention** | **None** | **Python 3.11+ stdlib only** |
45
+ | **`TokenBlame` (`v2.2`)** | **Local offline multi-agent cost + commit provenance + `t+30/60/90d` cohorts & HEAD retention + exit-code burn loops** | **Yes** (4-bucket + strict unbucketed separation) | **Out-of-repo `record-hook` spool + revert, HEAD retention & matured cohorts (`notYet` separated)** | **None** | **Python 3.11+ stdlib only** |
46
46
 
47
47
  > **Honest measurement scope:**
48
- > - **HEAD Line Retention (`line_survival_30d_pct`):** Measures what fraction of sampled lines added by AI-attributed commits from the **recent 30-day window** remain at `HEAD` (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate when `git blame` fails). It is **not** yet a fixed-horizon `t+30d` matured cohort score.
48
+ > - **HEAD Line Retention vs. Fixed-Horizon Cohorts (`t+30/60/90d`):** `line_survival_30d_pct` tracks HEAD retention of lines from the recent 30-day window (with Squash-Merge / Rebase fallback and `unobserved_lines` kept separate on `git blame` errors). Alongside it, `durability.cohorts` (`t30d`, `t60d`, `t90d`) measures **matured** fixed-horizon cohorts explicitly separated from immature `notYet` commits.
49
49
  > - **Pre-Indexed Query Latency (`3.5ms`):** Refers specifically to filtered `tokenblame summary` reads against an already-built `observatory.sqlite`, not cold full-history harvesting or `git blame` scans.
50
- > - **Diagnostic Signals ≠ Causal Proof:** `RETRY_LOOP`, uncommitted high-burn sessions, and HEAD line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
50
+ > - **Diagnostic Signals ≠ Causal Proof:** `FAILURE_LOOP` (nonzero exit/error streaks), `ITERATION_LOOP` (zero-error verification repeats), uncommitted high-burn sessions, and line retention are investigative signals — not automatic proofs of wasted effort, code correctness, or causal ROI.
51
51
 
52
52
  ---
53
53
 
@@ -55,7 +55,7 @@ Token accounting, commit attribution, and code survival each have strong existin
55
55
 
56
56
  ![TokenBlame Heatmap and High-Burn Forensics Radar](docs/assets/tokenblame-radar.png)
57
57
 
58
- - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and automatic loop warnings (`RETRY_LOOP(Edit x132)`, `RETRY_LOOP(Bash:pytest x9)`) using an allowlist of tool/command basenames — **never** storing command arguments, file paths, or prompts.
58
+ - **Allowlisted Tool Forensics (Zero Leakage):** Extracts peak turn spikes (`Peak #T: Out / Fresh`) and exit-code-aware loop classifications (`FAILURE_LOOP(Bash:pytest x6, err=4)` vs normal `ITERATION_LOOP(Bash:pytest x4)`) using an allowlist of tool/command basenames — **never** storing command arguments, stdout/stderr, file paths, or prompts.
59
59
  - **Privacy-Sealed `--shareable` Mode:** `tokenblame build --shareable` produces a standalone offline HTML dashboard (`shareable-observatory.html`) with salted SHA-256 aliases (`repo-01`, `c-9a4f1b2c`) and **zero** local paths, usernames, or commit subjects.
60
60
 
61
61
  ---
File without changes
File without changes
File without changes