@consiliency/agent-board-schema 1.74.0 → 1.76.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 (96) hide show
  1. package/fixtures/already-applied.json +8 -0
  2. package/migrations/20261108000100_agent_board_send_outcome.sql +708 -0
  3. package/migrations/20261109000100_agent_board_step_up_groundwork.sql +343 -0
  4. package/package.json +1 -1
  5. package/schema-manifest.json +21 -3
  6. package/src/deployment-drift-main.test.mjs +20 -3
  7. package/src/deployment-drift-script.test.mjs +77 -2
  8. package/src/deployment-drift.test.mjs +60 -0
  9. package/src/tooling.test.mjs +4 -2
  10. package/tests/agent_board_667_history_class.test.sql +2 -0
  11. package/tests/agent_board_717_native_surface.test.sql +223 -0
  12. package/tests/agent_board_delegate_role_class.test.sql +2 -2
  13. package/tests/agent_board_delivery_writer_execute.test.sql +4 -2
  14. package/tests/agent_board_enrollment_audit_content.test.sql +6 -1
  15. package/tests/agent_board_hosted_delegates.test.sql +8 -1
  16. package/tests/agent_board_send_outcome.test.sql +805 -0
  17. package/tests/agent_board_step_up_helper.test.sql +711 -0
  18. package/tests/agent_board_write_enforcement_class.test.sql +12 -5
  19. package/tests/catalog/function_execute_privileges.json +96 -0
  20. package/tests/catalog/p_metadata_parameters.json +40 -0
  21. package/tests/fixtures/isolation-substrate.sql +8 -0
  22. package/tests/fixtures/pgtap-unexposed.sql +61 -0
  23. package/tests/isolation/expected/send_outcome_cross_board.out +40 -0
  24. package/tests/isolation/expected/send_outcome_independence.out +295 -0
  25. package/tests/isolation/expected/send_outcome_membership.out +140 -0
  26. package/tests/isolation/expected/send_outcome_overlap.out +89 -0
  27. package/tests/isolation/expected/send_outcome_reader.out +87 -0
  28. package/tests/isolation/expected/send_outcome_recovery.out +107 -0
  29. package/tests/isolation/specs/send_outcome_cross_board.spec +66 -0
  30. package/tests/isolation/specs/send_outcome_independence.spec +95 -0
  31. package/tests/isolation/specs/send_outcome_membership.spec +73 -0
  32. package/tests/isolation/specs/send_outcome_overlap.spec +69 -0
  33. package/tests/isolation/specs/send_outcome_reader.spec +61 -0
  34. package/tests/isolation/specs/send_outcome_recovery.spec +68 -0
  35. package/tests/mutations/669/M10_service_role_blanket.sql +10 -0
  36. package/tests/mutations/669/M12a_no_parse_wrapper.sql +17 -0
  37. package/tests/mutations/669/M12b_no_session_wrapper.sql +23 -0
  38. package/tests/mutations/669/M12c_no_claim_type_guard.sql +13 -0
  39. package/tests/mutations/669/M12d_no_amr_element_guards.sql +15 -0
  40. package/tests/mutations/669/M14_now_not_clock.sql +9 -0
  41. package/tests/mutations/669/M15_classifier_reads_metadata.sql +17 -0
  42. package/tests/mutations/669/M17_skip_ledger.sql +15 -0
  43. package/tests/mutations/669/M18_service_role_sub_insensitive.sql +9 -0
  44. package/tests/mutations/669/M18b_drop_uid_conjunct.sql +9 -0
  45. package/tests/mutations/669/M23_definer_wrapper_over_writer.sql +5 -0
  46. package/tests/mutations/669/M3_age_from_iat.sql +9 -0
  47. package/tests/mutations/669/M4_window_900.sql +9 -0
  48. package/tests/mutations/669/M4b_lt_to_le.sql +9 -0
  49. package/tests/mutations/669/M5_no_skew_bound.sql +9 -0
  50. package/tests/mutations/669/M6a_user_metadata_amr.sql +9 -0
  51. package/tests/mutations/669/M6b_app_metadata_claim.sql +9 -0
  52. package/tests/mutations/669/M6c_legacy_guc.sql +9 -0
  53. package/tests/mutations/669/M7_either_claim_any_human.sql +9 -0
  54. package/tests/mutations/669/M8_any_amr_method.sql +9 -0
  55. package/tests/mutations/669/M8b_accept_aal2.sql +9 -0
  56. package/tests/mutations/669/M9_every_kind.sql +9 -0
  57. package/tests/mutations/669/MAL_allowlist_nonempty.sql +9 -0
  58. package/tests/mutations/669/MAR_writer_arg_renamed.sql +14 -0
  59. package/tests/mutations/669/MAU_audit_mode_retyped.sql +2 -0
  60. package/tests/mutations/669/MA_helper_always_raises.sql +10 -0
  61. package/tests/mutations/669/MDX_dynamic_execute_definer.sql +5 -0
  62. package/tests/mutations/669/MD_detail_carries_value.sql +12 -0
  63. package/tests/mutations/669/MEC0_caller_of_helper.sql +4 -0
  64. package/tests/mutations/669/MEC0b_overload_caller.sql +4 -0
  65. package/tests/mutations/669/MG1_helper_granted_authenticated.sql +2 -0
  66. package/tests/mutations/669/MG2_ledger_insert_authenticated.sql +2 -0
  67. package/tests/mutations/669/MG3_ledger_policy.sql +2 -0
  68. package/tests/mutations/669/MR1_writer_no_class_check.sql +9 -0
  69. package/tests/mutations/669/MR2_writer_wide_window.sql +9 -0
  70. package/tests/mutations/669/MR3_writer_prunes_everyone.sql +11 -0
  71. package/tests/mutations/669/MR4_writer_lower_exclusive.sql +9 -0
  72. package/tests/mutations/669/MR5_writer_upper_exclusive.sql +9 -0
  73. package/tests/mutations/669/MR6_writer_upper_61.sql +9 -0
  74. package/tests/mutations/669/MW2_second_ledger_writer.sql +4 -0
  75. package/tests/mutations/669/MXS_cross_schema_wrapper.sql +4 -0
  76. package/tests/mutations/669/run.sh +72 -0
  77. package/tests/mutations/670/E1_helper_author_from_message.sql +7 -0
  78. package/tests/mutations/670/E2_helper_no_null_check.sql +13 -0
  79. package/tests/mutations/670/M10_lock_removed.sql +10 -0
  80. package/tests/mutations/670/M11_table_granted_to_authenticated.sql +2 -0
  81. package/tests/mutations/670/M12_helper_granted_to_service_role.sql +2 -0
  82. package/tests/mutations/670/M13_message_fk_no_cascade.sql +8 -0
  83. package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +11 -0
  84. package/tests/mutations/670/M15_second_receipt_writer.sql +9 -0
  85. package/tests/mutations/670/M16_read_no_btrim.sql +7 -0
  86. package/tests/mutations/670/M17_read_volatile.sql +2 -0
  87. package/tests/mutations/670/M1_helper_no_service_role_guard.sql +13 -0
  88. package/tests/mutations/670/M3_helper_on_replay_branch.sql +10 -0
  89. package/tests/mutations/670/M4_read_checks_thread_existence.sql +10 -0
  90. package/tests/mutations/670/M5a_read_requires_thread_access.sql +10 -0
  91. package/tests/mutations/670/M5b_read_requires_board_membership.sql +11 -0
  92. package/tests/mutations/670/M6_read_admits_service_role.sql +14 -0
  93. package/tests/mutations/670/M7_confirmed_adds_message_sequence.sql +12 -0
  94. package/tests/mutations/670/M8_delivery_swallows_errors.sql +19 -0
  95. package/tests/mutations/670/M9_lock_key_includes_board.sql +10 -0
  96. package/tests/mutations/670/run.sh +84 -0
