Skip to content

fix(recipes): scope one-shot route mocks to their capture - #1432

Open
BenSheridanEdwards wants to merge 1 commit into
mainfrom
fix/route-mock-cleanup-leak
Open

BenSheridanEdwards wants to merge 1 commit into
mainfrom
fix/route-mock-cleanup-leak

Conversation

@BenSheridanEdwards

@BenSheridanEdwards BenSheridanEdwards commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Why

A route recipe that never requests its mocked endpoint leaves a one-shot error handler armed on the shared crawl page. The next ordinary surface can receive that error and silently capture the wrong state.

Closes #1417.

What changed

Expanded recipe surfaces retain the exact route handler and expose an internal cleanup callback. Capture and breakpoint detection release it in their finally blocks. Each subsequent go releases the previous handler before rearming, and a failed go releases its own handler. Other handlers registered for the same URL pattern remain installed. No public API or stored-map schema changes.

Reviewer view

expanded recipe go
  remove previous owned handler
  install one-shot handler -> navigate
  on failure: remove owned handler
capture / breakpoint detection
  go -> capture / self-check / popup reopens
  finally: remove owned handler (consumed or unused)

Proof

Not applicable for screenshots/video: this changes network interception lifetime, with no renderer or UI change. Real Chromium requests provide the regression evidence.

The four new route-recipe-cleanup.e2e.spec.ts scenarios all failed on the original code: capture, detection and failed-navigation cases received status 503 instead of the consumer handler's 202; repeated go received [503, 503] instead of [503, 202]. All four pass with the fix. The existing state-recipe E2E scenarios also pass (12 tests in the first run; 14 after adding the teardown regressions).

Astra found one P2 teardown issue: a rejected route cleanup skipped tracker disposal and HAR finalization. Finally protection fixes it; both new teardown regressions failed before the fix and pass afterward. Final focused Chromium result: 14 passed (24.7s) with one worker.

Regenerated docs/demo/report.md on this branch; it remains byte-identical. This is renderer-compatibility evidence only, not certification of this PR. Its disclosed limitations remain visible:

## 🗺️ StyleProof report

⚠️ **Product-state identity unproven** (pair with no product-state declared). Base and head used the same surface key, but product-state identity is unproven — treat the diff as visual-only, not a certified same-state compare.

**2 changes need review**

🆕 **1 new surface(s)** captured with no baseline to compare: `pricing @ 900`. These are reviewable first-adoption surfaces; approve them before they become the baseline.

**1 distinct change** (3 computed-style difference(s)) in 1 changed surface base with an existing baseline.

**What changed**

Proof Law: the change is false if the next surface can receive an unused previous mock, if repeated reopens stack handlers, or if cleanup removes the consumer's same-pattern handler.

Behaviour changes

Unused recipe mocks stop at the capture/detection boundary. Self-check and popup reopens keep only their current one-shot handler. Failed navigation also releases the handler.

Not asked for

Release work, changing the HAR replay policy, changing a consumer's own route handlers, or changing report rendering.

Review guide

Start with expandStateRecipe in src/runner/variants.ts, then the finally blocks in src/runner/surface-capture.ts. The new E2E file verifies the actual next response, including a same-pattern consumer handler.

Verification summary

Current security hold — not merge-ready. A fresh bounded pnpm audit --audit-level=high fails for locked picomatch 4.0.5 (GHSA-fc5q-39xc-vjpf). No validated compatible remedy is currently available. No dependency, audit-threshold, release-age or other security control was changed. Earlier passing implementation/hosted checks below do not establish current security readiness.

Final pnpm run verify --test-concurrency=1 passed (7,072 unit tests, zero failures), including build, typecheck, lint, anti-slop, formatting, privacy and context checks. The repository Node wrapper ignores concurrency flags; targeted Chromium checks used one worker. Final focused E2E: 14/14 pass. Normal hook results are recorded below. GitNexus tooling/index are unavailable in the fresh worktree; caller and diff scope were checked directly. No renderer output changed. No merge or release was performed.

  • Normal pre-commit hooks passed: lint, formatting, gitleaks (no leaks), Fallow (no new findings or threshold violations), commitlint.
  • Normal pre-push hooks passed: anti-slop, affected unit tests, full browser suite. ℹ pass 7073; 1 passed (459ms); 1 skipped; 1273 passed (7.9m)
  • Hosted required and the latest PR-body validation passed on c876a6479c9d3611fdbde95b66182c5cba2932b3. The earlier body validation failure is superseded.
  • Final independent Astra review: APPROVE recommendation on that exact head; the P2 teardown finding is resolved, including two red-then-green regressions. No GitHub approval, human signoff or merge was submitted.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

Synthetic action dogfood receipt. This report is the final deliberately failing fixture in the action contract suite. It proves that unproven evidence is rejected; it does not certify this pull request.

🗺️ StyleProof report

📊 View the side-by-side visual report →


Coverage, determinism, report/diff consistency, or Change Reach (changeReach: 'gate') evidence is incomplete — this is not a base recapture failure. Repair the named evidence in the report.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

Live StyleProof-on-StyleProof (advisory). This report is captured from the surfaces declared in styleproof.config.ts (example/demo). home@* carries matching productState {id, revision} (comparable / certifying path); the product-state acknowledgement file stays armed but empty so undeclared new pairs fail closed. fail-on-diff is false; the check is not part of hosted required CI. The synthetic Action contract suite remains action-dogfood.yml.

🗺️ StyleProof report

Nothing changed, so no report was uploaded. The verdict is in the run summary.


Advisory-only mode: no reviewable changes detected — the StyleProof dogfood check remains green.

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.

Route state recipe's one-shot mock is never removed and can answer a later crawl surface

1 participant