Requirements: analyze-wiring-verification
Status: APPROVED
Feature: Enhance /z:analyze and /zerg:design for full wiring verification
Created: 2026-02-02
Problem Statement
Three independent systems handle code quality verification with no overlap:
/z:analyze --check all — lint, complexity, coverage, security (no wiring, no dead code)
feature-dev:code-reviewer — AI semantic review (no wiring checks)
python -m zerg.validate_commands — wiring + Task ecosystem drift (not accessible via analyze)
Result: a module can pass all analyze checks while having zero production callers, circular imports, or broken context engineering splits. --check all doesn't actually check all.
Additionally, /zerg:rush does not validate that blocks/blockedBy/dependencies in task-graph.json reference real task IDs before execution, and /zerg:design doesn't mandate a quality gate as a final task.
Functional Requirements
FR-1: Dead code detection in --check all
- Add
DeadCodeChecker wrapping VultureAdapter from performance subsystem
vulture --min-confidence 80 as default
- Include in
--check all (currently dead code only runs under --performance)
- Configurable confidence threshold via
.zerg/config.yaml
FR-2: Wiring check via --check wiring
- Add
WiringChecker wrapping validate_module_wiring() from validate_commands.py
- Detect orphaned
.py modules with zero production imports
- Respect existing exemptions (
__init__.py, __main__.py, conftest.py, if __name__)
- Include in
--check all
FR-3: Cross-file semantic analysis
- Add
CrossFileChecker that walks AST across project
- Collect all exported symbols (functions, classes at module level)
- Collect all imports project-wide
- Report symbols exported but never imported by any other module
- Scope: Python files within
zerg/ package (not tests)
- Include in
--check all
FR-4: Project convention checking
- Add
ConventionsChecker that reads CLAUDE.md rules
- Check: bracketed Task prefixes (
[Plan], [L1], etc.) in command files
- Check: snake_case naming for Python modules
- Check: file organization rules (tests in
tests/, scripts in scripts/)
- Check: command files have Task ecosystem markers
- Include in
--check all
FR-5: Dependency graph validation in /zerg:rush
- Create
zerg/graph_validation.py with validate_graph_properties()
- Checks:
- All
dependencies reference existing task IDs → error if not
- No intra-level circular dependencies → error if found
- Orphan tasks (L2+ with no dependents) → warning
- Unreachable tasks (not reachable from L1 roots) → error
consumers fields reference real task IDs → error if not
- Tasks with non-empty
consumers must have integration_test set → error if missing
- Integrate into
rush.py after load_and_validate_task_graph() — fail-fast on errors, print warnings
- Also wire into
validation.py:load_and_validate_task_graph() as 4th validation step
FR-6: Import chain verification
- Add
ImportChainChecker with DFS on import graph
- Detect circular imports between modules
- Verify new module exports are consumed by at least one downstream module
- Report import depth (flag deep chains > configurable threshold, default 10)
- Include in
--check all
FR-7: Context engineering validation
- Add
ContextEngineeringChecker wrapping all 7 validate_commands.py checks:
- Task references in command files
- Backbone command depth (>= 3 Task refs)
- Split pair consistency (.core.md + .details.md)
- Split threshold (large files should be split)
- State JSON references have TaskList/TaskGet fallback
- Engineering rules valid
- Module wiring (overlaps FR-2 but includes full suite)
- Include in
--check all
FR-8: --check all means everything
--check all must run every registered checker — no exclusions
- Remove the
if k != "performance" filter at analyze.py:261
- Performance check included in
all alongside all new checks
- Individual checks still selectable via
--check <name>
FR-9: Print CLAUDE_CODE_TASK_LIST_ID
/zerg:design must print the CLAUDE_CODE_TASK_LIST_ID value whenever it sets or inherits it (so the user can see which task list workers will coordinate on)
/zerg:rush must print the CLAUDE_CODE_TASK_LIST_ID value at command start before any worker launches
- Format:
Task List ID: {value} in console output
- If not set, print
Task List ID: (default) to make implicit behavior visible
FR-10: Mandatory final analysis task in /zerg:design
- Every task graph generated by
/zerg:design must include a final Level 5 task
- Task runs
/z:analyze --check all --format json
- Task parses results and creates GitHub issues via
gh issue create for each failure
- Issues labeled
quality-gate + category name (e.g., lint, wiring, dead-code)
- Results logged to
.zerg/state/final-analysis.json
design.py validator must reject task graphs missing this final analysis task
- Template task embedded in
design.core.md Phase 5 instructions
Non-Functional Requirements
NFR-1: Performance
- All new checkers must complete within 60s for projects with < 200 Python files
- AST-based checkers (cross-file, import-chain) cache parsed ASTs to avoid double-parsing
NFR-2: Configurability
NFR-3: Output consistency
- All new checkers return
AnalysisResult with same schema as existing checkers
- All support text/json/sarif output formats
- SARIF output includes rule IDs for IDE integration
NFR-4: Testing
- Unit tests for each new checker
- Unit tests for graph validation
- Integration test for rush pre-execution validation
- Integration test for
--check all running all 10+ checks
NFR-5: Drift prevention
- New modules must have production callers (enforced by existing validate_commands)
- New modules must have integration tests
python -m zerg.validate_commands must pass after changes
Scope Boundaries
In scope
- 6 new checker classes in
zerg/commands/analyze.py
- 1 new module
zerg/graph_validation.py
- Updates to
rush.py, validation.py, design.core.md, design.py
- Config schema extension
- Command file updates
- Unit + integration tests
- CHANGELOG.md update
Out of scope
- JavaScript/TypeScript cross-file analysis (Python only for now)
- AI-powered semantic review (that's
feature-dev:code-reviewer's domain)
- Modifying
feature-dev:code-reviewer agent
- Performance audit refactoring (vulture stays in performance too)
Dependencies
vulture package (already used by VultureAdapter)
ast stdlib (for cross-file and import-chain analysis)
gh CLI (for GitHub issue creation in final analysis task)
- Existing
validate_commands.py (wrapping, not rewriting)
Acceptance Criteria
/z:analyze --check all runs 10+ checks (lint, complexity, coverage, security, performance, dead-code, wiring, cross-file, conventions, import-chain, context-engineering)
/z:analyze --check wiring runs wiring check standalone
/z:analyze --check dead-code detects unused Python code
/z:analyze --check cross-file reports exported-but-never-imported symbols
/z:analyze --check conventions validates CLAUDE.md rules compliance
/z:analyze --check import-chain detects circular imports
/z:analyze --check context-engineering runs all 7 validate_commands checks
/zerg:rush rejects task graphs with invalid dependency references
/zerg:rush warns on orphan tasks, errors on unreachable tasks
/zerg:design prints Task List ID: {value} when it sets/inherits the ID
/zerg:rush prints Task List ID: {value} at command start
/zerg:design output always includes L5 final analysis task
design.py validator rejects task graphs missing final analysis task
python -m zerg.validate_commands passes (no drift)
- All new modules have production callers and integration tests
Workstream Decomposition
WS1: Expand /z:analyze (parallel with WS2)
Files: zerg/commands/analyze.py, zerg/data/commands/analyze.md, .zerg/config.yaml
Tests: tests/unit/test_analyze_new_checks.py
WS2: Rush dependency validation (parallel with WS1)
Files: zerg/graph_validation.py (new), zerg/commands/rush.py, zerg/validation.py
Tests: tests/unit/test_graph_validation.py, tests/integration/test_rush_validation.py
WS3: Design mandatory final task (after WS1)
Files: zerg/data/commands/design.core.md, zerg/commands/design.py
Tests: validation via existing design.py test suite
Open Questions
None — all requirements specified by user.
1---2name: requirements-analyze-wiring-verification3description: Result: a module can pass all analyze checks while having zero production callers, circular imports, or broken context engineering splits. --check all doesn't actually check all.4---5# Requirements: analyze-wiring-verification67**Status: APPROVED**8**Feature**: Enhance `/z:analyze` and `/zerg:design` for full wiring verification9**Created**: 2026-02-021011---1213## Problem Statement1415Three independent systems handle code quality verification with no overlap:16- `/z:analyze --check all` — lint, complexity, coverage, security (no wiring, no dead code)17- `feature-dev:code-reviewer` — AI semantic review (no wiring checks)18- `python -m zerg.validate_commands` — wiring + Task ecosystem drift (not accessible via analyze)1920Result: a module can pass all analyze checks while having zero production callers, circular imports, or broken context engineering splits. `--check all` doesn't actually check all.2122Additionally, `/zerg:rush` does not validate that `blocks`/`blockedBy`/`dependencies` in task-graph.json reference real task IDs before execution, and `/zerg:design` doesn't mandate a quality gate as a final task.2324---2526## Functional Requirements2728### FR-1: Dead code detection in `--check all`29- Add `DeadCodeChecker` wrapping `VultureAdapter` from performance subsystem30- `vulture --min-confidence 80` as default31- Include in `--check all` (currently dead code only runs under `--performance`)32- Configurable confidence threshold via `.zerg/config.yaml`3334### FR-2: Wiring check via `--check wiring`35- Add `WiringChecker` wrapping `validate_module_wiring()` from `validate_commands.py`36- Detect orphaned `.py` modules with zero production imports37- Respect existing exemptions (`__init__.py`, `__main__.py`, `conftest.py`, `if __name__`)38- Include in `--check all`3940### FR-3: Cross-file semantic analysis41- Add `CrossFileChecker` that walks AST across project42- Collect all exported symbols (functions, classes at module level)43- Collect all imports project-wide44- Report symbols exported but never imported by any other module45- Scope: Python files within `zerg/` package (not tests)46- Include in `--check all`4748### FR-4: Project convention checking49- Add `ConventionsChecker` that reads CLAUDE.md rules50- Check: bracketed Task prefixes (`[Plan]`, `[L1]`, etc.) in command files51- Check: snake_case naming for Python modules52- Check: file organization rules (tests in `tests/`, scripts in `scripts/`)53- Check: command files have Task ecosystem markers54- Include in `--check all`5556### FR-5: Dependency graph validation in `/zerg:rush`57- Create `zerg/graph_validation.py` with `validate_graph_properties()`58- Checks:59 - All `dependencies` reference existing task IDs → error if not60 - No intra-level circular dependencies → error if found61 - Orphan tasks (L2+ with no dependents) → warning62 - Unreachable tasks (not reachable from L1 roots) → error63 - `consumers` fields reference real task IDs → error if not64 - Tasks with non-empty `consumers` must have `integration_test` set → error if missing65- Integrate into `rush.py` after `load_and_validate_task_graph()` — fail-fast on errors, print warnings66- Also wire into `validation.py:load_and_validate_task_graph()` as 4th validation step6768### FR-6: Import chain verification69- Add `ImportChainChecker` with DFS on import graph70- Detect circular imports between modules71- Verify new module exports are consumed by at least one downstream module72- Report import depth (flag deep chains > configurable threshold, default 10)73- Include in `--check all`7475### FR-7: Context engineering validation76- Add `ContextEngineeringChecker` wrapping all 7 `validate_commands.py` checks:77 1. Task references in command files78 2. Backbone command depth (>= 3 Task refs)79 3. Split pair consistency (.core.md + .details.md)80 4. Split threshold (large files should be split)81 5. State JSON references have TaskList/TaskGet fallback82 6. Engineering rules valid83 7. Module wiring (overlaps FR-2 but includes full suite)84- Include in `--check all`8586### FR-8: `--check all` means everything87- `--check all` must run every registered checker — no exclusions88- Remove the `if k != "performance"` filter at `analyze.py:261`89- Performance check included in `all` alongside all new checks90- Individual checks still selectable via `--check <name>`9192### FR-9: Print CLAUDE_CODE_TASK_LIST_ID93- `/zerg:design` must print the `CLAUDE_CODE_TASK_LIST_ID` value whenever it sets or inherits it (so the user can see which task list workers will coordinate on)94- `/zerg:rush` must print the `CLAUDE_CODE_TASK_LIST_ID` value at command start before any worker launches95- Format: `Task List ID: {value}` in console output96- If not set, print `Task List ID: (default)` to make implicit behavior visible9798### FR-10: Mandatory final analysis task in `/zerg:design`99- Every task graph generated by `/zerg:design` must include a final Level 5 task100- Task runs `/z:analyze --check all --format json`101- Task parses results and creates GitHub issues via `gh issue create` for each failure102- Issues labeled `quality-gate` + category name (e.g., `lint`, `wiring`, `dead-code`)103- Results logged to `.zerg/state/final-analysis.json`104- `design.py` validator must reject task graphs missing this final analysis task105- Template task embedded in `design.core.md` Phase 5 instructions106107---108109## Non-Functional Requirements110111### NFR-1: Performance112- All new checkers must complete within 60s for projects with < 200 Python files113- AST-based checkers (cross-file, import-chain) cache parsed ASTs to avoid double-parsing114115### NFR-2: Configurability116- New `.zerg/config.yaml` section for analyze settings:117 ```yaml118 analyze:119 dead_code:120 min_confidence: 80121 wiring:122 strict: false123 exclude_patterns: []124 cross_file:125 scope: "zerg/"126 conventions:127 naming: snake_case128 require_task_prefixes: true129 import_chain:130 max_depth: 10131 context_engineering:132 auto_split: false133 ```134135### NFR-3: Output consistency136- All new checkers return `AnalysisResult` with same schema as existing checkers137- All support text/json/sarif output formats138- SARIF output includes rule IDs for IDE integration139140### NFR-4: Testing141- Unit tests for each new checker142- Unit tests for graph validation143- Integration test for rush pre-execution validation144- Integration test for `--check all` running all 10+ checks145146### NFR-5: Drift prevention147- New modules must have production callers (enforced by existing validate_commands)148- New modules must have integration tests149- `python -m zerg.validate_commands` must pass after changes150151---152153## Scope Boundaries154155### In scope156- 6 new checker classes in `zerg/commands/analyze.py`157- 1 new module `zerg/graph_validation.py`158- Updates to `rush.py`, `validation.py`, `design.core.md`, `design.py`159- Config schema extension160- Command file updates161- Unit + integration tests162- CHANGELOG.md update163164### Out of scope165- JavaScript/TypeScript cross-file analysis (Python only for now)166- AI-powered semantic review (that's `feature-dev:code-reviewer`'s domain)167- Modifying `feature-dev:code-reviewer` agent168- Performance audit refactoring (vulture stays in performance too)169170---171172## Dependencies173174- `vulture` package (already used by VultureAdapter)175- `ast` stdlib (for cross-file and import-chain analysis)176- `gh` CLI (for GitHub issue creation in final analysis task)177- Existing `validate_commands.py` (wrapping, not rewriting)178179---180181## Acceptance Criteria1821831. `/z:analyze --check all` runs 10+ checks (lint, complexity, coverage, security, performance, dead-code, wiring, cross-file, conventions, import-chain, context-engineering)1842. `/z:analyze --check wiring` runs wiring check standalone1853. `/z:analyze --check dead-code` detects unused Python code1864. `/z:analyze --check cross-file` reports exported-but-never-imported symbols1875. `/z:analyze --check conventions` validates CLAUDE.md rules compliance1886. `/z:analyze --check import-chain` detects circular imports1897. `/z:analyze --check context-engineering` runs all 7 validate_commands checks1908. `/zerg:rush` rejects task graphs with invalid dependency references1919. `/zerg:rush` warns on orphan tasks, errors on unreachable tasks19210. `/zerg:design` prints `Task List ID: {value}` when it sets/inherits the ID19311. `/zerg:rush` prints `Task List ID: {value}` at command start19412. `/zerg:design` output always includes L5 final analysis task19513. `design.py` validator rejects task graphs missing final analysis task19614. `python -m zerg.validate_commands` passes (no drift)19715. All new modules have production callers and integration tests198199---200201## Workstream Decomposition202203### WS1: Expand /z:analyze (parallel with WS2)204Files: `zerg/commands/analyze.py`, `zerg/data/commands/analyze.md`, `.zerg/config.yaml`205Tests: `tests/unit/test_analyze_new_checks.py`206207### WS2: Rush dependency validation (parallel with WS1)208Files: `zerg/graph_validation.py` (new), `zerg/commands/rush.py`, `zerg/validation.py`209Tests: `tests/unit/test_graph_validation.py`, `tests/integration/test_rush_validation.py`210211### WS3: Design mandatory final task (after WS1)212Files: `zerg/data/commands/design.core.md`, `zerg/commands/design.py`213Tests: validation via existing design.py test suite214215---216217## Open Questions218219None — all requirements specified by user.