Bundled hygiene commit before cycle-3 /implement (AZ-776, AZ-777). Mixes two concerns by user choice (autodev option B): - Cycle-3 autodev artifacts not yet committed by Step 9 (new-task): task specs for AZ-776 / AZ-777 under _docs/02_tasks/todo/ and the updated _docs/02_tasks/_dependencies_table.md. - Accumulated skill / rule tooling maintenance under .cursor/ (skills: autodev, code-review, decompose, deploy, implement, new-task, plan, refactor, retrospective, test-spec; rules: coderule, cursor-meta, meta-rule, testing; new release skill scaffolding). - Autodev bootstrap state: _docs/_autodev_state.md (step 10 in_progress) and _docs/_process_leftovers/2026-05-11_d_cross_cve_1_opencv_pin_deferred.md (replay timestamp refreshed; gtsam 4.2 still numpy<2-only). Co-authored-by: Cursor <cursoragent@cursor.com>
14 KiB
Phase 2: Analysis & Task Decomposition
Role: Researcher, software architect, and task planner Goal: Research improvements, produce a refactoring roadmap, and decompose into implementable tasks Constraints: Analysis and planning only — no code changes
2a. Deep Research
-
Analyze current implementation patterns
-
Extract the Project Constraint Matrix from
problem.md,restrictions.md,acceptance_criteria.md, current architecture/docs, and actual code constraints. Include required inputs/outputs, operating context, lifecycle assumptions, integration boundaries, non-functional targets, and hard disqualifiers. -
Research modern approaches for similar systems
-
For each alternative pattern/library/service/architecture/algorithm, research intrinsic implementation constraints: required inputs/outputs, runtime assumptions, supported deployment modes, resource needs, operational limits, licensing/security constraints, and known failure reports.
API Capability Verification — Per-Mode (MANDATORY, BLOCKING for proposed replacements)
When a refactor recommendation replaces (or adds) a library/SDK/framework/service, the same per-mode verification used by
/researchStep 2 applies — selecting a replacement on category fit alone is the same silent-failure path. For every replacement candidate that has multiple modes or configurations:- Pin the exact mode/configuration the refactored code will use, in one explicit sentence. Inputs (data shapes, sensor counts, payloads, rates), outputs (per
acceptance_criteria.mdand contract files), runtime (matching the project's deployment). - Run
context7(or equivalent docs lookup) for the candidate. Mandatory for every replacement library/SDK/framework candidate, not optional. Minimum three queries per candidate: mode enumeration, project's exact mode (with input/output shapes), disqualifier probe ("does this mode produce the required output? are there published limitations on this runtime?"). Append URLs toRUN_DIR/analysis/research_findings.mdreferences section. - Save a Minimum Viable Example (MVE) for the pinned mode under
RUN_DIR/analysis/mve_evidence.mdwith: source, inputs in example, outputs in example, project inputs, project outputs required, match assessment ✅/⚠️/❌. If no official example covers the project's exact configuration, the recommendation cannot beSelectedbased on category fit alone — it must beExperimental only(with required-evidence note) orRejected. - Treat "the same library in a different mode" as a different recommendation. If the project's pinned mode is
<X>but the only documented evidence covers<Y>, do not silently soften the description. Open a separate recommendation row, with its own MVE, fit assessment, and disqualifiers. - Common silent-failure pattern: a fact summary paraphrases docs as "supports A, B, C, D modes" when the docs actually mean "supports A; B; C and D as separate orthogonal modes" — no
A+Bcombination exists. Cross-check paraphrased capability claims against the literal mode enumeration.
- Pin the exact mode/configuration the refactored code will use, in one explicit sentence. Inputs (data shapes, sensor counts, payloads, rates), outputs (per
-
Identify what could be done differently
-
Suggest improvements only when they fit the Project Constraint Matrix. A cleaner or more modern approach that violates product constraints must be marked
RejectedorExperimental only, not added as a roadmap recommendation.
Write RUN_DIR/analysis/research_findings.md:
- Current state analysis: patterns used, strengths, weaknesses
- Alternative approaches per component: current vs alternative, pros/cons, migration effort
- Prioritized recommendations: quick wins + strategic improvements
- Constraint-fit table: recommendation, pinned mode/config, constraints checked, API capability evidence (MVE link), evidence, mismatches/disqualifiers, status (
Selected/Rejected/Experimental only/Needs user decision) - For every recommendation that replaces or adds a library/SDK/framework, append a Restrictions × Candidate-Mode sub-matrix that walks every numbered line of
restrictions.mdandacceptance_criteria.mdagainst the candidate's pinned mode, marking each cell ✅ Pass / ❌ Fail / ❓ Verify / N/A with cited evidence. A recommendation cannot beSelectedwhile any cell is ❌ or ❓.
2b. Solution Assessment & Hardening Tracks
- Assess current implementation against acceptance criteria
- Identify weak points in codebase, map to specific code areas
- Perform gap analysis: acceptance criteria vs current state
- Prioritize changes by impact and effort
- Reject or escalate any proposed refactor that improves code structure while weakening required behavior, integration contracts, runtime constraints, safety/security posture, or acceptance criteria
2b.1. ADR Superseding Gate (BLOCKING)
A refactor that improves code structure while overturning a documented architecture decision is the silent-drift class the project repeatedly burns on (see meta-rule.mdc § GPS-passthrough postmortem and the auto-lessons it produced). This gate makes drift visible and forces a deliberate ADR update.
-
List candidate ADRs: read every
Status: Acceptedfile in_docs/02_document/adr/. If the directory does not exist or contains only the index, logNo ADRs in scopetoRUN_DIR/analysis/adr_impact.mdand skip the rest of this gate. -
Diff each candidate against the proposed refactor roadmap: for each ADR, ask the same two questions as code-review Phase 7:
- Violation: does any roadmap item do the opposite of the ADR's
Decision? - Drift: does any roadmap item materially affect the ADR's
Consequences(positive or negative) without contradicting the Decision outright?
- Violation: does any roadmap item do the opposite of the ADR's
-
Classify each impacted ADR in
RUN_DIR/analysis/adr_impact.md:ADR Roadmap item Impact Required action NNN roadmap-item-NNViolation / Drift / Aligned (filled by Choose A/B/C below) -
For every Violation row, present a BLOCKING Choose:
══════════════════════════════════════ DECISION REQUIRED: Refactor would violate ADR-NNN (<title>) ══════════════════════════════════════ A) Update the ADR via supersede: the refactor produces a NEW ADR (`Supersedes: NNN`) capturing the new Decision, and ADR-NNN's `Superseded by` field is updated. The supersede ADR is itself a deliverable of this refactor run (added to RUN_DIR/analysis/adr_impact.md and to TASKS_DIR as a task) and must be `Accepted` before Phase 4. B) Reduce the refactor scope to NOT violate ADR-NNN C) Re-evaluate ADR-NNN: keep the refactor but only after ADR-NNN is formally re-opened in a new /plan Step 4.5 round ══════════════════════════════════════ Recommendation: A — supersede is the only path that keeps the audit trail intact while letting the refactor land ══════════════════════════════════════ -
For every Drift row: do not block, but the roadmap item must include a
## ADR Impactsection in its task spec citing the affected ADR(s). The implementer surfaces this at code-review Phase 7, which would otherwise classify the change as ADR-Drift (High) without context. -
For every Aligned row: cite the ADR in the roadmap item's task spec under
## ADR Compliance. No further action. -
Self-supersede deliverable: any Choose A path adds a
[##]_supersede_adr_NNN.mdtask file to the refactor run's TASKS_DIR with the new ADR text drafted (using.cursor/skills/plan/templates/adr.md). The task's only Acceptance Criterion is "ADR file exists at_docs/02_document/adr/<next>_<slug>.mdwithStatus: Accepted, ADR-NNN'sSuperseded byfield updated, and_docs/02_document/adr/README.mdindex reflects both."
Present optional hardening tracks for user to include in the roadmap:
══════════════════════════════════════
DECISION REQUIRED: Include hardening tracks?
══════════════════════════════════════
A) Technical Debt — identify and address design/code/test debt
B) Performance Optimization — profile, identify bottlenecks, optimize
C) Security Review — OWASP Top 10, auth, encryption, input validation
D) All of the above
E) None — proceed with structural refactoring only
══════════════════════════════════════
For each selected track, add entries to RUN_DIR/list-of-changes.md (append to the file produced in Phase 1):
- Track A: tech debt items with location, impact, effort
- Track B: performance bottlenecks with profiling data
- Track C: security findings with severity and fix description
Write RUN_DIR/analysis/refactoring_roadmap.md:
- Weak points assessment: location, description, impact, proposed solution
- Gap analysis: what's missing, what needs improvement
- Phased roadmap: Phase 1 (critical fixes), Phase 2 (major improvements), Phase 3 (enhancements)
- Selected hardening tracks and their items
- Applicability gate: each roadmap item must state constraint fit, mismatches, required evidence, and status (
Selected/Rejected/Experimental only/Needs user decision)
BLOCKING applicability gate: Before 2c and 2d, every recommendation in the roadmap must be Selected. Items marked Rejected are excluded. Items marked Experimental only or Needs user decision require a user decision before task creation.
BLOCKING ADR-supersede gate: Before 2c and 2d, every Violation row in RUN_DIR/analysis/adr_impact.md (from 2b.1) must be resolved via Choose A, B, or C. A Violation row with no chosen path blocks task creation.
2c. Create Epic
Create a work item tracker epic for this refactoring run:
- Epic name: the RUN_DIR name (e.g.,
01-testability-refactoring) - Create the epic via configured tracker MCP
- Record the Epic ID — all tasks in 2d will be linked under this epic
- If tracker is unavailable, follow
.cursor/rules/tracker.mdc; only usePENDINGplaceholders if the user explicitly choosestracker: local
2d. Task Decomposition
Convert the finalized RUN_DIR/list-of-changes.md into implementable task files.
- Read
RUN_DIR/list-of-changes.md - For each change entry (or group of related entries), create an atomic task file in TASKS_DIR:
- Use the standard task template format (
.cursor/skills/decompose/templates/task.md) - File naming:
[##]_refactor_[short_name].md(temporary numeric prefix) - Task:
PENDING_refactor_[short_name] - Description: derived from the change entry's Problem + Change fields
- Complexity: estimate 1-5 points; split into multiple tasks if >5
- Dependencies: map change-level dependencies (C01, C02) to task-level tracker IDs
- Component: from the change entry's File(s) field
- Epic: the epic created in 2c
- Acceptance Criteria: derived from the change entry — verify the problem is resolved
- Use the standard task template format (
- Create work item ticket for each task under the epic from 2c
- Rename each file to
[TRACKER-ID]_refactor_[short_name].mdafter ticket creation - Update or append to
TASKS_DIR/_dependencies_table.mdwith the refactoring tasks
Self-verification:
- All acceptance criteria are addressed in gap analysis
- Recommendations are grounded in actual code, not abstract
- Every recommendation has been checked against the Project Constraint Matrix
- No recommendation violates product restrictions, acceptance criteria, documented architecture decisions, or actual code integration boundaries
- Every replacement library/SDK/framework recommendation has a pinned mode/config, a saved MVE in
mve_evidence.md, and a Restrictions × Candidate-Mode sub-matrix with no ❌ or ❓ cells context7(or equivalent) was consulted for every replacement library/SDK/framework recommendation- Paraphrased capability claims have been cross-checked against the literal mode-enumeration evidence (no
A, B → A+Bstyle conflation) - Rejected and experimental approaches are documented but not converted into implementation tasks without user approval
- Roadmap phases are prioritized by impact
- Epic created and all tasks linked to it
- Every entry in list-of-changes.md has a corresponding task file in TASKS_DIR
- No task exceeds 5 complexity points
- Task dependencies are consistent (no circular dependencies)
_dependencies_table.mdincludes all refactoring tasks- Every task has a work item ticket (or PENDING placeholder)
- If
_docs/02_document/adr/exists with Accepted ADRs,RUN_DIR/analysis/adr_impact.mdhas been written and every Violation row is resolved (A/B/C) — no implicit overrides - For every Violation resolved via Choose A, a
[##]_supersede_adr_NNN.mdtask exists in TASKS_DIR with the drafted supersede ADR - For every Drift row, the corresponding roadmap-item task spec has a
## ADR Impactsection - For every Aligned row, the corresponding roadmap-item task spec has a
## ADR Compliancesection
Save action: Write analysis artifacts to RUN_DIR, task files to TASKS_DIR
BLOCKING: Present refactoring roadmap and task list to user. Do NOT proceed until user confirms.
Quick Assessment mode stops here. Present final summary and write FINAL_report.md with phases 0-2 content.