@consiliency/agent-board-schema 1.60.0 → 1.64.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 (100) hide show
  1. package/README.md +86 -0
  2. package/fixtures/already-applied.json +16 -0
  3. package/migrations/20261011000100_agent_board_session_identities.sql +1964 -0
  4. package/migrations/20261012000100_agent_board_sidowner.sql +209 -0
  5. package/migrations/20261014000100_agent_board_grant_target_role.sql +218 -0
  6. package/migrations/20261014000200_agent_board_last_owner.sql +239 -0
  7. package/package.json +1 -1
  8. package/schema-manifest.json +39 -3
  9. package/src/tooling.test.mjs +10 -2
  10. package/tests/agent_board_atomic_fleet_onboarding.test.sql +15 -4
  11. package/tests/agent_board_atomic_fleet_onboarding_runtime.test.sql +7 -0
  12. package/tests/agent_board_consent_emission.test.sql +30 -11
  13. package/tests/agent_board_consent_gating.test.sql +16 -2
  14. package/tests/agent_board_delegate_role_class.test.sql +1 -1
  15. package/tests/agent_board_delegation_cap_ceiling.test.sql +26 -15
  16. package/tests/agent_board_delegation_enforcement.test.sql +1 -1
  17. package/tests/agent_board_enroll_resumption.test.sql +22 -4
  18. package/tests/agent_board_enroll_token_single_use.test.sql +18 -3
  19. package/tests/agent_board_federated_lock_order_class.test.sql +2 -2
  20. package/tests/agent_board_fk_lock_edges.test.sql +77 -16
  21. package/tests/agent_board_grant_target_role.test.sql +1118 -0
  22. package/tests/agent_board_hosted_delegates.test.sql +5 -3
  23. package/tests/agent_board_invite_no_downgrade.test.sql +15 -11
  24. package/tests/agent_board_ledger_authority.test.sql +77 -12
  25. package/tests/agent_board_membership_current_row_class.test.sql +9 -1
  26. package/tests/agent_board_mint_fleet_agent_session.test.sql +2 -2
  27. package/tests/agent_board_mint_harden.test.sql +38 -27
  28. package/tests/agent_board_role_guard.test.sql +319 -0
  29. package/tests/agent_board_rolereset.test.sql +25 -29
  30. package/tests/agent_board_roomdeleg.test.sql +8 -0
  31. package/tests/agent_board_roomdeleg_lane_b.test.sql +6 -6
  32. package/tests/agent_board_roomown.test.sql +3 -1
  33. package/tests/agent_board_rowid.test.sql +7 -2
  34. package/tests/agent_board_session_identity_approval_revocation.test.sql +334 -0
  35. package/tests/agent_board_session_identity_backfill.test.sql +82 -0
  36. package/tests/agent_board_session_identity_backfill_refusal.test.sql +14 -0
  37. package/tests/agent_board_session_identity_behavior_classes.test.sql +176 -0
  38. package/tests/agent_board_session_identity_class.test.sql +118 -0
  39. package/tests/agent_board_session_identity_fingerprint.test.sql +271 -0
  40. package/tests/agent_board_session_identity_labels_limits.test.sql +205 -0
  41. package/tests/agent_board_session_identity_lease.test.sql +235 -0
  42. package/tests/agent_board_session_identity_lifetime.test.sql +230 -0
  43. package/tests/agent_board_session_identity_limits.test.sql +208 -0
  44. package/tests/agent_board_session_identity_lineage.test.sql +64 -0
  45. package/tests/agent_board_session_identity_link.test.sql +201 -0
  46. package/tests/agent_board_session_identity_mint.test.sql +233 -0
  47. package/tests/agent_board_session_identity_panel_r1.test.sql +194 -0
  48. package/tests/agent_board_session_identity_panel_r2.test.sql +174 -0
  49. package/tests/agent_board_session_identity_protected_actions.test.sql +156 -0
  50. package/tests/agent_board_session_identity_revoke_closure.test.sql +131 -0
  51. package/tests/agent_board_sidowner_leases.test.sql +107 -0
  52. package/tests/agent_board_sidowner_owner_required.test.sql +97 -0
  53. package/tests/agent_board_sidowner_read_class.test.sql +171 -0
  54. package/tests/agent_board_sidowner_reads.test.sql +136 -0
  55. package/tests/agent_board_signer_lifecycle.test.sql +26 -4
  56. package/tests/agent_board_signing_challenge_pending_cap.test.sql +1 -1
  57. package/tests/agent_board_write_enforcement_class.test.sql +74 -15
  58. package/tests/catalog/function_execute_privileges.json +227 -2
  59. package/tests/catalog/p_metadata_parameters.json +102 -2
  60. package/tests/isolation/expected/grant_target_role_race.out +348 -0
  61. package/tests/isolation/expected/last_owner_departure.out +562 -0
  62. package/tests/isolation/expected/session_identity_limits.out +165 -0
  63. package/tests/isolation/expected/session_identity_links.out +235 -0
  64. package/tests/isolation/expected/session_identity_reclaim.out +253 -0
  65. package/tests/isolation/expected/session_identity_renew_revoke.out +115 -0
  66. package/tests/isolation/expected/session_identity_renew_revoke_key_gate.out +138 -0
  67. package/tests/isolation/expected/session_identity_tombstone_onboarding.out +247 -0
  68. package/tests/isolation/specs/atomic_fleet_authority_races.spec +8 -3
  69. package/tests/isolation/specs/atomic_fleet_binding_revoke.spec +0 -3
  70. package/tests/isolation/specs/atomic_fleet_board_archive.spec +0 -3
  71. package/tests/isolation/specs/atomic_fleet_human_fresh_revoke.spec +0 -3
  72. package/tests/isolation/specs/atomic_fleet_identity_disposition.spec +0 -3
  73. package/tests/isolation/specs/atomic_fleet_lifecycle_races.spec +0 -3
  74. package/tests/isolation/specs/atomic_fleet_subtree_lock_order.spec +0 -3
  75. package/tests/isolation/specs/ceiling_setter_lock_before_upsert.spec +0 -3
  76. package/tests/isolation/specs/claimpolicy_acquire_revert_race.spec +0 -2
  77. package/tests/isolation/specs/claimpolicy_board_scope.spec +0 -2
  78. package/tests/isolation/specs/claimpolicy_claimrow_lock_order.spec +0 -2
  79. package/tests/isolation/specs/claimpolicy_isolation_refusal.spec +0 -2
  80. package/tests/isolation/specs/claimpolicy_renew_revert_race.spec +0 -2
  81. package/tests/isolation/specs/claimpolicy_writer_keyshare.spec +0 -2
  82. package/tests/isolation/specs/consent_approval_lock.spec +0 -1
  83. package/tests/isolation/specs/consent_emit_actual_state.spec +0 -1
  84. package/tests/isolation/specs/grant_target_role_race.spec +206 -0
  85. package/tests/isolation/specs/hosted_delegate_add_tombstone_race.spec +0 -1
  86. package/tests/isolation/specs/hosted_delegate_tombstone_revoke_race.spec +0 -1
  87. package/tests/isolation/specs/hosted_delegate_withdraw_evict_race.spec +0 -1
  88. package/tests/isolation/specs/last_owner_departure.spec +137 -0
  89. package/tests/isolation/specs/ledger_authority_revoke.spec +0 -3
  90. package/tests/isolation/specs/onboarding_ceiling_lock_order.spec +0 -3
  91. package/tests/isolation/specs/outbox_wake_ordering.spec +0 -1
  92. package/tests/isolation/specs/session_identity_limits.spec +81 -0
  93. package/tests/isolation/specs/session_identity_links.spec +82 -0
  94. package/tests/isolation/specs/session_identity_reclaim.spec +125 -0
  95. package/tests/isolation/specs/session_identity_renew_revoke.spec +84 -0
  96. package/tests/isolation/specs/session_identity_renew_revoke_key_gate.spec +94 -0
  97. package/tests/isolation/specs/session_identity_tombstone_onboarding.spec +107 -0
  98. package/tests/isolation/specs/signed_grant_onboarding_deadlock.spec +0 -1
  99. package/tests/isolation/specs/signer_lifecycle_revoke.spec +0 -1
  100. package/tests/seeds/20261011000100_agent_board_session_identities.sql.pre.sql +47 -0
