- Extract shared payload-guards (asRecord, asString, asNumber, asStringArray)
into dashboard/src/utils/payload-guards.ts (DRY)
- Extract wrapWithMetrics() helper in src/metrics.ts to eliminate repetitive
try/catch instrumentation blocks
- Add exponential backoff to useSSE reconnect (3s→6s→12s, capped at 30s,
max 10 retries)
- Create centralized public/renderer/theme.js with named color and layout
constants; update all 5 layer files to import from it
- Extract parsePositiveInt/parsePositiveFloat into shared src/parse-env.ts;
remove duplicates from server.ts and token-budget.ts
- Deduplicate selectNextPrompt/selectNextSafePrompt via optional filter
predicate parameter
- Migrate console.warn/error to structured logger in server.ts,
orchestrator.ts, and broadcast/adapter.ts
- Rename bestOf→mostVotedChoice, input→promptConfig/rotationInput,
stitched→recentTurnsSummary for intent-revealing names
- Add named constants for magic numbers (JITTER_RANGE, RECENCY_PENALTY,
RECENT_TURNS_COUNT) and rationale comments for token budget defaults
- Add TODO(phase-8) header to OBS adapter stubs
- Document Object.create design choice in logger.ts
- Guard shake() timer leak in effects.js
All 158 tests passing, 0 type errors.