@@ -432,10 +432,16 @@ 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.
438
+ -- 65 -> 66 with #669 PR-A's agent_board.portal_step_up_proofs (20261109000100). Its only writer,
439
+ -- record_portal_step_up, is EXECUTE-able by service_role only and is called by no function, so
440
+ -- it adds no member to the `authenticated` writer population and WEC-2's set is unchanged.
435
441
  select is(
436
442
  (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');
443
+ '66',
444
+ '#325 canary: agent_board has 66 base tables — the universe the write scan runs over, pinned so an empty violating set below cannot mean an empty universe');
439
445
 
440
446
  -- WEC-2. The relations the class writes, as an EXACT SET. A new one names itself.
441
447
  select is(
@@ -479,13 +485,14 @@ select is(
479
485
  'presence',
480
486
  'read_receipts',
481
487
  'send_authz_telemetry',
488
+ 'send_outcomes',
482
489
  'session_id_aliases',
483
490
  'session_identities',
484
491
  'task_events',
485
492
  'tasks',
486
493
  'threads'
487
494
  ]::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');
495
+ '#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
496
 
490
497
  -- WEC-3. The class itself, as an EXACT SET of SIGNATURES, and it is signatures rather than
491
498
  -- `count(*) = 59` for two reasons. The routine response to a red count is to bump the count,
@@ -1039,8 +1046,8 @@ select is(
1039
1046
  from _wec_class_tables t
1040
1047
  join pg_constraint con on con.conrelid = t.reloid
1041
1048
  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');
1049
+ '93',
1050
+ '#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
1051
 
1045
1052
  -- ===========================================================================================
1046
1053
  -- 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)",
@@ -775,6 +784,15 @@
775
784
  "authenticated": false
776
785
  }
777
786
  },