@@ -0,0 +1,115 @@
1
+ Parsed test spec with 3 sessions
2
+
3
+ starting permutation: renew_begin renew revoke_begin revoke renew_commit revoke_commit check
4
+ step renew_begin:
5
+ BEGIN;
6
+ select set_config('request.jwt.claim.sub', (select auth_user_id::text from agent_board.agents where handle = 'sid-renew-child'), true) is not null as holder_forwarded;
7
+ SET LOCAL ROLE service_role;
8
+ SET LOCAL "request.jwt.claim.role" = 'service_role';
9
+ SET LOCAL "request.jwt.claim.identity_lease_epoch" = '0';
10
+
11
+ holder_forwarded
12
+ ----------------
13
+ t
14
+ (1 row)
15
+
16
+ step renew:
17
+ select agent_board.renew_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'), 'approved');
18
+
19
+ renew_session_identity
20
+ ----------------------
21
+
22
+ (1 row)
23
+
24
+ step revoke_begin:
25
+ BEGIN;
26
+ SET LOCAL ROLE authenticated;
27
+ SET LOCAL "request.jwt.claim.role" = 'authenticated';
28
+ SET LOCAL "request.jwt.claim.sub" = '81000000-0000-4000-8000-000000000001';
29
+
30
+ step revoke:
31
+ select agent_board.revoke_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'));
32
+ <waiting ...>
33
+ step renew_commit: COMMIT;
34
+ step revoke: <... completed>
35
+ revoke_session_identity
36
+ -----------------------
37
+
38
+ (1 row)
39
+
40
+ step revoke_commit: COMMIT;
41
+ step check:
42
+ select si.tombstone_reason, si.credential_epoch, a.status, g.revoked_at is not null as grant_revoked,
43
+ g.last_renewed_at is not null as renewal_preceded_revoke,
44
+ (select count(*) from agent_board.fleet_revocation_events e where e.subject_id = a.id) as permanent_revocations,
45
+ (select count(*) from agent_board.agent_signing_keys k where k.agent_id = a.id and k.status <> 'revoked') as active_keys
46
+ from agent_board.agents a join agent_board.session_identities si on si.agent_id = a.id
47
+ join agent_board.delegation_grants g on g.child_agent_id = a.id where a.handle = 'sid-renew-child';
48
+ select bool_and(expires_at <= issued_at + interval '900 seconds') as bounded_pre_revoke_tokens
49
+ from agent_board.nonfleet_sessions where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child');
50
+
51
+ tombstone_reason|credential_epoch|status |grant_revoked|renewal_preceded_revoke|permanent_revocations|active_keys
52
+ ----------------+----------------+-------+-------------+-----------------------+---------------------+-----------
53
+ revoked | 1|revoked|t |t | 1| 0
54
+ (1 row)
55
+
56
+ bounded_pre_revoke_tokens
57
+ -------------------------
58
+ t
59
+ (1 row)
60
+
61
+
62
+ starting permutation: revoke_begin revoke renew_begin renew revoke_commit renew_commit check
63
+ step revoke_begin:
64
+ BEGIN;
65
+ SET LOCAL ROLE authenticated;
66
+ SET LOCAL "request.jwt.claim.role" = 'authenticated';
67
+ SET LOCAL "request.jwt.claim.sub" = '81000000-0000-4000-8000-000000000001';
68
+
69
+ step revoke:
70
+ select agent_board.revoke_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'));
71
+
72
+ revoke_session_identity
73
+ -----------------------
74
+
75
+ (1 row)
76
+
77
+ step renew_begin:
78
+ BEGIN;
79
+ select set_config('request.jwt.claim.sub', (select auth_user_id::text from agent_board.agents where handle = 'sid-renew-child'), true) is not null as holder_forwarded;
80
+ SET LOCAL ROLE service_role;
81
+ SET LOCAL "request.jwt.claim.role" = 'service_role';
82
+ SET LOCAL "request.jwt.claim.identity_lease_epoch" = '0';
83
+
84
+ holder_forwarded
85
+ ----------------
86
+ t
87
+ (1 row)
88
+
89
+ step renew:
90
+ select agent_board.renew_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'), 'approved');
91
+ <waiting ...>
92
+ step revoke_commit: COMMIT;
93
+ step renew: <... completed>
94
+ ERROR: identity_tombstoned
95
+ step renew_commit: COMMIT;
96
+ step check:
97
+ select si.tombstone_reason, si.credential_epoch, a.status, g.revoked_at is not null as grant_revoked,
98
+ g.last_renewed_at is not null as renewal_preceded_revoke,
99
+ (select count(*) from agent_board.fleet_revocation_events e where e.subject_id = a.id) as permanent_revocations,
100
+ (select count(*) from agent_board.agent_signing_keys k where k.agent_id = a.id and k.status <> 'revoked') as active_keys
101
+ from agent_board.agents a join agent_board.session_identities si on si.agent_id = a.id
102
+ join agent_board.delegation_grants g on g.child_agent_id = a.id where a.handle = 'sid-renew-child';
103
+ select bool_and(expires_at <= issued_at + interval '900 seconds') as bounded_pre_revoke_tokens
104
+ from agent_board.nonfleet_sessions where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child');
105
+
106
+ tombstone_reason|credential_epoch|status |grant_revoked|renewal_preceded_revoke|permanent_revocations|active_keys
107
+ ----------------+----------------+-------+-------------+-----------------------+---------------------+-----------
108
+ revoked | 1|revoked|t |f | 1| 0
109
+ (1 row)
110
+
111
+ bounded_pre_revoke_tokens
112
+ -------------------------
113
+ t
114
+ (1 row)
115
+
@@ -0,0 +1,138 @@
1
+ Parsed test spec with 4 sessions
2
+
3
+ starting permutation: key_begin key_hold revoke_begin revoke renew_begin renew key_commit revoke_commit renew_commit check
4
+ step key_begin: BEGIN;
5
+ step key_hold:
6
+ select 1 as held from agent_board.agent_signing_keys
7
+ where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child') for update;
8
+
9
+ held
10
+ ----
11
+ 1
12
+ (1 row)
13
+
14
+ step revoke_begin:
15
+ BEGIN;
16
+ SET LOCAL ROLE authenticated;
17
+ SET LOCAL "request.jwt.claim.role" = 'authenticated';
18
+ SET LOCAL "request.jwt.claim.sub" = '81000000-0000-4000-8000-000000000001';
19
+
20
+ step revoke:
21
+ select agent_board.revoke_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'));
22
+ <waiting ...>
23
+ step renew_begin:
24
+ BEGIN;
25
+ select set_config('request.jwt.claim.sub', (select auth_user_id::text from agent_board.agents where handle = 'sid-renew-child'), true) is not null as holder_forwarded;
26
+ SET LOCAL ROLE service_role;
27
+ SET LOCAL "request.jwt.claim.role" = 'service_role';
28
+ SET LOCAL "request.jwt.claim.identity_lease_epoch" = '0';
29
+
30
+ holder_forwarded
31
+ ----------------
32
+ t
33
+ (1 row)
34
+
35
+ step renew:
36
+ select agent_board.renew_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'), 'approved');
37
+ <waiting ...>
38
+ step key_commit: COMMIT;
39
+ step revoke: <... completed>
40
+ revoke_session_identity
41
+ -----------------------
42
+
43
+ (1 row)
44
+
45
+ step revoke_commit: COMMIT;
46
+ step renew: <... completed>
47
+ ERROR: identity_tombstoned
48
+ step renew_commit: COMMIT;
49
+ step check:
50
+ select si.tombstone_reason, si.credential_epoch, a.status, g.revoked_at is not null as grant_revoked,
51
+ g.last_renewed_at is not null as renewal_preceded_revoke,
52
+ (select count(*) from agent_board.fleet_revocation_events e where e.subject_id = a.id) as permanent_revocations,
53
+ (select count(*) from agent_board.agent_signing_keys k where k.agent_id = a.id and k.status <> 'revoked') as active_keys
54
+ from agent_board.agents a join agent_board.session_identities si on si.agent_id = a.id
55
+ join agent_board.delegation_grants g on g.child_agent_id = a.id where a.handle = 'sid-renew-child';
56
+ select bool_and(expires_at <= issued_at + interval '900 seconds') as bounded_pre_revoke_tokens
57
+ from agent_board.nonfleet_sessions where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child');
58
+
59
+ tombstone_reason|credential_epoch|status |grant_revoked|renewal_preceded_revoke|permanent_revocations|active_keys
60
+ ----------------+----------------+-------+-------------+-----------------------+---------------------+-----------
61
+ revoked | 1|revoked|t |f | 1| 0
62
+ (1 row)
63
+
64
+ bounded_pre_revoke_tokens
65
+ -------------------------
66
+ t
67
+ (1 row)
68
+
69
+
70
+ starting permutation: key_begin key_hold renew_begin renew revoke_begin revoke key_commit renew_commit revoke_commit check
71
+ step key_begin: BEGIN;
72
+ step key_hold:
73
+ select 1 as held from agent_board.agent_signing_keys
74
+ where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child') for update;
75
+
76
+ held
77
+ ----
78
+ 1
79
+ (1 row)
80
+
81
+ step renew_begin:
82
+ BEGIN;
83
+ select set_config('request.jwt.claim.sub', (select auth_user_id::text from agent_board.agents where handle = 'sid-renew-child'), true) is not null as holder_forwarded;
84
+ SET LOCAL ROLE service_role;
85
+ SET LOCAL "request.jwt.claim.role" = 'service_role';
86
+ SET LOCAL "request.jwt.claim.identity_lease_epoch" = '0';
87
+
88
+ holder_forwarded
89
+ ----------------
90
+ t
91
+ (1 row)
92
+
93
+ step renew:
94
+ select agent_board.renew_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'), 'approved');
95
+
96
+ renew_session_identity
97
+ ----------------------
98
+
99
+ (1 row)
100
+
101
+ step revoke_begin:
102
+ BEGIN;
103
+ SET LOCAL ROLE authenticated;
104
+ SET LOCAL "request.jwt.claim.role" = 'authenticated';
105
+ SET LOCAL "request.jwt.claim.sub" = '81000000-0000-4000-8000-000000000001';
106
+
107
+ step revoke:
108
+ select agent_board.revoke_session_identity((select id from agent_board.agents where handle = 'sid-renew-child'));
109
+ <waiting ...>
110
+ step key_commit: COMMIT;
111
+ step renew_commit: COMMIT;
112
+ step revoke: <... completed>
113
+ revoke_session_identity
114
+ -----------------------
115
+
116
+ (1 row)
117
+
118
+ step revoke_commit: COMMIT;
119
+ step check:
120
+ select si.tombstone_reason, si.credential_epoch, a.status, g.revoked_at is not null as grant_revoked,
121
+ g.last_renewed_at is not null as renewal_preceded_revoke,
122
+ (select count(*) from agent_board.fleet_revocation_events e where e.subject_id = a.id) as permanent_revocations,
123
+ (select count(*) from agent_board.agent_signing_keys k where k.agent_id = a.id and k.status <> 'revoked') as active_keys
124
+ from agent_board.agents a join agent_board.session_identities si on si.agent_id = a.id
125
+ join agent_board.delegation_grants g on g.child_agent_id = a.id where a.handle = 'sid-renew-child';
126
+ select bool_and(expires_at <= issued_at + interval '900 seconds') as bounded_pre_revoke_tokens
127
+ from agent_board.nonfleet_sessions where agent_id = (select id from agent_board.agents where handle = 'sid-renew-child');
128
+
129
+ tombstone_reason|credential_epoch|status |grant_revoked|renewal_preceded_revoke|permanent_revocations|active_keys
130
+ ----------------+----------------+-------+-------------+-----------------------+---------------------+-----------
131
+ revoked | 1|revoked|t |t | 1| 0
132
+ (1 row)
133
+
134
+ bounded_pre_revoke_tokens
135
+ -------------------------
136
+ t
137
+ (1 row)
138
+
@@ -0,0 +1,247 @@
1
+ Parsed test spec with 3 sessions
2
+
3
+ starting permutation: o_begin o_advisory o_agents t_begin t_tomb o_membership o_commit t_commit check
4
+ step o_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
5
+ step o_advisory:
6
+ select agent_board._lock_board_authority_ceiling('85000000-0000-4000-8000-000000000002') is null as advisory_taken;
7
+
8
+ advisory_taken
9
+ --------------
10
+ f
11
+ (1 row)
12
+
13
+ step o_agents:
14
+ select count(*)::int as locked_agents from (
15
+ select 1 from agent_board.agents where id='85000000-0000-4000-8000-000000000001' for update) s;
16
+
17
+ locked_agents
18
+ -------------
19
+ 1
20
+ (1 row)
21
+
22
+ step t_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
23
+ step t_tomb:
24
+ select first from agent_board.tombstone_delegate_instance(
25
+ 'sid_ti_instance_00001','urn:sid-ti:issuer','sid-ti-owner','owner_revoked');
26
+ <waiting ...>
27
+ step o_membership:
28
+ select count(*)::int as locked_memberships from (
29
+ select 1 from agent_board.board_memberships
30
+ where board_id='85000000-0000-4000-8000-000000000002'
31
+ and agent_id='85000000-0000-4000-8000-000000000001' for update) s;
32
+
33
+ locked_memberships
34
+ ------------------
35
+ 1
36
+ (1 row)
37
+
38
+ step o_commit: COMMIT;
39
+ step t_tomb: <... completed>
40
+ first
41
+ -----
42
+ t
43
+ (1 row)
44
+
45
+ step t_commit: COMMIT;
46
+ step check:
47
+ select tombstoned_at is not null as instance_tombstoned from agent_board.delegate_instances
48
+ where instance_id='sid_ti_instance_00001';
49
+ select status from agent_board.agents where id='85000000-0000-4000-8000-000000000001';
50
+ select membership_state from agent_board.board_memberships
51
+ where board_id='85000000-0000-4000-8000-000000000002'
52
+ and agent_id='85000000-0000-4000-8000-000000000001';
53
+ select si.tombstoned_at is not null as child_tombstoned,si.credential_epoch,
54
+ (select count(*) from agent_board.agent_credentials ac where ac.agent_id=si.agent_id and ac.revoked_at is null) as live_credentials
55
+ from agent_board.session_identities si join agent_board.agents a on a.id=si.agent_id where a.handle='sid-ti-child';
56
+ select count(*) as withdrawal_events from agent_board.board_membership_events
57
+ where board_id='85000000-0000-4000-8000-000000000002' and event_kind='operator_removal';
58
+
59
+ instance_tombstoned
60
+ -------------------
61
+ t
62
+ (1 row)
63
+
64
+ status
65
+ -------
66
+ revoked
67
+ (1 row)
68
+
69
+ membership_state
70
+ ----------------
71
+ left
72
+ (1 row)
73
+
74
+ child_tombstoned|credential_epoch|live_credentials
75
+ ----------------+----------------+----------------
76
+ t | 1| 0
77
+ (1 row)
78
+
79
+ withdrawal_events
80
+ -----------------
81
+ 1
82
+ (1 row)
83
+
84
+
85
+ starting permutation: t_begin t_tomb o_begin o_advisory t_commit o_agents o_membership o_commit check
86
+ step t_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
87
+ step t_tomb:
88
+ select first from agent_board.tombstone_delegate_instance(
89
+ 'sid_ti_instance_00001','urn:sid-ti:issuer','sid-ti-owner','owner_revoked');
90
+
91
+ first
92
+ -----
93
+ t
94
+ (1 row)
95
+
96
+ step o_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
97
+ step o_advisory:
98
+ select agent_board._lock_board_authority_ceiling('85000000-0000-4000-8000-000000000002') is null as advisory_taken;
99
+ <waiting ...>
100
+ step t_commit: COMMIT;
101
+ step o_advisory: <... completed>
102
+ advisory_taken
103
+ --------------
104
+ f
105
+ (1 row)
106
+
107
+ step o_agents:
108
+ select count(*)::int as locked_agents from (
109
+ select 1 from agent_board.agents where id='85000000-0000-4000-8000-000000000001' for update) s;
110
+
111
+ locked_agents
112
+ -------------
113
+ 1
114
+ (1 row)
115
+
116
+ step o_membership:
117
+ select count(*)::int as locked_memberships from (
118
+ select 1 from agent_board.board_memberships
119
+ where board_id='85000000-0000-4000-8000-000000000002'
120
+ and agent_id='85000000-0000-4000-8000-000000000001' for update) s;
121
+
122
+ locked_memberships
123
+ ------------------
124
+ 1
125
+ (1 row)
126
+
127
+ step o_commit: COMMIT;
128
+ step check:
129
+ select tombstoned_at is not null as instance_tombstoned from agent_board.delegate_instances
130
+ where instance_id='sid_ti_instance_00001';
131
+ select status from agent_board.agents where id='85000000-0000-4000-8000-000000000001';
132
+ select membership_state from agent_board.board_memberships
133
+ where board_id='85000000-0000-4000-8000-000000000002'
134
+ and agent_id='85000000-0000-4000-8000-000000000001';
135
+ select si.tombstoned_at is not null as child_tombstoned,si.credential_epoch,
136
+ (select count(*) from agent_board.agent_credentials ac where ac.agent_id=si.agent_id and ac.revoked_at is null) as live_credentials
137
+ from agent_board.session_identities si join agent_board.agents a on a.id=si.agent_id where a.handle='sid-ti-child';
138
+ select count(*) as withdrawal_events from agent_board.board_membership_events
139
+ where board_id='85000000-0000-4000-8000-000000000002' and event_kind='operator_removal';
140
+
141
+ instance_tombstoned
142
+ -------------------
143
+ t
144
+ (1 row)
145
+
146
+ status
147
+ -------
148
+ revoked
149
+ (1 row)
150
+
151
+ membership_state
152
+ ----------------
153
+ left
154
+ (1 row)
155
+
156
+ child_tombstoned|credential_epoch|live_credentials
157
+ ----------------+----------------+----------------
158
+ t | 1| 0
159
+ (1 row)
160
+
161
+ withdrawal_events
162
+ -----------------
163
+ 1
164
+ (1 row)
165
+
166
+
167
+ starting permutation: o_begin o_advisory t_begin t_tomb o_agents o_membership o_commit t_commit check
168
+ step o_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
169
+ step o_advisory:
170
+ select agent_board._lock_board_authority_ceiling('85000000-0000-4000-8000-000000000002') is null as advisory_taken;
171
+
172
+ advisory_taken
173
+ --------------
174
+ f
175
+ (1 row)
176
+
177
+ step t_begin: BEGIN; SET LOCAL "request.jwt.claim.role" = 'service_role';
178
+ step t_tomb:
179
+ select first from agent_board.tombstone_delegate_instance(
180
+ 'sid_ti_instance_00001','urn:sid-ti:issuer','sid-ti-owner','owner_revoked');
181
+ <waiting ...>
182
+ step o_agents:
183
+ select count(*)::int as locked_agents from (
184
+ select 1 from agent_board.agents where id='85000000-0000-4000-8000-000000000001' for update) s;
185
+
186
+ locked_agents
187
+ -------------
188
+ 1
189
+ (1 row)
190
+
191
+ step o_membership:
192
+ select count(*)::int as locked_memberships from (
193
+ select 1 from agent_board.board_memberships
194
+ where board_id='85000000-0000-4000-8000-000000000002'
195
+ and agent_id='85000000-0000-4000-8000-000000000001' for update) s;
196
+
197
+ locked_memberships
198
+ ------------------
199
+ 1
200
+ (1 row)
201
+
202
+ step o_commit: COMMIT;
203
+ step t_tomb: <... completed>
204
+ first
205
+ -----
206
+ t
207
+ (1 row)
208
+
209
+ step t_commit: COMMIT;
210
+ step check:
211
+ select tombstoned_at is not null as instance_tombstoned from agent_board.delegate_instances
212
+ where instance_id='sid_ti_instance_00001';
213
+ select status from agent_board.agents where id='85000000-0000-4000-8000-000000000001';
214
+ select membership_state from agent_board.board_memberships
215
+ where board_id='85000000-0000-4000-8000-000000000002'
216
+ and agent_id='85000000-0000-4000-8000-000000000001';
217
+ select si.tombstoned_at is not null as child_tombstoned,si.credential_epoch,
218
+ (select count(*) from agent_board.agent_credentials ac where ac.agent_id=si.agent_id and ac.revoked_at is null) as live_credentials
219
+ from agent_board.session_identities si join agent_board.agents a on a.id=si.agent_id where a.handle='sid-ti-child';
220
+ select count(*) as withdrawal_events from agent_board.board_membership_events
221
+ where board_id='85000000-0000-4000-8000-000000000002' and event_kind='operator_removal';
222
+
223
+ instance_tombstoned
224
+ -------------------
225
+ t
226
+ (1 row)
227
+
228
+ status
229
+ -------
230
+ revoked
231
+ (1 row)
232
+
233
+ membership_state
234
+ ----------------
235
+ left
236
+ (1 row)
237
+
238
+ child_tombstoned|credential_epoch|live_credentials
239
+ ----------------+----------------+----------------
240
+ t | 1| 0
241
+ (1 row)
242
+
243
+ withdrawal_events
244
+ -----------------
245
+ 1
246
+ (1 row)
247
+
@@ -49,6 +49,10 @@ setup
49
49
  values ('16250000-0000-0000-0000-000000000001', 'agent', 'agent',
50
50
  'atomic-authority-owner', 'Atomic Authority Owner', 'active',
51
51
  '16250000-0000-0000-0000-0000000000a1');
