agent-bios 0.2.0 → 0.3.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/claude/CLAUDE.md +12 -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 +11 -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-learning-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 +12 -5
- package/codex/config-additions.toml +22 -0
- package/codex/guides/cli-multi-model-workflow.md +11 -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-learning-workflow.md +100 -0
- package/codex/guides/tooling-gotchas.md +155 -0
- package/config/agent-launch.toml +17 -0
- package/package.json +4 -1
- package/scripts/agent-launch.py +357 -12
- package/scripts/check-parity.sh +65 -3
- package/scripts/codex-helm.sh +19 -1
- package/scripts/codex-run.sh +19 -0
- package/scripts/install.sh +162 -2
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,20 +99,25 @@
|
|
|
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; 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.
|
|
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; 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
114
|
- 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.
|
|
115
|
+
- 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
116
|
|
|
112
117
|
## Multi-Model Workflow
|
|
113
118
|
|
|
119
|
+
- 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.
|
|
120
|
+
- 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
121
|
- 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
122
|
- 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
123
|
- 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.
|
|
@@ -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,7 @@ 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.
|
|
107
110
|
|
|
108
111
|
## Unattended Batch Safety
|
|
109
112
|
|
|
@@ -117,6 +120,8 @@ Instruction/config reach is per invocation. A rule in AGENTS.md cannot bind a he
|
|
|
117
120
|
- Resume-first from artifacts that parse, pass schema, and match their recorded source/config/HEAD fingerprint; unverifiable means invalid.
|
|
118
121
|
- Resubmit one invalid unit unless failures are broadly correlated, which is structural and halts the run.
|
|
119
122
|
- Treat halt→continue as normal operation.
|
|
123
|
+
- 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.
|
|
124
|
+
- 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
125
|
|
|
121
126
|
## Sessions, Branches, Worktrees
|
|
122
127
|
|
|
@@ -124,6 +129,7 @@ Instruction/config reach is per invocation. A rule in AGENTS.md cannot bind a he
|
|
|
124
129
|
- For a new worktree, relocate natively or write a handoff and start fresh. Re-integrate branches serially and re-verify after each merge.
|
|
125
130
|
- Mark superseded worktrees/handoffs dead so later resume cannot select them.
|
|
126
131
|
- After resume/clear/relocation, verify pwd, branch, and HEAD against the pinned handoff before acting.
|
|
132
|
+
- 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
133
|
|
|
128
134
|
## Handoff Contract
|
|
129
135
|
|
|
@@ -131,11 +137,12 @@ Write for the next agent and re-verification, not narrative. Required content:
|
|
|
131
137
|
|
|
132
138
|
1. One-line current state.
|
|
133
139
|
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.
|
|
140
|
+
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
141
|
4. Separate PROPOSED/OPEN items, including inherited claims not re-verified this session.
|
|
136
142
|
5. Ordered next actions and the literal first command: model, orchestration authorization, and guide load for T1+.
|
|
137
143
|
6. Credentials only by env-var/gitignored slot; scrub secrets from excerpts and commands.
|
|
138
144
|
|
|
145
|
+
- 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
146
|
- 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
147
|
- Store handoffs in the working repo's isolated dated docs path, never this instruction-SSOT repo. Re-verify load-bearing claims on resume.
|
|
141
148
|
|
|
@@ -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-learning-workflow
|
|
3
|
+
language: en
|
|
4
|
+
status: active
|
|
5
|
+
use_when:
|
|
6
|
+
- a session was launched with the Session learning 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-learning 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-Learning Workflow
|
|
19
|
+
|
|
20
|
+
Runbook for a learning-refinement session: 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-learning/HANDOFF.md` — initiative state, prior decisions,
|
|
27
|
+
open threads. 2. `design/session-learning/PLACEMENT-FRAMEWORK.md` — the
|
|
28
|
+
placement authority (typology A–G, layers, admission bars, lifecycle).
|
|
29
|
+
3. `design/session-learning/ledger.json` — cumulative item states
|
|
30
|
+
(placed / incubating / absorbed / retired) with provenance.
|
|
31
|
+
|
|
32
|
+
## Stage 1 — Mine (pipeline in `scripts/session-learning/`)
|
|
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 learning version: append {version = window end, commit = the
|
|
96
|
+
corpus-close commit} to `design/session-learning/versions.json` — this is
|
|
97
|
+
what the launcher's Versions & rollback screen offers — then run
|
|
98
|
+
`python3 scripts/session-learning/update-state.py --window-end <date>`
|
|
99
|
+
(nudge baseline) and `learning-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.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""PreToolUse(Bash) hook: inject tooling-gotchas reminders on matching commands.
|
|
3
|
+
|
|
4
|
+
Read-only context injection only — never blocks, rewrites, or judges (hook
|
|
5
|
+
charter, design/session-learning/PLACEMENT-FRAMEWORK.md). Message text derives
|
|
6
|
+
from claude/guides/tooling-gotchas.md; edit the guide first, then sync here.
|
|
7
|
+
The verification suite greps each message's anchor phrase against the guide.
|
|
8
|
+
"""
|
|
9
|
+
import json
|
|
10
|
+
import re
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
GUIDE = "guides/tooling-gotchas.md"
|
|
14
|
+
|
|
15
|
+
# (name, compiled trigger, one-line reminder). Priority order; max 2 injected.
|
|
16
|
+
RULES = [
|
|
17
|
+
("reserved-shell-names",
|
|
18
|
+
re.compile(r"\b(UID|EUID|GID|PPID)="),
|
|
19
|
+
"Assigning reserved shell names (UID/EUID/GID/PPID) can invoke the bound "
|
|
20
|
+
f"system behavior instead of storing a value — use unreserved names ({GUIDE})."),
|
|
21
|
+
("git-diff-two-dot",
|
|
22
|
+
re.compile(r"git\s+diff\s+[^|;&]*(?<!\.)\.\.(?!\.)"),
|
|
23
|
+
"git diff A..B is a direct snapshot comparison, not a range exclusion — "
|
|
24
|
+
f"for PR/review diffs use three-dot origin/base...HEAD ({GUIDE})."),
|
|
25
|
+
("git-pull-dirty",
|
|
26
|
+
re.compile(r"\bgit\s+pull\b"),
|
|
27
|
+
"Before pulling into a worktree with local changes: fetch first, compare "
|
|
28
|
+
f"incoming paths against dirty paths, prefer --ff-only ({GUIDE})."),
|
|
29
|
+
("metachar-inline-arg",
|
|
30
|
+
re.compile(r"(codex-run|codex-helm|codex\s+exec|claude\s+-p)\b[^|;&]*[\"'][^\"']*(\$\(|`)"),
|
|
31
|
+
"Values with shell metacharacters must reach the target via stdin or a "
|
|
32
|
+
f"file, not inline arguments — the shell expands them first ({GUIDE})."),
|
|
33
|
+
("pipe-exit-masking",
|
|
34
|
+
re.compile(r"\$\?"),
|
|
35
|
+
"A pipeline's $? reflects only the last stage — capture the tested "
|
|
36
|
+
f"stage's own status (unpiped run, PIPESTATUS, per-command pipefail) ({GUIDE})."),
|
|
37
|
+
("grep-binary-heuristic",
|
|
38
|
+
re.compile(r"(^|[;&(]\s*|&&\s*|\|\|\s*)grep\s"),
|
|
39
|
+
"grep can misread text with heavy non-ASCII/NUL as binary and return a "
|
|
40
|
+
f"false no-match — prefer the Grep tool (ripgrep) or grep -a ({GUIDE})."),
|
|
41
|
+
]
|
|
42
|
+
MAX_INJECT = 2
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def matches(command: str):
|
|
46
|
+
hits = []
|
|
47
|
+
for name, rx, msg in RULES:
|
|
48
|
+
if name == "pipe-exit-masking" and "|" not in command:
|
|
49
|
+
continue
|
|
50
|
+
if name == "grep-binary-heuristic" and re.search(r"(^|\s)(-a\b|--text)", command):
|
|
51
|
+
continue
|
|
52
|
+
if rx.search(command):
|
|
53
|
+
hits.append((name, msg))
|
|
54
|
+
return hits[:MAX_INJECT]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def main() -> int:
|
|
58
|
+
try:
|
|
59
|
+
payload = json.load(sys.stdin)
|
|
60
|
+
except Exception:
|
|
61
|
+
return 0 # never block on malformed input
|
|
62
|
+
if payload.get("tool_name") != "Bash":
|
|
63
|
+
return 0
|
|
64
|
+
command = (payload.get("tool_input") or {}).get("command") or ""
|
|
65
|
+
hits = matches(command)
|
|
66
|
+
if not hits:
|
|
67
|
+
return 0
|
|
68
|
+
context = " ".join(msg for _, msg in hits)
|
|
69
|
+
print(json.dumps({
|
|
70
|
+
"hookSpecificOutput": {
|
|
71
|
+
"hookEventName": "PreToolUse",
|
|
72
|
+
"additionalContext": context,
|
|
73
|
+
}
|
|
74
|
+
}))
|
|
75
|
+
return 0
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
sys.exit(main())
|