Files

8.2 KiB

name, description
name description
lyrebird_external_review Run a Lyrebird RT-safety and protocol-correctness review on an out-of-tree Swift package that depends on Lyrebird — custom Generators, Synthesizers, pedals, effects, or any code that runs on the audio render thread. Use this in projects that import Lyrebird but live OUTSIDE the Lyrebird repo (e.g. ShoeGaze, third-party extension packages). Invokes lyrebird_review_agent against the project's diff and the vendored Lyrebird checkout. Do not use inside the Lyrebird repo itself — use lyrebird_review there.

Lyrebird External Review

Run a strict Lyrebird review of changes in an out-of-tree Swift package that depends on the Lyrebird core module. This is the sibling of lyrebird_review, adapted for projects that live outside the Lyrebird repository — they have no main-branch phase workflow, no docs/00-working-order.md, and no agent/skill mirror to keep in sync, but they DO build Generator / Synthesizer implementations that run on the real-time audio thread and must obey the same hard constraints.

This review enforces the constraints that survive the repo boundary:

  • No allocation, deallocation, locking, blocking, print, String construction, or is / as? runtime type checks on the RT render thread
  • No force unwraps (!, try!) in render-path code
  • Correct Generator / Synthesizer / GeneratorBase protocol conformance
  • Pre-allocated, never-resized buffers; _checkCount(count) as the first line of every _computeSamples; no grow path
  • Proper use of Lyrebird's shared RT-safe helpers instead of re-inlined boilerplate
  • Input classification (generator vs scalar) at init, never on the RT thread
  • Test coverage for every new public Generator (a deterministic input→output assertion, not only an integration "not silent" check)

It deliberately does not enforce Lyrebird-internal repo conventions that cannot apply to an external package: the Sources/Lyrebird/ subfolder taxonomy, phase-history / working-order docs, the agent/skill mirror sync, or Lyrebird's exact SPDX header text. Those are flagged (if at all) as nits against the project's own conventions, never as blockers.

Step 0: Confirm context and locate the Lyrebird reference checkout

This skill is for a package that imports Lyrebird, not the Lyrebird repo. Sanity-check:

# Should find a Lyrebird dependency, NOT be the Lyrebird package itself.
grep -RInE 'Lyrebird' Package.swift 2>/dev/null | head
test -f Package.swift && ! grep -qE 'name:\s*"Lyrebird"\s*,' Package.swift && echo "OK: external package" || echo "WARNING: looks like the Lyrebird repo — use lyrebird_review instead"

The architecture agent compares against canonical Lyrebird source. For SwiftPM projects this is resolved under .build/checkouts/Lyrebird/Sources/Lyrebird/. Make sure it exists:

LYREBIRD_REF="$(pwd)/.build/checkouts/Lyrebird/Sources/Lyrebird"
if [ ! -d "$LYREBIRD_REF" ]; then
    echo "Reference checkout missing — running 'swift build' to resolve dependencies..."
    swift build >/dev/null 2>&1 || true
fi
test -d "$LYREBIRD_REF" && echo "Reference: $LYREBIRD_REF" || echo "No vendored Lyrebird checkout found — agent will review without canonical comparison."

If the project vendors Lyrebird differently (git submodule, sibling path, Xcode workspace), ask the user for the path to the Lyrebird Sources/Lyrebird directory and pass that as the reference instead.

Step 1: Build the review diff

External repos do not follow Lyrebird's main... branch model — changes may be uncommitted, untracked, or on an arbitrary branch. Capture everything under review.

  • If the user names a base ref (branch, tag, commit), diff against it:
    git diff --no-color <base> > review.diff
    
  • Otherwise (default — review all local changes, committed-or-not, including new files):
    # Intent-add untracked files so they appear in the diff as additions.
    git add -N $(git ls-files --others --exclude-standard) 2>/dev/null || true
    git diff --no-color HEAD > review.diff 2>/dev/null || git diff --no-color > review.diff
    git reset -q 2>/dev/null || true        # undo the intent-to-add; leaves working tree untouched
    wc -l review.diff
    

If review.diff is empty, stop and report that there is nothing to review (the changes may already be committed and merged — ask the user for a base ref to diff against).

Step 2: Run the tests

Use the project's own test command. For a SwiftPM package that is swift test. If the suite exercises multi-engine or multi-core paths it can hit Lyrebird's known parallel-teardown flake (_ContiguousArrayStorage retain count) — add --no-parallel in that case.

swift test 2>&1        # or: swift test --no-parallel 2>&1

If tests fail, report the failures and stop — do not proceed to review until the suite is green.

Step 3: Run reviews in parallel

Launch both agents in a single message (two Agent tool calls).

Agent A — Lyrebird RT-safety / protocol review (lyrebird_review_agent)

Pass the diff path and the reference checkout path. Use a prompt of this shape (fill in the real paths and branch name):

Working directory: <project root>. This is an OUT-OF-TREE Swift package that depends on the
Lyrebird core module — it is NOT the Lyrebird repository. The diff under review is at
<project root>/review.diff. Canonical Lyrebird source for comparison is at
<LYREBIRD_REF> (e.g. .build/checkouts/Lyrebird/Sources/Lyrebird) — read from it to verify
protocol shapes, helper signatures, and to compare new Generators against close analogs
(e.g. Generators/Analysis/ZeroCrossing.swift).

Read the FULL content of every changed file, not only the diff hunks. Review both changed and
unchanged portions of those files.

APPLY (blocking): RT thread safety in any _computeSamples / render path (no allocation, locks,
blocking, print, String construction, is/as? checks; no force unwraps; _checkCount first;
pre-allocated never-resized buffers; no grow path); input classification at init; correct
Generator/Synthesizer/GeneratorBase conformance and outputChannelCount; proper use of Lyrebird
shared RT-safe helpers instead of re-inlined boilerplate; bus memory rules; scheduling model
compliance; a deterministic input→output unit test for every new public Generator.

DO NOT flag as blocking (these are Lyrebird-internal repo rules that cannot apply to an
external package): the Sources/Lyrebird/ subfolder taxonomy, phase-history or working-order
docs, agent/skill mirror sync, or Lyrebird's exact SPDX header string. Header/file-org/style
conventions are the PROJECT's to set — mention deviations only as nits.

Generate a summary titled "Lyrebird External Review Results for '<project name>'".

Agent B — Caveman line-level sweep (general-purpose agent)

You are doing a fast, terse code review of Swift changes in a package that depends on the
Lyrebird audio framework. Read the diff at <project root>/review.diff (or run
`git diff --no-color HEAD`). Pay special attention to any code that runs on the RT render
thread (_computeSamples, render callbacks).

Review every changed line. One line of output per finding. Format exactly:
  L<line>: <severity> <problem>. <fix>.

Severity levels: bug, risk, nit, q
- bug  = definite defect, wrong output, crash risk
- risk = potential issue under specific conditions
- nit  = style, naming, minor clarity
- q    = question / needs clarification

Skip praise. Skip obvious. Skip anything already correct.
If all changes look good, output exactly: LGTM

Step 4: Present results

Two sections:

Section 1 — Lyrebird External Review Results — Agent A's summary, unmodified.

Section 2 — Caveman Line Sweep — Agent B's findings. If Agent B returned "LGTM", say so in one line.

Step 5: Resolve and re-run

If there are blocking findings, fix them and re-run this skill from Step 1 until the review is clean. There is no memory-file or phase-doc bookkeeping for external packages — once the review passes with no blocking findings, report the clean result and (optionally) suggest the project record the change in its own CHANGELOG or release notes.

Cleanup

Remove the temporary diff when done:

rm -f review.diff