@planu/cli 5.3.63 → 5.3.65

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 (52) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/create.js +3 -16
  4. package/dist/cli/commands/dashboard.js +2 -16
  5. package/dist/cli/commands/init.js +2 -16
  6. package/dist/cli/commands/spec.js +5 -36
  7. package/dist/cli/commands/status.js +5 -28
  8. package/dist/cli/formatter.d.ts +7 -1
  9. package/dist/cli/formatter.js +49 -6
  10. package/dist/engine/cascade-hooks/hooks/implementing-kickoff.hook.js +38 -6
  11. package/dist/engine/dor-dod/index.d.ts +1 -1
  12. package/dist/engine/dor-dod/index.js +1 -1
  13. package/dist/engine/dor-dod/plan.d.ts +1 -0
  14. package/dist/engine/dor-dod/plan.js +2 -0
  15. package/dist/engine/evidence-gates/artifact-reader.js +1 -0
  16. package/dist/engine/evidence-gates/evidence-skeletons.js +1 -0
  17. package/dist/engine/execution-plan/plan-utils.d.ts +2 -6
  18. package/dist/engine/execution-plan/plan-utils.js +71 -37
  19. package/dist/engine/handoff-artifacts/implementation-review-reader.d.ts +4 -0
  20. package/dist/engine/handoff-artifacts/implementation-review-reader.js +72 -0
  21. package/dist/engine/validator/dor-dod.d.ts +2 -2
  22. package/dist/engine/validator/dor-dod.js +5 -4
  23. package/dist/storage/knowledge-store/knowledge.js +31 -1
  24. package/dist/tools/challenge-spec/agent-challenge-scenarios.js +30 -9
  25. package/dist/tools/challenge-spec/resilience-challenge-scenarios-a.d.ts +2 -4
  26. package/dist/tools/challenge-spec/resilience-challenge-scenarios-a.js +24 -24
  27. package/dist/tools/challenge-spec/resilience-challenge-scenarios.js +1 -1
  28. package/dist/tools/challenge-spec/scenarios-failure.js +1 -2
  29. package/dist/tools/challenge-spec/scenarios-utils.d.ts +3 -0
  30. package/dist/tools/challenge-spec/scenarios-utils.js +16 -0
  31. package/dist/tools/challenge-spec-helpers.d.ts +1 -1
  32. package/dist/tools/challenge-spec-helpers.js +5 -2
  33. package/dist/tools/challenge-spec.js +5 -2
  34. package/dist/tools/create-spec.js +18 -0
  35. package/dist/tools/generate-execution-plan.js +160 -54
  36. package/dist/tools/update-status/dod-gates.js +46 -64
  37. package/dist/tools/update-status/side-effects.d.ts +4 -0
  38. package/dist/tools/update-status/side-effects.js +45 -4
  39. package/dist/tools/validate.js +8 -4
  40. package/dist/transports/transport-factory.js +13 -0
  41. package/dist/types/cli.d.ts +3 -0
  42. package/dist/types/evidence-gates.d.ts +2 -0
  43. package/dist/types/execution.d.ts +5 -0
  44. package/dist/types/handoff-artifacts.d.ts +19 -0
  45. package/dist/types/index.d.ts +1 -0
  46. package/package.json +1 -1
  47. package/planu-plugin.json +1 -1
  48. package/scripts/lib/portable-paths.mjs +1 -0
  49. package/dist/engine/execution-plan/phases-b.d.ts +0 -4
  50. package/dist/engine/execution-plan/phases-b.js +0 -88
  51. package/dist/engine/execution-plan/phases.d.ts +0 -7
  52. package/dist/engine/execution-plan/phases.js +0 -216
