Repository navigation
refactor: extract M4 E2E write-set audit CDP core into shared helper - #1989
Conversation
…1987) Extracts the CDP-based write-set operation-history audit (WriteOp type, CDP session setup, DOMStorage.* listeners, order/documentEpoch/epochOrder tracking, writeLog, flushAudit) that m4-upgrade-loop.spec.ts and m4-preview-namespace.spec.ts previously duplicated into a new tests/e2e/write-set-audit-helper.ts module, exposing attachWriteSetAudit(context, page). Both spec files now import this shared helper while keeping their lane-specific browser.newContext / storageState seeding / addInitScript calls inline (unchanged), preserving the runtime-lane vs preview-lane behavioral difference the Issue requires. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1989 closed). |
impl-review-loop PR レビュー結果(判定)verdict: APPROVE
reviewed_head_sha: "3b40893db7496f23a574762e454ffc653d3239cf"
blockers: []
warnings: []マージ可否(live readback)
Issue #1987 契約との一致
実行時・CI 証跡(current head
|
判定: REQUEST_CHANGEScurrent head は [P1 / blocker]
|
OWNER REQUEST_CHANGES (PR #1989 review, issuecomment-5179331591, P1 blocker): flushAudit() previously performed a bare DOMStorage.enable round-trip, which only proves events already in flight to this CDP session have been delivered -- not that a JS-level localStorage write that just returned has already been turned into a delivered DOMStorage.* event (Chromium notifies via an async Mojo Put() call, observed later via StorageAreaObserver::KeyChanged()). flushAudit() now writes-then-deletes a reserved marker key from the same page/origin and waits for this module's own listener to observe the marker's DOMStorage.domStorageItemRemoved event. Chromium processes pending storage mutations from a given source in a per-source FIFO queue, so the marker's removal event cannot arrive before every earlier mutation from the same page/origin already has its own event recorded in writeLog -- a genuine causal drain boundary. The marker is filtered out of the public writeLog and never remains in localStorage. Public API (attachWriteSetAudit / flushAudit signatures, WriteOp shape) is unchanged; only the internal flushAudit() implementation and its doc comment were revised. Verified locally: m4-upgrade-loop.spec.ts (both tests) and the dedicated preview-namespace lane pass with the new drain barrier. Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop PR レビュー結果(判定、iteration 2)OWNER の REQUEST_CHANGES(#1989 (comment) )に対する修正後の再レビューです。 verdict: APPROVE
reviewed_head_sha: "26f1bc8fa4f4d39f2487b845240cdd186578065f"
blockers: []
warnings:
- "follow-up Issue #1993(origin/storageKey 境界の記録)は OPEN のまま。本 PR のスコープ外として適切だが、未解決の技術的負債として記録。"マージ可否(live readback)
P1 blocker(
|
Summary
m4-upgrade-loop.spec.tsとm4-preview-namespace.spec.tsが重複していた CDP write-set audit core(WriteOp型、CDP session 生成、DOMStorage.enable、DOMStorage.*listener、globalOrder/documentEpoch/epochOrder追跡、writeLog、flushAudit)を新規tests/e2e/write-set-audit-helper.tsにattachWriteSetAudit(context, page)として抽出した。addInitScriptの有無)はインラインのまま変更していない。preview lane には runtime storage override を混入させていない(build-time namespace 検証を壊さないため)。26f1bc8f)。取り込んだ main には Issue 実装: PR #1964 の battle-stage 寸法修正に伴い vrt-running-hud-overlay.png VRT baseline を更新する #1980(vrt-running-hud-overlay.pngVRT baseline 不一致の修正、PR fix(e2e): capture HUD instead of canvas mask in running-hud-overlay-legacy-current VRT (#1980) #1988)が含まれており、以前 PR 本文に記載していた「preview-namespace lane が CI で未実行」という記録は current head では解消している(下記参照)。OWNER REQUEST_CHANGES 修正(issuecomment-5179331591)
OWNER レビュー(#1989 (comment) )で
REQUEST_CHANGESを受け、以下を修正した。flushAudit()の因果的drain化: 修正前のflushAudit()は同一 CDP セッションへのDOMStorage.enableround-trip のみで、これは「すでにセッションへ送出済みのイベントの受信」しか保証せず、「直前の JavaScript 書込みが確実にイベント化・受信されたこと」は保証しなかった(Chromium のlocalStorage.setItem()はレンダラー側キャッシュを同期更新した後、非同期の MojoPut()で browser process へ通知し、CDP イベントはその後のStorageAreaObserver::KeyChanged()callback で初めて生成されるため)。tests/e2e/write-set-audit-helper.tsのflushAudit()を、同一 page/origin から予約済み marker key を write→delete し、その marker 自身のDOMStorage.domStorageItemRemovedイベントの到着を待つ方式へ修正した。Chromium は同一 source からの pending mutation を FIFO queue で処理するため、marker の removal イベントが観測できた時点で、それ以前に同じ page/origin から発生した全 mutation のイベントがすでにwriteLogに記録済みであることを因果的に保証する。marker は公開writeLogから除外し、localStorageにも残さない。attachWriteSetAudit/flushAuditの公開シグネチャ・WriteOpの型は変更していない(挙動非互換なし)。ローカルでm4-upgrade-loop.spec.ts(2テストとも)と preview-namespace lane を再実行し green を確認済み(下記 CI 実行結果参照)。createRuntimeLaneContext()というローカル factory 関数として実装しており、OWNER は「同じ runtime 設定を2テストで重複させない現在の形の方が合理的」と評価した上で、Issue 側の文言修正を提案した。Issue 実装: M4 E2E write-set audit helper (createAuditedContext) を共有モジュールへ抽出する #1987 本文を「各 spec ファイル内に閉じたローカル factory 関数として実装することも許容する(呼び出し箇所への文字通りの展開は必須としない)」へ修正済み(コード変更なし、AC2/AC3 は影響を受けず引き続き満たされている)。Checks
pnpm typecheck:e2epnpm lintpnpm test(本 Issue のスコープ外。E2E spec のみの変更で Vitest 単体テストに影響しない)pnpm build(本 Issue のスコープ外。TypeScript ソースには触れていない)Schema Change Applicability
not_schema_changeSchema Consumer Inventory
N/A —
not_schema_changeのため対象外。Compatibility Decision(互換性判定)
N/AN/AN/AN/ASafety Claim Matrix
N/A — reason: 本 PR は安全境界・権限・サンドボックス・transport・auth・MCP・native tools・approvalMode・runtime verification・workflow gate のいずれにも触れない。E2E テストファイル内の CDP 監査ロジックを共有モジュールへ抽出するリファクタリングのみで、監査ロジック自体の挙動(CDP
DOMStoragedomain によるログ収集・flushAuditの drain 契約)は変更していないため。検証コマンド結果(current head
26f1bc8fで再実行)Verification Commands(Issue #1987 本文)を worktree 内で current head に対して再実行した結果:
pnpm test/pnpm buildは本 Issue のスコープ(E2E spec ファイルのみ)に含まれず、TypeScript ソース・Vitest 対象コードは変更していないため未実行。実行時検証適用性(Runtime Verification Applicability)
リンク先 Issue #1987 の本文には
## Runtime Verification Applicabilityセクションが実在し、以下の内容が定義されている:deferredpnpm test:e2e:ci)が対象 spec を実行する safety net として機能する。pnpm test:e2e:ci)tests/e2e/m4-upgrade-loop.spec.ts(main scenario と named-property adversarial test の両方)とtests/e2e/m4-preview-namespace.spec.tsが green であること。特に preview lane 側で runtime storage override が混入していないこと(build-time namespace 検証が壊れていないこと)を pr-reviewer が CI 結果から確認する。本 PR の CI 実行結果(deferred_verification_condition の確認、current head
26f1bc8f)因果的 drain 修正後の current head(
26f1bc8f)に対する CI run(https://github.com/squne121/loop-protocol/actions/runs/30912575226 )でe2ejob 全体が green(6m18s)で完了した:tests/e2e/m4-upgrade-loop.spec.ts:M4 upgrade loop: GIVEN seeded snapshot ... write-set operation history proves zero production-key / out-of-scope mutations): green(2.0s)M4 upgrade loop write-set audit: adversarial named-property Storage access is captured (Issue #1283 P1 Blocker 3 regression guard)): green(527ms)tests/e2e/m4-preview-namespace.spec.ts(Run AC9 preview-namespace lane via pnpm run test:e2e:preview-namespacestep、VITE_LOOP_STORAGE_NAMESPACE=pr-1989/LOOP_EXPECTED_STORAGE_KEY=loop-protocol.preview.pr-1989.mvp.save/VITE_BASE_PATH=/loop-protocol/pr-1989/): green(1 passed, 1.1s)。preview lane に runtime storage override(addInitScript/__LOOP_STORAGE_KEY__/__LOOP_E2E_BOOTSTRAP__)が混入していないことは、diff(addInitScriptを preview lane に追加していない)と AC5 の静的検証(DOMStorage.*listener 本体の非残存)の両方で確認済み。ローカル環境でも同一3経路を再実行し green を確認済み。旧コメント(issuecomment-5178266963)が記録していた「Issue #1980 の VRT 不一致により preview-namespace lane が実行されず PR が停止中」という状態は、main に PR #1988(Issue #1980 の修正)が取り込まれ、本 PR がその main を統合したことで解消済み。旧コメントは履歴として GitHub 上に残るが、本 PR の現在の検証結果はこの節が正本。
Notes