@consiliency/agent-board-schema 1.24.0 → 1.25.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 +8 -0
- package/migrations/20260906000100_agent_board_enroll_resumption.sql +749 -0
- package/migrations/20260907000100_agent_board_signed_authority_provenance.sql +243 -0
- package/package.json +1 -1
- package/schema-manifest.json +21 -3
- package/src/tooling.test.mjs +3 -3
- package/tests/agent_board_atomic_fleet_onboarding.test.sql +124 -112
- package/tests/agent_board_claimkey.test.sql +25 -3
- package/tests/agent_board_consent_emission.test.sql +17 -13
- package/tests/agent_board_consent_gating.test.sql +55 -11
- package/tests/agent_board_delegation_policies.test.sql +3 -1
- package/tests/agent_board_enroll_resumption.test.sql +412 -0
- package/tests/agent_board_federated_lock_order_class.test.sql +1 -3
- package/tests/agent_board_fedsession_provider_absence_gate.test.sql +9 -6
- package/tests/agent_board_fleet_machine_reactivation.test.sql +56 -5
- package/tests/agent_board_mint_harden.test.sql +39 -4
- package/tests/agent_board_outbox_wake_ordering.test.sql +27 -12
- package/tests/agent_board_rejectsem.test.sql +1 -1
- package/tests/agent_board_rolereset.test.sql +23 -2
- package/tests/agent_board_rowid.test.sql +24 -13
- package/tests/agent_board_scoped_send_regrant.test.sql +8 -4
- package/tests/agent_board_signed_authority_provenance.test.sql +454 -0
- package/tests/agent_board_source_strip_helper.test.sql +285 -0
- package/tests/agent_board_wake_recovery.test.sql +58 -40
- package/tests/catalog/p_metadata_parameters.json +689 -0
- package/tests/fixtures/test-prereqs.sql +313 -0
- package/tests/isolation/expected/atomic_fleet_lifecycle_races.out +3 -3
|
@@ -93,8 +93,13 @@ select is(
|
|
|
93
93
|
where n.nspname = 'agent_board'
|
|
94
94
|
and p.prokind = 'f'
|
|
95
95
|
and p.prolang <> (select oid from pg_language where lanname = 'internal')
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
-- CODE marker -> case-INSENSITIVE. PostgreSQL folds unquoted identifiers, so
|
|
97
|
+
-- `INSERT INTO AGENT_BOARD.CALLBACK_OUTBOX_EVENTS` is the same statement and a
|
|
98
|
+
-- case-sensitive scan drops that writer OUT of this exact set -- the fail-open
|
|
99
|
+
-- direction for a class filter. Missed by the round-3 sweep because that audit
|
|
100
|
+
-- was LINE-anchored and this predicate's operator sits on the next line.
|
|
101
|
+
and agent_board_test.stripped_body(p.oid)
|
|
102
|
+
~* 'insert into agent_board\.callback_outbox_events'),
|
|
98
103
|
'_queue_board_post_callbacks, _queue_inbox_callbacks',
|
|
99
104
|
'WO-3 CLASS: the catalog names exactly the two known outbox writers -- a new writer fails here and NAMES ITSELF');
|
|
100
105
|
|
|
@@ -108,9 +113,9 @@ select is(
|
|
|
108
113
|
where n.nspname = 'agent_board'
|
|
109
114
|
and p.prokind = 'f'
|
|
110
115
|
and p.prolang <> (select oid from pg_language where lanname = 'internal')
|
|
111
|
-
and
|
|
116
|
+
and agent_board_test.stripped_body(p.oid)
|
|
112
117
|
~* 'insert into agent_board\.callback_outbox_events'
|
|
113
|
-
and
|
|
118
|
+
and agent_board_test.stripped_body(p.oid)
|
|
114
119
|
~* 'overriding\s+(system|user)\s+value'),
|
|
115
120
|
'',
|
|
116
121
|
'WO-3 CLASS: no outbox writer uses OVERRIDING SYSTEM VALUE -- the identity bypass stays closed');
|
|
@@ -119,16 +124,16 @@ select is(
|
|
|
119
124
|
-- WO-4 ORDERING
|
|
120
125
|
-- ---------------------------------------------------------------------------
|
|
121
126
|
select ok(
|
|
122
|
-
(select
|
|
123
|
-
|
|
127
|
+
(select agent_board_test.stripped_body(p.oid)
|
|
128
|
+
~* 'order by coe\.available_at asc, coe\.seq asc'
|
|
124
129
|
from pg_proc p
|
|
125
130
|
join pg_namespace n on n.oid = p.pronamespace
|
|
126
131
|
where n.nspname = 'agent_board' and p.proname = 'claim_callback_outbox_events'),
|
|
127
132
|
'WO-4 claim_callback_outbox_events orders candidates by (available_at, seq)');
|
|
128
133
|
|
|
129
134
|
select ok(
|
|
130
|
-
(select
|
|
131
|
-
|
|
135
|
+
(select agent_board_test.stripped_body(p.oid)
|
|
136
|
+
!~* 'coe\.id asc'
|
|
132
137
|
from pg_proc p
|
|
133
138
|
join pg_namespace n on n.oid = p.pronamespace
|
|
134
139
|
where n.nspname = 'agent_board' and p.proname = 'claim_callback_outbox_events'),
|
|
@@ -141,8 +146,8 @@ select ok(
|
|
|
141
146
|
-- mutation produces NO failure. A property no mutation can break is not covered, so the
|
|
142
147
|
-- pin has to be stated where the mutation actually lands.
|
|
143
148
|
select ok(
|
|
144
|
-
(select
|
|
145
|
-
|
|
149
|
+
(select agent_board_test.stripped_body(p.oid)
|
|
150
|
+
~* 'order by u\.seq asc'
|
|
146
151
|
from pg_proc p
|
|
147
152
|
join pg_namespace n on n.oid = p.pronamespace
|
|
148
153
|
where n.nspname = 'agent_board' and p.proname = 'claim_callback_outbox_events'),
|
|
@@ -201,7 +206,12 @@ select is(
|
|
|
201
206
|
from pg_proc p
|
|
202
207
|
where p.pronamespace = 'agent_board'::regnamespace
|
|
203
208
|
and p.prosecdef
|
|
204
|
-
|
|
209
|
+
-- CODE marker in a CLASS FILTER -> stripped + case-INSENSITIVE, matching WO-3
|
|
210
|
+
-- above. Raw text lets a comment pull a function IN (fail-closed, a false
|
|
211
|
+
-- alarm); case-sensitivity lets a function spelling the table
|
|
212
|
+
-- `AGENT_BOARD.CALLBACK_OUTBOX_EVENTS` drop OUT, so its executability is
|
|
213
|
+
-- never checked at all -- fail-OPEN, on a privilege gate.
|
|
214
|
+
and agent_board_test.stripped_body(p.oid) ~* 'callback_outbox_events'
|
|
205
215
|
and (has_function_privilege('public', p.oid, 'EXECUTE')
|
|
206
216
|
or has_function_privilege('anon', p.oid, 'EXECUTE')
|
|
207
217
|
or has_function_privilege('authenticated', p.oid, 'EXECUTE'))),
|
|
@@ -213,7 +223,12 @@ select is(
|
|
|
213
223
|
from pg_proc p
|
|
214
224
|
where p.pronamespace = 'agent_board'::regnamespace
|
|
215
225
|
and p.prosecdef
|
|
216
|
-
|
|
226
|
+
-- CODE marker in a CLASS FILTER -> stripped + case-INSENSITIVE, matching WO-3
|
|
227
|
+
-- above. Raw text lets a comment pull a function IN (fail-closed, a false
|
|
228
|
+
-- alarm); case-sensitivity lets a function spelling the table
|
|
229
|
+
-- `AGENT_BOARD.CALLBACK_OUTBOX_EVENTS` drop OUT, so its executability is
|
|
230
|
+
-- never checked at all -- fail-OPEN, on a privilege gate.
|
|
231
|
+
and agent_board_test.stripped_body(p.oid) ~* 'callback_outbox_events'
|
|
217
232
|
and not has_function_privilege('service_role', p.oid, 'EXECUTE')),
|
|
218
233
|
'',
|
|
219
234
|
'WO-5 CLASS: every SECURITY DEFINER function reaching callback_outbox_events is executable by service_role -- a dropped-and-recreated function that lost its grant names itself here');
|
|
@@ -260,7 +260,7 @@ select is(pg_temp.state('b2000000-0000-4000-8000-000000000001','b1000000-0000-40
|
|
|
260
260
|
select is(
|
|
261
261
|
(select count(*)::int from pg_proc p join pg_namespace n on n.oid = p.pronamespace
|
|
262
262
|
where n.nspname = 'agent_board' and p.proname = 'resolve_board_request'
|
|
263
|
-
and
|
|
263
|
+
and agent_board_test.stripped_body(p.oid) ~* 'v_effective_state'),
|
|
264
264
|
1,
|
|
265
265
|
'the rewrite happens in resolve_board_request, not in the shared sink');
|
|
266
266
|
|
|
@@ -28,7 +28,7 @@ set search_path = extensions, public, agent_board;
|
|
|
28
28
|
|
|
29
29
|
begin;
|
|
30
30
|
|
|
31
|
-
select plan(
|
|
31
|
+
select plan(24);
|
|
32
32
|
|
|
33
33
|
create temp table _rr_fixture (
|
|
34
34
|
open_board uuid,
|
|
@@ -133,7 +133,17 @@ select is(
|
|
|
133
133
|
|
|
134
134
|
-- 3. Redemption bypasses the mutator entirely, so the clamp cannot reach its preset. -
|
|
135
135
|
select ok(
|
|
136
|
-
|
|
136
|
+
-- anchored to the CALL shape rather than a bare `like '%…%'`: the claim is
|
|
137
|
+
-- that redemption never CALLS the mutator, and a variable or argument merely
|
|
138
|
+
-- named after it is not a call.
|
|
139
|
+
-- SCHEMA-QUALIFIED, because a bare-name anchor proves call SYNTAX, not callee
|
|
140
|
+
-- IDENTITY: `\m_upsert_board_membership_state\s*\(` also matches
|
|
141
|
+
-- `zz_other._upsert_board_membership_state(...)` (measured true). Every live call
|
|
142
|
+
-- site in agent_board is `agent_board.`-qualified, so requiring the
|
|
143
|
+
-- qualification costs nothing today and is fail-CLOSED if someone later writes
|
|
144
|
+
-- an unqualified call (it reads as NOT calling). Overload count is pinned
|
|
145
|
+
-- separately, so schema + name is the identity.
|
|
146
|
+
(select agent_board_test.stripped_body(p.oid) !~* '\magent_board\._upsert_board_membership_state\s*\('
|
|
137
147
|
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
|
|
138
148
|
where n.nspname = 'agent_board' and p.proname = '_redeem_invite_for_agent'
|
|
139
149
|
limit 1),
|
|
@@ -346,6 +356,17 @@ select is(
|
|
|
346
356
|
select set_config('request.jwt.claim.role', '', true);
|
|
347
357
|
select set_config('request.jwt.claim.sub', '', true);
|
|
348
358
|
|
|
359
|
+
|
|
360
|
+
-- The schema-qualified call anchor above treats `agent_board._upsert_board_membership_state` as an
|
|
361
|
+
-- IDENTITY. That is only true while the name resolves to exactly one function:
|
|
362
|
+
-- a second overload would be a different implementation the same anchor accepts.
|
|
363
|
+
-- Catalog-derived, so a new overload fails here and the count names itself.
|
|
364
|
+
select is(
|
|
365
|
+
(select count(*)::int from pg_proc p join pg_namespace n on n.oid = p.pronamespace
|
|
366
|
+
where n.nspname = 'agent_board' and p.proname = '_upsert_board_membership_state'),
|
|
367
|
+
1,
|
|
368
|
+
'agent_board._upsert_board_membership_state has exactly ONE overload, so the schema-qualified call anchor identifies it uniquely');
|
|
369
|
+
|
|
349
370
|
select finish();
|
|
350
371
|
|
|
351
372
|
rollback;
|
|
@@ -26,17 +26,18 @@ with defs as (
|
|
|
26
26
|
select
|
|
27
27
|
p.proname::text as proname,
|
|
28
28
|
pg_get_function_identity_arguments(p.oid) as args,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
-- LITERALS STRIPPED, and re-derived rather than assumed. The first version of
|
|
30
|
+
-- this line kept literals "because some ORDER BY operands are literals"; that
|
|
31
|
+
-- was measured and is false for THIS view -- the derived checks over it match
|
|
32
|
+
-- `created_at desc` / `id desc`, which are code, and the whole file is 98/98
|
|
33
|
+
-- with literals stripped. Keeping them left a real, if narrow, hole: the site
|
|
34
|
+
-- set is built by splitting `def` on `;`, so a literal containing a semicolon
|
|
35
|
+
-- re-splits a statement and can drop it out of the set.
|
|
36
|
+
--
|
|
37
|
+
-- The two R-LINK-7 assertions below DO need literals (their patterns match the
|
|
38
|
+
-- operands `''removed''` / `''joined''`), and they read with `true`
|
|
39
|
+
-- individually. Verified by flipping them: they go red, assertions 12 and 13.
|
|
40
|
+
agent_board_test.stripped_body(p.oid) as def
|
|
40
41
|
from pg_proc p
|
|
41
42
|
join pg_namespace n on n.oid = p.pronamespace
|
|
42
43
|
where n.nspname = 'agent_board'
|
|
@@ -582,7 +583,12 @@ select is(
|
|
|
582
583
|
|
|
583
584
|
-- 12. EC-MBROWID-3 requires set-based removed standing, not one selected row.
|
|
584
585
|
select ok(
|
|
585
|
-
|
|
586
|
+
-- DATA literals in the marker (`''removed''`, `''joined''`, `''subscribed''` are
|
|
587
|
+
-- compared against column data, case-SENSITIVELY, at runtime), so this match is
|
|
588
|
+
-- case-sensitive too: `~*` cannot distinguish a live predicate from one rewritten
|
|
589
|
+
-- to `= ''REMOVED''`, which matches nothing. Same class as
|
|
590
|
+
-- agent_board_fleet_machine_reactivation.test.sql's `= ''machine''`.
|
|
591
|
+
(select regexp_replace(agent_board_test.stripped_body(p.oid, true), '\s+', ' ', 'g') ~
|
|
586
592
|
'exists\s*\(\s*select\s+1\s+from\s+agent_board\.board_memberships.*membership_state\s*=\s*''removed''.*\)\s+and\s+not\s+exists\s*\(\s*select\s+1\s+from\s+agent_board\.board_memberships.*membership_state\s+in\s*\(\s*''joined''\s*,\s*''subscribed''\s*\)'
|
|
587
593
|
from pg_proc p
|
|
588
594
|
join pg_namespace n on n.oid = p.pronamespace
|
|
@@ -593,7 +599,12 @@ select ok(
|
|
|
593
599
|
|
|
594
600
|
-- 13. Bootstrap must carry the same R-LINK-7 shape.
|
|
595
601
|
select ok(
|
|
596
|
-
|
|
602
|
+
-- DATA literals in the marker (`''removed''`, `''joined''`, `''subscribed''` are
|
|
603
|
+
-- compared against column data, case-SENSITIVELY, at runtime), so this match is
|
|
604
|
+
-- case-sensitive too: `~*` cannot distinguish a live predicate from one rewritten
|
|
605
|
+
-- to `= ''REMOVED''`, which matches nothing. Same class as
|
|
606
|
+
-- agent_board_fleet_machine_reactivation.test.sql's `= ''machine''`.
|
|
607
|
+
(select regexp_replace(agent_board_test.stripped_body(p.oid, true), '\s+', ' ', 'g') ~
|
|
597
608
|
'not\s+exists\s*\(\s*select\s+1\s+from\s+agent_board\.board_memberships.*membership_state\s+in\s*\(\s*''joined''\s*,\s*''subscribed''\s*\).*\)\s+and\s+not\s+exists\s*\(\s*select\s+1\s+from\s+agent_board\.board_memberships.*membership_state\s*=\s*''removed'''
|
|
598
609
|
from pg_proc p
|
|
599
610
|
join pg_namespace n on n.oid = p.pronamespace
|
|
@@ -128,13 +128,17 @@ select set_config('request.jwt.claim.role', '', true);
|
|
|
128
128
|
select set_config('request.jwt.claim.sub', '', true);
|
|
129
129
|
|
|
130
130
|
-- 6. Portal-offline static: no send RPC body references a Portal issuer / JWKS. -----
|
|
131
|
+
-- LITERALS KEPT on both of these: a Portal issuer or JWKS URL would appear as a
|
|
132
|
+
-- string LITERAL in the body, so the literal-stripping mode would delete exactly
|
|
133
|
+
-- what the claim is looking for and both would pass forever. Comments are still
|
|
134
|
+
-- stripped, so a `-- no portal here` note can no longer satisfy them.
|
|
131
135
|
select ok(
|
|
132
|
-
position('portal' in lower(
|
|
133
|
-
'agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure))) = 0,
|
|
136
|
+
position('portal' in lower(agent_board_test.stripped_body(
|
|
137
|
+
'agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure, true))) = 0,
|
|
134
138
|
'post_board_message references no Portal issuer/URL');
|
|
135
139
|
select ok(
|
|
136
|
-
position('jwks' in lower(
|
|
137
|
-
'agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure))) = 0,
|
|
140
|
+
position('jwks' in lower(agent_board_test.stripped_body(
|
|
141
|
+
'agent_board.post_board_message(uuid,uuid,uuid,text,text,text,text,text,jsonb)'::regprocedure, true))) = 0,
|
|
138
142
|
'post_board_message references no JWKS');
|
|
139
143
|
|
|
140
144
|
select finish();
|