@consiliency/agent-board-schema 1.22.0 → 1.24.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 (65) hide show
  1. package/README.md +75 -1
  2. package/fixtures/already-applied.json +40 -0
  3. package/migrations/20260901000100_agent_board_atomic_fleet_onboarding.sql +1496 -0
  4. package/migrations/20260901000110_agent_board_fleet_onboarding_ceiling_lock.sql +604 -0
  5. package/migrations/20260901000120_agent_board_human_revocation_evidence_completeness.sql +78 -0
  6. package/migrations/20260901000130_agent_board_fedsession_human_revocation_gate.sql +74 -0
  7. package/migrations/20260901000140_agent_board_fedsession_board_owner_lock_order.sql +102 -0
  8. package/migrations/20260902000100_agent_board_outbox_wake_ordering.sql +184 -0
  9. package/migrations/20260903000100_agent_board_enroll_identity_board_owner_lock_order.sql +604 -0
  10. package/migrations/20260903000200_agent_board_fedsession_provider_absence_gate.sql +177 -0
  11. package/migrations/20260904000100_agent_board_wake_recovery_surface.sql +155 -0
  12. package/migrations/20260905000100_agent_board_consent_gating_reconcile.sql +151 -0
  13. package/package.json +1 -1
  14. package/schema-manifest.json +93 -3
  15. package/src/check.js +23 -0
  16. package/src/index.js +20 -0
  17. package/src/plan.js +79 -5
  18. package/src/tooling.test.mjs +237 -4
  19. package/tests/agent_board_atomic_fleet_onboarding.test.sql +623 -0
  20. package/tests/agent_board_atomic_fleet_onboarding_backfill.test.sql +142 -0
  21. package/tests/agent_board_atomic_fleet_onboarding_runtime.test.sql +1250 -0
  22. package/tests/agent_board_enroll_federated_identity.test.sql +3 -3
  23. package/tests/agent_board_enroll_pop_binding.test.sql +13 -3
  24. package/tests/agent_board_enrollment_audit_content.test.sql +11 -7
  25. package/tests/agent_board_federated_lock_order_class.test.sql +390 -0
  26. package/tests/agent_board_fedsession.test.sql +46 -2
  27. package/tests/agent_board_fedsession_provider_absence_gate.test.sql +170 -0
  28. package/tests/agent_board_inbox_reads.test.sql +16 -19
  29. package/tests/agent_board_outbox_wake_ordering.test.sql +452 -0
  30. package/tests/agent_board_portal_offline_invariant.test.sql +1 -1
  31. package/tests/agent_board_roomlink.test.sql +2 -2
  32. package/tests/agent_board_wake_recovery.test.sql +756 -0
  33. package/tests/isolation/expected/atomic_fedsession_fleet_lock_order.out +79 -0
  34. package/tests/isolation/expected/atomic_fedsession_human_revoke.out +87 -0
  35. package/tests/isolation/expected/atomic_fleet_authority_races.out +469 -0
  36. package/tests/isolation/expected/atomic_fleet_binding_revoke.out +103 -0
  37. package/tests/isolation/expected/atomic_fleet_board_archive.out +117 -0
  38. package/tests/isolation/expected/atomic_fleet_human_fresh_revoke.out +136 -0
  39. package/tests/isolation/expected/atomic_fleet_identity_disposition.out +61 -0
  40. package/tests/isolation/expected/atomic_fleet_lifecycle_races.out +1479 -0
  41. package/tests/isolation/expected/atomic_fleet_onboarding.out +75 -0
  42. package/tests/isolation/expected/atomic_fleet_subtree_lock_order.out +60 -0
  43. package/tests/isolation/expected/ceiling_setter_lock_before_upsert.out +95 -0
  44. package/tests/isolation/expected/enroll_identity_board_owner_lock_order.out +55 -0
  45. package/tests/isolation/expected/fedsession_provider_absent_owner_lock.out +37 -0
  46. package/tests/isolation/expected/onboarding_ceiling_lock_order.out +123 -0
  47. package/tests/isolation/expected/outbox_wake_ordering.out +86 -0
  48. package/tests/isolation/expected/wake_recovery_late_commit.out +89 -0
  49. package/tests/isolation/specs/atomic_fedsession_fleet_lock_order.spec +117 -0
  50. package/tests/isolation/specs/atomic_fedsession_human_revoke.spec +66 -0
  51. package/tests/isolation/specs/atomic_fleet_authority_races.spec +235 -0
  52. package/tests/isolation/specs/atomic_fleet_binding_revoke.spec +127 -0
  53. package/tests/isolation/specs/atomic_fleet_board_archive.spec +134 -0
  54. package/tests/isolation/specs/atomic_fleet_human_fresh_revoke.spec +142 -0
  55. package/tests/isolation/specs/atomic_fleet_identity_disposition.spec +118 -0
  56. package/tests/isolation/specs/atomic_fleet_lifecycle_races.spec +244 -0
  57. package/tests/isolation/specs/atomic_fleet_onboarding.spec +106 -0
  58. package/tests/isolation/specs/atomic_fleet_subtree_lock_order.spec +147 -0
  59. package/tests/isolation/specs/ceiling_setter_lock_before_upsert.spec +117 -0
  60. package/tests/isolation/specs/enroll_identity_board_owner_lock_order.spec +117 -0
  61. package/tests/isolation/specs/fedsession_provider_absent_owner_lock.spec +63 -0
  62. package/tests/isolation/specs/onboarding_ceiling_lock_order.spec +183 -0
  63. package/tests/isolation/specs/outbox_wake_ordering.spec +202 -0
  64. package/tests/isolation/specs/wake_recovery_late_commit.spec +207 -0
  65. package/tests/seeds/20260901000100_agent_board_atomic_fleet_onboarding.sql.pre.sql +110 -0
