# Tasks — enterprise-react-audio-stream-session-core (chunk A) ## 0. Pre-flight (non-negotiable) - [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each) - [ ] 0.2 Account for every `.claude/worktrees/*` entry; prune stale ones via `bun scripts/worktree-prune.ts --remove`. - [ ] 0.3 Confirm `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json | wc -l`. ## 1. Package shell - [ ] 1.1 `package.json` (workspace:^ deps: `@suaveplan/audio-fx-plugin-base`, `@suaveplan/fsm`, `@suaveplan/events`, `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/opentelemetry`, `@suaveplan/audio-transport`, `@suaveplan/react-audio`; react 19 peer; `catalog:forms` zod; `catalog:state` zustand) - [ ] 1.2 `tsconfig.lib.json`, `vite.config.ts`, `vitest.config.ts` via `createTestConfig()` (forks, fileParallelism:false) - [ ] 1.3 Subpath exports — `.`, `./session`, `./error-codes` only for now - [ ] 1.4 `README.md` with quickstart + roadmap noting chunks B/C/D ## 2. Error codes - [ ] 2.1 `src/error-codes/error-codes.ts` — 7 `REACT_AUDIO_STREAM.*` codes via `defineCodes` - [ ] 2.2 `src/error-codes/error-codes.types.ts`, `.test.ts`, `.md`, `index.ts` ## 3. FSM - [ ] 3.1 `src/session/session-fsm/session-fsm.ts` — 7-state machine via `@suaveplan/fsm` - [ ] 3.2 `src/session/session-fsm/session-fsm.types.ts`, `.test.ts`, `.md`, `index.ts` ## 4. StreamSession - [ ] 4.1 `src/session/stream-session/stream-session.ts` — class wrapping FSM, injectable transport adapter contract `StreamTransportAdapter` - [ ] 4.2 `src/session/stream-session/stream-session.types.ts`, `.test.ts`, `.md`, `index.ts` - [ ] 4.3 Tests cover: happy path (8 state-changed events), illegal transition throws `INVALID_STATE`, `interruption` emission, peer-stream-added/removed events ## 5. InterruptionClassifier - [ ] 5.1 `src/session/interruption-classifier/interruption-classifier.ts` - [ ] 5.2 `.types.ts`, `.test.ts`, `.md`, `index.ts` ## 6. StreamSourcePlugin - [ ] 6.1 `src/session/stream-source-plugin/stream-source-plugin.ts` — implements `AudioFxPlugin`, `io.inputs[0].count === 0`, `setSourceStream(MediaStream)` - [ ] 6.2 `.types.ts`, `.test.ts`, `.md`, `index.ts` ## 7. Telemetry - [ ] 7.1 `src/telemetry/telemetry.ts` — 6 OTel instruments (2 counters + gauge + 2 counters + histogram per spec) - [ ] 7.2 `.test.ts`, `.md`, `index.ts` ## 8. Tests - [ ] 8.1 Per-feature `.test.ts` covering every scenario in the spec subset - [ ] 8.2 `tests/purity.test.ts` — built dist references no audio context - [ ] 8.3 Every `it(...)` carries `{ timeout: 5000 }` (30000 async) ## 9. Documentation - [ ] 9.1 Sibling `.md` per implementation `.ts` (≥200 words, basic + advanced examples) - [ ] 9.2 README links every co-located `.md` under `## Modules` ## 10. Pre-archive verification - [ ] 10.1 `bunx turbo lint typecheck test --filter=@suaveplan/react-audio-stream` — green - [ ] 10.2 `bunx turbo test:coverage --filter=@suaveplan/react-audio-stream` — 100/100/100/100 on touched modules ## 11. Hand-off (no archive yet) - [ ] 11.1 Commit on `feat/react-audio-stream-session-core`. Spec fold + archive of the parent `enterprise-react-audio-stream` folder happens after chunk D merges; this chunk does NOT archive.