@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.
Files changed (92) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +11 -0
  3. package/README.md +55 -0
  4. package/bin/agent-board-schema.js +97 -0
  5. package/fixtures/already-applied.json +181 -0
  6. package/fixtures/divergent-history.json +173 -0
  7. package/fixtures/production-history.json +173 -0
  8. package/migrations/20260501000001_agent_board_schema_version.sql +12 -0
  9. package/migrations/20260502000000_agent_board_schema.sql +180 -0
  10. package/migrations/20260503000000_agent_board_rpcs.sql +422 -0
  11. package/migrations/20260503000001_agent_board_coordination_rpcs.sql +229 -0
  12. package/migrations/20260504000000_agent_board_read_models.sql +206 -0
  13. package/migrations/20260505000000_agent_board_inbox_schema.sql +341 -0
  14. package/migrations/20260506000000_agent_board_inbox_delivery_rpcs.sql +1200 -0
  15. package/migrations/20260506000001_agent_board_inbox_callback_rpcs.sql +330 -0
  16. package/migrations/20260507000000_agent_board_inbox_reads.sql +334 -0
  17. package/migrations/20260508000000_agent_board_callback_runtime.sql +453 -0
  18. package/migrations/20260508000001_agent_board_inbox_service_role_reads.sql +10 -0
  19. package/migrations/20260510000000_agent_board_dblint_repairs.sql +413 -0
  20. package/migrations/20260511000000_agent_board_auth_schema.sql +146 -0
  21. package/migrations/20260511000001_agent_board_auth_credentials.sql +39 -0
  22. package/migrations/20260512000000_agent_board_auth_provisioning_rpcs.sql +622 -0
  23. package/migrations/20260512000001_agent_board_auth_v1_rpcs.sql +798 -0
  24. package/migrations/20260512000002_agent_board_auth_v2_rpcs.sql +1243 -0
  25. package/migrations/20260512000003_agent_board_auth_rls.sql +484 -0
  26. package/migrations/20260513000000_agent_board_backup_ops.sql +34 -0
  27. package/migrations/20260513000001_agent_board_retention.sql +160 -0
  28. package/migrations/20260513000002_agent_board_monitoring_views.sql +227 -0
  29. package/migrations/20260514000000_agent_board_auth_rls_id_qualification.sql +150 -0
  30. package/migrations/20260515000000_agent_board_boardopt.sql +493 -0
  31. package/migrations/20260516000000_agent_board_callbackcap.sql +113 -0
  32. package/migrations/20260517000000_agent_board_addressing.sql +542 -0
  33. package/migrations/20260628000000_agent_board_signing_store.sql +174 -0
  34. package/migrations/20260628000001_agent_board_signing_proof_rpcs.sql +215 -0
  35. package/migrations/20260628000002_agent_board_signature_rls_reads.sql +300 -0
  36. package/migrations/20260628000003_agent_board_signed_write_gateway.sql +288 -0
  37. package/migrations/20260628000004_agent_board_fleet_registry.sql +411 -0
  38. package/migrations/20260628000005_agent_board_fleet_policy.sql +509 -0
  39. package/migrations/20260628000006_agent_board_fleet_read_models.sql +170 -0
  40. package/migrations/20260629000100_agent_board_fleet_registry_repair.sql +411 -0
  41. package/migrations/20260629000101_agent_board_fleet_policy_refresh.sql +509 -0
  42. package/migrations/20260629000102_agent_board_fleet_read_models_refresh.sql +170 -0
  43. package/migrations/20260630000100_agent_board_harness_kind_open_vocab.sql +15 -0
  44. package/migrations/20260710000000_agent_board_authbound_boundary.sql +155 -0
  45. package/migrations/20260710000100_agent_board_schema_version_rpc.sql +14 -0
  46. package/migrations/20260710000400_agent_board_nonfleet_identity.sql +87 -0
  47. package/migrations/20260710000401_agent_board_workload_providers.sql +39 -0
  48. package/migrations/20260711000000_agent_board_provision_system_fail_closed.sql +242 -0
  49. package/migrations/20260711000100_canary_signed_fleet_enforcement.sql +234 -0
  50. package/migrations/20260712000000_agent_board_bundle_endpoint_compat.sql +97 -0
  51. package/migrations/20260713000000_agent_board_rls_reassert_board_scoping.sql +90 -0
  52. package/package.json +42 -0
  53. package/provenance.json +580 -0
  54. package/schema-manifest.json +458 -0
  55. package/src/check.js +23 -0
  56. package/src/index.js +50 -0
  57. package/src/materialize.js +73 -0
  58. package/src/plan.js +44 -0
  59. package/src/tooling.test.mjs +97 -0
  60. package/tests/agent_board_addressing.test.sql +166 -0
  61. package/tests/agent_board_auth_rls.test.sql +243 -0
  62. package/tests/agent_board_auth_rls_id_qualification.test.sql +225 -0
  63. package/tests/agent_board_auth_rpcs.test.sql +311 -0
  64. package/tests/agent_board_auth_schema.test.sql +411 -0
  65. package/tests/agent_board_authbound_boundary.test.sql +148 -0
  66. package/tests/agent_board_boardopt.test.sql +170 -0
  67. package/tests/agent_board_bundle_endpoint_compat.test.sql +49 -0
  68. package/tests/agent_board_callback_runtime.test.sql +425 -0
  69. package/tests/agent_board_callbackcap.test.sql +222 -0
  70. package/tests/agent_board_canary_signed_fleet_enforcement.test.sql +60 -0
  71. package/tests/agent_board_dblint_rpcs.test.sql +247 -0
  72. package/tests/agent_board_fleet_policy.test.sql +370 -0
  73. package/tests/agent_board_fleet_read_models.test.sql +158 -0
  74. package/tests/agent_board_fleet_registry.test.sql +149 -0
  75. package/tests/agent_board_inbox_reads.test.sql +471 -0
  76. package/tests/agent_board_inbox_rpcs.test.sql +452 -0
  77. package/tests/agent_board_inbox_schema.test.sql +355 -0
  78. package/tests/agent_board_nonfleet_identity.test.sql +26 -0
  79. package/tests/agent_board_rls_reassert_board_scoping.test.sql +39 -0
  80. package/tests/agent_board_schema_version.test.sql +24 -0
  81. package/tests/agent_board_schema_version_rpc.test.sql +40 -0
  82. package/tests/agent_board_signature_rls_reads.test.sql +133 -0
  83. package/tests/agent_board_signed_write_gateway.test.sql +219 -0
  84. package/tests/agent_board_signing_proof_rpcs.test.sql +143 -0
  85. package/tests/agent_board_signing_store.test.sql +183 -0
  86. package/tests/agent_board_smoke.test.sql +12 -0
  87. package/tests/agent_board_v1_invariants.test.sql +298 -0
  88. package/tests/agent_board_v2_invariants.test.sql +753 -0
  89. package/tests/agent_board_workload_providers.test.sql +15 -0
  90. package/tests/fixtures/adopter-base.sql +19 -0
  91. package/tests/fixtures/operator-hardening.sql +27 -0
  92. package/tests/fixtures/test-prereqs.sql +84 -0
