Skip to content

Fix markdown skills from another realm silently failing to attach#5446

Merged
jurgenwerk merged 3 commits into
mainfrom
md-skill-cache-bypass
Jul 13, 2026
Merged

Fix markdown skills from another realm silently failing to attach#5446
jurgenwerk merged 3 commits into
mainfrom
md-skill-cache-bypass

Conversation

@jurgenwerk

@jurgenwerk jurgenwerk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Markdown skills configured on a system card silently fail to attach to new AI assistant rooms (0 skills, only a console.warn) when the skill file lives in a different realm than the card.

Cause: for a cross-realm file link, fetchCrossRealmLinks requests the target with the card mime — the file-ness check behind it (fieldExpectsFileMeta) guesses from the card's own realm contents and gets cross-realm links wrong. A card-mime request for a file returns a minimal document built from the raw file, without index-derived fields like kind — so the host caches a partial file-meta and the file stops counting as a skill.

Fix, in two halves: the serving realm now answers a card-mime request for an indexed file with the same index-enriched file-meta document the file-meta route serves (raw-file form only when unindexed), and fetchCrossRealmLinks requests the file-meta mime outright when the relationship is known to expect a file.

Repro: link a .md skill file from another workspace into a system card's Default Skill Files, set the card active, reload the host, open a new room → 0 skills. Same-workspace links don't reproduce, which is why this stayed hidden.

Before:
image

After:

image

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

    1 files      1 suites   2h 53m 29s ⏱️
3 454 tests 3 439 ✅ 15 💤 0 ❌
3 473 runs  3 458 ✅ 15 💤 0 ❌

Results for commit 57ede98.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   10m 46s ⏱️ -50s
1 807 tests +1  1 807 ✅ +1  0 💤 ±0  0 ❌ ±0 
1 886 runs  +1  1 886 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 57ede98. ± Comparison against earlier commit bf03570.

@jurgenwerk
jurgenwerk force-pushed the md-skill-cache-bypass branch from 5b0835f to 2f1230e Compare July 9, 2026 15:58
@jurgenwerk jurgenwerk changed the title Work around cached empty file-meta silently dropping markdown skills Fetch cross-realm file links with the file-meta mime Jul 9, 2026
@jurgenwerk
jurgenwerk requested a review from Copilot July 9, 2026 16:17

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.

Pull request overview

This PR fixes cross-realm relationship hydration for file links by ensuring cross-realm fetches use (or upgrade to) the file-meta MIME type when the target is a file, so downstream consumers receive the enriched file-meta shape (including index-derived fields like kind) instead of the minimal “raw file” document.

Changes:

  • Extend cross-realm link context to track whether each URL is expected to resolve to file-meta.
  • Request cross-realm links with application/vnd.card.file-meta+json when the relationship is known to target a file.
  • When a card+json cross-realm fetch returns a file-meta document, re-fetch once with the file-meta MIME to get the enriched payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/runtime-common/realm-index-query-engine.ts Outdated
@jurgenwerk
jurgenwerk force-pushed the md-skill-cache-bypass branch from 2f1230e to 5936e6e Compare July 9, 2026 16:48
@jurgenwerk jurgenwerk changed the title Fetch cross-realm file links with the file-meta mime Serve index-enriched file-meta for cross-realm file links Jul 9, 2026
Stored relationships for linked files can carry only links.self (no
data.type), so loadLinks falls back to fieldExpectsFileMeta, which infers
file-ness from whether files of that type exist in the card's own realm —
wrong for a cross-realm file link when the card's realm holds no such
files. The cross-realm fetch then used the card mime, and a card-mime
request for a file returned a minimal document built from the raw file
(base attributes only), dropping index-derived fields like `kind`. That
partial resource lands in the card document's included bucket, the host
caches it, and markdown skills configured on a system card silently fail
to attach (kind is unset, so the file no longer counts as a skill).

Serve file-meta through one path that prefers the index-enriched document
and falls back to the raw-file form only when the file isn't indexed —
used by both the file-meta route and card-mime requests that turn out to
target files. The response keeps the mime the route was matched on;
callers discriminate the payload via data.type. fetchCrossRealmLinks now
also asks for the file-meta mime outright when the relationship is known
to expect a file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jurgenwerk
jurgenwerk force-pushed the md-skill-cache-bypass branch from 5936e6e to 1f183b8 Compare July 9, 2026 17:40
@jurgenwerk jurgenwerk changed the title Serve index-enriched file-meta for cross-realm file links Fix markdown skills from another realm silently failing to attach Jul 9, 2026
@jurgenwerk
jurgenwerk requested a review from Copilot July 9, 2026 18:57

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@jurgenwerk
jurgenwerk requested review from a team and habdelra July 9, 2026 19:03
@jurgenwerk
jurgenwerk marked this pull request as ready for review July 9, 2026 19:03

@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: 1f183b8946

ℹ️ 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".

Comment on lines +1387 to +1388
? SupportedMimeType.FileMeta
: SupportedMimeType.CardJson;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep file-link fetches on an index-draining endpoint

When the relationship is already typed as file-meta, this switches the remote request to Accept: application/vnd.card.file-meta+json. I checked the serving path in Realm.getFileMeta, and unlike getCard it does not await incrementalIndexing() before fileMetaResponse; after a provider realm has just created or updated an indexed markdown skill, this can race the index, fall back to raw file metadata, and still omit attributes.kind, so the cross-realm skill can fail to attach intermittently. Either drain indexing in the file-meta GET path or avoid bypassing the card JSON path for these cross-realm loads.

Useful? React with 👍 / 👎.

@lukemelia lukemelia 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.

What are the scenarios when we don't know whether a skill RRI is a card or a file? If it ends in .md, it is a file, otherwise it is a card. Relying on that heuristic seems better than the changes proposed in this PR.

Happy to discuss further if I am missing something.

Comment thread packages/runtime-common/realm.ts Outdated
Whether a link targets a file or a card is knowable from the URL alone:
card ids never carry a file extension, file URLs always do. Use that in
loadLinks to classify relationships and to pick the accept mime for
cross-realm link fetches, so a cross-realm file link is served the
index-enriched file-meta document (a markdown skill only counts as a
skill when its file-meta carries kind).

This replaces fieldExpectsFileMeta, which consulted the field definition
and then probed whether files of that type exist in the card's own
realm — wrong for a cross-realm link when the card's realm holds no such
files. The serving-side changes from the previous commit are reverted:
with the requester asking correctly, they are no longer needed for this
fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread packages/runtime-common/file-def-code-ref.ts Outdated
Comment thread packages/runtime-common/realm-index-query-engine.ts Outdated
Comment thread packages/runtime-common/realm-index-query-engine.ts Outdated
Card ids can legitimately contain dots (e.g. a versioned
ModelConfiguration instance like model-4.6), so treating any dotted path
segment as a file would misclassify such cross-realm card links and 404
them against the file-meta route. Count only extensions registered in
FILEDEF_CODE_REF_BY_EXTENSION as file tells, and cover the dotted-id
card link with a regression test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jurgenwerk

Copy link
Copy Markdown
Contributor Author

@lukemelia went with your approach, link classification now comes from the URL: a known FileDef extension (.md, .png, .gts, …) means file, otherwise card

@jurgenwerk
jurgenwerk requested a review from lukemelia July 10, 2026 09:09

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread packages/runtime-common/realm-index-query-engine.ts
@jurgenwerk
jurgenwerk merged commit 2573a1f into main Jul 13, 2026
67 checks passed
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