Skip to content

TEST-001A1 — Add the fail-closed synthetic provider test harness #175

Closed

Description

@daliu

Outcome

Create one dependency-free, Functions-test-only safety harness that later Stripe/Firebase suites can reuse without real people, live credentials, production projects, or outside network access.

This is the first atomic child of catalogued TEST-001A. It deliberately excludes the build/test-artifact scrubber and its CI/release integration; publish that as TEST-001A2 after this foundation merges.

Dependency and claim

  • Parent/catalog slice: TEST-001A
  • Dependency: CI-001A / CI-001A — Repair the deterministic frontend test baseline #103 — complete
  • Base: acaa961058177ea7266d489c9537a22802b0905e
  • Canonical owner: /root
  • Branch: codex/issue-175-test-safety-harness
  • One outcome at a time; do not combine payment runtime, Firebase deployment, provider configuration, or artifact scanning.

Exact owned paths

  • functions/testSupport/testSafety.js (new)
  • functions/testSupport/jestSafetySetup.js (new)
  • functions/testSupport/testSafety.test.js (new)
  • functions/package.json (Jest setup registration only; no dependency or lockfile change)
  • functions/stripeWebhook.test.js (adopt the shared signed-request helper only)
  • SECURITY.md (minimum exact status/risk hunk)
  • GITHUB_ISSUES.md (minimum child/status mapping)
  • GITHUB_ISSUE_SLICES.md (minimum child/status mapping)

Everything else is immutable for this issue.

Security invariants

  • Every identity/commerce fixture is deterministic, deeply frozen, and unmistakably synthetic, using reserved or non-deliverable values only; no arbitrary personal-data overrides.
  • The environment guard accepts missing optional variables for pure unit tests, but any supplied Firebase project, Stripe mode/key, site origin, or emulator host must be explicitly demo/test/non-production.
  • Missing required helper inputs, malformed values, production-like projects/origins, non-loopback emulator hosts, or live-mode keys fail closed with fixed errors that do not echo supplied values.
  • The Jest setup installs a process-wide outbound-network guard before tests. It allows only exact loopback targets needed by opted-in emulators and blocks supported external Node transports with one fixed error.
  • Guard installation is idempotent. Environment safety is checked around every test so top-level and test-local unsafe mutations fail.
  • Stripe webhook signatures are generated from caller-supplied synthetic test material; no real or secret-shaped committed credential is introduced.
  • The module is test-only. Runtime entry points and functions/index.js must not import/export it.

Allowed transitions and failure cases

  1. Jest loads the test-only setup, validates supplied environment values, and installs the network guard once.
  2. A test creates a deterministic synthetic fixture; the factory returns a fresh deeply immutable value.
  3. A test makes a loopback emulator call; the supported target passes the guard.
  4. A test attempts an external call through a guarded transport; it fails before DNS/provider contact.
  5. A Stripe test signs deterministic raw bytes and supplies the generated header to the existing webhook test.

Reject unsafe seeds, overrides, non-demo projects, production origins, live/restricted/publishable live keys, malformed test keys, non-loopback emulator hosts, invalid timestamps/payloads/secrets, and external network targets.

Acceptance criteria

  • Small deterministic member/order/contact and Stripe-event factories produce fresh deeply frozen reserved synthetic data and cannot accept arbitrary personal-data/livemode overrides.
  • A shared Stripe helper returns exact raw bytes plus a valid deterministic Stripe-Signature header without logging or retaining the secret.
  • A fixed environment guard positively accepts pure/synthetic cases and negatively rejects production project, live key/mode, production origin, non-loopback emulator host, malformed, and hostile cases.
  • A process-wide idempotent network guard blocks fetch, HTTP/HTTPS, HTTP/2, TCP/TLS, and UDP external entry points while allowing exact loopback forms for emulator traffic.
  • Deliberate negative tests prove failures and prove error/serialized text contains none of the hostile input.
  • The existing webhook suite uses the shared signing helper and remains behaviorally equivalent.
  • Focused and full Functions tests, Functions lint, the opt-in command-journal emulator suite, frontend Jest, SPA callback, Rules, build, link, diff, and sensitive-pattern checks pass.
  • No root package, lockfile, workflow, runtime endpoint, Rules, index export, Firebase project, Stripe account, website, or provider setting changes.

