@consiliency/agent-board-schema 1.76.0 → 1.79.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.
- package/fixtures/already-applied.json +12 -0
- package/migrations/20261120000200_agent_board_thread_key_serialize.sql +118 -0
- package/migrations/20261121000100_agent_board_thread_key_guards.sql +196 -0
- package/migrations/20261124000100_agent_board_step_up_enforcement.sql +1213 -0
- package/package.json +1 -1
- package/schema-manifest.json +30 -3
- package/src/deployment-drift-main.test.mjs +89 -6
- package/src/deployment-drift.test.mjs +20 -1
- package/src/tooling.test.mjs +9 -2
- package/tests/agent_board_717_message_replay_scope.test.sql +39 -2
- package/tests/agent_board_717_tasking_replay_scope.test.sql +21 -2
- package/tests/agent_board_role_guard.test.sql +3 -1
- package/tests/agent_board_send_outcome.test.sql +39 -1
- package/tests/agent_board_session_identity_approval_revocation.test.sql +5 -0
- package/tests/agent_board_step_up.test.sql +991 -0
- package/tests/agent_board_step_up_helper.test.sql +132 -28
- package/tests/agent_board_thread_key_guards.test.sql +186 -0
- package/tests/agent_board_thread_key_serialize.test.sql +182 -0
- package/tests/agent_board_write_enforcement_class.test.sql +3 -2
- package/tests/catalog/step_up_gated_closure.json +24 -0
- package/tests/fixtures/pgtap-unexposed.sql +9 -4
- package/tests/isolation/expected/create_or_find_thread_same_key_race.out +641 -0
- package/tests/isolation/expected/session_identity_links.out +4 -0
- package/tests/isolation/specs/create_or_find_thread_same_key_race.spec +252 -0
- package/tests/isolation/specs/session_identity_links.spec +5 -0
- package/tests/mutations/669/run.sh +12 -4
- package/tests/mutations/669b/M11_ceil_first.sql +10 -0
- package/tests/mutations/669b/M11_gate_first.sql +10 -0
- package/tests/mutations/669b/M11_grant_first.sql +10 -0
- package/tests/mutations/669b/M11_inv_first.sql +10 -0
- package/tests/mutations/669b/M11_mem_first.sql +10 -0
- package/tests/mutations/669b/M11_readmit_first.sql +10 -0
- package/tests/mutations/669b/M13a_gate_member_preset.sql +12 -0
- package/tests/mutations/669b/M13b_ungate_admin_preset.sql +12 -0
- package/tests/mutations/669b/M16_actor_is_target.sql +14 -0
- package/tests/mutations/669b/M19_drop_readmit.sql +9 -0
- package/tests/mutations/669b/M1_drop_grant.sql +9 -0
- package/tests/mutations/669b/M20_drop_d5_refusal.sql +9 -0
- package/tests/mutations/669b/M21_drop_removal.sql +9 -0
- package/tests/mutations/669b/M21b_only_removed.sql +9 -0
- package/tests/mutations/669b/M21c_gate_members.sql +12 -0
- package/tests/mutations/669b/M21d_requested_state.sql +9 -0
- package/tests/mutations/669b/M23b_api_wrapper_over_audit_writer.sql +6 -0
- package/tests/mutations/669b/M23c_drop_register_type_refusal.sql +9 -0
- package/tests/mutations/669b/M24_drop_kind_refusal.sql +9 -0
- package/tests/mutations/669b/M24b_drop_auth_bind_refusal.sql +9 -0
- package/tests/mutations/669b/M2a_drop_gate.sql +9 -0
- package/tests/mutations/669b/M2b_drop_ceiling.sql +9 -0
- package/tests/mutations/669b/M2c_drop_invite.sql +9 -0
- package/tests/mutations/669b/MAL2_drop_otp.sql +9 -0
- package/tests/mutations/669b/MAL3_admit_passkey.sql +9 -0
- package/tests/mutations/669b/MD7a_no_revocation.sql +2 -0
- package/tests/mutations/669b/MD7b_overwrite_revoked.sql +2 -0
- package/tests/mutations/669b/MD7c_revoke_members.sql +2 -0
- package/tests/mutations/669b/MD7d_revoke_expired.sql +2 -0
- package/tests/mutations/669b/ME1_wrapper_over_gate.sql +7 -0
- package/tests/mutations/669b/MEC2_write_after_helper.sql +10 -0
- package/tests/mutations/669b/MQX_query_to_xml_definer.sql +6 -0
- package/tests/mutations/669b/MQXb_ts_stat_other_schema.sql +4 -0
- package/tests/mutations/669b/MTR_trigger_route.sql +9 -0
- package/tests/mutations/669b/MTRb_new_assign.sql +11 -0
- package/tests/mutations/669b/MTRc_sync_assigns_value.sql +47 -0
- package/tests/mutations/669b/MTX1_tombstone_second_gated_call.sql +15 -0
- package/tests/mutations/669b/MTX2_tombstone_non_delegate_target.sql +10 -0
- package/tests/mutations/669b/MXS_other_schema_names_gated.sql +5 -0
- package/tests/mutations/669b/run.sh +83 -0
- package/tests/mutations/670/M18a_read_operation_default_dropped.sql +11 -0
- package/tests/mutations/670/M18b_read_operation_default_changed.sql +7 -0
- package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/s12/M0_identity.sql +56 -0
- package/tests/mutations/s12/M1_serialise_actor_key.sql +57 -0
- package/tests/mutations/s12/M1b_serialise_key_only.sql +57 -0
- package/tests/mutations/s12/M2_unique_index_no_handler.sql +9 -0
- package/tests/mutations/s12/M3_no_trim.sql +56 -0
- package/tests/mutations/s12/M4_casefold.sql +56 -0
- package/tests/mutations/s12/M5_lookup_ignores_actor.sql +56 -0
- package/tests/mutations/s12/M6_reuse_reports_false.sql +56 -0
- package/tests/mutations/s12/run.sh +112 -0
- package/tests/mutations/s12-fix/M0_identity.sql +83 -0
- package/tests/mutations/s12-fix/M10_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M11_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M12_reuse_writes_task.sql +84 -0
- package/tests/mutations/s12-fix/M13_dead_inbox_write.sql +84 -0
- package/tests/mutations/s12-fix/M14_metadata_unchecked.sql +78 -0
- package/tests/mutations/s12-fix/M15_metadata_check_after_lock.sql +84 -0
- package/tests/mutations/s12-fix/M16_sql_null_metadata_refused.sql +83 -0
- package/tests/mutations/s12-fix/M17_isolation_unchecked.sql +70 -0
- package/tests/mutations/s12-fix/M18_isolation_check_after_lock.sql +82 -0
- package/tests/mutations/s12-fix/M19_isolation_rr_only.sql +83 -0
- package/tests/mutations/s12-fix/M1_lock_dropped.sql +78 -0
- package/tests/mutations/s12-fix/M1b_lock_key_only.sql +83 -0
- package/tests/mutations/s12-fix/M20_isolation_unsafe_levels_only.sql +83 -0
- package/tests/mutations/s12-fix/M21_isolation_check_miss_path_only.sql +83 -0
- package/tests/mutations/s12-fix/M22_isolation_inverted.sql +83 -0
- package/tests/mutations/s12-fix/M23_isolation_wrong_sqlstate.sql +83 -0
- package/tests/mutations/s12-fix/M24_create_thread_key_unchecked.sql +37 -0
- package/tests/mutations/s12-fix/M25_create_thread_key_nonnull_only.sql +45 -0
- package/tests/mutations/s12-fix/M26_create_thread_key_casefold.sql +45 -0
- package/tests/mutations/s12-fix/M27_create_thread_no_object_guard.sql +45 -0
- package/tests/mutations/s12-fix/M28_create_thread_key_stripped.sql +40 -0
- package/tests/mutations/s12-fix/M29_create_thread_key_nested_refused.sql +45 -0
- package/tests/mutations/s12-fix/M2_lock_actor_only.sql +83 -0
- package/tests/mutations/s12-fix/M30_create_thread_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M31_create_thread_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M32_class_new_thread_inserter.sql +14 -0
- package/tests/mutations/s12-fix/M33_class_metadata_update.sql +12 -0
- package/tests/mutations/s12-fix/M33b_class_metadata_update_upper.sql +17 -0
- package/tests/mutations/s12-fix/M33c_class_metadata_update_row_form.sql +16 -0
- package/tests/mutations/s12-fix/M33d_class_metadata_merge_update.sql +16 -0
- package/tests/mutations/s12-fix/M33e_class_metadata_upsert.sql +16 -0
- package/tests/mutations/s12-fix/M34_class_api_role_insert.sql +9 -0
- package/tests/mutations/s12-fix/M3_lock_after_lookup.sql +83 -0
- package/tests/mutations/s12-fix/M4_lock_raw_key.sql +83 -0
- package/tests/mutations/s12-fix/M5_no_trim.sql +83 -0
- package/tests/mutations/s12-fix/M6_casefold.sql +83 -0
- package/tests/mutations/s12-fix/M7_lookup_ignores_actor.sql +82 -0
- package/tests/mutations/s12-fix/M8_reuse_reports_false.sql +83 -0
- package/tests/mutations/s12-fix/M9_blank_key_admitted.sql +83 -0
- package/tests/mutations/s12-fix/run.sh +288 -0
- package/tests/seeds/20261124000100_agent_board_step_up_enforcement.sql.pre.sql +47 -0
|
@@ -136,8 +136,10 @@ link_session_alias
|
|
|
136
136
|
|
|
137
137
|
step b_begin: BEGIN; SET LOCAL ROLE service_role; SET LOCAL "request.jwt.claim.role" = 'service_role'; SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001';
|
|
138
138
|
step b_narrow:
|
|
139
|
+
SET LOCAL "request.jwt.claim.sub" = '';
|
|
139
140
|
select role from agent_board.grant_board_role('74000000-0000-4000-8000-000000000002', '72000000-0000-4000-8000-000000000001', 'observer', '72000000-0000-4000-8000-000000000001');
|
|
140
141
|
select allowed_scopes from agent_board.upsert_delegation_policy('72000000-0000-4000-8000-000000000001', 'root_minted', '["read"]', 200, interval '8 hours', true);
|
|
142
|
+
SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001';
|
|
141
143
|
<waiting ...>
|
|
142
144
|
step a_commit: COMMIT;
|
|
143
145
|
step b_narrow: <... completed>
|
|
@@ -187,8 +189,10 @@ granted_scopes|role
|
|
|
187
189
|
starting permutation: b_begin b_narrow a_begin a_link b_commit a_commit check
|
|
188
190
|
step b_begin: BEGIN; SET LOCAL ROLE service_role; SET LOCAL "request.jwt.claim.role" = 'service_role'; SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001';
|
|
189
191
|
step b_narrow:
|
|
192
|
+
SET LOCAL "request.jwt.claim.sub" = '';
|
|
190
193
|
select role from agent_board.grant_board_role('74000000-0000-4000-8000-000000000002', '72000000-0000-4000-8000-000000000001', 'observer', '72000000-0000-4000-8000-000000000001');
|
|
191
194
|
select allowed_scopes from agent_board.upsert_delegation_policy('72000000-0000-4000-8000-000000000001', 'root_minted', '["read"]', 200, interval '8 hours', true);
|
|
195
|
+
SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001';
|
|
192
196
|
|
|
193
197
|
role
|
|
194
198
|
--------
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# S-12 — create_or_find_thread, SAME actor + SAME normalized idempotency key, two sessions.
|
|
2
|
+
#
|
|
3
|
+
# THE QUESTION (Portal's new-thread hold). Two sessions call
|
|
4
|
+
# agent_board.create_or_find_thread at once with an identical (actor, normalized key). Does
|
|
5
|
+
# the board end with exactly ONE thread, do both calls return that one id (one reused=false,
|
|
6
|
+
# one reused=true), and does neither surface a unique violation?
|
|
7
|
+
#
|
|
8
|
+
# THE CONTRACT, read from the body (first defined in 20260517000000_agent_board_addressing.sql,
|
|
9
|
+
# redefined by 20261120000200_agent_board_thread_key_serialize.sql; one overload,
|
|
10
|
+
# (uuid, text, text, text, jsonb)):
|
|
11
|
+
# * the key is normalized by `nullif(trim(p_idempotency_key), '')` and NOTHING ELSE. trim()
|
|
12
|
+
# with no character list strips only the space character: case is preserved, and a tab or
|
|
13
|
+
# newline is part of the key. So ' s12-key ' IS the key 's12-key'; 'S12-KEY' is NOT.
|
|
14
|
+
# * the identity of a key is (threads.created_by_agent_id, metadata->>'addressingThreadKey').
|
|
15
|
+
# * reuse = `select … for update` on that pair; miss = a plain INSERT. There is no ON
|
|
16
|
+
# CONFLICT and no unique index on the pair (threads' only unique index is threads_pkey).
|
|
17
|
+
# Under READ COMMITTED the FOR UPDATE matches nothing while the first session's row is
|
|
18
|
+
# uncommitted, so on its own it cannot wait for it. Since 20261120000200 the lookup is
|
|
19
|
+
# preceded by `_lock_idempotency_key('create_or_find_thread:' || actor, key)`, a
|
|
20
|
+
# transaction-scoped advisory lock on (actor, key): THAT is what makes the second caller wait.
|
|
21
|
+
# * since 20261121000100 a caller whose transaction is not READ COMMITTED is refused with
|
|
22
|
+
# 0A000 before the lock and the lookup (#815). The lock only helps if the lookup after the
|
|
23
|
+
# wait sees the winner's committed row, and a REPEATABLE READ or SERIALIZABLE snapshot does
|
|
24
|
+
# not advance while waiting.
|
|
25
|
+
#
|
|
26
|
+
# Every session records what its call RETURNED into s12_results, so `check` can compare the
|
|
27
|
+
# ids the callers saw against the rows the table holds without printing a uuid.
|
|
28
|
+
# threads rows for (actor A, key 's12-key') — the property wants 1
|
|
29
|
+
# distinct_ids distinct thread ids the two calls returned — the property wants 1
|
|
30
|
+
# reused_flags the reused values, in session order
|
|
31
|
+
# orphans rows for that (actor, key) that NO caller was handed
|
|
32
|
+
#
|
|
33
|
+
# Catalog facts behind those claims, read from a database built from this bundle rather than
|
|
34
|
+
# from the text (measured on the pre-fix bundle, #808): create_or_find_thread has exactly 1
|
|
35
|
+
# overload; agent_board.threads has exactly 1 unique index (threads_pkey), 0 exclusion
|
|
36
|
+
# constraints and 0 user triggers.
|
|
37
|
+
#
|
|
38
|
+
# HISTORY OF THE GOLDEN. #808 added this spec with a golden that PINNED THE DEFECT:
|
|
39
|
+
# permutations 1 and 2 showed threads=2, distinct_ids=2, s1=false,s2=false, no `<waiting ...>`,
|
|
40
|
+
# no error -- two rows for one (actor, normalized key), silently. 20261120000200 serialises the
|
|
41
|
+
# miss path, and the golden was regenerated: in permutations 1 and 2 the second call now WAITS
|
|
42
|
+
# for s1's commit, then returns reused=true with s1's id (threads=1, distinct_ids=1).
|
|
43
|
+
# Permutations 3-6 are controls and are byte-identical before and after the fix.
|
|
44
|
+
#
|
|
45
|
+
# Permutation 7 (added with the metadata refusal) is new; it has no pre-fix counterpart.
|
|
46
|
+
#
|
|
47
|
+
# Permutations 8-12 (added with 20261121000100, #815) pin the isolation-level refusal. Session s4
|
|
48
|
+
# chooses its level in BEGIN and calls through public.s12_level_call(), which reports what the
|
|
49
|
+
# call did as one text value -- `returned reused=<bool>` or `refused <SQLSTATE>: <message>` -- so
|
|
50
|
+
# the golden carries the SQLSTATE (isolationtester prints only an error's message). A pgTAP file
|
|
51
|
+
# cannot do this: the level is fixed by a transaction's first statement, and pgTAP is inside one.
|
|
52
|
+
# Without the guard, permutation 8 is the #815 defect itself: s4 waits for s1, then inserts a
|
|
53
|
+
# second thread (returned reused=false, threads=2).
|
|
54
|
+
#
|
|
55
|
+
# Discrimination is pinned twice. tests/mutations/s12/run.sh (#808) applies scratch bodies to
|
|
56
|
+
# the PRE-fix bundle; tests/mutations/s12-fix/run.sh applies them to this one and asserts that
|
|
57
|
+
# dropping the lock reverts permutations 1 and 2 to the defect, and that locking on the key
|
|
58
|
+
# alone makes permutation 5's different actors wait on each other.
|
|
59
|
+
|
|
60
|
+
setup
|
|
61
|
+
{
|
|
62
|
+
insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
|
|
63
|
+
values ('b5120000-0000-4000-8000-00000000000a','agent','agent','s12-actor-a','S12 Actor A','active'),
|
|
64
|
+
('b5120000-0000-4000-8000-00000000000b','agent','agent','s12-actor-b','S12 Actor B','active');
|
|
65
|
+
|
|
66
|
+
create table public.s12_results(
|
|
67
|
+
session text primary key,
|
|
68
|
+
thread_id uuid not null,
|
|
69
|
+
reused boolean not null
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
create function public.s12_level_call() returns text
|
|
73
|
+
language plpgsql as $f$
|
|
74
|
+
declare
|
|
75
|
+
v_id uuid;
|
|
76
|
+
v_reused boolean;
|
|
77
|
+
begin
|
|
78
|
+
select t.thread_id, t.reused into v_id, v_reused
|
|
79
|
+
from agent_board.create_or_find_thread(
|
|
80
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t;
|
|
81
|
+
insert into public.s12_results(session, thread_id, reused) values ('s4', v_id, v_reused);
|
|
82
|
+
return 'returned reused=' || v_reused::text;
|
|
83
|
+
exception when others then
|
|
84
|
+
return 'refused ' || sqlstate || ': ' || sqlerrm;
|
|
85
|
+
end
|
|
86
|
+
$f$;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
teardown
|
|
90
|
+
{
|
|
91
|
+
drop function public.s12_level_call();
|
|
92
|
+
drop table public.s12_results;
|
|
93
|
+
delete from agent_board.threads
|
|
94
|
+
where created_by_agent_id in ('b5120000-0000-4000-8000-00000000000a',
|
|
95
|
+
'b5120000-0000-4000-8000-00000000000b');
|
|
96
|
+
delete from agent_board.agents
|
|
97
|
+
where id in ('b5120000-0000-4000-8000-00000000000a',
|
|
98
|
+
'b5120000-0000-4000-8000-00000000000b');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Actor A, the canonical key.
|
|
102
|
+
session "s1"
|
|
103
|
+
step "s1_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
104
|
+
step "s1_call" {
|
|
105
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
106
|
+
select 's1', t.thread_id, t.reused
|
|
107
|
+
from agent_board.create_or_find_thread(
|
|
108
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
109
|
+
returning session, reused;
|
|
110
|
+
}
|
|
111
|
+
step "s1_commit" { COMMIT; }
|
|
112
|
+
|
|
113
|
+
# Actor A, the canonical key — a second caller of the same pair.
|
|
114
|
+
session "s2"
|
|
115
|
+
step "s2_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
116
|
+
step "s2_call" {
|
|
117
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
118
|
+
select 's2', t.thread_id, t.reused
|
|
119
|
+
from agent_board.create_or_find_thread(
|
|
120
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key') t
|
|
121
|
+
returning session, reused;
|
|
122
|
+
}
|
|
123
|
+
# Actor A, a key that differs from 's12-key' only by what trim() removes.
|
|
124
|
+
step "s2_call_padded" {
|
|
125
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
126
|
+
select 's2', t.thread_id, t.reused
|
|
127
|
+
from agent_board.create_or_find_thread(
|
|
128
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', ' s12-key ') t
|
|
129
|
+
returning session, reused;
|
|
130
|
+
}
|
|
131
|
+
# Actor A, a key that differs only in CASE — not part of the normalization.
|
|
132
|
+
step "s2_call_upper" {
|
|
133
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
134
|
+
select 's2', t.thread_id, t.reused
|
|
135
|
+
from agent_board.create_or_find_thread(
|
|
136
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 'S12-KEY') t
|
|
137
|
+
returning session, reused;
|
|
138
|
+
}
|
|
139
|
+
# Actor A, the canonical key, but a JSON ARRAY as metadata: refused (22023) since 20261120000200.
|
|
140
|
+
step "s2_call_array" {
|
|
141
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
142
|
+
select 's2', t.thread_id, t.reused
|
|
143
|
+
from agent_board.create_or_find_thread(
|
|
144
|
+
'b5120000-0000-4000-8000-00000000000a', 'S-12 subject', 's12-key', 'coordination', '[]'::jsonb) t
|
|
145
|
+
returning session, reused;
|
|
146
|
+
}
|
|
147
|
+
step "s2_commit" { COMMIT; }
|
|
148
|
+
|
|
149
|
+
# Actor B, the same literal key — a different (actor, key) pair.
|
|
150
|
+
session "s3"
|
|
151
|
+
step "s3_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
152
|
+
step "s3_call_other_actor" {
|
|
153
|
+
insert into public.s12_results(session, thread_id, reused)
|
|
154
|
+
select 's3', t.thread_id, t.reused
|
|
155
|
+
from agent_board.create_or_find_thread(
|
|
156
|
+
'b5120000-0000-4000-8000-00000000000b', 'S-12 subject', 's12-key') t
|
|
157
|
+
returning session, reused;
|
|
158
|
+
}
|
|
159
|
+
step "s3_commit" { COMMIT; }
|
|
160
|
+
|
|
161
|
+
# Actor A, the canonical key, at a level chosen in BEGIN (#815). One call step for every level,
|
|
162
|
+
# so the only thing that differs between these permutations is the level itself.
|
|
163
|
+
session "s4"
|
|
164
|
+
step "s4_begin_rr" { BEGIN ISOLATION LEVEL REPEATABLE READ; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
165
|
+
step "s4_begin_sz" { BEGIN ISOLATION LEVEL SERIALIZABLE; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
166
|
+
step "s4_begin_ru" { BEGIN ISOLATION LEVEL READ UNCOMMITTED; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
167
|
+
step "s4_begin_rc" { BEGIN ISOLATION LEVEL READ COMMITTED; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
|
|
168
|
+
step "s4_call" { select public.s12_level_call() as outcome; }
|
|
169
|
+
step "s4_commit" { COMMIT; }
|
|
170
|
+
step "s4_rollback" { ROLLBACK; }
|
|
171
|
+
|
|
172
|
+
session "check"
|
|
173
|
+
step "check" {
|
|
174
|
+
select (select count(*)::int from agent_board.threads t
|
|
175
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
176
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key') as threads,
|
|
177
|
+
(select count(distinct r.thread_id)::int from public.s12_results r
|
|
178
|
+
where r.session in ('s1','s2')) as distinct_ids,
|
|
179
|
+
(select string_agg(r.session || '=' || r.reused::text, ',' order by r.session)
|
|
180
|
+
from public.s12_results r) as reused_flags,
|
|
181
|
+
(select count(*)::int from agent_board.threads t
|
|
182
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a'
|
|
183
|
+
and t.metadata ->> 'addressingThreadKey' = 's12-key'
|
|
184
|
+
and t.id not in (select r.thread_id from public.s12_results r)) as orphans,
|
|
185
|
+
(select string_agg(t.metadata ->> 'addressingThreadKey', ',' order by t.metadata ->> 'addressingThreadKey')
|
|
186
|
+
from agent_board.threads t
|
|
187
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000a') as actor_a_keys,
|
|
188
|
+
(select count(*)::int from agent_board.threads t
|
|
189
|
+
where t.created_by_agent_id = 'b5120000-0000-4000-8000-00000000000b') as actor_b_threads,
|
|
190
|
+
(select bool_and(r3.thread_id <> r1.thread_id)
|
|
191
|
+
from public.s12_results r1, public.s12_results r3
|
|
192
|
+
where r1.session = 's1' and r3.session = 's3') as other_actor_distinct;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# 1. S-12 PROPER. Same actor, same key, both inside open transactions. The property wants
|
|
196
|
+
# s2_call to wait for s1 and come back reused=true with s1's id; threads=1, distinct_ids=1.
|
|
197
|
+
# MEASURED since 20261120000200: exactly that. (Before it, s2_call did not wait and inserted
|
|
198
|
+
# a second thread: threads=2, distinct_ids=2.)
|
|
199
|
+
permutation "s1_begin" "s1_call" "s2_begin" "s2_call" "s1_commit" "s2_commit" "check"
|
|
200
|
+
|
|
201
|
+
# 2. The same race through the normalization: s2's key is ' s12-key '. The lock is keyed on
|
|
202
|
+
# the TRIMMED key, so s2 waits and reuses s1's row exactly as in permutation 1.
|
|
203
|
+
permutation "s1_begin" "s1_call" "s2_begin" "s2_call_padded" "s1_commit" "s2_commit" "check"
|
|
204
|
+
|
|
205
|
+
# 3. CONTROL — the reuse path itself. s1 COMMITS before s2 calls, so the FOR UPDATE can see
|
|
206
|
+
# the row. One thread, one id, s1=false, s2=true. This is what permutation 1 is measured
|
|
207
|
+
# against: the defect is concurrency, not the reuse lookup.
|
|
208
|
+
permutation "s1_begin" "s1_call" "s1_commit" "s2_begin" "s2_call_padded" "s2_commit" "check"
|
|
209
|
+
|
|
210
|
+
# 4. CONTROL — case is NOT normalized. Committed first, then 'S12-KEY': a second thread
|
|
211
|
+
# under a distinct key, reused=false both times. The function's contract, asserted as is.
|
|
212
|
+
permutation "s1_begin" "s1_call" "s1_commit" "s2_begin" "s2_call_upper" "s2_commit" "check"
|
|
213
|
+
|
|
214
|
+
# 5. CONTROL — different actors with the same key are independent: two threads, two
|
|
215
|
+
# reused=false, no wait between them, distinct ids. (threads counts actor A only, so 1.)
|
|
216
|
+
# A lock keyed on the key alone, without the actor, makes s3 wait here.
|
|
217
|
+
permutation "s1_begin" "s1_call" "s3_begin" "s3_call_other_actor" "s1_commit" "s3_commit" "check"
|
|
218
|
+
|
|
219
|
+
# 6. CONTROL — actor scoping of the REUSE lookup. Permutation 5 cannot pin it on the shipped
|
|
220
|
+
# body: s3 could not see s1's uncommitted row whatever the predicate said. Here s1 commits
|
|
221
|
+
# first, so a lookup that ignored the actor would hand s3 actor A's thread (s3=true).
|
|
222
|
+
permutation "s1_begin" "s1_call" "s1_commit" "s3_begin" "s3_call_other_actor" "s3_commit" "check"
|
|
223
|
+
|
|
224
|
+
# 7. The metadata refusal comes BEFORE the lock. s1 holds the (actor, key) lock; s2 calls with the
|
|
225
|
+
# same pair and a JSON array as metadata. It must fail at once with 22023 -- no `<waiting ...>`
|
|
226
|
+
# -- and leave s1's single thread. A refusal placed after the lock would make s2 wait for s1
|
|
227
|
+
# first (tests/mutations/s12-fix M15); no refusal at all lets s2 wait and then reuse (M14).
|
|
228
|
+
permutation "s1_begin" "s1_call" "s2_begin" "s2_call_array" "s1_commit" "s2_commit" "check"
|
|
229
|
+
|
|
230
|
+
# 8. #815: REPEATABLE READ is refused, by name and with 0A000, BEFORE the lock. s1 holds the
|
|
231
|
+
# (actor, key) lock; s4 calls with the same pair at REPEATABLE READ. It must be refused at once
|
|
232
|
+
# -- no `<waiting ...>` -- and s1's thread stays the only one. A guard placed after the lock
|
|
233
|
+
# makes s4 wait first; no guard lets s4 wait and then insert a duplicate (threads=2).
|
|
234
|
+
permutation "s1_begin" "s1_call" "s4_begin_rr" "s4_call" "s1_commit" "s4_rollback" "check"
|
|
235
|
+
|
|
236
|
+
# 9. #815: SERIALIZABLE is refused the same way. Its own permutation because only the levels a
|
|
237
|
+
# permutation NAMES are pinned: a guard narrowed to `= 'repeatable read'` passes permutation 8.
|
|
238
|
+
permutation "s1_begin" "s1_call" "s4_begin_sz" "s4_call" "s1_commit" "s4_rollback" "check"
|
|
239
|
+
|
|
240
|
+
# 10. #815: READ UNCOMMITTED is refused too. PostgreSQL runs it AS read committed, so this pins the
|
|
241
|
+
# guard's one-accepted-spelling contract (`<> 'read committed'`), not a correctness property:
|
|
242
|
+
# a guard that lists the two unsafe levels instead lets this one through.
|
|
243
|
+
permutation "s1_begin" "s1_call" "s4_begin_ru" "s4_call" "s1_commit" "s4_rollback" "check"
|
|
244
|
+
|
|
245
|
+
# 11. #815: the refusal is of the LEVEL, not of the miss path. s1 has committed, so the lookup
|
|
246
|
+
# would find the thread and no duplicate could be written -- and the REPEATABLE READ caller is
|
|
247
|
+
# still refused. A guard placed after the reuse return hands s4 the thread here.
|
|
248
|
+
permutation "s1_begin" "s1_call" "s1_commit" "s4_begin_rr" "s4_call" "s4_rollback" "check"
|
|
249
|
+
|
|
250
|
+
# 12. #815 ALLOW SIDE: the identical call with READ COMMITTED named in BEGIN succeeds and reuses
|
|
251
|
+
# s1's thread. A refusal that fired at every level would fail here (and in permutations 1-6).
|
|
252
|
+
permutation "s1_begin" "s1_call" "s1_commit" "s4_begin_rc" "s4_call" "s4_commit" "check"
|
|
@@ -59,9 +59,14 @@ session "b"
|
|
|
59
59
|
step "b_begin" { BEGIN; SET LOCAL ROLE service_role; SET LOCAL "request.jwt.claim.role" = 'service_role'; SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001'; }
|
|
60
60
|
step "b_same" { select agent_board.link_session_alias('72000000-0000-4000-8000-000000000002', '0', 'continued-a'); }
|
|
61
61
|
step "b_other" { select agent_board.link_session_alias('72000000-0000-4000-8000-000000000002', '0', 'continued-b'); }
|
|
62
|
+
# #669 PR-B (D3, plan §5.4): the narrowing grant runs as the OPERATOR KEY (service_role, no sub).
|
|
63
|
+
# Under the session's sub (a session identity with no lease claim, so no resolved principal) the
|
|
64
|
+
# step-up helper refuses it with MBS01, which is the R-14b case by design.
|
|
62
65
|
step "b_narrow" {
|
|
66
|
+
SET LOCAL "request.jwt.claim.sub" = '';
|
|
63
67
|
select role from agent_board.grant_board_role('74000000-0000-4000-8000-000000000002', '72000000-0000-4000-8000-000000000001', 'observer', '72000000-0000-4000-8000-000000000001');
|
|
64
68
|
select allowed_scopes from agent_board.upsert_delegation_policy('72000000-0000-4000-8000-000000000001', 'root_minted', '["read"]', 200, interval '8 hours', true);
|
|
69
|
+
SET LOCAL "request.jwt.claim.sub" = '71000000-0000-4000-8000-000000000001';
|
|
65
70
|
}
|
|
66
71
|
step "b_commit" { COMMIT; }
|
|
67
72
|
|
|
@@ -22,7 +22,15 @@ HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
|
22
22
|
PKG="$(cd "$HERE/../../.." && pwd)"
|
|
23
23
|
TEST="${STEPUP_TEST:-$PKG/tests/agent_board_step_up_helper.test.sql}"
|
|
24
24
|
OUT="${1:?receipt path}"; shift
|
|
25
|
-
if [ "$#" -gt 0 ]; then
|
|
25
|
+
if [ "$#" -gt 0 ]; then
|
|
26
|
+
MUTS=()
|
|
27
|
+
for m in "$@"; do
|
|
28
|
+
# A relative or missing path made psql's \i fail with a lowercase "error:", which the
|
|
29
|
+
# applied() check below did not match, so a mutant that never loaded read as "applied".
|
|
30
|
+
[ -f "$m" ] || { echo "FATAL: mutation file not found: $m" >&2; exit 3; }
|
|
31
|
+
MUTS+=("$(cd "$(dirname "$m")" && pwd)/$(basename "$m")")
|
|
32
|
+
done
|
|
33
|
+
else mapfile -t MUTS < <(find "$HERE" -maxdepth 1 -name '*.sql' | sort -V); fi
|
|
26
34
|
[ -n "${PGDATABASE:-}" ] || { echo "FATAL: PGDATABASE unset (libpq environment required)" >&2; exit 3; }
|
|
27
35
|
P=(psql -X -qtA)
|
|
28
36
|
FPSQL="select md5(coalesce((select string_agg(p.oid::regprocedure::text || coalesce(p.proargnames::text, '') || coalesce(p.proacl::text, '') || p.prosrc || p.provolatile::text || p.prosecdef::text || coalesce(obj_description(p.oid, 'pg_proc'), ''), '|' order by p.oid::regprocedure::text) from pg_proc p where p.pronamespace not in ('pg_catalog'::regnamespace, 'information_schema'::regnamespace)), '') || coalesce((select string_agg(attrelid::regclass::text || '.' || attname || ':' || atttypid::regtype::text, '|' order by attrelid::regclass::text, attnum) from pg_attribute where attrelid in ('agent_board.portal_step_up_proofs'::regclass, 'agent_board.enrollment_federation_audit'::regclass) and attnum > 0 and not attisdropped), '') || coalesce((select relacl::text from pg_class where oid = 'agent_board.portal_step_up_proofs'::regclass), '') || coalesce((select string_agg(polname || pg_get_expr(polqual, polrelid), '|' order by polname) from pg_policy where polrelid = 'agent_board.portal_step_up_proofs'::regclass), ''))"
|
|
@@ -32,8 +40,8 @@ ORIG="$(fp)"
|
|
|
32
40
|
applied() { # $1 mutation file -> prints 'applied' / 'NOT APPLIED: <why>'
|
|
33
41
|
local out
|
|
34
42
|
out="$(printf 'begin;\n\\set ON_ERROR_STOP 1\n\\i %s\n%s;\nrollback;\n' "$1" "$FPSQL" | "${P[@]}" 2>&1)"
|
|
35
|
-
if grep -
|
|
36
|
-
echo "NOT APPLIED: $(grep -
|
|
43
|
+
if grep -qiE '(error|fatal):' <<<"$out"; then
|
|
44
|
+
echo "NOT APPLIED: $(grep -iE '(error|fatal):' <<<"$out" | head -1)"
|
|
37
45
|
elif [ "$(tail -1 <<<"$out")" = "$ORIG" ]; then
|
|
38
46
|
echo "NOT APPLIED: catalog fingerprint unchanged (no-op)"
|
|
39
47
|
else
|
|
@@ -51,7 +59,7 @@ tap() { # $1 label, $2 mutation file or empty
|
|
|
51
59
|
"$([ "${plan:-x}" = "$((ok + nok))" ] || echo ' ABORTED')"
|
|
52
60
|
grep -E '^not ok [0-9]+' <<<"$out" | sed 's/^/ /'
|
|
53
61
|
grep -E '^#\s+(have|want|caught|wanted|died):' <<<"$out" | head -8 | sed 's/^/ /'
|
|
54
|
-
grep -
|
|
62
|
+
grep -iE '(error|fatal):' <<<"$out" | head -3 | sed 's/^/ ERR /'
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of set_board_authority_ceiling; must fail R-9/R-10 (ceiling)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_authority_ceiling(uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''set_board_authority_ceiling'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of set_board_role_gate; must fail R-9/R-10 (gate)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_role_gate(uuid,boolean)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''set_board_role_gate'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of grant_board_role; must fail R-9/R-10 (grant)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''grant_board_role'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of create_invite_link; must fail R-9/R-10 (admin link)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''create_invite_link'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of update_board_membership; must fail E-6(a) removal R-9
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''update_board_membership'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of readmit_session_identity; must fail E-6(a) readmit R-9/R-10
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''readmit_session_identity'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- gate member presets too; must fail A-4
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_preset_role = 'admin' then
|
|
7
|
+
perform agent_board._require_human_step_up$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ if p_preset_role = 'admin' then
|
|
9
|
+
perform agent_board._require_human_step_up$q$, $q$ if p_preset_role in ('admin', 'member') then
|
|
10
|
+
perform agent_board._require_human_step_up$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- ungate admin presets (gate observer instead); must fail R-1 (admin link)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_preset_role = 'admin' then
|
|
7
|
+
perform agent_board._require_human_step_up$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ if p_preset_role = 'admin' then
|
|
9
|
+
perform agent_board._require_human_step_up$q$, $q$ if p_preset_role = 'observer' then
|
|
10
|
+
perform agent_board._require_human_step_up$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- the helper takes an actor and grant_board_role passes the TARGET; must fail R-13, R-13b
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._require_human_step_up(text)'::regprocedure); n text; g text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'agent_board._require_human_step_up(p_operation text)') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
if strpos(n, 'v_actor := agent_board.current_agent_id();') = 0 then raise exception 'MUTATION ANCHOR MISS (2)'; end if;
|
|
8
|
+
n := replace(n, 'agent_board._require_human_step_up(p_operation text)', 'agent_board._require_human_step_up(p_operation text, p_actor uuid)');
|
|
9
|
+
n := replace(n, 'v_actor := agent_board.current_agent_id();', 'v_actor := p_actor;');
|
|
10
|
+
execute n;
|
|
11
|
+
g := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure);
|
|
12
|
+
if strpos(g, $q$_require_human_step_up('grant_board_role')$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (3)'; end if;
|
|
13
|
+
execute replace(g, $q$_require_human_step_up('grant_board_role')$q$, $q$_require_human_step_up('grant_board_role', p_agent_id)$q$);
|
|
14
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from readmit_session_identity (M2 readmit); must fail R-15 and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from grant_board_role; must fail R-1/R-13/R-19 (grant) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the D5 human-root refusal from mint_delegated_child; must fail R-16
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.mint_delegated_child(uuid,text,jsonb,text,interval,boolean,text,text,text,jsonb,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ raise exception 'human_root_room_elevation_refused' using errcode = '42501';$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ raise exception 'human_root_room_elevation_refused' using errcode = '42501';$q$, $q$ null;$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the removal gate from update_board_membership (M2 removal); must fail R-17 and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- gate only 'removed' (not every active->non-active result); must fail R-17b
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$coalesce(v_membership.membership_state, '') not in ('joined', 'subscribed') then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$coalesce(v_membership.membership_state, '') not in ('joined', 'subscribed') then$q$, $q$v_membership.membership_state = 'removed' then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- gate member/observer removals too; must fail A-11
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ and v_target_role in ('owner', 'admin')
|
|
7
|
+
$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ and v_target_role in ('owner', 'admin')
|
|
9
|
+
$q$, $q$ and v_target_role in ('owner', 'admin', 'member', 'observer')
|
|
10
|
+
$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- key the removal condition on the REQUESTED state; must fail A-11d
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$coalesce(v_membership.membership_state, '') not in$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$coalesce(v_membership.membership_state, '') not in$q$, $q$coalesce(p_membership_state, '') not in$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- an authenticated-executable SECURITY DEFINER wrapper over a W(enrollment_federation_audit) member; must fail EC-SU-4 (tables)
|
|
2
|
+
create function agent_board.su669b_m23b(p_issuer text) returns void language plpgsql security definer set search_path = '' as $f$
|
|
3
|
+
begin
|
|
4
|
+
perform agent_board.enroll_federated_human(p_issuer, 'x', 'x', '{}'::jsonb, 'x');
|
|
5
|
+
end $f$;
|
|
6
|
+
grant execute on function agent_board.su669b_m23b(text) to authenticated;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop register_agent's type-change refusal; must fail X-1
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.register_agent(text,text,text,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_agent_type is distinct from v_existing.agent_type then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if p_agent_type is distinct from v_existing.agent_type then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop provision_agent's API kind-change refusal (E-3); must fail R-20
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.provision_agent(text,text,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if v_agent.kind::text is distinct from v_kind then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if v_agent.kind::text is distinct from v_kind then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop provision_agent's API auth-bind refusal (E-2(4)(i)); must fail X-3
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.provision_agent(text,text,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if v_agent.auth_user_id is null then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if v_agent.auth_user_id is null then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from set_board_role_gate; must fail R-1 (gate) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_role_gate(uuid,boolean)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from set_board_authority_ceiling; must fail R-1 (ceiling), R-19 (ceiling) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_authority_ceiling(uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from create_invite_link; must fail R-1 (admin link) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the allowlist drops otp (the owner-admitted email code); must fail A-2c and the freeze pin
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_amr_methods()'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$'{otp,totp}'::text[]$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$'{otp,totp}'::text[]$q$, $q$'{totp}'::text[]$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the allowlist admits passkey before it is measured (D11); must fail R-4c passkey and the freeze pin
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_amr_methods()'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$'{otp,totp}'::text[]$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$'{otp,totp}'::text[]$q$, $q$'{otp,passkey,totp}'::text[]$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|