Skip to content

fix(scripts): scan services/ for # MOCKED: markers in check_mocks - #8

Closed
rsanghvi21 wants to merge 1 commit into
mainfrom
fix/check-mocks-scan-services
Closed

rsanghvi21 wants to merge 1 commit into
mainfrom
fix/check-mocks-scan-services

Conversation

@rsanghvi21

Copy link
Copy Markdown
Collaborator

Build-Plan Step Implemented

Checkpoint Execution & Output

$ uv run python scripts/check_mocks.py
OK: Mock registry parity check passed.

$ uv run pytest tests/unit/test_check_mocks.py -v
12 passed in 0.43s

$ make check
(ruff check, ruff format --check, mypy --strict src tests, lint-imports, pytest --cov=understudy --cov-branch --cov-fail-under=100)
All green: 94 passed, 100.00% coverage, 0 lint/type/import-boundary errors.

ADRs Relied On

  • None directly; enforces the existing §7.3 mock-registry rule, does not introduce or change a decision.

Mock Registry Disclosures

  • None. This PR does not add or modify any # MOCKED: marker; it fixes the checker itself so a future marker placed under services/ is actually enforced (currently docs/MOCKS.md is empty, so nothing changes in practice yet).

Documentation Updates

  • None required. This is an internal tooling fix with no user-facing or documented-contract change.

Definition of Done

  • Implementation complete for the named build-plan step (N/A step; see above)
  • Unit tests written; 100% line and branch coverage of the added lines
  • make check green (ruff, mypy --strict, import-linter, pytest)
  • Checkpoint command run and output matches, OR marked unverified with a reason
  • Docs updated where this change made them untrue (none required, with why)
  • No new # MOCKED: marker without a row in docs/MOCKS.md
  • Conventional commit(s), conventional branch, PR opened, never pushed to main

Context

/code-review was run against PR #6 and flagged the auth-service synthetic-token
acceptance as needing a # MOCKED: marker + docs/MOCKS.md row (per AGENTS.md
§2.3/§7). Investigating that finding surfaced that scripts/check_mocks.py only
scans src/ for markers (src_dir = repo_root / "src"), so a marker placed
under services/ — a separate package tree from src/understudy/ — would
never be picked up by the make check parity gate. This PR fixes that gap so
PR 9 in the follow-up sequence (auth mock registration) is actually enforced.

While adding test coverage for the services/ scan, also found and fixed a
latent Windows bug: scan_source_markers built relative paths with str()
instead of .as_posix(), so on Windows a nested marker's backslash-separated
path would never match the forward-slash dotted module names produced by
_module_matches_file. This has been invisible because docs/MOCKS.md is
currently empty, but would have silently broken parity checking the moment a
nested src/ marker was registered on a Windows checkout.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh

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
@Harikeshav-R

Copy link
Copy Markdown
Owner

Closed as integrated into main via PR #6.

@Harikeshav-R
Harikeshav-R deleted the fix/check-mocks-scan-services branch September 11, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants