@consiliency/agent-board-schema 1.75.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 +16 -0
- package/migrations/20261109000100_agent_board_step_up_groundwork.sql +343 -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 +39 -3
- package/src/deployment-drift-main.test.mjs +89 -6
- package/src/deployment-drift.test.mjs +20 -1
- package/src/tooling.test.mjs +10 -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_enrollment_audit_content.test.sql +6 -1
- 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 +815 -0
- 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 +8 -4
- package/tests/catalog/function_execute_privileges.json +72 -0
- package/tests/catalog/p_metadata_parameters.json +32 -0
- 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/M10_service_role_blanket.sql +10 -0
- package/tests/mutations/669/M12a_no_parse_wrapper.sql +17 -0
- package/tests/mutations/669/M12b_no_session_wrapper.sql +23 -0
- package/tests/mutations/669/M12c_no_claim_type_guard.sql +13 -0
- package/tests/mutations/669/M12d_no_amr_element_guards.sql +15 -0
- package/tests/mutations/669/M14_now_not_clock.sql +9 -0
- package/tests/mutations/669/M15_classifier_reads_metadata.sql +17 -0
- package/tests/mutations/669/M17_skip_ledger.sql +15 -0
- package/tests/mutations/669/M18_service_role_sub_insensitive.sql +9 -0
- package/tests/mutations/669/M18b_drop_uid_conjunct.sql +9 -0
- package/tests/mutations/669/M23_definer_wrapper_over_writer.sql +5 -0
- package/tests/mutations/669/M3_age_from_iat.sql +9 -0
- package/tests/mutations/669/M4_window_900.sql +9 -0
- package/tests/mutations/669/M4b_lt_to_le.sql +9 -0
- package/tests/mutations/669/M5_no_skew_bound.sql +9 -0
- package/tests/mutations/669/M6a_user_metadata_amr.sql +9 -0
- package/tests/mutations/669/M6b_app_metadata_claim.sql +9 -0
- package/tests/mutations/669/M6c_legacy_guc.sql +9 -0
- package/tests/mutations/669/M7_either_claim_any_human.sql +9 -0
- package/tests/mutations/669/M8_any_amr_method.sql +9 -0
- package/tests/mutations/669/M8b_accept_aal2.sql +9 -0
- package/tests/mutations/669/M9_every_kind.sql +9 -0
- package/tests/mutations/669/MAL_allowlist_nonempty.sql +9 -0
- package/tests/mutations/669/MAR_writer_arg_renamed.sql +14 -0
- package/tests/mutations/669/MAU_audit_mode_retyped.sql +2 -0
- package/tests/mutations/669/MA_helper_always_raises.sql +10 -0
- package/tests/mutations/669/MDX_dynamic_execute_definer.sql +5 -0
- package/tests/mutations/669/MD_detail_carries_value.sql +12 -0
- package/tests/mutations/669/MEC0_caller_of_helper.sql +4 -0
- package/tests/mutations/669/MEC0b_overload_caller.sql +4 -0
- package/tests/mutations/669/MG1_helper_granted_authenticated.sql +2 -0
- package/tests/mutations/669/MG2_ledger_insert_authenticated.sql +2 -0
- package/tests/mutations/669/MG3_ledger_policy.sql +2 -0
- package/tests/mutations/669/MR1_writer_no_class_check.sql +9 -0
- package/tests/mutations/669/MR2_writer_wide_window.sql +9 -0
- package/tests/mutations/669/MR3_writer_prunes_everyone.sql +11 -0
- package/tests/mutations/669/MR4_writer_lower_exclusive.sql +9 -0
- package/tests/mutations/669/MR5_writer_upper_exclusive.sql +9 -0
- package/tests/mutations/669/MR6_writer_upper_61.sql +9 -0
- package/tests/mutations/669/MW2_second_ledger_writer.sql +4 -0
- package/tests/mutations/669/MXS_cross_schema_wrapper.sql +4 -0
- package/tests/mutations/669/run.sh +80 -0
- 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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
-- THREADKEYGUARDS (S-12 follow-ups, migration 20261121000100).
|
|
2
|
+
--
|
|
3
|
+
-- WHAT THIS FILE PINS: `create_thread` refuses object metadata carrying a top-level
|
|
4
|
+
-- `addressingThreadKey` with 22023 (Consiliency/message-board#816). That key is the idempotency
|
|
5
|
+
-- key `create_or_find_thread` stores and looks up under its (actor, key) lock; `create_thread`
|
|
6
|
+
-- takes no lock, so a caller who could write the key there could plant a second thread under a
|
|
7
|
+
-- pair that function serialises.
|
|
8
|
+
--
|
|
9
|
+
-- WHAT IT DOES NOT PIN: the other half of the migration, `create_or_find_thread` refusing a
|
|
10
|
+
-- transaction that is not READ COMMITTED (#815). A level is chosen by a transaction's first
|
|
11
|
+
-- statement and this file is already inside one, so that half lives in
|
|
12
|
+
-- tests/isolation/specs/create_or_find_thread_same_key_race.spec, permutations 8-12.
|
|
13
|
+
--
|
|
14
|
+
-- The rows, by what each one would catch:
|
|
15
|
+
-- TKG-1..4 REJECT: the key is refused whatever its value and whatever else the object holds,
|
|
16
|
+
-- and the refused calls create nothing (a "strip the key and insert" body fails 4).
|
|
17
|
+
-- TKG-5..8 ALLOW: ordinary object metadata and SQL NULL still work and are stored unchanged.
|
|
18
|
+
-- TKG-9..12 SCOPE: only the spelling the lookup reads, at the top level of an object, is
|
|
19
|
+
-- reserved. A differently cased key, a nested key and an ARRAY holding the string
|
|
20
|
+
-- are stored as before (`?` is true for such an array, hence the object guard).
|
|
21
|
+
-- TKG-13 nothing `create_thread` wrote is readable by the lookup under any key.
|
|
22
|
+
-- TKG-14..15 END TO END: after the refused plant, `create_or_find_thread` with that key creates
|
|
23
|
+
-- its own thread (reused=false) and it is the only one under the pair.
|
|
24
|
+
-- TKG-16..18 KEPT: the blank-subject refusal, SECURITY DEFINER, the pinned search_path.
|
|
25
|
+
-- TKG-19..21 THE CLASS, from pg_catalog (AGENTS.md rule 1), for the statement forms the matchers
|
|
26
|
+
-- see: which functions' bodies contain `INSERT INTO agent_board.threads` (TKG-19),
|
|
27
|
+
-- whether any function assigns `threads.metadata` by UPDATE SET (scalar or row
|
|
28
|
+
-- form), MERGE update or ON CONFLICT DO UPDATE (TKG-20), and whether anon,
|
|
29
|
+
-- authenticated or agent_board_delegate can INSERT/UPDATE the table directly
|
|
30
|
+
-- (TKG-21). A new writer of one of those forms fails these and names itself.
|
|
31
|
+
-- UNSEEN by these rows: a MERGE ... WHEN NOT MATCHED THEN INSERT, a subscripted
|
|
32
|
+
-- metadata assignment (`SET metadata[...] = ...`), and dynamic SQL. Dynamic SQL is
|
|
33
|
+
-- bounded by CPR-9, triggers and rules on threads by CPR-13b
|
|
34
|
+
-- (agent_board_claimpolicy_race.test.sql). The two exempt inserters are each
|
|
35
|
+
-- asserted positively:
|
|
36
|
+
-- `create_thread` refuses the key (TKG-1) and `create_or_find_thread` writes exactly
|
|
37
|
+
-- its own normalized key (TKS-20 in agent_board_thread_key_serialize.test.sql).
|
|
38
|
+
--
|
|
39
|
+
-- Every allow-side call runs under lives_ok and is captured, then asserted separately (#113).
|
|
40
|
+
create extension if not exists pgtap with schema extensions;
|
|
41
|
+
set search_path = extensions, public, agent_board;
|
|
42
|
+
|
|
43
|
+
begin;
|
|
44
|
+
|
|
45
|
+
select plan(21);
|
|
46
|
+
|
|
47
|
+
create temp table _tkg (actor uuid) on commit drop;
|
|
48
|
+
-- Capture tables exist BEFORE the calls they capture, so a call that raises under a mutation
|
|
49
|
+
-- leaves an EMPTY capture and its state assertion fails by name (AGENTS.md rule 3).
|
|
50
|
+
create temp table _tkg_plain (thread_id uuid) on commit drop;
|
|
51
|
+
create temp table _tkg_null (thread_id uuid) on commit drop;
|
|
52
|
+
create temp table _tkg_scope (label text, thread_id uuid) on commit drop;
|
|
53
|
+
create temp table _tkg_cof (thread_id uuid, reused boolean) on commit drop;
|
|
54
|
+
|
|
55
|
+
do $$
|
|
56
|
+
declare
|
|
57
|
+
v_suffix text := replace(substr(gen_random_uuid()::text, 1, 8), '-', '');
|
|
58
|
+
v_actor uuid := gen_random_uuid();
|
|
59
|
+
begin
|
|
60
|
+
insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
|
|
61
|
+
values (v_actor, 'agent', 'agent', 'tkg-actor-' || v_suffix, 'TKG Actor', 'active');
|
|
62
|
+
insert into _tkg(actor) values (v_actor);
|
|
63
|
+
-- The same caller identity the S-12 isolation spec uses.
|
|
64
|
+
perform set_config('request.jwt.claim.role', 'service_role', true);
|
|
65
|
+
end
|
|
66
|
+
$$;
|
|
67
|
+
|
|
68
|
+
-- TKG-1..4. REJECT rows.
|
|
69
|
+
select throws_ok(
|
|
70
|
+
$$ select * from agent_board.create_thread((select actor from _tkg), 'TKG planted', 'coordination', '{"addressingThreadKey":"tkg-key"}'::jsonb) $$,
|
|
71
|
+
'22023', 'metadata key addressingThreadKey is reserved for create_or_find_thread',
|
|
72
|
+
'TKG-1: create_thread refuses metadata carrying addressingThreadKey with 22023');
|
|
73
|
+
select throws_ok(
|
|
74
|
+
$$ select * from agent_board.create_thread((select actor from _tkg), 'TKG planted', 'coordination', '{"addressingThreadKey":null}'::jsonb) $$,
|
|
75
|
+
'22023', 'metadata key addressingThreadKey is reserved for create_or_find_thread',
|
|
76
|
+
'TKG-2: the key is reserved by NAME: a JSON null value is refused too');
|
|
77
|
+
select throws_ok(
|
|
78
|
+
$$ select * from agent_board.create_thread((select actor from _tkg), 'TKG planted', 'coordination', '{"topic":"tkg","addressingThreadKey":"tkg-key-2","z":1}'::jsonb) $$,
|
|
79
|
+
'22023', 'metadata key addressingThreadKey is reserved for create_or_find_thread',
|
|
80
|
+
'TKG-3: the key is refused among other keys');
|
|
81
|
+
select is(
|
|
82
|
+
(select count(*)::int from agent_board.threads t where t.created_by_agent_id = (select actor from _tkg)),
|
|
83
|
+
0, 'TKG-4: the refused calls created no thread at all (refused, not stripped and inserted)');
|
|
84
|
+
|
|
85
|
+
-- TKG-5..8. ALLOW rows.
|
|
86
|
+
select lives_ok(
|
|
87
|
+
$$ insert into _tkg_plain(thread_id)
|
|
88
|
+
select thread_id from agent_board.create_thread((select actor from _tkg), 'TKG plain', 'coordination', '{"topic":"tkg"}'::jsonb) $$,
|
|
89
|
+
'TKG-5: ordinary object metadata is still accepted');
|
|
90
|
+
select is(
|
|
91
|
+
(select t.metadata::text from _tkg_plain c join agent_board.threads t on t.id = c.thread_id),
|
|
92
|
+
'{"topic": "tkg"}', 'TKG-6: and is stored unchanged');
|
|
93
|
+
select lives_ok(
|
|
94
|
+
$$ insert into _tkg_null(thread_id)
|
|
95
|
+
select thread_id from agent_board.create_thread((select actor from _tkg), 'TKG null', 'coordination', null) $$,
|
|
96
|
+
'TKG-7: SQL NULL metadata is still accepted');
|
|
97
|
+
select is(
|
|
98
|
+
(select t.metadata::text from _tkg_null c join agent_board.threads t on t.id = c.thread_id),
|
|
99
|
+
'{}', 'TKG-8: and still means "no metadata"');
|
|
100
|
+
|
|
101
|
+
-- TKG-9..12. SCOPE rows: what the reservation does NOT reach.
|
|
102
|
+
select lives_ok(
|
|
103
|
+
$$ insert into _tkg_scope(label, thread_id)
|
|
104
|
+
select 'a-case', thread_id from agent_board.create_thread((select actor from _tkg), 'TKG case', 'coordination', '{"addressingthreadkey":"tkg-key"}'::jsonb) $$,
|
|
105
|
+
'TKG-9: a differently cased key is not the reserved key (the lookup is case-sensitive)');
|
|
106
|
+
select lives_ok(
|
|
107
|
+
$$ insert into _tkg_scope(label, thread_id)
|
|
108
|
+
select 'b-nested', thread_id from agent_board.create_thread((select actor from _tkg), 'TKG nested', 'coordination', '{"outer":{"addressingThreadKey":"tkg-key"}}'::jsonb) $$,
|
|
109
|
+
'TKG-10: a nested key is not refused (the lookup reads the top level only)');
|
|
110
|
+
select lives_ok(
|
|
111
|
+
$$ insert into _tkg_scope(label, thread_id)
|
|
112
|
+
select 'c-array', thread_id from agent_board.create_thread((select actor from _tkg), 'TKG array', 'coordination', '["addressingThreadKey"]'::jsonb) $$,
|
|
113
|
+
'TKG-11: non-object metadata is left as it was, even an array holding the string');
|
|
114
|
+
select is(
|
|
115
|
+
(select string_agg(c.label || '=' || t.metadata::text, ' ' order by c.label)
|
|
116
|
+
from _tkg_scope c join agent_board.threads t on t.id = c.thread_id),
|
|
117
|
+
'a-case={"addressingthreadkey": "tkg-key"} b-nested={"outer": {"addressingThreadKey": "tkg-key"}} c-array=["addressingThreadKey"]',
|
|
118
|
+
'TKG-12: all three are stored unchanged');
|
|
119
|
+
|
|
120
|
+
-- TKG-13. Whatever create_thread stored, the lookup cannot read a key out of it.
|
|
121
|
+
select is(
|
|
122
|
+
(select count(*)::int from agent_board.threads t
|
|
123
|
+
where t.created_by_agent_id = (select actor from _tkg)
|
|
124
|
+
and t.metadata ->> 'addressingThreadKey' is not null),
|
|
125
|
+
0, 'TKG-13: no thread create_thread wrote is readable by the addressingThreadKey lookup');
|
|
126
|
+
|
|
127
|
+
-- TKG-14/15. END TO END: the plant attempted in TKG-1 did not pre-empt the real call.
|
|
128
|
+
select lives_ok(
|
|
129
|
+
$$ insert into _tkg_cof(thread_id, reused)
|
|
130
|
+
select thread_id, reused from agent_board.create_or_find_thread((select actor from _tkg), 'TKG real', 'tkg-key') $$,
|
|
131
|
+
'TKG-14: create_or_find_thread with the key TKG-1 tried to plant succeeds');
|
|
132
|
+
select is(
|
|
133
|
+
(select c.reused::text || ' threads=' ||
|
|
134
|
+
(select count(*) from agent_board.threads t
|
|
135
|
+
where t.created_by_agent_id = (select actor from _tkg)
|
|
136
|
+
and t.metadata ->> 'addressingThreadKey' = 'tkg-key')
|
|
137
|
+
from _tkg_cof c),
|
|
138
|
+
'false threads=1',
|
|
139
|
+
'TKG-15: it creates its own thread (reused=false) and that is the only one under the pair');
|
|
140
|
+
|
|
141
|
+
-- TKG-16..18. KEPT.
|
|
142
|
+
select throws_ok(
|
|
143
|
+
$$ select * from agent_board.create_thread((select actor from _tkg), ' ', 'coordination', '{}'::jsonb) $$,
|
|
144
|
+
'22023', 'subject is required',
|
|
145
|
+
'TKG-16: a blank subject is still refused with 22023');
|
|
146
|
+
-- Both only READ pg_proc (the function is named in a string, never called), so they cannot raise:
|
|
147
|
+
-- hence the #113 opt-out. to_regprocedure, not a cast, so a missing signature fails by name.
|
|
148
|
+
select is( -- pgtap-allow-raise-checked
|
|
149
|
+
(select p.prosecdef from pg_proc p
|
|
150
|
+
where p.oid = to_regprocedure('agent_board.create_thread(uuid,text,text,jsonb)')),
|
|
151
|
+
true, 'TKG-17: create_thread is still SECURITY DEFINER');
|
|
152
|
+
select is( -- pgtap-allow-raise-checked
|
|
153
|
+
(select p.proconfig from pg_proc p
|
|
154
|
+
where p.oid = to_regprocedure('agent_board.create_thread(uuid,text,text,jsonb)')),
|
|
155
|
+
array['search_path=agent_board, public']::text[],
|
|
156
|
+
'TKG-18: create_thread still pins search_path = agent_board, public');
|
|
157
|
+
|
|
158
|
+
-- TKG-19..21. THE CLASS, derived from the catalog.
|
|
159
|
+
select is(
|
|
160
|
+
(select string_agg(p.oid::regprocedure::text, ', ' order by p.oid::regprocedure::text)
|
|
161
|
+
from pg_proc p
|
|
162
|
+
where p.pronamespace = 'agent_board'::regnamespace
|
|
163
|
+
and p.prokind in ('f', 'p')
|
|
164
|
+
and agent_board_test.stripped_body(p.oid) ~ agent_board_test.stmt_re('insert into', 'threads')),
|
|
165
|
+
'create_or_find_thread(uuid,text,text,text,jsonb), create_thread(uuid,text,text,jsonb)',
|
|
166
|
+
'TKG-19: the functions whose bodies contain INSERT INTO agent_board.threads are exactly create_or_find_thread and create_thread; a new INSERT INTO threads names itself here; a MERGE ... THEN INSERT or a dynamic-SQL insert does not');
|
|
167
|
+
select is(
|
|
168
|
+
(select string_agg(p.oid::regprocedure::text, ', ' order by p.oid::regprocedure::text)
|
|
169
|
+
from pg_proc p
|
|
170
|
+
where p.pronamespace = 'agent_board'::regnamespace
|
|
171
|
+
and p.prokind in ('f', 'p')
|
|
172
|
+
and agent_board_test.stripped_body(p.oid)
|
|
173
|
+
~ agent_board_test.re(agent_board_test.col_assign_frag('threads', 'metadata', true))),
|
|
174
|
+
null::text,
|
|
175
|
+
'TKG-20: no function assigns threads.metadata (UPDATE SET, MERGE update, or ON CONFLICT DO UPDATE); one that does names itself here; a subscripted target (metadata[...] =) is not an arm of col_assign_frag and is not seen');
|
|
176
|
+
select is(
|
|
177
|
+
(select string_agg(r || ':' || priv, ', ' order by r, priv)
|
|
178
|
+
from unnest(array['anon', 'authenticated', 'agent_board_delegate']) r
|
|
179
|
+
cross join unnest(array['INSERT', 'UPDATE']) priv
|
|
180
|
+
where has_table_privilege(r, 'agent_board.threads', priv)
|
|
181
|
+
or has_column_privilege(r, 'agent_board.threads', 'metadata', priv)),
|
|
182
|
+
null::text,
|
|
183
|
+
'TKG-21: no API role can INSERT into or UPDATE agent_board.threads directly, so the two functions are the only route');
|
|
184
|
+
|
|
185
|
+
select * from finish();
|
|
186
|
+
rollback;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
-- THREADKEYSERIALIZE (S-12, migration 20261120000200): create_or_find_thread serialises its
|
|
2
|
+
-- lookup-then-insert on a transaction-scoped advisory lock keyed by (actor, normalized key).
|
|
3
|
+
--
|
|
4
|
+
-- THE CONCURRENCY PROPERTY ITSELF IS PINNED BY THE ISOLATION SPEC, NOT HERE.
|
|
5
|
+
-- tests/isolation/specs/create_or_find_thread_same_key_race.spec runs two real sessions:
|
|
6
|
+
-- permutations 1 and 2 show the second same-(actor, key) caller WAIT and then reuse the first
|
|
7
|
+
-- caller's thread, and permutation 5 shows a different actor with the same key NOT wait. A
|
|
8
|
+
-- pgTAP file is one transaction and cannot observe a wait.
|
|
9
|
+
--
|
|
10
|
+
-- WHAT THIS FILE ADDS is the LOCK'S IDENTITY, by behaviour rather than by reading the body. It
|
|
11
|
+
-- counts the advisory locks THIS backend gains from each call (pg_locks, never prosrc), so it
|
|
12
|
+
-- does not depend on how the lock is spelled -- a helper, a direct pg_advisory_xact_lock, or any
|
|
13
|
+
-- other key text all count the same. Each count is a claim about which calls SHARE a lock:
|
|
14
|
+
-- * the first call takes exactly one new lock (no lock at all is the S-12 defect);
|
|
15
|
+
-- * the same actor with the same key, spelled with the padding trim() removes, takes none
|
|
16
|
+
-- (it re-enters the same lock: the key is locked AFTER normalization);
|
|
17
|
+
-- * a different actor with the same key takes a new one (a key-only lock would serialise
|
|
18
|
+
-- different actors -- #808's mutation M1b);
|
|
19
|
+
-- * the same actor with a different key takes a new one (an actor-only lock would serialise
|
|
20
|
+
-- every key of one actor).
|
|
21
|
+
-- It does NOT pin WHERE the lock is taken relative to the lookup: a lock taken after the
|
|
22
|
+
-- `select ... for update` passes every count here and still races. Only the spec sees that, and
|
|
23
|
+
-- tests/mutations/s12-fix/run.sh records that it does (mutation M3_lock_after_lookup).
|
|
24
|
+
--
|
|
25
|
+
-- Then the metadata refusal 20261120000200 adds (TKS-15..20): a JSON array, scalar or JSON null as
|
|
26
|
+
-- p_metadata is refused with 22023 and creates nothing, because `metadata || {addressingThreadKey}`
|
|
27
|
+
-- on a non-object stores the key where the lookup cannot read it (an array: `[{...}]`) and every
|
|
28
|
+
-- retry inserted again. SQL NULL still means "no metadata". That the refusal comes BEFORE the lock
|
|
29
|
+
-- is pinned by the spec's permutation 7, not here (a subtransaction's locks vanish on rollback).
|
|
30
|
+
--
|
|
31
|
+
-- Plus the behaviour the redefinition promises to KEEP: a blank key is still refused with 22023,
|
|
32
|
+
-- and the function is still SECURITY DEFINER with the same pinned search_path (its EXECUTE ACL
|
|
33
|
+
-- is pinned by tests/catalog/function_execute_privileges.json).
|
|
34
|
+
--
|
|
35
|
+
-- Every call runs under lives_ok and is captured, then asserted separately (#113): a bare
|
|
36
|
+
-- `is((select ... from create_or_find_thread(...)))` aborts the file on a raise instead of
|
|
37
|
+
-- failing it.
|
|
38
|
+
create extension if not exists pgtap with schema extensions;
|
|
39
|
+
set search_path = extensions, public, agent_board;
|
|
40
|
+
|
|
41
|
+
begin;
|
|
42
|
+
|
|
43
|
+
select plan(20);
|
|
44
|
+
|
|
45
|
+
create temp table _tks (actor uuid, other uuid) on commit drop;
|
|
46
|
+
-- The advisory locks this backend already held before the call being measured.
|
|
47
|
+
create temp table _tks_seen (classid oid, objid oid, objsubid smallint) on commit drop;
|
|
48
|
+
-- Capture tables exist BEFORE the calls they capture, so a call that raises under a mutation leaves
|
|
49
|
+
-- an EMPTY capture and its state assertion fails by name, instead of a missing relation aborting
|
|
50
|
+
-- the rest of the file (AGENTS.md rule 3).
|
|
51
|
+
create temp table _tks_first (thread_id uuid, reused boolean) on commit drop;
|
|
52
|
+
create temp table _tks_same (like _tks_first) on commit drop;
|
|
53
|
+
create temp table _tks_other (like _tks_first) on commit drop;
|
|
54
|
+
create temp table _tks_key2 (like _tks_first) on commit drop;
|
|
55
|
+
create temp table _tks_nullmeta (like _tks_first) on commit drop;
|
|
56
|
+
|
|
57
|
+
do $$
|
|
58
|
+
declare
|
|
59
|
+
v_suffix text := replace(substr(gen_random_uuid()::text, 1, 8), '-', '');
|
|
60
|
+
v_actor uuid := gen_random_uuid();
|
|
61
|
+
v_other uuid := gen_random_uuid();
|
|
62
|
+
begin
|
|
63
|
+
insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
|
|
64
|
+
values (v_actor, 'agent', 'agent', 'tks-actor-' || v_suffix, 'TKS Actor', 'active'),
|
|
65
|
+
(v_other, 'agent', 'agent', 'tks-other-' || v_suffix, 'TKS Other', 'active');
|
|
66
|
+
insert into _tks(actor, other) values (v_actor, v_other);
|
|
67
|
+
end
|
|
68
|
+
$$;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
-- How many advisory locks this backend holds that it did not hold at the previous call, and
|
|
72
|
+
-- remember them all. Called once after each measured call.
|
|
73
|
+
create function pg_temp.tks_new_advisory_locks() returns integer
|
|
74
|
+
language plpgsql as $f$
|
|
75
|
+
declare v_new integer;
|
|
76
|
+
begin
|
|
77
|
+
select count(*)::integer into v_new
|
|
78
|
+
from pg_locks l
|
|
79
|
+
where l.pid = pg_backend_pid() and l.locktype = 'advisory' and l.granted
|
|
80
|
+
and not exists (select 1 from _tks_seen s
|
|
81
|
+
where s.classid = l.classid and s.objid = l.objid and s.objsubid = l.objsubid);
|
|
82
|
+
insert into _tks_seen
|
|
83
|
+
select l.classid, l.objid, l.objsubid from pg_locks l
|
|
84
|
+
where l.pid = pg_backend_pid() and l.locktype = 'advisory' and l.granted
|
|
85
|
+
except select * from _tks_seen;
|
|
86
|
+
return v_new;
|
|
87
|
+
end
|
|
88
|
+
$f$;
|
|
89
|
+
-- The same caller identity the isolation spec uses, and the baseline: whatever the fixture took.
|
|
90
|
+
do $$ begin
|
|
91
|
+
perform set_config('request.jwt.claim.role', 'service_role', true);
|
|
92
|
+
perform pg_temp.tks_new_advisory_locks();
|
|
93
|
+
end $$;
|
|
94
|
+
|
|
95
|
+
-- TKS-1. A blank key is still refused, as before the redefinition.
|
|
96
|
+
select throws_ok(
|
|
97
|
+
$$ select * from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', ' ') $$,
|
|
98
|
+
'22023', 'subject and idempotency key are required',
|
|
99
|
+
'TKS-1: a key that trims to empty is still refused with 22023 (no null-key insert path)');
|
|
100
|
+
|
|
101
|
+
-- TKS-2/3/4. The first call, with a padded key.
|
|
102
|
+
select lives_ok(
|
|
103
|
+
$$ insert into _tks_first(thread_id, reused)
|
|
104
|
+
select thread_id, reused from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', ' tks-key ') $$,
|
|
105
|
+
'TKS-2: first call (actor A, key '' tks-key '') succeeds');
|
|
106
|
+
select is((select reused from _tks_first), false, 'TKS-3: the first call creates the thread');
|
|
107
|
+
select is(pg_temp.tks_new_advisory_locks(), 1,
|
|
108
|
+
'TKS-4: the first call takes exactly one new advisory lock (none at all is the S-12 race)');
|
|
109
|
+
|
|
110
|
+
-- TKS-5/6/7. Same actor, the trim-equivalent key: re-enters the SAME lock and reuses the row.
|
|
111
|
+
select lives_ok(
|
|
112
|
+
$$ insert into _tks_same(thread_id, reused)
|
|
113
|
+
select thread_id, reused from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-key') $$,
|
|
114
|
+
'TKS-5: second call (actor A, key ''tks-key'') succeeds');
|
|
115
|
+
select is((select reused::text || ':' || (thread_id = (select thread_id from _tks_first))::text from _tks_same),
|
|
116
|
+
'true:true', 'TKS-6: the second call reuses the first call''s thread');
|
|
117
|
+
select is(pg_temp.tks_new_advisory_locks(), 0,
|
|
118
|
+
'TKS-7: the same actor with the trim-equivalent key takes NO new lock: it is the same lock, so the key is locked after normalization');
|
|
119
|
+
|
|
120
|
+
-- TKS-8/9/10. A different actor, the same key: a DIFFERENT lock.
|
|
121
|
+
select lives_ok(
|
|
122
|
+
$$ insert into _tks_other(thread_id, reused)
|
|
123
|
+
select thread_id, reused from agent_board.create_or_find_thread((select other from _tks), 'TKS subject', 'tks-key') $$,
|
|
124
|
+
'TKS-8: a different actor with the same key succeeds');
|
|
125
|
+
select is((select reused from _tks_other), false, 'TKS-9: the different actor gets its own thread');
|
|
126
|
+
select is(pg_temp.tks_new_advisory_locks(), 1,
|
|
127
|
+
'TKS-10: the different actor takes a NEW lock: actors with the same key do not share one, so they never serialise each other');
|
|
128
|
+
|
|
129
|
+
-- TKS-11/12. The same actor, a different key: a DIFFERENT lock.
|
|
130
|
+
select lives_ok(
|
|
131
|
+
$$ insert into _tks_key2(thread_id, reused)
|
|
132
|
+
select thread_id, reused from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-key-2') $$,
|
|
133
|
+
'TKS-11: the same actor with a different key succeeds');
|
|
134
|
+
select is(pg_temp.tks_new_advisory_locks(), 1,
|
|
135
|
+
'TKS-12: a different key of the same actor takes a NEW lock: the lock is not per actor alone');
|
|
136
|
+
|
|
137
|
+
-- TKS-13/14. Kept: SECURITY DEFINER and the pinned search_path. to_regprocedure, not a cast, so a
|
|
138
|
+
-- missing signature fails these by name instead of aborting the file. Both only READ pg_proc (the
|
|
139
|
+
-- function is named in a string, never called), so they cannot raise: hence the #113 opt-out.
|
|
140
|
+
select is( -- pgtap-allow-raise-checked
|
|
141
|
+
(select p.prosecdef from pg_proc p
|
|
142
|
+
where p.oid = to_regprocedure('agent_board.create_or_find_thread(uuid,text,text,text,jsonb)')),
|
|
143
|
+
true, 'TKS-13: create_or_find_thread is still SECURITY DEFINER');
|
|
144
|
+
select is( -- pgtap-allow-raise-checked
|
|
145
|
+
(select p.proconfig from pg_proc p
|
|
146
|
+
where p.oid = to_regprocedure('agent_board.create_or_find_thread(uuid,text,text,text,jsonb)')),
|
|
147
|
+
array['search_path=agent_board, public']::text[],
|
|
148
|
+
'TKS-14: create_or_find_thread still pins search_path = agent_board, public');
|
|
149
|
+
|
|
150
|
+
-- TKS-15..18. Non-object metadata is REFUSED, and the refused calls create nothing.
|
|
151
|
+
select throws_ok(
|
|
152
|
+
$$ select * from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-meta', 'coordination', '[]'::jsonb) $$,
|
|
153
|
+
'22023', 'metadata must be a JSON object',
|
|
154
|
+
'TKS-15: a JSON array as metadata is refused with 22023');
|
|
155
|
+
select throws_ok(
|
|
156
|
+
$$ select * from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-meta', 'coordination', '"x"'::jsonb) $$,
|
|
157
|
+
'22023', 'metadata must be a JSON object',
|
|
158
|
+
'TKS-16: a JSON scalar as metadata is refused with 22023');
|
|
159
|
+
select throws_ok(
|
|
160
|
+
$$ select * from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-meta', 'coordination', 'null'::jsonb) $$,
|
|
161
|
+
'22023', 'metadata must be a JSON object',
|
|
162
|
+
'TKS-17: a JSON null (not SQL NULL) as metadata is refused with 22023');
|
|
163
|
+
select is(
|
|
164
|
+
(select count(*)::int from agent_board.threads t
|
|
165
|
+
where t.created_by_agent_id = (select actor from _tks)
|
|
166
|
+
and (t.metadata ->> 'addressingThreadKey' = 'tks-meta'
|
|
167
|
+
or (jsonb_typeof(t.metadata) = 'array' and t.metadata @> '[{"addressingThreadKey":"tks-meta"}]'))),
|
|
168
|
+
0, 'TKS-18: the refused calls created no thread under that key, in either storage shape');
|
|
169
|
+
|
|
170
|
+
-- TKS-19/20. SQL NULL metadata is still accepted and means "none"; a second call reuses it.
|
|
171
|
+
select lives_ok(
|
|
172
|
+
$$ insert into _tks_nullmeta(thread_id, reused)
|
|
173
|
+
select thread_id, reused from agent_board.create_or_find_thread((select actor from _tks), 'TKS subject', 'tks-meta', 'coordination', null) $$,
|
|
174
|
+
'TKS-19: SQL NULL metadata is still accepted');
|
|
175
|
+
select is(
|
|
176
|
+
(select n.reused::text || ' ' || t.metadata::text
|
|
177
|
+
from _tks_nullmeta n join agent_board.threads t on t.id = n.thread_id),
|
|
178
|
+
'false {"addressingThreadKey": "tks-meta"}',
|
|
179
|
+
'TKS-20: and the thread it creates stores exactly the key as its metadata');
|
|
180
|
+
|
|
181
|
+
select * from finish();
|
|
182
|
+
rollback;
|
|
@@ -435,10 +435,13 @@ select distinct p.oid,
|
|
|
435
435
|
-- 64 -> 65 with #670's agent_board.send_outcomes (20261108000100). Its only writer,
|
|
436
436
|
-- _record_send_outcome, is EXECUTE-able by no API role but is reached from the authenticated-
|
|
437
437
|
-- executable message cores, so the relation joins WEC-2's set below.
|
|
438
|
+
-- 65 -> 66 with #669 PR-A's agent_board.portal_step_up_proofs (20261109000100). Its only writer,
|
|
439
|
+
-- record_portal_step_up, is EXECUTE-able by service_role only and is called by no function, so
|
|
440
|
+
-- it adds no member to the `authenticated` writer population and WEC-2's set is unchanged.
|
|
438
441
|
select is(
|
|
439
442
|
(select count(*)::text from _wec_target where relkind = 'r'),
|
|
440
|
-
'
|
|
441
|
-
'#325 canary: agent_board has
|
|
443
|
+
'66',
|
|
444
|
+
'#325 canary: agent_board has 66 base tables — the universe the write scan runs over, pinned so an empty violating set below cannot mean an empty universe');
|
|
442
445
|
|
|
443
446
|
-- WEC-2. The relations the class writes, as an EXACT SET. A new one names itself.
|
|
444
447
|
select is(
|
|
@@ -689,7 +692,8 @@ select is( -- pgtap-allow-raise-checked
|
|
|
689
692
|
'agent_board.delete_callback_endpoint(uuid,uuid) -> _resolved_actor_agent_id',
|
|
690
693
|
'agent_board.disable_callback_endpoint(uuid,uuid,text,jsonb) -> _resolved_actor_agent_id',
|
|
691
694
|
'agent_board.issue_signing_key_challenge(uuid,text,interval) -> _resolved_actor_agent_id',
|
|
692
|
-
|
|
695
|
+
-- provision_agent left this set in #669 PR-B (20261124000100): E-3 gave it its own 42501
|
|
696
|
+
-- (kind_change_requires_operator / auth_binding_change_requires_operator).
|
|
693
697
|
'agent_board.register_callback_endpoint(uuid,text,jsonb) -> _resolved_actor_agent_id',
|
|
694
698
|
'agent_board.rotate_callback_signing_key(uuid,uuid,jsonb) -> _resolved_actor_agent_id',
|
|
695
699
|
'agent_board.subscribe_callback_endpoint(uuid,uuid,text,text,uuid,jsonb) -> _resolved_actor_agent_id',
|
|
@@ -699,7 +703,7 @@ select is( -- pgtap-allow-raise-checked
|
|
|
699
703
|
'agent_board.upsert_delegation_policy(uuid,text,jsonb,integer,interval,boolean) -> _resolved_actor_agent_id',
|
|
700
704
|
'agent_board.verify_callback_endpoint(uuid,uuid,jsonb) -> _resolved_actor_agent_id'
|
|
701
705
|
]::text[],
|
|
702
|
-
'#325 HALF B, part 1: exactly these
|
|
706
|
+
'#325 HALF B, part 1: exactly these 14 writers reach NO shared authz predicate and raise no 42501 of their own, and each NAMES the raising resolver it relies on — all 14 the session resolver (provision_agent raises its own 42501 since #669 PR-B); revoke_agent now refuses an unresolved actor in its own body; a new ungated writer joins this set, and a member that loses or switches its resolver reds here');
|
|
703
707
|
|
|
704
708
|
-- WEC-9. The union, and the only assertion here that is a claim about the WHOLE class rather than
|
|
705
709
|
-- about a category. Not spelled over the CLOSURE for 42501: that form is satisfied by 59 of 59
|
|
@@ -784,6 +784,15 @@
|
|
|
784
784
|
"authenticated": false
|
|
785
785
|
}
|
|
786
786
|
},
|
|
787
|
+
{
|
|
788
|
+
"name": "_require_human_step_up",
|
|
789
|
+
"signature": "_require_human_step_up(p_operation text)",
|
|
790
|
+
"executable_by": {
|
|
791
|
+
"anon": false,
|
|
792
|
+
"service_role": false,
|
|
793
|
+
"authenticated": false
|
|
794
|
+
}
|
|
795
|
+
},
|
|
787
796
|
{
|
|
788
797
|
"name": "_require_platform_admin_user_id",
|
|
789
798
|
"signature": "_require_platform_admin_user_id()",
|
|
@@ -964,6 +973,60 @@
|
|
|
964
973
|
"authenticated": false
|
|
965
974
|
}
|
|
966
975
|
},
|
|
976
|
+
{
|
|
977
|
+
"name": "_step_up_amr_methods",
|
|
978
|
+
"signature": "_step_up_amr_methods()",
|
|
979
|
+
"executable_by": {
|
|
980
|
+
"anon": false,
|
|
981
|
+
"service_role": false,
|
|
982
|
+
"authenticated": false
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"name": "_step_up_future_skew_seconds",
|
|
987
|
+
"signature": "_step_up_future_skew_seconds()",
|
|
988
|
+
"executable_by": {
|
|
989
|
+
"anon": false,
|
|
990
|
+
"service_role": false,
|
|
991
|
+
"authenticated": false
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"name": "_step_up_is_fresh",
|
|
996
|
+
"signature": "_step_up_is_fresh(p_proof numeric, p_now numeric)",
|
|
997
|
+
"executable_by": {
|
|
998
|
+
"anon": false,
|
|
999
|
+
"service_role": false,
|
|
1000
|
+
"authenticated": false
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"name": "_step_up_is_portal_human",
|
|
1005
|
+
"signature": "_step_up_is_portal_human(p_agent_id uuid)",
|
|
1006
|
+
"executable_by": {
|
|
1007
|
+
"anon": false,
|
|
1008
|
+
"service_role": false,
|
|
1009
|
+
"authenticated": false
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
"name": "_step_up_max_age_seconds",
|
|
1014
|
+
"signature": "_step_up_max_age_seconds()",
|
|
1015
|
+
"executable_by": {
|
|
1016
|
+
"anon": false,
|
|
1017
|
+
"service_role": false,
|
|
1018
|
+
"authenticated": false
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"name": "_step_up_proof_recordable",
|
|
1023
|
+
"signature": "_step_up_proof_recordable(p_proof numeric, p_now numeric)",
|
|
1024
|
+
"executable_by": {
|
|
1025
|
+
"anon": false,
|
|
1026
|
+
"service_role": false,
|
|
1027
|
+
"authenticated": false
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
967
1030
|
{
|
|
968
1031
|
"name": "_trim_inbox_text",
|
|
969
1032
|
"signature": "_trim_inbox_text(p_value text, p_max_length integer)",
|
|
@@ -1630,6 +1693,15 @@
|
|
|
1630
1693
|
"authenticated": false
|
|
1631
1694
|
}
|
|
1632
1695
|
},
|
|
1696
|
+
{
|
|
1697
|
+
"name": "record_portal_step_up",
|
|
1698
|
+
"signature": "record_portal_step_up(p_agent_id uuid, p_proof_at bigint)",
|
|
1699
|
+
"executable_by": {
|
|
1700
|
+
"anon": false,
|
|
1701
|
+
"service_role": true,
|
|
1702
|
+
"authenticated": false
|
|
1703
|
+
}
|
|
1704
|
+
},
|
|
1633
1705
|
{
|
|
1634
1706
|
"name": "record_session_identity_state",
|
|
1635
1707
|
"signature": "record_session_identity_state(p_identity_agent_id uuid, p_fingerprint jsonb)",
|
|
@@ -349,6 +349,10 @@
|
|
|
349
349
|
"signature": "_refuse_delegate_membership_target(p_agent_id uuid, p_operation text)",
|
|
350
350
|
"declares_p_metadata": false
|
|
351
351
|
},
|
|
352
|
+
{
|
|
353
|
+
"signature": "_require_human_step_up(p_operation text)",
|
|
354
|
+
"declares_p_metadata": false
|
|
355
|
+
},
|
|
352
356
|
{
|
|
353
357
|
"signature": "_require_platform_admin_user_id()",
|
|
354
358
|
"declares_p_metadata": false
|
|
@@ -429,6 +433,30 @@
|
|
|
429
433
|
"signature": "_signed_write_actor_id(p_payload jsonb, p_gateway_decision jsonb, p_actor_field text)",
|
|
430
434
|
"declares_p_metadata": false
|
|
431
435
|
},
|
|
436
|
+
{
|
|
437
|
+
"signature": "_step_up_amr_methods()",
|
|
438
|
+
"declares_p_metadata": false
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"signature": "_step_up_future_skew_seconds()",
|
|
442
|
+
"declares_p_metadata": false
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"signature": "_step_up_is_fresh(p_proof numeric, p_now numeric)",
|
|
446
|
+
"declares_p_metadata": false
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"signature": "_step_up_is_portal_human(p_agent_id uuid)",
|
|
450
|
+
"declares_p_metadata": false
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"signature": "_step_up_max_age_seconds()",
|
|
454
|
+
"declares_p_metadata": false
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"signature": "_step_up_proof_recordable(p_proof numeric, p_now numeric)",
|
|
458
|
+
"declares_p_metadata": false
|
|
459
|
+
},
|
|
432
460
|
{
|
|
433
461
|
"signature": "_trim_inbox_text(p_value text, p_max_length integer)",
|
|
434
462
|
"declares_p_metadata": false
|
|
@@ -725,6 +753,10 @@
|
|
|
725
753
|
"signature": "record_callback_delivery_terminal_failure(p_outbox_event_id uuid, p_endpoint_id uuid, p_http_status integer, p_error_summary text, p_metadata jsonb)",
|
|
726
754
|
"declares_p_metadata": true
|
|
727
755
|
},
|
|
756
|
+
{
|
|
757
|
+
"signature": "record_portal_step_up(p_agent_id uuid, p_proof_at bigint)",
|
|
758
|
+
"declares_p_metadata": false
|
|
759
|
+
},
|
|
728
760
|
{
|
|
729
761
|
"signature": "record_session_identity_state(p_identity_agent_id uuid, p_fingerprint jsonb)",
|
|
730
762
|
"declares_p_metadata": false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "GENERATED by scripts/build-step-up-closure-snapshot.mjs from pg_catalog -- do not hand-edit. #669 plan §14 E-1: `gated` is every agent_board function whose own stripped body calls _require_human_step_up; `forbidden` is the reflexive reverse call closure of that set over agent_board_test.fn_call_closure(), by bare name. scripts/check-step-up-tree.mjs (E-11) forbids supabase/functions/** from naming any `forbidden` name outside its positively-asserted exemptions.",
|
|
3
|
+
"gated": [
|
|
4
|
+
"agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)",
|
|
5
|
+
"agent_board.grant_board_role(uuid,uuid,text,uuid)",
|
|
6
|
+
"agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)",
|
|
7
|
+
"agent_board.set_board_authority_ceiling(uuid,text,uuid)",
|
|
8
|
+
"agent_board.set_board_role_gate(uuid,boolean)",
|
|
9
|
+
"agent_board.update_board_membership(uuid,uuid,text,jsonb)"
|
|
10
|
+
],
|
|
11
|
+
"forbidden": [
|
|
12
|
+
"create_fleet_onboarding_invite",
|
|
13
|
+
"create_invite_link",
|
|
14
|
+
"grant_board_role",
|
|
15
|
+
"leave_board",
|
|
16
|
+
"readmit_session_identity",
|
|
17
|
+
"set_board_authority_ceiling",
|
|
18
|
+
"set_board_role_gate",
|
|
19
|
+
"signed_grant_board_role",
|
|
20
|
+
"signed_set_board_authority_ceiling",
|
|
21
|
+
"tombstone_delegate_instance",
|
|
22
|
+
"update_board_membership"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
-- it there. So an existing install in any other schema is relocated if this session may
|
|
13
13
|
-- (`ALTER EXTENSION … SET SCHEMA` needs the extension's owner; pgtap.control is relocatable = true),
|
|
14
14
|
-- and otherwise REFUSED with the command that resolves it. It is never dropped: a shared cluster's
|
|
15
|
-
-- other tenants may be using it.
|
|
15
|
+
-- other tenants may be using it. Relocation is DATABASE-wide, not session-wide: on a shared cluster
|
|
16
|
+
-- it also moves pgTAP for every other tenant of that database, whose unqualified pgTAP calls then
|
|
17
|
+
-- resolve only if `extensions` is on their search_path too (message-board#764 N6).
|
|
16
18
|
--
|
|
17
19
|
-- The post-conditions are checked, not assumed: pgTAP ends in `extensions`, and resolves on this
|
|
18
20
|
-- session's search_path (the 90-odd test files that set no search_path rely on the role default).
|
|
@@ -52,10 +54,13 @@ begin
|
|
|
52
54
|
raise exception 'pgTAP post-condition failed: extension schema is %, expected extensions', coalesce(v_schema, '<absent>')
|
|
53
55
|
using errcode = '55000';
|
|
54
56
|
end if;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
-- `is null` was not enough: a second pgTAP-shaped plan(integer) earlier on the search_path
|
|
58
|
+
-- resolves too, and the tests would then run against it (message-board#764).
|
|
59
|
+
if to_regprocedure('plan(integer)') is distinct from 'extensions.plan(integer)'::regprocedure then
|
|
60
|
+
raise exception 'pgTAP post-condition failed: plan(integer) resolves to % on search_path %, expected extensions.plan(integer)',
|
|
61
|
+
coalesce(to_regprocedure('plan(integer)')::text, '<unresolved>'), current_setting('search_path')
|
|
57
62
|
using errcode = '55000',
|
|
58
|
-
hint = 'Put extensions on this role''s search_path (Supabase sets "$user", public, extensions for postgres).';
|
|
63
|
+
hint = 'Put extensions on this role''s search_path ahead of any other schema defining plan(integer) (Supabase sets "$user", public, extensions for postgres).';
|
|
59
64
|
end if;
|
|
60
65
|
end
|
|
61
66
|
$pgtap$;
|