docs(01-05): complete SW shrink + port host plan

Plan 05 closes: src/background/index.ts is now a pure coordinator with
zero video-buffer state, T-1-04 mitigations on both onConnect and
onMessage, OFFSCREEN_READY handshake, port-based buffer fetch via
'video-keepalive' port, IDB orphan cleanup on install, and chrome.offscreen.hasDocument()
re-sync on SW respawn (audit P1 #8). 9/9 vitest tests still green;
tsc clean; no as any / @ts-ignore.

REQ-video-ring-buffer stays pending — Plan 07's ffprobe gate owns the
final completion marker.
This commit is contained in:
2026-05-15 18:07:07 +02:00
parent 5cd1519858
commit 9e236cbc7b
3 changed files with 317 additions and 10 deletions

View File

@@ -3,15 +3,15 @@ gsd_state_version: 1.0
milestone: v2.0.0
milestone_name: milestone
status: executing
stopped_at: Completed Plan 01-04port keepalive + OFFSCREEN_READY handshake GREEN (9/9 tests pass); Plan 05 next (SW shrink + onConnect host with T-1-04 sender check)
last_updated: "2026-05-15T15:53:24.264Z"
stopped_at: Completed Plan 01-05SW shrink + onConnect host wired (T-1-04 sender check, OFFSCREEN_READY handshake, port-based buffer fetch, IDB orphan cleanup, hasDocument re-sync); 9/9 tests still green; Plan 06 next (vite.config.ts collapse)
last_updated: "2026-05-15T16:06:29.434Z"
last_activity: 2026-05-15
progress:
total_phases: 5
completed_phases: 0
total_plans: 7
completed_plans: 4
percent: 57
completed_plans: 5
percent: 71
---
# Project State
@@ -28,12 +28,12 @@ no server, no password leaks.
## Current Position
Phase: 1 (Stabilize Video Pipeline) — EXECUTING
Plan: 5 of 7
Plan: 6 of 7
Status: Ready to execute
Last activity: 2026-05-15
REQUIREMENTS.md, ROADMAP.md, STATE.md written)
Progress: [██████░░░] 57%
Progress: [██████░░░] 71%
## Performance Metrics
@@ -63,6 +63,7 @@ Progress: [██████░░░░] 57%
| Phase 01 P02 | 4min | 5 tasks | 8 files |
| Phase 1 P03 | 8min | 3 tasks | 5 files |
| Phase 01 P04 | 4min | 3 tasks | 1 files |
| Phase 01 P05 | 8min | 2 tasks | 1 files |
## Accumulated Context
@@ -92,6 +93,11 @@ current work:
- [Phase 01-04]: Kept Plan 03's defensive bootstrap guard (typeof chrome / per-API existence checks) instead of Plan 04's verbatim unguarded block — Plan 04's verbatim block regressed ring-buffer and codec-check tests (they don't stub full chrome surface); restored guard preserves Plan 02 RED contract while satisfying Plan 04's new GREEN contract. Rule 1 deviation.
- [Phase 01-04]: T-1-04 SW-side sender check documented redundantly (4 places in recorder.ts) for Plan 05 executor visibility — Offscreen is trusting party; SW is validating party. Documenting in module header, port-name constant, threat-mitigation comment near bootstrap, and inline at connectPort makes the contract impossible to miss when grepping for T-1-04 during Plan 05.
- [Phase 01-04]: REFACTOR pass NOT skipped: stale 'Plan 04 wires this' comments replaced with actual D-17/Pattern 5 citations — Forward-pointing TODO-style comments became misleading after the work landed; minimal correctness-preserving comment update with all 9 tests still GREEN.
- [Phase ?]: [Phase 01-05]: Deleted broken checkPermissions / requestPermissions flow (Rule 1)
- [Phase ?]: [Phase 01-05]: REQUEST_PERMISSIONS collapsed — under getDisplayMedia (D-01) no runtime perm check is meaningful; the broken 'tabCapture' permission check was sending recording-start into the never-granted branch
- [Phase ?]: [Phase 01-05]: Added chrome.offscreen.hasDocument() in initialize() — Rule 2 robustness, audit P1 #8 mitigation across SW respawns
- [Phase ?]: [Phase 01-05]: SW is now a pure coordinator — onConnect host bound to 'video-keepalive' port with T-1-04 sender check; getVideoBufferFromOffscreen replaces synchronous SW-local buffer fetch; OFFSCREEN_READY handshake closes the audit P1 #12 race
- [Phase ?]: [Phase 01-05]: indexedDB.deleteDatabase('VideoRecorderDB') in onInstalled — T-1-NEW-05-02 / RESEARCH.md Runtime State Inventory cleanup of orphaned IDB from pre-Phase-01 builds
### Pending Todos
@@ -114,7 +120,7 @@ Items acknowledged and carried forward from previous milestone close:
## Session Continuity
Last session: 2026-05-15T15:53:12.593Z
Stopped at: Completed Plan 01-04port keepalive + OFFSCREEN_READY handshake GREEN (9/9 tests pass); Plan 05 next (SW shrink + onConnect host with T-1-04 sender check)
Last session: 2026-05-15T16:06:29.412Z
Stopped at: Completed Plan 01-05SW shrink + onConnect host wired (T-1-04 sender check, OFFSCREEN_READY handshake, port-based buffer fetch, IDB orphan cleanup, hasDocument re-sync); 9/9 tests still green; Plan 06 next (vite.config.ts collapse)
intel synthesis. Coverage validated: 11/11 v1 REQs mapped.
Resume file: .planning/phases/01-stabilize-video-pipeline/01-05-PLAN.md
Resume file: .planning/phases/01-stabilize-video-pipeline/01-06-PLAN.md