Skip to content

fix(proof): reconcile managed browser preflights - #457

Merged
bizzybee90 merged 3 commits into
mainfrom
codex/fix-product-proof-managed-preflight-correlation-20260810
Aug 10, 2026
Merged

fix(proof): reconcile managed browser preflights#457
bizzybee90 merged 3 commits into
mainfrom
codex/fix-product-proof-managed-preflight-correlation-20260810

Conversation

@bizzybee90

@bizzybee90 bizzybee90 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Purpose

Repair product-proof HTTP teardown for Playwright 1.62.1 Chromium-managed CORS preflights. Chromium auto-fulfils intercepted preflight OPTIONS requests with a synthetic 204 before Playwright creates a Route, while the independent CDP observer still records the lifecycle. Those proven requests therefore remained uncorrelated and stopped governed Home proof with live_http_teardown_not_idle.

Included scope

  • Recognize only the exact Playwright-managed preflight lifecycle: preflight initiator, bodyless OPTIONS/other, exact source-owned full request identity and generated *-options policy, uncached 204/preflight response, then one loading-finished event.
  • Keep managed preflights in a separate bounded lifecycle with explicit reconciliation accounting.
  • Surface a fixed ID-only CDP cache signal and reject cached, unmatched, duplicate, late, conflicting, malformed, or out-of-order lifecycles.
  • Pin the Playwright 1.62.1 Chromium auto-fulfil source contract.
  • Add adversarial coverage for identity, policy provenance, ordering, cache, limits, ID reuse, hostile getters, redaction, and generic CDP-only non-authority.

Explicit exclusions

No application behavior, timeout, generic request acceptance, schema, migration, dependency, workflow, credential, provider, billing, customer-data, staging, or production change.

Architecture placement

Current owner / directory: Product-proof browser/network harness in scripts/product-proof-cloud-playwright.* and scripts/product-proof-live-evidence.*.

Dependencies and duplicate-system check: Reuses the existing expected-request policy, HMAC identity, CDP mediation, zero-open teardown, and evidence attestation boundaries. No parallel network policy or observer was introduced.

Security and tenancy impact

  • Authentication / authorization: Unchanged.
  • Tenant isolation: Unchanged; only exact source-generated request identities can reconcile.
  • Service-role impact: None.
  • Provider / webhook impact: None.
  • Secrets impact: Raw URLs, headers, bodies, IDs, initiator objects, cache detail, and browser errors remain excluded from evidence.

Data impact

  • Schema / migration / RLS / grant impact: None.
  • Backfill, retention, or rollback: None. Containment is revert of this source-only commit if protected or governed proof gates fail.

Verification

  • Behavioural tests: Focused cloud/live suites 243/243 pass; network-policy 18/18 pass; broader cloud suite 785 pass, 1 skip, with one independently reproduced unrelated asset_vite_manifest_invalid local fixture failure.
  • CI / security review: Scoped ESLint, Node syntax, diff check, and redaction scan pass. Independent security review: 0 high, medium, or low findings. Hosted exact-dependency CI and latest-head CodeRabbit remain mandatory.

Release safety

  • Deployment scope: Protected source merge, then private noindex preview and one governed synthetic staging proof only. No production deployment is authorized.
  • Monitoring / stop conditions: Stop on any latest-head review/check failure, main drift, identity/cache/order mismatch, nonzero open HTTP, cleanup/postflight/recovery failure, or incomplete writer/readback chain.
  • Rollback or containment: Do not weaken gates or retry blindly; revert/repair through a new protected source change if governed proof exposes a different lifecycle.

Documentation and generated files

  • Docs / diagrams / ADR updates: None; the dependency contract is pinned in executable source/tests.
  • Generated-file or lockfile justification: None changed.

Completion check

  • Starts from current origin/main.
  • No valuable work remains only in a dirty worktree, stash, or local-only branch.
  • Source branch will be retired under the branch policy after merge.
  • Any PR-size or branch-retention exception is documented below, or neither applies.

Policy exceptions (leave blank when none apply)

PR-size exception rationale: The +1,266/-29 four-file diff is atomic because this is a privacy/network evidence boundary; 883 added lines are adversarial tests covering the exact positive lifecycle and every required fail-closed identity, cache, ordering, limit, and non-disclosure branch. Splitting source from its security proof would create an unreviewable intermediate state.

Retained branch reason / owner / review date / maximum retention date:

Summary by CodeRabbit

  • Enhancements

    • Improved validation and tracking of browser-managed preflight requests.
    • Added clearer, sanitized network activity details, including request origins, redirects, headers, resource types, and cache status.
    • Improved reconciliation of preflight and cached requests during evidence collection.
    • Strengthened handling of malformed, incomplete, conflicting, or out-of-order network events.
  • Tests

    • Expanded coverage for preflight behavior, caching, event ordering, validation failures, diagnostics, and request lifecycle limits.

@bizzybee90
bizzybee90 temporarily deployed to release-status-ledger-writer August 10, 2026 01:44 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b7c4e8db-22ba-4d3c-98c6-5018477f5157

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2e48e and 9adf710.

