@consiliency/agent-board-schema 1.81.0 → 1.83.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/README.md +6 -0
- package/fixtures/already-applied.json +8 -0
- package/migrations/20261202000100_agent_board_archive_board.sql +1238 -0
- package/migrations/20261203000100_agent_board_archive_board_reads.sql +391 -0
- package/package.json +1 -1
- package/schema-manifest.json +21 -3
- package/src/tooling.test.mjs +6 -2
- package/tests/agent_board_667_history_class.test.sql +20 -3
- package/tests/agent_board_archive_board.test.sql +956 -0
- package/tests/agent_board_archive_board_reads.test.sql +785 -0
- package/tests/agent_board_archive_board_reads_plan.test.sql +56 -0
- package/tests/agent_board_atomic_fleet_onboarding.test.sql +2 -0
- package/tests/agent_board_board_claim_policy.test.sql +5 -3
- package/tests/agent_board_claimpolicy_race.test.sql +8 -6
- package/tests/agent_board_fk_lock_edges.test.sql +27 -3
- package/tests/agent_board_gatenull_membstate.test.sql +3 -1
- package/tests/agent_board_invite_no_downgrade.test.sql +2 -2
- package/tests/agent_board_ledger_authority.test.sql +3 -1
- package/tests/agent_board_role_guard.test.sql +4 -1
- package/tests/agent_board_rolereset.test.sql +5 -4
- package/tests/agent_board_room_roster.test.sql +2 -2
- package/tests/agent_board_step_up.test.sql +12 -7
- package/tests/agent_board_step_up_helper.test.sql +20 -17
- package/tests/agent_board_write_enforcement_class.test.sql +2 -1
- package/tests/catalog/function_execute_privileges.json +36 -0
- package/tests/catalog/p_metadata_parameters.json +16 -0
- package/tests/catalog/step_up_gated_closure.json +2 -0
- package/tests/isolation/expected/archive_vs_content.out +800 -0
- package/tests/isolation/specs/archive_vs_content.spec +128 -0
- package/tests/mutations/918/M01_any_role.sql +13 -0
- package/tests/mutations/918/M02_departed_owner.sql +13 -0
- package/tests/mutations/918/M03_no_fleet_recheck.sql +13 -0
- package/tests/mutations/918/M04_no_step_up.sql +13 -0
- package/tests/mutations/918/M04b_step_up_archive_only.sql +14 -0
- package/tests/mutations/918/M04c_step_up_change_only.sql +17 -0
- package/tests/mutations/918/M05_null_flag.sql +12 -0
- package/tests/mutations/918/M05b_null_board.sql +12 -0
- package/tests/mutations/918/M06_not_idempotent.sql +12 -0
- package/tests/mutations/918/M06b_wrong_flag_returned.sql +12 -0
- package/tests/mutations/918/M07_create_board_unarchives.sql +15 -0
- package/tests/mutations/918/M08_no_moderation.sql +12 -0
- package/tests/mutations/918/M08b_any_change.sql +12 -0
- package/tests/mutations/918/M09_bootstrap_archived.sql +12 -0
- package/tests/mutations/918/M10_drop_artifacts.sql +2 -0
- package/tests/mutations/918/M10_drop_board_authority_ceilings.sql +2 -0
- package/tests/mutations/918/M10_drop_board_invite_blocks.sql +2 -0
- package/tests/mutations/918/M10_drop_board_invite_tokens.sql +3 -0
- package/tests/mutations/918/M10_drop_board_memberships.sql +3 -0
- package/tests/mutations/918/M10_drop_boards.sql +2 -0
- package/tests/mutations/918/M10_drop_callback_subscriptions.sql +3 -0
- package/tests/mutations/918/M10_drop_claims.sql +3 -0
- package/tests/mutations/918/M10_drop_conflicts.sql +2 -0
- package/tests/mutations/918/M10_drop_delegations.sql +2 -0
- package/tests/mutations/918/M10_drop_delivery_recipients.sql +2 -0
- package/tests/mutations/918/M10_drop_escalations.sql +2 -0
- package/tests/mutations/918/M10_drop_fleet_receive_policies.sql +2 -0
- package/tests/mutations/918/M10_drop_messages.sql +2 -0
- package/tests/mutations/918/M10_drop_task_events.sql +2 -0
- package/tests/mutations/918/M10_drop_tasks.sql +2 -0
- package/tests/mutations/918/M10_drop_thread_memberships.sql +3 -0
- package/tests/mutations/918/M10_drop_threads.sql +2 -0
- package/tests/mutations/918/M10i_drop_insert_board_invite_tokens.sql +2 -0
- package/tests/mutations/918/M10i_drop_insert_board_memberships.sql +2 -0
- package/tests/mutations/918/M10i_drop_insert_callback_subscriptions.sql +2 -0
- package/tests/mutations/918/M10i_drop_insert_claims.sql +2 -0
- package/tests/mutations/918/M10i_drop_insert_thread_memberships.sql +2 -0
- package/tests/mutations/918/M10u_drop_update_board_invite_tokens.sql +2 -0
- package/tests/mutations/918/M10u_drop_update_board_memberships.sql +2 -0
- package/tests/mutations/918/M10u_drop_update_callback_subscriptions.sql +2 -0
- package/tests/mutations/918/M10u_drop_update_claims.sql +2 -0
- package/tests/mutations/918/M10u_drop_update_thread_memberships.sql +2 -0
- package/tests/mutations/918/M11_artifacts_no_message.sql +10 -0
- package/tests/mutations/918/M11_artifacts_no_task.sql +10 -0
- package/tests/mutations/918/M11_artifacts_no_task_event.sql +10 -0
- package/tests/mutations/918/M11_claims_no_resource_key.sql +10 -0
- package/tests/mutations/918/M11_claims_no_thread.sql +10 -0
- package/tests/mutations/918/M11_delivery_no_source_message.sql +10 -0
- package/tests/mutations/918/M11_delivery_no_source_task.sql +10 -0
- package/tests/mutations/918/M12_claims_all.sql +9 -0
- package/tests/mutations/918/M13_memberships_all.sql +9 -0
- package/tests/mutations/918/M14_tokens_all.sql +9 -0
- package/tests/mutations/918/M15_subscriptions_all.sql +9 -0
- package/tests/mutations/918/M15b_thread_memberships_all.sql +9 -0
- package/tests/mutations/918/M16_messages_update.sql +10 -0
- package/tests/mutations/918/M16b_task_events_update.sql +10 -0
- package/tests/mutations/918/M17_boards_old_only.sql +10 -0
- package/tests/mutations/918/M18_threads_insert_only.sql +10 -0
- package/tests/mutations/918/M18b_guard_disabled.sql +2 -0
- package/tests/mutations/918/M20_no_clamp_exemption.sql +14 -0
- package/tests/mutations/918/M20b_clamp_any_session.sql +14 -0
- package/tests/mutations/918/M20c_clamp_raise.sql +13 -0
- package/tests/mutations/918/M20d_clamp_other_columns.sql +13 -0
- package/tests/mutations/918/M20e_clamp_any_principal.sql +15 -0
- package/tests/mutations/918/M20f_clamp_any_identity_row.sql +13 -0
- package/tests/mutations/918/M21_ignore_old_row.sql +14 -0
- package/tests/mutations/918/M22_never_refuses.sql +12 -0
- package/tests/mutations/918/M22b_wrong_sqlstate.sql +12 -0
- package/tests/mutations/918/M23_delegate_execute.sql +2 -0
- package/tests/mutations/918/M23b_status_oracle.sql +2 -0
- package/tests/mutations/918/M24_new_writer.sql +2 -0
- package/tests/mutations/918/M24b_new_dynamic_writer.sql +2 -0
- package/tests/mutations/918/M24c_second_status_writer.sql +2 -0
- package/tests/mutations/918/M24d_new_relation.sql +2 -0
- package/tests/mutations/918/M24e_direct_grant.sql +2 -0
- package/tests/mutations/918/M25_memberships_dropped_on_archive.sql +10 -0
- package/tests/mutations/918/M27_departure_result_only.sql +10 -0
- package/tests/mutations/918/M27b_departure_any_role.sql +10 -0
- package/tests/mutations/918/M27c_claim_result_only.sql +10 -0
- package/tests/mutations/918/M27d_claim_any_thread.sql +10 -0
- package/tests/mutations/918/M27e_subscription_result_only.sql +10 -0
- package/tests/mutations/918/M28_token_update_not_expiry.sql +8 -0
- package/tests/mutations/918/M28_token_update_not_reanchor.sql +8 -0
- package/tests/mutations/918/M28_token_update_not_role.sql +8 -0
- package/tests/mutations/918/M28_token_update_not_uses.sql +8 -0
- package/tests/mutations/918/M28b_revocation_any_edit.sql +10 -0
- package/tests/mutations/918/M28c_unrevoke.sql +10 -0
- package/tests/mutations/918/M28d_thread_access_agent.sql +10 -0
- package/tests/mutations/918/M28e_thread_access_thread.sql +10 -0
- package/tests/mutations/918/M28f_thread_access_expiry.sql +10 -0
- package/tests/mutations/918/M28g_thread_access_unrevoke.sql +10 -0
- package/tests/mutations/918/M29_grant_no_refusal.sql +13 -0
- package/tests/mutations/918/M29b_grant_refuses_first.sql +18 -0
- package/tests/mutations/918/M30_redeem_no_status.sql +12 -0
- package/tests/mutations/918/M30b_redeem_distinct_text.sql +16 -0
- package/tests/mutations/918/M31_display_any_status.sql +7 -0
- package/tests/mutations/918/M31b_display_not_service.sql +2 -0
- package/tests/mutations/918/M32_status_before_authority.sql +15 -0
- package/tests/mutations/918/M33_retention_refused.sql +14 -0
- package/tests/mutations/918/M33b_retention_any_metadata.sql +14 -0
- package/tests/mutations/918/M34_guard_rewrites_board_id.sql +13 -0
- package/tests/mutations/918/M34_guard_rewrites_claim_policy.sql +13 -0
- package/tests/mutations/918/M34_guard_rewrites_status.sql +13 -0
- package/tests/mutations/918/M34d_guard_returns_null.sql +16 -0
- package/tests/mutations/918/M34e_guard_rewrites_uppercase.sql +13 -0
- package/tests/mutations/918/M34f_guard_select_into_uppercase.sql +13 -0
- package/tests/mutations/918/M35_new_resource_kind.sql +3 -0
- package/tests/mutations/918/M35b_new_fk_anchor.sql +2 -0
- package/tests/mutations/918/M35c_exempt_gains_writer.sql +2 -0
- package/tests/mutations/918/M35d_service_role_gains_update.sql +2 -0
- package/tests/mutations/918/M36_token_created_at.sql +10 -0
- package/tests/mutations/918/M36b_thread_access_created_at.sql +10 -0
- package/tests/mutations/918/M37_non_object_refused.sql +14 -0
- package/tests/mutations/918/M37b_non_object_any_edit.sql +13 -0
- package/tests/mutations/918/M37c_non_object_any_key.sql +13 -0
- package/tests/mutations/918/M37d_non_object_partial_mark.sql +13 -0
- package/tests/mutations/918/M37e_non_object_result_any_type.sql +13 -0
- package/tests/mutations/918/M37f_non_object_any_last_element.sql +13 -0
- package/tests/mutations/918/M38_claim_key_free.sql +10 -0
- package/tests/mutations/918/M38b_claim_key_verbatim.sql +10 -0
- package/tests/mutations/918/M38c_claim_key_canonical_only.sql +10 -0
- package/tests/mutations/918/equivalents/M37ef_grid.sql +42 -0
- package/tests/mutations/918/isolation/I1_guard_no_lock.sql +13 -0
- package/tests/mutations/918/isolation/I2_archive_no_key_update.sql +12 -0
- package/tests/mutations/918/isolation/I3_guard_for_update.sql +12 -0
- package/tests/mutations/918/isolation/I4_archive_any_isolation.sql +12 -0
- package/tests/mutations/918/isolation/I5_redeem_unlocked.sql +12 -0
- package/tests/mutations/918/isolation/I6_thread_membership_unlocked.sql +12 -0
- package/tests/mutations/918/isolation/I7_thread_membership_for_share.sql +12 -0
- package/tests/mutations/918/pr2/R01_inbox_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R01b_inbox_hides_boardless.sql +9 -0
- package/tests/mutations/918/pr2/R01d_inbox_requires_readable.sql +9 -0
- package/tests/mutations/918/pr2/R01e_inbox_active_too.sql +9 -0
- package/tests/mutations/918/pr2/R02_counts_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R02b_counts_hide_boardless.sql +9 -0
- package/tests/mutations/918/pr2/R03_dashboard_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R03b_dashboard_hides_boardless.sql +9 -0
- package/tests/mutations/918/pr2/R03c_dashboard_tasks.sql +9 -0
- package/tests/mutations/918/pr2/R03d_dashboard_calls_helper.sql +9 -0
- package/tests/mutations/918/pr2/R04_open_esc_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R04b_open_esc_no_task.sql +9 -0
- package/tests/mutations/918/pr2/R04c_open_esc_no_thread.sql +9 -0
- package/tests/mutations/918/pr2/R05_ops_esc_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R05b_ops_esc_no_task.sql +9 -0
- package/tests/mutations/918/pr2/R05c_ops_esc_no_thread.sql +9 -0
- package/tests/mutations/918/pr2/R06_stale_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R06b_stale_no_task.sql +9 -0
- package/tests/mutations/918/pr2/R06c_stale_no_thread.sql +9 -0
- package/tests/mutations/918/pr2/R06d_stale_no_key.sql +9 -0
- package/tests/mutations/918/pr2/R06e_stale_unguarded_cast.sql +9 -0
- package/tests/mutations/918/pr2/R07_memberships_filtered.sql +9 -0
- package/tests/mutations/918/pr2/R07b_memberships_constant.sql +9 -0
- package/tests/mutations/918/pr2/R08a_v_active_claims_filtered.sql +9 -0
- package/tests/mutations/918/pr2/R08b_v_board_feed_filtered.sql +9 -0
- package/tests/mutations/918/pr2/R08c_task_tree_filtered.sql +5 -0
- package/tests/mutations/918/pr2/R08d_thread_feed_filtered.sql +5 -0
- package/tests/mutations/918/pr2/R08e_callback_subs_filtered.sql +5 -0
- package/tests/mutations/918/pr2/R09_inbox_definer_view.sql +9 -0
- package/tests/mutations/918/pr2/R09b_view_grant.sql +2 -0
- package/tests/mutations/918/pr2/R09c_view_revoke.sql +2 -0
- package/tests/mutations/918/pr2/R09d_column_renamed.sql +2 -0
- package/tests/mutations/918/pr2/R10_new_view.sql +2 -0
- package/tests/mutations/918/pr2/R10b_new_routine.sql +2 -0
- package/tests/mutations/918/pr2/R10c_new_indirect_routine.sql +2 -0
- package/tests/mutations/918/pr2/R10d_predicate_returns_rows.sql +2 -0
- package/tests/mutations/918/pr2/R10e_overload.sql +3 -0
- package/tests/mutations/918/pr2/R10f_execute_root.sql +2 -0
- package/tests/mutations/918/pr2/R10g_predicate_array.sql +2 -0
- package/tests/mutations/918/pr2/R10h_predicate_domain.sql +2 -0
- package/tests/mutations/918/pr2/R10i_polymorphic.sql +2 -0
- package/tests/mutations/918/pr2/R10j_predicate_json.sql +2 -0
- package/tests/mutations/918/pr2/R10k_foreign_view.sql +2 -0
- package/tests/mutations/918/pr2/R10l_foreign_view_transitive.sql +2 -0
- package/tests/mutations/918/pr2/R10m_foreign_view_function.sql +2 -0
- package/tests/mutations/918/pr2/R10n_foreign_matview.sql +2 -0
- package/tests/mutations/918/pr2/R10o_ambiguous_overload.sql +6 -0
- package/tests/mutations/918/pr2/R10p_resolved_overload.sql +6 -0
- package/tests/mutations/918/pr2/R11_requests_no_filter.sql +9 -0
- package/tests/mutations/918/pr2/R11b_requests_hide_all.sql +9 -0
- package/tests/mutations/918/pr2/R11c_requests_no_creator.sql +11 -0
- package/tests/mutations/918/pr2/R11d_requests_no_pending.sql +9 -0
- package/tests/mutations/918/pr2/R11e_requests_any_state.sql +9 -0
- package/tests/mutations/918/pr2/R11f_requests_active_too.sql +9 -0
- package/tests/mutations/918/pr2/R12_helper_definer.sql +2 -0
- package/tests/mutations/918/pr2/R12b_helper_no_thread.sql +11 -0
- package/tests/mutations/918/pr2/R12c_helper_no_task.sql +11 -0
- package/tests/mutations/918/pr2/R12d_helper_any_board.sql +10 -0
- package/tests/mutations/918/pr2/R12e_helper_task_any_board.sql +10 -0
- package/tests/mutations/918/pr2/R12f_helper_null.sql +11 -0
- package/tests/mutations/918/pr2/R12g_helper_delegate.sql +2 -0
- package/tests/mutations/918/pr2/R12h_helper_public.sql +2 -0
- package/tests/mutations/918/pr2/R12i_no_generic_plan.sql +2 -0
- package/tests/mutations/918/pr2/R13_archive_columns.sql +2 -0
- package/tests/mutations/918/pr2/R13b_second_agents_fk.sql +2 -0
- package/tests/mutations/918/pr2/R13c_archive_column.sql +2 -0
- package/tests/mutations/918/pr2/R15_rls_narrowed.sql +2 -0
- package/tests/mutations/918/pr2/R15b_rls_widened.sql +2 -0
- package/tests/mutations/918/pr2/R15c_threads_rls_narrowed.sql +2 -0
- package/tests/mutations/918/pr2/R16_archive_deletes.sql +10 -0
- package/tests/mutations/918/pr2/R16b_archive_marks_read.sql +10 -0
- package/tests/mutations/918/pr2/R17_wake_bypasses_inbox.sql +8 -0
- package/tests/mutations/918/pr2/R18_directory_archived.sql +7 -0
- package/tests/mutations/918/pr2/R19_delegate_ids_active_only.sql +7 -0
- package/tests/mutations/918/run.sh +95 -0
- package/tests/seeds/20261202000100_agent_board_archive_board.sql.pre.sql +24 -0
- package/tests/seeds/20261203000100_agent_board_archive_board_reads.sql.pre.sql +38 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
-- #918 ARCHIVEBOARD PR-2 pgTAP: _thread_on_board's cached generic plan, ACROSS TRANSACTIONS of one backend.
|
|
2
|
+
--
|
|
3
|
+
-- plan_cache_mode = force_generic_plan keeps one cached plan for the life of the session, and that plan
|
|
4
|
+
-- carries the threads and tasks policies. Each caller must still get its own answer: the policies read the
|
|
5
|
+
-- caller's claims when the plan RUNS, and the plan cache re-plans when the role changes. This file commits
|
|
6
|
+
-- read-only transactions, so it uses the committed upgrade seed (tests/seeds/20261203000100_….pre.sql: SO owns and
|
|
7
|
+
-- SM is on an archived board) and an agent of another seed (OT) that can read none of it. It is a file of its own
|
|
8
|
+
-- because a mutation receipt runs a test inside one transaction it must be able to roll back. The same
|
|
9
|
+
-- sequence within one transaction is AR-E3 in agent_board_archive_board_reads.test.sql.
|
|
10
|
+
create extension if not exists pgtap with schema extensions;
|
|
11
|
+
set search_path = extensions, public, agent_board;
|
|
12
|
+
|
|
13
|
+
\set caller_so '{"role":"authenticated","sub":"91891000-0000-4000-8000-0000000000b1","aud":"authenticated"}'
|
|
14
|
+
\set caller_sm '{"role":"authenticated","sub":"91891000-0000-4000-8000-0000000000b2","aud":"authenticated"}'
|
|
15
|
+
\set caller_ot '{"role":"authenticated","sub":"91890000-0000-4000-8000-0000000000b2","aud":"authenticated"}'
|
|
16
|
+
\set caller_svc '{"role":"service_role"}'
|
|
17
|
+
-- Seven calls, so plpgsql is past its custom-plan trials whatever its setting; then what the caller can select itself.
|
|
18
|
+
\set q 'select concat_ws(chr(47), bool_and(agent_board._thread_on_board(array[''91891000-0000-4000-8000-000000000001''::uuid], ''91891000-0000-4000-8000-000000000002'')), (select count(*) from agent_board.threads where id = ''91891000-0000-4000-8000-000000000002''), (select count(*) from agent_board.v_open_escalations where thread_id = ''91891000-0000-4000-8000-000000000002''), current_user) from generate_series(1, 7)'
|
|
19
|
+
|
|
20
|
+
begin; select set_config('request.jwt.claims', :'caller_so', true) as c \gset x_
|
|
21
|
+
set local role authenticated; select (:q) as r1 \gset
|
|
22
|
+
commit;
|
|
23
|
+
begin; select set_config('request.jwt.claims', :'caller_ot', true) as c \gset x_
|
|
24
|
+
set local role authenticated; select (:q) as r2 \gset
|
|
25
|
+
commit;
|
|
26
|
+
begin; select set_config('request.jwt.claims', :'caller_sm', true) as c \gset x_
|
|
27
|
+
set local role authenticated; select (:q) as r3 \gset
|
|
28
|
+
commit;
|
|
29
|
+
begin; select set_config('request.jwt.claims', :'caller_svc', true) as c \gset x_
|
|
30
|
+
set local role service_role; select (:q) as r4 \gset
|
|
31
|
+
commit;
|
|
32
|
+
begin; select set_config('request.jwt.claims', :'caller_ot', true) as c \gset x_
|
|
33
|
+
set local role authenticated; select (:q) as r5 \gset
|
|
34
|
+
commit;
|
|
35
|
+
begin; select set_config('request.jwt.claims', :'caller_svc', true) as c \gset x_
|
|
36
|
+
set local role service_role; select (:q) as r6 \gset
|
|
37
|
+
commit;
|
|
38
|
+
begin; select set_config('request.jwt.claims', :'caller_so', true) as c \gset x_
|
|
39
|
+
set local role authenticated; select (:q) as r7 \gset
|
|
40
|
+
commit;
|
|
41
|
+
|
|
42
|
+
begin;
|
|
43
|
+
select plan(3);
|
|
44
|
+
select is(
|
|
45
|
+
(select status from agent_board.boards where id = '91891000-0000-4000-8000-000000000001')
|
|
46
|
+
|| '/' || (select count(*) from agent_board.escalations where thread_id = '91891000-0000-4000-8000-000000000002' and status = 'open'),
|
|
47
|
+
'archived/1', 'AR-P control: the seed board is archived, with one open escalation');
|
|
48
|
+
select is(
|
|
49
|
+
concat_ws(' ', :'r1'::text, :'r2'::text, :'r3'::text, :'r4'::text, :'r5'::text, :'r6'::text, :'r7'::text),
|
|
50
|
+
't/1/0/authenticated f/0/0/authenticated t/1/0/authenticated t/1/0/service_role f/0/0/authenticated t/1/0/service_role t/1/0/authenticated',
|
|
51
|
+
'AR-P: SO, OT, SM, service_role, OT, service_role, SO in consecutive transactions of one backend: _thread_on_board / threads readable / escalations listed, each caller its own answer');
|
|
52
|
+
select is(
|
|
53
|
+
(select array_to_string(proconfig, ',') from pg_proc where oid = to_regprocedure('agent_board._thread_on_board(uuid[],uuid,uuid)')),
|
|
54
|
+
'search_path="",plan_cache_mode=force_generic_plan', 'AR-P: the setting under test is the one in force');
|
|
55
|
+
select * from finish();
|
|
56
|
+
rollback;
|
|
@@ -729,6 +729,8 @@ select is( -- pgtap-allow-raise-checked: catalog read only; the RPC names below
|
|
|
729
729
|
'agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval) [definer] => authenticated',
|
|
730
730
|
'agent_board.revoke_fleet_subject(text,uuid,uuid,text,jsonb) [definer] => authenticated,service_role',
|
|
731
731
|
'agent_board.revoke_human_subtree(uuid,uuid,text) [definer] => service_role',
|
|
732
|
+
-- #918: joined because it takes _lock_board_authority_ceiling before the board row lock.
|
|
733
|
+
'agent_board.set_board_archived(uuid,boolean) [definer] => authenticated,service_role',
|
|
732
734
|
'agent_board.set_board_authority_ceiling(uuid,text,uuid) [definer] => authenticated,service_role',
|
|
733
735
|
-- Joined this class in #269 F4: the signed grant wrapper now takes the board advisory lock
|
|
734
736
|
-- FIRST, because its order was board_memberships(grantee) -> agents(signer) against
|
|
@@ -460,9 +460,11 @@ select is(
|
|
|
460
460
|
has_table_privilege('anon', 'agent_board.boards', 'update')::text,
|
|
461
461
|
has_table_privilege('authenticated', 'agent_board.boards', 'update')::text,
|
|
462
462
|
has_table_privilege('service_role', 'agent_board.boards', 'update')::text,
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
463
|
+
-- #918: the archived-board guard refuses or passes; it never rewrites NEW (pinned in
|
|
464
|
+
-- agent_board_archive_board.test.sql), so it cannot change the column.
|
|
465
|
+
(select string_agg(tgname || ':' || tgfoid::regproc::text, ',' order by tgname) from pg_trigger where tgrelid = 'agent_board.boards'::regclass and not tgisinternal)),
|
|
466
|
+
'anon=false, authenticated=false, service_role=false, user_triggers=trg_archived_board_guard:_archived_board_guard',
|
|
467
|
+
'BCP-20 CLASS: no role holds UPDATE on agent_board.boards and the table carries no user trigger but the refusal-only #918 guard — so the column is unreachable except through the definer function BCP-19 enumerates, which is the bound a source scan cannot give');
|
|
466
468
|
|
|
467
469
|
-- ---------------------------------------------------------------------------
|
|
468
470
|
-- BCP-10: A FLEET-REVOKED OWNER IS STILL AN OWNER BY MEMBERSHIP. This function shipped its first
|
|
@@ -1686,12 +1686,13 @@ select is(
|
|
|
1686
1686
|
select is(
|
|
1687
1687
|
format('rules=%s, user_triggers=%s, anon=%s, authenticated=%s, service_role=%s',
|
|
1688
1688
|
(select count(*) from pg_rewrite where ev_class = 'agent_board.boards'::regclass)::text,
|
|
1689
|
-
|
|
1689
|
+
-- #918: refusal-only guard (pinned in agent_board_archive_board.test.sql), named exactly.
|
|
1690
|
+
(select string_agg(tgname::text, ',' order by tgname) from pg_trigger where tgrelid = 'agent_board.boards'::regclass and not tgisinternal),
|
|
1690
1691
|
has_table_privilege('anon', 'agent_board.boards', 'update')::text,
|
|
1691
1692
|
has_table_privilege('authenticated', 'agent_board.boards', 'update')::text,
|
|
1692
1693
|
has_table_privilege('service_role', 'agent_board.boards', 'update')::text),
|
|
1693
|
-
'rules=0, user_triggers=
|
|
1694
|
-
'CPR-8 SOLE WRITER (rules/triggers/table privileges): boards carries no rewrite rule and no user trigger, and none of the three PostgREST roles holds table-level UPDATE — the general bound over ALL grantees is CPR-7, whose information_schema source expands a table-level grant per column and so sees a grant to any role, not just these three');
|
|
1694
|
+
'rules=0, user_triggers=trg_archived_board_guard, anon=false, authenticated=false, service_role=false',
|
|
1695
|
+
'CPR-8 SOLE WRITER (rules/triggers/table privileges): boards carries no rewrite rule and no user trigger but the refusal-only #918 guard, and none of the three PostgREST roles holds table-level UPDATE — the general bound over ALL grantees is CPR-7, whose information_schema source expands a table-level grant per column and so sees a grant to any role, not just these three');
|
|
1695
1696
|
|
|
1696
1697
|
-- CPR-9. Dynamic-SQL bound. A `set claim_policy` assembled at run time is invisible to CPR-6, so
|
|
1697
1698
|
-- the population that COULD assemble one is bounded instead, and each member is cleared
|
|
@@ -1825,9 +1826,10 @@ select is(
|
|
|
1825
1826
|
select is(
|
|
1826
1827
|
format('rules=%s, user_triggers=%s',
|
|
1827
1828
|
(select count(*) from pg_rewrite where ev_class = 'agent_board.threads'::regclass)::text,
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
'
|
|
1829
|
+
-- #918: refusal-only guard (pinned in agent_board_archive_board.test.sql), named exactly.
|
|
1830
|
+
(select string_agg(tgname::text, ',' order by tgname) from pg_trigger where tgrelid = 'agent_board.threads'::regclass and not tgisinternal)),
|
|
1831
|
+
'rules=0, user_triggers=trg_archived_board_guard',
|
|
1832
|
+
'CPR-13b BOARD IMMUTABILITY (rules/triggers): threads carries no rewrite rule and no user trigger but the refusal-only #918 guard, so nothing rewrites board_id beneath the first-board-wins guard CPR-12 pins');
|
|
1831
1833
|
|
|
1832
1834
|
-- CPR-13c. The dynamic-SQL bound is CPR-9's, EXTENDED IN PLACE rather than duplicated here: its
|
|
1833
1835
|
-- format string now carries `mentions_threads` beside `mentions_boards` for each of the two
|
|
@@ -40,7 +40,7 @@ set search_path = extensions, public, agent_board;
|
|
|
40
40
|
|
|
41
41
|
begin;
|
|
42
42
|
|
|
43
|
-
select plan(
|
|
43
|
+
select plan(24);
|
|
44
44
|
|
|
45
45
|
-- ---------------------------------------------------------------------------
|
|
46
46
|
-- The derivation, materialized once. `first_path` is the position PATH of the
|
|
@@ -226,8 +226,32 @@ select is(
|
|
|
226
226
|
join pg_class cl on cl.oid = t.tgrelid
|
|
227
227
|
join pg_namespace n on n.oid = cl.relnamespace
|
|
228
228
|
where not t.tgisinternal and n.nspname = 'agent_board')),
|
|
229
|
-
'_session_identity_agent_lineage',
|
|
230
|
-
'FKL-8: the catalog-derived locking trigger class is exactly the positively bounded fresh legacy-identity constructor; new trigger locks name themselves');
|
|
229
|
+
'_archived_board_guard, _session_identity_agent_lineage',
|
|
230
|
+
'FKL-8: the catalog-derived locking trigger class is exactly the positively bounded fresh legacy-identity constructor and the #918 archived-board guard; new trigger locks name themselves');
|
|
231
|
+
|
|
232
|
+
-- #918. The archived-board guard runs inside every guarded write, and this detector does not attach
|
|
233
|
+
-- a trigger's locks to the statement that fires it, so its edge is bounded here instead. On
|
|
234
|
+
-- boards it takes ONE lock: FOR KEY SHARE, the mode every FK to boards already takes at the end of the same
|
|
235
|
+
-- statement, taken BEFORE the row's own FK locks (so boards still precedes agents, the canonical
|
|
236
|
+
-- order). KEY SHARE conflicts only with FOR UPDATE; the functions that take it on boards are the
|
|
237
|
+
-- exact set below, each of which locks boards before agents.
|
|
238
|
+
select is((select string_agg(distinct e.rel_name || ' ' || e.lock_mode, ' | ' order by e.rel_name || ' ' || e.lock_mode)
|
|
239
|
+
from _le e where e.fn_name in ('_archived_board_guard', '_assert_boards_not_archived')),
|
|
240
|
+
'agent_board.boards key share | agent_board.threads no key update',
|
|
241
|
+
'FKL-8-archive-guard: the archived-board guard locks boards FOR KEY SHARE, and (thread_memberships only) the thread FOR NO KEY UPDATE');
|
|
242
|
+
-- The thread lock is taken in the thread_memberships branch alone (A3): that relation has no routine
|
|
243
|
+
-- writer, so no caller already holds the thread. It is threads-before-boards, as every content write is.
|
|
244
|
+
select is((select format('thread_reads=%s nku=%s in_branch=%s',
|
|
245
|
+
regexp_count(b, agent_board_test.re('\mfrom\s+agent_board\.threads\M')),
|
|
246
|
+
regexp_count(b, agent_board_test.re('\mfor\s+no\s+key\s+update\M')),
|
|
247
|
+
regexp_count(b, agent_board_test.re('tg_table_name\s*=\s*then\s+select\s+th\.board_id\s+into\s+v_board\s+from\s+agent_board\.threads\s+th\s+where\s+th\.id\s*=\s*v_thread\s+for\s+no\s+key\s+update\s*;\s*else')))
|
|
248
|
+
from (select agent_board_test.stripped_body('agent_board._archived_board_guard()'::regprocedure) as b) x),
|
|
249
|
+
'thread_reads=2 nku=1 in_branch=1', 'FKL-8-archive-guard: the thread lock is in one table''s branch, and the other branch reads without it');
|
|
250
|
+
select is((select string_agg(distinct e.fn_name, ', ' order by e.fn_name)
|
|
251
|
+
from _le e where e.own and e.rel_name = 'agent_board.boards' and e.via = 'textual'
|
|
252
|
+
and agent_board_test.row_locks_conflict(e.lock_mode, 'key share')),
|
|
253
|
+
'create_fleet_onboarding_invite, enroll_federated_human, onboard_federated_fleet_agent, set_board_archived',
|
|
254
|
+
'FKL-8-archive-guard: the functions whose explicit boards lock excludes the guard''s KEY SHARE are exactly these');
|
|
231
255
|
|
|
232
256
|
-- This trigger may INSERT only the identity for NEW.id on an agents INSERT,
|
|
233
257
|
-- never another ancestor and never on UPDATE. Its own-agent FK is already
|
|
@@ -230,7 +230,7 @@ begin
|
|
|
230
230
|
|
|
231
231
|
-- an ARCHIVED board on which a member still holds a joined row
|
|
232
232
|
insert into agent_board.boards(slug, name, created_by_agent_id, visibility, status)
|
|
233
|
-
values ('gn-arch-' || s, 'GN Archived', v_owner, 'invite_only', '
|
|
233
|
+
values ('gn-arch-' || s, 'GN Archived', v_owner, 'invite_only', 'active') returning id into v_arch;
|
|
234
234
|
|
|
235
235
|
-- an ADMIN on the main board (lower rank than owner)
|
|
236
236
|
v_admin_uid := gen_random_uuid();
|
|
@@ -245,6 +245,8 @@ begin
|
|
|
245
245
|
-- the admin also holds a joined row on the archived board (to test self-leave there)
|
|
246
246
|
insert into agent_board.board_memberships(board_id, agent_id, role, membership_state, created_by_agent_id)
|
|
247
247
|
values (v_arch, v_admin, 'member', 'joined', v_owner);
|
|
248
|
+
-- #918: seated BEFORE the archive; an archived board takes no new active membership.
|
|
249
|
+
update agent_board.boards set status = 'archived' where id = v_arch;
|
|
248
250
|
|
|
249
251
|
-- a KICKED agent (membership_state='removed') on the main board
|
|
250
252
|
v_kicked_uid := gen_random_uuid();
|
|
@@ -521,8 +521,8 @@ select is(
|
|
|
521
521
|
join pg_proc p on p.oid = t.tgfoid
|
|
522
522
|
where n.nspname = 'agent_board' and c.relname = 'board_memberships'
|
|
523
523
|
and not t.tgisinternal),
|
|
524
|
-
array['trg_board_memberships_last_owner_guard:27:_board_memberships_last_owner_guard']::text[],
|
|
525
|
-
'#317: only the exact UPDATE/DELETE last-owner guard
|
|
524
|
+
array['trg_archived_board_guard:7:_archived_board_guard','trg_archived_board_guard_update:19:_archived_board_guard','trg_board_memberships_last_owner_guard:27:_board_memberships_last_owner_guard']::text[],
|
|
525
|
+
'#317: only the exact UPDATE/DELETE last-owner guard and the INSERT and UPDATE refusal-only #918 guards are installed; new state-rewriting triggers name themselves (preserved-state controls are in agent_board_role_guard)');
|
|
526
526
|
|
|
527
527
|
select is(
|
|
528
528
|
(select coalesce(array_agg(r.rulename::text order by r.rulename::text), array[]::text[])
|
|
@@ -569,7 +569,7 @@ select is(
|
|
|
569
569
|
|| '|' || agent_board_test.call_frag('_actor_fleet_revoked'))),
|
|
570
570
|
'_redeem_unbounded_invite_for_agent,_session_identity_ancestor_ceiling,add_delegate_to_board,approve_identity_state,create_board,create_invite_link,grant_board_role,'
|
|
571
571
|
|| 'link_session_alias,mint_delegated_child,readmit_session_identity,rename_agent,revoke_agent,revoke_session_identity,'
|
|
572
|
-
|| 'set_board_authority_ceiling,set_board_claim_policy,set_board_role_gate',
|
|
572
|
+
|| 'set_board_archived,set_board_authority_ceiling,set_board_claim_policy,set_board_role_gate',
|
|
573
573
|
'the catalog-derived ledger-consult set includes SID writers and the read-only ancestor gate');
|
|
574
574
|
|
|
575
575
|
-- The gate proper: the two sets must differ by EXACTLY the three asserted exemptions, and any
|
|
@@ -608,6 +608,8 @@ select is(
|
|
|
608
608
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.stmt_re('insert into|update', 'board_authority_ceilings')
|
|
609
609
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('boards', 'role_gate_enforced')
|
|
610
610
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('boards', 'claim_policy')
|
|
611
|
+
-- #918: archiving is an authority write (owner-only, ledger-gated).
|
|
612
|
+
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('boards', 'status')
|
|
611
613
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.stmt_re('insert into', 'board_invite_tokens'))
|
|
612
614
|
<> (agent_board_test.stripped_body(p.oid)
|
|
613
615
|
~ agent_board_test.re(agent_board_test.call_frag('_assert_actor_not_fleet_revoked')
|
|
@@ -293,7 +293,10 @@ select isnt(obj_description(to_regprocedure('agent_board._board_memberships_last
|
|
|
293
293
|
|
|
294
294
|
-- Re-pinned by #669 PR-B (20261124000100): the only body change is the step-up helper call before
|
|
295
295
|
-- the final return; agent_board_step_up.test.sql EC-SU-2 pins that edit and its placement.
|
|
296
|
-
|
|
296
|
+
-- Re-pinned by #918 (20261202000100): the only body change is the archived-board refusal before the
|
|
297
|
+
-- UPDATE (f0532a58... plus that one block); agent_board_archive_board.test.sql and mutants M29/M29b pin
|
|
298
|
+
-- that it is there and that it follows the authority checks.
|
|
299
|
+
select is((select md5(prosrc) from pg_proc where oid=to_regprocedure('agent_board.grant_board_role(uuid,uuid,text,uuid)')),'671b705e7f86e05358b02663183e8042','CLASS-main grant body unchanged'); -- pgtap-allow-raise-checked: non-raising catalog identity lookup; no RPC is executed.
|
|
297
300
|
|
|
298
301
|
select ok(strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'agent_board._lock_board_authority_ceiling(')>0 and strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'agent_board._lock_board_authority_ceiling(')<strpos(agent_board_test.stripped_body('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure),'for update'),'CLASS-departure advisory before membership row lock');
|
|
299
302
|
|
|
@@ -288,16 +288,17 @@ select ok(
|
|
|
288
288
|
limit 1),
|
|
289
289
|
'grant_board_role carries the active-state predicate exactly THREE times (#674: step-6 target, step-6 grantor join, UPDATE -- the TOCTOU half)');
|
|
290
290
|
|
|
291
|
-
-- 16. The
|
|
292
|
-
--
|
|
291
|
+
-- 16. The user triggers are the UPDATE/DELETE last-owner refusal guard and the #918
|
|
292
|
+
-- INSERT/UPDATE archived-board refusal guard. Neither rewrites NEW (the second is pinned in
|
|
293
|
+
-- agent_board_archive_board.test.sql), so neither can erase an owner/admin preset.
|
|
293
294
|
select is(
|
|
294
295
|
(select string_agg(t.tgname || ':' || t.tgtype::text, ',' order by t.tgname) from pg_trigger t
|
|
295
296
|
join pg_class c on c.oid = t.tgrelid
|
|
296
297
|
join pg_namespace n on n.oid = c.relnamespace
|
|
297
298
|
where n.nspname = 'agent_board' and c.relname = 'board_memberships'
|
|
298
299
|
and not t.tgisinternal),
|
|
299
|
-
'trg_board_memberships_last_owner_guard:27',
|
|
300
|
-
'only the last-owner UPDATE/DELETE
|
|
300
|
+
'trg_archived_board_guard:7,trg_archived_board_guard_update:19,trg_board_memberships_last_owner_guard:27',
|
|
301
|
+
'only the last-owner UPDATE/DELETE and #918 INSERT/UPDATE refusal triggers exist; the role clamp remains mutator-sited');
|
|
301
302
|
|
|
302
303
|
-- 17. STRUCTURAL: the mutator's superseding comment no longer claims it never writes role.
|
|
303
304
|
select ok(
|
|
@@ -127,9 +127,9 @@ select is(
|
|
|
127
127
|
array[
|
|
128
128
|
'board_membership_id', 'board_id', 'board_slug', 'board_name', 'agent_id',
|
|
129
129
|
'agent_handle', 'agent_display_name', 'membership_state', 'created_by_agent_id',
|
|
130
|
-
'created_by_handle', 'left_at', 'created_at', 'updated_at', 'role'
|
|
130
|
+
'created_by_handle', 'left_at', 'created_at', 'updated_at', 'role', 'board_status'
|
|
131
131
|
]::text[],
|
|
132
|
-
'RC-12: v_board_memberships preserves prior ordinals and appends role after updated_at');
|
|
132
|
+
'RC-12: v_board_memberships preserves prior ordinals and appends role after updated_at, then board_status (#918)');
|
|
133
133
|
|
|
134
134
|
select is(
|
|
135
135
|
(select 'security_invoker=true' = any(coalesce(c.reloptions, '{}'::text[]))
|
|
@@ -223,7 +223,7 @@ create function pg_temp.gw(p_actor text) returns jsonb language sql as $$
|
|
|
223
223
|
-- ===========================================================================
|
|
224
224
|
create temp table _cl as select * from agent_board_test.fn_call_closure();
|
|
225
225
|
-- The §7.4 property: a function's own stripped body writes board_memberships.role,
|
|
226
|
-
-- boards.role_gate_enforced or board_authority_ceilings, or inserts board_invite_tokens.
|
|
226
|
+
-- boards.role_gate_enforced, boards.status (#918) or board_authority_ceilings, or inserts board_invite_tokens.
|
|
227
227
|
create temp table _direct as
|
|
228
228
|
select p.oid, p.proname::text as name
|
|
229
229
|
from pg_proc p
|
|
@@ -231,6 +231,9 @@ select p.oid, p.proname::text as name
|
|
|
231
231
|
and p.prolang <> (select oid from pg_language where lanname = 'internal')
|
|
232
232
|
and (agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('board_memberships', 'role')
|
|
233
233
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('boards', 'role_gate_enforced')
|
|
234
|
+
-- #918 (owner decision 2): archiving and un-archiving are gated acts, so a writer of
|
|
235
|
+
-- boards.status is in the class.
|
|
236
|
+
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.col_write_re('boards', 'status')
|
|
234
237
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.writes_any_re(array['board_authority_ceilings'])
|
|
235
238
|
or agent_board_test.stripped_body(p.oid) ~ agent_board_test.stmt_re('insert into', 'board_invite_tokens'));
|
|
236
239
|
-- F is in scope when its call closure reaches a direct writer.
|
|
@@ -250,6 +253,7 @@ create temp table _decl(name text primary key, cls text not null);
|
|
|
250
253
|
insert into _decl values
|
|
251
254
|
('grant_board_role', 'GATED'), ('set_board_role_gate', 'GATED'), ('set_board_authority_ceiling', 'GATED'),
|
|
252
255
|
('create_invite_link', 'GATED'), ('readmit_session_identity', 'GATED'), ('update_board_membership', 'GATED'),
|
|
256
|
+
('set_board_archived', 'GATED'),
|
|
253
257
|
('signed_grant_board_role', 'INHERIT'), ('signed_set_board_authority_ceiling', 'INHERIT'),
|
|
254
258
|
('mint_delegated_child', 'REFUSED'),
|
|
255
259
|
('create_board', 'EXEMPT-API'), ('redeem_invite_link', 'EXEMPT-API'), ('create_fleet_onboarding_invite', 'EXEMPT-API'),
|
|
@@ -297,7 +301,7 @@ select is(
|
|
|
297
301
|
select is(
|
|
298
302
|
(select string_agg(name, ' ' order by name) from _gated),
|
|
299
303
|
(select string_agg(name, ' ' order by name) from _decl where cls = 'GATED'),
|
|
300
|
-
'EC-SU-2: exactly the
|
|
304
|
+
'EC-SU-2: exactly the seven GATED functions call _require_human_step_up in their own body');
|
|
301
305
|
-- EC-SU-2 (D1): in every GATED body nothing that writes follows the LAST helper call: no direct
|
|
302
306
|
-- write statement, and no call to a function whose call closure reaches one (the membership
|
|
303
307
|
-- chokepoint writes only through the sink, so a direct-DML scan alone would miss its write).
|
|
@@ -326,12 +330,12 @@ select is(
|
|
|
326
330
|
'(none)',
|
|
327
331
|
'EC-SU-2 (D1): no GATED body writes, or calls a writer, after its last _require_human_step_up call');
|
|
328
332
|
-- EC-SU-2 control: the same matchers DO find a write (direct or through a writer call) BEFORE the
|
|
329
|
-
-- call in each of the
|
|
333
|
+
-- call in each of the seven bodies, so the tail check is not vacuous.
|
|
330
334
|
select is(
|
|
331
335
|
(select count(*)::int from _gsplit g
|
|
332
336
|
where g.head ~ agent_board_test.writes_any_re((select t from _wtables))
|
|
333
337
|
or exists (select 1 from _wreach r where r.name <> g.name and g.head ~ agent_board_test.call_re(r.name))),
|
|
334
|
-
|
|
338
|
+
7,
|
|
335
339
|
'EC-SU-2 control: each GATED body writes (directly or through a writer) before its helper call');
|
|
336
340
|
|
|
337
341
|
-- E-1(2): the reflexive reverse call closure of GATED (E-11's forbidden set) is exactly this set.
|
|
@@ -344,7 +348,7 @@ select is(
|
|
|
344
348
|
(select string_agg(distinct (select proname::text from pg_proc where oid = c.root_oid), ' '
|
|
345
349
|
order by (select proname::text from pg_proc where oid = c.root_oid))
|
|
346
350
|
from _cl c where c.reached_oid in (select oid from _gated)),
|
|
347
|
-
'create_fleet_onboarding_invite create_invite_link grant_board_role leave_board readmit_session_identity set_board_authority_ceiling set_board_role_gate signed_grant_board_role signed_set_board_authority_ceiling tombstone_delegate_instance update_board_membership',
|
|
351
|
+
'create_fleet_onboarding_invite create_invite_link grant_board_role leave_board readmit_session_identity set_board_archived set_board_authority_ceiling set_board_role_gate signed_grant_board_role signed_set_board_authority_ceiling tombstone_delegate_instance update_board_membership',
|
|
348
352
|
'E-1: the reflexive reverse call closure of GATED is exactly the E-11 forbidden set');
|
|
349
353
|
|
|
350
354
|
-- E-11 exemption premises (plan-owner ruling 1, 2026-11-21). tombstone_delegate_instance is the
|
|
@@ -650,8 +654,9 @@ select throws_ok(pg_temp.t(pg_temp.lc('P', 0), pg_temp.q_grant('BP', 'M')), 'MBS
|
|
|
650
654
|
delete from agent_board.portal_step_up_proofs where agent_id = pg_temp.u('P');
|
|
651
655
|
select throws_ok(pg_temp.t(pg_temp.c('P', jsonb_build_object('agent_board_step_up_at', pg_temp.now_s() - 11)), pg_temp.q_grant('BP', 'M')),
|
|
652
656
|
'MBS01', 'step_up_required', 'R-5f: a fresh Portal claim without its ledger row is refused');
|
|
653
|
-
-- R-6:
|
|
654
|
-
|
|
657
|
+
-- R-6: now_s() floors the proof's base time before the RPC reads the clock. Use +60
|
|
658
|
+
-- here for scheduling margin. P-3/P-4 in the helper test pin the exact +30 boundary.
|
|
659
|
+
select throws_ok(pg_temp.t(pg_temp.pc('P', -60), pg_temp.q_grant('BP', 'M')), 'MBS01', 'step_up_required', 'R-6: a proof beyond the future skew allowance is refused');
|
|
655
660
|
-- R-8: P with a live agent_credential_id and no proof: kind decides.
|
|
656
661
|
select throws_ok(pg_temp.t(pg_temp.c('P', jsonb_build_object('agent_credential_id', '669b3000-0000-4000-8000-000000000001')), pg_temp.q_grant('BP', 'M')),
|
|
657
662
|
'MBS01', 'step_up_required', 'R-8: a human carrying a credential claim is still a human');
|
|
@@ -229,7 +229,7 @@ insert into _su_fns values
|
|
|
229
229
|
|
|
230
230
|
-- EC-SU-0, as REPLACED by PR-B (plan §10.1: "PR-B replaces it with EC-SU-2"). PR-A asserted that
|
|
231
231
|
-- nothing called the helper. From 20261124000100 the functions whose OWN body calls it are
|
|
232
|
-
-- exactly the
|
|
232
|
+
-- exactly the seven GATED chokepoints (EC-SU-2 in agent_board_step_up.test.sql pins placement and
|
|
233
233
|
-- the reverse closure). Both sides are still keyed by OID: an overload such as
|
|
234
234
|
-- _require_human_step_up(uuid) that calls the helper is an extra caller and names itself.
|
|
235
235
|
select is(
|
|
@@ -244,10 +244,11 @@ select is(
|
|
|
244
244
|
'agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)',
|
|
245
245
|
'agent_board.grant_board_role(uuid,uuid,text,uuid)',
|
|
246
246
|
'agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)',
|
|
247
|
+
'agent_board.set_board_archived(uuid,boolean)',
|
|
247
248
|
'agent_board.set_board_authority_ceiling(uuid,text,uuid)',
|
|
248
249
|
'agent_board.set_board_role_gate(uuid,boolean)',
|
|
249
250
|
'agent_board.update_board_membership(uuid,uuid,text,jsonb)']) x),
|
|
250
|
-
'EC-SU-0 (replaced by PR-B): the direct callers of _require_human_step_up are exactly the
|
|
251
|
+
'EC-SU-0 (replaced by PR-B): the direct callers of _require_human_step_up are exactly the seven GATED chokepoints');
|
|
251
252
|
|
|
252
253
|
-- EC-SU-0 control: the same closure DOES see the helper's own calls, so (1) is not vacuous.
|
|
253
254
|
select is(
|
|
@@ -492,10 +493,11 @@ delete from agent_board.portal_step_up_proofs where agent_id = pg_temp.u('P');
|
|
|
492
493
|
select throws_ok(
|
|
493
494
|
format('select pg_temp.step(%L)', pg_temp.c('P', jsonb_build_object('agent_board_step_up_at', pg_temp.now_s() - 11))),
|
|
494
495
|
'MBS01', 'step_up_required', 'R-5f: a fresh Portal claim without its ledger row is refused');
|
|
495
|
-
-- R-6:
|
|
496
|
+
-- R-6: leave room for the clock to advance after now_s() floors the fixture time.
|
|
497
|
+
-- P-3/P-4 above check the exact future skew boundary with a fixed clock.
|
|
496
498
|
select throws_ok(
|
|
497
|
-
format('select pg_temp.step(%L)', pg_temp.c('P', jsonb_build_object('agent_board_step_up_at', pg_temp.ledger('P', pg_temp.now_s() +
|
|
498
|
-
'MBS01', 'step_up_required', 'R-6: a proof
|
|
499
|
+
format('select pg_temp.step(%L)', pg_temp.c('P', jsonb_build_object('agent_board_step_up_at', pg_temp.ledger('P', pg_temp.now_s() + 60)))),
|
|
500
|
+
'MBS01', 'step_up_required', 'R-6: a proof beyond the future skew allowance is refused');
|
|
499
501
|
-- R-7: request.jwt.claims is not JSON (never 22P02).
|
|
500
502
|
select throws_ok(format('select pg_temp.step(%L)', 'not json'),
|
|
501
503
|
'MBS01', 'step_up_required', 'R-7: unparseable claims are MBS01, never 22P02');
|
|
@@ -563,9 +565,9 @@ select ok(not pg_temp.has_row('L', pg_temp.v('T0')::bigint), 'RP-2 state: no (L,
|
|
|
563
565
|
select is(pg_temp.rec('service_role', 'G', pg_temp.v('T0')::bigint), 'false', 'RP-3: an agent''s proof is refused (false)');
|
|
564
566
|
-- RP-M15: LM (forged metadata) -> false.
|
|
565
567
|
select is(pg_temp.rec('service_role', 'LM', pg_temp.now_s()), 'false', 'RP-M15: agents.metadata never makes a Portal-class agent for the writer');
|
|
566
|
-
-- RP-4:
|
|
567
|
-
--
|
|
568
|
-
select pg_temp.put('T_OLD', (pg_temp.now_s() - 331)::text), pg_temp.put('T_NEW', (pg_temp.now_s() +
|
|
568
|
+
-- RP-4: elapsed time only makes -331 older. At +90, even after flooring,
|
|
569
|
+
-- the proof starts more than 29 seconds beyond the writer's inclusive +60 limit.
|
|
570
|
+
select pg_temp.put('T_OLD', (pg_temp.now_s() - 331)::text), pg_temp.put('T_NEW', (pg_temp.now_s() + 90)::text);
|
|
569
571
|
select is(pg_temp.rec('service_role', 'P', pg_temp.v('T_OLD')::bigint), 'false', 'RP-4: a proof older than clock - 330 is refused');
|
|
570
572
|
select is(pg_temp.rec('service_role', 'P', pg_temp.v('T_NEW')::bigint), 'false', 'RP-4: a proof later than clock + 60 is refused');
|
|
571
573
|
select ok(not pg_temp.has_row('P', pg_temp.v('T_OLD')::bigint) and not pg_temp.has_row('P', pg_temp.v('T_NEW')::bigint),
|
|
@@ -603,10 +605,11 @@ select is(pg_temp.rec('agent_board_delegate', 'P', pg_temp.now_s()), 'ERR 42501:
|
|
|
603
605
|
-- Fix round 1 (S1/S2 review of #800). Appended so every row number above stays stable.
|
|
604
606
|
-- ===========================================================================
|
|
605
607
|
|
|
606
|
-
-- RP-11:
|
|
607
|
-
|
|
608
|
-
select
|
|
609
|
-
select
|
|
608
|
+
-- RP-11: -290 leaves over 39 seconds before the floored proof ages past -330.
|
|
609
|
+
-- Use a different stamp from RP-5 so its ledger row cannot satisfy this state check.
|
|
610
|
+
select pg_temp.put('T_290', (pg_temp.now_s() - 290)::text);
|
|
611
|
+
select is(pg_temp.rec('service_role', 'P', pg_temp.v('T_290')::bigint), 'true', 'RP-11: a proof inside the writer age limit is recordable');
|
|
612
|
+
select ok(pg_temp.has_row('P', pg_temp.v('T_290')::bigint), 'RP-11 state: the recorded proof row exists');
|
|
610
613
|
-- RP-12: now_s + 60 <= clock + 60 -> true, and the row exists.
|
|
611
614
|
select pg_temp.put('T_P60', (pg_temp.now_s() + 60)::text);
|
|
612
615
|
select is(pg_temp.rec('service_role', 'P', pg_temp.v('T_P60')::bigint), 'true', 'RP-12: a proof at clock + 60 is recordable');
|
|
@@ -661,7 +664,7 @@ select p.oid, n.nspname::text as nspname,
|
|
|
661
664
|
-- EC-SU-4h (S1-2 floor b; #802 P-3): fn_call_closure scans agent_board only, and EC-SU-0 does too,
|
|
662
665
|
-- so no routine in ANY other persistent schema may NAME a step-up route. The route set is
|
|
663
666
|
-- derived from the closure, never listed: every agent_board routine whose reflexive call
|
|
664
|
-
-- closure reaches _require_human_step_up (the helper, the
|
|
667
|
+
-- closure reaches _require_human_step_up (the helper, the seven GATED, their wrappers) or a
|
|
665
668
|
-- writer of portal_step_up_proofs (record_portal_step_up and its wrappers). Matched as a
|
|
666
669
|
-- whole identifier, case-insensitively, over body_lit: literals KEPT, because a dynamic
|
|
667
670
|
-- call carries the target's name inside a string; comments stripped (a comment cannot call).
|
|
@@ -686,15 +689,15 @@ select ok(
|
|
|
686
689
|
(select count(*) > 100 from _xbody where nspname <> 'agent_board'),
|
|
687
690
|
'EC-SU-4h control: the cross-schema scan inspected more than 100 non-agent_board routines');
|
|
688
691
|
-- EC-SU-4h control (#802 P-3): the derived route set is not vacuous. It holds the helper, the
|
|
689
|
-
-- ledger writer and the
|
|
692
|
+
-- ledger writer and the seven GATED chokepoints by name (a positive floor, not the class:
|
|
690
693
|
-- the class is whatever the closure returns, and the assertion above scans all of it).
|
|
691
694
|
select is(
|
|
692
695
|
(select string_agg(x, ' ' order by x) from unnest(array[
|
|
693
696
|
'_require_human_step_up', 'create_invite_link', 'grant_board_role', 'readmit_session_identity',
|
|
694
|
-
'record_portal_step_up', 'set_board_authority_ceiling', 'set_board_role_gate', 'update_board_membership']) x
|
|
697
|
+
'record_portal_step_up', 'set_board_archived', 'set_board_authority_ceiling', 'set_board_role_gate', 'update_board_membership']) x
|
|
695
698
|
where x in (select name from _su_routes)),
|
|
696
|
-
'_require_human_step_up create_invite_link grant_board_role readmit_session_identity record_portal_step_up set_board_authority_ceiling set_board_role_gate update_board_membership',
|
|
697
|
-
'EC-SU-4h control: the closure-derived route set contains the helper, the ledger writer and the
|
|
699
|
+
'_require_human_step_up create_invite_link grant_board_role readmit_session_identity record_portal_step_up set_board_archived set_board_authority_ceiling set_board_role_gate update_board_membership',
|
|
700
|
+
'EC-SU-4h control: the closure-derived route set contains the helper, the ledger writer and the seven GATED chokepoints');
|
|
698
701
|
|
|
699
702
|
-- EC-SU-4d (S1-2 floor a): the closure cannot see dynamic EXECUTE. The API-executable
|
|
700
703
|
-- SECURITY DEFINER routines in EVERY schema whose bodies can run dynamic SQL (plpgsql with an
|
|
@@ -561,6 +561,7 @@ select is( -- pgtap-allow-raise-checked
|
|
|
561
561
|
'agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)',
|
|
562
562
|
'agent_board.send_multicast_message(uuid,uuid,jsonb,text,text,text,text,text,text,jsonb,uuid)',
|
|
563
563
|
'agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)',
|
|
564
|
+
'agent_board.set_board_archived(uuid,boolean)',
|
|
564
565
|
'agent_board.set_board_authority_ceiling(uuid,text,uuid)',
|
|
565
566
|
'agent_board.set_board_claim_policy(uuid,text)',
|
|
566
567
|
'agent_board.set_board_member_label(uuid,uuid,text)',
|
|
@@ -574,7 +575,7 @@ select is( -- pgtap-allow-raise-checked
|
|
|
574
575
|
'agent_board.upsert_delegation_policy(uuid,text,jsonb,integer,interval,boolean)',
|
|
575
576
|
'agent_board.verify_callback_endpoint(uuid,uuid,jsonb)'
|
|
576
577
|
]::text[],
|
|
577
|
-
'#325: the effect-derived class is exactly these
|
|
578
|
+
'#325: the effect-derived class is exactly these 67 authenticated-executable writer OVERLOADS — per-OID, and TRANSITIVE, so a delegating wrapper whose own body holds no DML is a member rather than a blind spot');
|
|
578
579
|
|
|
579
580
|
-- WEC-4. THE DELEGATION-CHAIN LIVENESS PIN, and the mitigation for the fail-open inversion the
|
|
580
581
|
-- header describes. Everything above depends on `fn_call_closure()` actually resolving edges; a
|
|
@@ -91,6 +91,15 @@
|
|
|
91
91
|
"authenticated": false
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
+
{
|
|
95
|
+
"name": "_archived_board_guard",
|
|
96
|
+
"signature": "_archived_board_guard()",
|
|
97
|
+
"executable_by": {
|
|
98
|
+
"anon": false,
|
|
99
|
+
"service_role": false,
|
|
100
|
+
"authenticated": false
|
|
101
|
+
}
|
|
102
|
+
},
|
|
94
103
|
{
|
|
95
104
|
"name": "_assert_actor_not_fleet_revoked",
|
|
96
105
|
"signature": "_assert_actor_not_fleet_revoked(p_actor_agent_id uuid, p_operation text)",
|
|
@@ -100,6 +109,15 @@
|
|
|
100
109
|
"authenticated": false
|
|
101
110
|
}
|
|
102
111
|
},
|
|
112
|
+
{
|
|
113
|
+
"name": "_assert_boards_not_archived",
|
|
114
|
+
"signature": "_assert_boards_not_archived(p_board_ids uuid[])",
|
|
115
|
+
"executable_by": {
|
|
116
|
+
"anon": false,
|
|
117
|
+
"service_role": false,
|
|
118
|
+
"authenticated": false
|
|
119
|
+
}
|
|
120
|
+
},
|
|
103
121
|
{
|
|
104
122
|
"name": "_assert_signed_authority_signer_live",
|
|
105
123
|
"signature": "_assert_signed_authority_signer_live(p_actor_agent_id uuid, p_gateway_decision jsonb)",
|
|
@@ -1036,6 +1054,15 @@
|
|
|
1036
1054
|
"authenticated": false
|
|
1037
1055
|
}
|
|
1038
1056
|
},
|
|
1057
|
+
{
|
|
1058
|
+
"name": "_thread_on_board",
|
|
1059
|
+
"signature": "_thread_on_board(p_board_ids uuid[], p_thread_id uuid, p_task_id uuid)",
|
|
1060
|
+
"executable_by": {
|
|
1061
|
+
"anon": false,
|
|
1062
|
+
"service_role": true,
|
|
1063
|
+
"authenticated": true
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1039
1066
|
{
|
|
1040
1067
|
"name": "_trim_inbox_text",
|
|
1041
1068
|
"signature": "_trim_inbox_text(p_value text, p_max_length integer)",
|
|
@@ -1999,6 +2026,15 @@
|
|
|
1999
2026
|
"authenticated": true
|
|
2000
2027
|
}
|
|
2001
2028
|
},
|
|
2029
|
+
{
|
|
2030
|
+
"name": "set_board_archived",
|
|
2031
|
+
"signature": "set_board_archived(p_board_id uuid, p_archived boolean)",
|
|
2032
|
+
"executable_by": {
|
|
2033
|
+
"anon": false,
|
|
2034
|
+
"service_role": true,
|
|
2035
|
+
"authenticated": true
|
|
2036
|
+
}
|
|
2037
|
+
},
|
|
2002
2038
|
{
|
|
2003
2039
|
"name": "set_board_authority_ceiling",
|
|
2004
2040
|
"signature": "set_board_authority_ceiling(p_board_id uuid, p_max_grantable_role text, p_actor_agent_id uuid)",
|
|
@@ -41,10 +41,18 @@
|
|
|
41
41
|
"signature": "_append_task_event(p_origin_posture text, p_task_id uuid, p_actor_agent_id uuid, p_event_type text, p_payload jsonb, p_status text, p_assigned_agent_id uuid, p_completed_at timestamp with time zone)",
|
|
42
42
|
"declares_p_metadata": false
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"signature": "_archived_board_guard()",
|
|
46
|
+
"declares_p_metadata": false
|
|
47
|
+
},
|
|
44
48
|
{
|
|
45
49
|
"signature": "_assert_actor_not_fleet_revoked(p_actor_agent_id uuid, p_operation text)",
|
|
46
50
|
"declares_p_metadata": false
|
|
47
51
|
},
|
|
52
|
+
{
|
|
53
|
+
"signature": "_assert_boards_not_archived(p_board_ids uuid[])",
|
|
54
|
+
"declares_p_metadata": false
|
|
55
|
+
},
|
|
48
56
|
{
|
|
49
57
|
"signature": "_assert_signed_authority_signer_live(p_actor_agent_id uuid, p_gateway_decision jsonb)",
|
|
50
58
|
"declares_p_metadata": false
|
|
@@ -461,6 +469,10 @@
|
|
|
461
469
|
"signature": "_step_up_proof_recordable(p_proof numeric, p_now numeric)",
|
|
462
470
|
"declares_p_metadata": false
|
|
463
471
|
},
|
|
472
|
+
{
|
|
473
|
+
"signature": "_thread_on_board(p_board_ids uuid[], p_thread_id uuid, p_task_id uuid)",
|
|
474
|
+
"declares_p_metadata": false
|
|
475
|
+
},
|
|
464
476
|
{
|
|
465
477
|
"signature": "_trim_inbox_text(p_value text, p_max_length integer)",
|
|
466
478
|
"declares_p_metadata": false
|
|
@@ -889,6 +901,10 @@
|
|
|
889
901
|
"signature": "send_multicast_message(p_thread_id uuid, p_author_agent_id uuid, p_recipient_descriptors jsonb, p_addressing_mode text, p_subject text, p_body text, p_message_type text, p_priority text, p_idempotency_key text, p_metadata jsonb, p_reply_to_message_id uuid)",
|
|
890
902
|
"declares_p_metadata": true
|
|
891
903
|
},
|
|
904
|
+
{
|
|
905
|
+
"signature": "set_board_archived(p_board_id uuid, p_archived boolean)",
|
|
906
|
+
"declares_p_metadata": false
|
|
907
|
+
},
|
|
892
908
|
{
|
|
893
909
|
"signature": "set_board_authority_ceiling(p_board_id uuid, p_max_grantable_role text, p_actor_agent_id uuid)",
|
|
894
910
|
"declares_p_metadata": false
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)",
|
|
5
5
|
"agent_board.grant_board_role(uuid,uuid,text,uuid)",
|
|
6
6
|
"agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)",
|
|
7
|
+
"agent_board.set_board_archived(uuid,boolean)",
|
|
7
8
|
"agent_board.set_board_authority_ceiling(uuid,text,uuid)",
|
|
8
9
|
"agent_board.set_board_role_gate(uuid,boolean)",
|
|
9
10
|
"agent_board.update_board_membership(uuid,uuid,text,jsonb)"
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
"grant_board_role",
|
|
15
16
|
"leave_board",
|
|
16
17
|
"readmit_session_identity",
|
|
18
|
+
"set_board_archived",
|
|
17
19
|
"set_board_authority_ceiling",
|
|
18
20
|
"set_board_role_gate",
|
|
19
21
|
"signed_grant_board_role",
|