agent-bios 0.19.3 → 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 (172) hide show
  1. package/DEPENDENCIES.md +62 -20
  2. package/INSTALL.md +1 -1
  3. package/README.md +16 -21
  4. package/claude/agents/frontier.md +1 -1
  5. package/claude/agents/sweep.md +2 -1
  6. package/claude/agents/workhorse.md +2 -2
  7. package/claude/guides/claude-prompting.md +494 -167
  8. package/claude/guides/cli-multi-model-workflow.md +8 -7
  9. package/claude/guides/gpt-prompting.md +241 -111
  10. package/claude/guides/session-distill-workflow.md +93 -43
  11. package/claude/guides/tooling-gotchas.md +3 -1
  12. package/codex/agents/reviewer.toml +2 -2
  13. package/codex/agents/sweep.toml +1 -1
  14. package/codex/agents/workhorse.toml +2 -2
  15. package/codex/guides/claude-prompting.md +494 -167
  16. package/codex/guides/cli-multi-model-workflow.md +8 -7
  17. package/codex/guides/gpt-prompting.md +241 -111
  18. package/codex/guides/session-distill-workflow.md +93 -43
  19. package/codex/guides/tooling-gotchas.md +3 -1
  20. package/compose/assemble.py +4 -1
  21. package/compose/canary.sh +8 -6
  22. package/compose/host_platform.py +158 -15
  23. package/compose/instructions-state.py +183 -41
  24. package/compose/instructions_app.py +2 -2
  25. package/compose/instructions_install.py +222 -27
  26. package/compose/instructions_session.py +250 -75
  27. package/compose/instructions_setup.py +6 -6
  28. package/compose/instructions_setup_cli.py +2 -36
  29. package/compose/instructions_setup_i18n.py +3 -3
  30. package/compose/instructions_store.py +160 -3
  31. package/compose/instructions_transaction.py +29 -5
  32. package/compose/instructions_ui_runtime.py +2 -2
  33. package/compose/setup/START.md +1 -1
  34. package/docs/advanced-launch.md +4 -0
  35. package/docs/releases/0.19.4.md +99 -0
  36. package/docs/releases/0.20.0.md +102 -0
  37. package/docs/setup.md +4 -4
  38. package/install.sh +54 -20
  39. package/launch/agent-launch.py +171 -22
  40. package/launch/agent-launch.toml +64 -29
  41. package/launch/agent-launch.zsh +104 -13
  42. package/launch/claude_subcommands.py +179 -0
  43. package/launch/provision-venv.sh +1 -1
  44. package/launch/shell_integration.py +7 -1
  45. package/learn/collect-learning.py +60 -9
  46. package/learn/migrate-learnings.py +70 -4
  47. package/learn/redact.py +2 -1
  48. package/package.json +37 -4
  49. package/provenance.json +1 -1
  50. package/session-cost.py +141 -18
  51. package/session-distill/coverage.json +6 -0
  52. package/session-distill/distill.py +2575 -0
  53. package/session-distill/grammar/__init__.py +0 -0
  54. package/session-distill/grammar/owner_lines.py +874 -0
  55. package/session-distill/originators.json +9 -0
  56. package/session-distill/packets/cross_review.md +31 -0
  57. package/session-distill/packets/form.md +86 -0
  58. package/session-distill/packets/judge.md +81 -0
  59. package/session-distill/packets/placement_contract.md +90 -0
  60. package/session-distill/packets/propose.md +124 -0
  61. package/session-distill/packets/read.md +57 -0
  62. package/session-distill/packets/reconsider.md +53 -0
  63. package/session-distill/packets/s7b.md +65 -0
  64. package/session-distill/packets/s9b.md +39 -0
  65. package/session-distill/packets/stitch.md +35 -0
  66. package/session-distill/packets/sweep.md +33 -0
  67. package/session-distill/runlib/__init__.py +0 -0
  68. package/session-distill/runlib/bound.py +1102 -0
  69. package/session-distill/runlib/breaker.py +467 -0
  70. package/session-distill/runlib/census.py +2347 -0
  71. package/session-distill/runlib/claims.py +420 -0
  72. package/session-distill/runlib/controls.py +902 -0
  73. package/session-distill/runlib/coverage.py +881 -0
  74. package/session-distill/runlib/declare.py +888 -0
  75. package/session-distill/runlib/delivery_evidence.py +1145 -0
  76. package/session-distill/runlib/derive.py +812 -0
  77. package/session-distill/runlib/destinations.py +3072 -0
  78. package/session-distill/runlib/dispatch.py +7939 -0
  79. package/session-distill/runlib/drift.py +1077 -0
  80. package/session-distill/runlib/entry.py +401 -0
  81. package/session-distill/runlib/evidence.py +890 -0
  82. package/session-distill/runlib/exposure.py +1162 -0
  83. package/session-distill/runlib/gate.py +2727 -0
  84. package/session-distill/runlib/gitread.py +79 -0
  85. package/session-distill/runlib/inventory.py +19624 -0
  86. package/session-distill/runlib/journal.py +1919 -0
  87. package/session-distill/runlib/ledger.py +3210 -0
  88. package/session-distill/runlib/ledger_compat.py +101 -0
  89. package/session-distill/runlib/ledger_migration.py +190 -0
  90. package/session-distill/runlib/lifecycle_intake.py +693 -0
  91. package/session-distill/runlib/lineage.py +454 -0
  92. package/session-distill/runlib/measures.py +249 -0
  93. package/session-distill/runlib/monitor.py +1180 -0
  94. package/session-distill/runlib/operations.py +522 -0
  95. package/session-distill/runlib/packet.py +838 -0
  96. package/session-distill/runlib/placement.py +1769 -0
  97. package/session-distill/runlib/projection.py +4090 -0
  98. package/session-distill/runlib/ranking.py +740 -0
  99. package/session-distill/runlib/receipts.py +200 -0
  100. package/session-distill/runlib/records.py +1965 -0
  101. package/session-distill/runlib/search.py +249 -0
  102. package/session-distill/runlib/sequencing.py +829 -0
  103. package/session-distill/runlib/sources.py +641 -0
  104. package/session-distill/runlib/stage_adjudicate.py +845 -0
  105. package/session-distill/runlib/stage_apply.py +1378 -0
  106. package/session-distill/runlib/stage_approvals.py +758 -0
  107. package/session-distill/runlib/stage_close.py +1220 -0
  108. package/session-distill/runlib/stage_confirm.py +929 -0
  109. package/session-distill/runlib/stage_delivery.py +3080 -0
  110. package/session-distill/runlib/stage_form.py +2576 -0
  111. package/session-distill/runlib/stage_judge.py +4248 -0
  112. package/session-distill/runlib/stage_propose.py +3307 -0
  113. package/session-distill/runlib/stage_read.py +5179 -0
  114. package/session-distill/runlib/stage_render.py +2739 -0
  115. package/session-distill/runlib/stage_retrieve.py +924 -0
  116. package/session-distill/runlib/stage_review_korean.py +1002 -0
  117. package/session-distill/runlib/stage_review_proposals.py +1292 -0
  118. package/session-distill/runlib/stagelock.py +412 -0
  119. package/session-distill/runlib/stop.py +1061 -0
  120. package/session-distill/runlib/targets.py +809 -0
  121. package/session-distill/runlib/usage.py +280 -0
  122. package/session-distill/runlib/validate.py +319 -0
  123. package/session-distill/runlib/views.py +4327 -0
  124. package/session-distill/schemas/adjudication.schema.json +35 -0
  125. package/session-distill/schemas/approval.schema.json +35 -0
  126. package/session-distill/schemas/census.schema.json +128 -0
  127. package/session-distill/schemas/checks.schema.json +207 -0
  128. package/session-distill/schemas/claim.schema.json +16 -0
  129. package/session-distill/schemas/confirmation.schema.json +24 -0
  130. package/session-distill/schemas/coverage.schema.json +66 -0
  131. package/session-distill/schemas/cross_review.schema.json +24 -0
  132. package/session-distill/schemas/event.schema.json +20 -0
  133. package/session-distill/schemas/evidence.schema.json +20 -0
  134. package/session-distill/schemas/expected_observation.schema.json +18 -0
  135. package/session-distill/schemas/form.schema.json +103 -0
  136. package/session-distill/schemas/intake.schema.json +71 -0
  137. package/session-distill/schemas/inventory.schema.json +872 -0
  138. package/session-distill/schemas/judge.schema.json +77 -0
  139. package/session-distill/schemas/ledger.schema.json +313 -0
  140. package/session-distill/schemas/observation.schema.json +16 -0
  141. package/session-distill/schemas/propose.schema.json +555 -0
  142. package/session-distill/schemas/read.schema.json +76 -0
  143. package/session-distill/schemas/reconsider.schema.json +122 -0
  144. package/session-distill/schemas/run.schema.json +150 -0
  145. package/session-distill/schemas/s7b.schema.json +200 -0
  146. package/session-distill/schemas/s9b.schema.json +28 -0
  147. package/session-distill/schemas/stitch.schema.json +25 -0
  148. package/session-distill/schemas/sweep.schema.json +25 -0
  149. package/session-distill/seats.json +149 -0
  150. package/session-distill/tables/allowed_pairs.json +257 -0
  151. package/session-distill/tables/controls.json +30 -0
  152. package/session-distill/tables/delivery_evidence.json +36 -0
  153. package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
  154. package/session-distill/tables/destinations.json +684 -0
  155. package/session-distill/tables/drift_layers.json +68 -0
  156. package/session-distill/tables/exposure_rules.json +192 -0
  157. package/session-distill/tables/placement_rules.json +148 -0
  158. package/session-distill/tables/propose_fixtures.json +154 -0
  159. package/session-distill/tables/ranking.json +194 -0
  160. package/session-distill/tables/redundancy.json +10 -0
  161. package/session-distill/tables/structural_rules.json +44 -0
  162. package/session-distill/tables/transition_fixtures.json +398 -0
  163. package/session-distill/tables/transitions.json +69 -0
  164. package/session-distill/tables/unit_outcome.json +67 -0
  165. package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
  166. package/wrappers/claude-run.sh +481 -33
  167. package/wrappers/claude_hermetic_evidence.py +1423 -0
  168. package/wrappers/codex-helm.sh +44 -13
  169. package/wrappers/codex-run.sh +183 -20
  170. package/wrappers/codex_frame_filter.py +1199 -0
  171. package/wrappers/codex_protocol.py +737 -0
  172. package/wrappers/jsonl_lines.py +65 -0
