@consiliency/agent-board-schema 1.75.0 → 1.79.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 +16 -0
- package/migrations/20261109000100_agent_board_step_up_groundwork.sql +343 -0
- package/migrations/20261120000200_agent_board_thread_key_serialize.sql +118 -0
- package/migrations/20261121000100_agent_board_thread_key_guards.sql +196 -0
- package/migrations/20261124000100_agent_board_step_up_enforcement.sql +1213 -0
- package/package.json +1 -1
- package/schema-manifest.json +39 -3
- package/src/deployment-drift-main.test.mjs +89 -6
- package/src/deployment-drift.test.mjs +20 -1
- package/src/tooling.test.mjs +10 -2
- package/tests/agent_board_717_message_replay_scope.test.sql +39 -2
- package/tests/agent_board_717_tasking_replay_scope.test.sql +21 -2
- package/tests/agent_board_enrollment_audit_content.test.sql +6 -1
- package/tests/agent_board_role_guard.test.sql +3 -1
- package/tests/agent_board_send_outcome.test.sql +39 -1
- package/tests/agent_board_session_identity_approval_revocation.test.sql +5 -0
- package/tests/agent_board_step_up.test.sql +991 -0
- package/tests/agent_board_step_up_helper.test.sql +815 -0
- package/tests/agent_board_thread_key_guards.test.sql +186 -0
- package/tests/agent_board_thread_key_serialize.test.sql +182 -0
- package/tests/agent_board_write_enforcement_class.test.sql +8 -4
- package/tests/catalog/function_execute_privileges.json +72 -0
- package/tests/catalog/p_metadata_parameters.json +32 -0
- package/tests/catalog/step_up_gated_closure.json +24 -0
- package/tests/fixtures/pgtap-unexposed.sql +9 -4
- package/tests/isolation/expected/create_or_find_thread_same_key_race.out +641 -0
- package/tests/isolation/expected/session_identity_links.out +4 -0
- package/tests/isolation/specs/create_or_find_thread_same_key_race.spec +252 -0
- package/tests/isolation/specs/session_identity_links.spec +5 -0
- package/tests/mutations/669/M10_service_role_blanket.sql +10 -0
- package/tests/mutations/669/M12a_no_parse_wrapper.sql +17 -0
- package/tests/mutations/669/M12b_no_session_wrapper.sql +23 -0
- package/tests/mutations/669/M12c_no_claim_type_guard.sql +13 -0
- package/tests/mutations/669/M12d_no_amr_element_guards.sql +15 -0
- package/tests/mutations/669/M14_now_not_clock.sql +9 -0
- package/tests/mutations/669/M15_classifier_reads_metadata.sql +17 -0
- package/tests/mutations/669/M17_skip_ledger.sql +15 -0
- package/tests/mutations/669/M18_service_role_sub_insensitive.sql +9 -0
- package/tests/mutations/669/M18b_drop_uid_conjunct.sql +9 -0
- package/tests/mutations/669/M23_definer_wrapper_over_writer.sql +5 -0
- package/tests/mutations/669/M3_age_from_iat.sql +9 -0
- package/tests/mutations/669/M4_window_900.sql +9 -0
- package/tests/mutations/669/M4b_lt_to_le.sql +9 -0
- package/tests/mutations/669/M5_no_skew_bound.sql +9 -0
- package/tests/mutations/669/M6a_user_metadata_amr.sql +9 -0
- package/tests/mutations/669/M6b_app_metadata_claim.sql +9 -0
- package/tests/mutations/669/M6c_legacy_guc.sql +9 -0
- package/tests/mutations/669/M7_either_claim_any_human.sql +9 -0
- package/tests/mutations/669/M8_any_amr_method.sql +9 -0
- package/tests/mutations/669/M8b_accept_aal2.sql +9 -0
- package/tests/mutations/669/M9_every_kind.sql +9 -0
- package/tests/mutations/669/MAL_allowlist_nonempty.sql +9 -0
- package/tests/mutations/669/MAR_writer_arg_renamed.sql +14 -0
- package/tests/mutations/669/MAU_audit_mode_retyped.sql +2 -0
- package/tests/mutations/669/MA_helper_always_raises.sql +10 -0
- package/tests/mutations/669/MDX_dynamic_execute_definer.sql +5 -0
- package/tests/mutations/669/MD_detail_carries_value.sql +12 -0
- package/tests/mutations/669/MEC0_caller_of_helper.sql +4 -0
- package/tests/mutations/669/MEC0b_overload_caller.sql +4 -0
- package/tests/mutations/669/MG1_helper_granted_authenticated.sql +2 -0
- package/tests/mutations/669/MG2_ledger_insert_authenticated.sql +2 -0
- package/tests/mutations/669/MG3_ledger_policy.sql +2 -0
- package/tests/mutations/669/MR1_writer_no_class_check.sql +9 -0
- package/tests/mutations/669/MR2_writer_wide_window.sql +9 -0
- package/tests/mutations/669/MR3_writer_prunes_everyone.sql +11 -0
- package/tests/mutations/669/MR4_writer_lower_exclusive.sql +9 -0
- package/tests/mutations/669/MR5_writer_upper_exclusive.sql +9 -0
- package/tests/mutations/669/MR6_writer_upper_61.sql +9 -0
- package/tests/mutations/669/MW2_second_ledger_writer.sql +4 -0
- package/tests/mutations/669/MXS_cross_schema_wrapper.sql +4 -0
- package/tests/mutations/669/run.sh +80 -0
- package/tests/mutations/669b/M11_ceil_first.sql +10 -0
- package/tests/mutations/669b/M11_gate_first.sql +10 -0
- package/tests/mutations/669b/M11_grant_first.sql +10 -0
- package/tests/mutations/669b/M11_inv_first.sql +10 -0
- package/tests/mutations/669b/M11_mem_first.sql +10 -0
- package/tests/mutations/669b/M11_readmit_first.sql +10 -0
- package/tests/mutations/669b/M13a_gate_member_preset.sql +12 -0
- package/tests/mutations/669b/M13b_ungate_admin_preset.sql +12 -0
- package/tests/mutations/669b/M16_actor_is_target.sql +14 -0
- package/tests/mutations/669b/M19_drop_readmit.sql +9 -0
- package/tests/mutations/669b/M1_drop_grant.sql +9 -0
- package/tests/mutations/669b/M20_drop_d5_refusal.sql +9 -0
- package/tests/mutations/669b/M21_drop_removal.sql +9 -0
- package/tests/mutations/669b/M21b_only_removed.sql +9 -0
- package/tests/mutations/669b/M21c_gate_members.sql +12 -0
- package/tests/mutations/669b/M21d_requested_state.sql +9 -0
- package/tests/mutations/669b/M23b_api_wrapper_over_audit_writer.sql +6 -0
- package/tests/mutations/669b/M23c_drop_register_type_refusal.sql +9 -0
- package/tests/mutations/669b/M24_drop_kind_refusal.sql +9 -0
- package/tests/mutations/669b/M24b_drop_auth_bind_refusal.sql +9 -0
- package/tests/mutations/669b/M2a_drop_gate.sql +9 -0
- package/tests/mutations/669b/M2b_drop_ceiling.sql +9 -0
- package/tests/mutations/669b/M2c_drop_invite.sql +9 -0
- package/tests/mutations/669b/MAL2_drop_otp.sql +9 -0
- package/tests/mutations/669b/MAL3_admit_passkey.sql +9 -0
- package/tests/mutations/669b/MD7a_no_revocation.sql +2 -0
- package/tests/mutations/669b/MD7b_overwrite_revoked.sql +2 -0
- package/tests/mutations/669b/MD7c_revoke_members.sql +2 -0
- package/tests/mutations/669b/MD7d_revoke_expired.sql +2 -0
- package/tests/mutations/669b/ME1_wrapper_over_gate.sql +7 -0
- package/tests/mutations/669b/MEC2_write_after_helper.sql +10 -0
- package/tests/mutations/669b/MQX_query_to_xml_definer.sql +6 -0
- package/tests/mutations/669b/MQXb_ts_stat_other_schema.sql +4 -0
- package/tests/mutations/669b/MTR_trigger_route.sql +9 -0
- package/tests/mutations/669b/MTRb_new_assign.sql +11 -0
- package/tests/mutations/669b/MTRc_sync_assigns_value.sql +47 -0
- package/tests/mutations/669b/MTX1_tombstone_second_gated_call.sql +15 -0
- package/tests/mutations/669b/MTX2_tombstone_non_delegate_target.sql +10 -0
- package/tests/mutations/669b/MXS_other_schema_names_gated.sql +5 -0
- package/tests/mutations/669b/run.sh +83 -0
- package/tests/mutations/670/M18a_read_operation_default_dropped.sql +11 -0
- package/tests/mutations/670/M18b_read_operation_default_changed.sql +7 -0
- package/tests/mutations/670/M3-DM_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/670/M3-MC_helper_on_replay_branch.sql +10 -0
- package/tests/mutations/s12/M0_identity.sql +56 -0
- package/tests/mutations/s12/M1_serialise_actor_key.sql +57 -0
- package/tests/mutations/s12/M1b_serialise_key_only.sql +57 -0
- package/tests/mutations/s12/M2_unique_index_no_handler.sql +9 -0
- package/tests/mutations/s12/M3_no_trim.sql +56 -0
- package/tests/mutations/s12/M4_casefold.sql +56 -0
- package/tests/mutations/s12/M5_lookup_ignores_actor.sql +56 -0
- package/tests/mutations/s12/M6_reuse_reports_false.sql +56 -0
- package/tests/mutations/s12/run.sh +112 -0
- package/tests/mutations/s12-fix/M0_identity.sql +83 -0
- package/tests/mutations/s12-fix/M10_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M11_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M12_reuse_writes_task.sql +84 -0
- package/tests/mutations/s12-fix/M13_dead_inbox_write.sql +84 -0
- package/tests/mutations/s12-fix/M14_metadata_unchecked.sql +78 -0
- package/tests/mutations/s12-fix/M15_metadata_check_after_lock.sql +84 -0
- package/tests/mutations/s12-fix/M16_sql_null_metadata_refused.sql +83 -0
- package/tests/mutations/s12-fix/M17_isolation_unchecked.sql +70 -0
- package/tests/mutations/s12-fix/M18_isolation_check_after_lock.sql +82 -0
- package/tests/mutations/s12-fix/M19_isolation_rr_only.sql +83 -0
- package/tests/mutations/s12-fix/M1_lock_dropped.sql +78 -0
- package/tests/mutations/s12-fix/M1b_lock_key_only.sql +83 -0
- package/tests/mutations/s12-fix/M20_isolation_unsafe_levels_only.sql +83 -0
- package/tests/mutations/s12-fix/M21_isolation_check_miss_path_only.sql +83 -0
- package/tests/mutations/s12-fix/M22_isolation_inverted.sql +83 -0
- package/tests/mutations/s12-fix/M23_isolation_wrong_sqlstate.sql +83 -0
- package/tests/mutations/s12-fix/M24_create_thread_key_unchecked.sql +37 -0
- package/tests/mutations/s12-fix/M25_create_thread_key_nonnull_only.sql +45 -0
- package/tests/mutations/s12-fix/M26_create_thread_key_casefold.sql +45 -0
- package/tests/mutations/s12-fix/M27_create_thread_no_object_guard.sql +45 -0
- package/tests/mutations/s12-fix/M28_create_thread_key_stripped.sql +40 -0
- package/tests/mutations/s12-fix/M29_create_thread_key_nested_refused.sql +45 -0
- package/tests/mutations/s12-fix/M2_lock_actor_only.sql +83 -0
- package/tests/mutations/s12-fix/M30_create_thread_security_invoker.sql +9 -0
- package/tests/mutations/s12-fix/M31_create_thread_search_path_changed.sql +9 -0
- package/tests/mutations/s12-fix/M32_class_new_thread_inserter.sql +14 -0
- package/tests/mutations/s12-fix/M33_class_metadata_update.sql +12 -0
- package/tests/mutations/s12-fix/M33b_class_metadata_update_upper.sql +17 -0
- package/tests/mutations/s12-fix/M33c_class_metadata_update_row_form.sql +16 -0
- package/tests/mutations/s12-fix/M33d_class_metadata_merge_update.sql +16 -0
- package/tests/mutations/s12-fix/M33e_class_metadata_upsert.sql +16 -0
- package/tests/mutations/s12-fix/M34_class_api_role_insert.sql +9 -0
- package/tests/mutations/s12-fix/M3_lock_after_lookup.sql +83 -0
- package/tests/mutations/s12-fix/M4_lock_raw_key.sql +83 -0
- package/tests/mutations/s12-fix/M5_no_trim.sql +83 -0
- package/tests/mutations/s12-fix/M6_casefold.sql +83 -0
- package/tests/mutations/s12-fix/M7_lookup_ignores_actor.sql +82 -0
- package/tests/mutations/s12-fix/M8_reuse_reports_false.sql +83 -0
- package/tests/mutations/s12-fix/M9_blank_key_admitted.sql +83 -0
- package/tests/mutations/s12-fix/run.sh +288 -0
- package/tests/seeds/20261124000100_agent_board_step_up_enforcement.sql.pre.sql +47 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- record_portal_step_up drops the Portal-class check; must fail RP-2 (#71-72), RP-3 (#73)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.record_portal_step_up(uuid,bigint)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'if agent_board._step_up_is_portal_human(p_agent_id) is not true then') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, 'if agent_board._step_up_is_portal_human(p_agent_id) is not true then', 'if false then');
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the writer's window drops its lower bound; must fail WR-3 (#94), WR-4 (#95), RP-4 old (#75)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_proof_recordable(numeric,numeric)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'p_proof >= p_now - 330 and ') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, 'p_proof >= p_now - 330 and ', '');
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- the prune ignores the agent; must fail RP-7 (#82)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.record_portal_step_up(uuid,bigint)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, ' where p.agent_id = p_agent_id
|
|
7
|
+
and p.proof_at::numeric < v_now - 86400;') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, ' where p.agent_id = p_agent_id
|
|
9
|
+
and p.proof_at::numeric < v_now - 86400;', ' where p.proof_at::numeric < v_now - 86400;');
|
|
10
|
+
execute n;
|
|
11
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the writer's lower bound becomes exclusive (>= -> >); must fail WR-2 (#93)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_proof_recordable(numeric,numeric)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'p_proof >= p_now - 330') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, 'p_proof >= p_now - 330', 'p_proof > p_now - 330');
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the writer's upper bound becomes exclusive (<= -> <); must fail WR-5 (#96)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_proof_recordable(numeric,numeric)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'p_proof <= p_now + 60') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, 'p_proof <= p_now + 60', 'p_proof < p_now + 60');
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the writer's upper bound widens 60 -> 61; must fail WR-6 (#97), WR-7 (#98), RP-4 new (#76)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_proof_recordable(numeric,numeric)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'p_proof <= p_now + 60') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, 'p_proof <= p_now + 60', 'p_proof <= p_now + 61');
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- a second (service-only) ledger writer; must fail EC-SU-4 (#3)
|
|
2
|
+
create function agent_board.zz_mw2_second_writer(p_agent_id uuid) returns void
|
|
3
|
+
language sql security definer set search_path = '' as $$ insert into agent_board.portal_step_up_proofs(agent_id, proof_at) values (p_agent_id, 1) $$;
|
|
4
|
+
revoke all on function agent_board.zz_mw2_second_writer(uuid) from public, anon, authenticated;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- S1-2(b): a routine OUTSIDE agent_board naming record_portal_step_up; must fail EC-SU-4h (#103)
|
|
2
|
+
create function public.zz_mxs_wrap(p_agent uuid, p_t bigint) returns boolean
|
|
3
|
+
language sql security definer set search_path = '' as $$ select agent_board.record_portal_step_up(p_agent, p_t) $$;
|
|
4
|
+
revoke all on function public.zz_mxs_wrap(uuid, bigint) from public;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# #669 STEPUP PR-A mutation receipts (AGENTS.md rule 2; plan §10.6 rows that apply to PR-A, plus
|
|
3
|
+
# E-2's M23 and E-6(b)'s "the helper always raises"). Connection comes ONLY from the libpq
|
|
4
|
+
# environment (PGHOST/PGPORT/PGUSER/PGPASSWORD/PGDATABASE), never argv. The target must be an
|
|
5
|
+
# OWNED database holding this tree's applied bundle (CI: a throwaway job's Supabase; never a
|
|
6
|
+
# shared cluster).
|
|
7
|
+
#
|
|
8
|
+
# Per mutation:
|
|
9
|
+
# applied the mutation runs ALONE in a rolled-back transaction with ON_ERROR_STOP, and the
|
|
10
|
+
# catalog fingerprint (every non-system routine with its argument names, ACL, body and
|
|
11
|
+
# comment; the ledger's ACL and policies; the ledger's and the fedsession audit's
|
|
12
|
+
# columns) read inside that transaction must differ from the baseline. An anchor miss raises 'MUTATION ANCHOR MISS' and is reported, never
|
|
13
|
+
# counted as a kill.
|
|
14
|
+
# pgTAP the mutation and agent_board_step_up_helper.test.sql run in ONE transaction that is
|
|
15
|
+
# rolled back. The receipt records plan, emitted, ok and not ok counts and every
|
|
16
|
+
# failing line, counted from the TAP, never inferred from an absence. An aborted file
|
|
17
|
+
# (emitted < plan) is reported as ABORTED, never as a kill.
|
|
18
|
+
# The fingerprint must equal the baseline after every leg (nothing leaked past a rollback).
|
|
19
|
+
# Usage: run.sh <receipt-path> [mutation.sql ...] (default: every *.sql beside this script)
|
|
20
|
+
set -uo pipefail
|
|
21
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
22
|
+
PKG="$(cd "$HERE/../../.." && pwd)"
|
|
23
|
+
TEST="${STEPUP_TEST:-$PKG/tests/agent_board_step_up_helper.test.sql}"
|
|
24
|
+
OUT="${1:?receipt path}"; shift
|
|
25
|
+
if [ "$#" -gt 0 ]; then
|
|
26
|
+
MUTS=()
|
|
27
|
+
for m in "$@"; do
|
|
28
|
+
# A relative or missing path made psql's \i fail with a lowercase "error:", which the
|
|
29
|
+
# applied() check below did not match, so a mutant that never loaded read as "applied".
|
|
30
|
+
[ -f "$m" ] || { echo "FATAL: mutation file not found: $m" >&2; exit 3; }
|
|
31
|
+
MUTS+=("$(cd "$(dirname "$m")" && pwd)/$(basename "$m")")
|
|
32
|
+
done
|
|
33
|
+
else mapfile -t MUTS < <(find "$HERE" -maxdepth 1 -name '*.sql' | sort -V); fi
|
|
34
|
+
[ -n "${PGDATABASE:-}" ] || { echo "FATAL: PGDATABASE unset (libpq environment required)" >&2; exit 3; }
|
|
35
|
+
P=(psql -X -qtA)
|
|
36
|
+
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(attrelid::regclass::text || '.' || attname || ':' || atttypid::regtype::text, '|' order by attrelid::regclass::text, attnum) from pg_attribute where attrelid in ('agent_board.portal_step_up_proofs'::regclass, 'agent_board.enrollment_federation_audit'::regclass) and attnum > 0 and not attisdropped), '') || coalesce((select relacl::text from pg_class where oid = 'agent_board.portal_step_up_proofs'::regclass), '') || coalesce((select string_agg(polname || pg_get_expr(polqual, polrelid), '|' order by polname) from pg_policy where polrelid = 'agent_board.portal_step_up_proofs'::regclass), ''))"
|
|
37
|
+
fp() { "${P[@]}" -c "$FPSQL"; }
|
|
38
|
+
ORIG="$(fp)"
|
|
39
|
+
|
|
40
|
+
applied() { # $1 mutation file -> prints 'applied' / 'NOT APPLIED: <why>'
|
|
41
|
+
local out
|
|
42
|
+
out="$(printf 'begin;\n\\set ON_ERROR_STOP 1\n\\i %s\n%s;\nrollback;\n' "$1" "$FPSQL" | "${P[@]}" 2>&1)"
|
|
43
|
+
if grep -qiE '(error|fatal):' <<<"$out"; then
|
|
44
|
+
echo "NOT APPLIED: $(grep -iE '(error|fatal):' <<<"$out" | head -1)"
|
|
45
|
+
elif [ "$(tail -1 <<<"$out")" = "$ORIG" ]; then
|
|
46
|
+
echo "NOT APPLIED: catalog fingerprint unchanged (no-op)"
|
|
47
|
+
else
|
|
48
|
+
echo "applied"
|
|
49
|
+
fi
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
tap() { # $1 label, $2 mutation file or empty
|
|
53
|
+
local out plan ok nok
|
|
54
|
+
if [ -n "$2" ]; then out="$(printf 'begin;\n\\i %s\n\\i %s\nrollback;\n' "$2" "$TEST" | "${P[@]}" 2>&1)"
|
|
55
|
+
else out="$(printf 'begin;\n\\i %s\nrollback;\n' "$TEST" | "${P[@]}" 2>&1)"; fi
|
|
56
|
+
plan="$(sed -nE 's/^1\.\.([0-9]+)$/\1/p' <<<"$out" | head -1)"
|
|
57
|
+
ok="$(grep -cE '^ok [0-9]+' <<<"$out")"; nok="$(grep -cE '^not ok [0-9]+' <<<"$out")"
|
|
58
|
+
printf '%s: pgtap plan=%s emitted=%s ok=%s not_ok=%s%s\n' "$1" "${plan:-NONE}" "$((ok + nok))" "$ok" "$nok" \
|
|
59
|
+
"$([ "${plan:-x}" = "$((ok + nok))" ] || echo ' ABORTED')"
|
|
60
|
+
grep -E '^not ok [0-9]+' <<<"$out" | sed 's/^/ /'
|
|
61
|
+
grep -E '^#\s+(have|want|caught|wanted|died):' <<<"$out" | head -8 | sed 's/^/ /'
|
|
62
|
+
grep -iE '(error|fatal):' <<<"$out" | head -3 | sed 's/^/ ERR /'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
echo "# #669 STEPUP PR-A mutation receipt -- $(date -u +%FT%TZ)"
|
|
67
|
+
echo "# tree $(git -C "$PKG" rev-parse HEAD)$(git -C "$PKG" diff --quiet HEAD -- . || echo ' + uncommitted changes')"
|
|
68
|
+
echo "# catalog fingerprint before: $ORIG"
|
|
69
|
+
tap "BASELINE" ""
|
|
70
|
+
for m in "${MUTS[@]}"; do
|
|
71
|
+
name="$(basename "$m" .sql)"
|
|
72
|
+
echo "-- $name: $(head -1 "$m" | sed 's/^-- //') [sha256 $(sha256sum "$m" | cut -c1-16)]"
|
|
73
|
+
echo " $(applied "$m")"
|
|
74
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back apply leg of $name"; exit 3; }
|
|
75
|
+
tap "$name" "$m"
|
|
76
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back pgTAP leg of $name"; exit 3; }
|
|
77
|
+
done
|
|
78
|
+
tap "AFTER" ""
|
|
79
|
+
echo "# catalog fingerprint after: $(fp)"
|
|
80
|
+
} | tee "$OUT"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of set_board_authority_ceiling; must fail R-9/R-10 (ceiling)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_authority_ceiling(uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''set_board_authority_ceiling'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of set_board_role_gate; must fail R-9/R-10 (gate)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_role_gate(uuid,boolean)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''set_board_role_gate'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of grant_board_role; must fail R-9/R-10 (grant)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''grant_board_role'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of create_invite_link; must fail R-9/R-10 (admin link)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''create_invite_link'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of update_board_membership; must fail E-6(a) removal R-9
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''update_board_membership'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- move the helper to the first statement of readmit_session_identity; must fail E-6(a) readmit R-9/R-10
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$, $q$$q$);
|
|
8
|
+
n := regexp_replace(n, E'\nbegin\n', E'\nbegin\n perform agent_board._require_human_step_up(''readmit_session_identity'');\n');
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- gate member presets too; must fail A-4
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_preset_role = 'admin' then
|
|
7
|
+
perform agent_board._require_human_step_up$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ if p_preset_role = 'admin' then
|
|
9
|
+
perform agent_board._require_human_step_up$q$, $q$ if p_preset_role in ('admin', 'member') then
|
|
10
|
+
perform agent_board._require_human_step_up$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- ungate admin presets (gate observer instead); must fail R-1 (admin link)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_preset_role = 'admin' then
|
|
7
|
+
perform agent_board._require_human_step_up$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ if p_preset_role = 'admin' then
|
|
9
|
+
perform agent_board._require_human_step_up$q$, $q$ if p_preset_role = 'observer' then
|
|
10
|
+
perform agent_board._require_human_step_up$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- the helper takes an actor and grant_board_role passes the TARGET; must fail R-13, R-13b
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._require_human_step_up(text)'::regprocedure); n text; g text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, 'agent_board._require_human_step_up(p_operation text)') = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
if strpos(n, 'v_actor := agent_board.current_agent_id();') = 0 then raise exception 'MUTATION ANCHOR MISS (2)'; end if;
|
|
8
|
+
n := replace(n, 'agent_board._require_human_step_up(p_operation text)', 'agent_board._require_human_step_up(p_operation text, p_actor uuid)');
|
|
9
|
+
n := replace(n, 'v_actor := agent_board.current_agent_id();', 'v_actor := p_actor;');
|
|
10
|
+
execute n;
|
|
11
|
+
g := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure);
|
|
12
|
+
if strpos(g, $q$_require_human_step_up('grant_board_role')$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (3)'; end if;
|
|
13
|
+
execute replace(g, $q$_require_human_step_up('grant_board_role')$q$, $q$_require_human_step_up('grant_board_role', p_agent_id)$q$);
|
|
14
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from readmit_session_identity (M2 readmit); must fail R-15 and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.readmit_session_identity(uuid,text,text,jsonb,jsonb,interval)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('readmit_session_identity');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from grant_board_role; must fail R-1/R-13/R-19 (grant) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.grant_board_role(uuid,uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('grant_board_role');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the D5 human-root refusal from mint_delegated_child; must fail R-16
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.mint_delegated_child(uuid,text,jsonb,text,interval,boolean,text,text,text,jsonb,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ raise exception 'human_root_room_elevation_refused' using errcode = '42501';$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ raise exception 'human_root_room_elevation_refused' using errcode = '42501';$q$, $q$ null;$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the removal gate from update_board_membership (M2 removal); must fail R-17 and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('update_board_membership');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- gate only 'removed' (not every active->non-active result); must fail R-17b
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$coalesce(v_membership.membership_state, '') not in ('joined', 'subscribed') then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$coalesce(v_membership.membership_state, '') not in ('joined', 'subscribed') then$q$, $q$v_membership.membership_state = 'removed' then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- gate member/observer removals too; must fail A-11
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ and v_target_role in ('owner', 'admin')
|
|
7
|
+
$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ and v_target_role in ('owner', 'admin')
|
|
9
|
+
$q$, $q$ and v_target_role in ('owner', 'admin', 'member', 'observer')
|
|
10
|
+
$q$);
|
|
11
|
+
execute n;
|
|
12
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- key the removal condition on the REQUESTED state; must fail A-11d
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.update_board_membership(uuid,uuid,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$coalesce(v_membership.membership_state, '') not in$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$coalesce(v_membership.membership_state, '') not in$q$, $q$coalesce(p_membership_state, '') not in$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- an authenticated-executable SECURITY DEFINER wrapper over a W(enrollment_federation_audit) member; must fail EC-SU-4 (tables)
|
|
2
|
+
create function agent_board.su669b_m23b(p_issuer text) returns void language plpgsql security definer set search_path = '' as $f$
|
|
3
|
+
begin
|
|
4
|
+
perform agent_board.enroll_federated_human(p_issuer, 'x', 'x', '{}'::jsonb, 'x');
|
|
5
|
+
end $f$;
|
|
6
|
+
grant execute on function agent_board.su669b_m23b(text) to authenticated;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop register_agent's type-change refusal; must fail X-1
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.register_agent(text,text,text,text,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if p_agent_type is distinct from v_existing.agent_type then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if p_agent_type is distinct from v_existing.agent_type then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop provision_agent's API kind-change refusal (E-3); must fail R-20
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.provision_agent(text,text,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if v_agent.kind::text is distinct from v_kind then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if v_agent.kind::text is distinct from v_kind then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop provision_agent's API auth-bind refusal (E-2(4)(i)); must fail X-3
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.provision_agent(text,text,jsonb,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ if v_agent.auth_user_id is null then$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$ if v_agent.auth_user_id is null then$q$, $q$ if false then$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from set_board_role_gate; must fail R-1 (gate) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_role_gate(uuid,boolean)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from set_board_authority_ceiling; must fail R-1 (ceiling), R-19 (ceiling) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_authority_ceiling(uuid,text,uuid)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_authority_ceiling');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- drop the helper call from create_invite_link; must fail R-1 (admin link) and EC-SU-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.create_invite_link(uuid,text,text,integer,timestamp with time zone,uuid,jsonb)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('create_invite_link');$q$, $q$$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the allowlist drops otp (the owner-admitted email code); must fail A-2c and the freeze pin
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_amr_methods()'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$'{otp,totp}'::text[]$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$'{otp,totp}'::text[]$q$, $q$'{totp}'::text[]$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- the allowlist admits passkey before it is measured (D11); must fail R-4c passkey and the freeze pin
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board._step_up_amr_methods()'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$'{otp,totp}'::text[]$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$'{otp,totp}'::text[]$q$, $q$'{otp,passkey,totp}'::text[]$q$);
|
|
8
|
+
execute n;
|
|
9
|
+
end $m$;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- a service-only SECURITY DEFINER wrapper over set_board_role_gate; must fail E-1 (reverse closure) and EC-SU-1, naming the wrapper
|
|
2
|
+
create function agent_board.su669b_wrap_gate(p_board uuid) returns void language plpgsql security definer set search_path = '' as $f$
|
|
3
|
+
begin
|
|
4
|
+
perform agent_board.set_board_role_gate(p_board, true);
|
|
5
|
+
end $f$;
|
|
6
|
+
revoke all on function agent_board.su669b_wrap_gate(uuid) from public, anon, authenticated;
|
|
7
|
+
grant execute on function agent_board.su669b_wrap_gate(uuid) to service_role;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- add a write AFTER the helper call in set_board_role_gate; must fail EC-SU-2 (D1 tail)
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.set_board_role_gate(uuid,boolean)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board._require_human_step_up('set_board_role_gate');$q$, $q$perform agent_board._require_human_step_up('set_board_role_gate');
|
|
8
|
+
update agent_board.boards set updated_at = now() where id = p_board_id;$q$);
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- (#802 P-1; run with STEPUP_TEST=agent_board_step_up_helper.test.sql) an authenticated-executable SECURITY DEFINER sql function reaching record_portal_step_up through query_to_xml; must fail both EC-SU-4q rows, naming it
|
|
2
|
+
create function agent_board.su669b_mqx(p_agent uuid) returns xml language sql security definer set search_path = '' as $f$
|
|
3
|
+
select pg_catalog.query_to_xml(pg_catalog.format('select agent_board.record_portal_step_up(%L::uuid, 0::bigint)', p_agent), true, false, '')
|
|
4
|
+
$f$;
|
|
5
|
+
revoke all on function agent_board.su669b_mqx(uuid) from public;
|
|
6
|
+
grant execute on function agent_board.su669b_mqx(uuid) to authenticated;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- (#802 P-1/P-3; run with STEPUP_TEST=agent_board_step_up_helper.test.sql) a public-schema SECURITY DEFINER sql function running a query string through bare TS_STAT; must fail EC-SU-4q (definer row) and EC-SU-4h (it names record_portal_step_up in a literal)
|
|
2
|
+
create function public.su669b_mqxb() returns bigint language sql security definer set search_path = pg_catalog as $f$
|
|
3
|
+
select count(*) from TS_STAT('select agent_board.record_portal_step_up(null::uuid, 0::bigint)::text::tsvector')
|
|
4
|
+
$f$;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- (#802 P-2) a service-only trigger function on board_memberships that writes agents.kind (inert: WHERE false); must fail EC-SU-4t (trigger edges), naming the API writers of board_memberships
|
|
2
|
+
create function agent_board.su669b_mtr() returns trigger language plpgsql security definer set search_path = '' as $f$
|
|
3
|
+
begin
|
|
4
|
+
update agent_board.agents set kind = 'human' where false;
|
|
5
|
+
return null;
|
|
6
|
+
end $f$;
|
|
7
|
+
revoke all on function agent_board.su669b_mtr() from public, anon, authenticated;
|
|
8
|
+
create trigger su669b_mtr after insert or update on agent_board.board_memberships
|
|
9
|
+
for each row execute function agent_board.su669b_mtr();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- (#802 P-2) a second BEFORE trigger on agents that assigns NEW.kind (inert: IF false); must fail EC-SU-4t (the NEW-assigning trigger class), naming su669b_mtrb
|
|
2
|
+
create function agent_board.su669b_mtrb() returns trigger language plpgsql set search_path = '' as $f$
|
|
3
|
+
begin
|
|
4
|
+
if false then
|
|
5
|
+
new.kind := 'human';
|
|
6
|
+
end if;
|
|
7
|
+
return new;
|
|
8
|
+
end $f$;
|
|
9
|
+
revoke all on function agent_board.su669b_mtrb() from public, anon, authenticated;
|
|
10
|
+
create trigger su669b_mtrb before insert or update on agent_board.agents
|
|
11
|
+
for each row execute function agent_board.su669b_mtrb();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- (#802 P-2) sync_agent_principal_columns also assigns NEW.auth_user_id a VALUE (inert: IF false); must fail EC-SU-4t's positive exemption row only
|
|
2
|
+
create or replace function agent_board.sync_agent_principal_columns()
|
|
3
|
+
returns trigger
|
|
4
|
+
language plpgsql
|
|
5
|
+
set search_path = ''
|
|
6
|
+
as $$
|
|
7
|
+
begin
|
|
8
|
+
if new.kind is null
|
|
9
|
+
or (
|
|
10
|
+
tg_op = 'UPDATE'
|
|
11
|
+
and new.kind is not distinct from old.kind
|
|
12
|
+
and new.agent_type is distinct from old.agent_type
|
|
13
|
+
and new.agent_type is not null
|
|
14
|
+
) then
|
|
15
|
+
new.kind := new.agent_type::agent_board.agent_kind;
|
|
16
|
+
end if;
|
|
17
|
+
|
|
18
|
+
if new.agent_type is null
|
|
19
|
+
or (
|
|
20
|
+
tg_op = 'UPDATE'
|
|
21
|
+
and new.agent_type is not distinct from old.agent_type
|
|
22
|
+
and new.kind is distinct from old.kind
|
|
23
|
+
and new.kind is not null
|
|
24
|
+
) then
|
|
25
|
+
new.agent_type := new.kind::text;
|
|
26
|
+
end if;
|
|
27
|
+
|
|
28
|
+
if new.kind is null or new.agent_type is null then
|
|
29
|
+
raise exception 'kind and agent_type are both required' using errcode = '23502';
|
|
30
|
+
end if;
|
|
31
|
+
|
|
32
|
+
if new.kind::text <> new.agent_type then
|
|
33
|
+
raise exception 'kind and agent_type must match' using errcode = '22000';
|
|
34
|
+
end if;
|
|
35
|
+
|
|
36
|
+
if new.kind = 'system'::agent_board.agent_kind then
|
|
37
|
+
new.owner_user_id := null;
|
|
38
|
+
new.auth_user_id := null;
|
|
39
|
+
end if;
|
|
40
|
+
|
|
41
|
+
if false then
|
|
42
|
+
new.auth_user_id := new.owner_user_id;
|
|
43
|
+
end if;
|
|
44
|
+
|
|
45
|
+
return new;
|
|
46
|
+
end;
|
|
47
|
+
$$;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- tombstone_delegate_instance gains a second GATED call (set_board_role_gate); must fail TX-1
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.tombstone_delegate_instance(text,text,text,text)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$ perform agent_board.update_board_membership(v_board, v_row.agent_id, 'left');
|
|
7
|
+
end loop;$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
8
|
+
n := replace(n, $q$ perform agent_board.update_board_membership(v_board, v_row.agent_id, 'left');
|
|
9
|
+
end loop;$q$, $q$ perform agent_board.update_board_membership(v_board, v_row.agent_id, 'left');
|
|
10
|
+
end loop;
|
|
11
|
+
if false then
|
|
12
|
+
perform agent_board.set_board_role_gate(v_board, false);
|
|
13
|
+
end if;$q$);
|
|
14
|
+
execute n;
|
|
15
|
+
end $m$;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- tombstone_delegate_instance's update_board_membership call targets v_owner, not v_row.agent_id (a non-delegate_instances target); must fail TX-2
|
|
2
|
+
do $m$
|
|
3
|
+
declare d text := pg_get_functiondef('agent_board.tombstone_delegate_instance(text,text,text,text)'::regprocedure); n text;
|
|
4
|
+
begin
|
|
5
|
+
n := d;
|
|
6
|
+
if strpos(n, $q$perform agent_board.update_board_membership(v_board, v_row.agent_id, 'left');$q$) = 0 then raise exception 'MUTATION ANCHOR MISS (1)'; end if;
|
|
7
|
+
n := replace(n, $q$perform agent_board.update_board_membership(v_board, v_row.agent_id, 'left');$q$,
|
|
8
|
+
$q$perform agent_board.update_board_membership(v_board, v_owner, 'left');$q$);
|
|
9
|
+
execute n;
|
|
10
|
+
end $m$;
|