@consiliency/agent-board-schema 1.68.0 → 1.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/fixtures/already-applied.json +32 -4
  2. package/migrations/20261026000100_agent_board_thread_association.sql +1287 -0
  3. package/migrations/20261101000100_agent_board_session_measured_mint.sql +145 -0
  4. package/migrations/20261104065658_agent_board_reply_delivery.sql +659 -0
  5. package/migrations/20261104170000_agent_board_tasking_replay_scope.sql +320 -0
  6. package/migrations/20261104180000_agent_board_delivery_writer_execute.sql +51 -0
  7. package/migrations/20261104190000_agent_board_message_replay_scope.sql +373 -0
  8. package/migrations/20261108000100_agent_board_send_outcome.sql +708 -0
  9. package/package.json +1 -1
  10. package/schema-manifest.json +66 -3
  11. package/src/deployment-drift-main.test.mjs +20 -3
  12. package/src/deployment-drift-script.test.mjs +77 -2
  13. package/src/deployment-drift.test.mjs +60 -0
  14. package/src/tooling.test.mjs +9 -2
  15. package/tests/agent_board_661_reply_delivery.test.sql +185 -0
  16. package/tests/agent_board_667_boundary.test.sql +162 -0
  17. package/tests/agent_board_667_conversion_branches.test.sql +91 -0
  18. package/tests/agent_board_667_conversion_profile.test.sql +112 -0
  19. package/tests/agent_board_667_history_class.test.sql +787 -0
  20. package/tests/agent_board_667_native_cast_effect.test.sql +88 -0
  21. package/tests/agent_board_667_realtime_apply_behavior.test.sql +117 -0
  22. package/tests/agent_board_667_realtime_apply_controls.test.sql +143 -0
  23. package/tests/agent_board_667_realtime_apply_profile.test.sql +61 -0
  24. package/tests/agent_board_667_retention.test.sql +201 -0
  25. package/tests/agent_board_667_routing.test.sql +294 -0
  26. package/tests/agent_board_667_sender_effects.test.sql +100 -0
  27. package/tests/agent_board_667_sender_profile_controls.test.sql +29 -0
  28. package/tests/agent_board_667_storage_delimiter_behavior.test.sql +84 -0
  29. package/tests/agent_board_667_storage_delimiter_controls.test.sql +23 -0
  30. package/tests/agent_board_667_storage_delimiter_profile.test.sql +61 -0
  31. package/tests/agent_board_667_storage_search_behavior.test.sql +93 -0
  32. package/tests/agent_board_667_storage_search_controls.test.sql +22 -0
  33. package/tests/agent_board_667_storage_search_profile.test.sql +60 -0
  34. package/tests/agent_board_667_storage_timestamp_behavior.test.sql +58 -0
  35. package/tests/agent_board_667_storage_timestamp_controls.test.sql +22 -0
  36. package/tests/agent_board_667_storage_timestamp_profile.test.sql +54 -0
  37. package/tests/agent_board_667_writers.test.sql +281 -0
  38. package/tests/agent_board_717_message_replay_scope.test.sql +828 -0
  39. package/tests/agent_board_717_native_surface.test.sql +223 -0
  40. package/tests/agent_board_717_tasking_replay_scope.test.sql +661 -0
  41. package/tests/agent_board_addressing.test.sql +8 -5
  42. package/tests/agent_board_claim_subject_gate.test.sql +7 -3
  43. package/tests/agent_board_claimpolicy_race.test.sql +39 -11
  44. package/tests/agent_board_delegate_role_class.test.sql +35 -17
  45. package/tests/agent_board_delivery_writer_execute.test.sql +373 -0
  46. package/tests/agent_board_fk_lock_edges.test.sql +3 -0
  47. package/tests/agent_board_hosted_delegates.test.sql +13 -3
  48. package/tests/agent_board_inbox_rpcs.test.sql +5 -3
  49. package/tests/agent_board_obsgate.test.sql +8 -4
  50. package/tests/agent_board_obsgate4.test.sql +2 -2
  51. package/tests/agent_board_outbox_wake_ordering.test.sql +25 -2
  52. package/tests/agent_board_own_post_not_delivered.test.sql +11 -9
  53. package/tests/agent_board_send_outcome.test.sql +805 -0
  54. package/tests/agent_board_session_identity_behavior_classes.test.sql +2 -2
  55. package/tests/agent_board_session_identity_limits.test.sql +1 -1
  56. package/tests/agent_board_session_identity_measured_mint.test.sql +342 -0
  57. package/tests/agent_board_session_identity_predicate_isolation.test.sql +146 -0
  58. package/tests/agent_board_sidserver_authority.test.sql +69 -0
  59. package/tests/agent_board_sidserver_catalog.test.sql +47 -0
  60. package/tests/agent_board_signed_write_gateway.test.sql +4 -2
  61. package/tests/agent_board_task_thread_lock_order.test.sql +67 -42
  62. package/tests/agent_board_v2_invariants.test.sql +5 -2
  63. package/tests/agent_board_write_enforcement_class.test.sql +12 -8
  64. package/tests/catalog/function_execute_privileges.json +65 -5
  65. package/tests/catalog/p_metadata_parameters.json +24 -0
  66. package/tests/fixtures/agent_board_667_apply_rls_guard.sql +195 -0
  67. package/tests/fixtures/agent_board_667_apply_rls_provenance.md +125 -0
  68. package/tests/fixtures/agent_board_667_apply_rls_reference.sql +1903 -0
  69. package/tests/fixtures/agent_board_667_conversion_guard.sql +162 -0
  70. package/tests/fixtures/agent_board_667_conversion_reference.md +23 -0
  71. package/tests/fixtures/agent_board_667_conversion_reference.sql +5325 -0
  72. package/tests/fixtures/agent_board_667_delimiter_guard.sql +92 -0
  73. package/tests/fixtures/agent_board_667_delimiter_provenance.md +116 -0
  74. package/tests/fixtures/agent_board_667_delimiter_reference.sql +10150 -0
  75. package/tests/fixtures/agent_board_667_search_guard.sql +92 -0
  76. package/tests/fixtures/agent_board_667_search_provenance.md +141 -0
  77. package/tests/fixtures/agent_board_667_search_reference.sql +4779 -0
  78. package/tests/fixtures/agent_board_667_sender_guard.sql +102 -0
  79. package/tests/fixtures/agent_board_667_sender_reference.md +20 -0
  80. package/tests/fixtures/agent_board_667_sender_reference.sql +875 -0
  81. package/tests/fixtures/agent_board_667_timestamp_graph.sql +84 -0
  82. package/tests/fixtures/agent_board_667_timestamp_guard.sql +94 -0
  83. package/tests/fixtures/agent_board_667_timestamp_provenance.md +99 -0
  84. package/tests/fixtures/agent_board_667_timestamp_reference.sql +2938 -0
  85. package/tests/fixtures/isolation-substrate.sql +8 -0
  86. package/tests/fixtures/pgtap-unexposed.sql +61 -0
  87. package/tests/isolation/expected/association_artifact_anchor_order.out +108 -0
  88. package/tests/isolation/expected/association_board_vs_board.out +71 -0
  89. package/tests/isolation/expected/association_post_wait_authority.out +77 -0
  90. package/tests/isolation/expected/association_strong_history_writers.out +203 -0
  91. package/tests/isolation/expected/association_strong_isolation.out +185 -0
  92. package/tests/isolation/expected/association_vs_artifact_claim_escalation.out +199 -0
  93. package/tests/isolation/expected/association_vs_heartbeat.out +78 -0
  94. package/tests/isolation/expected/association_vs_multi_anchor_artifact.out +67 -0
  95. package/tests/isolation/expected/association_vs_private_message.out +67 -0
  96. package/tests/isolation/expected/association_vs_task_and_conflict.out +133 -0
  97. package/tests/isolation/expected/association_vs_taskful_cross_thread.out +133 -0
  98. package/tests/isolation/expected/message_replay_scope.out +209 -0
  99. package/tests/isolation/expected/send_outcome_cross_board.out +40 -0
  100. package/tests/isolation/expected/send_outcome_independence.out +295 -0
  101. package/tests/isolation/expected/send_outcome_membership.out +140 -0
  102. package/tests/isolation/expected/send_outcome_overlap.out +89 -0
  103. package/tests/isolation/expected/send_outcome_reader.out +87 -0
  104. package/tests/isolation/expected/send_outcome_recovery.out +107 -0
  105. package/tests/isolation/expected/tasking_replay_scope.out +125 -0
  106. package/tests/isolation/specs/association_artifact_anchor_order.spec +46 -0
  107. package/tests/isolation/specs/association_board_vs_board.spec +37 -0
  108. package/tests/isolation/specs/association_post_wait_authority.spec +48 -0
  109. package/tests/isolation/specs/association_strong_history_writers.spec +61 -0
  110. package/tests/isolation/specs/association_strong_isolation.spec +50 -0
  111. package/tests/isolation/specs/association_vs_artifact_claim_escalation.spec +41 -0
  112. package/tests/isolation/specs/association_vs_heartbeat.spec +47 -0
  113. package/tests/isolation/specs/association_vs_multi_anchor_artifact.spec +38 -0
  114. package/tests/isolation/specs/association_vs_private_message.spec +33 -0
  115. package/tests/isolation/specs/association_vs_task_and_conflict.spec +38 -0
  116. package/tests/isolation/specs/association_vs_taskful_cross_thread.spec +42 -0
  117. package/tests/isolation/specs/message_replay_scope.spec +77 -0
  118. package/tests/isolation/specs/send_outcome_cross_board.spec +66 -0
  119. package/tests/isolation/specs/send_outcome_independence.spec +95 -0
  120. package/tests/isolation/specs/send_outcome_membership.spec +73 -0
  121. package/tests/isolation/specs/send_outcome_overlap.spec +69 -0
  122. package/tests/isolation/specs/send_outcome_reader.spec +61 -0
  123. package/tests/isolation/specs/send_outcome_recovery.spec +68 -0
  124. package/tests/isolation/specs/tasking_replay_scope.spec +72 -0
  125. package/tests/mutations/670/E1_helper_author_from_message.sql +7 -0
  126. package/tests/mutations/670/E2_helper_no_null_check.sql +13 -0
  127. package/tests/mutations/670/M10_lock_removed.sql +10 -0
  128. package/tests/mutations/670/M11_table_granted_to_authenticated.sql +2 -0
  129. package/tests/mutations/670/M12_helper_granted_to_service_role.sql +2 -0
  130. package/tests/mutations/670/M13_message_fk_no_cascade.sql +8 -0
  131. package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +11 -0
  132. package/tests/mutations/670/M15_second_receipt_writer.sql +9 -0
  133. package/tests/mutations/670/M16_read_no_btrim.sql +7 -0
  134. package/tests/mutations/670/M17_read_volatile.sql +2 -0
  135. package/tests/mutations/670/M1_helper_no_service_role_guard.sql +13 -0
  136. package/tests/mutations/670/M3_helper_on_replay_branch.sql +10 -0
  137. package/tests/mutations/670/M4_read_checks_thread_existence.sql +10 -0
  138. package/tests/mutations/670/M5a_read_requires_thread_access.sql +10 -0
  139. package/tests/mutations/670/M5b_read_requires_board_membership.sql +11 -0
  140. package/tests/mutations/670/M6_read_admits_service_role.sql +14 -0
  141. package/tests/mutations/670/M7_confirmed_adds_message_sequence.sql +12 -0
  142. package/tests/mutations/670/M8_delivery_swallows_errors.sql +19 -0
  143. package/tests/mutations/670/M9_lock_key_includes_board.sql +10 -0
  144. package/tests/mutations/670/run.sh +84 -0
  145. package/tests/mutations/717-f1/M0_prefix_main_acl_and_comments.sql +11 -0
  146. package/tests/mutations/717-f1/M10_wrapper_stops_delegating.sql +7 -0
  147. package/tests/mutations/717-f1/M11_transitive_recipient_content.sql +8 -0
  148. package/tests/mutations/717-f1/M12_transitive_recipient_visibility.sql +8 -0
  149. package/tests/mutations/717-f1/M13_transitive_worker_content.sql +15 -0
  150. package/tests/mutations/717-f1/M1a_regrant_upsert_delivery_recipient.sql +1 -0
  151. package/tests/mutations/717-f1/M1b_regrant_upsert_inbox_item.sql +1 -0
  152. package/tests/mutations/717-f1/M1c_regrant_queue_inbox_callbacks.sql +1 -0
  153. package/tests/mutations/717-f1/M1d_regrant_queue_board_post_callbacks.sql +1 -0
  154. package/tests/mutations/717-f1/M1e_regrant_next_thread_message_sequence.sql +1 -0
  155. package/tests/mutations/717-f1/M2_blanket_schema_grant.sql +1 -0
  156. package/tests/mutations/717-f1/M3_new_overload_of_sink.sql +10 -0
  157. package/tests/mutations/717-f1/M4_new_route_calling_sink.sql +7 -0
  158. package/tests/mutations/717-f1/M5_actor_trusts_supplied_id.sql +5 -0
  159. package/tests/mutations/717-f1/M6_signed_route_granted_to_authenticated.sql +1 -0
  160. package/tests/mutations/717-f1/M7_worker_granted_to_authenticated.sql +1 -0
  161. package/tests/mutations/717-f1/M8_recipient_state_rewrites_visibility.sql +5 -0
  162. package/tests/mutations/717-f1/M9_public_route_revoked_from_service_role.sql +1 -0
  163. package/tests/mutations/717-f1/outbox_wake_ordering/W1_regrant_queue_inbox_callbacks.sql +1 -0
  164. package/tests/mutations/717-f1/outbox_wake_ordering/W2_revoke_worker_from_service_role.sql +1 -0
  165. package/tests/mutations/717-f1/outbox_wake_ordering/W3_invoker_caller_of_sink.sql +1 -0
  166. package/tests/mutations/717-f1/outbox_wake_ordering/W4_public_regrant_board_post_sink.sql +1 -0
  167. package/tests/mutations/717-f1/run.sh +17 -0
  168. package/tests/mutations/717-f2b/C1_new_delivery_route.sql +4 -0
  169. package/tests/mutations/717-f2b/C2_new_replay_lookup.sql +3 -0
  170. package/tests/mutations/717-f2b/C3_internal_regranted.sql +2 -0
  171. package/tests/mutations/717-f2b/C4_wrapper_writes_delivery.sql +9 -0
  172. package/tests/mutations/717-f2b/C5_class_member_dynamic_sql.sql +9 -0
  173. package/tests/mutations/717-f2b/C6_drop_board_scope_constraint.sql +2 -0
  174. package/tests/mutations/717-f2b/C7_state_private_helper_content.sql +14 -0
  175. package/tests/mutations/717-f2b/L1_dm_lock_split_by_recipient.sql +8 -0
  176. package/tests/mutations/717-f2b/L2_dm_lock_removed.sql +12 -0
  177. package/tests/mutations/717-f2b/L3_mc_lock_split_by_recipients.sql +8 -0
  178. package/tests/mutations/717-f2b/L4_mc_lock_removed.sql +12 -0
  179. package/tests/mutations/717-f2b/M0_prefix_definitions.sql +17 -0
  180. package/tests/mutations/717-f2b/M10_mc_lookup_any_author.sql +15 -0
  181. package/tests/mutations/717-f2b/M11_dm_swallow_refusal.sql +8 -0
  182. package/tests/mutations/717-f2b/M12_mc_swallow_refusal.sql +8 -0
  183. package/tests/mutations/717-f2b/M13_signed_dm_swallows_refusal.sql +32 -0
  184. package/tests/mutations/717-f2b/M14_signed_mc_swallows_refusal.sql +20 -0
  185. package/tests/mutations/717-f2b/M15_mc_any_source.sql +7 -0
  186. package/tests/mutations/717-f2b/M1_dm_drop_recipient_proof.sql +16 -0
  187. package/tests/mutations/717-f2b/M2_mc_drop_recipient_proof.sql +16 -0
  188. package/tests/mutations/717-f2b/M3_dm_metadata_as_proof.sql +12 -0
  189. package/tests/mutations/717-f2b/M4_mc_metadata_as_proof.sql +16 -0
  190. package/tests/mutations/717-f2b/M5_dm_any_mode.sql +11 -0
  191. package/tests/mutations/717-f2b/M6_dm_board_delivery_counts.sql +11 -0
  192. package/tests/mutations/717-f2b/M7_mc_any_mode.sql +11 -0
  193. package/tests/mutations/717-f2b/M8_dm_thread_stamp_as_proof.sql +12 -0
  194. package/tests/mutations/717-f2b/M9_dm_lookup_any_author.sql +15 -0
  195. package/tests/mutations/717-f2b/run.sh +82 -0