52
+ -- ROLEGUARD: isolate creator authority loss while another owner preserves the board.
53
+ insert into agent_board.agents(id, agent_type, kind, handle, display_name, status)
54
+ values ('16250000-0000-0000-0000-000000000004', 'agent', 'agent',
55
+ 'atomic-authority-coowner', 'Atomic Authority Coowner', 'active');
52
56
 
53
57
  select count(*) from agent_board.create_board(
54
58
  '16250000-0000-0000-0000-000000000001',
@@ -56,6 +60,9 @@ setup
56
60
  'Consiliency/message-board#162 authority isolation proof',
57
61
  jsonb_build_object(), 'private'
58
62
  );
63
+ insert into agent_board.board_memberships(board_id, agent_id, role, membership_state)
64
+ values ((select id from agent_board.boards where slug='atomic-authority-board'),
65
+ '16250000-0000-0000-0000-000000000004', 'owner', 'joined');
59
66
  insert into agent_board.fleet_trust_domains(
60
67
  id, slug, display_name, domain_kind, owner_agent_id, lifecycle_state, approved_at
61
68
  ) values (
@@ -120,9 +127,6 @@ teardown
120
127
  delete from agent_board.board_authority_ceilings where board_id in (
121
128
  select id from agent_board.boards where slug='atomic-authority-board'
122
129
  );
123
- delete from agent_board.board_memberships where board_id in (
124
- select id from agent_board.boards where slug='atomic-authority-board'
125
- );
126
130
  delete from agent_board.enrollment_federation_audit where agent_id in (
127
131
  select id from agent_board.agents where handle='atomic-authority-agent'
128
132
  );
@@ -134,6 +138,7 @@ teardown
134
138
  delete from agent_board.fleet_machines where id='16250000-0000-0000-0000-000000000003';
135
139
  delete from agent_board.fleet_trust_domains where id='16250000-0000-0000-0000-000000000002';
136
140
  delete from agent_board.agents where id='16250000-0000-0000-0000-000000000001';
141
+ delete from agent_board.agents where id='16250000-0000-0000-0000-000000000004';
137
142
  delete from auth.users where id='16250000-0000-0000-0000-0000000000a1';
138
143
  delete from agent_board.identity_providers where issuer='https://atomic-authority.test';
139
144
  }