@@ -0,0 +1,72 @@
1
+ import { reportClassifiedDegradation } from '../../errors/classified-degradation.js';
2
+ import { readTransitionLog } from '../../storage/transition-log.js';
3
+ import { readArtifact } from './io.js';
4
+ export function isLifecycleStubBody(specId, body) {
5
+ return (body === `Spec ${specId} reviewed by planu-spec-reviewer and approved for approval gates.` ||
6
+ body === `Spec ${specId} reviewed by planu-spec-reviewer with requested changes.`);
7
+ }
8
+ async function findImplementingActor(specId, projectId) {
9
+ const entries = await readTransitionLog(projectId, specId);
10
+ for (let i = entries.length - 1; i >= 0; i--) {
11
+ const entry = entries[i];
12
+ if (entry?.to === 'implementing' && entry.actor) {
13
+ return entry.actor;
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ export async function readVerifiedImplementationReview(projectId, specId) {
19
+ try {
20
+ const result = await readArtifact({ projectId, specId, kind: 'implementation_review' });
21
+ if (!result.ok) {
22
+ const firstErr = result.errors[0];
23
+ return {
24
+ ok: false,
25
+ reason: firstErr?.code === 'ARTIFACT_NOT_FOUND' ? 'missing' : 'schema_invalid',
26
+ errors: result.errors,
27
+ };
28
+ }
29
+ const review = result.payload;
30
+ if (review.specId !== specId) {
31
+ return { ok: false, reason: 'wrong_spec', review };
32
+ }
33
+ if (isLifecycleStubBody(specId, review.body)) {
34
+ return { ok: false, reason: 'stub_body', review };
35
+ }
36
+ if (review.verdict !== 'approved' || review.reviewer.verdict !== 'approved') {
37
+ return { ok: false, reason: 'not_approved', review };
38
+ }
39
+ if (review.reviewer.kind !== 'implementation-review-agent' ||
40
+ review.reviewer.agent !== 'planu-implementation-reviewer') {
41
+ return { ok: false, reason: 'wrong_agent_or_kind', review };
42
+ }
43
+ let implementerActor;
44
+ try {
45
+ implementerActor = await findImplementingActor(specId, projectId);
46
+ }
47
+ catch (err) {
48
+ /* reliability-optional: TRANSITION_LOG_GATE_READ — typed gate error blocks done */
49
+ reportClassifiedDegradation('TRANSITION_LOG_GATE_READ', err);
50
+ return {
51
+ ok: false,
52
+ reason: 'actor_unreadable',
53
+ review,
54
+ readError: err instanceof Error ? err.message : String(err),
55
+ };
56
+ }
57
+ if (implementerActor !== undefined && implementerActor === review.reviewer.agent) {
58
+ return { ok: false, reason: 'self_review', review, implementingActor: implementerActor };
59
+ }
60
+ return { ok: true, review, implementingActor: implementerActor ?? null };
61
+ }
62
+ catch (err) {
63
+ /* reliability-optional: IMPLEMENTATION_REVIEW_GATE_READ — typed gate error blocks done */
64
+ reportClassifiedDegradation('IMPLEMENTATION_REVIEW_GATE_READ', err);
65
+ return {
66
+ ok: false,
67
+ reason: 'unreadable',
68
+ readError: err instanceof Error ? err.message : String(err),
69
+ };
70
+ }
71
+ }
72
+ //# sourceMappingURL=implementation-review-reader.js.map
@@ -1,4 +1,4 @@
1
- import type { Spec, ValidateResult, DefinitionOfReady, DefinitionOfDone, CodeState } from '../../types/index.js';
1
+ import type { Spec, ValidateResult, DefinitionOfReady, DefinitionOfDone, CodeState, VerifiedImplementationReviewResult } from '../../types/index.js';
2
2
  export declare function isBlockingQualitySeverity(severity: unknown): boolean;
3
3
  /**
4
4
  * Generate a Definition of Ready checklist for a spec.
@@ -7,5 +7,5 @@ export declare function generateDoR(spec: Spec): DefinitionOfReady;
7
7
  /**
8
8
  * Generate a Definition of Done checklist for a spec.
9
9
  */
10
- export declare function generateDoD(spec: Spec, validationResult?: ValidateResult, codeState?: CodeState, projectPath?: string): Promise<DefinitionOfDone>;
10
+ export declare function generateDoD(spec: Spec, validationResult?: ValidateResult, codeState?: CodeState, projectPath?: string, verifiedReview?: VerifiedImplementationReviewResult): Promise<DefinitionOfDone>;
11
11
  //# sourceMappingURL=dor-dod.d.ts.map
@@ -120,10 +120,11 @@ export function generateDoR(spec) {
120
120
  generatedAt: new Date().toISOString(),
121
121
  };
122
122
  }
123
- function buildDoDItems(spec, score, hasBlockingQualityIssues, hasTestFiles) {
123
+ function buildDoDItems(spec, score, hasBlockingQualityIssues, hasTestFiles, verifiedReview) {
124
124
  // If spec is already marked "done", manual gates are implicitly satisfied —
125
125
  // the user explicitly transitioned the spec, which implies review/tests/docs passed.
126
126
  const isDone = spec.status === 'done';
127
+ const reviewApproved = isDone || verifiedReview?.ok === true;
127
128
  return [
128
129
  {
129
130
  id: 'dod-1',
@@ -157,7 +158,7 @@ function buildDoDItems(spec, score, hasBlockingQualityIssues, hasTestFiles) {
157
158
  category: 'review',
158
159
  required: true,
159
160
  autoCheck: false,
160
- status: isDone ? 'passed' : 'pending',
161
+ status: reviewApproved ? 'passed' : 'pending',
161
162
  },
162
163
  {
163
164
  id: 'dod-5',
@@ -321,12 +322,12 @@ function gateCategory(gate) {
321
322
  /**
322
323
  * Generate a Definition of Done checklist for a spec.
323
324
  */
324
- export async function generateDoD(spec, validationResult, codeState, projectPath) {
325
+ export async function generateDoD(spec, validationResult, codeState, projectPath, verifiedReview) {
325
326
  const score = validationResult?.score ?? 0;
326
327
  const hasBlockingQualityIssues = validationResult?.qualityIssues.some((issue) => isBlockingQualitySeverity(issue.severity)) ??
327
328
  false;
328
329
  const hasTestFiles = await detectTestFiles(spec, codeState);
329
- const items = buildDoDItems(spec, score, hasBlockingQualityIssues, hasTestFiles);
330
+ const items = buildDoDItems(spec, score, hasBlockingQualityIssues, hasTestFiles, verifiedReview);
330
331
  // Override actuals check with progress.md parsing
331
332
  const actualsItem = items.find((i) => i.id === 'dod-8');
332
333
  if (actualsItem?.status === 'pending') {
@@ -7,6 +7,35 @@ function knowledgeFile(projectId) {
7
7
  function isKnowledgeOrNull(value) {
8
8
  return value === null || (typeof value === 'object' && !Array.isArray(value));
9
9
  }
10
+ function neutralArchitectureDetection() {
11
+ return {
12
+ primary: 'custom',
13
+ secondary: [],
14
+ layers: [],
15
+ boundaries: [],
16
+ communicationPatterns: [],
17
+ deploymentUnits: [],
18
+ };
19
+ }
20
+ function isValidArchitectureDetection(value) {
21
+ if (typeof value !== 'object' || value === null) {
22
+ return false;
23
+ }
24
+ const candidate = value;
25
+ return (typeof candidate.primary === 'string' &&
26
+ candidate.primary.length > 0 &&
27
+ Array.isArray(candidate.secondary) &&
28
+ Array.isArray(candidate.layers) &&
29
+ Array.isArray(candidate.boundaries) &&
30
+ Array.isArray(candidate.communicationPatterns) &&
31
+ Array.isArray(candidate.deploymentUnits));
32
+ }
33
+ function withNormalizedArchitecture(knowledge) {
34
+ if (isValidArchitectureDetection(knowledge.architecture)) {
35
+ return knowledge;
36
+ }
37
+ return { ...knowledge, architecture: neutralArchitectureDetection() };
38
+ }
10
39
  registerCriticalSchema({
11
40
  name: 'project-knowledge',
12
41
  currentVersion: 1,
@@ -20,7 +49,8 @@ registerCriticalSchema({
20
49
  },
21
50
  });
22
51
  async function readKnowledge(projectId) {
23
- return (await readCriticalSchema(knowledgeFile(projectId), 'project-knowledge')).data;
52
+ const knowledge = (await readCriticalSchema(knowledgeFile(projectId), 'project-knowledge')).data;
53
+ return knowledge === null ? null : withNormalizedArchitecture(knowledge);
24
54
  }
25
55
  async function writeKnowledge(projectId, knowledge) {
26
56
  await writeJson(knowledgeFile(projectId), { schemaVersion: 1, data: knowledge });
@@ -1,5 +1,6 @@
1
1
  // Planu — Agent Challenge Scenarios
2
2
  // SPEC-016a criteria 4 and 19: AI agent-specific failure modes for challenge_spec.
3
+ import { hasAffirmedMatch } from '../../engine/text-signal-boundaries.js';
3
4
  /**
4
5
  * Generate AI agent-specific failure scenarios.
5
6
  * Criteria 4: hallucinations, data leaks, wrong decisions, rate limits, cost.
@@ -89,19 +90,39 @@ export function generateAgentChallengeScenarios(spec, _specContent, _knowledge)
89
90
  });
90
91
  return scenarios;
91
92
  }
93
+ const AGENT_CONTENT_DISJUNCT_TERM = '(?:ai\\s+agent|agent\\s+contract|llm|tool\\s+call)';
94
+ const AGENT_RUNTIME_EVIDENCE_TERM = '(?:tool\\s+schema|mcp|handler|agent\\s+loop|subagent|llm\\s+call|inputschema|tool\\s+definition)';
95
+ const AGENT_CONTENT_EVIDENCE_PROXIMITY_RE = new RegExp(`\\b${AGENT_CONTENT_DISJUNCT_TERM}\\b(?:\\W+\\w+){0,6}?\\W+\\b${AGENT_RUNTIME_EVIDENCE_TERM}\\b` +
96
+ `|\\b${AGENT_RUNTIME_EVIDENCE_TERM}\\b(?:\\W+\\w+){0,6}?\\W+\\b${AGENT_CONTENT_DISJUNCT_TERM}\\b`, 'i');
97
+ const AGENT_TITLE_DISJUNCT_RE = /\b(?:agent|assistant|bot)\b/i;
98
+ const AGENT_OR_MCP_FILE_OWNERSHIP_RE = /\b[\w./-]*(?:agent|mcp)[\w./-]*\.(?:ts|tsx|js|jsx|mjs|cjs)\b/i;
99
+ function hasAgentRuntimeEvidenceNearby(specContent) {
100
+ return hasAffirmedMatch(specContent, AGENT_CONTENT_EVIDENCE_PROXIMITY_RE);
101
+ }
102
+ const FILES_SECTION_HEADING_RE = /^##\s+Files\s*$/im;
103
+ const NEXT_SECTION_HEADING_RE = /^##\s+/m;
104
+ function extractFilesSection(specContent) {
105
+ const headingMatch = FILES_SECTION_HEADING_RE.exec(specContent);
106
+ if (headingMatch === null) {
107
+ return '';
108
+ }
109
+ const sectionStart = headingMatch.index + headingMatch[0].length;
110
+ const remainder = specContent.slice(sectionStart);
111
+ const nextHeadingMatch = NEXT_SECTION_HEADING_RE.exec(remainder);
112
+ return nextHeadingMatch === null ? remainder : remainder.slice(0, nextHeadingMatch.index);
113
+ }
114
+ function titleClaimsAgentOrMcpSurface(spec, specContent) {
115
+ if (!AGENT_TITLE_DISJUNCT_RE.test(spec.title)) {
116
+ return false;
117
+ }
118
+ return AGENT_OR_MCP_FILE_OWNERSHIP_RE.test(extractFilesSection(specContent));
119
+ }
92
120
  /**
93
121
  * Check whether the spec is an AI agent spec.
94
122
  */
95
123
  export function isAgentSpec(spec, specContent) {
96
- const lower = specContent.toLowerCase();
97
- const titleLower = spec.title.toLowerCase();
98
124
  return (spec.type === 'agent' ||
99
- lower.includes('ai agent') ||
100
- lower.includes('agent contract') ||
101
- lower.includes('llm') ||
102
- lower.includes('tool call') ||
103
- titleLower.includes('agent') ||
104
- titleLower.includes('assistant') ||
105
- titleLower.includes('bot'));
125
+ hasAgentRuntimeEvidenceNearby(specContent) ||
126
+ titleClaimsAgentOrMcpSurface(spec, specContent));
106
127
  }
107
128
  //# sourceMappingURL=agent-challenge-scenarios.js.map
@@ -1,4 +1,5 @@
1
1
  import type { FailureScenario, Spec } from '../../types/index.js';
2
+ import { type ChallengeCapabilities } from './scenarios-utils.js';
2
3
  export declare const EXTERNAL_CALL_KEYWORDS: string[];
3
4
  export declare const VALIDATION_KEYWORDS: string[];
4
5
  export declare const RATE_LIMIT_KEYWORDS: string[];
@@ -24,10 +25,7 @@ export declare function hasConcurrencySignal(spec: Spec, specContent: string): b
24
25
  * Returns true when the spec describes a distributed saga.
25
26
  */
26
27
  export declare function hasSagaSignal(spec: Spec, specContent: string): boolean;
27
- /**
28
- * Generate validation boundary challenge scenarios.
29
- */
30
- export declare function generateValidationBoundaryScenarios(spec: Spec): FailureScenario[];
28
+ export declare function generateValidationBoundaryScenarios(spec: Spec, capabilities: ChallengeCapabilities): FailureScenario[];
31
29
  /**
32
30
  * Generate cascade failure challenge scenarios.
33
31
  */
@@ -97,11 +97,8 @@ export function hasConcurrencySignal(spec, specContent) {
97
97
  export function hasSagaSignal(spec, specContent) {
98
98
  return contentMentions(`${spec.title}\n${spec.tags.join(' ')}\n${specContent}`, SAGA_KEYWORDS);
99
99
  }
100
- /**
101
- * Generate validation boundary challenge scenarios.
102
- */
103
- export function generateValidationBoundaryScenarios(spec) {
104
- return [
100
+ export function generateValidationBoundaryScenarios(spec, capabilities) {
101
+ const scenarios = [
105
102
  {
106
103
  scenario: `[${spec.id}] Validation Boundary — String Fields: ` +
107
104
  'What happens when a required string field receives: (a) empty string "", (b) null, (c) field absent from body entirely, ' +
@@ -119,7 +116,9 @@ export function generateValidationBoundaryScenarios(spec) {
119
116
  dataConsistency: 'Accepting empty strings as valid inputs leads to records with meaningless values polluting the database.',
120
117
  userExperience: 'Clear per-field error messages with the specific constraint violated improve form UX significantly.',
121
118
  },
122
- {
119
+ ];
120
+ if (capabilities.numericInput) {
121
+ scenarios.push({
123
122
  scenario: `[${spec.id}] Validation Boundary — Numeric Fields: ` +
124
123
  'What happens when a numeric field receives: (a) value exactly at min boundary (e.g., min=0 → test with -1, 0, 1), ' +
125
124
  '(b) value exactly at max boundary, (c) NaN, (d) Infinity or -Infinity, ' +
@@ -132,24 +131,25 @@ export function generateValidationBoundaryScenarios(spec) {
132
131
  'Coercion policy must be explicit: either always reject type mismatches or always coerce with documented behavior.',
133
132
  dataConsistency: 'NaN or Infinity stored in numeric columns causes silent corruption or runtime exceptions.',
134
133
  userExperience: 'Off-by-one errors in validation create confusing UX where users cannot submit valid data.',
135
- },
136
- {
137
- scenario: `[${spec.id}] Validation Security — Injection Payloads: ` +
138
- 'Does the validation layer handle security-relevant strings without crashing or leaking internals? ' +
139
- "Test with: SQL injection ('; DROP TABLE users; --), XSS (<script>alert(1)</script>), " +
140
- 'path traversal (../../etc/passwd), null bytes (\\0), template injection ({{7*7}}). ' +
141
- 'Validation is not the primary defense (that is parameterized queries / output encoding), ' +
142
- 'but it must not crash and must not expose stack traces.',
143
- probability: 'medium',
144
- impact: 'critical',
145
- currentHandling: 'Injection payloads may cause unhandled exceptions in validation middleware, exposing internal error details.',
146
- requiredHandling: 'All string inputs must be treated as untrusted. ' +
147
- 'Validation rejects malformed types; sanitization and parameterized queries handle injection prevention downstream. ' +
148
- 'Error responses must never include the rejected payload or stack trace return sanitized field name + constraint only.',
149
- dataConsistency: 'If injection payloads reach the database layer (even as errors), they can leak schema information via error messages.',
150
- userExperience: 'Stack traces exposed in 400 responses are a security vulnerability use opaque error IDs instead.',
151
- },
152
- ];
134
+ });
135
+ }
136
+ scenarios.push({
137
+ scenario: `[${spec.id}] Validation Security Injection Payloads: ` +
138
+ 'Does the validation layer handle security-relevant strings without crashing or leaking internals? ' +
139
+ "Test with: SQL injection ('; DROP TABLE users; --), XSS (<script>alert(1)</script>), " +
140
+ 'path traversal (../../etc/passwd), null bytes (\\0), template injection ({{7*7}}). ' +
141
+ 'Validation is not the primary defense (that is parameterized queries / output encoding), ' +
142
+ 'but it must not crash and must not expose stack traces.',
143
+ probability: 'medium',
144
+ impact: 'critical',
145
+ currentHandling: 'Injection payloads may cause unhandled exceptions in validation middleware, exposing internal error details.',
146
+ requiredHandling: 'All string inputs must be treated as untrusted. ' +
147
+ 'Validation rejects malformed types; sanitization and parameterized queries handle injection prevention downstream. ' +
148
+ 'Error responses must never include the rejected payload or stack trace return sanitized field name + constraint only.',
149
+ dataConsistency: 'If injection payloads reach the database layer (even as errors), they can leak schema information via error messages.',
150
+ userExperience: 'Stack traces exposed in 400 responses are a security vulnerability — use opaque error IDs instead.',
151
+ });
152
+ return scenarios;
153
153
  }
154
154
  /**
155
155
  * Generate cascade failure challenge scenarios.
@@ -15,7 +15,7 @@ export function generateResilienceChallengeScenarios(spec, specContent, knowledg
15
15
  const resolvedCapabilities = capabilities ?? detectChallengeCapabilities(spec, specContent);
16
16
  if (resolvedCapabilities.validation &&
17
17
  (resolvedCapabilities.userInput || resolvedCapabilities.networkApi)) {
18
- scenarios.push(...generateValidationBoundaryScenarios(spec));
18
+ scenarios.push(...generateValidationBoundaryScenarios(spec, resolvedCapabilities));
19
19
  }
20
20
  if (resolvedCapabilities.externalService || resolvedCapabilities.payment) {
21
21
  scenarios.push(...generateCascadeFailureScenarios(spec));
@@ -3,8 +3,7 @@ import { contentMentions, detectChallengeCapabilities } from './scenarios-utils.
3
3
  export function generateFailureScenarios(spec, content, _knowledge) {
4
4
  const scenarios = [];
5
5
  const capabilities = detectChallengeCapabilities(spec, content);
6
- // Network failures
7
- if (capabilities.networkApi) {
6
+ if (capabilities.outboundDependency) {
8
7
  scenarios.push({
9
8
  scenario: 'API endpoint becomes unreachable (network timeout)',
10
9
  probability: 'medium',
@@ -24,6 +24,9 @@ export interface ChallengeCapabilities {
24
24
  rateLimit: boolean;
25
25
  saga: boolean;
26
26
  platform: boolean;
27
+ outboundDependency: boolean;
28
+ numericInput: boolean;
29
+ rollout: boolean;
27
30
  }
28
31
  /** Boundary-aware, affirmative replacement for advisory substring checks. */
29
32
  export declare function contentMentions(content: string, keywords: string[]): boolean;
@@ -87,6 +87,22 @@ const CAPABILITY_SIGNALS = {
87
87
  platform: [
88
88
  /\b(?:smart\s+contract|solidity|discord\s+bot|telegram\s+bot|iot\s+device|firmware|infrastructure\s+as\s+code|terraform|machine\s+learning\s+model)\b/i,
89
89
  ],
90
+ outboundDependency: [
91
+ /\boutbound\s+(?:http\s+)?(?:client|call|request|dependency)\b/i,
92
+ /\b(?:fetch(?:es|ing)?|calls?|invokes?)\b(?:\W+\w+){0,4}?\W+(?:api|endpoint|service|dependency)\b/i,
93
+ /\bremote\s+dependency\s+call\b/i,
94
+ ],
95
+ numericInput: [
96
+ /\bnumeric\s+(?:field|input|value|schema|constraint)\b/i,
97
+ /\b(?:integer|float|decimal)\s+field\b/i,
98
+ /\b(?:min|max)(?:imum)?\s+(?:value|constraint|boundary)\b/i,
99
+ /\bz\.number\(/i,
100
+ ],
101
+ rollout: [
102
+ /\b(?:canary|phased\s+rollout|gradual\s+rollout|blue-green\s+deploy(?:ment)?|rolling\s+deployment|feature\s+flag)\b/i,
103
+ /\broll(?:s|ed|ing)?\s+out\b(?:\W+\w+){0,4}?\W+(?:in\s+phases|gradually)\b/i,
104
+ /\bdeployment\s+strategy\b/i,
105
+ ],
90
106
  };
91
107
  const AUTHENTICATION_BARE_TOKEN_RE = /\bauth(?:entication|enticate)?\b/i;
92
108
  // A bare "auth" token next to registry/package-manager vocabulary describes a
@@ -9,7 +9,7 @@ export interface ConcurrencyAnalysisResult extends ConcurrencyAnalysis {
9
9
  suppressedCount: number;
10
10
  }
11
11
  export declare function generateConcurrencyAnalysis(_spec: Spec, content: string, _knowledge: ProjectKnowledge): ConcurrencyAnalysisResult;
12
- export declare function buildScalabilityAssessment(spec: Spec, knowledge: ProjectKnowledge, scenarios: FailureScenario[]): string;
12
+ export declare function buildScalabilityAssessment(spec: Spec, knowledge: ProjectKnowledge, scenarios: FailureScenario[], hasRolloutEvidence?: boolean): string;
13
13
  export declare function calculateOverallRisk(scenarios: FailureScenario[], concurrency: ConcurrencyAnalysis): RiskLevel;
14
14
  export declare function readSpecContent(spec: Spec): Promise<string>;
15
15
  //# sourceMappingURL=challenge-spec-helpers.d.ts.map
@@ -93,7 +93,7 @@ export function generateConcurrencyAnalysis(_spec, content, _knowledge) {
93
93
  return { hotPaths, raceConditions, sharedState, recommendations, suppressedCount };
94
94
  }
95
95
  // --- Scalability and risk ---
96
- export function buildScalabilityAssessment(spec, knowledge, scenarios) {
96
+ export function buildScalabilityAssessment(spec, knowledge, scenarios, hasRolloutEvidence = false) {
97
97
  const criticalCount = scenarios.filter((s) => s.impact === 'critical').length;
98
98
  const arch = knowledge.architecture.primary;
99
99
  const parts = [];
@@ -108,7 +108,10 @@ export function buildScalabilityAssessment(spec, knowledge, scenarios) {
108
108
  parts.push('No critical scalability concerns for the current scope.');
109
109
  }
110
110
  if (spec.scope === 'architectural' || spec.scope === 'cross-module') {
111
- parts.push('Cross-module scope increases blast radius. Consider phased rollout with feature flags.');
111
+ parts.push('Cross-module scope increases blast radius.');
112
+ if (hasRolloutEvidence) {
113
+ parts.push('Consider phased rollout with feature flags.');
114
+ }
112
115
  }
113
116
  return parts.join(' ');
114
117
  }
@@ -268,7 +268,7 @@ export async function handleChallengeSpec(args, server) {
268
268
  const actionableFailureScenarios = failureScenarios.filter((scenario) => isScenarioSupportedByCapabilities(scenario, capabilities));
269
269
  const suppressedScenarioCount = failureScenarios.length - actionableFailureScenarios.length;
270
270
  // 7. Build scalability assessment from grounded scenarios only.
271
- const scalabilityAssessment = buildScalabilityAssessment(spec, knowledge, actionableFailureScenarios);
271
+ const scalabilityAssessment = buildScalabilityAssessment(spec, knowledge, actionableFailureScenarios, capabilities.rollout);
272
272
  // 8. Calculate overall risk from grounded scenarios only.
273
273
  const overallRisk = calculateOverallRisk(actionableFailureScenarios, concurrencyAnalysis);
274
274
  // 9. Compute relevance scores and select top-3 diagnostics (SPEC-338) — retained as-is
@@ -465,7 +465,10 @@ function isScenarioSupportedByCapabilities(scenario, capabilities) {
465
465
  ],
466
466
  [/\b(?:sql|nosql|database|connection pool)\b/, capabilities.database],
467
467
  [/\b(?:event contract|event schema|message broker|kafka|rabbitmq|dlq)\b/, capabilities.events],
468
- [/\b(?:api endpoint|http route|http status|network timeout)\b/, capabilities.networkApi],
468
+ [
469
+ /\b(?:api endpoint|http route|http status|network timeout)\b/,
470
+ capabilities.outboundDependency,
471
+ ],
469
472
  [/\b(?:traffic spike|load test|auto-scaling|throughput)\b/, capabilities.scale],
470
473
  ];
471
474
  return rules.every(([pattern, supported]) => !pattern.test(haystack) || supported);
@@ -1335,8 +1335,26 @@ async function prepareCreateSpecCandidate(initialParams, server) {
1335
1335
  },
1336
1336
  };
1337
1337
  }
1338
+ function isNonEmptyString(value) {
1339
+ return typeof value === 'string' && value.trim().length > 0;
1340
+ }
1341
+ function buildMissingTitleResult() {
1342
+ return {
1343
+ content: [
1344
+ {
1345
+ type: 'text',
1346
+ text: 'create_spec requires a non-empty title. Provide the title field and call create_spec again.',
1347
+ },
1348
+ ],
1349
+ isError: true,
1350
+ structuredContent: { error: 'MISSING_TITLE', code: 'INVALID_INPUT', field: 'title' },
1351
+ };
1352
+ }
1338
1353
  // eslint-disable-next-line max-lines-per-function
1339
1354
  export async function handleCreateSpec(inputParams, server) {
1355
+ if (!isNonEmptyString(inputParams.title)) {
1356
+ return buildMissingTitleResult();
1357
+ }
1340
1358
  const enumValidation = validateCreateSpecEnums(inputParams);
1341
1359
  if (enumValidation) {
1342
1360
  return enumValidation;