Skip to content

Add realm.cards.get to the realm runner - #6632

Open
jurgenwerk wants to merge 4 commits into
mainfrom
cs-13475-realm-cards-get
Open

jurgenwerk wants to merge 4 commits into
mainfrom
cs-13475-realm-cards-get

Conversation

@jurgenwerk

@jurgenwerk jurgenwerk commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

A script in run-realm-code could 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 call read-card-for-ai-assistant for that. Scripts can now call realm.cards.get(path).

  • It reads the indexed card through the store and serializes it the same way read-card-for-ai-assistant does: computed fields included, base64 images left out, every URL absolute.
  • It returns { path, id, adoptsFrom, attributes, relationships }. The path can be Person/x, Person/x.json, or a full URL in the run's realm.
  • A missing card fails with Card not found; a card in an error state fails with its error message. Like fs.list, it does not count toward the run's file limit.

The paired cardstack/boxel-skills#199 documents realm.cards.get and removes the declaration of read-card-for-ai-assistant. It merges after this change is deployed. The host tool stays until nothing calls it.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files  ±0      1 suites  ±0   1h 47m 4s ⏱️ + 15m 27s
5 401 tests ±0  5 390 ✅ ±0  11 💤 ±0  0 ❌ ±0 
5 416 runs  ±0  5 405 ✅ ±0  11 💤 ±0  0 ❌ ±0 

Results for commit 009555a. ± Comparison against earlier commit 7ad5e90.

Realm Server Test Results

    1 files  ±0    319 suites  ±0   1h 57m 16s ⏱️ + 2m 0s
5 113 tests +7  5 113 ✅ +7  0 💤 ±0  0 ❌ ±0 
5 172 runs  +7  5 172 ✅ +7  0 💤 ±0  0 ❌ ±0 

Results for commit 009555a. ± Comparison against earlier commit 7ad5e90.

@jurgenwerk
jurgenwerk marked this pull request as ready for review October 9, 2026 12:43
@jurgenwerk
jurgenwerk requested a review from a team October 9, 2026 12:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T12:46:40.309671Z 0423071 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.get through 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 richardhjtan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Comment thread packages/host/app/tools/run-realm-code.ts Outdated
jurgenwerk and others added 2 commits October 12, 2026 09:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ort cards awaiting index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jurgenwerk
jurgenwerk force-pushed the cs-13475-realm-cards-get branch from 0423071 to 7ad5e90 Compare October 12, 2026 07:34
@jurgenwerk
jurgenwerk requested review from a team and richardhjtan October 12, 2026 07:44
jurgenwerk and others added 2 commits October 12, 2026 11:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jurgenwerk

Copy link
Copy Markdown
Contributor Author

[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 realm.cards.get in run-realm-code, not read-card-for-ai-assistant. The result includes the computed fields (cardTitle, cardDescription).

Missing card. realm.cards.get('HelloWorld/no-such-card') fails with Card not found: <realm>/HelloWorld/no-such-card, and the model reports the error.

Not covered yet: a card with links, to check that relationships holds absolute URLs.

This branch has not been deployed

No deployments
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.

3 participants