@@ -70,9 +70,6 @@ teardown
70
70
  );
71
71
  truncate agent_board.fleet_onboarding_invite_bounds;
72
72
  delete from agent_board.board_invite_tokens where created_by_agent_id='16230000-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-binding-board'
75
- );
76
73
  delete from agent_board.enrollment_federation_audit where agent_id in (
77
74
  select id from agent_board.agents where handle='atomic-binding-agent'
78
75
  );
@@ -70,9 +70,6 @@ teardown
70
70
  );
71
71
  truncate agent_board.fleet_onboarding_invite_bounds;
72
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
73
  delete from agent_board.enrollment_federation_audit where issuer='https://atomic-archive.test';
77
74
  delete from agent_board.agent_signing_keys where agent_id in (
78
75
  select id from agent_board.agents where handle='atomic-archive-agent'
@@ -68,9 +68,6 @@ teardown
68
68
  );
69
69
  truncate agent_board.fleet_onboarding_invite_bounds;
70
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
71
  delete from agent_board.enrollment_federation_audit where issuer='https://atomic-human.test';
75
72
  delete from agent_board.agent_signing_keys where agent_id in (
76
73
  select id from agent_board.agents where handle in ('atomic-human-existing','atomic-human-fresh')
@@ -57,9 +57,6 @@ teardown
57
57
  );