787
+ {
788
+ "name": "_require_human_step_up",
789
+ "signature": "_require_human_step_up(p_operation text)",
790
+ "executable_by": {
791
+ "anon": false,
792
+ "service_role": false,
793
+ "authenticated": false
794
+ }
795
+ },
778
796
  {
779
797
  "name": "_require_platform_admin_user_id",
780
798
  "signature": "_require_platform_admin_user_id()",
@@ -955,6 +973,60 @@
955
973
  "authenticated": false
956
974
  }
957
975
  },
976
+ {
977
+ "name": "_step_up_amr_methods",
978
+ "signature": "_step_up_amr_methods()",
979
+ "executable_by": {
980
+ "anon": false,
981
+ "service_role": false,
982
+ "authenticated": false
983
+ }
984
+ },
985
+ {
986
+ "name": "_step_up_future_skew_seconds",
987
+ "signature": "_step_up_future_skew_seconds()",
988
+ "executable_by": {
989
+ "anon": false,
990
+ "service_role": false,
991
+ "authenticated": false
992
+ }
993
+ },
994
+ {
995
+ "name": "_step_up_is_fresh",
996
+ "signature": "_step_up_is_fresh(p_proof numeric, p_now numeric)",
997
+ "executable_by": {
998
+ "anon": false,
999
+ "service_role": false,
1000
+ "authenticated": false
1001
+ }
1002
+ },
1003
+ {
1004
+ "name": "_step_up_is_portal_human",
1005
+ "signature": "_step_up_is_portal_human(p_agent_id uuid)",
1006
+ "executable_by": {
1007
+ "anon": false,
1008
+ "service_role": false,
1009
+ "authenticated": false
1010
+ }
1011
+ },
1012
+ {
1013
+ "name": "_step_up_max_age_seconds",
1014
+ "signature": "_step_up_max_age_seconds()",
1015
+ "executable_by": {
1016
+ "anon": false,
1017
+ "service_role": false,
1018
+ "authenticated": false
1019
+ }
1020
+ },
1021
+ {
1022
+ "name": "_step_up_proof_recordable",
1023
+ "signature": "_step_up_proof_recordable(p_proof numeric, p_now numeric)",
1024
+ "executable_by": {
1025
+ "anon": false,
1026
+ "service_role": false,
1027
+ "authenticated": false
1028
+ }
1029
+ },
958
1030
  {
959
1031
  "name": "_trim_inbox_text",
960
1032
  "signature": "_trim_inbox_text(p_value text, p_max_length integer)",
@@ -1270,6 +1342,15 @@
1270
1342
  "authenticated": true
1271
1343
  }
1272
1344
  },
1345
+ {
1346
+ "name": "get_send_outcome",
1347
+ "signature": "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
1348
+ "executable_by": {
1349
+ "anon": false,
1350
+ "service_role": false,
1351
+ "authenticated": true
1352
+ }
1353
+ },
1273
1354
  {
1274
1355
  "name": "get_session_identity_state",
1275
1356
  "signature": "get_session_identity_state(p_identity_agent_id uuid)",
@@ -1612,6 +1693,15 @@
1612
1693
  "authenticated": false
1613
1694
  }
