From ffa1d7788881bf9a92026b7b8b972a5982d843de Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 06:45:48 +1100 Subject: [PATCH 1/2] Fast checks every turn, screenshots and review once when ready The Stop gate judged every turn as if the change were finished: the full run-verify (Playwright screenshots, e2e, inspect) and, for standard and strict changes, a fresh review and evidence pack. The next edit threw all of it away, so a change built over several turns paid for each slow step several times. - Checks can be marked "stage": "final"; the template marks look, functional, inspect and security (and the RN simulator checks). - run-verify --fast skips them and records the lane as "fast". - The Stop gate (default enforce) blocks only on missing, failing or stale fast checks; what the final verification lacks is shown to the person and logged as final-pending. DX_WORKFLOW_GATE=full keeps 0.7 behaviour. - review-brief refuses a fast run; make-evidence marks it not ready. - Skills: implement with --fast, verify once when ready; acceptance only for Medium and Large (matching 0007); fix a broken sentence in frontend verify.md and a duplicated README paragraph. - ADR 0008, version 0.8.0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JaMb11KUWULtVrTGwgNRJt --- README.md | 40 ++++--- docs/adr/0008-fast-loop-final-verification.md | 37 +++++++ .../dx-workflow/.claude-plugin/plugin.json | 4 +- plugins/dx-workflow/scripts/make-evidence.mjs | 5 +- plugins/dx-workflow/scripts/review-brief.mjs | 7 +- plugins/dx-workflow/scripts/run-verify.mjs | 18 +++- plugins/dx-workflow/scripts/stop-gate.mjs | 100 ++++++++++++------ plugins/dx-workflow/shared/skill-packs.md | 5 +- plugins/dx-workflow/shared/verify-ci.yml | 2 +- plugins/dx-workflow/shared/verify.config.json | 14 +-- plugins/dx-workflow/skills/backend/SKILL.md | 14 +-- plugins/dx-workflow/skills/backend/build.md | 7 +- plugins/dx-workflow/skills/backend/verify.md | 8 +- plugins/dx-workflow/skills/frontend/SKILL.md | 19 ++-- plugins/dx-workflow/skills/frontend/build.md | 7 +- plugins/dx-workflow/skills/frontend/mobile.md | 3 +- plugins/dx-workflow/skills/frontend/verify.md | 32 +++--- plugins/dx-workflow/skills/workflow/SKILL.md | 37 ++++--- test/helpers.mjs | 12 ++- test/stages.test.mjs | 95 +++++++++++++++++ 20 files changed, 348 insertions(+), 118 deletions(-) create mode 100644 docs/adr/0008-fast-loop-final-verification.md create mode 100644 test/stages.test.mjs diff --git a/README.md b/README.md index f74086c..89ee1e2 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,20 @@ node /scripts/run-verify.mjs --config working # 在未改动的代码 **风险**由脚本从 diff 算出来,决定要验证多严(`node /scripts/level.mjs` 随时可以看): -| 级别 | 什么时候 | 要求 | +| 级别 | 什么时候 | 改完准备提 PR 时要求 | | --- | --- | --- | -| light | 小改动(默认 ≤40 行、≤3 个文件),什么风险都没碰 | 检查通过就行。不写验收文件、不派评审、不生成证据包 | -| standard | 其余的改动 | 验收标准 + 检查 + 一次独立评审;证据包自动生成 | +| light | 小改动(默认 ≤40 行、≤3 个文件),什么风险都没碰 | 完整检查通过就行。不写验收文件、不派评审、不生成证据包 | +| standard | 其余的改动 | 验收标准 + 完整检查 + 一次独立评审;证据包自动生成 | | strict | 不管多小,只要碰到鉴权、支付、权限、迁移、接口契约、原生配置、`sensitive` 路径,或者改了检查本身 | 再加深度评审和安全检查;合并前由 owner 确认(3 档) | +**验证分两段**,不管哪个级别都一样: + +- **实现过程中,每一轮**只跑快检查:`run-verify.mjs --fast`(样式、类型、lint、单元、负向检查)。Stop 钩子每轮只要求这一段。 +- **改完准备提 PR 时,跑一次**完整检查:不加 `--fast`,配置里标了 `"stage": "final"` 的慢检查(截图、e2e 用户路径、inspect、安全扫描)这时才跑; + 然后按级别做评审、生成证据包。截图和评审放在最后,是因为中途改一次代码,前面的截图和评审就作废了。 + +需要用户挑方案的原型(`frontend/build.md`)仍然在前面做:那是设计决定,不是验证。 + 风险不用配置也能识别:按路径(`auth/`、`payment`、`migrations/`、`.sql`、`.env` 等)和代码内容(Stripe、JWT、bcrypt、`DROP TABLE`、 `dangerouslySetInnerHTML`、权限判断等)判断;可以在配置的 `risk` 里调整或关掉。所以改动再小,碰了登录也会走严格验证;AI 也没法自称"这是小改动"来跳过。 @@ -81,7 +89,7 @@ node /scripts/run-verify.mjs --config working # 在未改动的代码 | 调试 | `superpowers:systematic-debugging`、`mattpocock-skills:diagnosing-bugs` | | 代码质量、复盘 | `mattpocock-skills:improve-codebase-architecture`、`code-review`、`retro` | -dx-workflow 自己负责:工作流编排、验证、独立评审、证据包、ratchet。重叠的地方以 dx-workflow 为准("做完"看 Stop 钩子, +dx-workflow 自己负责:工作流编排、验证、独立评审、证据包、ratchet。重叠的地方以 dx-workflow 为准("做完"看最后一段的完整验证, 独立评审看 `review-brief.mjs`,合并看分档),详见 `shared/skill-packs.md`。 上线(部署、灰度、监控、回滚)还没做:目前按合并分档决定谁批准合并,之后按你们团队现有的流程。 @@ -101,6 +109,9 @@ dx-workflow 自己负责:工作流编排、验证、独立评审、证据包 | 检查 | 写死的样式、类型、lint、截图 + 可访问性、用户路径(Web 用 Playwright) | 类型、lint、单元、真实数据库的集成测试、契约、迁移、用户路径 | | 评审 | 有界面改动时看截图(`design-review.md`),代码看 `frontend/code-review.md` | `backend/code-review.md` | +**检查的阶段**:`config.json` 里慢的、判断"做完的改动"的检查标 `"stage": "final"`(模板里默认标了截图 `look`、 +用户路径 `functional`、`inspect`、`security`),`run-verify --fast` 跳过它们;其余检查按从快到慢排,第一个失败就停。 + **负向检查**:把这条 lane 里的源码改动退回到基线、保留新测试,再跑一遍测试,测试必须失败。 测试在没有实现时也能通过,说明它没测到这次改动。 @@ -118,9 +129,6 @@ dx-workflow 自己负责:工作流编排、验证、独立评审、证据包 详见 `skills/frontend/mobile.md`。 -**负向检查**:把这条 lane 里的源码改动退回到基线、保留新测试,再跑一遍测试,测试必须失败。 -测试在没有实现时也能通过,说明它没测到这次改动。 - ## 合并分档 脚本算,不能手动改。 @@ -185,12 +193,14 @@ lint 规则、类型或约束 > 由 diff 触发的清单项 > 写进约定文件 ## 收尾检查和提交盖章 -**Stop 钩子**:这一轮改动了某条 lane 的文件(内容和这一轮开始时不同,由 UserPromptSubmit 钩子记录)时,按级别检查: -light 只要求这条 lane 的 `run-verify` 在当前内容上通过;standard 还要求独立评审针对当前内容且已通过、验收标准和清单项都已标记; -strict 还要求评审是 deep。证据包由钩子自己生成,其他条件都满足时它会自动跑 `make-evidence`。不满足时第一次结束会被拦下。仍未通过就结束时,AI 必须写明"未验证" -(钩子只拦一次,避免无限循环)。只聊天、没改内容的一轮不会被拦。 +**Stop 钩子**:这一轮改动了某条 lane 的文件(内容和这一轮开始时不同,由 UserPromptSubmit 钩子记录)时: + +- **拦下**:这条 lane 的快检查(`run-verify --fast` 或完整运行)没跑、没过,或者跑的不是当前内容。仍未通过就结束时,AI 必须写明"未验证" + (钩子只拦一次,避免无限循环)。只聊天、没改内容的一轮不会被拦。 +- **不拦,但告诉你**:最后一段还缺什么(final 检查没跑;standard 的评审、验收标准、清单项;strict 的 deep 评审)。这时证据包的分档是"未就绪", + CI 也会把所有检查重跑一遍,所以把关没有放松,只是不再每一轮都跑。其他条件都满足时,钩子会自己跑 `make-evidence` 生成证据包。 -`DX_WORKFLOW_GATE`:`enforce`(默认,拦截)、`observe`(只记录本来会拦什么,用来先看误报)、`off`(关闭)。 +`DX_WORKFLOW_GATE`:`enforce`(默认,见上)、`full`(每一轮都要求全部完成,0.7 的做法)、`observe`(只记录本来会拦什么,用来先看误报)、`off`(关闭)。 每次判断都追加到 `.verify/gate.log`,`ratchet.md` 建议每周看一次。 **提交盖章**(可选):`node /scripts/stamp.mjs --install` 装一个 `prepare-commit-msg` 钩子。每个改了 lane 文件的提交带上 @@ -228,7 +238,7 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含 | 变量 | 作用 | | --- | --- | | `VERIFY_BASE` | 基线提交(默认:和 `origin/HEAD`、`origin/main`、`origin/master` 的 merge-base,都没有就是 `HEAD`) | -| `DX_WORKFLOW_GATE` | Stop 钩子:`enforce`(默认)、`observe`、`off` | +| `DX_WORKFLOW_GATE` | Stop 钩子:`enforce`(默认)、`full`、`observe`、`off` | ## 文件 @@ -252,7 +262,7 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含 | 路径 | 作用 | | --- | --- | | `plugins/dx-workflow/hooks/hooks.json` | 注册 UserPromptSubmit 和 Stop 两个钩子 | -| `plugins/dx-workflow/scripts/run-verify.mjs` | 按 lane 跑检查(含负向检查),记录退出码和内容哈希;`--config working`、`--keep-going`、`--restore` | +| `plugins/dx-workflow/scripts/run-verify.mjs` | 按 lane 跑检查(含负向检查),记录退出码和内容哈希;`--fast`(不跑 final 检查)、`--config working`、`--keep-going`、`--restore` | | `plugins/dx-workflow/scripts/init.mjs` | 接入:找出已有的检查命令,生成最小的 `.verify/config.json` | | `plugins/dx-workflow/scripts/level.mjs`、`lib/level.mjs` | 这次改动的验证级别(light / standard / strict)和原因 | | `plugins/dx-workflow/scripts/flow-check.mjs` | 步骤之间的关卡:规格、任务、下一步可做的任务、生成任务的验收文件 | @@ -286,7 +296,7 @@ npm test # node evals/run.mjs all --reviewer "claude -p --permission-mode acceptEdits" # 改 code-review.md、brief 或换模型之前先跑,和 evals/results/ 里上一次比 ``` -发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.7.0`),CI 模板按 tag 锁定插件版本。 +发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.8.0`),CI 模板按 tag 锁定插件版本。 升级第三方工具:一次只升一个,读它的改动,在两个项目上各跑一次 `run-verify.mjs`,结果没变差再改 `vendor.lock.json` 里的 commit。 diff --git a/docs/adr/0008-fast-loop-final-verification.md b/docs/adr/0008-fast-loop-final-verification.md new file mode 100644 index 0000000..27fd9b3 --- /dev/null +++ b/docs/adr/0008-fast-loop-final-verification.md @@ -0,0 +1,37 @@ +# 8. A fast loop every turn, the final verification once + +Date: 2026-12-03 · Status: accepted + +## Context + +After 0007 the steps depended on the change, but not on when in the change they ran. The Stop gate +judged every turn that touched a lane as if the change were finished: the whole `run-verify` (for a +frontend lane: Playwright screenshots at three widths, the e2e journeys, inspect; on a phone: +simulators), and for standard and strict changes a fresh review and the evidence pack. All of it is +bound to the content hash, so the next edit threw it away. A change built over five turns paid for +five screenshot runs and five reviews, of which only the last meant anything. The UI checks were the +slowest and the most wasted: a screenshot of a screen that is still moving judges nothing. + +## Decision + +- A check can be marked `"stage": "final"` in `.verify/config.json`. The template marks the slow + checks that judge a finished change: `look`, `functional`, `inspect`, `security` (and the + simulator checks of a React Native lane). +- `run-verify.mjs --fast` skips them and records the lane as `fast`. A full run records `pass`. +- The Stop gate (default `enforce`) blocks a turn only when the touched lanes' fast checks are + missing, failing or stale. What the final verification still lacks (final checks, review, + acceptance, evidence) is shown to the person as a message, not blocked, and logged as + `final-pending`. `DX_WORKFLOW_GATE=full` keeps the 0.7 behaviour. +- The final verification happens once, in the workflow's Verify step: the full run, then the review + by level. `review-brief.mjs` refuses a `fast` run; `make-evidence.mjs` marks it "not ready". +- The prototype step (frontend `build.md`) stays early: picking a structure is a design decision, + not verification. + +## Consequences + +A turn costs the fast checks only. A change can end a turn, or a session, without its final +verification; the person sees that in the gate's message, the evidence pack says "not ready", the +commit stamp says `Verified: none`, and CI reruns every check, so nothing unverified reaches a merge +unnoticed. What is lost is the guarantee that the agent itself ran the review before saying "done"; +the workflow skill tells it to say so plainly, and `full` restores the guarantee for teams that want it. +A project whose config has no `stage` marks behaves as before: `--fast` runs everything. diff --git a/plugins/dx-workflow/.claude-plugin/plugin.json b/plugins/dx-workflow/.claude-plugin/plugin.json index 303da27..a80a942 100644 --- a/plugins/dx-workflow/.claude-plugin/plugin.json +++ b/plugins/dx-workflow/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "dx-workflow", - "version": "0.7.0", - "description": "One workflow from request to mergeable change, light by default and strict where it matters: the developer describes the change; it sizes it, computes how strictly to check it from the diff (light, standard, strict), uses superpowers and Matt Pocock's skills inside steps, acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. ", + "version": "0.8.0", + "description": "One workflow from request to mergeable change, light by default and strict where it matters: the developer describes the change; it sizes it, computes how strictly to check it from the diff (light, standard, strict), uses superpowers and Matt Pocock's skills inside steps, acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate that asks for fast checks each turn and the slow ones (screenshots, e2e) once, when the change is ready. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. ", "author": { "name": "davidxiaodev" }, diff --git a/plugins/dx-workflow/scripts/make-evidence.mjs b/plugins/dx-workflow/scripts/make-evidence.mjs index 1c0dbe9..a372447 100644 --- a/plugins/dx-workflow/scripts/make-evidence.mjs +++ b/plugins/dx-workflow/scripts/make-evidence.mjs @@ -141,7 +141,10 @@ const why3 = [ })(), ].filter(Boolean); const notReady = [ - !lanesReady && "a lane's checks did not pass", + !lanesReady && + (lanes.some((l) => last.lanes[l.name]?.result === "fast") && lanes.every((l) => ["pass", "fast"].includes(last.lanes[l.name]?.result)) + ? "only the fast checks ran (run run-verify.mjs without --fast for the final checks)" + : "a lane's checks did not pass"), !reviewsReady && "a review is not approved or has open lines", !acceptanceReady && "an acceptance criterion is not met or not reviewed", !sameTree && `verified a different tree than the one on disk (${[...staleRuns.map((n) => `run ${n}`), ...staleReviews.map((n) => `review ${n}`)].join(", ")})`, diff --git a/plugins/dx-workflow/scripts/review-brief.mjs b/plugins/dx-workflow/scripts/review-brief.mjs index 70a89c3..46c1016 100644 --- a/plugins/dx-workflow/scripts/review-brief.mjs +++ b/plugins/dx-workflow/scripts/review-brief.mjs @@ -40,7 +40,12 @@ const current = treeHash(root); const last = readJson(join(cfg.dir, "last-run.json")); const run = last?.lanes?.[lane.name]; if (!run || run.tree !== current || run.result !== "pass") { - fail(2, `review-brief: run-verify has not passed lane ${lane.name} on the current tree; run it first (the reviewer reviews what the checks passed).`); + fail( + 2, + run?.result === "fast" && run.tree === current + ? `review-brief: only the fast checks ran on lane ${lane.name}; run run-verify.mjs without --fast first (the review comes after the final checks, once).` + : `review-brief: run-verify has not passed lane ${lane.name} on the current tree; run it first (the reviewer reviews what the checks passed).`, + ); } // What changed, for this lane. diff --git a/plugins/dx-workflow/scripts/run-verify.mjs b/plugins/dx-workflow/scripts/run-verify.mjs index 648d3e5..5107a68 100644 --- a/plugins/dx-workflow/scripts/run-verify.mjs +++ b/plugins/dx-workflow/scripts/run-verify.mjs @@ -3,7 +3,12 @@ // .verify/last-run.json from real exit codes only, so the Stop gate can trust it. // // node run-verify.mjs [--lane frontend,backend] [--only name,name] [--root ] -// [--config base|working] [--base ] [--keep-going] +// [--config base|working] [--base ] [--keep-going] [--fast] +// +// --fast skips the checks marked "stage": "final" (screenshots, e2e journeys, inspect: the slow +// ones that judge a finished change). Use it while implementing; the lane is recorded as "fast", +// which satisfies the Stop gate turn by turn but not the evidence pack or the merge tier. Run +// without --fast once, when the change is ready. // // A lane stops at its first failing check (cheap checks first: order them in config.json from // fastest to slowest); the rest are recorded as skipped. --keep-going runs every check anyway. @@ -61,6 +66,7 @@ if (backupExists(cfg.dir)) { const wantLanes = opt("lane")?.split(",").filter(Boolean); const only = opt("only")?.split(",").filter(Boolean); +const fast = args.includes("--fast"); const lanes = cfg.lanes.filter((l) => !wantLanes || wantLanes.includes(l.name)); const unknown = (wantLanes ?? []).filter((n) => !cfg.lanes.some((l) => l.name === n)); if (unknown.length) { @@ -102,6 +108,11 @@ for (const lane of lanes) { const laneStarted = new Date().toISOString(); const results = []; for (const check of checks) { + if (fast && check.stage === "final") { + console.log(`run-verify: ${lane.name}/${check.name} … not run (stage final; runs without --fast)`); + results.push({ name: check.name, run: check.run ?? "built-in negative check", exitCode: null, skipped: true, stage: "final", seconds: 0, log: null, note: "stage final, not run with --fast" }); + continue; + } if (process.env.CI && check.ci === false) { console.log(`run-verify: ${lane.name}/${check.name} … skipped in CI ("ci": false; it needs a simulator, a device or a local service)`); results.push({ name: check.name, run: check.run ?? "built-in negative check", exitCode: null, skipped: true, seconds: 0, log: null, note: 'not run in CI ("ci": false)' }); @@ -140,7 +151,7 @@ for (const lane of lanes) { record.lanes[lane.name] = { startedAt: laneStarted, finishedAt: new Date().toISOString(), - result: failed.length ? "fail" : only ? "partial" : "pass", + result: failed.length ? "fail" : only ? "partial" : results.some((r) => r.stage === "final" && r.skipped) ? "fast" : "pass", runDir, tree: null, config: cfg.source, @@ -195,5 +206,8 @@ writeFileSync(join(cfg.dir, "last-run.json"), JSON.stringify(record, null, 2) + console.log(`\nrun-verify: logs and evidence in ${runDir}`); if (anyFailed) console.log("Read the failing logs before changing anything. Never weaken a test or a check to get green."); +if (fast && !anyFailed && ranLanes.some((n) => record.lanes[n].result === "fast")) { + console.log("Fast checks only. Before the pull request, run run-verify.mjs without --fast (the final checks), then the review for standard and strict changes."); +} if (only) console.log("A run with --only is recorded as partial and does not satisfy the Stop gate."); process.exit(anyFailed ? 1 : 0); diff --git a/plugins/dx-workflow/scripts/stop-gate.mjs b/plugins/dx-workflow/scripts/stop-gate.mjs index 5320bf8..cbec5c9 100644 --- a/plugins/dx-workflow/scripts/stop-gate.mjs +++ b/plugins/dx-workflow/scripts/stop-gate.mjs @@ -1,20 +1,30 @@ #!/usr/bin/env node -// Claude Code Stop hook. In a project with .verify/config.json it blocks the end of a turn that -// changed files of a lane (frontend, backend, …) when the change is not verified for exactly the -// content on disk now. What "verified" means depends on the change's level (lib/level.mjs): -// light every touched lane's last run-verify passed on this tree. Nothing else. -// standard also: an independent review of this tree, approved with no open line; the acceptance -// criteria all accounted for in a review; the evidence pack (the gate makes it itself -// when that is all that is missing). -// strict also: the review was deep ("Depth: deep", which review-brief.mjs asks for). +// Claude Code Stop hook. In a project with .verify/config.json it looks at the end of a turn that +// changed files of a lane (frontend, backend, …). Verification has two parts: +// +// every turn the touched lanes' fast checks passed on the content on disk now (run-verify.mjs +// --fast, or a full run). This is what keeps the inner loop honest and cheap. +// final once, when the change is ready (before the pull request): the full run including +// checks marked "stage": "final" (screenshots, e2e, inspect), and by level: +// light nothing more +// standard an independent review of this tree, approved with no open line; the +// acceptance criteria all accounted for; the evidence pack (the gate +// makes it itself when that is all that is missing) +// strict also: the review was deep ("Depth: deep", which review-brief.mjs asks for) +// // A run or review counts only for the tree it names (content hash, not file times). // "Changed" means: the files differ from the base commit (committed on this branch or not, deletions // included), and the tree differs from the one recorded when the turn started (turn-start.mjs), so a // turn that only talked is not stopped. // +// DX_WORKFLOW_GATE: +// "enforce" (default) blocks a turn whose fast checks are missing, failing or stale; what the +// final verification still lacks is shown to the user (systemMessage), not blocked. +// make-evidence marks such a change "not ready", and CI reruns every check. +// "full" blocks until the final verification is complete too, every turn (the 0.7 behaviour). +// "observe" only logs what "enforce" would have blocked; "off" does nothing. // It blocks once per stop (stop_hook_active lets the second attempt through, so a turn cannot loop -// forever). DX_WORKFLOW_GATE: "enforce" (default) blocks; "observe" only logs what it would have -// blocked; "off" does nothing. Every decision is appended to .verify/gate.log. +// forever). Every decision is appended to .verify/gate.log. import { spawnSync } from "node:child_process"; import { appendFileSync, existsSync, readFileSync, statSync } from "node:fs"; import { dirname, join } from "node:path"; @@ -54,59 +64,64 @@ if (current && turn?.tree === current) process.exit(0); // this turn changed not const lvl = changeLevel(cfg, changes); const last = readJson(join(cfg.dir, "last-run.json")); -const problems = []; +const turnProblems = []; // block the turn +const finalProblems = []; // the change is not ready for a pull request yet const reviewTimes = []; const coveredIds = new Set(); const short = (h) => (h ? h.slice(0, 12) : "none"); -if (!current) problems.push("could not hash the working tree (git failed); verification cannot be matched to the content."); +if (!current) turnProblems.push("could not hash the working tree (git failed); verification cannot be matched to the content."); for (const { lane, files } of required) { const run = last?.lanes?.[lane.name]; const reviewPath = join(cfg.dir, `review-${lane.name}.md`); const label = `lane ${lane.name} (${preview(files)})`; if (!run) { - problems.push(`${label}: run-verify has not run this lane.`); + turnProblems.push(`${label}: run-verify has not run this lane.`); continue; } - if (run.result !== "pass") problems.push(`${label}: the last run-verify result is "${run.result}", not "pass".`); - if (run.tree !== current) problems.push(`${label}: files changed since the last run-verify (it checked tree ${short(run.tree)}, the tree is now ${short(current)}).`); + if (!["pass", "fast"].includes(run.result)) turnProblems.push(`${label}: the last run-verify result is "${run.result}", not "pass".`); + if (run.tree !== current) turnProblems.push(`${label}: files changed since the last run-verify (it checked tree ${short(run.tree)}, the tree is now ${short(current)}).`); + if (run.result === "fast") { + const skipped = (run.checks ?? []).filter((c) => c.stage === "final" && c.skipped).map((c) => c.name); + finalProblems.push(`${label}: the final checks have not run (${skipped.join(", ") || "stage final"}): run run-verify.mjs without --fast.`); + } if (lvl.level === "light") continue; if (!existsSync(reviewPath)) { - problems.push(`${label}: .verify/review-${lane.name}.md is missing (independent review).`); + finalProblems.push(`${label}: .verify/review-${lane.name}.md is missing (independent review).`); continue; } const review = readFileSync(reviewPath, "utf8"); reviewTimes.push(statSync(reviewPath).mtimeMs); const reviewed = reviewTree(review); - if (!reviewed) problems.push(`${label}: its review has no "Tree:" line naming the tree it reviewed (lanes.${lane.name}.tree in last-run.json).`); - else if (current && !current.startsWith(reviewed)) problems.push(`${label}: its review is of tree ${short(reviewed)}, not the current tree ${short(current)}.`); + if (!reviewed) finalProblems.push(`${label}: its review has no "Tree:" line naming the tree it reviewed (lanes.${lane.name}.tree in last-run.json).`); + else if (current && !current.startsWith(reviewed)) finalProblems.push(`${label}: its review is of tree ${short(reviewed)}, not the current tree ${short(current)}.`); const open = review.split("\n").filter(OPEN_LINE); - if (open.length) problems.push(`${label}: its review still has ${open.length} open or failing line(s).`); - if (!/^Verdict:\s*approved\b/im.test(review)) problems.push(`${label}: its review does not say "Verdict: approved".`); - if (lvl.level === "strict" && !/^Depth:\s*deep\b/im.test(review)) problems.push(`${label}: the change is strict (${lvl.reasons[0]}), so its review must be deep: write a new brief with review-brief.mjs and dispatch a fresh reviewer.`); + if (open.length) finalProblems.push(`${label}: its review still has ${open.length} open or failing line(s).`); + if (!/^Verdict:\s*approved\b/im.test(review)) finalProblems.push(`${label}: its review does not say "Verdict: approved".`); + if (lvl.level === "strict" && !/^Depth:\s*deep\b/im.test(review)) finalProblems.push(`${label}: the change is strict (${lvl.reasons[0]}), so its review must be deep: write a new brief with review-brief.mjs and dispatch a fresh reviewer.`); for (const l of acceptanceLines(review)) for (const m of l.matchAll(/\bA\d+\b/gi)) coveredIds.add(m[0].toUpperCase()); } const acceptancePath = join(cfg.dir, "acceptance.md"); if (lvl.level === "light") { // nothing beyond passing checks -} else if (!existsSync(acceptancePath)) problems.push(".verify/acceptance.md is missing: write the observable criteria for this change (shared/acceptance.md)."); +} else if (!existsSync(acceptancePath)) finalProblems.push(".verify/acceptance.md is missing: write the observable criteria for this change (shared/acceptance.md)."); else { const ids = acceptanceIds(readFileSync(acceptancePath, "utf8")); - if (ids.length === 0) problems.push(".verify/acceptance.md has no criteria (lines starting with `- A1`)."); + if (ids.length === 0) finalProblems.push(".verify/acceptance.md has no criteria (lines starting with `- A1`)."); const missing = ids.filter((id) => !coveredIds.has(id)); - if (missing.length && reviewTimes.length) problems.push(`acceptance criteria ${missing.join(", ")} appear in no review's "## Acceptance" section.`); + if (missing.length && reviewTimes.length) finalProblems.push(`acceptance criteria ${missing.join(", ")} appear in no review's "## Acceptance" section.`); } // The evidence pack is bookkeeping, not a step: when everything else holds, make it here. if (lvl.level !== "light") { let evidence = evidenceProblems(); - if (evidence.length && problems.length === 0) { + if (evidence.length && turnProblems.length === 0 && finalProblems.length === 0) { spawnSync(process.execPath, [join(dirname(fileURLToPath(import.meta.url)), "make-evidence.mjs"), "--root", root], { cwd: root, stdio: "ignore", timeout: 20_000 }); evidence = evidenceProblems(); } - problems.push(...evidence); + finalProblems.push(...evidence); } function evidenceProblems() { @@ -119,25 +134,40 @@ function evidenceProblems() { return out; } -if (problems.length === 0) { - log(`pass (${lvl.level})`, []); +const header = `level ${lvl.level}${lvl.reasons.length ? `: ${lvl.reasons.slice(0, 3).join("; ")}` : ""}`; +const blocking = mode === "full" ? [...turnProblems, ...finalProblems] : turnProblems; + +if (blocking.length === 0) { + if (finalProblems.length === 0) { + log(`pass (${lvl.level})`, []); + process.exit(0); + } + // The inner loop is fine; the change is not ready for a pull request yet. Tell the person, do not block. + log("final-pending", finalProblems); + process.stdout.write( + JSON.stringify({ + systemMessage: `dx-workflow: fast checks pass; final verification still to do before the pull request (${header}): ${finalProblems.length} item(s), e.g. ${finalProblems[0]}`, + }) + "\n", + ); process.exit(0); } if (input.stop_hook_active) { - log("let-through-unverified", problems); + log("let-through-unverified", blocking); process.exit(0); } if (mode === "observe") { - log("would-block", problems); + log("would-block", blocking); process.exit(0); } -log("block", problems); +log("block", blocking); block([ - `Changes are not verified (level ${lvl.level}${lvl.reasons.length ? `: ${lvl.reasons.slice(0, 3).join("; ")}` : ""}):`, - ...problems.map((p) => `- ${p}`), + `Changes are not verified (${header}):`, + ...blocking.map((p) => `- ${p}`), lvl.level === "light" - ? "A light change needs only its checks: run run-verify.mjs and fix what fails." - : "Run run-verify.mjs, then an independent review: review-brief.mjs writes the brief for a fresh subagent, which writes .verify/review-.md. The gate makes the evidence pack itself.", + ? "A light change needs only its checks: run run-verify.mjs (--fast while working) and fix what fails." + : mode === "full" + ? "Run run-verify.mjs, then an independent review: review-brief.mjs writes the brief for a fresh subagent, which writes .verify/review-.md. The gate makes the evidence pack itself." + : "Run run-verify.mjs --fast (the fast checks) and fix what fails. The final checks and the review come once, when the change is ready.", "If you cannot verify (no browser, no database, server will not start), say so plainly to the user instead of claiming the work is done.", ]); diff --git a/plugins/dx-workflow/shared/skill-packs.md b/plugins/dx-workflow/shared/skill-packs.md index 21419d8..22b4646 100644 --- a/plugins/dx-workflow/shared/skill-packs.md +++ b/plugins/dx-workflow/shared/skill-packs.md @@ -17,8 +17,9 @@ fallback for that step. ## Where they overlap with this plugin, this plugin decides -- **Done** is the Stop gate letting the turn end: the checks passed on the tree on disk and, for - standard and strict changes, the independent review from `review-brief.mjs` approved it. "Tests +- **Done** is the final verification: the full `run-verify.mjs` (not `--fast`) passed on the tree on + disk and, for standard and strict changes, the independent review from `review-brief.mjs` + approved it. The Stop gate letting a turn end only means the fast checks passed. "Tests pass" (`superpowers:verification-before-completion`) is part of that. - **The independent review** is the one `review-brief.mjs` writes. Reviews inside other skills (`superpowers:requesting-code-review`, the reviewer in `superpowers:subagent-driven-development`, diff --git a/plugins/dx-workflow/shared/verify-ci.yml b/plugins/dx-workflow/shared/verify-ci.yml index 8d78c76..d1bda9c 100644 --- a/plugins/dx-workflow/shared/verify-ci.yml +++ b/plugins/dx-workflow/shared/verify-ci.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 60 env: # Pin the plugin to a release tag or commit; upgrade it in its own pull request. - DX_WORKFLOW_REF: v0.7.0 + DX_WORKFLOW_REF: v0.8.0 VERIFY_BASE: origin/${{ github.base_ref }} steps: - uses: actions/checkout@v4 diff --git a/plugins/dx-workflow/shared/verify.config.json b/plugins/dx-workflow/shared/verify.config.json index 52e753e..748cdf8 100644 --- a/plugins/dx-workflow/shared/verify.config.json +++ b/plugins/dx-workflow/shared/verify.config.json @@ -10,9 +10,9 @@ "checks": [ { "name": "raw-styles", "run": "node scripts/ui/check-raw-styles.mjs " }, { "name": "types", "run": "" }, - { "name": "functional", "run": "", "timeoutMin": 30 }, - { "name": "look", "run": "npx playwright test e2e/ui-look", "cwd": "", "timeoutMin": 30 }, - { "name": "inspect", "run": "node --out \"$VERIFY_RUN_DIR/inspect\" <--app for app screens>" } + { "name": "functional", "stage": "final", "run": "", "timeoutMin": 30 }, + { "name": "look", "stage": "final", "run": "npx playwright test e2e/ui-look", "cwd": "", "timeoutMin": 30 }, + { "name": "inspect", "stage": "final", "run": "node --out \"$VERIFY_RUN_DIR/inspect\" <--app for app screens>" } ] }, "app": { @@ -29,8 +29,8 @@ { "name": "lint", "run": "npx expo lint", "cwd": "" }, { "name": "unit", "run": "npx jest --ci", "cwd": "" }, { "name": "negative", "negative": { "test": "npx jest --ci" } }, - { "name": "functional", "run": "maestro test -e VERIFY_RUN_DIR=\"$VERIFY_RUN_DIR\" .maestro/journeys", "cwd": "", "timeoutMin": 30, "ci": false }, - { "name": "look", "run": "node scripts/ui/rn-look.mjs --config e2e/rn-look/screens.json", "cwd": "", "timeoutMin": 45, "ci": false } + { "name": "functional", "stage": "final", "run": "maestro test -e VERIFY_RUN_DIR=\"$VERIFY_RUN_DIR\" .maestro/journeys", "cwd": "", "timeoutMin": 30, "ci": false }, + { "name": "look", "stage": "final", "run": "node scripts/ui/rn-look.mjs --config e2e/rn-look/screens.json", "cwd": "", "timeoutMin": 45, "ci": false } ] }, "backend": { @@ -47,8 +47,8 @@ { "name": "negative", "negative": { "test": "" } }, { "name": "contract", "run": " --fail-on ERR, or the stack's schema check>" }, { "name": "migrations", "run": "", "timeoutMin": 15 }, - { "name": "functional", "run": "", "timeoutMin": 30 }, - { "name": "security", "run": "; gitleaks detect; osv-scanner -r .>" } + { "name": "functional", "stage": "final", "run": "", "timeoutMin": 30 }, + { "name": "security", "stage": "final", "run": "; gitleaks detect; osv-scanner -r .>" } ] } } diff --git a/plugins/dx-workflow/skills/backend/SKILL.md b/plugins/dx-workflow/skills/backend/SKILL.md index f618e28..e63d315 100644 --- a/plugins/dx-workflow/skills/backend/SKILL.md +++ b/plugins/dx-workflow/skills/backend/SKILL.md @@ -8,9 +8,11 @@ description: Use when building, changing, reviewing or debugging server-side cod ## Overview A backend change is done when what a caller can observe was decided before building, the code was -built test first at agreed seams, `run-verify.mjs` passed for the `backend` lane (including a negative -check proving the tests can fail), a reviewer who did not write it marked every acceptance criterion -from evidence, and the evidence pack says how much a person must look before merging. +built test first at agreed seams, `run-verify.mjs` passed for the `backend` lane (`--fast` while +building; once without it when ready, so the journeys and scans run too; the negative check proves +the tests can fail), and, for standard and strict changes, a reviewer who did not write it marked +every acceptance criterion from evidence and the evidence pack says how much a person must look +before merging. `docs/backend.md` plus the contract file (OpenAPI, GraphQL schema, proto) and the migrations folder are the contract. `` is this skill's folder; `` is two levels up (it holds `scripts/` and `shared/`). @@ -23,7 +25,7 @@ the contract. `` is this skill's folder; `` is two levels up (it | The same check failed two runs in a row, or the user reports a bug | `/shared/debug.md` before the next fix | | No `.verify/config.json` | `node /scripts/init.mjs`, then come back | | No `docs/backend.md`, and the change touches a contract, a migration or an endpoint the checks do not cover | `setup.md` for the parts this change needs; otherwise follow the code's existing patterns | -| Any change | `/shared/acceptance.md` first: write `.verify/acceptance.md` | +| A Medium or Large change (the `workflow` skill sizes it) | `/shared/acceptance.md` first: write `.verify/acceptance.md` | | Building or changing endpoints, jobs, schema | `build.md`, then `verify.md` | | Asked only to review a change | `verify.md` (dispatch), then `code-review.md` | | No scripted way to start the app and drive requests | `/shared/ctl.md` | @@ -54,8 +56,8 @@ non-breaking way unless they choose the break. It is tier 3 either way. ## Done means -`run-verify.mjs` printed `pass` for every lane the change touched, on the content now on disk; -`.verify/review-backend.md` (written by a fresh reviewer from the `review-brief.mjs` brief, with +`run-verify.mjs` (no `--fast`) printed `pass` for every lane the change touched, on the content now +on disk. For a light change that is all. For standard and strict: `.verify/review-backend.md` (written by a fresh reviewer from the `review-brief.mjs` brief, with `code-review.md`) names that same tree, has no open line, marks every acceptance id and every triggered checklist item, and says `Verdict: approved`; `make-evidence.mjs` wrote the evidence pack after it, for the same tree; diff --git a/plugins/dx-workflow/skills/backend/build.md b/plugins/dx-workflow/skills/backend/build.md index 1cb87bf..6e35635 100644 --- a/plugins/dx-workflow/skills/backend/build.md +++ b/plugins/dx-workflow/skills/backend/build.md @@ -1,7 +1,7 @@ # Build: changing the backend -1. Read `docs/backend.md`, the contract file and `.verify/acceptance.md`. No acceptance file yet: - write it now with `/shared/acceptance.md`, going through the API and data adverse cases. +1. Read `docs/backend.md`, the contract file and `.verify/acceptance.md`. A Medium or Large change + with no acceptance file yet: write it now with `/shared/acceptance.md`, going through the API and data adverse cases. 2. Find who depends on what you will change: callers of the functions, clients of the endpoints, readers of the tables and of the events or jobs. Grep stops at the code; also check the contract file, the web app's API client, queue consumers, reports and other services reading the same tables. @@ -28,7 +28,8 @@ handling the duplicate, or an atomic `UPDATE … WHERE state = old`), never check-then-insert. Errors use the format in `docs/backend.md`; never swallow an exception or return success on failure; log with the request id, never secrets or personal data. -8. Run the lane's fast checks while you work (`run-verify.mjs --lane backend --only types,unit`), then go to `verify.md`. +8. Run the lane's fast checks while you work (`run-verify.mjs --lane backend --fast`); when the change + has settled, go to `verify.md` for the full run and the review. Debugging a failure on the way: reproduce it in one focused test, find the cause, fix the cause, keep the test. Two fixes that did not hold mean you have not found the cause; stop guessing and trace it. diff --git a/plugins/dx-workflow/skills/backend/verify.md b/plugins/dx-workflow/skills/backend/verify.md index 2376a0b..2c41085 100644 --- a/plugins/dx-workflow/skills/backend/verify.md +++ b/plugins/dx-workflow/skills/backend/verify.md @@ -1,8 +1,10 @@ # Verify: prove the backend change works -What a change needs depends on its level (`node /scripts/level.mjs`): a **light** change is -done when the checks below pass, with no acceptance file, review or evidence pack. **Standard** and -**strict** changes go on to the independent review; the Stop gate makes the evidence pack. +Verification has two speeds. While you build, `run-verify.mjs --fast` runs the checks without +`"stage": "final"` turn by turn; that is all the Stop gate asks for. Once, when the change is ready, +run it without `--fast` so the final checks (functional journeys, security scans) run too. Then by +level (`node /scripts/level.mjs`): a **light** change is done; **standard** and **strict** +changes go on to the independent review; the Stop gate makes the evidence pack. ## Run the checks diff --git a/plugins/dx-workflow/skills/frontend/SKILL.md b/plugins/dx-workflow/skills/frontend/SKILL.md index 1a1bcfb..0369245 100644 --- a/plugins/dx-workflow/skills/frontend/SKILL.md +++ b/plugins/dx-workflow/skills/frontend/SKILL.md @@ -8,7 +8,8 @@ description: Use when building, restyling or reviewing any user-facing screen, p ## Overview One project has one style. `docs/design.md` plus one token file is the contract every screen -follows, and a screen is not done until `run-verify.mjs` passes and its screenshots were reviewed. +follows. While building, the fast checks keep it honest; once the change is ready, the screenshots +and journeys run and, for standard and strict changes, a fresh reviewer looks at them. Third-party design skills are tools this workflow calls; they never override the contract. `` below is this skill's folder; `` is two levels up (it holds `scripts/`). @@ -22,7 +23,7 @@ Third-party design skills are tools this workflow calls; they never override the | No `.verify/config.json` | `node /scripts/init.mjs`, then come back | | No `docs/design.md`, and the change adds or restyles screens | `setup.md` for the design contract (ask the developer first: it takes their decisions); for small changes follow the existing components and styles | | The app is React Native or Expo (a lane with `"platform": "react-native"`) | `mobile.md` alongside every file below | -| Any change | `/shared/acceptance.md` first: write `.verify/acceptance.md` | +| A Medium or Large change (the `workflow` skill sizes it) | `/shared/acceptance.md` first: write `.verify/acceptance.md` | | Request: one page/module should look different from `docs/design.md` | "Style change requests" below | | Building or changing a screen | `build.md`, then `verify.md` | | Asked only to review or check UI | `verify.md`, then `design-review.md` and `code-review.md` | @@ -76,9 +77,11 @@ A tool missing: say which, continue with this skill's own checks, never pretend ## Done means -`run-verify.mjs` printed `pass` for every lane the change touched, on the content now on disk; -`.verify/review-frontend.md` (written by a fresh reviewer from the `review-brief.mjs` brief, with -`design-review.md` and `code-review.md`) names that same tree, has no open line, marks every acceptance id from -`.verify/acceptance.md` and every triggered checklist item, and says `Verdict: approved`; -`make-evidence.mjs` wrote the evidence pack after it, for the same tree; and your final message starts with the evidence path and the merge tier, -then lists the follow-ups, the criteria not checked and what could not be checked. +While building: `run-verify.mjs --fast` passed for every touched lane on the content on disk. +Done, once the change is ready: `run-verify.mjs` (no `--fast`) printed `pass`, so the look, +functional and inspect checks ran on that content. For a light change that is all. For standard and +strict: `.verify/review-frontend.md` (a fresh reviewer, from the `review-brief.mjs` brief, with +`design-review.md` when something visual changed and `code-review.md`) names that same tree, has no +open line, marks every acceptance id and triggered checklist item, and says `Verdict: approved`; the +evidence pack was made after it; and your final message starts with the evidence path and the merge +tier, then lists the follow-ups, the criteria not checked and what could not be checked. diff --git a/plugins/dx-workflow/skills/frontend/build.md b/plugins/dx-workflow/skills/frontend/build.md index 1c4c3d0..66bc20a 100644 --- a/plugins/dx-workflow/skills/frontend/build.md +++ b/plugins/dx-workflow/skills/frontend/build.md @@ -3,7 +3,7 @@ In a React Native / Expo app, also follow `mobile.md` "Build" (safe areas, keyboard, Android back, large text, native changes) and its mobile adverse cases. -0. No `.verify/acceptance.md` for this change yet: write it with `/shared/acceptance.md`, +0. A Medium or Large change with no `.verify/acceptance.md` yet: write it with `/shared/acceptance.md`, going through the UI adverse cases (invalid input, keyboard, slow and failed requests, double submit, 390px, no permission). Each criterion names its proof: a page and state in `ui-pages.json`, a journey, or a test. @@ -20,8 +20,9 @@ large text, native changes) and its mobile adverse cases. lacks something, add a token and a line in design.md in the same change. 5. A third copy of the same markup becomes a part in the shared component folder and a row in design.md's Parts table. -6. Run `node scripts/ui/check-raw-styles.mjs ` and fix every finding. -7. Go to `verify.md`. +6. Run `node /scripts/run-verify.mjs --fast` as you go (raw-styles, types, lint, unit) and + fix every finding. No screenshots yet. +7. When the change has settled, go to `verify.md` for the final run and the review. ## Prototype: three structures, one style diff --git a/plugins/dx-workflow/skills/frontend/mobile.md b/plugins/dx-workflow/skills/frontend/mobile.md index 3268ae1..59412d4 100644 --- a/plugins/dx-workflow/skills/frontend/mobile.md +++ b/plugins/dx-workflow/skills/frontend/mobile.md @@ -58,7 +58,8 @@ Playwright, the web or 390 px, use what this file says instead. ## Verify -`run-verify.mjs` runs the lane as everywhere. The look check is `rn-look.mjs`; it writes screenshots +`run-verify.mjs` runs the lane as everywhere: `--fast` while building, and the simulator checks +(`look`, `functional`, both `"stage": "final"`) once the change is ready. The look check is `rn-look.mjs`; it writes screenshots named `---.png`, which the evidence pack shows next to the baselines. A baseline change is merge tier 2: review the images before `--update`. diff --git a/plugins/dx-workflow/skills/frontend/verify.md b/plugins/dx-workflow/skills/frontend/verify.md index b6d5699..5c10be9 100644 --- a/plugins/dx-workflow/skills/frontend/verify.md +++ b/plugins/dx-workflow/skills/frontend/verify.md @@ -1,9 +1,13 @@ # Verify: prove the screen is right -What a change needs depends on its level (`node /scripts/level.mjs`): a **light** change is -done when the lane's checks pass, with no acceptance file, review or evidence pack. **Standard** and -**strict** changes go on to the independent review (with a screenshot review only when something -visual changed); the Stop gate makes the evidence pack. +Verification has two speeds. **While you build**, run `node /scripts/run-verify.mjs --fast`: +the cheap checks (raw-styles, types, lint, unit, negative), turn by turn; that is all the Stop gate +asks for. **Once, when the change is ready**, run it without `--fast`: the checks marked +`"stage": "final"` (look, functional, inspect) run too, and then, by level +(`node /scripts/level.mjs`): a **light** change is done; **standard** and **strict** changes go +on to the independent review (with a screenshot review only when something visual changed), and the +Stop gate makes the evidence pack. Screenshots taken mid-change are thrown away by the next edit, so +do not take them, update baselines or ask for a review before the change has settled. In a React Native / Expo lane the look check is `rn-look.mjs` (simulators, default, dark and large-text variants) and the journeys are Maestro flows; read `mobile.md` "Verify" for what a phone @@ -12,16 +16,17 @@ adds. Use `--lane ` with the lane's name (`app`, `web`, …). ## Run the checks `node /scripts/run-verify.mjs --lane frontend` runs the frontend lane's checks in `.verify/config.json` -(without `--lane`, every lane) and records the result from real exit codes. Logs and screenshots land +(without `--lane`, every lane; with `--fast`, without the final stage) and records the result from real exit codes. Logs and screenshots land in the printed run folder. When the change also touched the backend lane, both lanes must pass. -| Check | Passes when | -| --- | --- | -| raw-styles | no palette classes, arbitrary values or literal colours in UI source | -| types, functional | the project's typecheck passes; its e2e suite or the `verify-` journeys pass | -| look | every page in `ui-pages.json` at 390, 768 and 1280: no sideways scroll, no serious axe issue, screenshot matches its baseline | -| inspect | taste-skill `inspect.mjs` reports 0 FAIL (only design.md's allowances passed with `--allow`) | -| native (if any) | Maestro or the platform's runner captures each changed screen | +| Check | Stage | Passes when | +| --- | --- | --- | +| raw-styles | fast | no palette classes, arbitrary values or literal colours in UI source | +| types | fast | the project's typecheck passes | +| functional | final | its e2e suite or the `verify-` journeys pass | +| look | final | every page in `ui-pages.json` at 390, 768 and 1280: no sideways scroll, no serious axe issue, screenshot matches its baseline | +| inspect | final | taste-skill `inspect.mjs` reports 0 FAIL (only design.md's allowances passed with `--allow`) | +| native (if any) | final | Maestro or the platform's runner captures each changed screen | A check that cannot run here (no browser, server will not start, simulator missing): fix the setup if you can; otherwise stop and tell the user exactly which check did not run. Never mark it passed. @@ -71,8 +76,7 @@ cannot loop forever; ending that way means your final message must say the UI is ## Evidence pack and merge tier -People read evidence instead of code. After the review, run -The Stop gate runs `node /scripts/make-evidence.mjs` itself after the review (run it with `--pr` when you will open a pull request). It writes `/evidence.md`: the merge tier, +People read evidence instead of code. The Stop gate runs `node /scripts/make-evidence.mjs` itself after the review (run it with `--pr` when you will open a pull request). It writes `/evidence.md`: the merge tier, the checks, before/after screenshots per page and width, recordings, the verdict, open and deferred findings, what was not checked, and the merge danger (door, blast radius, how to revert). The Stop gate requires it for the tree on disk, written after the review. diff --git a/plugins/dx-workflow/skills/workflow/SKILL.md b/plugins/dx-workflow/skills/workflow/SKILL.md index 8975dcf..827bad4 100644 --- a/plugins/dx-workflow/skills/workflow/SKILL.md +++ b/plugins/dx-workflow/skills/workflow/SKILL.md @@ -29,11 +29,11 @@ Understand → Plan → Implement → Verify → Complete `standard` or `strict`, and why. Auth, payments, permissions, migrations, contracts, native app config, sensitive paths or changes to the checks make a change `strict` however small it is. -| Level | Verify asks for | -| --- | --- | -| light | the lane's checks pass (`run-verify.mjs`). That is all. | -| standard | acceptance criteria, the checks, one independent review. The evidence pack is made for you. | -| strict | as standard, with a deep review and a security pass; the owner approves the merge (tier 3). | +| Level | Every turn while implementing | Once, when the change is ready | +| --- | --- | --- | +| light | fast checks pass (`run-verify.mjs --fast`) | the full run (final checks too). That is all. | +| standard | fast checks pass | the full run, then acceptance checked by one independent review; the evidence pack is made for you | +| strict | fast checks pass | as standard, with a deep review and a security pass; the owner approves the merge (tier 3) | A Small change is usually light, but size does not lower risk: a one-line change to a login check is strict. Run `level.mjs` again after implementing; the Stop gate uses the real diff. @@ -57,17 +57,27 @@ architecture section and the task list (`large.md`; `superpowers:writing-plans` tasks can run in parallel in worktrees (`superpowers:using-git-worktrees`); otherwise do not start subagents while building. -**4. Verify.** `node /scripts/run-verify.mjs`. When it says a check "failed again", stop and -find the cause (`/shared/debug.md`; `superpowers:systematic-debugging` or -`mattpocock-skills:diagnosing-bugs`). Then by level: light is done when the checks pass. Standard and -strict: one independent review, the only subagent this workflow starts by default: +The inner loop is `node /scripts/run-verify.mjs --fast`: it skips the checks marked +`"stage": "final"` (screenshots, e2e journeys, inspect, security scans) and is all the Stop gate asks +for turn by turn. When it says a check "failed again", stop and find the cause +(`/shared/debug.md`; `superpowers:systematic-debugging` or `mattpocock-skills:diagnosing-bugs`). +Do not take screenshots, update baselines or ask for a review while the change is still moving: +each would be thrown away by the next edit. + +**4. Verify, once, when the change is ready.** `node /scripts/run-verify.mjs` (no `--fast`): +every check, final ones included. Light is done when it passes. Standard and strict: one independent +review, the only subagent this workflow starts by default: `node /scripts/review-brief.mjs --lane --request ""`, dispatched to a fresh -subagent. The brief picks the reviews the diff needs (code always; UI only when something visual -changed; contract compatibility; security for risky changes). Fix what it finds; at most two rounds, -then hand the open findings to the developer. The Stop gate checks all of this and makes the evidence pack. +subagent. The brief picks the reviews the diff needs (code always; screenshots only when something +visual changed; contract compatibility; security for risky changes). Fix what it finds, run again; +at most two rounds, then hand the open findings to the developer. The Stop gate makes the evidence pack. + +The one visual step that stays early is a prototype the developer picks from (frontend `build.md`): +that is a design decision, not verification. **5. Complete.** Tell the developer in a few lines: what changed, the level and merge tier, anything -not verified and why. For standard and strict, the pull request body comes from +not verified and why. If you stop before step 4 (the developer wants to keep iterating), say that +only the fast checks ran; the Stop gate shows them the same. For standard and strict, the pull request body comes from `make-evidence.mjs --pr`. A Blocker the review found, a revert or a correction from the developer goes through `/shared/ratchet.md` afterwards, so the next change cannot repeat it. @@ -85,6 +95,7 @@ Otherwise keep going; do not ask permission for each step. - No file a step does not need: Small writes none; Medium writes the acceptance file only. - No review, no evidence pack and no subagent for light changes. +- Slow checks and the review run once per change, not once per turn. - No step for its own sake: if a phase has nothing to do for this change, skip it silently. - Other skills do the work inside a step; this plugin's files, gates and review decide when it is done (`/shared/skill-packs.md`). diff --git a/test/helpers.mjs b/test/helpers.mjs index 2728d8c..3a2cb74 100644 --- a/test/helpers.mjs +++ b/test/helpers.mjs @@ -86,8 +86,18 @@ export function node(script, args = [], { cwd, input, env = {} } = {}) { return { code: r.status, stdout: r.stdout, stderr: r.stderr }; } -/** Runs the Stop gate; returns the parsed block decision or null when it let the turn end. */ +/** + * Runs the Stop gate; returns the parsed block decision or null when it let the turn end. + * Defaults to DX_WORKFLOW_GATE=full (everything every turn), which most tests exercise; the default + * mode ("enforce": fast checks per turn, the rest reported) has its own tests via gateOutput. + */ export function gate(root, input = {}, env = {}) { + const out = gateOutput(root, input, { DX_WORKFLOW_GATE: "full", ...env }); + return out?.decision === "block" ? out : null; +} + +/** The Stop gate's raw JSON output (a block, a systemMessage) or null, in the default mode unless env says otherwise. */ +export function gateOutput(root, input = {}, env = {}) { const r = node("stop-gate.mjs", [], { cwd: root, input: { cwd: root, ...input }, env }); return r.stdout.trim() ? JSON.parse(r.stdout) : null; } diff --git a/test/stages.test.mjs b/test/stages.test.mjs new file mode 100644 index 0000000..8c8c205 --- /dev/null +++ b/test/stages.test.mjs @@ -0,0 +1,95 @@ +import assert from "node:assert/strict"; +import { after, describe, it } from "node:test"; +import { addFeature, CONFIG, cleanup, evidenceText, gate, gateOutput, makeProject, node, read, verify, write } from "./helpers.mjs"; + +// The backend lane plus a slow "look" check that only runs in the final stage. It writes a marker +// so the tests can tell whether it ran. +const STAGED = { + ...CONFIG, + lanes: { + backend: { + ...CONFIG.lanes.backend, + checks: [...CONFIG.lanes.backend.checks, { name: "look", stage: "final", run: 'node -e "require(\'fs\').writeFileSync(process.env.VERIFY_RUN_DIR + \'/looked\', \'1\')"' }], + }, + }, +}; + +const roots = []; +const project = () => { + const r = makeProject({ config: STAGED }); + roots.push(r); + return r; +}; +after(() => roots.forEach(cleanup)); +const lastRun = (root) => JSON.parse(read(root, ".verify/last-run.json")); + +describe("fast and final stages", () => { + it("run-verify --fast skips final checks and records the lane as fast; a full run records pass", () => { + const root = project(); + addFeature(root); + const r = node("run-verify.mjs", ["--fast"], { cwd: root }); + assert.equal(r.code, 0, r.stdout + r.stderr); + assert.match(r.stdout, /backend\/look … not run \(stage final/); + assert.match(r.stdout, /run run-verify\.mjs without --fast/); + const fast = lastRun(root).lanes.backend; + assert.equal(fast.result, "fast"); + assert.deepEqual(fast.checks.find((c) => c.name === "look"), { ...fast.checks.find((c) => c.name === "look"), skipped: true, stage: "final" }); + + const full = node("run-verify.mjs", [], { cwd: root }); + assert.equal(full.code, 0, full.stdout); + assert.equal(lastRun(root).lanes.backend.result, "pass"); + assert.match(read(root, `${lastRun(root).runDir.replace(root + "/", "")}/looked`), /1/); + }); + + it("the default gate lets a turn end on fast checks and tells the person what the final verification lacks", () => { + const root = project(); + addFeature(root); + node("run-verify.mjs", ["--fast"], { cwd: root }); + const out = gateOutput(root); + assert.equal(out.decision, undefined); + assert.match(out.systemMessage, /fast checks pass; final verification still to do/); + assert.match(out.systemMessage, /final checks have not run \(look\)/); + assert.equal(JSON.parse(read(root, ".verify/gate.log").trim().split("\n").at(-1)).decision, "final-pending"); + }); + + it("the default gate still blocks a turn whose fast checks are stale or failing", () => { + const root = project(); + addFeature(root); + node("run-verify.mjs", ["--fast"], { cwd: root }); + write(root, { "src/math.mjs": read(root, "src/math.mjs") + "// later edit\n" }); + const out = gateOutput(root); + assert.equal(out.decision, "block"); + assert.match(out.reason, /files changed since the last run-verify/); + assert.match(out.reason, /run-verify\.mjs --fast/); + assert.doesNotMatch(out.reason, /review-backend\.md is missing/); + + write(root, { "src/math.mjs": "export const add = (a, b) => a - b;\nexport const sub = (a, b) => a - b;\n" }); + node("run-verify.mjs", ["--fast"], { cwd: root }); + assert.match(gateOutput(root).reason, /result is "fail"/); + }); + + it("full mode blocks a fast-only run until the final checks and the review are done", () => { + const root = project(); + addFeature(root); + node("run-verify.mjs", ["--fast"], { cwd: root }); + assert.match(gate(root).reason, /final checks have not run \(look\)/); + const { evidence } = verify(root); + assert.equal(evidence.code, 0, evidence.stderr); + assert.equal(gate(root), null); + assert.equal(gateOutput(root, {}, { DX_WORKFLOW_GATE: "enforce" }), null, "nothing left to report"); + }); + + it("a fast-only run is not ready to merge, and the review waits for the final checks", () => { + const root = project(); + addFeature(root); + node("run-verify.mjs", ["--fast"], { cwd: root }); + const brief = node("review-brief.mjs", ["--lane", "backend", "--request", "add sub"], { cwd: root }); + assert.equal(brief.code, 2); + assert.match(brief.stderr, /only the fast checks ran/); + + write(root, { ".verify/acceptance.md": "# Acceptance\n## Criteria\n- A1 sub works · proof: test/run.mjs\n" }); + node("make-evidence.mjs", [], { cwd: root }); + assert.match(evidenceText(root), /Merge tier: not ready/); + assert.match(evidenceText(root), /only the fast checks ran/); + }); +}); From 7a7269a66081a331605447c51dfefa6a767540de Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 12:00:07 +1100 Subject: [PATCH 2/2] Fix stages test on macOS, where the temp dir is a symlink run-verify records the real path of the run directory (/private/var/...), so stripping the project root from it failed when the root was given through the /var symlink. Read the file at the recorded path instead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JaMb11KUWULtVrTGwgNRJt --- test/stages.test.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/stages.test.mjs b/test/stages.test.mjs index 8c8c205..fd27ab0 100644 --- a/test/stages.test.mjs +++ b/test/stages.test.mjs @@ -1,4 +1,6 @@ import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; import { after, describe, it } from "node:test"; import { addFeature, CONFIG, cleanup, evidenceText, gate, gateOutput, makeProject, node, read, verify, write } from "./helpers.mjs"; @@ -38,7 +40,8 @@ describe("fast and final stages", () => { const full = node("run-verify.mjs", [], { cwd: root }); assert.equal(full.code, 0, full.stdout); assert.equal(lastRun(root).lanes.backend.result, "pass"); - assert.match(read(root, `${lastRun(root).runDir.replace(root + "/", "")}/looked`), /1/); + // runDir is the real path (on macOS /var is /private/var), so read it as recorded. + assert.equal(readFileSync(join(lastRun(root).runDir, "looked"), "utf8"), "1"); }); it("the default gate lets a turn end on fast checks and tells the person what the final verification lacks", () => {