Repository navigation
Add realm.cards.get to the realm runner - #6632
jurgenwerk wants to merge 4 commits into
Conversation
82f12e7 to
0423071
Compare
Preview deploymentsHost Test Results 1 files ±0 1 suites ±0 1h 47m 4s ⏱️ + 15m 27s Results for commit 009555a. ± Comparison against earlier commit 7ad5e90. Realm Server Test Results 1 files ±0 319 suites ±0 1h 57m 16s ⏱️ + 2m 0s Results for commit 009555a. ± Comparison against earlier commit 7ad5e90. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04230714dc
ℹ️ 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".
| } | ||
|
|
||
| private async readCard(id: string): Promise<LooseSingleCardDocument> { | ||
| let card = await this.store.get(id); |
There was a problem hiding this comment.
Bypass the store cache when reading cards
When the requested card is already loaded, store.get() returns the cached instance without fetching the indexed state. For example, after await realm.fs.replace('people/hassan.json', ...), an immediately following realm.cards.get('people/hassan') can serialize the pre-edit instance because the realm invalidation and store reload are asynchronous; the same issue occurs with locally modified cached instances. Use the store's uncached read path so this API consistently returns durable indexed data.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
[Claude Code 🤖] Fixed in 7ad5e90: realm.cards.get now reads with store.getWithoutCache, as check-correctness does. The test reads a card, edits its file in the same run, and reads it again; with store.get the second read returned the old name.
There was a problem hiding this comment.
🟡 Changes recommended
Distinguish awaiting-index cards from missing cards and add the requested focused integration coverage.
1 open finding
What changed in this PR
Adds realm.cards.get(path) to the realm runner for retrieving indexed cards with computed fields and absolute URLs.
Changes:
- Adds host-side card lookup and serialization.
- Exposes
realm.cards.getthrough the worker API. - Adds integration coverage for card retrieval behavior.
| File | Summary |
|---|---|
packages/host/tests/integration/tools/run-realm-code-test.gts |
Adds integration tests; focused coverage is still needed for image omission, indexed-card errors, and the file-limit exemption. |
packages/host/app/tools/run-realm-code.ts |
Implements lookup and serialization. Moderate issue: awaitingIndex is incorrectly reported as Card not found. |
packages/host/app/lib/realm-runner/worker.ts |
Exposes realm.cards.get to sandboxed scripts. |
packages/host/app/lib/realm-runner/types.ts |
Registers the new call type. |
🧠 Review effort: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let card = await this.store.get(id); | ||
| if (!isCardInstance(card)) { | ||
| throw new Error( | ||
| card.status === 404 |
There was a problem hiding this comment.
[Claude Code 🤖] Fixed in 7ad5e90: a card awaiting index now fails with Card is not indexed yet: <id>; read it again in a moment, and only a plain 404 says Card not found.
richardhjtan
left a comment
There was a problem hiding this comment.
[Claude Code 🤖] One blocking finding, inline: realm.cards.get answers a card in a different shape from realm.cards.search, under the same realm.cards namespace.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ort cards awaiting index Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0423071 to
7ad5e90
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
[Claude Code 🤖] Tested by hand on a local stack, with this PR and the paired skills PR applied. Read a card. Asked for a card's fields and links. The model called Missing card. Not covered yet: a card with links, to check that |



A script in
run-realm-codecould read a card only as its file, so it could not tell whether the card is indexed or why it fails to load. The model had to leave the script and callread-card-for-ai-assistantfor that. Scripts can now callrealm.cards.get(path).read-card-for-ai-assistantdoes: computed fields included, base64 images left out, every URL absolute.{ path, id, adoptsFrom, attributes, relationships }. The path can bePerson/x,Person/x.json, or a full URL in the run's realm.Card not found; a card in an error state fails with its error message. Likefs.list, it does not count toward the run's file limit.The paired cardstack/boxel-skills#199 documents
realm.cards.getand removes the declaration ofread-card-for-ai-assistant. It merges after this change is deployed. The host tool stays until nothing calls it.🤖 Generated with Claude Code