Skip to content

feat(writeback): apply approved Salesforce merges through a durable journal (#995) - #1317

Merged
athvin merged 1 commit into
mainfrom
feat/995-journaled-apply
Nov 27, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/995-journaled-apply

Conversation

@athvin

@athvin athvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #995

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_apply job (one control task, apply_merges), src/merge_apply.rs (the journaled state machine), src/sf_apply.rs (queryAll / PATCH / SOAP merge with classified outcomes), entities merge_apply + merge_apply_operation, the apply route, an Egress on ExecutorConfig, and the as-built contract in connectors.md §4.3.2.

#995: execute exactly the approved proposals, safely, with a durable record. Builds on #993 (previews) and #994 (delegated authorization); #996 restore reads its preimages.

Proof

pg_merge_apply: eight approved groups against a mock Salesforce (queryAll, PATCH, SOAP merge, token refresh) — clean apply (victim deleted with MasterRecordId = master, preimage stored); stale member → skipped_stale + one resync extract queued, no mutation; external merge → applied_externally with zero mutations; missing victim → failed; a 429 with Retry-After retried to success; a merge whose response was lost (performed, then 500) left in flight, then resolved verified by the next run's re-read with no second merge call; a rejected merge (ENTITY_IS_LOCKED) fails its group while the batch continues; REQUEST_LIMIT_EXCEEDED stops the job and the begun group resumes and applies next run; a third run touches nothing. Journal path planned → approved → applying → applied. Route: 409 with nothing approved, viewer 403, admin 202. Full Postgres suite 159 passed; make check exit 0.

Risk & rollback

Writes to customer Salesforce only for previews a human approved, through a grant an admin authorized; nothing in dev has a grant. 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:20:43Z

  • 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: — 5ed5a11: rust 45955972000 success; its frontend run was cancelled by the next merge's burst, so frontend is proven on d05da84 (contains 5ed5a11), run 45956035108 success
  • images built, or correctly never ran because nothing that goes into
    an image changed: — success, run 45955972021 (and 45956035174 on d05da84)
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: — run 45956397395 deployed d05da84 (contains this change); the live process serves the new route: https://dupezero.com/api/openapi lists /merge-previews/apply
  • 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 success on 5ed5a11; marketing preview success on d05da84
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: — E9: Apply approved Salesforce merges with a durable journal #995 CLOSED by feat(writeback): apply approved Salesforce merges through a durable journal (#995) #1317 via automation
  • follow-ups are open for everything deferred here — numbers: — none
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: — a new required-ish workflow (stale tree guard, feat(ci): flag a pull request whose files return to an older main version (#1307) #1315) fails on a branch cut before it existed because its script is absent; rebasing is the fix, not a finding

Specific to this change

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

Plan

Discoveries

  • Salesforce's REST API has no merge; merge() is SOAP-only, so the apply speaks both.
  • The SQL analyser attributes a status literal in an INSERT … SELECT's WHERE to the insert target's accepted values (E010), so merge_apply/create/begin binds 'approved' as a parameter.
  • The apply runs inside the executor's control loop, which is serial; the per-job caps (25 groups, 100 mutations) bound how long it holds that loop.

Measurements

Files

🤖 Generated with Claude Code

@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.

…ournal (#995)

POST …/merge-previews/apply (Admin) queues a merge_apply job: one control
task that executes exactly the approved proposals, acting as the
connection's delegated reviewer (#994).

- APPROVED → APPLYING is a conditional insert under a unique index (at most
  once per preview), journaled in the same transaction; each apply settles
  once into applied / failed / skipped_stale / applied_externally.
- Before any write, every member is re-read (queryAll): a moved
  SystemModstamp skips the group as stale and queues an incremental extract
  so the next generation re-scores it; a victim deleted with MasterRecordId
  = master is external-merge evidence; a missing victim proves nothing and
  fails the group.
- The preimage is persisted before the first mutation; the master update
  (PATCH) and each merge batch (SOAP merge(), ≤2 victims) are journaled in
  flight before the call. An in-flight operation is resolved by the next
  run's re-read, never replayed blind.
- Reads retry with backoff; mutations retry only on 429/503 (Retry-After
  honoured up to 30s); any other post-send failure is ambiguous. API-budget
  exhaustion and exhausted rate limits stop the job and the begun group
  resumes. Groups fail in isolation; cancellation is checked between them.
- Entities merge_apply and merge_apply_operation; the executor carries an
  Egress (Guarded in product code) so the test can reach a mock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin force-pushed the feat/995-journaled-apply branch from 23fe622 to 0f181f4 Compare November 27, 2026 06:56
@athvin
athvin merged commit 5ed5a11 into main Nov 27, 2026
46 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 27, 2026 07:04 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 0f181f48 Deployed Nov 27, 2026 by athvin via remove closed PR previews #101
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: Apply approved Salesforce merges with a durable journal

2 participants