Skip to content

feat: self-checking /work — spec-diff verifier + scope-bound allowlist (#2) - #3

Merged
juliushamm merged 1 commit into
mainfrom
juliushamm/loom-2-self-checking-work
Apr 25, 2026
Merged

juliushamm merged 1 commit into
mainfrom
juliushamm/loom-2-self-checking-work

Conversation

@juliushamm

Copy link
Copy Markdown
Owner

Summary

Implements issue #2: adds a default balanced+self-checking profile that replaces the human dispatch-review gate with two automated safeguards.

  • §4.5 scope-arm — loom scope-arm <ISSUE> parses the Linear issue's ## Scope section (or **Files:** callout, or fenced ```files block) into a fire-scoped allowlist at ~/.loom/fires/<ISSUE>/scope.json. Tier 1 hooks honor the allowlist: in-scope writes don't prompt, out-of-scope writes block with `scope-exceeded:`, and `bashAllow`-matching commands are pre-approved.
  • §5.5 diff-verify — loom diff-verify <ISSUE> walks git diff --name-only main...HEAD against scope.json plus hardcoded collateral rules (README in same workspace, barrel index.ts, mirrored test files). Out-of-scope files exit 6 with the offending list; feature branch persists for human triage.

The legacy dispatch-review gate stays available behind pipeline.profile = paranoid. Global Tier 1 blocklist is unchanged — scope-allow only opens a window inside it (e.g. an in-scope CLAUDE.md is still blocked by the global rule).

Profile split

Profile Dispatch gate Scope-arm + diff-verify
balanced+self-checking (new default for self-checking flow) off on
paranoid on off
balanced+paranoid-step-3 (legacy default) on off
balanced off off
aggressive off off

New files

  • packages/cli/src/spec-scope.ts — extractScope() parser (217 LOC)
  • packages/cli/src/commands/scope-arm.ts — writes scope.json (63 LOC)
  • packages/cli/src/commands/scope-disarm.ts — deletes scope.json (43 LOC)
  • packages/cli/src/commands/diff-verify.ts — diff walker + collateral rules (206 LOC)
  • packages/cli/tests/spec-scope.test.ts — 12 parser tests (157 LOC)
  • packages/cli/tests/commands.scope.test.ts — 20 scope-arm/disarm/diff-verify tests (282 LOC)

Modified files

  • packages/cli/src/hooks/predicates.ts — checkPath and checkBash now read scope.json (testable seam: scopeDir arg). New helpers: readActiveScope, matchesGlob. Global blocklist still wins above scope-allow.
  • packages/cli/src/config/load.ts — adds 'balanced+self-checking' to the LoomProfile union and DEFAULT_BASH_ALLOW constant.
  • packages/cli/src/runtime-config.ts — same addition to ProfileName + PROFILES map (dispatch off, merge on).
  • packages/cli/src/clients/git-cli.ts + src/probe.ts — adds diffNamesAgainstMain() to the GitClient interface.
  • packages/cli/src/clients/linear-api.ts — adds getIssueDescription(issueId) to the ExtendedLinearClient.
  • packages/cli/bin/loom.ts — wires scope-arm, scope-disarm, diff-verify subcommands. New exit code 6 for scope-exceeded.
  • packages/cli/src/commands/index.ts + src/index.ts — exports.
  • packages/cli/tests/{hooks,commands,probe,runtime-config,preflight.integration}.test.ts — mocks updated for the new GitClient method + new profile; 22 new scope-aware test cases in hooks.test.ts.
  • skills/work/SKILL.md — §4 dispatch-review gated behind paranoid; new §4.5 scope-arm + §5.5 diff-verify; §7 cleanup runs scope-disarm.
  • docs/dispatch-gate.md — rewritten around the profile matrix.
  • README.md — flow ASCII updated; CLI reference table updated.

Acceptance (per issue #2)

  • loom scope-arm <ISSUE> writes the fire marker; loom scope-disarm cleans it up (verified by smoke run + 8 unit tests).
  • Write to an in-scope path with scope.json armed → hook returns ok (verified by checkPath — scope-aware additive allow > allows in-scope writes).
  • Write to an out-of-scope path → hook returns scope-exceeded:<path> (verified by blocks out-of-scope writes).
  • loom diff-verify <ISSUE> exits 0 on clean diff, exits 6 with JSON payload on out-of-scope (verified by diff-verify tests + bin handler).
  • All previously-passing test files still pass + 2 new test files added (199 tests pass total, was 165).
  • npm run typecheck, npm test, npm run build all green.
  • Global Tier 1 blocklist unchanged — scope-allow only widens the window within it (verified by global blocklist still wins for in-scope but globally-blocked paths).

Test plan

  • npm run typecheck — clean
  • npm test — 199 passed (12 files: 10 existing + 2 new)
  • npm run build — emits dist/ cleanly
  • Smoke: loom scope-arm TEST-1 --from-description issue.md writes valid JSON
  • Smoke: loom scope-disarm TEST-1 deletes the marker + parent dir
  • End-to-end: fire /work on a small well-specced consumer-repo issue with the new default profile (deferred to post-merge — needs a real consumer repo + Linear issue).
  • Negative: fire /work with a deliberately out-of-scope file write; confirm halt at §5.5 with scope-exceeded.

Closes #2.

🤖 Generated with Claude Code

#2)

Adds a default profile `balanced+self-checking` that removes the
dispatch-review gate as a blocking step and replaces it with two
automated safeguards:

- §4.5 scope-arm: `loom scope-arm <ISSUE>` writes a fire-scoped
  allowlist derived from the Linear issue's `## Scope` section.
  Tier 1 hooks read the marker and allow in-scope tool calls
  without prompting, while blocking out-of-scope writes with
  `scope-exceeded:<path>`.
- §5.5 diff-verify: `loom diff-verify <ISSUE>` walks `git diff
  --name-only main...HEAD` against the allowlist + collateral
  rules before the PR opens. Out-of-scope files halt with
  `scope-exceeded`; feature branch persists for human triage.

The existing dispatch-review gate stays available behind
`profile: paranoid` for ambiguous fires. Global Tier 1 blocklist
is unchanged — scope-allow only opens a window inside it.

Closes #2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@juliushamm
juliushamm merged commit ae8d5a1 into main Apr 25, 2026
1 check passed
@juliushamm
juliushamm deleted the juliushamm/loom-2-self-checking-work branch April 25, 2026 03:59
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.

Self-checking /work: spec-diff verifier + scope-bound allowlist

1 participant