Skip to content

Convert hostHome into hostRoutingMap#4943

Draft
backspace wants to merge 7 commits into
mainfrom
host-home-routing-rule-cs-10055
Draft

Convert hostHome into hostRoutingMap#4943
backspace wants to merge 7 commits into
mainfrom
host-home-routing-rule-cs-10055

Conversation

@backspace
Copy link
Copy Markdown
Contributor

@backspace backspace commented May 22, 2026

This is another step toward eliminating .realm.json. hostHome is a little-used feature that allows an override to what‘s shown at the root of a realm in host mode; using hostRoutingMap with a route for / accomplishes the same thing.

This also eliminates interactHome, which was never used, and which can be synthesised with setting index.json to what you want to show.

Extends the CS-11150 backfill so that the sidecar's `hostHome` (a string
URL) is materialized as a `/`-rooted entry in the realm.json card's
`hostRoutingRules`. `interactHome` is dropped from the sidecar
unconditionally — `index.json` already covers the interact-mode home
case so no card field is needed.

Three migration shapes coexist in one pass:
 - new card created from any sidecar with migratable keys
 - existing card augmented with a `/`-rule when sidecar has hostHome
   and the card doesn't already have one (existing rule wins; we log
   if it points elsewhere)
 - sidecar always trimmed of every key the card now owns

Two correctness fixes while in there:
 - `hostRoutingRules` from a sidecar is now split into the canonical
   shape — paths in `attributes.hostRoutingRules[i]`, instance linksTo
   under `data.relationships["hostRoutingRules.<i>.instance"]` with a
   relative `./Type/id` link. The previous code copied the field
   verbatim (instance as a URL string), which would not have produced
   a valid card.
 - Published-realm hostHome migration now requires the registry URL.
   When realm_registry is sparse (multi-instance startup race), we
   skip just the hostHome step for that realm and log; a future boot
   completes it. The card-keys-only migration still runs.

17 tests cover the new behavior end to end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

Preview deployments

Host Test Results

    1 files  ±0      1 suites  ±0   1h 30m 23s ⏱️ - 4m 11s
2 724 tests ±0  2 709 ✅ ±0  15 💤 ±0  0 ❌ ±0 
2 743 runs  ±0  2 728 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit 8f53ac1. ± Comparison against earlier commit 7b12a0d.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   10m 12s ⏱️ -41s
1 486 tests ±0  1 486 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 577 runs  ±0  1 577 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 8f53ac1. ± Comparison against earlier commit 7b12a0d.

backspace and others added 6 commits May 22, 2026 14:19
…CS-10055)

These fields no longer have a source-of-truth on disk:
 - hostHome was migrated to a `/`-rooted hostRoutingRules entry by the
   backfill in the previous commit
 - interactHome was already obsolete — index.json is the interact-mode
   home — and the backfill trims it from sidecars

Removes:
 - `hostHome` / `interactHome` from the RealmInfo type
 - their defaults in parseRealmInfo
 - the sidecar overlay reads in parseRealmInfo
 - matching `hostHome: null` / `interactHome: null` initializers across
   the host service, runtime-common helpers, the realm-server mock-route
   helper, and ~70 places in host integration test fixtures

Updates the REALM_CONFIG_CARD_PROPERTIES comment in runtime-common/realm.ts
to drop the "until CS-10055" framing. Also fixes a latent typing edge
in toRelativeInstanceLink to accept a nullable realm URL.

setHostHome on the host service and the publish-time hostHome rewrite
in handle-publish-realm.ts still write to the sidecar; both are
addressed in the next two commits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…CS-10055)

After CS-10055 the home card is the `/`-rooted entry in
`hostRoutingRules`, whose linksTo target lives at
`data.relationships["hostRoutingRules.<i>.instance"].links.self` on the
realm.json card. Replaces the previous sidecar-based hostHome rewrite
with a card-relationship walk: when a published realm's card carries
an absolute link still pointing at the source realm, rewrite it to the
published realm URL. Relative links (./Type/id) survive copySync and
need no rewrite.

`rewriteHostHomeForPublishedRealm` is gone — sidecars no longer carry
hostHome after the CS-11150 backfill + the previous commits in this
chain. The existing publish-rewrite test was rewritten to seed a card
with one absolute and one relative routing-rule link and assert that
only the absolute one is rewritten.

Not run locally: the publish-unpublish suite needs the wait-for-servers
harness (Synapse + realm servers). Typecheck is clean and the helper
is a pure function; full suite to run via `pnpm test:wait-for-servers`
in CI / locally before merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After the backfill + read-path + publish-rewrite changes, no surface
still writes hostHome via the sidecar PATCH path. setHostHome (both
the per-realm method and the service-level wrapper) is dead code with
no remaining callers — removed, along with `'interactHome' | 'hostHome'`
from the RealmInfoProperty union. Operators that want to set a host-
mode home now PATCH the realm.json card's hostRoutingRules directly.

create-realm.ts's hostHome/interactHome comment is updated to drop the
"until CS-10055" framing — a fresh realm has neither field; host mode
picks them up from the realm.json card once an operator sets routing
rules via /_config.

patchRealmConfig isn't touched: hostHome / interactHome are no longer
in REALM_CONFIG_CARD_PROPERTIES or REALM_CONFIG_METADATA_PROPERTIES,
so a PATCH carrying those keys falls through to the sidecar catch-all
— same handling as any other unrecognized attribute. That fallthrough
will go away with the rest of the sidecar in CS-11131.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two small cleanups now that hostHome / interactHome are gone:

 - The realm_metadata migration comment predicted hostHome / interactHome
   would land as columns on that table; instead CS-10055 unified hostHome
   into the RealmConfig card's hostRoutingRules and removed interactHome
   entirely. Comment rewritten so future readers don't go looking for
   them in realm_metadata.

 - Deleted realm-endpoints-test.ts's "realm-owner can patch multiple
   properties including interactHome and hostHome" — both keys no longer
   appear on RealmInfo, and the multi-property PATCH behavior it was
   actually exercising is already covered by:
     * "can clear card-owned URL fields by patching null" (multi-card
       PATCH against backgroundURL + iconURL)
     * "allows any property except showAsCatalog" (unrecognized keys
       still pass through the handler).

Other CS-10055 mentions remaining in the tree are descriptive ("this
is what CS-10055 introduced") rather than "until CS-10055 lands" — left
in place as tracking pointers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
My step-5 comment update to 1777591052962_create-realm-metadata.js was
the EARLIEST migration file touched in this PR. CI's migration test
auto-computes its rollback depth from that file's position, so the
edit forced the test to roll back 13 migrations — which exposed a
latent bug in `1779348449320_remove-legacy-catalog-realm-permissions`'s
DOWN script (its unconditional INSERT collides with the next-rolled-
back canonical-url-https-to-http migration's UPDATE on the
realm_user_permissions PK).

The bug exists on main but is dormant there — nothing touches that-old
a migration. Reverting my comment edit pulls our rollback footprint
back to the actual migration files added in this PR (none — we only
edited comments + code in non-migration files), and the down-test
covers what it covered before.

Filed as a separate follow-up so the migration comment can be
corrected once the DOWN bug is fixed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant