Skip to content

feat: protect enforcement — protected record wins the merge-plan master (1.3b) - #116

Merged
athvin merged 2 commits into
mainfrom
feat/protect-enforcement
Oct 16, 2026
Merged

athvin merged 2 commits into
mainfrom
feat/protect-enforcement

Conversation

@athvin

@athvin athvin commented Oct 16, 2026

Copy link
Copy Markdown
Owner

What

PR 1.3 shipped the protect overlay as inert storage — the apply arm wrote record_overlays kind='protect' but nothing read it. This wires the read-path enforcement the feature promised: a member record with an active protect overlay is elected the surviving master for its entity, overriding the survivorship policy.

Why the read path (merge-plans), not golden assembly

Golden records have committed, byte-identical fixtures gated in CI. Enforcing protect inside golden assembly would put a steward-exception feature on the determinism contract. read::merge_plans has no committed fixture, so the override is determinism-trivially-safe. The never-cut guarantee + contradiction precheck (the write-path half of protect) stay deferred to 1.3c.

Changes

  • read::merge_plans — a protected CTE (active record_overlays kind='protect' joined to the affected entities' members) COALESCE'd ahead of the policy election. Gated on the overlay table existing and holding ≥1 active protect row, so when nothing is protected (or the steward drain never created the table) the SQL collapses to the exact prior masters AS (…) — byte-exact, no behavior change. Mirrors load_suppressed_keys' is_missing_table graceful-absence pattern.
  • Endpoints — POST /records/protect + /unprotect, mirroring suppress/unsuppress. suppress_record_action generalised to record_overlay_action(overlay, retract) so both overlays share one staged-action → apply_corrections drain path.
  • Frontend — a steward Protect row action in the entity view (+ BFF routes + useProtectRecords), alongside Exclude. Viewer surfaces unchanged.
  • Tests — pg_protect_master e2e (own binary) drives a real merge_scenario (base→incremental, so reconcile emits merged/member_added — base_10 only emits created, so its plan is empty), protects a non-master member, asserts it becomes the merge-plan master, then unprotect reverts to the policy master. Plus a Playwright steward/viewer functional pair.

Verification (local)

  • Rust: cargo fmt / clippy -D warnings clean; pg_protect_master, pg_record_overlays (suppress, no regression), pg_golden_read, pg_drain_dispatcher, er-server lib tests, er-cli lake_e2e golden byte-identity — all green against docker Postgres.
  • Frontend: pnpm check (eslint/prettier/tsc/vitest 59) + protect/records/steward-surfaces Playwright (17) — all green.
  • No golden/fixture changes — determinism contract intact.

🤖 Generated with Claude Code

…-plan master (1.3b)

PR 1.3 shipped the `protect` overlay as inert storage (the apply arm writes
`record_overlays kind='protect'` but nothing read it). This wires the read-path
enforcement the feature promised: a member record with an active `protect`
overlay is elected the surviving master for its entity, overriding the
survivorship policy.

Why the read path (merge-plans), not golden assembly: golden records have
committed byte-identical fixtures gated in CI. Enforcing there would touch the
determinism contract for a steward-exception feature. merge-plans
(`read::merge_plans`) has no committed fixture, so the override is
determinism-trivially-safe. The never-cut guarantee + contradiction precheck
(the write-path half) stay deferred to 1.3c.

- read::merge_plans: a `protected` CTE (active `record_overlays kind='protect'`
  joined to the affected entities' members) COALESCE'd ahead of the policy
  election. Gated on the overlay table existing AND holding ≥1 active protect
  row — when nothing is protected (or the steward drain never created the
  table) the SQL collapses to the exact prior `masters AS (...)`, byte-exact.
  Mirrors load_suppressed_keys' is_missing_table graceful-absence pattern.
- endpoints: POST /records/protect + /unprotect, mirroring suppress/unsuppress.
  suppress_record_action generalised to record_overlay_action(overlay, retract)
  so both overlays share one staged-action + apply_corrections drain path.
- frontend: a steward Protect row action in the entity view (+ BFF routes +
  useProtectRecords), alongside Exclude. Viewer surfaces unchanged.
- tests: pg_protect_master e2e (own binary) drives a real merge_scenario
  (base→incremental so reconcile emits merged/member_added — base_10 only emits
  `created`, so its plan is empty), protects a non-master member, and asserts it
  becomes the merge-plan master; unprotect reverts to the policy master. Plus a
  Playwright steward/viewer functional pair. No golden fixture changes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@athvin
athvin force-pushed the feat/protect-enforcement branch from 74dc324 to 9aa3caa Compare October 16, 2026 09:10
The Members-card action row gained a third button (Protect, alongside
Unmerge and Exclude), each carrying a text label. In the CardHeader's
flex-row/justify-between layout with a non-wrapping `flex gap-2` button
container, three labelled buttons overflow horizontally on a ~412px
mobile viewport, pushing the last button (Protect) off-screen so its
click times out. This surfaced as mobile-chrome-only Playwright failures
on the new protect test plus the pre-existing merge/wizard specs sharing
the viewport.

Stack the header on mobile (`flex-col` → `sm:flex-row`) and let the
button row wrap (`flex-wrap`). The `sm:` breakpoint restores the exact
original desktop row, so desktop is behaviorally unchanged; the three
previously-failing specs now pass on `--project=mobile-chrome`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@athvin
athvin merged commit b9e07d4 into main Oct 16, 2026
10 checks passed
@athvin
athvin deleted the feat/protect-enforcement branch October 16, 2026 09:33
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.

2 participants