Repository navigation
feat(writeback): convert duplicate Salesforce Leads into existing Contacts (#520) - #1326
Merged
Merged
Conversation
…tacts (#520) A steward converts a duplicate Lead into the existing Contact it resolved with, through the same proposal, approval and journal discipline as merges — never a second write path. Opt-in by writeback policies for both Lead and Contact. - Proposed by the merge_preview job: an entity holding Leads and exactly one Contact converts each Lead into it (its Lead merge group is then not proposed); with several Contacts the Contact merge lands first. The proposal pins both records' revision tokens, both policy revisions and the snapshot, and is idempotent on its fingerprint. - Review: GET …/lead-conversions, POST …/lead-conversions/decide (fingerprint and both policy revisions live per item), and a Lead conversions section on the writeback page that states conversion cannot be undone. - Apply (POST …/lead-conversions/apply → lead_convert job): at most once per proposal; both records re-read; a Lead already converted into the same Contact is CONVERTED_EXTERNALLY, converted elsewhere or deleted is FAILED (reported, never retried); a moved SystemModstamp is SKIPPED_STALE; the Contact's Account recorded and the call marked in flight before SOAP convertLead(); a lost response is resolved by re-reading the Lead. - After a conversion, a FULL Lead extract (which omits converted Leads, so ingest tombstones it and the next run drops it from the entity) and an incremental Contact extract are queued. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
The marketing preview was removed because this PR is closed or merged. |
athvin
temporarily deployed
to
marketing-preview
November 27, 2026 10:10 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Closes #520
Lead conversion proposals materialized by the existing preview job, review (batch decide + a writeback-page section), the journaled
lead_convertjob over SOAPconvertLead(), and corpus convergence by a full Lead re-extract. Entitieslead_conversion,lead_conversion_apply;connectors.md§4.3.6 (including recovery: none — conversion is not reversible).#520 (E10): convert a duplicate Lead into its existing Contact from an approved proposal through the same writeback journal as merges.
Proof
pg_lead_convertagainst a mock Salesforce (queryAll, LeadStatus query, SOAP convertLead): a clean conversion into the Contact's Account; a Lead already converted into the same Contact →converted_externally, nothing sent; one converted into another Contact →failed"not reversible", nothing sent; a stale Lead →skipped_stale, nothing sent; a Contact without an Account →failed, nothing sent; a lost response → in flight, thenconverted"verified by re-reading the Lead" with no secondconvertLead. Four extracts queued for the two conversions (full Lead + incremental Contact each). Decide: viewer 403, steward 200 per item; apply 409 with nothing approved.writeback.spec.ts: a steward approves a conversion, an admin converts.make checkexit 0; Postgres suite 162 passed.make frontend: vitest 1139 passed; Playwright 1112 passed, 1 failed —triage.spec.ts"20 reviews by swipe alone" on mobile-safari, the reviews inbox this diff does not touch, run while the machine was loaded (the PG suite took 332s against the usual ~90s). CI's run is the arbiter.Risk & rollback
Conversion is irreversible in Salesforce, so the apply refuses on any doubt (stale, converted elsewhere, no Account) and never replays an unknown outcome; opt-in by two policies; admin-only apply.
git revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:24d16c2e-fec6-49d8-9797-060338df4848onbrians-MacBook-Pro· 2026-11-27T23:38:06Zmainis green with this change on it — the merge SHA, and the runthat proves it. A later head SHA with this commit as an ancestor counts;
a cancelled run with zero jobs does not: — b95e683, rust 45979912382 + frontend 45979912506 success
imagesbuilt, or correctly never ran because nothing that goes intoan image changed: — success, run 45979912492
deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: — run 45980524947 success; the live process serves the new route:
https://dupezero.com/api/openapilists/lead-conversions/applydeploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: — infra, devcontainer, marketing preview all success on b95e683
Donethrough the automation rather than byhand, and the issue closed: — E10 — Lead conversion #520 CLOSED by feat(writeback): convert duplicate Salesforce Leads into existing Contacts (#520) #1326 via automation
(a skill, a reference, memory) — or nothing new was learned: — the local mobile-safari triage failure did not reproduce in CI (the machine was loaded by a parallel release build)
Specific to this change
lead_conversionsandlead_conversion_applies— the new er-server serves (boot reconcile refuses to start on a failed apply), run 45980524947Context — plan, discoveries, measurements, files
Plan
Discoveries
IsConverted = false— so a full Lead re-extract after converting is exactly the exclusion.Measurements
Files
🤖 Generated with Claude Code