agent-bios 0.19.4 → 0.20.1

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 (162) hide show
  1. package/DEPENDENCIES.md +20 -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 +8 -7
  6. package/claude/guides/gpt-prompting.md +319 -144
  7. package/claude/guides/session-distill-workflow.md +93 -43
  8. package/claude/guides/tooling-gotchas.md +3 -1
  9. package/codex/agents/frontier.toml +1 -1
  10. package/codex/agents/reviewer.toml +1 -1
  11. package/codex/agents/workhorse.toml +1 -1
  12. package/codex/guides/claude-prompting.md +475 -234
  13. package/codex/guides/cli-multi-model-workflow.md +8 -7
  14. package/codex/guides/gpt-prompting.md +319 -144
  15. package/codex/guides/session-distill-workflow.md +93 -43
  16. package/codex/guides/tooling-gotchas.md +3 -1
  17. package/compose/assemble.py +4 -1
  18. package/compose/canary.sh +8 -6
  19. package/compose/host_platform.py +158 -15
  20. package/compose/instructions-state.py +183 -41
  21. package/compose/instructions_install.py +222 -27
  22. package/compose/instructions_session.py +250 -75
  23. package/compose/instructions_setup_cli.py +2 -36
  24. package/compose/instructions_store.py +160 -3
  25. package/compose/instructions_transaction.py +29 -5
  26. package/docs/advanced-launch.md +5 -1
  27. package/docs/releases/0.20.0.md +102 -0
  28. package/docs/releases/0.20.1.md +76 -0
  29. package/install.sh +42 -14
  30. package/launch/agent-launch.py +152 -18
  31. package/launch/agent-launch.toml +28 -16
  32. package/launch/agent-launch.zsh +104 -13
  33. package/launch/claude_subcommands.py +179 -0
  34. package/launch/shell_integration.py +7 -1
  35. package/learn/collect-learning.py +60 -9
  36. package/learn/migrate-learnings.py +70 -4
  37. package/learn/redact.py +2 -1
  38. package/package.json +36 -3
  39. package/provenance.json +1 -1
  40. package/session-cost.py +80 -9
  41. package/session-distill/coverage.json +6 -0
  42. package/session-distill/distill.py +2575 -0
  43. package/session-distill/grammar/__init__.py +0 -0
  44. package/session-distill/grammar/owner_lines.py +874 -0
  45. package/session-distill/originators.json +9 -0
  46. package/session-distill/packets/cross_review.md +31 -0
  47. package/session-distill/packets/form.md +86 -0
  48. package/session-distill/packets/judge.md +81 -0
  49. package/session-distill/packets/placement_contract.md +90 -0
  50. package/session-distill/packets/propose.md +124 -0
  51. package/session-distill/packets/read.md +57 -0
  52. package/session-distill/packets/reconsider.md +53 -0
  53. package/session-distill/packets/s7b.md +65 -0
  54. package/session-distill/packets/s9b.md +39 -0
  55. package/session-distill/packets/stitch.md +35 -0
  56. package/session-distill/packets/sweep.md +33 -0
  57. package/session-distill/runlib/__init__.py +0 -0
  58. package/session-distill/runlib/bound.py +1102 -0
  59. package/session-distill/runlib/breaker.py +467 -0
  60. package/session-distill/runlib/census.py +2347 -0
  61. package/session-distill/runlib/claims.py +420 -0
  62. package/session-distill/runlib/controls.py +902 -0
  63. package/session-distill/runlib/coverage.py +881 -0
  64. package/session-distill/runlib/declare.py +888 -0
  65. package/session-distill/runlib/delivery_evidence.py +1145 -0
  66. package/session-distill/runlib/derive.py +812 -0
  67. package/session-distill/runlib/destinations.py +3072 -0
  68. package/session-distill/runlib/dispatch.py +7940 -0
  69. package/session-distill/runlib/drift.py +1077 -0
  70. package/session-distill/runlib/entry.py +401 -0
  71. package/session-distill/runlib/evidence.py +890 -0
  72. package/session-distill/runlib/exposure.py +1162 -0
  73. package/session-distill/runlib/gate.py +2727 -0
  74. package/session-distill/runlib/gitread.py +79 -0
  75. package/session-distill/runlib/inventory.py +19624 -0
  76. package/session-distill/runlib/journal.py +1919 -0
  77. package/session-distill/runlib/ledger.py +3210 -0
  78. package/session-distill/runlib/ledger_compat.py +101 -0
  79. package/session-distill/runlib/ledger_migration.py +190 -0
  80. package/session-distill/runlib/lifecycle_intake.py +693 -0
  81. package/session-distill/runlib/lineage.py +454 -0
  82. package/session-distill/runlib/measures.py +249 -0
  83. package/session-distill/runlib/monitor.py +1180 -0
  84. package/session-distill/runlib/operations.py +522 -0
  85. package/session-distill/runlib/packet.py +838 -0
  86. package/session-distill/runlib/placement.py +1769 -0
  87. package/session-distill/runlib/projection.py +4090 -0
  88. package/session-distill/runlib/ranking.py +740 -0
  89. package/session-distill/runlib/receipts.py +200 -0
  90. package/session-distill/runlib/records.py +1965 -0
  91. package/session-distill/runlib/search.py +249 -0
  92. package/session-distill/runlib/sequencing.py +829 -0
  93. package/session-distill/runlib/sources.py +641 -0
  94. package/session-distill/runlib/stage_adjudicate.py +845 -0
  95. package/session-distill/runlib/stage_apply.py +1378 -0
  96. package/session-distill/runlib/stage_approvals.py +758 -0
  97. package/session-distill/runlib/stage_close.py +1220 -0
  98. package/session-distill/runlib/stage_confirm.py +929 -0
  99. package/session-distill/runlib/stage_delivery.py +3080 -0
  100. package/session-distill/runlib/stage_form.py +2576 -0
  101. package/session-distill/runlib/stage_judge.py +4248 -0
  102. package/session-distill/runlib/stage_propose.py +3307 -0
  103. package/session-distill/runlib/stage_read.py +5179 -0
  104. package/session-distill/runlib/stage_render.py +2739 -0
  105. package/session-distill/runlib/stage_retrieve.py +924 -0
  106. package/session-distill/runlib/stage_review_korean.py +1002 -0
  107. package/session-distill/runlib/stage_review_proposals.py +1292 -0
  108. package/session-distill/runlib/stagelock.py +412 -0
  109. package/session-distill/runlib/stop.py +1061 -0
  110. package/session-distill/runlib/targets.py +809 -0
  111. package/session-distill/runlib/usage.py +280 -0
  112. package/session-distill/runlib/validate.py +319 -0
  113. package/session-distill/runlib/views.py +4327 -0
  114. package/session-distill/schemas/adjudication.schema.json +35 -0
  115. package/session-distill/schemas/approval.schema.json +35 -0
  116. package/session-distill/schemas/census.schema.json +128 -0
  117. package/session-distill/schemas/checks.schema.json +207 -0
  118. package/session-distill/schemas/claim.schema.json +16 -0
  119. package/session-distill/schemas/confirmation.schema.json +24 -0
  120. package/session-distill/schemas/coverage.schema.json +66 -0
  121. package/session-distill/schemas/cross_review.schema.json +24 -0
  122. package/session-distill/schemas/event.schema.json +20 -0
  123. package/session-distill/schemas/evidence.schema.json +20 -0
  124. package/session-distill/schemas/expected_observation.schema.json +18 -0
  125. package/session-distill/schemas/form.schema.json +103 -0
  126. package/session-distill/schemas/intake.schema.json +71 -0
  127. package/session-distill/schemas/inventory.schema.json +872 -0
  128. package/session-distill/schemas/judge.schema.json +77 -0
  129. package/session-distill/schemas/ledger.schema.json +313 -0
  130. package/session-distill/schemas/observation.schema.json +16 -0
  131. package/session-distill/schemas/propose.schema.json +555 -0
  132. package/session-distill/schemas/read.schema.json +76 -0
  133. package/session-distill/schemas/reconsider.schema.json +122 -0
  134. package/session-distill/schemas/run.schema.json +150 -0
  135. package/session-distill/schemas/s7b.schema.json +200 -0
  136. package/session-distill/schemas/s9b.schema.json +28 -0
  137. package/session-distill/schemas/stitch.schema.json +25 -0
  138. package/session-distill/schemas/sweep.schema.json +25 -0
  139. package/session-distill/seats.json +149 -0
  140. package/session-distill/tables/allowed_pairs.json +257 -0
  141. package/session-distill/tables/controls.json +30 -0
  142. package/session-distill/tables/delivery_evidence.json +36 -0
  143. package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
  144. package/session-distill/tables/destinations.json +684 -0
  145. package/session-distill/tables/drift_layers.json +68 -0
  146. package/session-distill/tables/exposure_rules.json +192 -0
  147. package/session-distill/tables/placement_rules.json +148 -0
  148. package/session-distill/tables/propose_fixtures.json +154 -0
  149. package/session-distill/tables/ranking.json +194 -0
  150. package/session-distill/tables/redundancy.json +10 -0
  151. package/session-distill/tables/structural_rules.json +44 -0
  152. package/session-distill/tables/transition_fixtures.json +398 -0
  153. package/session-distill/tables/transitions.json +69 -0
  154. package/session-distill/tables/unit_outcome.json +67 -0
  155. package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
  156. package/wrappers/claude-run.sh +481 -33
  157. package/wrappers/claude_hermetic_evidence.py +1423 -0
  158. package/wrappers/codex-helm.sh +46 -15
  159. package/wrappers/codex-run.sh +183 -20
  160. package/wrappers/codex_frame_filter.py +1199 -0
  161. package/wrappers/codex_protocol.py +737 -0
  162. package/wrappers/jsonl_lines.py +65 -0
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env python3
2
+ """The receipt of one model call: `calls/<call_id>/receipt.json`, a ReviewReceipt/v1.
3
+
4
+ The receipt is written by the launcher's `--emit-receipt` (`launch/agent-launch.py
5
+ emit_receipt_command`), and its grammar is the launcher's: this module asks the launcher's own
6
+ `_raw_receipt_reason` whether a file is a raw ReviewReceipt/v1 at all, so the key set and the
7
+ exit-status rule have one owner. What distill adds is the binding to one call: the method id
8
+ is `distill/<stage>/<call_id>` (plan S-8), and `evidence` carries the keys of design §3.2 step
9
+ 1 — this call's id, the schema and payload hashes, the seat observed, the profile and its
10
+ flag-set hash, the working directory, the context-manifest and observed-context hashes, the
11
+ usage state and totals, the capture hash and the host's session or thread id. The packet and
12
+ result hashes and the seat sent are the launcher's own top-level fields.
13
+
14
+ This module checks presence and the binding to the call; whether each value EQUALS what the
15
+ call directory says is the gate's, which recomputes every one of them (gate.py).
16
+
17
+ Failures are named RECEIPT_MISSING (no readable receipt), RECORD_INTEGRITY (not a raw
18
+ ReviewReceipt/v1), RECEIPT_STALE (it belongs to another call) and RECEIPT_KEY_MISSING.
19
+
20
+ receipts.py --self-test
21
+ """
22
+ import importlib.util
23
+ import json
24
+ import pathlib
25
+ import sys
26
+
27
+ REPO = pathlib.Path(__file__).resolve().parents[2]
28
+ LAUNCHER = REPO / "launch" / "agent-launch.py"
29
+ # design §3.2 step 1's evidence list, plus payload_sha256 (plan WP-02, "Packet identity") and
30
+ # hermeticity (the contract-fix record of 2026-11-02 under design/contract-fix/, F-31: managed and
31
+ # server-delivered settings, D-20261102-6b6676 and D-20261102-252c92)
32
+ EVIDENCE_KEYS = ("call_id", "schema_sha256", "payload_sha256", "seat_observed", "profile", "profile_flags_sha256",
33
+ "cwd", "manifest_sha256", "context_observed_sha256", "usage_state", "usage_totals",
34
+ "capture_sha256", "session_id", "hermeticity")
35
+ # the launcher's top-level fields that design §3.2 also requires: packet and result hashes, the seat sent
36
+ TOP_KEYS = ("method_id", "dispatch_id", "packet_sha256", "result_sha256", "provider", "model", "effort", "exit_status")
37
+ _launcher = None
38
+
39
+
40
+ def launcher():
41
+ """`launch/agent-launch.py`, loaded once as a module (it is a script, not a package)."""
42
+ global _launcher
43
+ if _launcher is None:
44
+ spec = importlib.util.spec_from_file_location("distill_agent_launch", LAUNCHER)
45
+ module = importlib.util.module_from_spec(spec)
46
+ sys.modules[spec.name] = module # its dataclasses resolve their annotations through sys.modules
47
+ spec.loader.exec_module(module)
48
+ _launcher = module
49
+ return _launcher
50
+
51
+
52
+ def method_id(stage, call_id):
53
+ return f"distill/{stage}/{call_id}"
54
+
55
+
56
+ def read(call_dir):
57
+ """(receipt, violations): the parsed receipt object, and RECORD_INTEGRITY when it is not a
58
+ raw ReviewReceipt/v1. A structural defect does not hide the receipt: its binding and key set
59
+ are still judged (`problems`), so the failure set stays complete. None only when nothing
60
+ parses to an object."""
61
+ path = pathlib.Path(call_dir) / "receipt.json"
62
+ errors = []
63
+ try:
64
+ receipt = json.loads(path.read_text(encoding="utf-8"))
65
+ except (OSError, ValueError) as exc:
66
+ errors.append(f"RECEIPT_MISSING {path}: {exc.__class__.__name__}")
67
+ return None, errors
68
+ if not isinstance(receipt, dict):
69
+ errors.append("RECORD_INTEGRITY receipt: not an object")
70
+ return None, errors
71
+ reason = launcher()._raw_receipt_reason(receipt)
72
+ if reason:
73
+ errors.append(f"RECORD_INTEGRITY receipt: {reason}")
74
+ return receipt, errors
75
+
76
+
77
+ def problems(receipt, stage, call_id):
78
+ """Violations of the binding of `receipt` to call `call_id` of `stage`, and its key set."""
79
+ errors = []
80
+ if receipt.get("method_id") != method_id(stage, call_id):
81
+ errors.append(f"RECEIPT_STALE method_id {receipt.get('method_id')!r} is not {method_id(stage, call_id)!r}")
82
+ evidence = receipt.get("evidence") if isinstance(receipt.get("evidence"), dict) else {}
83
+ if evidence.get("call_id") != call_id and "call_id" in evidence:
84
+ errors.append(f"RECEIPT_STALE evidence.call_id {evidence.get('call_id')!r} is not this call {call_id!r}")
85
+ errors.extend(f"RECEIPT_KEY_MISSING {key}" for key in TOP_KEYS if key not in receipt)
86
+ errors.extend(f"RECEIPT_KEY_MISSING evidence.{key}" for key in EVIDENCE_KEYS if key not in evidence)
87
+ errors.extend(f"RECORD_INTEGRITY evidence.{key}: not a string" for key in EVIDENCE_KEYS
88
+ if key in evidence and not isinstance(evidence[key], str))
89
+ return errors
90
+
91
+
92
+ def self_test():
93
+ import os
94
+ import subprocess
95
+ import tempfile
96
+ failures, ran = [], []
97
+
98
+ def control(name, errors, *needles):
99
+ ran.append(name)
100
+ if not needles and errors:
101
+ failures.append(f"{name}: expected no violation, got {errors}")
102
+ for needle in needles:
103
+ if not any(needle in line for line in errors):
104
+ failures.append(f"{name}: expected {needle!r} in {errors}")
105
+
106
+ call_id, stage = "r1-S6-c1-a1", "S6"
107
+ # The receipt's field set, copied here from its sources and never derived from the module's own
108
+ # tuples: plan WP-02 "receipts.py" ({schema, method_id, dispatch_id, packet_sha256, result_sha256,
109
+ # provider, model, effort, exit_status, evidence{}}), and design §3.2 step 1's evidence list
110
+ # (call_id, the schema hash, the seat observed, the profile and flag-set hash, the working
111
+ # directory, the context-manifest and observed-context hashes, the usage state and totals, the
112
+ # capture hash, the session or thread id) with the plan's addition payload_sha256 ("Packet identity"),
113
+ # and the contract-fix record's hermeticity (2026-11-02, F-31).
114
+ required_top = ("schema", "method_id", "dispatch_id", "packet_sha256", "result_sha256", "provider", "model",
115
+ "effort", "exit_status", "evidence")
116
+ required_evidence = ("call_id", "schema_sha256", "seat_observed", "profile", "profile_flags_sha256", "cwd",
117
+ "manifest_sha256", "context_observed_sha256", "usage_state", "usage_totals", "capture_sha256",
118
+ "session_id", "payload_sha256", "hermeticity")
119
+ ran.append("receipt-field-inventory-is-the-contract")
120
+ if set(TOP_KEYS) | {"schema", "evidence"} != set(required_top) or set(EVIDENCE_KEYS) != set(required_evidence):
121
+ failures.append(f"receipt fields {sorted(TOP_KEYS)} / {sorted(EVIDENCE_KEYS)} are not the contract's "
122
+ f"{sorted(required_top)} / {sorted(required_evidence)}")
123
+ evidence = {key: f"value-of-{key}" for key in required_evidence}
124
+ evidence["call_id"] = call_id
125
+ with tempfile.TemporaryDirectory() as td:
126
+ call_dir = pathlib.Path(td)
127
+ (call_dir / "packet.md").write_text("CALL-ID: r1-S6-c1-a1\n", encoding="utf-8")
128
+ (call_dir / "result.json").write_text('{"answer": "OK"}\n', encoding="utf-8")
129
+ # positive control first: the receipt the real launcher writes, read back through its own check
130
+ argv = [sys.executable, str(LAUNCHER), "--emit-receipt", method_id(stage, call_id),
131
+ "claude:claude-opus-5-5/high", "0", str(call_dir / "packet.md"), str(call_dir / "result.json")]
132
+ for key, value in evidence.items():
133
+ argv += ["--evidence", f"{key}={value}"]
134
+ env = {**os.environ, "REVIEW_RECEIPT_DIR": str(call_dir / "receipts")}
135
+ env.pop("REVIEW_CRITERION_SCHEMA", None)
136
+ emitted = subprocess.run(argv, env=env, capture_output=True, text=True)
137
+ written = sorted((call_dir / "receipts").glob("*.json"))
138
+ if emitted.returncode != 0 or len(written) != 1:
139
+ failures.append(f"the launcher did not write one receipt: rc {emitted.returncode} {emitted.stderr.strip()[:200]}")
140
+ real = None
141
+ else:
142
+ written[0].replace(call_dir / "receipt.json")
143
+ real, errors = read(call_dir)
144
+ control("launcher-written-receipt", errors + (problems(real, stage, call_id) if real else []))
145
+ if real:
146
+ control("launcher-fields-are-the-top-keys", [] if set(TOP_KEYS) <= set(real) and real["provider"] == "claude"
147
+ else [f"keys {sorted(real)}"])
148
+
149
+ def mutated(edit):
150
+ receipt = json.loads(json.dumps(real))
151
+ edit(receipt)
152
+ (call_dir / "receipt.json").write_text(json.dumps(receipt), encoding="utf-8")
153
+ got, errors = read(call_dir)
154
+ return errors + (problems(got, stage, call_id) if got else [])
155
+
156
+ control("another-calls-method-id", mutated(lambda r: r.update(method_id=method_id(stage, "r1-S6-c2-a1"))),
157
+ "RECEIPT_STALE method_id")
158
+ control("another-stages-method-id", mutated(lambda r: r.update(method_id=method_id("S7b", call_id))),
159
+ "RECEIPT_STALE method_id")
160
+ control("another-calls-evidence", mutated(lambda r: r["evidence"].update(call_id="r1-S6-c2-a1")),
161
+ "RECEIPT_STALE evidence.call_id")
162
+ control("launcher-receipt-has-exactly-the-contract-fields", [] if set(real) == set(required_top)
163
+ and set(real["evidence"]) == set(required_evidence) else [f"fields {sorted(real)} {sorted(real['evidence'])}"])
164
+ for key in required_evidence:
165
+ control(f"evidence-without-{key}", mutated(lambda r, key=key: r["evidence"].pop(key)),
166
+ f"RECEIPT_KEY_MISSING evidence.{key}")
167
+ control("no-evidence-at-all", mutated(lambda r: r.pop("evidence")), "RECEIPT_KEY_MISSING evidence.call_id")
168
+ for key in [k for k in required_top if k not in ("schema", "evidence")]:
169
+ control(f"receipt-without-{key}", mutated(lambda r, key=key: r.pop(key)), f"RECEIPT_KEY_MISSING {key}")
170
+ control("structural-defect-keeps-the-rest-of-the-judgment", mutated(lambda r: (
171
+ r.update(note="x", method_id=method_id(stage, "r1-S6-c9-a1")), r["evidence"].pop("cwd"))),
172
+ "RECORD_INTEGRITY receipt: unknown receipt key", "RECEIPT_STALE method_id", "RECEIPT_KEY_MISSING evidence.cwd")
173
+ control("evidence-value-not-a-string", mutated(lambda r: r["evidence"].update(usage_totals={"measured": 1})),
174
+ "RECORD_INTEGRITY evidence.usage_totals: not a string")
175
+ # the launcher's own grammar decides what a receipt is, so its refusals reach the gate by name
176
+ control("unknown-receipt-key", mutated(lambda r: r.update(note="x")), "RECORD_INTEGRITY receipt: unknown receipt key")
177
+ control("boolean-exit-status", mutated(lambda r: r.update(exit_status=False)),
178
+ "RECORD_INTEGRITY receipt: records exit_status as bool")
179
+ control("not-a-review-receipt", mutated(lambda r: r.update(schema="ReviewReceipt/v0")),
180
+ "RECORD_INTEGRITY receipt: not a ReviewReceipt/v1")
181
+ control("folded-receipt", mutated(lambda r: r.update(passes=[])), "RECORD_INTEGRITY receipt: carries a pass list")
182
+ (call_dir / "receipt.json").write_text("[1]", encoding="utf-8")
183
+ control("receipt-not-an-object", read(call_dir)[1], "RECORD_INTEGRITY receipt: not an object")
184
+ (call_dir / "receipt.json").write_text("{not json", encoding="utf-8")
185
+ control("unreadable-receipt", read(call_dir)[1], "RECEIPT_MISSING")
186
+ (call_dir / "receipt.json").unlink()
187
+ control("no-receipt", read(call_dir)[1], "RECEIPT_MISSING")
188
+
189
+ for failure in failures:
190
+ print(f"receipts --self-test [FAIL] {failure}")
191
+ if failures:
192
+ return 1
193
+ print(f"receipts --self-test: OK ({len(ran)} controls: " + ", ".join(ran) + ")")
194
+ return 0
195
+
196
+
197
+ if __name__ == "__main__":
198
+ if "--self-test" not in sys.argv[1:]:
199
+ sys.exit("usage: receipts.py --self-test")
200
+ sys.exit(self_test())