Reviewer: Claude Fable 5.1 (claude-fable-5-1) — whole-code review @ de26fd8
Read as one diff, 7c9122f..de26fd8, beside connect, teammode and roster at Home main 602f513 (connect's README "Moving existing links onto connect", linkstore.Store.Adopt, Bridge.complete, Routes.Signin/LocalComplete), main's deleted homeBridge files, principalstore's 0001, Docs' AGENTS.md, and discussions #100 and home #99. Scratch worktree, the full gate, read-only replica queries on docs.bds and overnight-docs, six hand mutations of my own.
Verdict: APPROVED. No blockers. Rulings on the two questions and the deviation, a pre-deploy checklist (one item of it matters), and notes.
What I verified, point by point
- Sessions survive. rastrillo/auth's
SessionCookie()isa.sessions.CookieName();newHometakessessions.New(Config{DB, Origin}).CookieName()from the same store over the samesessionstable, andmount(home_connect.go:122) refuses to boot if the two differ.homeAssertionMethod = connect.HomeMethod(identity.go:17), both"home-assertion".readSessioncarriesAt, whichconnect.FreshLocalneeds for magic-link sessions (my mutation q, below, shows it is live). Namespaceoficina/docskept, so pending handoff rows still open.TestLinksMoveOntoConnectWithTeamModeOff/Onmint sessions with main's store on main's schema and sign in through the new router as the same people: that is the proof, not an assumption. - The backfill (
home_links_move.go). OneBeginTxon the writer;connect.Newhas run both Sweeps synchronously and committed before the move begins (connectbridge.go, no goroutines anywhere in connect), and the census runs after. Order inside the tx:RepointLinksfirst whendocs_home_identitiesexists, sodocs_local_identity_uniqueguards Adopt's own insert; every row read before any Adopt (no open cursor on the one connection);ErrRefused→errLinksRefused (person N), anything else including the trigger's RAISE →errLinksUnavailable(note 7 applied,TestLinksMoveAbortsWhenTheDisjointnessTriggerRefusesshows the ErrStorage path); clock carried withMAX; old keep triggers, table, flows and clock dropped;Commit. DDL is transactional in SQLite, so a stop leaves the triggers on the old table (asserted). Rerun: table absent → nil, Adopt never called (asserted).linkedAddressisSELECT email FROM people WHERE id = ?through the given Queryer (note 9 applied;TestLinksMoveNeedsNeitherTheRosterNorTheAllowlistboots with the directory down and an allowlist naming nobody). - Resolver. Home sessions go through
Bridge.Resolve(binding checked) in both modes, thenprincipals.Personin team mode.linkedSubjectcounts a link only if connect resolves it back to the same person. A stale link therefore signs nobody in and gives no standing (TestTeamStandingNeedsALinkConnectResolves), andhomeOnly's Kind check stops principalstore's union from answering with a link row connect refused. - Hooks.
homeOnly=principals.Resolve,ErrRefused/non-Home →ErrNoPerson, Home →Person{ID}with no label (connect's contract).unlinked=AdmitUnlinked(ErrNotMember→ErrNoPerson) thenEnsureHome, whoseRequireMembershipis the second gate, kept innewTeamRuntimefor every caller. - Access carried.
withAccesssets Docs' key andteammode.WithAccesstogether; both writers (admission,dashboardProvider) use it, soGuard'sStanding(ctx)is the latched Access (TestTeamAdmissionCarriesTheAccessToGuard). - Census.
IssuerTables: home_identity_links, docs_home_identities, read after the move. - The two overlays.
/signin: admitted-only shortcut kept, and connect'sSignin(which skips for any live session withHomeMethod/magiclink/keymail) is shown the request without the session cookie, so a refused session starts the exchange as before.localComplete: substitutes Docs' sealed return only when connect answered303 /, so the resume-link landing (/account/home) is untouched (my mutation c). - Pins. connect, teammode, roster at 602f513 (Adopt's merge); handoff at 481d2d5 as connect requires.
Rulings
- Deviation (team mode turned on after the move): sound, keep
ForPrincipals. Re-pointing principalstore's 0001 is barred by migration immutability, and the ledger check is live (proved on #100). It is true that no deployed database has applied 0001 yet, so a rewrite would not trip a production ledger today, but the fixtures (legacyTeamDatabase) are the record of a layout that existed, and a 0002 "re-point" migration would still need the shim for the fresh-0001-on-a-moved-database case, so it buys nothing.CREATE TABLE IF NOT EXISTSjust before 0001, team schema only, is the smallest thing that works, and the table is dropped in the same boot (migrations → move), not the next one. My mutation g (ForPrincipals after 0001) dies exactly where it should. - Q1, the append-only pair on connect's table: keep. connect never updates or deletes a
home_identity_linksrow (grepped non-test code at 602f513), so the triggers cost nothing and the guarantee survives the move. Record one coupling: a future connect migration that UPDATEs or DELETEs link rows (a re-keying, say) would fail at migration time on Docs team databases only; that connect change would need a Docs migration droppingdocs_home_links_keep_update/_keep_deletefirst. A sentence inrepointLinks's comment is enough. - Q2, boot-abort on an unmovable row: right for docs.oficina.works, with the checklist below. The alternative (boot with the old table, that person locked out of Home) hides a broken link behind a working-looking instance, which is the failure shape AGENTS.md rejects everywhere else. The replica shows the refusal is unreachable here unless
DOCS_HOME_ISSUERdisagrees with the stored issuer, and that is checkable before deploy. What I would add, non-blocking: log the stored issuer beside the person ID inerrLinksRefused. Issuers are public origins, not identity values, and with carlos offering no write path to a live database, the operator's only remedies are the env var or a redeploy; the log line should make it obvious which. - Rollback is one-way after the move. main (7c9122f) refuses to boot on a moved database:
newHomeBridgeruns its link store'sSweep, whosebeginwritesdocs_link_clock, which is gone. So the deploy needs a snapshot first, not a plan to roll the binary back. - A new operational property for Docs: every link now carries a binding keyed by
DOCS_HOME_DEK_BASE64. Rotating that DEK dead-ends every link, and Adopt never repairs one (connect's contract, which I approved on #99). Docs' old table had no such dependency. Worth a line wherever the Home env vars are documented. - Gate.
.amadan/ci.d/10-gatepassed here in full, exit 0, withGOTOOLCHAIN=go1.26.10, rustup's cargo and a shortTMPDIR—cmd/docsincluded. The "known macOS socket failures" are the long default temp path, not the code; a shortTMPDIRis the fix. Hub CI on de26fd8 passed (amadan ci statusexit 0, confirmed).
Replica facts (read-only, carlos db query, copies written 2026-10-30 15:01 UTC and 2026-10-28 22:11 UTC)
| Instance | Links | Stored issuer | Subject | Person email | Sessions | Team tables | Clock high-water | |---|---|---|---|---|---|---|---| | docs.bds (docs.oficina.works) | 1 | https://id.oficina.works | 29 chars, pr_ | 12 chars, non-empty | 1 home-assertion, 3 keymail, 10 magiclink | none | 2026-10-30T14:56:20Z | | overnight-docs | 1 | https://overnight-home-id.bds.oncarlos.com | 29 chars, pr_ | 13 chars, non-empty | 1 home-assertion | none | 2026-10-28T22:11:03Z |
Both move cleanly if the configured issuer equals the stored one. Paul's one Home session is the only thing anyone would notice.
Pre-deploy checklist
- Issuer check (the one that matters). Confirm the configured
DOCS_HOME_ISSUERon docs.bds is exactlyhttps://id.oficina.worksand on overnight-docs exactlyhttps://overnight-home-id.bds.oncarlos.com. A mismatch is the only reachableerrLinksRefusedon these two, and it takes the instance down. - Preflight query on the replica, immediately before deploying (both instances):
SELECT issuer, person_id, length(subject), (SELECT length(email) FROM people p WHERE p.id=l.person_id) FROM docs_identity_links l— every row: issuer as above, subject non-empty, email length > 0. - Snapshot:
carlos db pull --out …for docs.bds before the deploy (ruling 4). - Restart after deploy (carlos "live" needs it) and confirm the running version; then read the boot log for
docs: new—errLinksRefusedorerrLinksUnavailablemeans it did not come up, table intact. - Canary: Paul opens docs.oficina.works in the browser holding the Home session: still signed in, documents visible, the account menu does not offer Connect. A forced re-sign-in is a finding.
- Do not rotate
DOCS_HOME_DEK_BASE64as part of this deploy (ruling 5). - lagged-docs and contract-docs hold no links; nothing to move. Till's later team activation on lagged-docs goes through
ForPrincipals, whichTestTeamModeTurnedOnAfterTheMoveexercises.
My hand mutations
Killed: (c) localComplete substituting Docs' return on any 303 → TestHomeUnknownArrivalResumesLinkAfterLocalSignIn ("/" for "/account/home"); (g) ForPrincipals after principalstore.Schema → TestTeamModeTurnedOnAfterTheMove ("no such table: main.docsidentitylinks"); (q) readSession dropping At → TestHomeRouterExistingAccountRoundTripPreservesOwnedAndSharedContent and the move test's link start.
Survived:
- (o)
unlinkedmapping anEnsureHomestorage failure toErrNoPerson—TestTeamUnlinked*/TestTeamHomeOnly*pass. The author killed the opposite direction (refusal read as unavailable); this one is untested. Not a hole (nothing is allocated), but connect would answer "unknown" with the resume-linking marker where it should answer a retryable 503. Test gap: add toTestTeamUnlinkedAllocatesOnlyForAMemberThroughBothGatesthe closed-writer caseTestTeamHomeOnlyIsOnlyTheHomeOnlyPrincipalalready uses, asserting the error is neither nil norErrNoPerson. Small; a later tidy-up. - (M1)
linkedSubjectwithoutlinked.ID != person— equivalent: the PK(issuer, subject)andUNIQUE (issuer, person_id)make a link that resolves to a different person unreachable, and the binding covers the ID. Keep the check; it states the intent. - (h)
mountwithout the cookie-name check — equivalent today (both names come fromsessions.Newover the same DB and origin); it is a guard against drift, keep it.
Notes, no action needed
go.modlistsamadan.net/oficina/home/connectas// indirectthoughinternal/docsimports it directly;go mod tidymoves it up (and would demotemodernc.org/sqlite, which predates this branch). Cosmetic; the build and CI do not mind.- Docs' own return cookie (
__Host-oficina-docs-home-return) is no longer cleared atPOST /account/home/confirm(main cleared it there; connect'sConfirmPostclears its own__Host-oficina-home-return) nor atlocalComplete. It is sealed, ten minutes, overwritten by every freshGET /signin, and authorizes nothing, so the effect is at most "Use a different address" carrying a page from the last ten minutes. Clearing it inlocalCompletewould match main; your call. - Author's own accounting checks out:
linkedAddressaccepting an empty email is equivalent as recorded; the partway test's per-case context fix (2f8e647) is right. - The colophon addition of
home/connectis correct now that it is linked;internal/shippedpasses under the pinned toolchain.
Merge when you like. Deploy after checklist item 1; the rest is ten minutes.