📒 Files selected for processing (4)
  • scripts/product-proof-cloud-playwright.mjs
  • scripts/product-proof-cloud-playwright.test.mjs
  • scripts/product-proof-live-evidence.mjs
  • scripts/product-proof-live-evidence.test.mjs

📝 Walkthrough

Walkthrough

The change adds a Playwright-managed preflight contract, sanitizes CDP network metadata, and extends live evidence recording to validate, reconcile, count, diagnose, and dispose browser-managed preflight lifecycles.

Changes

Browser-managed preflight evidence

Layer / File(s) Summary
Playwright preflight contract and observers
scripts/product-proof-cloud-playwright.mjs, scripts/product-proof-cloud-playwright.test.mjs
Adds the exported preflight contract, header normalization, sanitized request and response metadata, cache handling, and Chromium contract tests.
Preflight policy detection and state
scripts/product-proof-live-evidence.mjs, scripts/product-proof-live-evidence.test.mjs
Recognizes valid OPTIONS policy pairs and tracks pending preflight state, counters, request IDs, cache events, and canonical requested headers.
Preflight event validation and reconciliation
scripts/product-proof-live-evidence.mjs, scripts/product-proof-live-evidence.test.mjs
Validates request, response, cache, completion, and failure events. Reconciles completed browser-managed preflights as synthetic evidence.
Finalization, teardown, and compatibility validation
scripts/product-proof-live-evidence.mjs, scripts/product-proof-live-evidence.test.mjs, scripts/product-proof-cloud-playwright.test.mjs
Updates final counts and teardown diagnostics, clears tracking state, and tests compatibility, provenance, snapshots, duplicate events, and request limits.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant CDPObserver
  participant LiveEvidenceRecorder
  participant Policy
  participant Evidence
  Browser->>CDPObserver: Emit preflight request and response events
  CDPObserver->>LiveEvidenceRecorder: Provide normalized lifecycle metadata
  LiveEvidenceRecorder->>Policy: Validate and correlate the preflight
  LiveEvidenceRecorder->>Evidence: Record synthetic completion
  LiveEvidenceRecorder->>Evidence: Reconcile counts during finalization
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: reconciling managed browser preflights in the product-proof system.
Description check ✅ Passed The description covers the required purpose, scope, architecture, security, data, verification, release safety, documentation, and completion sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-product-proof-managed-preflight-correlation-20260810

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot temporarily deployed to release-status-ledger-writer August 10, 2026 01:45 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/product-proof-cloud-playwright.mjs`:
- Around line 1716-1734: Update the header-validation loop processing
Object.entries(value) so name and value size limits are enforced only for
headers retained via cdpIdentityHeaderNames. Preserve the existing key-count
cap, duplicate-name detection, and CR/LF/NUL rejection for every header, while
continuing to set credentialHeaderPresent and forbiddenHeaderPresent as
currently implemented.
- Around line 43-44: Update the diagnostics configuration for browser-managed
preflight stages to require the cdp adapter for both
browser-managed-preflight-before-response and
browser-managed-preflight-response-only. Add the adapter check to the top-level
diagnostic and every corresponding open_lifecycles entry, preventing mediated
from being accepted even when policy_label is present.

In `@scripts/product-proof-cloud-playwright.test.mjs`:
- Around line 5438-5456: The bundle assertion around chromiumNetworkManager
should avoid coupling to generated identifiers and formatting. Keep the
preflight guard match and the responseCode: 204 and body: "" checks, but remove
the routeConstruction/indexOf dependency and the assertion requiring the exact
return/brace whitespace pattern.

In `@scripts/product-proof-live-evidence.mjs`:
- Around line 546-576: Deduplicate the header names assembled in
requestedHeaders within the browser-managed preflight detection loop before
sorting and joining them. Ensure base.request.headers keys are combined with
apikey, authorization, and x-client-info using unique-name semantics so
compareCanonical receives the same non-repeated Access-Control-Request-Headers
value Chromium emits.

In `@scripts/product-proof-live-evidence.test.mjs`:
- Around line 637-677: Update the requestFailures loop around
browserManagedPreflightRequestEvent so the missing forbidden posture case
removes the forbiddenHeaderPresent property when its override is undefined,
matching the existing redirected and credentialHeaderPresent handling. Preserve
the assertion and all other request override behavior unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c6293150-d617-40de-b57b-ff8b66ef207f

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5dd12 and 5a2e48e.

📒 Files selected for processing (4)
  • scripts/product-proof-cloud-playwright.mjs
  • scripts/product-proof-cloud-playwright.test.mjs
  • scripts/product-proof-live-evidence.mjs
  • scripts/product-proof-live-evidence.test.mjs

Comment thread scripts/product-proof-cloud-playwright.mjs
Comment thread scripts/product-proof-cloud-playwright.mjs
Comment thread scripts/product-proof-cloud-playwright.test.mjs Outdated
Comment thread scripts/product-proof-live-evidence.mjs
Comment thread scripts/product-proof-live-evidence.test.mjs
@bizzybee90
bizzybee90 temporarily deployed to release-status-ledger-writer August 10, 2026 02:10 — with GitHub Actions Inactive
@coderabbitai
coderabbitai Bot temporarily deployed to release-status-ledger-writer August 10, 2026 02:11 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant