|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | """QR decomposition for impl-code phase. |
3 | 3 |
|
4 | | -INTENT.md requires separate files per phase. |
5 | | -This file contains ONLY impl-code-specific item generation. |
6 | | -Shared logic lives in qr_decompose_base.py. |
7 | | -
|
8 | | -Impl-code checks: |
9 | | -- Acceptance criteria verification (factored: expectations vs observations) |
10 | | -- Cross-cutting concerns (shared state, error propagation) |
11 | | -- Code quality (all 8 quality documents) |
12 | | -- Intent marker validation |
| 4 | +Scope: Implemented code quality. |
| 5 | + - Acceptance criteria verification (expectations vs observations) |
| 6 | + - Cross-cutting concerns (shared state, error propagation) |
| 7 | + - Code quality (all 8 quality documents) |
| 8 | + - Intent marker validation |
| 9 | +NOT plan structure or documentation (verified in earlier phases). |
| 10 | +
|
| 11 | +Severity categories: Same as plan-code (Dev can fix code issues). |
13 | 12 | """ |
14 | 13 |
|
15 | | -from .qr_decompose_base import DecomposeBase |
| 14 | +from skills.planner.quality_reviewer.prompts.decompose import dispatch_step |
16 | 15 |
|
17 | 16 |
|
18 | | -class ImplCodeDecompose(DecomposeBase): |
19 | | - """QR decomposition for impl-code phase.""" |
| 17 | +PHASE = "impl-code" |
20 | 18 |
|
21 | | - PHASE = "impl-code" |
22 | 19 |
|
23 | | - def get_artifact_prompt(self) -> str: |
24 | | - """Impl-code reads plan.json and modified files from codebase.""" |
25 | | - return """Read plan.json from STATE_DIR: |
| 20 | +STEP_1_ABSORB = """\ |
| 21 | +Read plan.json from STATE_DIR: |
26 | 22 | cat $STATE_DIR/plan.json | jq '.' |
27 | 23 |
|
28 | 24 | Also read MODIFIED_FILES from codebase (paths from milestones). |
29 | 25 |
|
| 26 | +SCOPE: Implemented code quality. |
| 27 | +
|
30 | 28 | Focus on: |
31 | | - - milestones[].acceptance_criteria |
32 | | - - Actual implemented code in modified files |
33 | | - - Code quality (structure, patterns, documentation)""" |
| 29 | + - milestones[].acceptance_criteria (expectations) |
| 30 | + - Actual implemented code in modified files (observations) |
| 31 | + - Code quality (structure, patterns, documentation) |
| 32 | + - Intent markers in implemented code |
| 33 | +
|
| 34 | +OUT OF SCOPE: |
| 35 | + - Plan structure (already verified in plan-design) |
| 36 | + - Documentation files (impl-docs phase)""" |
| 37 | + |
| 38 | + |
| 39 | +STEP_2_CONCERNS = """\ |
| 40 | +Brainstorm concerns specific to IMPLEMENTED CODE: |
| 41 | + - Acceptance criteria not met |
| 42 | + - Cross-cutting concerns broken (error handling, logging) |
| 43 | + - Code quality violations (god objects, god functions) |
| 44 | + - Missing or invalid intent markers |
| 45 | + - Implementation drift from plan |
| 46 | +
|
| 47 | +DO NOT brainstorm plan structure or documentation concerns.""" |
34 | 48 |
|
35 | | - def get_enumeration_guidance(self) -> str: |
36 | | - """Return phase-specific enumeration guidance for Step 3.""" |
37 | | - return """For impl-code, enumerate: |
| 49 | + |
| 50 | +STEP_3_ENUMERATION = """\ |
| 51 | +For impl-code, enumerate IMPLEMENTATION ARTIFACTS: |
| 52 | +
|
| 53 | +ACCEPTANCE CRITERIA: |
38 | 54 | - Each milestone with acceptance_criteria (ID, criteria count) |
39 | | - - Files modified per milestone |
40 | | - - Cross-cutting concerns mentioned (error handling, logging, etc.) |
41 | | - - Code quality aspects to verify""" |
| 55 | + - Each criterion (ID, expectation text) |
| 56 | +
|
| 57 | +FILES: |
| 58 | + - Files modified per milestone (path list) |
| 59 | + - Actual file content (read from codebase) |
| 60 | +
|
| 61 | +CROSS-CUTTING: |
| 62 | + - Error handling patterns used |
| 63 | + - Logging patterns used |
| 64 | + - Shared state access patterns |
| 65 | +
|
| 66 | +CODE QUALITY: |
| 67 | + - Function sizes (line counts) |
| 68 | + - Nesting depths |
| 69 | + - Dependency counts""" |
| 70 | + |
| 71 | + |
| 72 | +STEP_5_GENERATE = """\ |
| 73 | +SEVERITY ASSIGNMENT (per conventions/severity.md, impl-code scope): |
| 74 | +
|
| 75 | + MUST (blocks all iterations): |
| 76 | + - Acceptance criterion not met |
| 77 | + - MARKER_INVALID: intent marker without valid explanation |
| 78 | +
|
| 79 | + SHOULD (iterations 1-4) - STRUCTURE categories: |
| 80 | + - GOD_OBJECT: >15 methods OR >10 deps |
| 81 | + - GOD_FUNCTION: >50 lines OR >3 nesting |
| 82 | + - CONVENTION_VIOLATION: violates documented project convention |
| 83 | + - INCONSISTENT_ERROR_HANDLING: mixed exceptions/codes |
| 84 | +
|
| 85 | + COULD (iterations 1-3) - COSMETIC: |
| 86 | + - DEAD_CODE: unused functions, impossible branches |
| 87 | + - FORMATTER_FIXABLE: style issues""" |
| 88 | + |
| 89 | + |
| 90 | +COMPONENT_EXAMPLES = """\ |
| 91 | + - A modified file |
| 92 | + - A milestone's implementation |
| 93 | + - A cross-cutting concern pattern""" |
| 94 | + |
| 95 | + |
| 96 | +CONCERN_EXAMPLES = """\ |
| 97 | + - Acceptance criteria compliance |
| 98 | + - Error handling consistency |
| 99 | + - Code structure quality""" |
| 100 | + |
| 101 | + |
| 102 | +PHASE_PROMPTS = { |
| 103 | + 1: STEP_1_ABSORB, |
| 104 | + 2: STEP_2_CONCERNS, |
| 105 | + 3: STEP_3_ENUMERATION, |
| 106 | + 5: STEP_5_GENERATE, |
| 107 | +} |
| 108 | + |
| 109 | +GROUPING_CONFIG = { |
| 110 | + "component_examples": COMPONENT_EXAMPLES, |
| 111 | + "concern_examples": CONCERN_EXAMPLES, |
| 112 | +} |
42 | 113 |
|
43 | 114 |
|
44 | | -def get_step_guidance(step: int, total_steps: int, module_path: str = None, **kwargs) -> dict: |
45 | | - """Entry point for workflow execution.""" |
| 115 | +def get_step_guidance(step: int, module_path: str = None, **kwargs) -> dict: |
46 | 116 | module_path = module_path or "skills.planner.quality_reviewer.impl_code_qr_decompose" |
47 | | - decomposer = ImplCodeDecompose() |
48 | | - return decomposer.get_step_guidance(step, total_steps, module_path=module_path, **kwargs) |
| 117 | + state_dir = kwargs.get("state_dir", "") |
| 118 | + return dispatch_step(step, PHASE, module_path, PHASE_PROMPTS, GROUPING_CONFIG, state_dir) |
49 | 119 |
|
50 | 120 |
|
51 | 121 | if __name__ == "__main__": |
|
0 commit comments