58
58
  truncate agent_board.fleet_onboarding_invite_bounds;
59
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
60
  delete from agent_board.enrollment_federation_audit where issuer='https://atomic-disposition.test';
64
61
  delete from agent_board.agent_signing_keys where agent_id in (
65
62
  select id from agent_board.agents where handle='atomic-disposition-agent'
@@ -83,9 +83,6 @@ teardown
83
83
  );
84
84
  truncate agent_board.fleet_onboarding_invite_bounds;
85
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
86
  delete from agent_board.enrollment_federation_audit where agent_id in (
90
87
  select id from agent_board.agents where handle='atomic-lifecycle-agent'
91
88
  );
@@ -81,9 +81,6 @@ teardown
81
81
  );
82
82
  truncate agent_board.fleet_onboarding_invite_bounds;
83
83
  delete from agent_board.board_invite_tokens where created_by_agent_id='ffffffff-ffff-ffff-ffff-ffffffffff01';
84
- delete from agent_board.board_memberships where board_id in (
85
- select id from agent_board.boards where slug='atomic-subtree-board'
86
- );
87
84
  delete from agent_board.enrollment_federation_audit where issuer='https://atomic-subtree.test';
88
85
  delete from agent_board.agent_signing_keys where agent_id in (
89
86
  select id from agent_board.agents where handle='atomic-subtree-agent'
@@ -53,9 +53,6 @@ teardown
53
53
  delete from agent_board.board_authority_ceilings where board_id in (
54
54
  select id from agent_board.boards where slug='ceiling-order-board'
55
55
  );
56
- delete from agent_board.board_memberships where board_id in (
57
- select id from agent_board.boards where slug='ceiling-order-board'
58
- );
59
56
  delete from agent_board.boards where slug='ceiling-order-board';
60
57
  delete from agent_board.agents where id='19600000-0000-0000-0000-000000000001';
61
58
  delete from auth.users where id='19600000-0000-0000-0000-0000000000a1';
@@ -68,8 +68,6 @@ teardown
68
68
  delete from agent_board.threads where id = '40500000-0000-4000-8000-000000000010';
69
69
  delete from agent_board.board_membership_events where board_id in (
70
70
  select id from agent_board.boards where slug = 'cpr-acq-board');
71
- delete from agent_board.board_memberships where board_id in (
72
- select id from agent_board.boards where slug = 'cpr-acq-board');
73
71
  delete from agent_board.boards where slug = 'cpr-acq-board';
74
72
  delete from agent_board.agents where id = '40500000-0000-4000-8000-000000000001';
75
73
  delete from auth.users where id = '40500000-0000-4000-8000-0000000000a1';
@@ -60,8 +60,6 @@ teardown
60
60
  '40500000-0000-4000-8000-000000000042');
