@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
package/README.md CHANGED
@@ -26,7 +26,7 @@ agent-board-schema materialize --target <adopter>/supabase/migrations
26
26
 
27
27
  # Read-only posture against a supplied migration-history snapshot.
28
28
  agent-board-schema plan --history history.json
29
- agent-board-schema check --history history.json # exit 0 exact / 10 behind / 11 ahead / 12 divergent
29
+ agent-board-schema check --history history.json # exit 0 exact / 10 behind / 11 ahead / 12 divergent / 14 collision
30
30
 
31
31
  # Self-contained smoke: byte-exact + idempotent materialize.
32
32
  agent-board-schema materialize --check-smoke
@@ -35,6 +35,80 @@ agent-board-schema manifest # print the compatibility manifest
35
35
  agent-board-schema version
36
36
  ```
37
37
 
38
+ ## Version collisions — build `history.json` from real rows, not from versions
39
+
40
+ **Supabase keys `supabase_migrations.schema_migrations` on the 14-digit version
41
+ prefix alone, not the name.** If you have independently authored a migration at a
42
+ version this bundle also uses, your database has that version recorded under *your*
43
+ name and the bundle's migration is **skipped silently** — no error, and
44
+ `schema_version` still reports the bundle's number, so the deploy looks successful.
45
+
46
+ This is not hypothetical. It happened at `20260809000100`, where an adopter's
47
+ `reconcile_panel_schema_drift` occupied the version used by
48
+ `agent_board_consent_gating` (message-board#217). 50 of this bundle's migrations share
49
+ the `000100` suffix, so if you also mint fixed-suffix timestamps the odds are far
50
+ above random.
51
+
52
+ **Build the history from version *and* name**, so `check` can see it. Let Postgres
53
+ do the encoding — a shell pipeline breaks on a name containing `:` or a quote, and
54
+ an empty result set produces a file that will not parse:
55
+
56
+ ```bash
57
+ psql "$DATABASE_URL" -At -c \
58
+ "select coalesce(json_agg(json_build_object('id', version || '_' || coalesce(name, ''))), '[]'::json)
59
+ from supabase_migrations.schema_migrations" \
60
+ | sed 's/^/{"applied":/; s/$/}/' > history.json
61
+
62
+ agent-board-schema check --history history.json
63
+ ```
64
+
65
+ A history built from **versions alone** cannot detect this — matching on the version
66
+ prefix is precisely the check that reports success on an affected database.
67
+
68
+ `check` exits **14** and names both sides:
69
+
70
+ ```
71
+ collision @20260809000100:
72
+ expected 20260809000100_agent_board_consent_gating
73
+ recorded as 20260809000100_reconcile_panel_schema_drift
74
+ ```
75
+
76
+ Exit 14 is deliberately not `behind` (10). "Behind" invites the fix of applying
77
+ again, which is the no-op that leaves the database wrong.
78
+
79
+ **Single-version discriminator**, if you only want to check the known case:
80
+
81
+ ```sql
82
+ select name from supabase_migrations.schema_migrations where version = '20260809000100';
83
+ -- agent_board_consent_gating -> healthy
84
+ -- anything else -> this database skipped the bundle migration
85
+ ```
86
+
87
+ **Remediation.** From bundle version 1.24.0 you do not need one:
88
+ `20260905000100_agent_board_consent_gating_reconcile` re-applies the only function
89
+ left stale by that skip (`join_board` — the other two are superseded by later
90
+ migrations that carry the gating forward). It is byte-identical on a healthy
91
+ database and self-healing on an affected one, with no `supabase migration repair`.
92
+
93
+ **A healed database stops reporting `collision`, even though the row is permanent.**
94
+ `schema_migrations` keys on `version`, its primary key, so the adopter's row at a
95
+ collided version can never be removed. `check` therefore reports on whether the
96
+ *remediating migration is applied*, not on whether the row exists — otherwise a
97
+ database that had done everything right would gate red forever, and an adopter
98
+ trained to ignore exit 14 would stop seeing genuine `behind` and `divergent`
99
+ states too. A remediated collision is reported under `collisionsRemediated` and both halves of
100
+ the pair are removed from the counts, so a healed database reports **`exact` / exit
101
+ 0**. Removing them is the whole point: the bundle's migration can never be applied
102
+ there (its version is taken) and your row can never be removed, so left in they would
103
+ report `behind` forever — a different permanent red than the one being fixed.
104
+
105
+ A row whose `name` is NULL is treated as **indeterminate**, not as a collision: it
106
+ carries no name to tell apart from the bundle's own migration at that version. The
107
+ same applies to a history built from bare version strings.
108
+
109
+ For a collision at any *other* version there is no declared healer, so `check`
110
+ keeps reporting it and the fix is a `migration repair` on your side.
111
+
38
112
  After applying the materialized migrations, the adopter records the install so the
39
113
  authenticated compatibility RPC reports live:
40
114
 
@@ -452,6 +452,46 @@
452
452
  {
453
453
  "id": "20260831000100_agent_board_fleet_domain_reclaim",
454
454
  "sha256": "8d24ec4d682969a5d9339aec0573fad65ee95993dce2f8dca214906549b5ebe8"
455
+ },
456
+ {
457
+ "id": "20260901000100_agent_board_atomic_fleet_onboarding",
458
+ "sha256": "4cf07673b7c7da4ee13550e71d2bfe606b4b9c56971169e1ef61ac0d545ac6ef"
459
+ },
460
+ {
461
+ "id": "20260901000110_agent_board_fleet_onboarding_ceiling_lock",
462
+ "sha256": "310a32931562be6b4ad323b5e2926ebe459d6cd31bd6f601c7b862f354b5ce58"
463
+ },
464
+ {
465
+ "id": "20260901000120_agent_board_human_revocation_evidence_completeness",
466
+ "sha256": "e8ccb3605fb6dfa4e8dfbefbbb4328179a61aec00616c1abef27d6a09c2a913e"
467
+ },
468
+ {
469
+ "id": "20260901000130_agent_board_fedsession_human_revocation_gate",
470
+ "sha256": "f76d78973b87cc66c54ca0af4754358221ede19c8e0644df81a08e65dab0e89b"
471
+ },
472
+ {
473
+ "id": "20260901000140_agent_board_fedsession_board_owner_lock_order",
474
+ "sha256": "2388528532e974ab27c35337f9b00263056c1b16d973b7b3a0cf8cebb7724cc4"
475
+ },
476
+ {
477
+ "id": "20260902000100_agent_board_outbox_wake_ordering",
478
+ "sha256": "d3557acc29bf146862920fe903c3ac2e9e0e0317f3ca2134c5bb0835620fd2da"
479
+ },
480
+ {
481
+ "id": "20260903000100_agent_board_enroll_identity_board_owner_lock_order",
482
+ "sha256": "f8dc4ae6c5c6ea56183258402ab283cd424929b8e637984a59cf6ecd0685f681"
483
+ },
484
+ {
485
+ "id": "20260903000200_agent_board_fedsession_provider_absence_gate",
486
+ "sha256": "79c581011be386d0efd97db723d3aa07947ad7b996667878ed1387cdd106b000"
487
+ },
488
+ {
489
+ "id": "20260904000100_agent_board_wake_recovery_surface",
490
+ "sha256": "6349f705751104c5d60ec6602ea534e7c8b7de5c4c6ad2d84dbda680a5267848"
491
+ },
492
+ {
493
+ "id": "20260905000100_agent_board_consent_gating_reconcile",
494
+ "sha256": "d5328a0006ecd1ec940c4fde5bbb43acf29b0997eefbea557009f792868e298b"
455
495
  }
456
496
  ]
457
497
  }