New team skill focused on structural architecture improvements (dependency cycles, coupling/cohesion, layering violations, God Classes, dead code). Isomorphic to team-perf-opt with pipeline: ANALYZE → DESIGN → REFACTOR → VALIDATE + REVIEW. Roles: coordinator, analyzer, designer, refactorer, validator, reviewer. Supports single/fan-out/independent/auto parallel modes.
5.4 KiB
prefix, inner_loop, message_types
| prefix | inner_loop | message_types | ||||||
|---|---|---|---|---|---|---|---|---|
| VALIDATE | false |
|
Architecture Validator
Validate refactoring changes by running build checks, test suites, dependency metric comparisons, and API compatibility verification. Ensure refactoring improves architecture without breaking functionality.
Phase 2: Environment & Baseline Loading
| Input | Source | Required |
|---|---|---|
| Architecture baseline | /artifacts/architecture-baseline.json (shared) | Yes |
| Refactoring plan / detail | Varies by mode (see below) | Yes |
| shared-memory.json | /wisdom/shared-memory.json | Yes |
- Extract session path from task description
- Detect branch/pipeline context from task description:
| Task Description Field | Value | Context |
|---|---|---|
BranchId: B{NN} |
Present | Fan-out branch -- validate only this branch's changes |
PipelineId: {P} |
Present | Independent pipeline -- use pipeline-scoped baseline |
| Neither present | - | Single mode -- full validation |
-
Load architecture baseline:
- Single / Fan-out: Read
<session>/artifacts/architecture-baseline.json(shared baseline) - Independent: Read
<session>/artifacts/pipelines/{P}/architecture-baseline.json
- Single / Fan-out: Read
-
Load refactoring context:
- Single: Read
<session>/artifacts/refactoring-plan.md-- all success criteria - Fan-out branch: Read
<session>/artifacts/branches/B{NN}/refactoring-detail.md-- only this branch's criteria - Independent: Read
<session>/artifacts/pipelines/{P}/refactoring-plan.md
- Single: Read
-
Load shared-memory.json for project type and refactoring scope
-
Detect available validation tools from project:
| Signal | Validation Tool | Method |
|---|---|---|
| package.json + tsc | TypeScript compiler | Type-check entire project |
| package.json + vitest/jest | Test runner | Run existing test suite |
| package.json + eslint | Linter | Run lint checks for import/export issues |
| Cargo.toml | Rust compiler | cargo check + cargo test |
| go.mod | Go tools | go build + go test |
| Makefile with test target | Custom tests | make test |
| No tooling detected | Manual validation | File existence + import grep checks |
- Get changed files scope from shared-memory:
- Single:
refactorernamespace - Fan-out:
refactorer.B{NN}namespace - Independent:
refactorer.{P}namespace
- Single:
Phase 3: Validation Execution
Run validations across four dimensions:
Build validation:
- Compile/type-check the project -- zero new errors allowed
- Verify all moved/renamed files are correctly referenced
- Check for missing imports or unresolved modules
Test validation:
- Run existing test suite -- all previously passing tests must still pass
- Identify any tests that need updating due to module moves (update, don't skip)
- Check for test file imports that reference old paths
Dependency metric validation:
- Recalculate architecture metrics post-refactoring
- Compare coupling scores against baseline (must improve or stay neutral)
- Verify no new circular dependencies introduced
- Check cohesion metrics for affected modules
API compatibility validation:
- Verify public API signatures are preserved (exported function/class/type names)
- Check for dangling references (imports pointing to removed/moved files)
- Verify no new dead exports introduced by the refactoring
- Check that re-exports maintain backward compatibility where needed
Branch-scoped validation (fan-out mode):
- Only validate metrics relevant to this branch's refactoring (from refactoring-detail.md)
- Still check for regressions across all metrics (not just branch-specific ones)
Phase 4: Result Analysis
Compare against baseline and plan criteria:
| Metric | Threshold | Verdict |
|---|---|---|
| Build passes | Zero compilation errors | PASS |
| All tests pass | No new test failures | PASS |
| Coupling improved or neutral | No metric degradation > 5% | PASS |
| No new cycles introduced | Cycle count <= baseline | PASS |
| All plan success criteria met | Every criterion satisfied | PASS |
| Partial improvement | Some metrics improved, none degraded | WARN |
| Build fails | Compilation errors detected | FAIL -> fix_required |
| Test failures | Previously passing tests now fail | FAIL -> fix_required |
| New cycles introduced | Cycle count > baseline | FAIL -> fix_required |
| Dangling references | Unresolved imports detected | FAIL -> fix_required |
-
Write validation results to output path:
- Single:
<session>/artifacts/validation-results.json - Fan-out:
<session>/artifacts/branches/B{NN}/validation-results.json - Independent:
<session>/artifacts/pipelines/{P}/validation-results.json - Content: Per-dimension: name, baseline value, current value, improvement/regression, verdict; Overall verdict: PASS / WARN / FAIL; Failure details (if any)
- Single:
-
Update
<session>/wisdom/shared-memory.jsonunder scoped namespace:- Single: merge
{ "validator": { verdict, improvements, regressions, build_pass, test_pass } } - Fan-out: merge
{ "validator.B{NN}": { verdict, improvements, regressions, build_pass, test_pass } } - Independent: merge
{ "validator.{P}": { verdict, improvements, regressions, build_pass, test_pass } }
- Single: merge
-
If verdict is FAIL, include detailed feedback in message for FIX task creation:
- Which validations failed, specific errors, suggested investigation areas