@planu/cli 5.7.12 → 5.7.14

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/doctor.d.ts +2 -1
  4. package/dist/cli/commands/doctor.js +51 -1
  5. package/dist/cli/commands/install.js +14 -0
  6. package/dist/config/negative-predicate-phrases.json +33 -0
  7. package/dist/config/registries/strict-audit-scripts.json +4 -0
  8. package/dist/engine/doctor/npm-cache-check.d.ts +10 -0
  9. package/dist/engine/doctor/npm-cache-check.js +109 -0
  10. package/dist/engine/ears-gate.d.ts +1 -0
  11. package/dist/engine/ears-gate.js +64 -2
  12. package/dist/engine/framework-detector.d.ts +1 -0
  13. package/dist/engine/framework-detector.js +1 -1
  14. package/dist/engine/handoff-artifacts/schemas.d.ts +2 -0
  15. package/dist/engine/handoff-artifacts/schemas.js +1 -1
  16. package/dist/engine/spec-format/bdd-parser.d.ts +2 -0
  17. package/dist/engine/spec-format/bdd-parser.js +70 -4
  18. package/dist/engine/spec-grounding/contract.js +3 -1
  19. package/dist/engine/spec-grounding/grounding-entry-parser.js +1 -0
  20. package/dist/engine/validator/analyzer.d.ts +0 -9
  21. package/dist/engine/validator/analyzer.js +33 -9
  22. package/dist/engine/validator/blast-radius-gate.js +181 -10
  23. package/dist/engine/validator/deep-code-checker.js +2 -5
  24. package/dist/engine/validator/negative-predicate.d.ts +18 -0
  25. package/dist/engine/validator/negative-predicate.js +240 -0
  26. package/dist/engine/validator/spec-compliance-runner.d.ts +1 -0
  27. package/dist/engine/validator/spec-compliance-runner.js +91 -26
  28. package/dist/engine/validator/strict-audits-gate.d.ts +3 -0
  29. package/dist/engine/validator/strict-audits-gate.js +74 -0
  30. package/dist/engine/validator/validation-report-writer.js +4 -2
  31. package/dist/storage/runtime-db.d.ts +1 -1
  32. package/dist/storage/runtime-db.js +15 -2
  33. package/dist/tools/challenge-spec/scenarios-data.js +4 -3
  34. package/dist/tools/challenge-spec/scenarios-utils.d.ts +1 -2
  35. package/dist/tools/challenge-spec/scenarios-utils.js +13 -2
  36. package/dist/tools/create-spec.js +10 -0
  37. package/dist/tools/jobs/handlers.d.ts +2 -1
  38. package/dist/tools/jobs/handlers.js +17 -3
  39. package/dist/tools/register-spec-tools/core-spec-tools.js +5 -0
  40. package/dist/tools/tool-registry/core-tools.js +28 -2
  41. package/dist/tools/update-status/batch.js +1 -0
  42. package/dist/tools/update-status/evidence-gate.js +13 -1
  43. package/dist/tools/update-status/file-sync.d.ts +1 -1
  44. package/dist/tools/update-status/file-sync.js +4 -2
  45. package/dist/tools/update-status/index.js +4 -1
  46. package/dist/tools/update-status/transition-guard.d.ts +0 -1
  47. package/dist/tools/update-status/transition-guard.js +42 -14
  48. package/dist/tools/validate.js +79 -2
  49. package/dist/types/analysis.d.ts +20 -0
  50. package/dist/types/errors/structured-error.d.ts +1 -1
  51. package/dist/types/handoff-artifacts.d.ts +1 -1
  52. package/dist/types/installation.d.ts +10 -0
  53. package/dist/types/plugin-configs.d.ts +4 -0
  54. package/dist/types/spec/inputs.d.ts +14 -0
  55. package/dist/types/spec-format.d.ts +1 -0
  56. package/dist/types/spec-grounding.d.ts +1 -1
  57. package/dist/types/validation-evidence.d.ts +32 -1
  58. package/package.json +2 -1
  59. package/planu-plugin.json +1 -1
  60. package/src/i18n/messages/en.json +1 -1
  61. package/src/i18n/messages/es.json +1 -1
  62. package/src/i18n/messages/pt.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## [5.7.14] - 2026-09-03
