Skip to content

fix(api): exact-match /v1/genomes/top router predicate — drop startsWith over-match (PKT-491) - #418

Open
bugsyhewitt wants to merge 1 commit into
mainfrom
fix/491-api-server-router-genomes-top-prefix-overmatch
Open

fix(api): exact-match /v1/genomes/top router predicate — drop startsWith over-match (PKT-491)#418
bugsyhewitt wants to merge 1 commit into
mainfrom
fix/491-api-server-router-genomes-top-prefix-overmatch

Conversation

@bugsyhewitt

Copy link
Copy Markdown
Owner

Summary

  • Defect (PKT-491): path.startsWith('/v1/genomes/top') in server.ts:203 silently dispatched unrelated paths (/v1/genomes/topology, /v1/genomes/topsecret, etc.) to handleTopGenomes — returning 200 with empty entries or 400 MISSING_PARAMETER instead of 404 NOT_FOUND.
  • Fix: Replace the over-matching compound predicate with exact equality: if (path === '/v1/genomes/top'). The || path === '/v1/genomes/top' term was dead code (already covered by startsWith).
  • Tests: New test/api/routing-prefix-mismatch.test.ts — 4 over-match regression cases + 2 control green cases.

Test plan

  • TDD red phase: 4 tests fail for the right reason (200/400 instead of 404) before fix
  • TDD green phase: all 6 tests pass after 1-LOC fix
  • Full vitest suite: 139 passed, 2 skipped, 0 failed — exit 0
  • Runtime verify (tsx, scratch port): /v1/genomes/topology, /v1/genomes/topsecret, /v1/genomes/topologyx all return 404; /v1/health returns 200
  • Binding architecture review: APPROVED (alienclaw-architect) — 3-layer, genome integrity, leaderboard safety, wall, naming all PASS

Files changed

  • src/alienclaw/api/server.ts — 1-LOC fix at line 203
  • test/api/routing-prefix-mismatch.test.ts — new regression test file (~92 LOC)

🤖 Generated with Claude Code

…ith over-match (PKT-491)

The `path.startsWith('/v1/genomes/top')` predicate silently dispatched
unrelated paths (e.g. /v1/genomes/topology, /v1/genomes/topsecret) to
handleTopGenomes instead of returning 404 NOT_FOUND. The `|| path ===
'/v1/genomes/top'` term was dead code — covered by startsWith already.

Replace with exact equality; adds regression test file covering 4
over-match cases + 2 control green cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bugsyhewitt bugsyhewitt added the auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant