prizmkit 1.1.130 → 1.1.134
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/bundled/VERSION.json +3 -3
- package/bundled/adapters/claude/command-adapter.js +0 -2
- package/bundled/dev-pipeline/.env.example +1 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +11 -6
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +445 -8
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +2 -9
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +21 -1
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +87 -66
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +53 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +55 -25
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +4 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +119 -18
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +3 -2
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +411 -17
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +57 -14
- package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +5 -4
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +55 -2
- package/bundled/dev-pipeline/scripts/prompt_framework.py +152 -1
- package/bundled/dev-pipeline/scripts/update-bug-status.py +53 -0
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +294 -69
- package/bundled/dev-pipeline/scripts/update-feature-status.py +57 -0
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +53 -0
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +5 -5
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +28 -22
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +24 -10
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +20 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +2 -2
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +5 -10
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +9 -19
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +21 -0
- package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +1 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +10 -10
- package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +1 -1
- package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +15 -0
- package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-commit.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +26 -23
- package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +5 -5
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +15 -11
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +1 -1
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +6 -6
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +21 -0
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +1 -1
- package/bundled/dev-pipeline/templates/sections/subagent-timeout-recovery.md +1 -1
- package/bundled/dev-pipeline/templates/sections/task-contract.md +4 -0
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +362 -3
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +349 -48
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +129 -0
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +91 -0
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +567 -23
- package/bundled/dev-pipeline/tests/test_unified_cli.py +37 -10
- package/bundled/skills/_metadata.json +63 -26
- package/bundled/skills/app-planner/SKILL.md +4 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +89 -180
- package/bundled/skills/bug-planner/SKILL.md +12 -27
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +131 -220
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +36 -90
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +129 -271
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +35 -76
- package/bundled/skills/feature-planner/SKILL.md +27 -22
- package/bundled/skills/feature-planner/assets/planning-guide.md +4 -4
- package/bundled/skills/feature-workflow/SKILL.md +94 -121
- package/bundled/skills/prizmkit/SKILL.md +130 -94
- package/bundled/skills/prizmkit/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-code-review/SKILL.md +132 -86
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +243 -0
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +42 -1
- package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +93 -1
- package/bundled/skills/prizmkit-committer/SKILL.md +125 -48
- package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-implement/SKILL.md +99 -73
- package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +1 -1
- package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-init/SKILL.md +5 -5
- package/bundled/skills/prizmkit-plan/SKILL.md +146 -105
- package/bundled/skills/prizmkit-plan/assets/plan-template.md +18 -0
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +242 -0
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +4 -4
- package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-retrospective/SKILL.md +111 -53
- package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +7 -6
- package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +5 -4
- package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-test/SKILL.md +52 -6
- package/bundled/skills/prizmkit-test/assets/authoritative-records.schema.json +63 -12
- package/bundled/skills/prizmkit-test/assets/evidence-manifest.schema.json +1 -1
- package/bundled/skills/prizmkit-test/assets/evidence-package-template.json +13 -0
- package/bundled/skills/prizmkit-test/references/evidence-protocol.md +6 -1
- package/bundled/skills/prizmkit-test/references/evidence-request-protocol.md +8 -1
- package/bundled/skills/prizmkit-test/references/examples.md +1 -1
- package/bundled/skills/prizmkit-test/references/test-generation-steps.md +4 -1
- package/bundled/skills/prizmkit-test/references/test-report-template.md +1 -1
- package/bundled/skills/prizmkit-test/references/trusted-evidence-execution.md +15 -0
- package/bundled/skills/prizmkit-test/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/prizmkit-test/scripts/build_test_evidence.py +744 -23
- package/bundled/skills/prizmkit-test/scripts/validate_test_evidence.py +194 -15
- package/bundled/skills/prizmkit-workflow/SKILL.md +266 -0
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +181 -0
- package/bundled/skills/recovery-workflow/SKILL.md +62 -241
- package/bundled/skills/recovery-workflow/evals/evals.json +17 -33
- package/bundled/skills/recovery-workflow/references/detection.md +28 -52
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +105 -439
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +136 -275
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +53 -88
- package/bundled/skills/refactor-planner/SKILL.md +12 -57
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +111 -230
- package/bundled/skills/refactor-planner/references/error-recovery.md +37 -0
- package/bundled/skills/refactor-planner/references/planning-phases.md +11 -17
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +1 -1
- package/bundled/skills/refactor-workflow/SKILL.md +98 -139
- package/bundled/templates/project-memory-template.md +4 -4
- package/package.json +1 -1
- package/src/index.js +4 -0
- package/src/prompts.js +10 -3
- package/src/scaffold.js +1 -1
- package/bundled/dev-pipeline/tests/test-deploy-safety.sh +0 -223
- package/bundled/skills/feature-pipeline-launcher/scripts/preflight-check.py +0 -462
|
@@ -1,306 +1,187 @@
|
|
|
1
|
-
# Behavior Preservation Guide
|
|
1
|
+
# Behavior Preservation Planning Guide
|
|
2
2
|
|
|
3
|
-
This guide
|
|
3
|
+
This guide helps the planner select and describe behavior-preservation evidence for each refactor item. It is a planning reference only: inspect existing code and test configuration as read-only evidence, then record what the downstream refactor session must prove. Do not run tests, change code, capture runtime snapshots, or perform rollback from this planner.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Table of Contents
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. [Planning Boundary](#planning-boundary)
|
|
8
|
+
2. [Preservation Strategies](#preservation-strategies)
|
|
9
|
+
3. [Strategy Selection](#strategy-selection)
|
|
10
|
+
4. [Behavior-Risk Checklist](#behavior-risk-checklist)
|
|
11
|
+
5. [Coverage Assessment](#coverage-assessment)
|
|
12
|
+
6. [Plan-Readiness Checklist](#plan-readiness-checklist)
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## Planning Boundary
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
For every refactor item, the planner must:
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
- choose a primary strategy: `test-gate`, `snapshot`, or `manual`;
|
|
19
|
+
- identify the observable behavior that must remain stable;
|
|
20
|
+
- identify existing evidence sources when they are discoverable by reading the repository;
|
|
21
|
+
- record missing evidence and any prerequisite item needed to close the gap;
|
|
22
|
+
- write measurable acceptance criteria that a non-interactive downstream session can evaluate;
|
|
23
|
+
- avoid claiming that tests, snapshots, or manual verification have already run.
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
- Target area has good test coverage (>60%)
|
|
22
|
-
- Tests are reliable (no flaky tests in the target area)
|
|
23
|
-
- Test suite runs in reasonable time (<5 minutes for the relevant subset)
|
|
24
|
-
- Tests cover the behavior contracts you need to preserve
|
|
25
|
+
## Preservation Strategies
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
- Most reliable automated strategy
|
|
28
|
-
- Catches regressions immediately
|
|
29
|
-
- Well-understood and widely practiced
|
|
30
|
-
- Works with any test framework
|
|
27
|
+
### Strategy: `test-gate`
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
Use when the target has reliable automated tests that cover the behavior being preserved.
|
|
30
|
+
|
|
31
|
+
Planning requirements:
|
|
32
|
+
|
|
33
|
+
- name the relevant test files, suites, or project-native test command when discoverable;
|
|
34
|
+
- identify the behavior contracts represented by those tests;
|
|
35
|
+
- require evidence that previously passing relevant tests remain passing after the structural change;
|
|
36
|
+
- note known flaky tests or coverage gaps;
|
|
37
|
+
- add a prerequisite planning item when missing tests make the refactor unsafe.
|
|
36
38
|
|
|
37
|
-
**Configuration in refactor-list.json**:
|
|
38
39
|
```json
|
|
39
40
|
{
|
|
40
41
|
"behavior_preservation": {
|
|
41
42
|
"strategy": "test-gate",
|
|
42
|
-
"existing_tests": true
|
|
43
|
+
"existing_tests": true,
|
|
44
|
+
"new_tests_needed": []
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
```
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Strategy: snapshot
|
|
49
|
+
### Strategy: `snapshot`
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Use when formal coverage is insufficient but deterministic observable behavior can be compared.
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
1. Identify observable outputs of the target code (API responses, rendered UI, log output, file output)
|
|
55
|
-
2. Capture a "before" snapshot by exercising the code with representative inputs
|
|
56
|
-
3. Implement the refactoring change
|
|
57
|
-
4. Capture an "after" snapshot with the same inputs
|
|
58
|
-
5. Compare: snapshots must match (or differ only in acceptable ways like formatting)
|
|
53
|
+
Planning requirements:
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
55
|
+
- define representative inputs;
|
|
56
|
+
- define the observable outputs or state to compare;
|
|
57
|
+
- define allowed normalization or acceptable differences;
|
|
58
|
+
- require before/after evidence from the same inputs;
|
|
59
|
+
- identify non-deterministic fields that must be excluded or normalized.
|
|
65
60
|
|
|
66
|
-
**Strengths**:
|
|
67
|
-
- Works even when formal tests are missing
|
|
68
|
-
- Captures real behavior rather than test assertions
|
|
69
|
-
- Can detect subtle regressions that tests might miss
|
|
70
|
-
|
|
71
|
-
**Limitations**:
|
|
72
|
-
- Requires deterministic behavior (non-deterministic outputs need normalization)
|
|
73
|
-
- May miss edge cases if representative inputs are incomplete
|
|
74
|
-
- Snapshot comparison tools may need configuration for acceptable differences
|
|
75
|
-
- More manual setup than test-gate
|
|
76
|
-
|
|
77
|
-
**Configuration in refactor-list.json**:
|
|
78
61
|
```json
|
|
79
62
|
{
|
|
80
63
|
"behavior_preservation": {
|
|
81
|
-
"strategy": "snapshot"
|
|
64
|
+
"strategy": "snapshot",
|
|
65
|
+
"existing_tests": false,
|
|
66
|
+
"new_tests_needed": []
|
|
82
67
|
},
|
|
83
68
|
"acceptance_criteria": [
|
|
84
|
-
"
|
|
85
|
-
"CLI output
|
|
69
|
+
"Responses for the documented API cases match the approved baseline after normalization",
|
|
70
|
+
"CLI help output preserves all documented flags and exit codes"
|
|
86
71
|
]
|
|
87
72
|
}
|
|
88
73
|
```
|
|
89
74
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
### Strategy: manual
|
|
75
|
+
### Strategy: `manual`
|
|
93
76
|
|
|
94
|
-
|
|
77
|
+
Use only when neither reliable tests nor deterministic observable output can prove preservation.
|
|
95
78
|
|
|
96
|
-
|
|
97
|
-
- No test coverage AND no easily observable deterministic output
|
|
98
|
-
- UI-heavy changes where visual regression is the primary concern
|
|
99
|
-
- Legacy code with unknown behavior contracts
|
|
100
|
-
- Code that interacts with external services in non-reproducible ways
|
|
79
|
+
Planning requirements:
|
|
101
80
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
81
|
+
- state exactly which behavior requires human judgment;
|
|
82
|
+
- define a reproducible verification checklist;
|
|
83
|
+
- identify required screenshots, recordings, or written baselines;
|
|
84
|
+
- mark the item as high verification risk;
|
|
85
|
+
- avoid subjective criteria such as “looks correct” without named observations.
|
|
107
86
|
|
|
108
|
-
**Strengths**:
|
|
109
|
-
- Works for any situation
|
|
110
|
-
- Humans can assess subjective quality (UI layout, user experience)
|
|
111
|
-
- Can catch issues that automated tools miss
|
|
112
|
-
|
|
113
|
-
**Limitations**:
|
|
114
|
-
- Slowest strategy — blocks on human availability
|
|
115
|
-
- Error-prone — humans miss regressions, especially subtle ones
|
|
116
|
-
- Not scalable — each item needs separate human attention
|
|
117
|
-
- Not repeatable — different humans may verify differently
|
|
118
|
-
|
|
119
|
-
**Configuration in refactor-list.json**:
|
|
120
87
|
```json
|
|
121
88
|
{
|
|
122
89
|
"behavior_preservation": {
|
|
123
|
-
"strategy": "manual"
|
|
90
|
+
"strategy": "manual",
|
|
91
|
+
"existing_tests": false,
|
|
92
|
+
"new_tests_needed": []
|
|
124
93
|
},
|
|
125
94
|
"acceptance_criteria": [
|
|
126
|
-
"
|
|
95
|
+
"The verification checklist covers email login, social login, and password reset without changing their documented outcomes"
|
|
127
96
|
]
|
|
128
97
|
}
|
|
129
98
|
```
|
|
130
99
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
## 2. Choosing the Right Strategy
|
|
134
|
-
|
|
135
|
-
Use this decision tree to select the appropriate strategy for each refactor item:
|
|
136
|
-
|
|
137
|
-
1. If the target area has reliable test coverage above 60%, choose `test-gate`.
|
|
138
|
-
2. If tests exist but are flaky, plan a prerequisite item to stabilize tests first; if stabilization is out of scope, choose `snapshot`.
|
|
139
|
-
3. If test coverage is below 60% but behavior is deterministic and observable, choose `snapshot`.
|
|
140
|
-
4. If neither reliable tests nor deterministic observable output exist, choose `manual` and flag the item as high risk.
|
|
141
|
-
|
|
142
|
-
### Strategy Selection Table
|
|
143
|
-
|
|
144
|
-
| Test Coverage | Output Observable | Recommended Strategy | Risk Level |
|
|
145
|
-
|--------------|-------------------|---------------------|------------|
|
|
146
|
-
| High (>60%) | Yes | test-gate | Low |
|
|
147
|
-
| High (>60%) | No | test-gate | Low |
|
|
148
|
-
| Medium (30-60%) | Yes | test-gate + snapshot | Medium |
|
|
149
|
-
| Medium (30-60%) | No | test-gate (acknowledge gaps) | Medium |
|
|
150
|
-
| Low (<30%) | Yes | snapshot | Medium-High |
|
|
151
|
-
| Low (<30%) | No | manual | High |
|
|
152
|
-
| None (0%) | Yes | snapshot | High |
|
|
153
|
-
| None (0%) | No | manual | Very High |
|
|
154
|
-
|
|
155
|
-
### Mixed Strategies
|
|
156
|
-
|
|
157
|
-
For complex items, you can combine strategies:
|
|
158
|
-
- **test-gate + snapshot**: Run tests AND compare output snapshots. Provides defense in depth.
|
|
159
|
-
- **test-gate + manual**: Run tests AND have a human verify UI/UX aspects.
|
|
160
|
-
- Use the primary strategy in the `behavior_preservation` field and note the secondary in `verification_notes`.
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 3. Common Behavior-Breaking Pitfalls
|
|
165
|
-
|
|
166
|
-
These are patterns that frequently cause unintended behavior changes during refactoring. Check for each one when planning.
|
|
167
|
-
|
|
168
|
-
### 3.1 Side Effect Ordering
|
|
169
|
-
|
|
170
|
-
**Pitfall**: Reordering function calls or module initialization can change side effects.
|
|
171
|
-
|
|
172
|
-
**Example**: Moving `initLogger()` after `loadConfig()` when the logger depends on config.
|
|
100
|
+
## Strategy Selection
|
|
173
101
|
|
|
174
|
-
|
|
102
|
+
Choose the smallest strategy that can credibly prove behavior preservation:
|
|
175
103
|
|
|
176
|
-
|
|
104
|
+
1. Reliable relevant tests exist and cover the contract: choose `test-gate`.
|
|
105
|
+
2. Tests are incomplete but behavior is deterministic and observable: choose `snapshot`.
|
|
106
|
+
3. Tests are flaky: plan stabilization as a prerequisite, or use `snapshot` when stabilization is explicitly out of scope.
|
|
107
|
+
4. Neither automated evidence source is viable: choose `manual` and document the risk.
|
|
177
108
|
|
|
178
|
-
|
|
109
|
+
| Existing Evidence | Observable Output | Primary Strategy | Planning Risk |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| Reliable tests | Any | `test-gate` | Low |
|
|
112
|
+
| Partial tests | Deterministic | `snapshot` or `test-gate` with documented gaps | Medium |
|
|
113
|
+
| No reliable tests | Deterministic | `snapshot` | High |
|
|
114
|
+
| No reliable tests | Non-deterministic or subjective | `manual` | Very high |
|
|
179
115
|
|
|
180
|
-
|
|
116
|
+
When a complex item needs more than one evidence type, keep one primary strategy in `behavior_preservation` and record supplemental evidence in acceptance criteria or verification notes.
|
|
181
117
|
|
|
182
|
-
|
|
118
|
+
## Behavior-Risk Checklist
|
|
183
119
|
|
|
184
|
-
|
|
120
|
+
Inspect the target and capture relevant risks in the item description or acceptance criteria.
|
|
185
121
|
|
|
186
|
-
|
|
122
|
+
### Side-effect ordering
|
|
187
123
|
|
|
188
|
-
|
|
124
|
+
Record initialization, mutation, and external-call ordering that must not change.
|
|
189
125
|
|
|
190
|
-
|
|
126
|
+
### Error propagation
|
|
191
127
|
|
|
192
|
-
|
|
128
|
+
Record which errors reach which handlers, including error types, messages, codes, and retry behavior.
|
|
193
129
|
|
|
194
|
-
|
|
130
|
+
### Closure and binding semantics
|
|
195
131
|
|
|
196
|
-
|
|
132
|
+
Record captured variables, `this` binding, lifetime, and scope assumptions affected by extraction or movement.
|
|
197
133
|
|
|
198
|
-
|
|
134
|
+
### Import-time behavior
|
|
199
135
|
|
|
200
|
-
|
|
136
|
+
Record side-effect imports, polyfills, registration order, and module initialization dependencies.
|
|
201
137
|
|
|
202
|
-
|
|
138
|
+
### Defaults and type coercion
|
|
203
139
|
|
|
204
|
-
|
|
140
|
+
Record existing default-value and coercion behavior, especially where falsy values differ from missing values.
|
|
205
141
|
|
|
206
|
-
|
|
142
|
+
### Async timing and concurrency
|
|
207
143
|
|
|
208
|
-
|
|
144
|
+
Record ordering, atomicity, cancellation, race, and shared-state constraints.
|
|
209
145
|
|
|
210
|
-
|
|
146
|
+
### Public interfaces
|
|
211
147
|
|
|
212
|
-
|
|
148
|
+
Record exports, signatures, import paths, configuration keys, CLI flags, response shapes, and compatibility commitments.
|
|
213
149
|
|
|
214
|
-
|
|
150
|
+
### Operational observability
|
|
215
151
|
|
|
216
|
-
|
|
152
|
+
Record log patterns, metrics, alerts, performance limits, and other externally observed behavior that consumers rely on.
|
|
217
153
|
|
|
218
|
-
|
|
154
|
+
## Coverage Assessment
|
|
219
155
|
|
|
220
|
-
|
|
156
|
+
Assess coverage by reading existing repository evidence only:
|
|
221
157
|
|
|
222
|
-
|
|
158
|
+
- test runner configuration;
|
|
159
|
+
- relevant test files and their imports;
|
|
160
|
+
- assertions that describe behavior contracts;
|
|
161
|
+
- existing coverage reports when already present;
|
|
162
|
+
- project documentation and CI configuration.
|
|
223
163
|
|
|
224
|
-
|
|
164
|
+
Do not generate fresh coverage evidence from this planner. When current coverage cannot be established from existing files, record it as `unknown` rather than guessing.
|
|
225
165
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
**Example**: Splitting a synchronous operation into two async steps creates a window where state is inconsistent.
|
|
229
|
-
|
|
230
|
-
**Prevention**: Identify shared mutable state. Ensure atomicity is preserved. Test concurrent scenarios.
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
## 4. Test Coverage Assessment
|
|
235
|
-
|
|
236
|
-
Before refactoring, assess the test coverage of the target area to select the appropriate preservation strategy.
|
|
237
|
-
|
|
238
|
-
### Quick Coverage Assessment
|
|
239
|
-
|
|
240
|
-
If a formal coverage tool is available:
|
|
241
|
-
```bash
|
|
242
|
-
# JavaScript (Istanbul/nyc)
|
|
243
|
-
npx nyc --reporter=text -- npm test -- --grep "target-module"
|
|
244
|
-
|
|
245
|
-
# Python (pytest-cov)
|
|
246
|
-
pytest --cov=target_module --cov-report=term-missing
|
|
247
|
-
|
|
248
|
-
# Go
|
|
249
|
-
go test -coverprofile=coverage.out ./target-package/...
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Manual Coverage Assessment
|
|
253
|
-
|
|
254
|
-
When coverage tools aren't available, assess manually:
|
|
255
|
-
|
|
256
|
-
1. **List all public functions/methods** in the target area
|
|
257
|
-
2. **Search for test files** that import or reference the target
|
|
258
|
-
3. **Check test assertions** — do they test behavior or just structure?
|
|
259
|
-
4. **Identify untested paths** — error handling, edge cases, default behavior
|
|
260
|
-
|
|
261
|
-
### Coverage-Based Planning Decisions
|
|
262
|
-
|
|
263
|
-
| Coverage Level | Planning Decision |
|
|
264
|
-
|---------------|-------------------|
|
|
265
|
-
| >80% | Proceed with test-gate. High confidence in behavior preservation. |
|
|
266
|
-
| 60-80% | Proceed with test-gate. Note gaps in refactor item descriptions for the pipeline to be cautious about. |
|
|
267
|
-
| 30-60% | Consider writing additional tests before refactoring as a normal `R-NNN` prerequisite item. Or use snapshot strategy for low-coverage areas. |
|
|
268
|
-
| <30% | Strongly recommend writing tests first. If user declines, use snapshot or manual strategy and flag as high risk. |
|
|
269
|
-
| 0% | WARN user explicitly. Recommend writing tests as a prerequisite. If user insists on proceeding, use manual strategy and document all known behaviors. |
|
|
270
|
-
|
|
271
|
-
### Adding Tests as a Prerequisite Item
|
|
272
|
-
|
|
273
|
-
When test coverage is insufficient, add a prerequisite refactor item using the normal `R-NNN` sequence. If the prerequisite is added before other generated items, it is usually `R-001`; downstream refactors depend on that ID.
|
|
274
|
-
|
|
275
|
-
```
|
|
276
|
-
Refactor Item R-001:
|
|
277
|
-
Title: Add test coverage for [target area] before refactoring
|
|
278
|
-
Type: restructure
|
|
279
|
-
Scope: [test files]
|
|
280
|
-
Priority: critical
|
|
281
|
-
Complexity: medium
|
|
282
|
-
Behavior Preservation: manual (no existing tests to gate against)
|
|
283
|
-
Acceptance Criteria:
|
|
284
|
-
- Test coverage for [target area] reaches >60%
|
|
285
|
-
- Tests cover: [list key behavior contracts]
|
|
286
|
-
- All new tests pass
|
|
287
|
-
Dependencies: none
|
|
288
|
-
```
|
|
166
|
+
Planning decisions:
|
|
289
167
|
|
|
290
|
-
|
|
168
|
+
- Strong relevant coverage: use `test-gate` and name the evidence source.
|
|
169
|
+
- Partial coverage: list uncovered paths and consider a prerequisite test item.
|
|
170
|
+
- No relevant coverage: prefer a prerequisite test item or a snapshot strategy.
|
|
171
|
+
- No viable automated evidence: use `manual`, document the verification protocol, and flag the risk.
|
|
291
172
|
|
|
292
|
-
|
|
173
|
+
A prerequisite test item remains a planning artifact. It must describe the missing contracts and measurable evidence without claiming the tests were already written or run.
|
|
293
174
|
|
|
294
|
-
##
|
|
175
|
+
## Plan-Readiness Checklist
|
|
295
176
|
|
|
296
|
-
Before
|
|
177
|
+
Before finalizing each refactor item, verify the plan states:
|
|
297
178
|
|
|
298
|
-
- [ ]
|
|
299
|
-
- [ ]
|
|
300
|
-
- [ ]
|
|
301
|
-
- [ ]
|
|
302
|
-
- [ ]
|
|
303
|
-
- [ ]
|
|
304
|
-
- [ ]
|
|
305
|
-
- [ ]
|
|
306
|
-
- [ ]
|
|
179
|
+
- [ ] the primary preservation strategy;
|
|
180
|
+
- [ ] the behavior contracts that must remain stable;
|
|
181
|
+
- [ ] the existing evidence sources, or an explicit `unknown`/missing-evidence statement;
|
|
182
|
+
- [ ] prerequisite evidence work when necessary;
|
|
183
|
+
- [ ] measurable post-change acceptance criteria;
|
|
184
|
+
- [ ] public interface and compatibility constraints;
|
|
185
|
+
- [ ] error, logging, configuration, and performance constraints when relevant;
|
|
186
|
+
- [ ] supplemental browser or manual evidence when automated evidence is insufficient;
|
|
187
|
+
- [ ] no claim that implementation or verification has already occurred.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Refactor Planner Error Recovery
|
|
2
|
+
|
|
3
|
+
Load this reference when validation fails, the planning session is interrupted, existing planning artifacts are detected, or the user exits before a valid final plan is produced.
|
|
4
|
+
|
|
5
|
+
## Validation Recovery
|
|
6
|
+
|
|
7
|
+
- Warnings only: present the warnings and ask whether to continue.
|
|
8
|
+
- Validation errors: group related errors, correct the planning draft, and regenerate. Limit automatic correction to three attempts before asking the user how to proceed.
|
|
9
|
+
- Keep `.prizmkit/plans/refactor-list.json` at the project-root `.prizmkit/plans/` path.
|
|
10
|
+
- Do not alter source code or run project tests while recovering a planning artifact.
|
|
11
|
+
|
|
12
|
+
## Resume Detection
|
|
13
|
+
|
|
14
|
+
| Artifact Found | Resume Point |
|
|
15
|
+
|---|---|
|
|
16
|
+
| No planning artifact | Phase 1: Project Context |
|
|
17
|
+
| Draft in `.prizmkit/plans/` | Phase matching the draft's completeness |
|
|
18
|
+
| Incomplete final refactor list | Phase 6: Completeness Review |
|
|
19
|
+
| Valid final refactor list | Mode D: Summary |
|
|
20
|
+
|
|
21
|
+
Read the artifact directly because `.prizmkit` content may be gitignored. Preserve existing valid entries and resume only the unfinished planning work.
|
|
22
|
+
|
|
23
|
+
## Session Exit Gate
|
|
24
|
+
|
|
25
|
+
Activate the exit gate when all of these are true:
|
|
26
|
+
|
|
27
|
+
- the user explicitly invoked `refactor-planner`;
|
|
28
|
+
- validation has not passed;
|
|
29
|
+
- no valid final refactor list was produced in this session.
|
|
30
|
+
|
|
31
|
+
Use `AskUserQuestion` with these options:
|
|
32
|
+
|
|
33
|
+
- **Continue to completion (Recommended)** — resume from the detected planning phase.
|
|
34
|
+
- **Save draft and exit** — save current planning content as `.prizmkit/plans/refactor-list.draft.json`.
|
|
35
|
+
- **Abandon** — exit without saving new planning content.
|
|
36
|
+
|
|
37
|
+
When saving a draft, state clearly that it is not validated and can be resumed by running `refactor-planner` again.
|
|
@@ -19,9 +19,9 @@ For each refactoring goal:
|
|
|
19
19
|
|
|
20
20
|
## Phase 5: Per-Item Confirmation Loop
|
|
21
21
|
|
|
22
|
-
For each item,
|
|
22
|
+
For each item, present the structured fields and use `AskUserQuestion` for the decision:
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```text
|
|
25
25
|
Refactor Item R-001:
|
|
26
26
|
Title: [title]
|
|
27
27
|
Type: [extract/rename/restructure/simplify/decouple/migrate]
|
|
@@ -35,15 +35,9 @@ Refactor Item R-001:
|
|
|
35
35
|
- [criterion 1]
|
|
36
36
|
- [criterion 2]
|
|
37
37
|
Dependencies: [none / R-002, R-003]
|
|
38
|
-
|
|
39
|
-
Confirm? (Y/modify/skip)
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
- **modify**: User provides changes, update item, re-display for confirmation
|
|
44
|
-
- **skip**: Remove item from the list
|
|
45
|
-
|
|
46
|
-
Continue until all items are confirmed or skipped.
|
|
40
|
+
Offer `Accept`, `Modify`, and `Skip` as selectable options. Re-display modified items before acceptance, and continue until all items are accepted or skipped.
|
|
47
41
|
|
|
48
42
|
---
|
|
49
43
|
|
|
@@ -83,9 +77,9 @@ Every item MUST declare a behavior preservation strategy. Read `${SKILL_DIR}/ref
|
|
|
83
77
|
|
|
84
78
|
| Strategy | When to Use |
|
|
85
79
|
|----------|-------------|
|
|
86
|
-
| `test-gate` |
|
|
87
|
-
| `snapshot` |
|
|
88
|
-
| `manual` | Human
|
|
80
|
+
| `test-gate` | Reliable tests cover the preserved contract; record the relevant evidence and the required downstream pass condition. |
|
|
81
|
+
| `snapshot` | Deterministic output or state can be compared; record representative inputs, normalization, and required equivalence. |
|
|
82
|
+
| `manual` | Human judgment is unavoidable; record a reproducible checklist and flag the higher verification risk. |
|
|
89
83
|
|
|
90
84
|
Flag items using `manual` strategy prominently — they carry the highest risk of behavior regression.
|
|
91
85
|
|
|
@@ -130,11 +124,11 @@ Anti-pattern: do not generate an all-high refactor list unless every item indepe
|
|
|
130
124
|
|
|
131
125
|
## Browser Verification
|
|
132
126
|
|
|
133
|
-
Browser verification is supported for UI-affecting refactors, but it is supplemental. Every refactor still uses `behavior_preservation.strategy` as the primary
|
|
127
|
+
Browser verification is supported for UI-affecting refactors, but it is supplemental. Every refactor still uses `behavior_preservation.strategy` as the primary preservation contract:
|
|
134
128
|
|
|
135
|
-
- `strategy: test-gate` —
|
|
136
|
-
- `strategy: snapshot` —
|
|
137
|
-
- `strategy: manual` —
|
|
129
|
+
- `strategy: test-gate` — Record the relevant existing tests and the required downstream pass condition.
|
|
130
|
+
- `strategy: snapshot` — Record the representative inputs, observable outputs, and allowed normalization for downstream comparison.
|
|
131
|
+
- `strategy: manual` — Record a reproducible human-verification checklist and the reason automated evidence is insufficient.
|
|
138
132
|
|
|
139
133
|
For refactors that modify UI code, add `browser_interaction.verify_steps` when visual or browser-flow verification is useful. Also keep behavior-preservation acceptance criteria explicit:
|
|
140
134
|
|
|
@@ -150,4 +144,4 @@ Acceptance Criteria:
|
|
|
150
144
|
4. Component is reusable in other views
|
|
151
145
|
```
|
|
152
146
|
|
|
153
|
-
The
|
|
147
|
+
The generated plan supplies this evidence contract to the autonomous refactor session; this planner does not execute the verification.
|
|
@@ -32,7 +32,7 @@ from datetime import datetime, timezone
|
|
|
32
32
|
|
|
33
33
|
SCHEMA_VERSION = "dev-pipeline-refactor-list-v1"
|
|
34
34
|
|
|
35
|
-
VALID_STATUSES = {"pending", "in_progress", "completed", "failed", "skipped"}
|
|
35
|
+
VALID_STATUSES = {"pending", "in_progress", "completed", "failed", "skipped", "auto_skipped"}
|
|
36
36
|
VALID_TYPES = {"extract", "rename", "restructure", "simplify", "decouple", "migrate"}
|
|
37
37
|
VALID_PRIORITIES = {"critical", "high", "medium", "low"}
|
|
38
38
|
VALID_COMPLEXITIES = {"low", "medium", "high"}
|