stopbar 1.1.3 → 1.2.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/dist/attest.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // Built from src/attest.ts by scripts/build.ts. Do not edit.
2
2
  // ATTEST: a deterministic attestation of the session from the current state and the event log. The same state and log
3
3
  // give the same report byte for byte (no clock, no machine name). The sha256 of events.jsonl is the anchor for signing in
4
- // a later version. Read-only for Stopbar state: it refreshes only the private snapshot index to see the working tree.
4
+ // a later version. Probe evidence: the latest `probe:result` per target, and whether its tree is the current one.
5
+ // Read-only for Stopbar state: it refreshes only the private snapshot index to see the working tree.
5
6
  import {createHash} from 'node:crypto'
6
7
  import {existsSync, readFileSync} from 'node:fs'
7
8
  import {decode, initKernel, MACHINE, } from './engine.js'
@@ -38,7 +39,12 @@ export function attestation(repoDir ) {
38
39
 
39
40
  // consistency: the state must be what the log says the last kernel step (or the last init/reset) left behind
40
41
  const checks = []
41
- const lastIdx = Math.max(...events.map((x, i) => (x.e.req || x.e.source === 'human:init' || x.e.source === 'human:reset' ? i : -1)), -1)
42
+ // a loop from the end, not Math.max(...events): one argument per entry overflows the stack on a long log
43
+ let lastIdx = -1
44
+ for (let i = events.length - 1; i >= 0; i--) {
45
+ const e = events[i].e
46
+ if (e.req || e.source === 'human:init' || e.source === 'human:reset') { lastIdx = i; break }
47
+ }
42
48
  if (lastIdx < 0) checks.push({name: 'log matches state', ok: false, detail: 'no kernel step and no init in events.jsonl'})
43
49
  else {
44
50
  const last = events[lastIdx]
@@ -49,18 +55,33 @@ export function attestation(repoDir ) {
49
55
  checks.push({name: 'config params = state params', ok: cfg.maxRetries === s.params.maxRetries && cfg.cap === s.params.cap, detail: `${JSON.stringify(s.params)}`})
50
56
  checks.push({name: 'working tree counted', ok: now.id === s.snapshot, detail: now.id === s.snapshot ? 'no change the kernel has not seen' : 'uncounted change (counted at the next hook)'})
51
57
 
58
+ // probe evidence: the latest probe:result per target since the last init / reset (not kernel steps: no req)
59
+ let since = 0
60
+ events.forEach(({e}, i) => { if (e.source === 'human:init' || e.source === 'human:reset') since = i + 1 })
61
+ const latest = new Map ()
62
+ for (const x of events.slice(since)) if (x.e.source === 'probe:result' && typeof x.e.target === 'string') latest.set(x.e.target, x)
63
+ const probes = [...latest.keys()].sort().map((k) => {
64
+ const {line, e} = latest.get(k)
65
+ const m = e.mutants && typeof e.mutants === 'object' ? e.mutants : null
66
+ return {target: k, targetPath: e.targetPath ?? null, ...(typeof e.targetCmd === 'string' ? {targetCmd: e.targetCmd} : {}), targetSha256: e.targetSha256 ?? null, ok: e.ok === true, runs: e.runs ?? 0, regressions: e.regressions ?? 0,
67
+ passed: e.passed ?? 0, failed: e.failed ?? 0, steps: e.steps ?? 0,
68
+ mutants: m ? {killed: m.killed ?? 0, total: m.total ?? 0, survived: Array.isArray(m.survived) ? m.survived : []} : null,
69
+ treeSnapshot: e.treeSnapshot ?? null, atCurrentSnapshot: e.treeSnapshot === now.id, summarySha256: e.summarySha256 ?? null, line, ts: e.ts ?? null}
70
+ })
71
+
52
72
  const commitNow = !v.halted && v.buildOkRev === v.treeRev && v.testsOkRev === v.treeRev && !v.testsTainted
53
73
  return {
54
74
  stopbar: VERSION,
55
75
  kernel: MACHINE,
56
76
  repository: {head, headTree, snapshot: s.snapshot, workingTreeSnapshot: now.id, treeRevision: v.treeRev},
57
77
  config: {profile: cfg.profile, buildCmd: cfg.buildCmd, fullTestCmd: cfg.fullTestCmd, maxRetries: cfg.maxRetries, cap: cfg.cap, costPerCall: cfg.costPerCall, ...(cfg.baseRef ? {baseRef: cfg.baseRef} : {}),
58
- stopGate: cfg.stopGate ?? 'block', ...(cfg.cliCmd ? {cliCmd: cfg.cliCmd} : {})},
78
+ stopGate: cfg.stopGate ?? 'block', ...(cfg.cliCmd ? {cliCmd: cfg.cliCmd} : {}), ...(cfg.requireRun ? {requireRun: true} : {})},
59
79
  gates: {build: v.buildOkRev === v.treeRev, fullTests: v.testsOkRev === v.treeRev, tainted: v.testsTainted, secretRead: v.secretTainted,
60
80
  ...(v.secretTainted ? {secretReadBy: secretReason(repo)?.text ?? 'not in the event log'} : {}),
61
81
  shellApprovalHeld: v.shellToken, halted: v.halted, commitAllowedNow: commitNow, ...(commitNow ? {} : {why: v.halted ? 'session halted' : whyBlocked(v, cfg)}),
62
82
  budget: {spent: v.spent, cap: v.capNow}, failures: {tests: v.testFails, builds: v.buildFails}},
63
83
  humanActions: approvals,
84
+ probes,
64
85
  log: {file: 'events.jsonl', sha256: createHash('sha256').update(raw).digest('hex'), bytes: raw.length, entries: events.length, tornLines: torn,
65
86
  kernelSteps: steps.length, blocks, commitsAllowed, decisions: Object.fromEntries(Object.entries(decisions).sort())},
66
87
  consistent: checks.every((c) => c.ok || c.name === 'working tree counted'),
@@ -79,6 +100,7 @@ export function attestMarkdown(a ) {
79
100
  `| HEAD | \`${a.repository.head ?? '(none)'}\` |`, `| HEAD tree | \`${a.repository.headTree ?? '(none)'}\` |`,
80
101
  ...(a.config.baseRef ? [`| Base ref | \`${a.config.baseRef}\` |`] : []),
81
102
  ...(a.config.stopGate === 'warn' ? ['| Stop gate | warn (Stop does not block a turn; git commit and git push stay gated) |'] : []),
103
+ ...(a.config.requireRun ? ['| requireRun | true (the build and full test gates count only through `stopbar run build` and `stopbar run test`) |'] : []),
82
104
  `| Counted snapshot | \`${a.repository.snapshot}\` (revision ${a.repository.treeRevision}) |`,
83
105
  `| Build gate | ${yn(g.build)} (\`${a.config.buildCmd}\`) |`, `| Full test gate | ${yn(g.fullTests)} (\`${a.config.fullTestCmd}\`) |`,
84
106
  `| Tests tainted | ${yn(g.tainted)} |`, `| Secret read | ${g.secretRead ? `yes: ${g.secretReadBy}` : 'no'} |`, `| Halted | ${yn(g.halted)} |`,
@@ -88,6 +110,9 @@ export function attestMarkdown(a ) {
88
110
  `| Kernel steps / blocks / commits allowed | ${a.log.kernelSteps} / ${a.log.blocks} / ${a.log.commitsAllowed} |`,
89
111
  `| Consistent | ${yn(a.consistent)} |`, '',
90
112
  `## Human actions`, '', ...(a.humanActions.length ? a.humanActions.map((h) => `- line ${h.line}, ${h.ts}: ${h.action}${'revision' in h ? ` revision ${h.revision}` : ''}${'extra' in h ? ` extra ${h.extra}` : ''}${h.decision ? ` -> ${h.decision}` : ''}`) : ['- none']), '',
113
+ `## Probe evidence`, '', ...(a.probes.length ? a.probes.map((p) => `- ${p.target}: ${p.ok ? 'PASS' : 'FAIL'}, ${p.runs} runs, ${p.steps} steps` +
114
+ `${p.mutants ? `, mutants ${p.mutants.killed}/${p.mutants.total} killed${p.mutants.survived.length ? ` (survived: ${p.mutants.survived.join(', ')})` : ''}` : ''}` +
115
+ `, at current snapshot: ${yn(p.atCurrentSnapshot)}${p.targetSha256 ? `, target sha256 \`${String(p.targetSha256).slice(0, 16)}\`` : ''} (line ${p.line})`) : ['- none']), '',
91
116
  `## Checks`, '', ...a.checks.map((c) => `- [${c.ok ? 'x' : ' '}] ${c.name}: ${c.detail}`), '',
92
117
  ].join('\n')
93
118
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.1.3",
2
+ "version": "1.2.0",
3
3
  "kernelSourceSha256": "c602fc4bcf8ffb2e312bf838986e6d4b006af6d0e6c7447c8c61d5888adc5ef8",
4
4
  "machineSha256": "b397085e0cb13e2e50aa655c54de0744d08f2ebf500bf32af8ff3e8a11ba7321",
5
- "files": 26
5
+ "files": 29
6
6
  }
package/dist/classify.js CHANGED
@@ -80,6 +80,39 @@ export function scanShell(cmd )
80
80
  }
81
81
  export const hasChain = (cmd ) => scanShell(cmd).chain
82
82
 
83
+ /** The command text as bash joins quoted parts of one word: `.e""nv`, `.g''it`, `.e"n"v` and `.cl''aude` become `.env`,
84
+ * `.git`, `.env` and `.claude`. For the text scans of secrets and self-protection only (never for gate matching):
85
+ * empty quote pairs are dropped, and so is a quote between two characters of a word. */
86
+ export function unsplice(cmd ) {
87
+ return cmd.replace(/""|''/g, '').replace(/(?<=[\w.\-/\\~])["'](?=[\w.\-/\\~])/g, '')
88
+ }
89
+
90
+ /** The command text with the quote pairs of every word removed, as bash joins the parts of a word: `'.cl'"aude"` is
91
+ * `.claude`, `.g"i"'t'` is `.git`, `gi"t"` is `git`. Separators (spaces, operators) and the spaces inside quotes stay as
92
+ * they are, so words are never joined across whitespace. Inside "..." the escapes \" \\ \$ \` work; inside '...' nothing.
93
+ * Outside quotes a backslash is kept as written (`g\it` is a known limit, SECURITY.md). An unterminated quote runs to the
94
+ * end. For the text scans (self-protection, secrets, the git subcommand) only; give it the command without the data
95
+ * bodies the caller skips (a plain `-m` message: commandForSelfProtect; a safe heredoc: its prefix). */
96
+ export function unquoteShellWords(cmd ) {
97
+ let out = ''
98
+ for (let i = 0; i < cmd.length; i++) {
99
+ const c = cmd[i]
100
+ if (c === "'") {
101
+ const j = cmd.indexOf("'", i + 1)
102
+ out += j < 0 ? cmd.slice(i + 1) : cmd.slice(i + 1, j)
103
+ i = j < 0 ? cmd.length : j
104
+ } else if (c === '"') {
105
+ let j = i + 1
106
+ for (; j < cmd.length && cmd[j] !== '"'; j++) {
107
+ if (cmd[j] === '\\' && j + 1 < cmd.length && '"\\$`'.includes(cmd[j + 1])) j++
108
+ out += cmd[j]
109
+ }
110
+ i = j
111
+ } else if (c === '\\' && i + 1 < cmd.length) { out += c + cmd[i + 1]; i++ } else out += c
112
+ }
113
+ return out
114
+ }
115
+
83
116
  // ---------------------------------------------------------------- risky / outbound shell
84
117
  const NET_TOOLS = /\b(curl|wget|nc|ncat|netcat|socat|ssh|scp|sftp|rsync|ftp|tftp|telnet)\b/i
85
118
  const PS_NET = /Invoke-WebRequest|Invoke-RestMethod|\biwr\b|\birm\b|Start-BitsTransfer|Net\.WebClient|System\.Net\.|Net\.Sockets/i
@@ -95,18 +128,95 @@ export function isRiskyShell(cmd ) {
95
128
  }
96
129
 
97
130
  // ---------------------------------------------------------------- git commands
98
- // git global options before the subcommand: -c k=v, -C dir, --git-dir=..., --work-tree ..., --no-pager, -p (values may be quoted)
99
- const GIT_GLOBALS = String.raw`(?:\s+(?:-[cC]\s*(?:"[^"]*"|'[^']*'|\S+)|--(?:git-dir|work-tree|namespace|exec-path|config-env)(?:=|\s+)(?:"[^"]*"|'[^']*'|\S+)|--[\w-]+|-[A-Za-z]))*`
131
+ // git global options before the subcommand: -c k=v, -C dir, --git-dir=..., --work-tree ..., --no-pager, -p (values may be
132
+ // quoted). With a separate value (git 2.56 `git --help` and git.c): --git-dir, --work-tree, --namespace, --config-env,
133
+ // --attr-source; --exec-path, --super-prefix (older git) and --list-cmds are listed too. Any other `--opt=value` is one word.
134
+ const GV = String.raw`(?:"[^"]*"|'[^']*'|\S+)`
135
+ const GIT_GLOBALS = String.raw`(?:\s+(?:-[cC]\s*${GV}|--(?:git-dir|work-tree|namespace|exec-path|config-env|attr-source|super-prefix|list-cmds)(?:=|\s+)${GV}|--[\w-]+=${GV}|--[\w-]+|-[A-Za-z]))*`
100
136
  const gitSub = (sub , flags = 'i') => new RegExp(String.raw`\bgit(?:\.exe)?${GIT_GLOBALS}\s+(?:${sub})\b`, flags)
101
- const COMMIT_RE = gitSub('commit|push'), PUSH_RE = gitSub('push'), CONFIG_RE = gitSub('config')
137
+ const COMMIT_RE = gitSub('commit|push'), PUSH_RE = gitSub('push'), CONFIG_RE_G = gitSub('config', 'gi')
102
138
  const COMMIT_ONLY_RE = new RegExp(String.raw`^git(?:\.exe)?${GIT_GLOBALS}\s+commit\b`, 'i')
103
- const CONFIG_READ = /\s(--get|--get-all|--get-regexp|--list|-l|--show-origin|--show-scope|get|list)(\s|=|$)/i
104
139
 
105
- /** Text a commit/push decision is made on: for a safe heredoc commit only the prefix (the message is data). */
140
+ /** Text a commit/push decision is made on: for a safe heredoc commit only the prefix (the message is data); as written
141
+ * and with the quotes of each word removed (`gi"t" commit` is `git commit`). */
106
142
  const commandPart = (cmd ) => parseSafeHeredocCommit(cmd)?.prefix ?? cmd
107
- export const isCommitCmd = (cmd ) => COMMIT_RE.test(commandPart(cmd))
108
- export const isPushCmd = (cmd ) => PUSH_RE.test(commandPart(cmd))
109
- export const isGitConfigWrite = (cmd ) => CONFIG_RE.test(cmd) && !CONFIG_READ.test(cmd)
143
+ const gitTexts = (part ) => [part, unquoteShellWords(part)]
144
+ export const isCommitCmd = (cmd ) => gitTexts(commandPart(cmd)).some((t) => COMMIT_RE.test(t))
145
+ export const isPushCmd = (cmd ) => gitTexts(commandPart(cmd)).some((t) => PUSH_RE.test(t))
146
+
147
+ // `git config` reads: only the tokens right after `config` decide, never a value at the end (`git config core.hooksPath
148
+ // list` is a write). A read is the subcommand `list` (no argument) or `get <name>` as the first positional word, or one
149
+ // of the options --get, --get-all, --get-regexp <name>, --get-urlmatch <name> <url>, --list / -l before the arguments;
150
+ // scope and format flags may stand around them. A write flag, an unknown flag, an expansion or any other argument count
151
+ // make it a write (fail closed).
152
+ const CFG_WRITE = new Set(['--add', '--unset', '--unset-all', '--replace-all', '--rename-section', '--remove-section', '--edit', '-e'])
153
+ const CFG_FLAG = new Set(['--local', '--global', '--system', '--worktree', '--includes', '--no-includes', '--show-origin', '--show-scope', '--null', '-z',
154
+ '--name-only', '--all', '--regexp', '--fixed-value', '--show-names', '--no-show-names', '--bool', '--int', '--bool-or-int', '--path', '--expiry-date', '--no-type'])
155
+ const CFG_FLAG_ARG = new Set(['--file', '-f', '--blob', '--default', '--type', '--value', '--url'])
156
+ const CFG_READ_OPT = new Map([['--get', 1], ['--get-all', 1], ['--get-regexp', 1], ['--get-urlmatch', 2], ['--list', 0], ['-l', 0]])
157
+ const CFG_READ_SUB = new Map([['list', 0], ['get', 1]])
158
+
159
+ /** The words of one simple command, quotes removed, up to the first operator outside quotes (`;`, `&`, `|`, `(`, `)`,
160
+ * a newline, a redirection; a file descriptor number right before `<` / `>` is dropped). Null for an expansion ($, `)
161
+ * outside single quotes: its value is unknown. */
162
+ function simpleWords(s ) {
163
+ const words = []
164
+ let w = '', inWord = false
165
+ for (let i = 0; i < s.length; i++) {
166
+ const c = s[i]
167
+ if (c === "'") { const j = s.indexOf("'", i + 1); w += j < 0 ? s.slice(i + 1) : s.slice(i + 1, j); inWord = true; i = j < 0 ? s.length : j; continue }
168
+ if (c === '"') {
169
+ let j = i + 1
170
+ for (; j < s.length && s[j] !== '"'; j++) {
171
+ if (s[j] === '\\' && j + 1 < s.length && '"\\$`'.includes(s[j + 1])) j++
172
+ else if (s[j] === '$' || s[j] === '`') return null
173
+ w += s[j]
174
+ }
175
+ inWord = true; i = j; continue
176
+ }
177
+ if (c === '$' || c === '`') return null
178
+ if (c === '\\') { w += s[i + 1] ?? ''; inWord = true; i++; continue }
179
+ if (c === ' ' || c === '\t') { if (inWord) words.push(w); w = ''; inWord = false; continue }
180
+ if (';&|()\r\n'.includes(c)) break
181
+ if (c === '<' || c === '>') { if (inWord && /^\d+$/.test(w)) inWord = false; break }
182
+ w += c; inWord = true
183
+ }
184
+ if (inWord) words.push(w)
185
+ return words
186
+ }
187
+
188
+ function configIsRead(args ) {
189
+ let mode
190
+ const pos = []
191
+ for (let i = 0; i < args.length; i++) {
192
+ const a = args[i]
193
+ if (a.length > 1 && a.startsWith('-')) {
194
+ const eq = a.startsWith('--') ? a.indexOf('=') : -1, name = eq < 0 ? a : a.slice(0, eq)
195
+ if (CFG_WRITE.has(name)) return false
196
+ if (CFG_READ_OPT.has(name)) {
197
+ if (eq >= 0 || pos.length || mode !== undefined) return false
198
+ mode = CFG_READ_OPT.get(name); continue
199
+ }
200
+ if (CFG_FLAG_ARG.has(name)) { if (eq < 0 && ++i >= args.length) return false; continue }
201
+ if (CFG_FLAG.has(name) && eq < 0) continue
202
+ return false
203
+ }
204
+ if (!pos.length && mode === undefined && CFG_READ_SUB.has(a)) { mode = CFG_READ_SUB.get(a); continue }
205
+ pos.push(a)
206
+ }
207
+ return mode !== undefined && pos.length === mode
208
+ }
209
+
210
+ /** Any `git config` in the text that is not a read (see above) is a write. */
211
+ export function isGitConfigWrite(cmd ) {
212
+ for (const m of cmd.matchAll(CONFIG_RE_G)) {
213
+ const rest = cmd.slice(m.index + m[0].length)
214
+ if (rest && !/^[\s;&|()<>]/.test(rest)) return true
215
+ const args = simpleWords(rest)
216
+ if (!args || !configIsRead(args)) return true
217
+ }
218
+ return false
219
+ }
110
220
 
111
221
  // A runner counts only as a command word: `cat pytest.ini` or `vim jest.config.js` is not a test run (fuzzer find, seed 12).
112
222
  const END = String.raw`(?![\w.\-/\\])`
@@ -128,7 +238,9 @@ const EXT_ONLY = /^\*\.[^/*?{}\[\]]+$/
128
238
 
129
239
  /** The first secret path named in a command (e.g. `cat .env`, `type secrets\\db.txt`), with the pattern it matched. */
130
240
  export function secretInCommand(cmd , paths , exists = () => true) {
131
- for (const tok of cmd.split(/[\s'"=(),;|&<>@:]+/).filter(Boolean)) {
241
+ const words = (s ) => s.split(/[\s'"=(),;|&<>@:]+/).filter(Boolean)
242
+ // the words as written, then as bash joins them (`.e""nv` is `.env`)
243
+ for (const tok of new Set([...words(cmd), ...words(unsplice(cmd)), ...words(unquoteShellWords(cmd))])) {
132
244
  const hits = paths.secrets.filter((g) => matchesSecretGlob(tok, g))
133
245
  if (!hits.length) continue
134
246
  const strong = hits.find((g) => !EXT_ONLY.test(g))
@@ -148,8 +260,8 @@ export const mentionsSecret = (cmd , paths , exists
148
260
  /** Exact match of gate commands: no chain operators, no extra arguments. `shell` is 'bash' or 'powershell'. */
149
261
  export function classifyBash(cmd , cfg , shell = 'bash', exists ) {
150
262
  const c = cmd.trim()
151
- const scan = shell === 'bash' ? scanShell(c) : scanPlain(c)
152
- if (COMMIT_RE.test(scan.heredoc ? commandPart(c) : c)) {
263
+ const scan = shell === 'bash' ? scanShell(c) : scanPlain(c)
264
+ if (gitTexts(scan.heredoc ? commandPart(c) : c).some((t) => COMMIT_RE.test(t))) {
153
265
  if (scan.chain) return {kind: 'commit-chained', reason: scan.reason ?? 'chain'}
154
266
  return {kind: 'commit', heredoc: !!scan.heredoc, push: isPushCmd(c)}
155
267
  }
@@ -221,7 +333,9 @@ const SEG = (name ) => new RegExp(String.raw`(^|[^a-z0-9_.\-])${name.repl
221
333
  const DOT_GIT = SEG('.git')
222
334
  const AGENT_DIRS = [[SEG('.claude'), '.claude'], [SEG('.cursor'), '.cursor'], [SEG('.codex'), '.codex'], [SEG('.gemini'), '.gemini'], [SEG('.agents'), '.agents']]
223
335
  const HUMAN_ONLY = /\b(approve-tests|approve-shell)\b|\bSTOPBAR_[A-Z_]+/i
224
- const STOPBAR_ADMIN = /stopbar[^\n]*\b(init|resume|reset|upgrade|doctor\s+--fix)\b/i
336
+ // an admin subcommand right after the program word (`stopbar`, `stopbar.mjs`, `stopbar@1.2.0`, `.../stopbar/dist/cli.js`,
337
+ // quoted or not): `stopbar init` is human-only, `stopbar probe init` (a prober scaffold, SKILL.md) is the agent's
338
+ const STOPBAR_ADMIN = /stopbar[^\s"'|;&]*["']?\s+(?:init|resume|reset|upgrade|doctor\b[^\n;&|]*?\s--fix)\b/i
225
339
 
226
340
  /** Command text inspected by self-protection. For a plain single-command `git commit` (chain-free, no substitution),
227
341
  * strips the commit message (safe heredoc body or quoted `-m` / `--message` string) because git treats it as data. */
@@ -261,14 +375,63 @@ export function commandForSelfProtect(cmd , shell
261
375
  return out
262
376
  }
263
377
 
264
- /** Shell command text. Returns the reason for a block, or null. Text matching only: see SECURITY.md. */
265
- export function protectedCommand(cmd , pr ) {
266
- const c = norm(cmd).toLowerCase()
267
- if (DOT_GIT.test(c)) return 'the command names a .git directory (Stopbar state, git hooks, git config live there)'
268
- for (const [re, d] of AGENT_DIRS) if (re.test(c)) return `the command names a ${d} directory (agent settings there hold the Stopbar hooks)`
269
- if (isGitConfigWrite(cmd)) return '`git config` writes .git/config; only reads (--get, --list) are allowed'
270
- if (c.includes(lc(pr.stateDir)) || c.includes(lc(pr.gitDir) + '/')) return 'the command names the git directory'
271
- for (const d of pr.codeDirs) if (c.includes(lc(d))) return `the command names Stopbar code (${d})`
272
- if (HUMAN_ONLY.test(cmd) || STOPBAR_ADMIN.test(cmd)) return 'human-only Stopbar command or setting'
378
+ // `git -c alias.ci=commit ci` (also `-calias.`, `--config-env alias.`, GIT_CONFIG_KEY_n=alias.): a one-off alias hides
379
+ // the real git subcommand from the classification of commits and pushes in PreToolUse.
380
+ const GIT_ALIAS = new RegExp(String.raw`\bgit(?:\.exe)?${GIT_GLOBALS}\s+(?:-c\s*|--config-env(?:=|\s+))["']?\s*alias\.`, 'i')
381
+ const GIT_ALIAS_ENV = /\bGIT_CONFIG_(?:PARAMETERS\b|KEY_\d+\s*=\s*["']?alias\.)/i
382
+
383
+ // A single-quoted heredoc fed to a command as stdin, e.g. a prompt for another agent CLI: `agy -p - <<'EOF'` ... `EOF`.
384
+ // With the delimiter in quotes bash expands nothing in the body, so the body is data for the command, unless the command
385
+ // runs it as code (a shell or an interpreter, xargs, at), hands it to Stopbar, or stores it in a file (> / >>, tee).
386
+ const STDIN_HEREDOC = /<<-?[ \t]*'([A-Za-z_][A-Za-z0-9_]*)'/g
387
+ const RUNS_STDIN = /^(?:sh|bash|zsh|dash|ksh|fish|pwsh|powershell|cmd|eval|source|\.|node|deno|bun|tsx|ts-node|python[0-9.]*|py|pypy[0-9.]*|perl|ruby|php|lua|osascript|xargs|parallel|at|batch|crontab|tee|dd|stopbar(?:\.mjs)?)$/i
388
+
389
+ /** The command without the body of its one single-quoted heredoc, when that body is plain stdin data (see above);
390
+ * else null. The lines before and after the heredoc stay: they are commands. */
391
+ export function withoutStdinHeredoc(cmd ) {
392
+ if (cmd.includes('\r') || cmd.includes('\0')) return null
393
+ const all = [...cmd.matchAll(STDIN_HEREDOC)]
394
+ if (all.length !== 1 || (cmd.match(/<</g) ?? []).length !== 1) return null
395
+ const m = all[0], at = m.index
396
+ const lineStart = cmd.lastIndexOf('\n', at) + 1
397
+ const nl = cmd.indexOf('\n', at)
398
+ if (nl < 0) return null
399
+ const header = cmd.slice(lineStart, at) + ' ' + cmd.slice(at + m[0].length, nl)
400
+ const lines = cmd.slice(nl + 1).split('\n')
401
+ const end = lines.indexOf(m[1])
402
+ if (end < 0) return null // no closing delimiter line: not a heredoc this function understands
403
+ // on the header line, outside quotes: a write redirection (fd duplication such as 2>&1 is fine) or a pipe; outside
404
+ // single quotes: an expansion ($X, $(...), `...`), which may name an interpreter (X=bash; $X <<'EOF')
405
+ if (/>(?!&\d)|&>|\|/.test(header.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g, "''"))) return null
406
+ if (/[$`]/.test(header.replace(/'[^']*'/g, "''"))) return null
407
+ // a word anywhere before the body that runs or stores stdin (also in a function or alias defined on an earlier line)
408
+ for (const w of (cmd.slice(0, at) + ' ' + header).split(/[\s;&|(){}<>=]+/).filter(Boolean)) {
409
+ const base = w.replace(/^["']+|["']+$/g, '').replace(/\\/g, '/').split('/').pop() .replace(/\.exe$/i, '')
410
+ if (RUNS_STDIN.test(base)) return null
411
+ }
412
+ return [cmd.slice(0, nl), ...lines.slice(end)].join('\n')
413
+ }
414
+
415
+ /** Shell command text. Returns the reason for a block, or null. Text matching only: see SECURITY.md.
416
+ * Every check runs on the text as written and as bash joins quoted parts of a word (`.g""it`, `'.cl'"aude"`, `gi"t"`:
417
+ * unsplice and unquoteShellWords). For bash, the body of
418
+ * one single-quoted heredoc that is plain stdin data (withoutStdinHeredoc) is skipped by the human-only checks only:
419
+ * .git, the agent settings directories and Stopbar code stay protected in it. */
420
+ export function protectedCommand(cmd , pr , shell = 'bash') {
421
+ const texts = [...new Set([cmd, unsplice(cmd), unquoteShellWords(cmd)])]
422
+ for (const t of texts) {
423
+ const c = norm(t).toLowerCase()
424
+ if (DOT_GIT.test(c)) return 'the command names a .git directory (Stopbar state, git hooks, git config live there)'
425
+ for (const [re, d] of AGENT_DIRS) if (re.test(c)) return `the command names a ${d} directory (agent settings there hold the Stopbar hooks)`
426
+ }
427
+ for (const t of texts) {
428
+ const c = norm(t).toLowerCase()
429
+ if (isGitConfigWrite(t)) return '`git config` writes .git/config; only reads (--get, --list) are allowed'
430
+ if (GIT_ALIAS.test(t) || GIT_ALIAS_ENV.test(t)) return '`git -c alias.<name>=...` defines a one-off git alias, which hides the real git subcommand'
431
+ if (c.includes(lc(pr.stateDir)) || c.includes(lc(pr.gitDir) + '/')) return 'the command names the git directory'
432
+ for (const d of pr.codeDirs) if (c.includes(lc(d))) return `the command names Stopbar code (${d})`
433
+ }
434
+ const admin = (shell === 'bash' ? withoutStdinHeredoc(cmd) : null) ?? cmd
435
+ for (const t of new Set([admin, unsplice(admin), unquoteShellWords(admin)])) if (HUMAN_ONLY.test(t) || STOPBAR_ADMIN.test(t)) return 'human-only Stopbar command or setting'
273
436
  return null
274
437
  }
package/dist/cli.js CHANGED
@@ -11,9 +11,12 @@ const HELP = `stopbar ${VERSION}: proven gates for coding agents (Claude Code ho
11
11
 
12
12
  stopbar init --build "<cmd>" --test "<cmd>" [--profile default|ts|python|strict] [--base-ref <ref>] [--max-retries 3] [--cap 500]
13
13
  [--cost 1] [--hooks claude,claude-project,cursor,codex,gemini,antigravity,git] [--no-pin] [--force] [--force-hooks] [--repo <dir>]
14
- [--cli "<cmd>"] [--stop-gate block|warn]
14
+ [--cli "<cmd>"] [--stop-gate block|warn] [--require-run] [--no-git-hooks]
15
+ --hooks <clients> adds the git hooks (pre-commit, pre-push) unless --no-git-hooks;
16
+ a foreign git hook is kept with a warning (replace it: --hooks git --force-hooks)
15
17
  --cli: command that starts Stopbar in hints (default: npx --no-install stopbar)
16
18
  --stop-gate warn: Stop only warns; git commit and git push stay blocked until the gates pass
19
+ --require-run: build and full test gates count only through stopbar run build|test
17
20
  stopbar upgrade [--hooks <targets>] [--force-hooks] [--repo <dir>]
18
21
  a human re-pins the hook runtime from this package (and rewrites hooks with --hooks);
19
22
  state, gates, taint and budget stay as they are
@@ -31,10 +34,25 @@ const HELP = `stopbar ${VERSION}: proven gates for coding agents (Claude Code ho
31
34
  Four pillars:
32
35
  PROVE stopbar prove [--out f.json] [--lean f.lean] inductive proof of the kernel and the 10 mutants
33
36
  (npm run verify:lean checks the Lean export with lake build in Docker)
34
- PROBE stopbar probe [--target wrapper] [--runs 200] [--seed 1] [--jobs N] [--work dir] [--out dir]
35
- stateful probing of the hooks against the proven kernel on real git repositories
37
+ PROBE stopbar probe [--target wrapper|<file> | --cmd "<command>" [--target-file <path>] [--cmd-timeout 300000]]
38
+ [--runs 200] [--seed 1] [--jobs N] [--work dir] [--out dir] [--regressions dir]
39
+ [--regressions-only] [--check-mutants] [--mutant-runs 50] [--no-record]
40
+ stateful probing: --target wrapper (default) checks the hooks against the proven kernel on real git
41
+ repositories; --target <file.ts|.mts|.js|.mjs> runs a model of any TS/JS project (defineModel from
42
+ 'stopbar/probe', export default or export target). A failure is shrunk to repro-<seed>.json in --out.
43
+ --cmd: a program in any language (Python, Go, Rust, ...), one process per job, NDJSON on stdin/stdout:
44
+ {"op":"info"} -> {"name","description","mutants"?} {"op":"generate","seed":N} -> {"seed":N,"actions":[...]}
45
+ {"op":"execute","run":{...},"dir":"...","mutant"?} -> {"ok":true,"steps","cov"} | {"ok":false,"mismatch":{...}}
46
+ --target-file: the file hashed as targetSha256 (default: the first existing file in the command)
47
+ --cmd-timeout: ms to wait for one answer (0 = no limit); a crash or bad answer exits 1 with its stderr
48
+ --check-mutants: every mutant of the target must fail within --mutant-runs seeds (exit 0 only if all do)
49
+ --no-record: do not append probe:result to events.jsonl (else recorded when Stopbar is initialised)
50
+ stopbar probe init [--lang ts|py] [--name sample] [--out probes] [--force] [--repo <dir>]
51
+ writes a starter target (<name>.probe.ts or <name>_probe.py, 2 mutants) and
52
+ prints the command that runs it
36
53
  GATE init, upgrade, hook, status, approve-tests, approve-shell, resume, reset, doctor (above)
37
- ATTEST stopbar attest [--format json|md] deterministic attestation: HEAD, tree, gates, human actions, log sha256
54
+ ATTEST stopbar attest [--format json|md] deterministic attestation: HEAD, tree, gates, human actions, log sha256,
55
+ probe evidence (the latest probe:result per target, and whether it was taken at the current snapshot)
38
56
  All commands take --repo <dir> (default: the current directory). 'verify' is an alias of 'prove'.`
39
57
 
40
58
  function opts(a ) {
@@ -76,11 +94,25 @@ async function main() {
76
94
  }
77
95
  if (cmd === 'probe') {
78
96
  const P = await import('./probe/index.js')
97
+ // a worker share: --worker-file <path> (the runner), or --worker <json> (older runners)
98
+ if (o.has('worker-file')) { await P.worker(JSON.parse(readFileSync(o.get('worker-file') , 'utf8'))); return {code: 0} }
79
99
  if (o.has('worker')) { await P.worker(JSON.parse(o.get('worker') )); return {code: 0} }
80
100
  const num = (n ) => (o.get(n) === undefined ? undefined : o.int(n, 0))
81
- const r = await P.probe({target: o.get('target'), runs: num('runs'), seed: num('seed'), jobs: num('jobs'), work: o.get('work'), out: o.get('out'),
82
- regressions: o.get('regressions'), regressionsOnly: o.has('regressions-only')})
83
- return {code: r.ok ? 0 : 1}
101
+ try {
102
+ if (argv[1] === 'init') {
103
+ const io = opts(argv.slice(2))
104
+ const r = (await import('./probe/init.js')).initProbe({lang: io.get('lang'), name: io.get('name'), out: io.get('out'), force: io.has('force'), repo: io.get('repo')})
105
+ return {code: 0, msg: r.message}
106
+ }
107
+ for (const f of ['target', 'cmd', 'target-file']) if (o.has(f) && o.get(f) === undefined) throw new P.ProbeError(`--${f} needs a value`)
108
+ const r = await P.probe({target: o.get('target'), cmd: o.get('cmd'), targetFile: o.get('target-file'), cmdTimeoutMs: num('cmd-timeout'), runs: num('runs'), seed: num('seed'), jobs: num('jobs'), work: o.get('work'), out: o.get('out'),
109
+ regressions: o.get('regressions'), regressionsOnly: o.has('regressions-only'), checkMutants: o.has('check-mutants'), mutantRuns: num('mutant-runs'),
110
+ repo: o.get('repo'), record: !o.has('no-record')})
111
+ return {code: r.ok ? 0 : 1}
112
+ } catch (e) {
113
+ if (e instanceof P.ProbeError) return {code: 1, msg: `stopbar probe: ${e.message}`}
114
+ throw e
115
+ }
84
116
  }
85
117
  if (cmd === 'attest') return (await import('./attest.js')).attest({repo: o.get('repo'), format: o.get('format')})
86
118
  return {code: 1, msg: `unknown command ${cmd}\n\n${HELP}`}
package/dist/commands.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import {cpSync, existsSync, mkdirSync, rmSync} from 'node:fs'
5
5
  import {join} from 'node:path'
6
6
  import {hasChain, protectedCommand} from './classify.js'
7
- import {CLAUDE_POST_MATCHER, claudeHooks, hookCommand, installHooks, parseTargets} from './integrations.js'
7
+ import {CLAUDE_POST_MATCHER, claudeHooks, hookCommand, installHooks, parseTargets, } from './integrations.js'
8
8
  import {cliOf, ConfigError, DEFAULT_SAFE_TOOLS, makeConfig, PROFILES} from './config.js'
9
9
  import {decode, initKernel, kstep, MACHINE, } from './engine.js'
10
10
  import {classifyChanges, whyBlocked} from './hook.js'
@@ -67,7 +67,8 @@ export function pinRuntime(r ) {
67
67
  const dst = join(r.stateDir, 'runtime')
68
68
  rmSync(dst, {recursive: true, force: true})
69
69
  mkdirSync(dst, {recursive: true})
70
- for (const n of ['bin', 'dist']) cpSync(join(PKG_ROOT, n), join(dst, n), {recursive: true})
70
+ // the .d.ts files in dist/ only type the tests (npm run typecheck); the runtime never loads them
71
+ for (const n of ['bin', 'dist']) cpSync(join(PKG_ROOT, n), join(dst, n), {recursive: true, filter: (f) => !f.endsWith('.d.ts')})
71
72
  for (const n of ['package.json', 'LICENSE']) if (existsSync(join(PKG_ROOT, n))) cpSync(join(PKG_ROOT, n), join(dst, n))
72
73
  return dst
73
74
  }
@@ -82,11 +83,11 @@ export function init(o ) {
82
83
  for (const [k, v] of [['--build', buildCmd], ['--test', fullTestCmd]]) {
83
84
  if (hasChain(v)) return {code: 1, msg: `${k} ${JSON.stringify(v)} has shell operators; put it in one script (e.g. an npm script) so its exit status is the gate`}
84
85
  }
85
- for (const f of ['cli', 'stop-gate']) if (o.has(f) && o.get(f) === undefined) return {code: 1, msg: `--${f} needs a value`}
86
+ for (const f of ['cli', 'stop-gate', 'hooks']) if (o.has(f) && o.get(f) === undefined) return {code: 1, msg: `--${f} needs a value`}
86
87
  let cfg
87
88
  try {
88
89
  cfg = makeConfig({buildCmd, fullTestCmd, profile: o.get('profile'), maxRetries: o.int('max-retries', 3), cap: o.int('cap', 500), costPerCall: o.int('cost', 1), baseRef: o.get('base-ref'),
89
- cliCmd: o.get('cli'), stopGate: o.get('stop-gate')})
90
+ cliCmd: o.get('cli'), stopGate: o.get('stop-gate'), requireRun: o.has('require-run')})
90
91
  } catch (e) { if (e instanceof ConfigError) return {code: 1, msg: e.message}; throw e }
91
92
  if (existsSync(paths(repo).config) && !o.has('force')) return {code: 1, msg: `already initialised (${paths(repo).config}); use --force to replace config and state`}
92
93
  const pin = !o.has('no-pin')
@@ -101,7 +102,12 @@ export function init(o ) {
101
102
  return {code: 1, msg: `--base-ref ${JSON.stringify(cfg.baseRef)} does not resolve to a commit/tree in ${repo.root}`}
102
103
  }
103
104
  const hooksOpt = o.get('hooks')
104
- const targets = hooksOpt === undefined ? [] : parseTargets(hooksOpt) // validated before anything is written
105
+ const named = hooksOpt === undefined ? [] : parseTargets(hooksOpt) // validated before anything is written
106
+ if (o.has('no-git-hooks') && named.includes('git')) return {code: 1, msg: '--no-git-hooks and --hooks ...git exclude each other'}
107
+ // the git hooks close what an agent hook cannot see (git aliases, merge, cherry-pick, am, commit-tree before a push):
108
+ // added to every --hooks <client> unless --no-git-hooks
109
+ const gitByDefault = named.length > 0 && !named.includes('git') && !o.has('no-git-hooks')
110
+ const targets = gitByDefault ? [...named, 'git'] : named
105
111
  mkdirSync(repo.stateDir, {recursive: true})
106
112
  return withLock(repo, () => {
107
113
  const {s, snap} = freshWithSnap(repo, cfg)
@@ -110,14 +116,17 @@ export function init(o ) {
110
116
  writeState(repo, s)
111
117
  const runtime = pin ? pinRuntime(repo) : PKG_ROOT
112
118
  const command = hookCommand(runtime)
113
- appendEvent(repo, {source: 'human:init', cfg, runtime, version: VERSION, kernel: MACHINE})
119
+ appendEvent(repo, {source: 'human:init', cfg, runtime, version: VERSION, kernel: MACHINE, ...(targets.length ? {hooks: targets} : {})})
114
120
  const warn = countDirtyTests(repo, s, dirty, 'init:dirty-tests')
115
121
  const lines = [`Stopbar ${VERSION} initialised in ${repo.stateDir}`, ` profile ${cfg.profile}; build: ${cfg.buildCmd}; full tests: ${cfg.fullTestCmd}${cfg.baseRef ? `; base ref: ${cfg.baseRef}` : ''}`,
116
- ` stop gate: ${cfg.stopGate ?? 'block'}; gate hints use: ${cliOf(cfg)} run build|test`,
122
+ ` stop gate: ${cfg.stopGate ?? 'block'}; gate hints use: ${cliOf(cfg)} run build|test${cfg.requireRun ? '; requireRun: true (gates count only through stopbar run build|test)' : ''}`,
117
123
  ` hooks run: ${command}`]
118
- if (targets.length) for (const l of installHooks(repo, targets, runtime, o.has('force-hooks'))) lines.push(` hooks written: ${l}`)
124
+ const warns = []
125
+ if (targets.length) for (const l of installHooks(repo, targets, runtime, o.has('force-hooks'), {gitByDefault, warn: (w) => warns.push(w)})) lines.push(` hooks written: ${l}`)
119
126
  else lines.push(' add these hooks to .claude/settings.local.json (or run init again with --hooks claude,cursor,codex,gemini,antigravity,git):', JSON.stringify(hooksConfig(command), null, 2))
120
- lines.push(...warn, 'Next: restart the agent in this repository and run `stopbar doctor`.')
127
+ if (gitByDefault) lines.push(' git hooks (pre-commit, pre-push) were added to --hooks by default; pass --no-git-hooks to skip them')
128
+ else if (named.length && o.has('no-git-hooks')) lines.push(' WARN: --no-git-hooks: git aliases, merge, cherry-pick, am and commit-tree are not gated before a push; stopbar doctor reports it')
129
+ lines.push(...warns.map((w) => ` ${w}`), ...warn, 'Next: restart the agent in this repository and run `stopbar doctor`.')
121
130
  return {code: 0, msg: lines.join('\n')}
122
131
  })
123
132
  }
@@ -158,21 +167,28 @@ export function secretReason(repo )
158
167
  return {text: `matched ${pattern} (${path}) in ${tool} at rev ${hit.treeRev}`, pattern, path, tool, revision: hit.treeRev}
159
168
  }
160
169
 
161
- function statusText(repo , cfg , s ) {
170
+ /** `now`: the working tree as it is now. A change no hook has counted yet (now.id !== s.snapshot) keeps a commit blocked
171
+ * at the next hook (pre:commit-sync), so status never says `allowed` then. */
172
+ function statusText(repo , cfg , s , now ) {
162
173
  const v = decode(s.kernel)
163
174
  const yn = (b ) => (b ? 'yes' : 'no')
164
175
  const ok = (rev ) => (rev === v.treeRev ? `ok at revision ${rev}` : 'not at the current revision')
165
- const commit = v.halted ? 'blocked: session halted' : v.buildOkRev === v.treeRev && v.testsOkRev === v.treeRev && !v.testsTainted ? 'allowed' : `blocked: ${whyBlocked(v, cfg)}`
176
+ const uncounted = now.id !== s.snapshot
177
+ const green = v.buildOkRev === v.treeRev && v.testsOkRev === v.treeRev && !v.testsTainted
178
+ const commit = v.halted ? 'blocked: session halted' : !green ? `blocked: ${whyBlocked(v, cfg)}`
179
+ : uncounted ? 'blocked: uncommitted working-tree changes not yet counted (run build and full tests on the current tree)' : 'allowed'
166
180
  const torn = readEvents(repo).torn.length
167
181
  return [
168
182
  `Stopbar ${VERSION} repo ${repo.root}`,
169
183
  `revision ${v.treeRev} (tree ${s.snapshot.slice(0, 12)})${cfg.baseRef ? ` base ref ${cfg.baseRef}` : ''}`,
184
+ ...(uncounted ? [` working tree has uncounted changes since revision ${v.treeRev}; gates will be re-checked on the next hook`] : []),
170
185
  `build ${ok(v.buildOkRev)} (${cfg.buildCmd})`,
171
186
  `full tests ${ok(v.testsOkRev)} (${cfg.fullTestCmd})`,
172
187
  `tainted ${yn(v.testsTainted)} secret read ${v.secretTainted ? `yes (${secretReason(repo)?.text ?? 'reason not in the event log'})` : 'no'} shell approval held ${yn(v.shellToken)}`,
173
188
  `session ${v.halted ? 'HALTED' : 'running'} spent ${v.spent}/${v.capNow} test failures ${v.testFails}/${s.params.maxRetries} build failures ${v.buildFails}/${s.params.maxRetries}`,
174
189
  `commit ${commit}`,
175
190
  `stop gate ${cfg.stopGate ?? 'block'}${cfg.stopGate === 'warn' ? ' (Stop only warns; git commit and git push stay blocked until the gates pass)' : ''}`,
191
+ ...(cfg.requireRun ? ['requireRun true (the build and full test gates count only through stopbar run build|test)'] : []),
176
192
  ...(torn ? [`event log ${torn} torn line(s) kept as they are (see stopbar doctor)`] : []),
177
193
  ].join('\n')
178
194
  }
@@ -191,8 +207,10 @@ export function human(cmd , o ) {
191
207
  }
192
208
  const s = readState(repo)
193
209
  if (cmd === 'status') {
194
- return {code: 0, msg: o.has('json') ? JSON.stringify({version: VERSION, repo: repo.root, stateDir: repo.stateDir, config: cfg, stopGate: cfg.stopGate ?? 'block', snapshot: s.snapshot, params: s.params, kernel: decode(s.kernel),
195
- secretRead: decode(s.kernel).secretTainted ? secretReason(repo) : null}, null, 1) : statusText(repo, cfg, s)}
210
+ // the working tree now (read-only for state.json, as in attest: only the private snapshot index is refreshed)
211
+ const now = snapshot(repo)
212
+ return {code: 0, msg: o.has('json') ? JSON.stringify({version: VERSION, repo: repo.root, stateDir: repo.stateDir, config: cfg, stopGate: cfg.stopGate ?? 'block', ...(cfg.requireRun ? {requireRun: true} : {}), snapshot: s.snapshot, params: s.params, kernel: decode(s.kernel),
213
+ secretRead: decode(s.kernel).secretTainted ? secretReason(repo) : null, workingTreeSnapshot: now.id, workingTreeCounted: now.id === s.snapshot}, null, 1) : statusText(repo, cfg, s, now)}
196
214
  }
197
215
  let res
198
216
  if (cmd === 'approve-tests') {
package/dist/config.js CHANGED
@@ -21,13 +21,16 @@ import {globToRegExp} from './glob.js'
21
21
 
22
22
 
23
23
 
24
+
25
+
26
+
24
27
 
25
28
 
26
29
  export const STOP_GATES = ['block', 'warn']
27
30
  /** Hint command when config.cliCmd is not set: uses an installed stopbar only, never downloads it from the registry. */
28
31
  export const DEFAULT_CLI = 'npx --no-install stopbar'
29
32
 
30
- const TEST_COMMON = ['**/tests/**', '**/test/**', '**/__tests__/**']
33
+ const TEST_COMMON = ['**/tests/**', '**/test/**', '**/__tests__/**', 'scripts/*test*']
31
34
  const TEST_JS = ['**/*.test.*', '**/*.spec.*', '**/e2e/**']
32
35
  const TEST_PY = ['**/test_*.py', '**/*_test.py']
33
36
  const TEST_OTHER = ['**/*_test.go', '**/*_test.rs', '**/*Test.java', '**/*Tests.cs']
@@ -106,6 +109,7 @@ export function validateConfig(c ) {
106
109
  if (o.stopGate !== undefined && !STOP_GATES.includes(o.stopGate )) {
107
110
  throw new ConfigError(`config.stopGate must be ${STOP_GATES.map((g) => JSON.stringify(g)).join(' or ')}, got ${JSON.stringify(o.stopGate)}`)
108
111
  }
112
+ if (o.requireRun !== undefined && typeof o.requireRun !== 'boolean') throw new ConfigError(`config.requireRun must be true or false, got ${JSON.stringify(o.requireRun)}`)
109
113
  return o
110
114
  }
111
115
 
@@ -131,7 +135,7 @@ export function isSafeRef(ref ) {
131
135
  }
132
136
 
133
137
  export function makeConfig(a
134
- ) {
138
+ ) {
135
139
  const profile = a.profile ?? 'default'
136
140
  const paths = PROFILES[profile]
137
141
  if (!paths) throw new ConfigError(`unknown profile ${JSON.stringify(profile)}; known: ${Object.keys(PROFILES).join(', ')}`)
@@ -145,5 +149,6 @@ export function makeConfig(a
145
149
  ...(baseRef && baseRef !== 'HEAD' ? {baseRef} : {}),
146
150
  ...(cliCmd !== undefined ? {cliCmd} : {}),
147
151
  ...(a.stopGate !== undefined ? {stopGate: a.stopGate} : {}),
152
+ ...(a.requireRun === true ? {requireRun: true} : {}),
148
153
  })
149
154
  }