agent-bios 0.19.4 → 0.20.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 (158) hide show
  1. package/DEPENDENCIES.md +19 -5
  2. package/README.md +14 -19
  3. package/claude/agents/frontier.md +1 -1
  4. package/claude/guides/claude-prompting.md +475 -234
  5. package/claude/guides/cli-multi-model-workflow.md +4 -3
  6. package/claude/guides/gpt-prompting.md +235 -136
  7. package/claude/guides/session-distill-workflow.md +93 -43
  8. package/claude/guides/tooling-gotchas.md +3 -1
  9. package/codex/guides/claude-prompting.md +475 -234
  10. package/codex/guides/cli-multi-model-workflow.md +4 -3
  11. package/codex/guides/gpt-prompting.md +235 -136
  12. package/codex/guides/session-distill-workflow.md +93 -43
  13. package/codex/guides/tooling-gotchas.md +3 -1
  14. package/compose/assemble.py +4 -1
  15. package/compose/canary.sh +8 -6
  16. package/compose/host_platform.py +158 -15
  17. package/compose/instructions-state.py +183 -41
  18. package/compose/instructions_install.py +222 -27
  19. package/compose/instructions_session.py +250 -75
  20. package/compose/instructions_setup_cli.py +2 -36
  21. package/compose/instructions_store.py +160 -3
  22. package/compose/instructions_transaction.py +29 -5
  23. package/docs/advanced-launch.md +4 -0
  24. package/docs/releases/0.20.0.md +102 -0
  25. package/install.sh +42 -14
  26. package/launch/agent-launch.py +152 -18
  27. package/launch/agent-launch.toml +17 -7
  28. package/launch/agent-launch.zsh +104 -13
  29. package/launch/claude_subcommands.py +179 -0
  30. package/launch/shell_integration.py +7 -1
  31. package/learn/collect-learning.py +60 -9
  32. package/learn/migrate-learnings.py +70 -4
  33. package/learn/redact.py +2 -1
  34. package/package.json +36 -3
  35. package/provenance.json +1 -1
  36. package/session-cost.py +80 -9
  37. package/session-distill/coverage.json +6 -0
  38. package/session-distill/distill.py +2575 -0
  39. package/session-distill/grammar/__init__.py +0 -0
  40. package/session-distill/grammar/owner_lines.py +874 -0
  41. package/session-distill/originators.json +9 -0
  42. package/session-distill/packets/cross_review.md +31 -0
  43. package/session-distill/packets/form.md +86 -0
  44. package/session-distill/packets/judge.md +81 -0
  45. package/session-distill/packets/placement_contract.md +90 -0
  46. package/session-distill/packets/propose.md +124 -0
  47. package/session-distill/packets/read.md +57 -0
  48. package/session-distill/packets/reconsider.md +53 -0
  49. package/session-distill/packets/s7b.md +65 -0
  50. package/session-distill/packets/s9b.md +39 -0
  51. package/session-distill/packets/stitch.md +35 -0
  52. package/session-distill/packets/sweep.md +33 -0
  53. package/session-distill/runlib/__init__.py +0 -0
  54. package/session-distill/runlib/bound.py +1102 -0
  55. package/session-distill/runlib/breaker.py +467 -0
  56. package/session-distill/runlib/census.py +2347 -0
  57. package/session-distill/runlib/claims.py +420 -0
  58. package/session-distill/runlib/controls.py +902 -0
  59. package/session-distill/runlib/coverage.py +881 -0
  60. package/session-distill/runlib/declare.py +888 -0
  61. package/session-distill/runlib/delivery_evidence.py +1145 -0
  62. package/session-distill/runlib/derive.py +812 -0
  63. package/session-distill/runlib/destinations.py +3072 -0
  64. package/session-distill/runlib/dispatch.py +7939 -0
  65. package/session-distill/runlib/drift.py +1077 -0
  66. package/session-distill/runlib/entry.py +401 -0
  67. package/session-distill/runlib/evidence.py +890 -0
  68. package/session-distill/runlib/exposure.py +1162 -0
  69. package/session-distill/runlib/gate.py +2727 -0
  70. package/session-distill/runlib/gitread.py +79 -0
  71. package/session-distill/runlib/inventory.py +19624 -0
  72. package/session-distill/runlib/journal.py +1919 -0
  73. package/session-distill/runlib/ledger.py +3210 -0
  74. package/session-distill/runlib/ledger_compat.py +101 -0
  75. package/session-distill/runlib/ledger_migration.py +190 -0
  76. package/session-distill/runlib/lifecycle_intake.py +693 -0
  77. package/session-distill/runlib/lineage.py +454 -0
  78. package/session-distill/runlib/measures.py +249 -0
  79. package/session-distill/runlib/monitor.py +1180 -0
  80. package/session-distill/runlib/operations.py +522 -0
  81. package/session-distill/runlib/packet.py +838 -0
  82. package/session-distill/runlib/placement.py +1769 -0
  83. package/session-distill/runlib/projection.py +4090 -0
  84. package/session-distill/runlib/ranking.py +740 -0
  85. package/session-distill/runlib/receipts.py +200 -0
  86. package/session-distill/runlib/records.py +1965 -0
  87. package/session-distill/runlib/search.py +249 -0
  88. package/session-distill/runlib/sequencing.py +829 -0
  89. package/session-distill/runlib/sources.py +641 -0
  90. package/session-distill/runlib/stage_adjudicate.py +845 -0
  91. package/session-distill/runlib/stage_apply.py +1378 -0
  92. package/session-distill/runlib/stage_approvals.py +758 -0
  93. package/session-distill/runlib/stage_close.py +1220 -0
  94. package/session-distill/runlib/stage_confirm.py +929 -0
  95. package/session-distill/runlib/stage_delivery.py +3080 -0
  96. package/session-distill/runlib/stage_form.py +2576 -0
  97. package/session-distill/runlib/stage_judge.py +4248 -0
  98. package/session-distill/runlib/stage_propose.py +3307 -0
  99. package/session-distill/runlib/stage_read.py +5179 -0
  100. package/session-distill/runlib/stage_render.py +2739 -0
  101. package/session-distill/runlib/stage_retrieve.py +924 -0
  102. package/session-distill/runlib/stage_review_korean.py +1002 -0
  103. package/session-distill/runlib/stage_review_proposals.py +1292 -0
  104. package/session-distill/runlib/stagelock.py +412 -0
  105. package/session-distill/runlib/stop.py +1061 -0
  106. package/session-distill/runlib/targets.py +809 -0
  107. package/session-distill/runlib/usage.py +280 -0
  108. package/session-distill/runlib/validate.py +319 -0
  109. package/session-distill/runlib/views.py +4327 -0
  110. package/session-distill/schemas/adjudication.schema.json +35 -0
  111. package/session-distill/schemas/approval.schema.json +35 -0
  112. package/session-distill/schemas/census.schema.json +128 -0
  113. package/session-distill/schemas/checks.schema.json +207 -0
  114. package/session-distill/schemas/claim.schema.json +16 -0
  115. package/session-distill/schemas/confirmation.schema.json +24 -0
  116. package/session-distill/schemas/coverage.schema.json +66 -0
  117. package/session-distill/schemas/cross_review.schema.json +24 -0
  118. package/session-distill/schemas/event.schema.json +20 -0
  119. package/session-distill/schemas/evidence.schema.json +20 -0
  120. package/session-distill/schemas/expected_observation.schema.json +18 -0
  121. package/session-distill/schemas/form.schema.json +103 -0
  122. package/session-distill/schemas/intake.schema.json +71 -0
  123. package/session-distill/schemas/inventory.schema.json +872 -0
  124. package/session-distill/schemas/judge.schema.json +77 -0
  125. package/session-distill/schemas/ledger.schema.json +313 -0
  126. package/session-distill/schemas/observation.schema.json +16 -0
  127. package/session-distill/schemas/propose.schema.json +555 -0
  128. package/session-distill/schemas/read.schema.json +76 -0
  129. package/session-distill/schemas/reconsider.schema.json +122 -0
  130. package/session-distill/schemas/run.schema.json +150 -0
  131. package/session-distill/schemas/s7b.schema.json +200 -0
  132. package/session-distill/schemas/s9b.schema.json +28 -0
  133. package/session-distill/schemas/stitch.schema.json +25 -0
  134. package/session-distill/schemas/sweep.schema.json +25 -0
  135. package/session-distill/seats.json +149 -0
  136. package/session-distill/tables/allowed_pairs.json +257 -0
  137. package/session-distill/tables/controls.json +30 -0
  138. package/session-distill/tables/delivery_evidence.json +36 -0
  139. package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
  140. package/session-distill/tables/destinations.json +684 -0
  141. package/session-distill/tables/drift_layers.json +68 -0
  142. package/session-distill/tables/exposure_rules.json +192 -0
  143. package/session-distill/tables/placement_rules.json +148 -0
  144. package/session-distill/tables/propose_fixtures.json +154 -0
  145. package/session-distill/tables/ranking.json +194 -0
  146. package/session-distill/tables/redundancy.json +10 -0
  147. package/session-distill/tables/structural_rules.json +44 -0
  148. package/session-distill/tables/transition_fixtures.json +398 -0
  149. package/session-distill/tables/transitions.json +69 -0
  150. package/session-distill/tables/unit_outcome.json +67 -0
  151. package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
  152. package/wrappers/claude-run.sh +481 -33
  153. package/wrappers/claude_hermetic_evidence.py +1423 -0
  154. package/wrappers/codex-helm.sh +38 -7
  155. package/wrappers/codex-run.sh +183 -20
  156. package/wrappers/codex_frame_filter.py +1199 -0
  157. package/wrappers/codex_protocol.py +737 -0
  158. package/wrappers/jsonl_lines.py +65 -0
