agent-bios 0.2.0 → 0.4.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 +1 -0
- package/README.md +2 -1
- package/claude/CLAUDE.md +14 -5
- package/claude/agents/frontier.md +9 -0
- package/claude/agents/sweep.md +9 -0
- package/claude/agents/workhorse.md +8 -0
- package/claude/guides/cli-multi-model-workflow.md +17 -4
- package/claude/guides/coding-staged-workflow.md +8 -0
- package/claude/guides/llm-capability-boundary-patterns.md +5 -0
- package/claude/guides/mock-realization-boundary.md +9 -0
- package/claude/guides/review-request.md +8 -0
- package/claude/guides/session-distill-workflow.md +100 -0
- package/claude/guides/tooling-gotchas.md +155 -0
- package/claude/hooks/tooling-gotchas-hook.py +79 -0
- package/codex/AGENTS.md +14 -5
- package/codex/config-additions.toml +22 -0
- package/codex/guides/cli-multi-model-workflow.md +17 -4
- package/codex/guides/coding-staged-workflow.md +8 -0
- package/codex/guides/llm-capability-boundary-patterns.md +5 -0
- package/codex/guides/mock-realization-boundary.md +9 -0
- package/codex/guides/review-request.md +8 -0
- package/codex/guides/session-distill-workflow.md +100 -0
- package/codex/guides/tooling-gotchas.md +155 -0
- package/config/agent-launch.toml +43 -0
- package/package.json +4 -1
- package/scripts/agent-launch.py +486 -52
- package/scripts/check-parity.sh +154 -7
- package/scripts/codex-helm.sh +19 -1
- package/scripts/codex-run.sh +19 -0
- package/scripts/install.sh +271 -10
package/DEPENDENCIES.md
CHANGED
|
@@ -12,6 +12,7 @@ Korean: [`ko/DEPENDENCIES.md`](ko/DEPENDENCIES.md). Dates = verification time; u
|
|
|
12
12
|
| `bash` | `scripts/*.sh` | POSIX + arrays; runs on macOS system bash | 3.2.57 · 2026-07 |
|
|
13
13
|
| `python3` | `scripts/session-cost.py`, `scripts/agent-launch.py` | stdlib for every direct / non-TTY / numbered path; Python 3.11+ (`tomllib`). The interactive preflight additionally needs `textual` (next row) | 3.14.5 · 2026-07-13 |
|
|
14
14
|
| `textual` (managed venv) | `scripts/agent-launch.py` interactive preflight; provisioned by `scripts/provision-venv.sh` | Textual TUI framework in `~/.local/share/agent-launch/venv` (override `AGENT_LAUNCH_VENV`); the launcher re-execs into it on the interactive TTY path only. Absent/broken venv, non-TTY, or `TERM` `dumb`/unset falls back to numbered prompts and never blocks | 8.2.8 · py 3.14.5 · 2026-07-13 |
|
|
15
|
+
| `jsonschema` (system python) | `scripts/check-learning.py` (learning record gate; chained from `scripts/check-parity.sh`) | JSON Schema Draft 2020-12 validator executing `config/learning.schema.json` as the SSOT | 4.26.0 · 2026-07-20 |
|
|
15
16
|
| `zsh` | `shell/agent-launch.zsh` | functions, TTY tests, argument-preserving dispatch | 5.9 · 2026-07-13 |
|
|
16
17
|
| `git` | scripts, workflow (`origin/<base>..HEAD`, worktrees) | modern git; worktree support | 2.50.1 · 2026-07 |
|
|
17
18
|
| coreutils (`mktemp`, `cp`) | `codex-run.sh` hermetic home; `codex-helm.sh` managed home | BSD or GNU | 2026-07 |
|
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ The `agent-bios` CLI deploys this SSOT into your environment by copy — idempot
|
|
|
59
59
|
```bash
|
|
60
60
|
npm install -g agent-bios
|
|
61
61
|
agent-bios install # deploy, back up replaced files, then verify
|
|
62
|
+
agent-bios onboard # pick domain packages, packaged install, activation canary
|
|
62
63
|
agent-bios verify # re-check the deployed state matches the source
|
|
63
64
|
agent-bios status # show what is installed and where
|
|
64
65
|
agent-bios update # git pull + reinstall (clone), or print the npm update line
|
|
@@ -67,7 +68,7 @@ agent-bios uninstall # remove deployed files and the zsh hook
|
|
|
67
68
|
|
|
68
69
|
From a git clone, run `./scripts/install.sh install` directly (the same CLI). `install` respects `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `AGENT_LAUNCH_VENV`, and `ZDOTDIR`; `--dry-run` prints actions without changing anything. Deploy to **every active environment in one sitting** — a partial deploy leaves a shared global pointing at a guide some environment lacks; globals are English only. Replaced files are backed up under `~/.local/share/agent-bios/backups/<timestamp>/`, and the installed set is recorded in a manifest that `uninstall` consumes. The published npm package ships only the deploy set (never `settings.json`, `config.toml`, `ko/`, or `benchmarks/`).
|
|
69
70
|
|
|
70
|
-
In a TTY, zero-argument `codex` or `claude` opens the launch preflight. Every arrow-key TUI selection screen keeps the complete current setup in a fixed top panel, followed by the highlighted option's description and then the option list. Move with Up/Down, select with Enter, use Esc to return to the previous menu, and use `q` to cancel; Esc at the
|
|
71
|
+
In a TTY, zero-argument `codex` or `claude` opens the launch preflight. Every arrow-key TUI selection screen keeps the complete current setup in a fixed top panel, followed by the highlighted option's description and then the option list. Move with Up/Down, select with Enter, use Esc to return to the previous menu, and use `q` to cancel; Esc at the mode root also cancels. Each tier's model is chosen from the host's configured catalog, or via **Other** to type any model id the backend accepts; that text input preserves values that start with `q`, so Esc or Ctrl-C cancels immediately there, while submitting `q` cancels after Enter. The Textual preflight reflows to the terminal size, so there is no fixed minimum geometry. The root menu picks a mode — **General user** (Vanilla: the bare CLI with no launch contract, no tier bindings, standard permissions; domain presets arrive with the non-technical rollout), **Builder** (the tier presets: Balanced, Deep review, Fast batch, Solo with delegation off), **Session distill** — then a preset within it. In Builder, select **Custom** to open a persistent settings hub for the main tier, review setup, host policy, and each tier binding. Every edit returns to that hub; **Start with these settings** is the final launch confirmation, **Save these settings globally and start** additionally persists the setup as a named preset (with host-scoped tier overrides) in your user config for reuse elsewhere, and **Exit without launching** cancels the launch. The rich preflight runs from a managed virtualenv (`scripts/provision-venv.sh`, at `~/.local/share/agent-launch/venv`) that the launcher re-execs into on the interactive path; when that venv is unavailable, or the call is non-interactive, or `TERM` is `dumb`/unset, the launcher falls back to numbered prompts, where `b` is the back command. Backend command names are resolved from the calling environment's `PATH`; shell functions are not re-entered. Codex child bindings are materialized as session-selected agent configs under the user cache, while Claude receives model and effort in `--agents` JSON when delegation is enabled. Review runs cross-family by default (`review_family`, default `cross`; `same` restores today's same-family projection): because the main's tiers are one model family, every dispatchable review route — native, onto, and ultracode — runs on the opposite family. The exception is `slash-review`, the host's own built-in review command (`/code-review` on Claude, with `ultra` for its deep multi-agent pass; `/review` on Codex): it needs no dependency and always resolves, but being the main's own command it cannot be dispatched cross-family, so under `cross` it runs as the same-family floor and its verdicts are labeled PROPOSED. A Claude main dispatches gpt/codex review (native via the `codex-run` reviewer wrapper resolved under `$CODEX_HOME/bin`, onto via an `llmOverride` to the configured openai seat, ultracode via the `$ultracode-for-codex` Codex skill); a Codex main dispatches Anthropic/Claude review (native via `claude -p --permission-mode plan`, onto via an `llmOverride` to the anthropic seat, ultracode via `claude --effort ultracode -p` — Claude Code's headless `/workflows` ultracode mode, verified accepted on claude 2.1.210). The concrete reviewer command, resolved absolute path, `llmOverride`, and opposite-family tier bindings are named in the injected session-start contract; cross-family reviewers are dispatched as read-only subprocesses, not CLI-native subagents, since neither CLI hosts the other family as a native subagent. When a cross-family route is unavailable at launch or unauthenticated at use time it degrades to same-family native subagent review labeled PROPOSED (family collapse) rather than blocking; a requested non-none review with no cross-family route and no same-family fallback (delegation off) stays fail-closed. Review setup means configured/requested; this launcher does not claim that review completed, and unavailable runtimes such as Ultrawork are not offered until integrated.
|
|
71
72
|
|
|
72
73
|
At the shell-wrapper boundary, every argument-bearing command (`codex exec ...`, `claude -p ...`) and every non-TTY invocation skips launch-profile projection and preserves caller arguments. The Claude direct path intentionally retains its wrapper default, `--dangerously-skip-permissions`. `codex --no-tui ...` / `claude --no-tui ...` explicitly take that direct path, and `AGENT_LAUNCH_TUI=0` disables zero-argument TUI interception for a process tree.
|
|
73
74
|
|
package/claude/CLAUDE.md
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
- Ask for the user's goal or constraint when that determines the answer; otherwise choose the safest default and proceed.
|
|
30
30
|
- Evaluate user suggestions for goal fit, risk, complexity, and verification before turning them into implementation plans; if a suggestion does not fit the user's goal, say so clearly and recommend a better path.
|
|
31
31
|
- Distinguish implementation feasibility from recommendation.
|
|
32
|
+
- Do not default to a restrictive lens (security, masking, capability limits) when the system's purpose is sharing or utilization; confirm the purpose framing first, and restrict only on concrete, named risk.
|
|
32
33
|
- Treat user suggestions, inherited premises, prior diagnoses, handoff and design claims, reviewer findings, and your own earlier conclusions as hypotheses, not facts; re-derive each load-bearing claim from real code or data before building on it, and record a dated correction in the source doc or memory when a finding overturns it.
|
|
33
34
|
|
|
34
35
|
## LLM And Capability Boundary
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
- Treat viability as real behavior against real inputs, real authority, and the intended runtime path. Use mocks only for tests, fixtures, or explicitly requested simulations; mock-backed paths support verification but do not count as product completion.
|
|
80
81
|
- Make surgical changes. Touch only what the request requires, preserve existing style, and avoid casual adjacent refactors.
|
|
81
82
|
- Clean up issues introduced by the current change. Mention unrelated dead code separately.
|
|
83
|
+
- Own the full lifecycle of what you create — spawned processes and handles through teardown, artifacts out of tool-managed temp locations into a durable home — and keep differently-owned state separate: never colocate deploy-managed and user-owned data in one overwrite-managed file.
|
|
82
84
|
- Define success criteria before multi-step coding work, then verify against them.
|
|
83
85
|
- For bugs, prefer a reproducing test before the fix when practical.
|
|
84
86
|
- Every changed line should trace back to the user's request.
|
|
@@ -97,23 +99,30 @@
|
|
|
97
99
|
- Report the checks run, results, and any unverified risk before calling the work done.
|
|
98
100
|
- Trust a green check only when it traversed the actual changed code through the real dispatch and real calls (not a mock, dry-run, or bypass), and remember that "it ran" is not "quality met" — a fallback, floor, or mock run is not done; treat a zero-findings verdict as suspect until you confirm the harness ran rather than silently crashed, and make PASS mean concrete assertions on real output from the real path.
|
|
99
101
|
- Make completion criteria falsifiable: prefer signals that fail when the mechanism is wrong (negative or contrast controls), and if no existing gate can judge a criterion, build the executable judge or do not claim the criterion met.
|
|
102
|
+
- Before comparing two of anything (cost, performance, quality, frequency), fix a common basis — units, denominators, population, measurement surface — compare on equivalent output, and exclude or flag non-representative data (promotions, outages, smoke slices).
|
|
100
103
|
- For non-trivial designs or high-risk changes, run independent adversarial review across distinct lenses, ideally on the design before implementation, and re-verify each finding against real code before acting on it. Apply the convergence heuristic by reviewer kind (detailed in the multi-model guide): same-kind convergence is high confidence but same-kind reviewers share blind spots — their shared "clean" is not verification; different-kind divergence is the expected signal — act on the union. Never accept an orchestrated workflow's self-reported all-green as sufficient; independently re-run the diff inspection and verification suite yourself.
|
|
101
|
-
- Proportion verification to cost, risk, and information gain: before expensive or slow live runs, diagnose in code and replay the changed deterministic logic over persisted real artifacts, probe at N=1 with inputs precondition-checked, and reserve full design-review-plus-live verification for first-of-kind or authority-changing work.
|
|
102
|
-
- Trust a green / zero-findings verdict only if the check could have failed over a real, non-empty subject: assert the entity-under-test set has cardinality > 0 before any "no bad X" or "all X satisfy P" claim (an empty subject set passes vacuously and proves nothing), and for any test touching a branch you add or delete, confirm its inputs satisfy the live branch's entry guard — a copied fixture that fails the new guard silently routes into the about-to-be-deleted dead branch and stays green even after the real behavior breaks. When a check goes green unexpectedly fast or empty, dump what it actually ran over.
|
|
104
|
+
- Proportion verification to cost, risk, and information gain: before expensive or slow live runs, diagnose in code and replay the changed deterministic logic over persisted real artifacts, probe at N=1 with inputs precondition-checked, and reserve full design-review-plus-live verification for first-of-kind or authority-changing work; proportion assurance to the deployment context — a single-user, own-data tool does not warrant production-grade assurance; prefer delivery.
|
|
105
|
+
- Trust a green / zero-findings verdict only if the check could have failed over a real, non-empty subject: assert the entity-under-test set has cardinality > 0 before any "no bad X" or "all X satisfy P" claim (an empty subject set passes vacuously and proves nothing), and for any test touching a branch you add or delete, confirm its inputs satisfy the live branch's entry guard — a copied fixture that fails the new guard silently routes into the about-to-be-deleted dead branch and stays green even after the real behavior breaks. When a check goes green unexpectedly fast or empty, dump what it actually ran over. Checker code itself must assert the expected shape and fail loud — a permissive fallback (`a || b`) inside a gate absorbs wrong assumptions and keeps passing.
|
|
103
106
|
|
|
104
107
|
## Tooling and Operational Safety
|
|
105
108
|
|
|
109
|
+
- For concrete shell/CLI traps — pipe exit codes, output rendering, git range/pull semantics, config and managed-service pitfalls — read and use `${CLAUDE_CONFIG_DIR:-$HOME/.claude}/guides/tooling-gotchas.md` as a scoped extension of this section.
|
|
110
|
+
- Ambient state — the active shell, cloud CLI project/context, command-name resolution, 'latest'-style pointers, version-bearing paths — drifts silently; where an outcome depends on it, pin it explicitly (a pinned interpreter, --project/--context flags, exact handles, resolved paths) instead of trusting the environment.
|
|
106
111
|
- Before relying on any model id, tool flag, API capability, dependency version, or runtime constraint, confirm it empirically against the live or installed artifact (a minimal probe, the binary's registered options, the installed package version) rather than docs, memory, or a version string.
|
|
107
|
-
- Scope destructive actions (kill, rm, force-push, reset --hard) to targets you own, identified by PID, path, or ancestry — never a broad command-line substring or blanket match — and diagnose the actual state before any irreversible git, remote, or process operation.
|
|
108
|
-
- Never accept secrets through transcript- or history-logged channels
|
|
112
|
+
- Scope destructive actions (kill, rm, force-push, reset --hard) to targets you own, identified by PID, path, or ancestry — never a broad command-line substring or blanket match — and diagnose the actual state before any irreversible git, remote, or process operation; snapshot the last good state before any in-place resume or overwrite of a completed run, and gate irreversible identity-tied actions (revoke, delete, grant, consent) on a live identity check — never auto-open a browser for a non-default identity (hand the operator the URL).
|
|
113
|
+
- Never accept secrets through transcript- or history-logged channels.
|
|
114
|
+
- When a secret must be supplied, provide a gitignored env slot, read the value only from the environment, verify its presence and format without echoing it, and advise rotating anything already pasted; assume a resource-creating call may echo the secret back in its success output — suppress or discard the response body, and treat an echoed secret as pasted (rotate).
|
|
109
115
|
- Treat a coarse runtime signal — a failure label, a `ps`/process-inspection result, idle CPU with no output — as a hypothesis, and confirm the cause against the authoritative low-level evidence the mechanism emits before attributing blame or intervening: read the raw provider/skill log payload (e.g. `input_tokens:0` proves a pre-dispatch rejection that exonerates your content and your change), and confirm a config/env toggle reached a subprocess via a cheap artifact the gated branch emits rather than an unreliable `ps` env read. A multi-minute LLM or subprocess call at ~0% CPU with an output gap is the normal signature of I/O wait, not a hang — check process state and the call trace's in-flight duration before acting, so you do not abort healthy long-running work.
|
|
110
|
-
- Before reasoning about what a branch contains or opening a PR, run `git fetch` and compute the range as `origin/<base>..HEAD`, never `<base>..HEAD` against the local tracking ref — on a shared repo the local base drifts behind the remote until you pull, silently inflating the diff with already-merged work; if the range is surprisingly large, suspect a stale base before suspecting the branch.
|
|
116
|
+
- Before reasoning about what a branch contains or opening a PR, run `git fetch` and compute the range as `origin/<base>..HEAD`, never `<base>..HEAD` against the local tracking ref — on a shared repo the local base drifts behind the remote until you pull, silently inflating the diff with already-merged work; if the range is surprisingly large, suspect a stale base before suspecting the branch. Platform "mergeable" flags are computed against the base only — sibling PRs can each look clean yet conflict; before picking a merge order, diff their changed-file sets and simulate the sequence.
|
|
111
117
|
|
|
112
118
|
## Multi-Model Workflow
|
|
113
119
|
|
|
120
|
+
- Standing spawn policy: check the spawn gates at every work-unit boundary — judgment latitude applies inside a gate, never to whether the gates are checked. Independence: verifying or reviewing your own work always spawns. Parallelism: two or more independent items spawn in parallel — SWEEP when each item applies one explicit rule and returns ambiguity as an exception, else WORKHORSE. Residual context: work whose log dwarfs the conclusion the main needs spawns with a bounded report contract. Escalation: an irreversible or authority-changing action ahead, two failed attempts, or two persisting design alternatives spawns a bounded FRONTIER judgment with a blind packet (evidence, constraints, rubric, neutral alternatives — never your draft conclusion) and a pre-noted change condition. Specifiability/de-minimis: work needing your live context, or whose verification would repeat the reasoning, or whose packet outweighs the work, stays inline.
|
|
121
|
+
- Down-spawns carry a machine-checkable done-when on decision-complete work with staged output (no external irreversible actions) and briefing-plus-verifying clearly cheaper than doing. Record one line per gate decision — `SpawnGate: <gate> <tier> spawn|inline — <why>` — and for FRONTIER record the disposition afterward (what changed, or why nothing did). A launch contract's `Delegation=off` lifts the spawn obligation, not the records; explicit user no-fan-out always wins.
|
|
114
122
|
- For work spanning multiple models or CLI agents, context resets and handoffs, unattended LLM batches (including orchestrated subagent fleets), or parallel worktree branches, read and use `${CLAUDE_CONFIG_DIR:-$HOME/.claude}/guides/cli-multi-model-workflow.md` as a scoped extension of this section.
|
|
115
123
|
- For composing a prompt, packet, or tool description aimed at a specific model family — including cross-family review dispatch, porting a prompt written for an older model, or choosing a reasoning-effort level for a model family — read and use `${CLAUDE_CONFIG_DIR:-$HOME/.claude}/guides/gpt-prompting.md` for gpt-family targets and `${CLAUDE_CONFIG_DIR:-$HOME/.claude}/guides/claude-prompting.md` for claude-family targets as scoped extensions of this section.
|
|
116
124
|
- Allocate models by difficulty × blast radius, not phase name; when implementation ran on a cheaper tier, compensate by raising reviewer effort or adding a reviewer kind — never economize on implementation and verification at once.
|
|
125
|
+
- When the user asks for design AND two or more providers are reachable at frontier tier, run dual-provider frontier design drafts: two independent drafts from the same blind packet, one per provider, compared and synthesized into the working draft. The consent gate is about metered spend, not the fan-out: a provider reached via an OAuth session (subscription-covered, no marginal cost) proceeds WITHOUT asking — if a non-main-context OAuth frontier provider exists, just run the dual-provider design; do not ask. Explicit per-request approval (never standing) is required ONLY before dispatching to a provider reachable solely via a metered API key, and it approves that spend. If withholding un-approved API spend leaves fewer than two providers, run single-provider rather than blocking the design on approval. Inject the corpus design principles (concept economy, LLM/capability boundary, staged workflow) into every dispatched design packet — an external model does not load this corpus.
|
|
117
126
|
- Never retry-storm a live rate limit: give unattended batches you author a code-level circuit breaker with per-item completion tracking (thresholds, backoff, and dead-letter rules in the guide); for third-party dispatchers, confirm equivalent protection exists or attend the run.
|
|
118
127
|
- On any resumed, cleared, or relocated session, re-verify where you are (pwd; in a repo, branch and HEAD) before acting on prior-session assumptions — against the pinned handoff state when one exists.
|
|
119
128
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontier
|
|
3
|
+
description: FRONTIER tier — bounded hardest decisions, first-of-kind design, triage gates, and final verdicts. Spawn when the Escalation gate fires — an irreversible or authority-changing action ahead, two failed attempts, or two persisting design alternatives — with a blind packet (evidence, constraints, rubric, neutral alternatives; no draft conclusion) and a pre-noted change condition.
|
|
4
|
+
model: claude-fable-5
|
|
5
|
+
effort: max
|
|
6
|
+
disallowedTools: [Edit, Write, NotebookEdit]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Resolve one bounded hardest decision, design question, triage gate, or verdict from the smallest sufficient evidence. Distinguish fact from inference. Do not implement, broaden scope, or seek wider authority. Report: status, decision, evidence, decisive tradeoffs and failure modes, falsifiable verification, risks_or_escalations.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sweep
|
|
3
|
+
description: SWEEP tier — cheap wide scans, candidate finding, mechanical checks, and closed-form summaries. Spawn when each item applies one explicit rule; ambiguity returns as an exception, never resolved.
|
|
4
|
+
model: claude-haiku-4-5
|
|
5
|
+
effort: low
|
|
6
|
+
disallowedTools: [Edit, Write, NotebookEdit]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Run one clear repeatable scan, candidate pass, mechanical check, or closed summary over exact inputs, rules, stop condition, and output shape. Read-only: do not edit, broaden scope, choose architecture, or seek authority. Parallelize independent reads. Surface ambiguity as an exception instead of inferring intent. Report: status, the non-empty items_checked, findings with proving evidence or command, risks_or_escalations.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workhorse
|
|
3
|
+
description: WORKHORSE tier — bounded implementation, fixes, tests, and per-item judgment. Spawn decision-complete work with frozen scope/interfaces and a machine-checkable done-when; two or more independent items spawn in parallel.
|
|
4
|
+
model: claude-sonnet-5
|
|
5
|
+
effort: high
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Complete one bounded implementation, fix, or per-item judgment from a packet naming objective, frozen scope and inputs, allowed actions, output, done-when, and verification. Preserve out-of-scope behavior; batch independent reads; escalate missing decisions or authority instead of resolving them. Stage output for the main's acceptance — no external irreversible actions (push, install, credential, or remote mutation). Run the narrowest reliable changed-path check. Report: status, files_or_items_touched, evidence, verification or gap, risks_or_escalations.
|
|
@@ -41,13 +41,14 @@ Main-context pollution is usually costlier than spawn overhead. Apply these gate
|
|
|
41
41
|
4. **Specifiability:** keep work local when it needs the main's live context or unresolved round-trips, especially deep debugging. Grind alone is not a FRONTIER reason.
|
|
42
42
|
5. **De-minimis:** do work directly when its dispatch packet would be larger than the work.
|
|
43
43
|
|
|
44
|
-
-
|
|
44
|
+
- **Escalation:** spawn FRONTIER first for a bounded judgment with material stakes (an irreversible or authority-changing action ahead, an architecture or public-interface commitment, or invalidation of two or more downstream units) and a named residual-risk signal (two failed attempts, two persisting alternatives, conflicting evidence, or an unverified assumption that can flip the decision). Pre-note the finding that would change what; send a blind packet — evidence, constraints, rubric, neutrally ordered alternatives, never the main's draft conclusion — and record the disposition afterward (what changed, or why nothing did; persistent no-change indicts the gate or the packet). Switch the main only when the judgment is not delegable.
|
|
45
45
|
- Every spawn gets a bounded report contract, artifact paths instead of pasted context, and an explicit model/effort pin. Never dump a worker transcript into the main.
|
|
46
46
|
- Explicit no-fan-out overrides standing authorization.
|
|
47
|
+
- Record one line per gate decision — `SpawnGate: <gate> <tier> spawn|inline — <why>` — plus the FRONTIER disposition. A launch contract's `Delegation=off` lifts the spawn obligation, not the records.
|
|
47
48
|
|
|
48
49
|
## Delegation Mechanics And Teammate Persistence
|
|
49
50
|
|
|
50
|
-
Delegate execution, not decisions. A unit is delegable only when it is decision-complete, self-containedly specifiable, machine-checkable at done-when, and bounded in blast radius.
|
|
51
|
+
Delegate execution, not decisions. A unit is delegable only when it is decision-complete, self-containedly specifiable, machine-checkable at done-when, and bounded in blast radius. Delegated output is staged until the main accepts it — workers take no external irreversible actions — and handling (brief, verify, correct, integrate) must be clearly subordinate to the work itself. A SWEEP-bound unit applies one explicit rule per item and returns ambiguity as an exception, never resolved.
|
|
51
52
|
|
|
52
53
|
- Re-cut units containing unresolved choice, discovery-before-spec, untestable completion, or unfrozen interfaces. A worker asking which direction to take is a sizing failure; the decision returns to the main.
|
|
53
54
|
- Bundle related sub-floor tasks up to the decision-complete ceiling. A scout is read-only and reports file:line evidence for named pending decisions, probing the highest kill-risk unknown first.
|
|
@@ -56,7 +57,8 @@ Delegate execution, not decisions. A unit is delegable only when it is decision-
|
|
|
56
57
|
- Use a resident teammate only for dependent slices in one burst. Verify that the CLI preserves its model and context; resume-after-completion may silently change both. Retire after the burst or cache TTL, and persist durable knowledge in files.
|
|
57
58
|
- After a discard or direction change, respawn once a routine round costs about as much as a fresh slice. Recover unique in-flight state to files first.
|
|
58
59
|
- Redirects to busy workers may queue rather than preempt. Check artifacts before destructive redirects, phrase them conditionally, and stop an actively harmful worker by scoped PID/worktree authority.
|
|
59
|
-
- Idle/progress notifications are hypotheses; verify repo artifacts before re-dispatch. Cross-reset state belongs in files, not task boards or transcripts.
|
|
60
|
+
- Idle/progress notifications are hypotheses; verify repo artifacts before re-dispatch. Cross-reset state belongs in files, not task boards or transcripts. When polling concurrent async jobs, pin the exact id/handle received at dispatch — a "latest" convenience selector can silently point at a sibling job and return plausible-but-wrong results.
|
|
61
|
+
- Give reviewers/subagents a read-only diff, snapshot, or isolated worktree — not the live tree the main is editing — and forbid destructive git ops (checkout --, reset --hard, stash, clean) on any tree with uncommitted work; re-verify tree integrity before trusting results produced mid-edit.
|
|
60
62
|
- Review cost scales with the diff, so layered review preserves delegation savings. Lower reviewer tier before dropping a review kind.
|
|
61
63
|
|
|
62
64
|
## Driving Codex CLI Directly
|
|
@@ -104,6 +106,13 @@ Instruction/config reach is per invocation. A rule in AGENTS.md cannot bind a he
|
|
|
104
106
|
- Run deterministic gates before LLM review. Funnel SWEEP finders → WORKHORSE judgments → FRONTIER triage/verdicts.
|
|
105
107
|
- On family collapse, record the downgrade and label clean verdicts PROPOSED until diversity is restored.
|
|
106
108
|
- A silent/dead lens is incomplete, never clean. Confirm liveness from usage/error/report evidence; rerun, swap provider, or report PROPOSED.
|
|
109
|
+
- Kind labels do not guarantee distinct backends: wrappers and rate-limit fallbacks can silently route two "different-kind" verifiers to the same model/provider. Before trusting diversity on a high-stakes verdict, confirm each verifier's actual backing model from live process or usage evidence; on collapse, treat the pair as one kind and label PROPOSED.
|
|
110
|
+
|
|
111
|
+
## Dual-Provider Design Drafts
|
|
112
|
+
|
|
113
|
+
- Trigger: the task is design (the staged-workflow guide's design stages) AND two or more providers are reachable at frontier tier. Reachability via an OAuth session is subscription-covered — no marginal spend, so no approval and no question: if a non-main-context OAuth frontier provider exists, proceed with the dual-provider design directly. The consent gate applies ONLY to a provider reachable solely via a metered API key: dispatching to it needs the user's explicit per-request approval of that spend (per-request, not standing — an old approval does not carry to the next design). If the only way to reach a second provider is un-approved metered API spend, stay single-provider rather than blocking the design.
|
|
114
|
+
- Mechanics: compose ONE blind packet (evidence, constraints, rubric, neutral alternatives — the escalation-gate packet shape) and dispatch it unchanged to one frontier-tier model per provider; drafts stay independent — neither sees the other's output. Then adjudicate: compare the two dual-provider frontier design drafts against the rubric, take the winner as the skeleton, graft the loser's superior parts, and record what differed and why the synthesis chose as it did (FRONTIER disposition line).
|
|
115
|
+
- Packet injection: a dispatched designer is hermetic — it reads only its packet and never loads this corpus. Inject the design principles the corpus would have supplied: concept economy (reuse/extend/rename/split, compact concept graph), the LLM/tools-code capability boundary, the staged-workflow design rules (smallest viable path, falsifiable done-when), and any domain-specific principles the design touches. A draft produced without the principles is not comparable to one produced with them.
|
|
107
116
|
|
|
108
117
|
## Unattended Batch Safety
|
|
109
118
|
|
|
@@ -117,6 +126,8 @@ Instruction/config reach is per invocation. A rule in AGENTS.md cannot bind a he
|
|
|
117
126
|
- Resume-first from artifacts that parse, pass schema, and match their recorded source/config/HEAD fingerprint; unverifiable means invalid.
|
|
118
127
|
- Resubmit one invalid unit unless failures are broadly correlated, which is structural and halts the run.
|
|
119
128
|
- Treat halt→continue as normal operation.
|
|
129
|
+
- Treat tool-managed temp/cache output locations as ephemeral — they are garbage-collected on the tool's own schedule. Copy any artifact a pending or handed-off decision depends on into a project-owned durable path before relying on it later.
|
|
130
|
+
- Bounded-size cross-session indexes (memory index files) truncate silently past their read limit. Compare size against the limit periodically; before compacting, migrate index-only detail into per-item files, then verify links and no orphans.
|
|
120
131
|
|
|
121
132
|
## Sessions, Branches, Worktrees
|
|
122
133
|
|
|
@@ -124,6 +135,7 @@ Instruction/config reach is per invocation. A rule in AGENTS.md cannot bind a he
|
|
|
124
135
|
- For a new worktree, relocate natively or write a handoff and start fresh. Re-integrate branches serially and re-verify after each merge.
|
|
125
136
|
- Mark superseded worktrees/handoffs dead so later resume cannot select them.
|
|
126
137
|
- After resume/clear/relocation, verify pwd, branch, and HEAD against the pinned handoff before acting.
|
|
138
|
+
- Attribute a parallel session's action (commit, branch, resource) by execution evidence in that session's own transcript, never by token mentions — shared handoff/memory files inject the same tokens into every session's context.
|
|
127
139
|
|
|
128
140
|
## Handoff Contract
|
|
129
141
|
|
|
@@ -131,11 +143,12 @@ Write for the next agent and re-verification, not narrative. Required content:
|
|
|
131
143
|
|
|
132
144
|
1. One-line current state.
|
|
133
145
|
2. Pinned worktree, branch, HEAD, upstream/merge-base, author tier, and active fallback/family collapse.
|
|
134
|
-
3. CONFIRMED claims whose cited command or anchored file evidence independently re-establishes them.
|
|
146
|
+
3. CONFIRMED claims whose cited command or anchored file evidence independently re-establishes them. Anchor code citations by stable symbol names (grep-re-derivable), not bare line numbers, which drift silently under later edits.
|
|
135
147
|
4. Separate PROPOSED/OPEN items, including inherited claims not re-verified this session.
|
|
136
148
|
5. Ordered next actions and the literal first command: model, orchestration authorization, and guide load for T1+.
|
|
137
149
|
6. Credentials only by env-var/gitignored slot; scrub secrets from excerpts and commands.
|
|
138
150
|
|
|
151
|
+
- Never record the hash of the commit that will contain the record itself — it is unstable by construction. Land substantive changes first and reference the settled hash from a follow-up commit, or use a relative phrase ("resume from the commit containing this handoff").
|
|
139
152
|
- A broken evidence anchor demotes CONFIRMED to PROPOSED. If pinned state fails or no trustworthy handoff exists, rebuild from source artifacts and write a fresh handoff before acting.
|
|
140
153
|
- Store handoffs in the working repo's isolated dated docs path, never this instruction-SSOT repo. Re-verify load-bearing claims on resume.
|
|
141
154
|
|
|
@@ -32,6 +32,8 @@ When the user asks to "설계" or design, stay in design mode. Focus on high-lev
|
|
|
32
32
|
2. Implementation-process design: turn the design into an ordered work plan with dependencies, verification points, review gates, and redesign triggers.
|
|
33
33
|
3. Implementation: make the smallest viable functional changes that satisfy the approved design and process plan.
|
|
34
34
|
|
|
35
|
+
When simplifying a pipeline, moving processing downstream and dropping captured source fields are separate decisions: relocation is free simplification, but reducing captured information is riskier and needs explicit confirmation — "no current consumer" is not evidence of no future value.
|
|
36
|
+
|
|
35
37
|
## Review Loop
|
|
36
38
|
|
|
37
39
|
- At each stage, run review loops as appropriate: self review, subagent review when available, and structured multi-lens review when the repository or domain supports one (concrete tool: Environment Binding below).
|
|
@@ -41,6 +43,7 @@ When the user asks to "설계" or design, stay in design mode. Focus on high-lev
|
|
|
41
43
|
- Treat high as supported user, environment, data, or execution path failure.
|
|
42
44
|
- Treat medium as meaningful weakening of trust, auditability, reproducibility, completeness, or decision quality.
|
|
43
45
|
- Treat low and info as non-blocking unless requested or promoted by new evidence.
|
|
46
|
+
- When a document declares sections co-authoritative for a rule (fixture blocks, conformance appendices), treat every occurrence as one replicated value: propagate edits to all declared locations in the same pass and check propagation completeness explicitly in review.
|
|
44
47
|
|
|
45
48
|
## Verification Menus
|
|
46
49
|
|
|
@@ -51,6 +54,11 @@ Per-domain menus for the global Verification Discipline loop; pick the narrowest
|
|
|
51
54
|
- Config or data: real parsers, schema checks, fixture validation, and sample transformations.
|
|
52
55
|
- Spreadsheets: static workbook checks, fixture-based output checks, cross-sheet flow checks, visual/layout checks, and real Microsoft Excel engine recalculation for formula-dependent results.
|
|
53
56
|
- Docs: links, terminology, current behavior alignment, and references to isolated historical notes.
|
|
57
|
+
- Release or distribution: after publishing to multiple independently writable channels (signed manifest, object storage, release host, embedded updater), digest-verify every referenced object against the staging original per channel — publish success and upload order are not evidence — and run the real installer/updater through its default path.
|
|
58
|
+
- A/B or on/off measurements: before accepting a null result, verify the arms actually received different treatment in the mechanism under test — a shared default or unconditional upstream step can silently apply the treatment to both arms.
|
|
59
|
+
- Model-behavior guardrails: verify by changed behavior, not recitation — a staged battery from named-trigger cases through disguised, deconfounded, category-wide, and single-variable framings; a clean pass means "no known defect", so re-run the battery when the model changes.
|
|
60
|
+
- Branch/version test builds against real data: explicitly separate every state sink the app touches (files, DB, OS-level stores that ignore env overrides), confirm the launch path propagates the isolation to child processes, and back up live data before the first run — a mismatched schema that drops unknown fields on write is data loss, not a no-op.
|
|
61
|
+
- Irreversible capture switches: when activation itself has unreproducible cost (a capture window that cannot be replayed), prove the downstream consumption path against existing samples before enabling — reversibility of the code path alone is not enough.
|
|
54
62
|
|
|
55
63
|
## Stop Conditions
|
|
56
64
|
|
|
@@ -278,6 +278,11 @@ Required rules:
|
|
|
278
278
|
- Log tool calls, arguments, policy decisions, and results for audit.
|
|
279
279
|
- Rate-limit and timeout tools that can loop, scan, spend, mutate, or call the
|
|
280
280
|
network.
|
|
281
|
+
- Resolve every authorization/allowlist entry against the live runtime key
|
|
282
|
+
space at boot or deploy — format validation only proves well-formedness, and
|
|
283
|
+
a mis-formatted entry can pass every deploy check while silently denying its
|
|
284
|
+
whole route class. Verify fixes with an explicit negative control plus a
|
|
285
|
+
live end-to-end call through the redeployed system.
|
|
281
286
|
|
|
282
287
|
The LLM can recommend an action. The capability surface decides whether the
|
|
283
288
|
action is available, permitted, confirmed, and accepted.
|
|
@@ -246,6 +246,15 @@ Examples:
|
|
|
246
246
|
- A mock provider can prove retry handling.
|
|
247
247
|
- A mock provider cannot prove the real provider integration is production-ready.
|
|
248
248
|
|
|
249
|
+
Connected cloud documents (live Sheets/Docs with bound scripts, triggers,
|
|
250
|
+
permissions, protections, named ranges, external references) are live
|
|
251
|
+
integrated systems, not portable files: unless the user explicitly asks for a
|
|
252
|
+
copy/export, edit in place through the native authority (connected-document
|
|
253
|
+
MCP/API). Before writing, enumerate the beyond-cell elements so none are
|
|
254
|
+
silently dropped, and report external load states (loading, timeout, quota,
|
|
255
|
+
permission-denied, broken reference) distinctly instead of collapsing them
|
|
256
|
+
into one success/failure.
|
|
257
|
+
|
|
249
258
|
## Design Procedure
|
|
250
259
|
|
|
251
260
|
Use this procedure before adding or extending mock behavior.
|
|
@@ -196,6 +196,14 @@ Two consequences for anyone consuming a review:
|
|
|
196
196
|
the channel that fires uses the wrong name, and the truth is only in the nested
|
|
197
197
|
stderr. Read the channel the mechanism actually writes, confirmed against the
|
|
198
198
|
low-level log, not the one named for the thing you want.
|
|
199
|
+
- Participation tells you the lenses ran, not that they saw the whole subject.
|
|
200
|
+
Git-diff-based review tools silently omit staged-but-uncommitted changes from
|
|
201
|
+
a HEAD-range diff, and untracked files from any diff. Before dispatch, list
|
|
202
|
+
the subject with `git status --porcelain` and expose untracked files
|
|
203
|
+
(`git add -N` or a WIP commit); after the run, compare the reviewed-file list
|
|
204
|
+
against that listing — an unexplained gap demotes the verdict to incomplete.
|
|
205
|
+
(Our own dispatch wrapper does this check itself; apply this manually on
|
|
206
|
+
review routes we do not own.)
|
|
199
207
|
- A review deliverable names the findings it *rejected* as well as the ones it
|
|
200
208
|
kept, so a finding's presence in the document is not its survival. Deriving
|
|
201
209
|
survival from presence returns 100% by construction — it did here, until the
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
guide_id: session-distill-workflow
|
|
3
|
+
language: en
|
|
4
|
+
status: active
|
|
5
|
+
use_when:
|
|
6
|
+
- a session was launched with the Session distill preset (mission-injected)
|
|
7
|
+
- the launcher nudge says enough sessions accumulated for a mining window
|
|
8
|
+
- mining local Claude/Codex sessions for learnings absent from the corpus
|
|
9
|
+
- promoting, incubating, or retiring items in the session-distill ledger
|
|
10
|
+
core_rules:
|
|
11
|
+
- the ledger and HANDOFF are the SSOT; read them before touching the pipeline
|
|
12
|
+
- placement follows PLACEMENT-FRAMEWORK.md, never ad-hoc judgment
|
|
13
|
+
- every promotion passes an explicit user-approval gate
|
|
14
|
+
- global growth per round is hard-capped (~500 tokens) by a measured gate
|
|
15
|
+
- close the window by updating mirrors, parity, deployment, and the nudge baseline
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Session-Distill Workflow
|
|
19
|
+
|
|
20
|
+
Runbook for a session-distill run: mine recent main-context sessions,
|
|
21
|
+
verify candidates, place them through the framework, and apply with the user.
|
|
22
|
+
Everything durable lives in the agent-bios repo.
|
|
23
|
+
|
|
24
|
+
## Read first (SSOT)
|
|
25
|
+
|
|
26
|
+
1. `design/session-distill/HANDOFF.md` — initiative state, prior decisions,
|
|
27
|
+
open threads. 2. `design/session-distill/PLACEMENT-FRAMEWORK.md` — the
|
|
28
|
+
placement authority (typology A–G, layers, admission bars, lifecycle).
|
|
29
|
+
3. `design/session-distill/ledger.json` — cumulative item states
|
|
30
|
+
(placed / incubating / absorbed / retired) with provenance.
|
|
31
|
+
|
|
32
|
+
## Stage 1 — Mine (pipeline in `scripts/session-distill/`)
|
|
33
|
+
|
|
34
|
+
Run in order; each stage reads the previous stage's `out/`:
|
|
35
|
+
|
|
36
|
+
1. `census.py --end YYYY-MM-DD` — enumerate from both providers'
|
|
37
|
+
history.jsonl; keep only directly-handled main-context sessions by
|
|
38
|
+
transcript-side provenance (dispatched = Codex source=exec /
|
|
39
|
+
Claude sidechain/sdk-cli/agentId).
|
|
40
|
+
2. `digest.py` — one secret-redacted digest per session with deterministic
|
|
41
|
+
6-criteria signals. Screen ALL digests; triage orders, never drops.
|
|
42
|
+
3. Provider-affine screening against the concatenated live baseline
|
|
43
|
+
(CLAUDE.md + guides): `screen-claude.js` (Workflow) and
|
|
44
|
+
`screen-codex.js` (ultracode). Novelty is judged against real baseline
|
|
45
|
+
text, not memory.
|
|
46
|
+
4. `consolidate.js` — dedup + independent novelty verification. Rank by
|
|
47
|
+
strength (recurrence × materiality), never by self-reported confidence.
|
|
48
|
+
5. `bundle_final.py` — tiered bundle. Merge new candidates into
|
|
49
|
+
`ledger.json` by cluster identity so recurrence accumulates across
|
|
50
|
+
windows (incubated items promote when they re-occur).
|
|
51
|
+
|
|
52
|
+
## Stage 2 — Review with the user
|
|
53
|
+
|
|
54
|
+
- Produce a Korean review edition as a local repo file (this user cannot
|
|
55
|
+
access web artifact renders): per item, principle, why it was selected,
|
|
56
|
+
verdict, and placement recommendation, with stable IDs.
|
|
57
|
+
- Decisions, in order: ① selection against the promotion bar (recurrence ≥2
|
|
58
|
+
or single-event high materiality — irreversible / verification-corrupting /
|
|
59
|
+
security); ② PROPOSED resolutions (never silently resolved); ③ G-candidate
|
|
60
|
+
adoption. Record every decision in the ledger.
|
|
61
|
+
|
|
62
|
+
## Stage 3 — Classify and apply (§P8)
|
|
63
|
+
|
|
64
|
+
- Walk each accepted item through the framework pipeline: type (A–G) →
|
|
65
|
+
leftward reformulation (fact→principle, knowledge→structure) → layer →
|
|
66
|
+
consumer check (hermetic dispatch and scripts read no prose) → admission
|
|
67
|
+
bar → token estimate. Ambiguity stays PROPOSED for the user.
|
|
68
|
+
- Apply canonical-first, on a branch, stepwise commits: canonical guide text
|
|
69
|
+
→ global edits under the measured budget gate (net growth ≤ ~500 tokens/
|
|
70
|
+
round; overflow re-routes to guides, not silent deferral) → other guides →
|
|
71
|
+
hooks (derive injected text from the canonical guide; read-only, never
|
|
72
|
+
blocking) → enforcement in owned wrappers (loud failures; keep
|
|
73
|
+
stdout/stderr channel contracts) → codex/ + ko/ mirrors.
|
|
74
|
+
- Verify per layer, not just by diff: enforcement/gate fixture tests
|
|
75
|
+
(non-vacuous — known-bad must fire), hook trigger positive/negative sets,
|
|
76
|
+
`scripts/check-parity.sh` exit 0 unpiped, prompting-target gate, then
|
|
77
|
+
`agent-bios install` to activate and re-verify.
|
|
78
|
+
|
|
79
|
+
## Stage 4 — G-pass (principles, not directives)
|
|
80
|
+
|
|
81
|
+
- Mine user-correction turns (deterministic marker extraction over digests)
|
|
82
|
+
and initiative-arc retrospectives; add upward distillation over newly
|
|
83
|
+
placed directives (≥3 sharing one value → parent-principle candidate).
|
|
84
|
+
- G evidence bar is higher: ≥3 independent consistent resolutions, or one
|
|
85
|
+
user-confirmed arc retrospective. A principle must name the tension, the
|
|
86
|
+
ordering, and what it forbids. For an under-applied gap (rule exists but
|
|
87
|
+
behavior does not follow), prose repetition is invalid — list it for the
|
|
88
|
+
behavior battery and change the surface instead.
|
|
89
|
+
|
|
90
|
+
## Stage 5 — Close the window
|
|
91
|
+
|
|
92
|
+
1. Ledger: statuses to placed (with implementation paths) / incubating;
|
|
93
|
+
dated corrections for anything refuted.
|
|
94
|
+
2. HANDOFF: completion record, incidental finds as next-window candidates.
|
|
95
|
+
3. Register the corpus version: append {version = window end, commit = the
|
|
96
|
+
corpus-close commit} to `design/session-distill/versions.json` — this is
|
|
97
|
+
what the launcher's Versions & rollback screen offers — then run
|
|
98
|
+
`python3 scripts/session-distill/update-state.py --window-end <date>`
|
|
99
|
+
(nudge baseline) and `corpus-state.py project` (launcher status panel).
|
|
100
|
+
4. Merge the branch, push, and confirm deployed state (`agent-bios verify`).
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
guide_id: tooling-gotchas
|
|
3
|
+
language: en
|
|
4
|
+
status: active
|
|
5
|
+
use_when:
|
|
6
|
+
- a shell command's exit code or output will gate a pass/fail or verification decision
|
|
7
|
+
- a tool returns empty / no-match / not-found output that contradicts other evidence
|
|
8
|
+
- running git diff over ranges, or pulling into a worktree with local changes
|
|
9
|
+
- passing dynamic or untrusted strings through a shell command line
|
|
10
|
+
- operating cloud/managed-service CLIs, update APIs, or secrets-bearing config
|
|
11
|
+
- spawning subprocesses or long-lived handles
|
|
12
|
+
core_rules:
|
|
13
|
+
- pin ambient state (interpreter, CLI context, command resolution) where an outcome depends on it
|
|
14
|
+
- a piped command's exit code reflects only the last stage — capture the stage under test
|
|
15
|
+
- treat surprising empty output as a tool artifact hypothesis before a world fact
|
|
16
|
+
- git two-dot diff is a snapshot comparison, not a range exclusion; protect dirty worktrees before pulling
|
|
17
|
+
- own the full lifecycle of anything you spawn
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Tooling Gotchas
|
|
21
|
+
|
|
22
|
+
Concrete, tool-level traps behind the global principles. Claude-side hook
|
|
23
|
+
injections derive their text from this file — edit here, never in the hook
|
|
24
|
+
data (single source of truth).
|
|
25
|
+
|
|
26
|
+
## Ambient state drifts — pin it
|
|
27
|
+
|
|
28
|
+
Instances of the global rule: ambient state silently drifts; where an outcome
|
|
29
|
+
depends on it, pin it explicitly instead of trusting the environment.
|
|
30
|
+
|
|
31
|
+
- **Interpreter**: the default shell differs across machines (zsh/bash/dash)
|
|
32
|
+
and bash-only idioms misbehave silently elsewhere (unquoted-variable word
|
|
33
|
+
splitting, `read -r -d ''` hangs). Don't probe the shell per command — make
|
|
34
|
+
shell identity irrelevant: keep inline one-liners POSIX-portable; when a
|
|
35
|
+
bash-specific feature (arrays, `read -d`, `PIPESTATUS`) is needed, pin the
|
|
36
|
+
interpreter with a `#!/bin/bash` script file or `bash -c '…'`. The session
|
|
37
|
+
environment block already declares the shell — read it for free; probe only
|
|
38
|
+
when diagnosing a misbehavior.
|
|
39
|
+
- **Command resolution**: a command name is not a fixed binary — interactive
|
|
40
|
+
shells resolve functions/aliases first, programmatic spawns resolve raw
|
|
41
|
+
PATH, and a same-named package can shadow a system tool with silent empty
|
|
42
|
+
output. Before trusting a result across execution contexts, confirm the
|
|
43
|
+
resolved target (`type -a`, absolute path).
|
|
44
|
+
- **Cloud CLI context**: gcloud/aws/kubectl/terraform carry mutable ambient
|
|
45
|
+
context (active project, profile, cluster) that drifts between sessions.
|
|
46
|
+
Before the first environment-affecting command — or right after a resume —
|
|
47
|
+
verify it against intent, then pin the target explicitly on every command
|
|
48
|
+
(`--project`, `--profile`, `--context`) rather than fixing the global
|
|
49
|
+
default once.
|
|
50
|
+
- **Installed is not running**: a live process keeps its old code until
|
|
51
|
+
restarted or reloaded. When confirming an update, config change, or
|
|
52
|
+
dependency bump took effect, don't stop at the on-disk artifact — confirm
|
|
53
|
+
the running process's actual version/behavior or force a restart.
|
|
54
|
+
|
|
55
|
+
## Shell execution traps
|
|
56
|
+
|
|
57
|
+
- **Pipe exit masking**: `$?` after a pipeline reflects only the last stage;
|
|
58
|
+
a real failure in the command under test is masked by a successful
|
|
59
|
+
`tail`/`grep`/`jq` and reads as a false green. Capture the tested stage's
|
|
60
|
+
own status: run it unpiped, store `$?` immediately, or use
|
|
61
|
+
`set -o pipefail`/`PIPESTATUS` — noting pipefail breaks legitimate
|
|
62
|
+
early-exit consumers (`cmd | head -1` → SIGPIPE 141), so it is a per-command
|
|
63
|
+
choice, not a global default. Does not apply when the final stage IS the
|
|
64
|
+
assertion (`cmd | grep -q pattern`).
|
|
65
|
+
- **Reserved parameter names**: assigning to reserved shell names (`UID`,
|
|
66
|
+
`EUID`, `GID`, `PPID`) can invoke the bound system behavior instead of
|
|
67
|
+
storing a value — silently changing process credentials mid-script. Use
|
|
68
|
+
unreserved names; if such an assignment already ran alongside a
|
|
69
|
+
side-effecting command, verify the resulting system state directly instead
|
|
70
|
+
of assuming the mistake inhibited the command.
|
|
71
|
+
- **Metacharacter-bearing values**: prompts, filenames, or content strings
|
|
72
|
+
that may contain `$`, backticks, quotes, or globs must not be inlined as
|
|
73
|
+
raw CLI arguments — the shell expands or mangles them before the target
|
|
74
|
+
process sees them. Pass via stdin, heredoc, or a temp file. (Our dispatch
|
|
75
|
+
scripts codex-run/codex-helm already accept stdin — use that path.)
|
|
76
|
+
- **Multi-line pasted commands**: a command pasted across lines without
|
|
77
|
+
continuation markers can be re-wrapped into two invocations, silently
|
|
78
|
+
dropping trailing flags (a real incident: `--scopes` lost during an auth
|
|
79
|
+
flow → wrong-scope credential). After running one, verify the target's
|
|
80
|
+
actual state (granted scopes, applied settings); on re-run, join to one
|
|
81
|
+
line or use explicit continuations.
|
|
82
|
+
|
|
83
|
+
## Tool output is a rendering, not the bytes
|
|
84
|
+
|
|
85
|
+
- **grep binary heuristic**: grep silently treats heavy non-ASCII or
|
|
86
|
+
NUL-containing text files as binary and returns a false no-match without
|
|
87
|
+
error. When a no-match contradicts other evidence (git diff, an earlier
|
|
88
|
+
read), re-check with the harness Grep tool (ripgrep) or `grep -a`, or read
|
|
89
|
+
the file directly.
|
|
90
|
+
- **Viewer normalization**: file-read tools can render non-printable bytes
|
|
91
|
+
(NUL) as visually indistinguishable blanks. When correctness rides on
|
|
92
|
+
byte-exact content (delimiters, encodings), verify with `hexdump`/`od` or a
|
|
93
|
+
byte-comparing script, not the rendered view.
|
|
94
|
+
- **Stale caches in rapid loops**: mtime/size-keyed compile or rewrite caches
|
|
95
|
+
can re-serve a previous file's result when mutate→test cycles run within
|
|
96
|
+
timestamp resolution (mutation testing). Clear the cache or run no-cache
|
|
97
|
+
per iteration, and re-confirm the unmutated baseline still passes after a
|
|
98
|
+
cache clear.
|
|
99
|
+
|
|
100
|
+
## Git operations
|
|
101
|
+
|
|
102
|
+
- **Two-dot diff semantics**: `git diff A..B` is a direct snapshot
|
|
103
|
+
comparison — unlike `git log A..B` it excludes nothing, so a lagging
|
|
104
|
+
merge-base injects unrelated upstream changes into the diff. For PR/review
|
|
105
|
+
diffs use `git diff origin/base...HEAD` (merge-base form); suspect this
|
|
106
|
+
mechanism first when a diff looks too large or shows deletions in untouched
|
|
107
|
+
files.
|
|
108
|
+
- **Dirty-worktree pulls**: before pulling into a worktree with
|
|
109
|
+
staged/unstaged/untracked changes, fetch first and compare incoming paths
|
|
110
|
+
against every dirty path; on overlap or a non-fast-forward, stop and clear
|
|
111
|
+
the conflict risk (stash, commit, ask). Otherwise pull `--ff-only`, confirm
|
|
112
|
+
dirty changes survived, and regenerate any local derived artifacts whose
|
|
113
|
+
inputs were updated.
|
|
114
|
+
|
|
115
|
+
## Config, secrets, and managed services
|
|
116
|
+
|
|
117
|
+
- **Verbatim slicing over parse-reserialize**: when provisioning part of a
|
|
118
|
+
user's structured config (TOML/YAML/INI) that may carry secrets and
|
|
119
|
+
comments, extract the section's raw text instead of parsing and
|
|
120
|
+
re-serializing — rewrites silently drop comments, formatting, or secret
|
|
121
|
+
values. Use a parser only for real structural change, and test the slicer
|
|
122
|
+
against actual shapes first.
|
|
123
|
+
- **Merge-not-replace update APIs**: managed-service update calls (secret
|
|
124
|
+
rotation, mount changes) often merge new definitions into the existing set,
|
|
125
|
+
leaving stale, unreferenced definitions live. After updating, re-read the
|
|
126
|
+
resource, check definitions and active references separately, and remove
|
|
127
|
+
the orphans explicitly.
|
|
128
|
+
- **Perimeter controls need the enforcement point's own logs**: an agent-side
|
|
129
|
+
fetch is not an independent external observer — its egress IP and caching
|
|
130
|
+
path are opaque, and it may share the protected network or serve a stale
|
|
131
|
+
cached response. Verify allow AND deny directions from the load balancer /
|
|
132
|
+
firewall's own logs, and check for a front-side cache/CDN separately.
|
|
133
|
+
- **Smoke limits outlive the smoke test**: item caps, sample sizes, and row
|
|
134
|
+
limits left in env vars/flags/config make a later "full-scale" run silently
|
|
135
|
+
succeed on a slice. Clearing or explicitly verifying their absence is a
|
|
136
|
+
precondition of declaring a full run.
|
|
137
|
+
- **Shared live config has concurrent writers**: before concluding your edit
|
|
138
|
+
to a shared state/config file was lost or corrupting, rule out concurrent
|
|
139
|
+
writers with a short live observation (mtime plus the fields you changed),
|
|
140
|
+
and scope merge/union operations to the intended fields only.
|
|
141
|
+
- **Production probes expose data**: default diagnostic queries against
|
|
142
|
+
production stores to read-only server-side aggregation (counts, types,
|
|
143
|
+
presence, hashes) — never pull raw payloads into logs, prompts, or
|
|
144
|
+
transcripts — and delete scratch probe resources after the decision.
|
|
145
|
+
|
|
146
|
+
## Own what you spawn
|
|
147
|
+
|
|
148
|
+
Instance of the global rule: own the full lifecycle of what you create.
|
|
149
|
+
|
|
150
|
+
- **Subprocess/handle lifecycle**: creating a subprocess means owning spawn
|
|
151
|
+
(set up a process group), result acquisition, and teardown — close owned
|
|
152
|
+
stdio handles, kill exactly that group (not just a wrapper PID, which
|
|
153
|
+
orphans the real child), and await exit. An unref'd child handle or open
|
|
154
|
+
stdin pipe keeps the parent's event loop alive and hangs otherwise-complete
|
|
155
|
+
commands.
|