@gobing-ai/spur 0.4.1 → 0.4.3
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/config.global.yaml +4 -2
- package/config/decisions/maker-liveness.yaml +39 -0
- package/config/plugin-scripts.json +0 -4
- package/config/rules/README.md +1 -0
- package/config/rules/docs/sourced-api-claims.yaml +56 -12
- package/config/rules/strict/runtime-boundaries.yaml +7 -0
- package/config/script-placement-baseline.json +1 -19
- package/config/templates/AGENTS.md +1 -1
- package/config/workflows/feature-lifecycle.yaml +46 -1
- package/config/workflows/feature-verification.yaml +11 -0
- package/config/workflows/wrapup-pipeline.yaml +1 -1
- package/package.json +10 -10
- package/plugins/sp/README.md +23 -18
- package/plugins/sp/agents/super-planner.md +5 -6
- package/plugins/sp/agents/super-reviewer.md +43 -0
- package/plugins/sp/bunfig.toml +8 -5
- package/plugins/sp/commands/dev-review-session.md +2 -1
- package/plugins/sp/commands/dev-runall.md +18 -9
- package/plugins/sp/hooks/careful-guard.ts +1 -1
- package/plugins/sp/hooks/context-post-tool.ts +7 -404
- package/plugins/sp/hooks/context-session-start.ts +6 -192
- package/plugins/sp/hooks/context-session-stop.ts +6 -91
- package/plugins/sp/hooks/pi/guard-extension.ts +26 -12
- package/plugins/sp/hooks/task-write-guard.ts +1 -1
- package/plugins/sp/{hooks → lib}/agent-hint.ts +1 -1
- package/plugins/sp/lib/context-owner.ts +56 -0
- package/plugins/sp/lib/context-post-tool.ts +432 -0
- package/plugins/sp/lib/context-session-start.ts +214 -0
- package/plugins/sp/lib/context-session-stop.ts +196 -0
- package/plugins/sp/lib/dogfood-pipeline.ts +265 -0
- package/plugins/sp/lib/dogfood-report.ts +278 -0
- package/plugins/sp/lib/idea-handoff.generated.mjs +6 -4
- package/plugins/sp/lib/inline-run-app.ts +40 -0
- package/plugins/sp/lib/inline-run.generated.d.mts +3 -3
- package/plugins/sp/lib/inline-run.generated.mjs +1361 -87
- package/plugins/sp/lib/plan-projection.generated.d.mts +169 -0
- package/plugins/sp/lib/plan-projection.generated.mjs +704 -1
- package/plugins/sp/lib/quality-gate.generated.d.mts +0 -12
- package/plugins/sp/lib/quality-gate.generated.mjs +62 -231
- package/plugins/sp/lib/residual-scan.generated.d.mts +7 -1
- package/plugins/sp/lib/residual-scan.generated.mjs +71 -6
- package/plugins/sp/lib/run-summary-core.ts +34 -370
- package/plugins/sp/lib/transcript.ts +37 -200
- package/plugins/sp/plugin.json +1 -1
- package/plugins/sp/references/roles.md +1 -1
- package/plugins/sp/scripts/batch-plan.mjs +740 -1
- package/plugins/sp/scripts/batch-plan.ts +48 -3
- package/plugins/sp/scripts/batch-preflight.mjs +23 -1
- package/plugins/sp/scripts/batch-preflight.ts +35 -295
- package/plugins/sp/scripts/daily-summary/daily-summary.mjs +108 -87
- package/plugins/sp/scripts/daily-summary/daily-summary.ts +111 -104
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +2 -1
- package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +7 -265
- package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +3 -0
- package/plugins/sp/scripts/dogfood-testing/validate-report.ts +6 -272
- package/plugins/sp/scripts/feature-verification-steps.mjs +7 -123
- package/plugins/sp/scripts/feature-verification-steps.ts +29 -181
- package/plugins/sp/scripts/inline-run-dispatch.mjs +27 -26
- package/plugins/sp/scripts/inline-run-dispatch.ts +1 -21
- package/plugins/sp/scripts/inline-run-setup.mjs +158 -120
- package/plugins/sp/scripts/inline-run-setup.ts +1 -21
- package/plugins/sp/scripts/pr-reviewing.mjs +19 -5
- package/plugins/sp/scripts/pr-reviewing.ts +34 -9
- package/plugins/sp/scripts/quality-gate.mjs +38 -208
- package/plugins/sp/scripts/residual-scan.mjs +73 -6
- package/plugins/sp/scripts/residual-scan.ts +8 -5
- package/plugins/sp/scripts/run-summary.mjs +160 -95
- package/plugins/sp/scripts/run-summary.ts +7 -5
- package/plugins/sp/scripts/session-timeline.mjs +57 -29
- package/plugins/sp/scripts/session-timeline.ts +4 -18
- package/plugins/sp/scripts/task-diffstat.mjs +43 -30
- package/plugins/sp/scripts/task-diffstat.ts +40 -71
- package/plugins/sp/skills/code-implementation/SKILL.md +7 -1
- package/plugins/sp/skills/code-verification/references/secu-review.md +2 -1
- package/plugins/sp/skills/code-verification/references/verdict-schema.md +4 -0
- package/plugins/sp/skills/dogfood-testing/SKILL.md +2 -2
- package/plugins/sp/skills/indexed-context/SKILL.md +14 -7
- package/plugins/sp/skills/next-feature/SKILL.md +1 -1
- package/plugins/sp/skills/parallel-execution/SKILL.md +2 -2
- package/plugins/sp/skills/parallel-execution/references/dispatch-surface.md +2 -2
- package/plugins/sp/skills/parallel-execution/references/fan-out-patterns.md +2 -2
- package/plugins/sp/skills/pr-reviewing/SKILL.md +7 -3
- package/plugins/sp/skills/session-review/SKILL.md +5 -3
- package/plugins/sp/skills/source-driven-development/SKILL.md +7 -4
- package/plugins/sp/skills/spur-cli/references/builder.md +3 -2
- package/plugins/sp/skills/spur-cli/references/decision.md +40 -8
- package/plugins/sp/skills/spur-cli/references/features.md +46 -5
- package/plugins/sp/skills/spur-cli/references/projects.md +7 -5
- package/plugins/sp/skills/spur-dev/SKILL.md +2 -0
- package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +27 -0
- package/plugins/sp/skills/spur-dev/references/dev-operations.md +2 -3
- package/plugins/sp/skills/spur-dev/references/execution-batch-report.md +6 -1
- package/plugins/sp/skills/spur-dev/references/execution-batch.md +56 -7
- package/plugins/sp/skills/spur-dev/references/execution-parallel-isolation.md +4 -1
- package/plugins/sp/skills/spur-dev/references/execution-worktree-landing.md +22 -0
- package/plugins/sp/skills/spur-dev/references/execution-worktree-setup.md +14 -0
- package/plugins/sp/skills/spur-dev/references/flag-glossary.md +13 -11
- package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +37 -25
- package/spur.js +89792 -76992
- package/web/_astro/{BoardApp.D66k_s_T.js → BoardApp.5IIl2O-z.js} +1 -1
- package/web/_astro/BoardApp.Drnx-KeM.js +324 -0
- package/web/_astro/TaskDetail.Ci4LNn9S.js +1 -0
- package/web/_astro/{arc._BUadrdH.js → arc.j2EVkYVd.js} +1 -1
- package/web/_astro/{architectureDiagram-3BPJPVTR.Dh7xS1Pp.js → architectureDiagram-3BPJPVTR.DZWSFqEG.js} +1 -1
- package/web/_astro/{blockDiagram-GPEHLZMM.DFDVpfXm.js → blockDiagram-GPEHLZMM.DE6GpXCN.js} +1 -1
- package/web/_astro/{c4Diagram-AAUBKEIU.V7_3_glh.js → c4Diagram-AAUBKEIU.DoVR1G6B.js} +1 -1
- package/web/_astro/channel.DmdDxGsq.js +1 -0
- package/web/_astro/{chunk-2J33WTMH.De1yx7Jz.js → chunk-2J33WTMH.Do6-Gbyf.js} +1 -1
- package/web/_astro/{chunk-4BX2VUAB.BDhHFuxx.js → chunk-4BX2VUAB.BYV1HGHx.js} +1 -1
- package/web/_astro/{chunk-55IACEB6.DDLkWnmC.js → chunk-55IACEB6.CvI1zkrc.js} +1 -1
- package/web/_astro/{chunk-727SXJPM.CwfiLnA7.js → chunk-727SXJPM.DNGSCRlX.js} +1 -1
- package/web/_astro/{chunk-AQP2D5EJ.CtGDmUnM.js → chunk-AQP2D5EJ.DXhhgT5z.js} +1 -1
- package/web/_astro/{chunk-FMBD7UC4.BOLjpw73.js → chunk-FMBD7UC4.dzkRKP2u.js} +1 -1
- package/web/_astro/{chunk-ND2GUHAM.BDhQls6O.js → chunk-ND2GUHAM.DujGLeEf.js} +1 -1
- package/web/_astro/{chunk-QZHKN3VN.76qBynDF.js → chunk-QZHKN3VN.BWtIT3ZU.js} +1 -1
- package/web/_astro/{classDiagram-4FO5ZUOK.N0mpPHT0.js → classDiagram-4FO5ZUOK.DyApg0Nn.js} +1 -1
- package/web/_astro/{classDiagram-v2-Q7XG4LA2.N0mpPHT0.js → classDiagram-v2-Q7XG4LA2.DyApg0Nn.js} +1 -1
- package/web/_astro/{cose-bilkent-S5V4N54A.CKknFfjB.js → cose-bilkent-S5V4N54A.DJQB-u_l.js} +1 -1
- package/web/_astro/{cynefin-OW5HDTMX.Cw3ZWBAh.js → cynefin-OW5HDTMX.bi3D_siV.js} +1 -1
- package/web/_astro/{dagre-BM42HDAG.D3yIKCRD.js → dagre-BM42HDAG.C-f7TrRg.js} +1 -1
- package/web/_astro/{diagram-2AECGRRQ.D51dO83Z.js → diagram-2AECGRRQ.DrPfjHQB.js} +1 -1
- package/web/_astro/{diagram-5GNKFQAL.Bb-FViDj.js → diagram-5GNKFQAL.C9S4WUHO.js} +1 -1
- package/web/_astro/{diagram-KO2AKTUF.D3mN8S6x.js → diagram-KO2AKTUF.Dzzye8QH.js} +1 -1
- package/web/_astro/{diagram-LMA3HP47.dMMyPcbJ.js → diagram-LMA3HP47.DX-LRiof.js} +1 -1
- package/web/_astro/{diagram-OG6HWLK6.AzbvzY4C.js → diagram-OG6HWLK6.Z-kAKwIz.js} +1 -1
- package/web/_astro/{erDiagram-TEJ5UH35.BR5I4OZb.js → erDiagram-TEJ5UH35.D6dyClSv.js} +1 -1
- package/web/_astro/{flowDiagram-I6XJVG4X.DFqvhGkn.js → flowDiagram-I6XJVG4X.Cx3q2cxD.js} +1 -1
- package/web/_astro/{ganttDiagram-6RSMTGT7.ByJbhH6J.js → ganttDiagram-6RSMTGT7.DU3gH6CT.js} +1 -1
- package/web/_astro/{gitGraphDiagram-PVQCEYII.CInHjQR3.js → gitGraphDiagram-PVQCEYII.ISmCnJ87.js} +1 -1
- package/web/_astro/index.Do2lLdgo.css +1 -0
- package/web/_astro/{infoDiagram-5YYISTIA.Cm0dGVjJ.js → infoDiagram-5YYISTIA.DR6_iNOK.js} +1 -1
- package/web/_astro/{ishikawaDiagram-YF4QCWOH.C3nOP6Sj.js → ishikawaDiagram-YF4QCWOH.D7wY-ZGA.js} +1 -1
- package/web/_astro/{journeyDiagram-JHISSGLW.4IvLa2MW.js → journeyDiagram-JHISSGLW.DkP9-WK8.js} +1 -1
- package/web/_astro/{kanban-definition-UN3LZRKU.DS87Cl-k.js → kanban-definition-UN3LZRKU.wtgY98M2.js} +1 -1
- package/web/_astro/{linear.MzmRrNER.js → linear.CI6djNi7.js} +1 -1
- package/web/_astro/{mermaid.core.fK-WNswS.js → mermaid.core.CuQPxS8b.js} +4 -4
- package/web/_astro/{mindmap-definition-RKZ34NQL.BqipOHhY.js → mindmap-definition-RKZ34NQL.5HNIEG7R.js} +1 -1
- package/web/_astro/{pieDiagram-4H26LBE5.0nBiPqFG.js → pieDiagram-4H26LBE5.CchhDFjE.js} +1 -1
- package/web/_astro/{quadrantDiagram-W4KKPZXB.Szj7Zpx5.js → quadrantDiagram-W4KKPZXB.PYXXJPSJ.js} +1 -1
- package/web/_astro/{requirementDiagram-4Y6WPE33.D4UR6TWo.js → requirementDiagram-4Y6WPE33.cUQuNAKU.js} +1 -1
- package/web/_astro/{sankeyDiagram-5OEKKPKP.DAE7BdOs.js → sankeyDiagram-5OEKKPKP.BO7MnRIA.js} +1 -1
- package/web/_astro/{sequenceDiagram-3UESZ5HK.BP9ZVq25.js → sequenceDiagram-3UESZ5HK.D9bElyD6.js} +1 -1
- package/web/_astro/{stateDiagram-AJRCARHV.BQW7mIxk.js → stateDiagram-AJRCARHV.DhGdRz7I.js} +1 -1
- package/web/_astro/{stateDiagram-v2-BHNVJYJU.PbK4nDih.js → stateDiagram-v2-BHNVJYJU.5GvLeAoL.js} +1 -1
- package/web/_astro/{timeline-definition-PNZ67QCA.Ci_GvUpo.js → timeline-definition-PNZ67QCA.LtAT9haM.js} +1 -1
- package/web/_astro/{vennDiagram-CIIHVFJN.DNw1Y5qx.js → vennDiagram-CIIHVFJN.DRth1yLA.js} +1 -1
- package/web/_astro/{wardleyDiagram-YWT4CUSO.CwlkaaNe.js → wardleyDiagram-YWT4CUSO.h9MlZfcr.js} +1 -1
- package/web/_astro/{xychartDiagram-2RQKCTM6.MI6ZuiH_.js → xychartDiagram-2RQKCTM6.DHqy9DYA.js} +1 -1
- package/web/index.html +2 -2
- package/config/proportional-route-table.ts +0 -155
- package/plugins/sp/commands/dev-parallel.md +0 -37
- package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
- package/web/_astro/BoardApp.D6sjAJr_.js +0 -324
- package/web/_astro/TaskDetail.BynLnMNc.js +0 -1
- package/web/_astro/channel.DZVfto-r.js +0 -1
- package/web/_astro/index.COh_kBxN.css +0 -1
- /package/plugins/sp/{hooks → lib}/destructive-policy.ts +0 -0
- /package/plugins/sp/{hooks → lib}/task-file-policy.ts +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* detect-pipeline-driving — @1.2
|
|
2
|
+
* detect-pipeline-driving — live Phase 1.0 CLI gate over the @1.2 detector (task 0277 W7).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Also ships a **CLI gate** (import.meta.main) so Phase 1.0 is a live shell call,
|
|
9
|
-
* not agent-only prose interpretation:
|
|
4
|
+
* The detector and its policy helpers are application-owned in
|
|
5
|
+
* `plugins/sp/lib/dogfood-pipeline.ts` (task 1173); this script keeps the shell entry the dogfood
|
|
6
|
+
* driver calls, with argv, usage, exit codes and refusal messages unchanged. Callers and tests may
|
|
7
|
+
* keep importing this path — every former export is re-exported.
|
|
10
8
|
*
|
|
11
9
|
* bun plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts \
|
|
12
10
|
* --testee "/sp:dev-run 0125 --auto --next" [--max-retry-present] \
|
|
@@ -16,267 +14,11 @@
|
|
|
16
14
|
* 0 — proceed (may print implement-heavy advisory on stderr)
|
|
17
15
|
* 2 — refuse: pipeline-driving without explicit --max-retry
|
|
18
16
|
* 1 — usage / argument error
|
|
19
|
-
*
|
|
20
|
-
* Contract (0274 §3 dogfood-pipeline-detect, 0277 R1):
|
|
21
|
-
* - Word-boundary matchers with `-` treated as a word char (NOT a boundary).
|
|
22
|
-
* A token counts only when it is a distinct hyphen-word, not when it is a
|
|
23
|
-
* substring of a longer alphanumeric or hyphen run. This removes the
|
|
24
|
-
* leading-space dependency of the @1.1 prose detector.
|
|
25
|
-
* - Two token shapes, both with strict `[^\w-]` boundaries:
|
|
26
|
-
* (a) complete tokens — `--next`, `dev-run`, `dev-runall`, `dev-wrap`,
|
|
27
|
-
* `dev-wrapall`, `dev-idea` — matched as whole hyphen-words so the
|
|
28
|
-
* slash form `/sp:dev-run` matches on its `dev-run` tail whether or
|
|
29
|
-
* not it is preceded by a space, but `--next` does NOT match inside
|
|
30
|
-
* `--next-gen` (the trailing `-gen` breaks the boundary).
|
|
31
|
-
* (b) bare nouns — `run`, `runall`, `wrap`, `wrapall`, `idea` — matched
|
|
32
|
-
* only as standalone words, so `run` matches in
|
|
33
|
-
* `bun ... task run 0042` but NOT inside `runaway`/`prerun`, and
|
|
34
|
-
* `idea` does NOT match inside `idealist`/`ideal`.
|
|
35
|
-
* - Listing both shapes is what makes the detector leading-space invariant
|
|
36
|
-
* (the slash form is caught by its `dev-*` tail; the bare noun is caught
|
|
37
|
-
* when it appears as its own word) without letting `run` leak into every
|
|
38
|
-
* `-run-` identifier.
|
|
39
|
-
*
|
|
40
|
-
* Non-goals of detectPipelineDriving: decides ambiguity only. It does NOT decide
|
|
41
|
-
* observe vs fix — any explicit `--max-retry` value proceeds regardless.
|
|
42
|
-
* Implement-heavy advisory is a separate helper (detectImplementHeavy).
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Tokens whose presence makes a testee pipeline-driving. Ordered for stable
|
|
47
|
-
* diagnostics. Two shapes per the contract above: complete `dev-*` / `--next`
|
|
48
|
-
* tokens first, then bare nouns.
|
|
49
|
-
*/
|
|
50
|
-
const PIPELINE_TOKENS = [
|
|
51
|
-
'--next',
|
|
52
|
-
'dev-runall',
|
|
53
|
-
'dev-wrapall',
|
|
54
|
-
'dev-refineall',
|
|
55
|
-
'dev-verifyall',
|
|
56
|
-
'dev-run',
|
|
57
|
-
'dev-wrap',
|
|
58
|
-
'dev-idea',
|
|
59
|
-
'refineall',
|
|
60
|
-
'verifyall',
|
|
61
|
-
'runall',
|
|
62
|
-
'wrapall',
|
|
63
|
-
'run',
|
|
64
|
-
'wrap',
|
|
65
|
-
'idea',
|
|
66
|
-
] as const;
|
|
67
|
-
|
|
68
|
-
/** Refuse message when pipeline-driving and `--max-retry` was not passed (exact string). */
|
|
69
|
-
export const PIPELINE_DRIVING_REFUSE_MESSAGE =
|
|
70
|
-
'⚠ pipeline-driving testee detected; pass --max-retry 0 (observe-only) or --max-retry N (fix mode, tree mutation acknowledged)';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Refuse message when the testee carries a mutating `--fix` mode (`--fix all` /
|
|
74
|
-
* `--fix blockers-first`) and `--max-retry` was not passed. A mutating fix mode
|
|
75
|
-
* mutates the working tree independent of pipeline-driving (task 0293 R1/R2):
|
|
76
|
-
* `--max-retry 0` bounds the **driver** only — the testee's own `--fix` pass
|
|
77
|
-
* still mutates the tree — so the message must not imply otherwise.
|
|
78
|
-
*/
|
|
79
|
-
export const MUTATING_FIX_REFUSE_MESSAGE =
|
|
80
|
-
'⚠ mutating --fix mode detected (--fix all | --fix blockers-first); pass --max-retry 0 (observe-only for the driver; the testee still mutates the tree) or --max-retry N (fix mode, driver + testee both mutate)';
|
|
81
|
-
|
|
82
|
-
/** Advisory when pipeline-driving + implement-heavy derived steps (exact string). */
|
|
83
|
-
export const IMPLEMENT_HEAVY_ADVISORY_MESSAGE =
|
|
84
|
-
'⚠ implement-heavy pipeline dogfood: prefer --max-retry 0 (observe-only) or step-split; operator --max-retry N overrides';
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Tokens that mark a derived step as implement-heavy (mutates product/code or
|
|
88
|
-
* drives a mutating pipeline leg). Deliberately excludes verify/review/unit-only
|
|
89
|
-
* surfaces even when they carry `--next`.
|
|
90
|
-
*/
|
|
91
|
-
const IMPLEMENT_HEAVY_TOKENS = [
|
|
92
|
-
'dev-runall',
|
|
93
|
-
'dev-wrapall',
|
|
94
|
-
'dev-run',
|
|
95
|
-
'dev-wrap',
|
|
96
|
-
'dev-idea',
|
|
97
|
-
'runall',
|
|
98
|
-
'wrapall',
|
|
99
|
-
// bare `run` / `wrap` / `idea` — only when not clearly a non-mutating surface
|
|
100
|
-
'run',
|
|
101
|
-
'wrap',
|
|
102
|
-
'idea',
|
|
103
|
-
'implement',
|
|
104
|
-
] as const;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* A verify/review surface stops being non-mutating the moment it carries a
|
|
108
|
-
* repair mode: `--fix all` / `--fix blockers-first` applies Edit/Write repairs
|
|
109
|
-
* to the working tree (0280 dogfood, finding P2). `--fix none` stays
|
|
110
|
-
* observational. Boundary-guarded so `--prefix all` / `--focus all` never match.
|
|
111
|
-
* Exported so the Phase 1.0 gate and tests share one matcher (task 0293 R1/R4).
|
|
112
|
-
*/
|
|
113
|
-
export function hasMutatingFixMode(step: string): boolean {
|
|
114
|
-
return /(?<![\w-])--fix[=\s]+(all|blockers-first)(?![\w-])/i.test(step);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Match a token at a word boundary. A "word boundary" here is the position
|
|
119
|
-
* between a non-`[\w-]` char (or string start) and the token, and between the
|
|
120
|
-
* token and a non-`[\w-]` char (or string end). Treating `-` as a word char
|
|
121
|
-
* is what makes `--next` reject `--next-gen` and `dev-run` reject `dev-runner`.
|
|
122
|
-
*/
|
|
123
|
-
function tokenMatches(testee: string, token: string): boolean {
|
|
124
|
-
const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
-
// (?<![\w-]) — not preceded by a word char or hyphen.
|
|
126
|
-
// (?![\w-]) — not followed by a word char or hyphen.
|
|
127
|
-
const re = new RegExp(`(?<![\\w-])${escaped}(?![\\w-])`, 'i');
|
|
128
|
-
return re.test(testee);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns whether the testee string is pipeline-driving (contains any of the
|
|
133
|
-
* pipeline-driving tokens as a distinct hyphen-word). Machine-checked
|
|
134
|
-
* counterpart of the prose list in SKILL.md §Pipeline-driving detection and
|
|
135
|
-
* dev-dogfood.md.
|
|
136
|
-
*/
|
|
137
|
-
export function detectPipelineDriving(testee: string): boolean {
|
|
138
|
-
if (typeof testee !== 'string' || testee.length === 0) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
return PIPELINE_TOKENS.some((token) => tokenMatches(testee, token));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* True when a single step label (or the whole testee) is implement-heavy —
|
|
146
|
-
* it chains into real implementation / wrap / idea work, not verify-only.
|
|
147
|
-
*
|
|
148
|
-
* Non-mutating surfaces (`dev-verify`, `dev-review`, `dev-unit`, plain
|
|
149
|
-
* `dev-refine` without a further run) are never implement-heavy even if
|
|
150
|
-
* pipeline-driving via `--next` — UNLESS they carry a mutating repair mode
|
|
151
|
-
* (`--fix all` / `--fix blockers-first`), which turns the verify/review leg
|
|
152
|
-
* into a tree-mutating fix pass (0280 dogfood, finding P2).
|
|
153
|
-
*/
|
|
154
|
-
export function isImplementHeavyStep(step: string): boolean {
|
|
155
|
-
if (typeof step !== 'string' || step.length === 0) return false;
|
|
156
|
-
// Explicit non-mutating surfaces win unless a mutating token co-occurs.
|
|
157
|
-
const nonMutatingOnly =
|
|
158
|
-
tokenMatches(step, 'dev-verify') || tokenMatches(step, 'dev-review') || tokenMatches(step, 'dev-unit');
|
|
159
|
-
const hasMutating = IMPLEMENT_HEAVY_TOKENS.some((token) => tokenMatches(step, token)) || hasMutatingFixMode(step);
|
|
160
|
-
if (nonMutatingOnly && !hasMutating) return false;
|
|
161
|
-
// refine alone is planning, not implement-heavy; refine+run/--next chain is.
|
|
162
|
-
if (tokenMatches(step, 'dev-refine') && !hasMutating && !tokenMatches(step, '--next')) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
if (tokenMatches(step, 'dev-refine') && tokenMatches(step, '--next')) {
|
|
166
|
-
// refine --next chains into run → implement-heavy
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
return hasMutating;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* True when the testee is implement-heavy: it carries a pipeline-driving token,
|
|
174
|
-
* a mutating `--fix` mode, OR at least one derived step (or the testee itself
|
|
175
|
-
* when no steps given) is implement-heavy. Used for the W8 Phase 1 advisory
|
|
176
|
-
* after step derivation.
|
|
177
|
-
*
|
|
178
|
-
* Task 0293 R3: a mutating `--fix` mode alone is implement-heavy even with no
|
|
179
|
-
* pipeline token — the verify/review leg itself becomes a tree-mutating fix
|
|
180
|
-
* pass.
|
|
181
|
-
*/
|
|
182
|
-
export function detectImplementHeavy(testee: string, derivedSteps: string[] = []): boolean {
|
|
183
|
-
if (isImplementHeavyStep(testee)) return true;
|
|
184
|
-
if (!detectPipelineDriving(testee)) return false;
|
|
185
|
-
return derivedSteps.some((step) => isImplementHeavyStep(step));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface GateResult {
|
|
189
|
-
pipelineDriving: boolean;
|
|
190
|
-
mutatingFix: boolean;
|
|
191
|
-
maxRetryPresent: boolean;
|
|
192
|
-
implementHeavy: boolean;
|
|
193
|
-
refuse: boolean;
|
|
194
|
-
advisory: boolean;
|
|
195
|
-
message: string | null;
|
|
196
|
-
exitCode: 0 | 1 | 2;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Phase 1.0 + W8 gate decision. Pure — no I/O. The CLI wrapper prints and exits.
|
|
201
|
-
*
|
|
202
|
-
* Refuse condition (task 0293 R1) is the union of two **independent** mutation
|
|
203
|
-
* sources, each gated on `!maxRetryPresent`:
|
|
204
|
-
*
|
|
205
|
-
* 1. pipeline-driving testee (`--next`, `dev-run`, …) — refuses because the
|
|
206
|
-
* testee chains lifecycle legs whose cumulative blast radius the driver
|
|
207
|
-
* cannot pre-attribute.
|
|
208
|
-
* 2. mutating `--fix` mode (`--fix all` / `--fix blockers-first`) — refuses
|
|
209
|
-
* because the testee itself applies Edit/Write repairs even with no
|
|
210
|
-
* pipeline token. `--max-retry 0` bounds the **driver** only; the testee
|
|
211
|
-
* still mutates (honesty note in MUTATING_FIX_REFUSE_MESSAGE).
|
|
212
|
-
*
|
|
213
|
-
* Pipeline-driving is reported first when both co-occur (its refuse message is
|
|
214
|
-
* the superset — chain + tree mutation).
|
|
215
17
|
*/
|
|
216
|
-
export function evaluateDogfoodGate(
|
|
217
|
-
testee: string,
|
|
218
|
-
options: { maxRetryPresent?: boolean; steps?: string[] } = {},
|
|
219
|
-
): GateResult {
|
|
220
|
-
const maxRetryPresent = options.maxRetryPresent === true;
|
|
221
|
-
const steps = options.steps ?? [];
|
|
222
|
-
const pipelineDriving = detectPipelineDriving(testee);
|
|
223
|
-
const mutatingFix = hasMutatingFixMode(testee);
|
|
224
|
-
const implementHeavy = detectImplementHeavy(testee, steps);
|
|
225
|
-
|
|
226
|
-
if (pipelineDriving && !maxRetryPresent) {
|
|
227
|
-
return {
|
|
228
|
-
pipelineDriving,
|
|
229
|
-
mutatingFix,
|
|
230
|
-
maxRetryPresent,
|
|
231
|
-
implementHeavy,
|
|
232
|
-
refuse: true,
|
|
233
|
-
advisory: false,
|
|
234
|
-
message: PIPELINE_DRIVING_REFUSE_MESSAGE,
|
|
235
|
-
exitCode: 2,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (mutatingFix && !maxRetryPresent) {
|
|
240
|
-
return {
|
|
241
|
-
pipelineDriving,
|
|
242
|
-
mutatingFix,
|
|
243
|
-
maxRetryPresent,
|
|
244
|
-
implementHeavy,
|
|
245
|
-
refuse: true,
|
|
246
|
-
advisory: false,
|
|
247
|
-
message: MUTATING_FIX_REFUSE_MESSAGE,
|
|
248
|
-
exitCode: 2,
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (implementHeavy) {
|
|
253
|
-
return {
|
|
254
|
-
pipelineDriving,
|
|
255
|
-
mutatingFix,
|
|
256
|
-
maxRetryPresent,
|
|
257
|
-
implementHeavy,
|
|
258
|
-
refuse: false,
|
|
259
|
-
advisory: true,
|
|
260
|
-
message: IMPLEMENT_HEAVY_ADVISORY_MESSAGE,
|
|
261
|
-
exitCode: 0,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return {
|
|
266
|
-
pipelineDriving,
|
|
267
|
-
mutatingFix,
|
|
268
|
-
maxRetryPresent,
|
|
269
|
-
implementHeavy,
|
|
270
|
-
refuse: false,
|
|
271
|
-
advisory: false,
|
|
272
|
-
message: null,
|
|
273
|
-
exitCode: 0,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
18
|
|
|
277
|
-
|
|
19
|
+
import { evaluateDogfoodGate } from '../../lib/dogfood-pipeline';
|
|
278
20
|
|
|
279
|
-
|
|
21
|
+
export * from '../../lib/dogfood-pipeline';
|
|
280
22
|
|
|
281
23
|
export interface CliArgs {
|
|
282
24
|
testee: string | null;
|
|
@@ -4,6 +4,8 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
4
4
|
|
|
5
5
|
// plugins/sp/scripts/dogfood-testing/validate-report.ts
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
|
+
|
|
8
|
+
// plugins/sp/lib/dogfood-report.ts
|
|
7
9
|
var REQUIRED_SECTIONS = [1, 2, 3, 4, 5, 6];
|
|
8
10
|
var CANONICAL_PROTOCOL = "sp:dogfood-testing@1.2";
|
|
9
11
|
function countSectionHeadings(markdown, section) {
|
|
@@ -188,6 +190,7 @@ function validateReport(markdown) {
|
|
|
188
190
|
validateCostEvidence(markdown, errors);
|
|
189
191
|
return { ok: errors.length === 0, errors };
|
|
190
192
|
}
|
|
193
|
+
// plugins/sp/scripts/dogfood-testing/validate-report.ts
|
|
191
194
|
function parseValidateCliArgs(argv) {
|
|
192
195
|
let file = null;
|
|
193
196
|
let json = false;
|
|
@@ -1,283 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* validate-report — @1.2 dogfood report contract checker (task 0276,
|
|
2
|
+
* validate-report — CLI entry for the @1.2 dogfood report contract checker (task 0276 W6, 0278 R6).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* mandatory summary footer with both delivery paths, frontmatter protocol string,
|
|
8
|
-
* ledger↔declared-steps cardinality, and the Cost evidence contract (task 0913):
|
|
9
|
-
* a complete report must carry a Cost block (Ledger estimate / Method / Meter),
|
|
10
|
-
* percentages within 0..100, observable token totals consistent with the ledger
|
|
11
|
-
* row sums (fresh + cached), and no fabricated share when no observable rows
|
|
12
|
-
* exist. Unknown cells are never folded into zero; all-unknown evidence must
|
|
13
|
-
* render `n/a`. Aborted/partial reports remain out of scope — they legitimately
|
|
14
|
-
* lack the footer and Steps line.
|
|
4
|
+
* The validation logic is application-owned in `plugins/sp/lib/dogfood-report.ts` (task 1173); this
|
|
5
|
+
* script opens the file, runs the check and prints — argv, usage, exit codes and every exported
|
|
6
|
+
* symbol stay as they were, so callers and tests keep importing this path.
|
|
15
7
|
*
|
|
16
8
|
* CLI (task 0278 R6): `bun …/validate-report.ts --file <report.md> [--json]`
|
|
17
9
|
*/
|
|
18
10
|
|
|
19
11
|
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { validateReport } from '../../lib/dogfood-report';
|
|
20
13
|
|
|
21
|
-
export
|
|
22
|
-
ok: boolean;
|
|
23
|
-
errors: string[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const REQUIRED_SECTIONS = [1, 2, 3, 4, 5, 6] as const;
|
|
27
|
-
const CANONICAL_PROTOCOL = 'sp:dogfood-testing@1.2';
|
|
28
|
-
|
|
29
|
-
function countSectionHeadings(markdown: string, section: number): number {
|
|
30
|
-
const re = new RegExp(`^### ${section}\\.`, 'gm');
|
|
31
|
-
return (markdown.match(re) ?? []).length;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function countLedgerDataRows(markdown: string): number | null {
|
|
35
|
-
const heading = markdown.match(/^### 3\. Monitor Ledger\s*$/m);
|
|
36
|
-
if (!heading || heading.index === undefined) return null;
|
|
37
|
-
const after = markdown.slice(heading.index + heading[0].length);
|
|
38
|
-
const nextHeading = after.search(/^### /m);
|
|
39
|
-
const body = nextHeading === -1 ? after : after.slice(0, nextHeading);
|
|
40
|
-
const rows = body
|
|
41
|
-
.split('\n')
|
|
42
|
-
.filter((line) => line.trim().startsWith('|'))
|
|
43
|
-
.filter((line) => !/^\|[\s:|-]+\|?\s*$/.test(line.trim()))
|
|
44
|
-
// drift:external rows are documentary (task 0296) — included in the table but
|
|
45
|
-
// subtracted from the executed-step count, per the @1.2 cardinality contract;
|
|
46
|
-
// the prescribed code-span form (`drift:external`) matches too (task 0701 R5b).
|
|
47
|
-
.filter((line) => !/^\|\s*`?drift:/.test(line.trim()));
|
|
48
|
-
// Minus the header row; what remains are data rows.
|
|
49
|
-
return Math.max(rows.length - 1, 0);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function declaredExecutedSteps(markdown: string): number | null {
|
|
53
|
-
const match = markdown.match(/\*\*Steps:\*\*\s*\d+\s+derived,\s*(\d+)\s+executed/)?.[1];
|
|
54
|
-
return match ? Number.parseInt(match, 10) : null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ── Cost evidence contract (task 0913, R2) ──────────────────────────────────
|
|
58
|
-
|
|
59
|
-
const UNKNOWN_CELLS = new Set(['~unknown', 'unknown', '—', '-', '?', 'n/a', '~n/a']);
|
|
60
|
-
|
|
61
|
-
/** Display-rounding tolerance: a whole-percent share may differ from the exact
|
|
62
|
-
* value by at most 1 point (e.g. 700/2100 = 33.3% may display as 33%). */
|
|
63
|
-
const CACHE_SHARE_TOLERANCE = 1;
|
|
64
|
-
|
|
65
|
-
function sectionBody(markdown: string, headingRe: RegExp): string | null {
|
|
66
|
-
const heading = markdown.match(headingRe);
|
|
67
|
-
if (!heading || heading.index === undefined) return null;
|
|
68
|
-
const after = markdown.slice(heading.index + heading[0].length);
|
|
69
|
-
const nextHeading = after.search(/^###? /m);
|
|
70
|
-
return nextHeading === -1 ? after : after.slice(0, nextHeading);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface CostTotals {
|
|
74
|
-
total: number | 'n/a' | null;
|
|
75
|
-
cached: number | 'n/a' | null;
|
|
76
|
-
pct: number | 'n/a' | null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function parseTokensLine(line: string): CostTotals | null {
|
|
80
|
-
const match = line.match(
|
|
81
|
-
/~(?<total>n\/a|\d+)\s+total\s*\|\s*~(?<cached>n\/a|\d+)\s+cached(?:\s*\(\s*~?(?<pct>n\/a|\d+(?:\.\d+)?)%\s*hit rate\))?/i,
|
|
82
|
-
);
|
|
83
|
-
if (!match) return null;
|
|
84
|
-
const num = (v: string | undefined): number | 'n/a' | null =>
|
|
85
|
-
v === undefined ? null : v === 'n/a' ? 'n/a' : Number.parseInt(v, 10);
|
|
86
|
-
return { total: num(match.groups?.total), cached: num(match.groups?.cached), pct: num(match.groups?.pct) };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
interface LedgerCostRow {
|
|
90
|
-
step: string;
|
|
91
|
-
fresh: number | null;
|
|
92
|
-
cached: number | null;
|
|
93
|
-
cachePct: number | null;
|
|
94
|
-
unknownCell: boolean;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function parseTokenCell(cell: string): number | null {
|
|
98
|
-
const t = cell.trim();
|
|
99
|
-
if (UNKNOWN_CELLS.has(t)) return null;
|
|
100
|
-
const m = t.match(/~?(\d+)/)?.[1];
|
|
101
|
-
return m ? Number.parseInt(m, 10) : null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function parsePctCell(cell: string): number | null {
|
|
105
|
-
const t = cell.trim();
|
|
106
|
-
if (UNKNOWN_CELLS.has(t)) return null;
|
|
107
|
-
const m = t.match(/(\d+(?:\.\d+)?)\s*%/)?.[1];
|
|
108
|
-
return m ? Number.parseFloat(m) : null;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function ledgerCostRows(markdown: string): LedgerCostRow[] {
|
|
112
|
-
const body = sectionBody(markdown, /^### 3\. Monitor Ledger\s*$/m);
|
|
113
|
-
if (body === null) return [];
|
|
114
|
-
return body
|
|
115
|
-
.split('\n')
|
|
116
|
-
.filter((line) => line.trim().startsWith('|'))
|
|
117
|
-
.filter((line) => !/^\|[\s:|-]+\|?\s*$/.test(line.trim()))
|
|
118
|
-
.filter((line) => !/^\|\s*`?drift:/.test(line.trim()))
|
|
119
|
-
.slice(1) // drop header row
|
|
120
|
-
.map((line) => {
|
|
121
|
-
const cells = line
|
|
122
|
-
.split('|')
|
|
123
|
-
.map((c) => c.trim())
|
|
124
|
-
.filter((c, i, a) => !(i === 0 && c === '') && !(i === a.length - 1 && c === ''));
|
|
125
|
-
// Columns: 0 Step … 5 Fresh, 6 Cached, 7 Cache %
|
|
126
|
-
const freshCell = cells[5] ?? '';
|
|
127
|
-
const cachedCell = cells[6] ?? '';
|
|
128
|
-
return {
|
|
129
|
-
step: cells[0] ?? '',
|
|
130
|
-
fresh: parseTokenCell(freshCell),
|
|
131
|
-
cached: parseTokenCell(cachedCell),
|
|
132
|
-
cachePct: parsePctCell(cells[7] ?? ''),
|
|
133
|
-
unknownCell: UNKNOWN_CELLS.has(freshCell) || UNKNOWN_CELLS.has(cachedCell),
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function validateCostEvidence(markdown: string, errors: string[]): void {
|
|
139
|
-
const costBlock = sectionBody(markdown, /^#### Cost\s*$/m);
|
|
140
|
-
if (costBlock === null) {
|
|
141
|
-
errors.push('missing_cost_block');
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
for (const field of ['Ledger estimate', 'Method', 'Meter']) {
|
|
145
|
-
if (!costBlock.includes(`**${field}:**`)) errors.push(`missing_cost_field:${field}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const ledgerLine = costBlock.split('\n').find((l) => l.includes('**Ledger estimate:**')) ?? '';
|
|
149
|
-
const costTotals = parseTokensLine(ledgerLine);
|
|
150
|
-
// A label present but unparseable is its own defect (task 0913 review P3-1): report it and
|
|
151
|
-
// keep validating — an early return here disabled every downstream cost check, including
|
|
152
|
-
// the per-row impossible-percentage scan. An absent label is already reported above as
|
|
153
|
-
// missing_cost_field; with no line to parse there is nothing further to check for it.
|
|
154
|
-
if (ledgerLine !== '' && costTotals === null) errors.push('malformed_cost_line');
|
|
155
|
-
const footerLine = markdown.split('\n').find((l) => l.trim().startsWith('Tokens:'));
|
|
156
|
-
const footerTotals = footerLine ? parseTokensLine(footerLine) : null;
|
|
157
|
-
// Same contract for the footer: a present-but-unparseable Tokens: line must not
|
|
158
|
-
// silently skip the footer totals comparison. An absent Tokens: line with the
|
|
159
|
-
// summary block present is its own defect (task 0913 verify advisory).
|
|
160
|
-
if (footerLine !== undefined && footerTotals === null) errors.push('malformed_footer');
|
|
161
|
-
if (footerLine === undefined && markdown.includes('── Dogfood Summary ──')) {
|
|
162
|
-
errors.push('missing_footer_tokens');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Percentages must be within 0..100 wherever cost evidence renders one.
|
|
166
|
-
const pctScopes = [costBlock, footerLine ?? ''];
|
|
167
|
-
for (const row of ledgerCostRows(markdown)) {
|
|
168
|
-
if (row.cachePct !== null) pctScopes.push(`${row.cachePct}%`);
|
|
169
|
-
}
|
|
170
|
-
for (const scope of pctScopes) {
|
|
171
|
-
for (const m of scope.matchAll(/(\d+(?:\.\d+)?)\s*%/g)) {
|
|
172
|
-
const pct = Number.parseFloat(m[1] ?? '');
|
|
173
|
-
if (pct < 0 || pct > 100) errors.push(`impossible_percentage:${m[0].trim()}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const rows = ledgerCostRows(markdown);
|
|
178
|
-
|
|
179
|
-
// Unknown cells are never folded into a numeric share: a row whose basis is
|
|
180
|
-
// unknown must carry `—`, never a computed percent.
|
|
181
|
-
for (const row of rows) {
|
|
182
|
-
if (row.unknownCell && row.cachePct !== null) errors.push('unknown_row_with_numeric_cache');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Per-row arithmetic: a numeric Cache % must match the row's own fresh/cached cells
|
|
186
|
-
// (±1pt display rounding), not merely the aggregate share (task 0913 verify advisory).
|
|
187
|
-
for (const row of rows) {
|
|
188
|
-
if (row.fresh === null || row.cached === null || row.cachePct === null) continue;
|
|
189
|
-
const basis = row.fresh + row.cached;
|
|
190
|
-
if (basis === 0) continue;
|
|
191
|
-
const expected = Math.round((row.cached / basis) * 100);
|
|
192
|
-
if (Math.abs(row.cachePct - expected) > CACHE_SHARE_TOLERANCE) {
|
|
193
|
-
errors.push(`cache_pct_mismatch:${row.step}_expected_${expected}`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const observable = rows.filter((r) => r.fresh !== null && r.cached !== null);
|
|
198
|
-
const sumFresh = observable.reduce((acc, r) => acc + (r.fresh ?? 0), 0);
|
|
199
|
-
const sumCached = observable.reduce((acc, r) => acc + (r.cached ?? 0), 0);
|
|
200
|
-
|
|
201
|
-
const checkTotals = (label: string, totals: CostTotals | null): void => {
|
|
202
|
-
if (totals === null) return;
|
|
203
|
-
if (observable.length > 0) {
|
|
204
|
-
const expectedTotal = sumFresh + sumCached;
|
|
205
|
-
if (typeof totals.total === 'number' && totals.total !== expectedTotal) {
|
|
206
|
-
errors.push(`cost_total_mismatch:${label}_expected_${expectedTotal}`);
|
|
207
|
-
}
|
|
208
|
-
if (typeof totals.cached === 'number' && totals.cached !== sumCached) {
|
|
209
|
-
errors.push(`cost_total_mismatch:${label}_cached_expected_${sumCached}`);
|
|
210
|
-
}
|
|
211
|
-
const expectedPct = expectedTotal > 0 ? Math.round((sumCached / expectedTotal) * 100) : null;
|
|
212
|
-
if (expectedPct !== null) {
|
|
213
|
-
if (totals.pct === 'n/a' || totals.pct === null) {
|
|
214
|
-
errors.push(`missing_cache_share:${label}`);
|
|
215
|
-
} else if (
|
|
216
|
-
typeof totals.pct === 'number' &&
|
|
217
|
-
Math.abs(totals.pct - expectedPct) > CACHE_SHARE_TOLERANCE
|
|
218
|
-
) {
|
|
219
|
-
errors.push(`cache_share_mismatch:${label}_expected_${expectedPct}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
} else if (
|
|
223
|
-
typeof totals.total === 'number' ||
|
|
224
|
-
typeof totals.cached === 'number' ||
|
|
225
|
-
typeof totals.pct === 'number'
|
|
226
|
-
) {
|
|
227
|
-
// No observable denominator: numeric totals/shares fabricate evidence
|
|
228
|
-
// from unknown rows (unknown folded into zero). `n/a` is the honest form.
|
|
229
|
-
errors.push(`fabricated_cache_share:${label}`);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
checkTotals('cost', costTotals);
|
|
233
|
-
checkTotals('footer', footerTotals);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export function validateReport(markdown: string): ReportValidation {
|
|
237
|
-
const errors: string[] = [];
|
|
238
|
-
|
|
239
|
-
// Footer (W2/D1) — the mirrored footer block at the report end.
|
|
240
|
-
if (!markdown.includes('── Dogfood Summary ──')) errors.push('missing_footer');
|
|
241
|
-
if (!markdown.includes('[Live:')) errors.push('missing_live_path');
|
|
242
|
-
if (!markdown.includes('[Report:')) errors.push('missing_report_path');
|
|
243
|
-
|
|
244
|
-
// Six unique section headings (W2/D3).
|
|
245
|
-
for (const section of REQUIRED_SECTIONS) {
|
|
246
|
-
const count = countSectionHeadings(markdown, section);
|
|
247
|
-
if (count === 0) errors.push(`missing_section:${section}`);
|
|
248
|
-
if (count > 1) errors.push(`duplicate_section:${section}`);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Issues subheads (W2/D3).
|
|
252
|
-
if (!markdown.includes('#### Fixed') || !markdown.includes('#### Unresolved')) {
|
|
253
|
-
errors.push('missing_issues_subheads');
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Protocol string (W1/D5) — colon form, exact version.
|
|
257
|
-
const protocolMatch = markdown.match(/^protocol:\s*(\S+)\s*$/m);
|
|
258
|
-
if (!protocolMatch || protocolMatch[1] !== CANONICAL_PROTOCOL) {
|
|
259
|
-
errors.push('protocol_string');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Ledger cardinality (W3/D4) — data rows == declared executed steps.
|
|
263
|
-
const executed = declaredExecutedSteps(markdown);
|
|
264
|
-
if (executed === null) {
|
|
265
|
-
errors.push('missing_steps_declared');
|
|
266
|
-
} else {
|
|
267
|
-
const rows = countLedgerDataRows(markdown);
|
|
268
|
-
if (rows === null || rows !== executed) {
|
|
269
|
-
errors.push('ledger_cardinality');
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Cost evidence (task 0913, R2) — required block, arithmetic consistency,
|
|
274
|
-
// honest unknowns.
|
|
275
|
-
validateCostEvidence(markdown, errors);
|
|
276
|
-
|
|
277
|
-
return { ok: errors.length === 0, errors };
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ── CLI entry (Phase 4 self-validate — task 0278 R6) ─────────────────────────
|
|
14
|
+
export * from '../../lib/dogfood-report';
|
|
281
15
|
|
|
282
16
|
export interface ValidateCliArgs {
|
|
283
17
|
file: string | null;
|