feat(doctrine): levers reach every contract flow and post-gate review

Contract dry run and run-base in contract-interview STEP 4 and after gitflow start in ship-feature/init-project; their review steps fix CRITICAL or Important only on reproducible evidence; run_base SHA-checked with --end-of-options.
This commit is contained in:
bchanot committed 2026-11-20 18:07:41 +01:00
1 parent 23c580249e
commit 0db885ed48
4 files changed
+38 -7

No files matched your search

+4 -2
View File
@@ -70,9 +70,11 @@ never a shell argument.
(`lib/verify-secure-loop.md` § BEFORE THE FIRST DISPATCH), else
`git rev-parse HEAD` now (shortcut: without a contract only the pending
TODO edits count; edits committed earlier in the run are missed). A
failing `git diff` → `TODO n/a`, never a silent `+0 / -0`.
`run_base` that is not a 7-40 hex SHA, or a failing `git diff` →
`TODO n/a`, never a silent `+0 / -0`.
if d=$(git diff --no-color --no-ext-diff "$run_base" \
if [[ $run_base =~ ^[0-9a-f]{7,40}$ ]] && d=$(git diff --no-color \
--no-ext-diff --end-of-options "$run_base" \
-- ':/.claude/tasks/TODO.md' 2>/dev/null); then
n=$(printf '%s\n' "$d" | grep -c '^+ *- \[ \]')
m=$(printf '%s\n' "$d" | grep -c '^- *- \[ \]')
+11
View File
@@ -141,6 +141,17 @@ Q: <question> / A: <answer> (pass B and mid-run entries: [gated <YYYY-MM-DD>])
Print one line to the user, then continue the flow:
`CONTRACT: <path> — <n> criteria, scope <files|repo-wide>, <q> questions asked`
Before the first dev-step dispatch, after the flow's branch step, a
contract with `CHECK:` lines gets its dry run: the main loop records
`- run-base:` (the run's start SHA, for the TODO count of
`lib/capitalize-commit.md`; a value written before the branch step is
replaced by `git rev-parse HEAD` right after it) and, from the project
root, runs `bash ~/.claude/lib/gates.sh run` on a `mktemp -d` copy of the
contract (`lib/verify-secure-loop.md` § BEFORE THE FIRST DISPATCH). Every
flow that writes such a contract does this, whether or not it challenges
its plan; a flow's own positive control on the unfixed tree counts as the
`gates.sh` half, and `- run-base:` is still recorded.
## MID-RUN CLARIFICATION (the channel executors halt into)
An executor cannot talk to the human. It halts with `NEED-DECISION`, the
+11 -2
View File
@@ -224,6 +224,9 @@ Start the MVP feature branch off develop, then implement on it:
```bash
bash "$HOME/.claude/lib/gitflow.sh" start feature mvp
```
Then, before the first dispatch, the contract dry run on this branch
(`lib/contract-interview.md` STEP 4;
`lib/verify-secure-loop.md` § BEFORE THE FIRST DISPATCH).
Invoke `subagent-driven-development` (vendored superpowers skill) for the per-task implement loop
**and** the final whole-branch review **only**. Do NOT run its terminal
`finishing-a-development-branch` step — this orchestrator owns integration via
@@ -277,7 +280,12 @@ Invoke `requesting-code-review` (vendored superpowers skill). **Model routing (B
review subagent it dispatches MUST carry `model: "opus"` and `effort="xhigh"` in the Agent call —
craft review is dispatched judgment, never inherited from the session.
Add to its brief: "you may call the `advisor` tool once, before your
verdict" (code review, BDR-150). Fix all CRITICAL before proceeding.
verdict" (code review, BDR-150). Fix every CRITICAL or Important finding
that carries reproducible evidence (a command that fails on HEAD, or real
output shown wrong) before proceeding. Without it, one attempt at a failing
command, else it is a MINOR; a security finding goes to the user
(`lib/verify-secure-loop.md` § DONE;
`lib/verify-secure-loop.md` § MINOR triage).
## STEP 10b — CAPITALIZE FOUNDING DECISIONS (memory registries)
A greenfield's founding architecture decisions are the highest-value BDRs — the
@@ -379,7 +387,8 @@ bash "$HOME/.claude/lib/gitflow.sh" finish # feature/mvp → develop
- Scaffolder = skeleton only, zero logic.
- Features → subagent pipeline only.
- Broken build = unacceptable output.
- Fix all CRITICAL review issues before proceeding.
- Fix every CRITICAL or Important review issue that carries
reproducible evidence before proceeding (STEP 10).
- Stop if requirements unclear at any step.
---
+12 -3
View File
@@ -186,6 +186,9 @@ Start the feature branch off develop, then implement on it:
```bash
bash "$HOME/.claude/lib/gitflow.sh" start feature <name>
```
Then, before the first dispatch, the contract dry run on this branch
(`lib/contract-interview.md` STEP 4;
`lib/verify-secure-loop.md` § BEFORE THE FIRST DISPATCH).
Invoke `subagent-driven-development` (vendored superpowers skill) for the per-task implement loop
**and** the final whole-branch review **only**. Do NOT run its terminal
`finishing-a-development-branch` step — this orchestrator owns integration via
@@ -259,7 +262,12 @@ Invoke `requesting-code-review` (vendored superpowers skill). **Model routing (B
review subagent it dispatches MUST carry `model: "opus"` and `effort="xhigh"` in the Agent call —
craft review is dispatched judgment, never inherited from the session.
Add to its brief: "you may call the `advisor` tool once, before your
verdict" (code review, BDR-150). Fix all CRITICAL before proceeding.
verdict" (code review, BDR-150). Fix every CRITICAL or Important finding
that carries reproducible evidence (a command that fails on HEAD, or real
output shown wrong) before proceeding. Without it, one attempt at a failing
command, else it is a MINOR; a security finding goes to the user
(`lib/verify-secure-loop.md` § DONE;
`lib/verify-secure-loop.md` § MINOR triage).
## STEP 7 — CAPITALIZE (memory registries)
Call memory_pending first, per /capitalize STEP 1 "Captured first".
@@ -341,7 +349,8 @@ bash "$HOME/.claude/lib/gitflow.sh" finish # feature/<name> → develop
- No skipping steps. No merged agent responsibilities.
- No implement without user approval at STEP 3.
- Subagents isolated — no shared context between tasks.
- Fix all CRITICAL review issues before proceeding.
- Fix every CRITICAL or Important review issue that carries
reproducible evidence before proceeding (STEP 6).
- Stop if requirements unclear at any step.
- STEP 4 errors → STEP 4b gate required before any fix. Never auto-patch a failing subagent.
@@ -361,7 +370,7 @@ The pipeline must handle these without aborting silently:
| STEP 3 — user replies "request changes" | Loop back to STEP 2 with user's notes. Cap at 3 iterations; on the 3rd "request changes" without approval, ask "Pause and rescope this feature?" |
| STEP 4 — subagent crashes (tool error, not test failure) | Treat as STEP 4b error path, present hypothesis-led gate. |
| STEP 4b — option A retried 2× still failing | Force fall-through to B or C. Do not loop a 3rd time. |
| STEP 6 — review returns CRITICAL items | Loop back to STEP 4 for those items only. Cap at 2 review-cycle iterations; if still CRITICAL, escalate. |
| STEP 6 — review returns CRITICAL or Important items with reproducible evidence | Loop back to STEP 4 for those items only. Cap at 2 review-cycle iterations; if still CRITICAL, escalate. |
| STEP 7 — `.claude/memory/` missing | Create the registry files from `~/.claude/templates/memory/` first, then proceed. |
---