@@ -0,0 +1,134 @@
1
+ # Consiliency/message-board#162 — board archival and composed fleet onboarding
2
+ # share the board row lock. Prove archive-first rejects and onboarding-first
3
+ # commits before archival without consuming another invite use.
4
+
5
+ setup
6
+ {
7
+ insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
8
+ values ('16290000-0000-0000-0000-000000000001', 'agent', 'agent',
9
+ 'atomic-archive-owner', 'Atomic Archive Owner', 'active');
10
+ select count(*) from agent_board.create_board(
11
+ '16290000-0000-0000-0000-000000000001',
12
+ 'atomic-archive-board', 'Atomic Archive Board',
13
+ 'Consiliency/message-board#162 archive race', jsonb_build_object(), 'private'
14
+ );
15
+ insert into agent_board.fleet_trust_domains(
16
+ id, slug, display_name, domain_kind, owner_agent_id, lifecycle_state, approved_at
17
+ ) values (
18
+ '16290000-0000-0000-0000-000000000002', 'atomic-archive-domain',
19
+ 'Atomic Archive Domain', 'tailnet', '16290000-0000-0000-0000-000000000001',
20
+ 'active', now()
21
+ );
22
+ insert into agent_board.fleet_machines(
23
+ id, trust_domain_id, owner_agent_id, machine_label, machine_fingerprint,
24
+ lifecycle_state, enrollment_source, enrolled_at
25
+ ) values (
26
+ '16290000-0000-0000-0000-000000000003',
27
+ '16290000-0000-0000-0000-000000000002',
28
+ '16290000-0000-0000-0000-000000000001',
29
+ 'claw', 'sha256:atomic-archive-machine', 'active', 'portal', now()
30
+ );
31
+ insert into agent_board.identity_providers(
32
+ issuer, audience, supported, policy_approved,
33
+ allowed_scopes, allowed_board_scopes, allowed_agent_kinds
34
+ ) values (
35
+ 'https://atomic-archive.test', 'message-board', true, true,
36
+ ARRAY['board:send'], ARRAY[]::text[], ARRAY['agent']
37
+ );
38
+ select count(*) from agent_board.create_fleet_onboarding_invite(
39
+ (select id from agent_board.boards where slug='atomic-archive-board'),
40
+ '16290000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
41
+ 'message-board', 'sha256:atomic-archive-repo', 'worker', 'phase_worker',
42
+ 'atomic-archive-agent', 1, now() + interval '1 hour',
43
+ '16290000-0000-0000-0000-000000000001', jsonb_build_object()
44
+ );
45
+ select count(*) from agent_board.onboard_federated_fleet_agent(
46
+ 'https://atomic-archive.test', 'message-board', 'human-archive',
47
+ jsonb_build_object('iss','https://atomic-archive.test','aud','message-board','sub','human-archive'),
48
+ 'atomic-archive-agent',
49
+ 'yd_DIFGWGusVg3SbktDJQ1bE5UWvtR33xln4b05JIhk',
50
+ 'raw_ed25519_base64url',
51
+ 'sha256:NeVC2vx1MbTY56jUwJcLLr6YwB4IKCERsXWbUwhf5pA',
52
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[],
53
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16290000-0000-0000-0000-000000000001'),
54
+ (select id from agent_board.boards where slug='atomic-archive-board'),
55
+ '16290000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
56
+ 'message-board', 'sha256:atomic-archive-repo', 'worker', 'phase_worker',
57
+ 'atomic-archive-agent'
58
+ );
59
+ }
60
+
61
+ teardown
62
+ {
63
+ delete from agent_board.fleet_machine_agents where machine_id='16290000-0000-0000-0000-000000000003';
64
+ delete from agent_board.fleet_repo_scopes where harness_registration_id in (
65
+ select id from agent_board.fleet_harness_registrations where machine_id='16290000-0000-0000-0000-000000000003'
66
+ );
67
+ delete from agent_board.fleet_harness_registrations where machine_id='16290000-0000-0000-0000-000000000003';
68
+ delete from agent_board.board_invite_redemptions where invite_id in (
69
+ select id from agent_board.board_invite_tokens where created_by_agent_id='16290000-0000-0000-0000-000000000001'
70
+ );
71
+ truncate agent_board.fleet_onboarding_invite_bounds;
72
+ delete from agent_board.board_invite_tokens where created_by_agent_id='16290000-0000-0000-0000-000000000001';
73
+ delete from agent_board.board_memberships where board_id in (
74
+ select id from agent_board.boards where slug='atomic-archive-board'
75
+ );
76
+ delete from agent_board.enrollment_federation_audit where issuer='https://atomic-archive.test';
77
+ delete from agent_board.agent_signing_keys where agent_id in (
78
+ select id from agent_board.agents where handle='atomic-archive-agent'
79
+ );
80
+ delete from agent_board.agents where handle='atomic-archive-agent';
81
+ delete from agent_board.boards where slug='atomic-archive-board';
82
+ delete from agent_board.fleet_machines where id='16290000-0000-0000-0000-000000000003';
83
+ delete from agent_board.fleet_trust_domains where id='16290000-0000-0000-0000-000000000002';
84
+ delete from agent_board.agents where id='16290000-0000-0000-0000-000000000001';
85
+ delete from agent_board.identity_providers where issuer='https://atomic-archive.test';
86
+ }
87
+
88
+ session "blocker"
89
+ step "blocker_begin" { BEGIN; }
90
+ step "block_machine" {
91
+ select id from agent_board.fleet_machines
92
+ where id='16290000-0000-0000-0000-000000000003' for update;
93
+ }
94
+ step "blocker_commit" { COMMIT; }
95
+
96
+ session "archive"
97
+ step "archive_begin" { BEGIN; }
98
+ step "archive_board" {
99
+ update agent_board.boards set status='archived'
100
+ where slug='atomic-archive-board' returning status;
101
+ }
102
+ step "archive_commit" { COMMIT; }
103
+
104
+ session "retry"
105
+ step "retry_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
106
+ step "retry_onboard" {
107
+ select identity_disposition, binding_disposition
108
+ from agent_board.onboard_federated_fleet_agent(
109
+ 'https://atomic-archive.test', 'message-board', 'human-archive',
110
+ jsonb_build_object('iss','https://atomic-archive.test','aud','message-board','sub','human-archive','iat',200),
111
+ 'atomic-archive-agent',
112
+ 'yd_DIFGWGusVg3SbktDJQ1bE5UWvtR33xln4b05JIhk',
113
+ 'raw_ed25519_base64url',
114
+ 'sha256:NeVC2vx1MbTY56jUwJcLLr6YwB4IKCERsXWbUwhf5pA',
115
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[],
116
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16290000-0000-0000-0000-000000000001'),
117
+ (select id from agent_board.boards where slug='atomic-archive-board'),
118
+ '16290000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
119
+ 'message-board', 'sha256:atomic-archive-repo', 'worker', 'phase_worker',
120
+ 'atomic-archive-agent'
121
+ );
122
+ }
123
+ step "retry_commit" { COMMIT; }
124
+
125
+ session "check"
126
+ step "check" {
127
+ select
128
+ (select status from agent_board.boards where slug='atomic-archive-board') as board_status,
129
+ (select uses_count from agent_board.board_invite_tokens where created_by_agent_id='16290000-0000-0000-0000-000000000001') as uses_count,
130
+ (select count(*) from agent_board.fleet_machine_agents where machine_id='16290000-0000-0000-0000-000000000003') as bindings;
131
+ }
132
+
133
+ permutation "archive_begin" "archive_board" "retry_begin" "retry_onboard" "archive_commit" "retry_commit" "check"
134
+ permutation "blocker_begin" "block_machine" "retry_begin" "retry_onboard" "archive_begin" "archive_board" "blocker_commit" "retry_commit" "archive_commit" "check"
@@ -0,0 +1,142 @@
1
+ # Consiliency/message-board#162 — a total human revocation and a fresh-key
2
+ # onboarding share the durable human-owner lock. Prove both orders: onboarding
3
+ # first is included in the subtree, while revocation first durably blocks it.
4
+
5
+ setup
6
+ {
7
+ insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
8
+ values ('16280000-0000-0000-0000-000000000001', 'agent', 'agent',
9
+ 'atomic-human-owner', 'Atomic Human Owner', 'active');
10
+ select count(*) from agent_board.create_board(
11
+ '16280000-0000-0000-0000-000000000001',
12
+ 'atomic-human-board', 'Atomic Human Board',
13
+ 'Consiliency/message-board#162 fresh human race', jsonb_build_object(), 'private'
14
+ );
15
+ insert into agent_board.fleet_trust_domains(
16
+ id, slug, display_name, domain_kind, owner_agent_id, lifecycle_state, approved_at
17
+ ) values (
18
+ '16280000-0000-0000-0000-000000000002', 'atomic-human-domain',
19
+ 'Atomic Human Domain', 'tailnet', '16280000-0000-0000-0000-000000000001',
20
+ 'active', now()
21
+ );
22
+ insert into agent_board.fleet_machines(
23
+ id, trust_domain_id, owner_agent_id, machine_label, machine_fingerprint,
24
+ lifecycle_state, enrollment_source, enrolled_at
25
+ ) values (
26
+ '16280000-0000-0000-0000-000000000003',
27
+ '16280000-0000-0000-0000-000000000002',
28
+ '16280000-0000-0000-0000-000000000001',
29
+ 'claw', 'sha256:atomic-human-machine', 'active', 'portal', now()
30
+ );
31
+ insert into agent_board.identity_providers(
32
+ issuer, audience, supported, policy_approved,
33
+ allowed_scopes, allowed_board_scopes, allowed_agent_kinds
34
+ ) values (
35
+ 'https://atomic-human.test', 'message-board', true, true,
36
+ ARRAY['board:send'], ARRAY[]::text[], ARRAY['agent']
37
+ );
38
+ select count(*) from agent_board.enroll_federated_identity(
39
+ 'https://atomic-human.test', 'message-board', 'human-fresh-race',
40
+ jsonb_build_object('iss','https://atomic-human.test','aud','message-board','sub','human-fresh-race'),
41
+ 'atomic-human-existing',
42
+ 'yd_DIFGWGusVg3SbktDJQ1bE5UWvtR33xln4b05JIhk',
43
+ 'raw_ed25519_base64url',
44
+ 'sha256:NeVC2vx1MbTY56jUwJcLLr6YwB4IKCERsXWbUwhf5pA',
45
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[], null
46
+ );
47
+ select count(*) from agent_board.create_fleet_onboarding_invite(
48
+ (select id from agent_board.boards where slug='atomic-human-board'),
49
+ '16280000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
50
+ 'message-board', 'sha256:atomic-human-repo', 'worker', 'phase_worker',
51
+ 'atomic-human-fresh', 1, now() + interval '1 hour',
52
+ '16280000-0000-0000-0000-000000000001', jsonb_build_object()
53
+ );
54
+ }
55
+
56
+ teardown
57
+ {
58
+ delete from agent_board.fleet_revocation_events where agent_id in (
59
+ select id from agent_board.agents where handle in ('atomic-human-existing','atomic-human-fresh')
60
+ );
61
+ delete from agent_board.fleet_machine_agents where machine_id='16280000-0000-0000-0000-000000000003';
62
+ delete from agent_board.fleet_repo_scopes where harness_registration_id in (
63
+ select id from agent_board.fleet_harness_registrations where machine_id='16280000-0000-0000-0000-000000000003'
64
+ );
65
+ delete from agent_board.fleet_harness_registrations where machine_id='16280000-0000-0000-0000-000000000003';
66
+ delete from agent_board.board_invite_redemptions where invite_id in (
67
+ select id from agent_board.board_invite_tokens where created_by_agent_id='16280000-0000-0000-0000-000000000001'
68
+ );
69
+ truncate agent_board.fleet_onboarding_invite_bounds;
70
+ delete from agent_board.board_invite_tokens where created_by_agent_id='16280000-0000-0000-0000-000000000001';
71
+ delete from agent_board.board_memberships where board_id in (
72
+ select id from agent_board.boards where slug='atomic-human-board'
73
+ );
74
+ delete from agent_board.enrollment_federation_audit where issuer='https://atomic-human.test';
75
+ delete from agent_board.agent_signing_keys where agent_id in (
76
+ select id from agent_board.agents where handle in ('atomic-human-existing','atomic-human-fresh')
77
+ );
78
+ delete from agent_board.fleet_human_revocations where owner_user_id in (
79
+ select owner_user_id from agent_board.agents where handle in ('atomic-human-existing','atomic-human-fresh')
80
+ );
81
+ delete from agent_board.agents where handle in ('atomic-human-existing','atomic-human-fresh');
82
+ delete from agent_board.boards where slug='atomic-human-board';
83
+ delete from agent_board.fleet_machines where id='16280000-0000-0000-0000-000000000003';
84
+ delete from agent_board.fleet_trust_domains where id='16280000-0000-0000-0000-000000000002';
85
+ delete from agent_board.agents where id='16280000-0000-0000-0000-000000000001';
86
+ delete from agent_board.identity_providers where issuer='https://atomic-human.test';
87
+ }
88
+
89
+ session "blocker"
90
+ step "blocker_begin" { BEGIN; }
91
+ step "block_creator" {
92
+ select id from agent_board.agents
93
+ where id='16280000-0000-0000-0000-000000000001' for update;
94
+ }
95
+ step "block_existing" {
96
+ select handle from agent_board.agents where handle='atomic-human-existing' for update;
97
+ }
98
+ step "blocker_commit" { COMMIT; }
99
+
100
+ session "onboard"
101
+ step "onboard_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
102
+ step "onboard_fresh" {
103
+ select identity_disposition, binding_disposition
104
+ from agent_board.onboard_federated_fleet_agent(
105
+ 'https://atomic-human.test', 'message-board', 'human-fresh-race',
106
+ jsonb_build_object('iss','https://atomic-human.test','aud','message-board','sub','human-fresh-race','iat',200),
107
+ 'atomic-human-fresh',
108
+ 'TDyof3w0SMg4SDYuj-qenolHC_n05cZbrLSckKVGtMo',
109
+ 'raw_ed25519_base64url',
110
+ 'sha256:lSBZnHvmPvQONy8aoygp-fmTg26iZenrZC-L5LN9m7M',
111
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[],
112
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16280000-0000-0000-0000-000000000001'),
113
+ (select id from agent_board.boards where slug='atomic-human-board'),
114
+ '16280000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
115
+ 'message-board', 'sha256:atomic-human-repo', 'worker', 'phase_worker',
116
+ 'atomic-human-fresh'
117
+ );
118
+ }
119
+ step "onboard_commit" { COMMIT; }
120
+
121
+ session "revoke"
122
+ step "revoke_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
123
+ step "revoke_human" {
124
+ select revoked_agent_count
125
+ from agent_board.revoke_human_subtree(
126
+ (select owner_user_id from agent_board.agents where handle='atomic-human-existing'),
127
+ '16280000-0000-0000-0000-000000000001', 'fresh race revoke'
128
+ );
129
+ }
130
+ step "revoke_commit" { COMMIT; }
131
+
132
+ session "check"
133
+ step "check" {
134
+ select
135
+ (select count(*) from agent_board.fleet_human_revocations) as human_revocations,
136
+ (select count(*) from agent_board.agents where handle='atomic-human-fresh') as fresh_agents,
137
+ (select coalesce(max(status),'absent') from agent_board.agents where handle='atomic-human-fresh') as fresh_status,
138
+ (select count(*) from agent_board.agent_signing_keys where fingerprint='sha256:lSBZnHvmPvQONy8aoygp-fmTg26iZenrZC-L5LN9m7M') as fresh_keys;
139
+ }
140
+
141
+ permutation "blocker_begin" "block_creator" "onboard_begin" "onboard_fresh" "revoke_begin" "revoke_human" "blocker_commit" "onboard_commit" "revoke_commit" "check"
142
+ permutation "blocker_begin" "block_existing" "revoke_begin" "revoke_human" "onboard_begin" "onboard_fresh" "blocker_commit" "revoke_commit" "onboard_commit" "check"
@@ -0,0 +1,118 @@
1
+ # Consiliency/message-board#162 — a fleet enrollment that waits behind a
2
+ # concurrent legacy enrollment for the same fingerprint must report the identity
3
+ # as reused. The outer composed RPC takes the fingerprint lock before classifying.
4
+
5
+ setup
6
+ {
7
+ insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
8
+ values ('16260000-0000-0000-0000-000000000001', 'agent', 'agent',
9
+ 'atomic-disposition-owner', 'Atomic Disposition Owner', 'active');
10
+ select count(*) from agent_board.create_board(
11
+ '16260000-0000-0000-0000-000000000001',
12
+ 'atomic-disposition-board', 'Atomic Disposition Board',
13
+ 'Consiliency/message-board#162 disposition isolation proof',
14
+ jsonb_build_object(), 'private'
15
+ );
16
+ insert into agent_board.fleet_trust_domains(
17
+ id, slug, display_name, domain_kind, owner_agent_id, lifecycle_state, approved_at
18
+ ) values (
19
+ '16260000-0000-0000-0000-000000000002', 'atomic-disposition-domain',
20
+ 'Atomic Disposition Domain', 'tailnet', '16260000-0000-0000-0000-000000000001',
21
+ 'active', now()
22
+ );
23
+ insert into agent_board.fleet_machines(
24
+ id, trust_domain_id, owner_agent_id, machine_label, machine_fingerprint,
25
+ lifecycle_state, enrollment_source, enrolled_at
26
+ ) values (
27
+ '16260000-0000-0000-0000-000000000003',
28
+ '16260000-0000-0000-0000-000000000002',
29
+ '16260000-0000-0000-0000-000000000001',
30
+ 'claw', 'sha256:atomic-disposition-machine', 'active', 'portal', now()
31
+ );
32
+ insert into agent_board.identity_providers(
33
+ issuer, audience, supported, policy_approved,
34
+ allowed_scopes, allowed_board_scopes, allowed_agent_kinds
35
+ ) values (
36
+ 'https://atomic-disposition.test', 'message-board', true, true,
37
+ ARRAY['board:send'], ARRAY[]::text[], ARRAY['agent']
38
+ );
39
+ select count(*) from agent_board.create_fleet_onboarding_invite(
40
+ (select id from agent_board.boards where slug='atomic-disposition-board'),
41
+ '16260000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
42
+ 'message-board', 'sha256:atomic-disposition-repo', 'worker', 'phase_worker',
43
+ 'atomic-disposition-agent', 1, now() + interval '1 hour',
44
+ '16260000-0000-0000-0000-000000000001', jsonb_build_object()
45
+ );
46
+ }
47
+
48
+ teardown
49
+ {
50
+ delete from agent_board.fleet_machine_agents where machine_id='16260000-0000-0000-0000-000000000003';
51
+ delete from agent_board.fleet_repo_scopes where harness_registration_id in (
52
+ select id from agent_board.fleet_harness_registrations where machine_id='16260000-0000-0000-0000-000000000003'
53
+ );
54
+ delete from agent_board.fleet_harness_registrations where machine_id='16260000-0000-0000-0000-000000000003';
55
+ delete from agent_board.board_invite_redemptions where invite_id in (
56
+ select id from agent_board.board_invite_tokens where created_by_agent_id='16260000-0000-0000-0000-000000000001'
57
+ );
58
+ truncate agent_board.fleet_onboarding_invite_bounds;
59
+ delete from agent_board.board_invite_tokens where created_by_agent_id='16260000-0000-0000-0000-000000000001';
60
+ delete from agent_board.board_memberships where board_id in (
61
+ select id from agent_board.boards where slug='atomic-disposition-board'
62
+ );
63
+ delete from agent_board.enrollment_federation_audit where issuer='https://atomic-disposition.test';
64
+ delete from agent_board.agent_signing_keys where agent_id in (
65
+ select id from agent_board.agents where handle='atomic-disposition-agent'
66
+ );
67
+ delete from agent_board.agents where handle='atomic-disposition-agent';
68
+ delete from agent_board.boards where slug='atomic-disposition-board';
69
+ delete from agent_board.fleet_machines where id='16260000-0000-0000-0000-000000000003';
70
+ delete from agent_board.fleet_trust_domains where id='16260000-0000-0000-0000-000000000002';
71
+ delete from agent_board.agents where id='16260000-0000-0000-0000-000000000001';
72
+ delete from agent_board.identity_providers where issuer='https://atomic-disposition.test';
73
+ }
74
+
75
+ session "legacy"
76
+ step "legacy_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
77
+ step "legacy_enroll" {
78
+ select agent_handle
79
+ from agent_board.enroll_federated_identity(
80
+ 'https://atomic-disposition.test', 'message-board', 'human-disposition',
81
+ jsonb_build_object('iss','https://atomic-disposition.test','aud','message-board','sub','human-disposition','iat',100),
82
+ 'atomic-disposition-agent',
83
+ '5TG73fnNhqeYkoSvPf9QwmWkvKWe0yA7B8YinAWQ8m4', 'raw_ed25519_base64url',
84
+ 'sha256:qhjEQe9R_x26TBZyBsd-LrpR1fh7Mvnz86rbsCKtjz8', true, null, 'agent',
85
+ ARRAY['board:send'], ARRAY[]::text[], null
86
+ );
87
+ }
88
+ step "legacy_commit" { COMMIT; }
89
+
90
+ session "fleet"
91
+ step "fleet_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
92
+ step "fleet_onboard" {
93
+ select identity_disposition, membership_disposition, binding_disposition
94
+ from agent_board.onboard_federated_fleet_agent(
95
+ 'https://atomic-disposition.test', 'message-board', 'human-disposition',
96
+ jsonb_build_object('iss','https://atomic-disposition.test','aud','message-board','sub','human-disposition','iat',101),
97
+ 'atomic-disposition-agent',
98
+ '5TG73fnNhqeYkoSvPf9QwmWkvKWe0yA7B8YinAWQ8m4', 'raw_ed25519_base64url',
99
+ 'sha256:qhjEQe9R_x26TBZyBsd-LrpR1fh7Mvnz86rbsCKtjz8', true, null, 'agent',
100
+ ARRAY['board:send'], ARRAY[]::text[],
101
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16260000-0000-0000-0000-000000000001'),
102
+ (select id from agent_board.boards where slug='atomic-disposition-board'),
103
+ '16260000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
104
+ 'message-board', 'sha256:atomic-disposition-repo', 'worker', 'phase_worker',
105
+ 'atomic-disposition-agent'
106
+ );
107
+ }
108
+ step "fleet_commit" { COMMIT; }
109
+
110
+ session "check"
111
+ step "check" {
112
+ select
113
+ (select count(*) from agent_board.agents where handle='atomic-disposition-agent') as agents,
114
+ (select count(*) from agent_board.agent_signing_keys where fingerprint='sha256:qhjEQe9R_x26TBZyBsd-LrpR1fh7Mvnz86rbsCKtjz8') as keys,
115
+ (select count(*) from agent_board.fleet_machine_agents where machine_id='16260000-0000-0000-0000-000000000003') as bindings;
116
+ }
117
+
118
+ permutation "legacy_begin" "legacy_enroll" "fleet_begin" "fleet_onboard" "legacy_commit" "fleet_commit" "check"
@@ -0,0 +1,244 @@
1
+ # Consiliency/message-board#162 — composed retry races every public lifecycle
2
+ # writer that can invalidate a completed fleet authority chain. Each writer is
3
+ # exercised in both winner orderings against the real onboarding RPC.
4
+
5
+ setup
6
+ {
7
+ insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
8
+ values
9
+ ('16240000-0000-0000-0000-000000000001', 'agent', 'agent',
10
+ 'atomic-lifecycle-owner', 'Atomic Lifecycle Owner', 'active'),
11
+ ('16240000-0000-0000-0000-000000000004', 'agent', 'agent',
12
+ 'atomic-lifecycle-new-owner', 'Atomic Lifecycle New Owner', 'active');
13
+
14
+ select count(*) from agent_board.create_board(
15
+ '16240000-0000-0000-0000-000000000001', 'atomic-lifecycle-board',
16
+ 'Atomic Lifecycle Board', 'Consiliency/message-board#162 isolation proof',
17
+ jsonb_build_object(), 'private'
18
+ );
19
+ insert into agent_board.fleet_trust_domains(
20
+ id, slug, display_name, domain_kind, owner_agent_id, lifecycle_state, approved_at
21
+ ) values (
22
+ '16240000-0000-0000-0000-000000000002', 'atomic-lifecycle-domain',
23
+ 'Atomic Lifecycle Domain', 'tailnet', '16240000-0000-0000-0000-000000000001',
24
+ 'active', now()
25
+ );
26
+ insert into agent_board.fleet_machines(
27
+ id, trust_domain_id, owner_agent_id, machine_label, machine_fingerprint,
28
+ lifecycle_state, enrollment_source, enrolled_at
29
+ ) values (
30
+ '16240000-0000-0000-0000-000000000003',
31
+ '16240000-0000-0000-0000-000000000002',
32
+ '16240000-0000-0000-0000-000000000001',
33
+ 'claw', 'sha256:atomic-lifecycle-machine', 'active', 'portal', now()
34
+ );
35
+ insert into agent_board.identity_providers(
36
+ issuer, audience, supported, policy_approved,
37
+ allowed_scopes, allowed_board_scopes, allowed_agent_kinds
38
+ ) values (
39
+ 'https://atomic-lifecycle.test', 'message-board', true, true,
40
+ ARRAY['board:send'], ARRAY[]::text[], ARRAY['agent']
41
+ );
42
+ select count(*) from agent_board.create_fleet_onboarding_invite(
43
+ (select id from agent_board.boards where slug='atomic-lifecycle-board'),
44
+ '16240000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
45
+ 'message-board', 'sha256:atomic-lifecycle-repo', 'worker', 'phase_worker',
46
+ 'atomic-lifecycle-agent', 1, now() + interval '1 hour',
47
+ '16240000-0000-0000-0000-000000000001', jsonb_build_object()
48
+ );
49
+ select count(*) from agent_board.onboard_federated_fleet_agent(
50
+ 'https://atomic-lifecycle.test', 'message-board', 'human-lifecycle',
51
+ jsonb_build_object('iss','https://atomic-lifecycle.test','aud','message-board','sub','human-lifecycle'),
52
+ 'atomic-lifecycle-agent',
53
+ 'yd_DIFGWGusVg3SbktDJQ1bE5UWvtR33xln4b05JIhk',
54
+ 'raw_ed25519_base64url',
55
+ 'sha256:NeVC2vx1MbTY56jUwJcLLr6YwB4IKCERsXWbUwhf5pA',
56
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[],
57
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16240000-0000-0000-0000-000000000001'),
58
+ (select id from agent_board.boards where slug='atomic-lifecycle-board'),
59
+ '16240000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
60
+ 'message-board', 'sha256:atomic-lifecycle-repo', 'worker', 'phase_worker',
61
+ 'atomic-lifecycle-agent'
62
+ );
63
+ }
64
+
65
+ teardown
66
+ {
67
+ delete from agent_board.fleet_human_revocations;
68
+ delete from agent_board.fleet_revocation_events where subject_id in (
69
+ '16240000-0000-0000-0000-000000000002',
70
+ '16240000-0000-0000-0000-000000000003',
71
+ (select id from agent_board.agents where handle='atomic-lifecycle-agent'),
72
+ (select k.id from agent_board.agent_signing_keys k join agent_board.agents a on a.id=k.agent_id where a.handle='atomic-lifecycle-agent'),
73
+ (select id from agent_board.fleet_harness_registrations where machine_id='16240000-0000-0000-0000-000000000003'),
74
+ (select frs.id from agent_board.fleet_repo_scopes frs join agent_board.fleet_harness_registrations fhr on fhr.id=frs.harness_registration_id where fhr.machine_id='16240000-0000-0000-0000-000000000003')
75
+ );
76
+ delete from agent_board.fleet_machine_agents where machine_id='16240000-0000-0000-0000-000000000003';
77
+ delete from agent_board.fleet_repo_scopes where harness_registration_id in (
78
+ select id from agent_board.fleet_harness_registrations where machine_id='16240000-0000-0000-0000-000000000003'
79
+ );
80
+ delete from agent_board.fleet_harness_registrations where machine_id='16240000-0000-0000-0000-000000000003';
81
+ delete from agent_board.board_invite_redemptions where invite_id in (
82
+ select id from agent_board.board_invite_tokens where created_by_agent_id='16240000-0000-0000-0000-000000000001'
83
+ );
84
+ truncate agent_board.fleet_onboarding_invite_bounds;
85
+ delete from agent_board.board_invite_tokens where created_by_agent_id='16240000-0000-0000-0000-000000000001';
86
+ delete from agent_board.board_memberships where board_id in (
87
+ select id from agent_board.boards where slug='atomic-lifecycle-board'
88
+ );
89
+ delete from agent_board.enrollment_federation_audit where agent_id in (
90
+ select id from agent_board.agents where handle='atomic-lifecycle-agent'
91
+ );
92
+ delete from agent_board.agent_signing_keys where agent_id in (
93
+ select id from agent_board.agents where handle='atomic-lifecycle-agent'
94
+ );
95
+ delete from agent_board.agents where handle='atomic-lifecycle-agent';
96
+ delete from agent_board.boards where slug='atomic-lifecycle-board';
97
+ delete from agent_board.fleet_machines where id='16240000-0000-0000-0000-000000000003';
98
+ delete from agent_board.fleet_trust_domains where id='16240000-0000-0000-0000-000000000002';
99
+ delete from agent_board.agents where id in (
100
+ '16240000-0000-0000-0000-000000000001',
101
+ '16240000-0000-0000-0000-000000000004'
102
+ );
103
+ delete from agent_board.identity_providers where issuer='https://atomic-lifecycle.test';
104
+ }
105
+
106
+ session "retry"
107
+ step "retry_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
108
+ step "retry_onboard" {
109
+ select identity_disposition, membership_disposition, binding_disposition
110
+ from agent_board.onboard_federated_fleet_agent(
111
+ 'https://atomic-lifecycle.test', 'message-board', 'human-lifecycle',
112
+ jsonb_build_object('iss','https://atomic-lifecycle.test','aud','message-board','sub','human-lifecycle','iat',200),
113
+ 'atomic-lifecycle-agent',
114
+ 'yd_DIFGWGusVg3SbktDJQ1bE5UWvtR33xln4b05JIhk',
115
+ 'raw_ed25519_base64url',
116
+ 'sha256:NeVC2vx1MbTY56jUwJcLLr6YwB4IKCERsXWbUwhf5pA',
117
+ true, null, 'agent', ARRAY['board:send'], ARRAY[]::text[],
118
+ (select code from agent_board.board_invite_tokens where created_by_agent_id='16240000-0000-0000-0000-000000000001'),
119
+ (select id from agent_board.boards where slug='atomic-lifecycle-board'),
120
+ '16240000-0000-0000-0000-000000000003', 'codex', 'phase-loop',
121
+ 'message-board', 'sha256:atomic-lifecycle-repo', 'worker', 'phase_worker',
122
+ 'atomic-lifecycle-agent'
123
+ );
124
+ }
125
+ step "retry_commit" { COMMIT; }
126
+
127
+ session "lifecycle"
128
+ step "lifecycle_begin" { BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role'; }
129
+ step "revoke_fleet_agent" {
130
+ select subject_kind from agent_board.revoke_fleet_subject(
131
+ 'agent', (select id from agent_board.agents where handle='atomic-lifecycle-agent'),
132
+ '16240000-0000-0000-0000-000000000001', 'isolation agent revoke', jsonb_build_object()
133
+ );
134
+ }
135
+ step "revoke_fleet_key" {
136
+ select subject_kind from agent_board.revoke_fleet_subject(
137
+ 'signing_key', (select k.id from agent_board.agent_signing_keys k join agent_board.agents a on a.id=k.agent_id where a.handle='atomic-lifecycle-agent'),
138
+ '16240000-0000-0000-0000-000000000001', 'isolation key revoke', jsonb_build_object()
139
+ );
140
+ }
141
+ step "revoke_agent" {
142
+ select status from agent_board.revoke_agent(
143
+ (select id from agent_board.agents where handle='atomic-lifecycle-agent'),
144
+ 'isolation legacy agent revoke'
145
+ );
146
+ }
147
+ step "revoke_agent_subtree" {
148
+ select revoked_agent_count from agent_board.revoke_agent_subtree(
149
+ (select id from agent_board.agents where handle='atomic-lifecycle-agent'),
150
+ '16240000-0000-0000-0000-000000000001', 'isolation agent subtree revoke'
151
+ );
152
+ }
153
+ step "revoke_human_subtree" {
154
+ select revoked_agent_count from agent_board.revoke_human_subtree(
155
+ (select owner_user_id from agent_board.agents where handle='atomic-lifecycle-agent'),
156
+ '16240000-0000-0000-0000-000000000001', 'isolation human subtree revoke'
157
+ );
158
+ }
159
+ step "revoke_harness" {
160
+ select subject_kind from agent_board.revoke_fleet_subject(
161
+ 'harness', (select id from agent_board.fleet_harness_registrations where machine_id='16240000-0000-0000-0000-000000000003'),
162
+ '16240000-0000-0000-0000-000000000001', 'isolation harness revoke', jsonb_build_object()
163
+ );
164
+ }
165
+ step "revoke_repo" {
166
+ select subject_kind from agent_board.revoke_fleet_subject(
167
+ 'repo_scope', (select frs.id from agent_board.fleet_repo_scopes frs join agent_board.fleet_harness_registrations fhr on fhr.id=frs.harness_registration_id where fhr.machine_id='16240000-0000-0000-0000-000000000003'),
168
+ '16240000-0000-0000-0000-000000000001', 'isolation repo revoke', jsonb_build_object()
169
+ );
170
+ }
171
+ step "revoke_machine" {
172
+ select subject_kind from agent_board.revoke_fleet_subject(
173
+ 'machine', '16240000-0000-0000-0000-000000000003',
174
+ '16240000-0000-0000-0000-000000000001', 'isolation machine revoke', jsonb_build_object()
175
+ );
176
+ }
177
+ step "reclaim_machine" {
178
+ select owner_agent_id from agent_board.reclaim_fleet_machine(
179
+ '16240000-0000-0000-0000-000000000003',
180
+ '16240000-0000-0000-0000-000000000004',
181
+ '16240000-0000-0000-0000-000000000001', 'isolation machine reclaim'
182
+ );
183
+ }
184
+ step "revoke_domain" {
185
+ select subject_kind from agent_board.revoke_fleet_subject(
186
+ 'trust_domain', '16240000-0000-0000-0000-000000000002',
187
+ '16240000-0000-0000-0000-000000000001', 'isolation domain revoke', jsonb_build_object()
188
+ );
189
+ }
190
+ step "reclaim_domain" {
191
+ select owner_agent_id from agent_board.reclaim_fleet_trust_domain(
192
+ '16240000-0000-0000-0000-000000000002',
193
+ '16240000-0000-0000-0000-000000000004',
194
+ '16240000-0000-0000-0000-000000000001', 'isolation domain reclaim'
195
+ );
196
+ }
197
+ step "lifecycle_commit" { COMMIT; }
198
+
199
+ session "check"
200
+ step "check" {
201
+ select a.status as agent_status,
202
+ k.status as key_status,
203
+ b.lifecycle_state as binding_state,
204
+ h.lifecycle_state as harness_state,
205
+ r.lifecycle_state as repo_state,
206
+ m.lifecycle_state as machine_state,
207
+ d.lifecycle_state as domain_state,
208
+ (select count(*) from agent_board.agents aa where aa.handle='atomic-lifecycle-agent') as agents,
209
+ (select count(*) from agent_board.fleet_machine_agents bb join agent_board.agents aa on aa.id=bb.agent_id where aa.handle='atomic-lifecycle-agent') as bindings
210
+ from agent_board.agents a
211
+ join agent_board.agent_signing_keys k on k.agent_id=a.id
212
+ join agent_board.fleet_machine_agents b on b.agent_id=a.id
213
+ join agent_board.fleet_machines m on m.id=b.machine_id
214
+ join agent_board.fleet_trust_domains d on d.id=m.trust_domain_id
215
+ join agent_board.fleet_harness_registrations h on h.machine_id=m.id
216
+ join agent_board.fleet_repo_scopes r on r.harness_registration_id=h.id
217
+ where a.handle='atomic-lifecycle-agent';
218
+ }
219
+
220
+ # Retry wins, then the real lifecycle writer commits.
221
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_fleet_agent" "retry_commit" "lifecycle_commit" "check"
222
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_fleet_key" "retry_commit" "lifecycle_commit" "check"
223
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_agent" "retry_commit" "lifecycle_commit" "check"
224
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_agent_subtree" "retry_commit" "lifecycle_commit" "check"
225
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_human_subtree" "retry_commit" "lifecycle_commit" "check"
226
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_harness" "retry_commit" "lifecycle_commit" "check"
227
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_repo" "retry_commit" "lifecycle_commit" "check"
228
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_machine" "retry_commit" "lifecycle_commit" "check"
229
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "reclaim_machine" "retry_commit" "lifecycle_commit" "check"
230
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "revoke_domain" "retry_commit" "lifecycle_commit" "check"
231
+ permutation "retry_begin" "retry_onboard" "lifecycle_begin" "reclaim_domain" "retry_commit" "lifecycle_commit" "check"
232
+
233
+ # The lifecycle writer wins; retry must roll back without replacement authority.
234
+ permutation "lifecycle_begin" "revoke_fleet_agent" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
235
+ permutation "lifecycle_begin" "revoke_fleet_key" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
236
+ permutation "lifecycle_begin" "revoke_agent" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
237
+ permutation "lifecycle_begin" "revoke_agent_subtree" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
238
+ permutation "lifecycle_begin" "revoke_human_subtree" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
239
+ permutation "lifecycle_begin" "revoke_harness" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
240
+ permutation "lifecycle_begin" "revoke_repo" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
241
+ permutation "lifecycle_begin" "revoke_machine" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
242
+ permutation "lifecycle_begin" "reclaim_machine" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
243
+ permutation "lifecycle_begin" "revoke_domain" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"
244
+ permutation "lifecycle_begin" "reclaim_domain" "retry_begin" "retry_onboard" "lifecycle_commit" "retry_commit" "check"