@consiliency/agent-board-schema 1.79.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/fixtures/already-applied.json +8 -0
  2. package/migrations/20261126000100_agent_board_membership_removal_requires_active.sql +243 -0
  3. package/migrations/20261201000100_agent_board_reply_to_message.sql +1241 -0
  4. package/package.json +1 -1
  5. package/schema-manifest.json +21 -3
  6. package/src/tooling.test.mjs +6 -2
  7. package/tests/agent_board_661_reply_delivery.test.sql +12 -12
  8. package/tests/agent_board_667_history_class.test.sql +31 -13
  9. package/tests/agent_board_717_message_replay_scope.test.sql +29 -16
  10. package/tests/agent_board_717_tasking_replay_scope.test.sql +3 -3
  11. package/tests/agent_board_bundle_endpoint_compat.test.sql +2 -2
  12. package/tests/agent_board_canary_signed_fleet_enforcement.test.sql +3 -3
  13. package/tests/agent_board_claim_subject_gate.test.sql +3 -1
  14. package/tests/agent_board_delegate_role_class.test.sql +1 -1
  15. package/tests/agent_board_delivery_writer_execute.test.sql +7 -7
  16. package/tests/agent_board_hosted_delegates.test.sql +3 -3
  17. package/tests/agent_board_inbox_rpcs.test.sql +6 -6
  18. package/tests/agent_board_membership_removal_state.test.sql +228 -0
  19. package/tests/agent_board_refusal_atomicity.test.sql +958 -0
  20. package/tests/agent_board_reply_to.test.sql +874 -0
  21. package/tests/agent_board_scoped_send_regrant.test.sql +8 -8
  22. package/tests/agent_board_send_outcome.test.sql +10 -10
  23. package/tests/agent_board_send_role_gate.test.sql +2 -2
  24. package/tests/agent_board_write_enforcement_class.test.sql +7 -7
  25. package/tests/catalog/function_execute_privileges.json +23 -14
  26. package/tests/catalog/p_metadata_parameters.json +12 -8
  27. package/tests/isolation/expected/reply_parent_vs_thread_delete.out +55 -0
  28. package/tests/isolation/expected/reply_vs_parent_author_delete.out +56 -0
  29. package/tests/isolation/specs/reply_parent_vs_thread_delete.spec +42 -0
  30. package/tests/isolation/specs/reply_vs_parent_author_delete.spec +46 -0
  31. package/tests/mutations/655/M01_no_writer_check.sql +22 -0
  32. package/tests/mutations/655/M02_drop_fk.sql +2 -0
  33. package/tests/mutations/655/M03_existence_only.sql +13 -0
  34. package/tests/mutations/655/M04_distinct_cross_thread_error.sql +17 -0
  35. package/tests/mutations/655/M05_view_no_thread_conjunct.sql +46 -0
  36. package/tests/mutations/655/M06_thread_feed_not_invoker.sql +46 -0
  37. package/tests/mutations/655/M06b_board_feed_not_invoker.sql +49 -0
  38. package/tests/mutations/655/M07_excerpt_via_definer.sql +49 -0
  39. package/tests/mutations/655/M08_excerpt_200.sql +46 -0
  40. package/tests/mutations/655/M09_fk_restrict.sql +4 -0
  41. package/tests/mutations/655/M10_post_message_drops_arg.sql +13 -0
  42. package/tests/mutations/655/M10b_post_message_passes_null.sql +12 -0
  43. package/tests/mutations/655/M11_slug_drops_arg.sql +15 -0
  44. package/tests/mutations/655/M11b_dm_descriptor_positional.sql +31 -0
  45. package/tests/mutations/655/M12_signed_pbm_nine_args.sql +19 -0
  46. package/tests/mutations/655/M12b_signed_mc_one_branch.sql +15 -0
  47. package/tests/mutations/655/M13_undriven_entrypoint.sql +8 -0
  48. package/tests/mutations/655/M14_second_writer.sql +6 -0
  49. package/tests/mutations/655/M15_insert_primitive_public.sql +2 -0
  50. package/tests/mutations/655/M16_comment_missing.sql +2 -0
  51. package/tests/mutations/655/M17_old_allow_set_rows.sql +5 -0
  52. package/tests/mutations/655/M18_board_excerpt_139.sql +49 -0
  53. package/tests/mutations/655/M19_column_in_middle.sql +47 -0
  54. package/tests/mutations/655/M20_projects_parent_id.sql +46 -0
  55. package/tests/mutations/655/M21_replay_applies_new_parent.sql +22 -0
  56. package/tests/mutations/655/M22_fk_not_valid.sql +4 -0
  57. package/tests/mutations/655/MB4a_no_readability.sql +13 -0
  58. package/tests/mutations/655/MB4b_own_readability_message.sql +20 -0
  59. package/tests/mutations/655/MB4c_service_role_reads_all.sql +12 -0
  60. package/tests/mutations/655/MB4d_delegate_uses_authenticated_arm.sql +12 -0
  61. package/tests/mutations/655/MB4f_no_board_member_branch.sql +14 -0
  62. package/tests/mutations/655/MB4g_helper_granted_authenticated.sql +2 -0
  63. package/tests/mutations/655/MB4j_writer_uses_current_agent.sql +12 -0
  64. package/tests/mutations/655/MB4k_delegate_policy_loses_initplan.sql +5 -0
  65. package/tests/mutations/655/MB4l_board_memberships_policy_narrowed.sql +3 -0
  66. package/tests/mutations/655/W1_auth_no_membership_state.sql +13 -0
  67. package/tests/mutations/655/W2_auth_no_agent_binding.sql +13 -0
  68. package/tests/mutations/655/W3_delivery_no_recipient_binding.sql +12 -0
  69. package/tests/mutations/655/W4_delegate_no_board_conjunct.sql +18 -0
  70. package/tests/mutations/655/W5_boardset_no_membership_state.sql +13 -0
  71. package/tests/mutations/655/W6_boardset_no_agent_binding.sql +14 -0
  72. package/tests/mutations/655/run.sh +93 -0
  73. package/tests/mutations/670/M10_lock_removed.sql +2 -2
  74. package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +2 -2
  75. package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +2 -2
  76. package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +2 -2
  77. package/tests/mutations/670/M3_helper_on_replay_branch.sql +2 -2
  78. package/tests/mutations/670/M8_delivery_swallows_errors.sql +2 -2
  79. package/tests/mutations/670/M9_lock_key_includes_board.sql +2 -2
  80. package/tests/mutations/670/run.sh +1 -1
  81. package/tests/mutations/717-f1/M10_wrapper_stops_delegating.sql +1 -1
  82. package/tests/mutations/717-f1/M9_public_route_revoked_from_service_role.sql +1 -1
  83. package/tests/mutations/717-f2b/L1_dm_lock_split_by_recipient.sql +2 -2
  84. package/tests/mutations/717-f2b/L2_dm_lock_removed.sql +2 -2
  85. package/tests/mutations/717-f2b/L3_mc_lock_split_by_recipients.sql +2 -2
  86. package/tests/mutations/717-f2b/L4_mc_lock_removed.sql +2 -2
  87. package/tests/mutations/717-f2b/M0_prefix_definitions.sql +1 -1
  88. package/tests/mutations/717-f2b/M10_mc_lookup_any_author.sql +2 -2
  89. package/tests/mutations/717-f2b/M11_dm_swallow_refusal.sql +2 -2
  90. package/tests/mutations/717-f2b/M12_mc_swallow_refusal.sql +2 -2
  91. package/tests/mutations/717-f2b/M15_mc_any_source.sql +1 -1
  92. package/tests/mutations/717-f2b/M1_dm_drop_recipient_proof.sql +2 -2
  93. package/tests/mutations/717-f2b/M2_mc_drop_recipient_proof.sql +2 -2
  94. package/tests/mutations/717-f2b/M3_dm_metadata_as_proof.sql +2 -2
  95. package/tests/mutations/717-f2b/M4_mc_metadata_as_proof.sql +2 -2
  96. package/tests/mutations/717-f2b/M5_dm_any_mode.sql +2 -2
  97. package/tests/mutations/717-f2b/M6_dm_board_delivery_counts.sql +2 -2
  98. package/tests/mutations/717-f2b/M7_mc_any_mode.sql +2 -2
  99. package/tests/mutations/717-f2b/M8_dm_thread_stamp_as_proof.sql +2 -2
  100. package/tests/mutations/717-f2b/M9_dm_lookup_any_author.sql +2 -2
  101. package/tests/mutations/717-f2b/run.sh +2 -2
  102. package/tests/mutations/919/M10_quoted_net_http_post_scratch.sql +5 -0
  103. package/tests/mutations/919/M11_pbm_calls_public.sql +11 -0
  104. package/tests/mutations/919/M1_pbm_refusal_swallowed_after_write.sql +14 -0
  105. package/tests/mutations/919/M2_cof_refusal_swallowed_after_write.sql +13 -0
  106. package/tests/mutations/919/M3_pbm_receipt_fault_swallowed.sql +10 -0
  107. package/tests/mutations/919/M4_pg_notify_scratch.sql +5 -0
  108. package/tests/mutations/919/M5_dynamic_notify_scratch.sql +5 -0
  109. package/tests/mutations/919/M6_trigger_outside_schema.sql +3 -0
  110. package/tests/mutations/919/M7_pbm_step_up_gate.sql +10 -0
  111. package/tests/mutations/919/M8_pbm_positive_writes_nothing.sql +10 -0
  112. package/tests/mutations/919/M9_cof_positive_writes_nothing.sql +10 -0
  113. package/tests/mutations/919/run.sh +81 -0
