Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ jobs:
python-version: "3.12"
- run: pip install -e ".[dev]"
- run: ruff check .
- run: mypy src
- run: pytest -q
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ A support engineer usually does that by hand. FirstSync gives the work to Claude
inspects the customer's org, proposes how each field maps, and explains every failure in
plain language. Deterministic code decides what actually runs.

> **Status: week 2 of 6.** Claude can inspect an org and propose a validated mapping for
> every target field, and an evaluation scores those proposals against answer keys for
> six synthetic orgs. Dry-run, approval, migration and sync are not built yet. This is a
> reference implementation with no customers. See
> **Status: week 3 of 6.** Claude can inspect an org and propose a validated mapping for
> every target field; an evaluation scores those proposals against answer keys for six
> synthetic orgs; and a deterministic dry-run engine now executes stored proposals over
> real records — writing nothing — and reports, per record, whether it would load,
> grouped by root cause, with duplicates flagged by natural key. The evaluation checks
> that the pipeline catches the defects planted in org D (it catches 4 of 4, for both
> models tested). Approval, migration and sync are not built yet. This is a reference
> implementation with no customers. See
> [What is and is not tested](#what-is-and-is-not-tested).

## The rule the design is built on
Expand All @@ -30,7 +34,7 @@ The full design is in [docs/SPEC.md](docs/SPEC.md).

## What works today

Seven tools, served from one MCP server:
Nine tools, served from one MCP server:

| Tool | What it does |
| --- | --- |
Expand All @@ -41,6 +45,20 @@ Seven tools, served from one MCP server:
| `target_get_schema` | The target app's tables, fields, allowed values and required fields |
| `rule_test` | Runs a transformation rule on a sample and reports what failed and why |
| `mapping_propose` | Validates mapping proposals and stores the valid ones for approval |
| `dryrun_start` | Executes stored proposals over real records without writing, grouped by root cause |
| `dryrun_get_results` | Returns a stored dry-run instead of re-running one |

The dry-run engine is deterministic code, not the model. Every record is built the way
the migration would build it and comes back as **clean**, **warning** (an optional value
would be dropped), **needs_decision** (an unmapped picklist value the administrator must
rule on) or **blocking** (the record cannot load). Failures are grouped by target field
and reason — fifty records failing for one cause read as one finding — with source
record Ids kept and example values masked. Records that would collide on a table's
natural key (account name, contact email) are reported as likely duplicates. A record
that crashes the engine is written to a dead-letter file and counted, never silently
dropped, and the REST client retries transient failures with exponential backoff and
jitter. There is also a CLI: `firstsync dryrun <org>` exits non-zero if anything blocks,
so it can gate a pipeline.

Six synthetic Salesforce orgs, each with an answer key:

Expand All @@ -64,7 +82,7 @@ Pythons refuse installs outside one.
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest -q # 174 tests, no network, no API key
pytest -q # 185 tests, no network, no API key
python scripts/run_eval.py --baseline # the evaluation, with name matching instead of a model
python -m firstsync.mcp_server # the MCP server, over stdio
```
Expand Down Expand Up @@ -233,6 +251,7 @@ administrator, and neither can a low-confidence mapping or a required field with
| Part | Tested how |
| --- | --- |
| Tools, masking, rules, mapping validation, scoring, fixtures, answer keys | Unit tests, offline |
| Dry-run engine | Unit tests against the planted defects in org D, plus property-based tests (Hypothesis) that any limit is safe and re-running never changes the verdict |
| MCP server | Unit tests, plus a real MCP client over stdio |
| Evaluation pipeline | End to end with the baseline mapper |
| `scripts/describe_org.py` | Run against org B in week 1: all six planted problems found. See [the report](docs/week1-org-b-report.md). |
Expand Down
18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ license = { text = "Apache-2.0" }
dependencies = [
"mcp>=2,<3",
"httpx>=0.27",
"pydantic>=2.7",
"pydantic-settings>=2.2",
]

[project.scripts]
firstsync = "firstsync.cli:main"

[project.optional-dependencies]
agent = ["claude-agent-sdk>=0.2"]
dev = ["pytest>=8", "ruff>=0.6"]
dev = ["pytest>=8", "ruff>=0.6", "mypy>=1.10", "hypothesis>=6.100"]

[tool.setuptools.packages.find]
where = ["src"]
Expand All @@ -33,3 +38,14 @@ target-version = "py311"

[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP"]

[tool.mypy]
python_version = "3.11"
warn_unused_ignores = true
warn_redundant_casts = true
no_implicit_optional = true
check_untyped_defs = true

[[tool.mypy.overrides]]
module = ["mcp.*", "claude_agent_sdk.*"]
ignore_missing_imports = true
87 changes: 71 additions & 16 deletions results/claude-claude-haiku-5-5.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"seconds": 58.2,
"cost_usd": 0.013272869999999999,
"tool_calls": 19,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -952,7 +952,7 @@
"seconds": 48.6,
"cost_usd": 0.011559305,
"tool_calls": 18,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -1677,7 +1677,7 @@
"seconds": 50.4,
"cost_usd": 0.011660684999999999,
"tool_calls": 20,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -2407,7 +2407,7 @@
"seconds": 68.7,
"cost_usd": 0.015237024999999998,
"tool_calls": 23,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "low",
Expand Down Expand Up @@ -3158,7 +3158,7 @@
"seconds": 53.8,
"cost_usd": 0.012514434999999999,
"tool_calls": 20,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "low",
Expand Down Expand Up @@ -3894,7 +3894,7 @@
"seconds": 79.8,
"cost_usd": 0.016670515,
"tool_calls": 22,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "low",
Expand Down Expand Up @@ -4637,7 +4637,7 @@
"seconds": 56.4,
"cost_usd": 0.012831579999999999,
"tool_calls": 19,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -5362,7 +5362,7 @@
"seconds": 63.6,
"cost_usd": 0.01379824,
"tool_calls": 20,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -6091,7 +6091,7 @@
"seconds": 61.5,
"cost_usd": 0.012992345000000002,
"tool_calls": 20,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "medium",
Expand Down Expand Up @@ -6824,7 +6824,25 @@
"seconds": 56.7,
"cost_usd": 0.01273169,
"tool_calls": 18,
"is_error": false,
"dryrun_defects": {
"duplicate_contacts": {
"planted": 6,
"found": 6
},
"missing_email": {
"planted": 5,
"found": 5
},
"missing_amount": {
"planted": 4,
"found": 4
},
"short_phone": {
"planted": 3,
"found": 3
},
"defects_found": "4/4"
},
"proposals": {
"accounts.customer_since": {
"confidence": "medium",
Expand Down Expand Up @@ -7560,7 +7578,25 @@
"seconds": 60.0,
"cost_usd": 0.013467749999999999,
"tool_calls": 19,
"is_error": false,
"dryrun_defects": {
"duplicate_contacts": {
"planted": 6,
"found": 6
},
"missing_email": {
"planted": 5,
"found": 5
},
"missing_amount": {
"planted": 4,
"found": 4
},
"short_phone": {
"planted": 3,
"found": 3
},
"defects_found": "4/4"
},
"proposals": {
"accounts.customer_since": {
"confidence": "medium",
Expand Down Expand Up @@ -8293,7 +8329,25 @@
"seconds": 69.1,
"cost_usd": 0.01488839,
"tool_calls": 20,
"is_error": false,
"dryrun_defects": {
"duplicate_contacts": {
"planted": 6,
"found": 6
},
"missing_email": {
"planted": 5,
"found": 5
},
"missing_amount": {
"planted": 4,
"found": 4
},
"short_phone": {
"planted": 3,
"found": 3
},
"defects_found": "4/4"
},
"proposals": {
"accounts.customer_since": {
"confidence": "medium",
Expand Down Expand Up @@ -9027,7 +9081,7 @@
"seconds": 60.9,
"cost_usd": 0.015198864999999999,
"tool_calls": 23,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -9782,7 +9836,7 @@
"seconds": 57.0,
"cost_usd": 0.014463805,
"tool_calls": 22,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -10553,7 +10607,7 @@
"seconds": 66.5,
"cost_usd": 0.01553959,
"tool_calls": 22,
"is_error": false,
"dryrun_defects": null,
"proposals": {
"accounts.customer_since": {
"confidence": "high",
Expand Down Expand Up @@ -11098,5 +11152,6 @@
]
}
},
"mean_accuracy": 0.9885
"mean_accuracy": 0.9885,
"rescored": "2026-11-13T21:33:57+00:00"
}
Loading
Loading