@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
@@ -432,10 +432,13 @@ select distinct p.oid,
432
432
  -- the `authenticated` writer population below.
433
433
  -- SIDSCHEMA adds identities and aliases. Human-owner readmission writes them and
434
434
  -- delegation_grants; these remain in the derived class, not an exemption list.
435
+ -- 64 -> 65 with #670's agent_board.send_outcomes (20261108000100). Its only writer,
436
+ -- _record_send_outcome, is EXECUTE-able by no API role but is reached from the authenticated-
437
+ -- executable message cores, so the relation joins WEC-2's set below.
435
438
  select is(
436
439
  (select count(*)::text from _wec_target where relkind = 'r'),
437
- '64',
438
- '#325 canary: agent_board has 64 base tables — the universe the write scan runs over, pinned so an empty violating set below cannot mean an empty universe');
440
+ '65',
441
+ '#325 canary: agent_board has 65 base tables — the universe the write scan runs over, pinned so an empty violating set below cannot mean an empty universe');
439
442
 
440
443
  -- WEC-2. The relations the class writes, as an EXACT SET. A new one names itself.
441
444
  select is(
@@ -479,13 +482,14 @@ select is(
479
482
  'presence',
480
483
  'read_receipts',
481
484
  'send_authz_telemetry',
485
+ 'send_outcomes',
482
486
  'session_id_aliases',
483
487
  'session_identities',
484
488
  'task_events',
485
489
  'tasks',
486
490
  'threads'
487
491
  ]::text[],
488
- '#325: these 40 agent_board relations are written by an authenticated-executable function, directly or through a callee — SIDSCHEMA readmission adds grants, identities and aliases without excluding their writers');
492
+ '#325: these 41 agent_board relations are written by an authenticated-executable function, directly or through a callee — SIDSCHEMA readmission adds grants, identities and aliases without excluding their writers; #670 adds send_outcomes through the message cores');
489
493
 
490
494
  -- WEC-3. The class itself, as an EXACT SET of SIGNATURES, and it is signatures rather than
491
495
  -- `count(*) = 59` for two reasons. The routine response to a red count is to bump the count,
@@ -1039,8 +1043,8 @@ select is(
1039
1043
  from _wec_class_tables t
1040
1044
  join pg_constraint con on con.conrelid = t.reloid
1041
1045
  where con.contype = 'f' and con.confdeltype in ('c', 'n', 'd')),
1042
- '92',
1043
- '#325: 92 writing referential actions (78 CASCADE + 14 SET NULL) reach the 40 class relations — the four SIDSCHEMA class additions are positively pinned in WEC-30');
1046
+ '93',
1047
+ '#325: 93 writing referential actions (79 CASCADE + 14 SET NULL) reach the 41 class relations — the four SIDSCHEMA class additions are positively pinned in WEC-30; #670 adds send_outcomes.message_id -> messages ON DELETE CASCADE (an existing parent), which is the receipt''s intended lifetime');
1044
1048
 
1045
1049
  -- ===========================================================================================
1046
1050
  -- WEC-24/25 — THE CROSS-CHECK (Consiliency/message-board#416 / #417 / #424, plan change 9).
@@ -721,6 +721,15 @@
721
721
  "authenticated": false
722
722
  }
723
723
  },
724
+ {
725
+ "name": "_record_send_outcome",
726
+ "signature": "_record_send_outcome(p_operation text, p_message_id uuid, p_idempotency_key text, p_board_id uuid)",
727
+ "executable_by": {
728
+ "anon": false,
729
+ "service_role": false,
730
+ "authenticated": false
731
+ }
732
+ },
724
733
  {
725
734
  "name": "_record_signed_write_evidence",
726
735
  "signature": "_record_signed_write_evidence(p_source_kind text, p_source_id uuid, p_operation text, p_payload jsonb, p_gateway_decision jsonb)",
@@ -1270,6 +1279,15 @@
1270
1279
  "authenticated": true
1271
1280
  }
1272
1281
  },
1282
+ {
1283
+ "name": "get_send_outcome",
1284
+ "signature": "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
1285
+ "executable_by": {
1286
+ "anon": false,
1287
+ "service_role": false,
1288
+ "authenticated": true
1289
+ }
1290
+ },
1273
1291
  {
1274
1292
  "name": "get_session_identity_state",
1275
1293
  "signature": "get_session_identity_state(p_identity_agent_id uuid)",
@@ -2434,6 +2452,11 @@
2434
2452
  "name": "create_or_find_thread",
2435
2453
  "signature": "create_or_find_thread(uuid, text, text, text, jsonb)"
2436
2454
  },
