Repository navigation
feat(writeback): apply approved Salesforce upserts through a journal (#998) - #1324
Merged
Merged
Conversation
…998) Golden records that arrived by upload and are not yet in a Salesforce object can be upserted there, reviewed and approved like merges. - Upsert policies (PUT/GET …/writeback/upsert-policies, append-only): the External ID field keyed on, a golden → field mapping, an allowlist, and the delivery sources (an import's) whose records may be upserted. - Materialized by the same merge_preview job, runs and checkpoint: an entity is a candidate when a member came from a policy source and none is already provenanced from the policy's object — that entity is a merge's, never an upsert's. Golden values, mapped and allowlisted; nulls omitted; keyed by the entity id; idempotent on a fingerprint. - Review: GET …/upsert-previews, POST …/upsert-previews/decide (≤100, each item checked against its fingerprint and live policy revision), and an Upserts section on the writeback page. - Apply (POST …/upsert-previews/apply → upsert_apply job): APPROVED → APPLYING at most once; the record read by its External ID; a record modified after the proposal is skipped as stale; the preimage written and the call marked in flight before PATCH …/{object}/{field}/{key}. An in-flight call is reconciled by reading back; keyed by External ID, a retry updates the same record and can never create a second. - A created record is asserted always-match to its entity's upload member, so the next extraction converges on it rather than resolving a new entity. 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 09:08 — 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 #998
Upsert policies, upsert previews materialized by the existing preview job, review (batch decide + the writeback page's Upserts section), the journaled
upsert_applyjob with read-back reconciliation, and convergence by an always-match assertion. Entitiesupsert_policy,upsert_preview,upsert_apply;connectors.md§4.3.5.#998: the last E9 writeback mode — upserting golden records Salesforce does not have yet, with the same authorization, staleness, journal and review as merges.
Proof
pg_upsert_applyagainst a mock Salesforce: a create (preimage = null, a new id, and the always-match assertionwebforms:<entity> ↔ sfdc:<new id>staged); an update (preimage holds the old value); a record modified after the proposal →skipped_stale, never written; an upsert that landed but answered 500 → left in flight, thencreated"verified by reading the record back" with no second write and no duplicate record; a refusal →failedwith the code. Policy validation (role, object, golden attribute,Idnever writable); batch decide reports a stale fingerprint per item; apply 409 with nothing approved.pg_merge_preview_dag(real DuckLake pipeline): with an upsert policy onwebforms, the webforms-only entities are proposed keyed by their entity id with only allowlisted, non-null golden fields; the entity already synced from Contact is not proposed (it is the merge preview).writeback.spec.ts: a steward approves a proposed upsert; an admin applies.make checkexit 0; Postgres suite 161 passed;make frontendgreen (vitest 1139, Playwright 1110).Risk & rollback
Opt-in per (connection, object) and per source; nothing is written until an admin applies approved upserts.
git revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:24d16c2e-fec6-49d8-9797-060338df4848onbrians-MacBook-Pro· 2026-11-27T09:58:37Zmainis 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: — 3ec5d1f, rust 45971243621 + frontend 45971243538 success
imagesbuilt, or correctly never ran because nothing that goes intoan image changed: — success, run 45971243513
deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: — run 45971807456 success; the live process serves the new route:
https://dupezero.com/api/openapilists/upsert-previews/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 3ec5d1f
Donethrough the automation rather than byhand, and the issue closed: — E9: Apply approved upserts through the writeback journal #998 CLOSED by feat(writeback): apply approved Salesforce upserts through a journal (#998) #1324 via automation
(a skill, a reference, memory) — or nothing new was learned: — the docs-reference gate needs each new public resource in a workflow group (
upsert-previews→ api-writeback); caught by vitest, fixed before pushSpecific to this change
upsert_policies,upsert_previewsandupsert_applies— the new er-server serves (boot reconcile refuses to start on a failed apply), run 45971807456Context — plan, discoveries, measurements, files
Plan
Discoveries
sources: an import into a named source feeds the same generation, so there is no second trigger path.Measurements
Files
🤖 Generated with Claude Code