Skip to content

The J5 ledger keys on projects, and every thread has a home (migration 030) #459

Closed

Description

@bryantderosier

Part of #412. Milestone: Squadron fold.

Outcome

A thread's home is its project. Every J5 table that keys on squadron_id keys on the project instead, through one J5 ledger migration (030). Every thread gets a home when it's created, with no separate registration step.

Scope (one slice, end to end on the server)

  • Migration 030 (apps/server/src/j5/a2a/migrations/). Re-key comm_event, epic_membership / squadron_membership, j5_a2a_exchange, j5_a2a_delivery (receiver_squadron_id, origin_squadron_id), human inbox, placement, machine participants, and Crew instances and proposals from Squadron to project. Drop j5_a2a_squadron_project_reference and the Squadron table once nothing reads them.
  • Snapshot. 030 is the migration that feat(server): the database is copied before a risky J5 ledger migration runs #429's J5_LEDGER_SNAPSHOT_MIGRATIONS = [30] guards. Its fixtures cover the snapshot path.
  • Every thread has a home. The Registrar answers with the thread's projectId. The native cohorts in SquadronLaunchPolicy go away: mobile-created threads, system bootstrap, legacy plan children, and imported conversations all register into their project. Backfill threads that have none today.
  • Services re-keyed: LedgerService, SendService / DeliveryWorker (cross-Squadron double entry becomes cross-project), HumanInboxService, PlacementService, MachineParticipantService, LifecycleService, Crew services, SpawnCompositionService. Peer Agents and Crews inherit their spawner's project.

Migration rules (from #412)

Case Rule
One Squadron, one project Its ledger, memberships, placement and Crews move to the project.
Several Squadrons on one project Refuse by name. The error names the project and the Squadrons, and gives the repair (archive their agents, then POST /api/j5/squadrons/<id>/delete). The snapshot is untouched.
One Squadron, several projects Refuse by name with the same repair. The UI never allowed it, but the create route did.
Squadron whose project was deleted Decide in the PR, and record why.
Name differs from the project title Keep the project title. The Squadron name is dropped.
Threads with no home Backfill membership from projectId.

Done when

Closes

#358, #287, #179, #357, #134

Notes

This is the largest slice. It can land as a stack, but the migration and the services that read the new keys have to ship together.

Activity

  1. added this to the Squadron fold milestone on Oct 5, 2026
  2. added
    enhancementNew feature or request
    size:XL500-999 effective changed lines (test files excluded in mixed PRs).
    on Oct 5, 2026
  3. Jacksondr5 commented on Oct 18, 2026

    @Jacksondr5
    Owner

    Done. Landed 2026-10-08 in #482 (migration 031: 030 was already taken), together with #457. #484 and #489 followed with the internal and peer-wire renames.

    • Every table listed here moved from Squadron to project. The reference table is dropped; the Squadron table is renamed rather than dropped, because dropping it would empty its child tables.
    • Every thread except a provider Subagent registers from its stored thread.created event. Threads without a home are backfilled at startup.
    • 031 is snapshotted before it runs (now through feat(j5): nightly releases from j5/main, with a snapshot before any migration #511's snapshot before any pending migration). The restore runbook is in docs/j5/runbooks/dogfood-runtime.md.
    • A Squadron whose project was deleted keeps its ledger (comment and test in the migration).
    • The live install has run 031 since 2026-10-10, and sends, Exchanges, Crews, placement and the inbox have all been used since.

    Known gap, not fixed: one Squadron with several projects is still refused and rolled back, but by the retired-table primary key rather than a named error with the repair. Only an install still before 031 that built that shape through the create route can hit it.

    — Claude Opus 5.5, on Jackson's behalf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsize:XL500-999 effective changed lines (test files excluded in mixed PRs).

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions