Repository navigation
Week 3: dry-run engine — the deterministic half does the checking - #4
Merged
Merged
Conversation
…ening The dry-run engine (src/firstsync/dryrun.py) executes stored mapping proposals over real records without writing anything. Every record is built the way the migration would build it and classified clean / warning / needs_decision / blocking; failures are grouped by target field and root cause with masked examples; natural-key collisions are reported as likely duplicates. Two new MCP tools: dryrun_start and dryrun_get_results. The evaluation now scores the whole pipeline, not just the mappings: score_defects checks that the dry-run catches the defects planted in org D. Rescoring both saved result sets: Sonnet 5.5 and Haiku 5.5 both catch 4/4 (duplicates, missing emails, missing amounts, short phones). Production-Python items from the course syllabus, built in rather than bolted on: - typed settings via pydantic-settings (FIRSTSYNC_* env), with a process-wide run ID stamped on every audit line - mypy strict-ish config, clean on src, added to CI - REST client retries 429/5xx with exponential backoff and full jitter; 400s never retried; reads are idempotent so retrying is safe - dead-letter path: a record that crashes the engine is filed and counted, never silently dropped and never fatal to the scan - property-based tests (Hypothesis): any limit is safe, re-running never changes the verdict - CLI entry point: `firstsync dryrun <org>` exits non-zero when anything blocks, so it can gate a pipeline 185 tests, no network, no API key. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ggB2HHn8zjybwfaJG1g3R
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.
What this adds
The dry-run engine (
src/firstsync/dryrun.py). It executes the stored mapping proposals over real records and writes nothing. Every record is built exactly the way the migration would build it, then classified:cleanwarningneeds_decisionblockingFailures come back grouped by target field and root cause — 50 records failing for one reason read as one finding — with source record Ids kept (that's how an admin finds them) and example values masked (that's how nothing sensitive leaks to the model). Records that would collide on a table's natural key are reported as likely duplicates.
Two new MCP tools:
dryrun_start,dryrun_get_results. Nine total.The evaluation now scores the pipeline, not just the mappings.
score_defectschecks whether the dry-run caught what we planted in org D. Rescored both saved result sets:This is the design working as intended: the engine is deterministic code, so once the mapping is right, defect detection doesn't depend on which model proposed it — and a wrong mapping upstream would make a planted defect invisible downstream, which the score would show.
Production hardening from the course syllabus, built in rather than bolted on:
pydantic-settings,FIRSTSYNC_*env vars) with a process-wide run ID on every audit linemypy srcclean; added to CIfirstsync dryrun <org>exits non-zero when anything blocks, so it can gate a CI/CD pipelineTests
185 passing (was 174), no network, no API key. New:
tests/test_dryrun.py— planted-defect detection, determinism, masking of failure examples, save/load round-trip with path traversal rejected, and the Hypothesis properties.Generated by Claude Code