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
@@ -25,9 +25,6 @@ from typing import Any, Callable, NoReturn
25
25
 
26
26
  if os.name == "nt":
27
27
  sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "compose"))
28
- from host_platform import file_locks as fcntl
29
- else:
30
- import fcntl
31
28
 
32
29
 
33
30
  TIER_ORDER = ("frontier", "helm", "workhorse", "sweep")
@@ -4108,6 +4105,42 @@ class BackRequested(RuntimeError):
4108
4105
  pass
4109
4106
 
4110
4107
 
4108
+ _LOCK_PLATFORMS: dict[pathlib.Path, Any] = {}
4109
+
4110
+
4111
+ def lock_platform(config_path: pathlib.Path):
4112
+ """compose/host_platform.py, which owns the shared bounded lock wait (D-20261102-49b466), loaded by
4113
+ path under a private name: from the package this launcher runs in, or, for the compatibility
4114
+ install's standalone copy in ~/.local/bin, from the copy deployed beside the launcher's config.
4115
+ With neither, the launcher refuses naming both rather than waiting on a lock without a bound."""
4116
+ import importlib.util
4117
+
4118
+ candidates = (pathlib.Path(__file__).resolve().parents[1] / "compose" / "host_platform.py",
4119
+ config_path.with_name("host_platform.py"))
4120
+ for path in candidates:
4121
+ if path in _LOCK_PLATFORMS:
4122
+ return _LOCK_PLATFORMS[path]
4123
+ if path.is_file():
4124
+ spec = importlib.util.spec_from_file_location(
4125
+ "agent_launch_host_platform_" + hashlib.sha256(str(path).encode()).hexdigest()[:12], path)
4126
+ module = importlib.util.module_from_spec(spec)
4127
+ spec.loader.exec_module(module)
4128
+ _LOCK_PLATFORMS[path] = module
4129
+ return module
4130
+ raise LaunchError("the launcher's lock helper is missing (looked for "
4131
+ + " and ".join(str(path) for path in candidates) + "); reinstall agent-bios")
4132
+
4133
+
4134
+ def lock_within(handle, name: str, config_path: pathlib.Path) -> None:
4135
+ """Hold `handle`'s exclusive lock, waiting at most the shared bound; past it, a LaunchError names
4136
+ the lock. The launcher's writers used to wait on their locks with no deadline."""
4137
+ platform = lock_platform(config_path)
4138
+ try:
4139
+ platform.lock_within(handle, name)
4140
+ except platform.LockWaitExpired as exc:
4141
+ raise LaunchError(str(exc)) from exc
4142
+
4143
+
4111
4144
  def resolve_command(value: str) -> str:
4112
4145
  # Guarded here rather than at each call site because the callers disagree about what a
4113
4146
  # failure means: `resolve_backend` reports it and stops, while `host_dispatch_command`
