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.
- package/DEPENDENCIES.md +62 -20
- package/INSTALL.md +1 -1
- package/README.md +16 -21
- package/claude/agents/frontier.md +1 -1
- package/claude/agents/sweep.md +2 -1
- package/claude/agents/workhorse.md +2 -2
- package/claude/guides/claude-prompting.md +494 -167
- package/claude/guides/cli-multi-model-workflow.md +8 -7
- package/claude/guides/gpt-prompting.md +241 -111
- package/claude/guides/session-distill-workflow.md +93 -43
- package/claude/guides/tooling-gotchas.md +3 -1
- package/codex/agents/reviewer.toml +2 -2
- package/codex/agents/sweep.toml +1 -1
- package/codex/agents/workhorse.toml +2 -2
- package/codex/guides/claude-prompting.md +494 -167
- package/codex/guides/cli-multi-model-workflow.md +8 -7
- package/codex/guides/gpt-prompting.md +241 -111
- package/codex/guides/session-distill-workflow.md +93 -43
- package/codex/guides/tooling-gotchas.md +3 -1
- package/compose/assemble.py +4 -1
- package/compose/canary.sh +8 -6
- package/compose/host_platform.py +158 -15
- package/compose/instructions-state.py +183 -41
- package/compose/instructions_app.py +2 -2
- package/compose/instructions_install.py +222 -27
- package/compose/instructions_session.py +250 -75
- package/compose/instructions_setup.py +6 -6
- package/compose/instructions_setup_cli.py +2 -36
- package/compose/instructions_setup_i18n.py +3 -3
- package/compose/instructions_store.py +160 -3
- package/compose/instructions_transaction.py +29 -5
- package/compose/instructions_ui_runtime.py +2 -2
- package/compose/setup/START.md +1 -1
- package/docs/advanced-launch.md +4 -0
- package/docs/releases/0.19.4.md +99 -0
- package/docs/releases/0.20.0.md +102 -0
- package/docs/setup.md +4 -4
- package/install.sh +54 -20
- package/launch/agent-launch.py +171 -22
- package/launch/agent-launch.toml +64 -29
- package/launch/agent-launch.zsh +104 -13
- package/launch/claude_subcommands.py +179 -0
- package/launch/provision-venv.sh +1 -1
- package/launch/shell_integration.py +7 -1
- package/learn/collect-learning.py +60 -9
- package/learn/migrate-learnings.py +70 -4
- package/learn/redact.py +2 -1
- package/package.json +37 -4
- package/provenance.json +1 -1
- package/session-cost.py +141 -18
- package/session-distill/coverage.json +6 -0
- package/session-distill/distill.py +2575 -0
- package/session-distill/grammar/__init__.py +0 -0
- package/session-distill/grammar/owner_lines.py +874 -0
- package/session-distill/originators.json +9 -0
- package/session-distill/packets/cross_review.md +31 -0
- package/session-distill/packets/form.md +86 -0
- package/session-distill/packets/judge.md +81 -0
- package/session-distill/packets/placement_contract.md +90 -0
- package/session-distill/packets/propose.md +124 -0
- package/session-distill/packets/read.md +57 -0
- package/session-distill/packets/reconsider.md +53 -0
- package/session-distill/packets/s7b.md +65 -0
- package/session-distill/packets/s9b.md +39 -0
- package/session-distill/packets/stitch.md +35 -0
- package/session-distill/packets/sweep.md +33 -0
- package/session-distill/runlib/__init__.py +0 -0
- package/session-distill/runlib/bound.py +1102 -0
- package/session-distill/runlib/breaker.py +467 -0
- package/session-distill/runlib/census.py +2347 -0
- package/session-distill/runlib/claims.py +420 -0
- package/session-distill/runlib/controls.py +902 -0
- package/session-distill/runlib/coverage.py +881 -0
- package/session-distill/runlib/declare.py +888 -0
- package/session-distill/runlib/delivery_evidence.py +1145 -0
- package/session-distill/runlib/derive.py +812 -0
- package/session-distill/runlib/destinations.py +3072 -0
- package/session-distill/runlib/dispatch.py +7939 -0
- package/session-distill/runlib/drift.py +1077 -0
- package/session-distill/runlib/entry.py +401 -0
- package/session-distill/runlib/evidence.py +890 -0
- package/session-distill/runlib/exposure.py +1162 -0
- package/session-distill/runlib/gate.py +2727 -0
- package/session-distill/runlib/gitread.py +79 -0
- package/session-distill/runlib/inventory.py +19624 -0
- package/session-distill/runlib/journal.py +1919 -0
- package/session-distill/runlib/ledger.py +3210 -0
- package/session-distill/runlib/ledger_compat.py +101 -0
- package/session-distill/runlib/ledger_migration.py +190 -0
- package/session-distill/runlib/lifecycle_intake.py +693 -0
- package/session-distill/runlib/lineage.py +454 -0
- package/session-distill/runlib/measures.py +249 -0
- package/session-distill/runlib/monitor.py +1180 -0
- package/session-distill/runlib/operations.py +522 -0
- package/session-distill/runlib/packet.py +838 -0
- package/session-distill/runlib/placement.py +1769 -0
- package/session-distill/runlib/projection.py +4090 -0
- package/session-distill/runlib/ranking.py +740 -0
- package/session-distill/runlib/receipts.py +200 -0
- package/session-distill/runlib/records.py +1965 -0
- package/session-distill/runlib/search.py +249 -0
- package/session-distill/runlib/sequencing.py +829 -0
- package/session-distill/runlib/sources.py +641 -0
- package/session-distill/runlib/stage_adjudicate.py +845 -0
- package/session-distill/runlib/stage_apply.py +1378 -0
- package/session-distill/runlib/stage_approvals.py +758 -0
- package/session-distill/runlib/stage_close.py +1220 -0
- package/session-distill/runlib/stage_confirm.py +929 -0
- package/session-distill/runlib/stage_delivery.py +3080 -0
- package/session-distill/runlib/stage_form.py +2576 -0
- package/session-distill/runlib/stage_judge.py +4248 -0
- package/session-distill/runlib/stage_propose.py +3307 -0
- package/session-distill/runlib/stage_read.py +5179 -0
- package/session-distill/runlib/stage_render.py +2739 -0
- package/session-distill/runlib/stage_retrieve.py +924 -0
- package/session-distill/runlib/stage_review_korean.py +1002 -0
- package/session-distill/runlib/stage_review_proposals.py +1292 -0
- package/session-distill/runlib/stagelock.py +412 -0
- package/session-distill/runlib/stop.py +1061 -0
- package/session-distill/runlib/targets.py +809 -0
- package/session-distill/runlib/usage.py +280 -0
- package/session-distill/runlib/validate.py +319 -0
- package/session-distill/runlib/views.py +4327 -0
- package/session-distill/schemas/adjudication.schema.json +35 -0
- package/session-distill/schemas/approval.schema.json +35 -0
- package/session-distill/schemas/census.schema.json +128 -0
- package/session-distill/schemas/checks.schema.json +207 -0
- package/session-distill/schemas/claim.schema.json +16 -0
- package/session-distill/schemas/confirmation.schema.json +24 -0
- package/session-distill/schemas/coverage.schema.json +66 -0
- package/session-distill/schemas/cross_review.schema.json +24 -0
- package/session-distill/schemas/event.schema.json +20 -0
- package/session-distill/schemas/evidence.schema.json +20 -0
- package/session-distill/schemas/expected_observation.schema.json +18 -0
- package/session-distill/schemas/form.schema.json +103 -0
- package/session-distill/schemas/intake.schema.json +71 -0
- package/session-distill/schemas/inventory.schema.json +872 -0
- package/session-distill/schemas/judge.schema.json +77 -0
- package/session-distill/schemas/ledger.schema.json +313 -0
- package/session-distill/schemas/observation.schema.json +16 -0
- package/session-distill/schemas/propose.schema.json +555 -0
- package/session-distill/schemas/read.schema.json +76 -0
- package/session-distill/schemas/reconsider.schema.json +122 -0
- package/session-distill/schemas/run.schema.json +150 -0
- package/session-distill/schemas/s7b.schema.json +200 -0
- package/session-distill/schemas/s9b.schema.json +28 -0
- package/session-distill/schemas/stitch.schema.json +25 -0
- package/session-distill/schemas/sweep.schema.json +25 -0
- package/session-distill/seats.json +149 -0
- package/session-distill/tables/allowed_pairs.json +257 -0
- package/session-distill/tables/controls.json +30 -0
- package/session-distill/tables/delivery_evidence.json +36 -0
- package/session-distill/tables/delivery_evidence_fixtures.json +731 -0
- package/session-distill/tables/destinations.json +684 -0
- package/session-distill/tables/drift_layers.json +68 -0
- package/session-distill/tables/exposure_rules.json +192 -0
- package/session-distill/tables/placement_rules.json +148 -0
- package/session-distill/tables/propose_fixtures.json +154 -0
- package/session-distill/tables/ranking.json +194 -0
- package/session-distill/tables/redundancy.json +10 -0
- package/session-distill/tables/structural_rules.json +44 -0
- package/session-distill/tables/transition_fixtures.json +398 -0
- package/session-distill/tables/transitions.json +69 -0
- package/session-distill/tables/unit_outcome.json +67 -0
- package/session-distill/tables/unit_outcome_fixtures.json +2364 -0
- package/wrappers/claude-run.sh +481 -33
- package/wrappers/claude_hermetic_evidence.py +1423 -0
- package/wrappers/codex-helm.sh +44 -13
- package/wrappers/codex-run.sh +183 -20
- package/wrappers/codex_frame_filter.py +1199 -0
- package/wrappers/codex_protocol.py +737 -0
- package/wrappers/jsonl_lines.py +65 -0
|
@@ -13,7 +13,7 @@ core_rules:
|
|
|
13
13
|
- the ledger is the SSOT for state; read it before touching the pipeline
|
|
14
14
|
- placement follows PLACEMENT-FRAMEWORK.md, never ad-hoc judgment
|
|
15
15
|
- every promotion passes an explicit user-approval gate
|
|
16
|
-
- the canonical always surface is
|
|
16
|
+
- the canonical always surface is capped at 20 KiB and distill proposes only deletions and merges there; route additions to guides, skills, or session-level injection
|
|
17
17
|
- close the window by updating mirrors, parity, deployment, and the nudge baseline
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -61,7 +61,9 @@ A run should produce:
|
|
|
61
61
|
gate, or other existing mechanism that reaches its consumer. Keep evidence
|
|
62
62
|
and decisions in the ledger; report what was applied and verified and what
|
|
63
63
|
remains open. A review-ready proposal and an applied change are distinct
|
|
64
|
-
outcomes, and promotion still requires explicit user approval.
|
|
64
|
+
outcomes, and promotion still requires explicit user approval. In release 1
|
|
65
|
+
the driver applies none of them: an approved change to the library is an
|
|
66
|
+
author's own work by hand (Stages 2 to 5).
|
|
65
67
|
|
|
66
68
|
Judge success by useful, justified learning and its appropriate application.
|
|
67
69
|
Candidate counts and added text measure output volume. A supported decision to
|
|
@@ -79,52 +81,100 @@ Everything durable lives in the agent-bios repo.
|
|
|
79
81
|
|
|
80
82
|
## Read next (SSOT)
|
|
81
83
|
|
|
82
|
-
1. `design/session-distill/ledger.json` — the initiative's state
|
|
83
|
-
|
|
84
|
-
adopted-no-text
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
correct on the day it is written
|
|
84
|
+
1. `design/session-distill/ledger.json` — the initiative's state, schema 2 since
|
|
85
|
+
the WP-22 cutover. An entry's `status` is one of incubating / placed /
|
|
86
|
+
adopted-no-text / absorbed / retired, its history is `decisions[]`, and its
|
|
87
|
+
type is `classification.type`; so what is open, what was promoted and what is
|
|
88
|
+
still incubating are all queries against this file. Read state here and nowhere
|
|
89
|
+
else: a count or a status written into prose is correct on the day it is written
|
|
90
|
+
and silently wrong afterwards. Schema 1's `verdict`, `strength` and `criteria`
|
|
91
|
+
are gone from the entry — `criteria` became `consequence.kinds`, and the dropped
|
|
92
|
+
values are written down in the dated migration record, not recoverable from the
|
|
93
|
+
file. The reader of the ledger is `runlib/ledger.py`; the schema is
|
|
94
|
+
`session-distill/schemas/ledger.schema.json`.
|
|
88
95
|
2. `design/session-distill/versions.json` — authoring provenance mapping each
|
|
89
96
|
closed mining window to its commit. Private rollback selects an installed
|
|
90
97
|
`baseline_ref` through the instructions plan; this registry is not that authority.
|
|
91
98
|
3. `design/session-distill/PLACEMENT-FRAMEWORK.md` — the placement framework
|
|
92
99
|
(typology A–G, layers, admission bars, lifecycle). Apply the current
|
|
93
|
-
`AGENTS.md`
|
|
94
|
-
choosing a destination; the framework does not authorize global
|
|
95
|
-
|
|
96
|
-
## Stage 1 —
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
100
|
+
`AGENTS.md` cap on the canonical always surface and `SURFACES.md` delivery contract when
|
|
101
|
+
choosing a destination; the framework does not authorize additions to the global file.
|
|
102
|
+
|
|
103
|
+
## Stage 1 — Run the driver (`session-distill/distill.py`)
|
|
104
|
+
|
|
105
|
+
One run, one run directory, one subcommand per stage. The v1 pipeline that used to
|
|
106
|
+
stand here — the per-session digests, the batches, the two provider screeners, the
|
|
107
|
+
union, the consolidation and the bundles — was deleted at the WP-22 cutover; the
|
|
108
|
+
driver replaces it. Every stage writes into `<run root>/<run-id>/`, the run root
|
|
109
|
+
being `--out` or, unset, the XDG state directory the driver resolves. **A run root
|
|
110
|
+
inside this checkout is refused** — `inventory` protects the checkout
|
|
111
|
+
unconditionally and exits `PROTECTED_OVERLAP` before writing anything, which is
|
|
112
|
+
the protection working: a run writes a copy of the owner's session records, and
|
|
113
|
+
the repository is not a place for them. So leave `--out` unset and let the driver
|
|
114
|
+
resolve the XDG state directory, or name a directory outside every protected root
|
|
115
|
+
(the checkout, the owner's state root, `~/.claude`, `~/.codex`).
|
|
116
|
+
|
|
117
|
+
**Every stage but S8 runs, and what does not refuses by name rather than doing
|
|
118
|
+
something approximate.** `STAGE_NOT_IMPLEMENTED <command> (<stage>)` on
|
|
119
|
+
stderr, exit 2. The table is what this checkout does today, not the design:
|
|
120
|
+
|
|
121
|
+
| Stage | Command | Today |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| S0 | `distill.py declare --run-id ID --from DECLARATION.json` | runs; `--set PATH=VALUE` edits it until a stage has read it, `--amend --reason TEXT` after |
|
|
124
|
+
| S1 | `distill.py census --run-id ID --coverage session-distill/local/coverage.json` | runs; `--reconcile RESULTS.json` folds S3's results back into the statuses. `--coverage` names the state the last periodic close promoted, and the declaration's `starting_hashes.coverage` pins its sha256 (a mismatch is `COVERAGE_BASE_STALE`); left out, the census reads the tracked `session-distill/coverage.json`, the empty state of a checkout no periodic close has written to |
|
|
125
|
+
| S2 | `distill.py views --run-id ID` | runs: the immutable copies, the redaction projection, the windows, the search index, the evidence store |
|
|
126
|
+
| S2 | `distill.py inventory --run-id ID --ledger design/session-distill/ledger.json` | runs: the units per reference point. The ledger path is the caller's to name |
|
|
127
|
+
| S3 | `distill.py read --run-id ID --dry --checkout-ledger design/session-distill/ledger.json` | runs: every window packet measured, no call, record partial |
|
|
128
|
+
| S3 | `distill.py read --run-id ID --cells DIR --checkout-ledger design/session-distill/ledger.json [--tranche calibration] [--jobs N] [--golden-plan PLAN.json]` | runs: the window readings and stitches through the supervisor, live (token only as `CLAUDE_RUN_TOKEN_FILE`) or golden with a plan |
|
|
129
|
+
| S4 | `distill.py form --run-id ID --dry --checkout-ledger design/session-distill/ledger.json` | runs: the barrier, the lifecycle intake and the packet held to its bound, record partial |
|
|
130
|
+
| S4 | `distill.py form --run-id ID --cells DIR --checkout-ledger design/session-distill/ledger.json [--golden-plan PLAN.json]` | runs: the one formation call, live (token only as `CLAUDE_RUN_TOKEN_FILE`) or golden with a plan |
|
|
131
|
+
| S5 | `distill.py retrieve --run-id ID --checkout-ledger design/session-distill/ledger.json` | runs: code only - each candidate's retrieved units, lineages and checks, with the planted controls |
|
|
132
|
+
| S5b | `distill.py deliver --run-id ID` | runs: code only - per (session, unit, decision) whether the unit was delivered. A pair whose candidate names no session is counted apart (`not_session_derived`) |
|
|
133
|
+
| S6 | `distill.py judge --run-id ID --checkout-ledger design/session-distill/ledger.json --dry`, then the same with `--cells DIR [--golden-plan PLAN.json]` in place of `--dry` | runs: two judges per candidate through the supervisor, then the derivations |
|
|
134
|
+
| S7, S7b | `distill.py propose --run-id ID --checkout-ledger design/session-distill/ledger.json` with `--dry`, `--cells DIR [--golden-plan PLAN.json]` or answers in hand (`--answers ANSWERS.json`); then `distill.py review-proposals --run-id ID` with `--dry`, `--cells DIR [--golden-plan PLAN.json]` or `--reviews REVIEWS.json` | runs: one proposal per candidate S6 admitted, held to the contract and to what S11 would refuse of its operations; a second seat's review of each proposal a model wrote. In release 1 a proposal or an alternative that would change a library file is refused by name (`RELEASE_1_NO_LIBRARY_CHANGE`) |
|
|
135
|
+
| S8 | `distill.py test` | refuses, and **stays refused in release 1: S8 is deferred to release 2 by name (D-20261111-818391).** No run tests whether an applied change helped; a row that would carry a test result carries the named state `untested: s8_deferred` |
|
|
136
|
+
| S9, S9b | `distill.py render --run-id ID --checkout-ledger design/session-distill/ledger.json`, then `distill.py review-korean --run-id ID --cells DIR` | runs: the Korean review file `decisions.ko.v<n>.md` in the run directory, and a faithfulness check of its Korean against the proposals. Without S8 the order falls back to the judges and S7b, and the header says so. The header also states how many planted controls got their expected verdict after S6, recorded in `review.v<n>.json`; a failed control is shown, never a stop (D-20261115-18d56b) |
|
|
137
|
+
| S10, S10b | `distill.py parse-decisions --run-id ID`, `distill.py adjudicate --run-id ID --cells DIR` (when the owner wrote a `판정`), `distill.py confirm --run-id ID`, then `distill.py confirm --run-id ID --decide` | runs: the owner's decisions parsed from their edited copy, the adjudications recomputed, the final set built, and the owner's confirmation line read. In release 1 a final set that holds a change to a library file is refused by name before the owner confirms it |
|
|
138
|
+
| S11 | `distill.py apply --run-id ID` | runs: **writes no library file in release 1 (D-20261116-7853bc).** A confirmed set that holds a change is refused by name (`RELEASE_1_NO_LIBRARY_CHANGE`) before any plan or effect; a set that changes no file is recorded as such, and no command is printed. No git, no installer, no personal layer |
|
|
139
|
+
| S12 | `distill.py close --run-id ID --checkout-ledger design/session-distill/ledger.json --checkout-coverage session-distill/local/coverage.json` | runs: records the window and each decision on an existing ledger entry in the checkout's ledger (a `none` on a new candidate makes no ledger row and is kept in the run's `close.json`, F-40) and, for a periodic run, promotes the coverage state into the file named. Name the file under the ignored `session-distill/local/`, as the command shows: the state is keyed by session ids and stays out of git; a periodic close without the flag is refused (`COVERAGE_UNNAMED`). Its report carries the planted controls' evaluation as S9 recorded it. It runs no process and names what it leaves to you: the commit, the install, the launcher state, the version-registry line. `--recovery` is reserved |
|
|
140
|
+
|
|
141
|
+
**What a release 1 run produces.** Evidence about the window, the owner's review
|
|
142
|
+
of it, and a record of what the owner decided. **Release 1 changes no library file
|
|
143
|
+
(D-20261116-7853bc).** A disposition that would - `place`, `correct`, `re-deliver`,
|
|
144
|
+
`reduce` - and any operation are refused by name (`RELEASE_1_NO_LIBRARY_CHANGE`)
|
|
145
|
+
where S7 and S7b accept an answer, where S10b builds the final set and where S11
|
|
146
|
+
takes its items. Every kind of candidate keeps an answer among `keep`, `incubate`,
|
|
147
|
+
`drop` and `none`; where the evidence supports a change to a library file, the
|
|
148
|
+
proposal names it in its Korean reason for the owner to read. Reopening those
|
|
149
|
+
dispositions waits on a redesign of the write path, after release 1 is published.
|
|
150
|
+
Nothing tests whether a change would help: that is S8, in release 2. The run
|
|
151
|
+
changes the declared checkout's ledger (S12) and, for a periodic run, the coverage
|
|
152
|
+
file it names; the commit, the install and the publish are yours.
|
|
153
|
+
|
|
154
|
+
The evidence that the runnable stages run is the driver's own suite,
|
|
155
|
+
`python3 session-distill/distill.py --self-test` (declare → stage → amend → stage on
|
|
156
|
+
real files), and the module suites `python3 session-distill/runlib/<name>.py
|
|
157
|
+
--self-test`, which are the checkout's tooling rather than a packaged user's.
|
|
158
|
+
|
|
159
|
+
Author-side window tools that are not stages of the driver and still run:
|
|
160
|
+
`census.py` (the v1 window census), `plain-asks.py` and `update-state.py
|
|
161
|
+
--window-end <date>` (the launcher's nudge baseline). `migrate-ledger.py` is the
|
|
162
|
+
ledger's schema 1 → 2 migration, performed once and idempotent after.
|
|
163
|
+
|
|
164
|
+
`merge-ledger.py` belongs to the v1 window flow and **is not part of this
|
|
165
|
+
workflow any more.** It writes schema 1 fields — a top-level `window` and
|
|
166
|
+
per-entry `strength` and `supporting_sessions` — which schema 2 does not have, so
|
|
167
|
+
against the migrated ledger it would leave a document the schema no longer
|
|
168
|
+
describes. It now refuses a ledger that is not schema 1 by name
|
|
169
|
+
(`LEDGER_SCHEMA_UNSUPPORTED`) before reading or writing anything. After the
|
|
170
|
+
migration a window is folded in by the lifecycle intake.
|
|
171
|
+
|
|
172
|
+
**Stages 2 to 5 are the author's own work, not the driver's.** In release 1 the
|
|
173
|
+
driver changes no library file (D-20261116-7853bc). Where the owner decides that a
|
|
174
|
+
run's finding should change the library, an author makes the change by hand, as
|
|
175
|
+
Stage 3 describes: on a branch, through the placement framework, verified and
|
|
176
|
+
committed like any other change to this repository. The run's ledger records the
|
|
177
|
+
owner's decision, not the edit.
|
|
128
178
|
|
|
129
179
|
## Stage 2 — Review with the user
|
|
130
180
|
|
|
@@ -107,7 +107,9 @@ depends on it, pin it explicitly instead of trusting the environment.
|
|
|
107
107
|
that may contain `$`, backticks, quotes, or globs must not be inlined as
|
|
108
108
|
raw CLI arguments — the shell expands or mangles them before the target
|
|
109
109
|
process sees them. Pass via stdin, heredoc, or a temp file. (Our dispatch
|
|
110
|
-
scripts codex-run/codex-helm already accept stdin — use that path
|
|
110
|
+
scripts codex-run/codex-helm already accept stdin — use that path; beside a
|
|
111
|
+
prompt argument, codex-helm reads a pipe only with a `-` argument, as in
|
|
112
|
+
`git diff | codex-helm.sh "review" -`, and appends a redirected file either way.)
|
|
111
113
|
- **Multi-line pasted commands**: a command pasted across lines without
|
|
112
114
|
continuation markers can be re-wrapped into two invocations, silently
|
|
113
115
|
dropping trailing flags (a real incident: `--scopes` lost during an auth
|
package/compose/assemble.py
CHANGED
|
@@ -525,7 +525,10 @@ def replace_atomically(path, text):
|
|
|
525
525
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
526
526
|
tmp = path.with_name(path.name + ".tmp-agent-bios")
|
|
527
527
|
try:
|
|
528
|
-
|
|
528
|
+
if isinstance(text, bytes): # written as given: no newline translation on any platform
|
|
529
|
+
tmp.write_bytes(text)
|
|
530
|
+
else:
|
|
531
|
+
tmp.write_text(text, encoding="utf-8")
|
|
529
532
|
if path.exists():
|
|
530
533
|
tmp.chmod(path.stat().st_mode & 0o777)
|
|
531
534
|
os.replace(tmp, path)
|
package/compose/canary.sh
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Activation canary: proves the central bundle actually LOADS in a live
|
|
3
|
-
# session — file presence cannot
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# session — file presence cannot show that the session reads what the entry
|
|
4
|
+
# file imports, so this asks a headless session to echo the bundle's rev
|
|
5
|
+
# marker back.
|
|
6
6
|
#
|
|
7
7
|
# Exit: 0 loading | 1 NOT loading | 3 nothing to probe / cannot probe.
|
|
8
8
|
#
|
|
@@ -69,7 +69,7 @@ fi
|
|
|
69
69
|
# the probe's own exit status. An empty reply was already treated as unprobed, but a
|
|
70
70
|
# FAILED dispatch that printed anything at all — a network error, an unrecognised flag,
|
|
71
71
|
# a CLI upgrade changing its error text — fell through to FAIL and sent the reader off
|
|
72
|
-
# to
|
|
72
|
+
# to debug a bundle that was never asked about. stderr is discarded
|
|
73
73
|
# above, so the message is quoted for whatever it is worth and the status decides.
|
|
74
74
|
if [ "$probe_status" -ne 0 ]; then
|
|
75
75
|
echo "CANARY SKIP: the probe command failed (exit $probe_status) — cannot tell activation"
|
|
@@ -81,6 +81,8 @@ fi
|
|
|
81
81
|
echo "CANARY FAIL: central bundle is NOT loading in live sessions."
|
|
82
82
|
echo " expected marker: $expected"
|
|
83
83
|
echo " probe replied: $(printf '%s' "$out" | head -c 200)"
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
# No approval cause is offered: the entry file is a user-scope memory file, and the vendor's memory page
|
|
85
|
+
# says Claude Code loads a user-scope file's imports without the approval dialog.
|
|
86
|
+
echo " Likely cause: $CLAUDE_DIR/CLAUDE.md no longer imports the bundle with its '@central/bundle.md' line."
|
|
87
|
+
echo " Diagnose with: agent-bios verify"
|
|
86
88
|
exit 1
|
package/compose/host_platform.py
CHANGED
|
@@ -9,6 +9,44 @@ import time
|
|
|
9
9
|
|
|
10
10
|
WINDOWS = os.name == 'nt'
|
|
11
11
|
|
|
12
|
+
# Every exclusive lock a writer takes waits at most LOCK_WAIT_S, says after LOCK_NOTICE_S what it waits
|
|
13
|
+
# for, and then refuses naming the lock (D-20261102-49b466). Read at each call, so a control can scale
|
|
14
|
+
# them. Measured holds: an install 0.38 s, verify 0.034 s, a launcher preset save under 1 ms; only a
|
|
15
|
+
# setup apply holds the transaction lock for minutes, and the refusal names it.
|
|
16
|
+
LOCK_WAIT_S = 30.0
|
|
17
|
+
LOCK_NOTICE_S = 2.0
|
|
18
|
+
LOCK_RETRY_S = 0.05
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class LockWaitExpired(TimeoutError):
|
|
22
|
+
"""An exclusive lock another process still held when the wait bound ran out."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def emulated_flock(fd, operation, locking, unlock_mode, try_mode) -> None:
|
|
26
|
+
"""flock's LOCK_EX/LOCK_NB/LOCK_UN over a byte-range `locking` call (msvcrt on Windows), retried
|
|
27
|
+
every LOCK_RETRY_S. A blocking request used to retry forever; it now waits no longer than
|
|
28
|
+
lock_within would and raises LockWaitExpired. Takes the primitive as arguments so a control can
|
|
29
|
+
drive it on any OS."""
|
|
30
|
+
position = os.lseek(fd, 0, os.SEEK_CUR)
|
|
31
|
+
began = time.monotonic()
|
|
32
|
+
try:
|
|
33
|
+
while True:
|
|
34
|
+
os.lseek(fd, 0, os.SEEK_SET)
|
|
35
|
+
try:
|
|
36
|
+
locking(fd, unlock_mode if operation & 8 else try_mode, 1)
|
|
37
|
+
return
|
|
38
|
+
except OSError as exc:
|
|
39
|
+
if operation & 8 or exc.errno not in (errno.EACCES, errno.EAGAIN, errno.EDEADLK):
|
|
40
|
+
raise
|
|
41
|
+
if operation & 4:
|
|
42
|
+
raise BlockingIOError(exc.errno, str(exc)) from exc
|
|
43
|
+
if time.monotonic() - began >= LOCK_WAIT_S:
|
|
44
|
+
raise LockWaitExpired(f"a file lock is still held after {LOCK_WAIT_S:g} s") from exc
|
|
45
|
+
time.sleep(LOCK_RETRY_S)
|
|
46
|
+
finally:
|
|
47
|
+
os.lseek(fd, position, os.SEEK_SET)
|
|
48
|
+
|
|
49
|
+
|
|
12
50
|
if not WINDOWS:
|
|
13
51
|
import fcntl as file_locks
|
|
14
52
|
else:
|
|
@@ -20,21 +58,126 @@ else:
|
|
|
20
58
|
@staticmethod
|
|
21
59
|
def flock(file, operation):
|
|
22
60
|
fd = file if isinstance(file, int) else file.fileno()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
emulated_flock(fd, operation, msvcrt.locking, msvcrt.LK_UNLCK, msvcrt.LK_NBLCK)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def lock_within(file, name, holder=None, stream=None) -> None:
|
|
66
|
+
"""Take an exclusive lock on `file` (a descriptor or an object with fileno()), waiting at most
|
|
67
|
+
LOCK_WAIT_S. `name` says what the lock guards and where, as "<what> (<path>)". After LOCK_NOTICE_S
|
|
68
|
+
one line on stderr says what is awaited; at the bound LockWaitExpired names the lock and, where
|
|
69
|
+
`holder()` can tell, who holds it. A writer used to block in flock with no deadline, so one stuck
|
|
70
|
+
holder hung every later command without a word."""
|
|
71
|
+
began = time.monotonic()
|
|
72
|
+
noticed = False
|
|
73
|
+
while True:
|
|
74
|
+
try:
|
|
75
|
+
file_locks.flock(file, file_locks.LOCK_EX | file_locks.LOCK_NB)
|
|
76
|
+
return
|
|
77
|
+
except BlockingIOError:
|
|
78
|
+
pass
|
|
79
|
+
waited = time.monotonic() - began
|
|
80
|
+
if waited >= LOCK_WAIT_S or (not noticed and waited >= LOCK_NOTICE_S):
|
|
81
|
+
held = _holder_text(holder)
|
|
82
|
+
by = f", held by {held}" if held else ""
|
|
83
|
+
if waited >= LOCK_WAIT_S:
|
|
84
|
+
raise LockWaitExpired(f"{name} is still held after {LOCK_WAIT_S:g} s{by}")
|
|
85
|
+
print(f"agent-bios: waiting for {name}{by}; giving up after {LOCK_WAIT_S:g} s",
|
|
86
|
+
file=stream or sys.stderr, flush=True)
|
|
87
|
+
noticed = True
|
|
88
|
+
time.sleep(LOCK_RETRY_S)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _holder_text(holder):
|
|
92
|
+
"""What `holder()` says about who holds a lock, or None: naming the holder is a courtesy, and a
|
|
93
|
+
holder that cannot be read must not turn the wait into a different error."""
|
|
94
|
+
if holder is None:
|
|
95
|
+
return None
|
|
96
|
+
try:
|
|
97
|
+
return holder()
|
|
98
|
+
except Exception:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def process_identity(pid: int) -> str | None:
|
|
103
|
+
"""A token that tells process `pid` from a later process reusing the number: its start time."""
|
|
104
|
+
if WINDOWS:
|
|
105
|
+
import ctypes
|
|
106
|
+
from ctypes import wintypes
|
|
107
|
+
kernel = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
108
|
+
kernel.OpenProcess.restype = wintypes.HANDLE
|
|
109
|
+
kernel.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD]
|
|
110
|
+
kernel.GetProcessTimes.argtypes = [wintypes.HANDLE] + [ctypes.POINTER(wintypes.FILETIME)] * 4
|
|
111
|
+
kernel.CloseHandle.argtypes = [wintypes.HANDLE]
|
|
112
|
+
handle = kernel.OpenProcess(0x1000, False, pid)
|
|
113
|
+
if not handle:
|
|
114
|
+
return None
|
|
115
|
+
try:
|
|
116
|
+
times = [wintypes.FILETIME() for _ in range(4)]
|
|
117
|
+
if not kernel.GetProcessTimes(handle, *(ctypes.byref(t) for t in times)):
|
|
118
|
+
return None
|
|
119
|
+
return str((times[0].dwHighDateTime << 32) | times[0].dwLowDateTime)
|
|
120
|
+
finally:
|
|
121
|
+
kernel.CloseHandle(handle)
|
|
122
|
+
if sys.platform.startswith("linux"):
|
|
123
|
+
try:
|
|
124
|
+
fields = (Path("/proc") / str(pid) / "stat").read_text().rsplit(")", 1)[1].split()
|
|
125
|
+
return fields[19]
|
|
126
|
+
except (OSError, IndexError):
|
|
127
|
+
return None
|
|
128
|
+
try:
|
|
129
|
+
result = subprocess.run(["/bin/ps", "-p", str(pid), "-o", "lstart="], stdin=subprocess.DEVNULL,
|
|
130
|
+
capture_output=True, text=True, timeout=3,
|
|
131
|
+
env={**os.environ, "LC_ALL": "C", "TZ": "UTC"})
|
|
132
|
+
return result.stdout.strip() if result.returncode == 0 and result.stdout.strip() else None
|
|
133
|
+
except (OSError, subprocess.SubprocessError):
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
_jsonl_lines = {}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def jsonl_lines_for(anchor) -> object:
|
|
141
|
+
"""The JSONL splitter of the package root that holds `anchor`, a consuming module's own
|
|
142
|
+
`__file__`: <root>/wrappers/jsonl_lines.py, loaded by path under a name of its own and kept
|
|
143
|
+
out of sys.modules. A private release's module that imported this file from another root
|
|
144
|
+
still reads with its own root's splitter, and fails naming its path when that is missing."""
|
|
145
|
+
path = Path(anchor).resolve().parents[1] / "wrappers" / "jsonl_lines.py"
|
|
146
|
+
module = _jsonl_lines.get(path)
|
|
147
|
+
if module is None:
|
|
148
|
+
if not path.is_file():
|
|
149
|
+
raise FileNotFoundError(f"the package's JSONL splitter is missing: {path}")
|
|
150
|
+
import hashlib
|
|
151
|
+
import importlib.util
|
|
152
|
+
spec = importlib.util.spec_from_file_location(
|
|
153
|
+
"agent_bios_jsonl_lines_" + hashlib.sha256(str(path).encode()).hexdigest()[:12], path)
|
|
154
|
+
module = importlib.util.module_from_spec(spec)
|
|
155
|
+
spec.loader.exec_module(module)
|
|
156
|
+
_jsonl_lines[path] = module
|
|
157
|
+
return module
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
_codex_protocol = {}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def codex_protocol_for(anchor) -> object:
|
|
164
|
+
"""The Codex app-server protocol module of the package root that holds `anchor`:
|
|
165
|
+
<root>/wrappers/codex_protocol.py, loaded by path under a name of its own, as jsonl_lines_for
|
|
166
|
+
loads the splitter. It lives in wrappers/ because codex_frame_filter.py loads it from beside
|
|
167
|
+
itself, where the compatibility install deploys the two together."""
|
|
168
|
+
path = Path(anchor).resolve().parents[1] / "wrappers" / "codex_protocol.py"
|
|
169
|
+
module = _codex_protocol.get(path)
|
|
170
|
+
if module is None:
|
|
171
|
+
if not path.is_file():
|
|
172
|
+
raise FileNotFoundError(f"the package's Codex protocol module is missing: {path}")
|
|
173
|
+
import hashlib
|
|
174
|
+
import importlib.util
|
|
175
|
+
spec = importlib.util.spec_from_file_location(
|
|
176
|
+
"agent_bios_codex_protocol_" + hashlib.sha256(str(path).encode()).hexdigest()[:12], path)
|
|
177
|
+
module = importlib.util.module_from_spec(spec)
|
|
178
|
+
spec.loader.exec_module(module)
|
|
179
|
+
_codex_protocol[path] = module
|
|
180
|
+
return module
|
|
38
181
|
|
|
39
182
|
|
|
40
183
|
def cli_argv(root: Path, *args: str) -> list[str]:
|