Skip to content

feat(writeback): merge-preview persistence and the approval API (#1305) - #1308

Merged
athvin merged 1 commit into
mainfrom
feat/1305-preview-approval
Nov 27, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/1305-preview-approval

Conversation

@athvin

@athvin athvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #1305

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

Three Postgres entities (writeback_policies, merge_previews, merge_preview_journal, 9 statements), PersistedProposalV1, pg::publish_preview / decide_preview, and five routes for policies, preview listing/detail and approve/reject. First half of #993.

E9 (#514) needs approval to bind an exact immutable proposal before any provider write (#995). The watermark entity moves to the materialization PR, where its consumer lives.

Proof

  • pg_merge_preview_api: policy roles/validation/append-only, idempotent publish, supersede, viewer read, steward decide, unknown body field 422, stale fingerprint 409, approve twice 200, reject-after-approve 409, cross-org 404, journal shows only real changes, replaced policy blocks approval.
  • writeback unit tests: round-trip to the same fingerprint, pinned fingerprint, unknown format and invalid input refused.
  • Full cargo test -p er-server --test main against Postgres: 156 passed. Frontend unit suite: 1117 passed. make check: exit 0.

Risk & rollback

Additive tables and routes; no external effect. Revert leaves empty tables.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on Mac · 2026-11-27T04:50:27Z

  • 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: bb0232cc — rust 45941203195, frontend 45941203186, infra 45941203613 success
  • images built, or correctly never ran because nothing that goes into
    an image changed: 45941203214 success
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: deploy 45941574295 success (dev + prod); its atomic pre-upgrade schema-migrate created the three tables
  • 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: drift/kind red for known reasons (Confirm the er-alerts email subscription and prove alert delivery #1056, kind probe red since 2026-11-10: KeyError 'token_hash' after the credential-omission fix #1106)
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: E9: merge-preview persistence and the approval API #1305 CLOSED via the merge
  • follow-ups are open for everything deferred here — numbers: E9: Materialize merge previews and persist approval #993 (the materialization job, in progress)
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: nothing new beyond the DATASET_SCOPED rule already in memory

Specific to this change

  • the deploy's schema-migrate created the three tables in dev and prod — deploy 45941574295 success
Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

🤖 Generated with Claude Code

The first half of #993: a writeback proposal can be stored, inspected and
approved through the tenant API, and an approval binds exactly one
immutable proposal. Nothing here writes to Salesforce.

- writeback_policies: append-only revisions per (connection, object) —
  allowlist, field mapping, election policy. A row id is the revision a
  preview binds; no policy means nothing is proposed.
- merge_previews: immutable content (persisted proposal, field changes,
  snapshot, policy revision, fingerprint) plus decision columns;
  merge_preview_journal records every change in the same transaction.
- PersistedProposalV1 stores the UNVALIDATED input; restoring always
  re-runs MergeProposal::build, with a pinned fingerprint fixture.
- pg::publish_preview is idempotent on the fingerprint and supersedes the
  group's older planned preview; pg::decide_preview is a compare-and-set on
  (id, fingerprint, planned).
- Routes: PUT/GET …/writeback/policies, GET …/merge-previews[/{id}],
  POST …/merge-previews/{id}/approve|reject {fingerprint, reason?}. Stale
  fingerprint, decided preview, replaced policy or inactive connection →
  409; repeat decision → idempotent 200; cross-org → 404.

The materialization job that produces previews from lake results is the
second half and closes #993.

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 bb0232c into main Nov 27, 2026
48 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 27, 2026 04:39 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — a078f6d1 Deployed Nov 27, 2026 by athvin via remove closed PR previews #93
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: merge-preview persistence and the approval API

2 participants