@consiliency/agent-board-schema 1.2.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/LICENSE +202 -0
- package/NOTICE +11 -0
- package/README.md +55 -0
- package/bin/agent-board-schema.js +97 -0
- package/fixtures/already-applied.json +181 -0
- package/fixtures/divergent-history.json +173 -0
- package/fixtures/production-history.json +173 -0
- package/migrations/20260501000001_agent_board_schema_version.sql +12 -0
- package/migrations/20260502000000_agent_board_schema.sql +180 -0
- package/migrations/20260503000000_agent_board_rpcs.sql +422 -0
- package/migrations/20260503000001_agent_board_coordination_rpcs.sql +229 -0
- package/migrations/20260504000000_agent_board_read_models.sql +206 -0
- package/migrations/20260505000000_agent_board_inbox_schema.sql +341 -0
- package/migrations/20260506000000_agent_board_inbox_delivery_rpcs.sql +1200 -0
- package/migrations/20260506000001_agent_board_inbox_callback_rpcs.sql +330 -0
- package/migrations/20260507000000_agent_board_inbox_reads.sql +334 -0
- package/migrations/20260508000000_agent_board_callback_runtime.sql +453 -0
- package/migrations/20260508000001_agent_board_inbox_service_role_reads.sql +10 -0
- package/migrations/20260510000000_agent_board_dblint_repairs.sql +413 -0
- package/migrations/20260511000000_agent_board_auth_schema.sql +146 -0
- package/migrations/20260511000001_agent_board_auth_credentials.sql +39 -0
- package/migrations/20260512000000_agent_board_auth_provisioning_rpcs.sql +622 -0
- package/migrations/20260512000001_agent_board_auth_v1_rpcs.sql +798 -0
- package/migrations/20260512000002_agent_board_auth_v2_rpcs.sql +1243 -0
- package/migrations/20260512000003_agent_board_auth_rls.sql +484 -0
- package/migrations/20260513000000_agent_board_backup_ops.sql +34 -0
- package/migrations/20260513000001_agent_board_retention.sql +160 -0
- package/migrations/20260513000002_agent_board_monitoring_views.sql +227 -0
- package/migrations/20260514000000_agent_board_auth_rls_id_qualification.sql +150 -0
- package/migrations/20260515000000_agent_board_boardopt.sql +493 -0
- package/migrations/20260516000000_agent_board_callbackcap.sql +113 -0
- package/migrations/20260517000000_agent_board_addressing.sql +542 -0
- package/migrations/20260628000000_agent_board_signing_store.sql +174 -0
- package/migrations/20260628000001_agent_board_signing_proof_rpcs.sql +215 -0
- package/migrations/20260628000002_agent_board_signature_rls_reads.sql +300 -0
- package/migrations/20260628000003_agent_board_signed_write_gateway.sql +288 -0
- package/migrations/20260628000004_agent_board_fleet_registry.sql +411 -0
- package/migrations/20260628000005_agent_board_fleet_policy.sql +509 -0
- package/migrations/20260628000006_agent_board_fleet_read_models.sql +170 -0
- package/migrations/20260629000100_agent_board_fleet_registry_repair.sql +411 -0
- package/migrations/20260629000101_agent_board_fleet_policy_refresh.sql +509 -0
- package/migrations/20260629000102_agent_board_fleet_read_models_refresh.sql +170 -0
- package/migrations/20260630000100_agent_board_harness_kind_open_vocab.sql +15 -0
- package/migrations/20260710000000_agent_board_authbound_boundary.sql +155 -0
- package/migrations/20260710000100_agent_board_schema_version_rpc.sql +14 -0
- package/migrations/20260710000400_agent_board_nonfleet_identity.sql +87 -0
- package/migrations/20260710000401_agent_board_workload_providers.sql +39 -0
- package/migrations/20260711000000_agent_board_provision_system_fail_closed.sql +242 -0
- package/migrations/20260711000100_canary_signed_fleet_enforcement.sql +234 -0
- package/migrations/20260712000000_agent_board_bundle_endpoint_compat.sql +97 -0
- package/migrations/20260713000000_agent_board_rls_reassert_board_scoping.sql +90 -0
- package/package.json +42 -0
- package/provenance.json +580 -0
- package/schema-manifest.json +458 -0
- package/src/check.js +23 -0
- package/src/index.js +50 -0
- package/src/materialize.js +73 -0
- package/src/plan.js +44 -0
- package/src/tooling.test.mjs +97 -0
- package/tests/agent_board_addressing.test.sql +166 -0
- package/tests/agent_board_auth_rls.test.sql +243 -0
- package/tests/agent_board_auth_rls_id_qualification.test.sql +225 -0
- package/tests/agent_board_auth_rpcs.test.sql +311 -0
- package/tests/agent_board_auth_schema.test.sql +411 -0
- package/tests/agent_board_authbound_boundary.test.sql +148 -0
- package/tests/agent_board_boardopt.test.sql +170 -0
- package/tests/agent_board_bundle_endpoint_compat.test.sql +49 -0
- package/tests/agent_board_callback_runtime.test.sql +425 -0
- package/tests/agent_board_callbackcap.test.sql +222 -0
- package/tests/agent_board_canary_signed_fleet_enforcement.test.sql +60 -0
- package/tests/agent_board_dblint_rpcs.test.sql +247 -0
- package/tests/agent_board_fleet_policy.test.sql +370 -0
- package/tests/agent_board_fleet_read_models.test.sql +158 -0
- package/tests/agent_board_fleet_registry.test.sql +149 -0
- package/tests/agent_board_inbox_reads.test.sql +471 -0
- package/tests/agent_board_inbox_rpcs.test.sql +452 -0
- package/tests/agent_board_inbox_schema.test.sql +355 -0
- package/tests/agent_board_nonfleet_identity.test.sql +26 -0
- package/tests/agent_board_rls_reassert_board_scoping.test.sql +39 -0
- package/tests/agent_board_schema_version.test.sql +24 -0
- package/tests/agent_board_schema_version_rpc.test.sql +40 -0
- package/tests/agent_board_signature_rls_reads.test.sql +133 -0
- package/tests/agent_board_signed_write_gateway.test.sql +219 -0
- package/tests/agent_board_signing_proof_rpcs.test.sql +143 -0
- package/tests/agent_board_signing_store.test.sql +183 -0
- package/tests/agent_board_smoke.test.sql +12 -0
- package/tests/agent_board_v1_invariants.test.sql +298 -0
- package/tests/agent_board_v2_invariants.test.sql +753 -0
- package/tests/agent_board_workload_providers.test.sql +15 -0
- package/tests/fixtures/adopter-base.sql +19 -0
- package/tests/fixtures/operator-hardening.sql +27 -0
- package/tests/fixtures/test-prereqs.sql +84 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
create table if not exists agent_board.fleet_trust_domains (
|
|
2
|
+
id uuid primary key default gen_random_uuid(),
|
|
3
|
+
slug text not null unique,
|
|
4
|
+
display_name text not null,
|
|
5
|
+
domain_kind text not null check (domain_kind in ('tailnet', 'regenesis', 'development_mac', 'partner', 'external')),
|
|
6
|
+
owner_agent_id uuid not null references agent_board.agents(id) on delete cascade,
|
|
7
|
+
lifecycle_state text not null default 'pending' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
8
|
+
approved_at timestamptz,
|
|
9
|
+
revoked_at timestamptz,
|
|
10
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
11
|
+
created_at timestamptz not null default now(),
|
|
12
|
+
updated_at timestamptz not null default now(),
|
|
13
|
+
constraint fleet_trust_domains_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
14
|
+
constraint fleet_trust_domains_revoked_shape check (
|
|
15
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
16
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
comment on table agent_board.fleet_trust_domains is 'Metadata-safe fleet trust-domain registry; does not store raw host inventory or provider payloads.';
|
|
21
|
+
|
|
22
|
+
create table if not exists agent_board.fleet_machines (
|
|
23
|
+
id uuid primary key default gen_random_uuid(),
|
|
24
|
+
trust_domain_id uuid not null references agent_board.fleet_trust_domains(id) on delete cascade,
|
|
25
|
+
owner_agent_id uuid not null references agent_board.agents(id) on delete cascade,
|
|
26
|
+
machine_label text not null,
|
|
27
|
+
machine_fingerprint text not null,
|
|
28
|
+
lifecycle_state text not null default 'pending' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
29
|
+
enrollment_source text not null default 'portal' check (enrollment_source in ('portal', 'tailnet_bootstrap', 'provider_bootstrap', 'manual_import')),
|
|
30
|
+
enrolled_at timestamptz,
|
|
31
|
+
revoked_at timestamptz,
|
|
32
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
33
|
+
created_at timestamptz not null default now(),
|
|
34
|
+
updated_at timestamptz not null default now(),
|
|
35
|
+
constraint fleet_machines_owner_fingerprint_unique unique (owner_agent_id, machine_fingerprint),
|
|
36
|
+
constraint fleet_machines_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
37
|
+
constraint fleet_machines_revoked_shape check (
|
|
38
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
39
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
comment on table agent_board.fleet_machines is 'Metadata-safe enrolled machine records. Fingerprints are bounded descriptors, not raw host inventory.';
|
|
44
|
+
|
|
45
|
+
create index if not exists idx_agent_board_fleet_machines_trust_domain
|
|
46
|
+
on agent_board.fleet_machines(trust_domain_id, lifecycle_state, enrolled_at desc);
|
|
47
|
+
|
|
48
|
+
create unique index if not exists idx_agent_board_fleet_machines_fingerprint_unique
|
|
49
|
+
on agent_board.fleet_machines(machine_fingerprint);
|
|
50
|
+
|
|
51
|
+
create table if not exists agent_board.fleet_harness_registrations (
|
|
52
|
+
id uuid primary key default gen_random_uuid(),
|
|
53
|
+
machine_id uuid not null references agent_board.fleet_machines(id) on delete cascade,
|
|
54
|
+
harness_kind text not null check (harness_kind in ('codex', 'claude', 'gemini', 'cursor', 'generic_cli', 'mcp')),
|
|
55
|
+
harness_label text not null,
|
|
56
|
+
lifecycle_state text not null default 'active' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
57
|
+
revoked_at timestamptz,
|
|
58
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
59
|
+
created_at timestamptz not null default now(),
|
|
60
|
+
updated_at timestamptz not null default now(),
|
|
61
|
+
constraint fleet_harness_registrations_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
62
|
+
constraint fleet_harness_registrations_revoked_shape check (
|
|
63
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
64
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
create unique index if not exists idx_agent_board_fleet_harness_active_unique
|
|
69
|
+
on agent_board.fleet_harness_registrations(machine_id, harness_kind, harness_label)
|
|
70
|
+
where lifecycle_state = 'active';
|
|
71
|
+
|
|
72
|
+
create table if not exists agent_board.fleet_repo_scopes (
|
|
73
|
+
id uuid primary key default gen_random_uuid(),
|
|
74
|
+
harness_registration_id uuid not null references agent_board.fleet_harness_registrations(id) on delete cascade,
|
|
75
|
+
repo_slug text not null,
|
|
76
|
+
repo_fingerprint text not null,
|
|
77
|
+
scope_role text not null check (scope_role in ('owner', 'operator', 'worker', 'reviewer', 'observer')),
|
|
78
|
+
lifecycle_state text not null default 'active' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
79
|
+
revoked_at timestamptz,
|
|
80
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
81
|
+
created_at timestamptz not null default now(),
|
|
82
|
+
updated_at timestamptz not null default now(),
|
|
83
|
+
constraint fleet_repo_scopes_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
84
|
+
constraint fleet_repo_scopes_revoked_shape check (
|
|
85
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
86
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
create unique index if not exists idx_agent_board_fleet_repo_scopes_active_unique
|
|
91
|
+
on agent_board.fleet_repo_scopes(harness_registration_id, repo_fingerprint, scope_role)
|
|
92
|
+
where lifecycle_state = 'active';
|
|
93
|
+
|
|
94
|
+
create table if not exists agent_board.fleet_machine_agents (
|
|
95
|
+
id uuid primary key default gen_random_uuid(),
|
|
96
|
+
machine_id uuid not null references agent_board.fleet_machines(id) on delete cascade,
|
|
97
|
+
agent_id uuid not null references agent_board.agents(id) on delete cascade,
|
|
98
|
+
repo_scope_id uuid references agent_board.fleet_repo_scopes(id) on delete set null,
|
|
99
|
+
signing_key_id uuid references agent_board.agent_signing_keys(id) on delete set null,
|
|
100
|
+
agent_role text not null default 'phase_worker' check (agent_role in ('portal_operator', 'pipeline_runtime', 'phase_worker', 'reviewer', 'callback_receiver')),
|
|
101
|
+
lifecycle_state text not null default 'active' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
102
|
+
parent_agent_id uuid references agent_board.agents(id) on delete set null,
|
|
103
|
+
revoked_at timestamptz,
|
|
104
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
105
|
+
created_at timestamptz not null default now(),
|
|
106
|
+
updated_at timestamptz not null default now(),
|
|
107
|
+
constraint fleet_machine_agents_not_self_parent check (parent_agent_id is null or parent_agent_id <> agent_id),
|
|
108
|
+
constraint fleet_machine_agents_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
109
|
+
constraint fleet_machine_agents_revoked_shape check (
|
|
110
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
111
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
create unique index if not exists idx_agent_board_fleet_machine_agents_active_unique
|
|
116
|
+
on agent_board.fleet_machine_agents(machine_id, agent_id, coalesce(repo_scope_id, '00000000-0000-0000-0000-000000000000'::uuid))
|
|
117
|
+
where lifecycle_state = 'active';
|
|
118
|
+
|
|
119
|
+
create index if not exists idx_agent_board_fleet_machine_agents_agent
|
|
120
|
+
on agent_board.fleet_machine_agents(agent_id, lifecycle_state, updated_at desc);
|
|
121
|
+
|
|
122
|
+
create table if not exists agent_board.fleet_receive_policies (
|
|
123
|
+
id uuid primary key default gen_random_uuid(),
|
|
124
|
+
recipient_agent_id uuid references agent_board.agents(id) on delete cascade,
|
|
125
|
+
board_id uuid references agent_board.boards(id) on delete cascade,
|
|
126
|
+
trust_domain_id uuid references agent_board.fleet_trust_domains(id) on delete cascade,
|
|
127
|
+
policy_name text not null,
|
|
128
|
+
default_action text not null default 'deny' check (default_action in ('allow', 'deny', 'quarantine', 'non_actionable')),
|
|
129
|
+
require_signed_sender boolean not null default false,
|
|
130
|
+
lifecycle_state text not null default 'active' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
131
|
+
revoked_at timestamptz,
|
|
132
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
133
|
+
created_at timestamptz not null default now(),
|
|
134
|
+
updated_at timestamptz not null default now(),
|
|
135
|
+
constraint fleet_receive_policies_has_target check (
|
|
136
|
+
recipient_agent_id is not null or board_id is not null or trust_domain_id is not null
|
|
137
|
+
),
|
|
138
|
+
constraint fleet_receive_policies_metadata_object check (jsonb_typeof(metadata) = 'object'),
|
|
139
|
+
constraint fleet_receive_policies_revoked_shape check (
|
|
140
|
+
(lifecycle_state = 'revoked' and revoked_at is not null)
|
|
141
|
+
or (lifecycle_state <> 'revoked' and revoked_at is null)
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
create index if not exists idx_agent_board_fleet_receive_policies_target
|
|
146
|
+
on agent_board.fleet_receive_policies(
|
|
147
|
+
coalesce(recipient_agent_id, '00000000-0000-0000-0000-000000000000'::uuid),
|
|
148
|
+
coalesce(board_id, '00000000-0000-0000-0000-000000000000'::uuid),
|
|
149
|
+
coalesce(trust_domain_id, '00000000-0000-0000-0000-000000000000'::uuid),
|
|
150
|
+
lifecycle_state,
|
|
151
|
+
updated_at desc
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
create table if not exists agent_board.fleet_trust_sets (
|
|
155
|
+
id uuid primary key default gen_random_uuid(),
|
|
156
|
+
receive_policy_id uuid not null references agent_board.fleet_receive_policies(id) on delete cascade,
|
|
157
|
+
subject_kind text not null default 'trust_domain' check (subject_kind in ('trust_domain', 'machine', 'harness', 'repo_scope', 'agent')),
|
|
158
|
+
trust_domain_id uuid references agent_board.fleet_trust_domains(id) on delete cascade,
|
|
159
|
+
machine_id uuid references agent_board.fleet_machines(id) on delete cascade,
|
|
160
|
+
agent_id uuid references agent_board.agents(id) on delete cascade,
|
|
161
|
+
repo_scope_id uuid references agent_board.fleet_repo_scopes(id) on delete cascade,
|
|
162
|
+
harness_registration_id uuid references agent_board.fleet_harness_registrations(id) on delete cascade,
|
|
163
|
+
effect text not null check (effect in ('allow', 'deny', 'quarantine', 'non_actionable')),
|
|
164
|
+
require_signed_sender boolean,
|
|
165
|
+
lifecycle_state text not null default 'active' check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked')),
|
|
166
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
167
|
+
created_at timestamptz not null default now(),
|
|
168
|
+
updated_at timestamptz not null default now(),
|
|
169
|
+
constraint fleet_trust_sets_has_target check (
|
|
170
|
+
trust_domain_id is not null
|
|
171
|
+
or machine_id is not null
|
|
172
|
+
or agent_id is not null
|
|
173
|
+
or repo_scope_id is not null
|
|
174
|
+
or harness_registration_id is not null
|
|
175
|
+
),
|
|
176
|
+
constraint fleet_trust_sets_metadata_object check (jsonb_typeof(metadata) = 'object')
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
create table if not exists agent_board.fleet_revocation_events (
|
|
180
|
+
id uuid primary key default gen_random_uuid(),
|
|
181
|
+
subject_kind text not null check (subject_kind in ('trust_domain', 'machine', 'harness', 'repo_scope', 'agent', 'signing_key', 'credential')),
|
|
182
|
+
subject_id uuid not null,
|
|
183
|
+
trust_domain_id uuid references agent_board.fleet_trust_domains(id) on delete cascade,
|
|
184
|
+
machine_id uuid references agent_board.fleet_machines(id) on delete cascade,
|
|
185
|
+
harness_registration_id uuid references agent_board.fleet_harness_registrations(id) on delete cascade,
|
|
186
|
+
repo_scope_id uuid references agent_board.fleet_repo_scopes(id) on delete cascade,
|
|
187
|
+
agent_id uuid references agent_board.agents(id) on delete cascade,
|
|
188
|
+
signing_key_id uuid references agent_board.agent_signing_keys(id) on delete cascade,
|
|
189
|
+
revoked_by_agent_id uuid not null references agent_board.agents(id) on delete restrict,
|
|
190
|
+
revocation_reason text not null,
|
|
191
|
+
effective_at timestamptz not null default now(),
|
|
192
|
+
metadata jsonb not null default '{}'::jsonb,
|
|
193
|
+
created_at timestamptz not null default now(),
|
|
194
|
+
constraint fleet_revocation_events_metadata_object check (jsonb_typeof(metadata) = 'object')
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
create index if not exists idx_agent_board_fleet_revocation_actor
|
|
198
|
+
on agent_board.fleet_revocation_events(revoked_by_agent_id, effective_at desc);
|
|
199
|
+
|
|
200
|
+
alter table agent_board.fleet_receive_policies
|
|
201
|
+
add column if not exists revoked_at timestamptz;
|
|
202
|
+
|
|
203
|
+
alter table agent_board.fleet_trust_sets
|
|
204
|
+
add column if not exists subject_kind text not null default 'trust_domain',
|
|
205
|
+
add column if not exists require_signed_sender boolean,
|
|
206
|
+
add column if not exists lifecycle_state text not null default 'active',
|
|
207
|
+
add column if not exists updated_at timestamptz not null default now();
|
|
208
|
+
|
|
209
|
+
alter table agent_board.fleet_trust_sets
|
|
210
|
+
drop constraint if exists fleet_trust_sets_subject_kind_check,
|
|
211
|
+
add constraint fleet_trust_sets_subject_kind_check check (subject_kind in ('trust_domain', 'machine', 'harness', 'repo_scope', 'agent')),
|
|
212
|
+
drop constraint if exists fleet_trust_sets_lifecycle_state_check,
|
|
213
|
+
add constraint fleet_trust_sets_lifecycle_state_check check (lifecycle_state in ('pending', 'active', 'quarantined', 'suspended', 'revoked'));
|
|
214
|
+
|
|
215
|
+
create index if not exists idx_agent_board_fleet_trust_sets_policy
|
|
216
|
+
on agent_board.fleet_trust_sets(receive_policy_id, lifecycle_state, effect);
|
|
217
|
+
|
|
218
|
+
alter table agent_board.fleet_revocation_events
|
|
219
|
+
add column if not exists subject_id uuid,
|
|
220
|
+
add column if not exists trust_domain_id uuid references agent_board.fleet_trust_domains(id) on delete cascade,
|
|
221
|
+
add column if not exists machine_id uuid references agent_board.fleet_machines(id) on delete cascade,
|
|
222
|
+
add column if not exists harness_registration_id uuid references agent_board.fleet_harness_registrations(id) on delete cascade,
|
|
223
|
+
add column if not exists repo_scope_id uuid references agent_board.fleet_repo_scopes(id) on delete cascade,
|
|
224
|
+
add column if not exists agent_id uuid references agent_board.agents(id) on delete cascade,
|
|
225
|
+
add column if not exists signing_key_id uuid references agent_board.agent_signing_keys(id) on delete cascade;
|
|
226
|
+
|
|
227
|
+
update agent_board.fleet_revocation_events
|
|
228
|
+
set subject_id = coalesce(subject_id, trust_domain_id, machine_id, harness_registration_id, repo_scope_id, agent_id, signing_key_id)
|
|
229
|
+
where subject_id is null;
|
|
230
|
+
|
|
231
|
+
create unique index if not exists idx_agent_board_fleet_revocation_subject_unique
|
|
232
|
+
on agent_board.fleet_revocation_events(subject_kind, subject_id);
|
|
233
|
+
|
|
234
|
+
grant select, insert, update, delete on agent_board.fleet_trust_domains,
|
|
235
|
+
agent_board.fleet_machines,
|
|
236
|
+
agent_board.fleet_harness_registrations,
|
|
237
|
+
agent_board.fleet_repo_scopes,
|
|
238
|
+
agent_board.fleet_machine_agents,
|
|
239
|
+
agent_board.fleet_receive_policies,
|
|
240
|
+
agent_board.fleet_trust_sets,
|
|
241
|
+
agent_board.fleet_revocation_events
|
|
242
|
+
to service_role;
|
|
243
|
+
|
|
244
|
+
grant select on agent_board.fleet_trust_domains,
|
|
245
|
+
agent_board.fleet_machines,
|
|
246
|
+
agent_board.fleet_harness_registrations,
|
|
247
|
+
agent_board.fleet_repo_scopes,
|
|
248
|
+
agent_board.fleet_machine_agents,
|
|
249
|
+
agent_board.fleet_receive_policies,
|
|
250
|
+
agent_board.fleet_trust_sets,
|
|
251
|
+
agent_board.fleet_revocation_events
|
|
252
|
+
to authenticated;
|
|
253
|
+
|
|
254
|
+
alter table agent_board.fleet_trust_domains enable row level security;
|
|
255
|
+
alter table agent_board.fleet_machines enable row level security;
|
|
256
|
+
alter table agent_board.fleet_harness_registrations enable row level security;
|
|
257
|
+
alter table agent_board.fleet_repo_scopes enable row level security;
|
|
258
|
+
alter table agent_board.fleet_machine_agents enable row level security;
|
|
259
|
+
alter table agent_board.fleet_receive_policies enable row level security;
|
|
260
|
+
alter table agent_board.fleet_trust_sets enable row level security;
|
|
261
|
+
alter table agent_board.fleet_revocation_events enable row level security;
|
|
262
|
+
|
|
263
|
+
do $$
|
|
264
|
+
declare
|
|
265
|
+
v_table text;
|
|
266
|
+
begin
|
|
267
|
+
foreach v_table in array array[
|
|
268
|
+
'fleet_trust_domains',
|
|
269
|
+
'fleet_machines',
|
|
270
|
+
'fleet_harness_registrations',
|
|
271
|
+
'fleet_repo_scopes',
|
|
272
|
+
'fleet_machine_agents',
|
|
273
|
+
'fleet_receive_policies',
|
|
274
|
+
'fleet_trust_sets',
|
|
275
|
+
'fleet_revocation_events'
|
|
276
|
+
]
|
|
277
|
+
loop
|
|
278
|
+
execute format('drop policy if exists %I on agent_board.%I', 'agent_board_service_all_' || v_table, v_table);
|
|
279
|
+
execute format('create policy %I on agent_board.%I as permissive for all to service_role using (true) with check (true)', 'agent_board_service_all_' || v_table, v_table);
|
|
280
|
+
end loop;
|
|
281
|
+
end;
|
|
282
|
+
$$;
|
|
283
|
+
|
|
284
|
+
drop policy if exists agent_board_authenticated_select_fleet_trust_domains on agent_board.fleet_trust_domains;
|
|
285
|
+
create policy agent_board_authenticated_select_fleet_trust_domains
|
|
286
|
+
on agent_board.fleet_trust_domains
|
|
287
|
+
as permissive
|
|
288
|
+
for select
|
|
289
|
+
to authenticated
|
|
290
|
+
using (owner_agent_id = agent_board.current_agent_id());
|
|
291
|
+
|
|
292
|
+
drop policy if exists agent_board_authenticated_select_fleet_machines on agent_board.fleet_machines;
|
|
293
|
+
create policy agent_board_authenticated_select_fleet_machines
|
|
294
|
+
on agent_board.fleet_machines
|
|
295
|
+
as permissive
|
|
296
|
+
for select
|
|
297
|
+
to authenticated
|
|
298
|
+
using (
|
|
299
|
+
owner_agent_id = agent_board.current_agent_id()
|
|
300
|
+
or exists (
|
|
301
|
+
select 1
|
|
302
|
+
from agent_board.fleet_machine_agents fma
|
|
303
|
+
where fma.machine_id = id
|
|
304
|
+
and fma.agent_id = agent_board.current_agent_id()
|
|
305
|
+
and fma.lifecycle_state = 'active'
|
|
306
|
+
)
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
drop policy if exists agent_board_authenticated_select_fleet_harness_registrations on agent_board.fleet_harness_registrations;
|
|
310
|
+
create policy agent_board_authenticated_select_fleet_harness_registrations
|
|
311
|
+
on agent_board.fleet_harness_registrations
|
|
312
|
+
as permissive
|
|
313
|
+
for select
|
|
314
|
+
to authenticated
|
|
315
|
+
using (
|
|
316
|
+
exists (
|
|
317
|
+
select 1
|
|
318
|
+
from agent_board.fleet_machines fm
|
|
319
|
+
where fm.id = machine_id
|
|
320
|
+
and fm.owner_agent_id = agent_board.current_agent_id()
|
|
321
|
+
)
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
drop policy if exists agent_board_authenticated_select_fleet_repo_scopes on agent_board.fleet_repo_scopes;
|
|
325
|
+
create policy agent_board_authenticated_select_fleet_repo_scopes
|
|
326
|
+
on agent_board.fleet_repo_scopes
|
|
327
|
+
as permissive
|
|
328
|
+
for select
|
|
329
|
+
to authenticated
|
|
330
|
+
using (
|
|
331
|
+
exists (
|
|
332
|
+
select 1
|
|
333
|
+
from agent_board.fleet_harness_registrations fhr
|
|
334
|
+
join agent_board.fleet_machines fm on fm.id = fhr.machine_id
|
|
335
|
+
where fhr.id = harness_registration_id
|
|
336
|
+
and fm.owner_agent_id = agent_board.current_agent_id()
|
|
337
|
+
)
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
drop policy if exists agent_board_authenticated_select_fleet_machine_agents on agent_board.fleet_machine_agents;
|
|
341
|
+
create policy agent_board_authenticated_select_fleet_machine_agents
|
|
342
|
+
on agent_board.fleet_machine_agents
|
|
343
|
+
as permissive
|
|
344
|
+
for select
|
|
345
|
+
to authenticated
|
|
346
|
+
using (
|
|
347
|
+
agent_id = agent_board.current_agent_id()
|
|
348
|
+
or exists (
|
|
349
|
+
select 1
|
|
350
|
+
from agent_board.fleet_machines fm
|
|
351
|
+
where fm.id = machine_id
|
|
352
|
+
and fm.owner_agent_id = agent_board.current_agent_id()
|
|
353
|
+
)
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
drop policy if exists agent_board_authenticated_select_fleet_receive_policies on agent_board.fleet_receive_policies;
|
|
357
|
+
create policy agent_board_authenticated_select_fleet_receive_policies
|
|
358
|
+
on agent_board.fleet_receive_policies
|
|
359
|
+
as permissive
|
|
360
|
+
for select
|
|
361
|
+
to authenticated
|
|
362
|
+
using (
|
|
363
|
+
recipient_agent_id = agent_board.current_agent_id()
|
|
364
|
+
or exists (
|
|
365
|
+
select 1
|
|
366
|
+
from agent_board.fleet_trust_domains ftd
|
|
367
|
+
where ftd.id = trust_domain_id
|
|
368
|
+
and ftd.owner_agent_id = agent_board.current_agent_id()
|
|
369
|
+
)
|
|
370
|
+
or exists (
|
|
371
|
+
select 1
|
|
372
|
+
from agent_board.boards b
|
|
373
|
+
where b.id = board_id
|
|
374
|
+
and b.created_by_agent_id = agent_board.current_agent_id()
|
|
375
|
+
)
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
drop policy if exists agent_board_authenticated_select_fleet_trust_sets on agent_board.fleet_trust_sets;
|
|
379
|
+
create policy agent_board_authenticated_select_fleet_trust_sets
|
|
380
|
+
on agent_board.fleet_trust_sets
|
|
381
|
+
as permissive
|
|
382
|
+
for select
|
|
383
|
+
to authenticated
|
|
384
|
+
using (
|
|
385
|
+
exists (
|
|
386
|
+
select 1
|
|
387
|
+
from agent_board.fleet_receive_policies frp
|
|
388
|
+
where frp.id = receive_policy_id
|
|
389
|
+
and (
|
|
390
|
+
frp.recipient_agent_id = agent_board.current_agent_id()
|
|
391
|
+
or exists (
|
|
392
|
+
select 1
|
|
393
|
+
from agent_board.fleet_trust_domains ftd
|
|
394
|
+
where ftd.id = frp.trust_domain_id
|
|
395
|
+
and ftd.owner_agent_id = agent_board.current_agent_id()
|
|
396
|
+
)
|
|
397
|
+
)
|
|
398
|
+
)
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
drop policy if exists agent_board_authenticated_select_fleet_revocation_events on agent_board.fleet_revocation_events;
|
|
402
|
+
create policy agent_board_authenticated_select_fleet_revocation_events
|
|
403
|
+
on agent_board.fleet_revocation_events
|
|
404
|
+
as permissive
|
|
405
|
+
for select
|
|
406
|
+
to authenticated
|
|
407
|
+
using (revoked_by_agent_id = agent_board.current_agent_id());
|
|
408
|
+
|
|
409
|
+
insert into agent_board.schema_version (version)
|
|
410
|
+
values (6)
|
|
411
|
+
on conflict ((true)) do update set version = excluded.version;
|