@consiliency/agent-board-schema 1.74.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.
Files changed (51) hide show
  1. package/fixtures/already-applied.json +4 -0
  2. package/migrations/20261108000100_agent_board_send_outcome.sql +708 -0
  3. package/package.json +1 -1
  4. package/schema-manifest.json +12 -3
  5. package/src/deployment-drift-main.test.mjs +20 -3
  6. package/src/deployment-drift-script.test.mjs +77 -2
  7. package/src/deployment-drift.test.mjs +60 -0
  8. package/src/tooling.test.mjs +3 -2
  9. package/tests/agent_board_667_history_class.test.sql +2 -0
  10. package/tests/agent_board_717_native_surface.test.sql +223 -0
  11. package/tests/agent_board_delegate_role_class.test.sql +2 -2
  12. package/tests/agent_board_delivery_writer_execute.test.sql +4 -2
  13. package/tests/agent_board_hosted_delegates.test.sql +8 -1
  14. package/tests/agent_board_send_outcome.test.sql +805 -0
  15. package/tests/agent_board_write_enforcement_class.test.sql +9 -5
  16. package/tests/catalog/function_execute_privileges.json +24 -0
  17. package/tests/catalog/p_metadata_parameters.json +8 -0
  18. package/tests/fixtures/isolation-substrate.sql +8 -0
  19. package/tests/fixtures/pgtap-unexposed.sql +61 -0
  20. package/tests/isolation/expected/send_outcome_cross_board.out +40 -0
  21. package/tests/isolation/expected/send_outcome_independence.out +295 -0
  22. package/tests/isolation/expected/send_outcome_membership.out +140 -0
  23. package/tests/isolation/expected/send_outcome_overlap.out +89 -0
  24. package/tests/isolation/expected/send_outcome_reader.out +87 -0
  25. package/tests/isolation/expected/send_outcome_recovery.out +107 -0
  26. package/tests/isolation/specs/send_outcome_cross_board.spec +66 -0
  27. package/tests/isolation/specs/send_outcome_independence.spec +95 -0
  28. package/tests/isolation/specs/send_outcome_membership.spec +73 -0
  29. package/tests/isolation/specs/send_outcome_overlap.spec +69 -0
  30. package/tests/isolation/specs/send_outcome_reader.spec +61 -0
  31. package/tests/isolation/specs/send_outcome_recovery.spec +68 -0
  32. package/tests/mutations/670/E1_helper_author_from_message.sql +7 -0
  33. package/tests/mutations/670/E2_helper_no_null_check.sql +13 -0
  34. package/tests/mutations/670/M10_lock_removed.sql +10 -0
  35. package/tests/mutations/670/M11_table_granted_to_authenticated.sql +2 -0
  36. package/tests/mutations/670/M12_helper_granted_to_service_role.sql +2 -0
  37. package/tests/mutations/670/M13_message_fk_no_cascade.sql +8 -0
  38. package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +11 -0
  39. package/tests/mutations/670/M15_second_receipt_writer.sql +9 -0
  40. package/tests/mutations/670/M16_read_no_btrim.sql +7 -0
  41. package/tests/mutations/670/M17_read_volatile.sql +2 -0
  42. package/tests/mutations/670/M1_helper_no_service_role_guard.sql +13 -0
  43. package/tests/mutations/670/M3_helper_on_replay_branch.sql +10 -0
  44. package/tests/mutations/670/M4_read_checks_thread_existence.sql +10 -0
  45. package/tests/mutations/670/M5a_read_requires_thread_access.sql +10 -0
  46. package/tests/mutations/670/M5b_read_requires_board_membership.sql +11 -0
  47. package/tests/mutations/670/M6_read_admits_service_role.sql +14 -0
  48. package/tests/mutations/670/M7_confirmed_adds_message_sequence.sql +12 -0
  49. package/tests/mutations/670/M8_delivery_swallows_errors.sql +19 -0
  50. package/tests/mutations/670/M9_lock_key_includes_board.sql +10 -0
  51. package/tests/mutations/670/run.sh +84 -0