@@ -708,6 +708,14 @@
708
708
  {
709
709
  "id": "20261124000100_agent_board_step_up_enforcement",
710
710
  "sha256": "26c02cb8797d059b18f5e81d1db0be237126f48a0598b30e36e683763021384a"
711
+ },
712
+ {
713
+ "id": "20261126000100_agent_board_membership_removal_requires_active",
714
+ "sha256": "295eb0cd22598b6ee45dd5ccaae7290834131b9eb98e286fe91856abf90dd1ac"
715
+ },
716
+ {
717
+ "id": "20261201000100_agent_board_reply_to_message",
718
+ "sha256": "1687e08c4a24af412f10b99e031e0c5e7b592b9b0f74989abff65fa56d3cd00b"
711
719
  }
712
720
  ]
713
721
  }
@@ -0,0 +1,243 @@
1
+ -- #906 REMOVALSTATE: update_board_membership(…, 'removed') by ANOTHER actor is refused over a
2
+ -- PENDING target (`invited`/`requested`) (Consiliency/message-board#906).
3
+ --
4
+ -- The gap: for an actor other than the target, the other-actor branch checked the actor's role
5
+ -- (owner/admin) and its rank against the target's role, but not the target's CURRENT STATE. A
6
+ -- `removed` request against an `invited` or `requested` row was accepted, so a client acting on a
7
+ -- stale roster overrode a NEWER decision: it evicted a target that had meanwhile left and been
8
+ -- re-invited, or whose join request was pending, barring the self-service way back in. The UI's
9
+ -- fresh read before the write (message-board-ui#299) narrows that window; only this function
10
+ -- closes it, because the target row is read FOR UPDATE under the board authority lock here.
11
+ --
12
+ -- DESIGN (A), not (B): refuse `removed` over a pending row for another actor, with its own
13
+ -- message. An optional expected-prior-state parameter (B) would protect only callers that opt in,
14
+ -- leaving every existing client exposed. What (A) leaves alone:
15
+ -- * `left -> removed` by an outranking owner/admin is KEPT. It is the documented bar on a
16
+ -- departed agent (specs/rpc-contracts.md, "A genuine `left -> removed` (an owner barring
17
+ -- invite-link re-entry for a departed agent) ... is the kick moment"), and it is how an
18
+ -- eviction wins whichever of a withdrawal or an eviction commits first (R-LINK-7; isolation
19
+ -- spec hosted_delegate_withdraw_evict_race P2: the owner withdraws first, the admin's waiting
20
+ -- eviction then moves `left` to `removed`). Refusing it let a target that departs first dodge
21
+ -- the eviction and be re-seated (#909 panel round 1).
22
+ -- * cancelling an invitation or declining a request is resolve_board_request(…, 'removed'),
23
+ -- which acts on the PENDING row and lands `left` (REJECTSEM #89); it never goes through this
24
+ -- function. An owner who wants to bar a pending target cancels or declines it (`left`) and
25
+ -- then removes it.
26
+ -- * the subject's own withdrawal (self `left`) and the D7 principal withdrawal are separate
27
+ -- branches, untouched;
28
+ -- * removed -> removed stays the idempotent no-op (LEAVEIDEM);
29
+ -- * service_role keeps the operator carve-out, as for every other rule in this function.
30
+ -- The predicate is spelled as the complement of the permitted prior states (joined, subscribed,
31
+ -- left, removed), so a state added later is refused until someone decides otherwise.
32
+ --
33
+ -- ERROR: 42501 with a message unique to this refusal ('board membership removal requires an
34
+ -- active target membership'), DETAIL = the target's current state, HINT = resolve_board_request.
35
+ -- 42501 keeps PostgREST's 403 (55000/P0002 map to HTTP 500, which reads as a server fault) and
36
+ -- matches every other transition refusal in this body (self change, principal withdrawal from
37
+ -- `removed`); clients already pass 42501 for this RPC through unchanged, so no client mapping or
38
+ -- release is needed.
39
+ --
40
+ -- PLACEMENT: inside the other-actor branch, AFTER the owner/admin check and the rank check, so a
41
+ -- caller that does not outrank the target learns nothing about its state (the existing refusals
42
+ -- still come first and keep their messages), and BEFORE the sink, so the #669 step-up gate stays
43
+ -- the LAST statement before return, keyed on the sink's resulting state, exactly as 20261124000100
44
+ -- left it. Its condition requires a prior joined/subscribed state, which this guard never refuses.
45
+ --
46
+ -- The body is a fresh copy of 20261124000100's definition plus only the #906-marked block. ACL and
47
+ -- COMMENT are restated (AGENTS.md "Schema-change mechanics that bite").
48
+ --
49
+ -- Writes no agent_board.schema_version (stays 8).
50
+
51
+ CREATE OR REPLACE FUNCTION agent_board.update_board_membership(p_board_id uuid, p_agent_id uuid, p_membership_state text, p_metadata jsonb DEFAULT '{}'::jsonb)
52
+ RETURNS TABLE(membership_id uuid, board_id uuid, agent_id uuid, membership_state text, left_at timestamp with time zone, updated_at timestamp with time zone)
53
+ LANGUAGE plpgsql
54
+ SECURITY DEFINER
55
+ SET search_path TO 'agent_board', 'public'
56
+ AS $function$
57
+ declare
58
+ v_membership agent_board.board_memberships%rowtype;
59
+ v_board agent_board.boards%rowtype;
60
+ v_actor uuid := agent_board.current_agent_id();
61
+ v_is_service boolean := agent_board._is_service_role();
62
+ v_existing_state text;
63
+ v_target_role text;
64
+ v_actor_role text;
65
+ -- HOSTED (D7): the caller is the target hosted delegate's principal asking for `left`.
66
+ v_principal_withdraw boolean;
67
+ begin
68
+ if v_actor is null and not v_is_service then
69
+ raise exception 'current agent principal not resolved' using errcode = '42501';
70
+ end if;
71
+
72
+ -- Board authority lock first, before the target row and the sink's FK locks.
73
+ perform agent_board._lock_board_authority_ceiling(p_board_id);
74
+
75
+ v_principal_withdraw := not v_is_service
76
+ and v_actor <> p_agent_id
77
+ and p_membership_state = 'left'
78
+ and v_actor = agent_board._delegate_principal_agent_id(p_agent_id);
79
+
80
+ if not v_is_service and v_actor <> p_agent_id and not v_principal_withdraw then
81
+ select * into v_board from agent_board.boards where id = p_board_id and status = 'active';
82
+ if v_board.id is null then
83
+ raise exception 'board not found' using errcode = 'P0002';
84
+ end if;
85
+ select bm.role
86
+ into v_actor_role
87
+ from agent_board.board_memberships bm
88
+ where bm.board_id = p_board_id
89
+ and bm.agent_id = v_actor
90
+ and bm.membership_state in ('joined', 'subscribed')
91
+ limit 1;
92
+ if v_actor_role is null or v_actor_role not in ('owner', 'admin') then
93
+ raise exception 'board membership change requires owner or admin role'
94
+ using errcode = '42501';
95
+ end if;
96
+ end if;
97
+
98
+ -- HOSTED: LOCKED, so every transition rule below is decided on the state the sink will
99
+ -- overwrite. Unlocked, an admin's uncommitted `removed` committed after this read, and the D7
100
+ -- withdrawal (and an ordinary self-leave, the same branch shape) then wrote `left` over it in
101
+ -- the sink, erasing the eviction R-LINK-7 reads (hosted_delegate_withdraw_evict_race). The
102
+ -- sink's own first lock is this same row in the same order, so the lock set is unchanged;
103
+ -- it is only taken earlier, before reads that lock nothing.
104
+ select bm.membership_state, bm.role
105
+ into v_existing_state, v_target_role
106
+ from agent_board.board_memberships bm
107
+ where bm.board_id = p_board_id
108
+ and bm.agent_id = p_agent_id
109
+ order by
110
+ case when bm.membership_state in ('joined', 'subscribed') then 0 else 1 end,
111
+ bm.created_at desc,
112
+ bm.id desc
113
+ limit 1
114
+ for update;
115
+ if v_existing_state is null then
116
+ raise exception 'board membership not found' using errcode = 'P0002';
117
+ end if;
118
+
119
+ if v_principal_withdraw then
120
+ -- HOSTED (D7): the owner withdraws its own delegate whatever its board role, but ONLY from
121
+ -- the states a self-leave may leave. Never from `removed`: turning an eviction into `left`
122
+ -- would erase the standing R-LINK-7 reads and let the owner re-add the evicted delegate.
123
+ if v_existing_state not in ('joined', 'subscribed', 'invited', 'requested') then
124
+ raise exception 'a principal may withdraw its delegate only from an active or pending membership'
125
+ using errcode = '42501';
126
+ end if;
127
+ elsif not v_is_service then
128
+ if v_actor = p_agent_id then
129
+ if not (
130
+ (p_membership_state = 'left'
131
+ and v_existing_state in ('joined', 'subscribed', 'invited', 'requested'))
132
+ or (p_membership_state in ('joined', 'subscribed')
133
+ and v_existing_state in ('joined', 'subscribed'))
134
+ or (p_membership_state = v_existing_state
135
+ and p_membership_state in ('left', 'removed'))
136
+ ) then
137
+ raise exception 'self membership change not permitted; use the join/approval path'
138
+ using errcode = '42501';
139
+ end if;
140
+ else
141
+ if agent_board._role_rank(v_actor_role)
142
+ <= agent_board._role_rank(
143
+ case
144
+ when p_membership_state in ('joined', 'subscribed')
145
+ and coalesce(v_existing_state, '') not in ('joined', 'subscribed')
146
+ then 'member'
147
+ else coalesce(v_target_role, '')
148
+ end) then
149
+ raise exception 'board membership change requires a higher board role than the target'
150
+ using errcode = '42501';
151
+ end if;
152
+
153
+ -- #906 REMOVALSTATE: another actor may not remove a PENDING target. Without this, a
154
+ -- client acting on a stale roster evicted a target that had meanwhile left and been
155
+ -- re-invited, or is `requested`, overriding that newer decision. Pending rows are
156
+ -- cancelled/declined through resolve_board_request (it lands `left`, REJECTSEM #89).
157
+ -- NOT refused: `left` (the documented bar on a departed agent, and R-LINK-7's
158
+ -- order-independent eviction, isolation hosted_delegate_withdraw_evict_race P2) and
159
+ -- `removed` (the LEAVEIDEM no-op below). Spelled as the complement of the permitted prior
160
+ -- states, so a state added later is refused until someone decides otherwise. After the
161
+ -- rank check (a caller that does not outrank the target learns nothing about its state)
162
+ -- and before the sink, so the #669 step-up gate below remains the last statement.
163
+ if p_membership_state = 'removed'
164
+ and v_existing_state not in ('joined', 'subscribed', 'left', 'removed') then
165
+ raise exception 'board membership removal requires an active target membership'
166
+ using errcode = '42501',
167
+ detail = format('current membership state: %s', v_existing_state),
168
+ hint = 'cancel a pending invitation or request with resolve_board_request';
169
+ end if;
170
+
171
+ if p_membership_state in ('joined', 'subscribed')
172
+ and coalesce(v_existing_state, '') not in ('joined', 'subscribed')
173
+ and not agent_board._membership_consent_present(p_board_id, p_agent_id) then
174
+ raise exception 'admitting % requires an act by that agent', p_agent_id
175
+ using errcode = '42501';
176
+ end if;
177
+
178
+ -- INVITEPOLICY (#90): seating an inbound-disclosure membership ('invited'/'requested')
179
+ -- for a target that has blocked THIS actor is refused, mirroring invite_board_member.
180
+ -- Without this, an owner/admin re-seats the exact row the block refuses. Active-admission
181
+ -- states are already consent-gated above; service_role/self never reach this branch.
182
+ if p_membership_state in ('invited', 'requested')
183
+ and not agent_board._invite_permitted(p_board_id, p_agent_id, v_actor) then
184
+ raise exception 'target has blocked invitations from this inviter on this board'
185
+ using errcode = '42501';
186
+ end if;
187
+ end if;
188
+ end if;
189
+
190
+ if not v_is_service
191
+ and p_membership_state = v_existing_state
192
+ and p_membership_state in ('left', 'removed') then
193
+ return query
194
+ select bm.id, bm.board_id, bm.agent_id, bm.membership_state, bm.left_at, bm.updated_at
195
+ from agent_board.board_memberships bm
196
+ where bm.board_id = p_board_id
197
+ and bm.agent_id = p_agent_id
198
+ order by
199
+ case when bm.membership_state in ('joined', 'subscribed') then 0 else 1 end,
200
+ bm.created_at desc,
201
+ bm.id desc
202
+ limit 1;
203
+ return;
204
+ end if;
205
+
206
+ select * into v_membership
207
+ from agent_board._upsert_board_membership_state(
208
+ p_board_id,
209
+ p_agent_id,
210
+ p_membership_state,
211
+ null,
212
+ p_metadata
213
+ );
214
+
215
+ -- #669 STEPUP PR-B (D1, plan §6.2): the step-up check is the LAST statement before the
216
+ -- function returns, after every refusal, the write and the fleet-revocation assert, so every
217
+ -- authorization refusal (22023, P0002, 42501 incl. fleet_revoked: and last-owner) comes first
218
+ -- by construction and MBS01 means "otherwise allowed; confirm it is you". The raise rolls the
219
+ -- whole transaction back. The helper takes no actor: it judges the SESSION (D2).
220
+ -- Q1 as amended by E-5: another actor takes an owner/admin target out of active standing.
221
+ -- Keyed on the target's role and prior state read FOR UPDATE above, and on the state the SINK
222
+ -- RESULTED in, never on the requested state: the #317 sink suppresses an offer (`invited`/
223
+ -- `requested`) over an active row, so a re-invite of an active admin keeps it joined and is
224
+ -- ungated (A-11d), while `removed` or `left` set by another member is gated (R-17/R-17b).
225
+ -- IS DISTINCT FROM: a NULL actor (the operator key) reaches the helper, which exempts it.
226
+ -- coalesce: a NULL resulting state must gate, never pass by three-valued logic.
227
+ if v_actor is distinct from p_agent_id
228
+ and v_target_role in ('owner', 'admin')
229
+ and v_existing_state in ('joined', 'subscribed')
230
+ and coalesce(v_membership.membership_state, '') not in ('joined', 'subscribed') then
231
+ perform agent_board._require_human_step_up('update_board_membership');
232
+ end if;
233
+
234
+ return query
235
+ select v_membership.id, v_membership.board_id, v_membership.agent_id, v_membership.membership_state, v_membership.left_at, v_membership.updated_at;
236
+ end;
237
+ $function$;
238
+
239
+ revoke all on function agent_board.update_board_membership(uuid, uuid, text, jsonb)
240
+ from public, anon, authenticated, service_role, agent_board_delegate;
241
+ grant execute on function agent_board.update_board_membership(uuid, uuid, text, jsonb) to authenticated, service_role;
242
+ comment on function agent_board.update_board_membership(uuid, uuid, text, jsonb) is
243
+ 'Authorized membership state transitions with existing self, principal-withdrawal, rank, consent and idempotency rules. Consiliency/message-board#675: board advisory lock before target membership/FK locks; the table refuses any transition removing the last active owner. Consiliency/message-board#906: another (non-service) actor may not set `removed` over a PENDING target: from invited/requested it raises 42501 ''board membership removal requires an active target membership'' (DETAIL the current state, HINT resolve_board_request), after the owner/admin and rank checks and before the write. Cancel or decline a pending row with resolve_board_request (lands left). left -> removed by an outranking owner/admin is unchanged (the bar on a departed agent; R-LINK-7 order-independent eviction), and removed -> removed stays the idempotent no-op. #669 STEPUP PR-B (Q1, E-5): after the membership sink and before the final return, when the actor is not the target, the target''s role (read FOR UPDATE before the write) is owner or admin, its prior state was joined/subscribed and the sink''s RESULTING state is not joined/subscribed, it calls _require_human_step_up(''update_board_membership''), so a human removing an owner/admin, or setting one to left, needs a fresh step-up proof (else MBS01 step_up_required, the transition rolled back). Ordinary members, self transitions, idempotent no-ops and a re-invite the sink suppresses are ungated.';