Unify the mapped/excluded route existence checks in scopes.test.ts #191

Merged
lz merged 1 commit from fix/scopes-existence-guard into main 2026-09-21 22:45:14 +02:00
Owner

Fixes #189.

TOKEN_ROUTES.has(id) === false is trivially true for a route that's been deleted entirely, so the "excludes routes that would leak logs, config, secrets, or file/artifact contents" test kept passing vacuously the moment /api/settings/agent-instructions was removed from the codebase while still sitting in that list — the test looked like it was guarding something but wasn't checking anything for that entry anymore.

Rather than add a second, separate existence check next to the existing one (for TOKEN_ROUTES's mapped keys), this hoists the excluded array up next to the existing isDeadMapping predicate and folds both lists into the single test that already asks "does this id map to a real route" — one check, one meaning, covering mapped and excluded ids alike. Net effect: fewer independent assertions expressing the same property, not more.

Verified by mutation: swapped a real excluded entry for a nonexistent path — passed before this change, fails after it (both confirmed directly, not assumed).

Test plan

  • pnpm typecheck — 0 errors
  • pnpm lint — clean
  • pnpm vitest run src/lib/server/tokens/scopes.test.ts — 17/17
  • Mutation test: nonexistent route in excluded — SURVIVED before this change, KILLED after
Fixes #189. `TOKEN_ROUTES.has(id) === false` is trivially true for a route that's been deleted entirely, so the "excludes routes that would leak logs, config, secrets, or file/artifact contents" test kept passing vacuously the moment `/api/settings/agent-instructions` was removed from the codebase while still sitting in that list — the test looked like it was guarding something but wasn't checking anything for that entry anymore. Rather than add a second, separate existence check next to the existing one (for `TOKEN_ROUTES`'s mapped keys), this hoists the `excluded` array up next to the existing `isDeadMapping` predicate and folds both lists into the single test that already asks "does this id map to a real route" — one check, one meaning, covering mapped and excluded ids alike. Net effect: fewer independent assertions expressing the same property, not more. Verified by mutation: swapped a real excluded entry for a nonexistent path — passed before this change, fails after it (both confirmed directly, not assumed). ## Test plan - [x] `pnpm typecheck` — 0 errors - [x] `pnpm lint` — clean - [x] `pnpm vitest run src/lib/server/tokens/scopes.test.ts` — 17/17 - [x] Mutation test: nonexistent route in `excluded` — SURVIVED before this change, KILLED after
test: unify the mapped/excluded route existence checks (fixes #189)
All checks were successful
ci / nexus (pull_request) Successful in 11m26s
pr-image-cleanup / delete-pr-images (pull_request) Successful in 24s
ci / nexus (push) Successful in 10m5s
ci / images (pull_request) Successful in 8m52s
ci / images (push) Successful in 14m14s
b607dd3a5a
TOKEN_ROUTES.has(id) === false is trivially true for a route that's been
deleted entirely, so the 'excludes routes...' test kept passing vacuously
once /api/settings/agent-instructions was removed from the codebase while
still sitting in this list. Rather than bolt on a second existence check,
hoist `excluded` next to the existing isDeadMapping predicate and fold both
lists into the one test that already checks "does this id map to a real
route" — one check, one meaning, covering mapped and excluded ids alike.

Verified by mutation: swapping a real excluded entry for a nonexistent path
passed before this change and fails after it.
lz merged commit b607dd3a5a into main 2026-09-21 22:45:14 +02:00
lz deleted branch fix/scopes-existence-guard 2026-09-21 22:45:14 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lz/agent-nexus!191
No description provided.