@@ -7,9 +7,9 @@ host; that is the launch adapter's job.
7
7
  """
8
8
  from __future__ import annotations
9
9
  try:
10
- from host_platform import sync_directory, cli_argv
10
+ from host_platform import sync_directory, cli_argv, jsonl_lines_for
11
11
  except ImportError:
12
- from .host_platform import sync_directory, cli_argv
12
+ from .host_platform import sync_directory, cli_argv, jsonl_lines_for
13
13
 
14
14
  import copy
15
15
  import contextlib
@@ -30,6 +30,16 @@ except ImportError:
30
30
  from .instructions_transaction import environment_value, transaction_lock, guard_pending, pending_operations, operation_scope_active, reject_symlink_ancestors
31
31
 
32
32
  SCHEMA_VERSION = 1
33
+ RECEIPT_DIR = "receipts"
34
+ RECEIPT_SCHEMA = "InstallationReceipt/v1"
35
+ RECEIPT_ROLES = {"release", "owned"}
36
+ RECEIPT_INSTALLER = {"digest_at_import", "digest", "build", "root", "files", "package_modules_run"}
37
+ _SHA256 = re.compile(r"[0-9a-f]{64}")
38
+ # Snapshot input -> the file in the receipt's release artifacts that must carry the same bytes. The
39
+ # installer digest cannot answer this: an old installer runs the new package's store and catalog.
40
+ RECEIPT_ARTIFACTS = {"compiler_digest": "compose/instructions_catalog.py",
41
+ "store_schema_digest": "compose/instructions_store.py",
42
+ "bootstrap_digest": "compose/bootstrap/SKILL.md"}
33
43
  LOCAL_PACKAGE = "@local/personal"
34
44
  SURFACES = {"always", "relevant", "requested", "event", "delegated"}
35
45
  KINDS = {"rule", "guide", "skill", "hook", "agent"}
@@ -200,6 +210,133 @@ def _snapshot_assets(value: Any, files: list[str]) -> dict[str, Any]:
200
210
  return _copy_json(value)
201
211
 
202
212
 
213
+ def read_installation_receipt(state_root: Path, receipt_id: str) -> dict[str, Any]:
214
+ """A success receipt whose bytes hash to its id; anything else is not evidence.
215
+
216
+ The id lives outside the body (the file name), so reading one is also the check that the
217
+ body was not edited: a re-serialization with reordered keys hashes the same, a changed
218
+ field does not.
219
+ """
220
+ _safe_part(receipt_id, "receipt id")
221
+ path = Path(state_root) / "runtime" / RECEIPT_DIR / f"{receipt_id}.json"
222
+ _reject_symlink_path(path)
223
+ if not path.is_file():
224
+ raise ValidationError("installation receipt is missing")
225
+ raw = path.read_bytes()
226
+ if hashlib.sha256(raw).hexdigest() != receipt_id:
227
+ raise ValidationError("installation receipt does not hash to its id")
228
+ receipt = json.loads(raw)
229
+ if not isinstance(receipt, dict) or receipt.get("schema") != RECEIPT_SCHEMA or receipt.get("result") != "success":
230
+ raise ValidationError("not a success installation receipt")
231
+ _receipt_contract(receipt)
232
+ return receipt
233
+
234
+
235
+ def _receipt_contract(receipt: dict[str, Any]) -> None:
236
+ """Hold a receipt to the contract the installer writes, not only to its own hash.
237
+
238
+ A body can hash to its file name and still be no evidence: it can carry the id that must live
239
+ outside it, claim two different installer digests where a difference refuses the receipt, lack
240
+ the fields a verdict reads, or hold artifact rows of another shape. Each of those was accepted
241
+ as bound, or raised where a verdict was promised (X r1 F4), so each is a named refusal here and
242
+ `installation_binding` turns it into `unbound` with its reason.
243
+ """
244
+ carried = [key for key in ("receipt_id",) if key in receipt]
245
+ if carried:
246
+ raise ValidationError("installation receipt carries its own id: " + ", ".join(carried))
247
+ installer = receipt.get("installer")
248
+ if not isinstance(installer, dict):
249
+ raise ValidationError("installation receipt names no installer")
250
+ if set(installer) != RECEIPT_INSTALLER:
251
+ # Every field here is one the writer ALWAYS writes, so a receipt missing one, or carrying a field
252
+ # the writer never writes, was not written by that installer (X r2 F2).
253
+ raise ValidationError("installation receipt's installer is not the shape the installer writes: "
254
+ + ", ".join(sorted(RECEIPT_INSTALLER.symmetric_difference(installer))))
255
+ digests = [installer["digest_at_import"], installer["digest"]]
256
+ if not all(isinstance(value, str) and _SHA256.fullmatch(value) for value in digests):
257
+ raise ValidationError("installation receipt's installer digests are not digests")
258
+ if digests[0] != digests[1]:
259
+ # The installer refuses the receipt on a difference, so a receipt holding one was not written
260
+ # by that installer: the claim about which code ran is unusable either way.
261
+ raise ValidationError("installation receipt claims two different installer digests")
262
+ if not isinstance(installer["root"], str) or not installer["root"]:
263
+ raise ValidationError("installation receipt's installer names no root")
264
+ if not (installer["build"] is None or (isinstance(installer["build"], str) and installer["build"])):
265
+ raise ValidationError("installation receipt's installer build is neither a version nor absent")
266
+ files = installer["files"]
267
+ if not isinstance(files, list) or not files:
268
+ raise ValidationError("installation receipt lists no installer files")
269
+ for row in files:
270
+ if not isinstance(row, dict) or set(row) != {"path", "sha256"} \
271
+ or not isinstance(row["path"], str) or not row["path"] \
272
+ or not (isinstance(row["sha256"], str) and _SHA256.fullmatch(row["sha256"])):
273
+ # A null sha256 is an unreadable installer file, on which the writer refuses the receipt.
274
+ raise ValidationError("installation receipt holds an installer file row of another shape")
275
+ if _digest(files) != installer["digest"]:
276
+ # The digest IS the hash of these rows, canonically, so the two can be held against each other
277
+ # rather than taken on the receipt's word.
278
+ raise ValidationError("installation receipt's installer digest is not the hash of its own file list")
279
+ modules = installer["package_modules_run"]
280
+ if not isinstance(modules, list):
281
+ raise ValidationError("installation receipt lists no package modules")
282
+ for row in modules:
283
+ if not isinstance(row, dict) or set(row) != {"path", "sha256"} or not isinstance(row["path"], str) \
284
+ or not isinstance(row["sha256"], str) or not row["sha256"]:
285
+ raise ValidationError("installation receipt holds a package module row of another shape")
286
+ for field, kind in (("transaction_id", str), ("release_digest", str), ("baseline_ref", str),
287
+ ("selection", list), ("at", int)):
288
+ if not isinstance(receipt.get(field), kind) or (kind is str and not receipt[field]) \
289
+ or (kind is int and isinstance(receipt[field], bool)):
290
+ raise ValidationError(f"installation receipt's {field} is not a {kind.__name__}")
291
+ begun_by = receipt.get("begun_by_installer_digest")
292
+ if "begun_by_installer_digest" not in receipt:
293
+ raise ValidationError("installation receipt names no beginning installer digest, not even as absent")
294
+ if begun_by is not None and not (isinstance(begun_by, str) and _SHA256.fullmatch(begun_by)):
295
+ raise ValidationError("installation receipt's beginning installer digest is not a digest")
296
+ if begun_by == installer["digest"]:
297
+ # The writer normalises "begun by the installer that finished it" to null, so an equal pair is a
298
+ # claim no installer makes, and reading it as "a different installer began this" would be false.
299
+ raise ValidationError("installation receipt's beginning installer digest equals the finishing one")
300
+ artifacts = receipt.get("artifacts")
301
+ if not isinstance(artifacts, list) or not artifacts:
302
+ raise ValidationError("installation receipt lists no artifacts")
303
+ for row in artifacts:
304
+ # `role` is checked for being a string BEFORE set membership: an unhashable role raised a
305
+ # TypeError where a verdict was promised (X r2 F1).
306
+ if not isinstance(row, dict) or set(row) != {"path", "sha256", "role"} \
307
+ or not isinstance(row["path"], str) or not row["path"] \
308
+ or not (isinstance(row["sha256"], str) and _SHA256.fullmatch(row["sha256"])) \
309
+ or not isinstance(row["role"], str) or row["role"] not in RECEIPT_ROLES:
310
+ raise ValidationError("installation receipt holds an artifact row of another shape")
311
+
312
+
313
+ def installation_binding(state_root: Path, inputs: dict[str, Any]) -> dict[str, Any]:
314
+ """Does the receipt a snapshot names cover the artifacts the snapshot recorded?
315
+
316
+ A verdict, never a refusal: a development override (`AGENT_BIOS_PACKAGE_ROOT` at an older
317
+ tree) legitimately produces snapshots no current receipt covers, and `bound: False` is what
318
+ makes installer exposure unknown downstream rather than stopping a launch.
319
+ """
320
+ receipt_id = inputs.get("installation_receipt_id")
321
+ if not isinstance(receipt_id, str) or not receipt_id:
322
+ return {"bound": False, "reason": "snapshot records no installation receipt"}
323
+ try:
324
+ receipt = read_installation_receipt(state_root, receipt_id)
325
+ except (InstructionsStoreError, ValueError, OSError) as exc:
326
+ return {"bound": False, "receipt_id": receipt_id, "reason": str(exc)}
327
+ hashes = {entry["path"]: entry["sha256"] for entry in receipt["artifacts"]
328
+ if isinstance(entry, dict) and entry.get("role") == "release"}
329
+ wrong = [f"{field} != {path}" for field, path in RECEIPT_ARTIFACTS.items()
330
+ if not inputs.get(field) or hashes.get(path) != inputs[field]]
331
+ if receipt.get("baseline_ref") != inputs.get("baseline_ref"):
332
+ wrong.append("baseline_ref")
333
+ if wrong:
334
+ return {"bound": False, "receipt_id": receipt_id, "reason": "artifacts differ from the receipt: " + ", ".join(wrong)}
335
+ return {"bound": True, "receipt_id": receipt_id, "transaction_id": receipt["transaction_id"],
336
+ "installer_digest": receipt["installer"]["digest"], "release_digest": receipt["release_digest"],
337
+ "begun_by_installer_digest": receipt.get("begun_by_installer_digest")}
338
+
339
+
203
340
  def verify_snapshot(path: Path, expected_content_ref: str) -> dict[str, Any]:
204
341
  """Validate a persisted snapshot without consulting current authoring state."""
205
342
  root = Path(path)
@@ -438,7 +575,7 @@ class InstructionsStore:
438
575
  if not path.is_file():
439
576
  return []
440
577
  events: list[dict[str, Any]] = []
441
- for line_no, raw in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
578
+ for line_no, raw in enumerate(jsonl_lines_for(__file__).read(path), 1):
442
579
  if not raw.strip():
443
580
  continue
444
581
  try:
@@ -1464,6 +1601,17 @@ class InstructionsStore:
1464
1601
  selected.append(item)
1465
1602
  return selected
1466
1603
 
1604
+ def _current_installation_receipt_id(self) -> str | None:
1605
+ """The receipt of the install transaction the current install record belongs to, if it committed."""
1606
+ record = _json_read(self.runtime / "private-install.json")
1607
+ transaction_id = record.get("transaction_id") if isinstance(record, dict) else None
1608
+ if not isinstance(transaction_id, str):
1609
+ return None # installed before receipts existed: the snapshot stays unbound
1610
+ journal = _json_read(self.runtime / "installer-transactions"
1611
+ / _safe_part(transaction_id, "transaction id") / "journal.json")
1612
+ receipt_id = journal.get("receipt_id") if isinstance(journal, dict) and journal.get("state") == "COMMITTED" else None
1613
+ return receipt_id if isinstance(receipt_id, str) else None
1614
+
1467
1615
  def snapshot(self, host: str, selection: list[str] | None = None, dry_run: bool = False,
1468
1616
  native: bool = False, *, selection_mode: str | None = None,
1469
1617
  cwd: str | Path | None = None) -> dict[str, Any]:
@@ -1519,6 +1667,14 @@ class InstructionsStore:
1519
1667
  "store_schema_digest": _digest(Path(__file__).read_bytes()),
1520
1668
  "bootstrap_digest": _digest(bootstrap_path.read_bytes()),
1521
1669
  }
1670
+ # Recorded BEFORE content_ref is derived, so activation binds a session to exactly one
1671
+ # installation transaction even when several transactions served the same release — and
1672
+ # only when the receipt covers the files this store just hashed.
1673
+ receipt_id = self._current_installation_receipt_id()
1674
+ inputs["installation_receipt_id"] = (
1675
+ receipt_id if receipt_id and installation_binding(
1676
+ self.state_root, {**inputs, "installation_receipt_id": receipt_id})["bound"]
1677
+ else None)
1522
1678
  if native:
1523
1679
  import sys
1524
1680
  inputs["native"] = True
@@ -1631,6 +1787,7 @@ class InstructionsStore:
1631
1787
  verified = verify_snapshot(root, content_ref)
1632
1788
  output = verified["output"]
1633
1789
  return {"content_ref": content_ref, "path": str(root), "inputs": verified["inputs"],
1790
+ "installation_binding": installation_binding(self.state_root, verified["inputs"]),
1634
1791
  "items": verified["items"], "files": output.get("files"),
1635
1792
  "item_refs": output.get("item_refs"), "instruction_text": output.get("instruction_text"),
1636
1793
  "unavailable": output.get("unavailable"), "assets": output.get("assets", {})}
@@ -9,10 +9,11 @@ from __future__ import annotations
9
9
 
10
10
  import contextlib
11
11
  import base64
12
+ import datetime
12
13
  try:
13
- from host_platform import file_locks as fcntl, redirected
14
+ from host_platform import LockWaitExpired, file_locks as fcntl, lock_within, process_identity, redirected
14
15
  except ImportError:
15
- from .host_platform import file_locks as fcntl, redirected
16
+ from .host_platform import LockWaitExpired, file_locks as fcntl, lock_within, process_identity, redirected
16
17
  import hashlib
17
18
  import json
18
19
  import os
@@ -82,6 +83,26 @@ def _depths(name: str) -> dict[str, int]:
82
83
  return value
83
84
 
84
85
 
86
+ def _setup_holder(root: Path) -> str | None:
87
+ """The setup apply holding the transaction lock, if one does: the one writer that records itself, in
88
+ its receipt (written under the lock), so a waiter can name it. A receipt whose owner no longer runs,
89
+ or whose pid now belongs to another process, names nobody."""
90
+ for path in sorted((root / "setup" / "receipts").glob("*.json")):
91
+ try:
92
+ receipt = json.loads(path.read_text(encoding="utf-8"))
93
+ owner = receipt.get("owner") or {}
94
+ pid = owner.get("pid")
95
+ if receipt.get("state") != "running" or not isinstance(pid, int):
96
+ continue
97
+ if owner.get("process_identity") is None or process_identity(pid) != owner["process_identity"]:
98
+ continue
99
+ started = datetime.datetime.fromtimestamp(receipt["created_at"]).astimezone().isoformat(timespec="seconds")
100
+ except (OSError, ValueError, TypeError, KeyError, AttributeError, OverflowError):
101
+ continue
102
+ return f"setup apply {receipt.get('review_id')}, pid {pid}, started {started}"
103
+ return None
104
+
105
+
85
106
  @contextlib.contextmanager
86
107
  def _transaction_lock(state_root: Path, *, readonly: bool) -> Iterator[bool]:
87
108
  root = Path(state_root).expanduser()
@@ -115,12 +136,15 @@ def _transaction_lock(state_root: Path, *, readonly: bool) -> Iterator[bool]:
115
136
  if readonly and not stat.S_ISREG(os.fstat(descriptor).st_mode):
116
137
  raise TransactionError(f"unsafe instructions transaction lock: {lock}")
117
138
  try:
118
- fcntl.flock(descriptor, fcntl.LOCK_EX | (fcntl.LOCK_NB if readonly else 0))
139
+ if readonly:
140
+ fcntl.flock(descriptor, fcntl.LOCK_EX | fcntl.LOCK_NB)
141
+ else:
142
+ lock_within(descriptor, f"the instructions transaction lock ({lock})", holder=lambda: _setup_holder(root))
119
143
  except BlockingIOError:
120
- if not readonly:
121
- raise
122
144
  yield False
123
145
  return
146
+ except LockWaitExpired as exc:
147
+ raise TransactionError(str(exc)) from exc
124
148
  depths[key] = 1
125
149
  try:
126
150
  yield True
@@ -238,8 +238,8 @@ def release_ui_runtime() -> None:
238
238
  def activate_ui_runtime(repo: Path) -> Path:
239
239
  """Activate only verified shipped modules; imports must follow this call."""
240
240
  global _ACTIVE
241
- if sys.version_info < (3, 11):
242
- raise UiRuntimeError("the bundled UI runtime requires Python 3.11 or newer")
241
+ if sys.version_info < (3, 12):
242
+ raise UiRuntimeError("the bundled UI runtime requires Python 3.12 or newer")
243
243
  with _LOCK:
244
244
  manifest, archives = _read_bundle(repo)
245
245
  if _ACTIVE is not None and _ACTIVE[0] != manifest["bundle_id"]:
@@ -3,7 +3,7 @@
3
3
  This guide uses the same installation controller as the terminal wizard. The
4
4
  conversation collects choices and presents effects; `setup` validates and executes
5
5
  them. It needs local command and file access on the intended machine, Bash, and
6
- Python 3.11 or newer. Codex CLI, an additional model login, and Textual are not
6
+ Python 3.12 or newer. Codex CLI, an additional model login, and Textual are not
7
7
  requirements for this route.
8
8
 
9
9
  ## Start without an installed skill
@@ -124,6 +124,10 @@ When the internal Codex wrappers are available to a configured route, `codex-hel
124
124
 
125
125
  `claude-run` is the Claude-side review adapter carried by the release, and it takes `--model` and `--effort` to pin the seat. Omitting either warns and dispatches anyway, matching `codex-run`: refusing outright turned "the review ran unpinned" into "the review did not run", which is the worse of the two. The honest signal is downstream instead — an unpinned dispatch can name no seat, so it emits no receipt and the method adjudicates to UNKNOWN rather than to a clean pass. Its default denies the mutating tools, which is not the OS-level sandbox its Codex twin gets — do not read the two defaults as equivalent guarantees.
126
126
 
127
+ `claude-run --profile hermetic` is the isolated route, for a call whose judgment must not carry your own instructions. Each call runs in a cell — a fresh `HOME`, `CLAUDE_CONFIG_DIR` and working directory under `--cell-root`, a directory of your own with mode 700, outside your home, with no `CLAUDE.md`, `CLAUDE.local.md`, `AGENTS.md`, `.claude/`, `.codex/`, `.mcp.json` or settings file in it or above it — with an environment built from scratch, so your `CLAUDE.md` files, skills, memory, MCP servers, hooks and settings are denied to it, and so are those in the working directory and its ancestors. The flags that deny them are `--safe-mode --setting-sources "" --strict-mcp-config --disable-slash-commands --tools ""`. Login is the subscription token (`claude setup-token`), given as `CLAUDE_CODE_OAUTH_TOKEN` or in a file named by `CLAUDE_RUN_TOKEN_FILE`; it reaches the child's environment only, never an argument or a file the adapter writes. Instructions you mean the call to have go through `--append-system-prompt-file F --declared-sha256 H`. The session is kept until the call ends, because its transcript is the only record of what the host loaded: with `REVIEW_CAPTURE_DIR` set, `claude_hermetic_evidence.py` — installed beside the adapter and found nowhere else — writes that record to `host.json` (instruction files, appended prompts by sha256, skills, agents, hooks by event, MCP servers, the requests as sent) for a gate to compare with what was declared, and the stream to `stream.jsonl`. `--use producing --tools Read --manifest DIR` grants the one tool Claude can confine to a directory, and `DIR` must be the call's working directory; nothing else is granted. Each call names the versioned `claude` executable and the version it must report (`--claude-bin`, `--host-version`); a symlink or another version is refused before the call. The flag set was verified against Claude Code 2.1.317, and the profile name and flag-set hash are recorded with every call, so a host upgrade that changes their meaning shows in the record rather than in the result.
128
+
129
+ `codex-run --capture DIR` (or `REVIEW_CAPTURE_DIR`, with `REVIEW_CALL_ID` naming the call) records what one call showed about itself: the effective context rendered beforehand with the call's own homes and overrides (`prompt-input.txt`, `instruction-sources.json`), codex's thread and turn events, the server frames and usage rows reduced to an allow-list that keeps no prompt or output text, and `host.json` and `usage.json`; the receipt then carries the call id, the capture's digest and the other evidence keys. The model that answered is visible only on codex's trace frames, which appear only when the caller sets `RUST_LOG` to open `tungstenite::protocol=trace`, `codex_otel.log_only=info` and `codex_core::responses_retry=warn`. That channel is unsupported and changes with codex-cli releases, so a capture without it, or after an upgrade that removed it, attests no model. A capture runs one codex executable (`CODEX_RUN_BIN`, else `codex` on `PATH` resolved to its versioned file) and refuses to start when its version is not `CODEX_RUN_VERSION` or when the context cannot be rendered, and it refuses a named Codex configuration profile (`-p`, or `-c profile=`), whose layered settings the rendering cannot reproduce. An inline instruction override (`-c developer_instructions=…` or `-c instructions=…`) is recorded with the hash of its text among the call's appended prompts; an override naming an instruction file is refused. Capture adds `--json` and an output file to the exec arguments and changes nothing else: stdout is still the final message and stderr still carries codex's whole stream.
130
+
127
131
  ## Review receipts
128
132
 
129
133
  **Review receipts.** A launch reports what it *projected*, because at launch no review has run — so a clean verdict without a receipt is PROPOSED, never ACHIEVED. Given `REVIEW_RECEIPT_DIR`, both adapters record what they observed of the dispatch they just performed: exit status, a hash of the packet fed in, a hash of the bytes returned, and the seat actually sent. Unset, they behave exactly as they would otherwise and write nothing. `agent-launch --fold-receipts DIR PACKET MAIN_DISPATCH_ID` folds a run into a `ReviewReceipts/v1` bundle — several passes of one method become the one record it is judged on — and `agent-launch --verify-receipts PLAN BUNDLE` adjudicates it, exiting non-zero unless every selected method verified. Adapting another tool needs no change here: call `agent-launch --emit-receipt` from your adapter and prove it conforms with `agent-launch --check-adapter SEAT -- CMD`, which is adjudicated by the same code that credits a real review. A receipt is still written by whoever ran the review, so this buys drift rather than honesty: what it stops is a reviewer that quietly never ran, returned nothing, or exited non-zero reading as a clean pass.
@@ -0,0 +1,99 @@
1
+ # agent-bios 0.19.4
2
+
3
+ Release changes relative to 0.19.3.
4
+
5
+ ## Current model bindings
6
+
7
+ Six of the eight role bindings named a previous-generation model. The shipped
8
+ launch profile now binds:
9
+
10
+ | Seat | Claude | Codex |
11
+ | --- | --- | --- |
12
+ | FRONTIER | `claude-fable-5-1` · max | `gpt-6-astra` · max |
13
+ | HELM | `claude-opus-5-5` · high | `gpt-6.1-sol` · xhigh |
14
+ | WORKHORSE | `claude-sonnet-5-5` · high | `gpt-6.1-sol` · high |
15
+ | SWEEP | `claude-haiku-5-5` · medium | `gpt-6-luna` · max |
16
+
17
+ The Claude HELM and WORKHORSE seats move down one effort step with the rebind. The
18
+ 5.5 models recalibrate their levels and think more per turn at a given level, so
19
+ carrying `xhigh` forward would buy longer turns rather than more depth. SWEEP now
20
+ states its effort instead of following the vendor default, because Haiku 5.5 takes
21
+ the same effort vocabulary as the other seats.
22
+
23
+ The Codex catalogue retired `gpt-5.6-terra` without a same-role successor, so
24
+ WORKHORSE shares HELM's model and differs by effort alone. A review dispatched to
25
+ that seat no longer adds a second model's perspective; the guides say so where the
26
+ seat is named.
27
+
28
+ The deep reviewer that the Deep review and Session distill presets dispatch from a
29
+ Claude session is now `gpt-6.1-sol` at `ultra`. `ultra` is not the rung above
30
+ `xhigh`: the Codex CLI catalogue reports it as maximum reasoning with automatic task
31
+ delegation, a different mode, and `gpt-6-luna` refuses it.
32
+
33
+ Presets you saved yourself live in `~/.config/agent-launch/presets.local.toml`,
34
+ which installation never deploys or verifies. A saved preset that overrides a seat
35
+ with an older model keeps that override after the upgrade.
36
+
37
+ ## Model currency is checked against the host catalogues
38
+
39
+ A model-currency check reads the model catalogues the Claude and Codex CLIs
40
+ already cache on disk, so judging whether a binding is current needs no
41
+ network and no API key. Structure blocks: every bound model must carry a row in
42
+ the profile's `[models]` table, an unused row fails, and the agent definitions
43
+ must agree with the profile. Currency only discloses during development, because a
44
+ model going stale is the vendor's action rather than a defect in the tree.
45
+ Publishing is where it blocks: `prepublishOnly` refuses a package whose bindings
46
+ the catalogues have moved past.
47
+
48
+ Moving the bindings surfaced pre-existing defects that are fixed here:
49
+
50
+ - `session-cost.py` matched prices by model-name prefix, so `claude-opus-5-5` was
51
+ billed at the Opus 5 rate, and `claude-sonnet-5` carried another model's rate,
52
+ overstating Sonnet 5 sessions by half. Prices now match the exact model id,
53
+ optionally with a release-date suffix, and controls hold the rule.
54
+ - The launcher hard-coded a model name in two places, so an effort restriction it
55
+ encoded never applied to the model that replaced it.
56
+
57
+ ## Prompting guides re-derived
58
+
59
+ `claude-prompting.md` and `gpt-prompting.md` were re-read against their vendor
60
+ sources rather than re-pinned: all three Claude seats now have their own vendor
61
+ page, and four of the five pinned documents had moved. The multi-model workflow
62
+ guide was updated for the shared Codex seat.
63
+
64
+ ## Python 3.12 is the stated floor
65
+
66
+ `launch/agent-launch.py` has required Python 3.12 since 0.19.0, while the
67
+ documentation, the installer and the setup checks said 3.11. The stated floor is
68
+ now 3.12 everywhere it is stated, and the installer and the UI loader check for
69
+ it. The bundled UI wheels still declare 3.11, which they support; that is no
70
+ longer the package's floor.
71
+
72
+ ## Installation messages
73
+
74
+ - `agent-bios update --check` run from a directory deleted under the shell
75
+ reported that the registry was unreachable, although npm never started there.
76
+ The check now moves to `$HOME` first.
77
+ - The macOS and Linux installation command ended its success line with the whole
78
+ help text, because it asked for a `--version` flag the command does not have.
79
+ It now reads the version npm installed, and says when it cannot.
80
+
81
+ ## Upgrading
82
+
83
+ ```bash
84
+ npm i -g agent-bios@0.19.4
85
+ agent-bios install
86
+ ```
87
+
88
+ Install the exact version: right after a release, `@latest` can still resolve to
89
+ the previous one.
90
+
91
+ ## Not established by this release
92
+
93
+ Model currency is judged against the catalogues on the publishing machine at the
94
+ time of publication; a model released later is not reflected until the next
95
+ release. The Windows script route, its unsigned preview channel and the Claude
96
+ Desktop route are unchanged from 0.19.3, with the same unestablished points.
97
+
98
+ Domain knowledge, Decision memory and shared environment editions remain design
99
+ directions rather than features of this release.
@@ -0,0 +1,102 @@
1
+ # agent-bios 0.20.0
2
+
3
+ Release changes relative to 0.19.4.
4
+
5
+ ## The purpose statement describes the shipped product
6
+
7
+ The product purpose described team work environments built from Instructions,
8
+ Domain knowledge and Decision memory, with the team as the unit of sharing. What
9
+ ships is a personal library of Instructions, chosen per Claude Code or Codex
10
+ session, with packages others publish. The purpose text in the README and its
11
+ Korean reference now says that. The team work-environment initiative is stopped;
12
+ its design records remain as history.
13
+
14
+ ## The session-distill driver is in the package
15
+
16
+ `session-distill/distill.py` and its modules, schemas, tables and packets ship for
17
+ the first time. The driver runs a session-distill run as declared stages: a census
18
+ of the window's sessions, their immutable copies and inventories, the readings and
19
+ the formation of candidates, the evidence checks, two judges per candidate, the
20
+ proposals and their review, the owner's review file in Korean with a faithfulness
21
+ check, the owner's decisions and their confirmation, and the close.
22
+
23
+ What this release's run produces is evidence about the window, the owner's review of
24
+ it, and a record of what the owner decided. **It changes no library file.** A
25
+ proposal that would place, correct, re-deliver or reduce instruction text is refused
26
+ by name (`RELEASE_1_NO_LIBRARY_CHANGE`), and where the evidence supports such a
27
+ change the proposal names it in its reason for the owner to read; the change itself
28
+ is the author's work by hand. The run writes the ledger it is given and, for a
29
+ periodic run, the coverage state it names, and refuses to write either, or its own
30
+ run directory, inside the instructions: under a checkout's `claude/`, `codex/` or
31
+ `ko/` trees, or in a host's home as `CLAUDE_CONFIG_DIR` and `CODEX_HOME` configure
32
+ it. Testing whether an applied change helps (stage S8) is not part of this release.
33
+
34
+ Running it still requires an agent-bios checkout. Its runbook,
35
+ `session-distill-workflow`, is an author guide and is not delivered by a packaged
36
+ install, and the launcher now withholds the Session distill preset on a packaged
37
+ install, where it was still offered.
38
+
39
+ The driver declares its dependencies in `DEPENDENCIES.md`: Python 3.12, `jsonschema`
40
+ at the version it was measured with (a missing or different one is refused by name),
41
+ `git`, `zstd` for a compressed session capture, and the Claude Code and Codex CLIs for
42
+ the calls it makes.
43
+
44
+ ## Isolated review runs
45
+
46
+ - `claude-run --profile hermetic` runs a call in a cell: a fresh `HOME`,
47
+ `CLAUDE_CONFIG_DIR` and working directory under a cell root you name, so the call
48
+ carries none of your instructions. The run records the request as sent and the
49
+ context the host loaded, and a call counts as isolated only on that record.
50
+ - `codex-run --profile hermetic` gave Codex only a temporary `CODEX_HOME`, while Codex
51
+ also reads the repository's `AGENTS.md` and your skills from `HOME`: a review run
52
+ inside a repository saw that repository's working rules and your skills. Codex now
53
+ runs with an empty temporary `HOME` and no project documents.
54
+ - `codex-run --capture DIR` records what one call showed about itself. It reads a
55
+ version-bound trace channel of the Codex CLI, so it refuses a Codex whose version is
56
+ not the one it was verified against, and every exit before Codex starts names its
57
+ code.
58
+
59
+ Installation deploys and verifies the helpers these routes load beside themselves
60
+ (`claude_hermetic_evidence.py`, `jsonl_lines.py`, `codex_frame_filter.py`,
61
+ `codex_protocol.py`, `claude_subcommands.py`, `host_platform.py`).
62
+
63
+ ## Model bindings
64
+
65
+ The Claude FRONTIER seat moves from Fable 5.1 to `claude-fable-5-2`, and Fable 5.1
66
+ leaves the launch profile's model list rather than staying beside it. The Claude
67
+ prompting guide was re-derived for Fable 5.2 before the binding moved.
68
+
69
+ ## Reliability
70
+
71
+ - Every lock the package takes waits a bounded time: it says after two seconds what it
72
+ waits for, and after thirty refuses, naming the lock.
73
+ - A child process's group is ended before the child is reaped, on every path, and no
74
+ wait on a child's output is unbounded.
75
+ - Every reader of a JSONL log, the hosts' and the package's own, reads through one
76
+ splitter from the file's bytes, so a record ends at LF or CRLF and nowhere else.
77
+ - A Codex session's activation records the rollout file the host wrote, so a session's
78
+ selection and delivery can be read from its transcript, and an installation receipt
79
+ names the installer that executed.
80
+ - Shell scripts no longer pipe a long output into `grep -q`, which under `pipefail` read
81
+ a match as a miss.
82
+
83
+ ## Upgrading
84
+
85
+ ```bash
86
+ npm i -g agent-bios@0.20.0
87
+ agent-bios install
88
+ ```
89
+
90
+ Install the exact version: right after a release, `@latest` can still resolve to the
91
+ previous one.
92
+
93
+ ## Not established by this release
94
+
95
+ No packaged install has run a session-distill run; the driver's evidence is its own
96
+ suites, run from a checkout, and a check that the packed tarball starts the driver and
97
+ imports every module it ships. A file the driver reads only once a command runs is held
98
+ by the payload check's classification of every driver file, not by a run. The driver's
99
+ refusal to write inside the instructions reads a destination as it resolves when the
100
+ command starts; a parent directory another process replaces afterwards is not held. The
101
+ Windows script route and the Claude Desktop route are not re-established by this
102
+ release.
package/docs/setup.md CHANGED
@@ -11,9 +11,9 @@ Commands below use the installed `agent-bios` CLI. From a source checkout, run
11
11
 
12
12
  | Route | Requirements | Interface |
13
13
  | --- | --- | --- |
14
- | Codex app | A local task with command/file access on the intended machine, Bash, Python 3.11+ | Questions and effect review in the conversation; no extra Codex CLI or model login |
15
- | Terminal | macOS or Linux, Bash, Python 3.11+, an input/output terminal; Node.js 18+/npm for package installation | Included Textual wizard |
16
- | Automation | Bash, Python 3.11+, explicit machine commands | JSON inspection, review and results |
14
+ | Codex app | A local task with command/file access on the intended machine, Bash, Python 3.12+ | Questions and effect review in the conversation; no extra Codex CLI or model login |
15
+ | Terminal | macOS or Linux, Bash, Python 3.12+, an input/output terminal; Node.js 18+/npm for package installation | Included Textual wizard |
16
+ | Automation | Bash, Python 3.12+, explicit machine commands | JSON inspection, review and results |
17
17
 
18
18
  Host CLIs and their authentication are needed when you choose to launch them.
19
19
  Node/npm are needed to obtain the npm package and for any selected capability that
@@ -153,7 +153,7 @@ agent-bios app desktop
153
153
  The command writes `agent-bios.mcpb` under the private state root and prints its path.
154
154
  Open that file with Claude Desktop and confirm the installation dialog; agent-bios never
155
155
  writes into Desktop's own folders or configuration. The extension runs Python at the
156
- absolute path the file names — the interpreter that ran the command, which must be 3.11
156
+ absolute path the file names — the interpreter that ran the command, which must be 3.12
157
157
  or newer. Run the command again after changing that Python; an agent-bios update alone
158
158
  needs no new file, because the extension finds the current installation on every call.
159
159