@@ -0,0 +1,298 @@
1
+ create extension if not exists pgtap with schema extensions;
2
+ set search_path = extensions, public, agent_board;
3
+
4
+ begin;
5
+
6
+ select plan(17);
7
+
8
+ insert into agent_board.agents(id, agent_type, handle, display_name)
9
+ values
10
+ ('10000000-0000-0000-0000-000000000101', 'agent', 'v1_creator', 'V1 Creator'),
11
+ ('10000000-0000-0000-0000-000000000102', 'agent', 'v1_delegate', 'V1 Delegate')
12
+ on conflict (id) do nothing;
13
+
14
+ insert into agent_board.threads(id, thread_type, created_by_agent_id, subject)
15
+ values
16
+ ('10000000-0000-0000-0000-000000000201', 'coordination', '10000000-0000-0000-0000-000000000101', 'V1 invariant thread'),
17
+ ('10000000-0000-0000-0000-000000000202', 'coordination', '10000000-0000-0000-0000-000000000101', 'V1 other thread');
18
+
19
+ create temporary table v1_root_task on commit drop as
20
+ select *
21
+ from agent_board.create_task(
22
+ '10000000-0000-0000-0000-000000000201',
23
+ '10000000-0000-0000-0000-000000000101',
24
+ 'Root task',
25
+ 'Primary root task',
26
+ null,
27
+ null,
28
+ 'high',
29
+ 'distributed',
30
+ '{}'::jsonb
31
+ );
32
+
33
+ select is(
34
+ (select root_task_id::text from v1_root_task),
35
+ (select task_id::text from v1_root_task),
36
+ 'create_task self-roots root tasks'
37
+ );
38
+
39
+ create temporary table v1_child_task on commit drop as
40
+ select *
41
+ from agent_board.create_task(
42
+ '10000000-0000-0000-0000-000000000201',
43
+ '10000000-0000-0000-0000-000000000101',
44
+ 'Child task',
45
+ 'Child under root',
46
+ '10000000-0000-0000-0000-000000000102',
47
+ (select task_id from v1_root_task),
48
+ 'medium',
49
+ 'distributed',
50
+ '{}'::jsonb
51
+ );
52
+
53
+ select is(
54
+ (select parent_task_id::text from v1_child_task),
55
+ (select task_id::text from v1_root_task),
56
+ 'child tasks preserve parent_task_id'
57
+ );
58
+
59
+ select is(
60
+ (select root_task_id::text from v1_child_task),
61
+ (select task_id::text from v1_root_task),
62
+ 'child tasks inherit the canonical root_task_id'
63
+ );
64
+
65
+ create temporary table v1_message_one on commit drop as
66
+ select *
67
+ from agent_board.post_message(
68
+ '10000000-0000-0000-0000-000000000201',
69
+ '10000000-0000-0000-0000-000000000101',
70
+ 'First invariant message',
71
+ 'comment',
72
+ null,
73
+ '{}'::jsonb
74
+ );
75
+
76
+ create temporary table v1_message_two on commit drop as
77
+ select *
78
+ from agent_board.post_message(
79
+ '10000000-0000-0000-0000-000000000201',
80
+ '10000000-0000-0000-0000-000000000101',
81
+ 'Second invariant message',
82
+ 'comment',
83
+ null,
84
+ '{}'::jsonb
85
+ );
86
+
87
+ select is(
88
+ (select message_sequence from v1_message_one),
89
+ 1::bigint,
90
+ 'post_message starts thread-local sequences at one'
91
+ );
92
+
93
+ select is(
94
+ (select message_sequence from v1_message_two),
95
+ 2::bigint,
96
+ 'post_message increments thread-local sequences monotonically'
97
+ );
98
+
99
+ select is(
100
+ (select last_message_sequence from agent_board.threads where id = '10000000-0000-0000-0000-000000000201'),
101
+ 2::bigint,
102
+ 'threads.last_message_sequence tracks the latest inserted message'
103
+ );
104
+
105
+ create temporary table v1_event_two on commit drop as
106
+ select *
107
+ from agent_board.append_task_event(
108
+ (select task_id from v1_root_task),
109
+ '10000000-0000-0000-0000-000000000101',
110
+ 'commented',
111
+ jsonb_build_object('note', 'second event')
112
+ );
113
+
114
+ create temporary table v1_event_three on commit drop as
115
+ select *
116
+ from agent_board.append_task_event(
117
+ (select task_id from v1_root_task),
118
+ '10000000-0000-0000-0000-000000000101',
119
+ 'status_changed',
120
+ jsonb_build_object('status', 'in_progress'),
121
+ 'in_progress'
122
+ );
123
+
124
+ select is(
125
+ (select event_sequence from v1_event_two),
126
+ 2::bigint,
127
+ 'append_task_event advances task-local event sequences to two'
128
+ );
129
+
130
+ select is(
131
+ (select event_sequence from v1_event_three),
132
+ 3::bigint,
133
+ 'append_task_event advances task-local event sequences monotonically'
134
+ );
135
+
136
+ create temporary table v1_expired_claim on commit drop as
137
+ select *
138
+ from agent_board.acquire_claim(
139
+ '10000000-0000-0000-0000-000000000101',
140
+ 'repo_file',
141
+ 'README.md',
142
+ now() - interval '1 minute',
143
+ (select task_id from v1_root_task),
144
+ '10000000-0000-0000-0000-000000000201',
145
+ '{}'::jsonb
146
+ );
147
+
148
+ create temporary table v1_reused_claim on commit drop as
149
+ select *
150
+ from agent_board.acquire_claim(
151
+ '10000000-0000-0000-0000-000000000102',
152
+ 'repo_file',
153
+ 'README.md',
154
+ now() + interval '10 minutes',
155
+ (select task_id from v1_root_task),
156
+ '10000000-0000-0000-0000-000000000201',
157
+ '{}'::jsonb
158
+ );
159
+
160
+ select is(
161
+ (select status from agent_board.claims where id = (select claim_id from v1_expired_claim)),
162
+ 'expired',
163
+ 'acquire_claim expires stale active claims before reusing the resource'
164
+ );
165
+
166
+ select is(
167
+ (select agent_id::text from v1_reused_claim),
168
+ '10000000-0000-0000-0000-000000000102',
169
+ 'acquire_claim reassigns an expired resource to the next claimant'
170
+ );
171
+
172
+ create temporary table v1_active_claim on commit drop as
173
+ select *
174
+ from agent_board.acquire_claim(
175
+ '10000000-0000-0000-0000-000000000101',
176
+ 'file',
177
+ 'src/index.ts',
178
+ now() + interval '10 minutes',
179
+ (select task_id from v1_root_task),
180
+ '10000000-0000-0000-0000-000000000201',
181
+ '{}'::jsonb
182
+ );
183
+
184
+ select throws_ok(
185
+ $$select *
186
+ from agent_board.acquire_claim(
187
+ '10000000-0000-0000-0000-000000000102',
188
+ 'file',
189
+ 'src/index.ts',
190
+ now() + interval '10 minutes',
191
+ null,
192
+ '10000000-0000-0000-0000-000000000201'::uuid,
193
+ '{}'::jsonb
194
+ )$$,
195
+ '23505',
196
+ 'conflicting active claim',
197
+ 'conflicting active claims are rejected while the lease is still live'
198
+ );
199
+
200
+ create temporary table v1_delegation on commit drop as
201
+ select *
202
+ from agent_board.delegate_task(
203
+ (select task_id from v1_root_task),
204
+ '10000000-0000-0000-0000-000000000101',
205
+ 'Delegated child task',
206
+ 'Delegated details',
207
+ '10000000-0000-0000-0000-000000000102',
208
+ 'high',
209
+ 'handoff note',
210
+ '{}'::jsonb
211
+ );
212
+
213
+ select is(
214
+ (select parent_task_id::text from v1_delegation),
215
+ (select task_id::text from v1_root_task),
216
+ 'delegate_task preserves the parent task id on the delegation edge'
217
+ );
218
+
219
+ select is(
220
+ (select root_task_id::text from v1_delegation),
221
+ (select task_id::text from v1_root_task),
222
+ 'delegate_task preserves the canonical root task id on delegated children'
223
+ );
224
+
225
+ select is(
226
+ (select child_event_sequence from v1_delegation),
227
+ 1::bigint,
228
+ 'delegate_task creates delegated child tasks with a created event at sequence one'
229
+ );
230
+
231
+ select is(
232
+ (select parent_event_sequence from v1_delegation),
233
+ (
234
+ select max(event_sequence)
235
+ from agent_board.task_events
236
+ where task_id = (select task_id from v1_root_task)
237
+ ),
238
+ 'delegate_task appends the latest parent task event in sequence order'
239
+ );
240
+
241
+ insert into agent_board.tasks(
242
+ id,
243
+ thread_id,
244
+ created_by_agent_id,
245
+ root_task_id,
246
+ title
247
+ )
248
+ values (
249
+ '10000000-0000-0000-0000-000000000301'::uuid,
250
+ '10000000-0000-0000-0000-000000000201'::uuid,
251
+ '10000000-0000-0000-0000-000000000101'::uuid,
252
+ '10000000-0000-0000-0000-000000000301'::uuid,
253
+ 'Known root for cross-thread rejection'
254
+ );
255
+
256
+ select throws_ok(
257
+ $$select *
258
+ from agent_board.create_task(
259
+ '10000000-0000-0000-0000-000000000202',
260
+ '10000000-0000-0000-0000-000000000101',
261
+ 'Cross-thread child',
262
+ 'Should fail',
263
+ null,
264
+ '10000000-0000-0000-0000-000000000301'::uuid,
265
+ 'medium',
266
+ 'distributed',
267
+ '{}'::jsonb
268
+ )$$,
269
+ '22023',
270
+ 'parent task not found in thread',
271
+ 'create_task rejects parent_task_id values from another thread'
272
+ );
273
+
274
+ select throws_ok(
275
+ $$insert into agent_board.tasks(
276
+ id,
277
+ thread_id,
278
+ created_by_agent_id,
279
+ parent_task_id,
280
+ root_task_id,
281
+ title
282
+ )
283
+ values (
284
+ '10000000-0000-0000-0000-000000000401'::uuid,
285
+ '10000000-0000-0000-0000-000000000201'::uuid,
286
+ '10000000-0000-0000-0000-000000000101'::uuid,
287
+ '10000000-0000-0000-0000-000000000401'::uuid,
288
+ '10000000-0000-0000-0000-000000000401'::uuid,
289
+ 'Self-linked task'
290
+ )$$,
291
+ '23514',
292
+ NULL,
293
+ 'tasks_not_self_parent rejects self-linked task shapes'
294
+ );
295
+
296
+ select * from finish();
297
+
298
+ rollback;