test(preflight): #357 backfill — de-mock test_preflight_dedup_v2.py + decrement trap cap 8→5#365
Merged
Merged
Conversation
… decrement trap cap 8→5 The Phase A audit (PR #359) flagged three solitary-trap rows in the preflight cluster — get_decisions_for_files, get_collision_pending_decisions, get_context_for_ready_decisions — all of which had test_preflight_dedup_v2.py as one of their direct mock-only callers. This PR converts the two integration tests in that file from MagicMock-based ctx to a real memory:// SurrealDB adapter. The two helper-fn tests (pure _normalize_file_paths_for_key / _dedup_key_for / _check_dedup checks) remain solitary because they're testing pure functions. The retained AsyncMock on `ledger.queries.get_ledger_revision` is the SPECIFIC behavior under test in both integration cases ("returns None" and "returns stable-rev-1") — narrow seam permitted by CLAUDE.md, same class as the `patch time.monotonic for TTL math` example. The retained mock on `handlers.sync_middleware.ensure_ledger_synced` keeps the auto- sync from touching the working tree, same narrow-seam pattern. Audit before/after: - Direct sociable: 24 → 27 (+3 — all 3 preflight cluster functions) - Solitary trap: 8 → 5 (-3 — preflight cluster cleared) - Indirect: 25 (unchanged) - Uncovered: 0 (unchanged) EXPECTED_TRAP_CAP decremented 8→5 to lock in the improvement (per the one-way-ratchet convention in tests/test_ledger_mock_regression.py). Out of scope: - test_preflight_dedup_telemetry.py and test_v055_region_anchored_preflight.py still use the old MagicMock pattern but no longer contribute to trap status (every preflight-cluster function is now sociable-covered). They get follow-up PRs if review-effort budget allows; the trap cap doesn't strictly require them. - The remove_source cluster (4 trap rows) and the link_commit cluster (1 trap row) are separate follow-up PRs. Verified: - pytest tests/test_preflight_dedup_v2.py: 18/18 passing (0.77s) - pytest tests/test_ledger_mock_regression.py: 3/3 passing (cap=5 holds) - ruff check + format clean Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
First trap-row backfill PR driven by the #359 sub-task 1 audit. Converts the two integration tests in `tests/test_preflight_dedup_v2.py` from `MagicMock`-based ctx to a real `memory://` SurrealDB adapter. Drops trap count from 8 to 5 in one go — all three preflight-cluster traps (`get_decisions_for_files`, `get_collision_pending_decisions`, `get_context_for_ready_decisions`) flip from solitary to direct-sociable.
What changed
`tests/test_preflight_dedup_v2.py`:
`tests/test_ledger_mock_regression.py`:
Audit impact
The three preflight-cluster trap rows are gone. Remaining traps are in two clusters:
Out of scope
Verification
```
$ pytest tests/test_preflight_dedup_v2.py
18 passed in 0.77s
$ pytest tests/test_ledger_mock_regression.py
3 passed
```
Ruff check + format clean.
Test plan
🤖 Generated with Claude Code