@descent-vtt/spec-harness 0.19.0 → 0.20.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +212 -0
- package/README.md +30 -15
- package/dist/briefs.d.ts +45 -0
- package/dist/briefs.js +73 -0
- package/dist/briefs.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +211 -134
- package/dist/cli.js.map +1 -1
- package/dist/commands.js +7 -2
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +13 -1
- package/dist/config.js +14 -3
- package/dist/config.js.map +1 -1
- package/dist/configure.d.ts +55 -1
- package/dist/configure.js +130 -22
- package/dist/configure.js.map +1 -1
- package/dist/fs.d.ts +78 -1
- package/dist/fs.js +289 -10
- package/dist/fs.js.map +1 -1
- package/dist/git.d.ts +50 -2
- package/dist/git.js +98 -8
- package/dist/git.js.map +1 -1
- package/dist/hooks.d.ts +45 -0
- package/dist/hooks.js +62 -3
- package/dist/hooks.js.map +1 -1
- package/dist/round.d.ts +8 -0
- package/dist/round.js +23 -8
- package/dist/round.js.map +1 -1
- package/dist/sandbox.js +4 -3
- package/dist/sandbox.js.map +1 -1
- package/dist/server.d.ts +25 -1
- package/dist/server.js +194 -27
- package/dist/server.js.map +1 -1
- package/dist/setup.js +40 -10
- package/dist/setup.js.map +1 -1
- package/dist/siblings.d.ts +24 -3
- package/dist/siblings.js +106 -14
- package/dist/siblings.js.map +1 -1
- package/dist/usage.d.ts +42 -7
- package/dist/usage.js +65 -6
- package/dist/usage.js.map +1 -1
- package/dist/workspace.d.ts +45 -3
- package/dist/workspace.js +133 -13
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Rounds of agent work under a brief: context, a guard on every write, escalations a person signs, an audit at the end. Needs Claude Code 2.1.139 or later, and @descent-vtt/spec-harness and @descent-vtt/spec-brief 0.2.0 or later installed in the project.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "DescentVTT",
|
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,218 @@ only fixes, reports less or documents, so `^0.7.0` takes only releases that
|
|
|
9
9
|
cannot turn a run red. The family's policy is
|
|
10
10
|
[spec-core's ADR-0009](https://github.com/DescentVTT/spec-core/blob/main/docs/adr/0009-versions-before-1-0.md).
|
|
11
11
|
|
|
12
|
+
## 0.20.0
|
|
13
|
+
|
|
14
|
+
The hook decides each path by the work tree that holds it, a third
|
|
15
|
+
worktree's and the MCP server's included, and finds siblings in the main
|
|
16
|
+
checkout's install wherever a work tree has none; every process it starts
|
|
17
|
+
has a time limit, and it reads only a file where a file is expected, so a
|
|
18
|
+
named pipe no longer holds it without end; it says a guard that is off with
|
|
19
|
+
exit 0, and `init --block-on-failure` asks Claude Code to hold a write when
|
|
20
|
+
the hook cannot start. It gives a session spec-brief's answer again where
|
|
21
|
+
nothing that answer was read from has changed, and it can report, at the end
|
|
22
|
+
of a turn and where the configuration asks for it, what the work tree holds
|
|
23
|
+
that the brief protects or that is outside its scope
|
|
24
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md),
|
|
25
|
+
[ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
26
|
+
|
|
27
|
+
A configuration that does not load lets a write to itself through, so
|
|
28
|
+
that a session can mend it; a write outside every work tree of the
|
|
29
|
+
repository is held by no brief and no configuration; and `doctor` fails
|
|
30
|
+
where the branch names a brief no round can work under
|
|
31
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md),
|
|
32
|
+
[ADR-0004](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0004-the-active-brief-is-named-not-guessed.md)).
|
|
33
|
+
|
|
34
|
+
`doctor` says a line of Claude Code's hook that asks for the help or the
|
|
35
|
+
version as a guard that is off, fails `--strict` where git cannot say
|
|
36
|
+
where it runs its hooks, and notes in a linked worktree the release the
|
|
37
|
+
hook's line runs; a `.spec-harness.json` that cannot be read is said as
|
|
38
|
+
that; and on Windows a drive letter is one in either case
|
|
39
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- **A report at the end of a turn, where `.spec-harness.json` asks for
|
|
44
|
+
one.** With `"turnReport": true`, `hook claude` answers Claude Code's
|
|
45
|
+
`Stop`: with one `git status`, every path the work tree holds changed
|
|
46
|
+
that the brief protects or that is outside its scope, a shell's writes
|
|
47
|
+
among them, in the words a write of it is given, as one `systemMessage`,
|
|
48
|
+
exit 0, and never a field that has Claude go on. `init` writes the entry,
|
|
49
|
+
in the background, where the key is on, and Claude reads the report as the
|
|
50
|
+
next turn begins; the plugin carries none, and with it on `init` says
|
|
51
|
+
what to add
|
|
52
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md),
|
|
53
|
+
[ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
54
|
+
Upgrading: off by default, so nothing changes until the key is turned on
|
|
55
|
+
and `spec-harness init --write` run again. A `Stop` entry aimed at the
|
|
56
|
+
hook exited 1, `the hook input names no event or tool`, and now exits 0;
|
|
57
|
+
a configuration's unknown key is refused with `turnReport` among the keys
|
|
58
|
+
it names.
|
|
59
|
+
- **`init --block-on-failure` writes `"onFailure": "block"` on its hook
|
|
60
|
+
entries before and after a write and as a session starts**, and on those
|
|
61
|
+
an earlier run wrote, so that Claude Code 2.1.295 or later holds a write
|
|
62
|
+
where the hook cannot start, as in a worktree with no install, or runs
|
|
63
|
+
past its timeout. It is written only
|
|
64
|
+
where asked for, and the plugin does not carry it: no page says what an
|
|
65
|
+
older release does with the key. `doctor` advises it in a note, failing
|
|
66
|
+
nothing, for a line that guards without it where the Claude Code on
|
|
67
|
+
`PATH` reads the field
|
|
68
|
+
([ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
69
|
+
The entry at the end of a turn is left without it: it runs in the
|
|
70
|
+
background, where the hooks reference gives the field no effect.
|
|
71
|
+
- **`doctor`, run in a linked worktree, notes the release the hook's line
|
|
72
|
+
runs.** The line names its script under `${CLAUDE_PROJECT_DIR}`, which
|
|
73
|
+
in a worktree session of the desktop app is the main checkout. Where the
|
|
74
|
+
main checkout's install of spec-harness and the worktree's are not one
|
|
75
|
+
release, a note names both; it fails nothing.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- **The hook gives a session spec-brief's list of the briefs again, where
|
|
80
|
+
nothing it was read from has changed.** On a brief's branch the hook
|
|
81
|
+
started spec-brief before every write, most of what a write waited for on
|
|
82
|
+
Windows. Where spec-brief's `list --format json` names everything its
|
|
83
|
+
answer was read from, its `inputs`, the hook keeps the answer for the
|
|
84
|
+
session under the git common directory, in `spec-harness/answers/`, and
|
|
85
|
+
gives it again to the session's later runs while every file, directory
|
|
86
|
+
and index on the list reads as listed, with no process started; anything
|
|
87
|
+
else starts spec-brief as before. No answer changes
|
|
88
|
+
([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md),
|
|
89
|
+
[ADR-0003](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0003-state-outside-the-work-tree.md)).
|
|
90
|
+
Upgrading: nothing to change. A spec-brief whose `list` names no
|
|
91
|
+
`inputs`, 0.9.0 and every release before it, is started before every
|
|
92
|
+
write as it was.
|
|
93
|
+
- **A process the harness asks a question of is stopped after 20 seconds,
|
|
94
|
+
and the hook holds the write there.** git had no limit and spec-brief
|
|
95
|
+
ten minutes, where Claude Code cancels the hook at the 60 seconds its
|
|
96
|
+
entry gives it, and before a write lets the write go ahead: a named pipe
|
|
97
|
+
at `.spec-brief.json` or `.git/config` kept the hook, `doctor` and
|
|
98
|
+
every command from coming back. git's reads and spec-brief's list are
|
|
99
|
+
now stopped at 20 seconds and said, `spec-brief did not answer within
|
|
100
|
+
20 seconds, and was stopped`; before a write that is `cannot check this
|
|
101
|
+
write: ...`, exit 2, which holds it. A round's work, a diff, a probe's
|
|
102
|
+
worktree, a sibling's check, keeps ten minutes
|
|
103
|
+
([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
104
|
+
Upgrading: where git or spec-brief takes longer than 20 seconds to
|
|
105
|
+
answer, which none measured does, writes are held and commands exit 2
|
|
106
|
+
with the line: find what it waits on.
|
|
107
|
+
- **A path is decided by the work tree that holds it.** A path in a work
|
|
108
|
+
tree of the repository that was neither the one the project names nor
|
|
109
|
+
the one the question's `cwd` is in was read from the project's top, as a
|
|
110
|
+
file of `.claude/worktrees/<name>/` under the project's branch or as one
|
|
111
|
+
outside the project, and a write its own brief protects passed with no
|
|
112
|
+
word. That work tree now decides it, by its branch, briefs and
|
|
113
|
+
configuration; a nested repository's file is decided as before
|
|
114
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
115
|
+
Upgrading: a session that writes into another worktree has the write
|
|
116
|
+
refused where that worktree's brief protects it.
|
|
117
|
+
- **Every command finds the siblings in the main work tree's install** where
|
|
118
|
+
a linked worktree has none, as git's hook and `doctor` did: `guard`,
|
|
119
|
+
`context`, `audit`, `probe` and the rest exited 2, `spec-brief is not
|
|
120
|
+
installed here`.
|
|
121
|
+
Upgrading: in such a worktree these commands run, and `guard` and
|
|
122
|
+
`audit` can exit 1 where they exited 2.
|
|
123
|
+
- **The server reads the work tree a path is in, and the round in the one
|
|
124
|
+
its client names.** `check_path` read every path as the project's, and
|
|
125
|
+
every tool the project's branch, so a worktree's file read as
|
|
126
|
+
`.claude/worktrees/<name>/...` and its brief went unnamed. `check_path`
|
|
127
|
+
decides an absolute path by the work tree of the repository that holds
|
|
128
|
+
it, and `start_round`, `check_path`, `request_escalation` and
|
|
129
|
+
`audit_round` read the round in the work tree a new `directory`
|
|
130
|
+
argument names, else the one the client's roots name where they name
|
|
131
|
+
exactly one of the repository's, else the project's, and say which as
|
|
132
|
+
`workTree`
|
|
133
|
+
([ADR-0008](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0008-one-server-for-rounds.md)).
|
|
134
|
+
Upgrading: a client that declares roots naming a worktree has its calls
|
|
135
|
+
answered for that worktree; a script reading the tools' structured
|
|
136
|
+
answers finds `workTree`.
|
|
137
|
+
- **The hook says the guard is off with exit 0, where it exited 1.** A
|
|
138
|
+
question it cannot read and a line of its own that turns the guard off
|
|
139
|
+
(one it cannot read, a `--root` that is no directory) were one line on
|
|
140
|
+
stderr and exit 1, which Claude Code counts as a hook that failed: under
|
|
141
|
+
`"onFailure": "block"` that held every write of the session, the one
|
|
142
|
+
that mends the line among them. Each is now the same line to the person,
|
|
143
|
+
as `systemMessage`, and exit 0, and the write goes on as it did, so
|
|
144
|
+
`onFailure` holds only a hook that did not run
|
|
145
|
+
([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
146
|
+
Upgrading: a script that read the hook's exit 1 or its stderr reads the
|
|
147
|
+
line as `systemMessage` on stdout, with exit 0.
|
|
148
|
+
- **A write to `.spec-harness.json` itself goes on while it does not
|
|
149
|
+
load.** Every write was held, exit 2, the one that mends the file among
|
|
150
|
+
them, so a session could not mend a typo in it. Before a write to that
|
|
151
|
+
file and to nothing else, the hook now decides nothing, exit 0, so the
|
|
152
|
+
person's own permission prompt stands, and says why every other write is
|
|
153
|
+
held, to the person and to Claude. A file of that name elsewhere, a link
|
|
154
|
+
to it, a second name of it and the configuration of another work tree
|
|
155
|
+
are held as before, and so is a configuration that is a directory, a
|
|
156
|
+
named pipe, or a link to a file of the repository. As a session starts
|
|
157
|
+
the hook says the same.
|
|
158
|
+
Upgrading: a brief that protects `.spec-harness.json` does not hold that
|
|
159
|
+
write while the file does not load, since none of it is read; the audit
|
|
160
|
+
and spec-brief's archive still measure the change.
|
|
161
|
+
- **`doctor` exits 1 where the branch names a brief spec-brief does not
|
|
162
|
+
know, or has archived.** The hook holds every write on such a branch,
|
|
163
|
+
and `doctor` said so on its `brief` line and exited 0. One the flag or
|
|
164
|
+
`SPEC_BRIEF` names still fails nothing.
|
|
165
|
+
Upgrading: a branch whose name only reads as a brief's, as
|
|
166
|
+
`fix/brief-list-order` names `list` under the default `branches`, fails
|
|
167
|
+
`doctor` as it holds every write: rename the branch, or set `branches` in
|
|
168
|
+
`.spec-harness.json`.
|
|
169
|
+
- **A write outside every work tree of the repository is not held by what
|
|
170
|
+
holds the writes inside.** A brief that is archived, or that spec-brief
|
|
171
|
+
does not list, whichever names it, and a configuration that does not
|
|
172
|
+
load held every write, a file outside the repository among them, and
|
|
173
|
+
`guard` refused such a path, exit 2. Such a write passes as one outside
|
|
174
|
+
the repository does, with no word, and spec-brief is not asked about it;
|
|
175
|
+
one inside any work tree of the repository, a linked worktree's among
|
|
176
|
+
them, is decided as before, by the work tree that holds it, and a path
|
|
177
|
+
with a `..` in it is held as before.
|
|
178
|
+
Upgrading: `guard` of a path outside the repository exits 0 under such
|
|
179
|
+
a brief, where it exited 2.
|
|
180
|
+
- **A hook line that asks for the help or the version is a guard that is
|
|
181
|
+
off.** `hook claude --help`, `--version`, `-h` and `-v` print the help
|
|
182
|
+
or the version, exit 0, and check no write, which Claude Code takes for a
|
|
183
|
+
hook that succeeded; `doctor` said such a line guards, and said a
|
|
184
|
+
`--brief 404` beside it held every write. It says the line as one under
|
|
185
|
+
which no write is checked, whatever else is on it, and exits 1.
|
|
186
|
+
Upgrading: take the option off the hook's line; `doctor` exits 1 until
|
|
187
|
+
it is.
|
|
188
|
+
- **`--help` or `--version` beside a `--root` that is not a directory is
|
|
189
|
+
a line the hook cannot read.** `hook claude --help --root nowhere`
|
|
190
|
+
printed the help, exit 0, where without `--help` the hook says the
|
|
191
|
+
root. It says `the hook's line cannot be read (--help is given beside a
|
|
192
|
+
fault, --root is "nowhere", which is not a directory, ...)` as it says
|
|
193
|
+
every line it cannot read, to the person with exit 0, before a write and
|
|
194
|
+
after one, and holds no write; as a session starts it says the same.
|
|
195
|
+
`doctor` says the line in the same words.
|
|
196
|
+
Upgrading: mend the line; no line a release wrote carries either.
|
|
197
|
+
- **`doctor --strict` fails where git cannot say where it runs its
|
|
198
|
+
hooks.** Under a `core.hooksPath` that names a file, `where git runs its
|
|
199
|
+
hooks cannot be told` failed nothing, under `--strict` or not, where a
|
|
200
|
+
release, a hook's line, a plugin or a hook file that cannot be told
|
|
201
|
+
fails `--strict`.
|
|
202
|
+
Upgrading: point `core.hooksPath` at a directory, or leave it unset.
|
|
203
|
+
|
|
204
|
+
### Fixed
|
|
205
|
+
|
|
206
|
+
- **A named pipe where the harness reads a file** no longer keeps a
|
|
207
|
+
command from coming back: a document a brief cites, a sibling's
|
|
208
|
+
`package.json`, what the run before a write kept, git's configuration
|
|
209
|
+
and a worktree's `commondir` as the hook reads them, a request waiting
|
|
210
|
+
for a ruling, a probe's report. Only a regular file is read, and what
|
|
211
|
+
else stands there is read as a file that is not there
|
|
212
|
+
([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
213
|
+
- **A `.spec-harness.json` that cannot be read is said as that.** One the
|
|
214
|
+
account may not read, or one another process holds open on Windows, was
|
|
215
|
+
`.spec-harness.json is not valid JSON: EACCES: ...`. It is
|
|
216
|
+
`.spec-harness.json cannot be read: EACCES: ...`, exit 2 as before, and
|
|
217
|
+
a write to the file itself goes on, as to one that does not load.
|
|
218
|
+
- **On Windows `--root C:\work` beside `--root c:\work` is one root.**
|
|
219
|
+
Every command refused the two as two directories, exit 2, and the hook
|
|
220
|
+
read such a line as one it cannot read, under which it checked no write;
|
|
221
|
+
Windows names a volume by its letter in either case. The hook now guards
|
|
222
|
+
under that root, and the rest of the path is compared as before.
|
|
223
|
+
|
|
12
224
|
## 0.19.0
|
|
13
225
|
|
|
14
226
|
An option that takes one value is given one, and a line that is wrong is
|
package/README.md
CHANGED
|
@@ -91,8 +91,11 @@ An app that makes a branch for a session puts a name of its own before the brief
|
|
|
91
91
|
- A branch that names an id spec-brief does not list, as `claude/brief-999-x`, is not passed over for the next: every write of the session is held until the brief or the branch is mended. Where Claude Code starts the hook as a session starts, the entry `init` and the plugin write under `SessionStart`, the session is told so before its first write.
|
|
92
92
|
- A tag of the same name as the branch does not hide it: the branch is read as HEAD names it.
|
|
93
93
|
- In a worktree session started from the desktop app, and after Claude enters a worktree mid-session, Claude Code starts the hook with `${CLAUDE_PROJECT_DIR}` at the main checkout and hands it the worktree as the question's `cwd` (the worktrees page, *What worktrees share with the main checkout*; [the hooks reference](https://code.claude.com/docs/en/hooks), *Reference scripts by path*). The worktree's branch names the brief, and a worktree with no install of its own is checked with the project's: an Edit of a file brief 042 protects, in a worktree on `claude/brief-042-x` of a main checkout on `main`, is refused.
|
|
94
|
-
-
|
|
95
|
-
-
|
|
94
|
+
- A path is decided by the work tree that holds it, where that is a work tree of the same repository, whichever `cwd` is in: an Edit of a file brief 042 protects, in a worktree on `claude/brief-042-x`, is refused from a session at the main checkout and from one in another worktree, inside the project or beside it. A path in no work tree of the repository is decided as before ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
95
|
+
- A nested repository, a submodule or a clone inside the tree, is another repository, and a path in it is decided as before, by the work tree of the project's repository that holds it, under the path it has there. What that lets through: a file the nested repository's own brief protects is outside the project's scope, warned of after the write and not refused, and one the project's brief does not reach passes with no word. That repository is guarded by its own hook, in its own sessions.
|
|
96
|
+
- Where `${CLAUDE_PROJECT_DIR}` points in a session started with `claude --worktree` is on no page of Claude Code's: the hooks reference has it the project root where the session started, the worktrees page has the flag start Claude in the worktree, and a worktree a fresh checkout to install dependencies into, and says where it points only for a session started from the desktop app. Where it is the worktree, the next point holds.
|
|
97
|
+
- git's pre-commit hook in such a worktree runs the main work tree's install where the worktree has none, and refuses the same file at the commit. So does every other command, `guard`, `context`, `audit`, `probe` and the rest, where each said that spec-brief is not installed here. A hook an earlier release wrote reads the worktree's own install alone: take it away and run `init --git-hook --write`.
|
|
98
|
+
- Where `${CLAUDE_PROJECT_DIR}` is the worktree itself, the project root a session started in, the hook's script is looked for in the worktree's own `node_modules`. A worktree is a fresh checkout (the worktrees page, *Set up the worktree environment*), and where it has no install, node cannot find the script and exits 1: Claude Code reads that as a hook's non-blocking error, and the write goes ahead (the hooks reference, *Exit code output*). Install in the worktree before such a session writes. From Claude Code 2.1.295, `"onFailure": "block"` on the hook's entry holds the write instead: `init --block-on-failure` writes it on init's PreToolUse, PostToolUse and SessionStart entries, and the plugin does not carry it ([ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
96
99
|
|
|
97
100
|
### Sessions that write through a shell, with no rulings
|
|
98
101
|
|
|
@@ -103,6 +106,7 @@ Claude Code starts the guard for `Edit`, `Write`, `MultiEdit` and `NotebookEdit`
|
|
|
103
106
|
| The guard, before an Edit | an Edit of `src/db/schema.ts`: refused, with the next step | an Edit of `notes.md` under `outOfScope: "warn"`; every shell command |
|
|
104
107
|
| The guard, after an Edit | an Edit of `notes.md`: a warning to Claude | every shell command |
|
|
105
108
|
| The hook as a session starts | a configuration that does not load, an id spec-brief does not list, spec-brief missing or too old where a brief is named: one line, to the person and to Claude | everything: it holds nothing, and the event cannot block |
|
|
109
|
+
| The report at the end of a turn, `"turnReport": true` | every path the work tree holds changed, a shell's writes among them: `src/db/schema.ts` reported as protected and `notes.md` as outside the scope, to Claude as the next turn begins | a change made and undone, or committed, within the turn; an ignored file; a turn an interrupt or an API error ends; and it refuses nothing, the write having happened |
|
|
106
110
|
| git's pre-commit hook, `init --git-hook` | every staged path, a shell's writes among them: `src/db/schema.ts` refused; `notes.md` warned of under `warn`, refused under `ask` and `deny` | `git commit --no-verify`, which skips the hook ([githooks](https://git-scm.com/docs/githooks), *pre-commit*) |
|
|
107
111
|
| `spec-harness audit` | the round's commits from the base: `src/db/schema.ts` changed, an error, and `notes.md`, a warning; exit 1 | what the brief, as it stands at the end, allows |
|
|
108
112
|
| `spec-brief archive --strict --base <branch>` | the same, both errors: the brief is not archived | the same |
|
|
@@ -110,11 +114,11 @@ Claude Code starts the guard for `Edit`, `Write`, `MultiEdit` and `NotebookEdit`
|
|
|
110
114
|
What every layer lets through:
|
|
111
115
|
|
|
112
116
|
- **An edit of the brief.** Its file is always writable, and the audit and the archive read the brief as it stands at the end: a round that adds `notes.md` to `affectedFiles` and takes `src/db/schema.ts` out of `protectedFiles` is archived with `--strict`. The change is in the brief's diff, for the person who approved it to read.
|
|
113
|
-
- **A shell's write**, until the commit.
|
|
117
|
+
- **A shell's write**, until the commit; with `turnReport` on, it is reported at the end of the turn, and not refused.
|
|
114
118
|
- **`git commit --no-verify`**, until the audit.
|
|
115
119
|
- **A Claude Code mod** that handles `tool.check` can approve a call a `PreToolUse` hook blocked, unless the hook is in managed settings ([Claude Code's permissions page](https://code.claude.com/docs/en/permissions), *Precedence among rules, hooks, and mods*).
|
|
116
120
|
|
|
117
|
-
Two more layers were weighed and not built. A `PostToolUse` hook for the shell tools: every shell command would pay for it, it is easy to get around, and the audit stays the gate ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md), amended 2026-09-30). And `"protected": "ask"`: a protected file passes the guard only by a ruling whose commit a person signed, which the audit and the archive check again ([ADR-0006](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0006-a-ruling-is-a-signed-commit.md)), and an approval given in the session is kept nowhere they read.
|
|
121
|
+
Two more layers were weighed and not built. A `PostToolUse` hook for the shell tools: every shell command would pay for it, it is easy to get around, and the audit stays the gate; the report at the end of a turn is paid once a turn, in the background, and reads the work tree rather than a command ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md), amended 2026-09-30). And `"protected": "ask"`: a protected file passes the guard only by a ruling whose commit a person signed, which the audit and the archive check again ([ADR-0006](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0006-a-ruling-is-a-signed-commit.md)), and an approval given in the session is kept nowhere they read.
|
|
118
122
|
|
|
119
123
|
## Commands
|
|
120
124
|
|
|
@@ -171,13 +175,18 @@ May the round write this?
|
|
|
171
175
|
Paths are compared as the filesystem spells them, links resolved and case corrected, so `SRC/db/schema.ts` does not walk past a protection on `src/db/schema.ts` on Windows.
|
|
172
176
|
|
|
173
177
|
- `spec-harness hook claude` answers Claude Code's PreToolUse and PostToolUse hooks: a refusal before the write, with the reason and the next step; a warning after a write outside the scope. It never answers `allow`, which would skip the person's own permission prompt. When it cannot answer - the configuration does not load, the briefs cannot be read, the harness meets an error it did not expect - it exits 2, and before a write Claude Code then holds the write.
|
|
178
|
+
- While `.spec-harness.json` does not load, a write to that file itself is let through, so that a session can mend it: no decision, so the person's own permission prompt stands, and the line that says why every other write is held, to the person as `systemMessage` and to Claude as `additionalContext`, as `.spec-harness.json: unknown key "outofscope"; ..., so every other write is held until it loads; this write, to /work/app/.spec-harness.json itself, is not checked`. The write is to the file and nothing else as the hook reads a path and as the disk does: a file that stands under that name alone, not a link to one and with no second name, named by every path of the call. A file of the same name elsewhere, a link to it, and the configuration of another work tree than the one that does not load are held as every other write is. After the write the hook loads the file again, and says, exit 2, where it still does not load. While it does not load nothing of it is read, so a brief that protects the file, or an `outOfScope` it sets, does not hold this write; the audit and spec-brief's archive still measure the round's change to it ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
179
|
+
- A write outside every work tree of the repository is decided as one outside the repository is, whatever holds the writes inside: a brief that is archived, or that spec-brief does not list, whichever names it, and a configuration that does not load. It passes with no word, before the write and after it, and spec-brief is not asked about it; `guard` says it is outside the repository. The work trees are the main one and every linked worktree, as the files git keeps under its common directory name them, and a file of a linked worktree is decided as any other inside, by the worktree that holds it. Where they cannot all be named, a git directory kept apart, an entry git keeps that cannot be read, or a `core.worktree` where the configuration does not load, the write is held as before, and so is a path with a `..` in it, which the hook reads before its links where Linux and macOS write it after ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
174
180
|
- In a worktree, a write is decided by the worktree's brief. Claude Code names the project a session started in, and hands the hook the directory Claude works in as the question's `cwd`: in a worktree session started from the desktop app, and after Claude enters a worktree, the first is the main checkout and the second the worktree. Where `cwd` is in another work tree of the same repository, that work tree's branch names the brief, its briefs and configuration are read, and its siblings are looked for in its own `node_modules` and then the project's, so a worktree with no install is checked with the project's. A path it does not hold, and every path where `cwd` is in another repository or in none, is decided by the project as before ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
175
181
|
- After a write the hook answers from what it decided before it, for the same call: the run before keeps the warnings it would give under the git common directory, in `spec-harness/calls/`, named by the question's `session_id` and `tool_use_id`, and the run after takes them away and answers with no process started. A refused call keeps nothing, nor one that writes `.spec-harness.json`, spec-brief's configuration, the brief or a file beside it, which are decided again after the write; what no run after a write reads is removed after a day. Under `outOfScope: "ask"` or `"deny"` no write is warned of, and the run after one says nothing with no process started ([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
182
|
+
- On a brief's branch the hook asks spec-brief for the briefs, which on Windows is most of what a write waits on. Within a session it keeps spec-brief's answer, where spec-brief's `list` names every input it was read from (`inputs`), under the git common directory in `spec-harness/answers/`, by the work tree, the session, spec-brief's script and version, the command line, and the variables git and Node read; and it gives the answer again while each file on the list has the digest listed, or is still not there, each directory holds the files listed, or is still not there where it was listed as not there, and the git index and ignore files read as listed, with no process started. Anything else starts spec-brief as before: an input that is missing, unreadable or reads otherwise, `keep` not `true`, an answer with no `inputs`, a command `tools` names, and, where the list names what git read, `GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE` or `GIT_COMMON_DIR` set. What is kept is removed after a day; every other command starts spec-brief every time ([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
176
183
|
- As a session starts, resumes, is cleared, compacted or forked, `hook claude` answers Claude Code's SessionStart with what would hold every write of the session, in one line, to the person as `systemMessage` and to Claude as `additionalContext`: a configuration that does not load, a brief the line, `SPEC_BRIEF` or the branch names that spec-brief does not list, spec-brief missing or too old where a brief is named, and what is wrong with the hook's own line. Nothing is said where all is well, and it exits 0 whatever it finds: the event cannot block, and the session's start is not to be stopped by it ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
184
|
+
- With `"turnReport": true` in `.spec-harness.json`, `hook claude` answers Claude Code's `Stop`, which it runs as its main agent finishes a turn: with one `git --no-optional-locks status`, every path the work tree holds changed, a shell's writes among them, that the brief protects or that is outside its scope under the `outOfScope` in force, in the words a write of each is given, twenty by name and how many more, as one `systemMessage`; or nothing. It exits 0 and never has Claude go on. `init` writes the entry with `"async": true`, so the turn waits on none of it and Claude Code hands the report to Claude as the next turn begins; without `async` the person sees it as the turn ends, Claude does not, and the end of the turn waits for it. No ruling is read: a protected file a signed ruling allows is reported, and the audit reads the ruling. The plugin brings no such entry; with it on, `init` says the entry to add ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md), [ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
185
|
+
- A process the hook asks a question of, git or spec-brief's list of the briefs, is stopped after 20 seconds: Claude Code cancels the hook at the 60 seconds `init` and the plugin give its entry, and before a write lets the write go ahead. At the limit the hook says `cannot check this write: spec-brief did not answer within 20 seconds, and was stopped` and exits 2, which holds the write. Every command gives a question the same time, and a round's work, a diff, a probe's worktree, a sibling's check, ten minutes ([ADR-0002](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0002-siblings-through-their-command-lines.md)).
|
|
177
186
|
- `spec-harness hook git` is a pre-commit hook for any agent or none. `init --git-hook` writes it; in a hook of your own it is the line `node node_modules/@descent-vtt/spec-harness/bin/spec-harness.js hook git`.
|
|
178
187
|
- `hook claude` passes over whatever else is on its line that it does not read, as every release has, where every other command [refuses it](#an-input-that-names-nothing): its line is in settings a later release cannot rewrite, and exit 2 from it holds every write.
|
|
179
|
-
- A `--root` on the hook's line that is a file, or is not there, is a guard that was set up and is off: `hook claude` says so
|
|
180
|
-
- A line the hook cannot read - an option no command has, an option left without its value, a `--format` or an `--at` that is none, two values for an option that takes one, `--help` beside `--version` - is said the same way: one line
|
|
188
|
+
- A `--root` on the hook's line that is a file, or is not there, is a guard that was set up and is off: `hook claude` says so in one line to the person, as `systemMessage`, and exits 0, and the write goes on. It refuses nothing for it. No release wrote a `--root` there; without one the hook reads the project Claude Code names, then the session's directory, and outside a git work tree it has nothing to guard and says nothing.
|
|
189
|
+
- A line the hook cannot read - an option no command has, an option left without its value, a `--format` or an `--at` that is none, two values for an option that takes one, `--help` beside `--version` - is said the same way: one line to the person, exit 0, and no write held for it. So is a question the hook cannot read, one that is not JSON or names no event. Exit 2 from `hook claude` is for a write it could not check, never for what is wrong with its own line; and no answer of the hook's is exit 1, which Claude Code counts as a hook that failed, so that `"onFailure": "block"` holds a write only for a hook that did not run ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)). `hook git` stops the commit on such a line, exit 2, where a person reads why.
|
|
181
190
|
|
|
182
191
|
A guard is a guardrail - an agent that writes through a shell passes it - so the audit and spec-brief's archive are the gates ([ADR-0005](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0005-a-guard-is-a-guardrail.md)).
|
|
183
192
|
|
|
@@ -367,6 +376,8 @@ Run it in CI: exit 1 when a premise is stale, exit 2 when spec-guard is not ther
|
|
|
367
376
|
|
|
368
377
|
`start_round`, `check_path`, `request_escalation`, `audit_round` and `list_rounds` over MCP on stdio, with the four workflow prompts. Both protocol eras are served. The architecture rules themselves stay with spec-guard's server.
|
|
369
378
|
|
|
379
|
+
- The server is started for the project Claude Code names. `check_path` decides an absolute path by the work tree of the same repository that holds it, as the hook decides a write, and `start_round`, `check_path`, `request_escalation` and `audit_round` read the round, its branch and its brief, in one work tree: the one a `directory` argument names; else the one the client's roots name, where they name exactly one work tree of the repository, asked with `roots/list` where the client declared roots; else the project's. Each says which as `workTree`, and in its text where it is not the project's ([ADR-0008](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0008-one-server-for-rounds.md)).
|
|
380
|
+
|
|
370
381
|
A tool answers an argument it cannot use with a tool error that names the argument, and writes nothing: one it does not take, one of the wrong type, and one that is given and [names nothing](#an-input-that-names-nothing), such as an empty `brief`.
|
|
371
382
|
|
|
372
383
|
### `init`
|
|
@@ -385,6 +396,7 @@ Configures the family to agree. It prints the plan, merges into files that exist
|
|
|
385
396
|
- when it cannot tell, it says so and writes none: set `"base"` yourself.
|
|
386
397
|
- **Claude Code**: the guard hooks in `.claude/settings.json` and the MCP server in `.mcp.json`, each run with `node` from the project's `node_modules`. The `npx` entries 0.1 wrote are replaced.
|
|
387
398
|
- Beside the hook's entries under `PreToolUse` and `PostToolUse`, one under `SessionStart`, with no matcher: every way a session starts. In a file whose two an earlier release wrote, `init --write` adds it by itself; beside a line of the hook a person wrote or changed it adds none.
|
|
399
|
+
- With `--block-on-failure`, each of its entries before and after a write and as a session starts carries `"onFailure": "block"`, and so do those an earlier run wrote (`update`); the entry at the end of a turn, which runs in the background, is left without it, since the hooks reference gives the field no effect on a `Stop` hook or on one in the background. Claude Code 2.1.295 or later then holds a write where the hook cannot start, as where the project's install is not there, or runs past its timeout, where without the field it lets the write go ahead with a notice. Claude Code's documentation does not say what a release before 2.1.295 does with a key it does not know, and the file is read by every clone's Claude Code, so the field is written only where asked for: ask for it where every Claude Code that reads the file is 2.1.295 or later. The plugin's hooks do not carry it, and a line a person wrote is theirs to give it ([ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
388
400
|
- These are the ones the [Claude Code plugin](#as-a-claude-code-plugin) brings, so while that plugin is on - `"spec-harness@<marketplace>": true` under `enabledPlugins` in your user, project or local Claude Code settings - `init` writes neither and says why (`skip`).
|
|
389
401
|
- To have its entries instead, which every clone reads, turn the Claude Code plugin off for the project, `claude plugin disable spec-harness@spec-tools --scope local`, and run `init` again.
|
|
390
402
|
- It removes nothing: where the Claude Code plugin is on and a file already holds its entry, it says so (`advise`) and leaves the file alone. So where the hook stands in a settings file of your own, which `init` does not write.
|
|
@@ -415,7 +427,7 @@ The first thing to run when a hook refuses something unexpectedly. It reports:
|
|
|
415
427
|
- In a linked worktree with no install of its own, the siblings are the main work tree's, as git's hook runs them there, and each such row says whose install it is: `(0.8.0, the install of /work/app: this work tree has none of its own)`. `--format json` has it as `elsewhere`, `null` for a sibling of the work tree's own.
|
|
416
428
|
- **The repository**: its root, the branch, and the brief the flag, `SPEC_BRIEF` or the branch names.
|
|
417
429
|
- A brief no round can work under is said on that line, with why: `brief none: the flag names brief 999, and spec-brief knows no such brief`. So is one spec-brief has archived, an empty `--brief`, and a spec-brief that could not list the briefs. The guard holds every write while it stands, which is often why `doctor` is being run.
|
|
418
|
-
-
|
|
430
|
+
- Where the branch names it, a brief spec-brief does not know or has archived, the hook holds every write on that branch, and `doctor` exits 1, as for a hook's line that holds every write: `brief none: the branch names brief 999, and spec-brief knows no such brief`. One the flag or `SPEC_BRIEF` names fails nothing: the flag is the question `doctor` was asked, and the variable `doctor` reads is its own, which need not be the one Claude Code's hook is started with. Nor does a spec-brief that could not list the briefs, which is a sibling's row to judge. A base that names no commit fails nothing either. `--format json` has the id as `brief` and the reason as `briefProblem`, `null` where there is none ([ADR-0004](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0004-the-active-brief-is-named-not-guessed.md)).
|
|
419
431
|
- **What a signed ruling needs to count**:
|
|
420
432
|
- the base, and whether `--base`, `.spec-harness.json` or the remote named it;
|
|
421
433
|
- whether the allowed-signers file is on that base;
|
|
@@ -426,11 +438,13 @@ The first thing to run when a hook refuses something unexpectedly. It reports:
|
|
|
426
438
|
- A line OpenSSH refuses is named as no signer, with why. Its quotes are read as OpenSSH reads them: in the principals, the first double quote, wherever it opens, is taken out with the next, which ends the field; an option's value is always in double quotes, `\"` a quote inside it. And its options are OpenSSH's: `cert-authority`, `namespaces`, `valid-after` and `valid-before`, separated by commas.
|
|
427
439
|
- **How Claude Code runs the guard**: the Claude Code plugin, with the settings file that turns it on; `init`'s hooks and server; both, which guards every write twice and exits 1, with how to keep one; or neither.
|
|
428
440
|
- Where a settings file guards writes and none starts the hook as a session starts, a note says so and how to add it, `spec-harness init --write`, and fails nothing. `--format json` has `claudeCode.sessionStart`.
|
|
441
|
+
- Run in a linked worktree where something wires the guard, a note says which release of spec-harness the hook's line runs, where the main checkout's install and this work tree's are not one: the line names its script under `${CLAUDE_PROJECT_DIR}`, which is this work tree in a session started in it, and the main checkout in a worktree session of the desktop app, where by [Claude Code's worktrees page](https://code.claude.com/docs/en/worktrees) Claude Code reads the hooks from the main checkout's root and points the placeholder at it. Either decides a write by the work tree that holds it, from 0.19.0 on, so the note says which release answers, and fails nothing.
|
|
429
442
|
- `"disableAllHooks": true` in a settings file switches the guard off: by [Claude Code's settings reference](https://code.claude.com/docs/en/settings-reference) it turns off the hooks of the user's, the project's and the local settings and of plugins. `doctor` reads the key from the three files as Claude Code merges them, the last that sets it deciding, names the file that holds it, and exits 1 where there are guard hooks for it to switch off. Where nothing is wired it is a note. Hooks of managed settings, and of a plugin managed settings force on, keep running; `doctor` reads no managed settings and no `--settings`.
|
|
430
443
|
- A hook in Claude Code's settings is the guard by its command, `spec-harness` or its script, and the words `hook claude`, whatever else is on its line. `doctor` reads the line as the hook reads it, through the same code, with the project in place of `${CLAUDE_PROJECT_DIR}`, and says what the hook does with it.
|
|
431
444
|
- Only an entry Claude Code runs as a command is a line of the hook, `"type": "command"`. An entry of another handler type (`http`, `mcp_tool`, `prompt`, `agent`) runs no command, whatever it holds, and is not reported. One with no `type`, or with a word the hooks reference does not list, is *cannot tell*, never fine: the reference requires the field and says nothing of an entry without it; `--strict` fails it.
|
|
432
445
|
- A line that holds more than `init` writes, such as `--root ${CLAUDE_PROJECT_DIR}` or `--brief 012`, is said as it is and fails nothing: `"hook claude --root ${CLAUDE_PROJECT_DIR}" in .claude/settings.json is more than init writes, and guards: the hook reads the line, and its root, /work/app, is a directory`.
|
|
433
446
|
- A line the hook cannot read, and a `--root` that is a file or is not there, are a guard that is off. Each is said in the words the hook itself says before a write, and exits 1.
|
|
447
|
+
- A line that asks for the help or the version, with `--help`, `--version`, `-h` or `-v`, is a guard that is off as well. The hook prints the help or the version, exit 0, in place of reading its question, and [Claude Code's hooks reference](https://code.claude.com/docs/en/hooks) has what a hook that exits 0 prints go to the debug log: no write is checked, and nothing says so. `doctor` says it and exits 1, whatever else is on the line: `"hook claude --help" in .claude/settings.json: the line asks for the help, which the hook prints, exit 0, in place of checking the write, so the guard is off and no write is checked`. Beside a `--root` that is a file or is not there, it is a line the hook cannot read, which the hook says before a write as it says the root without either.
|
|
434
448
|
- A `--root` that is a directory outside any git work tree is a guard that is off as well, and the one fault the hook says nothing of: it reads a session outside a work tree there, checks no write, and exits 0. `doctor` asks git about the root as the hook does, says so, and exits 1: `"hook claude --root /elsewhere" in .claude/settings.json: --root is "/elsewhere", a directory outside any git work tree, which the hook reads as a session outside one, exit 0 and no word, so the guard is off and no write is checked`.
|
|
435
449
|
- A `--root` in another git work tree than the project's is read by where that work tree is. The hook opens the work tree its root is in and decides by that work tree's briefs, and a file outside it is none of its repository's, which the hook passes with no word. So where that work tree does not hold the project - another repository beside it, or one inside it: a repository of its own, a submodule, a linked worktree - no write to a file of the project is checked. The guard is off, and `doctor` exits 1: `"hook claude --root ../other" in .claude/settings.json: --root is "../other", a directory in /work/other, the work tree of another repository, which does not hold this project: the hook checks a write to a file of that work tree, by its briefs, and passes any other with no word, exit 0, so the guard is off and no write to a file of this project is checked`. Where the work tree holds the project, as a repository the project is nested in does, or the main work tree around a linked one, a write here is checked, by that work tree's briefs and its branch and under the path the file has there: `doctor` says whose briefs they are and fails nothing. A work tree of the project's own repository, linked or main, is named `another work tree of this repository`, and is read by the same rule: a linked worktree beside the project holds none of its files.
|
|
436
450
|
- A line that names a brief which is not one, as `--brief 404` does where spec-brief knows no brief 404 or has archived it, holds every write: the hook exits 2 before each until the line is mended. `doctor` asks spec-brief about the name as the hook does, in the work tree the line's root is in, says it in the words the hook holds the write with, and exits 1: `"hook claude --brief 404" in .claude/settings.json: the flag names brief 404, and spec-brief knows no such brief, so the hook holds every write until the line is mended: name a brief spec-brief lists, or take --brief off the line`.
|
|
@@ -443,7 +457,7 @@ The first thing to run when a hook refuses something unexpectedly. It reports:
|
|
|
443
457
|
- A matcher of names with a hyphen in one, `Edit|Write|my-tool`, is read as the Claude Code on `PATH` reads it too. By [Claude Code's changelog](https://code.claude.com/docs/en/changelog), 2.1.195, such a matcher matched as a substring before that release and exactly from it on; the changelog does not say how the rest of it was read, the names it lists exactly, the matcher as a pattern, under which `Edit` is in `NotebookEdit` too, or its whole text, which is in no tool's name. So under 2.1.139 to 2.1.194, and where the release cannot be told, which writes the line is started for is *cannot tell* wherever those readings differ, never fine; `--strict` fails it: `(under PreToolUse it has the matcher "Edit|Write|my-tool", which Claude Code 2.1.194 may read otherwise: before 2.1.195 a matcher with a hyphenated name in it matched as a substring, and Claude Code's changelog does not say how the rest of it was read; from 2.1.195 on it is Edit and Write)`. A matcher whose readings all come to no tool that writes, `Bash|my-tool`, is no guard under any release, and nothing is said of the release.
|
|
444
458
|
- A matcher that is an array, `["Edit", "Write"]`, is by the same page an entry Claude Code lists as an invalid setting, and no hook under it is started. Where one stands under `PreToolUse` or `PermissionRequest`, in an entry of the hook's or of any other program's, Claude Code loads none of that settings file's other hooks either. `doctor` says so of every line of the hook the file holds, and a line that stood to be started for a write is a guard that is off, exit 1: `"hook claude" in .claude/settings.json: .claude/settings.json has an array for a matcher under PreToolUse, ["Bash"], which Claude Code lists as an invalid setting, and beside one under PreToolUse or PermissionRequest it loads none of the file's other hooks, so the guard is off and no write is checked`. The hooks of another settings file are read as that file has them. Where such an array stands in the project's `.claude/settings.json`, the file `init` writes its hooks into, `doctor`'s advice is the array's first, since `init` writes no hook there while it stands, and then `init --write`. `--format json` has the array as `claudeCode.unloaded`, `null` where there is none.
|
|
445
459
|
- A line with no `args` is one Claude Code hands to a shell. Where it holds a quote, a variable or anything else a shell rewrites after its command, what the hook is handed is *cannot tell*, never fine; `--strict` fails it. Written with `args`, each word reaches the hook as it stands, and `doctor` reads it.
|
|
446
|
-
- `"onFailure": "block"` on the hook's entry is said in a note. Claude Code 2.1.295 or later then holds a write when the hook fails, where without the field the write goes ahead: by
|
|
460
|
+
- `"onFailure": "block"` on the hook's entry is said in a note. Claude Code 2.1.295 or later then holds a write when the hook fails, where without the field the write goes ahead: by a hook that does not start, or by one that runs past its timeout. The hook says each of its own answers with exit 0 or 2, a line that turns the guard off among them, so the field holds no write for those. Where the Claude Code on `PATH` is 2.1.295 or later and a line that guards sets no `onFailure`, a note advises it, with `init --write --block-on-failure` for `init`'s own entries, and fails nothing: every Claude Code that reads the file has to be one that reads the field.
|
|
447
461
|
- `--format json` has each line under `claudeCode.lines`: its `file`, `events`, the `line` as written, its `state` (`guards`, `off`, `held`, `unstarted` or `unknown`), `onFailure`, the writing tools Claude Code waits on it `before` a write by and starts it `after` one by, of `Edit`, `Write` and `NotebookEdit` (`null` where that cannot be told), and what is said of it as `detail`, `cover` and `note`, `null` where there is nothing to say. Beside the lines, `claudeCode.presence` is whether the plugin is on this machine, `null` where no plugin is on and otherwise its `state` (`present`, `absent` or `unknown`) with the reason as `detail`; `claudeCode.hooksOff` is the settings file whose `disableAllHooks` is `true`, or `null`; and `claudeCode.notes` holds what is said of the two.
|
|
448
462
|
- The plugin's own hooks are not read: they are a release's files, and every release wrote `hook claude` and no more on the line, under the matcher `init` writes. What is read is whether the plugin that settings turn on is on this machine, by [Claude Code's plugin loading reference](https://code.claude.com/docs/en/plugins/loading), from the directories Claude Code keeps plugins in: `plugins` in its configuration directory, or what `CLAUDE_CODE_PLUGIN_CACHE_DIR` names, and each directory `CLAUDE_CODE_PLUGIN_SEED_DIR` names.
|
|
449
463
|
- *On the machine*: a version of it is in a cache, `cache/<marketplace>/spec-harness/<version>/`, which no `.orphaned_at` marks as left behind. Nothing more is said.
|
|
@@ -458,8 +472,8 @@ The first thing to run when a hook refuses something unexpectedly. It reports:
|
|
|
458
472
|
- A hook that runs it through `npx` is one that runs it. A note names the line that runs it with `node`: `npx` starts npm to start node on every commit, and under npm 12 prints two `npm notice run` lines each time. A note, never a failure; `--format json` has it as `gitHook.note`.
|
|
459
473
|
- What stands at the hook's path and is no file is no hook, and git takes it for one all the same. A directory there, which a repository whose `core.hooksPath` is in its work tree can hold, is one git tries to run where it may execute it, which on Windows is always: it cannot, and stops every commit, with `cannot spawn` on Windows and `cannot exec` elsewhere. `doctor` says the path, what it is and what git does with it, and exits 1, since nothing is checked there and nothing is committed: `.git/hooks/pre-commit is a directory, not a hook, and git stops every commit at it`. Where git may not execute it, it skips it as it skips a hook that is not executable: that is said, and fails nothing. `--format json` has the two as the `gitHook.state` `stops` and `ignored`. Only a file is read, so `doctor` and `init` come back from a named pipe there as well.
|
|
460
474
|
- A hook file the account may not read is said with what git does with it, where `doctor` and `init` ended on a stack. Where git may not execute it either, it skips it with a hint and commits: said, and nothing fails. Where it may, git runs it, and a script the shell cannot read stops every commit, where a program runs unread: whether it runs spec-harness is *cannot tell*, never fine; `--strict` fails it. `--format json` has the `gitHook.state` `unreadable`.
|
|
461
|
-
- A `core.hooksPath` that names a file is one git names no hook under: it says `Invalid path ...: Not a directory`, and commits with no hook. `doctor` says that where git runs its hooks cannot be told, in git's own words, where it gave the reason it has for a git older than 2.31.
|
|
462
|
-
- **What stands where a file is read.** A settings file, `.mcp.json` or a record of Claude Code's plugins that is neither a file nor a directory, such as a named pipe, is read as one that cannot be read as JSON, as a directory is: a pipe nothing writes to was read without end, and neither `doctor` nor `init` came back. `.spec-harness.json` that is neither stops every command, the hook among them, with `.spec-harness.json is neither a file nor a directory, not a configuration file`, exit 2, as one that is a directory does.
|
|
475
|
+
- A `core.hooksPath` that names a file is one git names no hook under: it says `Invalid path ...: Not a directory`, and commits with no hook. `doctor` says that where git runs its hooks cannot be told, in git's own words, where it gave the reason it has for a git older than 2.31. That is *cannot tell*, never fine; `--strict` fails it, where it failed nothing.
|
|
476
|
+
- **What stands where a file is read.** A settings file, `.mcp.json` or a record of Claude Code's plugins that is neither a file nor a directory, such as a named pipe, is read as one that cannot be read as JSON, as a directory is: a pipe nothing writes to was read without end, and neither `doctor` nor `init` came back. `.spec-harness.json` that is neither stops every command, the hook among them, with `.spec-harness.json is neither a file nor a directory, not a configuration file`, exit 2, as one that is a directory does. One that cannot be read, which the account may not read or another process holds open on Windows, is said as that, with the reason: `.spec-harness.json cannot be read: EACCES: permission denied, open ...`, exit 2, where it was said to be JSON that is not valid. Every other file the harness reads is read only where it is a file, and what else stands there as a file that is not there: a document a brief cites, a sibling's `package.json`, what the run before a write kept, git's configuration and a worktree's `commondir` as the hook reads them, a request waiting for a ruling, and a probe's report, said as `neither a file nor a directory`.
|
|
463
477
|
|
|
464
478
|
### An input that names nothing
|
|
465
479
|
|
|
@@ -475,7 +489,7 @@ An option, an argument or a value that is given and names nothing is refused: ex
|
|
|
475
489
|
| `premises` | `--brief`, `--root`, `--format`, `--strict` |
|
|
476
490
|
| `escalate` | `--brief`, `--root`, `--format`, `--path`, `--reason`, `--option`, `--recommend`, `--list`, `--show` |
|
|
477
491
|
| `rule` | `--root`, `--format`, `--allow`, `--deny`, `--note` |
|
|
478
|
-
| `init` | `--root`, `--format`, `--write`, `--git-hook` |
|
|
492
|
+
| `init` | `--root`, `--format`, `--write`, `--git-hook`, `--block-on-failure` |
|
|
479
493
|
| `hook` | `--brief`, `--base`, `--root` |
|
|
480
494
|
| `mcp` | `--root` |
|
|
481
495
|
|
|
@@ -485,19 +499,19 @@ An option, an argument or a value that is given and names nothing is refused: ex
|
|
|
485
499
|
- **An argument a command does not take.** `context`, `rulings`, `audit` and `probe` take one brief's id at most, `rule` one escalation's id, `guard` its paths and `hook` the word `claude` or `git`; `escalate`, `premises`, `init`, `mcp` and `doctor` take none. `init mydir` set up the directory it stood in; `init --root mydir` sets up another.
|
|
486
500
|
- **A value that names nothing.** An option that takes a value refuses one that is empty or only space, by the option's name: `--brief is "", which names no brief`. So does an argument, as in `guard ""`. No option gives an empty value a meaning: leave the option out for what the command does without it.
|
|
487
501
|
- **A `--root` that is no directory**, a file or a path that is not there: `--root is "nowhere", which is not a directory`.
|
|
488
|
-
- **An option that takes one value, given two.** `doctor --root nowhere --root .` ran in `.`, and `--brief 404 --brief 001` was brief 001: the parser kept the last, and the earlier went unread with no word. It is `--root is given twice, as "nowhere" and as ".", and one of the two would go unread; give it one`. Two values are compared as the option reads them, so the same thing given twice is the option once: `--root .` beside `--root ./`, a directory however it is spelt from where the command is started, and `--brief 12` beside `--brief 012`, a brief by its id as spec-brief's names are matched. A base, a format, an id and text are compared as written. `--path` and `--option` are lists, and each use adds to the list.
|
|
502
|
+
- **An option that takes one value, given two.** `doctor --root nowhere --root .` ran in `.`, and `--brief 404 --brief 001` was brief 001: the parser kept the last, and the earlier went unread with no word. It is `--root is given twice, as "nowhere" and as ".", and one of the two would go unread; give it one`. Two values are compared as the option reads them, so the same thing given twice is the option once: `--root .` beside `--root ./`, a directory however it is spelt from where the command is started, a drive letter on Windows in either case (`--root C:\work` beside `--root c:\work`, which [spec-core's ADR-0005](https://github.com/DescentVTT/spec-core/blob/main/docs/adr/0005-the-family-contract.md) has every tool read as one: Windows names a volume by its letter in either case), and `--brief 12` beside `--brief 012`, a brief by its id as spec-brief's names are matched. A base, a format, an id and text are compared as written. `--path` and `--option` are lists, and each use adds to the list.
|
|
489
503
|
- **A `.spec-harness.json` that is a directory** does not load, and is said so in a line, as one that is not JSON is.
|
|
490
504
|
|
|
491
505
|
A line that is wrong is refused with `--help` or `--version` on it, each of the above and a command that is none, as an option no command has always was: `doctor --help --root a --root b` printed the help, exit 0. `--help` beside `--version` asks for two answers, of which one would go unread, and is refused: `--help is given beside --version, and one of the two answers would go unread; give one of them`. On a line that is right, either answers, a command that needs more than the line gives it among them, as `guard --help` does. Three things are read another way, each for its reason:
|
|
492
506
|
|
|
493
507
|
- **`hook claude` reads its line as every release has.** The line is in `.claude/settings.json` and in the Claude Code plugin of every release since 0.1.0, which a later release cannot rewrite, and exit 2 from it holds every write of a session, the one that would mend the line among them. So what it does not read is passed over as before, an empty `--brief` with the rest. The releases have handed the harness five command lines, `hook claude`, `hook git`, `mcp`, and `mcp --root` with the project or with `.`, and each is read as the release that wrote it read it ([ADR-0012](https://github.com/DescentVTT/spec-harness/blob/main/docs/adr/0012-one-way-into-claude-code.md)).
|
|
494
508
|
|
|
495
|
-
Two things on its line are said, and still refuse nothing. Each is one line
|
|
509
|
+
Two things on its line are said, and still refuse nothing. Each is one line to the person, as `systemMessage`, and exit 0, said where there is a write the line leaves unchecked: Claude Code goes on with the write. It was exit 1, which Claude Code counts as a hook that failed, and under `"onFailure": "block"` that held every write of the session. No release wrote more than `hook claude` on the hook's line, so either is a line a person changed.
|
|
496
510
|
|
|
497
511
|
- **A `--root` that is a file, or is not there.** It read as a session outside a git work tree, exit 0 and no word, and the guard was off. It is `--root is "nowhere", which is not a directory, so the guard is off and this write is not checked`, with what to do. An empty `--root` is the directory the hook was started in, and guards there, as before.
|
|
498
|
-
- **A line the parser cannot read**: an option no command has, as in `hook claude --nope`; an option left without its value, as `--root $DIR` is in a shell where the variable is not set; a `--format` or an `--at` that is none; two values for an option that takes one, whichever option it is, as in `hook claude --brief 001 --brief 404`, with `--help` beside them or not; `--help` beside `--version
|
|
512
|
+
- **A line the parser cannot read**: an option no command has, as in `hook claude --nope`; an option left without its value, as `--root $DIR` is in a shell where the variable is not set; a `--format` or an `--at` that is none; two values for an option that takes one, whichever option it is, as in `hook claude --brief 001 --brief 404`, with `--help` beside them or not; `--help` beside `--version`; and `--help` or `--version` beside a `--root` that is a file or is not there, which the hook said only as it ran, and printed the help over, exit 0. Each was exit 2, as it is from every other command, and Claude Code blocks the tool call on a PreToolUse hook's exit 2: every write of the session waited on a line only a write can mend. It is `the hook's line cannot be read (Option '--root <value>' argument missing), so the guard is off and this write is not checked`, with what to do. The parser's own words stand between the brackets, on one line.
|
|
499
513
|
|
|
500
|
-
Exit 2 from `hook claude` is kept for a write it could not check: a configuration that does not load, briefs that cannot be read, a brief that is named and is not one, an error nothing expected. `hook git` is not read this way. It stops one commit, exit 2, on a line a person reads, who can then mend the hook. Nor is a line that does not say `hook claude`, such as `hook` alone: the harness cannot tell whose it is. A hook entry that sets `"onFailure": "block"`, which Claude Code 2.1.295 and later read, has Claude Code hold the action when the hook fails,
|
|
514
|
+
Exit 2 from `hook claude` is kept for a write it could not check: a configuration that does not load, briefs that cannot be read, a brief that is named and is not one, an error nothing expected. `hook git` is not read this way. It stops one commit, exit 2, on a line a person reads, who can then mend the hook. Nor is a line that does not say `hook claude`, such as `hook` alone: the harness cannot tell whose it is. A hook entry that sets `"onFailure": "block"`, which Claude Code 2.1.295 and later read, has Claude Code hold the action when the hook fails: when it cannot start, runs past its timeout, or exits with a code other than 0 and 2, which no answer of the hook's is. `init --block-on-failure` writes the field; the plugin does not. [`doctor`](#doctor) says each of these of a line it finds in Claude Code's settings, before any write meets it.
|
|
501
515
|
- **`doctor` says an empty `--brief` or `--base` in its report**, as it says a brief spec-brief does not know: a diagnosis is what a person runs when something is wrong, and it reports what is wrong with what it was given.
|
|
502
516
|
- **`SPEC_BRIEF` set and empty is as unset**, since what sets it sets it whether or not there is a round ([Which brief](#which-brief)).
|
|
503
517
|
|
|
@@ -571,6 +585,7 @@ A person who runs the tools by hand runs `npx --no-install @descent-vtt/spec-har
|
|
|
571
585
|
| `assertions.premises` | `The Defect, Measured`, `Premises`, `Preconditions` | Sections whose assertions state what was true before the round. |
|
|
572
586
|
| `probes.runs`, `probes.timeout` | `2`, `600` | Runs per probe, and seconds per run. |
|
|
573
587
|
| `tools` | found in `node_modules` | A sibling's command by name: `{ "spec-brief": ["node", "path/to/spec-brief.js"] }`. |
|
|
588
|
+
| `turnReport` | `false` | `true`: as each of Claude Code's turns ends, the hook reports every changed path the brief protects or that is outside its scope, to Claude as the next turn begins ([`guard` and the hooks](#guard-path-and-the-hooks)). `init` writes the entry that runs it where it is on. |
|
|
574
589
|
|
|
575
590
|
**Exit codes:**
|
|
576
591
|
|
package/dist/briefs.d.ts
CHANGED
|
@@ -19,6 +19,51 @@ export declare class SiblingOutputError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
/** Reads the document `spec-brief list --format json` prints. */
|
|
21
21
|
export declare function parseBriefList(document: unknown): BriefRow[];
|
|
22
|
+
/**
|
|
23
|
+
* A file a `list` answer was read from, by the SHA-256 of its bytes in hex;
|
|
24
|
+
* or `null` where spec-brief looked for it and found none, which is then to
|
|
25
|
+
* be found none again.
|
|
26
|
+
*/
|
|
27
|
+
export interface InputFile {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly sha256: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A directory whose files a `list` answer was read from, by their names:
|
|
33
|
+
* entries that are files, as spec-brief lists them; or `null` where
|
|
34
|
+
* spec-brief looked for the directory and found none, which is then to be
|
|
35
|
+
* found none again.
|
|
36
|
+
*/
|
|
37
|
+
export interface InputDirectory {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly entries: readonly string[] | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Everything a `list` answer was read from, as spec-brief lists it: its
|
|
43
|
+
* version, the files and directories it read, and what git read for it, the
|
|
44
|
+
* index and the ignore files, or `null` where it asked git nothing. A path
|
|
45
|
+
* is relative to the work tree and POSIX, or absolute where git names a
|
|
46
|
+
* file outside it (spec-core ADR-0005, amended 2026-10-19).
|
|
47
|
+
*/
|
|
48
|
+
export interface BriefInputs {
|
|
49
|
+
readonly tool: string;
|
|
50
|
+
readonly files: readonly InputFile[];
|
|
51
|
+
readonly directories: readonly InputDirectory[];
|
|
52
|
+
readonly git: {
|
|
53
|
+
readonly index: string | null;
|
|
54
|
+
readonly ignores: readonly InputFile[];
|
|
55
|
+
} | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* What a `list` document says its answer was read from, where it may be
|
|
59
|
+
* given again; `null` where it lists nothing, where `keep` is anything but
|
|
60
|
+
* `true`, where it names nothing, and where anything on it is in a form not
|
|
61
|
+
* read here. Each is a doubt, and a doubt starts spec-brief as before
|
|
62
|
+
* (ADR-0002). The rows are `parseBriefList`'s to read, whatever this
|
|
63
|
+
* answers: a list this cannot read keeps an answer from being given again,
|
|
64
|
+
* and changes nothing of it.
|
|
65
|
+
*/
|
|
66
|
+
export declare function inputsOf(document: unknown): BriefInputs | null;
|
|
22
67
|
/**
|
|
23
68
|
* How the active brief was named, for messages. An argument is the id a
|
|
24
69
|
* command takes after its name, or a tool call's `brief`: said to be the
|
package/dist/briefs.js
CHANGED
|
@@ -83,6 +83,79 @@ export function parseBriefList(document) {
|
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
+
const DIGEST = /^[0-9a-f]{64}$/;
|
|
87
|
+
function inputPath(value) {
|
|
88
|
+
return typeof value === 'string' && value !== '';
|
|
89
|
+
}
|
|
90
|
+
function digestOf(value) {
|
|
91
|
+
return value === null || (typeof value === 'string' && DIGEST.test(value)) ? value : undefined;
|
|
92
|
+
}
|
|
93
|
+
function inputFiles(value) {
|
|
94
|
+
if (!Array.isArray(value))
|
|
95
|
+
return null;
|
|
96
|
+
const files = [];
|
|
97
|
+
for (const item of value) {
|
|
98
|
+
if (!isObject(item) || !inputPath(item['path']))
|
|
99
|
+
return null;
|
|
100
|
+
const sha256 = digestOf(item['sha256']);
|
|
101
|
+
if (sha256 === undefined)
|
|
102
|
+
return null;
|
|
103
|
+
files.push({ path: item['path'], sha256 });
|
|
104
|
+
}
|
|
105
|
+
return files;
|
|
106
|
+
}
|
|
107
|
+
function inputDirectories(value) {
|
|
108
|
+
if (!Array.isArray(value))
|
|
109
|
+
return null;
|
|
110
|
+
const directories = [];
|
|
111
|
+
for (const item of value) {
|
|
112
|
+
if (!isObject(item) || !inputPath(item['path']))
|
|
113
|
+
return null;
|
|
114
|
+
const entries = item['entries'];
|
|
115
|
+
// A name listed twice is a list that is not of one directory's files.
|
|
116
|
+
if (entries !== null && (!Array.isArray(entries) || !entries.every((entry) => typeof entry === 'string') || new Set(entries).size !== entries.length))
|
|
117
|
+
return null;
|
|
118
|
+
directories.push({ path: item['path'], entries });
|
|
119
|
+
}
|
|
120
|
+
return directories;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* What a `list` document says its answer was read from, where it may be
|
|
124
|
+
* given again; `null` where it lists nothing, where `keep` is anything but
|
|
125
|
+
* `true`, where it names nothing, and where anything on it is in a form not
|
|
126
|
+
* read here. Each is a doubt, and a doubt starts spec-brief as before
|
|
127
|
+
* (ADR-0002). The rows are `parseBriefList`'s to read, whatever this
|
|
128
|
+
* answers: a list this cannot read keeps an answer from being given again,
|
|
129
|
+
* and changes nothing of it.
|
|
130
|
+
*/
|
|
131
|
+
export function inputsOf(document) {
|
|
132
|
+
if (!isObject(document))
|
|
133
|
+
return null;
|
|
134
|
+
const inputs = document['inputs'];
|
|
135
|
+
if (!isObject(inputs) || inputs['keep'] !== true || typeof inputs['tool'] !== 'string')
|
|
136
|
+
return null;
|
|
137
|
+
const files = inputFiles(inputs['files']);
|
|
138
|
+
const directories = inputDirectories(inputs['directories']);
|
|
139
|
+
const git = inputs['git'];
|
|
140
|
+
let asked;
|
|
141
|
+
if (git === null) {
|
|
142
|
+
asked = null;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (!isObject(git))
|
|
146
|
+
return null;
|
|
147
|
+
const index = digestOf(git['index']);
|
|
148
|
+
const ignores = inputFiles(git['ignores']);
|
|
149
|
+
if (index === undefined || ignores === null)
|
|
150
|
+
return null;
|
|
151
|
+
asked = { index, ignores };
|
|
152
|
+
}
|
|
153
|
+
// A list that names nothing is an answer that cannot be told from one that
|
|
154
|
+
// was read from nowhere.
|
|
155
|
+
if (files === null || directories === null || files.length + directories.length === 0)
|
|
156
|
+
return null;
|
|
157
|
+
return { tool: inputs['tool'], files, directories, git: asked };
|
|
158
|
+
}
|
|
86
159
|
/**
|
|
87
160
|
* The brief a round is working on: named by an argument, by a flag, by
|
|
88
161
|
* `SPEC_BRIEF`, or by the branch - never guessed from which brief happens to
|