SPIKE OUTCOME: FAILED (offscreen DIED across 5-min SW idle + worker.close())
Per Plan 04-04 spike-first contract, Wave 0 empirically investigated whether
the offscreen document's RAM-only `segments: Blob[] = []` at
src/offscreen/recorder.ts:91 survives a 5-min SW idle followed by Puppeteer
CDP-driven `worker.close()`. RESEARCH Q2 hypothesis (MEDIUM confidence): yes,
the offscreen has its own lifecycle anchored by active MediaRecorder. Spike
result REFUTES that hypothesis.
Empirical measurement (HEADLESS=1; one full run; reproducible via the
committed spike script):
- assertA2 priming: PASSED (badge=REC; offscreen + MediaRecorder live)
- 5-min idle: elapsed cleanly (308.7s total wall-clock)
- stopServiceWorker: succeeded (worker.close() returned)
- SAVE_ARCHIVE ack: {success: true} (SW respawned + processed message)
- video/last_30sec.webm size: 8505 bytes (well below 100 KB floor)
- meta.urls: only chrome-extension://* origins; real-page URLs LOST
- rrweb/session.json: []
- logs/events.json: []
- ffprobe on extracted webm: 'End of file' + 'Duplicate element' errors
(corrupt/truncated; not a valid 30s segment cluster sequence)
Interpretation: offscreen-document lifecycle is NOT independent of the SW
under Puppeteer CDP-driven worker.close() conditions. The 8505 bytes are
likely stale/partial header bytes from a re-initialized empty offscreen
context after SW respawn, not a surviving 30s buffer. The plan's Task 2
GATING CONDITION (videoSize > 100_000) is NOT satisfied; Task 2 is BLOCKED.
Per saved memory `feedback-gsd-ceremony-for-fixes.md`: architectural changes
(moving segments from offscreen RAM to IndexedDB per RESEARCH Q2 sub-question
b Option C) MUST route through proper plan-fix ceremony, NOT improvised
inline inside Plan 04-04. Plan 04-04 SUMMARY flags the failure mode + cites
exact remediation path. ROADMAP SC #1 remains OPEN pending the persistence-
layer plan-fix.
Task 1 persisting artifacts (this commit):
- tests/uat/lib/harness-page-driver.ts:
+ Browser type import (puppeteer)
+ stopServiceWorker(browser, extensionId) helper (verbatim from Chrome
devrel canonical pattern — Puppeteer >=22.1.0; project pin ^25 OK)
+ findLatestZip exported (was module-internal) so the spike script can
reuse the canonical mtime-sort selection logic without duplication
- tests/uat/spike-a33-sw-persistence.ts (NEW):
+ One-shot empirical investigation script; reusable for future SW-
lifecycle regression testing (e.g., verifying the eventual IndexedDB
persistence layer actually closes ROADMAP SC #1)
+ Step 1 reuses __mokoshHarness.assertA2 (canonical fresh-recording
prime; not the non-existent dispatchSaveArchive that REVISION iter-2
explicitly forbids)
+ Step 5 dispatches SAVE_ARCHIVE via chrome.runtime.sendMessage inline
from harness-page realm (Option B per plan-checker BLOCKER 2;
matches A5/A11/A12/A13/A26/A28/A29/A30/A31 pattern)
Verification (Task 1 acceptance criteria):
- npx tsc --noEmit: exits 0
- HEADLESS=1 tsx tests/uat/spike-a33-sw-persistence.ts: ran to completion
(no Puppeteer throw); SPIKE RESULT line emitted with explicit
videoSize=8505 bytes; SAVE_ARCHIVE ack received
- grep -c 'dispatchSaveArchive' tests/uat/spike-a33-sw-persistence.ts: 0
- grep -c "type: 'SAVE_ARCHIVE'" tests/uat/spike-a33-sw-persistence.ts: 1
- Total spike wall-clock: 308.7s (~5min idle + ~8s orchestration)
References:
- Plan 04-04 PLAN.md spike contract (lines 64-72)
- 04-RESEARCH.md Q2 sub-question (b) — Chrome MV3 offscreen lifecycle
- https://developer.chrome.com/docs/extensions/how-to/test/test-serviceworker-termination-with-puppeteer
- Saved memory: feedback-gsd-ceremony-for-fixes.md (no inline architectural
fixes; route through plan-fix ceremony)
103 KiB
103 KiB