Repository navigation
test(e2e): record securityOrigin/storageKey metadata in write-set audit helper - #1996
Conversation
…it helper (#1993) attachWriteSetAudit()'s WriteOp/record() now capture CDP DOMStorage.StorageId's securityOrigin/storageKey verbatim for all four DOMStorage.* listeners (domStorageItemAdded/Updated/Removed/ItemsCleared). This is metadata retention only, not boundary enforcement (no filtering, no OOPIF coverage) -- documented explicitly in the module-level doc comment. Adds a new focused test (write-set-audit-helper.spec.ts) exercising real setItem/update/removeItem/clear localStorage mutations and asserting the recorded metadata. Existing callers (m4-upgrade-loop.spec.ts, m4-preview-namespace.spec.ts) only read individual WriteOp fields, so the added fields do not affect their assertions. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1996 closed). |
PR レビュー結果(Issue #1993 契約照合)
|
敵対的レビュー結果判定: 確認対象は head 1. [P1 / blocker] focused test が
|
…ed metadata (#1993) OWNER REQUEST_CHANGES repair (PR #1996 review, issuecomment-5191160187): - P1 blocker 1: write-set-audit-helper.spec.ts previously only asserted storageKey non-emptiness and mutual consistency, which a securityOrigin/ storageKey field-swap bug would still satisfy. Now obtains the real CDP storage key from an independent oracle (a second CDP session -> Page.getFrameTree -> Storage.getStorageKey) and asserts exact equality, which a field swap fails (empirically verified: securityOrigin and storageKey differ by a trailing slash for the same origin; reverting to the swapped-field mutation makes this assertion fail as expected). - P2: write-set-audit-helper.ts no longer substitutes '' for a missing CDP StorageId.securityOrigin/storageKey (the CDP protocol marks both optional). A missing field now records auditFailure and drops that event from writeLog; flushAudit() throws the recorded failure once the causal drain completes. - P2: write-set-audit-helper.spec.ts no longer navigates into the actual built product app via page.goto('./'). It now serves a minimal inert same-origin HTML fixture via page.route()/route.fulfill() and navigates there, decoupling this helper-focused test from the app's own storage lifecycle. Blocker 2 (Issue #1993 deferred Runtime Verification Applicability condition -- full green e2e CI including the AC9 preview-namespace lane) investigated: CI run 30998931032's `e2e` job failure is NOT caused by this PR. The failing tests are pre-existing VRT/visual-regression baseline mismatches (m2-combat-mvp.spec.ts, phase-screens.spec.ts, visual- overlay.spec.ts canvas/HUD screenshot diffs) that also fail identically on main HEAD's own CI run (30957803240, commit 11d72d8) -- confirmed via `gh run view --log-failed` on both runs. This PR's own three specs (write-set-audit-helper.spec.ts, m4-upgrade-loop.spec.ts main scenario + adversarial test, m4-preview-namespace.spec.ts) all pass locally, including the AC9 preview-namespace lane run via the actual `pnpm run test:e2e:preview-namespace` script. Fixing the pre-existing VRT baseline drift requires touching tests/e2e/__screenshots__/*.png and/or .github/workflows/ci.yml, both outside this Issue's Allowed Paths (tests/ e2e/write-set-audit-helper.ts and .spec.ts only) and outside this repair's mandate -- .github/CLAUDE.md requires human review for workflow changes. This is reported as a structural blocker requiring a human decision / separate follow-up, not resolved in this commit.
PR レビュー結果(iteration 1 fix_delta 後の再照合)OWNER の敵対的レビュー(issuecomment-5191160187)指摘 4 件のうち 3 件は解消:
残る P1 blocker 2(Issue #1993 の deferred_verification_condition:PR CI で
Allowed Paths 遵守: |
…pe expansion, Issue #1993) pr-reviewer の HUMAN_REVIEW_REQUIRED 判定(reviewed_head_sha 173a082)で、 Issue #1993 の deferred_verification_condition(PR CI で m4-preview-namespace.spec.ts の専用 lane が green になること)が、標準 e2e job 内の VRT スクリーンショット差分 10 件(e2e job 失敗 → 後続 preview-namespace lane ステップが skip される)により 未達だった。main HEAD(11d72d8a)自身の CI でも同一の 10 件が失敗しており、 本 PR の変更(tests/e2e/write-set-audit-helper.ts / .spec.ts)とは無関係な pre-existing drift であることを確認済み。 CI が使う pinned Playwright Docker image (mcr.microsoft.com/playwright@sha256:9bd26ad900...)内でこれら10件の diff 画像を目視確認したところ、いずれも主要画面(title-menu / load-menu / preparation / combat HUD / pause dialog / result screen)全体で一律に発生する テキストのフォントレンダリングずれであり、アプリ側の UI 変更・レイアウトバグ ではないと判断した(既存 baseline PNG が現在の CI 環境と異なる環境で生成された ことによるドリフト)。 owner の明示的な承認(本 Issue のスコープ内での修正指示)に基づき、同一 Docker image 内で `playwright test tests/e2e/m2-combat-mvp.spec.ts tests/e2e/phase-screens.spec.ts tests/e2e/visual-overlay.spec.ts --update-snapshots=all` を実行し、10件の baseline PNG を再生成した。 再生成後、同一 Docker image 内で3ファイルの全テスト実行(41 passed, 2 skipped [既存の pending-baseline scenario 2件、本コミットと無関係])を確認。 HUD 数値部分のマゼンタ表示は Playwright 標準の mask 色(動的値のマスキング、 visual-utils.ts の既存 mask 機構)であり意図通り。 Allowed Paths 外(tests/e2e/__screenshots__/**)への変更のため、Issue #1993 本文への追記は別途 issue-refinement-loop 経由で行う。
PR レビュー結果(最終、head
|
…1986) PR #2003 レビュー(issuecomment-5204495941, OWNER REQUEST_CHANGES)の fix_delta 対応。 - docs/dev/visual-baseline-registry.md: Issue #1986 エントリが baseline canonicalization を PR #1998 のマージに誤って帰属させていた欠陥を修正した。 実際の canonicalization source は PR #1996(baseline 生成コミット d6217bb、merge コミット 10925fb)であり、PR #1998 は無関係な 後続コミットに過ぎない(git merge-base --is-ancestor で確認済み)。 environment_fingerprint / visual_diff_artifacts セクションも追加した。 - tests/e2e/m2-combat-mvp.spec.ts: timeout overlay screenshot テストの CSS masking から [data-legacy-debrief-surface] を除外し(rename 後に実 DOM 要素へマッチするようになったため、masking のままだと実際の統合退行を 静かに隠しうる構造だった)、代わりに新規ヘルパー expectLegacyDebriefInactive() で legacy debrief surface が実際に inactive(count=1, hidden=true, inert=true, aria-hidden='true')である ことを screenshot 取得前に明示的にアサートするよう変更した。期待値は src/ui/HudController.ts の setHudRootVisibility() 実装を読解して確認した 実際の production 契約に基づく。running HUD テストは data-combat-hud の みをキャプチャし legacy debrief surface と DOM 上分離されているため、 同種の masking パターンは存在せず、ヘルパーの再利用は行っていない。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
* test(e2e): PR #1984 pause-dialog/result-surface 追従の残存差分を修正 (#1986) - m2-combat-mvp.spec.ts:780 の data-legacy-result-surface 参照 (CSS masking selector)を data-legacy-debrief-surface へ更新した (実体は既に HudController.ts 側で改名済みで、この selector 部分は 何にもマッチしていなかった) - m2-combat-mvp.spec.ts:701 の data-legacy-debrief-surface アサーション を toHaveCount(1) + toBeHidden の非空虚な検証へ更新した - AC1(pause/resume パターン)は PR #1998 で既に修正済みのため コード変更なし(再 inventory で確認) - phase-screens.spec.ts の VRT baseline 6 件は、実装着手時点の origin/main(PR #1998 マージ後、1c4f938b)の CI e2e job が既に 全件 PASS していることを確認し、更新を見送った(ローカルで観測 された diff はフォントレンダリングによる既知の環境差であり、 docs/dev/visual-baseline-registry.md に評価根拠を記録した) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(e2e): OWNER レビュー指摘の baseline 帰属誤りと masking-hides-regression を修正 (#1986) PR #2003 レビュー(issuecomment-5204495941, OWNER REQUEST_CHANGES)の fix_delta 対応。 - docs/dev/visual-baseline-registry.md: Issue #1986 エントリが baseline canonicalization を PR #1998 のマージに誤って帰属させていた欠陥を修正した。 実際の canonicalization source は PR #1996(baseline 生成コミット d6217bb、merge コミット 10925fb)であり、PR #1998 は無関係な 後続コミットに過ぎない(git merge-base --is-ancestor で確認済み)。 environment_fingerprint / visual_diff_artifacts セクションも追加した。 - tests/e2e/m2-combat-mvp.spec.ts: timeout overlay screenshot テストの CSS masking から [data-legacy-debrief-surface] を除外し(rename 後に実 DOM 要素へマッチするようになったため、masking のままだと実際の統合退行を 静かに隠しうる構造だった)、代わりに新規ヘルパー expectLegacyDebriefInactive() で legacy debrief surface が実際に inactive(count=1, hidden=true, inert=true, aria-hidden='true')である ことを screenshot 取得前に明示的にアサートするよう変更した。期待値は src/ui/HudController.ts の setHudRootVisibility() 実装を読解して確認した 実際の production 契約に基づく。running HUD テストは data-combat-hud の みをキャプチャし legacy debrief surface と DOM 上分離されているため、 同種の masking パターンは存在せず、ヘルパーの再利用は行っていない。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]> Co-authored-by: Test User <[email protected]>
Summary
tests/e2e/write-set-audit-helper.tsのWriteOp型に CDPDOMStorage.StorageId由来のsecurityOrigin: string/storageKey: stringを必須フィールドとして追加するrecord()関数のシグネチャにsecurityOrigin: string, storageKey: stringを必須パラメータとして追加するDOMStorage.*listener(domStorageItemAdded/domStorageItemUpdated/domStorageItemRemoved/domStorageItemsCleared)全てで同一イベントのevent.storageId.securityOrigin/event.storageId.storageKeyをrecord()に渡すtests/e2e/write-set-audit-helper.spec.tsを追加し、実際のsetItem/ 更新(domStorageItemUpdated)/removeItem/clearmutation でsecurityOrigin/storageKeyが期待通り記録されることを検証するCloses #1993(本 PR で Issue #1993 の Acceptance Criteria をクローズする)
Checks
pnpm typecheckpnpm lintpnpm testpnpm buildpnpm typecheck:e2e(AC6)uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pynpx playwright test tests/e2e/write-set-audit-helper.spec.ts(新規 focused test、実 Chromium 実行で PASS)npx playwright test tests/e2e/m4-upgrade-loop.spec.ts(既存呼び出し元、フィールド追加後も既存 assertion が壊れないことを確認)pnpm test:e2e:preview-namespace(既存呼び出し元m4-preview-namespace.spec.ts、フィールド追加後も PASS)受け入れ条件の達成状況
WriteOpにsecurityOrigin: stringフィールドを追加 —rg -qF 'securityOrigin: string' tests/e2e/write-set-audit-helper.tsPASSWriteOpにstorageKey: stringフィールドを追加 —rg -qF 'storageKey: string' tests/e2e/write-set-audit-helper.tsPASSrecord()のシグネチャがsecurityOrigin: string, storageKey: stringを必須パラメータとして受け取りvoidを返す —rg -qF 'securityOrigin: string, storageKey: string): void' tests/e2e/write-set-audit-helper.tsPASS。4 listener 全てが実際にこの2値を渡さない限りpnpm typecheck:e2eが失敗する構造(listener 単位の記録漏れを機械的に検出)tests/e2e/write-set-audit-helper.spec.tsを追加 —test -f tests/e2e/write-set-audit-helper.spec.tsPASS。実際にsetItem/更新/removeItem/clearの 5 op を発生させ、各WriteOp.securityOriginがページ origin と一致しstorageKeyが非空文字列であることを assert(実 Chromium 実行で PASS 済み)rg -qi 'OOPIF' tests/e2e/write-set-audit-helper.tsPASSpnpm typecheck:e2ePASSpnpm lintPASSSchema Change Applicability
not_schema_changeWriteOpはテストヘルパー内部の型であり公開 API/永続化スキーマではない。フィールド追加のみで既存フィールドの削除・型変更はなく、attachWriteSetAudit(context, page)の呼び出しシグネチャも変更していない。Schema Consumer Inventory
N/A(
not_schema_changeのため)Safety Claim Matrix
N/A — 本 PR は E2E テストヘルパーと専用テストのみを変更し、
transport/permission/sandbox/auth/mcp/.claude/skills//.github/workflows/のいずれにも該当しない。reason: 変更範囲はtests/e2e/write-set-audit-helper.tsと新規tests/e2e/write-set-audit-helper.spec.tsのみ(Allowed Paths と一致)。Notes
attachWriteSetAuditの呼び出しシグネチャ・境界強制(filter・拒否・caller assertion)・OOPIF 完全網羅は Out of Scope(別 Issue で扱う)。deferred(Issue 本文参照)。CI(pnpm test:e2e:ci)が新規 focused test と既存 2 呼び出し元 spec を実行する safety net として機能する。ローカルでも実 Chromium で 3 spec とも PASS を確認済み(上記 Checks 参照)。m4-upgrade-loop.spec.ts/m4-preview-namespace.spec.ts)はWriteOpオブジェクト全体ではなくop.key/op.type等の個別フィールド抽出に基づく assertion のため、フィールド追加のみでは影響しない — ローカル実行で両 spec とも PASS を確認済み。DOMStorage.StorageIdのsecurityOrigin/storageKeyは protocol 型上は optional(securityOrigin?: string/storageKey?: string)。本実装は?? ''で TS の型安全性のみ担保しており、実行時に空文字列になった場合は新規 focused test のアサーションが failing として検出する(silent gap にしない)。