You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strengthen planner system prompts to prevent common linter errors
Fixes recurring issues where generated specs had:
- Landmarks (RULES, DONE_WHEN, etc.) appearing outside FUNCTION blocks
- Undefined DATA types referenced in FUNCTION signatures
Changes:
1. Added CRITICAL STRUCTURE RULE emphasizing landmarks must be inside FUNCTION blocks
2. Made DATA type definition requirement explicit (must define before use)
3. Clarified top-level vs FUNCTION-level landmark hierarchy
4. Improved refinement prompt to explain Simplex structure upfront
5. Added reminder in brownfield fragment about DATA type definitions
The prompt now explicitly states:
- Top-level: only DATA and CONSTRAINT
- Inside FUNCTION: all required landmarks (RULES, DONE_WHEN, EXAMPLES, ERRORS)
- Custom types in signatures require DATA blocks defined first
This should eliminate W001 (landmarks outside FUNCTION) and W006
(undefined DATA type) errors in planner-generated specifications.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: web/cmd/server/static/js/simplex-spec.js
+40-27Lines changed: 40 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -307,18 +307,24 @@ ${COMPLEX_EXAMPLE}
307
307
308
308
Based on the user's description and any refinement conversation, generate a complete Simplex specification that:
309
309
310
-
1. Contains at least one FUNCTION block with all required landmarks (RULES, DONE_WHEN, EXAMPLES, ERRORS)
311
-
2. Uses DATA blocks when custom types would clarify the specification
312
-
3. Includes CONSTRAINT blocks for important invariants
313
-
4. Provides enough EXAMPLES to cover every conditional branch in RULES (this is a strict requirement — the linter will reject specs where the number of examples is less than the number of conditional branches)
314
-
5. Always includes a catch-all error handler: "any unhandled condition → fail with descriptive message"
315
-
6. Stays within complexity limits:
310
+
1. **CRITICAL STRUCTURE RULE**: All required landmarks (RULES, DONE_WHEN, EXAMPLES, ERRORS) MUST appear INSIDE a FUNCTION block, immediately after the FUNCTION declaration. They are NOT top-level landmarks. See the reference examples above for correct structure.
311
+
312
+
2. **Top-level landmarks**: Only DATA and CONSTRAINT appear at the top level (outside FUNCTION blocks). Everything else goes inside FUNCTION blocks.
313
+
314
+
3. **DATA types**: When using custom types in FUNCTION signatures (like "updated cart" or "PolicyRule"), you MUST define them with a DATA block BEFORE the FUNCTION that uses them. Never reference undefined types.
315
+
316
+
4. **Example coverage**: Provide enough EXAMPLES to cover every conditional branch in RULES. The linter will reject specs where example count is less than conditional branch count.
317
+
318
+
5. **Error handling**: Always include the catch-all error handler: "any unhandled condition → fail with descriptive message"
319
+
320
+
6. **Complexity limits**:
316
321
- Maximum 15 RULES items per function
317
322
- Maximum 6 function inputs
318
323
- Maximum 200 characters per single rule item
319
324
- If more complex, decompose into multiple functions
320
325
321
-
Generate ONLY the specification. No explanations, no markdown code blocks, no surrounding text. Output the raw Simplex spec text directly.`;
326
+
**Output format**: Generate ONLY the specification. No explanations, no markdown code blocks, no surrounding text. Output the raw Simplex spec text directly.`;
327
+
322
328
323
329
// Appended to BASE_SYSTEM_PROMPT when brownfield project type is selected
This is an EVOLUTIONARY specification for an existing codebase. You MUST include:
329
335
330
-
1. **BASELINE** landmark with all three required fields:
336
+
1. **BASELINE** landmark (inside FUNCTION block) with all three required fields:
331
337
- reference: description or pointer to the current/prior state being evolved
332
338
- preserve: list of behaviors, contracts, or APIs that must NOT regress
333
339
- evolve: list of capabilities being added or changed
334
340
335
-
2. **EVAL** landmark with all three required fields:
341
+
2. **EVAL** landmark (inside FUNCTION block) with all three required fields:
336
342
- preserve: pass^k threshold (e.g., pass^3 means all 3 trials must pass - for regression testing)
337
343
- evolve: pass@k threshold (e.g., pass@5 means at least 1 of 5 must pass - for capability testing)
338
344
- grading: code | model | outcome
@@ -341,6 +347,8 @@ This is an EVOLUTIONARY specification for an existing codebase. You MUST include
341
347
- Preserved behaviors (regression tests) - these verify nothing breaks
342
348
- Evolved capabilities (capability tests) - these verify new functionality
343
349
350
+
4. **Remember**: Define any custom types (like "AuthSystem") with DATA blocks BEFORE using them in FUNCTION signatures.
351
+
344
352
Here is an evolutionary specification example:
345
353
\`\`\`
346
354
${EVOLUTION_EXAMPLE}
@@ -349,24 +357,29 @@ ${EVOLUTION_EXAMPLE}
349
357
// System prompt for refinement (used with temperature 0.7, max_tokens 1024)
350
358
constREFINE_SYSTEM_PROMPT=`You are a helpful assistant that helps users refine their software requirements into clear, testable specifications for the Simplex specification (v0.5).
351
359
352
-
Simplex specs have these required landmarks:
353
-
- FUNCTION: The name, inputs, and return type
354
-
- RULES: Business logic and behavioral constraints
Ask clarifying questions to gather enough information to generate a complete spec. Focus on:
379
+
1. **What types are needed?** (Will become DATA blocks if not obvious primitive types)
380
+
2. **What are the behavioral rules?** (Outcomes, not implementation steps)
381
+
3. **What are the edge cases?** (Every conditional needs an example)
382
+
4. **How should errors be handled?** (Specific conditions and responses)
370
383
371
384
Be conversational but focused. Ask 2-3 questions at a time. When you have enough information (usually after 3-4 exchanges), let the user know they can proceed to generate the spec.
0 commit comments