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/SECURITY.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
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.
|
|
9
|
+
|
|
10
|
+
| Proven (Lean 4.34.0) | Tested (wrapper + E2E + PROBE) | Not covered without OS sandbox |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| The decision rule `src/kernel.ts`: laws L1, L2.1, L2.2, L3.1–L3.3, L4.1–L4.4 (section 1), with 10 mutants that each fall with a counterexample. | How tool calls become kernel requests (section 2): gate commands, tree snapshots, path patterns, self-protection, client adapters, git hooks. | Names built at run time, scripts the agent runs, code that the gates run, secrets in ordinary files, a writable state directory (section 3). |
|
|
6
13
|
|
|
7
14
|
## 1. What is proven
|
|
8
15
|
|
|
@@ -82,8 +89,34 @@ There is no proof for them.
|
|
|
82
89
|
`.cursor/hooks.json`, `.codex/hooks.json`, `.codex/config.toml`, `.gemini/*settings*.json`, `.gemini/**/hooks.json`,
|
|
83
90
|
`.agents/hooks.json`, at project and user level), or the Stopbar code that runs the hooks. A shell command may not
|
|
84
91
|
name a `.git`, `.claude`, `.cursor`, `.codex`, `.gemini` or `.agents` directory, write git config (`git config`
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
other than a read: `--get`, `--get-all`, `--get-regexp`, `--get-urlmatch`, `--list`, `-l`, or the subcommands `list`
|
|
93
|
+
and `get` right after `config`; a value such as `core.hooksPath list` is a write), define a one-off git alias
|
|
94
|
+
(`git -c alias.<name>=...`, `--config-env alias.*`, `GIT_CONFIG_KEY_<n>=alias.*`), name the Stopbar code, use a
|
|
95
|
+
`STOPBAR_*` variable, or run a human command (`approve-tests`, `approve-shell`, and `init`, `resume`, `reset`,
|
|
96
|
+
`upgrade`, `doctor --fix` right after the `stopbar` program word; `stopbar probe init` is allowed). Since 1.2.0
|
|
97
|
+
every text check runs on the command as written and as bash joins the quoted parts of a word, so `.e""nv`, `.g''it`,
|
|
98
|
+
`.cl''aude`, `'.cl'"aude"`, `.e"n"'v'` and `gi"t"` count as `.env`, `.git`, `.claude` and `git`. In Bash, the body
|
|
99
|
+
of one single-quoted heredoc that is stdin data (`agy -p - <<'EOF'` … `EOF`) is skipped by the human-only checks,
|
|
100
|
+
so a prompt may mention `approve-tests`; this does not apply when the command line pipes, redirects with `>`/`>>`,
|
|
101
|
+
expands a variable, or names a shell, an interpreter, `xargs`, `at`, `tee` or
|
|
102
|
+
`stopbar`. `.git`, the agent settings directories and the Stopbar code stay protected inside the body.
|
|
103
|
+
- **Since 1.2.1, wildcards and expansions.** A wildcard that reaches `.git` or an agent settings directory is blocked
|
|
104
|
+
for `rm`, `rmdir`, `unlink`, `shred`, `mv`, `del`, `erase`, `rd`, `move`, `Remove-Item` and `Move-Item` (`rm -rf
|
|
105
|
+
.g*`, `mv .cl* x`, `rm -rf .*`), and for any command when a path inside follows (`cp x .g*/hooks/pre-commit`). In
|
|
106
|
+
Bash a quoted or escaped wildcard does not expand and does not count. A git subcommand that comes from an expansion
|
|
107
|
+
(`git $f -m x`, `p=push; git $p`, `git "${cmd}"`, ``git `echo push` ``) is blocked, because the commit and push gates
|
|
108
|
+
cannot see it. A secret read is also: a command that prints the environment (`printenv`, a bare `env`,
|
|
109
|
+
`Get-ChildItem Env:`, `/proc/self/environ`); a path with `..` segments (`cat src/../.env`); a live wildcard that
|
|
110
|
+
reaches a secret name (`cat .en*`, `cat .en?`, `cat src/../.en*`). `env VAR=1 cmd` and `set` are not a read.
|
|
111
|
+
- **Halted sessions.** While halted, every tool is paused except the tools in `config.safeTools` (default:
|
|
112
|
+
`mcp__ccd_turn__*` and `mcp__ccd_session_mgmt__*`, the local task-list, turn and session-message tools of Claude
|
|
113
|
+
Desktop), so the agent can still ask a human for `stopbar resume`. These tools never take a kernel step, so they
|
|
114
|
+
cannot change the state that laws L4.1 and L4.4 speak about. Edit, Write, Read, Bash, WebFetch and every other MCP
|
|
115
|
+
tool stay paused. Edit, Write, Read and the shell tools stay paused even when a `safeTools` glob matches them (the
|
|
116
|
+
E2E suite checks `safeTools: ["*"]`). Keep the globs narrow: a broad glob such as `mcp__*` lets every MCP tool
|
|
117
|
+
through while halted and after a secret read.
|
|
118
|
+
- **`requireRun`.** With `config.requireRun: true`, a build or full test run counts only through `stopbar run
|
|
119
|
+
build|test`; the same command from the agent's shell is recorded neither as a pass nor as a failure.
|
|
87
120
|
- **One kernel for every agent.** An adapter per client (Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity CLI)
|
|
88
121
|
translates the hook payload into one internal event and the decision into the client's output protocol. The
|
|
89
122
|
adapters are wrapper code: the E2E suite runs each with payloads in the client's published schema.
|
|
@@ -102,11 +135,14 @@ that tries to defeat it:
|
|
|
102
135
|
|
|
103
136
|
1. **Indirect execution.** A script written to a normal file and then run (`node x.js`, `bash x.sh`) can do anything:
|
|
104
137
|
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`
|
|
138
|
+
inside the script. Obfuscation (`c=cu; ${c}rl`, `g=.g; d=$g"it"; rm -rf $d`), backslash escapes inside a word,
|
|
139
|
+
aliases and shell functions also pass the text checks. Only simple quote splicing (`.g""it`) is undone. The unit
|
|
140
|
+
test "known limits without an OS sandbox" keeps these cases visible.
|
|
106
141
|
2. **Gate commands run arbitrary code.** `buildCmd` and `fullTestCmd` run the repository's code. A new test file is
|
|
107
142
|
trusted. It can read secrets, use the network or weaken other checks at run time.
|
|
108
|
-
3. **Secrets by file name only.** Secrets in
|
|
109
|
-
|
|
143
|
+
3. **Secrets by file name only.** Secrets in files with ordinary names, or found with Grep in ordinary files, are not
|
|
144
|
+
seen. A command that prints the whole environment counts as a secret read since 1.2.1; one variable in a command
|
|
145
|
+
(`echo $TOKEN`) or a dump through another program (`export -p`, `node -e "console.log(process.env)"`) is not seen. The exfiltration gate works on command text only. In a shell command, a bare token
|
|
110
146
|
that matches only an extension pattern such as `*.key` counts only if that file exists (a field access like
|
|
111
147
|
`claim.key` is not a file); a command that names a `.key` file which does not exist yet is therefore not a read.
|
|
112
148
|
Tools listed in `config.safeTools` (default: Claude Desktop's `mcp__ccd_turn__*` UI tools and its
|
|
@@ -123,8 +159,11 @@ that tries to defeat it:
|
|
|
123
159
|
flagged. Stopbar does not watch the ref itself.
|
|
124
160
|
5. **Ignored files.** Files ignored by `.gitignore` are invisible to the snapshot (for example patches in
|
|
125
161
|
`node_modules`). A change to `.gitignore` itself is suspicious.
|
|
126
|
-
6. **Other commit paths.**
|
|
127
|
-
and similar are not detected as commits
|
|
162
|
+
6. **Other commit paths.** Aliases from a git config file, `git commit-tree`, `git stash`, `git cherry-pick`,
|
|
163
|
+
`git rebase`, `gh pr create` and similar are not detected as commits by the agent hooks (a one-off
|
|
164
|
+
`git -c alias.*` is blocked). The git hooks, which `init --hooks <client>` writes by default since 1.2.0, close part
|
|
165
|
+
of this: `pre-commit` runs for every `git commit`, also through an alias, and `pre-push` gates every push of
|
|
166
|
+
commits made by `merge`, `cherry-pick`, `am` or `commit-tree`. `--no-verify` still skips them. The Stop hook
|
|
128
167
|
catches uncommitted work only. With `config.stopGate: "warn"` it does not even block that: the turn ends with a
|
|
129
168
|
`WARN (stopbar)` answer and a `stop:warn` entry in `events.jsonl`. This mode takes no kernel step at Stop and does not
|
|
130
169
|
weaken the commit gate: `git commit` and `git push` in the agent hooks and in the git hooks are judged by the kernel
|
|
@@ -153,39 +192,90 @@ that tries to defeat it:
|
|
|
153
192
|
- Git fallback: git hooks see only commits and pushes, not reads or shell commands, so the secret gate needs an agent
|
|
154
193
|
hook to record the read. `git commit --no-verify` and `git push --no-verify` skip git hooks.
|
|
155
194
|
|
|
156
|
-
For a hostile-agent threat model,
|
|
157
|
-
|
|
158
|
-
|
|
195
|
+
**Hardening: OS sandbox + client deny rules.** For a hostile-agent threat model, add two layers that do not read
|
|
196
|
+
command text:
|
|
197
|
+
|
|
198
|
+
- Client deny rules refuse a tool call before any hook. Claude Code example in `.claude/settings.json` (check the rule
|
|
199
|
+
syntax against your client's documentation):
|
|
200
|
+
`{"permissions": {"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)", "Edit(./.git/**)", "Edit(./.claude/**)", "Bash(curl:*)", "Bash(wget:*)", "Bash(printenv:*)", "WebFetch"]}}`.
|
|
201
|
+
- Run the agent in a container, a VM or a sandbox runtime (for example Anthropic's `sandbox-runtime` or Claude Code's
|
|
202
|
+
Bash sandbox): no network by default, the repository writable, `.claude/` and `.git/hooks/` read-only, for example
|
|
203
|
+
`docker run --rm -it --network none -v "$PWD:/work" -v "$PWD/.claude:/work/.claude:ro" -v "$PWD/.git/hooks:/work/.git/hooks:ro" -w /work <agent-image>`.
|
|
204
|
+
The hooks write `.git/stopbar/`: when they run inside the same sandbox as the agent's shell, the shell can write it
|
|
205
|
+
too. A sandbox that wraps only the agent's shell (the hooks run outside it) can deny writes to `.git/stopbar/`. Run
|
|
206
|
+
the human commands outside the sandbox. Stopbar's kernel then gives the proven decisions and the sandbox gives the
|
|
207
|
+
boundary.
|
|
208
|
+
|
|
209
|
+
## 4. PROBE, `--cmd` and probe evidence
|
|
210
|
+
|
|
211
|
+
`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.
|
|
212
|
+
|
|
213
|
+
- A probe target is code you trust. `--target <file>` imports the file into the worker processes, and
|
|
214
|
+
`--cmd "<command>"` runs the command in a shell, with the rights of the user who starts the probe. Do not probe
|
|
215
|
+
a file or a command from outside the session that no human has read. An agent may run a prober it wrote in the
|
|
216
|
+
current session (`skills/stopbar/SKILL.md`); a human reads it before its `probe:result` counts as evidence.
|
|
217
|
+
- `probe:result` in `events.jsonl` is evidence, not a gate. It has no `req`, it is not a kernel step and it does not
|
|
218
|
+
change `state.json`, so it can never allow a commit. It is appended under Stopbar's lock, like every other entry.
|
|
219
|
+
- `stopbar attest` shows the latest `probe:result` per target since the last `init` or `reset`, with the sha256 of the
|
|
220
|
+
target file (`targetSha256`), the command (`targetCmd`), the tree snapshot and `atCurrentSnapshot`. **Probe evidence
|
|
221
|
+
is the recorded result of one run, tied to the tree snapshot and to the hash of the prober file.** It says what the
|
|
222
|
+
prober saw on that tree. It is no proof against a hostile agent without an OS sandbox: an agent that can write to
|
|
223
|
+
`events.jsonl` can also write a false entry, as for every other log line (see section 3). Compare `targetSha256`
|
|
224
|
+
with the file you reviewed.
|
|
225
|
+
- For `--cmd`, `targetSha256` covers one file only: `--target-file`, else the first existing file after the
|
|
226
|
+
interpreter, else nothing (`null`). Imports, libraries and the interpreter are not hashed.
|
|
227
|
+
|
|
228
|
+
## Known limits of 1.2.1
|
|
229
|
+
|
|
230
|
+
What a regular expression cannot block (the unit test "1.2.1 known limits without an OS sandbox" keeps these visible):
|
|
231
|
+
|
|
232
|
+
- A name built at run time: `cat $(echo .e)nv`, `f=.e; cat ${f}nv`, `g=.g; rm -rf $g"it"`. The hook sees `.e` and
|
|
233
|
+
`nv`, never `.env`. The same holds for aliases, shell functions and a backslash inside a word (`g\it`).
|
|
234
|
+
- A script: `node /tmp/x.js`, `bash x.sh`. The text checks do not read the script.
|
|
235
|
+
- A wildcard outside the cases of section 2: `find . -name '.g*' -delete`, `echo .g* | xargs rm -rf`, a PowerShell
|
|
236
|
+
`Remove-Item * -Recurse -Force` (on Windows `*` also matches dot directories), and directory wildcards on the way to a
|
|
237
|
+
secret (`cat secre*/db.txt`). A bare `.*` in `echo .*` or `ls .*` counts as a secret read (it reaches `.env`).
|
|
238
|
+
- One variable or another program: `echo $TOKEN`, `export -p`, `declare -x`, `node -e "console.log(process.env)"`.
|
|
159
239
|
|
|
160
|
-
|
|
240
|
+
Other limits:
|
|
161
241
|
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
- `
|
|
165
|
-
|
|
166
|
-
|
|
242
|
+
- `safeTools` while halted: a human who adds a glob vouches that those tools are local. With a broad glob (for example
|
|
243
|
+
`mcp__*`) a halted agent keeps those tools. Edit, Write, Read and the shell stay paused whatever the list says.
|
|
244
|
+
- `--require-run` is optional (default `false`). It decides by the event's source (`stopbar run` or an agent hook), not
|
|
245
|
+
by what ran. Without it, the exact gate command from the agent's shell counts.
|
|
246
|
+
- The stdin heredoc exception holds only for one single-quoted `<<'EOF'` and trusts the command on the header line not
|
|
247
|
+
to run its stdin. Stopbar knows the common shells and interpreters (and `xargs`, `at`, `tee`, `stopbar`); another
|
|
248
|
+
program that executes stdin passes. The exception covers only the human-only checks.
|
|
249
|
+
- Git hooks: a foreign `pre-commit` or `pre-push` is kept with a `WARN` when the git hooks were added by default; that
|
|
250
|
+
git action is not gated until a human runs `stopbar upgrade --hooks git --force-hooks`. With a custom
|
|
251
|
+
`core.hooksPath` (Husky, Lefthook, a shared directory) Stopbar writes no git hook there without `--force-hooks`, so
|
|
252
|
+
git commit and git push are not gated until a human adds the `git-hook` lines that `stopbar doctor` prints.
|
|
253
|
+
`stopbar doctor` reports `[WARN] hooks git` (not `[FAIL]`) while a Stopbar git hook is missing.
|
|
254
|
+
- `baseRef`: a mutable branch name can be moved by the agent (section 3, point 4). Use a commit SHA as `--base-ref`
|
|
255
|
+
when the agent must not move the baseline. `stopbar status` prints a `note:` when the tree no longer differs from
|
|
256
|
+
`baseRef` on existing tests; it never clears the taint (L2.2).
|
|
257
|
+
- `init --force` and `reset` count all suspicious uncommitted changes as one kernel step; a branch whose tests differ
|
|
258
|
+
from `baseRef` starts tainted until `approve-tests`.
|
|
167
259
|
- `stopbar upgrade` re-pins the runtime from the package that runs the command. It does not check that the package is
|
|
168
|
-
newer, and it does not change `config.json
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- `
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
deterministic: each export is a different proof tree, and the gate checks the one it exports.
|
|
260
|
+
newer, and it does not change `config.json`.
|
|
261
|
+
- `stopGate: "warn"`: in Cursor, Codex CLI, Gemini CLI and Antigravity CLI the WARN text is not shown to the agent; the
|
|
262
|
+
entry in `events.jsonl` and `stopbar status` show it.
|
|
263
|
+
- `cliCmd` is checked as text, not for whether it starts Stopbar. `buildCmd` and `fullTestCmd` that run the same script
|
|
264
|
+
under two names (`npm test` and `npm run test`) are not detected.
|
|
265
|
+
- `stopbar doctor` checks the kernel link only where `gdp-wired` resolves from the running copy; a pinned runtime
|
|
266
|
+
reports `[WARN] kernel link`.
|
|
267
|
+
- `--cmd`: the command runs through the system shell (`cmd.exe` on Windows, `/bin/sh` elsewhere). A shell can hold
|
|
268
|
+
stdout open after the program closed it; then only `--cmd-timeout` (default 300000 ms) ends the wait. Answers are
|
|
269
|
+
checked for their shape, not for meaning; mutants (`--check-mutants`) are the check that the model can fail.
|
|
270
|
+
Stopbar does not check that `generate` is deterministic.
|
|
271
|
+
- `probe init --lang py` prints `python` on Windows and `python3` elsewhere. `probe init --lang ts` runs only where
|
|
272
|
+
`stopbar/probe` resolves.
|
|
273
|
+
- Lean: the check needs Docker and a one-time image build with network access, or Lean 4.34.0 on `PATH` with
|
|
274
|
+
`node scripts/verify-lean.ts --local`. The base image and the Lean archive are pinned at the first build (trust on
|
|
275
|
+
first use). Each export is a different proof tree; the gate checks the one it exports.
|
|
185
276
|
- 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
|
|
187
|
-
- Adapters: Cursor, Codex CLI, Gemini CLI and Antigravity CLI are spec-tested
|
|
188
|
-
change its hook schema in a later version.
|
|
277
|
+
Linux (Debian 13, Node 24). macOS runs only in CI (`.github/workflows/ci.yml`).
|
|
278
|
+
- Adapters: Cursor, Codex CLI, Gemini CLI and Antigravity CLI are spec-tested; a client can change its hook schema.
|
|
189
279
|
- Hook latency: Windows starts a process in 50–70 ms, so a hook with one git process takes about 120–200 ms in all.
|
|
190
280
|
|
|
191
281
|
## Reporting a vulnerability
|
package/bin/stopbar.mjs
CHANGED
|
File without changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// hookEventName, toolCall {id, name, args}, cwd, workspacePaths; PostToolUse carries `error` when the tool failed;
|
|
4
4
|
// Stop carries continuationActive. Output is JSON on stdout: PreToolUse {"decision": "deny", "reason"}; Stop
|
|
5
5
|
// {"decision": "continue", "reason"} keeps the agent working. Tool names are the lower-cased step types.
|
|
6
|
-
import { byName, commandText, edit, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
6
|
+
import { str, byName, commandText, edit, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
7
7
|
|
|
8
8
|
// names seen in a live Antigravity CLI 1.5.18 session (write_file with Path) plus the step types of its hooks spec
|
|
9
9
|
const EDIT = new Set(['write_file', 'write_to_file', 'replace_file_content', 'multi_replace_file_content', 'sed_file', 'notebook_edit', 'code_action',
|
|
@@ -11,7 +11,7 @@ const EDIT = new Set(['write_file', 'write_to_file', 'replace_file_content', 'mu
|
|
|
11
11
|
const READ = new Set(['view_file', 'view_file_outline', 'view_code_item', 'view_content_chunk', 'read_notebook', 'list_directory', 'list_dir', 'find', 'find_by_name', 'code_search', 'read_resource'])
|
|
12
12
|
const OUT = new Set(['read_url_content', 'search_web', 'open_browser_url', 'read_browser_page', 'execute_browser_javascript', 'click_browser_pixel', 'mcp_tool', 'call_mcp_tool'])
|
|
13
13
|
|
|
14
|
-
function tool(name , args
|
|
14
|
+
function tool(name , args ) {
|
|
15
15
|
if (name === 'run_command' || name === 'shell_exec' || name === 'send_command_input' || name === 'notebook_execution') return shell(commandText(args.CommandLine ?? args.Command ?? args.command ?? args.Input ?? ''), args.IsDaemon === true)
|
|
16
16
|
if (EDIT.has(name)) return edit(pathsOf(args))
|
|
17
17
|
if (READ.has(name)) return read(pathsOf(args))
|
|
@@ -26,13 +26,13 @@ export const antigravity = {
|
|
|
26
26
|
normalize(i) {
|
|
27
27
|
const ev = String(i.hookEventName ?? '')
|
|
28
28
|
const cwd = typeof i.cwd === 'string' && i.cwd ? i.cwd : Array.isArray(i.workspacePaths) ? i.workspacePaths[0] : undefined
|
|
29
|
-
const call = (i.toolCall ?? {})
|
|
30
|
-
const args = (call.args && typeof call.args === 'object' ? call.args : {})
|
|
31
|
-
if (ev === 'PreToolUse') return {kind: 'pre-tool', event: make('antigravity', i, ev, {hook_event_name: 'PreToolUse', cwd, ...tool(String(call.name ?? ''), args)}, {tool: call.name})}
|
|
29
|
+
const call = (i.toolCall ?? {})
|
|
30
|
+
const args = (call.args && typeof call.args === 'object' ? call.args : {})
|
|
31
|
+
if (ev === 'PreToolUse') return {kind: 'pre-tool', event: make('antigravity', i, ev, {hook_event_name: 'PreToolUse', cwd, ...tool(String(call.name ?? ''), args)}, {tool: str(call.name)})}
|
|
32
32
|
if (ev === 'PostToolUse') {
|
|
33
33
|
const failed = typeof i.error === 'string' ? i.error.length > 0 : !!i.error
|
|
34
34
|
return {kind: failed ? 'post-tool-failure' : 'post-tool', event: make('antigravity', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse', cwd,
|
|
35
|
-
...tool(String(call.name ?? ''), args), tool_response: failed ? {error: i.error} : {}}, {tool: call.name})}
|
|
35
|
+
...tool(String(call.name ?? ''), args), tool_response: failed ? {error: i.error} : {}}, {tool: str(call.name)})}
|
|
36
36
|
}
|
|
37
37
|
if (ev === 'Stop') return {kind: 'stop', event: make('antigravity', i, ev, {hook_event_name: 'Stop', cwd, stop_hook_active: i.continuationActive === true})}
|
|
38
38
|
return {kind: 'other', event: null}
|
package/dist/adapters/claude.js
CHANGED
|
@@ -9,7 +9,7 @@ export const claude = {
|
|
|
9
9
|
name: 'claude',
|
|
10
10
|
detect: (i) => typeof i.hook_event_name === 'string',
|
|
11
11
|
normalize(i) {
|
|
12
|
-
const kind = KIND[i.hook_event_name] ?? 'other'
|
|
12
|
+
const kind = KIND[String(i.hook_event_name)] ?? 'other'
|
|
13
13
|
return {kind, event: kind === 'other' ? null : (i )}
|
|
14
14
|
},
|
|
15
15
|
render(_kind, out) {
|
package/dist/adapters/codex.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// (pre-tool-use / post-tool-use / stop .command.input and .command.output): every input carries turn_id and model.
|
|
4
4
|
// There is no failure event: PostToolUse also follows a failed command, so a gate passes only with an exit code 0
|
|
5
5
|
// found in tool_response. Output: JSON on stdout with exit 0 (permissionDecision deny / decision block).
|
|
6
|
-
import {
|
|
6
|
+
import { str, byName, commandText, edit, exitCodeIn, json, make, patchPaths, shell, } from './types.js'
|
|
7
7
|
|
|
8
8
|
const SHELL = new Set(['Bash', 'shell', 'exec_command', 'local_shell', 'unified_exec', 'shell_command', 'container.exec'])
|
|
9
9
|
|
|
10
|
-
function tool(name , ti
|
|
10
|
+
function tool(name , ti ) {
|
|
11
11
|
if (SHELL.has(name)) return shell(commandText(ti.command ?? ti.cmd ?? ti.argv))
|
|
12
12
|
if (name === 'apply_patch') return edit(patchPaths(ti.input ?? ti.patch ?? ti.command))
|
|
13
13
|
if (name.startsWith('mcp__')) return {tool_name: name, tool_input: ti}
|
|
@@ -19,20 +19,20 @@ export const codex = {
|
|
|
19
19
|
name: 'codex',
|
|
20
20
|
detect: (i) => typeof i.hook_event_name === 'string' && typeof i.turn_id === 'string',
|
|
21
21
|
normalize(i) {
|
|
22
|
-
const ev = i.hook_event_name, ti = (i.tool_input && typeof i.tool_input === 'object' ? i.tool_input : {})
|
|
22
|
+
const ev = i.hook_event_name, ti = (i.tool_input && typeof i.tool_input === 'object' ? i.tool_input : {})
|
|
23
23
|
if (ev === 'PreToolUse') {
|
|
24
24
|
const t = tool(String(i.tool_name ?? ''), ti)
|
|
25
|
-
return {kind: 'pre-tool', event: make('codex', i, ev, {hook_event_name: 'PreToolUse', cwd: i.cwd, ...t}, {tool: i.tool_name})}
|
|
25
|
+
return {kind: 'pre-tool', event: make('codex', i, ev, {hook_event_name: 'PreToolUse', cwd: str(i.cwd), ...t}, {tool: str(i.tool_name)})}
|
|
26
26
|
}
|
|
27
27
|
if (ev === 'PostToolUse') {
|
|
28
28
|
const t = tool(String(i.tool_name ?? ''), ti)
|
|
29
29
|
const code = exitCodeIn(i.tool_response)
|
|
30
30
|
const failed = code !== undefined && code !== 0
|
|
31
31
|
return {kind: failed ? 'post-tool-failure' : 'post-tool',
|
|
32
|
-
event: make('codex', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse', cwd: i.cwd, ...t,
|
|
33
|
-
tool_response: code === undefined ? i.tool_response : {exitCode: code}}, {requireExitCode: true, tool: i.tool_name})}
|
|
32
|
+
event: make('codex', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse', cwd: str(i.cwd), ...t,
|
|
33
|
+
tool_response: code === undefined ? i.tool_response : {exitCode: code}}, {requireExitCode: true, tool: str(i.tool_name)})}
|
|
34
34
|
}
|
|
35
|
-
if (ev === 'Stop') return {kind: 'stop', event: make('codex', i, ev, {hook_event_name: 'Stop', cwd: i.cwd, stop_hook_active: i.stop_hook_active === true})}
|
|
35
|
+
if (ev === 'Stop') return {kind: 'stop', event: make('codex', i, ev, {hook_event_name: 'Stop', cwd: str(i.cwd), stop_hook_active: i.stop_hook_active === true})}
|
|
36
36
|
return {kind: 'other', event: null}
|
|
37
37
|
},
|
|
38
38
|
render(kind , out) {
|
package/dist/adapters/cursor.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// beforeReadFile, afterFileEdit, afterShellExecution. Permission events: exit 2 denies, and the JSON on stdout carries
|
|
5
5
|
// permission "deny" with user_message and agent_message. Other non-zero exits are fail-open unless the entry sets
|
|
6
6
|
// failClosed: true, so `stopbar init --hooks cursor` writes failClosed: true.
|
|
7
|
-
import { byName, commandText, edit, exitCodeIn, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
7
|
+
import { str, byName, commandText, edit, exitCodeIn, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
8
8
|
|
|
9
|
-
function tool(name , ti
|
|
9
|
+
function tool(name , ti ) {
|
|
10
10
|
if (name === 'Shell') return shell(commandText(ti.command), ti.is_background === true || ti.run_in_background === true)
|
|
11
11
|
if (name === 'Read') return read(pathsOf(ti))
|
|
12
12
|
if (['Write', 'Edit', 'Delete', 'StrReplace', 'MultiEdit', 'ApplyPatch'].includes(name)) return edit(pathsOf(ti))
|
|
@@ -17,7 +17,7 @@ function tool(name , ti ) {
|
|
|
17
17
|
}
|
|
18
18
|
const toolInput = (x ) => {
|
|
19
19
|
if (typeof x === 'string') { try { const o = JSON.parse(x); return o && typeof o === 'object' ? o : {} } catch { return {} } }
|
|
20
|
-
return x && typeof x === 'object' ? (x
|
|
20
|
+
return x && typeof x === 'object' ? (x ) : {}
|
|
21
21
|
}
|
|
22
22
|
const PERMISSION = new Set(['preToolUse', 'beforeShellExecution', 'beforeMCPExecution', 'beforeReadFile'])
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ export const cursor = {
|
|
|
29
29
|
const cwd = typeof i.cwd === 'string' && i.cwd ? i.cwd : Array.isArray(i.workspace_roots) ? i.workspace_roots[0] : undefined
|
|
30
30
|
const base = (t ) => ({cwd, ...t})
|
|
31
31
|
switch (ev) {
|
|
32
|
-
case 'preToolUse': return {kind: 'pre-tool', event: make('cursor', i, ev, {hook_event_name: 'PreToolUse', ...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input)))}, {tool: i.tool_name})}
|
|
32
|
+
case 'preToolUse': return {kind: 'pre-tool', event: make('cursor', i, ev, {hook_event_name: 'PreToolUse', ...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input)))}, {tool: str(i.tool_name)})}
|
|
33
33
|
case 'beforeShellExecution': return {kind: 'pre-tool', event: make('cursor', i, ev, {hook_event_name: 'PreToolUse', ...base(shell(commandText(i.command)))})}
|
|
34
34
|
case 'beforeMCPExecution': return {kind: 'pre-tool', event: make('cursor', i, ev, {hook_event_name: 'PreToolUse', ...base(outbound(`mcp__${i.mcp_server_name ?? 'server'}__${i.tool_name ?? 'tool'}`))})}
|
|
35
35
|
case 'beforeReadFile': return {kind: 'pre-tool', event: make('cursor', i, ev, {hook_event_name: 'PreToolUse', ...base(read(pathsOf(i)))})}
|
|
@@ -38,10 +38,10 @@ export const cursor = {
|
|
|
38
38
|
const code = exitCodeIn(out)
|
|
39
39
|
const failed = code !== undefined && code !== 0
|
|
40
40
|
return {kind: failed ? 'post-tool-failure' : 'post-tool', event: make('cursor', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse',
|
|
41
|
-
...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input))), tool_response: code === undefined ? out : {exitCode: code}}, {tool: i.tool_name})}
|
|
41
|
+
...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input))), tool_response: code === undefined ? out : {exitCode: code}}, {tool: str(i.tool_name)})}
|
|
42
42
|
}
|
|
43
43
|
case 'postToolUseFailure': return {kind: 'post-tool-failure', event: make('cursor', i, ev, {hook_event_name: 'PostToolUseFailure',
|
|
44
|
-
...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input))), is_interrupt: i.is_interrupt === true || i.failure_type === 'permission_denied'}, {tool: i.tool_name})}
|
|
44
|
+
...base(tool(String(i.tool_name ?? ''), toolInput(i.tool_input))), is_interrupt: i.is_interrupt === true || i.failure_type === 'permission_denied'}, {tool: str(i.tool_name)})}
|
|
45
45
|
case 'afterFileEdit': return {kind: 'post-tool', event: make('cursor', i, ev, {hook_event_name: 'PostToolUse', ...base(edit(pathsOf(i)))})}
|
|
46
46
|
// no exit code in afterShellExecution: a gate command seen only here never passes (use postToolUse)
|
|
47
47
|
case 'afterShellExecution': return {kind: 'post-tool', event: make('cursor', i, ev, {hook_event_name: 'PostToolUse', ...base(shell(commandText(i.command)))}, {requireExitCode: true})}
|
package/dist/adapters/gemini.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Gemini CLI (.gemini/settings.json "hooks"). Events BeforeTool, AfterTool and AfterAgent (the end of a turn). Exit 2 is
|
|
3
3
|
// a system block with the reason on stderr; any other non-zero exit is only a warning and the call proceeds, and
|
|
4
4
|
// invalid JSON on stdout counts as "allow". Stopbar exits 2 for every block and fail-closed error.
|
|
5
|
-
import { byName, commandText, edit, exitCodeIn, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
5
|
+
import { str, byName, commandText, edit, exitCodeIn, json, make, outbound, pathsOf, read, shell, } from './types.js'
|
|
6
6
|
|
|
7
7
|
const UNIQUE = new Set(['BeforeTool', 'AfterTool', 'BeforeAgent', 'AfterAgent', 'BeforeModel', 'AfterModel', 'BeforeToolSelection', 'PreCompress', 'Notification'])
|
|
8
8
|
|
|
9
|
-
function tool(name , ti
|
|
9
|
+
function tool(name , ti ) {
|
|
10
10
|
switch (name) {
|
|
11
11
|
case 'run_shell_command': return shell(commandText(ti.command), ti.is_background === true || ti.run_in_background === true)
|
|
12
12
|
case 'write_file': case 'replace': return edit(pathsOf(ti))
|
|
@@ -24,16 +24,16 @@ export const gemini = {
|
|
|
24
24
|
name: 'gemini',
|
|
25
25
|
detect: (i) => typeof i.hook_event_name === 'string' && (UNIQUE.has(i.hook_event_name) || (typeof i.timestamp === 'string' && /^Session(Start|End)$/.test(i.hook_event_name))),
|
|
26
26
|
normalize(i) {
|
|
27
|
-
const ev = String(i.hook_event_name), ti = (i.tool_input && typeof i.tool_input === 'object' ? i.tool_input : {})
|
|
28
|
-
if (ev === 'BeforeTool') return {kind: 'pre-tool', event: make('gemini', i, ev, {hook_event_name: 'PreToolUse', cwd: i.cwd, ...tool(String(i.tool_name ?? ''), ti)}, {tool: i.tool_name})}
|
|
27
|
+
const ev = String(i.hook_event_name), ti = (i.tool_input && typeof i.tool_input === 'object' ? i.tool_input : {})
|
|
28
|
+
if (ev === 'BeforeTool') return {kind: 'pre-tool', event: make('gemini', i, ev, {hook_event_name: 'PreToolUse', cwd: str(i.cwd), ...tool(String(i.tool_name ?? ''), ti)}, {tool: str(i.tool_name)})}
|
|
29
29
|
if (ev === 'AfterTool') {
|
|
30
30
|
const r = (i.tool_response ?? {})
|
|
31
31
|
const code = exitCodeIn(r)
|
|
32
32
|
const failed = !!r.error || (code !== undefined && code !== 0)
|
|
33
|
-
return {kind: failed ? 'post-tool-failure' : 'post-tool', event: make('gemini', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse', cwd: i.cwd,
|
|
34
|
-
...tool(String(i.tool_name ?? ''), ti), tool_response: code === undefined ? r : {exitCode: code}}, {tool: i.tool_name})}
|
|
33
|
+
return {kind: failed ? 'post-tool-failure' : 'post-tool', event: make('gemini', i, ev, {hook_event_name: failed ? 'PostToolUseFailure' : 'PostToolUse', cwd: str(i.cwd),
|
|
34
|
+
...tool(String(i.tool_name ?? ''), ti), tool_response: code === undefined ? r : {exitCode: code}}, {tool: str(i.tool_name)})}
|
|
35
35
|
}
|
|
36
|
-
if (ev === 'AfterAgent') return {kind: 'stop', event: make('gemini', i, ev, {hook_event_name: 'Stop', cwd: i.cwd, stop_hook_active: i.stop_hook_active === true})}
|
|
36
|
+
if (ev === 'AfterAgent') return {kind: 'stop', event: make('gemini', i, ev, {hook_event_name: 'Stop', cwd: str(i.cwd), stop_hook_active: i.stop_hook_active === true})}
|
|
37
37
|
return {kind: 'other', event: null}
|
|
38
38
|
},
|
|
39
39
|
render(kind, out) {
|
package/dist/adapters/index.js
CHANGED
|
@@ -31,9 +31,10 @@ const failClosed = (why ) => ({code: 2, msg: `STOPBAR FAIL-CLOSED: $
|
|
|
31
31
|
export function handle(raw , which = 'auto', t0 = performance.now()) {
|
|
32
32
|
const explicit = which === 'auto' ? null : adapterByName(which)
|
|
33
33
|
if (which !== 'auto' && !explicit) return claude.render('pre-tool', failClosed(`unknown adapter ${JSON.stringify(which)}; known: auto, ${ADAPTERS.join(', ')}`), null)
|
|
34
|
-
let
|
|
35
|
-
try {
|
|
36
|
-
if (!
|
|
34
|
+
let parsed
|
|
35
|
+
try { parsed = JSON.parse(raw) } catch (e) { return (explicit ?? claude).render('pre-tool', failClosed(`hook input is not JSON (${(e ).message})`), null) }
|
|
36
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return (explicit ?? claude).render('pre-tool', failClosed('hook input must be a JSON object'), null)
|
|
37
|
+
const input = parsed
|
|
37
38
|
const a = explicit ?? detect(input)
|
|
38
39
|
if (!a) return claude.render('pre-tool', failClosed('unknown hook payload: no adapter recognises it (use --adapter)'), null)
|
|
39
40
|
let n
|
package/dist/adapters/types.js
CHANGED
|
@@ -27,9 +27,9 @@ export const ADAPTERS = ['claude', 'codex', 'cursor', 'gemini', '
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
// ---------------------------------------------------------------- shared tool mapping
|
|
@@ -73,14 +73,14 @@ export function pathsOf(args ) {
|
|
|
73
73
|
/** Fallback by name for tools a client adds later: shell, edit, read or outbound by keyword, else other. */
|
|
74
74
|
export function byName(name , args , command ) {
|
|
75
75
|
const n = name.toLowerCase()
|
|
76
|
-
if (/shell|terminal|command|exec|bash|run_/.test(n)) return shell(commandText(command ??
|
|
76
|
+
if (/shell|terminal|command|exec|bash|run_/.test(n)) return shell(commandText(command ?? args?.command ?? args?.CommandLine ?? ''))
|
|
77
77
|
if (/write|edit|delete|replace|patch|create|move|rename|remove|change|propose|blob/.test(n)) return edit(pathsOf(args))
|
|
78
78
|
if (/read|view|open_file|cat|grep|search_file|find|glob|list/.test(n)) return read(pathsOf(args))
|
|
79
79
|
if (/fetch|web|browser|http|url|mcp/.test(n)) return outbound(n.startsWith('mcp') ? `mcp__${name}` : name)
|
|
80
80
|
return other(name)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function make(adapter , raw
|
|
83
|
+
export function make(adapter , raw , event , base , extra = {}) {
|
|
84
84
|
return {...base, stopbar: {adapter, rawKeys: Object.keys(raw), event, ...extra}}
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -101,3 +101,6 @@ export function exitCodeIn(r , depth = 0) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export const json = (o ) => JSON.stringify(o)
|
|
104
|
+
|
|
105
|
+
/** A payload field that must be a string; anything else counts as absent. */
|
|
106
|
+
export const str = (x ) => (typeof x === 'string' ? x : undefined)
|
package/dist/attest.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Built from src/attest.ts by scripts/build.ts. Do not edit.
|
|
2
2
|
// ATTEST: a deterministic attestation of the session from the current state and the event log. The same state and log
|
|
3
3
|
// give the same report byte for byte (no clock, no machine name). The sha256 of events.jsonl is the anchor for signing in
|
|
4
|
-
// a later version.
|
|
4
|
+
// a later version. Probe evidence: the latest `probe:result` per target, and whether its tree is the current one.
|
|
5
|
+
// Read-only for Stopbar state: it refreshes only the private snapshot index to see the working tree.
|
|
5
6
|
import {createHash} from 'node:crypto'
|
|
6
7
|
import {existsSync, readFileSync} from 'node:fs'
|
|
7
8
|
import {decode, initKernel, MACHINE, } from './engine.js'
|
|
@@ -38,7 +39,12 @@ export function attestation(repoDir ) {
|
|
|
38
39
|
|
|
39
40
|
// consistency: the state must be what the log says the last kernel step (or the last init/reset) left behind
|
|
40
41
|
const checks = []
|
|
41
|
-
|
|
42
|
+
// a loop from the end, not Math.max(...events): one argument per entry overflows the stack on a long log
|
|
43
|
+
let lastIdx = -1
|
|
44
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
45
|
+
const e = events[i].e
|
|
46
|
+
if (e.req || e.source === 'human:init' || e.source === 'human:reset') { lastIdx = i; break }
|
|
47
|
+
}
|
|
42
48
|
if (lastIdx < 0) checks.push({name: 'log matches state', ok: false, detail: 'no kernel step and no init in events.jsonl'})
|
|
43
49
|
else {
|
|
44
50
|
const last = events[lastIdx]
|
|
@@ -49,18 +55,33 @@ export function attestation(repoDir ) {
|
|
|
49
55
|
checks.push({name: 'config params = state params', ok: cfg.maxRetries === s.params.maxRetries && cfg.cap === s.params.cap, detail: `${JSON.stringify(s.params)}`})
|
|
50
56
|
checks.push({name: 'working tree counted', ok: now.id === s.snapshot, detail: now.id === s.snapshot ? 'no change the kernel has not seen' : 'uncounted change (counted at the next hook)'})
|
|
51
57
|
|
|
58
|
+
// probe evidence: the latest probe:result per target since the last init / reset (not kernel steps: no req)
|
|
59
|
+
let since = 0
|
|
60
|
+
events.forEach(({e}, i) => { if (e.source === 'human:init' || e.source === 'human:reset') since = i + 1 })
|
|
61
|
+
const latest = new Map ()
|
|
62
|
+
for (const x of events.slice(since)) if (x.e.source === 'probe:result' && typeof x.e.target === 'string') latest.set(x.e.target, x)
|
|
63
|
+
const probes = [...latest.keys()].sort().map((k) => {
|
|
64
|
+
const {line, e} = latest.get(k)
|
|
65
|
+
const m = e.mutants && typeof e.mutants === 'object' ? e.mutants : null
|
|
66
|
+
return {target: k, targetPath: e.targetPath ?? null, ...(typeof e.targetCmd === 'string' ? {targetCmd: e.targetCmd} : {}), targetSha256: e.targetSha256 ?? null, ok: e.ok === true, runs: e.runs ?? 0, regressions: e.regressions ?? 0,
|
|
67
|
+
passed: e.passed ?? 0, failed: e.failed ?? 0, steps: e.steps ?? 0,
|
|
68
|
+
mutants: m ? {killed: m.killed ?? 0, total: m.total ?? 0, survived: Array.isArray(m.survived) ? m.survived : []} : null,
|
|
69
|
+
treeSnapshot: e.treeSnapshot ?? null, atCurrentSnapshot: e.treeSnapshot === now.id, summarySha256: e.summarySha256 ?? null, line, ts: e.ts ?? null}
|
|
70
|
+
})
|
|
71
|
+
|
|
52
72
|
const commitNow = !v.halted && v.buildOkRev === v.treeRev && v.testsOkRev === v.treeRev && !v.testsTainted
|
|
53
73
|
return {
|
|
54
74
|
stopbar: VERSION,
|
|
55
75
|
kernel: MACHINE,
|
|
56
76
|
repository: {head, headTree, snapshot: s.snapshot, workingTreeSnapshot: now.id, treeRevision: v.treeRev},
|
|
57
77
|
config: {profile: cfg.profile, buildCmd: cfg.buildCmd, fullTestCmd: cfg.fullTestCmd, maxRetries: cfg.maxRetries, cap: cfg.cap, costPerCall: cfg.costPerCall, ...(cfg.baseRef ? {baseRef: cfg.baseRef} : {}),
|
|
58
|
-
stopGate: cfg.stopGate ?? 'block', ...(cfg.cliCmd ? {cliCmd: cfg.cliCmd} : {})},
|
|
78
|
+
stopGate: cfg.stopGate ?? 'block', ...(cfg.cliCmd ? {cliCmd: cfg.cliCmd} : {}), ...(cfg.requireRun ? {requireRun: true} : {})},
|
|
59
79
|
gates: {build: v.buildOkRev === v.treeRev, fullTests: v.testsOkRev === v.treeRev, tainted: v.testsTainted, secretRead: v.secretTainted,
|
|
60
80
|
...(v.secretTainted ? {secretReadBy: secretReason(repo)?.text ?? 'not in the event log'} : {}),
|
|
61
81
|
shellApprovalHeld: v.shellToken, halted: v.halted, commitAllowedNow: commitNow, ...(commitNow ? {} : {why: v.halted ? 'session halted' : whyBlocked(v, cfg)}),
|
|
62
82
|
budget: {spent: v.spent, cap: v.capNow}, failures: {tests: v.testFails, builds: v.buildFails}},
|
|
63
83
|
humanActions: approvals,
|
|
84
|
+
probes,
|
|
64
85
|
log: {file: 'events.jsonl', sha256: createHash('sha256').update(raw).digest('hex'), bytes: raw.length, entries: events.length, tornLines: torn,
|
|
65
86
|
kernelSteps: steps.length, blocks, commitsAllowed, decisions: Object.fromEntries(Object.entries(decisions).sort())},
|
|
66
87
|
consistent: checks.every((c) => c.ok || c.name === 'working tree counted'),
|
|
@@ -79,6 +100,7 @@ export function attestMarkdown(a ) {
|
|
|
79
100
|
`| HEAD | \`${a.repository.head ?? '(none)'}\` |`, `| HEAD tree | \`${a.repository.headTree ?? '(none)'}\` |`,
|
|
80
101
|
...(a.config.baseRef ? [`| Base ref | \`${a.config.baseRef}\` |`] : []),
|
|
81
102
|
...(a.config.stopGate === 'warn' ? ['| Stop gate | warn (Stop does not block a turn; git commit and git push stay gated) |'] : []),
|
|
103
|
+
...(a.config.requireRun ? ['| requireRun | true (the build and full test gates count only through `stopbar run build` and `stopbar run test`) |'] : []),
|
|
82
104
|
`| Counted snapshot | \`${a.repository.snapshot}\` (revision ${a.repository.treeRevision}) |`,
|
|
83
105
|
`| Build gate | ${yn(g.build)} (\`${a.config.buildCmd}\`) |`, `| Full test gate | ${yn(g.fullTests)} (\`${a.config.fullTestCmd}\`) |`,
|
|
84
106
|
`| Tests tainted | ${yn(g.tainted)} |`, `| Secret read | ${g.secretRead ? `yes: ${g.secretReadBy}` : 'no'} |`, `| Halted | ${yn(g.halted)} |`,
|
|
@@ -88,6 +110,9 @@ export function attestMarkdown(a ) {
|
|
|
88
110
|
`| Kernel steps / blocks / commits allowed | ${a.log.kernelSteps} / ${a.log.blocks} / ${a.log.commitsAllowed} |`,
|
|
89
111
|
`| Consistent | ${yn(a.consistent)} |`, '',
|
|
90
112
|
`## Human actions`, '', ...(a.humanActions.length ? a.humanActions.map((h) => `- line ${h.line}, ${h.ts}: ${h.action}${'revision' in h ? ` revision ${h.revision}` : ''}${'extra' in h ? ` extra ${h.extra}` : ''}${h.decision ? ` -> ${h.decision}` : ''}`) : ['- none']), '',
|
|
113
|
+
`## Probe evidence`, '', ...(a.probes.length ? a.probes.map((p) => `- ${p.target}: ${p.ok ? 'PASS' : 'FAIL'}, ${p.runs} runs, ${p.steps} steps` +
|
|
114
|
+
`${p.mutants ? `, mutants ${p.mutants.killed}/${p.mutants.total} killed${p.mutants.survived.length ? ` (survived: ${p.mutants.survived.join(', ')})` : ''}` : ''}` +
|
|
115
|
+
`, at current snapshot: ${yn(p.atCurrentSnapshot)}${p.targetSha256 ? `, target sha256 \`${String(p.targetSha256).slice(0, 16)}\`` : ''} (line ${p.line})`) : ['- none']), '',
|
|
91
116
|
`## Checks`, '', ...a.checks.map((c) => `- [${c.ok ? 'x' : ' '}] ${c.name}: ${c.detail}`), '',
|
|
92
117
|
].join('\n')
|
|
93
118
|
}
|
package/dist/build-info.json
CHANGED