@@ -5727,6 +5760,12 @@ def build_plan(config: dict[str, Any], host: str, preset_name: str) -> dict[str,
5727
5760
  raise LaunchError(f"invalid preset or host binding: {host}/{preset_name}") from exc
5728
5761
  if not isinstance(preset, dict) or not isinstance(tiers, dict):
5729
5762
  raise LaunchError(f"invalid preset or host binding: {host}/{preset_name}")
5763
+ # The same verdict wherever a preset is named — a flag, a saved mode, a resume. The menu
5764
+ # withholds it; this is what makes the withholding a rule rather than a screen.
5765
+ if preset_withheld(preset):
5766
+ raise LaunchError(
5767
+ f"PRESET_AUTHOR_ONLY {preset_name}: the preset edits the agent-bios instructions "
5768
+ f"themselves and names paths only a checkout has; this tree is a packaged install")
5730
5769
  validate_host_tiers(host, tiers)
5731
5770
  all_overrides = preset.get("tier_overrides", {})
5732
5771
  if not isinstance(all_overrides, dict):
@@ -6644,7 +6683,12 @@ def register_reviewer_wizard(
6644
6683
  lock_path, os.O_CREAT | os.O_WRONLY | getattr(os, "O_NOFOLLOW", 0), 0o600
6645
6684
  )
6646
6685
  with os.fdopen(lock_fd, "w") as lock_handle:
6647
- fcntl.flock(lock_handle, fcntl.LOCK_EX)
6686
+ try:
6687
+ lock_within(lock_handle, f"the launcher methods lock ({lock_path})", config_path)
6688
+ except LaunchError as exc:
6689
+ _instructions_info(ui, t("wizard.title"), [str(exc)],
6690
+ back_hint=t("instructions.back.hint"))
6691
+ return False
6648
6692
  # Existence is part of the snapshot: a file created (or removed)
6649
6693
  # since the trial must read as a race even when its bytes happen
6650
6694
  # to equal the header the wizard would have invented.
@@ -7692,7 +7736,7 @@ def save_preset(
7692
7736
  lock_path = target.with_name(target.name + ".lock")
7693
7737
  lock_fd = os.open(lock_path, os.O_CREAT | os.O_WRONLY | getattr(os, "O_NOFOLLOW", 0), 0o600)
7694
7738
  with os.fdopen(lock_fd, "w") as lock_handle:
7695
- fcntl.flock(lock_handle, fcntl.LOCK_EX)
7739
+ lock_within(lock_handle, f"the launcher presets lock ({lock_path})", config_path)
7696
7740
  try:
7697
7741
  kept = remove_preset_block(
7698
7742
  target.read_text(encoding="utf-8"), name
@@ -8244,6 +8288,29 @@ def customize(
8244
8288
 
8245
8289
 
8246
8290
  DISTILL_PRESET = "session-distill"
8291
+ # An author-only preset instructs its agent to edit THIS repository's instructions, so its mission
8292
+ # names paths that exist only in a checkout. Offering it on a packaged install offers a route whose
8293
+ # first step fails, which is why `compose/assemble.py` already withholds an author-only GUIDE from a
8294
+ # packaged user; until now the preset's own `audience = "author"` was read by the payload gate and
8295
+ # by nothing else, so the route stayed open.
8296
+ #
8297
+ # The marker is `gates/`, which `gates/check-package.sh` forbids the payload from carrying in both
8298
+ # directions. Its presence therefore IS "this tree is a checkout", and no second declaration exists
8299
+ # to drift from it.
8300
+ AUTHOR_TREE_MARKER = "gates"
8301
+
8302
+
8303
+ def author_tree(root: Any = None) -> bool:
8304
+ """Whether the tree this launcher runs from is an agent-bios checkout."""
8305
+ base = pathlib.Path(root) if root is not None else pathlib.Path(__file__).resolve().parent.parent
8306
+ return (base / AUTHOR_TREE_MARKER).is_dir()
8307
+
8308
+
8309
+ def preset_withheld(preset: dict[str, Any], root: Any = None) -> bool:
8310
+ """Whether this preset must not be offered or launched from the tree we run in."""
8311
+ return isinstance(preset, dict) and preset.get("audience") == "author" and not author_tree(root)
8312
+
8313
+
8247
8314
  INSTRUCTIONS_STATUS_PATH = pathlib.Path(
8248
8315
  _instructions_environment(
8249
8316
  "AGENT_BIOS_INSTRUCTIONS_STATUS", "AGENT_BIOS_CORPUS_STATUS",
@@ -9369,6 +9436,10 @@ def pick_mode_and_preset(
9369
9436
  t("instructions.private.description") if private_instructions_enabled() else t("instructions.description"),
9370
9437
  )
9371
9438
  )
9439
+ if preset_withheld(presets.get(DISTILL_PRESET, {})):
9440
+ # Withheld, not greyed out: a route whose first instruction names a path the
9441
+ # reader does not have is worse than an absent route (WP-22a).
9442
+ mode_options = [o for o in mode_options if o.value != DISTILL_MODE]
9372
9443
  if private_instructions_enabled():
9373
9444
  mode_options.append(MenuOption(UNDERSTAND_OPTION, t("understand.title"), t("understand.description")))
9374
9445
  mode_options.append(MenuOption(SHELL_CONNECTION_OPTION, t("shell.title"), t("shell.description")))
@@ -9446,6 +9517,13 @@ def pick_mode_and_preset(
9446
9517
  mode = None
9447
9518
  continue
9448
9519
  if mode == DISTILL_MODE:
9520
+ # Reached by a resume, a flag or a stale saved mode rather than the menu: the same
9521
+ # verdict, by name, instead of a hub whose first instruction cannot be followed.
9522
+ if preset_withheld(presets.get(DISTILL_PRESET, {})):
9523
+ raise LaunchError(
9524
+ f"PRESET_AUTHOR_ONLY {DISTILL_PRESET}: this preset edits the agent-bios "
9525
+ f"instructions themselves and needs a checkout; a packaged install has none, "
9526
+ f"so it is not offered here")
9449
9527
  if distill_hub(config, ui) != "start":
9450
9528
  mode = None
9451
9529
  continue
@@ -10711,26 +10789,79 @@ def _line_count(path: pathlib.Path) -> int:
10711
10789
  return 0
10712
10790
 
10713
10791
 
10714
- def session_distill_nudge(config: dict[str, Any]) -> str | None:
10715
- """Nudge when enough sessions accumulated since the last mining window.
10792
+ def _transcript_file_count(home: pathlib.Path) -> int:
10793
+ """Transcript files under the two hosts' roots: a directory listing, no parsing.
10716
10794
 
10717
- The baseline is written by session-distill/update-state.py at
10718
- window close; provider history line counts are a cheap proxy for new
10719
- sessions. No state file means no nudge.
10720
- """
10795
+ Claude keeps one file per session directly inside each project directory; Codex keeps
10796
+ rollouts, plain or compressed in place, anywhere below `sessions/` and `archived_sessions/`.
10797
+ The window-close writer (session-distill/update-state.py) counts them the same way, and its
10798
+ self-test holds the two counts to one answer."""
10799
+ total = 0
10800
+ try:
10801
+ with os.scandir(home / ".claude" / "projects") as projects:
10802
+ for project in projects:
10803
+ if project.is_dir(follow_symlinks=False):
10804
+ with os.scandir(project.path) as files:
10805
+ total += sum(1 for f in files if f.name.endswith(".jsonl") and f.is_file(follow_symlinks=False))
10806
+ except OSError:
10807
+ pass
10808
+ pending = [home / ".codex" / "sessions", home / ".codex" / "archived_sessions"]
10809
+ while pending:
10810
+ try:
10811
+ with os.scandir(pending.pop()) as entries:
10812
+ for entry in entries:
10813
+ if entry.is_dir(follow_symlinks=False):
10814
+ pending.append(pathlib.Path(entry.path))
10815
+ elif entry.name.endswith((".jsonl", ".jsonl.zst")) and entry.is_file(follow_symlinks=False):
10816
+ total += 1
10817
+ except OSError:
10818
+ continue
10819
+ return total
10820
+
10821
+
10822
+ def _nudge_setting(settings: Any, key: str, default: int) -> int:
10823
+ """A positive integer setting of `[session_distill]`, or `default`.
10824
+
10825
+ A hand-edited "250" made the comparison a TypeError before the launcher drew anything — a
10826
+ nudge is a hint, so an unusable value falls back to the default rather than taking the
10827
+ launch down with it. `bool` is excluded because `True` is an int that means nothing here."""
10828
+ value = settings.get(key, default) if isinstance(settings, dict) else default
10829
+ return default if isinstance(value, bool) or not isinstance(value, int) or value < 1 else value
10830
+
10831
+
10832
+ def session_distill_nudge(config: dict[str, Any]) -> str | None:
10833
+ """Nudge when a mining window is due.
10834
+
10835
+ The baseline is written by session-distill/update-state.py at window close. A state file that
10836
+ carries `transcript_files_total` nudges when `cadence_days` have passed since its `window_end`
10837
+ or the transcript files under the hosts' roots grew by `transcript_growth`; one without it
10838
+ keeps the original rule, provider history line counts as a cheap proxy for new sessions. No
10839
+ state file means no nudge. The launcher reads this file and the hosts' directories, nothing
10840
+ in a checkout."""
10721
10841
  try:
10722
10842
  state = json.loads(SESSION_DISTILL_STATE.read_text(encoding="utf-8"))
10723
10843
  baseline = int(state["history_lines_total"])
10724
10844
  except (OSError, ValueError, KeyError, TypeError):
10725
10845
  return None
10726
10846
  settings = config.get("session_distill", {})
10727
- threshold = settings.get("nudge_after", 250) if isinstance(settings, dict) else 250
10728
- # `nudge_after` is compared against a line count, and a hand-edited "250" made that
10729
- # comparison a TypeError before the launcher drew anything — a nudge is a hint, so
10730
- # an unusable threshold falls back to the default rather than taking the launch
10731
- # down with it. `bool` is excluded because `True` is an int that means nothing here.
10732
- if isinstance(threshold, bool) or not isinstance(threshold, int) or threshold < 1:
10733
- threshold = 250
10847
+ files_then = state.get("transcript_files_total")
10848
+ if isinstance(files_then, int) and not isinstance(files_then, bool):
10849
+ cadence = _nudge_setting(settings, "cadence_days", 14)
10850
+ growth = _nudge_setting(settings, "transcript_growth", 250)
10851
+ reasons = []
10852
+ try:
10853
+ days = (datetime.date.today() - datetime.date.fromisoformat(state["window_end"])).days
10854
+ except (KeyError, TypeError, ValueError):
10855
+ days = None
10856
+ if days is not None and days >= cadence:
10857
+ reasons.append(f"{days} days since {state['window_end']} (cadence {cadence})")
10858
+ grown = _transcript_file_count(pathlib.Path.home()) - files_then
10859
+ if grown >= growth:
10860
+ reasons.append(f"~{grown} new transcript files since {state.get('window_end', '?')} (threshold {growth})")
10861
+ if not reasons:
10862
+ return None
10863
+ return "session-distill due: " + "; ".join(reasons) + " — launch the Session distill preset to run the next mining window"
10864
+ threshold = _nudge_setting(settings, "nudge_after", 250)
10734
10865
  current = _line_count(pathlib.Path.home() / ".claude/history.jsonl") + _line_count(
10735
10866
  pathlib.Path.home() / ".codex/history.jsonl"
10736
10867
  )
@@ -11161,6 +11292,7 @@ def main(argv: list[str], *, bundled_ui: bool = False) -> int:
11161
11292
  raise LaunchError("an instruction-pinned resume requires a private installation")
11162
11293
  store = instructions_store()
11163
11294
  import instructions_session
11295
+ instructions_session.raise_on_termination()
11164
11296
  return instructions_session.launch(command, [], store.state_root, args.host, {},
11165
11297
  resume_id=args.resume_session)
11166
11298
  nudge = session_distill_nudge(config)
@@ -11303,6 +11435,7 @@ def main(argv: list[str], *, bundled_ui: bool = False) -> int:
11303
11435
  projected += [understand_initial_prompt("<pinned-understand-session-prompt>")]
11304
11436
  if snapshot is not None and args.dry_run:
11305
11437
  import instructions_session
11438
+ instructions_session.raise_on_termination()
11306
11439
  projected = instructions_session.compose_argv(
11307
11440
  command,
11308
11441
  projected,
@@ -11359,6 +11492,7 @@ def main(argv: list[str], *, bundled_ui: bool = False) -> int:
11359
11492
  summary_stream.flush()
11360
11493
  if snapshot is not None:
11361
11494
  import instructions_session
11495
+ instructions_session.raise_on_termination()
11362
11496
  return instructions_session.launch(command, projected, store.state_root, args.host,
11363
11497
  snapshot, env=env,
11364
11498
  include_global_instructions=plan["include_global_instructions"])
@@ -141,23 +141,25 @@ severity_map = { blocker = "blocker", high = "high", medium = "medium", low = "l
141
141
  # The model family this host speaks for. A review binding names a provider, and
142
142
  # the reverse map must be unique so it resolves to exactly one validatable seat.
143
143
  provider = "openai"
144
- models = ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-luna"]
144
+ models = ["gpt-6.2-astra", "gpt-6.2-sol", "gpt-6-luna"]
145
145
 
146
146
  [hosts.codex.tiers.frontier]
147
- model = "gpt-6-astra"
147
+ model = "gpt-6.2-astra"
148
148
  effort = "max"
149
149
 
150
150
  [hosts.codex.tiers.helm]
151
- model = "gpt-6.1-sol"
151
+ model = "gpt-6.2-sol"
152
152
  effort = "xhigh"
153
153
 
154
154
  # Same model as HELM, one effort step down. The catalogue retired `terra` without a
155
155
  # same-role successor, so the tiers can no longer be three distinct models; effort is
156
156
  # what separates this seat from HELM, and a seat sharing HELM's model buys no
157
157
  # cross-model perspective — a review dispatched here is a lower-effort echo, not a
158
- # second reader.
158
+ # second reader. `gpt-6.1-terra` returned on 2026-11-24, described as an efficient model
159
+ # for visual understanding and computer use rather than for this seat's coding work, and
160
+ # the owner kept the shared model (D-20261124-20922b).
159
161
  [hosts.codex.tiers.workhorse]
160
- model = "gpt-6.1-sol"
162
+ model = "gpt-6.2-sol"
161
163
  effort = "high"
162
164
 
163
165
  [hosts.codex.tiers.sweep]
@@ -189,20 +191,25 @@ sweep = "${CODEX_HOME}/agents/sweep.toml"
189
191
  # Every id named anywhere in this file must have a row here, and every row must be named
190
192
  # somewhere — both directions are gated, so this table cannot quietly outlive its bindings.
191
193
  [models]
192
- "claude-fable-5-1" = { display = "Claude Fable 5.1" }
194
+ "claude-fable-5-2" = { display = "Claude Fable 5.2" }
193
195
  "claude-opus-5-5" = { display = "Claude Opus 5.5" }
194
196
  "claude-sonnet-5-5" = { display = "Claude Sonnet 5.5" }
195
197
  "claude-haiku-5-5" = { display = "Claude Haiku 5.5" }
196
- "gpt-6-astra" = { display = "GPT-6 Astra" }
197
- "gpt-6.1-sol" = { display = "GPT-6.1 Sol" }
198
+ "gpt-6.2-astra" = { display = "GPT-6.2 Astra" }
199
+ "gpt-6.2-sol" = { display = "GPT-6.2 Sol" }
198
200
  "gpt-6-luna" = { display = "GPT-6 Luna" }
199
201
 
200
202
  [hosts.claude]
201
203
  provider = "anthropic"
202
- models = ["claude-fable-5-1", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"]
204
+ models = ["claude-fable-5-2", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"]
203
205
 
206
+ # Rebound from Fable 5.1 on 2026-11-11, and Fable 5.1 is RETIRED rather than kept beside
207
+ # it: `models` is the selectable catalogue, and a listed model no tier binds would be a
208
+ # site the currency check reports superseded forever, answerable only by a `superseded_by`
209
+ # acknowledgement nobody has a reason to make. The codex host lists exactly its distinct
210
+ # tier-bound models for the same reason.
204
211
  [hosts.claude.tiers.frontier]
205
- model = "claude-fable-5-1"
212
+ model = "claude-fable-5-2"
206
213
  effort = "max"
207
214
 
208
215
  # One step below the seats the 5.x generation used. The vendor's Opus 5.5 guidance
@@ -275,9 +282,9 @@ claude_permission_mode = "standard"
275
282
  [presets.session-distill]
276
283
  # Author-only: the workflow edits the agent-bios instructions and needs a checkout, so
277
284
  # its mission names repo paths a packaged user does not have. Declaring it lets
278
- # gates/check-package.sh judge the mission text. NOTE: this declaration is read by
279
- # the gate, not yet by the launcher — the preset is still offered on a packaged
280
- # install. Closing that route belongs with the package-based distill work.
285
+ # gates/check-package.sh judge the mission text, and the launcher reads it too: a tree
286
+ # with no `gates/` directory is not a checkout, and the menu, the mode branch and
287
+ # `build_plan` each refuse the preset by name there (`preset_withheld`, WP-22a).
281
288
  audience = "author"
282
289
  label = "Session distill"
283
290
  description = "Dedicated session-distill run: mine recent sessions, verify, place, and apply per the session-distill workflow. Requires an agent-bios checkout."
@@ -310,7 +317,7 @@ tier = "frontier"
310
317
 
311
318
  [presets.deep-review.review.hosts.claude.methods."codex-exec"]
312
319
  provider = "openai"
313
- model = "gpt-6.1-sol"
320
+ model = "gpt-6.2-sol"
314
321
  effort = "ultra"
315
322
 
316
323
  [presets.deep-review.review.hosts.codex.base]
@@ -335,7 +342,7 @@ tier = "frontier"
335
342
 
336
343
  [presets.session-distill.review.hosts.claude.methods."codex-exec"]
337
344
  provider = "openai"
338
- model = "gpt-6.1-sol"
345
+ model = "gpt-6.2-sol"
339
346
  effort = "ultra"
340
347
 
341
348
  [presets.session-distill.review.hosts.codex.base]
@@ -347,6 +354,11 @@ provider = "anthropic"
347
354
  tier = "frontier"
348
355
 
349
356
  # Nudge baseline lives in ~/.local/share/agent-bios/session-distill-state.json,
350
- # written by session-distill/update-state.py at window close.
357
+ # written by session-distill/update-state.py at window close. A state file that records
358
+ # transcript_files_total nudges when cadence_days have passed since its window end or the
359
+ # transcript files grew by transcript_growth; one without it nudges after nudge_after new
360
+ # history lines.
351
361
  [session_distill]
352
362
  nudge_after = 250
363
+ cadence_days = 14
364
+ transcript_growth = 250
@@ -1,7 +1,9 @@
1
1
  # Alias expansion is OFF while this file is parsed and restored to what it was at the
2
2
  # end: zsh expands aliases at parse time, inside function bodies too, so an alias named
3
3
  # `builtin`, `command`, or `claude` that exists when this file is sourced would be baked
4
- # into the functions below and the real binary never reached.
4
+ # into the functions below and the real binary never reached. A command substitution is
5
+ # the exception: its text is parsed again each time it runs, under the aliases then in
6
+ # force, so a builtin inside `$(...)` is written `\builtin`, which no alias can replace.
5
7
  [[ -o aliases ]] && _agent_launch_aliases_were=1 || _agent_launch_aliases_were=0
6
8
  setopt no_aliases
7
9
 
@@ -17,22 +19,111 @@ _agent_launch_direct() {
17
19
  # provide is handed to whatever the user's function does. `builtin` cannot be shadowed,
18
20
  # so the resolution is the one the comment above already promised.
19
21
  if [[ "$host" == "claude" && -z "${_agent_launch_private_connection:-}" ]]; then
20
- case "${1-}" in
21
- # These six background-session verbs are dispatched only from the first argument:
22
- # with a flag in front, `claude attach <id>` is a new session whose prompt is
23
- # "attach <id>". Measured on 2.1.280 over all 21 subcommand spellings — only these
24
- # six are displaced, and the other fifteen (mcp, doctor, plugin, project, auth,
25
- # agents, ultrareview, update ...) parse the flag in front, which is what makes the
26
- # list this short rather than every verb. They act on a session that already exists,
27
- # so no permission default belongs in front of them.
28
- logs|attach|stop|kill|respawn|rm) builtin command claude "$@" ;;
29
- *) builtin command claude --dangerously-skip-permissions "$@" ;;
30
- esac
22
+ # The permission default goes in front of a prompt or an option, never in front of a
23
+ # subcommand: some subcommands are dispatched only from the first argument, so with a
24
+ # flag in front `claude attach <id>` is a new session whose prompt is "attach <id>",
25
+ # and which ones is the installed version's to say. The subcommands are what that
26
+ # version's `claude --help` lists (_agent_launch_claude_subcommands); a first argument
27
+ # that starts with `-` is no subcommand and needs no probe. When the list cannot be
28
+ # read, the flag stays off.
29
+ if [[ $# -eq 0 || "$1" == -* ]]; then
30
+ builtin command claude --dangerously-skip-permissions "$@"
31
+ elif _agent_launch_claude_subcommands && ! _agent_launch_claude_lists "$1"; then
32
+ builtin command claude --dangerously-skip-permissions "$@"
33
+ else
34
+ builtin command claude "$@"
35
+ fi
31
36
  else
32
37
  builtin command "$host" "$@"
33
38
  fi
34
39
  }
35
40
 
41
+ # The subcommand spellings (`stop|kill` is two) the installed `claude --help` lists under
42
+ # `Commands:`, in `_agent_launch_claude_verbs`. Read once per installed binary: the key is the
43
+ # binary's resolved path, modification time and size, held in this shell and in
44
+ # ~/.local/share/agent-bios/claude-subcommands (the state dir the shadow log below uses, never
45
+ # created here), so an update, which installs a new versioned path or rewrites the file, is
46
+ # probed again. Returns nonzero when no list can be read, and a failed probe is not cached.
47
+ #
48
+ # The help is run by the lister, launch/claude_subcommands.py: in a process group of its own, for
49
+ # at most 5 s, and answered for only when it exited 0 and listed a subcommand; on any other outcome
50
+ # it says why in one line on stderr. The lister is found where the private shell connection's
51
+ # header names it, else beside this file (the compatibility install deploys the two together, as
52
+ # the checkout holds them). The python3 that runs it is the one on PATH; on macOS /usr/bin/python3
53
+ # without the Command Line Tools would open their installer on every call, so it is not run then.
54
+ # When zsh/stat does not load or cannot read the binary, or there is no python3 or lister, the flag
55
+ # stays off and one line names the check (_agent_launch_claude_unread). A claude missing from PATH
56
+ # is not reported: the call that follows fails by itself, and a line about the flag would only
57
+ # stand in front of that error. The builtins are called as builtins, past any function of the
58
+ # user's that shares their name.
59
+ typeset -ga _agent_launch_claude_verbs
60
+ typeset -g _agent_launch_claude_verbs_key=""
61
+ typeset -g _agent_launch_claude_lister="${_agent_launch_claude_lister:-${${(%):-%x}:a:h}/claude_subcommands.py}"
62
+ _agent_launch_claude_unread() {
63
+ builtin print -ru2 -- "agent-bios: $1, so the subcommands claude lists cannot be read; claude starts" \
64
+ "without --dangerously-skip-permissions"
65
+ return 1
66
+ }
67
+ _agent_launch_claude_subcommands() {
68
+ setopt localoptions noksharrays no_err_return no_err_exit
69
+ local bin real key py listed why cache="$HOME/.local/share/agent-bios/claude-subcommands"
70
+ local -a words cached
71
+ local -A meta
72
+ bin="$(\builtin whence -p claude)" || return 1
73
+ [[ -n "$bin" ]] || return 1
74
+ real="${bin:A}"
75
+ if ! builtin zmodload -F zsh/stat b:zstat 2>/dev/null; then
76
+ _agent_launch_claude_unread "zsh's zsh/stat module did not load"
77
+ return 1
78
+ fi
79
+ if ! { builtin zstat -H meta -- "$real" } 2>/dev/null; then
80
+ _agent_launch_claude_unread "zstat could not read $real"
81
+ return 1
82
+ fi
83
+ key="${real}"$'\t'"${meta[mtime]}"$'\t'"${meta[size]}"
84
+ [[ "$key" == "$_agent_launch_claude_verbs_key" ]] && return 0
85
+ if [[ -f "$cache" && ! -L "$cache" ]]; then
86
+ cached=("${(@f)$(<"$cache")}")
87
+ if [[ "${cached[1]-}" == "$key" && ${#cached} -gt 1 ]]; then
88
+ _agent_launch_claude_verbs=("${(@)cached[2,-1]}")
89
+ _agent_launch_claude_verbs_key="$key"
90
+ return 0
91
+ fi
92
+ fi
93
+ py="$(\builtin whence -p python3)" || py=""
94
+ if [[ -n "$py" && "$OSTYPE" == darwin* && "${py:A}" == /usr/bin/python3 ]] \
95
+ && ! builtin command xcode-select -p >/dev/null 2>&1; then
96
+ why="python3 is the Command Line Tools stub, which are not installed"
97
+ elif [[ -z "$py" ]]; then
98
+ why="no python3 is on PATH"
99
+ elif [[ ! -f "$_agent_launch_claude_lister" ]]; then
100
+ why="the subcommand lister is missing at $_agent_launch_claude_lister"
101
+ fi
102
+ if [[ -n "$why" ]]; then
103
+ _agent_launch_claude_unread "$why"
104
+ return 1
105
+ fi
106
+ listed="$("$py" -I "$_agent_launch_claude_lister" "$bin" </dev/null)" || return 1
107
+ words=("${(@f)listed}")
108
+ (( ${#words} )) || return 1
109
+ _agent_launch_claude_verbs=("${words[@]}")
110
+ _agent_launch_claude_verbs_key="$key"
111
+ if [[ -d "${cache:h}" && ( ! -e "$cache" || ( -f "$cache" && ! -L "$cache" ) ) ]]; then
112
+ builtin print -rl -- "$key" "${words[@]}" >| "$cache.$$" 2>/dev/null \
113
+ && builtin command mv -f -- "$cache.$$" "$cache" 2>/dev/null \
114
+ || builtin command rm -f -- "$cache.$$" 2>/dev/null
115
+ fi
116
+ return 0
117
+ }
118
+
119
+ # Whether $1 is a spelling `_agent_launch_claude_verbs` holds. A function of its own so the
120
+ # subscript is read under zsh's array options, not the user's: with KSH_ARRAYS set, `(Ie)` answers
121
+ # 0 for the first element, the same answer as "absent".
122
+ _agent_launch_claude_lists() {
123
+ setopt localoptions noksharrays no_err_return no_err_exit
124
+ (( ${_agent_launch_claude_verbs[(Ie)$1]} ))
125
+ }
126
+
36
127
  _agent_launch_dispatch() {
37
128
  local host="$1"
38
129
  shift
@@ -108,7 +199,7 @@ _agent_launch_note_shadow() {
108
199
  prog="${TERM_PROGRAM:-unknown}"
109
200
  prog="${prog//[[:cntrl:]]/ }"
110
201
  # `builtin command`: a shell function named `date` must not write this field.
111
- stamp="$(builtin command date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null)"
202
+ stamp="$(\builtin command date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null)"
112
203
  stamp="${stamp//[[:cntrl:]]/ }"
113
204
  # `builtin printf`: a shell function named printf could report success and write nothing.
114
205
  if builtin printf '%s\t%s\t%s\t%s\n' "${stamp:-<unknown>}" "$host" "$prog" \