@consiliency/agent-board-schema 1.75.0 → 1.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fixtures/already-applied.json +4 -0
- package/migrations/20261109000100_agent_board_step_up_groundwork.sql +343 -0
- package/package.json +1 -1
- package/schema-manifest.json +12 -3
- package/src/tooling.test.mjs +3 -2
- package/tests/agent_board_enrollment_audit_content.test.sql +6 -1
- package/tests/agent_board_step_up_helper.test.sql +711 -0
- package/tests/agent_board_write_enforcement_class.test.sql +5 -2
- package/tests/catalog/function_execute_privileges.json +72 -0
- package/tests/catalog/p_metadata_parameters.json +32 -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 +72 -0
|
@@ -0,0 +1,72 @@
|
|
|
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 MUTS=("$@"); else mapfile -t MUTS < <(find "$HERE" -maxdepth 1 -name '*.sql' | sort -V); fi
|
|
26
|
+
[ -n "${PGDATABASE:-}" ] || { echo "FATAL: PGDATABASE unset (libpq environment required)" >&2; exit 3; }
|
|
27
|
+
P=(psql -X -qtA)
|
|
28
|
+
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), ''))"
|
|
29
|
+
fp() { "${P[@]}" -c "$FPSQL"; }
|
|
30
|
+
ORIG="$(fp)"
|
|
31
|
+
|
|
32
|
+
applied() { # $1 mutation file -> prints 'applied' / 'NOT APPLIED: <why>'
|
|
33
|
+
local out
|
|
34
|
+
out="$(printf 'begin;\n\\set ON_ERROR_STOP 1\n\\i %s\n%s;\nrollback;\n' "$1" "$FPSQL" | "${P[@]}" 2>&1)"
|
|
35
|
+
if grep -qE '(ERROR|FATAL):' <<<"$out"; then
|
|
36
|
+
echo "NOT APPLIED: $(grep -E '(ERROR|FATAL):' <<<"$out" | head -1)"
|
|
37
|
+
elif [ "$(tail -1 <<<"$out")" = "$ORIG" ]; then
|
|
38
|
+
echo "NOT APPLIED: catalog fingerprint unchanged (no-op)"
|
|
39
|
+
else
|
|
40
|
+
echo "applied"
|
|
41
|
+
fi
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
tap() { # $1 label, $2 mutation file or empty
|
|
45
|
+
local out plan ok nok
|
|
46
|
+
if [ -n "$2" ]; then out="$(printf 'begin;\n\\i %s\n\\i %s\nrollback;\n' "$2" "$TEST" | "${P[@]}" 2>&1)"
|
|
47
|
+
else out="$(printf 'begin;\n\\i %s\nrollback;\n' "$TEST" | "${P[@]}" 2>&1)"; fi
|
|
48
|
+
plan="$(sed -nE 's/^1\.\.([0-9]+)$/\1/p' <<<"$out" | head -1)"
|
|
49
|
+
ok="$(grep -cE '^ok [0-9]+' <<<"$out")"; nok="$(grep -cE '^not ok [0-9]+' <<<"$out")"
|
|
50
|
+
printf '%s: pgtap plan=%s emitted=%s ok=%s not_ok=%s%s\n' "$1" "${plan:-NONE}" "$((ok + nok))" "$ok" "$nok" \
|
|
51
|
+
"$([ "${plan:-x}" = "$((ok + nok))" ] || echo ' ABORTED')"
|
|
52
|
+
grep -E '^not ok [0-9]+' <<<"$out" | sed 's/^/ /'
|
|
53
|
+
grep -E '^#\s+(have|want|caught|wanted|died):' <<<"$out" | head -8 | sed 's/^/ /'
|
|
54
|
+
grep -E '(ERROR|FATAL):' <<<"$out" | head -3 | sed 's/^/ ERR /'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
echo "# #669 STEPUP PR-A mutation receipt -- $(date -u +%FT%TZ)"
|
|
59
|
+
echo "# tree $(git -C "$PKG" rev-parse HEAD)$(git -C "$PKG" diff --quiet HEAD -- . || echo ' + uncommitted changes')"
|
|
60
|
+
echo "# catalog fingerprint before: $ORIG"
|
|
61
|
+
tap "BASELINE" ""
|
|
62
|
+
for m in "${MUTS[@]}"; do
|
|
63
|
+
name="$(basename "$m" .sql)"
|
|
64
|
+
echo "-- $name: $(head -1 "$m" | sed 's/^-- //') [sha256 $(sha256sum "$m" | cut -c1-16)]"
|
|
65
|
+
echo " $(applied "$m")"
|
|
66
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back apply leg of $name"; exit 3; }
|
|
67
|
+
tap "$name" "$m"
|
|
68
|
+
[ "$(fp)" = "$ORIG" ] || { echo "FATAL: fingerprint changed after the rolled-back pgTAP leg of $name"; exit 3; }
|
|
69
|
+
done
|
|
70
|
+
tap "AFTER" ""
|
|
71
|
+
echo "# catalog fingerprint after: $(fp)"
|
|
72
|
+
} | tee "$OUT"
|