2
+
3
+ ### Features
4
+ - feat(validator): credit negative and deletion criteria via fail-closed absence scan (SPEC-1579)
5
+ - feat(gates): carry executable next actions and external blockage state (SPEC-1691)
6
+ - feat(jobs): accept projectPath in get_job and restart_job (SPEC-1392)
7
+
8
+ ### Bug Fixes
9
+ - fix(types): import ToolResult from primitives to break the structured-error barrel cycle (SPEC-1691)
10
+ - fix(validate): rebuild stale dist once before the blast-radius importer run (SPEC-1781)
11
+ - fix(gates): prefer projectPath by undefined check and drop comments (SPEC-1691)
12
+ - fix(bdd-parser): tolerate list markers and split single-line GWT criteria (SPEC-1720)
13
+
14
+ ### Refactoring
15
+ - refactor(gates): move GateUnavailableIdentity to types and compact blocked text (SPEC-1691)
16
+
17
+
18
+ ## [5.7.13] - 2026-09-03
19
+
20
+ ### Features
21
+ - feat(cli): diagnose root-owned npm cache in doctor and install (SPEC-1733)
22
+
23
+ ### Bug Fixes
24
+ - fix(spec-grounding): accept review_evidence as contract grounding source
25
+ - fix(validator): return indeterminate verdicts when vitest runner fails (SPEC-1734)
26
+ - fix(challenge): exclude package-manager cache clauses from stale-cache scenario (SPEC-1778)
27
+ - fix(validate): run strict audit scripts as a validate gate (SPEC-1775)
28
+ - fix(update-status): allow done to discarded with an audited reason (SPEC-1708)
29
+ - fix(update-status): forward reason through update_status_batch (SPEC-1728)
30
+ - fix(validate): run integration importers in the blast-radius gate (SPEC-1777)
31
+ - fix(ears): mask quoted literals before the vague-verb scan (SPEC-1632)
32
+
33
+
1
34
  ## [5.7.12] - 2026-09-03
2
35
 
3
36
  ### Features
@@ -1 +1 @@
1
- {"schemaVersion":1,"commit":"088e6b8cc7a4e82395e945609d0c575d31895578"}
1
+ {"schemaVersion":1,"commit":"d670004fb49b403f699139c7c2781e651ed0d04a"}
@@ -27,8 +27,9 @@ declare function checkRuntimeDatabase(): DeepCheckResult;
27
27
  declare function checkLocaleResolution(): DeepCheckResult;
28
28
  /** Check (5): every package-owned runtime helper compiled CLI code imports is present. */
29
29
  declare function checkInstallationIntegrity(): DeepCheckResult;
30
+ declare function checkNpmCache(): DeepCheckResult;
30
31
  declare function runDeepChecks(): DeepCheckResult[];
31
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
32
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
32
33
  export { checkTool };
33
34
  export declare const doctorCommand: CliCommand;
34
35
  //# sourceMappingURL=doctor.d.ts.map
@@ -10,6 +10,7 @@ import { readJsonFile, hasPlanuEntry } from './install.js';
10
10
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
11
11
  import { RuntimeDatabase } from '../../storage/runtime-db.js';
12
12
  import { getLocale, t } from '../../i18n/index.js';
13
+ import { MAX_FOREIGN_ENTRIES, MAX_SCANNED_ENTRIES, currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
13
14
  // ---------------------------------------------------------------------------
14
15
  // Constants
15
16
  // ---------------------------------------------------------------------------
@@ -251,6 +252,54 @@ function checkInstallationIntegrity() {
251
252
  detail: `INCOMPLETE_INSTALLATION: ${packageName}@${version} is missing ${missing.join(', ')}. Reinstall with: npm install -g ${packageName}@${version}`,
252
253
  };
253
254
  }
