@planu/cli 5.7.6 → 5.7.8
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/CHANGELOG.md +31 -0
- package/dist/.planu-build.json +1 -1
- package/dist/config/hook-templates/planu-review-panel-trigger.sh +2 -3
- package/dist/config/skill-templates/planu-multi-teammate-review.md +7 -11
- package/dist/engine/evidence-gates/evidence-skeletons.js +3 -1
- package/dist/engine/execution/job-runtime.d.ts +7 -3
- package/dist/engine/execution/job-runtime.js +18 -6
- package/dist/engine/execution/validate-job-executor.d.ts +2 -0
- package/dist/engine/execution/validate-job-executor.js +25 -0
- package/dist/engine/readiness-checker.js +17 -6
- package/dist/engine/reconcile/propagate-mirrors.js +6 -6
- package/dist/engine/spec-format/lean-spec-generator.js +2 -2
- package/dist/engine/spec-grounding/contract.d.ts +3 -3
- package/dist/engine/spec-grounding/contract.js +23 -76
- package/dist/engine/spec-grounding/grounding-entry-parser.d.ts +5 -0
- package/dist/engine/spec-grounding/grounding-entry-parser.js +185 -0
- package/dist/storage/runtime-db.d.ts +4 -2
- package/dist/storage/runtime-db.js +50 -12
- package/dist/storage/spec-store.d.ts +2 -1
- package/dist/storage/spec-store.js +28 -3
- package/dist/tools/bump-spec-version.js +5 -5
- package/dist/tools/create-spec.js +4 -1
- package/dist/tools/init-project/skills-multi-teammate-review-writer.js +1 -1
- package/dist/tools/jobs/handlers.js +18 -11
- package/dist/tools/list-specs.js +33 -15
- package/dist/tools/multi-teammate-review.js +1 -14
- package/dist/tools/register-platform-tools/design-stack-tools.js +3 -3
- package/dist/tools/register-spec-tools/analysis-tools.js +22 -9
- package/dist/tools/register-spec-tools/core-spec-tools.js +97 -43
- package/dist/tools/schemas/output-schemas.d.ts +14 -0
- package/dist/tools/schemas/output-schemas.js +14 -0
- package/dist/tools/schemas/package-handoff-output-schema.d.ts +1 -0
- package/dist/tools/schemas/package-handoff-output-schema.js +3 -1
- package/dist/tools/schemas/validate-output-schema.d.ts +1 -0
- package/dist/tools/schemas/validate-output-schema.js +3 -1
- package/dist/tools/sync-spec-state-handler.js +92 -23
- package/dist/tools/tool-registry/core-tools.js +71 -24
- package/dist/tools/tool-registry/group-quality-compliance.js +11 -14
- package/dist/tools/tool-registry-helpers.js +6 -2
- package/dist/types/durable-job.d.ts +1 -0
- package/dist/types/spec/core.d.ts +4 -0
- package/dist/types/spec-grounding.d.ts +14 -0
- package/package.json +3 -3
- package/planu-plugin.json +1 -1
- package/dist/tools/tool-registry/deprecated-stubs.d.ts +0 -19
- package/dist/tools/tool-registry/deprecated-stubs.js +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## [5.7.8] - 2026-09-02
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
- fix(create-spec): emit the double-dash joiner only for npm in verification commands
|
|
5
|
+
- fix(hooks): route unmirrored sources through the vitest related lane in the pre-push selector
|
|
6
|
+
- fix(deps): override qs to >=6.16.0 to clear moderate advisories
|
|
7
|
+
- fix(jobs): expose restarts in public job projections
|
|
8
|
+
- fix(sync-spec-state): quarantine only missing or empty specs and reject unresolvable terminal paths
|
|
9
|
+
- fix(jobs): recover expired validate leases, surface stalled queue status and cap restarts
|
|
10
|
+
- fix(spec-store): resolve specPath against project root for ghost detection
|
|
11
|
+
|
|
12
|
+
### Refactoring
|
|
13
|
+
- refactor(preflight): drop duplicated gates from check:preflight and cap coverage at 6 workers
|
|
14
|
+
|
|
15
|
+
### Chores
|
|
16
|
+
- chore(deps): raise the fast-uri override to the patched 4.1.3 range
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [5.7.7] - 2026-09-02
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
- fix(hooks): route src/config template assets through reference classification in selector
|
|
23
|
+
- fix(tools): drop phantom multi_teammate_review from review-panel hook and scan hook templates
|
|
24
|
+
- fix(tools): delete dead deprecated-tool stubs dropped by the purged registry
|
|
25
|
+
- fix(tools): extend schema constraint audit to nested items and combinators
|
|
26
|
+
- fix(tools): declare regex and max constraints in tool input schema descriptions
|
|
27
|
+
- fix(storage): spec store returns absent for deleted canonical spec so validate fails closed with spec_not_found
|
|
28
|
+
- fix(spec-grounding): surface structured diagnostics for dropped grounding records
|
|
29
|
+
- fix(spec-format): accept plus bullet markers in checkbox and plain-list criterion parsers
|
|
30
|
+
|
|
31
|
+
|
|
1
32
|
## [5.7.6] - 2026-09-01
|
|
2
33
|
|
|
3
34
|
### Features
|
package/dist/.planu-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"commit":"
|
|
1
|
+
{"schemaVersion":1,"commit":"bb0b76967c77e4a602407783d6fdfcee6f0be92d"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Wired as a PreToolUse hook for the Bash tool.
|
|
6
6
|
# When Claude Code is about to run a git diff or review command and the diff is
|
|
7
|
-
# large (>500 LOC), this hook
|
|
7
|
+
# large (>500 LOC), this hook suggests the panel review skill.
|
|
8
8
|
# It NEVER blocks execution — exit 0 always.
|
|
9
9
|
|
|
10
10
|
set -uo pipefail
|
|
@@ -26,8 +26,7 @@ if [[ "$LOC" -gt "$THRESHOLD" ]]; then
|
|
|
26
26
|
echo ""
|
|
27
27
|
echo "💡 Planu tip: This diff is ${LOC} LOC (threshold: ${THRESHOLD})."
|
|
28
28
|
echo " Consider running the 5-specialist panel review for thorough analysis:"
|
|
29
|
-
echo " →
|
|
30
|
-
echo " Or use the /planu-multi-teammate-review skill."
|
|
29
|
+
echo " → use the /planu-multi-teammate-review skill."
|
|
31
30
|
echo ""
|
|
32
31
|
fi
|
|
33
32
|
|
|
@@ -25,18 +25,14 @@ Use this skill when you want a thorough, multi-perspective code review:
|
|
|
25
25
|
|
|
26
26
|
**Trigger phrases**: "panel review", "thorough review", "5-agent review", "deep review", "run the specialist panel"
|
|
27
27
|
|
|
28
|
-
## How
|
|
28
|
+
## How this skill runs the review
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
commitRange: "main..HEAD", // optional: for context
|
|
37
|
-
spec: "<linked spec content>" // optional: helps the arbitrator detect spec drift
|
|
38
|
-
})
|
|
39
|
-
```
|
|
30
|
+
This skill runs the panel directly — it is not an MCP tool call. Gather the review inputs below, then run the panel yourself following the specialist roles described in this skill:
|
|
31
|
+
|
|
32
|
+
- `projectPath` — absolute path to the project
|
|
33
|
+
- `diff` — unified diff text (preferred: paste the output of `git diff`)
|
|
34
|
+
- `prNumber`, `branch`, or `commitRange` — optional context for the report header
|
|
35
|
+
- `spec` — optional linked spec content, enables spec-drift detection in the Maintainability specialist's report
|
|
40
36
|
|
|
41
37
|
At least one of `diff`, `prNumber`, `branch`, or `commitRange` must be provided.
|
|
42
38
|
|
|
@@ -32,7 +32,9 @@ function outOfScopeFromBody(specBody) {
|
|
|
32
32
|
}
|
|
33
33
|
/** Build a strict-schema discovery.json skeleton grounded in the spec's own grounding metadata. */
|
|
34
34
|
export function generateDiscoverySkeleton(args) {
|
|
35
|
-
const records = args.body
|
|
35
|
+
const records = args.body
|
|
36
|
+
? parseCriterionGroundingRecords(specFrontmatter(args.body)).records
|
|
37
|
+
: [];
|
|
36
38
|
const rules = records.length > 0 ? [...new Set(records.map((record) => record.text))] : [DEFAULT_RULE];
|
|
37
39
|
const examples = records.length > 0
|
|
38
40
|
? records.map((record) => ({
|
|
@@ -19,7 +19,10 @@ export declare class DurableJobRuntime implements Disposable {
|
|
|
19
19
|
}): DurableJobRecord;
|
|
20
20
|
get(input: DurableJobIdentity): DurableJobRecord;
|
|
21
21
|
/** Return the allowlisted public projection for one job and its current queue scope. */
|
|
22
|
-
observe(input: DurableJobIdentity | DurableJobRecord
|
|
22
|
+
observe(input: DurableJobIdentity | DurableJobRecord, options?: {
|
|
23
|
+
readonly scopeActive?: boolean;
|
|
24
|
+
}): ReturnType<typeof publicJobObservation>;
|
|
25
|
+
recoverExpired(projectId: string, workspaceId: string): number;
|
|
23
26
|
list(projectId: string, workspaceId?: string): readonly DurableJobRecord[];
|
|
24
27
|
listRunnableScopes(): readonly {
|
|
25
28
|
projectId: string;
|
|
@@ -71,7 +74,7 @@ export declare class DurableJobRuntime implements Disposable {
|
|
|
71
74
|
/** Stable watcher cursor that detects state changes even within one clock millisecond. */
|
|
72
75
|
export declare function durableJobCursor(job: DurableJobRecord): string;
|
|
73
76
|
/** Build a privacy-safe job projection from existing durable records. */
|
|
74
|
-
export declare function publicJobObservation(job: DurableJobRecord, scopeJobs: readonly DurableJobRecord[], now?: number): {
|
|
77
|
+
export declare function publicJobObservation(job: DurableJobRecord, scopeJobs: readonly DurableJobRecord[], now?: number, scopeActive?: boolean): {
|
|
75
78
|
id: string;
|
|
76
79
|
projectId: string;
|
|
77
80
|
workspaceId: string;
|
|
@@ -81,11 +84,12 @@ export declare function publicJobObservation(job: DurableJobRecord, scopeJobs: r
|
|
|
81
84
|
error?: string;
|
|
82
85
|
attempts: number;
|
|
83
86
|
maxAttempts: number;
|
|
87
|
+
restarts: number;
|
|
84
88
|
cancelRequested: boolean;
|
|
85
89
|
createdAt: string;
|
|
86
90
|
updatedAt: string;
|
|
87
91
|
queue: {
|
|
88
|
-
status: 'active' | 'queued' | 'terminal';
|
|
92
|
+
status: 'active' | 'queued' | 'stalled' | 'terminal';
|
|
89
93
|
position: number | null;
|
|
90
94
|
aheadCount: number;
|
|
91
95
|
capacity: number;
|
|
@@ -47,9 +47,12 @@ export class DurableJobRuntime {
|
|
|
47
47
|
return this.requireJob(input);
|
|
48
48
|
}
|
|
49
49
|
/** Return the allowlisted public projection for one job and its current queue scope. */
|
|
50
|
-
observe(input) {
|
|
50
|
+
observe(input, options) {
|
|
51
51
|
const job = 'id' in input ? input : this.requireJob(input);
|
|
52
|
-
return publicJobObservation(job, this.list(job.projectId, job.workspaceId));
|
|
52
|
+
return publicJobObservation(job, this.list(job.projectId, job.workspaceId), Date.now(), options?.scopeActive ?? true);
|
|
53
|
+
}
|
|
54
|
+
recoverExpired(projectId, workspaceId) {
|
|
55
|
+
return this.database.recoverExpiredJobs(new Date().toISOString(), projectId, workspaceId);
|
|
53
56
|
}
|
|
54
57
|
list(projectId, workspaceId = DEFAULT_WORKSPACE_ID) {
|
|
55
58
|
return this.database.listJobs(projectId, workspaceId);
|
|
@@ -184,8 +187,8 @@ export function durableJobCursor(job) {
|
|
|
184
187
|
});
|
|
185
188
|
}
|
|
186
189
|
/** Build a privacy-safe job projection from existing durable records. */
|
|
187
|
-
export function publicJobObservation(job, scopeJobs, now = Date.now()) {
|
|
188
|
-
const status = queueStatus(job);
|
|
190
|
+
export function publicJobObservation(job, scopeJobs, now = Date.now(), scopeActive = true) {
|
|
191
|
+
const status = queueStatus(job, now, scopeActive);
|
|
189
192
|
const queueJobs = scopeJobs.filter(isQueueRelevant).filter((candidate) => !isTerminal(candidate));
|
|
190
193
|
const positionIndex = queueJobs.findIndex((candidate) => candidate.id === job.id);
|
|
191
194
|
const position = status === 'terminal' ? null : Math.max(0, positionIndex) + 1;
|
|
@@ -230,16 +233,25 @@ function publicJobFields(job) {
|
|
|
230
233
|
...(job.error === undefined ? {} : { error: sanitizePublicJobValue(job.error) }),
|
|
231
234
|
attempts: job.attempts,
|
|
232
235
|
maxAttempts: job.maxAttempts,
|
|
236
|
+
restarts: job.restarts,
|
|
233
237
|
cancelRequested: job.cancelRequested,
|
|
234
238
|
createdAt: job.createdAt,
|
|
235
239
|
updatedAt: job.updatedAt,
|
|
236
240
|
};
|
|
237
241
|
}
|
|
238
|
-
function queueStatus(job) {
|
|
242
|
+
function queueStatus(job, now = Date.now(), scopeActive = true) {
|
|
239
243
|
if (isTerminal(job)) {
|
|
240
244
|
return 'terminal';
|
|
241
245
|
}
|
|
242
|
-
|
|
246
|
+
if (job.state === 'running') {
|
|
247
|
+
return 'active';
|
|
248
|
+
}
|
|
249
|
+
if ((job.state === 'accepted' || job.state === 'checkpointed') &&
|
|
250
|
+
!scopeActive &&
|
|
251
|
+
now - Date.parse(job.updatedAt) > getRuntimePolicy().validation.workerLeaseMs) {
|
|
252
|
+
return 'stalled';
|
|
253
|
+
}
|
|
254
|
+
return 'queued';
|
|
243
255
|
}
|
|
244
256
|
function isTerminal(job) {
|
|
245
257
|
return TERMINAL_STATES.has(job.state);
|
|
@@ -9,6 +9,7 @@ export declare class ValidateJobExecutor {
|
|
|
9
9
|
constructor(runtime: DurableJobRuntime, workerId?: string, options?: ValidateJobExecutorOptions);
|
|
10
10
|
runOnce(projectId: string, workspaceId?: string): Promise<readonly DurableJobRecord[]>;
|
|
11
11
|
runUntilIdle(projectId: string, workspaceId?: string): Promise<void>;
|
|
12
|
+
private ownLeaseWaitMs;
|
|
12
13
|
private execute;
|
|
13
14
|
private runClaimedValidation;
|
|
14
15
|
private resumeReceiptPublication;
|
|
@@ -28,6 +29,7 @@ export declare class ValidateJobExecutor {
|
|
|
28
29
|
private preparePublicationLease;
|
|
29
30
|
private persistReceiptArtifacts;
|
|
30
31
|
}
|
|
32
|
+
export declare function isValidateScopeActive(projectId: string, workspaceId?: string): boolean;
|
|
31
33
|
/** Schedules background execution after the submit response can be flushed. */
|
|
32
34
|
export declare function scheduleValidateJobExecution(projectId: string, workspaceId?: string): void;
|
|
33
35
|
/** Re-enqueues accepted/checkpointed validate work discovered after a process restart. */
|
|
@@ -24,6 +24,7 @@ import { redactSensitiveValue, redactText } from '../../security/redactor.js';
|
|
|
24
24
|
import { MacOSKeychainOperationError } from '../../security/adapters/macos-keychain.js';
|
|
25
25
|
import { createDurableJobHeartbeat } from './durable-job-heartbeat-runtime.js';
|
|
26
26
|
const WORKSPACE_ID = 'global';
|
|
27
|
+
const MIN_LEASE_WAIT_MS = 50;
|
|
27
28
|
const activeScopes = new Map();
|
|
28
29
|
const RECEIPT_PUBLICATION_FAILURE_MESSAGES = {
|
|
29
30
|
keychain_timeout: '[Planu] VALIDATION_RECEIPT_PENDING action=restart_job cause=keychain_timeout: the signing key could not be read from the keychain before the read timed out',
|
|
@@ -89,6 +90,9 @@ function truncateUtf8ByBytes(value, maximumBytes) {
|
|
|
89
90
|
function canonicalJson(value) {
|
|
90
91
|
return JSON.stringify(value);
|
|
91
92
|
}
|
|
93
|
+
function delay(ms) {
|
|
94
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
95
|
+
}
|
|
92
96
|
function hasReceipt(result) {
|
|
93
97
|
const structured = result.structuredContent;
|
|
94
98
|
return typeof structured?.receiptId === 'string' && typeof structured.receiptKey === 'string';
|
|
@@ -180,8 +184,10 @@ export class ValidateJobExecutor {
|
|
|
180
184
|
}
|
|
181
185
|
async runUntilIdle(projectId, workspaceId = WORKSPACE_ID) {
|
|
182
186
|
const capacity = getRuntimePolicy().validation.workerConcurrency;
|
|
187
|
+
const workerLeaseMs = getRuntimePolicy().validation.workerLeaseMs;
|
|
183
188
|
const active = new Set();
|
|
184
189
|
for (;;) {
|
|
190
|
+
this.runtime.recoverExpired(projectId, workspaceId);
|
|
185
191
|
const available = capacity - active.size;
|
|
186
192
|
const candidates = this.runtime
|
|
187
193
|
.list(projectId, workspaceId)
|
|
@@ -200,6 +206,15 @@ export class ValidateJobExecutor {
|
|
|
200
206
|
active.add(execution);
|
|
201
207
|
}
|
|
202
208
|
if (active.size === 0) {
|
|
209
|
+
const ownLostLease = this.runtime
|
|
210
|
+
.list(projectId, workspaceId)
|
|
211
|
+
.find((job) => job.state === 'running' &&
|
|
212
|
+
job.leaseOwner === this.workerId &&
|
|
213
|
+
isValidateJob(job.payload));
|
|
214
|
+
if (ownLostLease) {
|
|
215
|
+
await delay(this.ownLeaseWaitMs(ownLostLease.leaseExpiresAt, workerLeaseMs));
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
203
218
|
return;
|
|
204
219
|
}
|
|
205
220
|
if (active.size >= capacity || candidates.length === 0) {
|
|
@@ -207,6 +222,13 @@ export class ValidateJobExecutor {
|
|
|
207
222
|
}
|
|
208
223
|
}
|
|
209
224
|
}
|
|
225
|
+
ownLeaseWaitMs(leaseExpiresAt, workerLeaseMs) {
|
|
226
|
+
const expiresAtMs = leaseExpiresAt ? Date.parse(leaseExpiresAt) : Number.NaN;
|
|
227
|
+
if (!Number.isFinite(expiresAtMs)) {
|
|
228
|
+
return workerLeaseMs;
|
|
229
|
+
}
|
|
230
|
+
return Math.min(Math.max(expiresAtMs - Date.now(), MIN_LEASE_WAIT_MS), workerLeaseMs);
|
|
231
|
+
}
|
|
210
232
|
async execute(job) {
|
|
211
233
|
const identity = {
|
|
212
234
|
operationId: job.id,
|
|
@@ -818,6 +840,9 @@ export class ValidateJobExecutor {
|
|
|
818
840
|
return undefined;
|
|
819
841
|
}
|
|
820
842
|
}
|
|
843
|
+
export function isValidateScopeActive(projectId, workspaceId = WORKSPACE_ID) {
|
|
844
|
+
return activeScopes.has(`${projectId}:${workspaceId}`);
|
|
845
|
+
}
|
|
821
846
|
/** Schedules background execution after the submit response can be flushed. */
|
|
822
847
|
export function scheduleValidateJobExecution(projectId, workspaceId = WORKSPACE_ID) {
|
|
823
848
|
const scope = `${projectId}:${workspaceId}`;
|
|
@@ -12,14 +12,29 @@ import { evaluateImplementationContract } from './implementation-contract/index.
|
|
|
12
12
|
import { extractNormalizedAcceptanceCriteria } from './spec-format/acceptance-criteria.js';
|
|
13
13
|
import { isRetiredScaffoldText } from './spec-format/retired-scaffold.js';
|
|
14
14
|
import { detectCrossSpecPremiseContradictions } from './contradiction-detector.js';
|
|
15
|
+
import { parseCriterionGroundingRecords, parseTechnicalReferenceGroundingRecords, } from './spec-grounding/contract.js';
|
|
15
16
|
// ── SPEC-784: Technical section quality constants ─────────────────────────────
|
|
16
17
|
const TECHNICAL_MIN_CHARS = 500;
|
|
18
|
+
const GROUNDING_FRONTMATTER_RE = /^---\n([\s\S]*?)\n---/;
|
|
17
19
|
// Detects "See technical.md", "See spec.md", or "See `<file>` technical.md" patterns
|
|
18
20
|
const TECHNICAL_PLACEHOLDER_REGEX = /\bSee\s+(?:`?[^`\n]+`?\s+)?(?:technical|spec)\.md/i;
|
|
19
21
|
const BDD_CRITERION_RE = /\bGIVEN\b[\s\S]*\bWHEN\b[\s\S]*\bTHEN\b/i;
|
|
20
22
|
function isExecutableBddLine(line) {
|
|
21
23
|
return !isRetiredScaffoldText(line) && BDD_CRITERION_RE.test(line);
|
|
22
24
|
}
|
|
25
|
+
function groundingParseDiagnosticFindings(huRaw) {
|
|
26
|
+
const frontmatter = GROUNDING_FRONTMATTER_RE.exec(huRaw)?.[1] ?? '';
|
|
27
|
+
const criteriaDiagnostics = parseCriterionGroundingRecords(frontmatter).diagnostics;
|
|
28
|
+
const technicalDiagnostics = parseTechnicalReferenceGroundingRecords(frontmatter).diagnostics;
|
|
29
|
+
return [...criteriaDiagnostics, ...technicalDiagnostics].map((diagnostic) => `GROUNDING_PARSE_DROPPED: "${diagnostic.identifier}" has an invalid ${diagnostic.field} ` +
|
|
30
|
+
`("${diagnostic.value}") — allowed: ${diagnostic.allowed.join(', ') || 'n/a'}`);
|
|
31
|
+
}
|
|
32
|
+
function checkScenariosWithoutTests(huRaw, bddScenarioCount) {
|
|
33
|
+
if (bddScenarioCount === 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return findScenariosWithoutTests(huRaw).map((title) => `scenarios_missing_tests: scenario "${title}" has no tests array — add tests entries as a block list (tests: with one "- path" line per test) or an inline array (tests: ["path"]) (SPEC-732)`);
|
|
37
|
+
}
|
|
23
38
|
function checkZeroBddCriteria(criteriaLines) {
|
|
24
39
|
if (criteriaLines.length === 0 || criteriaLines.some(isExecutableBddLine)) {
|
|
25
40
|
return [];
|
|
@@ -449,16 +464,12 @@ export async function checkSpecReadiness(spec, mode, projectHash) {
|
|
|
449
464
|
// SPEC-732: Executable AC gate — block approved when any scenario lacks a `tests` array.
|
|
450
465
|
// Only enforce when the spec uses frontmatter scenarios (BDD format).
|
|
451
466
|
const bddScenarioCount = countFrontmatterScenarios(huRaw);
|
|
452
|
-
|
|
453
|
-
const scenariosWithoutTests = findScenariosWithoutTests(huRaw);
|
|
454
|
-
for (const title of scenariosWithoutTests) {
|
|
455
|
-
allBlockers.push(`scenarios_missing_tests: scenario "${title}" has no tests array — add tests entries as a block list (tests: with one "- path" line per test) or an inline array (tests: ["path"]) (SPEC-732)`);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
467
|
+
allBlockers.push(...checkScenariosWithoutTests(huRaw, bddScenarioCount));
|
|
458
468
|
const scavengeWarning = frontmatterScenarioScavengeWarning(bddScenarioCount, normalizedCriteria);
|
|
459
469
|
if (scavengeWarning) {
|
|
460
470
|
allWarnings.push(scavengeWarning);
|
|
461
471
|
}
|
|
472
|
+
allWarnings.push(...groundingParseDiagnosticFindings(huRaw));
|
|
462
473
|
// SPEC-1214: BDD-criteria executable-evidence gate — when a spec has no frontmatter
|
|
463
474
|
// scenarios, its criteria must carry a TEST: marker mapping to an executable test file,
|
|
464
475
|
// or validation will later score 0 with "No executable scenarios declared".
|
|
@@ -33,9 +33,9 @@ function propagateAcceptanceCriteria(content) {
|
|
|
33
33
|
const sectionBody = content.slice(section.contentStart, section.end);
|
|
34
34
|
const criteriaTexts = extractSectionCriteria(sectionBody);
|
|
35
35
|
const scenarios = criteriaTexts.map(criterionToScenario);
|
|
36
|
-
const oldRecords = mapWithFrontmatter(content, (fm) => indexCriterionRecords(parseCriterionGroundingRecords(fm)));
|
|
36
|
+
const oldRecords = mapWithFrontmatter(content, (fm) => indexCriterionRecords(parseCriterionGroundingRecords(fm).records));
|
|
37
37
|
const oldTestPaths = mapWithFrontmatter(content, (fm) => parseTechnicalReferenceGroundingRecords(fm)
|
|
38
|
-
.filter((record) => record.section === 'test')
|
|
38
|
+
.records.filter((record) => record.section === 'test')
|
|
39
39
|
.map((record) => record.path));
|
|
40
40
|
const criteriaRecords = criteriaTexts.map((text) => oldRecords.get(normalizeCriterionText(text)) ?? {
|
|
41
41
|
text,
|
|
@@ -59,9 +59,9 @@ function propagateFiles(content) {
|
|
|
59
59
|
const sectionBody = content.slice(section.contentStart, section.end);
|
|
60
60
|
const files = parseFilesSection(sectionBody);
|
|
61
61
|
const oldTestPaths = mapWithFrontmatter(content, (fm) => parseTechnicalReferenceGroundingRecords(fm)
|
|
62
|
-
.filter((record) => record.section === 'test')
|
|
62
|
+
.records.filter((record) => record.section === 'test')
|
|
63
63
|
.map((record) => record.path));
|
|
64
|
-
const oldTechnicalReferences = mapWithFrontmatter(content, (fm) => indexTechnicalReferenceRecords(parseTechnicalReferenceGroundingRecords(fm)));
|
|
64
|
+
const oldTechnicalReferences = mapWithFrontmatter(content, (fm) => indexTechnicalReferenceRecords(parseTechnicalReferenceGroundingRecords(fm).records));
|
|
65
65
|
const technicalReferences = buildTechnicalReferenceRecords(files, oldTechnicalReferences);
|
|
66
66
|
const newTestPaths = files.test;
|
|
67
67
|
let result = transformFrontmatter(content, (fm) => replaceFrontmatterKeyBlock(fm, 'grounding', groundingBlockLines(criteriaRecordsFromFrontmatter(fm), technicalReferences)));
|
|
@@ -285,10 +285,10 @@ function mapWithFrontmatter(content, read) {
|
|
|
285
285
|
return read(match?.[1] ?? '');
|
|
286
286
|
}
|
|
287
287
|
function technicalReferencesFromFrontmatter(frontmatter) {
|
|
288
|
-
return parseTechnicalReferenceGroundingRecords(frontmatter);
|
|
288
|
+
return parseTechnicalReferenceGroundingRecords(frontmatter).records;
|
|
289
289
|
}
|
|
290
290
|
function criteriaRecordsFromFrontmatter(frontmatter) {
|
|
291
|
-
return parseCriterionGroundingRecords(frontmatter);
|
|
291
|
+
return parseCriterionGroundingRecords(frontmatter).records;
|
|
292
292
|
}
|
|
293
293
|
function groundingBlockLines(criteria, technicalReferences) {
|
|
294
294
|
const criteriaLines = renderGroundingFrontmatter(criteria).slice(2);
|
|
@@ -154,7 +154,7 @@ export function extractCriteria(description) {
|
|
|
154
154
|
/** Extract checkbox-style criteria: `- [ ] text` or `- [x] text`. */
|
|
155
155
|
function extractCheckboxCriteria(description) {
|
|
156
156
|
const criteria = [];
|
|
157
|
-
const checkboxRegex = /^[
|
|
157
|
+
const checkboxRegex = /^[-*+]\s*\[([ xX])\]\s*(.+)$/gm;
|
|
158
158
|
let match = checkboxRegex.exec(description);
|
|
159
159
|
while (match) {
|
|
160
160
|
criteria.push({
|
|
@@ -205,7 +205,7 @@ function extractPlainListCriteria(description) {
|
|
|
205
205
|
}
|
|
206
206
|
const criteria = [];
|
|
207
207
|
// Plain list: `- text` or `* text`, not followed by `[`
|
|
208
|
-
const plainListRegex = /^[
|
|
208
|
+
const plainListRegex = /^[-*+]\s+(?!\[)(.+)$/gm;
|
|
209
209
|
let match = plainListRegex.exec(acceptanceSection);
|
|
210
210
|
while (match) {
|
|
211
211
|
const text = match[1]?.trim() ?? '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Spec } from '../../types/index.js';
|
|
2
|
-
import type { CriterionGroundingRecord, GroundingGateResult, TechnicalReferenceGroundingRecord } from '../../types/spec-grounding.js';
|
|
2
|
+
import type { CriterionGroundingRecord, GroundingGateResult, GroundingParseResult, TechnicalReferenceGroundingRecord } from '../../types/spec-grounding.js';
|
|
3
3
|
export { normalizeCriterionText } from '../criterion-identity.js';
|
|
4
4
|
export declare function isGenericCriterion(text: string): boolean;
|
|
5
5
|
export declare function filterGroundedCriteria(criteria: string[]): string[];
|
|
@@ -19,8 +19,8 @@ export declare function getAdvisoryCriteria(records: CriterionGroundingRecord[])
|
|
|
19
19
|
export declare function renderGroundingFrontmatter(records: CriterionGroundingRecord[]): string[];
|
|
20
20
|
export declare function renderTechnicalReferenceGroundingFrontmatter(records: TechnicalReferenceGroundingRecord[]): string[];
|
|
21
21
|
export declare function checkGroundedSpecContract(spec: Spec, content: string): GroundingGateResult;
|
|
22
|
-
export declare function parseCriterionGroundingRecords(frontmatter: string): CriterionGroundingRecord
|
|
23
|
-
export declare function parseTechnicalReferenceGroundingRecords(frontmatter: string): TechnicalReferenceGroundingRecord
|
|
22
|
+
export declare function parseCriterionGroundingRecords(frontmatter: string): GroundingParseResult<CriterionGroundingRecord>;
|
|
23
|
+
export declare function parseTechnicalReferenceGroundingRecords(frontmatter: string): GroundingParseResult<TechnicalReferenceGroundingRecord>;
|
|
24
24
|
export declare function parseApprovedFileLevelWorkPlanPaths(content: string): string[];
|
|
25
25
|
export declare function parseGroundedTechnicalPaths(content: string): string[];
|
|
26
26
|
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import YAML from 'yaml';
|
|
2
2
|
import { createCriterionIdentity, normalizeCriterionText } from '../criterion-identity.js';
|
|
3
|
-
|
|
4
|
-
'user_input',
|
|
5
|
-
'project_evidence',
|
|
6
|
-
'documented_assumption',
|
|
7
|
-
'ungrounded_advisory',
|
|
8
|
-
];
|
|
9
|
-
const GROUNDING_CONFIDENCES = ['low', 'medium', 'high'];
|
|
10
|
-
const TECHNICAL_REFERENCE_SECTIONS = [
|
|
11
|
-
'create',
|
|
12
|
-
'modify',
|
|
13
|
-
'test',
|
|
14
|
-
];
|
|
3
|
+
import { isRecord, toCriterionGroundingRecord, toTechnicalReferenceGroundingRecord, } from './grounding-entry-parser.js';
|
|
15
4
|
export { normalizeCriterionText } from '../criterion-identity.js';
|
|
16
5
|
const GENERIC_CRITERION_PATTERNS = [
|
|
17
6
|
/\bimplementation complete\b/i,
|
|
@@ -115,7 +104,7 @@ export function renderTechnicalReferenceGroundingFrontmatter(records) {
|
|
|
115
104
|
export function checkGroundedSpecContract(spec, content) {
|
|
116
105
|
const frontmatter = FRONTMATTER_RE.exec(content)?.[1] ?? '';
|
|
117
106
|
const required = /^grounding_required:\s*true\s*$/m.test(frontmatter);
|
|
118
|
-
const records = parseCriterionGroundingRecords(frontmatter);
|
|
107
|
+
const records = parseCriterionGroundingRecords(frontmatter).records;
|
|
119
108
|
if (!required) {
|
|
120
109
|
return { passed: true, required: false, issues: [], records };
|
|
121
110
|
}
|
|
@@ -131,7 +120,7 @@ export function checkGroundedSpecContract(spec, content) {
|
|
|
131
120
|
issues.push(`Criterion has no grounding evidence: ${record.text}`);
|
|
132
121
|
}
|
|
133
122
|
}
|
|
134
|
-
const technicalRecords = parseTechnicalReferenceGroundingRecords(frontmatter);
|
|
123
|
+
const technicalRecords = parseTechnicalReferenceGroundingRecords(frontmatter).records;
|
|
135
124
|
for (const record of technicalRecords) {
|
|
136
125
|
if (record.source === 'ungrounded_advisory' || record.source === 'documented_assumption') {
|
|
137
126
|
issues.push(`Technical reference is advisory-only and cannot be contract: ${record.path}`);
|
|
@@ -150,23 +139,28 @@ export function checkGroundedSpecContract(spec, content) {
|
|
|
150
139
|
export function parseCriterionGroundingRecords(frontmatter) {
|
|
151
140
|
const outcome = parseFrontmatterYaml(frontmatter);
|
|
152
141
|
if (!outcome.parsed) {
|
|
153
|
-
return parseCriterionGroundingRecordsLegacy(frontmatter);
|
|
142
|
+
return { records: parseCriterionGroundingRecordsLegacy(frontmatter), diagnostics: [] };
|
|
154
143
|
}
|
|
155
144
|
const grounding = readGroundingSection(outcome.document);
|
|
156
145
|
const entries = Array.isArray(grounding?.criteria) ? grounding.criteria : [];
|
|
157
146
|
const records = [];
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
147
|
+
const diagnostics = [];
|
|
148
|
+
for (const [index, entry] of entries.entries()) {
|
|
149
|
+
const entryOutcome = toCriterionGroundingRecord(entry, index);
|
|
150
|
+
if (entryOutcome.record) {
|
|
151
|
+
records.push(entryOutcome.record);
|
|
162
152
|
}
|
|
153
|
+
diagnostics.push(...entryOutcome.diagnostics);
|
|
163
154
|
}
|
|
164
|
-
return records;
|
|
155
|
+
return { records, diagnostics };
|
|
165
156
|
}
|
|
166
157
|
export function parseTechnicalReferenceGroundingRecords(frontmatter) {
|
|
167
158
|
const outcome = parseFrontmatterYaml(frontmatter);
|
|
168
159
|
if (!outcome.parsed) {
|
|
169
|
-
return
|
|
160
|
+
return {
|
|
161
|
+
records: parseTechnicalReferenceGroundingRecordsLegacy(frontmatter),
|
|
162
|
+
diagnostics: [],
|
|
163
|
+
};
|
|
170
164
|
}
|
|
171
165
|
const grounding = readGroundingSection(outcome.document);
|
|
172
166
|
const entries = grounding
|
|
@@ -177,13 +171,15 @@ export function parseTechnicalReferenceGroundingRecords(frontmatter) {
|
|
|
177
171
|
? outcome.document.technicalReferences
|
|
178
172
|
: [];
|
|
179
173
|
const records = [];
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
const diagnostics = [];
|
|
175
|
+
for (const [index, entry] of entries.entries()) {
|
|
176
|
+
const entryOutcome = toTechnicalReferenceGroundingRecord(entry, index);
|
|
177
|
+
if (entryOutcome.record) {
|
|
178
|
+
records.push(entryOutcome.record);
|
|
184
179
|
}
|
|
180
|
+
diagnostics.push(...entryOutcome.diagnostics);
|
|
185
181
|
}
|
|
186
|
-
return records;
|
|
182
|
+
return { records, diagnostics };
|
|
187
183
|
}
|
|
188
184
|
function parseFrontmatterYaml(frontmatter) {
|
|
189
185
|
let value;
|
|
@@ -199,55 +195,6 @@ function readGroundingSection(document) {
|
|
|
199
195
|
const grounding = document?.grounding;
|
|
200
196
|
return isRecord(grounding) ? grounding : undefined;
|
|
201
197
|
}
|
|
202
|
-
function toCriterionGroundingRecord(entry) {
|
|
203
|
-
if (!isRecord(entry)) {
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
const text = typeof entry.text === 'string' && entry.text.length > 0 ? entry.text : null;
|
|
207
|
-
const source = toGroundingSource(entry.source);
|
|
208
|
-
const confidence = toGroundingConfidence(entry.confidence);
|
|
209
|
-
if (!text || !source || !confidence) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
return { text, source, evidence: toStringArray(entry.evidence), confidence };
|
|
213
|
-
}
|
|
214
|
-
function toTechnicalReferenceGroundingRecord(entry) {
|
|
215
|
-
if (!isRecord(entry)) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
const path = typeof entry.path === 'string' && entry.path.length > 0 ? entry.path : null;
|
|
219
|
-
const section = toTechnicalReferenceSection(entry.section);
|
|
220
|
-
const source = toGroundingSource(entry.source);
|
|
221
|
-
const confidence = toGroundingConfidence(entry.confidence);
|
|
222
|
-
if (!path || !section || !source || !confidence) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
return { path, section, source, evidence: toStringArray(entry.evidence), confidence };
|
|
226
|
-
}
|
|
227
|
-
function toGroundingSource(value) {
|
|
228
|
-
return typeof value === 'string' && GROUNDING_SOURCES.includes(value)
|
|
229
|
-
? value
|
|
230
|
-
: null;
|
|
231
|
-
}
|
|
232
|
-
function toGroundingConfidence(value) {
|
|
233
|
-
return typeof value === 'string' && GROUNDING_CONFIDENCES.includes(value)
|
|
234
|
-
? value
|
|
235
|
-
: null;
|
|
236
|
-
}
|
|
237
|
-
function toTechnicalReferenceSection(value) {
|
|
238
|
-
return typeof value === 'string' &&
|
|
239
|
-
TECHNICAL_REFERENCE_SECTIONS.includes(value)
|
|
240
|
-
? value
|
|
241
|
-
: null;
|
|
242
|
-
}
|
|
243
|
-
function toStringArray(value) {
|
|
244
|
-
return Array.isArray(value)
|
|
245
|
-
? value.filter((item) => typeof item === 'string')
|
|
246
|
-
: [];
|
|
247
|
-
}
|
|
248
|
-
function isRecord(value) {
|
|
249
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
250
|
-
}
|
|
251
198
|
function parseCriterionGroundingRecordsLegacy(frontmatter) {
|
|
252
199
|
const records = [];
|
|
253
200
|
const chunks = frontmatter.split(/\n\s{4}- text:\s*/).slice(1);
|
|
@@ -311,7 +258,7 @@ export function parseGroundedTechnicalPaths(content) {
|
|
|
311
258
|
const frontmatter = FRONTMATTER_RE.exec(content)?.[1] ?? '';
|
|
312
259
|
return [
|
|
313
260
|
...new Set([
|
|
314
|
-
...parseTechnicalReferenceGroundingRecords(frontmatter).map((record) => record.path),
|
|
261
|
+
...parseTechnicalReferenceGroundingRecords(frontmatter).records.map((record) => record.path),
|
|
315
262
|
...parseApprovedFileLevelWorkPlanPaths(content),
|
|
316
263
|
]),
|
|
317
264
|
];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CriterionGroundingRecord, GroundingEntryOutcome, TechnicalReferenceGroundingRecord } from '../../types/spec-grounding.js';
|
|
2
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
|
+
export declare function toCriterionGroundingRecord(entry: unknown, index: number): GroundingEntryOutcome<CriterionGroundingRecord>;
|
|
4
|
+
export declare function toTechnicalReferenceGroundingRecord(entry: unknown, index: number): GroundingEntryOutcome<TechnicalReferenceGroundingRecord>;
|
|
5
|
+
//# sourceMappingURL=grounding-entry-parser.d.ts.map
|