Skip to content

feat(writeback): restore merged Salesforce records and revert master changes (#996) - #1320

Merged
athvin merged 1 commit into
mainfrom
feat/996-restore
Nov 27, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/996-restore

Conversation

@athvin

@athvin athvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #996

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

The merge_restore job (restore_merges), src/merge_restore.rs, three Salesforce calls in sf_apply (SOAP undelete(), REST create, field read), entities merge_restore + merge_restore_step, the POST/GET restore routes, and connectors.md §4.3.3.

#996: an applied merge must be undoable from its journal — without overwriting edits made since and without pretending reparented children move back.

Proof

pg_merge_restore against a mock Salesforce (queryAll, query, PATCH, create, SOAP merge/undelete): three groups applied through #995, then undone. A: victim undeleted, master Email reverted → restored. B: Recycle Bin emptied and the master edited after the merge → victim recreated with old→new id recorded, the edited Email reported as a conflict and left untouched → partial. C: the undelete's response lost → left in flight, then verified by the next run with no second undelete call. Never-match assertions staged; a repeated undo queues nothing; viewer 403; another tenant 404; nothing-applied 404; a third run touches nothing; the journal reads planned → approved → applying → applied → restoring → partial. Full Postgres suite 160 passed; make check exit 0.

Risk & rollback

Admin-only, acts only on our own applied merges, refuses to overwrite anything changed since. git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-27T07:39:08Z

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not: — 14f24d0, rust 45957756424 + frontend 45957756342 success
  • images built, or correctly never ran because nothing that goes into
    an image changed: — success, run 45957756451
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: — run 45958143471 success; the live process serves the new route: https://dupezero.com/api/openapi lists /merge-previews/{preview_id}/restore
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: — infra, devcontainer, marketing preview all success on 14f24d0
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: — E9: Restore merged records and revert approved master changes #996 CLOSED by feat(writeback): restore merged Salesforce records and revert master changes (#996) #1320 via automation
  • follow-ups are open for everything deferred here — numbers: — Salesforce Files archival and audit-driven retry stay with API: restore a dataset's results to an earlier run, and document the recovery operations #530, as the ticket scoped
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: — nothing beyond the PR's Discoveries

Specific to this change

  • the deploy reconciles merge_restores and merge_restore_steps — the new pod serves (boot reconcile refuses to start on a failed apply), run 45958143471
Context — plan, discoveries, measurements, files

Plan

Discoveries

  • Like merge(), undelete() is SOAP-only.
  • A retried master revert whose first attempt landed reads back the preimage value; treating "already the preimage" as reverted (not a conflict) is what makes the revert retry-safe.

Measurements

Files

🤖 Generated with Claude Code

…changes (#996)

POST …/merge-previews/{id}/restore (Admin) undoes an applied merge from the
apply's journal; GET shows its steps and conflicts. One undo per apply — a
repeat request returns it and queues nothing.

- Resolution side: a never-match assertion per (master, victim), staged
  exactly as the engine's unmerge does, so resolution does not re-propose.
- Victims: SOAP undelete() from the Recycle Bin; when the bin no longer has
  the record, recreated from the preimage (system fields dropped) with the
  old → new id recorded; a victim already live is left alone.
- Master: each field the apply wrote is reverted only where Salesforce still
  holds what the apply wrote; a value already back is left; anything else
  is a conflict, never overwritten.
- merge_restore_steps are journaled in flight before each call: a lost
  undelete is resolved by the next run's re-read; a recreate with an unknown
  outcome is a conflict, never retried (it could duplicate).
- Records the merge reparented are NOT moved back, and the view says so
  (related_records_reverted: false).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

@athvin
athvin merged commit 14f24d0 into main Nov 27, 2026
49 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 27, 2026 07:20 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — c754fb31 Deployed Nov 27, 2026 by athvin via remove closed PR previews #103
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.

E9: Restore merged records and revert approved master changes

2 participants