255
+ function checkNpmCache() {
256
+ const uid = currentUid();
257
+ if (uid === null) {
258
+ return {
259
+ name: 'npm cache',
260
+ status: 'ok',
261
+ detail: 'Ownership check does not apply on this platform.',
262
+ };
263
+ }
264
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
265
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
266
+ if (finding.status === 'ok') {
267
+ if (!finding.truncated) {
268
+ return {
269
+ name: 'npm cache',
270
+ status: 'ok',
271
+ detail: `Checked ${String(finding.scanned)} entries under ${finding.cacheDir}; all owned by the current user.`,
272
+ };
273
+ }
274
+ return {
275
+ name: 'npm cache',
276
+ status: 'ok',
277
+ detail: `Checked the first ${String(MAX_SCANNED_ENTRIES)} entries under ${finding.cacheDir}; all owned by the current user.`,
278
+ };
279
+ }
280
+ if (finding.status === 'unreadable') {
281
+ return {
282
+ name: 'npm cache',
283
+ status: 'warn',
284
+ detail: `Cannot read ${finding.cacheDir}. Check permissions, then run: ${finding.fix}`,
285
+ };
286
+ }
287
+ const noun = finding.foreignCount === 1 ? 'entry' : 'entries';
288
+ const limits = [];
289
+ if (finding.foreignCount >= MAX_FOREIGN_ENTRIES) {
290
+ limits.push(`count capped at ${String(MAX_FOREIGN_ENTRIES)}`);
291
+ }
292
+ if (finding.truncated) {
293
+ limits.push(`scan stopped at ${String(MAX_SCANNED_ENTRIES)} entries`);
294
+ }
295
+ const suffix = limits.length > 0 ? ` (${limits.join('; ')})` : '';
296
+ return {
297
+ name: 'npm cache',
298
+ status: 'fail',
299
+ detail: `npm cache contains ${String(finding.foreignCount)} ${noun} not owned by the current user${suffix}` +
300
+ ` — npx cannot write to it and the MCP server fails to start. Run: ${finding.fix}`,
301
+ };
302
+ }
254
303
  function runDeepChecks() {
255
304
  return [
256
305
  checkNodeVersion(),
@@ -258,6 +307,7 @@ function runDeepChecks() {
258
307
  checkRuntimeDatabase(),
259
308
  checkLocaleResolution(),
260
309
  checkInstallationIntegrity(),
310
+ checkNpmCache(),
261
311
  ];
262
312
  }
263
313
  function deepCheckIcon(status) {
@@ -282,7 +332,7 @@ function printDeepChecks(results) {
282
332
  }
283
333
  }
284
334
  // Exported for tests
285
- export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, runDeepChecks, };
335
+ export { checkNodeVersion, checkDataDirWritable, checkRuntimeDatabase, checkLocaleResolution, checkInstallationIntegrity, checkNpmCache, runDeepChecks, };
286
336
  function statusIcon(status) {
287
337
  switch (status) {
288
338
  case 'ok':
@@ -8,6 +8,7 @@ import { planuVersion } from '../../config/version.js';
8
8
  import { confirm, select } from '../interactive.js';
9
9
  import { resolveStorageLayout } from '../../storage/storage-layout.js';
10
10
  import { removeCommercialState } from '../../engine/migrations/remove-commercial-state.js';
11
+ import { currentUid, resolveNpmCacheDir, checkNpmCacheOwnership, } from '../../engine/doctor/npm-cache-check.js';
11
12
  // ---------------------------------------------------------------------------
12
13
  // Constants
13
14
  // ---------------------------------------------------------------------------
@@ -299,6 +300,18 @@ function printDetectionResults(detected, notFound) {
299
300
  process.stdout.write(` ${dim('-')} ${tool.name} ${dim('(not found)')}\n`);
300
301
  }
301
302
  }
303
+ function printNpmCacheWarning() {
304
+ const uid = currentUid();
305
+ if (uid === null) {
306
+ return;
307
+ }
308
+ const cacheDir = resolveNpmCacheDir(process.env, homedir());
309
+ const finding = checkNpmCacheOwnership(cacheDir, uid);
310
+ if (finding.status !== 'foreign-owned') {
311
+ return;
312
+ }
313
+ process.stdout.write(`${yellow('⚠ npm cache has files owned by another user.')} Run: ${finding.fix}\n\n`);
314
+ }
302
315
  async function resolveScope(scopeArg) {
303
316
  if (scopeArg === 'user' || scopeArg === 'project') {
304
317
  return scopeArg;
@@ -417,6 +430,7 @@ export const installCommand = {
417
430
  }
418
431
  printDetectionResults(detected, notFound);
419
432
  process.stdout.write('\n');
433
+ printNpmCacheWarning();
420
434
  if (detected.length === 0) {
421
435
  const docsUrl = claudeCodeDocsUrl();
422
436
  process.stdout.write(`${yellow('⚠ No AI tools detected on this machine.')}\n\n` +
@@ -0,0 +1,33 @@
1
+ [
2
+ {
3
+ "id": "deletion",
4
+ "phrases": [
5
+ "no longer exist",
6
+ "does not exist",
7
+ "do not exist",
8
+ "must not exist",
9
+ "is removed",
10
+ "are removed",
11
+ "has been removed",
12
+ "have been removed",
13
+ "is deleted",
14
+ "are deleted"
15
+ ]
16
+ },
17
+ {
18
+ "id": "import-absence",
19
+ "phrases": [
20
+ "nothing imports",
21
+ "no longer imports",
22
+ "must not import",
23
+ "does not import",
24
+ "no references to",
25
+ "no remaining references",
26
+ "with no"
27
+ ]
28
+ },
29
+ {
30
+ "id": "literal-absence",
31
+ "phrases": ["no hardcoded", "no literal", "no magic", "no raw", "remove all"]
32
+ }
33
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "scripts": ["audit:hardcodes", "check:public-privacy", "check:environment-schema", "audit:i18n"]
4
+ }
@@ -0,0 +1,10 @@
1
+ import type { NpmCacheFinding } from '../../types/index.js';
2
+ export declare const CACACHE_DIR = "_cacache";
3
+ export declare const NPM_CACHE_SUBDIRS: readonly ['content-v2', 'index-v5'];
4
+ export declare const MAX_FOREIGN_ENTRIES = 50;
5
+ export declare const MAX_SCANNED_ENTRIES = 2000;
6
+ export declare const MAX_SAMPLE_ENTRIES = 5;
7
+ export declare function currentUid(): number | null;
8
+ export declare function resolveNpmCacheDir(env: NodeJS.ProcessEnv, home: string): string;
9
+ export declare function checkNpmCacheOwnership(cacheDir: string, uid: number): NpmCacheFinding;
10
+ //# sourceMappingURL=npm-cache-check.d.ts.map
@@ -0,0 +1,109 @@
1
+ import { existsSync, readdirSync, lstatSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ export const CACACHE_DIR = '_cacache';
4
+ export const NPM_CACHE_SUBDIRS = ['content-v2', 'index-v5'];
5
+ export const MAX_FOREIGN_ENTRIES = 50;
6
+ export const MAX_SCANNED_ENTRIES = 2000;
7
+ export const MAX_SAMPLE_ENTRIES = 5;
8
+ export function currentUid() {
9
+ return process.getuid?.() ?? null;
10
+ }
11
+ export function resolveNpmCacheDir(env, home) {
12
+ const configured = env.npm_config_cache;
13
+ if (configured !== undefined && configured.trim() !== '') {
14
+ return configured;
15
+ }
16
+ return join(home, '.npm');
17
+ }
18
+ function readDirEntries(dir) {
19
+ try {
20
+ return readdirSync(dir, { withFileTypes: true });
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ function statEntry(entryPath) {
27
+ try {
28
+ return lstatSync(entryPath);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ export function checkNpmCacheOwnership(cacheDir, uid) {
35
+ const fix = `sudo chown -R $USER ${cacheDir}`;
36
+ const emptyFinding = (status) => ({
37
+ status,
38
+ cacheDir,
39
+ foreignCount: 0,
40
+ scanned: 0,
41
+ truncated: false,
42
+ sampleEntries: [],
43
+ fix,
44
+ });
45
+ if (!existsSync(cacheDir)) {
46
+ return emptyFinding('ok');
47
+ }
48
+ if (readDirEntries(cacheDir) === null) {
49
+ return emptyFinding('unreadable');
50
+ }
51
+ const cacache = join(cacheDir, CACACHE_DIR);
52
+ if (!existsSync(cacache)) {
53
+ return emptyFinding('ok');
54
+ }
55
+ let foreignCount = 0;
56
+ let scanned = 0;
57
+ let truncated = false;
58
+ const sampleEntries = [];
59
+ const walkDir = (dir) => {
60
+ const entries = readDirEntries(dir);
61
+ if (entries === null) {
62
+ return false;
63
+ }
64
+ for (const entry of entries) {
65
+ if (scanned >= MAX_SCANNED_ENTRIES) {
66
+ truncated = true;
67
+ return true;
68
+ }
69
+ scanned += 1;
70
+ const entryPath = join(dir, entry.name);
71
+ const st = statEntry(entryPath);
72
+ if (st === null) {
73
+ continue;
74
+ }
75
+ if (st.uid !== uid) {
76
+ foreignCount += 1;
77
+ if (sampleEntries.length < MAX_SAMPLE_ENTRIES) {
78
+ sampleEntries.push(relative(cacheDir, entryPath));
79
+ }
80
+ if (foreignCount >= MAX_FOREIGN_ENTRIES) {
81
+ return true;
82
+ }
83
+ }
84
+ if (st.isDirectory() && walkDir(entryPath)) {
85
+ return true;
86
+ }
87
+ }
88
+ return false;
89
+ };
90
+ for (const name of NPM_CACHE_SUBDIRS) {
91
+ const root = join(cacache, name);
92
+ if (!existsSync(root)) {
93
+ continue;
94
+ }
95
+ if (walkDir(root)) {
96
+ break;
97
+ }
98
+ }
99
+ return {
100
+ status: foreignCount > 0 ? 'foreign-owned' : 'ok',
101
+ cacheDir,
102
+ foreignCount,
103
+ scanned,
104
+ truncated,
105
+ sampleEntries,
106
+ fix,
107
+ };
108
+ }
109
+ //# sourceMappingURL=npm-cache-check.js.map
@@ -9,6 +9,7 @@ export interface CopulaViolation {
9
9
  * Returns a CopulaViolation if found, or null if the text is clean.
10
10
  */
11
11
  export declare function checkCopulaViolation(scenarioText: string): CopulaViolation | null;
12
+ export declare function maskQuotedSpans(text: string): string;
12
13
  /**
13
14
  * SPEC-631: Scan acceptance criteria lines for vague modal verbs.
14
15
  * Returns formatted blocker strings (one per violation) with original line and GWT rewrite.
@@ -26,8 +26,70 @@ export function checkCopulaViolation(scenarioText) {
26
26
  function stripLeadingBullet(line) {
27
27
  return line.replace(/^-\s*(\[[ x]\]\s*)?/i, '').trim();
28
28
  }
29
+ const QUOTE_MASK_CHAR = '#';
30
+ const QUOTE_DELIMITERS = ["'", '"', '`'];
31
+ const WORD_CHARACTER = /[A-Za-z0-9]/;
32
+ function isSingleQuoteOpener(text, index) {
33
+ return index === 0 || !WORD_CHARACTER.test(text.charAt(index - 1));
34
+ }
35
+ function findClosingQuote(text, delimiter, openIndex) {
36
+ let cursor = openIndex + 1;
37
+ while (cursor < text.length) {
38
+ const candidate = text.indexOf(delimiter, cursor);
39
+ if (candidate === -1) {
40
+ return -1;
41
+ }
42
+ if (delimiter === "'" && WORD_CHARACTER.test(text.charAt(candidate + 1))) {
43
+ cursor = candidate + 1;
44
+ continue;
45
+ }
46
+ return candidate;
47
+ }
48
+ return -1;
49
+ }
50
+ export function maskQuotedSpans(text) {
51
+ let result = '';
52
+ let index = 0;
53
+ while (index < text.length) {
54
+ const char = text.charAt(index);
55
+ if (!QUOTE_DELIMITERS.includes(char)) {
56
+ result += char;
57
+ index += 1;
58
+ continue;
59
+ }
60
+ if (char === "'" && !isSingleQuoteOpener(text, index)) {
61
+ result += char;
62
+ index += 1;
63
+ continue;
64
+ }
65
+ const closeIndex = findClosingQuote(text, char, index);
66
+ if (closeIndex === -1) {
67
+ result += text.slice(index);
68
+ break;
69
+ }
70
+ const span = text.slice(index, closeIndex + 1);
71
+ result += span.replace(/\S/g, QUOTE_MASK_CHAR);
72
+ index = closeIndex + 1;
73
+ }
74
+ return result;
75
+ }
76
+ function stripVerbOutsideQuotes(text, verb) {
77
+ const masked = maskQuotedSpans(text);
78
+ const ranges = [];
79
+ for (const match of masked.matchAll(new RegExp(`\\b${verb}\\b\\s*`, 'gi'))) {
80
+ ranges.push([match.index, match.index + match[0].length]);
81
+ }
82
+ let result = '';
83
+ let cursor = 0;
84
+ for (const [start, end] of ranges) {
85
+ result += text.slice(cursor, start);
86
+ cursor = end;
87
+ }
88
+ result += text.slice(cursor);
89
+ return result.trim();
90
+ }
29
91
  function rewriteToGwt(text, vagueWord) {
30
- const withoutModal = text.replace(new RegExp(`\\b${vagueWord}\\s*`, 'gi'), '').trim();
92
+ const withoutModal = stripVerbOutsideQuotes(text, vagueWord);
31
93
  return `GIVEN <precondition> WHEN <trigger> THEN ${withoutModal}`;
32
94
  }
33
95
  /**
@@ -41,7 +103,7 @@ export function runEarsGate(criteriaLines) {
41
103
  if (line === 'bdd-scenario') {
42
104
  continue;
43
105
  }
44
- const lower = line.toLowerCase();
106
+ const lower = maskQuotedSpans(line).toLowerCase();
45
107
  const found = EARS_VAGUE_VERBS.filter((verb) => new RegExp(`\\b${verb}\\b`).test(lower));
46
108
  if (found.length === 0) {
47
109
  continue;
@@ -31,4 +31,5 @@ export declare function detectTestCommand(projectPath: string, packageManager: s
31
31
  * Detect lint command from project config files.
32
32
  */
33
33
  export declare function detectLintCommand(projectPath: string, packageManager: string | null): Promise<string | null>;
34
+ export declare function pmRunner(packageManager: string | null): string;
34
35
  //# sourceMappingURL=framework-detector.d.ts.map
@@ -253,7 +253,7 @@ export async function detectLintCommand(projectPath, packageManager) {
253
253
  }
254
254
  return null;
255
255
  }
256
- function pmRunner(packageManager) {
256
+ export function pmRunner(packageManager) {
257
257
  if (packageManager === 'pnpm') {
258
258
  return 'pnpm';
259
259
  }
@@ -116,6 +116,7 @@ export declare const ValidationReportV1Schema: z.ZodObject<{
116
116
  title: z.ZodString;
117
117
  verdict: z.ZodEnum<{
118
118
  fail: "fail";
119
+ indeterminate: "indeterminate";
119
120
  missing: "missing";
120
121
  pass: "pass";
121
122
  }>;
@@ -284,6 +285,7 @@ export declare const ARTIFACT_SCHEMAS: {
284
285
  title: z.ZodString;
285
286
  verdict: z.ZodEnum<{
286
287
  fail: "fail";
288
+ indeterminate: "indeterminate";
287
289
  missing: "missing";
288
290
  pass: "pass";
289
291
  }>;
@@ -88,7 +88,7 @@ export const ValidationReportV1Schema = z.object({
88
88
  command: z.string(),
89
89
  scenarios: z.array(z.object({
90
90
  title: z.string(),
91
- verdict: z.enum(['pass', 'fail', 'missing']),
91
+ verdict: z.enum(['pass', 'fail', 'missing', 'indeterminate']),
92
92
  evidence: z.array(z.string()),
93
93
  unverifiable: z.literal(true).optional(),
94
94
  })),
@@ -20,5 +20,7 @@ export declare function renderBddScenariosYaml(scenarios: BddScenario[]): string
20
20
  * Plain text criteria get a generic GIVEN (system context) and WHEN (action trigger)
21
21
  * so scenarios are always structurally valid BDD.
22
22
  */
23
+ export declare const PLACEHOLDER_GIVEN_STEP_TEXT = "the system is in its default state";
24
+ export declare const PLACEHOLDER_WHEN_STEP_TEXT = "the described behavior is triggered";
23
25
  export declare function convertCheckboxToBdd(criteria: LeanCriterion[]): BddScenario[];
24
26
  //# sourceMappingURL=bdd-parser.d.ts.map
@@ -1,12 +1,17 @@
1
1
  // engine/spec-format/bdd-parser.ts — BDD/Gherkin parser and emitter (SPEC-481)
2
2
  import { consumePathRunPreservingCase } from './technical-md-populator.js';
3
3
  const TEST_MARKER_RE = /\bTESTS?\s*:/gi;
4
+ const MARKER_BOUNDARY_RE = /\b(?:FILES?|FUNCTIONS?|OWNER|TESTS?)\s*:/i;
5
+ const PATH_SHAPED_TOKEN_RE = /(?:[\w.@-]+\/)+[\w.-]+\.[a-zA-Z0-9]+/g;
4
6
  export function extractInlineTestPaths(text) {
5
7
  const paths = [];
6
8
  const seen = new Set();
7
9
  for (const marker of text.matchAll(TEST_MARKER_RE)) {
8
10
  const start = marker.index + marker[0].length;
9
- for (const path of consumePathRunPreservingCase(text.slice(start))) {
11
+ const segment = text.slice(start).split(MARKER_BOUNDARY_RE)[0] ?? '';
12
+ const run = consumePathRunPreservingCase(segment);
13
+ const found = run.length > 0 ? run : (segment.match(PATH_SHAPED_TOKEN_RE) ?? []);
14
+ for (const path of found) {
10
15
  if (!seen.has(path)) {
11
16
  seen.add(path);
12
17
  paths.push(path);
@@ -50,6 +55,58 @@ function opensHeaderlessScenario(rawKeyword, text, rawLine) {
50
55
  function suffixedTitle(thenText, steps) {
51
56
  return `${thenText} (given ${steps.find((step) => step.keyword === 'given')?.text ?? ''})`;
52
57
  }
58
+ const LIST_MARKER_RE = /^(?:[-*+>]\s+|\d+[.)]\s+)/;
59
+ const MARKER_TAIL_RE = /\s*\b(?:FILES?|FUNCTIONS?|TESTS?|OWNER)\s*:[\s\S]*$/i;
60
+ const CODE_SPAN_RE = /`[^`]*`/g;
61
+ function stripMarkerTail(text) {
62
+ return text.replace(MARKER_TAIL_RE, '').trim();
63
+ }
64
+ function maskCodeSpans(text) {
65
+ return text.replace(CODE_SPAN_RE, (span) => ' '.repeat(span.length));
66
+ }
67
+ function splitSingleLineGwt(line) {
68
+ const masked = maskCodeSpans(line);
69
+ const given = /^GIVEN\b/.exec(masked);
70
+ if (given === null) {
71
+ return null;
72
+ }
73
+ const when = /\bWHEN\b/.exec(masked.slice(given.index));
74
+ if (when === null) {
75
+ return null;
76
+ }
77
+ const whenIndex = given.index + when.index;
78
+ const then = /\bTHEN\b/.exec(masked.slice(whenIndex));
79
+ if (then === null) {
80
+ return null;
81
+ }
82
+ const thenIndex = whenIndex + then.index;
83
+ const givenText = line.slice(given.index + 'GIVEN'.length, whenIndex).trim();
84
+ const whenText = line.slice(whenIndex + 'WHEN'.length, thenIndex).trim();
85
+ const thenText = line.slice(thenIndex + 'THEN'.length).trim();
86
+ if (givenText === '' || whenText === '' || thenText === '') {
87
+ return null;
88
+ }
89
+ return [
90
+ { keyword: 'given', text: givenText },
91
+ { keyword: 'when', text: whenText },
92
+ { keyword: 'then', text: stripMarkerTail(thenText) },
93
+ ];
94
+ }
95
+ function buildSingleLineScenario(line, closedTitles) {
96
+ const singleLineSteps = splitSingleLineGwt(line);
97
+ if (singleLineSteps === null) {
98
+ return null;
99
+ }
100
+ const thenText = singleLineSteps[singleLineSteps.length - 1]?.text ?? '';
101
+ const title = closedTitles.has(thenText) ? suffixedTitle(thenText, singleLineSteps) : thenText;
102
+ const tests = extractInlineTestPaths(line).map((path) => ({ path }));
103
+ return {
104
+ title,
105
+ steps: singleLineSteps,
106
+ done: false,
107
+ ...(tests.length > 0 ? { tests } : {}),
108
+ };
109
+ }
53
110
  export function parseBddScenarios(markdown) {
54
111
  const scenarios = [];
55
112
  const lines = markdown.split('\n');
@@ -65,7 +122,7 @@ export function parseBddScenarios(markdown) {
65
122
  currentIsHeaderless = false;
66
123
  };
67
124
  for (const raw of lines) {
68
- const line = raw.trim();
125
+ const line = raw.trim().replace(LIST_MARKER_RE, '');
69
126
  // Detect scenario header
70
127
  const scenarioMatch = /^(?:#{1,6}\s*)?scenario(?:\s+\d+)?:\s*(.+)$/i.exec(line);
71
128
  if (scenarioMatch) {
@@ -73,6 +130,13 @@ export function parseBddScenarios(markdown) {
73
130
  current = { title: (scenarioMatch[1] ?? '').trim(), steps: [], done: false };
74
131
  continue;
75
132
  }
133
+ const singleLineScenario = buildSingleLineScenario(line, closedTitles);
134
+ if (singleLineScenario !== null) {
135
+ closeCurrent();
136
+ current = singleLineScenario;
137
+ closeCurrent();
138
+ continue;
139
+ }
76
140
  // Detect step keywords
77
141
  const stepMatch = /^(given|when|then|and|but)\s+(.+)$/i.exec(line);
78
142
  if (!stepMatch) {
@@ -141,12 +205,14 @@ export function renderBddScenariosYaml(scenarios) {
141
205
  * Plain text criteria get a generic GIVEN (system context) and WHEN (action trigger)
142
206
  * so scenarios are always structurally valid BDD.
143
207
  */
208
+ export const PLACEHOLDER_GIVEN_STEP_TEXT = 'the system is in its default state';
209
+ export const PLACEHOLDER_WHEN_STEP_TEXT = 'the described behavior is triggered';
144
210
  export function convertCheckboxToBdd(criteria) {
145
211
  return criteria.map((criterion) => ({
146
212
  title: criterion.text,
147
213
  steps: [
148
- { keyword: 'given', text: 'the system is in its default state' },
149
- { keyword: 'when', text: 'the described behavior is triggered' },
214
+ { keyword: 'given', text: PLACEHOLDER_GIVEN_STEP_TEXT },
215
+ { keyword: 'when', text: PLACEHOLDER_WHEN_STEP_TEXT },
150
216
  { keyword: 'then', text: criterion.text },
151
217
  ],
152
218
  done: criterion.done,
@@ -65,7 +65,9 @@ export function buildCriterionGroundingRecords(args) {
65
65
  });
66
66
  }
67
67
  export function getContractCriteria(records) {
68
- return records.filter((record) => record.source === 'user_input' || record.source === 'project_evidence');
68
+ return records.filter((record) => record.source === 'user_input' ||
69
+ record.source === 'project_evidence' ||
70
+ record.source === 'review_evidence');
69
71
  }
70
72
  export function getAdvisoryCriteria(records) {
71
73
  return records.filter((record) => record.source === 'documented_assumption' || record.source === 'ungrounded_advisory');
@@ -1,6 +1,7 @@
1
1
  const GROUNDING_SOURCES = [
2
2
  'user_input',
3
3
  'project_evidence',
4
+ 'review_evidence',
4
5
  'documented_assumption',
5
6
  'ungrounded_advisory',
6
7
  ];
@@ -3,15 +3,6 @@ import type { Spec, AuditFinding, CodeState, VerifyBlock, CriterionEvidenceResul
3
3
  * Scan the project directory to build a CodeState for the given spec.
4
4
  */
5
5
  export declare function scanCodeForSpec(spec: Spec, projectPath: string): Promise<CodeState>;
6
- /**
7
- * Check whether a single criterion is satisfied in the given code state.
8
- * When `verifyBlock` is provided it is forwarded to deepCheckCriterion,
9
- * bypassing keyword-based classification (explicit beats inferred).
10
- *
11
- * Pass `sharedFileContents` (pre-built via buildBroadCache or
12
- * buildFileContentsCache from criterion-matcher) to avoid a redundant
13
- * glob+readFile pass when checking multiple criteria in the same call.
14
- */
15
6
  export declare function checkCriterionEvidence(criterion: string, projectPath: string, codeState: CodeState, verifyBlock?: VerifyBlock, sharedFileContents?: Map<string, string>, declaredTestPaths?: string[], probeCache?: Map<string, {
16
7
  passed: boolean;
17
8
  evidence: string;