Skip to content

Week 3: dry-run engine — the deterministic half does the checking - #4

Merged
TAM-DS merged 1 commit into
mainfrom
week-3-dryrun
Nov 13, 2026
Merged

TAM-DS merged 1 commit into
mainfrom
week-3-dryrun

Conversation

@TAM-DS

@TAM-DS TAM-DS commented Nov 13, 2026

Copy link
Copy Markdown
Owner

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:

status meaning
clean would load as-is
warning an optional value would be dropped; the record still loads
needs_decision an unmapped picklist value — the administrator must rule on it
blocking the record cannot load (a required value is missing or invalid)

Failures 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_defects checks whether the dry-run caught what we planted in org D. Rescored both saved result sets:

sonnet-5-5  org_d  dryrun defects 4/4: duplicate_contacts 6/6, missing_email 5/5, missing_amount 4/4, short_phone 3/3  (all 3 runs)
haiku-5-5   org_d  dryrun defects 4/4: duplicate_contacts 6/6, missing_email 5/5, missing_amount 4/4, short_phone 3/3  (all 3 runs)

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:

  • Typed settings (pydantic-settings, FIRSTSYNC_* env vars) with a process-wide run ID on every audit line
  • mypy src clean; added to CI
  • REST client retries 429/5xx with exponential backoff + full jitter (reads are idempotent, so retrying is always safe); 4xx never retried
  • Dead-letter path: a record that crashes the engine is filed and counted, never silently dropped, 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 CI/CD pipeline

Tests

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

…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
@TAM-DS
TAM-DS merged commit d492df0 into main Nov 13, 2026
1 check passed
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