@gobing-ai/spur 0.3.92 → 0.3.93
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/config/pipeline-budgets.json +0 -7
- package/config/plugin-scripts.json +10 -0
- package/config/templates/AGENTS.md +4 -0
- package/config/templates/docs/02_ROADMAP.md +2 -0
- package/config/templates/docs/03_ARCHITECTURE.md +3 -1
- package/config/templates/docs/04_DESIGN.md +2 -0
- package/config/templates/docs/99_PROJECT_CONSTITUTION.md +10 -2
- package/config/workflow-candidates.json +72 -1
- package/config/workflows/feature-verification.yaml +1 -0
- package/config/workflows/history-anatomy.yaml +2 -0
- package/config/workflows/idea-pipeline.yaml +67 -18
- package/config/workflows/pr-review.yaml +8 -0
- package/config/workflows/task-pipeline.yaml +180 -39
- package/config/workflows/wayfinder-resolution.yaml +5 -0
- package/config/workflows/wrapup-pipeline.yaml +55 -14
- package/package.json +9 -9
- package/plugins/sp/README.md +7 -2
- package/plugins/sp/commands/dev-run.md +2 -2
- package/plugins/sp/commands/dev-runall.md +2 -2
- package/plugins/sp/lib/idea-handoff.generated.mjs +8 -4
- package/plugins/sp/lib/inline-run.generated.d.mts +1 -0
- package/plugins/sp/lib/inline-run.generated.mjs +24 -16
- package/plugins/sp/plugin.json +1 -1
- package/plugins/sp/scripts/inline-pipeline-parity-check.ts +1 -1
- package/plugins/sp/scripts/inline-run-setup.mjs +75 -3
- package/plugins/sp/scripts/inline-run-setup.ts +133 -3
- package/plugins/sp/scripts/quality-gate.mjs +248 -6
- package/plugins/sp/scripts/quality-gate.ts +410 -9
- package/plugins/sp/scripts/residual-scan.mjs +12 -4
- package/plugins/sp/scripts/residual-scan.ts +32 -6
- package/plugins/sp/scripts/task-diffstat.mjs +156 -0
- package/plugins/sp/scripts/task-diffstat.ts +229 -0
- package/plugins/sp/scripts/wrapup-drift-probe.mjs +181 -0
- package/plugins/sp/scripts/wrapup-drift-probe.ts +258 -0
- package/plugins/sp/scripts/wrapup-steps.mjs +60 -1
- package/plugins/sp/scripts/wrapup-steps.ts +89 -4
- package/plugins/sp/skills/brainstorm/SKILL.md +2 -0
- package/plugins/sp/skills/brainstorm/references/workflows.md +17 -2
- package/plugins/sp/skills/code-verification/SKILL.md +2 -2
- package/plugins/sp/skills/code-verification/references/secu-review.md +3 -2
- package/plugins/sp/skills/spur-check/SKILL.md +112 -0
- package/plugins/sp/skills/spur-dev/SKILL.md +2 -1
- package/plugins/sp/skills/spur-dev/references/cross-cutting.md +14 -2
- package/plugins/sp/skills/spur-dev/references/document-authoring.md +85 -0
- package/plugins/sp/skills/spur-dev/references/execution-batch.md +1 -1
- package/plugins/sp/skills/spur-dev/references/flag-glossary.md +8 -0
- package/plugins/sp/skills/spur-dev/references/gate-checklists.md +3 -2
- package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +19 -1
- package/plugins/sp/skills/spur-dev/references/planning-workflow.md +5 -5
- package/plugins/sp/skills/spur-dev/templates/design.md +31 -0
- package/plugins/sp/skills/spur-dev/templates/plan.md +32 -0
- package/plugins/sp/skills/spur-doctor/SKILL.md +60 -14
- package/schemas/state-machine-workflow.schema.json +4 -0
- package/spur.js +1117 -472
- package/config/workflows/decision-routing-example.yaml +0 -134
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* wrapup-drift-probe — deterministic doc-ownership drift probe behind the wrapup-pipeline
|
|
4
|
+
* task-resolve onEnter (task 0944, feature D64, ADR-115 composition budgets).
|
|
5
|
+
*
|
|
6
|
+
* Reads the validated wrapup capture `.spur/run/<runId>-wrapup-tasks.json` (never raw
|
|
7
|
+
* vars.tasks — 0783 contract), runs `spur task show <wbs> --json` per member, collects the
|
|
8
|
+
* changed paths from each task's `### Solution` file:line map, and writes:
|
|
9
|
+
* - `<runId>-drift-probe.json` `{ clean: boolean, reasons: string[], paths: string[] }`
|
|
10
|
+
* - `<runId>-mode.txt` projected wrapup mode: `fast` when clean, empty otherwise
|
|
11
|
+
*
|
|
12
|
+
* The probe runs ONLY when the caller left `mode` empty; a caller-set mode is projected
|
|
13
|
+
* verbatim by the workflow wrapper and this script is never invoked (0944 R3).
|
|
14
|
+
*
|
|
15
|
+
* Dirty (clean=false, mode stays empty → the safety route) whenever ANY changed path
|
|
16
|
+
* matches a doc-owned surface (AGENTS.md doc map + docs/99_PROJECT_CONSTITUTION.md
|
|
17
|
+
* ownership table), or a task's Solution section is empty or unparseable (fail safe —
|
|
18
|
+
* a wrapup without a readable change map must still reach doc-sync). Paths under the
|
|
19
|
+
* task/feature corpus are never treated as drift.
|
|
20
|
+
*
|
|
21
|
+
* Node-builtin imports only; the spur lookup is a spawnable `SpurRunner` so tests can
|
|
22
|
+
* fake it; `main(argv, env, options)` is the same injection point the workflow wrapper
|
|
23
|
+
* and its node twin exercise. Always exits 0 after probing; only an empty `__runId`
|
|
24
|
+
* (mis-invocation) exits 1.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { spawnSync } from 'node:child_process';
|
|
28
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
29
|
+
import { join } from 'node:path';
|
|
30
|
+
import { getEnvVars } from '../lib/env';
|
|
31
|
+
|
|
32
|
+
export interface DriftProbeEnv {
|
|
33
|
+
__runId?: string;
|
|
34
|
+
spurBin?: string;
|
|
35
|
+
[key: string]: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DriftProbeOptions {
|
|
39
|
+
/** Base directory for `.spur/run`; defaults to the process cwd. */
|
|
40
|
+
cwd?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Minimal spawnable spur surface — tests fake this to return canned `task show` output. */
|
|
44
|
+
export interface SpurShowResult {
|
|
45
|
+
status: number;
|
|
46
|
+
stdout: string;
|
|
47
|
+
}
|
|
48
|
+
export type SpurRunner = (args: string[]) => SpurShowResult;
|
|
49
|
+
|
|
50
|
+
export interface DriftProbeResult {
|
|
51
|
+
clean: boolean;
|
|
52
|
+
reasons: string[];
|
|
53
|
+
paths: string[];
|
|
54
|
+
probeFile: string;
|
|
55
|
+
modeFile: string;
|
|
56
|
+
/** Exit code the workflow wrapper observes (only an empty __runId is a hard failure). */
|
|
57
|
+
exitCode: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Doc-owned surfaces (0944 R2): a changed path under any of these means doc-sync must
|
|
62
|
+
* still run. Mirrors the AGENTS.md documentation map and the
|
|
63
|
+
* docs/99_PROJECT_CONSTITUTION.md ownership table: contracts / cli commands / config /
|
|
64
|
+
* migrations / workflow YAML / plugin commands, skills and hooks / root manifest / the
|
|
65
|
+
* authoritative docs (00_ADR, 03_ARCHITECTURE, 04_DESIGN, docs/design). docs/tasks* and
|
|
66
|
+
* docs/features/* (the corpus) are intentionally absent — they are never drift.
|
|
67
|
+
*
|
|
68
|
+
* WHY join('config', 'workflows'): rule sp-runtime-path forbids the literal
|
|
69
|
+
* config/<dir> in runtime source; this constant is a drift TARGET (Solution
|
|
70
|
+
* change-map paths against the build-time SSOT), not a runtime config read.
|
|
71
|
+
*/
|
|
72
|
+
const WORKFLOWS_GLOB = `${join('config', 'workflows')}/**`;
|
|
73
|
+
export const DOC_OWNED_SURFACES = [
|
|
74
|
+
'packages/contracts/**',
|
|
75
|
+
'apps/cli/src/commands/**',
|
|
76
|
+
'packages/config/src/**',
|
|
77
|
+
'drizzle/*.sql',
|
|
78
|
+
WORKFLOWS_GLOB,
|
|
79
|
+
'plugins/sp/commands/**',
|
|
80
|
+
'plugins/sp/skills/**',
|
|
81
|
+
'plugins/sp/hooks/**',
|
|
82
|
+
'package.json',
|
|
83
|
+
'docs/00_ADR.md',
|
|
84
|
+
'docs/03_ARCHITECTURE.md',
|
|
85
|
+
'docs/04_DESIGN.md',
|
|
86
|
+
'docs/design/**',
|
|
87
|
+
] as const;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Top-level workspace entries from the AGENTS.md stack layout. A changed path whose first
|
|
91
|
+
* segment is none of these is a new top-level workspace directory — doc-owned by default.
|
|
92
|
+
* Single-segment paths (root files) are not directories and are exempt.
|
|
93
|
+
*/
|
|
94
|
+
const KNOWN_TOP_LEVEL = new Set([
|
|
95
|
+
'apps',
|
|
96
|
+
'packages',
|
|
97
|
+
'plugins',
|
|
98
|
+
'config',
|
|
99
|
+
'docs',
|
|
100
|
+
'drizzle',
|
|
101
|
+
'scripts',
|
|
102
|
+
'vendors',
|
|
103
|
+
'package.json',
|
|
104
|
+
'bun.lock',
|
|
105
|
+
'bunfig.toml',
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
/** Corpus paths (task/feature records) are never drift — excluded before surface matching. */
|
|
109
|
+
const CORPUS_PREFIXES = ['docs/tasks', 'docs/features/'];
|
|
110
|
+
|
|
111
|
+
/** `### Solution` section of a task record (tolerates `##`–`####` heading depth). */
|
|
112
|
+
export function solutionSectionOf(content: string): string | null {
|
|
113
|
+
const heading = /^#{2,4}\s+Solution\s*$/m.exec(content);
|
|
114
|
+
if (!heading) return null;
|
|
115
|
+
const rest = content.slice(heading.index + heading[0].length);
|
|
116
|
+
const next = /^#{2,4}\s+\S/m.exec(rest);
|
|
117
|
+
return next ? rest.slice(0, next.index) : rest;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const CHANGE_ENTRY = /`([^`\r\n]+):(\d+)(?:-\d+)?`/g;
|
|
121
|
+
|
|
122
|
+
/** Backticked `path:line` (or `path:line-range`) tokens from a Solution section. */
|
|
123
|
+
export function changedPathsOf(section: string | null): string[] {
|
|
124
|
+
if (section === null) return [];
|
|
125
|
+
const paths: string[] = [];
|
|
126
|
+
for (const match of section.matchAll(CHANGE_ENTRY)) {
|
|
127
|
+
const path = match[1];
|
|
128
|
+
// Path-like: no whitespace and at least one separator or dotted suffix, so prose
|
|
129
|
+
// backticks never masquerade as change-map entries.
|
|
130
|
+
if (/\s/.test(path)) continue;
|
|
131
|
+
if (!path.includes('/') && !path.includes('.')) continue;
|
|
132
|
+
paths.push(path);
|
|
133
|
+
}
|
|
134
|
+
return paths;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function surfaceRegex(glob: string): RegExp {
|
|
138
|
+
const escaped = glob
|
|
139
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
140
|
+
.replaceAll('**', '\u0000')
|
|
141
|
+
.replaceAll('*', '[^/]*')
|
|
142
|
+
.replaceAll('\u0000', '.*');
|
|
143
|
+
return new RegExp(`^${escaped}$`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const SURFACE_MATCHERS = DOC_OWNED_SURFACES.map((glob) => ({ glob, regex: surfaceRegex(glob) }));
|
|
147
|
+
|
|
148
|
+
/** 0944 R2 surface match: doc-owned glob, corpus exclusion, new top-level directory. */
|
|
149
|
+
export function driftReasonForPath(path: string): string | null {
|
|
150
|
+
if (CORPUS_PREFIXES.some((prefix) => path.startsWith(prefix))) return null;
|
|
151
|
+
if (path.includes('/') && !KNOWN_TOP_LEVEL.has(path.split('/')[0])) {
|
|
152
|
+
return 'new top-level workspace directory';
|
|
153
|
+
}
|
|
154
|
+
const match = SURFACE_MATCHERS.find((entry) => entry.regex.test(path));
|
|
155
|
+
return match ? `matches doc-owned surface ${match.glob}` : null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function defaultSpurRunner(env: DriftProbeEnv, cwd?: string): SpurRunner {
|
|
159
|
+
const parts = (env.spurBin ?? 'spur').split(/\s+/).filter((part) => part.length > 0);
|
|
160
|
+
return (args: string[]): SpurShowResult => {
|
|
161
|
+
const run = spawnSync(parts[0], [...parts.slice(1), ...args], {
|
|
162
|
+
cwd,
|
|
163
|
+
encoding: 'utf8',
|
|
164
|
+
env: getEnvVars(),
|
|
165
|
+
});
|
|
166
|
+
return { status: run.status ?? 1, stdout: run.stdout ?? '' };
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* `probe` — classify the wrapup as clean (pure application-code change, no doc-owned
|
|
172
|
+
* surface touched) or dirty, and project the wrapup mode. Fail safe: every lookup or
|
|
173
|
+
* parse problem is a dirty probe, never a silent clean.
|
|
174
|
+
*/
|
|
175
|
+
export function runDriftProbe(
|
|
176
|
+
env: DriftProbeEnv,
|
|
177
|
+
options: DriftProbeOptions = {},
|
|
178
|
+
spur = defaultSpurRunner(env, options.cwd),
|
|
179
|
+
): DriftProbeResult {
|
|
180
|
+
const cwd = options.cwd;
|
|
181
|
+
const runId = env.__runId ?? '';
|
|
182
|
+
if (runId.length === 0) {
|
|
183
|
+
process.stderr.write('wrapup-drift-probe: __runId is empty — refusing the legacy fixed-path fallback\n');
|
|
184
|
+
return { clean: false, reasons: [], paths: [], probeFile: '', modeFile: '', exitCode: 1 };
|
|
185
|
+
}
|
|
186
|
+
const relProbeFile = join('.spur', 'run', `${runId}-drift-probe.json`);
|
|
187
|
+
const relModeFile = join('.spur', 'run', `${runId}-mode.txt`);
|
|
188
|
+
const relTasksFile = join('.spur', 'run', `${runId}-wrapup-tasks.json`);
|
|
189
|
+
const abs = (p: string): string => (cwd ? join(cwd, p) : p);
|
|
190
|
+
mkdirSync(abs(join('.spur', 'run')), { recursive: true });
|
|
191
|
+
// Write the dirty projection first so a crash mid-probe fails safe (mode stays empty).
|
|
192
|
+
writeFileSync(abs(relModeFile), '\n');
|
|
193
|
+
|
|
194
|
+
const finish = (clean: boolean, reasons: string[], paths: string[]): DriftProbeResult => {
|
|
195
|
+
writeFileSync(abs(relProbeFile), `${JSON.stringify({ clean, reasons, paths })}\n`);
|
|
196
|
+
writeFileSync(abs(relModeFile), clean ? 'fast\n' : '\n');
|
|
197
|
+
return { clean, reasons, paths, probeFile: relProbeFile, modeFile: relModeFile, exitCode: 0 };
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
let tasks: unknown;
|
|
201
|
+
try {
|
|
202
|
+
tasks = JSON.parse(readFileSync(abs(relTasksFile), 'utf8'));
|
|
203
|
+
} catch {
|
|
204
|
+
tasks = undefined;
|
|
205
|
+
}
|
|
206
|
+
if (!Array.isArray(tasks) || !tasks.every((wbs) => typeof wbs === 'string')) {
|
|
207
|
+
process.stderr.write(
|
|
208
|
+
'wrapup-drift-probe: normalized task capture is missing or corrupted — failing safe (dirty)\n',
|
|
209
|
+
);
|
|
210
|
+
return finish(false, ['normalized task capture missing or corrupted'], []);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const reasons: string[] = [];
|
|
214
|
+
const allPaths = new Set<string>();
|
|
215
|
+
for (const wbs of tasks as string[]) {
|
|
216
|
+
const shown = spur(['task', 'show', wbs, '--json']);
|
|
217
|
+
if (shown.status !== 0) {
|
|
218
|
+
reasons.push(`${wbs}: task show failed (status=${shown.status})`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let content: unknown;
|
|
222
|
+
try {
|
|
223
|
+
content = JSON.parse(shown.stdout).content;
|
|
224
|
+
} catch {
|
|
225
|
+
content = undefined;
|
|
226
|
+
}
|
|
227
|
+
if (typeof content !== 'string') {
|
|
228
|
+
reasons.push(`${wbs}: task show output unparseable`);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const changedPaths = changedPathsOf(solutionSectionOf(content));
|
|
232
|
+
if (changedPaths.length === 0) {
|
|
233
|
+
reasons.push(`${wbs}: Solution empty or unparseable`);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
for (const path of changedPaths) {
|
|
237
|
+
if (CORPUS_PREFIXES.some((prefix) => path.startsWith(prefix))) continue;
|
|
238
|
+
allPaths.add(path);
|
|
239
|
+
const drift = driftReasonForPath(path);
|
|
240
|
+
if (drift) reasons.push(`${wbs}: ${path} ${drift}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return finish(reasons.length === 0, reasons, [...allPaths].sort());
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export const WRAPUP_DRIFT_PROBE_USAGE = 'usage: wrapup-drift-probe (env: __runId, spurBin)';
|
|
247
|
+
|
|
248
|
+
export function main(argv: string[], env: DriftProbeEnv = getEnvVars(), options: DriftProbeOptions = {}): number {
|
|
249
|
+
if (argv.length > 0) {
|
|
250
|
+
process.stderr.write(`${WRAPUP_DRIFT_PROBE_USAGE}\n`);
|
|
251
|
+
return 2;
|
|
252
|
+
}
|
|
253
|
+
return runDriftProbe(env, options).exitCode;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (import.meta.main) {
|
|
257
|
+
process.exit(main(process.argv.slice(2)));
|
|
258
|
+
}
|
|
@@ -116,6 +116,62 @@ function resolveTasks(env, options = {}) {
|
|
|
116
116
|
`);
|
|
117
117
|
return { status: "PASS", statusFile: relStatusFile, tasksFile: relTasksFile, exitCode: 0 };
|
|
118
118
|
}
|
|
119
|
+
var ROUTE_REASON_TABLE = {
|
|
120
|
+
fast: "fast:evidence complete+consistent",
|
|
121
|
+
"": "safety:missing evidence (mode empty)",
|
|
122
|
+
unknown: "safety:unknown evidence quality",
|
|
123
|
+
conflict: "safety:conflicting evidence",
|
|
124
|
+
safety: "safety:operator-forced doc-sync"
|
|
125
|
+
};
|
|
126
|
+
function writeRouteReason(env, options = {}) {
|
|
127
|
+
const cwd = options.cwd;
|
|
128
|
+
const runId = env.__runId ?? "";
|
|
129
|
+
if (runId.length === 0) {
|
|
130
|
+
process.stderr.write(`task-resolve: __runId is empty \u2014 refusing to write a route reason
|
|
131
|
+
`);
|
|
132
|
+
return { reason: "", reasonFile: "", exitCode: 1 };
|
|
133
|
+
}
|
|
134
|
+
mkdirSync(cwd ? join(cwd, ".spur", "run") : join(".spur", "run"), { recursive: true });
|
|
135
|
+
mkdirSync(cwd ? join(cwd, ".spur", "memory") : join(".spur", "memory"), { recursive: true });
|
|
136
|
+
const relReasonFile = join(".spur", "run", `${runId}-route-reason.txt`);
|
|
137
|
+
const abs = (p) => cwd ? join(cwd, p) : p;
|
|
138
|
+
const statusFile = join(".spur", "run", `${runId}-wrapup-resolve.status`);
|
|
139
|
+
if (readFileSyncSafe(abs(statusFile))?.trim() === "FAIL") {
|
|
140
|
+
return { reason: "", reasonFile: relReasonFile, exitCode: 0 };
|
|
141
|
+
}
|
|
142
|
+
let taskCount = -1;
|
|
143
|
+
try {
|
|
144
|
+
const parsed = JSON.parse(readFileSync(abs(join(".spur", "run", `${runId}-wrapup-tasks.json`)), "utf8"));
|
|
145
|
+
if (Array.isArray(parsed))
|
|
146
|
+
taskCount = parsed.length;
|
|
147
|
+
} catch {}
|
|
148
|
+
let probeClean = false;
|
|
149
|
+
try {
|
|
150
|
+
const probe = JSON.parse(readFileSync(abs(join(".spur", "run", `${runId}-drift-probe.json`)), "utf8"));
|
|
151
|
+
probeClean = probe?.clean === true;
|
|
152
|
+
} catch {}
|
|
153
|
+
const mode = env.mode ?? "";
|
|
154
|
+
let reason;
|
|
155
|
+
if (taskCount === 0) {
|
|
156
|
+
reason = "skipped:empty task list";
|
|
157
|
+
} else if (mode === "fast" && probeClean) {
|
|
158
|
+
reason = "fast:drift-probe-clean";
|
|
159
|
+
} else {
|
|
160
|
+
reason = ROUTE_REASON_TABLE[mode] ?? `safety:unrecognized evidence (mode=${mode})`;
|
|
161
|
+
}
|
|
162
|
+
writeFileSync(abs(relReasonFile), `${reason}
|
|
163
|
+
`);
|
|
164
|
+
appendFileSync(abs(join(".spur", "memory", "wrapup-routes.log")), `${runId} ${reason}
|
|
165
|
+
`);
|
|
166
|
+
return { reason, reasonFile: relReasonFile, exitCode: 0 };
|
|
167
|
+
}
|
|
168
|
+
function readFileSyncSafe(path) {
|
|
169
|
+
try {
|
|
170
|
+
return readFileSync(path, "utf8");
|
|
171
|
+
} catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
119
175
|
function runMetrics(env, options = {}) {
|
|
120
176
|
const cwd = options.cwd;
|
|
121
177
|
const runId = env.__runId ?? "";
|
|
@@ -325,11 +381,13 @@ function runFeatureTransition(env, options = {}) {
|
|
|
325
381
|
`);
|
|
326
382
|
return { status: syncStatus, statusFile: relStatusFile, exitCode: 0 };
|
|
327
383
|
}
|
|
328
|
-
var WRAPUP_STEPS_USAGE = "usage: wrapup-steps.ts <resolve|metrics|feature-transition> (env: __runId, tasks, feature, featureGateCmd, spurBin)";
|
|
384
|
+
var WRAPUP_STEPS_USAGE = "usage: wrapup-steps.ts <resolve|route-reason|metrics|feature-transition> (env: __runId, tasks, mode, feature, featureGateCmd, spurBin)";
|
|
329
385
|
function main(argv, env = getEnvVars(), options = {}) {
|
|
330
386
|
const sub = argv[0];
|
|
331
387
|
if (sub === "resolve")
|
|
332
388
|
return resolveTasks(env, options).exitCode;
|
|
389
|
+
if (sub === "route-reason")
|
|
390
|
+
return writeRouteReason(env, options).exitCode;
|
|
333
391
|
if (sub === "metrics") {
|
|
334
392
|
runMetrics(env, options);
|
|
335
393
|
return 0;
|
|
@@ -344,6 +402,7 @@ function main(argv, env = getEnvVars(), options = {}) {
|
|
|
344
402
|
process.exit(main(process.argv.slice(2)));
|
|
345
403
|
}
|
|
346
404
|
export {
|
|
405
|
+
writeRouteReason,
|
|
347
406
|
taskStatusOf,
|
|
348
407
|
spurCommand,
|
|
349
408
|
runMetrics,
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* wrapup-steps — deterministic wrap-up capture, metrics and feature sync behind the
|
|
4
4
|
* wrapup-pipeline wrappers (task 0824, feature I21, governance §1.2 composition budgets).
|
|
5
5
|
*
|
|
6
|
-
* Reproduces the former wrapup-pipeline `task-resolve:onEnter:0`, `
|
|
7
|
-
*
|
|
6
|
+
* Reproduces the former wrapup-pipeline `task-resolve:onEnter:0`, `task-resolve:onEnter:1`
|
|
7
|
+
* (route-reason writer, moved here in 0944), `metrics-record:onEnter:0` and
|
|
8
|
+
* `feature-transition:onEnter:0` shell programs one-for-one so the workflow stays inside
|
|
8
9
|
* the shell-program caps while writing the same `.spur/run` artifacts:
|
|
9
10
|
* - `<runId>-wrapup-tasks.json` normalized, deduplicated WBS capture (resolve)
|
|
10
11
|
* - `<runId>-wrapup-resolve.status` `PASS`/`FAIL` (resolve)
|
|
11
|
-
* - `<runId>-route-reason.txt` route reason (
|
|
12
|
+
* - `<runId>-route-reason.txt` route reason (route-reason subcommand)
|
|
12
13
|
* - `.spur/memory/wrapup-metrics.jsonl` one row per task (metrics)
|
|
13
14
|
* - `<runId>-wrapup-metrics.status` `PASS`/`FAIL` (metrics)
|
|
14
15
|
* - `<runId>-wrapup-sync.status` `PASS`/`FAIL` (feature-transition)
|
|
@@ -185,6 +186,89 @@ export function resolveTasks(env: WrapupStepsEnv, options: WrapupStepsOptions =
|
|
|
185
186
|
return { status: 'PASS', statusFile: relStatusFile, tasksFile: relTasksFile, exitCode: 0 };
|
|
186
187
|
}
|
|
187
188
|
|
|
189
|
+
/**
|
|
190
|
+
* 0944 R3 route-reason map — mirrors the former inline jq object one-for-one, plus the
|
|
191
|
+
* `safety` entry (operator-forced doc-sync). `fast:drift-probe-clean` is NOT in the map:
|
|
192
|
+
* it is only claimable when the drift probe itself classified the wrapup clean.
|
|
193
|
+
*/
|
|
194
|
+
const ROUTE_REASON_TABLE: Record<string, string> = {
|
|
195
|
+
fast: 'fast:evidence complete+consistent',
|
|
196
|
+
'': 'safety:missing evidence (mode empty)',
|
|
197
|
+
unknown: 'safety:unknown evidence quality',
|
|
198
|
+
conflict: 'safety:conflicting evidence',
|
|
199
|
+
safety: 'safety:operator-forced doc-sync',
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export interface RouteReasonResult {
|
|
203
|
+
reason: string;
|
|
204
|
+
reasonFile: string;
|
|
205
|
+
exitCode: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* `route-reason` — derive the task-resolve route reason from the validated capture, the
|
|
210
|
+
* projected mode and the drift probe verdict (0944). A resolve FAIL keeps its own reason
|
|
211
|
+
* (nothing is written, exit 0). A missing or corrupted capture never yields a `skipped`
|
|
212
|
+
* or `fast:drift-probe-clean` claim. The log line is run-attributed (0770).
|
|
213
|
+
*/
|
|
214
|
+
export function writeRouteReason(env: WrapupStepsEnv, options: WrapupStepsOptions = {}): RouteReasonResult {
|
|
215
|
+
const cwd = options.cwd;
|
|
216
|
+
const runId = env.__runId ?? '';
|
|
217
|
+
if (runId.length === 0) {
|
|
218
|
+
process.stderr.write('task-resolve: __runId is empty — refusing to write a route reason\n');
|
|
219
|
+
return { reason: '', reasonFile: '', exitCode: 1 };
|
|
220
|
+
}
|
|
221
|
+
mkdirSync(cwd ? join(cwd, '.spur', 'run') : join('.spur', 'run'), { recursive: true });
|
|
222
|
+
mkdirSync(cwd ? join(cwd, '.spur', 'memory') : join('.spur', 'memory'), { recursive: true });
|
|
223
|
+
const relReasonFile = join('.spur', 'run', `${runId}-route-reason.txt`);
|
|
224
|
+
const abs = (p: string): string => (cwd ? join(cwd, p) : p);
|
|
225
|
+
|
|
226
|
+
const statusFile = join('.spur', 'run', `${runId}-wrapup-resolve.status`);
|
|
227
|
+
if (readFileSyncSafe(abs(statusFile))?.trim() === 'FAIL') {
|
|
228
|
+
// The failed reason stands; the failed edge already owns the run.
|
|
229
|
+
return { reason: '', reasonFile: relReasonFile, exitCode: 0 };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// A missing/corrupted capture stays at -1: never 0, so no skipped claim can be invented.
|
|
233
|
+
let taskCount = -1;
|
|
234
|
+
try {
|
|
235
|
+
const parsed: unknown = JSON.parse(
|
|
236
|
+
readFileSync(abs(join('.spur', 'run', `${runId}-wrapup-tasks.json`)), 'utf8'),
|
|
237
|
+
);
|
|
238
|
+
if (Array.isArray(parsed)) taskCount = parsed.length;
|
|
239
|
+
} catch {
|
|
240
|
+
// treated as uncountable below
|
|
241
|
+
}
|
|
242
|
+
let probeClean = false;
|
|
243
|
+
try {
|
|
244
|
+
const probe: unknown = JSON.parse(readFileSync(abs(join('.spur', 'run', `${runId}-drift-probe.json`)), 'utf8'));
|
|
245
|
+
probeClean = (probe as { clean?: unknown } | null)?.clean === true;
|
|
246
|
+
} catch {
|
|
247
|
+
// no probe verdict — the map decides
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const mode = env.mode ?? '';
|
|
251
|
+
let reason: string;
|
|
252
|
+
if (taskCount === 0) {
|
|
253
|
+
reason = 'skipped:empty task list';
|
|
254
|
+
} else if (mode === 'fast' && probeClean) {
|
|
255
|
+
reason = 'fast:drift-probe-clean';
|
|
256
|
+
} else {
|
|
257
|
+
reason = ROUTE_REASON_TABLE[mode] ?? `safety:unrecognized evidence (mode=${mode})`;
|
|
258
|
+
}
|
|
259
|
+
writeFileSync(abs(relReasonFile), `${reason}\n`);
|
|
260
|
+
appendFileSync(abs(join('.spur', 'memory', 'wrapup-routes.log')), `${runId} ${reason}\n`);
|
|
261
|
+
return { reason, reasonFile: relReasonFile, exitCode: 0 };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function readFileSyncSafe(path: string): string | null {
|
|
265
|
+
try {
|
|
266
|
+
return readFileSync(path, 'utf8');
|
|
267
|
+
} catch {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
188
272
|
export interface MetricsResult {
|
|
189
273
|
status: 'PASS' | 'FAIL';
|
|
190
274
|
statusFile: string;
|
|
@@ -448,11 +532,12 @@ export function runFeatureTransition(env: WrapupStepsEnv, options: WrapupStepsOp
|
|
|
448
532
|
}
|
|
449
533
|
|
|
450
534
|
export const WRAPUP_STEPS_USAGE =
|
|
451
|
-
'usage: wrapup-steps.ts <resolve|metrics|feature-transition> (env: __runId, tasks, feature, featureGateCmd, spurBin)';
|
|
535
|
+
'usage: wrapup-steps.ts <resolve|route-reason|metrics|feature-transition> (env: __runId, tasks, mode, feature, featureGateCmd, spurBin)';
|
|
452
536
|
|
|
453
537
|
export function main(argv: string[], env: WrapupStepsEnv = getEnvVars(), options: WrapupStepsOptions = {}): number {
|
|
454
538
|
const sub = argv[0];
|
|
455
539
|
if (sub === 'resolve') return resolveTasks(env, options).exitCode;
|
|
540
|
+
if (sub === 'route-reason') return writeRouteReason(env, options).exitCode;
|
|
456
541
|
if (sub === 'metrics') {
|
|
457
542
|
runMetrics(env, options);
|
|
458
543
|
return 0;
|
|
@@ -137,6 +137,8 @@ template, source-citation format) is needed only inside each phase, not at the p
|
|
|
137
137
|
2. IDEATE → Generate 2-3 approaches with trade-offs (delegate research inline; escalate via spur agent run on a trigger)
|
|
138
138
|
3. OUTPUT → Structured markdown (Overview → Approaches → Recommendations → Next Steps),
|
|
139
139
|
delivered incrementally; saved to docs/plans/YYYY-MM-DD-<topic>-brainstorm.md
|
|
140
|
+
with the spur-dev plan frontmatter (kind: plan, tags: [brainstorm, …]) plus
|
|
141
|
+
needs_design/run_id; keeps its own sections and the required ## Design Summary
|
|
140
142
|
```
|
|
141
143
|
|
|
142
144
|
## Design Approval Gate
|
|
@@ -158,10 +158,25 @@ DO NOT implement research directly. Delegate to specialized skills:
|
|
|
158
158
|
|
|
159
159
|
### Output Template
|
|
160
160
|
|
|
161
|
+
Frontmatter follows the spur-dev
|
|
162
|
+
[document-authoring vocabulary](../../spur-dev/references/document-authoring.md#frontmatter-vocabulary);
|
|
163
|
+
`needs_design` and `run_id` are brainstorm keys kept beside it. The body keeps this brainstorm shape,
|
|
164
|
+
not the plan template's sections.
|
|
165
|
+
|
|
161
166
|
```markdown
|
|
162
|
-
|
|
167
|
+
---
|
|
168
|
+
kind: plan
|
|
169
|
+
title: "Brainstorm: [Topic]"
|
|
170
|
+
status: proposed
|
|
171
|
+
created_at: YYYY-MM-DD
|
|
172
|
+
updated_at: YYYY-MM-DD
|
|
173
|
+
related: [] # owning feature/task ids when known
|
|
174
|
+
tags: [brainstorm] # then feature ids, then ≤2 area tags
|
|
175
|
+
needs_design: true
|
|
176
|
+
run_id: <run id, omit when none>
|
|
177
|
+
---
|
|
163
178
|
|
|
164
|
-
|
|
179
|
+
# Brainstorm: [Topic]
|
|
165
180
|
|
|
166
181
|
## Overview
|
|
167
182
|
|
|
@@ -261,8 +261,8 @@ the deterministic Testing writer `spur task record` (section authorship never ha
|
|
|
261
261
|
# write .spur/run/<wbs>-verdict.json (shape in references/verdict-schema.md), then:
|
|
262
262
|
# F96 residual sweep (observe-only): scan + fold BEFORE record, under every --fix mode.
|
|
263
263
|
RESIDUAL=$(superskill script path sp residual-scan.mjs)
|
|
264
|
-
node "$RESIDUAL" scan
|
|
265
|
-
node "$RESIDUAL" fold
|
|
264
|
+
node "$RESIDUAL" scan <wbs>
|
|
265
|
+
node "$RESIDUAL" fold <wbs>
|
|
266
266
|
spur task record <wbs> --verdict-file .spur/run/<wbs>-verdict.json # renders ## Testing
|
|
267
267
|
```
|
|
268
268
|
|
|
@@ -82,8 +82,9 @@ verdict artifact so quality failures are not lost behind a requirements-only PAS
|
|
|
82
82
|
|
|
83
83
|
Before declaring a task `done`, run this lightweight checklist. It catches the most common oversights that survive the formal pipeline gates:
|
|
84
84
|
|
|
85
|
-
- [ ]
|
|
86
|
-
|
|
85
|
+
- [ ] Check receipt `.spur/run/<wbs>-check-receipt.json` reports `reuse: true` for the current
|
|
86
|
+
digest via `quality-gate.ts status`; run `bun run spur-check` only when it reports stale or
|
|
87
|
+
missing (0940).
|
|
87
88
|
- [ ] No `TODO` or `FIXME` without a linked task WBS.
|
|
88
89
|
- [ ] `git status` shows only intentional changes (no debug artifacts, no temp files).
|
|
89
90
|
- [ ] No `console.log` / `console.error` in production code (use the project logger).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spur-check
|
|
3
|
+
description: 'Two-tier check primitive for the sp pipeline: light (changed-scope biome, per-workspace typecheck, related tests) during development; full (bun run spur-check) once at the quality boundary. Reads/writes fingerprint-bound check receipts (.spur/run/<wbs>-check-receipt.json) and reuses a PASS full receipt only at the same proof digest.'
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
metadata:
|
|
7
|
+
author: spur
|
|
8
|
+
platforms: "claude-code,codex,openclaw,opencode,antigravity,pi"
|
|
9
|
+
category: check-execution
|
|
10
|
+
interactions:
|
|
11
|
+
- pipeline
|
|
12
|
+
operations:
|
|
13
|
+
- check
|
|
14
|
+
- accumulate
|
|
15
|
+
- reuse
|
|
16
|
+
openclaw:
|
|
17
|
+
emoji: "🧾"
|
|
18
|
+
see_also:
|
|
19
|
+
- sp:spur-dev
|
|
20
|
+
- sp:spur-cli
|
|
21
|
+
- sp:code-verification
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# sp:spur-check — the two-tier check primitive (ADR-124)
|
|
25
|
+
|
|
26
|
+
One check primitive with two tiers behind the shipped `quality-gate` script
|
|
27
|
+
([task 0939](../../../../docs/tasks5/0939_add-the-two-tier-spur-check-primitive-with-fingerprint-bound.md),
|
|
28
|
+
[workflow catalogue refactor §4](../../../../docs/design/workflow-catalogue-refactor.md)): light
|
|
29
|
+
checks accumulate during development, the full chain runs once at the quality boundary, and every
|
|
30
|
+
gate writes a fingerprint-bound receipt that downstream stages read instead of re-running checks.
|
|
31
|
+
|
|
32
|
+
## Tiers
|
|
33
|
+
|
|
34
|
+
| Tier | Mode | When | Scope |
|
|
35
|
+
| --- | --- | --- | --- |
|
|
36
|
+
| `light` | `quality-gate.ts light` | after each implement/fix edit | `bunx biome check` on the changed files (`git diff --name-only HEAD` + untracked), `bun run typecheck` per touched workspace, and related tests (`<ws>/src/**/x.ts` → `<ws>/tests/**/x.test.ts` filename mapping) run via `cd <ws> && bun test …` — never from the repo root, whose bunfig preload does not apply inside the workspace |
|
|
37
|
+
| `full` | `quality-gate.ts run` | once at the task quality boundary (`test`) | today's chain: `bun run lint` + `bun run test-pre-check` + `bun run test` + `bun run test-post-check` (=`bun run spur-check`), with bounded findings, SQLite-busy retry, and the `recheck` probe |
|
|
38
|
+
|
|
39
|
+
Soft-fail contract: both tiers always exit 0; the verdict lives in files (`*-test-gate.status`,
|
|
40
|
+
receipt `status`), never in the exit code.
|
|
41
|
+
|
|
42
|
+
## Receipt
|
|
43
|
+
|
|
44
|
+
`.spur/run/<wbs>-check-receipt.json`, schema `check-receipt/v1`:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"schemaVersion": "check-receipt/v1",
|
|
49
|
+
"wbs": "0939",
|
|
50
|
+
"runId": "pipeline-0939",
|
|
51
|
+
"tier": "full",
|
|
52
|
+
"inputDigest": "<proof-input digest>",
|
|
53
|
+
"checks": [{ "id": "test", "cmd": "…", "status": "PASS", "durationMs": 0, "logPath": "…" }],
|
|
54
|
+
"status": "PASS",
|
|
55
|
+
"completedAt": "2026-09-25T00:00:00.000Z"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `inputDigest` is the shared `ProofInputFingerprint` (task markdown + git tree of tracked
|
|
60
|
+
sources). The plugin never computes it — the pipeline captures it with the `proof.fingerprint`
|
|
61
|
+
action into `env.proofDigest` (ADR-124: no second fingerprint, no `@gobing-ai/*` import);
|
|
62
|
+
standalone callers use `inline-run-setup.ts --fingerprint`.
|
|
63
|
+
- Only `run`/`full` writes a reusable receipt. Without a digest, `run` writes no receipt and says
|
|
64
|
+
so in the gate log. The gate executes `qualityGateCmd` as one unit, so the full receipt carries a
|
|
65
|
+
single `test` row for the whole chain; `lint`, `typecheck`, `test-pre-check`,
|
|
66
|
+
`test-post-check` name the chain steps the full tier covers.
|
|
67
|
+
- `light` merges its rows under `tier: light` and skips any sub-check already `PASS` in a light
|
|
68
|
+
receipt at the same `{id, inputDigest}` (accumulation). Light rows never make a receipt
|
|
69
|
+
reusable for review.
|
|
70
|
+
|
|
71
|
+
## Reuse rule
|
|
72
|
+
|
|
73
|
+
Check `status` mode before re-running a gate. Resolve the shipped script through the superskill
|
|
74
|
+
runtime (shipped surfaces never hard-code repo paths):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
QG="$(superskill script path sp quality-gate.mjs)"
|
|
78
|
+
bun "$QG" status # env: wbs, proofDigest → prints {"reuse":…,"reason":…}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`reuse: true` only when the receipt is `status: PASS`, `tier: full`, and `inputDigest` equals the
|
|
82
|
+
current digest. Otherwise the reason is one of `missing | failed | stale | light-only`:
|
|
83
|
+
|
|
84
|
+
- `missing` — no readable receipt (or foreign schema version)
|
|
85
|
+
- `failed` — last full run failed
|
|
86
|
+
- `stale` — digest mismatch (or no current digest supplied)
|
|
87
|
+
- `light-only` — a valid PASS receipt that came from the light tier
|
|
88
|
+
|
|
89
|
+
Only `full` may satisfy a review/verify/record boundary: "review only after a green full gate" is
|
|
90
|
+
preserved by construction. `recheck` stays the no-progress probe path for fix loops.
|
|
91
|
+
|
|
92
|
+
## Composition
|
|
93
|
+
|
|
94
|
+
- **Pipeline:** `sp:spur-dev` runs `run` at `test` and `recheck` at `test-recheck`; light mode
|
|
95
|
+
belongs to implement/fix edits, not to the gate state.
|
|
96
|
+
- **Fix loops:** `/sp:dev-fixall --gate-log` consumes `<wbs>-test-gate.log` (and the bounded
|
|
97
|
+
`<wbs>-test-gate.findings` anchors) after a red gate; it never writes receipts. A green fixall
|
|
98
|
+
output still requires a fresh `run` receipt before review.
|
|
99
|
+
- **Verification:** `sp:code-verification` and the review checklists read the receipt (status
|
|
100
|
+
mode) instead of re-running `bun run test`.
|
|
101
|
+
- **Feature scope:** `spur-check-feature` remains the ADR-119 repo-wide pass; this primitive is
|
|
102
|
+
task-local. A public `spur check` verb is out of scope without separate consent.
|
|
103
|
+
|
|
104
|
+
## Gotchas
|
|
105
|
+
|
|
106
|
+
1. **Never value-import `@gobing-ai/*` into the script** — the plugin standalone contract fails
|
|
107
|
+
the install; the digest arrives via `env.proofDigest`.
|
|
108
|
+
2. **Never run light tests from the repo root** — the workspace `bunfig.toml` preload (coverage,
|
|
109
|
+
thresholds) only applies inside the workspace; `cd <ws> && bun test …` is the contract.
|
|
110
|
+
3. **Light is a filter, not a boundary** — unmapped files (root-level scripts, non-src layouts)
|
|
111
|
+
are simply not covered by light; the full tier is the safety net. Do not widen the mapping
|
|
112
|
+
without an ADR.
|
|
@@ -116,7 +116,7 @@ reference for the half you're operating; do not duplicate its content here.
|
|
|
116
116
|
| Feature check gate | planning | `spur feature check` | [planning-workflow.md](references/planning-workflow.md) |
|
|
117
117
|
| Decomposition (dispatch) | planning | `task-batch.schema.json` | `sp:spec-decomposition` competency — the spine dispatches, does not inline |
|
|
118
118
|
| Batch-create gate | planning | `spur task batch-create` | [planning-workflow.md](references/planning-workflow.md) |
|
|
119
|
-
| Design doc
|
|
119
|
+
| Design doc | planning | — (§4.5/T9) | [document-authoring.md](references/document-authoring.md) |
|
|
120
120
|
| Refine | planning | `spur task update --section` | [planning-workflow.md](references/planning-workflow.md) |
|
|
121
121
|
| Batch refine | planning | `sp:dev-refineall` → per-task `refine` | [dev-operations.md](references/dev-operations.md) § refineall · [planning-workflow.md](references/planning-workflow.md) |
|
|
122
122
|
| Task selection | execution | `spur task list` | [execution-workflow.md](references/execution-workflow.md) |
|
|
@@ -246,6 +246,7 @@ for "what's actually in file Y" or for resources that sit outside the step seque
|
|
|
246
246
|
- `idea-pipeline.yaml` — the front-half state machine (absorbed the retired
|
|
247
247
|
planning-pipeline in D5-K; `/sp:dev-plan` routes here, ADR-072).
|
|
248
248
|
- `templates/bdd/gherkin.md` — the BDD scenario template.
|
|
249
|
+
- `templates/plan.md` and `templates/design.md` — plan and design starting points.
|
|
249
250
|
|
|
250
251
|
## Platform Notes
|
|
251
252
|
|