Opt private realms out of full reindex on startup#4858
Conversation
By default, only kind='bootstrap' realms (the CLI --path realms — base, catalog, skills) full-index when the realm-server process boots. kind='source' and kind='published' realms skip the boot reindex; a brand-new index still builds lazily via the isNewIndex branch in Realm.start(). REALM_SERVER_FULL_INDEX_ON_STARTUP is now a three-state override: unset → bootstrap-only (the new default) 'true' → every kind full-indexes (matches the prior behavior) 'false' → no kind full-indexes (preserves the cached-index dev flow) The deploy-time platform-code reindex storm flows through a separate path (handle-post-deployment.ts + boxel-ui checksum), so flipping the default here does not affect post-deploy reindex. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7057f4a6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Host Test Results 1 files ±0 1 suites ±0 1h 30m 40s ⏱️ - 1m 56s Results for commit b271db1. ± Comparison against earlier commit d7057f4. Realm Server Test Results 1 files ±0 1 suites ±0 8m 36s ⏱️ -17s Results for commit b271db1. ± Comparison against earlier commit d7057f4. |
There was a problem hiding this comment.
Pull request overview
Adjusts realm-server startup indexing behavior to avoid expensive from-scratch reindexing for user/private realms on process boot, while preserving eager indexing for bootstrap realms and keeping a three-state env override for operators/dev flows.
Changes:
- Introduces
resolveFullIndexOnStartup(kind, envOverride)to compute per-realm startup full-index behavior from realm kind +REALM_SERVER_FULL_INDEX_ON_STARTUP. - Updates realm-server boot to apply full-index-on-startup only for bootstrap realms by default, with
'true'/'false'overrides. - Adds unit coverage for the three-state resolution and clarifies the existing “new realm indexes on first boot” test’s intent.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/realm-server/main.ts | Switches startup full-index decision to per-realm resolution based on kind + env override; updates boot log field. |
| packages/realm-server/lib/full-index-on-startup.ts | New helper encapsulating three-state env override + kind-based default. |
| packages/realm-server/tests/full-index-on-startup-test.ts | New QUnit tests covering default/true/false/non-boolean env values across realm kinds. |
| packages/realm-server/tests/index.ts | Registers the new test file in the test suite list. |
| packages/realm-server/tests/indexing-test.ts | Renames and documents the “new realm full-indexes on first boot” test to clarify it guards isNewIndex. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Document that any value other than 'true' / 'false' falls through to the kind-based default (not just `undefined`). - Clarify the 'false' branch: it suppresses the env-driven full-index, but the `isNewIndex` branch in Realm.start() still indexes a brand-new realm on first boot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
kind='bootstrap'realms (the CLI--pathrealms — base, catalog, skills) full-index on realm-server boot.kind='source'(user/private) andkind='published'realms now skip the boot reindex.isNewIndexbranch inRealm.start()is independent of this flag, so first-time indexing of a private realm is unchanged.REALM_SERVER_FULL_INDEX_ON_STARTUPbecomes a three-state override:truefalsescripts/import-cached-index.sh)Why
On a developer machine, restarting the realm server triggered a from-scratch index of every private user realm under
realms/, which is expensive and rarely what we want — the realm's existing index is still valid across a process restart. Bootstrap realms (base / catalog / skills) genuinely benefit from a from-scratch index on boot because platform code in those realms can change between boots, so they keep the eager behavior.A
kind='source'/kind='published'realm that genuinely needs a from-scratch index will still get one: either throughisNewIndex(first boot of that realm's index) or via the dedicated/_full-reindexoperator endpoint.Compatibility notes
handle-post-deployment.ts:42→full-reindexjob, gated on a boxel-ui asset checksum change. It does not flow throughfullIndexOnStartup. Flipping the startup default does not change post-deploy behavior; if an operator wants every realm to additionally reindex on every process restart in a deployed environment, setREALM_SERVER_FULL_INDEX_ON_STARTUP=truein the task definition.scripts/import-cached-index.shflow preserved. That flow sets the env var to'false', which now disables full-index for all kinds (including bootstrap), matching its prior effect.Open question for review
I treated
kind='published'as "private" (default off), grouping it withkind='source'. The user-facing definition of "public" in the original ask was "realms specified in the start script" — that's bootstrap, not published. Holler ifkind='published'should be kept on the always-full-index path with bootstrap.Test plan
packages/realm-server/tests/full-index-on-startup-test.tscover the three-state resolution across all three realm kinds (12 cases, all passing).packages/realm-server/tests/indexing-test.ts"newly-created realm full-indexes on first boot" test to explicitly document that it guards theisNewIndexbranch — independent offullIndexOnStartup— which is what guarantees a brand-new private realm still indexes on first boot after this flip.🤖 Generated with Claude Code