2455
+ {
2456
+ "kind": "rpc",
2457
+ "name": "get_send_outcome",
2458
+ "signature": "get_send_outcome(uuid, text, text)"
2459
+ },
2437
2460
  {
2438
2461
  "kind": "rpc",
2439
2462
  "name": "post_board_message",
@@ -2458,6 +2481,7 @@
2458
2481
  "create_or_find_thread(p_created_by_agent_id uuid, p_subject text, p_idempotency_key text, p_thread_type text, p_metadata jsonb)",
2459
2482
  "current_agent_id()",
2460
2483
  "get_schema_version()",
2484
+ "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
2461
2485
  "post_board_message(p_thread_id uuid, p_author_agent_id uuid, p_board_id uuid, p_subject text, p_body text, p_message_type text, p_priority text, p_idempotency_key text, p_metadata jsonb)",
2462
2486
  "post_board_message(p_thread_id uuid, p_author_agent_id uuid, p_board_slug text, p_addressing_mode text, p_subject text, p_body text, p_message_type text, p_priority text, p_idempotency_key text, p_metadata jsonb)",
2463
2487
  "post_message(p_thread_id uuid, p_author_agent_id uuid, p_body text, p_message_type text, p_task_id uuid, p_metadata jsonb)",
@@ -321,6 +321,10 @@
321
321
  "signature": "_record_send_authz_telemetry(p_kind text, p_origin text, p_actor_agent_id uuid, p_board_id uuid, p_operation text, p_scope_key text, p_denial_class text, p_metadata jsonb)",
322
322
  "declares_p_metadata": true
323
323
  },
324
+ {
325
+ "signature": "_record_send_outcome(p_operation text, p_message_id uuid, p_idempotency_key text, p_board_id uuid)",
326
+ "declares_p_metadata": false
327
+ },
324
328
  {
325
329
  "signature": "_record_signed_write_evidence(p_source_kind text, p_source_id uuid, p_operation text, p_payload jsonb, p_gateway_decision jsonb)",
326
330
  "declares_p_metadata": false
@@ -565,6 +569,10 @@
565
569
  "signature": "get_schema_version()",
566
570
  "declares_p_metadata": false
567
571
  },
