@consiliency/agent-board-schema 1.80.0 → 1.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fixtures/already-applied.json +4 -0
- package/migrations/20261201000100_agent_board_reply_to_message.sql +1241 -0
- package/package.json +1 -1
- package/schema-manifest.json +12 -3
- package/src/tooling.test.mjs +4 -2
- package/tests/agent_board_661_reply_delivery.test.sql +12 -12
- package/tests/agent_board_667_history_class.test.sql +31 -13
- package/tests/agent_board_717_message_replay_scope.test.sql +29 -16
- package/tests/agent_board_717_tasking_replay_scope.test.sql +3 -3
- package/tests/agent_board_bundle_endpoint_compat.test.sql +2 -2
- package/tests/agent_board_canary_signed_fleet_enforcement.test.sql +3 -3
- package/tests/agent_board_claim_subject_gate.test.sql +3 -1
- package/tests/agent_board_delegate_role_class.test.sql +1 -1
- package/tests/agent_board_delivery_writer_execute.test.sql +7 -7
- package/tests/agent_board_hosted_delegates.test.sql +3 -3
- package/tests/agent_board_inbox_rpcs.test.sql +6 -6
- package/tests/agent_board_refusal_atomicity.test.sql +958 -0
- package/tests/agent_board_reply_to.test.sql +874 -0
- package/tests/agent_board_scoped_send_regrant.test.sql +8 -8
- package/tests/agent_board_send_outcome.test.sql +10 -10
- package/tests/agent_board_send_role_gate.test.sql +2 -2
- package/tests/agent_board_write_enforcement_class.test.sql +7 -7
- package/tests/catalog/function_execute_privileges.json +23 -14
- package/tests/catalog/p_metadata_parameters.json +12 -8
- package/tests/isolation/expected/reply_parent_vs_thread_delete.out +55 -0
- package/tests/isolation/expected/reply_vs_parent_author_delete.out +56 -0
- package/tests/isolation/specs/reply_parent_vs_thread_delete.spec +42 -0
- package/tests/isolation/specs/reply_vs_parent_author_delete.spec +46 -0
- package/tests/mutations/655/M01_no_writer_check.sql +22 -0
- package/tests/mutations/655/M02_drop_fk.sql +2 -0
- package/tests/mutations/655/M03_existence_only.sql +13 -0
- package/tests/mutations/655/M04_distinct_cross_thread_error.sql +17 -0
- package/tests/mutations/655/M05_view_no_thread_conjunct.sql +46 -0
- package/tests/mutations/655/M06_thread_feed_not_invoker.sql +46 -0
- package/tests/mutations/655/M06b_board_feed_not_invoker.sql +49 -0
- package/tests/mutations/655/M07_excerpt_via_definer.sql +49 -0
- package/tests/mutations/655/M08_excerpt_200.sql +46 -0
- package/tests/mutations/655/M09_fk_restrict.sql +4 -0
- package/tests/mutations/655/M10_post_message_drops_arg.sql +13 -0
- package/tests/mutations/655/M10b_post_message_passes_null.sql +12 -0
- package/tests/mutations/655/M11_slug_drops_arg.sql +15 -0
- package/tests/mutations/655/M11b_dm_descriptor_positional.sql +31 -0
- package/tests/mutations/655/M12_signed_pbm_nine_args.sql +19 -0
- package/tests/mutations/655/M12b_signed_mc_one_branch.sql +15 -0
- package/tests/mutations/655/M13_undriven_entrypoint.sql +8 -0
- package/tests/mutations/655/M14_second_writer.sql +6 -0
- package/tests/mutations/655/M15_insert_primitive_public.sql +2 -0
- package/tests/mutations/655/M16_comment_missing.sql +2 -0
- package/tests/mutations/655/M17_old_allow_set_rows.sql +5 -0
- package/tests/mutations/655/M18_board_excerpt_139.sql +49 -0
- package/tests/mutations/655/M19_column_in_middle.sql +47 -0
- package/tests/mutations/655/M20_projects_parent_id.sql +46 -0
- package/tests/mutations/655/M21_replay_applies_new_parent.sql +22 -0
- package/tests/mutations/655/M22_fk_not_valid.sql +4 -0
- package/tests/mutations/655/MB4a_no_readability.sql +13 -0
- package/tests/mutations/655/MB4b_own_readability_message.sql +20 -0
- package/tests/mutations/655/MB4c_service_role_reads_all.sql +12 -0
- package/tests/mutations/655/MB4d_delegate_uses_authenticated_arm.sql +12 -0
- package/tests/mutations/655/MB4f_no_board_member_branch.sql +14 -0
- package/tests/mutations/655/MB4g_helper_granted_authenticated.sql +2 -0
- package/tests/mutations/655/MB4j_writer_uses_current_agent.sql +12 -0
- package/tests/mutations/655/MB4k_delegate_policy_loses_initplan.sql +5 -0
- package/tests/mutations/655/MB4l_board_memberships_policy_narrowed.sql +3 -0
- package/tests/mutations/655/W1_auth_no_membership_state.sql +13 -0
- package/tests/mutations/655/W2_auth_no_agent_binding.sql +13 -0
- package/tests/mutations/655/W3_delivery_no_recipient_binding.sql +12 -0
- package/tests/mutations/655/W4_delegate_no_board_conjunct.sql +18 -0
- package/tests/mutations/655/W5_boardset_no_membership_state.sql +13 -0
- package/tests/mutations/655/W6_boardset_no_agent_binding.sql +14 -0
- package/tests/mutations/655/run.sh +93 -0
- package/tests/mutations/670/M10_lock_removed.sql +2 -2
- package/tests/mutations/670/M14_post_message_mints_from_metadata.sql +2 -2
- package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +2 -2
- package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +2 -2
- package/tests/mutations/670/M3_helper_on_replay_branch.sql +2 -2
- package/tests/mutations/670/M8_delivery_swallows_errors.sql +2 -2
- package/tests/mutations/670/M9_lock_key_includes_board.sql +2 -2
- package/tests/mutations/670/run.sh +1 -1
- package/tests/mutations/717-f1/M10_wrapper_stops_delegating.sql +1 -1
- package/tests/mutations/717-f1/M9_public_route_revoked_from_service_role.sql +1 -1
- package/tests/mutations/717-f2b/L1_dm_lock_split_by_recipient.sql +2 -2
- package/tests/mutations/717-f2b/L2_dm_lock_removed.sql +2 -2
- package/tests/mutations/717-f2b/L3_mc_lock_split_by_recipients.sql +2 -2
- package/tests/mutations/717-f2b/L4_mc_lock_removed.sql +2 -2
- package/tests/mutations/717-f2b/M0_prefix_definitions.sql +1 -1
- package/tests/mutations/717-f2b/M10_mc_lookup_any_author.sql +2 -2
- package/tests/mutations/717-f2b/M11_dm_swallow_refusal.sql +2 -2
- package/tests/mutations/717-f2b/M12_mc_swallow_refusal.sql +2 -2
- package/tests/mutations/717-f2b/M15_mc_any_source.sql +1 -1
- package/tests/mutations/717-f2b/M1_dm_drop_recipient_proof.sql +2 -2
- package/tests/mutations/717-f2b/M2_mc_drop_recipient_proof.sql +2 -2
- package/tests/mutations/717-f2b/M3_dm_metadata_as_proof.sql +2 -2
- package/tests/mutations/717-f2b/M4_mc_metadata_as_proof.sql +2 -2
- package/tests/mutations/717-f2b/M5_dm_any_mode.sql +2 -2
- package/tests/mutations/717-f2b/M6_dm_board_delivery_counts.sql +2 -2
- package/tests/mutations/717-f2b/M7_mc_any_mode.sql +2 -2
- package/tests/mutations/717-f2b/M8_dm_thread_stamp_as_proof.sql +2 -2
- package/tests/mutations/717-f2b/M9_dm_lookup_any_author.sql +2 -2
- package/tests/mutations/717-f2b/run.sh +2 -2
- package/tests/mutations/919/M10_quoted_net_http_post_scratch.sql +5 -0
- package/tests/mutations/919/M11_pbm_calls_public.sql +11 -0
- package/tests/mutations/919/M1_pbm_refusal_swallowed_after_write.sql +14 -0
- package/tests/mutations/919/M2_cof_refusal_swallowed_after_write.sql +13 -0
- package/tests/mutations/919/M3_pbm_receipt_fault_swallowed.sql +10 -0
- package/tests/mutations/919/M4_pg_notify_scratch.sql +5 -0
- package/tests/mutations/919/M5_dynamic_notify_scratch.sql +5 -0
- package/tests/mutations/919/M6_trigger_outside_schema.sql +3 -0
- package/tests/mutations/919/M7_pbm_step_up_gate.sql +10 -0
- package/tests/mutations/919/M8_pbm_positive_writes_nothing.sql +10 -0
- package/tests/mutations/919/M9_cof_positive_writes_nothing.sql +10 -0
- package/tests/mutations/919/run.sh +81 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- M-B4j: the writer passes current_agent_id() instead of the session-derived actor
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._insert_thread_message(uuid,uuid,text,text,uuid,jsonb,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$agent_board._actor_can_read_message(v_actor_agent_id, v_reply_parent_id)$a$;
|
|
8
|
+
r := $r$agent_board._actor_can_read_message(agent_board.current_agent_id(), v_reply_parent_id)$r$;
|
|
9
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (M-B4j)'; end if;
|
|
10
|
+
d := replace(d, a, r);
|
|
11
|
+
execute d;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- M-B4k: a policy edit: the delegate messages policy loses its InitPlan wrapper
|
|
2
|
+
alter policy agent_board_delegate_select_messages on agent_board.messages
|
|
3
|
+
using (exists (select 1 from agent_board.delivery_recipients dr
|
|
4
|
+
where dr.source_message_id = messages.id
|
|
5
|
+
and dr.board_id = any (agent_board._delegate_visible_board_ids())));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
-- M-B4l: a policy SUB-READ narrows: the authenticated board_memberships policy stops admitting subscribed rows (panel #921 R1 F1)
|
|
2
|
+
alter policy agent_board_authenticated_select_board_memberships on agent_board.board_memberships
|
|
3
|
+
using (agent_id = agent_board.current_agent_id() and membership_state <> 'subscribed');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- W-1: the writer copy's authenticated arm drops membership_state in ('joined','subscribed')
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ and bm.agent_id = p_actor_agent_id
|
|
8
|
+
and bm.membership_state in ('joined', 'subscribed')))))$a$;
|
|
9
|
+
r := $r$ and bm.agent_id = p_actor_agent_id))))$r$;
|
|
10
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-1)'; end if;
|
|
11
|
+
d := replace(d, a, r);
|
|
12
|
+
execute d;
|
|
13
|
+
end $m$;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- W-2: the writer copy's authenticated arm drops the bm.agent_id binding
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ and bm.agent_id = p_actor_agent_id
|
|
8
|
+
$a$;
|
|
9
|
+
r := $r$$r$;
|
|
10
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-2)'; end if;
|
|
11
|
+
d := replace(d, a, r);
|
|
12
|
+
execute d;
|
|
13
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- W-3: the writer copy's delivery arm drops the recipient binding
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ and (dr.recipient_agent_id = p_actor_agent_id$a$;
|
|
8
|
+
r := $r$ and (dr.recipient_agent_id is not null$r$;
|
|
9
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-3)'; end if;
|
|
10
|
+
d := replace(d, a, r);
|
|
11
|
+
execute d;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- W-4: the writer copy's delegate arm drops dr.board_id = any (...)
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ and dr.board_id = any (coalesce(($a$;
|
|
8
|
+
r := $r$ and (dr.board_id = any (coalesce(($r$;
|
|
9
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-4)'; end if;
|
|
10
|
+
d := replace(d, a, r);
|
|
11
|
+
a := $a$'{}'::uuid[])))
|
|
12
|
+
else$a$;
|
|
13
|
+
r := $r$'{}'::uuid[])) or true))
|
|
14
|
+
else$r$;
|
|
15
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-4)'; end if;
|
|
16
|
+
d := replace(d, a, r);
|
|
17
|
+
execute d;
|
|
18
|
+
end $m$;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- W-5: the writer copy's board-set derivation drops its membership-state filter
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ where bm.agent_id = p_actor_agent_id
|
|
8
|
+
and bm.membership_state in ('joined', 'subscribed')), '{}'::uuid[])))$a$;
|
|
9
|
+
r := $r$ where bm.agent_id = p_actor_agent_id), '{}'::uuid[])))$r$;
|
|
10
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-5)'; end if;
|
|
11
|
+
d := replace(d, a, r);
|
|
12
|
+
execute d;
|
|
13
|
+
end $m$;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- W-6: the writer copy's board-set derivation drops its agent binding (exposed by Y1)
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board._actor_can_read_message(uuid,uuid)'::regprocedure);
|
|
5
|
+
a text; r text;
|
|
6
|
+
begin
|
|
7
|
+
a := $a$ where bm.agent_id = p_actor_agent_id
|
|
8
|
+
and bm.membership_state$a$;
|
|
9
|
+
r := $r$ where true
|
|
10
|
+
and bm.membership_state$r$;
|
|
11
|
+
if a = '' or (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (W-6)'; end if;
|
|
12
|
+
d := replace(d, a, r);
|
|
13
|
+
execute d;
|
|
14
|
+
end $m$;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# #655 REPLYTO mutation receipts (AGENTS.md rule 2; plan §8.9 M-* and W-*, NIT-8). Same method as
|
|
3
|
+
# ../919/run.sh, against SEVERAL test files, because the rows a mutant must turn red live in the
|
|
4
|
+
# reply suite, the refusal-atomicity suite and the re-keyed class files. Run against a database
|
|
5
|
+
# whose bundle was applied by scripts/run-agent-board-schema-tests.sh. Connection comes ONLY from the
|
|
6
|
+
# libpq environment (PGHOST/PGPORT/PGUSER/PGPASSWORD/PGDATABASE), never argv. The target must be an
|
|
7
|
+
# OWNED database holding this tree's applied bundle (CI: a throwaway job's Supabase).
|
|
8
|
+
#
|
|
9
|
+
# Per mutation:
|
|
10
|
+
# applied the mutation runs ALONE in a rolled-back transaction with ON_ERROR_STOP, and the catalog
|
|
11
|
+
# fingerprint (every non-system routine with argument names, ACL, body, volatility, definer
|
|
12
|
+
# flag and comment; every user trigger; every agent_board constraint, view definition and
|
|
13
|
+
# reloptions, and policy; the delegate allow set) read inside that transaction must differ
|
|
14
|
+
# from the baseline. An anchor miss raises 'MUTATION ANCHOR MISS' and is NOT APPLIED.
|
|
15
|
+
# overloads (NIT-8) inside the same transaction, the overload count of every agent_board routine
|
|
16
|
+
# name that existed before must be unchanged: a mutant that creates an overload instead of
|
|
17
|
+
# replacing the function is reported INERT, never counted as a kill.
|
|
18
|
+
# pgTAP for each test file: the mutation and the file run in ONE transaction that is rolled
|
|
19
|
+
# back; plan, emitted, ok and not ok are COUNTED from the TAP, every failing line is
|
|
20
|
+
# listed, and an aborted file (emitted < plan) is reported ABORTED.
|
|
21
|
+
# The fingerprint must equal the baseline after every leg (nothing leaked past a rollback).
|
|
22
|
+
# Usage: run.sh <receipt-path> [mutation.sql ...] (default: every *.sql beside this script)
|
|
23
|
+
# TESTS="a.test.sql b.test.sql" overrides the test files (names relative to tests/).
|
|
24
|
+
set -uo pipefail
|
|
25
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
26
|
+
PKG="$(cd "$HERE/../../.." && pwd)"
|
|
27
|
+
TDIR="$PKG/tests"
|
|
28
|
+
read -r -a TESTS <<< "${TESTS:-agent_board_reply_to.test.sql agent_board_refusal_atomicity.test.sql agent_board_661_reply_delivery.test.sql agent_board_667_history_class.test.sql agent_board_717_message_replay_scope.test.sql agent_board_delegate_role_class.test.sql agent_board_grants_hygiene.test.sql}"
|
|
29
|
+
OUT="${1:?receipt path}"; shift
|
|
30
|
+
if [ "$#" -gt 0 ]; then
|
|
31
|
+
MUTS=()
|
|
32
|
+
for m in "$@"; do
|
|
33
|
+
[ -f "$m" ] || { echo "FATAL: mutation file not found: $m" >&2; exit 3; }
|
|
34
|
+
MUTS+=("$(cd "$(dirname "$m")" && pwd)/$(basename "$m")")
|
|
35
|
+
done
|
|
36
|
+
else mapfile -t MUTS < <(find "$HERE" -maxdepth 1 -name '*.sql' | sort -V); fi
|
|
37
|
+
[ "${#MUTS[@]}" -gt 0 ] || { echo "FATAL: no mutation files" >&2; exit 3; }
|
|
38
|
+
[ -n "${PGDATABASE:-}" ] || { echo "FATAL: PGDATABASE unset (libpq environment required)" >&2; exit 3; }
|
|
39
|
+
P=(psql -X -qtA)
|
|
40
|
+
FPSQL="select md5(coalesce((select string_agg(p.oid::regprocedure::text || coalesce(p.proargnames::text, '') || coalesce(p.proacl::text, '') || p.prosrc || p.provolatile::text || p.prosecdef::text || coalesce(obj_description(p.oid, 'pg_proc'), ''), '|' order by p.oid::regprocedure::text) from pg_proc p where p.pronamespace not in ('pg_catalog'::regnamespace, 'information_schema'::regnamespace)), '') || coalesce((select string_agg(t.tgrelid::regclass::text || '.' || t.tgname || ':' || t.tgfoid::regprocedure::text, '|' order by t.tgrelid::regclass::text, t.tgname) from pg_trigger t where not t.tgisinternal), '') || coalesce((select string_agg(c.conrelid::regclass::text || '.' || c.conname || ':' || pg_get_constraintdef(c.oid) || c.convalidated::text, '|' order by c.conrelid::regclass::text, c.conname) from pg_constraint c where c.connamespace = 'agent_board'::regnamespace), '') || coalesce((select string_agg(c.relname || ':' || pg_get_viewdef(c.oid) || coalesce(array_to_string(c.reloptions, ','), '') || coalesce(c.relacl::text, ''), '|' order by c.relname) from pg_class c where c.relnamespace = 'agent_board'::regnamespace and c.relkind = 'v'), '') || coalesce((select string_agg(polrelid::regclass::text || '.' || polname || ':' || coalesce(pg_get_expr(polqual, polrelid), ''), '|' order by polrelid::regclass::text, polname) from pg_policy), '') || coalesce((select string_agg(kind || signature, '|' order by kind, signature) from agent_board.delegate_allowed_operations), ''))"
|
|
41
|
+
OVSQL="select coalesce(string_agg(proname || '=' || n, ',' order by proname), '') from (select proname, count(*) n from pg_proc where pronamespace = 'agent_board'::regnamespace group by proname) x"
|
|
42
|
+
fp() { "${P[@]}" -c "$FPSQL"; }
|
|
43
|
+
ORIG="$(fp)"
|
|
44
|
+
[ -n "$ORIG" ] || { echo "FATAL: could not read the catalog fingerprint" >&2; exit 3; }
|
|
45
|
+
OV0="$("${P[@]}" -c "$OVSQL")"
|
|
46
|
+
|
|
47
|
+
applied() { # $1 mutation file -> 'applied overloads-unchanged' / 'NOT APPLIED: ...' / 'INERT: ...'
|
|
48
|
+
local out fpl ovl changed
|
|
49
|
+
out="$(printf 'begin;\n\\set ON_ERROR_STOP 1\n\\i %s\n%s;\n%s;\nrollback;\n' "$1" "$FPSQL" "$OVSQL" | "${P[@]}" 2>&1)"
|
|
50
|
+
if grep -qiE '(error|fatal):' <<<"$out"; then
|
|
51
|
+
echo "NOT APPLIED: $(grep -iE '(error|fatal):' <<<"$out" | head -1)"; return
|
|
52
|
+
fi
|
|
53
|
+
fpl="$(tail -2 <<<"$out" | head -1)"; ovl="$(tail -1 <<<"$out")"
|
|
54
|
+
if [ "$fpl" = "$ORIG" ]; then echo "NOT APPLIED: catalog fingerprint unchanged (no-op)"; return; fi
|
|
55
|
+
changed="$(OV0="$OV0" OVL="$ovl" python3 -c '
|
|
56
|
+
import os
|
|
57
|
+
a=dict(x.split("=") for x in os.environ["OV0"].split(",") if x)
|
|
58
|
+
b=dict(x.split("=") for x in os.environ["OVL"].split(",") if x)
|
|
59
|
+
print(",".join(f"{k}:{a[k]}->{b.get(k,0)}" for k in sorted(a) if b.get(k,"0")!=a[k]))')"
|
|
60
|
+
if [ -n "$changed" ]; then echo "INERT: overload count changed ($changed)"; else echo "applied; overloads unchanged"; fi
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
tap() { # $1 label, $2 mutation file or empty, $3 test file
|
|
64
|
+
local out plan ok nok t="$TDIR/$3"
|
|
65
|
+
if [ -n "$2" ]; then out="$(printf 'begin;\n\\i %s\n\\i %s\nrollback;\n' "$2" "$t" | "${P[@]}" 2>&1)"
|
|
66
|
+
else out="$(printf 'begin;\n\\i %s\nrollback;\n' "$t" | "${P[@]}" 2>&1)"; fi
|
|
67
|
+
plan="$(sed -nE 's/^1\.\.([0-9]+)$/\1/p' <<<"$out" | head -1)"
|
|
68
|
+
ok="$(grep -cE '^ok [0-9]+' <<<"$out" || true)"; nok="$(grep -cE '^not ok [0-9]+' <<<"$out" || true)"
|
|
69
|
+
printf ' %s %s: plan=%s emitted=%s ok=%s not_ok=%s%s\n' "$1" "${3%.test.sql}" "${plan:-NONE}" "$((ok + nok))" "$ok" "$nok" \
|
|
70
|
+
"$([ "${plan:-x}" = "$((ok + nok))" ] || echo ' ABORTED')"
|
|
71
|
+
grep -E '^not ok [0-9]+' <<<"$out" | sed 's/^/ /'
|
|
72
|
+
grep -iE '(error|fatal):' <<<"$out" | head -2 | sed 's/^/ ERR /'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
{
|
|
76
|
+
echo "# #655 REPLYTO mutation receipt -- $(date -u +%FT%TZ)"
|
|
77
|
+
echo "# tree $(git -C "$PKG" rev-parse HEAD)$(git -C "$PKG" diff --quiet HEAD -- . || echo ' + uncommitted changes')"
|
|
78
|
+
for t in "${TESTS[@]}"; do echo "# test $t [sha256 $(sha256sum "$TDIR/$t" | cut -c1-16)]"; done
|
|
79
|
+
echo "# catalog fingerprint before: $ORIG"
|
|
80
|
+
for t in "${TESTS[@]}"; do tap "BASELINE" "" "$t"; done
|
|
81
|
+
for m in "${MUTS[@]}"; do
|
|
82
|
+
name="$(basename "$m" .sql)"
|
|
83
|
+
echo "-- $name: $(head -1 "$m" | sed 's/^-- //') [sha256 $(sha256sum "$m" | cut -c1-16)]"
|
|
84
|
+
status="$(applied "$m")"
|
|
85
|
+
echo " $status"
|
|
86
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back apply leg of $name"; exit 3; }
|
|
87
|
+
case "$status" in applied*) ;; *) continue ;; esac
|
|
88
|
+
for t in "${TESTS[@]}"; do tap "$name" "$m" "$t"; done
|
|
89
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back pgTAP legs of $name"; exit 3; }
|
|
90
|
+
done
|
|
91
|
+
for t in "${TESTS[@]}"; do tap "AFTER" "" "$t"; done
|
|
92
|
+
echo "# catalog fingerprint after: $(fp)"
|
|
93
|
+
} | tee "$OUT"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- post_board_message: the idempotency advisory lock is removed
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
-
'post_board_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
4
|
+
'post_board_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'; end if;
|
|
5
5
|
n := replace(d, $q$ perform agent_board._lock_idempotency_key(
|
|
6
6
|
'post_board_message:'$q$, $q$ perform concat(
|
|
7
7
|
'post_board_message:'$q$);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- post_message: mints a receipt when its caller metadata carries an idempotencyKey
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_message(uuid,uuid,text,text,uuid,jsonb)'::regprocedure); n text; begin
|
|
3
|
-
if position($q$ return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_message(uuid,uuid,text,text,uuid,jsonb)'; end if;
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_message(uuid,uuid,text,text,uuid,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_message(uuid,uuid,text,text,uuid,jsonb,uuid)'; end if;
|
|
4
4
|
n := replace(d, $q$ return query select v_message.message_id,v_message.thread_id,v_message.task_id,$q$, $q$ if p_metadata ? 'idempotencyKey' then
|
|
5
5
|
perform agent_board._record_send_outcome(coalesce(p_metadata ->> 'rpcName', 'post_board_message'), v_message.message_id,
|
|
6
6
|
p_metadata ->> 'idempotencyKey', v_board_id);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- send_direct_message: the helper is called on the replay branch too
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ if v_inserted and v_idempotency_key is not null then
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'; end if;
|
|
5
5
|
n := replace(d, $q$ if v_inserted and v_idempotency_key is not null then
|
|
6
6
|
$q$, $q$ if v_idempotency_key is not null then
|
|
7
7
|
$q$);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- send_multicast_message: the helper is called on the replay branch too
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ if v_inserted and v_idempotency_key is not null then
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'; end if;
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'; end if;
|
|
5
5
|
n := replace(d, $q$ if v_inserted and v_idempotency_key is not null then
|
|
6
6
|
$q$, $q$ if v_idempotency_key is not null then
|
|
7
7
|
$q$);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- post_board_message: the helper is called on the replay branch too
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ if v_inserted and v_idempotency_key is not null then
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'; end if;
|
|
5
5
|
n := replace(d, $q$ if v_inserted and v_idempotency_key is not null then
|
|
6
6
|
$q$, $q$ if v_idempotency_key is not null then
|
|
7
7
|
$q$);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
-- post_board_message: delivery is wrapped in exception when others then null
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ select d.delivered_recipient_count, d.callback_outbox_count
|
|
4
4
|
into v_delivered_count, v_callback_count
|
|
5
5
|
from agent_board._deliver_board_message(v_message.id, trim(p_subject), p_body, p_priority) d;
|
|
6
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
6
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'; end if;
|
|
7
7
|
n := replace(d, $q$ select d.delivered_recipient_count, d.callback_outbox_count
|
|
8
8
|
into v_delivered_count, v_callback_count
|
|
9
9
|
from agent_board._deliver_board_message(v_message.id, trim(p_subject), p_body, p_priority) d;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- post_board_message: the board is put back into the idempotency lock key
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'; end if;
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'; end if;
|
|
5
5
|
n := replace(d, $q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,
|
|
6
6
|
$q$, $q$ 'post_board_message:' || p_thread_id::text || ':' || v_actor_agent_id::text || ':' || p_board_id::text,
|
|
7
7
|
$q$);
|
|
@@ -26,7 +26,7 @@ if [ "$#" -gt 0 ]; then MUTS=("$@"); else mapfile -t MUTS < <(find "$HERE" -maxd
|
|
|
26
26
|
ISO="$(ls -1 /usr/lib/postgresql/*/lib/pgxs/src/test/isolation/isolationtester 2>/dev/null | sort -V | tail -1)"
|
|
27
27
|
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
|
28
28
|
P=(psql -X -qtA)
|
|
29
|
-
FNS=("agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)")
|
|
29
|
+
FNS=("agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)")
|
|
30
30
|
fp() { "${P[@]}" -c "select md5(coalesce((select string_agg(p.oid::regprocedure::text || coalesce(p.proacl::text, '') || p.prosrc || p.provolatile::text || coalesce(obj_description(p.oid, 'pg_proc'), ''), '|' order by p.oid::regprocedure::text) from pg_proc p where p.pronamespace = 'agent_board'::regnamespace), '') || coalesce((select string_agg(conname || pg_get_constraintdef(oid), '|' order by conname) from pg_constraint where conrelid = 'agent_board.send_outcomes'::regclass), '') || coalesce((select relacl::text from pg_class where oid = 'agent_board.send_outcomes'::regclass), ''))"; }
|
|
31
31
|
: > "$WORK/restore.sql"
|
|
32
32
|
for f in "${FNS[@]}"; do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,text,text,text,text,text,text,text,jsonb)'::regprocedure);
|
|
1
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,text,text,text,text,text,text,text,jsonb,uuid)'::regprocedure);
|
|
2
2
|
hdr text; body text;
|
|
3
3
|
begin
|
|
4
4
|
hdr := split_part(d, '$function$', 1); body := split_part(d, '$function$', 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
revoke execute on function agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb) from service_role;
|
|
1
|
+
revoke execute on function agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid) from service_role;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- direct: the idempotency lock is keyed by recipient (split domain)
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
-
if position($q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, 60); end if;
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, 60); end if;
|
|
4
4
|
n := replace(d, $q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, $q$ 'send_direct_message:' || p_thread_id::text || ':' || v_actor_agent_id::text || ':' || p_recipient_agent_id::text,$q$);
|
|
5
5
|
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
6
|
d := n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- direct: the idempotency lock is removed
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
-
'send_direct_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
+
'send_direct_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ perform agent_board._lock_idempotency_key(
|
|
5
5
|
'send_direct_message:'$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ perform agent_board._lock_idempotency_key(
|
|
7
7
|
'send_direct_message:'$q$, $q$ perform concat(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- multicast: the idempotency lock is keyed by the recipient set (split domain)
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
-
if position($q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, 60); end if;
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, 60); end if;
|
|
4
4
|
n := replace(d, $q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text,$q$, $q$ 'send_multicast_message:' || p_thread_id::text || ':' || v_actor_agent_id::text || ':' || array_to_string(v_recipient_ids, ','),$q$);
|
|
5
5
|
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
6
|
d := n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- multicast: the idempotency lock is removed
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
-
'send_multicast_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ perform agent_board._lock_idempotency_key(
|
|
4
|
+
'send_multicast_message:'$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ perform agent_board._lock_idempotency_key(
|
|
5
5
|
'send_multicast_message:'$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ perform agent_board._lock_idempotency_key(
|
|
7
7
|
'send_multicast_message:'$q$, $q$ perform concat(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
do $m$
|
|
3
3
|
declare d text; s int; e int;
|
|
4
4
|
begin
|
|
5
|
-
foreach d in array array[pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure), pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure)] loop
|
|
5
|
+
foreach d in array array[pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure), pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure)] loop
|
|
6
6
|
s := position(' -- #717 F2b:' in d);
|
|
7
7
|
e := position(' raise exception ''message replay cannot widen delivery scope'' using errcode = ''42501'';
|
|
8
8
|
end if;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- multicast: the replay lookup is widened across authors
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ where thread_id = p_thread_id
|
|
4
4
|
and author_agent_id = v_actor_agent_id
|
|
5
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ where thread_id = p_thread_id
|
|
5
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ where thread_id = p_thread_id
|
|
6
6
|
and author_agent_id = v_actor_agent_id
|
|
7
7
|
$q$, 60); end if;
|
|
8
8
|
n := replace(d, $q$ where thread_id = p_thread_id
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- direct: the core swallows its refusal and returns nothing
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
-
if position($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, 60); end if;
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, 60); end if;
|
|
4
4
|
n := replace(d, $q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, $q$ return;$q$);
|
|
5
5
|
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
6
|
d := n;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
-- multicast: the core swallows its refusal and returns nothing
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
3
|
-
if position($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, 60); end if;
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
|
+
if position($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, 60); end if;
|
|
4
4
|
n := replace(d, $q$ raise exception 'message replay cannot widen delivery scope' using errcode = '42501';$q$, $q$ return;$q$);
|
|
5
5
|
if n = d then raise exception 'mutation is a no-op'; end if;
|
|
6
6
|
d := n;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
do $m$
|
|
2
|
-
declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure);
|
|
2
|
+
declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure);
|
|
3
3
|
anchor text := ' and dr.source_message_id = v_message.id';
|
|
4
4
|
begin
|
|
5
5
|
if position(anchor in d)=0 then raise exception 'missing anchor'; end if;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- direct: the replay ceiling never fires
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ if v_message.id is not null and not exists (
|
|
4
4
|
select 1
|
|
5
|
-
from agent_board.delivery_recipients dr$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ if v_message.id is not null and not exists (
|
|
5
|
+
from agent_board.delivery_recipients dr$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ if v_message.id is not null and not exists (
|
|
6
6
|
select 1
|
|
7
7
|
from agent_board.delivery_recipients dr$q$, 60); end if;
|
|
8
8
|
n := replace(d, $q$ if v_message.id is not null and not exists (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- multicast: the replay ceiling never fires
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ if v_message.id is not null and exists (
|
|
4
4
|
select 1
|
|
5
|
-
from unnest(v_recipient_ids) as requested(recipient_id)$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ if v_message.id is not null and exists (
|
|
5
|
+
from unnest(v_recipient_ids) as requested(recipient_id)$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ if v_message.id is not null and exists (
|
|
6
6
|
select 1
|
|
7
7
|
from unnest(v_recipient_ids) as requested(recipient_id)$q$, 60); end if;
|
|
8
8
|
n := replace(d, $q$ if v_message.id is not null and exists (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- direct: caller metadata naming the recipient substitutes for a delivery
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.board_id is null
|
|
4
|
-
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ and dr.board_id is null
|
|
4
|
+
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.board_id is null
|
|
5
5
|
) then$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ and dr.board_id is null
|
|
7
7
|
) then$q$, $q$ and dr.board_id is null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- multicast: caller metadata naming the recipient substitutes for a delivery
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.board_id is null
|
|
4
4
|
)
|
|
5
|
-
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ and dr.board_id is null
|
|
5
|
+
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.board_id is null
|
|
6
6
|
)
|
|
7
7
|
) then$q$, 60); end if;
|
|
8
8
|
n := replace(d, $q$ and dr.board_id is null
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- direct: a delivery of the source in ANY mode counts as proof
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.delivery_mode = 'direct'
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ and dr.delivery_mode = 'direct'
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.delivery_mode = 'direct'
|
|
5
5
|
$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ and dr.delivery_mode = 'direct'
|
|
7
7
|
$q$, $q$$q$);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- direct: the `board_id is null` conjunct is dropped (EQUIVALENT given delivery_recipients_board_scope; see C6 and assertion 64)
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.board_id is null
|
|
4
|
-
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ and dr.board_id is null
|
|
4
|
+
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.board_id is null
|
|
5
5
|
) then$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ and dr.board_id is null
|
|
7
7
|
) then$q$, $q$ ) then$q$);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- multicast: a delivery of the source in ANY mode counts as proof
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.delivery_mode = 'multicast'
|
|
4
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb): %', left($q$ and dr.delivery_mode = 'multicast'
|
|
4
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.delivery_mode = 'multicast'
|
|
5
5
|
$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ and dr.delivery_mode = 'multicast'
|
|
7
7
|
$q$, $q$$q$);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
-- direct: a recipient on the thread's stamped board counts as proof
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ and dr.board_id is null
|
|
4
|
-
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ and dr.board_id is null
|
|
4
|
+
) then$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ and dr.board_id is null
|
|
5
5
|
) then$q$, 60); end if;
|
|
6
6
|
n := replace(d, $q$ and dr.board_id is null
|
|
7
7
|
) then$q$, $q$ and dr.board_id is null
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- direct: the replay lookup is widened across authors
|
|
2
|
-
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure); n text; begin
|
|
2
|
+
do $m$ declare d text := pg_get_functiondef('agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure); n text; begin
|
|
3
3
|
if position($q$ where thread_id = p_thread_id
|
|
4
4
|
and author_agent_id = v_actor_agent_id
|
|
5
|
-
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb): %', left($q$ where thread_id = p_thread_id
|
|
5
|
+
$q$ in d) = 0 then raise exception 'mutation anchor not found in agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid): %', left($q$ where thread_id = p_thread_id
|
|
6
6
|
and author_agent_id = v_actor_agent_id
|
|
7
7
|
$q$, 60); end if;
|
|
8
8
|
n := replace(d, $q$ where thread_id = p_thread_id
|
|
@@ -25,8 +25,8 @@ ISO="$(ls -1 /usr/lib/postgresql/*/lib/pgxs/src/test/isolation/isolationtester 2
|
|
|
25
25
|
[ -x "$ISO" ] || { echo "FATAL: isolationtester not found" >&2; exit 3; }
|
|
26
26
|
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
|
27
27
|
P=(psql -X -qtA)
|
|
28
|
-
FNS=("agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)"
|
|
29
|
-
"agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb)"
|
|
28
|
+
FNS=("agent_board.send_direct_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)"
|
|
29
|
+
"agent_board.send_multicast_message(uuid,uuid,uuid[],text,text,text,text,text,jsonb,uuid)"
|
|
30
30
|
"agent_board.signed_send_direct_message(jsonb,jsonb)"
|
|
31
31
|
"agent_board.signed_send_multicast_message(jsonb,jsonb)")
|
|
32
32
|
fp() { "${P[@]}" -c "select md5(string_agg(p.oid::regprocedure::text || coalesce(p.proacl::text, '') || p.prosrc || coalesce(obj_description(p.oid, 'pg_proc'), ''), '|' order by p.oid::regprocedure::text)) from pg_proc p where p.pronamespace = 'agent_board'::regnamespace"; }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- a scratch agent_board function calls pg_net through QUOTED identifiers, "net"."http_post"(...) (#920 R1 B1); must fail RA-SE-0 and RA-SE-1, naming agent_board.m919_scratch_quoted() [http_call] and [pg_net]
|
|
2
|
+
create function agent_board.m919_scratch_quoted() returns void language plpgsql as $s$
|
|
3
|
+
begin
|
|
4
|
+
perform "net"."http_post"('https://example.test');
|
|
5
|
+
end $s$;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- post_board_message calls a public function, outside the schema RA-SE-1 and fn_call_closure read (#920 R1 F2); must fail RA-EXT-1, naming public.m919_ext()
|
|
2
|
+
create function public.m919_ext() returns void language plpgsql as $e$ begin null; end $e$;
|
|
3
|
+
do $m$
|
|
4
|
+
declare
|
|
5
|
+
d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure);
|
|
6
|
+
a text := E' perform agent_board._record_send_outcome(''post_board_message'', v_message.id, v_idempotency_key, p_board_id);\n';
|
|
7
|
+
r text := a || E' perform public.m919_ext();\n';
|
|
8
|
+
begin
|
|
9
|
+
if (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (M11)'; end if;
|
|
10
|
+
execute replace(d, a, r);
|
|
11
|
+
end $m$;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- post_board_message: the non-member refusal first INSERTS a message, then raises inside a swallowed EXCEPTION block and returns a row; must fail RA-R1, RA-R1 rows, RA-R1 catalog
|
|
2
|
+
do $m$
|
|
3
|
+
declare
|
|
4
|
+
d text := pg_get_functiondef('agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb,uuid)'::regprocedure);
|
|
5
|
+
a text := E'\n if not agent_board._current_agent_has_board_access(p_board_id) then\n raise exception ''board not accessible to current agent'' using errcode = ''42501'';\n end if;\n';
|
|
6
|
+
r text := E'\n if not agent_board._current_agent_has_board_access(p_board_id) then\n'
|
|
7
|
+
|| E' insert into agent_board.messages(thread_id, author_agent_id, message_sequence, body)\n'
|
|
8
|
+
|| E' values (p_thread_id, v_actor_agent_id, agent_board._next_thread_message_sequence(p_thread_id), ''m919 partial write'');\n'
|
|
9
|
+
|| E' begin\n raise exception ''board not accessible to current agent'' using errcode = ''42501'';\n'
|
|
10
|
+
|| E' exception when others then\n return query select null::uuid, p_board_id, 0, 0, now();\n return;\n end;\n end if;\n';
|
|
11
|
+
begin
|
|
12
|
+
if (length(d) - length(replace(d, a, ''))) / length(a) <> 1 then raise exception 'MUTATION ANCHOR MISS (M1)'; end if;
|
|
13
|
+
execute replace(d, a, r);
|
|
14
|
+
end $m$;
|