@@ -0,0 +1,140 @@
1
+ Parsed test spec with 5 sessions
2
+
3
+ starting permutation: p_begin p_post p_commit l_leave r_read r_fresh check
4
+ set_config
5
+ --------------------------------------------------------------------------
6
+ {"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
7
+ (1 row)
8
+
9
+ 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);
10
+ set_config|set_config|set_config
11
+ ----------+----------+--------------------------------------------------------------------------
12
+ | |{"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
13
+ (1 row)
14
+
15
+ 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());
16
+ step p_commit: commit;
17
+ 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());
18
+ left_rows
19
+ ---------
20
+ 1
21
+ (1 row)
22
+
23
+ step r_read: select status from agent_board.get_send_outcome('670b3000-0000-4000-8000-000000000012','K','post_board_message');
24
+ status
25
+ ---------
26
+ confirmed
27
+ (1 row)
28
+
29
+ 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());
30
+ ERROR: board not accessible to current agent
31
+ step check:
32
+ select (select count(*) from agent_board.messages where thread_id in ('670b3000-0000-4000-8000-000000000012')) as messages,
33
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b3000-0000-4000-8000-000000000012')) as receipts,
34
+ (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,
35
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso3_ret r) as returned_by,
36
+ (select count(distinct r.message_id) from public.so670_iso3_ret r) as distinct_returned,
37
+ (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;
38
+
39
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
40
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
41
+ 1| 1|post_board_message:so670-iso3-x-m|p | 1|t
42
+ (1 row)
43
+
44
+
45
+ starting permutation: l_leave p_begin p_post p_end r_read check
46
+ set_config
47
+ --------------------------------------------------------------------------
48
+ {"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
49
+ (1 row)
50
+
51
+ 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());
52
+ left_rows
53
+ ---------
54
+ 1
55
+ (1 row)
56
+
57
+ 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);
58
+ set_config|set_config|set_config
59
+ ----------+----------+--------------------------------------------------------------------------
60
+ | |{"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
61
+ (1 row)
62
+
63
+ 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());
64
+ ERROR: board not accessible to current agent
65
+ step p_end: end;
66
+ step r_read: select status from agent_board.get_send_outcome('670b3000-0000-4000-8000-000000000012','K','post_board_message');
67
+ status
68
+ -------
69
+ unknown
70
+ (1 row)
71
+
72
+ step check:
73
+ select (select count(*) from agent_board.messages where thread_id in ('670b3000-0000-4000-8000-000000000012')) as messages,
74
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b3000-0000-4000-8000-000000000012')) as receipts,
75
+ (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,
76
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso3_ret r) as returned_by,
77
+ (select count(distinct r.message_id) from public.so670_iso3_ret r) as distinct_returned,
78
+ (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;
79
+
80
+ messages|receipts|receipt_owners|returned_by|distinct_returned|every_returned_has_receipt
81
+ --------+--------+--------------+-----------+-----------------+--------------------------
82
+ 0| 0| | | 0|f
83
+ (1 row)
84
+
85
+
86
+ starting permutation: h_begin h_lock p_begin p_post m_lockwait l_leave h_commit p_end r_read check
87
+ set_config
88
+ --------------------------------------------------------------------------
89
+ {"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
90
+ (1 row)
91
+
92
+ step h_begin: begin;
93
+ step h_lock: select agent_board._lock_idempotency_key('post_board_message:' || '670b3000-0000-4000-8000-000000000012' || ':' || '670b3000-0000-4000-8000-000000000003', 'K');
94
+ _lock_idempotency_key
95
+ ---------------------
96
+
97
+ (1 row)
98
+
99
+ 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);
100
+ set_config|set_config|set_config
101
+ ----------+----------+--------------------------------------------------------------------------
102
+ | |{"role" : "authenticated", "sub" : "670b3000-0000-4000-8000-0000000000c1"}
103
+ (1 row)
104
+
105
+ 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()); <waiting ...>
106
+ 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;
107
+ locktype|mode
108
+ --------+-------------
109
+ advisory|ExclusiveLock
110
+ (1 row)
111
+
112
+ 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());
113
+ left_rows
114
+ ---------
115
+ 1
116
+ (1 row)
117
+
118
+ step h_commit: commit;
119
+ step p_post: <... completed>
120
+ ERROR: board not accessible to current agent
121
+ step p_end: end;
122
+ step r_read: select status from agent_board.get_send_outcome('670b3000-0000-4000-8000-000000000012','K','post_board_message');
123
+ status
124
+ -------
125
+ unknown
126
+ (1 row)
127
+
128
+ step check:
129
+ select (select count(*) from agent_board.messages where thread_id in ('670b3000-0000-4000-8000-000000000012')) as messages,
130
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b3000-0000-4000-8000-000000000012')) as receipts,
131
+ (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,
132
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso3_ret r) as returned_by,
133
+ (select count(distinct r.message_id) from public.so670_iso3_ret r) as distinct_returned,
134
+ (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;
135
+
136
+ messages|receipts|receipt_owners|returned_by|distinct_returned|every_returned_has_receipt
137
+ --------+--------+--------------+-----------+-----------------+--------------------------
138
+ 0| 0| | | 0|f
139
+ (1 row)
140
+
@@ -0,0 +1,89 @@
1
+ Parsed test spec with 4 sessions
2
+
3
+ starting permutation: p_begin p_post w_begin w_post m_lockwait p_commit w_commit check b_deliveries
4
+ 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);
5
+ set_config|set_config|set_config
6
+ ----------+----------+--------------------------------------------------------------------------
7
+ | |{"role" : "authenticated", "sub" : "670b1000-0000-4000-8000-0000000000a1"}
8
+ (1 row)
9
+
10
+ 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());
11
+ 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);
12
+ set_config|set_config|set_config
13
+ ----------+----------+--------------------------------------------------------------------------
14
+ | |{"role" : "authenticated", "sub" : "670b1000-0000-4000-8000-0000000000a1"}
15
+ (1 row)
16
+
17
+ 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()); <waiting ...>
18
+ 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;
19
+ locktype|mode
20
+ --------+-------------
21
+ advisory|ExclusiveLock
22
+ (1 row)
23
+
24
+ step p_commit: commit;
25
+ step w_post: <... completed>
26
+ step w_commit: commit;
27
+ step check:
28
+ select (select count(*) from agent_board.messages where thread_id in ('670b1000-0000-4000-8000-000000000010')) as messages,
29
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b1000-0000-4000-8000-000000000010')) as receipts,
30
+ (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,
31
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso1_ret r) as returned_by,
32
+ (select count(distinct r.message_id) from public.so670_iso1_ret r) as distinct_returned,
33
+ (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;
34
+
35
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
36
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
37
+ 1| 1|post_board_message:so670-iso1-x-a|p,w | 1|t
38
+ (1 row)
39
+
40
+ 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';
41
+ b_deliveries
42
+ ------------
43
+ 1
44
+ (1 row)
45
+
46
+
47
+ starting permutation: p_begin p_post w_begin w_post m_lockwait p_rollback w_commit check b_deliveries
48
+ 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);
49
+ set_config|set_config|set_config
50
+ ----------+----------+--------------------------------------------------------------------------
51
+ | |{"role" : "authenticated", "sub" : "670b1000-0000-4000-8000-0000000000a1"}
52
+ (1 row)
53
+
54
+ 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());
55
+ 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);
56
+ set_config|set_config|set_config
57
+ ----------+----------+--------------------------------------------------------------------------
58
+ | |{"role" : "authenticated", "sub" : "670b1000-0000-4000-8000-0000000000a1"}
59
+ (1 row)
60
+
61
+ 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()); <waiting ...>
62
+ 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;
63
+ locktype|mode
64
+ --------+-------------
65
+ advisory|ExclusiveLock
66
+ (1 row)
67
+
68
+ step p_rollback: rollback;
69
+ step w_post: <... completed>
70
+ step w_commit: commit;
71
+ step check:
72
+ select (select count(*) from agent_board.messages where thread_id in ('670b1000-0000-4000-8000-000000000010')) as messages,
73
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b1000-0000-4000-8000-000000000010')) as receipts,
74
+ (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,
75
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso1_ret r) as returned_by,
76
+ (select count(distinct r.message_id) from public.so670_iso1_ret r) as distinct_returned,
77
+ (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;
78
+
79
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
80
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
81
+ 1| 1|post_board_message:so670-iso1-x-a|w | 1|t
82
+ (1 row)
83
+
84
+ 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';
85
+ b_deliveries
86
+ ------------
87
+ 1
88
+ (1 row)
89
+
@@ -0,0 +1,87 @@
1
+ Parsed test spec with 3 sessions
2
+
3
+ starting permutation: r_read p_begin p_post r_read p_commit r_read check
4
+ set_config
5
+ --------------------------------------------------------------------------
6
+ {"role" : "authenticated", "sub" : "670b2000-0000-4000-8000-0000000000a1"}
7
+ (1 row)
8
+
9
+ step r_read: select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message');
10
+ status
11
+ -------
12
+ unknown
13
+ (1 row)
14
+
15
+ 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);
16
+ set_config|set_config|set_config
17
+ ----------+----------+--------------------------------------------------------------------------
18
+ | |{"role" : "authenticated", "sub" : "670b2000-0000-4000-8000-0000000000a1"}
19
+ (1 row)
20
+
21
+ 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());
22
+ step r_read: select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message');
23
+ status
24
+ -------
25
+ unknown
26
+ (1 row)
27
+
28
+ step p_commit: commit;
29
+ step r_read: select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message');
30
+ status
31
+ ---------
32
+ confirmed
33
+ (1 row)
34
+
35
+ step check:
36
+ select (select count(*) from agent_board.messages where thread_id in ('670b2000-0000-4000-8000-000000000010')) as messages,
37
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b2000-0000-4000-8000-000000000010')) as receipts,
38
+ (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,
39
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso2_ret r) as returned_by,
40
+ (select count(distinct r.message_id) from public.so670_iso2_ret r) as distinct_returned,
41
+ (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;
42
+
43
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
44
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
45
+ 1| 1|post_board_message:so670-iso2-x-a|p | 1|t
46
+ (1 row)
47
+
48
+
49
+ starting permutation: p_begin p_post r_read p_rollback r_read check
50
+ set_config
51
+ --------------------------------------------------------------------------
52
+ {"role" : "authenticated", "sub" : "670b2000-0000-4000-8000-0000000000a1"}
53
+ (1 row)
54
+
55
+ 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);
56
+ set_config|set_config|set_config
57
+ ----------+----------+--------------------------------------------------------------------------
58
+ | |{"role" : "authenticated", "sub" : "670b2000-0000-4000-8000-0000000000a1"}
59
+ (1 row)
60
+
61
+ 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());
62
+ step r_read: select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message');
63
+ status
64
+ -------
65
+ unknown
66
+ (1 row)
67
+
68
+ step p_rollback: rollback;
69
+ step r_read: select status from agent_board.get_send_outcome('670b2000-0000-4000-8000-000000000010','K','post_board_message');
70
+ status
71
+ -------
72
+ unknown
73
+ (1 row)
74
+
75
+ step check:
76
+ select (select count(*) from agent_board.messages where thread_id in ('670b2000-0000-4000-8000-000000000010')) as messages,
77
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b2000-0000-4000-8000-000000000010')) as receipts,
78
+ (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,
79
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso2_ret r) as returned_by,
80
+ (select count(distinct r.message_id) from public.so670_iso2_ret r) as distinct_returned,
81
+ (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;
82
+
83
+ messages|receipts|receipt_owners|returned_by|distinct_returned|every_returned_has_receipt
84
+ --------+--------+--------------+-----------+-----------------+--------------------------
85
+ 0| 0| | | 0|f
86
+ (1 row)
87
+
@@ -0,0 +1,107 @@
1
+ Parsed test spec with 4 sessions
2
+
3
+ starting permutation: p_post fanout l_begin l_leave r_read l_commit r_read fanout check
4
+ set_config
5
+ --------------------------------------------------------------------------
6
+ {"role" : "authenticated", "sub" : "670b5000-0000-4000-8000-0000000000c1"}
7
+ (1 row)
8
+
9
+ 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());
10
+ 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;
11
+ deliveries|inbox|receipts
12
+ ----------+-----+--------
13
+ 2| 2| 1
14
+ (1 row)
15
+
16
+ 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);
17
+ set_config|set_config|set_config
18
+ ----------+----------+--------------------------------------------------------------------------
19
+ | |{"role" : "authenticated", "sub" : "670b5000-0000-4000-8000-0000000000c1"}
20
+ (1 row)
21
+
22
+ 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());
23
+ left_rows
24
+ ---------
25
+ 1
26
+ (1 row)
27
+
28
+ step r_read: select status from agent_board.get_send_outcome('670b5000-0000-4000-8000-000000000012','K','post_board_message');
29
+ status
30
+ ---------
31
+ confirmed
32
+ (1 row)
33
+
34
+ step l_commit: commit;
35
+ step r_read: select status from agent_board.get_send_outcome('670b5000-0000-4000-8000-000000000012','K','post_board_message');
36
+ status
37
+ ---------
38
+ confirmed
39
+ (1 row)
40
+
41
+ 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;
42
+ deliveries|inbox|receipts
43
+ ----------+-----+--------
44
+ 2| 2| 1
45
+ (1 row)
46
+
47
+ step check:
48
+ select (select count(*) from agent_board.messages where thread_id in ('670b5000-0000-4000-8000-000000000012')) as messages,
49
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b5000-0000-4000-8000-000000000012')) as receipts,
50
+ (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,
51
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso5_ret r) as returned_by,
52
+ (select count(distinct r.message_id) from public.so670_iso5_ret r) as distinct_returned,
53
+ (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;
54
+
55
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
56
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
57
+ 1| 1|post_board_message:so670-iso5-x-m|p | 1|t
58
+ (1 row)
59
+
60
+
61
+ starting permutation: p_post fanout d_begin d_delete r_read d_commit r_read fanout check
62
+ set_config
63
+ --------------------------------------------------------------------------
64
+ {"role" : "authenticated", "sub" : "670b5000-0000-4000-8000-0000000000c1"}
65
+ (1 row)
66
+
67
+ 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());
68
+ 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;
69
+ deliveries|inbox|receipts
70
+ ----------+-----+--------
71
+ 2| 2| 1
72
+ (1 row)
73
+
74
+ step d_begin: begin;
75
+ step d_delete: delete from agent_board.messages where thread_id = '670b5000-0000-4000-8000-000000000012';
76
+ step r_read: select status from agent_board.get_send_outcome('670b5000-0000-4000-8000-000000000012','K','post_board_message');
77
+ status
78
+ ---------
79
+ confirmed
80
+ (1 row)
81
+
82
+ step d_commit: commit;
83
+ step r_read: select status from agent_board.get_send_outcome('670b5000-0000-4000-8000-000000000012','K','post_board_message');
84
+ status
85
+ -------
86
+ unknown
87
+ (1 row)
88
+
89
+ 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;
90
+ deliveries|inbox|receipts
91
+ ----------+-----+--------
92
+ 0| 0| 0
93
+ (1 row)
94
+
95
+ step check:
96
+ select (select count(*) from agent_board.messages where thread_id in ('670b5000-0000-4000-8000-000000000012')) as messages,
97
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b5000-0000-4000-8000-000000000012')) as receipts,
98
+ (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,
99
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso5_ret r) as returned_by,
100
+ (select count(distinct r.message_id) from public.so670_iso5_ret r) as distinct_returned,
101
+ (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;
102
+
103
+ messages|receipts|receipt_owners|returned_by|distinct_returned|every_returned_has_receipt
104
+ --------+--------+--------------+-----------+-----------------+--------------------------
105
+ 0| 0| |p | 1|f
106
+ (1 row)
107
+
@@ -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"