@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,38 @@
|
|
|
1
|
+
# #667: an artifact may name an empty explicit thread and a task on another
|
|
2
|
+
# thread. The explicit thread must serialize with first association even when a
|
|
3
|
+
# different canonical anchor is also present.
|
|
4
|
+
setup
|
|
5
|
+
{
|
|
6
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status)
|
|
7
|
+
values ('66730000-0000-4000-8000-000000000001','agent','xb-multi-anchor','XB multi anchor','active');
|
|
8
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
9
|
+
values ('66730000-0000-4000-8000-000000000020','xb-multi-anchor-board','XB multi anchor board',
|
|
10
|
+
'66730000-0000-4000-8000-000000000001','private','active');
|
|
11
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
12
|
+
values ('66730000-0000-4000-8000-000000000010','coordination','66730000-0000-4000-8000-000000000001','explicit empty'),
|
|
13
|
+
('66730000-0000-4000-8000-000000000011','coordination','66730000-0000-4000-8000-000000000001','task parent');
|
|
14
|
+
insert into agent_board.tasks(id,thread_id,created_by_agent_id,title)
|
|
15
|
+
values ('66730000-0000-4000-8000-000000000030','66730000-0000-4000-8000-000000000011','66730000-0000-4000-8000-000000000001','parent task');
|
|
16
|
+
}
|
|
17
|
+
teardown
|
|
18
|
+
{
|
|
19
|
+
delete from agent_board.artifacts where thread_id='66730000-0000-4000-8000-000000000010';
|
|
20
|
+
delete from agent_board.task_events where task_id='66730000-0000-4000-8000-000000000030';
|
|
21
|
+
delete from agent_board.tasks where id='66730000-0000-4000-8000-000000000030';
|
|
22
|
+
delete from agent_board.messages where thread_id='66730000-0000-4000-8000-000000000010';
|
|
23
|
+
delete from agent_board.threads where id in ('66730000-0000-4000-8000-000000000010','66730000-0000-4000-8000-000000000011');
|
|
24
|
+
delete from agent_board.boards where id='66730000-0000-4000-8000-000000000020';
|
|
25
|
+
delete from agent_board.agents where id='66730000-0000-4000-8000-000000000001';
|
|
26
|
+
}
|
|
27
|
+
session "w"
|
|
28
|
+
step "w_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
29
|
+
step "w_artifact" { select count(*) from agent_board.add_artifact('66730000-0000-4000-8000-000000000001','https://example.test/mixed',p_thread_id=>'66730000-0000-4000-8000-000000000010',p_task_id=>'66730000-0000-4000-8000-000000000030'); }
|
|
30
|
+
step "w_commit" { commit; }
|
|
31
|
+
session "a"
|
|
32
|
+
step "a_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
33
|
+
step "a_post" { select count(*) from agent_board.post_board_message('66730000-0000-4000-8000-000000000010','66730000-0000-4000-8000-000000000001','66730000-0000-4000-8000-000000000020','s','b'); }
|
|
34
|
+
step "a_end" { end; }
|
|
35
|
+
session "check"
|
|
36
|
+
step "check" { select (t.board_id is not null) as stamped, (select count(*) from agent_board.artifacts where thread_id=t.id and task_id='66730000-0000-4000-8000-000000000030') as mixed_artifacts, (select count(*) from agent_board.messages where thread_id=t.id) as messages from agent_board.threads t where t.id='66730000-0000-4000-8000-000000000010'; }
|
|
37
|
+
permutation "w_begin" "w_artifact" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
38
|
+
permutation "a_begin" "a_post" "w_begin" "w_artifact" "a_end" "w_commit" "check"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# #667: a private append and first board association serialize on the thread.
|
|
2
|
+
# The private writer wins with committed history and the association refuses;
|
|
3
|
+
# if association wins, the later service writer uses the stamped thread.
|
|
4
|
+
setup
|
|
5
|
+
{
|
|
6
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status)
|
|
7
|
+
values ('66810000-0000-4000-8000-000000000001','agent','xb-private-race','XB private race','active');
|
|
8
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
9
|
+
values ('66810000-0000-4000-8000-000000000020','xb-private-race-board','XB private race board',
|
|
10
|
+
'66810000-0000-4000-8000-000000000001','private','active');
|
|
11
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
12
|
+
values ('66810000-0000-4000-8000-000000000010','coordination',
|
|
13
|
+
'66810000-0000-4000-8000-000000000001','private race');
|
|
14
|
+
}
|
|
15
|
+
teardown
|
|
16
|
+
{
|
|
17
|
+
delete from agent_board.messages where thread_id='66810000-0000-4000-8000-000000000010';
|
|
18
|
+
delete from agent_board.threads where id='66810000-0000-4000-8000-000000000010';
|
|
19
|
+
delete from agent_board.boards where id='66810000-0000-4000-8000-000000000020';
|
|
20
|
+
delete from agent_board.agents where id='66810000-0000-4000-8000-000000000001';
|
|
21
|
+
}
|
|
22
|
+
session "w"
|
|
23
|
+
step "w_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
24
|
+
step "w_post" { select count(*) from agent_board.post_message('66810000-0000-4000-8000-000000000010','66810000-0000-4000-8000-000000000001','private race message'); }
|
|
25
|
+
step "w_commit" { commit; }
|
|
26
|
+
session "a"
|
|
27
|
+
step "a_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
28
|
+
step "a_post" { select count(*) from agent_board.post_board_message('66810000-0000-4000-8000-000000000010','66810000-0000-4000-8000-000000000001','66810000-0000-4000-8000-000000000020','board','board race message'); }
|
|
29
|
+
step "a_end" { end; }
|
|
30
|
+
session "check"
|
|
31
|
+
step "check" { select (t.board_id is not null) as stamped, (select count(*) from agent_board.messages m where m.thread_id=t.id and m.body='private race message') as private_messages, (select count(*) from agent_board.messages m where m.thread_id=t.id and m.body='board race message') as board_messages from agent_board.threads t where t.id='66810000-0000-4000-8000-000000000010'; }
|
|
32
|
+
permutation "w_begin" "w_post" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
33
|
+
permutation "a_begin" "a_post" "w_begin" "w_post" "a_end" "w_commit" "check"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# #667: private task creation and taskless conflict serialize with first board
|
|
2
|
+
# association. Each operation wins once; the checker observes the resulting rows.
|
|
3
|
+
setup
|
|
4
|
+
{
|
|
5
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status)
|
|
6
|
+
values ('66710000-0000-4000-8000-000000000001','agent','xb-task-conflict','XB task conflict','active');
|
|
7
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
8
|
+
values ('66710000-0000-4000-8000-000000000020','xb-task-conflict-board','XB task conflict board',
|
|
9
|
+
'66710000-0000-4000-8000-000000000001','private','active');
|
|
10
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
11
|
+
values ('66710000-0000-4000-8000-000000000010','coordination',
|
|
12
|
+
'66710000-0000-4000-8000-000000000001','task conflict race');
|
|
13
|
+
}
|
|
14
|
+
teardown
|
|
15
|
+
{
|
|
16
|
+
delete from agent_board.conflicts where thread_id='66710000-0000-4000-8000-000000000010';
|
|
17
|
+
delete from agent_board.task_events where thread_id='66710000-0000-4000-8000-000000000010';
|
|
18
|
+
delete from agent_board.tasks where thread_id='66710000-0000-4000-8000-000000000010';
|
|
19
|
+
delete from agent_board.messages where thread_id='66710000-0000-4000-8000-000000000010';
|
|
20
|
+
delete from agent_board.threads where id='66710000-0000-4000-8000-000000000010';
|
|
21
|
+
delete from agent_board.boards where id='66710000-0000-4000-8000-000000000020';
|
|
22
|
+
delete from agent_board.agents where id='66710000-0000-4000-8000-000000000001';
|
|
23
|
+
}
|
|
24
|
+
session "w"
|
|
25
|
+
step "w_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
26
|
+
step "w_task" { select count(*) from agent_board.create_task('66710000-0000-4000-8000-000000000010','66710000-0000-4000-8000-000000000001','private task'); }
|
|
27
|
+
step "w_conflict" { select count(*) from agent_board.raise_conflict('66710000-0000-4000-8000-000000000010','66710000-0000-4000-8000-000000000001','private conflict'); }
|
|
28
|
+
step "w_commit" { commit; }
|
|
29
|
+
session "a"
|
|
30
|
+
step "a_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
31
|
+
step "a_post" { select count(*) from agent_board.post_board_message('66710000-0000-4000-8000-000000000010','66710000-0000-4000-8000-000000000001','66710000-0000-4000-8000-000000000020','s','b'); }
|
|
32
|
+
step "a_end" { end; }
|
|
33
|
+
session "check"
|
|
34
|
+
step "check" { select (t.board_id is not null) as stamped, (select count(*) from agent_board.tasks where thread_id=t.id) as tasks, (select count(*) from agent_board.conflicts where thread_id=t.id) as conflicts, (select count(*) from agent_board.messages where thread_id=t.id) as messages from agent_board.threads t where t.id='66710000-0000-4000-8000-000000000010'; }
|
|
35
|
+
permutation "w_begin" "w_task" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
36
|
+
permutation "a_begin" "a_post" "w_begin" "w_task" "a_end" "w_commit" "check"
|
|
37
|
+
permutation "w_begin" "w_conflict" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
38
|
+
permutation "a_begin" "a_post" "w_begin" "w_conflict" "a_end" "w_commit" "check"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# #667: a task argument does not prove that a conflict or escalation's own
|
|
2
|
+
# thread equals its task thread. Both taskful writers serialize on their supplied
|
|
3
|
+
# thread before appending an event to the separately anchored task.
|
|
4
|
+
setup
|
|
5
|
+
{
|
|
6
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status)
|
|
7
|
+
values ('66760000-0000-4000-8000-000000000001','agent','xb-cross-task','XB cross task','active');
|
|
8
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
9
|
+
values ('66760000-0000-4000-8000-000000000020','xb-cross-task-board','XB cross task board',
|
|
10
|
+
'66760000-0000-4000-8000-000000000001','private','active');
|
|
11
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
12
|
+
values ('66760000-0000-4000-8000-000000000010','coordination','66760000-0000-4000-8000-000000000001','empty target'),
|
|
13
|
+
('66760000-0000-4000-8000-000000000011','coordination','66760000-0000-4000-8000-000000000001','task parent');
|
|
14
|
+
insert into agent_board.tasks(id,thread_id,created_by_agent_id,title)
|
|
15
|
+
values ('66760000-0000-4000-8000-000000000030','66760000-0000-4000-8000-000000000011','66760000-0000-4000-8000-000000000001','parent task');
|
|
16
|
+
}
|
|
17
|
+
teardown
|
|
18
|
+
{
|
|
19
|
+
delete from agent_board.conflicts where thread_id='66760000-0000-4000-8000-000000000010';
|
|
20
|
+
delete from agent_board.escalations where thread_id='66760000-0000-4000-8000-000000000010';
|
|
21
|
+
delete from agent_board.task_events where task_id='66760000-0000-4000-8000-000000000030';
|
|
22
|
+
delete from agent_board.tasks where id='66760000-0000-4000-8000-000000000030';
|
|
23
|
+
delete from agent_board.messages where thread_id='66760000-0000-4000-8000-000000000010';
|
|
24
|
+
delete from agent_board.threads where id in ('66760000-0000-4000-8000-000000000010','66760000-0000-4000-8000-000000000011');
|
|
25
|
+
delete from agent_board.boards where id='66760000-0000-4000-8000-000000000020';
|
|
26
|
+
delete from agent_board.agents where id='66760000-0000-4000-8000-000000000001';
|
|
27
|
+
}
|
|
28
|
+
session "w"
|
|
29
|
+
step "w_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
30
|
+
step "w_conflict" { select count(*) from agent_board.raise_conflict('66760000-0000-4000-8000-000000000010','66760000-0000-4000-8000-000000000001','private conflict',p_task_id=>'66760000-0000-4000-8000-000000000030'); }
|
|
31
|
+
step "w_escalation" { select count(*) from agent_board.raise_escalation('66760000-0000-4000-8000-000000000010','66760000-0000-4000-8000-000000000001','private escalation',p_task_id=>'66760000-0000-4000-8000-000000000030'); }
|
|
32
|
+
step "w_commit" { commit; }
|
|
33
|
+
session "a"
|
|
34
|
+
step "a_begin" { begin; select set_config('request.jwt.claim.role','service_role',true); }
|
|
35
|
+
step "a_post" { select count(*) from agent_board.post_board_message('66760000-0000-4000-8000-000000000010','66760000-0000-4000-8000-000000000001','66760000-0000-4000-8000-000000000020','s','b'); }
|
|
36
|
+
step "a_end" { end; }
|
|
37
|
+
session "check"
|
|
38
|
+
step "check" { select (t.board_id is not null) as stamped, (select count(*) from agent_board.conflicts where thread_id=t.id and task_id='66760000-0000-4000-8000-000000000030') as conflicts, (select count(*) from agent_board.escalations where thread_id=t.id and task_id='66760000-0000-4000-8000-000000000030') as escalations, (select count(*) from agent_board.messages where thread_id=t.id) as messages from agent_board.threads t where t.id='66760000-0000-4000-8000-000000000010'; }
|
|
39
|
+
permutation "w_begin" "w_conflict" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
40
|
+
permutation "a_begin" "a_post" "w_begin" "w_conflict" "a_end" "w_commit" "check"
|
|
41
|
+
permutation "w_begin" "w_escalation" "a_begin" "a_post" "w_commit" "a_end" "check"
|
|
42
|
+
permutation "a_begin" "a_post" "w_begin" "w_escalation" "a_end" "w_commit" "check"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# #717 F2b: concurrent same-key send_direct_message / send_multicast_message calls serialize on the
|
|
2
|
+
# unchanged (rpc, thread, resolved author, key) lock, and the second one is judged against what the
|
|
3
|
+
# first COMMITTED. Two sends naming DIFFERENT recipients on one key: whichever commits first is the
|
|
4
|
+
# message, and the other is refused (42501) rather than widening it. Two identical retries: one
|
|
5
|
+
# message, one delivery per recipient, one inbox item each, one callback each.
|
|
6
|
+
# A lock keyed by recipient (split domain) or removed lets the second send miss the uncommitted
|
|
7
|
+
# first message and mint a second one; the check step then counts two messages.
|
|
8
|
+
setup
|
|
9
|
+
{
|
|
10
|
+
insert into auth.users(id) values ('717b4000-0000-4000-8000-0000000000a1'),('717b4000-0000-4000-8000-0000000000c1'),('717b4000-0000-4000-8000-0000000000c2'),('717b4000-0000-4000-8000-0000000000e1');
|
|
11
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
12
|
+
values ('717b4000-0000-4000-8000-000000000001','agent','f2b717-iso-a','F2b iso A','active','717b4000-0000-4000-8000-0000000000a1'),
|
|
13
|
+
('717b4000-0000-4000-8000-000000000003','agent','f2b717-iso-c','F2b iso C','active','717b4000-0000-4000-8000-0000000000c1'),
|
|
14
|
+
('717b4000-0000-4000-8000-000000000004','agent','f2b717-iso-c2','F2b iso C2','active','717b4000-0000-4000-8000-0000000000c2'),
|
|
15
|
+
('717b4000-0000-4000-8000-000000000005','agent','f2b717-iso-x','F2b iso X','active','717b4000-0000-4000-8000-0000000000e1');
|
|
16
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
17
|
+
values ('717b4000-0000-4000-8000-000000000010','coordination','717b4000-0000-4000-8000-000000000001','f2b iso thread');
|
|
18
|
+
insert into agent_board.callback_endpoints(id,owner_agent_id,endpoint_url,endpoint_status)
|
|
19
|
+
values ('717b4000-0000-4000-8000-000000000030','717b4000-0000-4000-8000-000000000003','https://example.test/f2b717-iso-c','verified'),
|
|
20
|
+
('717b4000-0000-4000-8000-000000000031','717b4000-0000-4000-8000-000000000004','https://example.test/f2b717-iso-c2','verified'),
|
|
21
|
+
('717b4000-0000-4000-8000-000000000032','717b4000-0000-4000-8000-000000000005','https://example.test/f2b717-iso-x','verified');
|
|
22
|
+
insert into agent_board.callback_subscriptions(endpoint_id,agent_id,subscription_scope,event_category)
|
|
23
|
+
values ('717b4000-0000-4000-8000-000000000030','717b4000-0000-4000-8000-000000000003','own_inbox','inbox.item.delivered'),
|
|
24
|
+
('717b4000-0000-4000-8000-000000000031','717b4000-0000-4000-8000-000000000004','own_inbox','inbox.item.delivered'),
|
|
25
|
+
('717b4000-0000-4000-8000-000000000032','717b4000-0000-4000-8000-000000000005','own_inbox','inbox.item.delivered');
|
|
26
|
+
}
|
|
27
|
+
teardown
|
|
28
|
+
{
|
|
29
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004','717b4000-0000-4000-8000-000000000005');
|
|
30
|
+
delete from agent_board.callback_subscriptions where endpoint_id in ('717b4000-0000-4000-8000-000000000030','717b4000-0000-4000-8000-000000000031','717b4000-0000-4000-8000-000000000032');
|
|
31
|
+
delete from agent_board.callback_endpoints where id in ('717b4000-0000-4000-8000-000000000030','717b4000-0000-4000-8000-000000000031','717b4000-0000-4000-8000-000000000032');
|
|
32
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004','717b4000-0000-4000-8000-000000000005');
|
|
33
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004','717b4000-0000-4000-8000-000000000005');
|
|
34
|
+
delete from agent_board.messages where thread_id='717b4000-0000-4000-8000-000000000010';
|
|
35
|
+
delete from agent_board.threads where id='717b4000-0000-4000-8000-000000000010';
|
|
36
|
+
delete from agent_board.agents where id in ('717b4000-0000-4000-8000-000000000001','717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004','717b4000-0000-4000-8000-000000000005');
|
|
37
|
+
delete from auth.users where id in ('717b4000-0000-4000-8000-0000000000a1','717b4000-0000-4000-8000-0000000000c1','717b4000-0000-4000-8000-0000000000c2','717b4000-0000-4000-8000-0000000000e1');
|
|
38
|
+
}
|
|
39
|
+
# Each sending session is the author A: authenticated role AND matching JSON claims (built with
|
|
40
|
+
# json_build_object: a literal brace would end the step), with the flattened claim GUCs cleared so
|
|
41
|
+
# they cannot stand in for another identity.
|
|
42
|
+
session "p"
|
|
43
|
+
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','717b4000-0000-4000-8000-0000000000a1')::text,true); }
|
|
44
|
+
step "p_dm_c" { select callback_outbox_count from agent_board.send_direct_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001','717b4000-0000-4000-8000-000000000003','iso','iso dm','comment','medium','f2b717-kd',jsonb_build_object()); }
|
|
45
|
+
step "p_mc_cc2" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.send_multicast_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001',array['717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004']::uuid[],'iso','iso mc','comment','medium','f2b717-km',jsonb_build_object()); }
|
|
46
|
+
step "p_end" { end; }
|
|
47
|
+
session "w"
|
|
48
|
+
step "w_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','717b4000-0000-4000-8000-0000000000a1')::text,true); }
|
|
49
|
+
step "w_dm_x" { select callback_outbox_count from agent_board.send_direct_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001','717b4000-0000-4000-8000-000000000005','iso','iso dm','comment','medium','f2b717-kd',jsonb_build_object()); }
|
|
50
|
+
step "w_mc_cx" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.send_multicast_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001',array['717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000005']::uuid[],'iso','iso mc','comment','medium','f2b717-km',jsonb_build_object()); }
|
|
51
|
+
step "w_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','717b4000-0000-4000-8000-0000000000a1')::text,true); }
|
|
54
|
+
step "r_dm_c" { select callback_outbox_count from agent_board.send_direct_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001','717b4000-0000-4000-8000-000000000003','iso','iso dm','comment','medium','f2b717-kd',jsonb_build_object()); }
|
|
55
|
+
step "r_mc_c2c" { select delivered_recipient_count, inbox_item_count, callback_outbox_count from agent_board.send_multicast_message('717b4000-0000-4000-8000-000000000010','717b4000-0000-4000-8000-000000000001',array['717b4000-0000-4000-8000-000000000004','717b4000-0000-4000-8000-000000000003','717b4000-0000-4000-8000-000000000004']::uuid[],'iso','iso mc','comment','medium','f2b717-km',jsonb_build_object()); }
|
|
56
|
+
step "r_end" { end; }
|
|
57
|
+
session "check"
|
|
58
|
+
step "check" {
|
|
59
|
+
select count(*) as messages,
|
|
60
|
+
(select string_agg(a.handle || ':' || dr.delivery_mode, ',' order by a.handle, dr.delivery_mode)
|
|
61
|
+
from agent_board.delivery_recipients dr join agent_board.messages m on m.id = dr.source_message_id
|
|
62
|
+
join agent_board.agents a on a.id = dr.recipient_agent_id
|
|
63
|
+
where m.thread_id = '717b4000-0000-4000-8000-000000000010') as deliveries,
|
|
64
|
+
(select count(*) from agent_board.inbox_items ii join agent_board.messages m on m.id = ii.source_message_id where m.thread_id = '717b4000-0000-4000-8000-000000000010') as inbox,
|
|
65
|
+
(select count(*) from agent_board.callback_outbox_events co join agent_board.messages m on m.id = co.source_message_id where m.thread_id = '717b4000-0000-4000-8000-000000000010') as callbacks
|
|
66
|
+
from agent_board.messages where thread_id = '717b4000-0000-4000-8000-000000000010';
|
|
67
|
+
}
|
|
68
|
+
# direct, C wins: the send to X waits on the key lock, then is refused against the committed message
|
|
69
|
+
permutation "p_begin" "p_dm_c" "w_begin" "w_dm_x" "p_end" "w_end" "check"
|
|
70
|
+
# direct, X wins: the send to C waits, then is refused (C holds no direct delivery of X's message)
|
|
71
|
+
permutation "w_begin" "w_dm_x" "p_begin" "p_dm_c" "w_end" "p_end" "check"
|
|
72
|
+
# direct, identical retries: the second waits and reuses -- one message, delivery, inbox item, callback
|
|
73
|
+
permutation "p_begin" "p_dm_c" "r_begin" "r_dm_c" "p_end" "r_end" "check"
|
|
74
|
+
# multicast, {C,C2} wins: {C,X} waits, then is refused (X is new)
|
|
75
|
+
permutation "p_begin" "p_mc_cc2" "w_begin" "w_mc_cx" "p_end" "w_end" "check"
|
|
76
|
+
# multicast, identical set reordered and duplicated: one message, two deliveries, two inbox items, two callbacks
|
|
77
|
+
permutation "p_begin" "p_mc_cc2" "r_begin" "r_mc_c2c" "p_end" "r_end" "check"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# #670 D12 spec 6 (D6): one author, one thread, one key, posted concurrently to two different boards.
|
|
2
|
+
# D6 dropped the board from post_board_message's lock key, so the second post waits on the SAME advisory
|
|
3
|
+
# lock as the first (m_lockwait names it). After the first commits, the thread belongs to X, and the
|
|
4
|
+
# second -- addressed to Y -- is refused 42501 'thread belongs to a different board' by
|
|
5
|
+
# _associate_empty_thread (20261026000100) rather than replaying: one message, one receipt. A board in
|
|
6
|
+
# the lock key (D11 M9) still serializes the two on the thread row, but the waiter then waits on that
|
|
7
|
+
# row lock, not the advisory lock, and this trace changes.
|
|
8
|
+
setup
|
|
9
|
+
{
|
|
10
|
+
create table public.so670_iso6_pids(s text primary key, pid int not null);
|
|
11
|
+
create table public.so670_iso6_ret(s text not null, message_id uuid);
|
|
12
|
+
grant select, insert on public.so670_iso6_ret to authenticated, service_role;
|
|
13
|
+
insert into auth.users(id) values ('670b6000-0000-4000-8000-0000000000a1'),('670b6000-0000-4000-8000-0000000000b1'),('670b6000-0000-4000-8000-0000000000c1');
|
|
14
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
15
|
+
values ('670b6000-0000-4000-8000-000000000001','agent','so670-iso6-x-a','SO670 iso A','active','670b6000-0000-4000-8000-0000000000a1'),
|
|
16
|
+
('670b6000-0000-4000-8000-000000000002','agent','so670-iso6-x-b','SO670 iso B','active','670b6000-0000-4000-8000-0000000000b1'),
|
|
17
|
+
('670b6000-0000-4000-8000-000000000003','agent','so670-iso6-x-m','SO670 iso M','active','670b6000-0000-4000-8000-0000000000c1');
|
|
18
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
19
|
+
values ('670b6000-0000-4000-8000-000000000020','so670-iso6-x','SO670 iso X','670b6000-0000-4000-8000-000000000001','private','active'),
|
|
20
|
+
('670b6000-0000-4000-8000-000000000021','so670-iso6-y','SO670 iso Y','670b6000-0000-4000-8000-000000000001','private','active');
|
|
21
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
22
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
23
|
+
values ('670b6000-0000-4000-8000-000000000020','670b6000-0000-4000-8000-000000000001','joined','670b6000-0000-4000-8000-000000000001','owner'),('670b6000-0000-4000-8000-000000000020','670b6000-0000-4000-8000-000000000002','joined','670b6000-0000-4000-8000-000000000001','member'),
|
|
24
|
+
('670b6000-0000-4000-8000-000000000020','670b6000-0000-4000-8000-000000000003','joined','670b6000-0000-4000-8000-000000000001','member'),('670b6000-0000-4000-8000-000000000021','670b6000-0000-4000-8000-000000000001','joined','670b6000-0000-4000-8000-000000000001','owner');
|
|
25
|
+
select set_config('request.jwt.claim.role','',false);
|
|
26
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
27
|
+
values ('670b6000-0000-4000-8000-000000000010','coordination','670b6000-0000-4000-8000-000000000001','so670 iso T'),('670b6000-0000-4000-8000-000000000011','coordination','670b6000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
28
|
+
('670b6000-0000-4000-8000-000000000012','coordination','670b6000-0000-4000-8000-000000000003','so670 iso TM');
|
|
29
|
+
}
|
|
30
|
+
teardown
|
|
31
|
+
{
|
|
32
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000002','670b6000-0000-4000-8000-000000000003');
|
|
33
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000002','670b6000-0000-4000-8000-000000000003');
|
|
34
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000002','670b6000-0000-4000-8000-000000000003');
|
|
35
|
+
delete from agent_board.messages where thread_id in ('670b6000-0000-4000-8000-000000000010','670b6000-0000-4000-8000-000000000011','670b6000-0000-4000-8000-000000000012');
|
|
36
|
+
delete from agent_board.threads where id in ('670b6000-0000-4000-8000-000000000010','670b6000-0000-4000-8000-000000000011','670b6000-0000-4000-8000-000000000012');
|
|
37
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000002','670b6000-0000-4000-8000-000000000003');
|
|
38
|
+
delete from agent_board.board_membership_events where board_id in ('670b6000-0000-4000-8000-000000000020','670b6000-0000-4000-8000-000000000021');
|
|
39
|
+
delete from agent_board.boards where id in ('670b6000-0000-4000-8000-000000000020','670b6000-0000-4000-8000-000000000021');
|
|
40
|
+
delete from agent_board.agents where id in ('670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000002','670b6000-0000-4000-8000-000000000003');
|
|
41
|
+
delete from auth.users where id in ('670b6000-0000-4000-8000-0000000000a1','670b6000-0000-4000-8000-0000000000b1','670b6000-0000-4000-8000-0000000000c1');
|
|
42
|
+
drop table public.so670_iso6_pids;
|
|
43
|
+
drop table public.so670_iso6_ret;
|
|
44
|
+
}
|
|
45
|
+
session "p"
|
|
46
|
+
setup { reset role; insert into public.so670_iso6_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
47
|
+
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','670b6000-0000-4000-8000-0000000000a1')::text,true); }
|
|
48
|
+
step "p_post" { insert into public.so670_iso6_ret select 'p', message_id from agent_board.post_board_message('670b6000-0000-4000-8000-000000000010','670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
49
|
+
step "p_commit" { commit; }
|
|
50
|
+
session "w"
|
|
51
|
+
setup { reset role; insert into public.so670_iso6_pids values ('w', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
52
|
+
step "w_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','670b6000-0000-4000-8000-0000000000a1')::text,true); }
|
|
53
|
+
step "w_post_y" { insert into public.so670_iso6_ret select 'w', message_id from agent_board.post_board_message('670b6000-0000-4000-8000-000000000010','670b6000-0000-4000-8000-000000000001','670b6000-0000-4000-8000-000000000021','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
54
|
+
step "w_end" { end; }
|
|
55
|
+
session "m"
|
|
56
|
+
step "m_lockwait" { select l.locktype, l.mode from pg_locks l join public.so670_iso6_pids p on p.pid = l.pid where p.s = 'w' and not l.granted order by 1, 2; }
|
|
57
|
+
session "check"
|
|
58
|
+
step "check" {
|
|
59
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b6000-0000-4000-8000-000000000010')) as messages,
|
|
60
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b6000-0000-4000-8000-000000000010')) as receipts,
|
|
61
|
+
(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 ('670b6000-0000-4000-8000-000000000010')) as receipt_owners,
|
|
62
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso6_ret r) as returned_by,
|
|
63
|
+
(select count(distinct r.message_id) from public.so670_iso6_ret r) as distinct_returned,
|
|
64
|
+
(select coalesce(bool_and(exists (select 1 from agent_board.send_outcomes so where so.message_id = r.message_id)), false) from public.so670_iso6_ret r) as every_returned_has_receipt;
|
|
65
|
+
}
|
|
66
|
+
permutation "p_begin" "p_post" "w_begin" "w_post_y" "m_lockwait" "p_commit" "w_end" "check"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# #670 D12 spec 4: which same-key sends share an idempotency domain and which do not.
|
|
2
|
+
# independent (each mints its own receipt; any wait is the thread row, never the advisory lock):
|
|
3
|
+
# two authors, one key, one thread; one author, one key, post vs direct message; one author,
|
|
4
|
+
# one key, two threads (no wait at all);
|
|
5
|
+
# one domain (the second waits on the ADVISORY lock and replays the first; one receipt):
|
|
6
|
+
# the by-slug addressing overload vs the UUID core; two signing-client session retries with
|
|
7
|
+
# fresh signed_write envelopes;
|
|
8
|
+
# service-only (D4): a signed wrapper as service_role for A never mints. If it goes first, A's
|
|
9
|
+
# session send replays its message and still mints nothing; if A goes first, the wrapper replays.
|
|
10
|
+
# T is seeded in setup with one UNKEYED post (a direct postgres session: service_role, so no receipt):
|
|
11
|
+
# it stamps T to X and delivers to B, which is what gives B (not T's creator) access to T. The seed
|
|
12
|
+
# is the extra message on T in every check row.
|
|
13
|
+
setup
|
|
14
|
+
{
|
|
15
|
+
create table public.so670_iso4_pids(s text primary key, pid int not null);
|
|
16
|
+
create table public.so670_iso4_ret(s text not null, message_id uuid);
|
|
17
|
+
grant select, insert on public.so670_iso4_ret to authenticated, service_role;
|
|
18
|
+
insert into auth.users(id) values ('670b4000-0000-4000-8000-0000000000a1'),('670b4000-0000-4000-8000-0000000000b1'),('670b4000-0000-4000-8000-0000000000c1');
|
|
19
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
20
|
+
values ('670b4000-0000-4000-8000-000000000001','agent','so670-iso4-x-a','SO670 iso A','active','670b4000-0000-4000-8000-0000000000a1'),
|
|
21
|
+
('670b4000-0000-4000-8000-000000000002','agent','so670-iso4-x-b','SO670 iso B','active','670b4000-0000-4000-8000-0000000000b1'),
|
|
22
|
+
('670b4000-0000-4000-8000-000000000003','agent','so670-iso4-x-m','SO670 iso M','active','670b4000-0000-4000-8000-0000000000c1');
|
|
23
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
24
|
+
values ('670b4000-0000-4000-8000-000000000020','so670-iso4-x','SO670 iso X','670b4000-0000-4000-8000-000000000001','private','active'),
|
|
25
|
+
('670b4000-0000-4000-8000-000000000021','so670-iso4-y','SO670 iso Y','670b4000-0000-4000-8000-000000000001','private','active');
|
|
26
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
27
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
28
|
+
values ('670b4000-0000-4000-8000-000000000020','670b4000-0000-4000-8000-000000000001','joined','670b4000-0000-4000-8000-000000000001','owner'),('670b4000-0000-4000-8000-000000000020','670b4000-0000-4000-8000-000000000002','joined','670b4000-0000-4000-8000-000000000001','member'),
|
|
29
|
+
('670b4000-0000-4000-8000-000000000020','670b4000-0000-4000-8000-000000000003','joined','670b4000-0000-4000-8000-000000000001','member'),('670b4000-0000-4000-8000-000000000021','670b4000-0000-4000-8000-000000000001','joined','670b4000-0000-4000-8000-000000000001','owner');
|
|
30
|
+
select set_config('request.jwt.claim.role','',false);
|
|
31
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
32
|
+
values ('670b4000-0000-4000-8000-000000000010','coordination','670b4000-0000-4000-8000-000000000001','so670 iso T'),('670b4000-0000-4000-8000-000000000011','coordination','670b4000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
33
|
+
('670b4000-0000-4000-8000-000000000012','coordination','670b4000-0000-4000-8000-000000000003','so670 iso TM');
|
|
34
|
+
select count(*) as seeded from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','seed','comment','medium',null,jsonb_build_object());
|
|
35
|
+
}
|
|
36
|
+
teardown
|
|
37
|
+
{
|
|
38
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000003');
|
|
39
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000003');
|
|
40
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000003');
|
|
41
|
+
delete from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011','670b4000-0000-4000-8000-000000000012');
|
|
42
|
+
delete from agent_board.threads where id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011','670b4000-0000-4000-8000-000000000012');
|
|
43
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000003');
|
|
44
|
+
delete from agent_board.board_membership_events where board_id in ('670b4000-0000-4000-8000-000000000020','670b4000-0000-4000-8000-000000000021');
|
|
45
|
+
delete from agent_board.boards where id in ('670b4000-0000-4000-8000-000000000020','670b4000-0000-4000-8000-000000000021');
|
|
46
|
+
delete from agent_board.agents where id in ('670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000003');
|
|
47
|
+
delete from auth.users where id in ('670b4000-0000-4000-8000-0000000000a1','670b4000-0000-4000-8000-0000000000b1','670b4000-0000-4000-8000-0000000000c1');
|
|
48
|
+
drop table public.so670_iso4_pids;
|
|
49
|
+
drop table public.so670_iso4_ret;
|
|
50
|
+
}
|
|
51
|
+
session "p"
|
|
52
|
+
setup { reset role; insert into public.so670_iso4_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
53
|
+
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','670b4000-0000-4000-8000-0000000000a1')::text,true); }
|
|
54
|
+
step "p_post" { insert into public.so670_iso4_ret select 'p', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
55
|
+
step "p_post_env1" { insert into public.so670_iso4_ret select 'p', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','env 1','comment','medium','K',jsonb_build_object('signed_write',jsonb_build_object('nonce','1'))); }
|
|
56
|
+
step "p_commit" { commit; }
|
|
57
|
+
session "w"
|
|
58
|
+
setup { reset role; insert into public.so670_iso4_pids values ('w', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
59
|
+
step "w_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','670b4000-0000-4000-8000-0000000000a1')::text,true); }
|
|
60
|
+
step "w_dm" { insert into public.so670_iso4_ret select 'w', message_id from agent_board.send_direct_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000002','iso','dm body','comment','medium','K',jsonb_build_object()); }
|
|
61
|
+
step "w_slug" { insert into public.so670_iso4_ret select 'w', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','so670-iso4-x','addressing_v1','iso','by slug','comment','medium','K',jsonb_build_object()); }
|
|
62
|
+
step "w_post_env2" { insert into public.so670_iso4_ret select 'w', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','env 2','comment','medium','K',jsonb_build_object('signed_write',jsonb_build_object('nonce','2'))); }
|
|
63
|
+
step "w_post" { insert into public.so670_iso4_ret select 'w', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','session','comment','medium','K',jsonb_build_object()); }
|
|
64
|
+
step "w_post_t2" { insert into public.so670_iso4_ret select 'w', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000011','670b4000-0000-4000-8000-000000000001','670b4000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
65
|
+
step "w_commit" { commit; }
|
|
66
|
+
session "b"
|
|
67
|
+
setup { reset role; insert into public.so670_iso4_pids values ('b', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
68
|
+
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','670b4000-0000-4000-8000-0000000000b1')::text,true); }
|
|
69
|
+
step "b_post" { insert into public.so670_iso4_ret select 'b', message_id from agent_board.post_board_message('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000002','670b4000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
70
|
+
step "b_commit" { commit; }
|
|
71
|
+
session "s"
|
|
72
|
+
setup { insert into public.so670_iso4_pids values ('s', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
73
|
+
step "s_begin" { begin; set local role service_role; select set_config('request.jwt.claims',json_build_object('role','service_role')::text,true); }
|
|
74
|
+
step "s_signed" { insert into public.so670_iso4_ret select 's', message_id from agent_board.signed_post_board_message(jsonb_build_object('p_thread_id','670b4000-0000-4000-8000-000000000010','p_author_agent_id','670b4000-0000-4000-8000-000000000001','p_board_id','670b4000-0000-4000-8000-000000000020','p_subject','iso','p_body','signed','p_idempotency_key','K'), jsonb_build_object('agent_id','670b4000-0000-4000-8000-000000000001','verification_status','verified','payload_digest','sha256:' || repeat('6',64),'enforcement_mode','warn')); }
|
|
75
|
+
step "s_commit" { commit; }
|
|
76
|
+
session "m"
|
|
77
|
+
step "m_lockwait_b" { select l.locktype, l.mode from pg_locks l join public.so670_iso4_pids p on p.pid = l.pid where p.s = 'b' and not l.granted order by 1, 2; }
|
|
78
|
+
step "m_lockwait_w" { select l.locktype, l.mode from pg_locks l join public.so670_iso4_pids p on p.pid = l.pid where p.s = 'w' and not l.granted order by 1, 2; }
|
|
79
|
+
step "m_lockwait_s" { select l.locktype, l.mode from pg_locks l join public.so670_iso4_pids p on p.pid = l.pid where p.s = 's' and not l.granted order by 1, 2; }
|
|
80
|
+
session "check"
|
|
81
|
+
step "check" {
|
|
82
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
|
|
83
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
|
|
84
|
+
(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 ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipt_owners,
|
|
85
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
|
|
86
|
+
(select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
|
|
87
|
+
(select coalesce(bool_and(exists (select 1 from agent_board.send_outcomes so where so.message_id = r.message_id)), false) from public.so670_iso4_ret r) as every_returned_has_receipt;
|
|
88
|
+
}
|
|
89
|
+
permutation "p_begin" "p_post" "b_begin" "b_post" "m_lockwait_b" "p_commit" "b_commit" "check"
|
|
90
|
+
permutation "p_begin" "p_post" "w_begin" "w_dm" "m_lockwait_w" "p_commit" "w_commit" "check"
|
|
91
|
+
permutation "p_begin" "p_post" "w_begin" "w_post_t2" "p_commit" "w_commit" "check"
|
|
92
|
+
permutation "p_begin" "p_post" "w_begin" "w_slug" "m_lockwait_w" "p_commit" "w_commit" "check"
|
|
93
|
+
permutation "p_begin" "p_post_env1" "w_begin" "w_post_env2" "m_lockwait_w" "p_commit" "w_commit" "check"
|
|
94
|
+
permutation "s_begin" "s_signed" "w_begin" "w_post" "m_lockwait_w" "s_commit" "w_commit" "check"
|
|
95
|
+
permutation "p_begin" "p_post" "s_begin" "s_signed" "m_lockwait_s" "p_commit" "s_commit" "check"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# #670 D12 spec 3: membership removal against the send and the read (author M, member of X, its own thread TM).
|
|
2
|
+
# (1) the send commits, then M leaves X: M's read is still confirmed, and a fresh send with a new key
|
|
3
|
+
# is refused 42501;
|
|
4
|
+
# (2) M leaves first: the send is refused 42501 and no receipt exists, so the read is unknown;
|
|
5
|
+
# (3) removal DURING a lock wait: h holds M's (thread, key) idempotency lock, M's send waits on it,
|
|
6
|
+
# M leaves and commits, h releases, and the send's post-wait access recheck refuses it (42501) --
|
|
7
|
+
# no message, no receipt.
|
|
8
|
+
setup
|
|
9
|
+
{
|
|
10
|
+
create table public.so670_iso3_pids(s text primary key, pid int not null);
|
|
11
|
+
create table public.so670_iso3_ret(s text not null, message_id uuid);
|
|
12
|
+
grant select, insert on public.so670_iso3_ret to authenticated, service_role;
|
|
13
|
+
insert into auth.users(id) values ('670b3000-0000-4000-8000-0000000000a1'),('670b3000-0000-4000-8000-0000000000b1'),('670b3000-0000-4000-8000-0000000000c1');
|
|
14
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
15
|
+
values ('670b3000-0000-4000-8000-000000000001','agent','so670-iso3-x-a','SO670 iso A','active','670b3000-0000-4000-8000-0000000000a1'),
|
|
16
|
+
('670b3000-0000-4000-8000-000000000002','agent','so670-iso3-x-b','SO670 iso B','active','670b3000-0000-4000-8000-0000000000b1'),
|
|
17
|
+
('670b3000-0000-4000-8000-000000000003','agent','so670-iso3-x-m','SO670 iso M','active','670b3000-0000-4000-8000-0000000000c1');
|
|
18
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
19
|
+
values ('670b3000-0000-4000-8000-000000000020','so670-iso3-x','SO670 iso X','670b3000-0000-4000-8000-000000000001','private','active'),
|
|
20
|
+
('670b3000-0000-4000-8000-000000000021','so670-iso3-y','SO670 iso Y','670b3000-0000-4000-8000-000000000001','private','active');
|
|
21
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
22
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
23
|
+
values ('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000001','joined','670b3000-0000-4000-8000-000000000001','owner'),('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000002','joined','670b3000-0000-4000-8000-000000000001','member'),
|
|
24
|
+
('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000003','joined','670b3000-0000-4000-8000-000000000001','member'),('670b3000-0000-4000-8000-000000000021','670b3000-0000-4000-8000-000000000001','joined','670b3000-0000-4000-8000-000000000001','owner');
|
|
25
|
+
select set_config('request.jwt.claim.role','',false);
|
|
26
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
27
|
+
values ('670b3000-0000-4000-8000-000000000010','coordination','670b3000-0000-4000-8000-000000000001','so670 iso T'),('670b3000-0000-4000-8000-000000000011','coordination','670b3000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
28
|
+
('670b3000-0000-4000-8000-000000000012','coordination','670b3000-0000-4000-8000-000000000003','so670 iso TM');
|
|
29
|
+
}
|
|
30
|
+
teardown
|
|
31
|
+
{
|
|
32
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b3000-0000-4000-8000-000000000001','670b3000-0000-4000-8000-000000000002','670b3000-0000-4000-8000-000000000003');
|
|
33
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b3000-0000-4000-8000-000000000001','670b3000-0000-4000-8000-000000000002','670b3000-0000-4000-8000-000000000003');
|
|
34
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b3000-0000-4000-8000-000000000001','670b3000-0000-4000-8000-000000000002','670b3000-0000-4000-8000-000000000003');
|
|
35
|
+
delete from agent_board.messages where thread_id in ('670b3000-0000-4000-8000-000000000010','670b3000-0000-4000-8000-000000000011','670b3000-0000-4000-8000-000000000012');
|
|
36
|
+
delete from agent_board.threads where id in ('670b3000-0000-4000-8000-000000000010','670b3000-0000-4000-8000-000000000011','670b3000-0000-4000-8000-000000000012');
|
|
37
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b3000-0000-4000-8000-000000000001','670b3000-0000-4000-8000-000000000002','670b3000-0000-4000-8000-000000000003');
|
|
38
|
+
delete from agent_board.board_membership_events where board_id in ('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000021');
|
|
39
|
+
delete from agent_board.boards where id in ('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000021');
|
|
40
|
+
delete from agent_board.agents where id in ('670b3000-0000-4000-8000-000000000001','670b3000-0000-4000-8000-000000000002','670b3000-0000-4000-8000-000000000003');
|
|
41
|
+
delete from auth.users where id in ('670b3000-0000-4000-8000-0000000000a1','670b3000-0000-4000-8000-0000000000b1','670b3000-0000-4000-8000-0000000000c1');
|
|
42
|
+
drop table public.so670_iso3_pids;
|
|
43
|
+
drop table public.so670_iso3_ret;
|
|
44
|
+
}
|
|
45
|
+
session "p"
|
|
46
|
+
setup { reset role; insert into public.so670_iso3_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
47
|
+
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','670b3000-0000-4000-8000-0000000000c1')::text,true); }
|
|
48
|
+
step "p_post" { insert into public.so670_iso3_ret select 'p', message_id from agent_board.post_board_message('670b3000-0000-4000-8000-000000000012','670b3000-0000-4000-8000-000000000003','670b3000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K',jsonb_build_object()); }
|
|
49
|
+
step "p_commit" { commit; }
|
|
50
|
+
step "p_end" { end; }
|
|
51
|
+
session "l"
|
|
52
|
+
setup { reset role; insert into public.so670_iso3_pids values ('l', 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','670b3000-0000-4000-8000-0000000000c1')::text,false); }
|
|
53
|
+
step "l_leave" { select count(*) as left_rows from agent_board.leave_board('670b3000-0000-4000-8000-000000000020','670b3000-0000-4000-8000-000000000003',jsonb_build_object()); }
|
|
54
|
+
step "r_read" { select status from agent_board.get_send_outcome('670b3000-0000-4000-8000-000000000012','K','post_board_message'); }
|
|
55
|
+
step "r_fresh" { insert into public.so670_iso3_ret select 'fresh', message_id from agent_board.post_board_message('670b3000-0000-4000-8000-000000000012','670b3000-0000-4000-8000-000000000003','670b3000-0000-4000-8000-000000000020','iso','so670 body','comment','medium','K2',jsonb_build_object()); }
|
|
56
|
+
session "h"
|
|
57
|
+
step "h_begin" { begin; }
|
|
58
|
+
step "h_lock" { select agent_board._lock_idempotency_key('post_board_message:' || '670b3000-0000-4000-8000-000000000012' || ':' || '670b3000-0000-4000-8000-000000000003', 'K'); }
|
|
59
|
+
step "h_commit" { commit; }
|
|
60
|
+
session "m"
|
|
61
|
+
step "m_lockwait" { select l.locktype, l.mode from pg_locks l join public.so670_iso3_pids p on p.pid = l.pid where p.s = 'p' and not l.granted order by 1, 2; }
|
|
62
|
+
session "check"
|
|
63
|
+
step "check" {
|
|
64
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b3000-0000-4000-8000-000000000012')) as messages,
|
|
65
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b3000-0000-4000-8000-000000000012')) as receipts,
|
|
66
|
+
(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 ('670b3000-0000-4000-8000-000000000012')) as receipt_owners,
|
|
67
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso3_ret r) as returned_by,
|
|
68
|
+
(select count(distinct r.message_id) from public.so670_iso3_ret r) as distinct_returned,
|
|
69
|
+
(select coalesce(bool_and(exists (select 1 from agent_board.send_outcomes so where so.message_id = r.message_id)), false) from public.so670_iso3_ret r) as every_returned_has_receipt;
|
|
70
|
+
}
|
|
71
|
+
permutation "p_begin" "p_post" "p_commit" "l_leave" "r_read" "r_fresh" "check"
|
|
72
|
+
permutation "l_leave" "p_begin" "p_post" "p_end" "r_read" "check"
|
|
73
|
+
permutation "h_begin" "h_lock" "p_begin" "p_post" "m_lockwait" "l_leave" "h_commit" "p_end" "r_read" "check"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# #670 D12 spec 1: two same-author, same-thread, same-board, same-key post_board_message calls.
|
|
2
|
+
# The second waits on the (thread, author, key) advisory idempotency lock -- the lockwait step names the
|
|
3
|
+
# lock it waits on, so removing that lock (D11 M10) changes this trace even though the thread row lock
|
|
4
|
+
# would still serialize the two posts. First commit: the second returns the FIRST transaction's
|
|
5
|
+
# message_id (returned_by p,w with one distinct id), with one message and one receipt; its changed body
|
|
6
|
+
# is the #717-permitted replay (D2), and the replay re-fans out to the board without duplicating B's
|
|
7
|
+
# delivery. First rollback: the second succeeds once, as the only message and receipt.
|
|
8
|
+
setup
|
|
9
|
+
{
|
|
10
|
+
create table public.so670_iso1_pids(s text primary key, pid int not null);
|
|
11
|
+
create table public.so670_iso1_ret(s text not null, message_id uuid);
|
|
12
|
+
grant select, insert on public.so670_iso1_ret to authenticated, service_role;
|
|
13
|
+
insert into auth.users(id) values ('670b1000-0000-4000-8000-0000000000a1'),('670b1000-0000-4000-8000-0000000000b1'),('670b1000-0000-4000-8000-0000000000c1');
|
|
14
|
+
insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id)
|
|
15
|
+
values ('670b1000-0000-4000-8000-000000000001','agent','so670-iso1-x-a','SO670 iso A','active','670b1000-0000-4000-8000-0000000000a1'),
|
|
16
|
+
('670b1000-0000-4000-8000-000000000002','agent','so670-iso1-x-b','SO670 iso B','active','670b1000-0000-4000-8000-0000000000b1'),
|
|
17
|
+
('670b1000-0000-4000-8000-000000000003','agent','so670-iso1-x-m','SO670 iso M','active','670b1000-0000-4000-8000-0000000000c1');
|
|
18
|
+
insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
|
|
19
|
+
values ('670b1000-0000-4000-8000-000000000020','so670-iso1-x','SO670 iso X','670b1000-0000-4000-8000-000000000001','private','active'),
|
|
20
|
+
('670b1000-0000-4000-8000-000000000021','so670-iso1-y','SO670 iso Y','670b1000-0000-4000-8000-000000000001','private','active');
|
|
21
|
+
select set_config('request.jwt.claim.role','service_role',false);
|
|
22
|
+
insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
|
|
23
|
+
values ('670b1000-0000-4000-8000-000000000020','670b1000-0000-4000-8000-000000000001','joined','670b1000-0000-4000-8000-000000000001','owner'),('670b1000-0000-4000-8000-000000000020','670b1000-0000-4000-8000-000000000002','joined','670b1000-0000-4000-8000-000000000001','member'),
|
|
24
|
+
('670b1000-0000-4000-8000-000000000020','670b1000-0000-4000-8000-000000000003','joined','670b1000-0000-4000-8000-000000000001','member'),('670b1000-0000-4000-8000-000000000021','670b1000-0000-4000-8000-000000000001','joined','670b1000-0000-4000-8000-000000000001','owner');
|
|
25
|
+
select set_config('request.jwt.claim.role','',false);
|
|
26
|
+
insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
|
|
27
|
+
values ('670b1000-0000-4000-8000-000000000010','coordination','670b1000-0000-4000-8000-000000000001','so670 iso T'),('670b1000-0000-4000-8000-000000000011','coordination','670b1000-0000-4000-8000-000000000001','so670 iso T2'),
|
|
28
|
+
('670b1000-0000-4000-8000-000000000012','coordination','670b1000-0000-4000-8000-000000000003','so670 iso TM');
|
|
29
|
+
}
|
|
30
|
+
teardown
|
|
31
|
+
{
|
|
32
|
+
delete from agent_board.inbox_items where recipient_agent_id in ('670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000002','670b1000-0000-4000-8000-000000000003');
|
|
33
|
+
delete from agent_board.callback_outbox_events where recipient_agent_id in ('670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000002','670b1000-0000-4000-8000-000000000003');
|
|
34
|
+
delete from agent_board.delivery_recipients where recipient_agent_id in ('670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000002','670b1000-0000-4000-8000-000000000003');
|
|
35
|
+
delete from agent_board.messages where thread_id in ('670b1000-0000-4000-8000-000000000010','670b1000-0000-4000-8000-000000000011','670b1000-0000-4000-8000-000000000012');
|
|
36
|
+
delete from agent_board.threads where id in ('670b1000-0000-4000-8000-000000000010','670b1000-0000-4000-8000-000000000011','670b1000-0000-4000-8000-000000000012');
|
|
37
|
+
delete from agent_board.send_authz_telemetry where actor_agent_id in ('670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000002','670b1000-0000-4000-8000-000000000003');
|
|
38
|
+
delete from agent_board.board_membership_events where board_id in ('670b1000-0000-4000-8000-000000000020','670b1000-0000-4000-8000-000000000021');
|
|
39
|
+
delete from agent_board.boards where id in ('670b1000-0000-4000-8000-000000000020','670b1000-0000-4000-8000-000000000021');
|
|
40
|
+
delete from agent_board.agents where id in ('670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000002','670b1000-0000-4000-8000-000000000003');
|
|
41
|
+
delete from auth.users where id in ('670b1000-0000-4000-8000-0000000000a1','670b1000-0000-4000-8000-0000000000b1','670b1000-0000-4000-8000-0000000000c1');
|
|
42
|
+
drop table public.so670_iso1_pids;
|
|
43
|
+
drop table public.so670_iso1_ret;
|
|
44
|
+
}
|
|
45
|
+
session "p"
|
|
46
|
+
setup { reset role; insert into public.so670_iso1_pids values ('p', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
47
|
+
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','670b1000-0000-4000-8000-0000000000a1')::text,true); }
|
|
48
|
+
step "p_post" { insert into public.so670_iso1_ret select 'p', message_id from agent_board.post_board_message('670b1000-0000-4000-8000-000000000010','670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000020','iso','first body','comment','medium','K',jsonb_build_object()); }
|
|
49
|
+
step "p_commit" { commit; }
|
|
50
|
+
step "p_rollback" { rollback; }
|
|
51
|
+
session "w"
|
|
52
|
+
setup { reset role; insert into public.so670_iso1_pids values ('w', pg_backend_pid()) on conflict (s) do update set pid = excluded.pid; }
|
|
53
|
+
step "w_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','670b1000-0000-4000-8000-0000000000a1')::text,true); }
|
|
54
|
+
step "w_post" { insert into public.so670_iso1_ret select 'w', message_id from agent_board.post_board_message('670b1000-0000-4000-8000-000000000010','670b1000-0000-4000-8000-000000000001','670b1000-0000-4000-8000-000000000020','iso','changed retry body','comment','medium','K',jsonb_build_object()); }
|
|
55
|
+
step "w_commit" { commit; }
|
|
56
|
+
session "m"
|
|
57
|
+
step "m_lockwait" { select l.locktype, l.mode from pg_locks l join public.so670_iso1_pids p on p.pid = l.pid where p.s = 'w' and not l.granted order by 1, 2; }
|
|
58
|
+
session "check"
|
|
59
|
+
step "check" {
|
|
60
|
+
select (select count(*) from agent_board.messages where thread_id in ('670b1000-0000-4000-8000-000000000010')) as messages,
|
|
61
|
+
(select count(*) from agent_board.send_outcomes where thread_id in ('670b1000-0000-4000-8000-000000000010')) 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 ('670b1000-0000-4000-8000-000000000010')) as receipt_owners,
|
|
63
|
+
(select string_agg(r.s, ',' order by r.s) from public.so670_iso1_ret r) as returned_by,
|
|
64
|
+
(select count(distinct r.message_id) from public.so670_iso1_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_iso1_ret r) as every_returned_has_receipt;
|
|
66
|
+
}
|
|
67
|
+
step "b_deliveries" { select count(*) as b_deliveries from agent_board.delivery_recipients dr join agent_board.messages m on m.id = dr.source_message_id where m.thread_id = '670b1000-0000-4000-8000-000000000010' and dr.recipient_agent_id = '670b1000-0000-4000-8000-000000000002'; }
|
|
68
|
+
permutation "p_begin" "p_post" "w_begin" "w_post" "m_lockwait" "p_commit" "w_commit" "check" "b_deliveries"
|
|
69
|
+
permutation "p_begin" "p_post" "w_begin" "w_post" "m_lockwait" "p_rollback" "w_commit" "check" "b_deliveries"
|