1614
1695
  },
1696
+ {
1697
+ "name": "record_portal_step_up",
1698
+ "signature": "record_portal_step_up(p_agent_id uuid, p_proof_at bigint)",
1699
+ "executable_by": {
1700
+ "anon": false,
1701
+ "service_role": true,
1702
+ "authenticated": false
1703
+ }
1704
+ },
1615
1705
  {
1616
1706
  "name": "record_session_identity_state",
1617
1707
  "signature": "record_session_identity_state(p_identity_agent_id uuid, p_fingerprint jsonb)",
@@ -2434,6 +2524,11 @@
2434
2524
  "name": "create_or_find_thread",
2435
2525
  "signature": "create_or_find_thread(uuid, text, text, text, jsonb)"
2436
2526
  },
2527
+ {
2528
+ "kind": "rpc",
2529
+ "name": "get_send_outcome",
2530
+ "signature": "get_send_outcome(uuid, text, text)"
2531
+ },
2437
2532
  {
2438
2533
  "kind": "rpc",
2439
2534
  "name": "post_board_message",
@@ -2458,6 +2553,7 @@
2458
2553
  "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
2554
  "current_agent_id()",
2460
2555
  "get_schema_version()",
2556
+ "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
2461
2557
  "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
2558
  "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
2559
  "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
@@ -345,6 +349,10 @@
345
349
  "signature": "_refuse_delegate_membership_target(p_agent_id uuid, p_operation text)",
346
350
  "declares_p_metadata": false
347
351
  },
352
+ {
353
+ "signature": "_require_human_step_up(p_operation text)",
354
+ "declares_p_metadata": false
355
+ },
348
356
  {
349
357
  "signature": "_require_platform_admin_user_id()",
350
358
  "declares_p_metadata": false
@@ -425,6 +433,30 @@
425
433
  "signature": "_signed_write_actor_id(p_payload jsonb, p_gateway_decision jsonb, p_actor_field text)",
426
434
  "declares_p_metadata": false
427
435
  },
436
+ {
437
+ "signature": "_step_up_amr_methods()",
438
+ "declares_p_metadata": false
439
+ },
440
+ {
441
+ "signature": "_step_up_future_skew_seconds()",
442
+ "declares_p_metadata": false
443
+ },
444
+ {
445
+ "signature": "_step_up_is_fresh(p_proof numeric, p_now numeric)",
446
+ "declares_p_metadata": false
447
+ },
448
+ {
449
+ "signature": "_step_up_is_portal_human(p_agent_id uuid)",
450
+ "declares_p_metadata": false
451
+ },
452
+ {
453
+ "signature": "_step_up_max_age_seconds()",
454
+ "declares_p_metadata": false
455
+ },
456
+ {
457
+ "signature": "_step_up_proof_recordable(p_proof numeric, p_now numeric)",
458
+ "declares_p_metadata": false
459
+ },
428
460
  {
429
461
  "signature": "_trim_inbox_text(p_value text, p_max_length integer)",
430
462
  "declares_p_metadata": false
@@ -565,6 +597,10 @@
565
597
  "signature": "get_schema_version()",
566
598
  "declares_p_metadata": false
567
599
  },
600
+ {
601
+ "signature": "get_send_outcome(p_thread_id uuid, p_idempotency_key text, p_operation text)",
602
+ "declares_p_metadata": false
603
+ },
568
604
  {
569
605
  "signature": "get_session_identity_state(p_identity_agent_id uuid)",
570
606
  "declares_p_metadata": false
@@ -717,6 +753,10 @@
717
753
  "signature": "record_callback_delivery_terminal_failure(p_outbox_event_id uuid, p_endpoint_id uuid, p_http_status integer, p_error_summary text, p_metadata jsonb)",
718
754
  "declares_p_metadata": true
719
755
  },
756
+ {
757
+ "signature": "record_portal_step_up(p_agent_id uuid, p_proof_at bigint)",
758
+ "declares_p_metadata": false
759
+ },
720
760
  {
721
761
  "signature": "record_session_identity_state(p_identity_agent_id uuid, p_fingerprint jsonb)",
722
762
  "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
+