572
+ {
573
+ "signature": "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
574
+ "declares_p_metadata": false
575
+ },
568
576
  {
569
577
  "signature": "get_session_identity_state(p_identity_agent_id uuid)",
570
578
  "declares_p_metadata": false
@@ -29,6 +29,14 @@
29
29
 
30
30
  create schema if not exists auth;
31
31
  create schema if not exists extensions;
32
+ -- Supabase's own default, nothing broader: its init script grants exactly this
33
+ -- (supabase/postgres 00000000000000-initial-schema.sql), and a live 17.11.0.006
34
+ -- catalog shows `extensions` nspacl anon=U, authenticated=U, service_role=U.
35
+ -- pgTAP lives here (message-board#741), so a test that does `set local role
36
+ -- authenticated|service_role` and then calls pgTAP aborts without it. USAGE is
37
+ -- not exposure: PostgREST serves only its configured schemas (public,
38
+ -- graphql_public), and `extensions` is not one of them.
39
+ grant usage on schema extensions to anon, authenticated, service_role;
32
40
 
33
41
  create extension if not exists pgcrypto with schema extensions;
34
42
  create extension if not exists "uuid-ossp" with schema extensions;
@@ -0,0 +1,61 @@
1
+ -- Install pgTAP where PostgREST does not serve it, or refuse (message-board#741, #717 #715).
2
+ --
3
+ -- WHY. pgTAP's single-unnamed-`text` routines (`lives_ok(text)`, `throws_ok(text)`, `is_empty(text)`, …)
4
+ -- EXECUTE caller SQL. Installed into `public`, which PostgREST exposes, they were an HTTP route: with
5
+ -- the anon key, `rpc/no_plan` then `rpc/lives_ok` ran a DO block that did `SET LOCAL ROLE service_role`
6
+ -- (authenticator holds SET on it) and read agent_board (plans/evidence/717-native/). `extensions` is
7
+ -- on PostgREST's extra search path but is not an exposed schema, so nothing in it is an rpc route.
8
+ --
9
+ -- WHY NOT `create extension if not exists pgtap with schema extensions` ALONE. When pgTAP already
10
+ -- exists, IF NOT EXISTS returns before WITH SCHEMA is considered: an existing `public` install stays
11
+ -- exactly where it is and the statement reports success. Every database the old runner touched has
12
+ -- it there. So an existing install in any other schema is relocated if this session may
13
+ -- (`ALTER EXTENSION … SET SCHEMA` needs the extension's owner; pgtap.control is relocatable = true),
14
+ -- and otherwise REFUSED with the command that resolves it. It is never dropped: a shared cluster's
15
+ -- other tenants may be using it.
16
+ --
17
+ -- The post-conditions are checked, not assumed: pgTAP ends in `extensions`, and resolves on this
18
+ -- session's search_path (the 90-odd test files that set no search_path rely on the role default).
19
+ do $pgtap$
20
+ declare
21
+ v_schema text;
22
+ v_owner regrole;
23
+ v_may boolean;
24
+ begin
25
+ if to_regnamespace('extensions') is null then
26
+ raise exception 'pgTAP prerequisite: schema "extensions" does not exist in database %', current_database()
27
+ using errcode = '55000',
28
+ hint = 'Run against a Supabase-shaped database, or apply tests/fixtures/isolation-substrate.sql first.';
29
+ end if;
30
+
31
+ select e.extnamespace::regnamespace::text, e.extowner::regrole
32
+ into v_schema, v_owner
33
+ from pg_extension e where e.extname = 'pgtap';
34
+
35
+ if v_schema is null then
36
+ create extension pgtap with schema extensions;
37
+ elsif v_schema <> 'extensions' then
38
+ select r.rolsuper or pg_has_role(current_user, v_owner, 'USAGE')
39
+ into v_may from pg_roles r where r.rolname = current_user;
40
+ if not v_may then
41
+ raise exception 'pgTAP is installed in schema "%" (owner %); this runner will not run against it there', v_schema, v_owner
42
+ using errcode = '42501',
43
+ detail = 'An exposed schema makes pgTAP''s caller-SQL routines a PostgREST route (message-board#741). '
44
+ || current_user || ' does not own the extension, so it cannot relocate it.',
45
+ hint = format('As %s (the extension owner): ALTER EXTENSION pgtap SET SCHEMA extensions;', v_owner);
46
+ end if;
47
+ alter extension pgtap set schema extensions;
48
+ end if;
49
+
50
+ select e.extnamespace::regnamespace::text into v_schema from pg_extension e where e.extname = 'pgtap';
51
+ if v_schema is distinct from 'extensions' then
52
+ raise exception 'pgTAP post-condition failed: extension schema is %, expected extensions', coalesce(v_schema, '<absent>')
53
+ using errcode = '55000';
54
+ end if;
55
+ if to_regprocedure('plan(integer)') is null then
56
+ raise exception 'pgTAP post-condition failed: plan(integer) does not resolve on search_path %', current_setting('search_path')
57
+ using errcode = '55000',
58
+ hint = 'Put extensions on this role''s search_path (Supabase sets "$user", public, extensions for postgres).';
59
+ end if;
60
+ end
61
+ $pgtap$;
@@ -0,0 +1,40 @@
1
+ Parsed test spec with 4 sessions
2
+
3
+ starting permutation: p_begin p_post w_begin w_post_y m_lockwait p_commit w_end check
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','670b6000-0000-4000-8000-0000000000a1')::text,true);
5
+ set_config|set_config|set_config
6
+ ----------+----------+--------------------------------------------------------------------------
7
+ | |{"role" : "authenticated", "sub" : "670b6000-0000-4000-8000-0000000000a1"}
8
+ (1 row)
9
+
10
+ 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());
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','670b6000-0000-4000-8000-0000000000a1')::text,true);
12
+ set_config|set_config|set_config
13
+ ----------+----------+--------------------------------------------------------------------------
14
+ | |{"role" : "authenticated", "sub" : "670b6000-0000-4000-8000-0000000000a1"}
15
+ (1 row)
16
+
17
+ 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()); <waiting ...>
18
+ 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;
19
+ locktype|mode
20
+ --------+-------------
21
+ advisory|ExclusiveLock
22
+ (1 row)
23
+
24
+ step p_commit: commit;
25
+ step w_post_y: <... completed>
26
+ ERROR: thread belongs to a different board
27
+ step w_end: end;
28
+ step check:
29
+ select (select count(*) from agent_board.messages where thread_id in ('670b6000-0000-4000-8000-000000000010')) as messages,
30
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b6000-0000-4000-8000-000000000010')) as receipts,
31
+ (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,
32
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso6_ret r) as returned_by,
33
+ (select count(distinct r.message_id) from public.so670_iso6_ret r) as distinct_returned,
34
+ (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;
35
+
36
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
37
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
38
+ 1| 1|post_board_message:so670-iso6-x-a|p | 1|t
39
+ (1 row)
40
+
@@ -0,0 +1,295 @@
1
+ Parsed test spec with 6 sessions
2
+
3
+ starting permutation: p_begin p_post b_begin b_post m_lockwait_b p_commit b_commit check
4
+ seeded
5
+ ------
6
+ 1
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','670b4000-0000-4000-8000-0000000000a1')::text,true);
10
+ set_config|set_config|set_config
11
+ ----------+----------+--------------------------------------------------------------------------
12
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
13
+ (1 row)
14
+
15
+ 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());
16
+ 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);
17
+ set_config|set_config|set_config
18
+ ----------+----------+--------------------------------------------------------------------------
19
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000b1"}
20
+ (1 row)
21
+
22
+ 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()); <waiting ...>
23
+ 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;
24
+ locktype |mode
25
+ -------------+---------
26
+ transactionid|ShareLock
27
+ (1 row)
28
+
29
+ step p_commit: commit;
30
+ step b_post: <... completed>
31
+ step b_commit: commit;
32
+ step check:
33
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
34
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
35
+ (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,
36
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
37
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
38
+ (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;
39
+
40
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
41
+ --------+--------+-------------------------------------------------------------------+-----------+-----------------+--------------------------
42
+ 3| 2|post_board_message:so670-iso4-x-a,post_board_message:so670-iso4-x-b|b,p | 2|t
43
+ (1 row)
44
+
45
+
46
+ starting permutation: p_begin p_post w_begin w_dm m_lockwait_w p_commit w_commit check
47
+ seeded
48
+ ------
49
+ 1
50
+ (1 row)
51
+
52
+ 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);
53
+ set_config|set_config|set_config
54
+ ----------+----------+--------------------------------------------------------------------------
55
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
56
+ (1 row)
57
+
58
+ 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());
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
+ set_config|set_config|set_config
61
+ ----------+----------+--------------------------------------------------------------------------
62
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
63
+ (1 row)
64
+
65
+ 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()); <waiting ...>
66
+ 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;
67
+ locktype |mode
68
+ -------------+---------
69
+ transactionid|ShareLock
70
+ (1 row)
71
+
72
+ step p_commit: commit;
73
+ step w_dm: <... completed>
74
+ step w_commit: commit;
75
+ step check:
76
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
77
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) 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 ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipt_owners,
79
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
80
+ (select count(distinct r.message_id) from public.so670_iso4_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_iso4_ret r) as every_returned_has_receipt;
82
+
83
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
84
+ --------+--------+--------------------------------------------------------------------+-----------+-----------------+--------------------------
85
+ 3| 2|post_board_message:so670-iso4-x-a,send_direct_message:so670-iso4-x-a|p,w | 2|t
86
+ (1 row)
87
+
88
+
89
+ starting permutation: p_begin p_post w_begin w_post_t2 p_commit w_commit check
90
+ seeded
91
+ ------
92
+ 1
93
+ (1 row)
94
+
95
+ 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);
96
+ set_config|set_config|set_config
97
+ ----------+----------+--------------------------------------------------------------------------
98
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
99
+ (1 row)
100
+
101
+ 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());
102
+ 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);
103
+ set_config|set_config|set_config
104
+ ----------+----------+--------------------------------------------------------------------------
105
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
106
+ (1 row)
107
+
108
+ 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());
109
+ step p_commit: commit;
110
+ step w_commit: commit;
111
+ step check:
112
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
113
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
114
+ (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,
115
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
116
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
117
+ (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;
118
+
119
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
120
+ --------+--------+-------------------------------------------------------------------+-----------+-----------------+--------------------------
121
+ 3| 2|post_board_message:so670-iso4-x-a,post_board_message:so670-iso4-x-a|p,w | 2|t
122
+ (1 row)
123
+
124
+
125
+ starting permutation: p_begin p_post w_begin w_slug m_lockwait_w p_commit w_commit check
126
+ seeded
127
+ ------
128
+ 1
129
+ (1 row)
130
+
131
+ 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);
132
+ set_config|set_config|set_config
133
+ ----------+----------+--------------------------------------------------------------------------
134
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
135
+ (1 row)
136
+
137
+ 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());
138
+ 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);
139
+ set_config|set_config|set_config
140
+ ----------+----------+--------------------------------------------------------------------------
141
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
142
+ (1 row)
143
+
144
+ 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()); <waiting ...>
145
+ 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;
146
+ locktype|mode
147
+ --------+-------------
148
+ advisory|ExclusiveLock
149
+ (1 row)
150
+
151
+ step p_commit: commit;
152
+ step w_slug: <... completed>
153
+ step w_commit: commit;
154
+ step check:
155
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
156
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
157
+ (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,
158
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
159
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
160
+ (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;
161
+
162
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
163
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
164
+ 2| 1|post_board_message:so670-iso4-x-a|p,w | 1|t
165
+ (1 row)
166
+
167
+
168
+ starting permutation: p_begin p_post_env1 w_begin w_post_env2 m_lockwait_w p_commit w_commit check
169
+ seeded
170
+ ------
171
+ 1
172
+ (1 row)
173
+
174
+ 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);
175
+ set_config|set_config|set_config
176
+ ----------+----------+--------------------------------------------------------------------------
177
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
178
+ (1 row)
179
+
180
+ 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')));
181
+ 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);
182
+ set_config|set_config|set_config
183
+ ----------+----------+--------------------------------------------------------------------------
184
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
185
+ (1 row)
186
+
187
+ 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'))); <waiting ...>
188
+ 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;
189
+ locktype|mode
190
+ --------+-------------
191
+ advisory|ExclusiveLock
192
+ (1 row)
193
+
194
+ step p_commit: commit;
195
+ step w_post_env2: <... completed>
196
+ step w_commit: commit;
197
+ step check:
198
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
199
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
200
+ (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,
201
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
202
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
203
+ (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;
204
+
205
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
206
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
207
+ 2| 1|post_board_message:so670-iso4-x-a|p,w | 1|t
208
+ (1 row)
209
+
210
+
211
+ starting permutation: s_begin s_signed w_begin w_post m_lockwait_w s_commit w_commit check
212
+ seeded
213
+ ------
214
+ 1
215
+ (1 row)
216
+
217
+ step s_begin: begin; set local role service_role; select set_config('request.jwt.claims',json_build_object('role','service_role')::text,true);
218
+ set_config
219
+ -------------------------
220
+ {"role" : "service_role"}
221
+ (1 row)
222
+
223
+ 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'));
224
+ 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);
225
+ set_config|set_config|set_config
226
+ ----------+----------+--------------------------------------------------------------------------
227
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
228
+ (1 row)
229
+
230
+ 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()); <waiting ...>
231
+ 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;
232
+ locktype|mode
233
+ --------+-------------
234
+ advisory|ExclusiveLock
235
+ (1 row)
236
+
237
+ step s_commit: commit;
238
+ step w_post: <... completed>
239
+ step w_commit: commit;
240
+ step check:
241
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
242
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
243
+ (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,
244
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
245
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
246
+ (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;
247
+
248
+ messages|receipts|receipt_owners|returned_by|distinct_returned|every_returned_has_receipt
249
+ --------+--------+--------------+-----------+-----------------+--------------------------
250
+ 2| 0| |s,w | 1|f
251
+ (1 row)
252
+
253
+
254
+ starting permutation: p_begin p_post s_begin s_signed m_lockwait_s p_commit s_commit check
255
+ seeded
256
+ ------
257
+ 1
258
+ (1 row)
259
+
260
+ 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);
261
+ set_config|set_config|set_config
262
+ ----------+----------+--------------------------------------------------------------------------
263
+ | |{"role" : "authenticated", "sub" : "670b4000-0000-4000-8000-0000000000a1"}
264
+ (1 row)
265
+
266
+ 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());
267
+ step s_begin: begin; set local role service_role; select set_config('request.jwt.claims',json_build_object('role','service_role')::text,true);
268
+ set_config
269
+ -------------------------
270
+ {"role" : "service_role"}
271
+ (1 row)
272
+
273
+ 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')); <waiting ...>
274
+ 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;
275
+ locktype|mode
276
+ --------+-------------
277
+ advisory|ExclusiveLock
278
+ (1 row)
279
+
280
+ step p_commit: commit;
281
+ step s_signed: <... completed>
282
+ step s_commit: commit;
283
+ step check:
284
+ select (select count(*) from agent_board.messages where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as messages,
285
+ (select count(*) from agent_board.send_outcomes where thread_id in ('670b4000-0000-4000-8000-000000000010','670b4000-0000-4000-8000-000000000011')) as receipts,
286
+ (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,
287
+ (select string_agg(r.s, ',' order by r.s) from public.so670_iso4_ret r) as returned_by,
288
+ (select count(distinct r.message_id) from public.so670_iso4_ret r) as distinct_returned,
289
+ (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;
290
+
291
+ messages|receipts|receipt_owners |returned_by|distinct_returned|every_returned_has_receipt
292
+ --------+--------+---------------------------------+-----------+-----------------+--------------------------
293
+ 2| 1|post_board_message:so670-iso4-x-a|p,s | 1|t
294
+ (1 row)
295
+