scopes.test.ts's TOKEN_ROUTES exclusion list has no existence guard #189

Closed
opened 2026-09-21 21:21:29 +02:00 by lz · 0 comments
Owner

Context

nexus/src/lib/server/tokens/scopes.test.ts has a test ("excludes routes that would leak logs, config, secrets, or file/artifact contents") that asserts a hand-maintained excluded array of route ids are never present in TOKEN_ROUTES. Caught during the fix/nexus-plugin branch's Task 6 review: when a route in that list is later deleted from the codebase entirely (as happened with /api/settings/agent-instructions), the assertion TOKEN_ROUTES.has(id) === false stays trivially green forever — a deleted route can't be in the map either way — so the guard silently loses its meaning without any test going red.

The file already has the fix pattern next door: isDeadMapping (used elsewhere in the same file to catch a mapped route id that no longer resolves to a real route). The same idea applies here in the other direction — an excluded entry should still resolve to a real route file, or the exclusion is decorative.

Suggested fix

Add an assertion alongside the existing exclusion-list test:

expect(excluded.filter(isDeadMapping)).toEqual([]);

(or equivalent — whatever fits isDeadMapping's actual signature/usage in that file) so a route deleted from the codebase without also being removed from this list fails loudly instead of silently.

Verified

All seven entries in the excluded array were confirmed to still exist and export GET as of the review that caught this — so this is prophylactic, not a live defect today.

## Context `nexus/src/lib/server/tokens/scopes.test.ts` has a test ("excludes routes that would leak logs, config, secrets, or file/artifact contents") that asserts a hand-maintained `excluded` array of route ids are never present in `TOKEN_ROUTES`. Caught during the `fix/nexus-plugin` branch's Task 6 review: when a route in that list is later deleted from the codebase entirely (as happened with `/api/settings/agent-instructions`), the assertion `TOKEN_ROUTES.has(id) === false` stays trivially green forever — a deleted route can't be in the map either way — so the guard silently loses its meaning without any test going red. The file already has the fix pattern next door: `isDeadMapping` (used elsewhere in the same file to catch a *mapped* route id that no longer resolves to a real route). The same idea applies here in the other direction — an *excluded* entry should still resolve to a real route file, or the exclusion is decorative. ## Suggested fix Add an assertion alongside the existing exclusion-list test: ```ts expect(excluded.filter(isDeadMapping)).toEqual([]); ``` (or equivalent — whatever fits `isDeadMapping`'s actual signature/usage in that file) so a route deleted from the codebase without also being removed from this list fails loudly instead of silently. ## Verified All seven entries in the `excluded` array were confirmed to still exist and export `GET` as of the review that caught this — so this is prophylactic, not a live defect today.
lz closed this issue 2026-09-21 22:45:14 +02:00
Sign in to join this conversation.
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#189
No description provided.