stopbar 1.1.3 → 1.2.1
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 +184 -0
- package/README.md +225 -31
- package/SECURITY.md +129 -39
- package/bin/stopbar.mjs +0 -0
- package/dist/adapters/antigravity.js +6 -6
- package/dist/adapters/claude.js +1 -1
- package/dist/adapters/codex.js +7 -7
- package/dist/adapters/cursor.js +6 -6
- package/dist/adapters/gemini.js +7 -7
- package/dist/adapters/index.js +4 -3
- package/dist/adapters/types.js +7 -4
- package/dist/attest.js +28 -3
- package/dist/build-info.json +2 -2
- package/dist/classify.js +356 -29
- package/dist/cli.js +39 -7
- package/dist/commands.js +36 -13
- package/dist/config.js +7 -2
- package/dist/doctor.js +63 -28
- package/dist/hook.js +59 -32
- package/dist/integrations.js +50 -6
- package/dist/probe/index.js +261 -62
- package/dist/probe/init.js +217 -0
- package/dist/probe/sdk.js +242 -0
- package/dist/probe/stdio.js +219 -0
- package/dist/probe/wrapper.js +1 -1
- package/dist/store.js +1 -1
- package/dist/verify.js +34 -26
- package/package.json +17 -2
- package/skills/stopbar/SKILL.md +126 -0
- package/src/probe/sdk.ts +241 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,189 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.1 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
`src/kernel.ts` is unchanged (sha256 `c602fc4bcf8ffb2e...`); every kernel law holds as in 1.2.0. No new dependency.
|
|
6
|
+
A `config.json` and a `state.json` from 1.0.0–1.2.0 work without migration.
|
|
7
|
+
|
|
8
|
+
- **Custom `core.hooksPath` is not written.** When `core.hooksPath` points outside `.git/hooks` (Husky, Lefthook, a
|
|
9
|
+
shared or tracked hooks directory), `init --hooks <client>` writes no git hook there and prints a `WARN` with the
|
|
10
|
+
manual `node "<runtime>/bin/stopbar.mjs" git-hook pre-commit|pre-push` lines; explicit `--hooks git` without
|
|
11
|
+
`--force-hooks` fails closed (exit 2) before any hook file is written; `--force-hooks` writes the hooks and keeps a foreign
|
|
12
|
+
one as `<name>.stopbar-backup`. `stopbar doctor` reports `[WARN] hooks git`: it says that git commit and git push are
|
|
13
|
+
not gated, and prints the exact line for each missing hook. A `stopbar git-hook <name>` line chained by hand counts.
|
|
14
|
+
- **`stopbar status` after `baseRef` advanced.** With `testsTainted` and a non-`HEAD` `baseRef`, `status` prints
|
|
15
|
+
`note: no existing test or test-config file currently differs from <baseRef>; ...` when that is so, and
|
|
16
|
+
`status --json` has `taintedDiffersFromBaseRef` (`true`, `false`, or `null` when untainted or without `baseRef`).
|
|
17
|
+
The taint stays (L2.2): `status` never writes `state.json`.
|
|
18
|
+
- **`stopbar probe --cmd`: no silent exit.** A target that printed a banner or a non-JSON answer to `info` ended the
|
|
19
|
+
CLI with exit 0 (and `await probe()` with exit 13) on Linux: `close()` waited for an `exit` event of a killed,
|
|
20
|
+
unref'd child against an unref'd timer. `close()` now returns at once for a killed or exited process, and its timers
|
|
21
|
+
hold the event loop and are cleared. Regression test: banner, non-JSON and crash on `info` give exit 1 from the CLI
|
|
22
|
+
and a `ProbeError` from `probe()` and `loadCmd()`; exit 0 comes only with `PROBE PASS`.
|
|
23
|
+
- **Four bypasses closed in `src/classify.ts`.** `printenv`, a bare `env`, `Get-ChildItem Env:` and
|
|
24
|
+
`/proc/self/environ` are a secret read (`env VAR=1 cmd` and `set` are not). Tokens with `..` are normalised
|
|
25
|
+
(`cat src/../.env`), and a live wildcard that reaches a secret name is a read (`cat .en*`, `cat .en?`). `rm`, `mv`,
|
|
26
|
+
`del`, `Remove-Item` and the like with a wildcard on `.git` or an agent settings directory are blocked (`rm -rf .g*`,
|
|
27
|
+
`rm -rf .cl*`), and so is a wildcard followed by a path inside (`cp x .g*/hooks/pre-commit`). A git subcommand from
|
|
28
|
+
an expansion is blocked (`git $f -m x`, `p=push; git $p --no-verify`, `git "${cmd}"`). Unit tests also record the
|
|
29
|
+
known limits (`cat $(echo .e)nv`, `f=.e; cat ${f}nv`, `node /tmp/x.js`).
|
|
30
|
+
- **`stopbar doctor` names the gate mode** on the `config.json` line: `gates: hook command text (use --require-run for
|
|
31
|
+
exit-code-only gates)` or `gates: stopbar run only (--require-run)`. `--require-run` stays optional.
|
|
32
|
+
- **Tests:** HALT with `safeTools: ["*"]` still pauses Bash, Edit, Write and Read; the heredoc exceptions hold only
|
|
33
|
+
for `<<'EOF'` (not `<<EOF`, `<<"EOF"`, `bash -s <<'EOF'` or `sh <<'EOF'`).
|
|
34
|
+
- **Types:** no `any` left in `src/hook.ts`, `src/verify.ts`, `src/doctor.ts`, `src/probe/` and `src/adapters/`.
|
|
35
|
+
In the probe SDK, `ActionSpec.run` takes `args: unknown` (was `any`); destructured arguments such as
|
|
36
|
+
`run: (s, {x}, check)` still compile. `npm run typecheck` builds first, so it works on a fresh clone.
|
|
37
|
+
- **Release:** `.github/workflows/release.yml` publishes to npm with provenance (Trusted Publishing, OIDC) when a `v*`
|
|
38
|
+
tag that matches `package.json` is pushed.
|
|
39
|
+
- **Docs:** README and SECURITY open with what is proven, what is tested and what needs an OS sandbox, add
|
|
40
|
+
"Hardening: OS sandbox + client deny rules", list the default `safeTools` with a warning about broad globs, and say
|
|
41
|
+
what probe evidence in `attest` is. SECURITY has one "Known limits of 1.2.1" section.
|
|
42
|
+
|
|
43
|
+
## 1.2.0 (2026-11-26)
|
|
44
|
+
|
|
45
|
+
`src/kernel.ts` is unchanged (sha256 `c602fc4bcf8ffb2e...`); every kernel law holds as in 1.1.3. A `config.json` and a
|
|
46
|
+
`state.json` from 1.0.0–1.1.3 work without migration. `stopbar probe --target wrapper` (the default) runs as before.
|
|
47
|
+
This release joins 1.2.0-rc.1 (PROBE for TS/JS) with PROBE for any language and `stopbar probe init`. No new runtime
|
|
48
|
+
dependency: `gdp-wired` 0.60.0 is still the only one.
|
|
49
|
+
|
|
50
|
+
Selftest fixes (8 findings of the 1.2.0 audit, each with a regression test):
|
|
51
|
+
|
|
52
|
+
- **F1 (P1) `git config` with the word `list` or `get` in a value is a write.** Only the words right after `config`
|
|
53
|
+
decide a read: the subcommands `list` and `get <name>`, or `--get`, `--get-all`, `--get-regexp`, `--get-urlmatch`,
|
|
54
|
+
`--list`, `-l` before the arguments, with scope and format flags around them. `git config core.hooksPath list` and
|
|
55
|
+
`git config alias.ci "commit -m list -q"` were taken for reads and are now blocked.
|
|
56
|
+
- **F2 (P1) git global options with a value.** `--attr-source <tree>` (also `=`), `--super-prefix`, `--list-cmds` and
|
|
57
|
+
any other `--opt=value` before the subcommand no longer hide `commit`, `push`, `config` or `-c alias.*`.
|
|
58
|
+
- **F3 (P2) `stopbar probe init` is not blocked.** The human-only check now looks for `init`, `resume`, `reset`,
|
|
59
|
+
`upgrade` and `doctor --fix` right after the `stopbar` program word (`stopbar`, `stopbar.mjs`, `stopbar@<version>`,
|
|
60
|
+
quoted or not). `stopbar init` and `npx stopbar init` stay blocked.
|
|
61
|
+
- **F4 (P2) `stopbar attest` with a long `events.jsonl`.** The last kernel step is found with a loop, not with
|
|
62
|
+
`Math.max(...events)`, which overflowed the stack at about 130 000 lines.
|
|
63
|
+
- **F5, F6 (P2) mixed and word-final quotes.** New `unquoteShellWords`: the text checks also read each word with its
|
|
64
|
+
quote pairs removed, so `'.cl'"aude"`, `.g"i"'t'`, `.e"n"'v'` and `gi"t"` are `.claude`, `.git`, `.env` and `git`
|
|
65
|
+
for self-protection, the secret check and the commit and push classification.
|
|
66
|
+
- **F7 (P2) `stopbar probe` with large `--runs` or `--mutant-runs`.** A worker gets its share in a file
|
|
67
|
+
(`--worker-file <path>` in the work directory, removed when the worker ends) instead of one JSON argument, which
|
|
68
|
+
failed with `spawn ENAMETOOLONG`. `--worker <json>` still works.
|
|
69
|
+
- **F8 (P2) `stopbar status` on an uncounted working tree.** `status` compares the working tree with the counted
|
|
70
|
+
snapshot. After a change that no hook has counted, it says so on the `revision` line and shows `commit blocked:
|
|
71
|
+
uncommitted working-tree changes not yet counted` instead of `allowed`. `status --json` has the new fields
|
|
72
|
+
`workingTreeSnapshot` and `workingTreeCounted`.
|
|
73
|
+
- `skills/stopbar/SKILL.md`: who runs which prober (agrees with SECURITY.md section 4), `--cmd-timeout` under CPU
|
|
74
|
+
load, what to do after the first finding, and when `--no-record` is allowed.
|
|
75
|
+
- Tests: unit tests for F1–F7 (`classify`, `attestation` on 140 000 log lines, `probe()` with 40 000 mutant seeds) and
|
|
76
|
+
E2E scenario S41 (F8).
|
|
77
|
+
|
|
78
|
+
Launch hardening:
|
|
79
|
+
|
|
80
|
+
- **`stopbar probe --cmd` never hangs after a failed kill.** `taskkill` reports a failure (no rights, a sandbox, not on
|
|
81
|
+
`PATH`) by its exit status, not by an exception; Stopbar now checks it and then kills the direct child. The pipes of
|
|
82
|
+
the process are always destroyed and the child is unref'd, also after the grace period of `close()`, so a process that
|
|
83
|
+
survives can no longer keep Stopbar's event loop open.
|
|
84
|
+
- **Git hooks by default.** `init --hooks <clients>` also writes `pre-commit` and `pre-push` (they close git aliases,
|
|
85
|
+
and before a push `merge`, `cherry-pick`, `am` and `commit-tree`). `--no-git-hooks` skips them. A foreign git hook is
|
|
86
|
+
kept with a `WARN` that names `--hooks git --force-hooks`; with `git` named in `--hooks` it is still an error.
|
|
87
|
+
`init` without `--hooks` writes nothing outside `.git/stopbar/`. `stopbar doctor` reports `[WARN] hooks git` while
|
|
88
|
+
one of the two Stopbar git hooks is missing, with the fix `stopbar upgrade --hooks git`.
|
|
89
|
+
- **`git -c alias.<name>=...` is blocked** (also `-calias.`, quoted, `--config-env alias.*` and
|
|
90
|
+
`GIT_CONFIG_KEY_<n>=alias.*`): a one-off alias hid the real git subcommand from the commit and push gates.
|
|
91
|
+
- **Quote splicing.** The secret and self-protection checks also read the command as bash joins the quoted parts of a
|
|
92
|
+
word: `cat .e""nv` is a read of `.env`, `rm -rf .g""it` and `cat .cl''aude/...` are blocked.
|
|
93
|
+
- **`--require-run`** (`config.requireRun`, default `false`): the build and full test gates count only through
|
|
94
|
+
`stopbar run build|test`; the same command from the agent's shell is not recorded and the hook names `stopbar run`
|
|
95
|
+
(`post:require-run` in the log). `status`, `doctor` and `attest` show it.
|
|
96
|
+
- `scripts/*test*` is a test pattern in every profile (new `config.json` files).
|
|
97
|
+
- **`safeTools` while halted** (telemetry): the tools in `config.safeTools` (default `mcp__ccd_turn__*`,
|
|
98
|
+
`mcp__ccd_session_mgmt__*`) pass in `HALT`, so the agent can ask a human for `stopbar resume`. They take no kernel
|
|
99
|
+
step. Read, Edit, Write, Bash, WebFetch and every other MCP tool stay paused.
|
|
100
|
+
- **A single-quoted heredoc as stdin is data** (telemetry): `agy -p - <<'EOF'` … `EOF` whose prompt mentions
|
|
101
|
+
`approve-tests` is no longer blocked as a human-only command. A shell or interpreter on the command line, a pipe, a
|
|
102
|
+
`>`/`>>` redirection, a variable or a command that stores or runs stdin (`xargs`, `at`, `tee`, `stopbar`) keeps the
|
|
103
|
+
full check; `.git`, agent settings and Stopbar code stay protected in the body.
|
|
104
|
+
- **No false `[WARN] kernel link`** (telemetry): `stopbar doctor` finds `gdp-wired` with `import.meta.resolve`, so a
|
|
105
|
+
hoisted install (`npm install stopbar`) is checked. The WARN stays for a copy where it cannot be resolved.
|
|
106
|
+
- `stopbar doctor` reports missing Claude Code hooks also when only the git hooks are present, if the last `init` or
|
|
107
|
+
`upgrade` wrote Claude Code hooks (`human:init` now logs the hook targets).
|
|
108
|
+
- **Typecheck.** `npm run typecheck` (`tsc --noEmit`, strict, over `src/`, `scripts/`, `tests/`, `bench/`) with
|
|
109
|
+
`typescript` 5.9.3 and `@types/node` 24 as devDependencies only. `src/hook.ts` has no `any` left. The build writes
|
|
110
|
+
`dist/*.d.ts` files that point at `src/*.ts` for the typecheck; they are not in the npm package and not in the pinned
|
|
111
|
+
runtime.
|
|
112
|
+
- **CI.** `.github/workflows/ci.yml`: build, typecheck, tests and a PROBE of `examples/bounded-queue.probe.ts` with
|
|
113
|
+
mutants on Ubuntu, Windows and macOS; `npm run prove`; `lake build` with Lean 4.34.0 from elan through the new
|
|
114
|
+
`node scripts/verify-lean.ts --local` (no Docker). The Docker mode is unchanged.
|
|
115
|
+
- README and SECURITY.md say in their first lines what is proven (the kernel) and what is tested (the wrapper), and
|
|
116
|
+
that without an OS sandbox Stopbar is no security boundary against a hostile agent.
|
|
117
|
+
- **Agent skill.** `skills/stopbar/SKILL.md` (Agent Skills format) tells an agent how to work under the gate and how to
|
|
118
|
+
write Zero-FP probes. It is in the npm package (`files`) and linked from the README.
|
|
119
|
+
- Tests: unit tests for the kill fallback (a stuck target with no `taskkill` on `PATH`), `git -c alias.*`, quote
|
|
120
|
+
splicing, the stdin heredoc and the documented limits; E2E scenarios S38 (`safeTools` in `HALT`), S39
|
|
121
|
+
(`--require-run`, `.e""nv`, `.g""it`, `git -c alias.*`, a heredoc prompt) and S40 (git hooks by default, foreign hooks,
|
|
122
|
+
`--no-git-hooks`, `[WARN] hooks git`, kernel link).
|
|
123
|
+
|
|
124
|
+
- **PROBE for any language: `stopbar probe --cmd "<command>"`.** Each worker starts the command once (in a shell) and
|
|
125
|
+
speaks NDJSON with it on stdin/stdout: `{"op":"info"}` (name, description, optional mutants),
|
|
126
|
+
`{"op":"generate","seed":N}` (a run of pure JSON actions) and `{"op":"execute","run":...,"dir":...,"mutant"?}` (an
|
|
127
|
+
`Outcome`). Shrinking, `--regressions` / `--regressions-only`, `--check-mutants` / `--mutant-runs`, `summary.json`,
|
|
128
|
+
`repro-<seed>.json`, `probe:result` and the probe evidence of `attest` work as with `--target <file>`. A reproduction
|
|
129
|
+
names the target by the `name` from `info`; `summary.json`, `repro-<seed>.json`, `probe:result` and `attest` also
|
|
130
|
+
have `targetCmd`. A `--cmd` target replays only the regressions in `--regressions <dir>`.
|
|
131
|
+
- `--target` and `--cmd` together exit 1 with the reason. `--target-file <path>` names the file for `targetSha256`;
|
|
132
|
+
without it, the first word after the interpreter that is an existing file is hashed, else `targetSha256` is `null`.
|
|
133
|
+
- Errors of the external process do not hang a worker: a process that exits, closes stdout, prints a line that is not
|
|
134
|
+
JSON, answers `{"error": ...}` or an answer of the wrong shape, or gives no answer within `--cmd-timeout` ms (default
|
|
135
|
+
300000) stops the probe with exit 1 and the end of its stderr. At the end Stopbar closes stdin and kills the process
|
|
136
|
+
tree after 2 s.
|
|
137
|
+
- **`stopbar probe init [--lang ts|py] [--name sample] [--out probes] [--force] [--repo <dir>]`:** writes
|
|
138
|
+
`<name>.probe.ts` (`defineModel` from `stopbar/probe`) or `<name>_probe.py` (the NDJSON protocol, Python standard
|
|
139
|
+
library only) with 2 actions, 1 invariant, 2 mutants and the rules for zero false positives, and prints the command
|
|
140
|
+
that runs it. An existing file stays without `--force`; an unknown `--lang` and a `--name` with anything other than
|
|
141
|
+
letters, digits, `-` and `_` (for example `../`) exit 1.
|
|
142
|
+
- Example: `examples/bounded_queue_probe.py`, the Python counterpart of `examples/bounded-queue.probe.ts` (the same
|
|
143
|
+
queue model, invariants and mutants `M1_dropCap` and `M2_lifoInsteadOfFifo`).
|
|
144
|
+
- Tests: unit tests `tests/unit/probe-stdio.test.ts` (the NDJSON client, mutants, chunked shrinking over stdio, a
|
|
145
|
+
process that crashes, closes stdout, prints garbage, hangs or answers with an error, `probe init`); E2E scenario S37
|
|
146
|
+
(`--cmd` with a Node NDJSON target, so it runs without Python: mutants, `probe:result`, `attest` json and md, minimal
|
|
147
|
+
reproduction and replay, `--target` with `--cmd`, a crashing process, `probe init --lang ts|py`; with `python3` or
|
|
148
|
+
`python` on the machine also `examples/bounded_queue_probe.py` and the `--lang py` template).
|
|
149
|
+
|
|
150
|
+
From 1.2.0-rc.1:
|
|
151
|
+
|
|
152
|
+
- **PROBE for any TS/JS project.** `stopbar probe --target <file>` loads a `.ts`, `.mts`, `.js` or `.mjs` file and
|
|
153
|
+
runs its `default` export (or the export `target`) as a probe target. A missing file or an export that is not a
|
|
154
|
+
target exits 1 with the reason. The sha256 of the file goes into the log and into `summary.json` (`targetSha256`).
|
|
155
|
+
A file target replays regressions only from `--regressions <dir>`, never Stopbar's own.
|
|
156
|
+
- **SDK `stopbar/probe`** (`exports["./probe"]`, types from `src/probe/sdk.ts`): `defineModel` (actions with
|
|
157
|
+
`gen(r)` and `run(state, args, check)`, invariants, `setup` / `teardown`, mutants), `createRng` (xorshift32, the
|
|
158
|
+
same numbers on every platform), `MismatchError` and the types `ModelSpec`, `Rng`, `Check`, `ActionSpec`,
|
|
159
|
+
`ProbeTarget`, `ProbeRun`, `Outcome`, `Mismatch`. A failed check or an exception of the code under test is a
|
|
160
|
+
mismatch with the step and the action. The worker does not crash.
|
|
161
|
+
- **`--check-mutants [--mutant-runs 50]`:** the original runs first. If it passes, each mutant runs seeds from
|
|
162
|
+
`--seed` in order until the first failure (`KILLED`, with seed, step, check and action) or `--mutant-runs` seeds
|
|
163
|
+
(`SURVIVED`). Exit 0 only if the original passes and no mutant survives. `summary.json` has
|
|
164
|
+
`mutants: {total, killed, survived, details}`. A target without mutants is refused (exit 1).
|
|
165
|
+
- **Faster shrinking:** after the cut at the failing step, blocks of half, a quarter, ... of the run (at least 2
|
|
166
|
+
steps) go first, then single steps to a fixed point. On a 200-step run with two relevant steps: 25 executions
|
|
167
|
+
instead of 147 (measured by the unit test). The order is fixed, so the minimal run is the same on every platform.
|
|
168
|
+
- **`probe:result` in `events.jsonl`:** in a repository with a valid Stopbar `config.json` and `state.json`, every
|
|
169
|
+
probe run appends one entry under the lock (target, target path and sha256, tree snapshot, runs, regressions,
|
|
170
|
+
passed, failed, steps, ok, mutants, sha256 of `summary.json`). It has no `req`: it is not a kernel step,
|
|
171
|
+
`state.json` is not touched and `attest` stays consistent. `--no-record` skips it. Without Stopbar nothing is
|
|
172
|
+
recorded and the prober works on its own. The test suite's own probe run passes `record: false`.
|
|
173
|
+
- **`stopbar attest`: probe evidence.** JSON `probes: [...]` (the latest `probe:result` per target since the last
|
|
174
|
+
`init` / `reset`, with `atCurrentSnapshot`); Markdown `## Probe evidence` (or `- none`).
|
|
175
|
+
- Smaller fixes in the runner: `summary.json` and other files without a run in a regression directory are skipped;
|
|
176
|
+
when `--regressions` and `--out` are the same directory, the reproductions in it are kept for the replay; a failing
|
|
177
|
+
regression writes its own run as the reproduction; results are sorted by seed; every execution starts in an empty
|
|
178
|
+
directory; the default work directory follows `--repo` (in a repository without Stopbar it is a temporary
|
|
179
|
+
directory, so the prober creates no `.git/stopbar`); the last line of the output names `summary.json`.
|
|
180
|
+
- Example: `examples/bounded-queue.probe.ts` (a FIFO queue with a fixed capacity, mutants `M1_dropCap` and
|
|
181
|
+
`M2_lifoInsteadOfFifo`).
|
|
182
|
+
- Tests: unit tests `tests/unit/probe-sdk.test.ts` (`createRng`, `defineModel`, checks, teardown, mutants, chunked
|
|
183
|
+
`shrink`, `loadTarget`); E2E scenario S36 (file target with mutants, `probe:result`, `attest` before and after an
|
|
184
|
+
edit, minimal reproduction and replay, a surviving mutant, a target without mutants, `--no-record`, a repository
|
|
185
|
+
without Stopbar).
|
|
186
|
+
|
|
3
187
|
## 1.1.3 (2026-11-26)
|
|
4
188
|
|
|
5
189
|
`src/kernel.ts` is unchanged (sha256 `c602fc4bcf8ffb2e...`); every kernel law holds as in 1.1.2. A `config.json` and a
|
package/README.md
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
# Stopbar
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://github.com/polszewski-pl/stopbar/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/stopbar)
|
|
5
|
+
|
|
6
|
+
Stopbar is an execution gate for AI coding agents in three parts: a **formally proven decision kernel**
|
|
7
|
+
(`src/kernel.ts`, about 160 lines, its laws proven by induction and checked again by `lake build` in Lean 4.34.0), a
|
|
8
|
+
**tested wrapper** around it (the hooks of Claude Code, Cursor, Codex CLI, Gemini CLI and Antigravity CLI, and git
|
|
9
|
+
hooks for any other tool), and an **attestation** of the session (`stopbar attest`). The wrapper reads tool calls and
|
|
10
|
+
command text and asks the kernel; it is covered by unit and E2E tests and stateful probing, not by the proof.
|
|
11
|
+
|
|
12
|
+
| Proven (Lean 4.34.0) | Tested (wrapper + E2E + PROBE) | Not covered without OS sandbox |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| The decision rule `src/kernel.ts`: no commit without a passing build and full suite at the current revision (L1); test taint until a human approval (L2.x); pause of risky and outbound calls after a secret read (L3.x); halt on budget and retries (L4.x). 10 mutants each fall with a counterexample. | How tool calls become kernel requests: exact gate commands, content snapshots of the tree, test and secret path patterns, self-protection of `.git`, agent settings and the Stopbar code, the client adapters, the git hooks. | A path or name built at run time (`f=.e; cat ${f}nv`), a script the agent wrote and runs (`node /tmp/x.js`), code that the gate commands run, secrets in files with ordinary names. See [SECURITY.md](SECURITY.md) section 3. |
|
|
15
|
+
|
|
16
|
+
**Without an OS sandbox, Stopbar stops shortcuts and mistakes of an agent; it is not a security boundary against a
|
|
17
|
+
hostile agent.** A command can build a path at run time or hide it in a script that the text rules do not see. See
|
|
18
|
+
[SECURITY.md](SECURITY.md) for what is proven, what the wrapper enforces and what needs an OS sandbox.
|
|
19
|
+
|
|
20
|
+
It stops an agent from:
|
|
5
21
|
|
|
6
22
|
- committing without a passing build and a passing **full** test suite at the current revision of the working tree;
|
|
7
23
|
- weakening existing tests or test configuration without a human approval;
|
|
@@ -11,8 +27,7 @@ CLI, Gemini CLI and Antigravity CLI, and as git hooks for any other tool. It sto
|
|
|
11
27
|
|
|
12
28
|
The decisions come from one rule, `src/kernel.ts`. gdp-wired 0.60.0 proves its laws by induction, and 10 mutants of
|
|
13
29
|
the rule each fall with a counterexample. Every client goes through the same rule: an adapter translates the client's
|
|
14
|
-
hook payload into one internal event and renders the decision in the client's own output format.
|
|
15
|
-
[SECURITY.md](SECURITY.md) for what is proven, what the wrapper enforces and what needs an OS sandbox.
|
|
30
|
+
hook payload into one internal event and renders the decision in the client's own output format.
|
|
16
31
|
|
|
17
32
|
## Supported agents
|
|
18
33
|
|
|
@@ -36,15 +51,6 @@ working. An unknown or damaged payload fails closed (exit 2). The configs writte
|
|
|
36
51
|
`stopbar run build` and `stopbar run test`. The git hooks then allow a commit only after both passed at the
|
|
37
52
|
current tree, block it after an unapproved test change, and block a push after a secret read without approval.
|
|
38
53
|
|
|
39
|
-
## Four pillars
|
|
40
|
-
|
|
41
|
-
| Pillar | Command | What it gives you |
|
|
42
|
-
|---|---|---|
|
|
43
|
-
| PROVE | `stopbar prove`, `npm run verify:lean` | The inductive proof of the kernel, 10 mutants that must fall with a counterexample, and (release gate) `lake build` of the Lean export in a pinned Lean 4.34.0 container without network. |
|
|
44
|
-
| PROBE | `stopbar probe` | Stateful probing: at least 200 random multi-step sequences of hook events, human commands and damaged files on real git repositories, compared step by step with the proven kernel. v1.0 has one target, `wrapper` (Stopbar itself). |
|
|
45
|
-
| GATE | `stopbar init`, `upgrade`, `hook`, `git-hook`, `run`, `status`, `approve-tests`, `approve-shell`, `resume`, `reset`, `doctor` | The agent hooks, the git fallback and the human commands. |
|
|
46
|
-
| ATTEST | `stopbar attest` | A deterministic attestation of the session: HEAD, tree, gates, human actions and the sha256 of the event log. |
|
|
47
|
-
|
|
48
54
|
## Set up in 3 steps
|
|
49
55
|
|
|
50
56
|
Requirements: Node.js 22.18 or later, git, a git repository.
|
|
@@ -63,9 +69,13 @@ Requirements: Node.js 22.18 or later, git, a git repository.
|
|
|
63
69
|
|
|
64
70
|
Profiles for the path patterns: `--profile default|ts|python|strict`. `init` copies the runtime to
|
|
65
71
|
`.git/stopbar/runtime/` and points every hook to it. Existing settings and hooks in those files stay; earlier
|
|
66
|
-
Stopbar entries are replaced.
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
Stopbar entries are replaced. Since 1.2.0, `--hooks <clients>` also writes the git hooks (`pre-commit`,
|
|
73
|
+
`pre-push`): they close git aliases, and before a push `merge`, `cherry-pick`, `am` and `commit-tree`, which an
|
|
74
|
+
agent hook does not see. Pass `--no-git-hooks` to skip them. `init` does not overwrite a git hook it did not write:
|
|
75
|
+
when the git hooks were added by default, it keeps the foreign hook and prints a `WARN`; when you named `git` in
|
|
76
|
+
`--hooks`, it stops with an error. `--hooks git --force-hooks` replaces it (the old hook is kept as
|
|
77
|
+
`<name>.stopbar-backup`). Without `--hooks`, `init` writes nothing outside `.git/stopbar/` and prints the Claude
|
|
78
|
+
Code JSON to paste. A template is in [claude-hooks.example.json](claude-hooks.example.json).
|
|
69
79
|
|
|
70
80
|
3. **Check** the setup, then restart the agent in the repository:
|
|
71
81
|
|
|
@@ -99,7 +109,7 @@ EOF
|
|
|
99
109
|
|
|
100
110
|
| Command | Who | What it does |
|
|
101
111
|
|---|---|---|
|
|
102
|
-
| `stopbar init --build "<cmd>" --test "<cmd>" [--profile p] [--base-ref <ref>] [--cli "<cmd>"] [--stop-gate block\|warn] [--max-retries 3] [--cap 500] [--cost 1] [--hooks <targets>] [--no-pin] [--force] [--force-hooks]` | human | Writes `config.json` and a fresh state, pins the runtime, writes or prints the hooks. Targets: `claude` (`local`), `claude-project` (`project`), `cursor`, `codex`, `gemini`, `antigravity` (`agy`), `git`, comma separated
|
|
112
|
+
| `stopbar init --build "<cmd>" --test "<cmd>" [--profile p] [--base-ref <ref>] [--cli "<cmd>"] [--stop-gate block\|warn] [--require-run] [--max-retries 3] [--cap 500] [--cost 1] [--hooks <targets>] [--no-git-hooks] [--no-pin] [--force] [--force-hooks]` | human | Writes `config.json` and a fresh state, pins the runtime, writes or prints the hooks. Targets: `claude` (`local`), `claude-project` (`project`), `cursor`, `codex`, `gemini`, `antigravity` (`agy`), `git`, comma separated; `git` is added to any other target unless `--no-git-hooks`. `--require-run`: the build and full test gates count only through `stopbar run build\|test`. `--build` and `--test` must be different commands. `--base-ref` sets the git ref used to judge whether a test file already existed (default `HEAD`). `--cli` sets the Stopbar command in hints (default `npx --no-install stopbar`). `--stop-gate warn` lets a turn end with unverified changes (default `block`); commit and push stay gated. |
|
|
103
113
|
| `stopbar upgrade [--hooks <targets>] [--force-hooks]` | human | After you update the Stopbar package: re-pins the hook runtime in `.git/stopbar/runtime` and, with `--hooks`, rewrites the hooks. `state.json`, `config.json` and the snapshots stay as they are (revision, gates, taint, budget), so an active session keeps its green gates. Use it instead of `init --force`. |
|
|
104
114
|
| `stopbar hook [--adapter auto\|claude\|cursor\|codex\|gemini\|antigravity]` | agent | The hook. JSON on stdin; the decision in the client's format (see Supported agents). |
|
|
105
115
|
| `stopbar git-hook pre-commit\|pre-push` | git | The git fallback gate. Exit 1 aborts the commit or push. |
|
|
@@ -111,14 +121,125 @@ EOF
|
|
|
111
121
|
| `stopbar reset` | human | Fresh kernel state. Config and event log stay. Also repairs a damaged `state.json`. Uncommitted changes of existing tests or test config (against `baseRef`, else `HEAD`) are not forgotten: the session starts tainted, with a `WARN`, until `approve-tests`. `init --force` does the same. |
|
|
112
122
|
| `stopbar doctor [--json]` | human | Environment, config, state, hooks and a dry run. Exit 1 on a problem. |
|
|
113
123
|
| `stopbar prove [--out f.json] [--lean f.lean]` | human, CI | PROVE: the inductive proof of the kernel and the 10 mutants. Exit 0 only if everything holds. `verify` is an alias. |
|
|
114
|
-
| `stopbar probe [--target wrapper] [--runs 200] [--seed 1] [--jobs N] [--work dir] [--out dir]` | human, CI | PROBE: stateful probing against the proven kernel. A failure is shrunk to a minimal JSON reproduction.
|
|
115
|
-
| `stopbar
|
|
124
|
+
| `stopbar probe [--target wrapper\|<file> \| --cmd "<command>" [--target-file <path>] [--cmd-timeout 300000]] [--runs 200] [--seed 1] [--jobs N] [--work dir] [--out dir] [--regressions dir] [--regressions-only] [--check-mutants] [--mutant-runs 50] [--no-record]` | human, CI | PROBE: stateful probing of the hooks against the proven kernel (`wrapper`, needs the full package with gdp-wired), of your own model in a `.ts`, `.mts`, `.js` or `.mjs` file, or of a program in any language over NDJSON (`--cmd`, see [PROBE for your project](#probe-for-your-project)). `--target` and `--cmd` exclude each other. A failure is shrunk to a minimal JSON reproduction. |
|
|
125
|
+
| `stopbar probe init [--lang ts\|py] [--name sample] [--out probes] [--force] [--repo <dir>]` | human, agent | Writes a starter target with 2 actions, 1 invariant and 2 mutants (`<name>.probe.ts` or `<name>_probe.py`) and prints the command that runs it. It does not overwrite a file without `--force`. |
|
|
126
|
+
| `stopbar attest [--format json\|md]` | human, CI | ATTEST: the session attestation. The same state and log give the same output. Exit 1 if the state and the log disagree, exit 2 if a file is damaged. `probes` (Markdown: `## Probe evidence`) lists the latest `probe:result` per target since the last `init` or `reset`, with `atCurrentSnapshot`. |
|
|
116
127
|
|
|
117
128
|
All commands take `--repo <dir>`. The agent cannot run the human commands: the hooks block them.
|
|
118
129
|
|
|
119
130
|
State, configuration and the event log are in `<repo>/.git/stopbar/`: `config.json`, `state.json`, `events.jsonl`, the
|
|
120
131
|
private snapshot index and the pinned runtime. They are outside the working tree, so they never change the tree hash.
|
|
121
132
|
|
|
133
|
+
## Parts of the package
|
|
134
|
+
|
|
135
|
+
The gate (GATE, with PROVE and ATTEST) is the product. PROBE is a test tool that ships in the same package.
|
|
136
|
+
|
|
137
|
+
| Part | Command | What it gives you |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| PROVE | `stopbar prove`, `npm run verify:lean` | The inductive proof of the kernel, 10 mutants that must fall with a counterexample, and (release gate) `lake build` of the Lean export in a pinned Lean 4.34.0 container without network. |
|
|
140
|
+
| PROBE | `stopbar probe` | Stateful probing: at least 200 random multi-step sequences of hook events, human commands and damaged files on real git repositories, compared step by step with the proven kernel (target `wrapper`, Stopbar itself). Since 1.2.0 also your own project: a TS/JS model written with `defineModel` from `stopbar/probe`, or a program in any language (Python, Go, Rust, ...) that speaks NDJSON on stdin/stdout (`--cmd`), with mutants that must be caught. |
|
|
141
|
+
| GATE | `stopbar init`, `upgrade`, `hook`, `git-hook`, `run`, `status`, `approve-tests`, `approve-shell`, `resume`, `reset`, `doctor` | The agent hooks, the git fallback and the human commands. |
|
|
142
|
+
| ATTEST | `stopbar attest` | A deterministic attestation of the session: HEAD, tree, gates, human actions, probe evidence and the sha256 of the event log. |
|
|
143
|
+
|
|
144
|
+
**Probe evidence** in `stopbar attest` is the recorded result of one probe run, tied to the tree snapshot and to the
|
|
145
|
+
sha256 of the prober file. It says what the prober saw on that tree. It is no proof against a hostile agent without an
|
|
146
|
+
OS sandbox: an agent that can write `events.jsonl` can also write a false entry ([SECURITY.md](SECURITY.md) section 4).
|
|
147
|
+
|
|
148
|
+
## PROBE for your project
|
|
149
|
+
|
|
150
|
+
`stopbar probe --target <file>` runs a model of any TS/JS code. The file exports (as `default` or as `target`) a
|
|
151
|
+
target; `defineModel` from `stopbar/probe` builds one from a list of actions:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import {defineModel} from 'stopbar/probe'
|
|
155
|
+
|
|
156
|
+
export default defineModel<{q: BoundedQueue<number>; model: number[]}>({
|
|
157
|
+
name: 'bounded-queue', description: 'FIFO queue with capacity 4 vs an array model',
|
|
158
|
+
setup: () => ({q: new BoundedQueue<number>(4), model: []}),
|
|
159
|
+
actions: [
|
|
160
|
+
{name: 'push', weight: 3, gen: (r) => ({x: r.int(0, 99)}), run: (s, {x}, check) => {
|
|
161
|
+
const accepted = s.model.length < 4
|
|
162
|
+
check.eq('push result', s.q.push(x), accepted)
|
|
163
|
+
if (accepted) s.model.push(x)
|
|
164
|
+
}},
|
|
165
|
+
{name: 'shift', gen: () => null, run: (s, _a, check) => check.eq('shift result', s.q.shift(), s.model.shift())},
|
|
166
|
+
],
|
|
167
|
+
invariants: [{name: 'size', check: (s, check) => check.eq('size', s.q.size, s.model.length)}],
|
|
168
|
+
mutants: {M1_dropCap: () => ({q: new BoundedQueue<number>(4, {checkCap: false}), model: []})},
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- `gen(r)` returns pure JSON data for one step. `r` is a deterministic generator (`createRng`: xorshift32, the same
|
|
173
|
+
numbers on Windows and Linux). A run is `{seed, actions: [{t: name, args}]}` with `minSteps`..`maxSteps` steps
|
|
174
|
+
(default 15..40).
|
|
175
|
+
- `run(state, args, check)` drives the real code and compares it with the model: `check.eq` (deep strict equality),
|
|
176
|
+
`check.ok`, `check.fail`. A failed check, and any exception from the code under test, is a mismatch with the step and
|
|
177
|
+
the action, not a crash. Invariants run after `setup` (step -1) and after every step. `teardown` runs after every run
|
|
178
|
+
whose `setup` returned, also after a failure.
|
|
179
|
+
- A failure is shrunk (cut after the failing step, then removal of blocks of half, a quarter, ... of the run, then of
|
|
180
|
+
single steps) and written to `repro-<seed>.json` in `--out`. `--regressions <dir>` replays such files on every run.
|
|
181
|
+
A file target replays only the regressions you name.
|
|
182
|
+
- `--check-mutants`: each mutant replaces `setup` with a damaged system under test. The original must pass, and every
|
|
183
|
+
mutant must fail within `--mutant-runs` seeds (default 50). Exit 0 only then. A survivor is named in the output and
|
|
184
|
+
in `summary.json` (`mutants.survived`). A target without mutants is refused.
|
|
185
|
+
- In a repository with Stopbar, every run appends a `probe:result` entry to `events.jsonl` (target, sha256 of the
|
|
186
|
+
target file, tree snapshot, runs, steps, mutants, sha256 of `summary.json`). It is not a kernel step and does not
|
|
187
|
+
change `state.json`. `stopbar attest` shows the latest entry per target and whether the tree is still the one that
|
|
188
|
+
was probed. `--no-record` skips the entry. Outside a Stopbar repository nothing is recorded.
|
|
189
|
+
|
|
190
|
+
A complete example with two mutants: [`examples/bounded-queue.probe.ts`](examples/bounded-queue.probe.ts)
|
|
191
|
+
(`stopbar probe --target examples/bounded-queue.probe.ts --check-mutants`). TypeScript files need Node's type
|
|
192
|
+
stripping (Node 22.18 or later): only erasable syntax, no `enum` and no constructor parameter properties.
|
|
193
|
+
|
|
194
|
+
### Any language: `--cmd`
|
|
195
|
+
|
|
196
|
+
`stopbar probe --cmd "<command>"` probes a program in any language (Python, Go, Rust, ...). Each worker (`--jobs`)
|
|
197
|
+
starts the command once, in a shell, in the current directory, and keeps it for all its runs, so the start-up cost
|
|
198
|
+
is paid once per worker and not once per seed. Stopbar sends one JSON object per line on stdin and reads one answer
|
|
199
|
+
per line on stdout (NDJSON):
|
|
200
|
+
|
|
201
|
+
| Request | Answer |
|
|
202
|
+
|---|---|
|
|
203
|
+
| `{"op":"info"}` | `{"name":"<string>","description":"<string>","mutants":["M1",...]}` (`mutants` is optional) |
|
|
204
|
+
| `{"op":"generate","seed":123}` | `{"seed":123,"actions":[...]}`: pure JSON data, the same for the same seed |
|
|
205
|
+
| `{"op":"execute","run":{"seed":123,"actions":[...]},"dir":"<scratch dir>","mutant":"M1"}` | `{"ok":true,"steps":N,"cov":{"push":3}}` or `{"ok":false,"mismatch":{"step":2,"action":{...},"what":"...","expected":...,"actual":...}}` |
|
|
206
|
+
|
|
207
|
+
- `mutant` is sent only with `--check-mutants`. `dir` is an empty scratch directory for each execution.
|
|
208
|
+
- Any answer can be `{"error":"<text>"}`. stdout is for the protocol only: print logs to stderr.
|
|
209
|
+
- An exception of the code under test is a finding: catch it in `execute` and answer with a mismatch (the
|
|
210
|
+
templates do this). A process that exits, closes stdout, prints a line that is not JSON or gives no answer within
|
|
211
|
+
`--cmd-timeout` ms (default 300000) stops the probe with exit 1 and the end of its stderr. When the probe ends,
|
|
212
|
+
Stopbar closes stdin; a process that does not exit within 2 s is killed.
|
|
213
|
+
- Shrinking, `--regressions` / `--regressions-only`, `--check-mutants`, `summary.json`, `repro-<seed>.json`,
|
|
214
|
+
`probe:result` and `attest` work as for `--target <file>`. `target` in a reproduction is the `name` from `info`;
|
|
215
|
+
`targetCmd` is the command. A `--cmd` target replays only the regressions in `--regressions <dir>`.
|
|
216
|
+
- `targetSha256` is the sha256 of `--target-file <path>`, else of the first word after the interpreter that is an
|
|
217
|
+
existing file (`python examples/bounded_queue_probe.py` hashes that file), else `null`.
|
|
218
|
+
|
|
219
|
+
[`examples/bounded_queue_probe.py`](examples/bounded_queue_probe.py) is the same queue model in Python, with the
|
|
220
|
+
standard library only:
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
stopbar probe --cmd "python examples/bounded_queue_probe.py" --runs 200 --check-mutants
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### A starter target: `stopbar probe init`
|
|
227
|
+
|
|
228
|
+
`stopbar probe init --lang ts` writes `probes/sample.probe.ts` (`defineModel`), and `--lang py` writes
|
|
229
|
+
`probes/sample_probe.py` (the NDJSON protocol, standard library only: `json`, `random`, `sys`). Both hold the same
|
|
230
|
+
model with 2 actions, 1 invariant, 2 mutants and the rules for zero false positives, and `--check-mutants` passes on
|
|
231
|
+
them as written. The command prints the line that runs the file. `--name` takes letters, digits, `-` and `_` only;
|
|
232
|
+
`--out` (default `probes`) is relative to `--repo`, else to the current directory; an existing file stays unless you
|
|
233
|
+
pass `--force`.
|
|
234
|
+
|
|
235
|
+
## Agent skill
|
|
236
|
+
|
|
237
|
+
[`skills/stopbar/SKILL.md`](skills/stopbar/SKILL.md) tells an agent how to work under the gate (exact gate commands,
|
|
238
|
+
one-command commits, the human-only commands and when to stop and ask) and how to write a probe with zero false
|
|
239
|
+
positives. It uses the Agent Skills format (`SKILL.md` with `name` and `description`), so Claude Code, Codex CLI,
|
|
240
|
+
Cursor, Gemini CLI and Antigravity CLI can load it; copy the `skills/stopbar/` directory into the skills directory of
|
|
241
|
+
your agent. The npm package includes it.
|
|
242
|
+
|
|
122
243
|
## Configuration
|
|
123
244
|
|
|
124
245
|
`config.json` keeps the gate commands, the limits and three lists of glob patterns:
|
|
@@ -163,8 +284,12 @@ profile by editing the lists: no code change is necessary.
|
|
|
163
284
|
- **`safeTools`** (optional) lists glob patterns of tool names that are local and never outbound. The default
|
|
164
285
|
(`DEFAULT_SAFE_TOOLS`) is `["mcp__ccd_turn__*", "mcp__ccd_session_mgmt__*"]`: the task-list and turn-summary tools of
|
|
165
286
|
Claude Desktop and its tools for messages between local sessions. It only exempts tools from the outbound gate
|
|
166
|
-
(WebFetch, WebSearch, MCP tools); shell commands, edits and reads are gated as before
|
|
167
|
-
|
|
287
|
+
(WebFetch, WebSearch, MCP tools); shell commands, edits and reads are gated as before. Since 1.2.0 these tools also
|
|
288
|
+
pass while the session is halted, so the agent can still ask a human for `stopbar resume`; they never take a kernel
|
|
289
|
+
step. Every other tool stays paused while halted. Edit, Write, Read and the shell tools stay gated even if a glob in
|
|
290
|
+
`safeTools` matches them (also `["*"]`). **Keep the globs narrow**: with a broad glob such as `mcp__*`, every MCP tool
|
|
291
|
+
is treated as local, passes the outbound gate after a secret read and keeps working while the session is halted.
|
|
292
|
+
A `config.json` written by 1.0.0–1.1.1 keeps its own list and keeps working; to stop false
|
|
168
293
|
`PAUSE`s on the session tools after a secret read, add `"mcp__ccd_session_mgmt__*"` to `safeTools` or write the file
|
|
169
294
|
again with `stopbar init --force ...`. `stopbar doctor` shows a `[WARN] safeTools` while a default entry is missing.
|
|
170
295
|
- **`cliCmd`** (optional, set via `stopbar init --cli "<cmd>"`) is the command that starts Stopbar in the hints shown to
|
|
@@ -177,13 +302,64 @@ profile by editing the lists: no code change is necessary.
|
|
|
177
302
|
`warn`: for long tasks with one commit at the end, the turn may end with unverified changes (for example to ask the
|
|
178
303
|
human a question); Stopbar logs a `stop:warn` entry in `events.jsonl` and answers `WARN (stopbar): ...` without
|
|
179
304
|
blocking. `git commit` and `git push` in the agent hooks and in the git hooks stay fully gated by the kernel.
|
|
180
|
-
`status`, `doctor` and `attest` show the mode.
|
|
181
|
-
|
|
305
|
+
`status`, `doctor` and `attest` show the mode.
|
|
306
|
+
- **`requireRun`** (optional, set via `stopbar init --require-run`, default `false`): the build and full test gates
|
|
307
|
+
count only when they run through `stopbar run build` or `stopbar run test`. The same command run from the agent's own
|
|
308
|
+
shell is not recorded (neither a pass nor a failure); the hook answers with a `NOTE` that names `stopbar run` and logs
|
|
309
|
+
`post:require-run`. `status`, `doctor` and `attest` show `requireRun: true` when it is on.
|
|
310
|
+
|
|
311
|
+
A damaged or empty `config.json` or `state.json` blocks every tool call (exit 2) with a message that says how to
|
|
312
|
+
repair it.
|
|
313
|
+
|
|
314
|
+
`stopbar doctor` shows the gate mode on the `config.json` line: `gates: hook command text (use --require-run for
|
|
315
|
+
exit-code-only gates)` by default, `gates: stopbar run only (--require-run)` with `requireRun`.
|
|
316
|
+
|
|
317
|
+
**Custom `core.hooksPath`** (Husky, Lefthook, a shared hooks directory): since 1.2.1 Stopbar does not write into it.
|
|
318
|
+
`init --hooks <client>` then writes no git hook and prints a `WARN`; `init --hooks git` fails closed (exit 2);
|
|
319
|
+
`stopbar doctor` reports `[WARN] hooks git`: git commit and git push are not gated by Stopbar until a human adds one
|
|
320
|
+
line to each hook of the hook manager, `node "<runtime>/bin/stopbar.mjs" git-hook pre-commit` and `... git-hook
|
|
321
|
+
pre-push` (doctor prints the exact lines), or runs `stopbar upgrade --hooks git --force-hooks`.
|
|
322
|
+
|
|
323
|
+
## Hardening: OS sandbox + client deny rules
|
|
324
|
+
|
|
325
|
+
Stopbar reads command text. To stop an agent that tries to get around it, add two layers that do not depend on text.
|
|
326
|
+
|
|
327
|
+
1. **Client deny rules.** The agent's own permission rules refuse a tool call before any hook. For Claude Code, in
|
|
328
|
+
`.claude/settings.json` (check the rule syntax against your client's documentation):
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"permissions": {
|
|
333
|
+
"deny": [
|
|
334
|
+
"Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)",
|
|
335
|
+
"Edit(./.git/**)", "Edit(./.claude/**)",
|
|
336
|
+
"Bash(curl:*)", "Bash(wget:*)", "Bash(printenv:*)",
|
|
337
|
+
"WebFetch"
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
2. **OS sandbox.** Run the agent in a container, a VM or a sandbox runtime (for example Anthropic's `sandbox-runtime`
|
|
344
|
+
or Claude Code's Bash sandbox) without network, with only the repository writable:
|
|
345
|
+
|
|
346
|
+
```sh
|
|
347
|
+
docker run --rm -it --network none -v "$PWD:/work" -v "$PWD/.claude:/work/.claude:ro" \
|
|
348
|
+
-v "$PWD/.git/hooks:/work/.git/hooks:ro" -w /work <agent-image>
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
The hooks write `.git/stopbar/`. When the whole agent runs in the container, the hooks run there too, so
|
|
352
|
+
`.git/stopbar/` must stay writable, and the agent's shell can write it as well. A sandbox that wraps only the
|
|
353
|
+
agent's shell (the hooks run outside it) can deny writes to `.git/stopbar/` inside the sandbox. Run the human
|
|
354
|
+
commands (`approve-tests`, `approve-shell`, `resume`, `reset`) outside the sandbox.
|
|
182
355
|
|
|
183
356
|
## Local use
|
|
184
357
|
|
|
185
358
|
- `npm run build` builds `dist/` from `src/` with Node's own type stripping and generates `dist/kernel.gen.js` from
|
|
186
|
-
the kernel with gdp-wired's `compileJs`. There is no
|
|
359
|
+
the kernel with gdp-wired's `compileJs`. There is no bundler, and the build needs no TypeScript compiler.
|
|
360
|
+
- `npm run typecheck` runs `tsc --noEmit` (TypeScript is a devDependency only) over `src/`, `scripts/`, `tests/` and
|
|
361
|
+
`bench/` in strict mode. The build writes small `dist/*.d.ts` files that point the tests' `dist/*.js` imports at
|
|
362
|
+
`src/*.ts`; they are not in the npm package and not in the pinned runtime.
|
|
187
363
|
- `npm test` runs the unit tests, the E2E suite (real git repositories, a separate hook process for each call) and the
|
|
188
364
|
stateful fuzzer (200 random sequences of 20–30 steps, compared with the proven kernel). It takes about 3 minutes.
|
|
189
365
|
In Claude Code, give the Bash tool enough time, for example `"env": {"BASH_DEFAULT_TIMEOUT_MS": "600000"}` in the
|
|
@@ -192,13 +368,18 @@ tool call (exit 2) with a message that says how to repair it.
|
|
|
192
368
|
- `npm run verify:lean` exports the Lean project (`leanProject()` of gdp-wired) and runs `lake build` in the
|
|
193
369
|
container from `docker/lean.Dockerfile` with `--network none`. It is the release gate for changes of `src/kernel.ts`,
|
|
194
370
|
not part of `npm test`. Build the image once (this needs the network):
|
|
195
|
-
`docker build -f docker/lean.Dockerfile -t stopbar-lean:4.34.0 docker`.
|
|
371
|
+
`docker build -f docker/lean.Dockerfile -t stopbar-lean:4.34.0 docker`. Without Docker, with Lean 4.34.0 on `PATH`
|
|
372
|
+
(for example from elan): `npm run build` and `node scripts/verify-lean.ts --local`. Both write
|
|
373
|
+
`results/lean/lean-verify.json`.
|
|
196
374
|
- `npm run bench` measures the hook latency.
|
|
197
375
|
- `npm run test:e2e` or `npm run test:fuzz` runs only the E2E suite or only the stateful prober.
|
|
198
376
|
|
|
199
377
|
## Use in CI
|
|
200
378
|
|
|
201
|
-
|
|
379
|
+
Stopbar's own workflow, [.github/workflows/ci.yml](.github/workflows/ci.yml), runs on every push to `main` and every
|
|
380
|
+
pull request: build, typecheck, the full test suite and a PROBE of `examples/bounded-queue.probe.ts` with mutants on
|
|
381
|
+
Ubuntu, Windows and macOS (Node 24); `npm run prove`; and `lake build` of the Lean export with Lean 4.34.0 from elan
|
|
382
|
+
(`node scripts/verify-lean.ts --local`). The minimum for a fork:
|
|
202
383
|
|
|
203
384
|
```yaml
|
|
204
385
|
- run: npm ci
|
|
@@ -230,15 +411,28 @@ latency. An earlier prototype that loaded the prover in every hook measured p50
|
|
|
230
411
|
|
|
231
412
|
## Tested platforms
|
|
232
413
|
|
|
233
|
-
| Platform | Node | git | Unit | E2E | `stopbar probe` | `stopbar prove` | `stopbar doctor` |
|
|
234
|
-
|
|
235
|
-
| Windows 11, Git for Windows | 24.19.0 | 2.56.0 |
|
|
236
|
-
| Linux, Debian 13 (container, no network) | 24.21.0 | 2.47.3 |
|
|
414
|
+
| Platform | Node | git | Python | Typecheck | Unit | E2E | `stopbar probe` | `--cmd` Python example | `stopbar prove` | `stopbar doctor` |
|
|
415
|
+
|---|---|---|---|---|---|---|---|---|---|---|
|
|
416
|
+
| Windows 11, Git for Windows | 24.19.0 | 2.56.0 | 3.14.7 | 0 errors | 74/74 | 460/460 | 202/202 sequences | 200/200, mutants 2/2 | proven, 10/10 mutants | OK |
|
|
417
|
+
| Linux, Debian 13 (container, no network) | 24.21.0 | 2.47.3 | 3.13.5 | 0 errors | 74/74 | 460/460 | 202/202 sequences | 200/200, mutants 2/2 | proven, 10/10 mutants | OK |
|
|
418
|
+
| macOS 26.7.2 arm64 (`macos-latest`, GitHub Actions, CI of 1.2.0) | 24.22.3 | 2.56.1 | – | 0 errors | pass | 443/443 | 202/202 sequences | – | – | – |
|
|
419
|
+
| Ubuntu, Windows (GitHub Actions) | 24 | runner | runner | CI | CI | CI | CI | – | CI (Ubuntu) | – |
|
|
420
|
+
|
|
421
|
+
The first two rows are runs of 1.2.1 on our machines; both also pass `stopbar probe --target
|
|
422
|
+
examples/bounded-queue.probe.ts --runs 50 --check-mutants` (50/50, mutants 2/2). The macOS row is the CI run of 1.2.0
|
|
423
|
+
(commit `8bfd8cb`, workflow `.github/workflows/ci.yml`): build, typecheck, `npm test` (unit with the dot reporter, so no
|
|
424
|
+
count in the log) and the same `bounded-queue` probe (50/50, mutants 2/2). The `prove` job of CI runs on Ubuntu only.
|
|
425
|
+
CI runs after a push; the results of 1.2.1 will be on the repository's Actions page (see the CI badge).
|
|
237
426
|
|
|
238
427
|
The E2E suite runs every adapter (Cursor, Codex CLI, Gemini CLI, Antigravity CLI) and the git fallback with real
|
|
239
428
|
git commits and pushes. The probe runs the same 200 seeds plus 2 regressions on both platforms, with the same 5020 steps
|
|
240
429
|
and 7152 hook calls (half of the seeds with a base ref). `stopbar doctor` passes on a fresh repository with all six `--hooks` targets.
|
|
241
|
-
|
|
430
|
+
The `--cmd` column is `stopbar probe --cmd "<python> examples/bounded_queue_probe.py" --runs 200 --check-mutants`
|
|
431
|
+
(3970 steps on both platforms). E2E scenario S37 runs `--cmd` with a Node target everywhere, and the Python example
|
|
432
|
+
and the `--lang py` template only where `python3` or `python` is found.
|
|
433
|
+
`npm run verify:lean` passes in the Lean 4.34.0 container: `lake build` exit 0, 0 errors, 0 `sorry` (run on the same
|
|
434
|
+
`src/kernel.ts`, sha256 `c602fc4bcf8ffb2e...`, which 1.2.0 and 1.2.1 do not change). `node scripts/verify-lean.ts --local`
|
|
435
|
+
gives the same result with Lean 4.34.0 on `PATH` (checked in a Debian 13 container with the toolchain of that image).
|
|
242
436
|
|
|
243
437
|
## License
|
|
244
438
|
|