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/CHANGELOG.md +144 -0
- package/README.md +155 -24
- package/SECURITY.md +83 -10
- package/dist/attest.js +28 -3
- package/dist/build-info.json +2 -2
- package/dist/classify.js +184 -21
- package/dist/cli.js +39 -7
- package/dist/commands.js +31 -13
- package/dist/config.js +7 -2
- package/dist/doctor.js +18 -8
- package/dist/hook.js +59 -32
- package/dist/integrations.js +14 -5
- package/dist/probe/index.js +247 -57
- package/dist/probe/init.js +217 -0
- package/dist/probe/sdk.js +242 -0
- package/dist/probe/stdio.js +207 -0
- package/dist/store.js +1 -1
- 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,149 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0 (2026-11-26)
|
|
4
|
+
|
|
5
|
+
`src/kernel.ts` is unchanged (sha256 `c602fc4bcf8ffb2e...`); every kernel law holds as in 1.1.3. A `config.json` and a
|
|
6
|
+
`state.json` from 1.0.0–1.1.3 work without migration. `stopbar probe --target wrapper` (the default) runs as before.
|
|
7
|
+
This release joins 1.2.0-rc.1 (PROBE for TS/JS) with PROBE for any language and `stopbar probe init`. No new runtime
|
|
8
|
+
dependency: `gdp-wired` 0.60.0 is still the only one.
|
|
9
|
+
|
|
10
|
+
Selftest fixes (8 findings of the 1.2.0 audit, each with a regression test):
|
|
11
|
+
|
|
12
|
+
- **F1 (P1) `git config` with the word `list` or `get` in a value is a write.** Only the words right after `config`
|
|
13
|
+
decide a read: the subcommands `list` and `get <name>`, or `--get`, `--get-all`, `--get-regexp`, `--get-urlmatch`,
|
|
14
|
+
`--list`, `-l` before the arguments, with scope and format flags around them. `git config core.hooksPath list` and
|
|
15
|
+
`git config alias.ci "commit -m list -q"` were taken for reads and are now blocked.
|
|
16
|
+
- **F2 (P1) git global options with a value.** `--attr-source <tree>` (also `=`), `--super-prefix`, `--list-cmds` and
|
|
17
|
+
any other `--opt=value` before the subcommand no longer hide `commit`, `push`, `config` or `-c alias.*`.
|
|
18
|
+
- **F3 (P2) `stopbar probe init` is not blocked.** The human-only check now looks for `init`, `resume`, `reset`,
|
|
19
|
+
`upgrade` and `doctor --fix` right after the `stopbar` program word (`stopbar`, `stopbar.mjs`, `stopbar@<version>`,
|
|
20
|
+
quoted or not). `stopbar init` and `npx stopbar init` stay blocked.
|
|
21
|
+
- **F4 (P2) `stopbar attest` with a long `events.jsonl`.** The last kernel step is found with a loop, not with
|
|
22
|
+
`Math.max(...events)`, which overflowed the stack at about 130 000 lines.
|
|
23
|
+
- **F5, F6 (P2) mixed and word-final quotes.** New `unquoteShellWords`: the text checks also read each word with its
|
|
24
|
+
quote pairs removed, so `'.cl'"aude"`, `.g"i"'t'`, `.e"n"'v'` and `gi"t"` are `.claude`, `.git`, `.env` and `git`
|
|
25
|
+
for self-protection, the secret check and the commit and push classification.
|
|
26
|
+
- **F7 (P2) `stopbar probe` with large `--runs` or `--mutant-runs`.** A worker gets its share in a file
|
|
27
|
+
(`--worker-file <path>` in the work directory, removed when the worker ends) instead of one JSON argument, which
|
|
28
|
+
failed with `spawn ENAMETOOLONG`. `--worker <json>` still works.
|
|
29
|
+
- **F8 (P2) `stopbar status` on an uncounted working tree.** `status` compares the working tree with the counted
|
|
30
|
+
snapshot. After a change that no hook has counted, it says so on the `revision` line and shows `commit blocked:
|
|
31
|
+
uncommitted working-tree changes not yet counted` instead of `allowed`. `status --json` has the new fields
|
|
32
|
+
`workingTreeSnapshot` and `workingTreeCounted`.
|
|
33
|
+
- `skills/stopbar/SKILL.md`: who runs which prober (agrees with SECURITY.md section 4), `--cmd-timeout` under CPU
|
|
34
|
+
load, what to do after the first finding, and when `--no-record` is allowed.
|
|
35
|
+
- Tests: unit tests for F1–F7 (`classify`, `attestation` on 140 000 log lines, `probe()` with 40 000 mutant seeds) and
|
|
36
|
+
E2E scenario S41 (F8).
|
|
37
|
+
|
|
38
|
+
Launch hardening:
|
|
39
|
+
|
|
40
|
+
- **`stopbar probe --cmd` never hangs after a failed kill.** `taskkill` reports a failure (no rights, a sandbox, not on
|
|
41
|
+
`PATH`) by its exit status, not by an exception; Stopbar now checks it and then kills the direct child. The pipes of
|
|
42
|
+
the process are always destroyed and the child is unref'd, also after the grace period of `close()`, so a process that
|
|
43
|
+
survives can no longer keep Stopbar's event loop open.
|
|
44
|
+
- **Git hooks by default.** `init --hooks <clients>` also writes `pre-commit` and `pre-push` (they close git aliases,
|
|
45
|
+
and before a push `merge`, `cherry-pick`, `am` and `commit-tree`). `--no-git-hooks` skips them. A foreign git hook is
|
|
46
|
+
kept with a `WARN` that names `--hooks git --force-hooks`; with `git` named in `--hooks` it is still an error.
|
|
47
|
+
`init` without `--hooks` writes nothing outside `.git/stopbar/`. `stopbar doctor` reports `[WARN] hooks git` while
|
|
48
|
+
one of the two Stopbar git hooks is missing, with the fix `stopbar upgrade --hooks git`.
|
|
49
|
+
- **`git -c alias.<name>=...` is blocked** (also `-calias.`, quoted, `--config-env alias.*` and
|
|
50
|
+
`GIT_CONFIG_KEY_<n>=alias.*`): a one-off alias hid the real git subcommand from the commit and push gates.
|
|
51
|
+
- **Quote splicing.** The secret and self-protection checks also read the command as bash joins the quoted parts of a
|
|
52
|
+
word: `cat .e""nv` is a read of `.env`, `rm -rf .g""it` and `cat .cl''aude/...` are blocked.
|
|
53
|
+
- **`--require-run`** (`config.requireRun`, default `false`): the build and full test gates count only through
|
|
54
|
+
`stopbar run build|test`; the same command from the agent's shell is not recorded and the hook names `stopbar run`
|
|
55
|
+
(`post:require-run` in the log). `status`, `doctor` and `attest` show it.
|
|
56
|
+
- `scripts/*test*` is a test pattern in every profile (new `config.json` files).
|
|
57
|
+
- **`safeTools` while halted** (telemetry): the tools in `config.safeTools` (default `mcp__ccd_turn__*`,
|
|
58
|
+
`mcp__ccd_session_mgmt__*`) pass in `HALT`, so the agent can ask a human for `stopbar resume`. They take no kernel
|
|
59
|
+
step. Read, Edit, Write, Bash, WebFetch and every other MCP tool stay paused.
|
|
60
|
+
- **A single-quoted heredoc as stdin is data** (telemetry): `agy -p - <<'EOF'` … `EOF` whose prompt mentions
|
|
61
|
+
`approve-tests` is no longer blocked as a human-only command. A shell or interpreter on the command line, a pipe, a
|
|
62
|
+
`>`/`>>` redirection, a variable or a command that stores or runs stdin (`xargs`, `at`, `tee`, `stopbar`) keeps the
|
|
63
|
+
full check; `.git`, agent settings and Stopbar code stay protected in the body.
|
|
64
|
+
- **No false `[WARN] kernel link`** (telemetry): `stopbar doctor` finds `gdp-wired` with `import.meta.resolve`, so a
|
|
65
|
+
hoisted install (`npm install stopbar`) is checked. The WARN stays for a copy where it cannot be resolved.
|
|
66
|
+
- `stopbar doctor` reports missing Claude Code hooks also when only the git hooks are present, if the last `init` or
|
|
67
|
+
`upgrade` wrote Claude Code hooks (`human:init` now logs the hook targets).
|
|
68
|
+
- **Typecheck.** `npm run typecheck` (`tsc --noEmit`, strict, over `src/`, `scripts/`, `tests/`, `bench/`) with
|
|
69
|
+
`typescript` 5.9.3 and `@types/node` 24 as devDependencies only. `src/hook.ts` has no `any` left. The build writes
|
|
70
|
+
`dist/*.d.ts` files that point at `src/*.ts` for the typecheck; they are not in the npm package and not in the pinned
|
|
71
|
+
runtime.
|
|
72
|
+
- **CI.** `.github/workflows/ci.yml`: build, typecheck, tests and a PROBE of `examples/bounded-queue.probe.ts` with
|
|
73
|
+
mutants on Ubuntu, Windows and macOS; `npm run prove`; `lake build` with Lean 4.34.0 from elan through the new
|
|
74
|
+
`node scripts/verify-lean.ts --local` (no Docker). The Docker mode is unchanged.
|
|
75
|
+
- README and SECURITY.md say in their first lines what is proven (the kernel) and what is tested (the wrapper), and
|
|
76
|
+
that without an OS sandbox Stopbar is no security boundary against a hostile agent.
|
|
77
|
+
- **Agent skill.** `skills/stopbar/SKILL.md` (Agent Skills format) tells an agent how to work under the gate and how to
|
|
78
|
+
write Zero-FP probes. It is in the npm package (`files`) and linked from the README.
|
|
79
|
+
- Tests: unit tests for the kill fallback (a stuck target with no `taskkill` on `PATH`), `git -c alias.*`, quote
|
|
80
|
+
splicing, the stdin heredoc and the documented limits; E2E scenarios S38 (`safeTools` in `HALT`), S39
|
|
81
|
+
(`--require-run`, `.e""nv`, `.g""it`, `git -c alias.*`, a heredoc prompt) and S40 (git hooks by default, foreign hooks,
|
|
82
|
+
`--no-git-hooks`, `[WARN] hooks git`, kernel link).
|
|
83
|
+
|
|
84
|
+
- **PROBE for any language: `stopbar probe --cmd "<command>"`.** Each worker starts the command once (in a shell) and
|
|
85
|
+
speaks NDJSON with it on stdin/stdout: `{"op":"info"}` (name, description, optional mutants),
|
|
86
|
+
`{"op":"generate","seed":N}` (a run of pure JSON actions) and `{"op":"execute","run":...,"dir":...,"mutant"?}` (an
|
|
87
|
+
`Outcome`). Shrinking, `--regressions` / `--regressions-only`, `--check-mutants` / `--mutant-runs`, `summary.json`,
|
|
88
|
+
`repro-<seed>.json`, `probe:result` and the probe evidence of `attest` work as with `--target <file>`. A reproduction
|
|
89
|
+
names the target by the `name` from `info`; `summary.json`, `repro-<seed>.json`, `probe:result` and `attest` also
|
|
90
|
+
have `targetCmd`. A `--cmd` target replays only the regressions in `--regressions <dir>`.
|
|
91
|
+
- `--target` and `--cmd` together exit 1 with the reason. `--target-file <path>` names the file for `targetSha256`;
|
|
92
|
+
without it, the first word after the interpreter that is an existing file is hashed, else `targetSha256` is `null`.
|
|
93
|
+
- Errors of the external process do not hang a worker: a process that exits, closes stdout, prints a line that is not
|
|
94
|
+
JSON, answers `{"error": ...}` or an answer of the wrong shape, or gives no answer within `--cmd-timeout` ms (default
|
|
95
|
+
300000) stops the probe with exit 1 and the end of its stderr. At the end Stopbar closes stdin and kills the process
|
|
96
|
+
tree after 2 s.
|
|
97
|
+
- **`stopbar probe init [--lang ts|py] [--name sample] [--out probes] [--force] [--repo <dir>]`:** writes
|
|
98
|
+
`<name>.probe.ts` (`defineModel` from `stopbar/probe`) or `<name>_probe.py` (the NDJSON protocol, Python standard
|
|
99
|
+
library only) with 2 actions, 1 invariant, 2 mutants and the rules for zero false positives, and prints the command
|
|
100
|
+
that runs it. An existing file stays without `--force`; an unknown `--lang` and a `--name` with anything other than
|
|
101
|
+
letters, digits, `-` and `_` (for example `../`) exit 1.
|
|
102
|
+
- Example: `examples/bounded_queue_probe.py`, the Python counterpart of `examples/bounded-queue.probe.ts` (the same
|
|
103
|
+
queue model, invariants and mutants `M1_dropCap` and `M2_lifoInsteadOfFifo`).
|
|
104
|
+
- Tests: unit tests `tests/unit/probe-stdio.test.ts` (the NDJSON client, mutants, chunked shrinking over stdio, a
|
|
105
|
+
process that crashes, closes stdout, prints garbage, hangs or answers with an error, `probe init`); E2E scenario S37
|
|
106
|
+
(`--cmd` with a Node NDJSON target, so it runs without Python: mutants, `probe:result`, `attest` json and md, minimal
|
|
107
|
+
reproduction and replay, `--target` with `--cmd`, a crashing process, `probe init --lang ts|py`; with `python3` or
|
|
108
|
+
`python` on the machine also `examples/bounded_queue_probe.py` and the `--lang py` template).
|
|
109
|
+
|
|
110
|
+
From 1.2.0-rc.1:
|
|
111
|
+
|
|
112
|
+
- **PROBE for any TS/JS project.** `stopbar probe --target <file>` loads a `.ts`, `.mts`, `.js` or `.mjs` file and
|
|
113
|
+
runs its `default` export (or the export `target`) as a probe target. A missing file or an export that is not a
|
|
114
|
+
target exits 1 with the reason. The sha256 of the file goes into the log and into `summary.json` (`targetSha256`).
|
|
115
|
+
A file target replays regressions only from `--regressions <dir>`, never Stopbar's own.
|
|
116
|
+
- **SDK `stopbar/probe`** (`exports["./probe"]`, types from `src/probe/sdk.ts`): `defineModel` (actions with
|
|
117
|
+
`gen(r)` and `run(state, args, check)`, invariants, `setup` / `teardown`, mutants), `createRng` (xorshift32, the
|
|
118
|
+
same numbers on every platform), `MismatchError` and the types `ModelSpec`, `Rng`, `Check`, `ActionSpec`,
|
|
119
|
+
`ProbeTarget`, `ProbeRun`, `Outcome`, `Mismatch`. A failed check or an exception of the code under test is a
|
|
120
|
+
mismatch with the step and the action. The worker does not crash.
|
|
121
|
+
- **`--check-mutants [--mutant-runs 50]`:** the original runs first. If it passes, each mutant runs seeds from
|
|
122
|
+
`--seed` in order until the first failure (`KILLED`, with seed, step, check and action) or `--mutant-runs` seeds
|
|
123
|
+
(`SURVIVED`). Exit 0 only if the original passes and no mutant survives. `summary.json` has
|
|
124
|
+
`mutants: {total, killed, survived, details}`. A target without mutants is refused (exit 1).
|
|
125
|
+
- **Faster shrinking:** after the cut at the failing step, blocks of half, a quarter, ... of the run (at least 2
|
|
126
|
+
steps) go first, then single steps to a fixed point. On a 200-step run with two relevant steps: 25 executions
|
|
127
|
+
instead of 147 (measured by the unit test). The order is fixed, so the minimal run is the same on every platform.
|
|
128
|
+
- **`probe:result` in `events.jsonl`:** in a repository with a valid Stopbar `config.json` and `state.json`, every
|
|
129
|
+
probe run appends one entry under the lock (target, target path and sha256, tree snapshot, runs, regressions,
|
|
130
|
+
passed, failed, steps, ok, mutants, sha256 of `summary.json`). It has no `req`: it is not a kernel step,
|
|
131
|
+
`state.json` is not touched and `attest` stays consistent. `--no-record` skips it. Without Stopbar nothing is
|
|
132
|
+
recorded and the prober works on its own. The test suite's own probe run passes `record: false`.
|
|
133
|
+
- **`stopbar attest`: probe evidence.** JSON `probes: [...]` (the latest `probe:result` per target since the last
|
|
134
|
+
`init` / `reset`, with `atCurrentSnapshot`); Markdown `## Probe evidence` (or `- none`).
|
|
135
|
+
- Smaller fixes in the runner: `summary.json` and other files without a run in a regression directory are skipped;
|
|
136
|
+
when `--regressions` and `--out` are the same directory, the reproductions in it are kept for the replay; a failing
|
|
137
|
+
regression writes its own run as the reproduction; results are sorted by seed; every execution starts in an empty
|
|
138
|
+
directory; the default work directory follows `--repo` (in a repository without Stopbar it is a temporary
|
|
139
|
+
directory, so the prober creates no `.git/stopbar`); the last line of the output names `summary.json`.
|
|
140
|
+
- Example: `examples/bounded-queue.probe.ts` (a FIFO queue with a fixed capacity, mutants `M1_dropCap` and
|
|
141
|
+
`M2_lifoInsteadOfFifo`).
|
|
142
|
+
- Tests: unit tests `tests/unit/probe-sdk.test.ts` (`createRng`, `defineModel`, checks, teardown, mutants, chunked
|
|
143
|
+
`shrink`, `loadTarget`); E2E scenario S36 (file target with mutants, `probe:result`, `attest` before and after an
|
|
144
|
+
edit, minimal reproduction and replay, a surviving mutant, a target without mutants, `--no-record`, a repository
|
|
145
|
+
without Stopbar).
|
|
146
|
+
|
|
3
147
|
## 1.1.3 (2026-11-26)
|
|
4
148
|
|
|
5
149
|
`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,16 @@
|
|
|
1
1
|
# Stopbar
|
|
2
2
|
|
|
3
|
-
Stopbar is
|
|
4
|
-
|
|
3
|
+
Stopbar is an execution gate for AI coding agents in two parts: a **formally proven decision kernel**
|
|
4
|
+
(`src/kernel.ts`, about 160 lines, its laws proven by induction and checked again by `lake build` in Lean 4.34.0) and
|
|
5
|
+
a **tested wrapper** around it: the hooks of Claude Code, Cursor, Codex CLI, Gemini CLI and Antigravity CLI, and git
|
|
6
|
+
hooks for any other tool. The wrapper reads tool calls and command text and asks the kernel; it is covered by unit and
|
|
7
|
+
E2E tests and stateful probing, not by the proof.
|
|
8
|
+
|
|
9
|
+
**Without an OS sandbox, Stopbar stops shortcuts and mistakes of an agent; it is not a security boundary against a
|
|
10
|
+
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
|
|
11
|
+
[SECURITY.md](SECURITY.md) for what is proven, what the wrapper enforces and what needs an OS sandbox.
|
|
12
|
+
|
|
13
|
+
It stops an agent from:
|
|
5
14
|
|
|
6
15
|
- committing without a passing build and a passing **full** test suite at the current revision of the working tree;
|
|
7
16
|
- weakening existing tests or test configuration without a human approval;
|
|
@@ -11,8 +20,7 @@ CLI, Gemini CLI and Antigravity CLI, and as git hooks for any other tool. It sto
|
|
|
11
20
|
|
|
12
21
|
The decisions come from one rule, `src/kernel.ts`. gdp-wired 0.60.0 proves its laws by induction, and 10 mutants of
|
|
13
22
|
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.
|
|
23
|
+
hook payload into one internal event and renders the decision in the client's own output format.
|
|
16
24
|
|
|
17
25
|
## Supported agents
|
|
18
26
|
|
|
@@ -41,9 +49,9 @@ current tree, block it after an unapproved test change, and block a push after a
|
|
|
41
49
|
| Pillar | Command | What it gives you |
|
|
42
50
|
|---|---|---|
|
|
43
51
|
| 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.
|
|
52
|
+
| 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. |
|
|
45
53
|
| 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. |
|
|
54
|
+
| ATTEST | `stopbar attest` | A deterministic attestation of the session: HEAD, tree, gates, human actions, probe evidence and the sha256 of the event log. |
|
|
47
55
|
|
|
48
56
|
## Set up in 3 steps
|
|
49
57
|
|
|
@@ -63,9 +71,13 @@ Requirements: Node.js 22.18 or later, git, a git repository.
|
|
|
63
71
|
|
|
64
72
|
Profiles for the path patterns: `--profile default|ts|python|strict`. `init` copies the runtime to
|
|
65
73
|
`.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
|
-
|
|
74
|
+
Stopbar entries are replaced. Since 1.2.0, `--hooks <clients>` also writes the git hooks (`pre-commit`,
|
|
75
|
+
`pre-push`): they close git aliases, and before a push `merge`, `cherry-pick`, `am` and `commit-tree`, which an
|
|
76
|
+
agent hook does not see. Pass `--no-git-hooks` to skip them. `init` does not overwrite a git hook it did not write:
|
|
77
|
+
when the git hooks were added by default, it keeps the foreign hook and prints a `WARN`; when you named `git` in
|
|
78
|
+
`--hooks`, it stops with an error. `--hooks git --force-hooks` replaces it (the old hook is kept as
|
|
79
|
+
`<name>.stopbar-backup`). Without `--hooks`, `init` writes nothing outside `.git/stopbar/` and prints the Claude
|
|
80
|
+
Code JSON to paste. A template is in [claude-hooks.example.json](claude-hooks.example.json).
|
|
69
81
|
|
|
70
82
|
3. **Check** the setup, then restart the agent in the repository:
|
|
71
83
|
|
|
@@ -99,7 +111,7 @@ EOF
|
|
|
99
111
|
|
|
100
112
|
| Command | Who | What it does |
|
|
101
113
|
|---|---|---|
|
|
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
|
|
114
|
+
| `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
115
|
| `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
116
|
| `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
117
|
| `stopbar git-hook pre-commit\|pre-push` | git | The git fallback gate. Exit 1 aborts the commit or push. |
|
|
@@ -111,14 +123,110 @@ EOF
|
|
|
111
123
|
| `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
124
|
| `stopbar doctor [--json]` | human | Environment, config, state, hooks and a dry run. Exit 1 on a problem. |
|
|
113
125
|
| `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
|
|
126
|
+
| `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. |
|
|
127
|
+
| `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`. |
|
|
128
|
+
| `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
129
|
|
|
117
130
|
All commands take `--repo <dir>`. The agent cannot run the human commands: the hooks block them.
|
|
118
131
|
|
|
119
132
|
State, configuration and the event log are in `<repo>/.git/stopbar/`: `config.json`, `state.json`, `events.jsonl`, the
|
|
120
133
|
private snapshot index and the pinned runtime. They are outside the working tree, so they never change the tree hash.
|
|
121
134
|
|
|
135
|
+
## PROBE for your project
|
|
136
|
+
|
|
137
|
+
`stopbar probe --target <file>` runs a model of any TS/JS code. The file exports (as `default` or as `target`) a
|
|
138
|
+
target; `defineModel` from `stopbar/probe` builds one from a list of actions:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import {defineModel} from 'stopbar/probe'
|
|
142
|
+
|
|
143
|
+
export default defineModel<{q: BoundedQueue<number>; model: number[]}>({
|
|
144
|
+
name: 'bounded-queue', description: 'FIFO queue with capacity 4 vs an array model',
|
|
145
|
+
setup: () => ({q: new BoundedQueue<number>(4), model: []}),
|
|
146
|
+
actions: [
|
|
147
|
+
{name: 'push', weight: 3, gen: (r) => ({x: r.int(0, 99)}), run: (s, {x}, check) => {
|
|
148
|
+
const accepted = s.model.length < 4
|
|
149
|
+
check.eq('push result', s.q.push(x), accepted)
|
|
150
|
+
if (accepted) s.model.push(x)
|
|
151
|
+
}},
|
|
152
|
+
{name: 'shift', gen: () => null, run: (s, _a, check) => check.eq('shift result', s.q.shift(), s.model.shift())},
|
|
153
|
+
],
|
|
154
|
+
invariants: [{name: 'size', check: (s, check) => check.eq('size', s.q.size, s.model.length)}],
|
|
155
|
+
mutants: {M1_dropCap: () => ({q: new BoundedQueue<number>(4, {checkCap: false}), model: []})},
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- `gen(r)` returns pure JSON data for one step. `r` is a deterministic generator (`createRng`: xorshift32, the same
|
|
160
|
+
numbers on Windows and Linux). A run is `{seed, actions: [{t: name, args}]}` with `minSteps`..`maxSteps` steps
|
|
161
|
+
(default 15..40).
|
|
162
|
+
- `run(state, args, check)` drives the real code and compares it with the model: `check.eq` (deep strict equality),
|
|
163
|
+
`check.ok`, `check.fail`. A failed check, and any exception from the code under test, is a mismatch with the step and
|
|
164
|
+
the action, not a crash. Invariants run after `setup` (step -1) and after every step. `teardown` runs after every run
|
|
165
|
+
whose `setup` returned, also after a failure.
|
|
166
|
+
- A failure is shrunk (cut after the failing step, then removal of blocks of half, a quarter, ... of the run, then of
|
|
167
|
+
single steps) and written to `repro-<seed>.json` in `--out`. `--regressions <dir>` replays such files on every run.
|
|
168
|
+
A file target replays only the regressions you name.
|
|
169
|
+
- `--check-mutants`: each mutant replaces `setup` with a damaged system under test. The original must pass, and every
|
|
170
|
+
mutant must fail within `--mutant-runs` seeds (default 50). Exit 0 only then. A survivor is named in the output and
|
|
171
|
+
in `summary.json` (`mutants.survived`). A target without mutants is refused.
|
|
172
|
+
- In a repository with Stopbar, every run appends a `probe:result` entry to `events.jsonl` (target, sha256 of the
|
|
173
|
+
target file, tree snapshot, runs, steps, mutants, sha256 of `summary.json`). It is not a kernel step and does not
|
|
174
|
+
change `state.json`. `stopbar attest` shows the latest entry per target and whether the tree is still the one that
|
|
175
|
+
was probed. `--no-record` skips the entry. Outside a Stopbar repository nothing is recorded.
|
|
176
|
+
|
|
177
|
+
A complete example with two mutants: [`examples/bounded-queue.probe.ts`](examples/bounded-queue.probe.ts)
|
|
178
|
+
(`stopbar probe --target examples/bounded-queue.probe.ts --check-mutants`). TypeScript files need Node's type
|
|
179
|
+
stripping (Node 22.18 or later): only erasable syntax, no `enum` and no constructor parameter properties.
|
|
180
|
+
|
|
181
|
+
### Any language: `--cmd`
|
|
182
|
+
|
|
183
|
+
`stopbar probe --cmd "<command>"` probes a program in any language (Python, Go, Rust, ...). Each worker (`--jobs`)
|
|
184
|
+
starts the command once, in a shell, in the current directory, and keeps it for all its runs, so the start-up cost
|
|
185
|
+
is paid once per worker and not once per seed. Stopbar sends one JSON object per line on stdin and reads one answer
|
|
186
|
+
per line on stdout (NDJSON):
|
|
187
|
+
|
|
188
|
+
| Request | Answer |
|
|
189
|
+
|---|---|
|
|
190
|
+
| `{"op":"info"}` | `{"name":"<string>","description":"<string>","mutants":["M1",...]}` (`mutants` is optional) |
|
|
191
|
+
| `{"op":"generate","seed":123}` | `{"seed":123,"actions":[...]}`: pure JSON data, the same for the same seed |
|
|
192
|
+
| `{"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":...}}` |
|
|
193
|
+
|
|
194
|
+
- `mutant` is sent only with `--check-mutants`. `dir` is an empty scratch directory for each execution.
|
|
195
|
+
- Any answer can be `{"error":"<text>"}`. stdout is for the protocol only: print logs to stderr.
|
|
196
|
+
- An exception of the code under test is a finding: catch it in `execute` and answer with a mismatch (the
|
|
197
|
+
templates do this). A process that exits, closes stdout, prints a line that is not JSON or gives no answer within
|
|
198
|
+
`--cmd-timeout` ms (default 300000) stops the probe with exit 1 and the end of its stderr. When the probe ends,
|
|
199
|
+
Stopbar closes stdin; a process that does not exit within 2 s is killed.
|
|
200
|
+
- Shrinking, `--regressions` / `--regressions-only`, `--check-mutants`, `summary.json`, `repro-<seed>.json`,
|
|
201
|
+
`probe:result` and `attest` work as for `--target <file>`. `target` in a reproduction is the `name` from `info`;
|
|
202
|
+
`targetCmd` is the command. A `--cmd` target replays only the regressions in `--regressions <dir>`.
|
|
203
|
+
- `targetSha256` is the sha256 of `--target-file <path>`, else of the first word after the interpreter that is an
|
|
204
|
+
existing file (`python examples/bounded_queue_probe.py` hashes that file), else `null`.
|
|
205
|
+
|
|
206
|
+
[`examples/bounded_queue_probe.py`](examples/bounded_queue_probe.py) is the same queue model in Python, with the
|
|
207
|
+
standard library only:
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
stopbar probe --cmd "python examples/bounded_queue_probe.py" --runs 200 --check-mutants
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### A starter target: `stopbar probe init`
|
|
214
|
+
|
|
215
|
+
`stopbar probe init --lang ts` writes `probes/sample.probe.ts` (`defineModel`), and `--lang py` writes
|
|
216
|
+
`probes/sample_probe.py` (the NDJSON protocol, standard library only: `json`, `random`, `sys`). Both hold the same
|
|
217
|
+
model with 2 actions, 1 invariant, 2 mutants and the rules for zero false positives, and `--check-mutants` passes on
|
|
218
|
+
them as written. The command prints the line that runs the file. `--name` takes letters, digits, `-` and `_` only;
|
|
219
|
+
`--out` (default `probes`) is relative to `--repo`, else to the current directory; an existing file stays unless you
|
|
220
|
+
pass `--force`.
|
|
221
|
+
|
|
222
|
+
## Agent skill
|
|
223
|
+
|
|
224
|
+
[`skills/stopbar/SKILL.md`](skills/stopbar/SKILL.md) tells an agent how to work under the gate (exact gate commands,
|
|
225
|
+
one-command commits, the human-only commands and when to stop and ask) and how to write a probe with zero false
|
|
226
|
+
positives. It uses the Agent Skills format (`SKILL.md` with `name` and `description`), so Claude Code, Codex CLI,
|
|
227
|
+
Cursor, Gemini CLI and Antigravity CLI can load it; copy the `skills/stopbar/` directory into the skills directory of
|
|
228
|
+
your agent. The npm package includes it.
|
|
229
|
+
|
|
122
230
|
## Configuration
|
|
123
231
|
|
|
124
232
|
`config.json` keeps the gate commands, the limits and three lists of glob patterns:
|
|
@@ -163,8 +271,9 @@ profile by editing the lists: no code change is necessary.
|
|
|
163
271
|
- **`safeTools`** (optional) lists glob patterns of tool names that are local and never outbound. The default
|
|
164
272
|
(`DEFAULT_SAFE_TOOLS`) is `["mcp__ccd_turn__*", "mcp__ccd_session_mgmt__*"]`: the task-list and turn-summary tools of
|
|
165
273
|
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
|
-
|
|
274
|
+
(WebFetch, WebSearch, MCP tools); shell commands, edits and reads are gated as before. Since 1.2.0 these tools also
|
|
275
|
+
pass while the session is halted, so the agent can still ask a human for `stopbar resume`; they never take a kernel
|
|
276
|
+
step. Every other tool stays paused while halted. A `config.json` written by 1.0.0–1.1.1 keeps its own list and keeps working; to stop false
|
|
168
277
|
`PAUSE`s on the session tools after a secret read, add `"mcp__ccd_session_mgmt__*"` to `safeTools` or write the file
|
|
169
278
|
again with `stopbar init --force ...`. `stopbar doctor` shows a `[WARN] safeTools` while a default entry is missing.
|
|
170
279
|
- **`cliCmd`** (optional, set via `stopbar init --cli "<cmd>"`) is the command that starts Stopbar in the hints shown to
|
|
@@ -177,13 +286,22 @@ profile by editing the lists: no code change is necessary.
|
|
|
177
286
|
`warn`: for long tasks with one commit at the end, the turn may end with unverified changes (for example to ask the
|
|
178
287
|
human a question); Stopbar logs a `stop:warn` entry in `events.jsonl` and answers `WARN (stopbar): ...` without
|
|
179
288
|
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
|
-
|
|
289
|
+
`status`, `doctor` and `attest` show the mode.
|
|
290
|
+
- **`requireRun`** (optional, set via `stopbar init --require-run`, default `false`): the build and full test gates
|
|
291
|
+
count only when they run through `stopbar run build` or `stopbar run test`. The same command run from the agent's own
|
|
292
|
+
shell is not recorded (neither a pass nor a failure); the hook answers with a `NOTE` that names `stopbar run` and logs
|
|
293
|
+
`post:require-run`. `status`, `doctor` and `attest` show `requireRun: true` when it is on.
|
|
294
|
+
|
|
295
|
+
A damaged or empty `config.json` or `state.json` blocks every tool call (exit 2) with a message that says how to
|
|
296
|
+
repair it.
|
|
182
297
|
|
|
183
298
|
## Local use
|
|
184
299
|
|
|
185
300
|
- `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
|
|
301
|
+
the kernel with gdp-wired's `compileJs`. There is no bundler, and the build needs no TypeScript compiler.
|
|
302
|
+
- `npm run typecheck` runs `tsc --noEmit` (TypeScript is a devDependency only) over `src/`, `scripts/`, `tests/` and
|
|
303
|
+
`bench/` in strict mode. The build writes small `dist/*.d.ts` files that point the tests' `dist/*.js` imports at
|
|
304
|
+
`src/*.ts`; they are not in the npm package and not in the pinned runtime.
|
|
187
305
|
- `npm test` runs the unit tests, the E2E suite (real git repositories, a separate hook process for each call) and the
|
|
188
306
|
stateful fuzzer (200 random sequences of 20–30 steps, compared with the proven kernel). It takes about 3 minutes.
|
|
189
307
|
In Claude Code, give the Bash tool enough time, for example `"env": {"BASH_DEFAULT_TIMEOUT_MS": "600000"}` in the
|
|
@@ -192,13 +310,18 @@ tool call (exit 2) with a message that says how to repair it.
|
|
|
192
310
|
- `npm run verify:lean` exports the Lean project (`leanProject()` of gdp-wired) and runs `lake build` in the
|
|
193
311
|
container from `docker/lean.Dockerfile` with `--network none`. It is the release gate for changes of `src/kernel.ts`,
|
|
194
312
|
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`.
|
|
313
|
+
`docker build -f docker/lean.Dockerfile -t stopbar-lean:4.34.0 docker`. Without Docker, with Lean 4.34.0 on `PATH`
|
|
314
|
+
(for example from elan): `npm run build` and `node scripts/verify-lean.ts --local`. Both write
|
|
315
|
+
`results/lean/lean-verify.json`.
|
|
196
316
|
- `npm run bench` measures the hook latency.
|
|
197
317
|
- `npm run test:e2e` or `npm run test:fuzz` runs only the E2E suite or only the stateful prober.
|
|
198
318
|
|
|
199
319
|
## Use in CI
|
|
200
320
|
|
|
201
|
-
|
|
321
|
+
Stopbar's own workflow, [.github/workflows/ci.yml](.github/workflows/ci.yml), runs on every push to `main` and every
|
|
322
|
+
pull request: build, typecheck, the full test suite and a PROBE of `examples/bounded-queue.probe.ts` with mutants on
|
|
323
|
+
Ubuntu, Windows and macOS (Node 24); `npm run prove`; and `lake build` of the Lean export with Lean 4.34.0 from elan
|
|
324
|
+
(`node scripts/verify-lean.ts --local`). The minimum for a fork:
|
|
202
325
|
|
|
203
326
|
```yaml
|
|
204
327
|
- run: npm ci
|
|
@@ -230,15 +353,23 @@ latency. An earlier prototype that loaded the prover in every hook measured p50
|
|
|
230
353
|
|
|
231
354
|
## Tested platforms
|
|
232
355
|
|
|
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 |
|
|
356
|
+
| Platform | Node | git | Python | Typecheck | Unit | E2E | `stopbar probe` | `--cmd` Python example | `stopbar prove` | `stopbar doctor` |
|
|
357
|
+
|---|---|---|---|---|---|---|---|---|---|---|
|
|
358
|
+
| Windows 11, Git for Windows | 24.19.0 | 2.56.0 | 3.14.7 | 0 errors | 70/70 | 443/443 | 202/202 sequences | 200/200, mutants 2/2 | proven, 10/10 mutants | OK |
|
|
359
|
+
| Linux, Debian 13 (container, no network) | 24.21.0 | 2.47.3 | 3.13.5 | 0 errors | 70/70 | 443/443 | 202/202 sequences | 200/200, mutants 2/2 | proven, 10/10 mutants | OK |
|
|
360
|
+
| Ubuntu, Windows, macOS (GitHub Actions) | 24 | runner | runner | CI | CI | CI | CI | – | CI (Ubuntu) | – |
|
|
361
|
+
|
|
362
|
+
The last row is the CI workflow: it runs after a push, so its results are on the repository's Actions page, not here.
|
|
237
363
|
|
|
238
364
|
The E2E suite runs every adapter (Cursor, Codex CLI, Gemini CLI, Antigravity CLI) and the git fallback with real
|
|
239
365
|
git commits and pushes. The probe runs the same 200 seeds plus 2 regressions on both platforms, with the same 5020 steps
|
|
240
366
|
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
|
-
|
|
367
|
+
The `--cmd` column is `stopbar probe --cmd "<python> examples/bounded_queue_probe.py" --runs 200 --check-mutants`
|
|
368
|
+
(3970 steps on both platforms). E2E scenario S37 runs `--cmd` with a Node target everywhere, and the Python example
|
|
369
|
+
and the `--lang py` template only where `python3` or `python` is found.
|
|
370
|
+
`npm run verify:lean` passes in the Lean 4.34.0 container: `lake build` exit 0, 0 errors, 0 `sorry` (run on the same
|
|
371
|
+
`src/kernel.ts`, sha256 `c602fc4bcf8ffb2e...`, which 1.2.0 does not change). `node scripts/verify-lean.ts --local`
|
|
372
|
+
gives the same result with Lean 4.34.0 on `PATH` (checked in a Debian 13 container with the toolchain of that image).
|
|
242
373
|
|
|
243
374
|
## License
|
|
244
375
|
|
package/SECURITY.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# Security model
|
|
2
2
|
|
|
3
|
-
Stopbar
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Stopbar has two parts: a formally proven decision kernel (`src/kernel.ts`, proven by induction with gdp-wired and
|
|
4
|
+
checked again by `lake build` in Lean 4.34.0) and a tested wrapper around it: the hooks of Claude Code, Cursor, Codex
|
|
5
|
+
CLI, Gemini CLI and Antigravity CLI, and git hooks (`pre-commit`, `pre-push`) for any other tool. This file says what
|
|
6
|
+
is proven (section 1), what the wrapper enforces and how it is tested (section 2), and what Stopbar cannot give you
|
|
7
|
+
without an operating-system sandbox (section 3). Without an OS sandbox, Stopbar stops shortcuts and mistakes of an
|
|
8
|
+
agent; it is not a security boundary against a hostile agent.
|
|
6
9
|
|
|
7
10
|
## 1. What is proven
|
|
8
11
|
|
|
@@ -82,8 +85,23 @@ There is no proof for them.
|
|
|
82
85
|
`.cursor/hooks.json`, `.codex/hooks.json`, `.codex/config.toml`, `.gemini/*settings*.json`, `.gemini/**/hooks.json`,
|
|
83
86
|
`.agents/hooks.json`, at project and user level), or the Stopbar code that runs the hooks. A shell command may not
|
|
84
87
|
name a `.git`, `.claude`, `.cursor`, `.codex`, `.gemini` or `.agents` directory, write git config (`git config`
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
other than a read: `--get`, `--get-all`, `--get-regexp`, `--get-urlmatch`, `--list`, `-l`, or the subcommands `list`
|
|
89
|
+
and `get` right after `config`; a value such as `core.hooksPath list` is a write), define a one-off git alias
|
|
90
|
+
(`git -c alias.<name>=...`, `--config-env alias.*`, `GIT_CONFIG_KEY_<n>=alias.*`), name the Stopbar code, use a
|
|
91
|
+
`STOPBAR_*` variable, or run a human command (`approve-tests`, `approve-shell`, and `init`, `resume`, `reset`,
|
|
92
|
+
`upgrade`, `doctor --fix` right after the `stopbar` program word; `stopbar probe init` is allowed). Since 1.2.0
|
|
93
|
+
every text check runs on the command as written and as bash joins the quoted parts of a word, so `.e""nv`, `.g''it`,
|
|
94
|
+
`.cl''aude`, `'.cl'"aude"`, `.e"n"'v'` and `gi"t"` count as `.env`, `.git`, `.claude` and `git`. In Bash, the body
|
|
95
|
+
of one single-quoted heredoc that is stdin data (`agy -p - <<'EOF'` … `EOF`) is skipped by the human-only checks,
|
|
96
|
+
so a prompt may mention `approve-tests`; this does not apply when the command line pipes, redirects with `>`/`>>`,
|
|
97
|
+
expands a variable, or names a shell, an interpreter, `xargs`, `at`, `tee` or
|
|
98
|
+
`stopbar`. `.git`, the agent settings directories and the Stopbar code stay protected inside the body.
|
|
99
|
+
- **Halted sessions.** While halted, every tool is paused except the tools in `config.safeTools` (default: the local
|
|
100
|
+
task-list, turn and session-message tools of Claude Desktop), so the agent can still ask a human for `stopbar resume`.
|
|
101
|
+
These tools never take a kernel step, so they cannot change the state that laws L4.1 and L4.4 speak about. Edit,
|
|
102
|
+
Write, Read, Bash, WebFetch and every other MCP tool stay paused.
|
|
103
|
+
- **`requireRun`.** With `config.requireRun: true`, a build or full test run counts only through `stopbar run
|
|
104
|
+
build|test`; the same command from the agent's shell is recorded neither as a pass nor as a failure.
|
|
87
105
|
- **One kernel for every agent.** An adapter per client (Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity CLI)
|
|
88
106
|
translates the hook payload into one internal event and the decision into the client's output protocol. The
|
|
89
107
|
adapters are wrapper code: the E2E suite runs each with payloads in the client's published schema.
|
|
@@ -102,7 +120,9 @@ that tries to defeat it:
|
|
|
102
120
|
|
|
103
121
|
1. **Indirect execution.** A script written to a normal file and then run (`node x.js`, `bash x.sh`) can do anything:
|
|
104
122
|
delete `.git/stopbar`, edit `.claude/settings.local.json`, run `stopbar approve-tests`. The text checks do not see
|
|
105
|
-
inside the script. Obfuscation (`c=cu; ${c}rl`
|
|
123
|
+
inside the script. Obfuscation (`c=cu; ${c}rl`, `g=.g; d=$g"it"; rm -rf $d`), backslash escapes inside a word,
|
|
124
|
+
aliases and shell functions also pass the text checks. Only simple quote splicing (`.g""it`) is undone. The unit
|
|
125
|
+
test "known limits without an OS sandbox" keeps these cases visible.
|
|
106
126
|
2. **Gate commands run arbitrary code.** `buildCmd` and `fullTestCmd` run the repository's code. A new test file is
|
|
107
127
|
trusted. It can read secrets, use the network or weaken other checks at run time.
|
|
108
128
|
3. **Secrets by file name only.** Secrets in environment variables, in files with ordinary names, or found with Grep in
|
|
@@ -123,8 +143,11 @@ that tries to defeat it:
|
|
|
123
143
|
flagged. Stopbar does not watch the ref itself.
|
|
124
144
|
5. **Ignored files.** Files ignored by `.gitignore` are invisible to the snapshot (for example patches in
|
|
125
145
|
`node_modules`). A change to `.gitignore` itself is suspicious.
|
|
126
|
-
6. **Other commit paths.**
|
|
127
|
-
and similar are not detected as commits
|
|
146
|
+
6. **Other commit paths.** Aliases from a git config file, `git commit-tree`, `git stash`, `git cherry-pick`,
|
|
147
|
+
`git rebase`, `gh pr create` and similar are not detected as commits by the agent hooks (a one-off
|
|
148
|
+
`git -c alias.*` is blocked). The git hooks, which `init --hooks <client>` writes by default since 1.2.0, close part
|
|
149
|
+
of this: `pre-commit` runs for every `git commit`, also through an alias, and `pre-push` gates every push of
|
|
150
|
+
commits made by `merge`, `cherry-pick`, `am` or `commit-tree`. `--no-verify` still skips them. The Stop hook
|
|
128
151
|
catches uncommitted work only. With `config.stopGate: "warn"` it does not even block that: the turn ends with a
|
|
129
152
|
`WARN (stopbar)` answer and a `stop:warn` entry in `events.jsonl`. This mode takes no kernel step at Stop and does not
|
|
130
153
|
weaken the commit gate: `git commit` and `git push` in the agent hooks and in the git hooks are judged by the kernel
|
|
@@ -157,6 +180,54 @@ For a hostile-agent threat model, run the agent in a container or VM: no network
|
|
|
157
180
|
read-write, `.git/stopbar` and `.claude` mounted read-only or owned by another user, and the human commands run outside
|
|
158
181
|
the sandbox. Stopbar's kernel then gives the proven decisions and the sandbox gives the boundary.
|
|
159
182
|
|
|
183
|
+
## 4. PROBE, `--cmd` and probe evidence
|
|
184
|
+
|
|
185
|
+
`stopbar probe` is a test tool run by a human or by CI. It is not a hook and it is not part of the proof.
|
|
186
|
+
|
|
187
|
+
- A probe target is code you trust. `--target <file>` imports the file into the worker processes, and
|
|
188
|
+
`--cmd "<command>"` runs the command in a shell, with the rights of the user who starts the probe. Do not probe
|
|
189
|
+
a file or a command from outside the session that no human has read. An agent may run a prober it wrote in the
|
|
190
|
+
current session (`skills/stopbar/SKILL.md`); a human reads it before its `probe:result` counts as evidence.
|
|
191
|
+
- `probe:result` in `events.jsonl` is evidence, not a gate. It has no `req`, it is not a kernel step and it does not
|
|
192
|
+
change `state.json`, so it can never allow a commit. It is appended under Stopbar's lock, like every other entry.
|
|
193
|
+
- `stopbar attest` shows the latest `probe:result` per target since the last `init` or `reset`, with the sha256 of the
|
|
194
|
+
target file (`targetSha256`), the command (`targetCmd`), the tree snapshot and `atCurrentSnapshot`. The entry says
|
|
195
|
+
what the prober saw on that tree. It does not prove the target file: an agent that can write to `events.jsonl` can
|
|
196
|
+
also write a false entry, as for every other log line (see section 3). Compare `targetSha256` with the file you
|
|
197
|
+
reviewed.
|
|
198
|
+
- For `--cmd`, `targetSha256` covers one file only: `--target-file`, else the first existing file after the
|
|
199
|
+
interpreter, else nothing (`null`). Imports, libraries and the interpreter are not hashed.
|
|
200
|
+
|
|
201
|
+
## Known limits of 1.2.0
|
|
202
|
+
|
|
203
|
+
- `safeTools` in `HALT`: a halted session still lets the tools in `config.safeTools` through. A human who adds a glob
|
|
204
|
+
there vouches that those tools are local; with a broad glob (for example `mcp__*`) a halted agent keeps those tools.
|
|
205
|
+
Edit, Write, Read, the shell and every tool outside the list stay paused.
|
|
206
|
+
- `--require-run` decides by the event's source (`stopbar run` or an agent hook), not by what ran. Without it, the
|
|
207
|
+
exact gate command from the agent's shell still counts, as before.
|
|
208
|
+
- Quote splicing: only quotes inside a word are undone (`.e""nv`, `.e"n"v`, `'.cl'"aude"`, `gi"t"`). A path built at
|
|
209
|
+
run time (`g=.g; d=$g"it"`), a backslash escape, a variable or a script (`node /tmp/x.js`) passes the text checks;
|
|
210
|
+
section 3 point 1. Only an OS sandbox closes this.
|
|
211
|
+
- The stdin heredoc exception trusts the command on the header line not to run its stdin. Stopbar knows the common
|
|
212
|
+
shells and interpreters (and `xargs`, `at`, `tee`, `stopbar`); another program that executes stdin passes. The
|
|
213
|
+
exception covers only `HUMAN_ONLY` and `STOPBAR_ADMIN`; every other check still reads the body.
|
|
214
|
+
- Git hooks by default: a foreign `pre-commit` or `pre-push` is kept with a `WARN` when the git hooks were added by
|
|
215
|
+
default; then that git action is not gated until a human runs `stopbar upgrade --hooks git --force-hooks`.
|
|
216
|
+
`stopbar doctor` reports `[WARN] hooks git` while one of the two Stopbar git hooks is missing.
|
|
217
|
+
- `stopbar doctor` checks the kernel link only where `gdp-wired` resolves from the running copy (`import.meta.resolve`).
|
|
218
|
+
A pinned runtime outside any `node_modules` tree reports `[WARN] kernel link`; run `stopbar prove` in the package.
|
|
219
|
+
- `--cmd`: the command runs through the system shell (`cmd.exe` on Windows, `/bin/sh` elsewhere), so quoting follows
|
|
220
|
+
that shell. A shell can hold stdout open after the program closed it; then only `--cmd-timeout` (default 300000 ms)
|
|
221
|
+
ends the wait.
|
|
222
|
+
- `--cmd`: answers are checked for their shape (`name`, `seed`, `actions`, `ok`, `steps`, `cov`, `mismatch.step`,
|
|
223
|
+
`mismatch.what`), not for meaning. A program that answers `ok: true` without running anything passes. Mutants
|
|
224
|
+
(`--check-mutants`) are the check that the model can fail.
|
|
225
|
+
- `--cmd`: Stopbar does not check that `generate` is deterministic. A reproduction replays the saved actions, so it
|
|
226
|
+
stays valid, but a new run of the same seed can differ if the program uses another source of randomness.
|
|
227
|
+
- `probe init --lang py` prints `python` on Windows and `python3` elsewhere; use the name your system has.
|
|
228
|
+
- `probe init --lang ts` writes a file that imports `stopbar/probe`: it runs only where that import resolves (Stopbar
|
|
229
|
+
installed in the project).
|
|
230
|
+
|
|
160
231
|
## Known limits of 1.1.3
|
|
161
232
|
|
|
162
233
|
- The blob-id comparison trusts `baseRef`: see point 4 of section 3 (a mutable branch name can be moved by the agent).
|
|
@@ -179,11 +250,13 @@ the sandbox. Stopbar's kernel then gives the proven decisions and the sandbox gi
|
|
|
179
250
|
- `buildCmd` and `fullTestCmd` that differ only in whitespace at the ends count as equal and are refused. Two different
|
|
180
251
|
commands that run the same script (for example `npm test` and `npm run test`) are not detected.
|
|
181
252
|
|
|
182
|
-
- Lean: the check needs Docker and a one-time image build with network access
|
|
253
|
+
- Lean: the check needs Docker and a one-time image build with network access, or (since 1.2.0, used in CI) Lean
|
|
254
|
+
4.34.0 on `PATH` with `node scripts/verify-lean.ts --local`. The base image is pinned by digest and
|
|
183
255
|
the Lean archive by sha256, both recorded at the first build (trust on first use). The Lean export is not
|
|
184
256
|
deterministic: each export is a different proof tree, and the gate checks the one it exports.
|
|
185
257
|
- Platforms: the unit tests, E2E, `stopbar probe` and `stopbar prove` pass on Windows 11 with Git for Windows and on
|
|
186
|
-
Linux (Debian 13, Node 24, git 2.47). A live Claude Code session ran on Windows. macOS
|
|
258
|
+
Linux (Debian 13, Node 24, git 2.47). A live Claude Code session ran on Windows. macOS runs only in CI (since
|
|
259
|
+
1.2.0, `.github/workflows/ci.yml`).
|
|
187
260
|
- Adapters: Cursor, Codex CLI, Gemini CLI and Antigravity CLI are spec-tested (see the README table); a client can
|
|
188
261
|
change its hook schema in a later version.
|
|
189
262
|
- Hook latency: Windows starts a process in 50–70 ms, so a hook with one git process takes about 120–200 ms in all.
|