create-agent-rig 0.6.2 → 0.7.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/CHANGELOG.md +95 -0
- package/package.json +1 -1
- package/templates/agent-os/stack/node-ts/.claude/rules/node-ts.md +2 -3
- package/templates/agent-os/universal/.agents/skills/loop/SKILL.md +117 -80
- package/templates/agent-os/universal/.agents/skills/pr-ship/SKILL.md +19 -12
- package/templates/agent-os/universal/.claude/hooks/block-no-verify.mjs +23 -3
- package/templates/agent-os/universal/.claude/hooks/guard-bash.mjs +65 -7
- package/templates/agent-os/universal/.claude/hooks/guard-core-purity.mjs +2 -2
- package/templates/agent-os/universal/.claude/hooks/guard-web-boundary.mjs +2 -2
- package/templates/agent-os/universal/.claude/hooks/lib/hook-input.mjs +109 -0
- package/templates/agent-os/universal/.claude/rules/invariants.md +19 -0
- package/templates/agent-os/universal/.claude/scripts/lib/claim-records.mjs +800 -0
- package/templates/agent-os/universal/.claude/scripts/lib/revalidation-evidence.mjs +56 -0
- package/templates/agent-os/universal/.claude/scripts/lib/shell-tools.mjs +81 -0
- package/templates/agent-os/universal/.claude/scripts/preflight.mjs +19 -1
- package/templates/agent-os/universal/.claude/scripts/queue/core.mjs +17 -66
- package/templates/agent-os/universal/.claude/scripts/queue/github-issues.mjs +29 -7
- package/templates/agent-os/universal/.claude/scripts/queue/index.mjs +159 -23
- package/templates/agent-os/universal/.claude/scripts/queue/jira.mjs +41 -19
- package/templates/agent-os/universal/.claude/scripts/queue/plan-md.mjs +4 -2
- package/templates/agent-os/universal/.claude/scripts/revalidate.mjs +268 -48
- package/templates/agent-os/universal/.claude/scripts/revalidation-report.mjs +32 -15
- package/templates/agent-os/universal/.claude/scripts/run-state.mjs +180 -37
- package/templates/agent-os/universal/.claude/settings.json +1 -1
- package/templates/agent-os/universal/.claude/skills/loop/SKILL.md +117 -80
- package/templates/agent-os/universal/.claude/skills/pr-ship/SKILL.md +19 -12
- package/templates/agent-os/universal/.codex/hooks.json +1 -1
- package/templates/agent-os/universal/.rig/revalidation.json +10 -0
- package/templates/agent-os/universal/docs/decisions/codex-adapter.md +3 -2
- package/templates/agent-os/universal/docs/decisions/content-blind-revalidation.md +144 -0
- package/templates/agent-os/universal/layers.json +5 -0
- package/templates/hash-history.json +36 -15
- package/templates/release-ledger.json +2 -1
|
@@ -74,13 +74,48 @@
|
|
|
74
74
|
// written without thinking — not an adversary, and circumventing it is itself a
|
|
75
75
|
// Never-tier violation. The layers behind it are review and CI.
|
|
76
76
|
//
|
|
77
|
+
// ── Which SURFACES it sees, and what that does not promise (RP-65) ───────────
|
|
78
|
+
//
|
|
79
|
+
// This runs for every tool named in `.claude/scripts/lib/shell-tools.mjs`, not
|
|
80
|
+
// for `Bash` alone. It used to be wired under `Bash` only, and the measurement
|
|
81
|
+
// that changed it is in that file: the same `--no-verify` command was blocked
|
|
82
|
+
// through one tool and ran through the other, in one session.
|
|
83
|
+
//
|
|
84
|
+
// ⚠ Widening the matcher makes the same RULES run on both surfaces. It does not
|
|
85
|
+
// make the PARSING identical: the tokeniser above is POSIX, and PowerShell's
|
|
86
|
+
// quoting, escaping and separators are its own, so a command whose danger is
|
|
87
|
+
// visible only after PowerShell-specific parsing can read differently here.
|
|
88
|
+
//
|
|
89
|
+
// ⚠ And the coarse checks are narrower than "coarse" suggests. The rules
|
|
90
|
+
// match a command NAME — `git`, `gh`, `rm` — so they refuse the operation
|
|
91
|
+
// only when the operation is spelled that way.
|
|
92
|
+
// Measured with the brake armed: `gh pr merge …` is refused on both surfaces,
|
|
93
|
+
// while `gh.exe pr merge …`, `Start-Process gh -ArgumentList …` and
|
|
94
|
+
// `Remove-Item -Recurse -Force C:\` are all allowed. The first of those is
|
|
95
|
+
// allowed under `Bash` too, so this is a rule-set bound rather than anything
|
|
96
|
+
// the widened matcher introduced — but it is a bound, and an earlier draft of
|
|
97
|
+
// this block claimed the opposite. This gap is why the file keeps a name that
|
|
98
|
+
// says `bash`: a rename would promise a parity the parser does not have.
|
|
99
|
+
//
|
|
77
100
|
// Contract (Claude Code): JSON on stdin; exit 0 = allow, exit 2 = block, and
|
|
78
|
-
// stderr is shown to the agent as the reason.
|
|
79
|
-
//
|
|
101
|
+
// stderr is shown to the agent as the reason.
|
|
102
|
+
//
|
|
103
|
+
// Two different things happen to input this guard cannot act on, and collapsing
|
|
104
|
+
// them into one sentence is the mistake `.claude/rules/invariants.md`
|
|
105
|
+
// ("Refusing to inspect is a third outcome") says costs a credential either way:
|
|
106
|
+
// - NOTHING TO JUDGE -> allow. An unparseable payload, no `tool_input`, no
|
|
107
|
+
// `command`, an empty one, a tool this guard does not answer for, or a crash
|
|
108
|
+
// inside `inspect` — a guard that has nothing to look at, or that broke, must
|
|
109
|
+
// never make the session unusable.
|
|
110
|
+
// - HANDED SOMETHING IT CANNOT READ -> block. A `command` that is present in a
|
|
111
|
+
// shape this guard does not accept is refused, naming the shape expected,
|
|
112
|
+
// because allowing it would report a check that never ran.
|
|
113
|
+
// The split is decided in one place for both shell guards, `lib/hook-input.mjs`.
|
|
80
114
|
import { realpathSync } from 'node:fs';
|
|
81
115
|
import { fileURLToPath } from 'node:url';
|
|
82
116
|
import { brakeIsOn } from '../scripts/stop-flag.mjs';
|
|
83
|
-
import {
|
|
117
|
+
import { SHELL_TOOLS } from '../scripts/lib/shell-tools.mjs';
|
|
118
|
+
import { readHookInput, refusalText, shellCommandOf } from './lib/hook-input.mjs';
|
|
84
119
|
|
|
85
120
|
/** Branches that are shared by definition. */
|
|
86
121
|
const PROTECTED_BRANCH = /^(main|master|develop|development|trunk)$/;
|
|
@@ -807,10 +842,33 @@ export const inspect = (raw, brake, depth = 0) => {
|
|
|
807
842
|
function main() {
|
|
808
843
|
const input = readHookInput();
|
|
809
844
|
if (input === null) return 0;
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
845
|
+
// The ONE list decides which surfaces this guard answers for. Comparing a
|
|
846
|
+
// literal here is what made the widened matcher in `settings.json` cosmetic:
|
|
847
|
+
// the hook was launched for every shell tool and then excused itself from all
|
|
848
|
+
// but one, so the Never tier and the kill switch stayed bypassable on the
|
|
849
|
+
// other. Two spellings of one fact, and the one that ran was the wrong one.
|
|
850
|
+
if (!SHELL_TOOLS.includes(input.tool_name)) return 0;
|
|
851
|
+
// Three outcomes, decided in one shared place (RP-80): absent → allow, a
|
|
852
|
+
// string → inspect, present-in-a-shape-this-cannot-read → REFUSE. The last
|
|
853
|
+
// one used to be an allow, and what that cost is measured rather than
|
|
854
|
+
// asserted: on `master` at `254b25c8`, with the kill switch armed, a
|
|
855
|
+
// `command` spelled as an array of argv words returned 0 here before
|
|
856
|
+
// `brakeIsOn()` was ever consulted. Pinned in hook-command-shape.test.ts
|
|
857
|
+
// (absent in a generated rig) › "refuses an unreadable command through %s
|
|
858
|
+
// while the kill switch is armed". A rule that can be stepped over by
|
|
859
|
+
// restating the same command in another container is not a rule.
|
|
860
|
+
const command = shellCommandOf(input);
|
|
861
|
+
if (command.kind === 'unreadable') {
|
|
862
|
+
process.stderr.write(`${refusalText(command)}\n`);
|
|
863
|
+
return 2;
|
|
864
|
+
}
|
|
865
|
+
// Every member except `string` leaves nothing to inspect. Stated as one
|
|
866
|
+
// POSITIVE test rather than a list of the others, so a member added later
|
|
867
|
+
// cannot fall through to `raw.trim()` — which sits outside the try below,
|
|
868
|
+
// where a throw exits 1 and the harness reads that as allow. That is the
|
|
869
|
+
// fail-open this change removes, re-entering by another door.
|
|
870
|
+
if (command.kind !== 'string') return 0;
|
|
871
|
+
const raw = command.command;
|
|
814
872
|
if (!raw.trim()) return 0;
|
|
815
873
|
|
|
816
874
|
try {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// Contract (Claude Code and Codex): JSON on stdin; exit 0 = allow, exit 2 = block, and
|
|
7
7
|
// stderr is shown to the agent as the reason.
|
|
8
8
|
// Generator-owned coverage for the neutral bounded-inspection refusal lives upstream in
|
|
9
|
-
// codex.test.ts › "$guard blocks with a neutral,
|
|
10
|
-
//
|
|
9
|
+
// codex.test.ts (absent in a generated rig) › "$guard blocks with a neutral,
|
|
10
|
+
// actionable size-limit refusal" — a downstream edit requires a local replacement test.
|
|
11
11
|
import { editFragments } from './lib/edit-input.mjs';
|
|
12
12
|
import { readHookInput } from './lib/hook-input.mjs';
|
|
13
13
|
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// Contract (Claude Code and Codex): JSON on stdin; exit 0 = allow, exit 2 = block, and
|
|
7
7
|
// stderr is shown to the agent as the reason.
|
|
8
8
|
// Generator-owned coverage for the neutral bounded-inspection refusal lives upstream in
|
|
9
|
-
// codex.test.ts › "$guard blocks with a neutral,
|
|
10
|
-
//
|
|
9
|
+
// codex.test.ts (absent in a generated rig) › "$guard blocks with a neutral,
|
|
10
|
+
// actionable size-limit refusal" — a downstream edit requires a local replacement test.
|
|
11
11
|
import { editFragments } from './lib/edit-input.mjs';
|
|
12
12
|
import { readHookInput } from './lib/hook-input.mjs';
|
|
13
13
|
|
|
@@ -53,3 +53,112 @@ export const readHookInput = () => {
|
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* ── The shape of a shell command, for the Never-tier SHELL guards (RP-80) ───
|
|
59
|
+
*
|
|
60
|
+
* One place, for the two guards that read `tool_input.command` on a shell tool —
|
|
61
|
+
* `guard-bash` and `block-no-verify`. It is deliberately NOT a repository-wide
|
|
62
|
+
* ruling on the word `command`: `guard-secret-file` reads an `apply_patch`
|
|
63
|
+
* `command` that is a **list of strings**, which is exactly the shape this
|
|
64
|
+
* module classifies as unreadable, and it is right to — the reasoning is in
|
|
65
|
+
* `docs/decisions/codex-adapter.md`. Routing a third guard through here without
|
|
66
|
+
* checking which shape its tool actually sends would start refusing input
|
|
67
|
+
* another guard exists to read.
|
|
68
|
+
*
|
|
69
|
+
* `.claude/rules/invariants.md` ("Refusing to inspect is a third outcome, not a
|
|
70
|
+
* match and not an error") draws the line these guards need:
|
|
71
|
+
*
|
|
72
|
+
* - **absent** — nothing to judge, so the guard fails OPEN. A `Write` with no
|
|
73
|
+
* content and a shell tool with no `command` are the same case.
|
|
74
|
+
* - **`string`** — the guard inspects it as it always did.
|
|
75
|
+
* - **present and unreadable** — the guard was handed something and can tell
|
|
76
|
+
* that it cannot read it. That is a REFUSAL: block, name the shape expected,
|
|
77
|
+
* and say to resend in that shape.
|
|
78
|
+
*
|
|
79
|
+
* 🔴 Getting that last line backwards costs the whole rule set. Measured on
|
|
80
|
+
* `master` at `254b25c8`: a payload whose `command` was `["gh","pr","merge","1"]`
|
|
81
|
+
* exited 0 from `guard-bash` **with the kill switch armed** — the brake was
|
|
82
|
+
* never consulted, because the guard had already excused itself. `block-no-verify`
|
|
83
|
+
* had the same hole by another road: `String(argv)` comma-joins, and its
|
|
84
|
+
* tokeniser never splits on a comma, so `--no-verify` became invisible rather
|
|
85
|
+
* than unreadable.
|
|
86
|
+
*
|
|
87
|
+
* 🔴 The remedy is carried as a FIELD beside the reason, not inferred from the
|
|
88
|
+
* reason's wording by whoever prints it — `invariants.md` again. A remedy
|
|
89
|
+
* chosen by pattern-matching a sentence is wrong the day somebody rewords the
|
|
90
|
+
* sentence, in every copy at once. And it is deliberately NOT "split the change
|
|
91
|
+
* and retry": that advice belongs to a crossed BOUND, where a smaller input
|
|
92
|
+
* really does fit. Nothing about splitting changes a container's shape, so
|
|
93
|
+
* offering it here would turn a refusal into a loop.
|
|
94
|
+
*
|
|
95
|
+
* Bounded work, because a fail-open guard is a total bypass if any input can
|
|
96
|
+
* make it spin or throw: a fixed number of `typeof` tests and one lookup. The
|
|
97
|
+
* offending value is NEVER serialised into the message — only its shape word —
|
|
98
|
+
* so an enormous or cyclic `command` costs nothing and leaks nothing.
|
|
99
|
+
*
|
|
100
|
+
* Limits, stated rather than implied:
|
|
101
|
+
* - It reads `tool_input.command`. A surface that names its command field
|
|
102
|
+
* differently is not seen at all, and that is the same blind spot the whole
|
|
103
|
+
* list in `.claude/scripts/lib/shell-tools.mjs` has: harness → guard is
|
|
104
|
+
* guarded by nobody.
|
|
105
|
+
* - `absent` covers `null` as well as `undefined`, on both `tool_input` and
|
|
106
|
+
* `command`. A key explicitly set to null carries no command to read, and
|
|
107
|
+
* refusing it would fire on payloads that mean "no command".
|
|
108
|
+
* - An empty or whitespace-only string is READABLE and allowed. It is a
|
|
109
|
+
* command that does nothing, not a shape the guard failed to parse.
|
|
110
|
+
* Pinned in hook-command-shape.test.ts (absent in a generated rig) ›
|
|
111
|
+
* "refuses an unreadable command through %s while the kill switch is armed"
|
|
112
|
+
* and › "allows an ABSENT command through %s".
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/** The shape word for a value, bounded: never the value itself. */
|
|
116
|
+
const shapeOf = (value) => {
|
|
117
|
+
if (Array.isArray(value)) return 'an array';
|
|
118
|
+
const type = typeof value;
|
|
119
|
+
return type === 'object' ? 'an object' : `a ${type}`;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* What a shell guard was handed, as one of three outcomes.
|
|
124
|
+
*
|
|
125
|
+
* @returns {{kind:'absent'}
|
|
126
|
+
* |{kind:'string', command:string}
|
|
127
|
+
* |{kind:'unreadable', reason:string, remedy:string}}
|
|
128
|
+
*/
|
|
129
|
+
export const shellCommandOf = (input) => {
|
|
130
|
+
const toolInput = input?.tool_input;
|
|
131
|
+
if (toolInput === undefined || toolInput === null) return { kind: 'absent' };
|
|
132
|
+
if (typeof toolInput !== 'object' || Array.isArray(toolInput)) {
|
|
133
|
+
return unreadable('tool_input', shapeOf(toolInput), 'an object');
|
|
134
|
+
}
|
|
135
|
+
const command = toolInput.command;
|
|
136
|
+
if (command === undefined || command === null) return { kind: 'absent' };
|
|
137
|
+
if (typeof command !== 'string') {
|
|
138
|
+
return unreadable('tool_input.command', shapeOf(command), 'a string');
|
|
139
|
+
}
|
|
140
|
+
return { kind: 'string', command };
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const unreadable = (field, got, expected) => ({
|
|
144
|
+
kind: 'unreadable',
|
|
145
|
+
reason:
|
|
146
|
+
`BLOCKED — ${field} is present as ${got}, and this guard reads ${expected}. ` +
|
|
147
|
+
'An input it cannot read is refused, never allowed: the Never-tier rules and ' +
|
|
148
|
+
'the kill switch are decided by reading the command, so allowing what was ' +
|
|
149
|
+
'not read would report a check that did not happen ' +
|
|
150
|
+
'(.claude/rules/invariants.md, "Refusing to inspect is a third outcome").',
|
|
151
|
+
remedy: `Resend the call with ${field} as ${expected}.`,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* One refusal, one wording — so two guards cannot drift apart in what they say.
|
|
156
|
+
*
|
|
157
|
+
* It answers for the `unreadable` member only. Handed anything else it returns
|
|
158
|
+
* the empty string rather than `"undefined undefined"`: a guard that printed
|
|
159
|
+
* that would be reporting a refusal it cannot explain, and the caller could not
|
|
160
|
+
* act on it. The call sites below never do this today; the guard is here so a
|
|
161
|
+
* later one cannot introduce it silently.
|
|
162
|
+
*/
|
|
163
|
+
export const refusalText = (refusal) =>
|
|
164
|
+
refusal?.kind === 'unreadable' ? `${refusal.reason} ${refusal.remedy}` : '';
|
|
@@ -223,6 +223,25 @@ an artifact may cite the generator's upstream tests, which are absent locally,
|
|
|
223
223
|
only when the pointer says they are absent and `.claude/.rig-manifest.json`
|
|
224
224
|
proves the current artifact's hash matches the installed manifest.
|
|
225
225
|
|
|
226
|
+
**In the generator, part of that is mechanical.** A citation there is a
|
|
227
|
+
test-file name followed by `›` and a quoted test name, and the generator's
|
|
228
|
+
`test/template/evidence-pointers.test.ts` (absent in a generated rig) resolves
|
|
229
|
+
the citations it reads: › "names a test file this repository still has" and ›
|
|
230
|
+
"quotes a test name that file still declares" go red when a target is renamed
|
|
231
|
+
or a test retitled, and › "says so when the test it names is one a generated
|
|
232
|
+
project never receives" goes red when a pointer into the generator's suite
|
|
233
|
+
carries no word that the reader does not have it. The wording that satisfies
|
|
234
|
+
the last one is `(absent in a generated rig)` beside the pointer, or the
|
|
235
|
+
one-line disclosure nine scripts here open with — a phrase naming the generator
|
|
236
|
+
is not enough, because it tells the reader where the test lives and nothing
|
|
237
|
+
about whether they have it.
|
|
238
|
+
|
|
239
|
+
⚠ **"the citations it reads" is not all of them**, and the test's own header
|
|
240
|
+
states where the edges are: it looks only at the tree that ships into a rig,
|
|
241
|
+
and it reads a citation's names from the line the file is named on and the two
|
|
242
|
+
after it. A green run means no citation it read has gone dead — not that every
|
|
243
|
+
pointer in the generator was verified.
|
|
244
|
+
|
|
226
245
|
A manifest-backed upgrade remains an inherited, generator-owned artifact even
|
|
227
246
|
though the upgrade diff changes its bytes. The exception applies **only while the
|
|
228
247
|
manifest hash matches**. A hash mismatch, missing manifest, or no evidence ends
|