@@ -0,0 +1,162 @@
1
+ -- #667 association, private-history and delivery-source boundary witnesses.
2
+ create extension if not exists pgtap with schema extensions;
3
+ set search_path = extensions, public, agent_board;
4
+ begin;
5
+ select plan(36);
6
+ create temp table xb_fixture (board1 uuid, board2 uuid, empty_board uuid, actor uuid, actor_user uuid, thread uuid, private_thread uuid) on commit drop;
7
+ do $$
8
+ declare
9
+ suffix text := replace(substr(gen_random_uuid()::text, 1, 8), '-', '');
10
+ actor_user uuid; actor uuid := gen_random_uuid(); creator uuid := gen_random_uuid();
11
+ board1 uuid; board2 uuid; empty_board uuid := gen_random_uuid(); th uuid := gen_random_uuid(); private_th uuid := gen_random_uuid();
12
+ begin
13
+ actor_user := public.ensure_github_user('xb-actor-' || suffix, 'xb-actor-' || suffix || '@example.test', 'xb-actor-' || suffix, 'XB Actor');
14
+ insert into agent_board.agents(id,agent_type,handle,display_name,status,auth_user_id,owner_user_id)
15
+ values (creator,'agent','xb-creator-' || suffix,'XB Creator','active',null,null),
16
+ (actor,'agent','xb-actor-' || suffix,'XB Actor','active',actor_user,actor_user);
17
+ select board_id into board1 from agent_board.create_board(creator,'xb-one-' || suffix,'XB One','fixture','{}'::jsonb,'private');
18
+ select board_id into board2 from agent_board.create_board(creator,'xb-two-' || suffix,'XB Two','fixture','{}'::jsonb,'private');
19
+ insert into agent_board.boards(id,slug,name,created_by_agent_id,visibility,status)
20
+ values (empty_board,'xb-empty-' || suffix,'XB empty board',creator,'private','active');
21
+ insert into agent_board.board_memberships(board_id,agent_id,membership_state,created_by_agent_id,role)
22
+ values (board1,actor,'joined',creator,'member'), (board2,actor,'joined',creator,'member');
23
+ insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
24
+ values (th,'coordination',actor,'XB associated'),(private_th,'coordination',actor,'XB private');
25
+ perform set_config('request.jwt.claim.role','authenticated',true);
26
+ perform set_config('request.jwt.claim.sub',actor_user::text,true);
27
+ insert into xb_fixture values(board1,board2,empty_board,actor,actor_user,th,private_th);
28
+ end $$;
29
+ select lives_ok($$select * from agent_board.post_board_message((select thread from xb_fixture),(select actor from xb_fixture),(select board1 from xb_fixture),'first','first')$$,'XB empty first association succeeds');
30
+ select is((select board_id from agent_board.threads where id=(select thread from xb_fixture)),(select board1 from xb_fixture),'XB first association stamps the target');
31
+ select throws_ok($$select * from agent_board.post_board_message((select thread from xb_fixture),(select actor from xb_fixture),(select board2 from xb_fixture),'second','second')$$,'42501','thread belongs to a different board','XB mismatch refuses before delivery');
32
+ select is((select count(*) from agent_board.messages where thread_id=(select thread from xb_fixture)),1::bigint,'XB mismatch leaves message count unchanged');
33
+ select is((select board_id from agent_board.threads where id=(select thread from xb_fixture)),(select board1 from xb_fixture),'XB mismatch preserves original stamp');
34
+ select lives_ok($$select * from agent_board.post_message((select private_thread from xb_fixture),(select actor from xb_fixture),'private')$$,'XB setup writes private history');
35
+ select throws_ok($$select * from agent_board.post_board_message((select private_thread from xb_fixture),(select actor from xb_fixture),(select board1 from xb_fixture),'shared','shared')$$,'42501','thread has private history','XB private history cannot be associated');
36
+ select is((select board_id from agent_board.threads where id=(select private_thread from xb_fixture)),null::uuid,'XB private thread remains unstamped');
37
+ select throws_ok($$select set_config('request.jwt.claim.role','service_role',true); select * from agent_board.post_board_message((select thread from xb_fixture),(select actor from xb_fixture),(select board2 from xb_fixture),'service','service')$$,'42501','thread belongs to a different board','XB service transport cannot bypass mismatch');
38
+ select is((select count(*) from agent_board.messages where thread_id=(select thread from xb_fixture)),1::bigint,'XB service mismatch writes no message');
39
+ select throws_ok($$select set_config('request.jwt.claim.role','service_role',true); select agent_board._upsert_delivery_recipient('board',(select actor from xb_fixture),'message',(select id from agent_board.messages where thread_id=(select thread from xb_fixture)),null,null,(select board2 from xb_fixture),null)$$,'42501','thread belongs to a different board','XB sink independently refuses mismatch');
40
+ select is((select board_id from agent_board.threads where id=(select thread from xb_fixture)),(select board1 from xb_fixture),'XB sink mismatch preserves the stamp');
41
+ -- With no board memberships, no delivery sink runs: this independently pins
42
+ -- the sender's early boundary instead of accepting a later sink refusal.
43
+ select throws_ok($$select set_config('request.jwt.claim.role','service_role',true); select * from agent_board.post_board_message((select thread from xb_fixture),(select actor from xb_fixture),(select empty_board from xb_fixture),'early','early')$$,
44
+ '42501','thread belongs to a different board','XB early sender refuses mismatch without sink recipients');
45
+ select is((select count(*) from agent_board.messages where thread_id=(select thread from xb_fixture)),1::bigint,
46
+ 'XB early refusal leaves message count unchanged');
47
+ -- Isolate the task and event predicates: the event's task belongs to another
48
+ -- thread, so a task predicate on the event thread cannot mask its omission.
49
+ create temp table xb_history_case(kind text primary key,thread_id uuid not null,task_id uuid) on commit drop;
50
+ select lives_ok($q$
51
+ do $setup$
52
+ declare task_thread uuid:=gen_random_uuid(); event_thread uuid:=gen_random_uuid(); sink_thread uuid:=gen_random_uuid();
53
+ task_only uuid:=gen_random_uuid(); parent_task uuid:=gen_random_uuid();
54
+ begin
55
+ insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
56
+ values (task_thread,'coordination',(select actor from xb_fixture),'XB task only'),
57
+ (event_thread,'coordination',(select actor from xb_fixture),'XB event only'),
58
+ (sink_thread,'coordination',(select actor from xb_fixture),'XB sink source only');
59
+ insert into agent_board.messages(thread_id,author_agent_id,message_sequence,body) values (sink_thread,(select actor from xb_fixture),1,'XB private sink source');
60
+ insert into agent_board.tasks(id,thread_id,created_by_agent_id,title)
61
+ values (task_only,task_thread,(select actor from xb_fixture),'XB isolated task'),
62
+ (parent_task,(select private_thread from xb_fixture),(select actor from xb_fixture),'XB event parent');
63
+ insert into agent_board.task_events(task_id,thread_id,actor_agent_id,event_sequence,event_type,payload,origin_posture)
64
+ values (parent_task,event_thread,(select actor from xb_fixture),1,'created','{}'::jsonb,'unattested:signed-metadata-rpc');
65
+ insert into xb_history_case values ('task',task_thread,task_only),('event',event_thread,parent_task),('sink',sink_thread,null);
66
+ end $setup$;
67
+ $q$, 'XB isolated task and event histories are seeded');
68
+ select throws_ok($$select * from agent_board.post_board_message((select thread_id from xb_history_case where kind='task'),
69
+ (select actor from xb_fixture),(select board1 from xb_fixture),'task','body')$$,
70
+ '42501','thread has private history','XB task-only history refuses association');
71
+ select ok((select board_id is null from agent_board.threads where id=(select thread_id from xb_history_case where kind='task'))
72
+ and exists(select 1 from agent_board.tasks where id=(select task_id from xb_history_case where kind='task')),
73
+ 'XB task-only refusal preserves task and null stamp');
74
+ select throws_ok($$select * from agent_board.post_board_message((select thread_id from xb_history_case where kind='event'),
75
+ (select actor from xb_fixture),(select board1 from xb_fixture),'event','body')$$,
76
+ '42501','thread has private history','XB event-only history refuses association');
77
+ select ok((select board_id is null from agent_board.threads where id=(select thread_id from xb_history_case where kind='event'))
78
+ and exists(select 1 from agent_board.task_events where thread_id=(select thread_id from xb_history_case where kind='event')),
79
+ 'XB event-only refusal preserves event and null stamp');
80
+ select throws_ok($$select agent_board._upsert_delivery_recipient('board',(select actor from xb_fixture),'message',
81
+ (select id from agent_board.messages where thread_id=(select thread_id from xb_history_case where kind='sink')),null,null,(select board1 from xb_fixture),
82
+ (select id from agent_board.board_memberships where board_id=(select board1 from xb_fixture) and agent_id=(select actor from xb_fixture)))$$,
83
+ '42501','thread has private history','XB direct sink cannot associate an existing private source');
84
+ select ok((select board_id is null from agent_board.threads where id=(select thread_id from xb_history_case where kind='sink'))
85
+ and (select count(*) from agent_board.messages where thread_id=(select thread_id from xb_history_case where kind='sink'))=1,
86
+ 'XB direct sink refusal preserves source and null stamp');
87
+ select is((select count(*) from agent_board.delivery_recipients d join agent_board.messages m on m.id=d.source_message_id
88
+ where m.thread_id=(select thread_id from xb_history_case where kind='sink')),
89
+ 0::bigint,'XB direct sink refusal creates no delivery for its private source');
90
+ -- The existing board remains usable; replaying the same key returns the
91
+ -- original message rather than inserting a second copy.
92
+ create temp table xb_same_board_results(message_id uuid) on commit drop;
93
+ select lives_ok($$insert into xb_same_board_results select message_id from agent_board.post_board_message(
94
+ (select thread from xb_fixture),(select actor from xb_fixture),(select board1 from xb_fixture),
95
+ 'same board','replayed body',p_idempotency_key=>'xb-same-board')$$,
96
+ 'XB same-board keyed post succeeds');
97
+ select lives_ok($$insert into xb_same_board_results select message_id from agent_board.post_board_message(
98
+ (select thread from xb_fixture),(select actor from xb_fixture),(select board1 from xb_fixture),
99
+ 'same board','replayed body',p_idempotency_key=>'xb-same-board')$$,
100
+ 'XB same-board keyed replay succeeds');
101
+ select is((select count(distinct message_id) from xb_same_board_results),1::bigint,
102
+ 'XB same-board replay returns the original message');
103
+ select is((select count(*) from agent_board.messages where thread_id=(select thread from xb_fixture)),2::bigint,
104
+ 'XB same-board replay inserts exactly one new message');
105
+ select is((select board_id from agent_board.threads where id=(select thread from xb_fixture)),(select board1 from xb_fixture),
106
+ 'XB same-board replay preserves the original stamp');
107
+ -- A task and a delegation each carry their own real canonical parent. Their
108
+ -- private histories cannot be promoted by calling the sink directly; a
109
+ -- same-board source, however, remains a valid delivery.
110
+ create temp table xb_sink_sources(kind text primary key,thread_id uuid not null,source_id uuid not null) on commit drop;
111
+ select lives_ok($q$
112
+ do $setup$
113
+ declare private_thread uuid:=gen_random_uuid(); private_parent uuid:=gen_random_uuid(); private_child uuid:=gen_random_uuid();
114
+ private_delegation uuid:=gen_random_uuid(); board_parent uuid:=gen_random_uuid(); board_child uuid:=gen_random_uuid(); board_delegation uuid:=gen_random_uuid();
115
+ begin
116
+ insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
117
+ values(private_thread,'coordination',(select actor from xb_fixture),'XB private delegation');
118
+ insert into agent_board.tasks(id,thread_id,created_by_agent_id,title)
119
+ values(private_parent,private_thread,(select actor from xb_fixture),'private parent'),
120
+ (private_child,private_thread,(select actor from xb_fixture),'private child'),
121
+ (board_parent,(select thread from xb_fixture),(select actor from xb_fixture),'board parent'),
122
+ (board_child,(select thread from xb_fixture),(select actor from xb_fixture),'board child');
123
+ insert into agent_board.delegations(id,parent_task_id,child_task_id,delegated_by_agent_id,delegated_to_agent_id)
124
+ values(private_delegation,private_parent,private_child,(select actor from xb_fixture),(select actor from xb_fixture)),
125
+ (board_delegation,board_parent,board_child,(select actor from xb_fixture),(select actor from xb_fixture));
126
+ insert into xb_sink_sources values ('private_task',(select thread_id from xb_history_case where kind='task'),(select task_id from xb_history_case where kind='task')),
127
+ ('private_delegation',private_thread,private_delegation),('board_task',(select thread from xb_fixture),board_parent),
128
+ ('board_delegation',(select thread from xb_fixture),board_delegation);
129
+ end $setup$;
130
+ $q$, 'XB task and delegation sink sources are seeded');
131
+ select throws_ok($$select agent_board._upsert_delivery_recipient('tasking',(select actor from xb_fixture),'task',null,
132
+ (select source_id from xb_sink_sources where kind='private_task'),null,(select board1 from xb_fixture),
133
+ (select id from agent_board.board_memberships where board_id=(select board1 from xb_fixture) and agent_id=(select actor from xb_fixture)))$$,
134
+ '42501','thread has private history','XB direct task sink refuses private parent history');
135
+ select ok((select board_id is null from agent_board.threads where id=(select thread_id from xb_sink_sources where kind='private_task'))
136
+ and not exists(select 1 from agent_board.delivery_recipients where source_task_id=(select source_id from xb_sink_sources where kind='private_task')),
137
+ 'XB private task sink leaves stamp and delivery unchanged');
138
+ select throws_ok($$select agent_board._upsert_delivery_recipient('tasking',(select actor from xb_fixture),'delegation',null,null,
139
+ (select source_id from xb_sink_sources where kind='private_delegation'),(select board1 from xb_fixture),
140
+ (select id from agent_board.board_memberships where board_id=(select board1 from xb_fixture) and agent_id=(select actor from xb_fixture)))$$,
141
+ '42501','thread has private history','XB direct delegation sink refuses private child history');
142
+ select ok((select board_id is null from agent_board.threads where id=(select thread_id from xb_sink_sources where kind='private_delegation'))
143
+ and not exists(select 1 from agent_board.delivery_recipients where source_delegation_id=(select source_id from xb_sink_sources where kind='private_delegation'))
144
+ and exists(select 1 from agent_board.delegations d join agent_board.tasks c on c.id=d.child_task_id
145
+ where d.id=(select source_id from xb_sink_sources where kind='private_delegation') and c.thread_id=(select thread_id from xb_sink_sources where kind='private_delegation')),
146
+ 'XB private delegation sink preserves canonical child and leaves no delivery');
147
+ select lives_ok($$select agent_board._upsert_delivery_recipient('tasking',(select actor from xb_fixture),'task',null,
148
+ (select source_id from xb_sink_sources where kind='board_task'),null,(select board1 from xb_fixture),
149
+ (select id from agent_board.board_memberships where board_id=(select board1 from xb_fixture) and agent_id=(select actor from xb_fixture)))$$,
150
+ 'XB same-board direct task sink succeeds');
151
+ select ok(exists(select 1 from agent_board.delivery_recipients where source_task_id=(select source_id from xb_sink_sources where kind='board_task')
152
+ and board_id=(select board1 from xb_fixture)), 'XB same-board task sink retains source and board');
153
+ select lives_ok($$select agent_board._upsert_delivery_recipient('tasking',(select actor from xb_fixture),'delegation',null,null,
154
+ (select source_id from xb_sink_sources where kind='board_delegation'),(select board1 from xb_fixture),
155
+ (select id from agent_board.board_memberships where board_id=(select board1 from xb_fixture) and agent_id=(select actor from xb_fixture)))$$,
156
+ 'XB same-board direct delegation sink succeeds');
157
+ select ok(exists(select 1 from agent_board.delivery_recipients d join agent_board.delegations g on g.id=d.source_delegation_id
158
+ join agent_board.tasks c on c.id=g.child_task_id where g.id=(select source_id from xb_sink_sources where kind='board_delegation')
159
+ and d.board_id=(select board1 from xb_fixture) and c.thread_id=(select thread from xb_fixture)),
160
+ 'XB same-board delegation sink retains canonical child and board');
161
+ select * from finish();
162
+ rollback;
@@ -0,0 +1,91 @@
1
+ -- Native calls execute only when their full overload identity is present.
2
+ -- The plan is derived from those present cases; absence earns no call credit.
3
+ create extension if not exists pgtap with schema extensions;
4
+ set search_path=extensions,public,agent_board;
5
+ begin;
6
+ \ir fixtures/agent_board_667_conversion_guard.sql
7
+ select set_config('request.jwt.claim.role','service_role',true);
8
+ insert into agent_board.agents(id,agent_type,handle,display_name,status)
9
+ values('667f0000-0000-4000-8000-000000000001','agent','conversion-branches','Conversion branches','active');
10
+ insert into agent_board.threads(id,thread_type,created_by_agent_id,subject)
11
+ values('667f0000-0000-4000-8000-000000000010','coordination','667f0000-0000-4000-8000-000000000001','Quoted values are data');
12
+ create type pg_temp.xb_cf_pair as(i integer,t text);
13
+ create temp table xb_cf_cases(fn text,label text,expression text,expected jsonb,primary key(label)) on commit drop;
14
+ insert into xb_cf_cases values
15
+ ('realtime."cast"(text,regtype)','cast integer',$q$realtime."cast"('4','integer')$q$,'4'),
16
+ ('realtime."cast"(text,regtype)','cast quoted text',$q$realtime."cast"('a''b','text')$q$,to_jsonb('a''b'::text)),
17
+ ('realtime."cast"(text,regtype)','cast bytea preserves encoded text',$q$realtime."cast"('\x0041','bytea')$q$,to_jsonb('\x0041'::text)),
18
+ ('realtime."cast"(text,regtype)','cast bytea preserves plain text',$q$realtime."cast"('hello','bytea')$q$,to_jsonb('hello'::text)),
19
+ ('realtime."cast"(text,regtype)','cast integer array',$q$realtime."cast"('{1,2}','integer[]')$q$,'[1,2]'),
20
+ ('realtime."cast"(text,regtype)','cast composite',$q$realtime."cast"('(7,"a,b")','pg_temp.xb_cf_pair')$q$,'{"i":7,"t":"a,b"}'),
21
+ ('realtime."cast"(text,regtype)','cast reviewed domain',$q$realtime."cast"('4','information_schema.cardinal_number')$q$,'4'),
22
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text)','four argument equality',$q$realtime.check_equality_op('eq','integer','4','4')$q$,'true'),
23
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text)','four argument membership',$q$realtime.check_equality_op('in','integer','4','{3,4}')$q$,'true'),
24
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text)','four argument inequality',$q$realtime.check_equality_op('neq','integer','4','4')$q$,'false'),
25
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','five argument equality',$q$realtime.check_equality_op('eq','integer','4','4',false)$q$,'true'),
26
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','five argument negation',$q$realtime.check_equality_op('eq','integer','4','4',true)$q$,'false'),
27
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','distinct',$q$realtime.check_equality_op('isdistinct','integer','4','5',false)$q$,'true'),
28
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','not distinct',$q$realtime.check_equality_op('isdistinct','integer','4','4',true)$q$,'true'),
29
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','is null',$q$realtime.check_equality_op('is','integer',null::text,'null',false)$q$,'true'),
30
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','is not null',$q$realtime.check_equality_op('is','integer',null::text,'null',true)$q$,'false'),
31
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','like quoted text',$q$realtime.check_equality_op('like','text','a''b','%''%',false)$q$,'true'),
32
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','case insensitive like',$q$realtime.check_equality_op('ilike','text','Alpha','a%',false)$q$,'true'),
33
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','regular expression',$q$realtime.check_equality_op('match','text','alpha','^a.*',false)$q$,'true'),
34
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','case insensitive regular expression',$q$realtime.check_equality_op('imatch','text','ALPHA','^a.*',false)$q$,'true'),
35
+ ('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','negated membership',$q$realtime.check_equality_op('in','integer','4','{3,4}',true)$q$,'false');
36
+ -- Removing native literal quoting turns this valid text value into a successful
37
+ -- guarded task write. The final scoped assertion detects that side effect.
38
+ insert into xb_cf_cases
39
+ select 'realtime."cast"(text,regtype)','cast expression-looking text',
40
+ format('realtime."cast"(%L,''text'')',p),to_jsonb(p)
41
+ from(values($v$agent_board.create_task('667f0000-0000-4000-8000-000000000010','667f0000-0000-4000-8000-000000000001','escaped literal')$v$)) v(p);
42
+ insert into xb_cf_cases
43
+ select 'realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','distinct expression-looking text',
44
+ format('realtime.check_equality_op(''isdistinct'',''text'',%L,%L,false)',p,p),'false'::jsonb
45
+ from(values($v$agent_board.create_task('667f0000-0000-4000-8000-000000000010','667f0000-0000-4000-8000-000000000001','escaped literal')$v$)) v(p);
46
+ insert into xb_cf_cases
47
+ select 'realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','is-null expression-looking text',
48
+ format('realtime.check_equality_op(''is'',''text'',%L,''null'',false)',p),'false'::jsonb
49
+ from(values($v$agent_board.create_task('667f0000-0000-4000-8000-000000000010','667f0000-0000-4000-8000-000000000001','escaped literal')$v$)) v(p);
50
+ insert into xb_cf_cases
51
+ select 'realtime.check_equality_op(realtime.equality_op,regtype,text,text)','four argument expression-looking text',
52
+ format('realtime.check_equality_op(''eq'',''text'',%L,%L)',p,p),'true'::jsonb
53
+ from(values($v$agent_board.create_task('667f0000-0000-4000-8000-000000000010','667f0000-0000-4000-8000-000000000001','escaped literal')$v$)) v(p);
54
+ insert into xb_cf_cases
55
+ select 'realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)','five argument expression-looking text',
56
+ format('realtime.check_equality_op(''eq'',''text'',%L,%L,false)',p,p),'true'::jsonb
57
+ from(values($v$agent_board.create_task('667f0000-0000-4000-8000-000000000010','667f0000-0000-4000-8000-000000000001','escaped literal')$v$)) v(p);
58
+ create temp table xb_cf_values(label text primary key,value jsonb) on commit drop;
59
+ create function pg_temp.xb_cf_run(p_label text,p_expression text,p_expected jsonb) returns setof text
60
+ language plpgsql volatile as $$
61
+ begin
62
+ return next lives_ok(format('insert into pg_temp.xb_cf_values select %L,to_jsonb((%s))',p_label,p_expression),
63
+ 'CB '||p_label||' call succeeds');
64
+ return next is((select value from pg_temp.xb_cf_values where label=p_label),p_expected,
65
+ 'CB '||p_label||' returns the expected value');
66
+ end$$;
67
+ select plan(4+2*(select count(*)::integer from xb_cf_cases where to_regprocedure(fn) is not null)
68
+ +(to_regprocedure('realtime."cast"(text,regtype)') is not null)::integer
69
+ +(to_regprocedure('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)') is not null)::integer);
70
+ select ok((select count(distinct fn) from xb_cf_cases)=3,'CB fixtures cover exactly three native overloads');
71
+ select is((select count(*) from pg_temp.xb_cf_problems()),0::bigint,'CB call fixtures retain the reviewed dispatch profile')
72
+ where exists(select 1 from xb_cf_cases where to_regprocedure(fn) is not null);
73
+ select * from skip('native converters absent; no primitive admission credit',1)
74
+ where not exists(select 1 from xb_cf_cases where to_regprocedure(fn) is not null);
75
+ select is((select count(*) from pg_temp.xb_cf_wrapper_problems()),0::bigint,'CB present native definitions and security metadata are exact');
76
+ select diag('Native calls absent; no native branch execution credit')
77
+ where not exists(select 1 from xb_cf_cases where to_regprocedure(fn) is not null);
78
+ select r.* from (select * from xb_cf_cases where to_regprocedure(fn) is not null order by label) c
79
+ cross join lateral pg_temp.xb_cf_run(c.label,c.expression,c.expected) r;
80
+ select throws_ok($$select realtime."cast"('-1','information_schema.cardinal_number')$$,'23514',
81
+ 'value for domain information_schema.cardinal_number violates check constraint "cardinal_number_domain_check"',
82
+ 'CB native cast preserves the reviewed domain refusal')
83
+ where to_regprocedure('realtime."cast"(text,regtype)') is not null;
84
+ select throws_ok($$select realtime.check_equality_op('is','integer','4','true; select 1',false)$$,'P0001',
85
+ 'invalid value for is filter: must be null, true, false, or unknown',
86
+ 'CB is-filter rejects a non-keyword before interpolation')
87
+ where to_regprocedure('realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)') is not null;
88
+ select is((select count(*) from agent_board.tasks where thread_id='667f0000-0000-4000-8000-000000000010'),0::bigint,
89
+ 'CB native literal interpolation creates no fixture history');
90
+ select * from finish();
91
+ rollback;
@@ -0,0 +1,112 @@
1
+ -- This proves the finite dispatch recognizer, independently of platform presence.
2
+ -- Native-call effects are covered by the companion native_cast_effect file.
3
+ create extension if not exists pgtap with schema extensions;
4
+ set search_path=extensions,public,agent_board;
5
+ begin;
6
+ select plan(29);
7
+ \ir fixtures/agent_board_667_conversion_guard.sql
8
+ create temp table xb_cf_prior_profile on commit drop as select * from pg_temp.xb_cf_problems();
9
+ select ok((select count(*)>0 from pg_temp.xb_cf_primitives)
10
+ and (select count(*)>0 from pg_temp.xb_cf_slots()),'CF reference and registered callback census are nonempty');
11
+ select is((select array_agg(identity order by identity) from pg_temp.xb_cf_wrappers),
12
+ array['realtime."cast"(text,regtype)',
13
+ 'realtime.check_equality_op(realtime.equality_op,regtype,text,text,boolean)',
14
+ 'realtime.check_equality_op(realtime.equality_op,regtype,text,text)']::text[],
15
+ 'CF admission scope is exactly the three conversion identities');
16
+ select is((select string_agg(identity||': '||problem,', ' order by identity,problem) from pg_temp.xb_cf_problems()),
17
+ null::text,'CF clean dispatch matches the finite primitive reference')
18
+ where exists(select 1 from pg_temp.xb_cf_wrappers where to_regprocedure(identity) is not null);
19
+ select * from skip('native converters absent; no primitive admission credit',1)
20
+ where not exists(select 1 from pg_temp.xb_cf_wrappers where to_regprocedure(identity) is not null);
21
+ select is((select string_agg(identity,', ' order by identity) from pg_temp.xb_cf_type_coverage()),
22
+ null::text,'CF every catalog type callback is discovered');
23
+ select is((select string_agg(identity||': '||problem,', ' order by identity) from pg_temp.xb_cf_wrapper_problems()),
24
+ null::text,'CF present native definitions and security metadata match');
25
+ select is((select count(*) from pg_temp.xb_cf_admitted()),
26
+ (select count(*) from pg_temp.xb_cf_wrappers where to_regprocedure(identity) is not null),
27
+ 'CF only the present verified conversion wrappers are admitted');
28
+ select diag('No native conversion wrapper present: classifier checks are not native execution credit')
29
+ where not exists(select 1 from pg_temp.xb_cf_wrappers where to_regprocedure(identity) is not null);
30
+
31
+ create temp table xb_cf_answer(value integer) on commit drop;
32
+ select lives_ok($$insert into xb_cf_answer select '4'::information_schema.cardinal_number$$,
33
+ 'CF reviewed system-domain conversion succeeds');
34
+ select is((select value from xb_cf_answer),4,'CF reviewed system-domain conversion returns its value');
35
+ select throws_ok($$select '-1'::information_schema.cardinal_number$$,'23514',
36
+ 'value for domain information_schema.cardinal_number violates check constraint "cardinal_number_domain_check"',
37
+ 'CF reviewed system-domain constraint actually refuses its invalid value');
38
+
39
+ create schema xb_conversion_profile_probe;
40
+ create function xb_conversion_profile_probe.positive(i integer) returns boolean language sql immutable as $$select i>0$$;
41
+ create domain xb_conversion_profile_probe.positive_integer as integer check(xb_conversion_profile_probe.positive(value));
42
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='domain xb_conversion_profile_probe.positive_integer'),
43
+ 'CF new domain constraint names its domain');
44
+ select is((select count(*) from pg_temp.xb_cf_admitted()),0::bigint,'CF custom domain prevents conversion admission');
45
+ drop domain xb_conversion_profile_probe.positive_integer;
46
+ drop function xb_conversion_profile_probe.positive(integer);
47
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
48
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF domain removal restores the prior profile');
49
+
50
+ create function xb_conversion_profile_probe.compare(a integer,b integer) returns boolean language sql immutable as $$select a=b$$;
51
+ create operator xb_conversion_profile_probe.=== (leftarg=integer,rightarg=integer,procedure=xb_conversion_profile_probe.compare);
52
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='xb_conversion_profile_probe.compare(integer,integer)' and problem like 'unreviewed primitive%'),
53
+ 'CF custom operator callback names its full implementation identity');
54
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='operator xb_conversion_profile_probe.===(pg_catalog.int4,pg_catalog.int4)'),
55
+ 'CF custom operator also names its dispatch identity');
56
+ drop operator xb_conversion_profile_probe.=== (integer,integer);
57
+ drop function xb_conversion_profile_probe.compare(integer,integer);
58
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
59
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF operator removal restores the prior profile');
60
+
61
+ create type xb_conversion_profile_probe.cast_target as enum('one','two');
62
+ create function xb_conversion_profile_probe.from_integer(i integer) returns xb_conversion_profile_probe.cast_target
63
+ language sql immutable as $$select case when i=1 then 'one'::xb_conversion_profile_probe.cast_target else 'two'::xb_conversion_profile_probe.cast_target end$$;
64
+ create cast(integer as xb_conversion_profile_probe.cast_target) with function xb_conversion_profile_probe.from_integer(integer) as implicit;
65
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='xb_conversion_profile_probe.from_integer(integer)' and problem like 'unreviewed primitive%'),
66
+ 'CF custom cast callback names its full implementation identity');
67
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='cast pg_catalog.int4 -> xb_conversion_profile_probe.cast_target'),
68
+ 'CF custom implicit cast also names its dispatch identity');
69
+ drop cast(integer as xb_conversion_profile_probe.cast_target);
70
+ drop function xb_conversion_profile_probe.from_integer(integer);
71
+ drop type xb_conversion_profile_probe.cast_target;
72
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
73
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF cast removal restores the prior profile');
74
+
75
+ create function xb_conversion_profile_probe.format(text,text) returns text language sql immutable as $$select $1$$;
76
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='xb_conversion_profile_probe.format(text,text)' and problem='shadow of fixed conversion call'),
77
+ 'CF format shadow names its full overload');
78
+ drop function xb_conversion_profile_probe.format(text,text);
79
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
80
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF shadow removal restores the prior profile');
81
+
82
+ create function xb_conversion_profile_probe.range_difference(a float8,b float8) returns float8 language sql immutable as $$select a-b$$;
83
+ create type xb_conversion_profile_probe.float_span as range(subtype=float8,subtype_diff=xb_conversion_profile_probe.range_difference);
84
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='xb_conversion_profile_probe.range_difference(double precision,double precision)' and problem like 'unreviewed primitive%'),
85
+ 'CF range callback names its full implementation identity');
86
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='range xb_conversion_profile_probe.float_span'),
87
+ 'CF custom range also names its dispatch identity');
88
+ drop type xb_conversion_profile_probe.float_span;
89
+ drop function xb_conversion_profile_probe.range_difference(float8,float8);
90
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
91
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF range removal restores the prior profile');
92
+
93
+ create text search configuration xb_conversion_profile_probe.words(copy=pg_catalog.simple);
94
+ select ok(exists(select 1 from pg_temp.xb_cf_problems() where identity='configuration xb_conversion_profile_probe.words'),
95
+ 'CF new text-search configuration names itself');
96
+ select is((select count(*) from pg_temp.xb_cf_admitted()),0::bigint,'CF unreviewed text-search dispatch prevents admission');
97
+ drop text search configuration xb_conversion_profile_probe.words;
98
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
99
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF text-search removal restores the prior profile');
100
+
101
+ create function xb_conversion_profile_probe.unknown_callback(integer) returns boolean language sql immutable as $$select true$$;
102
+ select is(pg_temp.xb_cf_function_problem('xb_conversion_profile_probe.unknown_callback(integer)'::regprocedure),
103
+ 'unreviewed primitive xb_conversion_profile_probe.unknown_callback(integer)',
104
+ 'CF classifier positively refuses an unreviewed implementation');
105
+ drop function xb_conversion_profile_probe.unknown_callback(integer);
106
+ select is((select jsonb_agg(to_jsonb(p) order by identity,problem) from pg_temp.xb_cf_problems() p),
107
+ (select jsonb_agg(to_jsonb(p) order by identity,problem) from xb_cf_prior_profile p),'CF all negative controls restore the prior dispatch profile');
108
+ select is((select count(*) from pg_temp.xb_cf_admitted()),
109
+ (select count(*) from pg_temp.xb_cf_wrappers where to_regprocedure(identity) is not null),
110
+ 'CF exact profile restoration restores only the verified present admissions');
111
+ select * from finish();
112
+ rollback;