test(workspace): stop routing-pin leaking a binding lookup into the next test file

Merged
RA
2mo ago
+18-10

Issue for this PR

Closes #1363

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes the source of the create-then-rebind flake in #1363. #1375 made that test ignore GET requests, which stopped the failure, but the request that caused it still leaks into whichever file runs next.

routing-pin.test.ts seeds a local link with recordApprovedBinding and does not wait for the skill sync and memory seed that the call starts. They keep running after the file finishes. By then its afterEach has cleared the pin and deleted the binding cache, so the sync falls through to a server lookup (GET /datamate-project-bindings/by-path). bun runs every file in one process, so the lookup goes out under the next file's credentials and through its fetch stub. Every failing CI run had routing-pin directly before create-then-rebind; every passing run I checked had a different file there.

The fix passes { awaitBackfill: true } from seedLocalLink, so that work finishes inside the test that started it. Test-only change.

Claims (for review)

  • C1: When a routing-pin test returns, no skill sync or memory seed it started is still running, so the file sends no request after it ends.
  • C2: No production code changes. routing-pin's assertions are unchanged and pass 9/9.

Residuals (known, out of scope):

  • R1: About 35 other recordApprovedBinding calls in 7 test files also skip awaitBackfill and may leak the same way. Left for a follow-up.
  • R2: The awaited skill sync now requests https://api.test/skills inside routing-pin. The .test host is reserved and never resolves, so it fails at DNS; before this change the leaked sync made its request after the file ended instead. File runtime goes from about 2.4s to 2.6โ€“3.0s locally.

How did you verify your code works?

Repro, all in one bun process: a throwaway file that pre-loads create-then-rebind's modules (as earlier files do in a full CI run), then routing-pin, then create-then-rebind as it was before #1375 (it still counted GETs):

  • routing-pin from main: 3/3 runs fail with the CI diff (an extra GET by-path).
  • routing-pin from this branch: 3/3 pass, no stray request.

Also: routing-pin alone passes 9/9; routing-pin followed by the current create-then-rebind passes 20/20; typecheck and Marker Guard are clean. The full suite, run the way CI's main pass runs it, passes except the same 22 tests that fail on main on this machine; they read local MCP, skill and header config.

Screenshots / recordings

N/A, test-only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Appendix โ€” complexity delta

โœ… No touched function changed in complexity (0 touched, 0 new). Test files excluded.

๐Ÿค– Generated with Claude Code

https://claude.ai/code/session_0174HUYiaceApqHP7EKMNgnb


Summary by cubic

Test-only fix for the create-then-rebind flake (#1363). routing-pin.test.ts seeded a local link and left the skill sync and memory seed it starts running after the file finished, so they leaked into the next file's fetch stub under that file's credentials. Passing { awaitBackfill: true } keeps that work inside the test that started it. No production code touched; routing-pin's assertions are unchanged.

Summary by CodeRabbit

  • Tests
    • Updated workspace routing test setup to wait for binding backfill to finish before the helper returns. This makes the test sequence reflect the completed setup state before continuing with routing checks.