fix: ingest-card copies Spec + instances from shared/published source realms#5276
fix: ingest-card copies Spec + instances from shared/published source realms#5276jurgenwerk wants to merge 3 commits into
Conversation
… realms ingest-card discovered instances and Specs via the profile-scoped `_federated-search`, which only covers realms in the active profile's set. A shared/published source realm (e.g. the catalog) isn't in that set, so every discovery query returned nothing and ingest copied modules only — forcing the software factory to reconstruct Specs/instances by hand on every adjust run. (The module crawl was unaffected because it uses direct file fetches.) Query the source realm's own `_search` endpoint directly via authedRealmFetch instead. A published realm returns matches in `included` with an empty `data`, so `selectSearchResults` prefers `data` and falls back to `included` (never merges, so a normal realm's linked-dep `included` isn't mistaken for matches). Verified end-to-end against the live catalog: ingesting the WineCellar card now copies both Specs + 10 sample instances alongside the 2 modules (was 2 files). CS-11652. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The fake-realm graph test stubbed the old profile-scoped federated search (`profileManager.authedRealmServerFetch`); ingest now queries the source realm's own `_search` via `authedRealmFetch`, so move the instance/Spec stub there (keyed on `<realm>/_search`) and drop the now-dead profile-manager search mock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes boxel realm ingest-card so it can discover and copy a card’s Catalog Specs and sample instances even when the source realm is shared/published (and therefore not in the active profile’s federated-search realm set). It does this by querying the source realm’s own _search endpoint directly and handling the published-realm response shape.
Changes:
- Switch ingest discovery queries from profile-scoped
/_federated-searchto the source realm’s/_searchviaauthenticator.authedRealmFetch(...). - Add
selectSearchResults()to handle the “published realm returns matches inincludedwith emptydata” response shape. - Update and extend tests (unit coverage for
selectSearchResults, and update the fake realm end-to-end ingest test’s_searchstub).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/boxel-cli/src/commands/realm/ingest-card.ts | Query source realm /_search directly; add selectSearchResults; remove federated-search dependency. |
| packages/boxel-cli/tests/commands/ingest-card.test.ts | Add unit tests for selectSearchResults behavior across response shapes. |
| packages/boxel-cli/tests/commands/ingest-card-graph.test.ts | Update fake authenticator to handle /_search (QUERY) and remove federated-search stubbing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!res.ok) { | ||
| this.hasError = true; | ||
| console.warn(` search failed: ${result.error ?? 'unknown'}`); | ||
| console.warn(` search failed: HTTP ${res.status}`); | ||
| return []; | ||
| } |
There was a problem hiding this comment.
(Written by Claude on Matic's behalf.)
Fixed in 814f807. The _search failure now logs HTTP <status> <statusText> plus a truncated (300-char) response-body snippet, so auth errors / malformed queries are diagnosable from the CLI output — parity with the old federated-search path.
…ilure The realm `_search` failure path logged only the bare HTTP status; surface statusText and a truncated response body too, so auth errors / malformed queries are diagnosable from the CLI output (parity with the previous federated-search path). Co-Authored-By: Claude Opus 4.8 (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: 814f807c04
ℹ️ 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".
| let res = await this.authenticator.authedRealmFetch( | ||
| `${this.realmRoot}_search`, | ||
| { | ||
| method: 'QUERY', | ||
| headers: { | ||
| Accept: CARD_JSON, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(query), | ||
| }, | ||
| ); |
There was a problem hiding this comment.
Preserve best-effort behavior when search throws
If the direct _search fetch rejects (for example during token refresh/network failure) or the response body cannot be parsed as JSON, the exception now escapes searchCards() and aborts sync() before downloadAll(), so even the module graph already discovered is not copied. The previous federated search() converted these failures into ok: false, and the surrounding code still treats search as optional via hasError and return []; this direct path should catch fetch/parse failures and use the same warning/empty-result path.
Useful? React with 👍 / 👎.
What was wrong
boxel realm ingest-cardcopied a card's code modules but not its catalog Spec or sample instances when the source realm was a shared/published one (like the catalog). So the software factory's "adjust an existing card" flow had to reconstruct those by hand on every run — slow, and a lossy approximation of the real card.Why
Ingest discovered instances + Specs through a profile-scoped search that only covers realms the active profile owns. A shared realm like the catalog isn't in that set, so every discovery query came back empty and ingest fell back to copying modules only. (The module copy survived because it uses direct file fetches, not search.)
What this changes
included, with an emptydata); a smallselectSearchResultshelper handles both shapes.Testing