Migration and compatibility

Additive test-only source plus Jest setup registration. No stored data, schema, migration, production environment, or runtime behavior changes. Later TEST-001A2 may reuse these fixed conventions while adding an artifact scrubber and named CI/release gates.

Officer impact

None. This only makes automated tests safer and more reusable; it does not change the website or an officer procedure.

Officer documentation

None — there is no officer-visible behavior, account duty, deployment step, payment operation, or data-handling procedure in this child.

Deployment evidence

Record source, tests, merge, website, Firebase, and provider states separately. Expected for this child: source/test/merge evidence only; no website publication required, no Firebase deployment, no Stripe/provider configuration, and no production behavior claim.

Activity

  1. self-assigned this
    on Jul 13, 2026
  2. added
    priority:P0Launch blocker or urgent security risk
    type:securitySecurity or privacy boundary
    area:firebaseFirebase services and data
    size:SSmall focused issue
    status:in-progressClaimed and actively being implemented
    area:stripeStripe payments and financial lifecycle
    type:testingTest infrastructure and quality gates
    on Jul 13, 2026
  3. daliu commented on Jul 13, 2026

    @daliu
    ContributorAuthor

    CLAIMED by /root at 2026-07-13T18:59:28Z on branch codex/issue-175-test-safety-harness from exact base acaa961. Exact seven-path boundary is in the issue body. No edits began before this marker.

  4. daliu commented on Jul 13, 2026

    @daliu
    ContributorAuthor

    SCOPE AMENDED before source edits at 2026-07-13T19:00:53Z: exact A1 boundary is now the eight paths in the issue body. The process-wide Jest setup and functions/package.json registration make the network/environment guard effective for the full Functions suite while preserving loopback emulator traffic. OPERATIONS_RUNBOOK.md is no longer owned. TEST-001A2 retains artifact scanning/CI integration.

  5. daliu commented on Jul 13, 2026

    @daliu
    ContributorAuthor

    EXTRACTION FINISHED — 2026-07-13T19:47:22Z

    • Branch: codex/issue-175-test-safety-harness
    • Exact source commit: 71c5874ff971a5704b0518b519ca61aa79938077
    • Pull request: TEST-001A1: add fail-closed Functions test safety harness #176
    • Exact owned paths: 8/8; no runtime, workflow, lockfile, provider, deployment, or officer-procedure path changed.
    • Pre-commit staged diff SHA-256: 2eec0b8e5ea423a78395f9c4bb74db7bc88365fcd3e265271ef2c0bfc4838564
    • Node 20 local proof: lint; focused 223/223; full Functions 931 passed/26 skipped; full Auth+Firestore emulator 932 passed/25 skipped; command-journal emulator 25/25.
    • Two independent exact-snapshot reviews approved with no remaining findings.
    • Publication truth: source pushed and PR open. Not merged. Website not published/verified. Firebase not deployed. Providers not configured/contacted. Production behavior unchanged/unproven.

    The timestamped file claim remains active until controlled merge and post-merge verification.

  6. daliu commented on Jul 13, 2026

    @daliu
    ContributorAuthor

    COMPLETE / CLAIM RELEASED — 2026-07-13T19:53:06Z

    • PR TEST-001A1: add fail-closed Functions test safety harness #176 squash-merged to main as e6d8929698b95ddcda78b00108cc7665bf9f5e01.
    • Exact post-merge CI run 29280065948 passed Frontend, Cloud Functions, Firestore Rules, and commerce command-journal jobs.
    • PR Netlify review preview 6a5540c54a65f20008c6cdef was ready; Pages/header were neutral and redirects passed.
    • No production website publication or runmprc.com verification was required or performed because this issue changed only test infrastructure and engineering status docs.
    • Firebase was not deployed. Stripe and other outside providers were not configured or contacted. No live behavior is claimed.
    • TEST-001A2 remains separate for artifact scanning and its named CI/protected-release gate.

    The timestamped claim on all eight #175 paths is released. The issue is closed and status:in-progress is removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:firebaseFirebase services and dataarea:stripeStripe payments and financial lifecyclepriority:P0Launch blocker or urgent security risksize:SSmall focused issuetype:securitySecurity or privacy boundarytype:testingTest infrastructure and quality gates

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions