Skip to content

feat(aidd-pm): refuse a write to a locked spec before it happens - #1343

Merged
blafourcade merged 23 commits into
nextfrom
feat/spec-lock-guard
Nov 25, 2026
Merged

blafourcade merged 23 commits into
nextfrom
feat/spec-lock-guard

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

A spec whose status is locked was protected only by the skill's instruction, and a small model rewrote one through its file-edit tool (Kilo, free nemotron, trial on #1338). This adds a deterministic guard: before a write, spec-lock.cjs refuses it when the spec already on disk declares status: locked.

Refs #1342: the guard does nothing until the CLI adapters report the moment before a tool and can deny. Stacked on #1338, which introduces the spec's status.

🛠️ How it works

  • plugins/aidd-pm/hooks/spec-lock.cjs reads readEvent().files and refuses through refuse(reason) when any file is a spec under aidd_docs/tasks/ whose front matter holds status: locked (quoted or not, CRLF too).
  • It reads the file already on disk, never the content being written, so a draft is never blocked.
  • hooks.json registers it under PreToolUse with no matcher: each host names its write tools differently, and the adapters give files: [] for any other tool.
  • docs/ARCHITECTURE.md gains level 3, Refuse, and the moment Before the write. "No level stops a write" becomes: a refusal never judges the content being written. Rule 2 lists refuse(reason) in the neutral interface.

🧪 How to verify

  • node scripts/check-tests-leave-git-alone.js -- node --test scripts/__tests__/spec-lock-hook.test.js: 6 pass, against a stand-in adapter speaking the shape agreed in feat(cli): let a plugin hook refuse a file write on every host #1342.
  • Mutations, each alone: front matter not required, its closing --- ignored, the locked match removed, the path filter widened, the refusal made unconditional, only the first file checked. Each turns at least one test red.
  • Hook, contract and generation suites: 400 pass, 0 fail. check-architecture-rules.js passes; catalogs regenerated (3 → 4 hooks).

⚠️ Heads-up

  • Inert until feat(cli): let a plugin hook refuse a file write on every host #1342 ships: no host runs it yet. No real-host trial is possible before then.
  • A shell command is let through. What it writes is unknown before it runs, and refusing every command naming a locked spec would refuse reading it too. The rewrite observed went through a file tool.
  • With no matcher, Claude Code spawns the hook on every tool call (about 50 ms of Node each).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS

blafourcade and others added 13 commits November 24, 2026 19:25
…nd check the spec it writes

The router keeps only its diagram and transversal rules, each action step is one
sentence, and build and refine run validate-spec.cjs on the spec they write.
SPEC-01 holds spec.md to its template; the aidd-pm turn-end hook applies it too.
The weighted spec-validator.yml, read by no file, is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
… respects

A spec now carries status: draft or locked in its front matter, and SPEC-01
refuses any other value. Refine reads it first and writes nothing on a locked
spec; only the person who approves a spec locks it. Build maps a PRD's headings
to the spec's sections and takes a hard constraint only from its Dependencies.
The vague "few acceptance criteria" rule is dropped, and the argument hint names
the findings refine needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
…ailure case

A locked spec must have no open question left, checked by SPEC-02. Build
asks at most three questions on the gaps that change the target most,
and goes on with the gaps when no user can answer. Every hard constraint
is proven by a Done-when condition, Done-when covers a refused or failed
case, and a request holding several outcomes keeps one and lists the
others as Non-goals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
A spec whose status is locked was protected by the skill's instruction only,
and a small model rewrote one. spec-lock.cjs runs before a write and refuses
it when the file already on disk declares status: locked. It reads the file,
never the content being written, so a draft is never blocked.

ARCHITECTURE.md gains a third level, Refuse, and the refuse(reason) entry of
the neutral host interface. Until the adapters report the moment before a
tool, the hook does nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
…g the files written

Each host names its write tools differently; a Claude-named matcher missed
Copilot's create and every Antigravity write. A call writing several files is
refused when any one is a locked spec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
Adds the session start, prompt and session end moments, and folds the
placement prose into the level and moment rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RY5w5YEbGF6DpKkbU9uyJS
…ne content reference

The description names both modes, build writes the spec first and asks its open
questions after, and the per-section judgment moves to references/spec-content.md,
replacing the TBD marker reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A model wrote the empty marker as a bullet, `- None`, which a locked spec then
failed on. Omitting the section leaves nothing to spell. A refine now answers
with each changed line as a diff and names any other section that breaks the
content reference, without changing it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A refine trial added a bare question to Open Questions and the contract let it
through, since the template checks headings, not lines. SPEC-03 holds every line
of that section to `- TBD: <question>`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An SDLC trial on a small model wrote `node --test` passes as a Done-when
condition. SPEC-04 refuses a test runner or a tests-pass phrase there: the plan
and the assert step own how a condition is checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
A list of test runners can never be complete. The contract checks only a spec's
shape; whether Done-when names a command stays a judgment in spec-content.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
blafourcade and others added 9 commits November 25, 2026 12:15
…answer template

Build no longer maps a PRD's headings: spec-content.md says what each section
holds, whatever the source calls it. Refine fills assets/refine-answer.md, a diff
of the changed lines. The gap definition moves into the Open Questions row, and
the locked-spec sentence goes, since SPEC-02 checks it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
docs/ARCHITECTURE.md § Hooks keeps the table form and folds in next's facts:
aidd-telemetry under the contract, its event.raw and detached-ingest
exceptions, the person channel per host, a silent level 0 and an inert level 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
… one

The skill no longer tells a request from a document, or review findings from
answers: build reads the need wherever it is written, and refine applies the
changes it is given.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
Build asks only when no outcome can be named, and writes to the first folder
that exists in an ordered list. Refine stops before writing when no change
applies, and its answer template carries the open questions the transversal
rule asks for. The template's title slot holds one name, and a non-goal is
decided, while an undecided item is a gap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
Both trial models refused to rewrite a locked spec, then offered to flip its
status on confirmation. The rule now forbids changing that status or offering
to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeK3mDBqVCeeSgD36xKnAf
Base automatically changed from refactor/spec-skill-format to next November 25, 2026 15:04
@blafourcade
blafourcade marked this pull request as ready for review November 25, 2026 15:04
@blafourcade
blafourcade requested a review from a team as a code owner November 25, 2026 15:04
@blafourcade
blafourcade merged commit b7a28bb into next Nov 25, 2026
38 checks passed
@blafourcade
blafourcade deleted the feat/spec-lock-guard branch November 25, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant