@consiliency/agent-board-schema 1.68.0 → 1.75.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 +32 -4
- package/migrations/20261026000100_agent_board_thread_association.sql +1287 -0
- package/migrations/20261101000100_agent_board_session_measured_mint.sql +145 -0
- package/migrations/20261104065658_agent_board_reply_delivery.sql +659 -0
- package/migrations/20261104170000_agent_board_tasking_replay_scope.sql +320 -0
- package/migrations/20261104180000_agent_board_delivery_writer_execute.sql +51 -0
- package/migrations/20261104190000_agent_board_message_replay_scope.sql +373 -0
- package/migrations/20261108000100_agent_board_send_outcome.sql +708 -0
- package/package.json +1 -1
- package/schema-manifest.json +66 -3
- package/src/deployment-drift-main.test.mjs +20 -3
- package/src/deployment-drift-script.test.mjs +77 -2
- package/src/deployment-drift.test.mjs +60 -0
- package/src/tooling.test.mjs +9 -2
- package/tests/agent_board_661_reply_delivery.test.sql +185 -0
- package/tests/agent_board_667_boundary.test.sql +162 -0
- package/tests/agent_board_667_conversion_branches.test.sql +91 -0
- package/tests/agent_board_667_conversion_profile.test.sql +112 -0
- package/tests/agent_board_667_history_class.test.sql +787 -0
- package/tests/agent_board_667_native_cast_effect.test.sql +88 -0
- package/tests/agent_board_667_realtime_apply_behavior.test.sql +117 -0
- package/tests/agent_board_667_realtime_apply_controls.test.sql +143 -0
- package/tests/agent_board_667_realtime_apply_profile.test.sql +61 -0
- package/tests/agent_board_667_retention.test.sql +201 -0
- package/tests/agent_board_667_routing.test.sql +294 -0
- package/tests/agent_board_667_sender_effects.test.sql +100 -0
- package/tests/agent_board_667_sender_profile_controls.test.sql +29 -0
- package/tests/agent_board_667_storage_delimiter_behavior.test.sql +84 -0
- package/tests/agent_board_667_storage_delimiter_controls.test.sql +23 -0
- package/tests/agent_board_667_storage_delimiter_profile.test.sql +61 -0
- package/tests/agent_board_667_storage_search_behavior.test.sql +93 -0
- package/tests/agent_board_667_storage_search_controls.test.sql +22 -0
- package/tests/agent_board_667_storage_search_profile.test.sql +60 -0
- package/tests/agent_board_667_storage_timestamp_behavior.test.sql +58 -0
- package/tests/agent_board_667_storage_timestamp_controls.test.sql +22 -0
- package/tests/agent_board_667_storage_timestamp_profile.test.sql +54 -0
- package/tests/agent_board_667_writers.test.sql +281 -0
- package/tests/agent_board_717_message_replay_scope.test.sql +828 -0
- package/tests/agent_board_717_native_surface.test.sql +223 -0
- package/tests/agent_board_717_tasking_replay_scope.test.sql +661 -0
- package/tests/agent_board_addressing.test.sql +8 -5
- package/tests/agent_board_claim_subject_gate.test.sql +7 -3
- package/tests/agent_board_claimpolicy_race.test.sql +39 -11
- package/tests/agent_board_delegate_role_class.test.sql +35 -17
- package/tests/agent_board_delivery_writer_execute.test.sql +373 -0
- package/tests/agent_board_fk_lock_edges.test.sql +3 -0
- package/tests/agent_board_hosted_delegates.test.sql +13 -3
- package/tests/agent_board_inbox_rpcs.test.sql +5 -3
- package/tests/agent_board_obsgate.test.sql +8 -4
- package/tests/agent_board_obsgate4.test.sql +2 -2
- package/tests/agent_board_outbox_wake_ordering.test.sql +25 -2
- package/tests/agent_board_own_post_not_delivered.test.sql +11 -9
- package/tests/agent_board_send_outcome.test.sql +805 -0
- package/tests/agent_board_session_identity_behavior_classes.test.sql +2 -2
- package/tests/agent_board_session_identity_limits.test.sql +1 -1
- package/tests/agent_board_session_identity_measured_mint.test.sql +342 -0
- package/tests/agent_board_session_identity_predicate_isolation.test.sql +146 -0
- package/tests/agent_board_sidserver_authority.test.sql +69 -0
- package/tests/agent_board_sidserver_catalog.test.sql +47 -0
- package/tests/agent_board_signed_write_gateway.test.sql +4 -2
- package/tests/agent_board_task_thread_lock_order.test.sql +67 -42
- package/tests/agent_board_v2_invariants.test.sql +5 -2
- package/tests/agent_board_write_enforcement_class.test.sql +12 -8
- package/tests/catalog/function_execute_privileges.json +65 -5
- package/tests/catalog/p_metadata_parameters.json +24 -0
- package/tests/fixtures/agent_board_667_apply_rls_guard.sql +195 -0
- package/tests/fixtures/agent_board_667_apply_rls_provenance.md +125 -0
- package/tests/fixtures/agent_board_667_apply_rls_reference.sql +1903 -0
- package/tests/fixtures/agent_board_667_conversion_guard.sql +162 -0
- package/tests/fixtures/agent_board_667_conversion_reference.md +23 -0
- package/tests/fixtures/agent_board_667_conversion_reference.sql +5325 -0
- package/tests/fixtures/agent_board_667_delimiter_guard.sql +92 -0
- package/tests/fixtures/agent_board_667_delimiter_provenance.md +116 -0
- package/tests/fixtures/agent_board_667_delimiter_reference.sql +10150 -0
- package/tests/fixtures/agent_board_667_search_guard.sql +92 -0
- package/tests/fixtures/agent_board_667_search_provenance.md +141 -0
- package/tests/fixtures/agent_board_667_search_reference.sql +4779 -0
- package/tests/fixtures/agent_board_667_sender_guard.sql +102 -0
- package/tests/fixtures/agent_board_667_sender_reference.md +20 -0
- package/tests/fixtures/agent_board_667_sender_reference.sql +875 -0
- package/tests/fixtures/agent_board_667_timestamp_graph.sql +84 -0
- package/tests/fixtures/agent_board_667_timestamp_guard.sql +94 -0
- package/tests/fixtures/agent_board_667_timestamp_provenance.md +99 -0
- package/tests/fixtures/agent_board_667_timestamp_reference.sql +2938 -0
- package/tests/fixtures/isolation-substrate.sql +8 -0
- package/tests/fixtures/pgtap-unexposed.sql +61 -0
- package/tests/isolation/expected/association_artifact_anchor_order.out +108 -0
- package/tests/isolation/expected/association_board_vs_board.out +71 -0
- package/tests/isolation/expected/association_post_wait_authority.out +77 -0
- package/tests/isolation/expected/association_strong_history_writers.out +203 -0
- package/tests/isolation/expected/association_strong_isolation.out +185 -0
- package/tests/isolation/expected/association_vs_artifact_claim_escalation.out +199 -0
- package/tests/isolation/expected/association_vs_heartbeat.out +78 -0
- package/tests/isolation/expected/association_vs_multi_anchor_artifact.out +67 -0
- package/tests/isolation/expected/association_vs_private_message.out +67 -0
- package/tests/isolation/expected/association_vs_task_and_conflict.out +133 -0
- package/tests/isolation/expected/association_vs_taskful_cross_thread.out +133 -0
- package/tests/isolation/expected/message_replay_scope.out +209 -0
- package/tests/isolation/expected/send_outcome_cross_board.out +40 -0
- package/tests/isolation/expected/send_outcome_independence.out +295 -0
- package/tests/isolation/expected/send_outcome_membership.out +140 -0
- package/tests/isolation/expected/send_outcome_overlap.out +89 -0
- package/tests/isolation/expected/send_outcome_reader.out +87 -0
- package/tests/isolation/expected/send_outcome_recovery.out +107 -0
- package/tests/isolation/expected/tasking_replay_scope.out +125 -0
- package/tests/isolation/specs/association_artifact_anchor_order.spec +46 -0
- package/tests/isolation/specs/association_board_vs_board.spec +37 -0
- package/tests/isolation/specs/association_post_wait_authority.spec +48 -0
- package/tests/isolation/specs/association_strong_history_writers.spec +61 -0
- package/tests/isolation/specs/association_strong_isolation.spec +50 -0
- package/tests/isolation/specs/association_vs_artifact_claim_escalation.spec +41 -0
- package/tests/isolation/specs/association_vs_heartbeat.spec +47 -0
- package/tests/isolation/specs/association_vs_multi_anchor_artifact.spec +38 -0
- package/tests/isolation/specs/association_vs_private_message.spec +33 -0
- package/tests/isolation/specs/association_vs_task_and_conflict.spec +38 -0
- package/tests/isolation/specs/association_vs_taskful_cross_thread.spec +42 -0
- package/tests/isolation/specs/message_replay_scope.spec +77 -0
- package/tests/isolation/specs/send_outcome_cross_board.spec +66 -0
- package/tests/isolation/specs/send_outcome_independence.spec +95 -0
- package/tests/isolation/specs/send_outcome_membership.spec +73 -0
- package/tests/isolation/specs/send_outcome_overlap.spec +69 -0
- package/tests/isolation/specs/send_outcome_reader.spec +61 -0
- package/tests/isolation/specs/send_outcome_recovery.spec +68 -0
- package/tests/isolation/specs/tasking_replay_scope.spec +72 -0
- package/tests/mutations/670/E1_helper_author_from_message.sql +7 -0
- package/tests/mutations/670/E2_helper_no_null_check.sql +13 -0
- package/tests/mutations/670/M10_lock_removed.sql +10 -0
- package/tests/mutations/670/M11_table_granted_to_authenticated.sql +2 -0
- package/tests/mutations/670/M12_helper_granted_to_service_role.sql +2 -0
- package/tests/mutations/670/M13_message_fk_no_cascade.sql +8 -0
- package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +11 -0
- package/tests/mutations/670/M15_second_receipt_writer.sql +9 -0
- package/tests/mutations/670/M16_read_no_btrim.sql +7 -0
- package/tests/mutations/670/M17_read_volatile.sql +2 -0
- package/tests/mutations/670/M1_helper_no_service_role_guard.sql +13 -0
- package/tests/mutations/670/M3_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/670/M4_read_checks_thread_existence.sql +10 -0
- package/tests/mutations/670/M5a_read_requires_thread_access.sql +10 -0
- package/tests/mutations/670/M5b_read_requires_board_membership.sql +11 -0
- package/tests/mutations/670/M6_read_admits_service_role.sql +14 -0
- package/tests/mutations/670/M7_confirmed_adds_message_sequence.sql +12 -0
- package/tests/mutations/670/M8_delivery_swallows_errors.sql +19 -0
- package/tests/mutations/670/M9_lock_key_includes_board.sql +10 -0
- package/tests/mutations/670/run.sh +84 -0
- package/tests/mutations/717-f1/M0_prefix_main_acl_and_comments.sql +11 -0
- package/tests/mutations/717-f1/M10_wrapper_stops_delegating.sql +7 -0
- package/tests/mutations/717-f1/M11_transitive_recipient_content.sql +8 -0
- package/tests/mutations/717-f1/M12_transitive_recipient_visibility.sql +8 -0
- package/tests/mutations/717-f1/M13_transitive_worker_content.sql +15 -0
- package/tests/mutations/717-f1/M1a_regrant_upsert_delivery_recipient.sql +1 -0
- package/tests/mutations/717-f1/M1b_regrant_upsert_inbox_item.sql +1 -0
- package/tests/mutations/717-f1/M1c_regrant_queue_inbox_callbacks.sql +1 -0
- package/tests/mutations/717-f1/M1d_regrant_queue_board_post_callbacks.sql +1 -0
- package/tests/mutations/717-f1/M1e_regrant_next_thread_message_sequence.sql +1 -0
- package/tests/mutations/717-f1/M2_blanket_schema_grant.sql +1 -0
- package/tests/mutations/717-f1/M3_new_overload_of_sink.sql +10 -0
- package/tests/mutations/717-f1/M4_new_route_calling_sink.sql +7 -0
- package/tests/mutations/717-f1/M5_actor_trusts_supplied_id.sql +5 -0
- package/tests/mutations/717-f1/M6_signed_route_granted_to_authenticated.sql +1 -0
- package/tests/mutations/717-f1/M7_worker_granted_to_authenticated.sql +1 -0
- package/tests/mutations/717-f1/M8_recipient_state_rewrites_visibility.sql +5 -0
- package/tests/mutations/717-f1/M9_public_route_revoked_from_service_role.sql +1 -0
- package/tests/mutations/717-f1/outbox_wake_ordering/W1_regrant_queue_inbox_callbacks.sql +1 -0
- package/tests/mutations/717-f1/outbox_wake_ordering/W2_revoke_worker_from_service_role.sql +1 -0
- package/tests/mutations/717-f1/outbox_wake_ordering/W3_invoker_caller_of_sink.sql +1 -0
- package/tests/mutations/717-f1/outbox_wake_ordering/W4_public_regrant_board_post_sink.sql +1 -0
- package/tests/mutations/717-f1/run.sh +17 -0
- package/tests/mutations/717-f2b/C1_new_delivery_route.sql +4 -0
- package/tests/mutations/717-f2b/C2_new_replay_lookup.sql +3 -0
- package/tests/mutations/717-f2b/C3_internal_regranted.sql +2 -0
- package/tests/mutations/717-f2b/C4_wrapper_writes_delivery.sql +9 -0
- package/tests/mutations/717-f2b/C5_class_member_dynamic_sql.sql +9 -0
- package/tests/mutations/717-f2b/C6_drop_board_scope_constraint.sql +2 -0
- package/tests/mutations/717-f2b/C7_state_private_helper_content.sql +14 -0
- package/tests/mutations/717-f2b/L1_dm_lock_split_by_recipient.sql +8 -0
- package/tests/mutations/717-f2b/L2_dm_lock_removed.sql +12 -0
- package/tests/mutations/717-f2b/L3_mc_lock_split_by_recipients.sql +8 -0
- package/tests/mutations/717-f2b/L4_mc_lock_removed.sql +12 -0
- package/tests/mutations/717-f2b/M0_prefix_definitions.sql +17 -0
- package/tests/mutations/717-f2b/M10_mc_lookup_any_author.sql +15 -0
- package/tests/mutations/717-f2b/M11_dm_swallow_refusal.sql +8 -0
- package/tests/mutations/717-f2b/M12_mc_swallow_refusal.sql +8 -0
- package/tests/mutations/717-f2b/M13_signed_dm_swallows_refusal.sql +32 -0
- package/tests/mutations/717-f2b/M14_signed_mc_swallows_refusal.sql +20 -0
- package/tests/mutations/717-f2b/M15_mc_any_source.sql +7 -0
- package/tests/mutations/717-f2b/M1_dm_drop_recipient_proof.sql +16 -0
- package/tests/mutations/717-f2b/M2_mc_drop_recipient_proof.sql +16 -0
- package/tests/mutations/717-f2b/M3_dm_metadata_as_proof.sql +12 -0
- package/tests/mutations/717-f2b/M4_mc_metadata_as_proof.sql +16 -0
- package/tests/mutations/717-f2b/M5_dm_any_mode.sql +11 -0
- package/tests/mutations/717-f2b/M6_dm_board_delivery_counts.sql +11 -0
- package/tests/mutations/717-f2b/M7_mc_any_mode.sql +11 -0
- package/tests/mutations/717-f2b/M8_dm_thread_stamp_as_proof.sql +12 -0
- package/tests/mutations/717-f2b/M9_dm_lookup_any_author.sql +15 -0
- package/tests/mutations/717-f2b/run.sh +82 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# #670 D12 spec 2: the author reads get_send_outcome before, during and after its own writer commits.
|
|
2
|
+
# Before and during: unknown (the uncommitted receipt is invisible, and the read does not wait for it).
|
|
3
|
+
# After commit: confirmed. A read racing a rollback stays unknown before and after: absence is not a
|
|
4
|
+
# concurrency fence, and unknown never means "not sent".
|
|
5
|
+
setup
|
|
6
|
+
{
|
|
7
|
+
create table public.so670_iso2_pids(s text primary key, pid int not null);
|
|
8
|
+
create table public.so670_iso2_ret(s text not null, message_id uuid);
|
|
9
|
+
grant select, insert on public.so670_iso2_ret to authenticated, service_role;
|
|
10
|
+
insert into auth.users(id) values ('670b2000-0000-4000-8000-0000000000a1'),('670b2000-0000-4000-8000-0000000000b1'),('670b2000-0000-4000-8000-0000000000c1');
|
|
11
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
12
|
+
values ('670b2000-0000-4000-8000-000000000001','agent','so670-iso2-x-a','SO670 iso A','active','670b2000-0000-4000-8000-0000000000a1'),
|
|
13
|
+
('670b2000-0000-4000-8000-000000000002','agent','so670-iso2-x-b','SO670 iso B','active','670b2000-0000-4000-8000-0000000000b1'),
|
|
14
|
+
('670b2000-0000-4000-8000-000000000003','agent','so670-iso2-x-m','SO670 iso M','active','670b2000-0000-4000-8000-0000000000c1');
|
|
15
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
16
|
+
values ('670b2000-0000-4000-8000-000000000020','so670-iso2-x','SO670 iso X','670b2000-0000-4000-8000-000000000001','private','active'),
|
|
17
|
+
('670b2000-0000-4000-8000-000000000021','so670-iso2-y','SO670 iso Y','670b2000-0000-4000-8000-000000000001','private','active');
|
|
18
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
19
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
20
|
+
values ('670b2000-0000-4000-8000-000000000020','670b2000-0000-4000-8000-000000000001','joined','670b2000-0000-4000-8000-000000000001','owner'),('670b2000-0000-4000-8000-000000000020','670b2000-0000-4000-8000-000000000002','joined','670b2000-0000-4000-8000-000000000001','member'),
|
|
21
|
+
('670b2000-0000-4000-8000-000000000020','670b2000-0000-4000-8000-000000000003','joined','670b2000-0000-4000-8000-000000000001','member'),('670b2000-0000-4000-8000-000000000021','670b2000-0000-4000-8000-000000000001','joined','670b2000-0000-4000-8000-000000000001','owner');
|
|
22
|
+
select set_config('request.jwt.claim.role','',false);
|
|
23
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
24
|
+
values ('670b2000-0000-4000-8000-000000000010','coordination','670b2000-0000-4000-8000-000000000001','so670 iso T'),('670b2000-0000-4000-8000-000000000011','coordination','670b2000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
25
|
+
('670b2000-0000-4000-8000-000000000012','coordination','670b2000-0000-4000-8000-000000000003','so670 iso TM');
|
|
26
|
+
}
|
|
27
|
+
teardown
|
|
28
|
+
{
|
|
29
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000002','670b2000-0000-4000-8000-000000000003');
|
|
30
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000002','670b2000-0000-4000-8000-000000000003');
|
|
31
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000002','670b2000-0000-4000-8000-000000000003');
|
|
32
|
+
delete from agent_board.messages where thread_id in ('670b2000-0000-4000-8000-000000000010','670b2000-0000-4000-8000-000000000011','670b2000-0000-4000-8000-000000000012');
|
|
33
|
+
delete from agent_board.threads where id in ('670b2000-0000-4000-8000-000000000010','670b2000-0000-4000-8000-000000000011','670b2000-0000-4000-8000-000000000012');
|
|
34
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000002','670b2000-0000-4000-8000-000000000003');
|
|
35
|
+
delete from agent_board.board_membership_events where board_id in ('670b2000-0000-4000-8000-000000000020','670b2000-0000-4000-8000-000000000021');
|
|
36
|
+
delete from agent_board.boards where id in ('670b2000-0000-4000-8000-000000000020','670b2000-0000-4000-8000-000000000021');
|
|
37
|
+
delete from agent_board.agents where id in ('670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000002','670b2000-0000-4000-8000-000000000003');
|
|
38
|
+
delete from auth.users where id in ('670b2000-0000-4000-8000-0000000000a1','670b2000-0000-4000-8000-0000000000b1','670b2000-0000-4000-8000-0000000000c1');
|
|
39
|
+
drop table public.so670_iso2_pids;
|
|
40
|
+
drop table public.so670_iso2_ret;
|
|
41
|
+
}
|
|
42
|
+
session "p"
|
|
43
|
+
setup { reset role; insert into public.so670_iso2_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
44
|
+
step "p_begin" { begin; set local role authenticated; select set_config('request.jwt.claim.role','',true), set_config('request.jwt.claim.sub','',true), set_config('request.jwt.claims',json_build_object('role','authenticated','sub','670b2000-0000-4000-8000-0000000000a1')::text,true); }
|
|
45
|
+
step "p_post" { insert into public.so670_iso2_ret select 'p', message_id from agent_board.post_board_message('670b2000-0000-4000-8000-000000000010','670b2000-0000-4000-8000-000000000001','670b2000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
46
|
+
step "p_commit" { commit; }
|
|
47
|
+
step "p_rollback" { rollback; }
|
|
48
|
+
session "r"
|
|
49
|
+
setup { reset role; insert into public.so670_iso2_pids values ('r', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; set role authenticated; select set_config('request.jwt.claims',json_build_object('role','authenticated','sub','670b2000-0000-4000-8000-0000000000a1')::text,false); }
|
|
50
|
+
step "r_read" { select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message'); }
|
|
51
|
+
session "check"
|
|
52
|
+
step "check" {
|
|
53
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b2000-0000-4000-8000-000000000010')) as messages,
|
|
54
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b2000-0000-4000-8000-000000000010')) as receipts,
|
|
55
|
+
(select string_agg(so.operation || ':' || a.handle, ',' order by so.operation, a.handle) from agent_board.send_outcomes so join agent_board.agents a on a.id = so.author_agent_id where so.thread_id in ('670b2000-0000-4000-8000-000000000010')) as receipt_owners,
|
|
56
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso2_ret r) as returned_by,
|
|
57
|
+
(select count(distinct r.message_id) from public.so670_iso2_ret r) as distinct_returned,
|
|
58
|
+
(select coalesce(bool_and(exists (select 1 from agent_board.send_outcomes so where so.message_id = r.message_id)), false) from public.so670_iso2_ret r) as every_returned_has_receipt;
|
|
59
|
+
}
|
|
60
|
+
permutation "r_read" "p_begin" "p_post" "r_read" "p_commit" "r_read" "check"
|
|
61
|
+
permutation "p_begin" "p_post" "r_read" "p_rollback" "r_read" "check"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# #670 D12 spec 5: recovery racing a membership change and a content deletion.
|
|
2
|
+
# (1) M's receipt is committed; while M's own leave is in flight M reads confirmed, and after it
|
|
3
|
+
# commits M still reads confirmed (the read has no membership check and waits on nothing);
|
|
4
|
+
# (2) while a deletion of M's message is in flight the committed receipt still reads confirmed; once
|
|
5
|
+
# the deletion commits the receipt is gone with its message and M reads unknown;
|
|
6
|
+
# the reads write nothing and fan out nothing (fanout counts are equal before and after).
|
|
7
|
+
setup
|
|
8
|
+
{
|
|
9
|
+
create table public.so670_iso5_pids(s text primary key, pid int not null);
|
|
10
|
+
create table public.so670_iso5_ret(s text not null, message_id uuid);
|
|
11
|
+
grant select, insert on public.so670_iso5_ret to authenticated, service_role;
|
|
12
|
+
insert into auth.users(id) values ('670b5000-0000-4000-8000-0000000000a1'),('670b5000-0000-4000-8000-0000000000b1'),('670b5000-0000-4000-8000-0000000000c1');
|
|
13
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
14
|
+
values ('670b5000-0000-4000-8000-000000000001','agent','so670-iso5-x-a','SO670 iso A','active','670b5000-0000-4000-8000-0000000000a1'),
|
|
15
|
+
('670b5000-0000-4000-8000-000000000002','agent','so670-iso5-x-b','SO670 iso B','active','670b5000-0000-4000-8000-0000000000b1'),
|
|
16
|
+
('670b5000-0000-4000-8000-000000000003','agent','so670-iso5-x-m','SO670 iso M','active','670b5000-0000-4000-8000-0000000000c1');
|
|
17
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
18
|
+
values ('670b5000-0000-4000-8000-000000000020','so670-iso5-x','SO670 iso X','670b5000-0000-4000-8000-000000000001','private','active'),
|
|
19
|
+
('670b5000-0000-4000-8000-000000000021','so670-iso5-y','SO670 iso Y','670b5000-0000-4000-8000-000000000001','private','active');
|
|
20
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
21
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
22
|
+
values ('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000001','joined','670b5000-0000-4000-8000-000000000001','owner'),('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000002','joined','670b5000-0000-4000-8000-000000000001','member'),
|
|
23
|
+
('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000003','joined','670b5000-0000-4000-8000-000000000001','member'),('670b5000-0000-4000-8000-000000000021','670b5000-0000-4000-8000-000000000001','joined','670b5000-0000-4000-8000-000000000001','owner');
|
|
24
|
+
select set_config('request.jwt.claim.role','',false);
|
|
25
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
26
|
+
values ('670b5000-0000-4000-8000-000000000010','coordination','670b5000-0000-4000-8000-000000000001','so670 iso T'),('670b5000-0000-4000-8000-000000000011','coordination','670b5000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
27
|
+
('670b5000-0000-4000-8000-000000000012','coordination','670b5000-0000-4000-8000-000000000003','so670 iso TM');
|
|
28
|
+
}
|
|
29
|
+
teardown
|
|
30
|
+
{
|
|
31
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002','670b5000-0000-4000-8000-000000000003');
|
|
32
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002','670b5000-0000-4000-8000-000000000003');
|
|
33
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002','670b5000-0000-4000-8000-000000000003');
|
|
34
|
+
delete from agent_board.messages where thread_id in ('670b5000-0000-4000-8000-000000000010','670b5000-0000-4000-8000-000000000011','670b5000-0000-4000-8000-000000000012');
|
|
35
|
+
delete from agent_board.threads where id in ('670b5000-0000-4000-8000-000000000010','670b5000-0000-4000-8000-000000000011','670b5000-0000-4000-8000-000000000012');
|
|
36
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002','670b5000-0000-4000-8000-000000000003');
|
|
37
|
+
delete from agent_board.board_membership_events where board_id in ('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000021');
|
|
38
|
+
delete from agent_board.boards where id in ('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000021');
|
|
39
|
+
delete from agent_board.agents where id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002','670b5000-0000-4000-8000-000000000003');
|
|
40
|
+
delete from auth.users where id in ('670b5000-0000-4000-8000-0000000000a1','670b5000-0000-4000-8000-0000000000b1','670b5000-0000-4000-8000-0000000000c1');
|
|
41
|
+
drop table public.so670_iso5_pids;
|
|
42
|
+
drop table public.so670_iso5_ret;
|
|
43
|
+
}
|
|
44
|
+
session "p"
|
|
45
|
+
setup { reset role; insert into public.so670_iso5_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; set role authenticated; select set_config('request.jwt.claims',json_build_object('role','authenticated','sub','670b5000-0000-4000-8000-0000000000c1')::text,false); }
|
|
46
|
+
step "p_post" { insert into public.so670_iso5_ret select 'p', message_id from agent_board.post_board_message('670b5000-0000-4000-8000-000000000012','670b5000-0000-4000-8000-000000000003','670b5000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
47
|
+
step "r_read" { select status from agent_board.get_send_outcome('670b5000-0000-4000-8000-000000000012','K','post_board_message'); }
|
|
48
|
+
session "l"
|
|
49
|
+
setup { reset role; insert into public.so670_iso5_pids values ('l', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
50
|
+
step "l_begin" { begin; set local role authenticated; select set_config('request.jwt.claim.role','',true), set_config('request.jwt.claim.sub','',true), set_config('request.jwt.claims',json_build_object('role','authenticated','sub','670b5000-0000-4000-8000-0000000000c1')::text,true); }
|
|
51
|
+
step "l_leave" { select count(*) as left_rows from agent_board.leave_board('670b5000-0000-4000-8000-000000000020','670b5000-0000-4000-8000-000000000003',jsonb_build_object()); }
|
|
52
|
+
step "l_commit" { commit; }
|
|
53
|
+
session "d"
|
|
54
|
+
step "d_begin" { begin; }
|
|
55
|
+
step "d_delete" { delete from agent_board.messages where thread_id = '670b5000-0000-4000-8000-000000000012'; }
|
|
56
|
+
step "d_commit" { commit; }
|
|
57
|
+
session "check"
|
|
58
|
+
step "fanout" { select (select count(*) from agent_board.delivery_recipients where recipient_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002')) as deliveries, (select count(*) from agent_board.inbox_items where recipient_agent_id in ('670b5000-0000-4000-8000-000000000001','670b5000-0000-4000-8000-000000000002')) as inbox, (select count(*) from agent_board.send_outcomes where thread_id = '670b5000-0000-4000-8000-000000000012') as receipts; }
|
|
59
|
+
step "check" {
|
|
60
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b5000-0000-4000-8000-000000000012')) as messages,
|
|
61
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b5000-0000-4000-8000-000000000012')) as receipts,
|
|
62
|
+
(select string_agg(so.operation || ':' || a.handle, ',' order by so.operation, a.handle) from agent_board.send_outcomes so join agent_board.agents a on a.id = so.author_agent_id where so.thread_id in ('670b5000-0000-4000-8000-000000000012')) as receipt_owners,
|
|
63
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso5_ret r) as returned_by,
|
|
64
|
+
(select count(distinct r.message_id) from public.so670_iso5_ret r) as distinct_returned,
|
|
65
|
+
(select coalesce(bool_and(exists (select 1 from agent_board.send_outcomes so where so.message_id = r.message_id)), false) from public.so670_iso5_ret r) as every_returned_has_receipt;
|
|
66
|
+
}
|
|
67
|
+
permutation "p_post" "fanout" "l_begin" "l_leave" "r_read" "l_commit" "r_read" "fanout" "check"
|
|
68
|
+
permutation "p_post" "fanout" "d_begin" "d_delete" "r_read" "d_commit" "r_read" "fanout" "check"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# #717 F2: concurrent same-key create_tasking_delivery sends serialize on the unchanged
|
|
2
|
+
# (thread, resolved creator, key) lock, and the second one is judged against what the first
|
|
3
|
+
# COMMITTED. A private send and a board send racing on one key: whichever commits first is the
|
|
4
|
+
# task, and the other is refused (42501) rather than widening it. Two identical retries racing:
|
|
5
|
+
# one task, one created event, one delivery, one inbox item, one callback.
|
|
6
|
+
# The thread is already stamped to the board, so first association never serializes them: only
|
|
7
|
+
# the idempotency lock does.
|
|
8
|
+
setup
|
|
9
|
+
{
|
|
10
|
+
insert into auth.users(id) values ('71740000-0000-4000-8000-0000000000a1'),('71740000-0000-4000-8000-0000000000c1');
|
|
11
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
12
|
+
values ('71740000-0000-4000-8000-000000000001','agent','f2717-iso-a','F2 iso A','active','71740000-0000-4000-8000-0000000000a1'),
|
|
13
|
+
('71740000-0000-4000-8000-000000000003','agent','f2717-iso-c','F2 iso C','active','71740000-0000-4000-8000-0000000000c1');
|
|
14
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
15
|
+
values ('71740000-0000-4000-8000-000000000020','f2717-iso-b','F2 iso board','71740000-0000-4000-8000-000000000001','private','active');
|
|
16
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
17
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
18
|
+
values ('71740000-0000-4000-8000-000000000020','71740000-0000-4000-8000-000000000001','joined','71740000-0000-4000-8000-000000000001','member');
|
|
19
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject,board_id)
|
|
20
|
+
values ('71740000-0000-4000-8000-000000000010','coordination','71740000-0000-4000-8000-000000000001','f2 iso thread','71740000-0000-4000-8000-000000000020');
|
|
21
|
+
insert into agent_board.callback_endpoints(id,owner_agent_id,endpoint_url,endpoint_status)
|
|
22
|
+
values ('71740000-0000-4000-8000-000000000030','71740000-0000-4000-8000-000000000003','https://example.test/f2717-iso','verified');
|
|
23
|
+
insert into agent_board.callback_subscriptions(endpoint_id,agent_id,subscription_scope,event_category)
|
|
24
|
+
values ('71740000-0000-4000-8000-000000000030','71740000-0000-4000-8000-000000000003','own_inbox','inbox.item.delivered');
|
|
25
|
+
}
|
|
26
|
+
teardown
|
|
27
|
+
{
|
|
28
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('71740000-0000-4000-8000-000000000001','71740000-0000-4000-8000-000000000003');
|
|
29
|
+
delete from agent_board.callback_subscriptions where endpoint_id='71740000-0000-4000-8000-000000000030';
|
|
30
|
+
delete from agent_board.callback_endpoints where id='71740000-0000-4000-8000-000000000030';
|
|
31
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('71740000-0000-4000-8000-000000000001','71740000-0000-4000-8000-000000000003');
|
|
32
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('71740000-0000-4000-8000-000000000001','71740000-0000-4000-8000-000000000003');
|
|
33
|
+
delete from agent_board.task_events where thread_id='71740000-0000-4000-8000-000000000010';
|
|
34
|
+
delete from agent_board.tasks where thread_id='71740000-0000-4000-8000-000000000010';
|
|
35
|
+
delete from agent_board.threads where id='71740000-0000-4000-8000-000000000010';
|
|
36
|
+
delete from agent_board.board_membership_events where board_id='71740000-0000-4000-8000-000000000020';
|
|
37
|
+
delete from agent_board.boards where id='71740000-0000-4000-8000-000000000020';
|
|
38
|
+
delete from agent_board.agents where id in ('71740000-0000-4000-8000-000000000001','71740000-0000-4000-8000-000000000003');
|
|
39
|
+
delete from auth.users where id in ('71740000-0000-4000-8000-0000000000a1','71740000-0000-4000-8000-0000000000c1');
|
|
40
|
+
}
|
|
41
|
+
# Each sending session is the creator A: authenticated role AND matching JSON claims (built with
|
|
42
|
+
# json_build_object: a literal brace would end the step), with the
|
|
43
|
+
# flattened claim GUCs cleared so they cannot stand in for another identity.
|
|
44
|
+
session "p"
|
|
45
|
+
step "p_begin" { begin; set local role authenticated; select set_config('request.jwt.claim.role','',true), set_config('request.jwt.claim.sub','',true), set_config('request.jwt.claims',json_build_object('role','authenticated','sub','71740000-0000-4000-8000-0000000000a1')::text,true); }
|
|
46
|
+
step "p_private" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.create_tasking_delivery('71740000-0000-4000-8000-000000000010','71740000-0000-4000-8000-000000000001','iso private',null,array['71740000-0000-4000-8000-000000000003']::uuid[],null,'medium','distributed','f2717-kc',jsonb_build_object()); }
|
|
47
|
+
step "p_end" { end; }
|
|
48
|
+
session "b"
|
|
49
|
+
step "b_begin" { begin; set local role authenticated; select set_config('request.jwt.claim.role','',true), set_config('request.jwt.claim.sub','',true), set_config('request.jwt.claims',json_build_object('role','authenticated','sub','71740000-0000-4000-8000-0000000000a1')::text,true); }
|
|
50
|
+
step "b_board" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.create_tasking_delivery('71740000-0000-4000-8000-000000000010','71740000-0000-4000-8000-000000000001','iso board',null,null,'71740000-0000-4000-8000-000000000020','medium','distributed','f2717-kc',jsonb_build_object()); }
|
|
51
|
+
step "b_end" { end; }
|
|
52
|
+
session "r"
|
|
53
|
+
step "r_begin" { begin; set local role authenticated; select set_config('request.jwt.claim.role','',true), set_config('request.jwt.claim.sub','',true), set_config('request.jwt.claims',json_build_object('role','authenticated','sub','71740000-0000-4000-8000-0000000000a1')::text,true); }
|
|
54
|
+
step "r_private" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.create_tasking_delivery('71740000-0000-4000-8000-000000000010','71740000-0000-4000-8000-000000000001','iso private',null,array['71740000-0000-4000-8000-000000000003']::uuid[],null,'medium','distributed','f2717-kc',jsonb_build_object()); }
|
|
55
|
+
step "r_end" { end; }
|
|
56
|
+
session "check"
|
|
57
|
+
step "check" {
|
|
58
|
+
select count(*) as tasks,
|
|
59
|
+
(select count(*) from agent_board.task_events te join agent_board.tasks t on t.id = te.task_id where t.thread_id = '71740000-0000-4000-8000-000000000010') as events,
|
|
60
|
+
(select count(*) from agent_board.delivery_recipients dr join agent_board.tasks t on t.id = dr.source_task_id where t.thread_id = '71740000-0000-4000-8000-000000000010' and dr.board_id is null) as private_deliveries,
|
|
61
|
+
(select count(*) from agent_board.delivery_recipients dr join agent_board.tasks t on t.id = dr.source_task_id where t.thread_id = '71740000-0000-4000-8000-000000000010' and dr.board_id is not null) as board_deliveries,
|
|
62
|
+
(select count(*) from agent_board.inbox_items ii join agent_board.tasks t on t.id = ii.source_task_id where t.thread_id = '71740000-0000-4000-8000-000000000010') as inbox,
|
|
63
|
+
(select count(*) from agent_board.callback_outbox_events co join agent_board.tasks t on t.id = co.source_task_id where t.thread_id = '71740000-0000-4000-8000-000000000010') as callbacks,
|
|
64
|
+
string_agg(title, ',' order by title) as titles
|
|
65
|
+
from agent_board.tasks where thread_id = '71740000-0000-4000-8000-000000000010';
|
|
66
|
+
}
|
|
67
|
+
# private wins: the board send waits on the key lock, then is refused against the committed private task
|
|
68
|
+
permutation "p_begin" "p_private" "b_begin" "b_board" "p_end" "b_end" "check"
|
|
69
|
+
# board wins: the private send waits, then is refused (C holds no private delivery of the board task)
|
|
70
|
+
permutation "b_begin" "b_board" "p_begin" "p_private" "b_end" "p_end" "check"
|
|
71
|
+
# identical retries: the second waits and reuses -- one task, event, delivery, inbox item, callback
|
|
72
|
+
permutation "p_begin" "p_private" "r_begin" "r_private" "p_end" "r_end" "check"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- EQUIVALENT: the helper takes the author from the message the writer inserted, not from the session
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board._record_send_outcome(text,uuid,text,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ v_author := agent_board.current_agent_id();$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board._record_send_outcome(text,uuid,text,uuid)'; end if;
|
|
4
|
+
n := replace(d, $q$ v_author := agent_board.current_agent_id();$q$, $q$ v_author := (select m.author_agent_id from agent_board.messages m where m.id = p_message_id);$q$);
|
|
5
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
|
+
execute n;
|
|
7
|
+
end $m$;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- EQUIVALENT: the helper's null-principal check is removed
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board._record_send_outcome(text,uuid,text,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ if v_author is null then
|
|
4
|
+
raise exception 'send outcome requires a session principal' using errcode = '42501';
|
|
5
|
+
end if;
|
|
6
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board._record_send_outcome(text,uuid,text,uuid)'; end if;
|
|
7
|
+
n := replace(d, $q$ if v_author is null then
|
|
8
|
+
raise exception 'send outcome requires a session principal' using errcode = '42501';
|
|
9
|
+
end if;
|
|
10
|
+
$q$, $q$$q$);
|
|
11
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
12
|
+
execute n;
|
|
13
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- post_board_message: the idempotency advisory lock is removed
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
+
'post_board_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
5
|
+
n := replace(d, $q$ perform agent_board._lock_idempotency_key(
|
|
6
|
+
'post_board_message:'$q$, $q$ perform concat(
|
|
7
|
+
'post_board_message:'$q$);
|
|
8
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- send_outcomes: the message foreign key loses ON DELETE CASCADE
|
|
2
|
+
do $m$ declare c text; begin
|
|
3
|
+
select conname into c from pg_constraint
|
|
4
|
+
where conrelid = 'agent_board.send_outcomes'::regclass and contype = 'f' and confrelid = 'agent_board.messages'::regclass;
|
|
5
|
+
if c is null then raise exception 'M13 anchor: no message FK'; end if;
|
|
6
|
+
execute format('alter table agent_board.send_outcomes drop constraint %I', c);
|
|
7
|
+
execute format('alter table agent_board.send_outcomes add constraint %I foreign key (message_id) references agent_board.messages(id)', c);
|
|
8
|
+
end $m$;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- post_message: mints a receipt when its caller metadata carries an idempotencyKey
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_message(uuid,uuid,text,text,uuid,jsonb)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_message(uuid,uuid,text,text,uuid,jsonb)'; end if;
|
|
4
|
+
n := replace(d, $q$ return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$, $q$ if p_metadata ? 'idempotencyKey' then
|
|
5
|
+
perform agent_board._record_send_outcome(coalesce(p_metadata ->> 'rpcName', 'post_board_message'), v_message.message_id,
|
|
6
|
+
p_metadata ->> 'idempotencyKey', v_board_id);
|
|
7
|
+
end if;
|
|
8
|
+
return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$);
|
|
9
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
10
|
+
execute n;
|
|
11
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- a second receipt writer: an overload of the helper that inserts directly
|
|
2
|
+
create function agent_board._record_send_outcome(p_operation text, p_message_id uuid, p_idempotency_key text)
|
|
3
|
+
returns void language plpgsql security definer set search_path = '' as $f$
|
|
4
|
+
begin
|
|
5
|
+
insert into agent_board.send_outcomes(operation, author_agent_id, thread_id, idempotency_key, message_id, created_at)
|
|
6
|
+
select p_operation, m.author_agent_id, m.thread_id, btrim(p_idempotency_key), m.id, m.created_at
|
|
7
|
+
from agent_board.messages m where m.id = p_message_id;
|
|
8
|
+
end $f$;
|
|
9
|
+
revoke all on function agent_board._record_send_outcome(text, uuid, text) from public, anon, authenticated, service_role, agent_board_delegate;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- read: the key is no longer trimmed
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ v_key := nullif(btrim(p_idempotency_key), '');$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.get_send_outcome(uuid,text,text)'; end if;
|
|
4
|
+
n := replace(d, $q$ v_key := nullif(btrim(p_idempotency_key), '');$q$, $q$ v_key := nullif(p_idempotency_key, '');$q$);
|
|
5
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
|
+
execute n;
|
|
7
|
+
end $m$;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- helper: the _is_service_role() guard is removed
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board._record_send_outcome(text,uuid,text,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ if agent_board._is_service_role() then
|
|
4
|
+
return;
|
|
5
|
+
end if;
|
|
6
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board._record_send_outcome(text,uuid,text,uuid)'; end if;
|
|
7
|
+
n := replace(d, $q$ if agent_board._is_service_role() then
|
|
8
|
+
return;
|
|
9
|
+
end if;
|
|
10
|
+
$q$, $q$$q$);
|
|
11
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
12
|
+
execute n;
|
|
13
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- post_board_message: the helper is called on the replay branch too
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ if v_inserted and v_idempotency_key is not null then
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
5
|
+
n := replace(d, $q$ if v_inserted and v_idempotency_key is not null then
|
|
6
|
+
$q$, $q$ if v_idempotency_key is not null then
|
|
7
|
+
$q$);
|
|
8
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- read: checks thread existence and raises P0002
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ -- Step 3, the lookup:$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.get_send_outcome(uuid,text,text)'; end if;
|
|
4
|
+
n := replace(d, $q$ -- Step 3, the lookup:$q$, $q$ if not exists (select 1 from agent_board.threads t where t.id = p_thread_id) then
|
|
5
|
+
raise exception 'thread not found' using errcode = 'P0002';
|
|
6
|
+
end if;
|
|
7
|
+
-- Step 3, the lookup:$q$);
|
|
8
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- read: requires thread access (M5a: the thread-access form)
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ -- Step 3, the lookup:$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.get_send_outcome(uuid,text,text)'; end if;
|
|
4
|
+
n := replace(d, $q$ -- Step 3, the lookup:$q$, $q$ if not agent_board._current_agent_can_access_thread(p_thread_id) then
|
|
5
|
+
raise exception 'thread not accessible to current agent' using errcode = '42501';
|
|
6
|
+
end if;
|
|
7
|
+
-- Step 3, the lookup:$q$);
|
|
8
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- read: requires current board access to the thread's board (membership)
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ -- Step 3, the lookup:$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.get_send_outcome(uuid,text,text)'; end if;
|
|
4
|
+
n := replace(d, $q$ -- Step 3, the lookup:$q$, $q$ if exists (select 1 from agent_board.threads t where t.id = p_thread_id and t.board_id is not null
|
|
5
|
+
and not agent_board._current_agent_has_board_access(t.board_id)) then
|
|
6
|
+
raise exception 'board not accessible to current agent' using errcode = '42501';
|
|
7
|
+
end if;
|
|
8
|
+
-- Step 3, the lookup:$q$);
|
|
9
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
10
|
+
execute n;
|
|
11
|
+
end $m$;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- read: the service_role refusal is dropped, and service_role gets a (test-only) grant
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ if agent_board._is_service_role() then
|
|
4
|
+
raise exception 'get_send_outcome requires an agent session' using errcode = '42501';
|
|
5
|
+
end if;
|
|
6
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.get_send_outcome(uuid,text,text)'; end if;
|
|
7
|
+
n := replace(d, $q$ if agent_board._is_service_role() then
|
|
8
|
+
raise exception 'get_send_outcome requires an agent session' using errcode = '42501';
|
|
9
|
+
end if;
|
|
10
|
+
$q$, $q$$q$);
|
|
11
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
12
|
+
execute n;
|
|
13
|
+
end $m$;
|
|
14
|
+
grant execute on function agent_board.get_send_outcome(uuid,text,text) to service_role;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- read: the confirmed row also carries message_sequence (drop + recreate, grants restated)
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.get_send_outcome(uuid,text,text)'::regprocedure); n text; begin
|
|
3
|
+
n := replace(d, $q$created_at timestamp with time zone)$q$, $q$created_at timestamp with time zone, message_sequence bigint)$q$);
|
|
4
|
+
n := replace(n, $q$null::uuid, null::timestamptz;$q$, $q$null::uuid, null::timestamptz, null::bigint;$q$);
|
|
5
|
+
n := replace(n, $q$v_row.board_id, v_row.created_at;$q$, $q$v_row.board_id, v_row.created_at, (select m.message_sequence from agent_board.messages m where m.id = v_row.message_id);$q$);
|
|
6
|
+
if n = d or position('message_sequence bigint' in n) = 0 or position('null::bigint' in n) = 0 or position('m.message_sequence' in n) = 0 then
|
|
7
|
+
raise exception 'M7 anchors not found';
|
|
8
|
+
end if;
|
|
9
|
+
execute 'drop function agent_board.get_send_outcome(uuid,text,text)';
|
|
10
|
+
execute n;
|
|
11
|
+
end $m$;
|
|
12
|
+
grant execute on function agent_board.get_send_outcome(uuid,text,text) to authenticated, agent_board_delegate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- post_board_message: delivery is wrapped in exception when others then null
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ select d.delivered_recipient_count, d.callback_outbox_count
|
|
4
|
+
into v_delivered_count, v_callback_count
|
|
5
|
+
from agent_board._deliver_board_message(v_message.id, trim(p_subject), p_body, p_priority) d;
|
|
6
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
7
|
+
n := replace(d, $q$ select d.delivered_recipient_count, d.callback_outbox_count
|
|
8
|
+
into v_delivered_count, v_callback_count
|
|
9
|
+
from agent_board._deliver_board_message(v_message.id, trim(p_subject), p_body, p_priority) d;
|
|
10
|
+
$q$, $q$ begin
|
|
11
|
+
select d.delivered_recipient_count, d.callback_outbox_count
|
|
12
|
+
into v_delivered_count, v_callback_count
|
|
13
|
+
from agent_board._deliver_board_message(v_message.id, trim(p_subject), p_body, p_priority) d;
|
|
14
|
+
exception when others then null;
|
|
15
|
+
end;
|
|
16
|
+
$q$);
|
|
17
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
18
|
+
execute n;
|
|
19
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- post_board_message: the board is put back into the idempotency lock key
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
5
|
+
n := replace(d, $q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,
|
|
6
|
+
$q$, $q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text || ':' || p_board_id::text,
|
|
7
|
+
$q$);
|
|
8
|
+
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# #670 SENDOUTCOME mutation receipts (D11). Connection comes ONLY from libpq environment (PGHOST/
|
|
3
|
+
# PGPORT/PGUSER/PGPASSWORD/PGDATABASE), never argv. The target must be an OWNED database holding this
|
|
4
|
+
# tree's applied bundle (CI: the dev job's throwaway Supabase; never a shared cluster).
|
|
5
|
+
#
|
|
6
|
+
# Per mutation:
|
|
7
|
+
# pgTAP the mutation and agent_board_send_outcome.test.sql run in ONE transaction that is
|
|
8
|
+
# rolled back. The receipt records the plan, emitted, ok and not ok counts and every
|
|
9
|
+
# failing line, counted from the TAP, never inferred from an absence. An aborted file
|
|
10
|
+
# (emitted < plan) or a mutation that failed to apply is NOT a kill.
|
|
11
|
+
# isolation (M9, M10 only) the mutation is COMMITTED, its target spec is diffed against the
|
|
12
|
+
# committed golden, and every touched definition is restored from text captured BEFORE
|
|
13
|
+
# mutating.
|
|
14
|
+
# Both legs require the agent_board catalog fingerprint (every routine's signature, ACL, source and
|
|
15
|
+
# comment, plus send_outcomes' constraints and ACL) to equal the pre-run value afterwards.
|
|
16
|
+
# Usage: run.sh <receipt-path> [mutation.sql ...] (default: every *.sql beside this script)
|
|
17
|
+
set -uo pipefail
|
|
18
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
19
|
+
PKG="$(cd "$HERE/../../.." && pwd)"
|
|
20
|
+
TEST="$PKG/tests/agent_board_send_outcome.test.sql"
|
|
21
|
+
SPECS="$PKG/tests/isolation/specs"
|
|
22
|
+
GOLDEN="$PKG/tests/isolation/expected"
|
|
23
|
+
OUT="${1:?receipt path}"; shift
|
|
24
|
+
if [ "$#" -gt 0 ]; then MUTS=("$@"); else mapfile -t MUTS < <(find "$HERE" -maxdepth 1 -name '*.sql' | sort -V); fi
|
|
25
|
+
[ -n "${PGDATABASE:-}" ] || { echo "FATAL: PGDATABASE unset (libpq environment required)" >&2; exit 3; }
|
|
26
|
+
ISO="$(ls -1 /usr/lib/postgresql/*/lib/pgxs/src/test/isolation/isolationtester 2>/dev/null | sort -V | tail -1)"
|
|
27
|
+
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
|
28
|
+
P=(psql -X -qtA)
|
|
29
|
+
FNS=("agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)")
|
|
30
|
+
fp() { "${P[@]}" -c "select md5(coalesce((select string_agg(p.oid::regprocedure::text || coalesce(p.proacl::text, '') || p.prosrc || p.provolatile::text || coalesce(obj_description(p.oid, 'pg_proc'), ''), '|' order by p.oid::regprocedure::text) from pg_proc p where p.pronamespace = 'agent_board'::regnamespace), '') || coalesce((select string_agg(conname || pg_get_constraintdef(oid), '|' order by conname) from pg_constraint where conrelid = 'agent_board.send_outcomes'::regclass), '') || coalesce((select relacl::text from pg_class where oid = 'agent_board.send_outcomes'::regclass), ''))"; }
|
|
31
|
+
: > "$WORK/restore.sql"
|
|
32
|
+
for f in "${FNS[@]}"; do
|
|
33
|
+
"${P[@]}" -c "select pg_get_functiondef('$f'::regprocedure)" >> "$WORK/restore.sql" || exit 3
|
|
34
|
+
printf ';\n' >> "$WORK/restore.sql"
|
|
35
|
+
done
|
|
36
|
+
ORIG="$(fp)"
|
|
37
|
+
|
|
38
|
+
tap() { # $1 label, $2 mutation file or empty
|
|
39
|
+
local out plan ok nok
|
|
40
|
+
if [ -n "$2" ]; then out="$(printf 'begin;\n\\i %s\n\\i %s\nrollback;\n' "$2" "$TEST" | "${P[@]}" 2>&1)"
|
|
41
|
+
else out="$(printf 'begin;\n\\i %s\nrollback;\n' "$TEST" | "${P[@]}" 2>&1)"; fi
|
|
42
|
+
plan="$(sed -nE 's/^1\.\.([0-9]+)$/\1/p' <<<"$out" | head -1)"
|
|
43
|
+
ok="$(grep -cE '^ok [0-9]+' <<<"$out")"; nok="$(grep -cE '^not ok [0-9]+' <<<"$out")"
|
|
44
|
+
printf '%s: pgtap plan=%s emitted=%s ok=%s not_ok=%s%s\n' "$1" "${plan:-NONE}" "$((ok + nok))" "$ok" "$nok" \
|
|
45
|
+
"$([ "${plan:-x}" = "$((ok + nok))" ] || echo ' ABORTED')"
|
|
46
|
+
grep -E '^not ok [0-9]+' <<<"$out" | sed 's/^/ /'
|
|
47
|
+
grep -E '(ERROR|FATAL):' <<<"$out" | head -3 | sed 's/^/ ERR /'
|
|
48
|
+
}
|
|
49
|
+
iso() { # $1 label, $2 spec basename
|
|
50
|
+
[ -x "$ISO" ] || { echo " isolation=UNDETERMINED (no isolationtester)"; return; }
|
|
51
|
+
"$ISO" "dbname=$PGDATABASE" < "$SPECS/$2.spec" > "$WORK/iso.out" 2>&1
|
|
52
|
+
if diff -q "$GOLDEN/$2.out" "$WORK/iso.out" >/dev/null; then echo " isolation[$2]=identical"
|
|
53
|
+
else
|
|
54
|
+
echo " isolation[$2]=DIFFERS ($(diff "$GOLDEN/$2.out" "$WORK/iso.out" | grep -cE '^[<>]') lines)"
|
|
55
|
+
diff "$GOLDEN/$2.out" "$WORK/iso.out" | grep -E '^[<>]' | head -12 | sed 's/^/ /'
|
|
56
|
+
fi
|
|
57
|
+
}
|
|
58
|
+
spec_for() { case "$1" in M9_*) echo send_outcome_cross_board ;; M10_*) echo send_outcome_overlap ;; *) echo "" ;; esac; }
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
echo "# #670 SENDOUTCOME mutation receipt -- $(date -u +%FT%TZ)"
|
|
62
|
+
echo "# tree $(git -C "$PKG" rev-parse HEAD)$(git -C "$PKG" diff --quiet HEAD -- . || echo ' + uncommitted changes')"
|
|
63
|
+
echo "# catalog fingerprint before: $ORIG"
|
|
64
|
+
tap "BASELINE" ""
|
|
65
|
+
iso "BASELINE" send_outcome_cross_board; iso "BASELINE" send_outcome_overlap
|
|
66
|
+
for m in "${MUTS[@]}"; do
|
|
67
|
+
name="$(basename "$m" .sql)"
|
|
68
|
+
echo "-- $name: $(head -1 "$m" | sed 's/^-- //') [sha256 $(sha256sum "$m" | cut -c1-16)]"
|
|
69
|
+
tap "$name" "$m"
|
|
70
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back pgTAP leg of $name"; exit 3; }
|
|
71
|
+
spec="$(spec_for "$name")"
|
|
72
|
+
if [ -n "$spec" ]; then
|
|
73
|
+
"${P[@]}" -v ON_ERROR_STOP=1 -1 -f "$m" >/dev/null 2>&1 || { echo "FATAL: $name did not apply for the isolation leg"; exit 3; }
|
|
74
|
+
[ "$(fp)" != "$ORIG" ] || { echo "FATAL: $name applied but the fingerprint is unchanged (no-op)"; exit 3; }
|
|
75
|
+
iso "$name" "$spec"
|
|
76
|
+
"${P[@]}" -v ON_ERROR_STOP=1 -1 -f "$WORK/restore.sql" >/dev/null || { echo "FATAL: restore failed after $name"; exit 3; }
|
|
77
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: restore fingerprint differs after $name"; exit 3; }
|
|
78
|
+
echo " restored: fingerprint identical"
|
|
79
|
+
fi
|
|
80
|
+
done
|
|
81
|
+
tap "AFTER-RESTORE" ""
|
|
82
|
+
iso "AFTER-RESTORE" send_outcome_cross_board; iso "AFTER-RESTORE" send_outcome_overlap
|
|
83
|
+
echo "# catalog fingerprint after: $(fp)"
|
|
84
|
+
} | tee "$OUT"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Reverse of 20261104180000: the exact origin/main 21b7b158 ACL (service_role EXECUTE) and comments.
|
|
2
|
+
grant execute on function agent_board._upsert_delivery_recipient(text,uuid,text,uuid,uuid,uuid,uuid,uuid,jsonb) to service_role;
|
|
3
|
+
grant execute on function agent_board._upsert_inbox_item(uuid,uuid,uuid,text,text,uuid,uuid,uuid,text,text,text,boolean,boolean,jsonb,jsonb) to service_role;
|
|
4
|
+
grant execute on function agent_board._queue_inbox_callbacks(uuid,text) to service_role;
|
|
5
|
+
grant execute on function agent_board._queue_board_post_callbacks(uuid,uuid,text,text,text,jsonb) to service_role;
|
|
6
|
+
grant execute on function agent_board._next_thread_message_sequence(uuid) to service_role;
|
|
7
|
+
comment on function agent_board._upsert_delivery_recipient(text,uuid,text,uuid,uuid,uuid,uuid,uuid,jsonb) is 'Enforces thread/board identity and the locked empty-history boundary for message, task and delegation delivery sources. Supplying a source ID does not exempt its private history. The sending RPC validates caller authority before its own writes.';
|
|
8
|
+
comment on function agent_board._upsert_inbox_item(uuid,uuid,uuid,text,text,uuid,uuid,uuid,text,text,text,boolean,boolean,jsonb,jsonb) is null;
|
|
9
|
+
comment on function agent_board._queue_inbox_callbacks(uuid,text) is null;
|
|
10
|
+
comment on function agent_board._queue_board_post_callbacks(uuid,uuid,text,text,text,jsonb) is null;
|
|
11
|
+
comment on function agent_board._next_thread_message_sequence(uuid) is null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,text,text,text,text,text,text,text,jsonb)'::regprocedure);
|
|
2
|
+
hdr text; body text;
|
|
3
|
+
begin
|
|
4
|
+
hdr := split_part(d, '$function$', 1); body := split_part(d, '$function$', 2);
|
|
5
|
+
if body !~ 'agent_board\.post_board_message\(' then raise exception 'mutation anchor missing'; end if;
|
|
6
|
+
execute hdr || '$function$' || regexp_replace(body, 'agent_board\.post_board_message\(', 'agent_board.post_board_message_gone(', 'g') || '$function$';
|
|
7
|
+
end $m$;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
create function agent_board.review_f1_widen(p_inbox uuid) returns void language sql security definer set search_path=agent_board,public as $f$
|
|
2
|
+
update agent_board.inbox_items set preview='forged preview through state update' where id=p_inbox;
|
|
3
|
+
$f$;
|
|
4
|
+
revoke all on function agent_board.review_f1_widen(uuid) from public,anon,authenticated,service_role,agent_board_delegate;
|
|
5
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.update_inbox_item_state(uuid,uuid,text,jsonb)'::regprocedure); begin
|
|
6
|
+
if position('v_callback_count := agent_board._queue_inbox_callbacks' in d)=0 then raise exception 'missing anchor'; end if;
|
|
7
|
+
execute replace(d, 'v_callback_count := agent_board._queue_inbox_callbacks', 'perform agent_board.review_f1_widen(v_inbox.id); v_callback_count := agent_board._queue_inbox_callbacks');
|
|
8
|
+
end $m$;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
create function agent_board.review_f1_widen(p_inbox uuid) returns void language sql security definer set search_path=agent_board,public as $f$
|
|
2
|
+
update agent_board.inbox_items set visible_in_board_feed=true where id=p_inbox;
|
|
3
|
+
$f$;
|
|
4
|
+
revoke all on function agent_board.review_f1_widen(uuid) from public,anon,authenticated,service_role,agent_board_delegate;
|
|
5
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.update_inbox_item_state(uuid,uuid,text,jsonb)'::regprocedure); begin
|
|
6
|
+
if position('v_callback_count := agent_board._queue_inbox_callbacks' in d)=0 then raise exception 'missing anchor'; end if;
|
|
7
|
+
execute replace(d, 'v_callback_count := agent_board._queue_inbox_callbacks', 'perform agent_board.review_f1_widen(v_inbox.id); v_callback_count := agent_board._queue_inbox_callbacks');
|
|
8
|
+
end $m$;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Two private hops must not hide a worker's content write from DWX-4c.
|
|
2
|
+
create function agent_board.dwx_worker_sink() returns void language sql security definer
|
|
3
|
+
set search_path=agent_board,public as $f$
|
|
4
|
+
update agent_board.inbox_items set preview='forged worker preview' where false;
|
|
5
|
+
$f$;
|
|
6
|
+
create function agent_board.dwx_worker_bridge() returns void language sql security definer
|
|
7
|
+
set search_path=agent_board,public as $f$ select agent_board.dwx_worker_sink(); $f$;
|
|
8
|
+
revoke all on function agent_board.dwx_worker_sink(), agent_board.dwx_worker_bridge()
|
|
9
|
+
from public,anon,authenticated,service_role,agent_board_delegate;
|
|
10
|
+
do $m$
|
|
11
|
+
declare d text := pg_get_functiondef('agent_board.claim_callback_outbox_events(integer)'::regprocedure);
|
|
12
|
+
begin
|
|
13
|
+
if position(E'begin\n' in d)=0 then raise exception 'missing worker begin anchor'; end if;
|
|
14
|
+
execute replace(d, E'begin\n', E'begin\n perform agent_board.dwx_worker_bridge();\n');
|
|
15
|
+
end $m$;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grant execute on function agent_board._upsert_delivery_recipient(text,uuid,text,uuid,uuid,uuid,uuid,uuid,jsonb) to service_role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grant execute on function agent_board._upsert_inbox_item(uuid,uuid,uuid,text,text,uuid,uuid,uuid,text,text,text,boolean,boolean,jsonb,jsonb) to service_role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grant execute on function agent_board._queue_inbox_callbacks(uuid,text) to service_role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grant execute on function agent_board._queue_board_post_callbacks(uuid,uuid,text,text,text,jsonb) to service_role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grant execute on function agent_board._next_thread_message_sequence(uuid) to service_role;
|