@@ -639,17 +639,40 @@ def print_upload_summary(s):
639
639
  f"pending={s['pending']}{tail}")
640
640
 
641
641
 
642
+ def drain_under_lock(destination, drain):
643
+ """Run `drain` holding the host's upload lock, so two captures never drain one queue at once. The
644
+ wait is bounded (host_platform.lock_within): past it the drain is not run and the lock is named;
645
+ the learning is already captured, and the next drain sends it."""
646
+ if str(REPO / "compose") not in sys.path:
647
+ sys.path.insert(0, str(REPO / "compose"))
648
+ from host_platform import LockWaitExpired, lock_within
649
+ lock = destination / 'upload.lock'
650
+ fd = os.open(lock, os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
651
+ with os.fdopen(fd, 'a') as handle:
652
+ try:
653
+ lock_within(handle, f"the learning upload lock ({lock})")
654
+ except LockWaitExpired as exc:
655
+ print(f" upload -> NOT RUN: {exc}; the record is captured and stays queued for the next "
656
+ f"learn!", file=sys.stderr)
657
+ return None
658
+ return drain()
659
+
660
+
642
661
  def _self_test():
643
662
  """Socket-free verification of the drain: status classification, watermark
644
663
  advance, transient-stop (no storm), permanent-drop, no-token skip, poison
645
664
  line, plus capture-time redaction wiring. Injects post_fn/now; exits
646
665
  non-zero on any failure."""
666
+ import atexit
647
667
  import tempfile
648
668
 
649
669
  # One scratch tree for the whole run, removed at the end: every mkdtemp here
650
670
  # used to survive the process, and the gate that calls this ran on every
651
- # commit — 10k directories before anyone counted.
671
+ # commit — 10k directories before anyone counted. Removed again when the
672
+ # process ends, however it ends: a run that raises never reaches the last
673
+ # line, and the seam-coverage gate runs this suite on mutated copies.
652
674
  scratch = pathlib.Path(tempfile.mkdtemp(prefix="learn-selftest-"))
675
+ atexit.register(shutil.rmtree, scratch, True)
653
676
  made = {"n": 0}
654
677
 
655
678
  def scratch_dir(tag):
@@ -1135,6 +1158,37 @@ def _self_test():
1135
1158
  checks.append(("post limit is a hard cap",
1136
1159
  capped["n"] == 1 and s["uploaded"] == 1 and s["reason"] == "limit"))
1137
1160
 
1161
+ # 18) a drain behind an upload lock held past the bound is not run, and the lock is named — the
1162
+ # writer used to wait on it with no deadline. The bounds are scaled; the holder is a child
1163
+ # that lets go after 8 s, so a drain that waits without a bound runs late and fails here.
1164
+ import contextlib
1165
+ import io
1166
+ import subprocess
1167
+ if str(REPO / "compose") not in sys.path:
1168
+ sys.path.insert(0, str(REPO / "compose"))
1169
+ import host_platform
1170
+ held_dir = scratch_dir("held-upload")
1171
+ holder = subprocess.Popen([sys.executable, "-c", "import fcntl, sys, time; f = open(sys.argv[1], 'a'); "
1172
+ "fcntl.flock(f, fcntl.LOCK_EX); print('held', flush=True); time.sleep(8)",
1173
+ str(held_dir / "upload.lock")], stdout=subprocess.PIPE, text=True)
1174
+ saved = (host_platform.LOCK_WAIT_S, host_platform.LOCK_NOTICE_S)
1175
+ drained = {"n": 0}
1176
+ said = io.StringIO()
1177
+ try:
1178
+ holder.stdout.readline()
1179
+ host_platform.LOCK_WAIT_S, host_platform.LOCK_NOTICE_S = 0.6, 0.2
1180
+ with contextlib.redirect_stderr(said):
1181
+ outcome = drain_under_lock(held_dir, lambda: drained.update(n=1) or {"status": "ok"})
1182
+ finally:
1183
+ host_platform.LOCK_WAIT_S, host_platform.LOCK_NOTICE_S = saved
1184
+ holder.kill()
1185
+ holder.wait()
1186
+ holder.stdout.close()
1187
+ checks.append(("a drain behind a held upload lock is not run and names the lock",
1188
+ outcome is None and drained["n"] == 0
1189
+ and f"the learning upload lock ({held_dir / 'upload.lock'}) is still held after 0.6 s" in said.getvalue()
1190
+ and "waiting for the learning upload lock" in said.getvalue()))
1191
+
1138
1192
  shutil.rmtree(scratch, ignore_errors=True)
1139
1193
  failed = [name for name, ok in checks if not ok]
1140
1194
  if failed:
@@ -1195,14 +1249,11 @@ def main():
1195
1249
  result = store.capture_learning(host, record)
1196
1250
  print(f"collect-learning: OK host={host} learning_id={result['learning_id']} · private source; future activated sessions")
1197
1251
  if not args.no_upload:
1198
- import fcntl
1199
- lock = destination / 'upload.lock'
1200
- fd = os.open(lock, os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
1201
- with os.fdopen(fd, 'a') as handle:
1202
- fcntl.flock(handle, fcntl.LOCK_EX)
1203
- print_upload_summary(drain_uploads(
1204
- home, jsonl_path=destination / 'events.jsonl',
1205
- state_path=destination / 'upload-state.json'))
1252
+ summary = drain_under_lock(destination, lambda: drain_uploads(
1253
+ home, jsonl_path=destination / 'events.jsonl',
1254
+ state_path=destination / 'upload-state.json'))
1255
+ if summary is not None:
1256
+ print_upload_summary(summary)
1206
1257
  return
1207
1258
  bullet = prose_bullet(record)
1208
1259
  jsonl = append_record(home, record, dry)
@@ -75,6 +75,18 @@ def _load(name, filename):
75
75
  return module
76
76
 
77
77
 
78
+ def load_jsonl():
79
+ """wrappers/jsonl_lines.py, in this package root: a JSONL record ends at "\n" or "\r\n"
80
+ only, read from the file's bytes (single source)."""
81
+ path = REPO / "wrappers" / "jsonl_lines.py"
82
+ if not path.is_file():
83
+ die(f"the JSONL splitter is missing: {path}")
84
+ spec = importlib.util.spec_from_file_location("jsonl_lines", path)
85
+ module = importlib.util.module_from_spec(spec)
86
+ spec.loader.exec_module(module)
87
+ return module
88
+
89
+
78
90
  def load_collect():
79
91
  """Reuse collect-learning.py's host/home/marker constants (single source)."""
80
92
  return _load("collect_learning", "collect-learning.py")
@@ -212,7 +224,7 @@ def prune_jsonl(jsonl, remove_ids, dry):
212
224
  if not jsonl.is_file():
213
225
  return 0
214
226
  kept, removed = [], 0
215
- for line in jsonl.read_text(encoding="utf-8").splitlines():
227
+ for line, terminator in load_jsonl().read_terminated(jsonl):
216
228
  s = line.strip()
217
229
  if s:
218
230
  try:
@@ -222,9 +234,10 @@ def prune_jsonl(jsonl, remove_ids, dry):
222
234
  continue
223
235
  except json.JSONDecodeError:
224
236
  pass # keep malformed lines untouched
225
- kept.append(line)
237
+ kept.append(line + terminator)
226
238
  if removed and not dry:
227
- atomic_write(jsonl, "\n".join(kept) + ("\n" if kept else ""))
239
+ # bytes, so no newline translation (Windows text mode) touches a kept line's own terminator
240
+ atomic_write(jsonl, "".join(kept).encode("utf-8"))
228
241
  return removed
229
242
 
230
243
 
@@ -327,7 +340,7 @@ def migrate(home, host, promotions, in_bundle, collect, dry=False, instructions_
327
340
  jsonl = home / "personal" / "learnings.jsonl"
328
341
  local_ids = set()
329
342
  if jsonl.is_file():
330
- for line in jsonl.read_text(encoding="utf-8").splitlines():
343
+ for line in load_jsonl().read(jsonl):
331
344
  s = line.strip()
332
345
  if not s:
333
346
  continue
@@ -461,8 +474,15 @@ def _self_test():
461
474
  user's bundle), removal of an in-bundle promotion from BOTH prose + jsonl,
462
475
  idempotency, and that the user's own '## Personal' text is untouched. Uses
463
476
  collect-learning's own writers so the seeded format is authoritative."""
477
+ import atexit
478
+ import shutil
464
479
  import tempfile
465
480
 
481
+ # Every scratch home below is made inside one root, removed when the process ends however it ends: the
482
+ # homes used to outlive it, sixteen directories per umbrella run.
483
+ tempfile.tempdir = tempfile.mkdtemp(prefix="migrate-selftest-root-")
484
+ atexit.register(shutil.rmtree, tempfile.tempdir, True)
485
+
466
486
  collect = load_collect()
467
487
 
468
488
  def rec(lid, domain):
@@ -699,6 +719,52 @@ def _self_test():
699
719
  valid.write_text('{"version": 2, "promotions": [{"learning_id": "x"}]}', encoding="utf-8")
700
720
  checks.append(("a real manifest still loads", len(load_manifest(valid)) == 1))
701
721
 
722
+ # a learnings.jsonl record ends at "\n" only; collect-learning writes U+2028 and U+2029 raw
723
+ # (ensure_ascii=False), and str.splitlines() would cut the record there
724
+ sep = "before\u2028between\u2029after"
725
+ sep_dir = pathlib.Path(tempfile.mkdtemp(prefix="migrate-jsonl-"))
726
+ kept_line = json.dumps(dict(rec(L["off"], "office-work"), lesson=sep), ensure_ascii=False)
727
+ (sep_dir / "learnings.jsonl").write_text(kept_line + "\n" + json.dumps(rec(L["core"], "core")) + "\n", encoding="utf-8")
728
+ pruned = prune_jsonl(sep_dir / "learnings.jsonl", {L["core"]}, dry=False)
729
+ checks.append(("jsonl-line-separators-inside-a-string-read-whole (prune_jsonl): the kept record is byte for byte",
730
+ pruned == 1 and (sep_dir / "learnings.jsonl").read_text(encoding="utf-8") == kept_line + "\n"))
731
+ # a bare CR is JSON whitespace, which text-mode reading would turn into a line break; a CRLF record stays CRLF
732
+ cr_line = "{\r" + json.dumps(rec(L["off"], "office-work"))[1:]
733
+ (sep_dir / "learnings.jsonl").write_bytes((cr_line + "\r\n" + json.dumps(rec(L["core"], "core")) + "\n").encode("utf-8"))
734
+ pruned = prune_jsonl(sep_dir / "learnings.jsonl", {L["core"]}, dry=False)
735
+ checks.append(("jsonl-bare-cr-whitespace-and-crlf-read-whole (prune_jsonl): the kept record is byte for byte",
736
+ pruned == 1 and (sep_dir / "learnings.jsonl").read_bytes() == (cr_line + "\r\n").encode("utf-8")))
737
+ # the rewrite keeps each line's own terminator under Windows text-mode writing too, which
738
+ # turns every "\n" written as text into "\r\n"
739
+ from unittest import mock
740
+ real_write_text = pathlib.Path.write_text
741
+
742
+ def windows_write_text(self, data, encoding=None, errors=None, newline=None):
743
+ return real_write_text(self, data.replace("\n", "\r\n") if newline is None else data,
744
+ encoding=encoding, errors=errors, newline=newline)
745
+ lf_line = json.dumps(rec(L["bb"], "builder-base"))
746
+ (sep_dir / "learnings.jsonl").write_bytes((cr_line + "\r\n" + lf_line + "\n" + json.dumps(rec(L["core"], "core")) + "\n")
747
+ .encode("utf-8"))
748
+ with mock.patch.object(pathlib.Path, "write_text", windows_write_text):
749
+ pruned = prune_jsonl(sep_dir / "learnings.jsonl", {L["core"]}, dry=False)
750
+ checks.append(("jsonl-rewrite-keeps-each-terminator-under-windows-newline-translation (prune_jsonl)",
751
+ pruned == 1 and (sep_dir / "learnings.jsonl").read_bytes()
752
+ == (cr_line + "\r\n" + lf_line + "\n").encode("utf-8")))
753
+ home = seed_claude()
754
+ jsonl = home / "personal" / "learnings.jsonl"
755
+ jsonl.write_text("".join(json.dumps(dict(json.loads(line), lesson=sep), ensure_ascii=False) + "\n"
756
+ for line in jsonl.read_text(encoding="utf-8").split("\n") if line), encoding="utf-8")
757
+ s = migrate(home, "claude", promos, make_in_bundle(["builder-base"]), collect)
758
+ checks.append(("jsonl-line-separators-inside-a-string-read-whole (migrate): every record's id is held locally",
759
+ s["removed"] == 2 and s["kept_not_in_bundle"] == 1))
760
+ home = seed_claude()
761
+ jsonl = home / "personal" / "learnings.jsonl"
762
+ jsonl.write_bytes("".join("{\r" + json.dumps(json.loads(line))[1:] + "\r\n"
763
+ for line in jsonl.read_text(encoding="utf-8").split("\n") if line).encode("utf-8"))
764
+ s = migrate(home, "claude", promos, make_in_bundle(["builder-base"]), collect)
765
+ checks.append(("jsonl-bare-cr-whitespace-and-crlf-read-whole (migrate): every record's id is held locally",
766
+ s["removed"] == 2 and s["kept_not_in_bundle"] == 1))
767
+
702
768
  failed = [n for n, ok in checks if not ok]
703
769
  if failed:
704
770
  for n in failed:
package/learn/redact.py CHANGED
@@ -3,7 +3,8 @@
3
3
 
4
4
  Both flows that egress session-derived text redact through here, so the floor
5
5
  is single-sourced (concept economy) rather than duplicated per call site:
6
- * heavy flow — session-distill/digest.py (per-session digests);
6
+ * heavy flow — session-distill/runlib/projection.py (the driver's transcript
7
+ views; it loads this module by path, never a copy of its patterns);
7
8
  * light flow — learn/collect-learning.py (`learn!` prose + upload + the
8
9
  curator export downstream, since the server stores what it receives —
9
10
  redaction that does not happen HERE cannot be undone there).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-bios",
3
- "version": "0.19.4",
4
- "releaseDate": "2026-11-03",
3
+ "version": "0.20.0",
4
+ "releaseDate": "2026-11-17",
5
5
  "description": "A thin, low-level instruction layer for LLM CLI agents: one set of principles and behavior whichever model you run. Stores private, editable instructions for explicitly activated sessions.",
6
6
  "bin": {
7
7
  "agent-bios": "install.sh"
@@ -23,6 +23,7 @@
23
23
  "learn/learning.schema.json",
24
24
  "learn/promotions.json",
25
25
  "launch/agent-launch.zsh",
26
+ "launch/claude_subcommands.py",
26
27
  "launch/agent-launch.py",
27
28
  "launch/shell_integration.py",
28
29
  "compose/pkgid.py",
@@ -75,11 +76,39 @@
75
76
  "learn/migrate-learnings.py",
76
77
  "learn/redact.py",
77
78
  "wrappers/codex-run.sh",
79
+ "wrappers/codex_frame_filter.py",
80
+ "wrappers/codex_protocol.py",
78
81
  "wrappers/codex-helm.sh",
79
82
  "wrappers/claude-run.sh",
83
+ "wrappers/claude_hermetic_evidence.py",
84
+ "wrappers/jsonl_lines.py",
80
85
  "install.sh",
81
86
  "launch/provision-venv.sh",
82
87
  "session-cost.py",
88
+ "session-distill/distill.py",
89
+ "session-distill/runlib/",
90
+ "session-distill/grammar/",
91
+ "session-distill/schemas/",
92
+ "session-distill/tables/redundancy.json",
93
+ "session-distill/tables/transition_fixtures.json",
94
+ "session-distill/tables/allowed_pairs.json",
95
+ "session-distill/tables/destinations.json",
96
+ "session-distill/tables/drift_layers.json",
97
+ "session-distill/tables/exposure_rules.json",
98
+ "session-distill/tables/structural_rules.json",
99
+ "session-distill/tables/placement_rules.json",
100
+ "session-distill/tables/ranking.json",
101
+ "session-distill/tables/propose_fixtures.json",
102
+ "session-distill/tables/transitions.json",
103
+ "session-distill/tables/controls.json",
104
+ "session-distill/tables/delivery_evidence.json",
105
+ "session-distill/tables/delivery_evidence_fixtures.json",
106
+ "session-distill/tables/unit_outcome.json",
107
+ "session-distill/tables/unit_outcome_fixtures.json",
108
+ "session-distill/packets/",
109
+ "session-distill/seats.json",
110
+ "session-distill/originators.json",
111
+ "session-distill/coverage.json",
83
112
  "docs/",
84
113
  "README.md",
85
114
  "INSTALL.md",
@@ -88,7 +117,11 @@
88
117
  "compose/native_cli.py",
89
118
  "compose/host_platform.py",
90
119
  "compose/runtime_entry.py",
91
- "compose/windows_deploy.py"
120
+ "compose/windows_deploy.py",
121
+ "!**/__pycache__",
122
+ "!**/__pycache__/**",
123
+ "!**/*.pyc",
124
+ "!**/*.pyo"
92
125
  ],
93
126
  "scripts": {
94
127
  "postinstall": "printf '\\n> agent-bios installed. Deploy into this environment with: agent-bios install\\n> Then: agent-bios verify | status | uninstall\\n\\n'",
package/provenance.json CHANGED
@@ -1 +1 @@
1
- {"commit":"cd424da6d7b2ae7f5ba34158bd1ae01383a5be72","committedAt":"2026-11-03T17:09:20+09:00","dirty":false}
1
+ {"commit":"9cfe7f54af3e841e9739e30072c16c98a76b187d","committedAt":"2026-11-17T13:30:35+09:00","dirty":false}
package/session-cost.py CHANGED
@@ -25,8 +25,17 @@ from datetime import datetime, timezone
25
25
  # Whole table re-read against the vendor pricing page on 2026-10-21. That pass added the
26
26
  # 5.5 generation and corrected `claude-sonnet-5`, which carried Sonnet 4.6's rates — it
27
27
  # had been overcharging every Sonnet 5 session by half since it was written.
28
+ # `claude-fable-5-2` added 2026-11-11 from the same page — the vendor's platform docs at
29
+ # `about-claude/pricing`, named without its URL because `gates/check-endpoints.py` forbids a
30
+ # shipped file from carrying one. Its "Model pricing" table
31
+ # reads base input / 5m cache writes / 1h cache writes / cache hits / output — NOT this
32
+ # tuple's order, so the row is reordered rather than copied across. The generation's cache
33
+ # hit is 0.025x base input, which is why it reads cheaper per cached token than Opus 5.5 on
34
+ # a dearer model. The page prices Mythos 5.2 identically; no Mythos row past `claude-mythos-5`
35
+ # is carried here, so a Mythos session reports unpriced rather than at a guessed rate.
28
36
  PRICES = {
29
37
  "claude-fable-5": (10.0, 50.0, 1.00, 12.50, 20.0),
38
+ "claude-fable-5-2": (8.0, 40.0, 0.20, 10.0, 16.0),
30
39
  "claude-fable-5-1": (10.0, 50.0, 0.25, 12.50, 20.0),
31
40
  "claude-mythos-5": (10.0, 50.0, 1.00, 12.50, 20.0),
32
41
  "claude-opus-5-5": (4.0, 20.0, 0.20, 5.0, 8.0),
@@ -89,8 +98,19 @@ def moment(ts):
89
98
  return parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc)
90
99
 
91
100
 
101
+ # The usage keys this report reads. The vendor calls the transcript format internal and liable to
102
+ # change between versions, so a usage object carrying none of them is a moved format, not a free
103
+ # request: it is counted and named with the host version. A key added beside these is no alarm.
104
+ USAGE_KEYS = ("input_tokens", "output_tokens", "cache_read_input_tokens", "cache_creation_input_tokens",
105
+ "cache_creation")
106
+
107
+
92
108
  def scan(path):
93
- """-> {(scope, model): {in,out,cr,cw5,cw1,turns}}, (t_min, t_max), {scope: agent_ids}
109
+ """-> {(scope, model): {in,out,cr,cw5,cw1,turns}}, (t_min, t_max), {scope: agent_ids}, drift
110
+
111
+ `drift` is what the totals leave out: `unread`, the responses whose usage object carries none
112
+ of USAGE_KEYS, `versions`, the host versions those records name, and `bad_lines`, the lines
113
+ that are not JSON.
94
114
 
95
115
  A single API response is written to the transcript several times as it
96
116
  streams, each line carrying output_tokens *so far* (e.g. 2, 2, 2, 540).
@@ -100,17 +120,22 @@ def scan(path):
100
120
  """
101
121
  best, tmin, tmax = {}, None, None
102
122
  agents = {"main": set(), "sub": set()}
123
+ drift = {"unread": 0, "versions": set(), "bad_lines": 0}
103
124
  anonymous = itertools.count()
104
125
  try:
105
126
  handle = open(path, errors="replace")
106
127
  except OSError as exc:
107
128
  print(f"session-cost: cannot read {path}: {exc}", file=sys.stderr)
108
- return {}, (None, None), agents
129
+ return {}, (None, None), agents, drift
109
130
  with handle:
110
131
  for line in handle:
111
132
  try:
112
133
  d = json.loads(line)
113
134
  except json.JSONDecodeError:
135
+ drift["bad_lines"] += 1
136
+ continue
137
+ if not isinstance(d, dict):
138
+ drift["bad_lines"] += 1
114
139
  continue
115
140
  at = moment(d.get("timestamp"))
116
141
  if at is not None:
@@ -133,10 +158,13 @@ def scan(path):
133
158
  key = (scope, ident if ident else f"anonymous-{next(anonymous)}")
134
159
  prev = best.get(key)
135
160
  if prev is None or u.get("output_tokens", 0) > prev[1].get("output_tokens", 0):
136
- best[key] = (model, u)
161
+ best[key] = (model, u, d.get("version"))
137
162
 
138
163
  agg = {}
139
- for (scope, _), (model, u) in best.items():
164
+ for (scope, _), (model, u, version) in best.items():
165
+ if not any(k in u for k in USAGE_KEYS):
166
+ drift["unread"] += 1
167
+ drift["versions"].add(version if isinstance(version, str) and version else None)
140
168
  a = agg.setdefault((scope, model), dict(inp=0, out=0, cr=0, cw5=0, cw1=0, turns=0))
141
169
  a["inp"] += u.get("input_tokens", 0)
142
170
  a["out"] += u.get("output_tokens", 0)
@@ -148,7 +176,7 @@ def scan(path):
148
176
  else:
149
177
  a["cw5"] += u.get("cache_creation_input_tokens", 0)
150
178
  a["turns"] += 1
151
- return agg, (tmin, tmax), agents
179
+ return agg, (tmin, tmax), agents, drift
152
180
 
153
181
  def cost(model, a):
154
182
  p = price_for(model)
@@ -176,8 +204,12 @@ def report(session_path):
176
204
  f"{'cache_rd':>10}{'cache_wr':>10}{'cost$':>9}")
177
205
  print(hdr); print("-" * len(hdr))
178
206
  span_min = span_max = None
207
+ unread, versions, bad_lines = 0, set(), 0
179
208
  for label, path in sources:
180
- agg, (tmin, tmax), agents = scan(path)
209
+ agg, (tmin, tmax), agents, drift = scan(path)
210
+ unread += drift["unread"]
211
+ versions |= drift["versions"]
212
+ bad_lines += drift["bad_lines"]
181
213
  if tmin:
182
214
  span_min = min(span_min or tmin, tmin); span_max = max(span_max or tmax, tmax)
183
215
  for (scope, model), a in sorted(agg.items()):
@@ -205,6 +237,15 @@ def report(session_path):
205
237
  print(f"\nwall clock: no usable timestamps | modeled total cost: ${grand:,.2f}")
206
238
  if unpriced:
207
239
  print(f"WARN unpriced models: {set(unpriced)}")
240
+ if unread:
241
+ named = sorted(v for v in versions if v)
242
+ writer = ", ".join(f"Claude Code {v}" for v in named) + (", " if named and None in versions else "")
243
+ writer += "a record naming no host version" if None in versions else ""
244
+ print(f"WARN {unread} response(s) carry a usage object with none of the keys this report reads "
245
+ f"({', '.join(USAGE_KEYS)}), written by {writer}: the transcript format has moved, and the "
246
+ f"totals above count them as zero")
247
+ if bad_lines:
248
+ print(f"WARN {bad_lines} line(s) are not a JSON record and were skipped")
208
249
  for key in sorted(tiered_seen):
209
250
  print(f"NOTE {key}: {TIERED[key]}")
210
251
  return 0
@@ -418,7 +459,9 @@ def _self_test():
418
459
 
419
460
  def check(name, got, want):
420
461
  ok = got == want
421
- print(f" {'ok ' if ok else 'FAIL'} {name}" + ("" if ok else f" got {got!r} want {want!r}"))
462
+ # A failure goes to stderr too: the umbrella runs this quietly and shows stderr alone.
463
+ print(f" {'ok ' if ok else 'FAIL'} {name}" + ("" if ok else f" got {got!r} want {want!r}"),
464
+ file=sys.stdout if ok else sys.stderr)
422
465
  if not ok:
423
466
  failures.append(name)
424
467
 
@@ -450,7 +493,8 @@ def _self_test():
450
493
  with tempfile.TemporaryDirectory() as td:
451
494
  # A version-specific cache rate must reach the public report without
452
495
  # changing the older model's rate. Run the real CLI/scan/cost path.
453
- for model, expected in (("claude-fable-5-1", "$0.25"),
496
+ for model, expected in (("claude-fable-5-2", "$0.20"),
497
+ ("claude-fable-5-1", "$0.25"),
454
498
  ("claude-fable-5", "$1.00")):
455
499
  transcript = write(td, model + ".jsonl", [
456
500
  {"type": "assistant", "message": {
@@ -465,6 +509,32 @@ def _self_test():
465
509
  "modeled total cost: " + expected in result.stdout),
466
510
  (0, True))
467
511
 
512
+ # A usage key the vendor renames reads as zero. The report names how many responses it
513
+ # could not read and the host version that wrote them; a key added beside the known ones
514
+ # is no alarm; a line that is not JSON is counted, not skipped in silence.
515
+ def cost_report(name, records, raw=""):
516
+ path = write(td, name, records)
517
+ if raw:
518
+ with open(path, "a", encoding="utf-8") as fh:
519
+ fh.write(raw)
520
+ done = subprocess.run([sys.executable, os.path.abspath(__file__), path], capture_output=True, text=True)
521
+ return done.returncode, done.stdout
522
+ moved = [{"type": "assistant", "version": "9.9.9-planted", "message": {
523
+ "id": f"moved-{n}", "model": "claude-opus-5", "usage": {"inputTokens": 10, "outputTokens": 5}}}
524
+ for n in range(2)]
525
+ code, out = cost_report("moved.jsonl", moved)
526
+ check("a renamed usage key is reported by count and host version",
527
+ (code, "WARN 2 response(s) carry a usage object with none of the keys" in out, "9.9.9-planted" in out),
528
+ (0, True, True))
529
+ code, out = cost_report("added.jsonl", [{"type": "assistant", "version": "9.9.9-planted", "message": {
530
+ "id": "added", "model": "claude-opus-5",
531
+ "usage": {"input_tokens": 10, "output_tokens": 5, "planted_new_key": 3}}}])
532
+ check("a usage key added beside the known ones raises nothing", (code, "WARN" in out), (0, False))
533
+ code, out = cost_report("bad-line.jsonl", moved[:0] + [{"type": "assistant", "message": {
534
+ "id": "fine", "model": "claude-opus-5", "usage": {"input_tokens": 10}}}], raw="{not json\n")
535
+ check("a line that is not JSON is counted", (code, "WARN 1 line(s) are not a JSON record" in out),
536
+ (0, True))
537
+
468
538
  # Claude: two requests. The first is written twice as it streams, the
469
539
  # second is a sidechain that must not be counted.
470
540
  claude = write(td, "claude.jsonl", [
@@ -542,7 +612,8 @@ def _self_test():
542
612
  check("an unmeasurable transcript reports failure, not zero",
543
613
  context_report(empty), False)
544
614
 
545
- print("\nself-test: " + (f"{len(failures)} FAILED" if failures else "all passed"))
615
+ print("\nself-test: " + (f"{len(failures)} FAILED" if failures else "all passed"),
616
+ file=sys.stderr if failures else sys.stdout)
546
617
  return 1 if failures else 0
547
618
 
548
619
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "backlog": [],
3
+ "pending_events": [],
4
+ "transcripts": {},
5
+ "windows": {}
6
+ }