61
61
  delete from agent_board.board_membership_events where board_id in (
62
62
  select id from agent_board.boards where slug in ('cpr-scope-b1', 'cpr-scope-b2'));
63
- delete from agent_board.board_memberships where board_id in (
64
- select id from agent_board.boards where slug in ('cpr-scope-b1', 'cpr-scope-b2'));
65
63
  delete from agent_board.boards where slug in ('cpr-scope-b1', 'cpr-scope-b2');
66
64
  delete from agent_board.agents where id = '40500000-0000-4000-8000-000000000003';
67
65
  delete from auth.users where id = '40500000-0000-4000-8000-0000000000c1';
@@ -133,8 +133,6 @@ teardown
133
133
  delete from agent_board.threads where id = '40500000-0000-4000-8000-000000000090';
134
134
  delete from agent_board.board_membership_events where board_id in (
135
135
  select id from agent_board.boards where slug = 'cpr-inv-board');
136
- delete from agent_board.board_memberships where board_id in (
137
- select id from agent_board.boards where slug = 'cpr-inv-board');
138
136
  delete from agent_board.boards where slug = 'cpr-inv-board';
139
137
  delete from agent_board.fleet_revocation_events where subject_id = '40500000-0000-4000-8000-0000000000c0';
140
138
  delete from agent_board.fleet_machine_agents where machine_id = '40500000-0000-4000-8000-0000000000c0';
