{#- Context variables:
   - company: str (e.g., "ACME Bank")
   - industry: str (e.g., "fsi")
   - catalog: str (e.g., "acme_fsi_demo")
   - bundle_name: str (e.g., "acme-bank-fsi-demo")
   - app_name: str (e.g., "acme-bank-fsi-app")
   - warehouse_id: str
   - workspace_host: str
   - databricks_profile: str | None
   - lakebase_url: str | None
   - notification_email: str
-#}
# Wave Playbook -- {{ company }} {{ industry | upper }} Demo

## Wave Governance Rules

### Rule 1: Sequential Execution
Waves MUST be completed in order (1 -> 2 -> 3 -> 4 -> 5). Never start a wave until the previous wave is completed and reviewed.

### Rule 2: Quality Gates Are Mandatory
Every wave MUST pass all quality gates before being marked as completed:
- Python: `ruff check`, `ruff format --check`, `mypy`, `pytest`
- Frontend (Wave 4+): `tsc --noEmit`, `vitest run`, `npm run build`
- Bundle: `databricks bundle validate`

### Rule 3: Reviewer Sign-off
After completing a wave, the `reviewer` agent MUST be spawned to verify:
- Pattern adherence (DLT patterns, 3-layer architecture, etc.)
- Completeness (all components in the manifest are delivered)
- Quality (code review grade A-C is acceptable)

### Rule 4: Manifest Is Source of Truth
The `conf/demo_manifest.json` file defines what each wave should deliver. Agents read the manifest to understand their scope. The manifest status field tracks completion.

### Rule 5: Progress Updates Are Mandatory
After every wave, update `docs/PROGRESS.md` with:
- Wave status (completed/blocked)
- Agent(s) that worked on it
- Any issues or decisions made

---

## Wave Execution Checklist

### Before Starting a Wave
- [ ] Read `conf/demo_manifest.json` for the wave definition
- [ ] Read `docs/PROGRESS.md` for current state
- [ ] Read `docs/supplements/ARCHITECTURE.md` for patterns
- [ ] Identify the correct agent(s) to spawn
- [ ] Present the plan to the user for approval

### During a Wave
- [ ] Build one component at a time
- [ ] Run quality gates after each component
- [ ] Test that the component works as expected
- [ ] Do not skip ahead to the next component if current one fails

### After Completing a Wave
- [ ] Run full quality gates
- [ ] Spawn the reviewer agent
- [ ] Address any reviewer findings
- [ ] Update wave status in `conf/demo_manifest.json` to `"completed"`
- [ ] Update `docs/PROGRESS.md`
- [ ] Commit the changes

---

## Failure Protocol

### Quality Gate Failure
1. Read the error message carefully.
2. Fix the root cause (not the symptom).
3. Re-run quality gates.
4. If stuck after 3 attempts, report to user.

### Reviewer Rejection
1. Read the reviewer's specific findings.
2. Fix each finding individually.
3. Re-run the reviewer.
4. If still rejected after 2 attempts, report to user.

### Deployment Failure
1. Check `databricks bundle validate` output.
2. Check workspace permissions and catalog access.
3. Check notebook paths and variable references.
4. If infrastructure issue, report to user (cannot self-fix).

---

## Agent Assignment Matrix

| Wave | Primary Agent | Secondary Agent | Reviewer |
|------|--------------|-----------------|----------|
| 1 | lakehouse-dev | -- | reviewer |
| 2 | lakehouse-dev | -- | reviewer |
| 3 | lakehouse-dev | dashboard-dev | reviewer |
| 4 | app-dev | -- | reviewer |
| 5 | lakehouse-dev | -- | reviewer |
