Repository navigation
fix(services): gate synthetic auth tokens as an explicit mock - #18
Merged
Harikeshav-R merged 2 commits intoSep 11, 2026
Merged
Conversation
check_mocks.py only scanned src/ for # MOCKED: markers, so a marker placed anywhere under services/ was invisible to the make check mock-parity gate required by AGENTS.md §7.3. Add a second scan of services/, re-keying its markers with the services/ prefix so they match the dotted module names used in docs/MOCKS.md (e.g. services.auth_service.app). Also fixes a latent Windows bug uncovered while adding this: rel_path was built with str() instead of as_posix(), so backslash-separated paths never matched the forward-slash dotted module names produced by _module_matches_file. This was invisible until now because docs/MOCKS.md has been empty, but would have silently broken parity checking for any nested src/ marker on Windows. Discovered while investigating a code-review finding for PR #6; this fix unblocks registering the auth_service synthetic-token mock in a follow-up PR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh
services/auth_service/app.py accepted any Bearer valid-*/token-*
token as valid on the always-reachable /validate path, with no real
credential store behind it -- an unmarked, unregistered mock
(AGENTS.md section 2.3, section 7). Compounding this, TOKEN_CACHE's
FIFO eviction could evict the seeded admin token
("Bearer valid-token", scope: admin) under sustained synthetic
traffic; revalidating it afterward fell through to the
synthetic-pattern branch (it also matches "Bearer valid-"), silently
re-caching it as scope: standard with no error.
Fix both together:
- Carve the two seeded tokens into SEEDED_TOKENS, a separate,
non-evictable dict checked before TOKEN_CACHE and before the
synthetic-pattern branch. A seeded token can no longer be evicted
or re-derived with a different scope.
- Gate the synthetic-pattern branch behind
AUTH_SERVICE_ALLOW_SYNTHETIC_TOKENS, defaulting to enabled outside
prod (mirroring how is_fault_injection_enabled gates on
UNDERSTUDY_ROLE=prod) so it can be forced off, or explicitly
re-enabled in prod for the eval harness.
- Mark the remaining synthetic-acceptance branch # MOCKED: and
register it in docs/MOCKS.md (module services.auth_service.app,
tracked in #16) -- now enforced by
scripts/check_mocks.py per the earlier services/ scan fix.
Implements build-plan step A1.2 (fix on an already-completed
service), resolving an AGENTS.md section 8 stop-and-ask flagged
during code review.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build-Plan Step Implemented
Checkpoint Execution & Output
ADRs Relied On
not a decision.
Mock Registry Disclosures
services.auth_service.app--Bearer valid-*/Bearer token-*accepted as valid with no real credential check. Why: no Postgres-backed
token store exists yet. Real path:
services/auth_service/app.py::validate_token(Postgres-backed lookup). Issue: auth-service: replace synthetic token acceptance with real Postgres-backed validation #16. Row added to
docs/MOCKS.mdin this same PR, matching the new# MOCKED:marker.Documentation Updates
docs/02-architecture.md§2.5: updated theauth-servicerow to describethe current seeded+synthetic in-memory design and link the tracking issue,
replacing the stale "in-memory cache over Postgres" description that implied
the Postgres fallback already existed.
Definition of Done
make checkgreen (see checkpoint output)# MOCKED:marker without a row in docs/MOCKS.mdContext
A
/code-reviewpass against PR #6 flaggedauth_service's/validateendpoint: it accepts any
Bearer valid-*/Bearer token-*token as validwith no real credential store, on the always-reachable path -- an unmarked
mock (AGENTS.md §2.3 "never fake an integration silently"). Investigation
also found a related bug: the seeded admin token could be evicted from the
FIFO
TOKEN_CACHEunder sustained traffic and then silently re-derived witha downgraded scope via the same synthetic-pattern branch.
Per AGENTS.md §8, this was raised as a blocking decision rather than resolved
unilaterally: keep the synthetic-token convenience (gated + marked) or build
real Postgres-backed validation. The user chose to gate and mark it
rather than build the real store now. This PR implements that choice:
AUTH_SERVICE_ALLOW_SYNTHETIC_TOKENSgates the branch (on by default outsideprod), the branch is marked
# MOCKED:with a real tracking issue(#16, opened as part of this work since none existed),
and the admin-token-downgrade bug is fixed by giving seeded tokens a
separate, non-evictable path that's checked before the synthetic branch can
ever see them.
Depends on #8 (
fix(scripts): scan services/ for # MOCKED: markers in check_mocks) for the new marker to actually be enforced bymake check--that commit is cherry-picked onto this branch so both can be reviewed and
merged independently; once #8 merges to
feat/policies-and-loadgen, thisPR's diff will narrow to just this PR's changes.
Base branch is
feat/policies-and-loadgen(PR #6, still open), sinceservices/only exists on that branch's stack.🤖 Generated with Claude Code
https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh