--- name: lyrebird_review_cycle description: Full codebase review cycle for Lyrebird — architecture/consistency, Swift code quality, and documentation accuracy. Sweeps all of Sources/, not just a diff. Use periodically and before major merges. --- # Lyrebird Review Cycle Run a comprehensive whole-codebase review across three dimensions, then report findings and fix any stale docs. ## Phase 1: Gather Context 1. Run `git branch --show-current` to note the branch name 2. Run `swift test --no-parallel 2>&1` to confirm the test suite is green (the default parallel runner hits a known xctest-teardown SIGABRT on multi-engine combos — see `memory/project_parallel_test_crash.md`; `--no-parallel` is the canonical full-suite command) If tests fail, report the failures immediately and **stop** — do not proceed to reviews. ## Phase 2: Parallel Reviews Launch **all three agents in a single message** (three Agent tool calls): ### Agent A — Lyrebird Architecture & Consistency (`lyrebird_architect_agent`) ``` Perform a comprehensive architecture and code-reuse audit of the Lyrebird project at /Users/josh/Documents/LyrebirdII. Goals: 1. Identify duplicate or near-duplicate patterns across generators and modules that should be consolidated into shared helpers or base classes 2. Check naming consistency — do public API names align with SuperCollider conventions where intended? Are there inconsistencies between similar generators? 3. Check interface consistency — parameter naming conventions (mul/add, freq/cutoff, q/resonance), init parameter order, return types 4. Identify generators or modules that deviate from the _Base / GeneratorBase pattern without good reason 5. Find public API surface that looks accidental (types or methods that are public but should be internal/private) 6. Check that GeneratorEnum conformance is present for all paired (Audio+Control) generators 7. Look for architectural risks — things that could become hard to maintain as the project grows 8. Check the doc map in CLAUDE.md — are all modules covered? Start by reading CLAUDE.md and docs/00-working-order.md for current state, then explore Sources/ for the actual code. Produce a concise findings report: grouped by category, each finding with file path, line number, and specific recommendation. Analysis only — do not modify any files. ``` ### Agent B — Swift Code Quality (`general-purpose` agent) ``` Perform a Swift code quality review of the Lyrebird audio synthesis framework at /Users/josh/Documents/LyrebirdII/Sources/. This is a macOS 15+, Swift 6, swift-tools-version 6.0 project. Read CLAUDE.md first for hard constraints and style rules. Review for: 1. Force unwraps (`!` on optionals, `try!`) — project bans these 2. Magic numbers — non-trivial literals without named constants (exempt: 0, 1, -1, 2 in obvious arithmetic) 3. Access control — anything unexpectedly public, missing private/internal 4. Swift 6 concurrency correctness — Sendable, actor isolation, nonisolated, @unchecked Sendable usage without invariant comments 5. Long functions (>60 lines) that do too many things 6. Error handling gaps — missing throws/try patterns at system boundaries 7. Missed Swift idioms — nested if instead of guard, missing defer, compactMap opportunities 8. Naming deviations — types not UpperCamelCase, methods/vars not lowerCamelCase 9. Dead code — unreachable branches, unused variables, commented-out blocks Focus on Sources/Lyrebird/ and Sources/LyrebirdUI/. Skip test files and legacy/ directory. For each finding: file path (relative to project root), approximate line number, severity (bug/risk/nit), problem, concrete fix. Do NOT report RT thread safety or Lyrebird-protocol-specific issues — those are handled by the architecture agent. Be thorough but skip trivial/obvious style nits. Report genuinely actionable findings only. ``` ### Agent C — RT Audio Correctness (`lyrebird_review_agent`) ``` @workspace Perform a full RT-safety and protocol-correctness sweep of the Lyrebird project at /Users/josh/Documents/LyrebirdII/Sources/Lyrebird/. Read CLAUDE.md first for all hard constraints. Apply the Lyrebird-specific review rules from your agent instructions across the entire Sources/Lyrebird/ directory: - RT thread safety: no allocation, deallocation, or locking in _computeSamples or the render callback - Bus memory rules: no dynamic resizing after engine start - Generator/Synthesizer protocol correctness: _Base pattern, GeneratorBase, _setupSubBlockBuffer, calculatedSamples overrides - Shared helper usage: applyIfNeeded, fillRampedResult, xorshift64NextRaw — never inline - Scheduling model compliance: no ARC on RT thread, correct SPSCQueue usage - Test coverage: new generator types have corresponding tests Do NOT summarize what code does — only report problems with file paths, line numbers, and concrete fixes. ``` ## Phase 3: Documentation Check and Update After all three reviews complete, verify and fix project documentation: 1. Check `CLAUDE.md` doc map — do all active modules have a row? 2. Check `docs/00-working-order.md` — does it correctly reflect which phases are complete? 3. For any stale doc found: **edit it directly** using the Edit tool. Do not just report the gap. 4. Keep edits focused — match the existing writing style. Do not rewrite docs that are accurate. ## Phase 4: Synthesis Report Present a single unified report: ### Blocking (must fix before merging) - RT safety violations, protocol correctness failures, bus rule violations, test coverage gaps - Source: Agent C (lyrebird_review_agent) - Include: file path, line number, concrete fix ### Architecture & Consistency - Duplicate patterns, API inconsistencies, missing conformances, public API surface issues - Source: Agent A (lyrebird_architect_agent) - Include: file path and specific recommendation ### Swift Code Quality - Magic numbers, access control, concurrency, long functions, error handling gaps, naming - Source: Agent B (Swift quality agent) - Include: file path, line number, severity, suggested fix ### Documentation Updated - List each doc file edited and summarize what changed - If no docs needed updating: "All documentation is current" ### Verdict - One line: "No issues found", "Needs N fixes", or "Significant rework needed" - Prioritised next steps If no issues are found in a category, say so explicitly.