← Back to Pull requests

test(frontend): run the crypto worker and keystore in real browsers #231

Closed
unknown closed this pull request without merging on Nov 17, 2026 00:06 UTC
View on GitHub
unknown unknown commented on Nov 13, 2026 09:07 UTC
Author

What and why

Part of #223 (stage A; stage B, the lifecycle specs, remains). Every frontend test ran under Node or jsdom with the keystore, wasm and drive layer mocked. A vitest browser project now runs *.browser.test.ts in real headless browsers through Playwright: the module crypto worker, Web Crypto keys, IndexedDB persistence across a worker restart, a drive round trip with ciphertext checked in the real IndexedDB vault, and the device's HPKE key stored sealed (ADR 0007). No backend; npm test and check.sh are unchanged.

browser.yml builds the wasm envelope module, then runs Chromium on every pull request and Chromium, Firefox and WebKit on main, nightly and on demand, keeping failure screenshots and Playwright traces as artifacts. It is not a required check yet.

Found a Safari bug, fixed by #200. WebKit refuses to store an X25519 CryptoKey in IndexedDB, and the device private key used to be stored as one, so the crypto worker could not start in WebKit. #200 stores that key sealed under an AES seed key. Rebased onto it, WebKit passes like the other browsers, so the WebKit exemption and the README's Safari caveat are gone.

Updated for #200: test 1 checks hpkeKeyAvailable; test 2 checks the sealed key (the seed key is non-extractable, encrypt and decrypt only, and the stored key decrypts only under its tenant and public key); the X25519 probe test is gone with the key it probed. The round trip now checks that no 1 KiB window of the plaintext appears in the stored chunk. The browser job's rust-cache saves only from main, as in #226.

Also: the coverage job in ci.yml ran a bare vitest run, which would now start the browser project on a runner without browsers (the error was hidden by | tee); it now runs only the node and dom projects.

How it was tested

  • Chromium, Firefox and WebKit: 4/4 each. Before #200, WebKit was 0/5, root-caused with a probe (AES keys and buffers store fine; X25519 keys, private and public, do not).

  • The original checks were each shown to fail when broken: an extractable KEK, keys not saved, no HPKE key, plaintext stored.

  • npm test runs only node and dom (204 passed); typecheck and lint pass; coverage with no browsers installed exits 0.

  • frontend/package-lock.json also drops 14 libc fields from an npm version difference; the new packages are @vitest/browser-playwright, playwright and their deps (MIT/Apache-2.0).
  • Checklist

  • scripts/check.sh passes locally: all steps pass except the secret scan, which fails for the reason #230 fixes

  • Every new refusal has a negative test: n/a

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs: n/a

  • Fails closed on missing configuration, key material, or attestation: n/a

  • No new cryptographic primitives; suites stay behind their type aliases: n/a

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made: n/a
  • Diff: 383 lines (+287 / -96) across 4 files Reviewer: gabrielzubovsky Review duration: 5219m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 383 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.356
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #231"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 66.2% (HIGH) · Higher = larger blast radius
    66.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.1% · Safe to merge
    26.1%