@@ -59,8 +59,6 @@ teardown
59
59
  delete from agent_board.threads where id = '40500000-0000-4000-8000-000000000050';
60
60
  delete from agent_board.board_membership_events where board_id in (
61
61
  select id from agent_board.boards where slug = 'cpr-iso-board');
62
- delete from agent_board.board_memberships where board_id in (
63
- select id from agent_board.boards where slug = 'cpr-iso-board');
64
62
  delete from agent_board.boards where slug = 'cpr-iso-board';
65
63
  delete from agent_board.agents where id = '40500000-0000-4000-8000-000000000004';
66
64
  delete from auth.users where id = '40500000-0000-4000-8000-0000000000d1';
@@ -99,8 +99,6 @@ teardown
99
99
  delete from agent_board.threads where id = '40500000-0000-4000-8000-000000000020';
100
100
  delete from agent_board.board_membership_events where board_id in (
101
101
  select id from agent_board.boards where slug = 'cpr-ren-board');
102
- delete from agent_board.board_memberships where board_id in (
103
- select id from agent_board.boards where slug = 'cpr-ren-board');
104
102
  delete from agent_board.boards where slug = 'cpr-ren-board';
105
103
  delete from agent_board.agents where id = '40500000-0000-4000-8000-000000000002';
106
104
  delete from auth.users where id = '40500000-0000-4000-8000-0000000000b1';