Change loader to return RRIs for dependencies and identities#5468
Conversation
…ity APIs getConsumedModules and getKnownConsumedModules now return module identifiers in canonical RRI form (realm-prefix spelling where a prefix mapping is registered), deduping spellings that collapse to one module and excluding self references under any spelling. identify() already recorded identities via unresolveURL; it now shares the same canonicalIdentifier helper. The runtime dependency tracker keys module nodes by http(s) URL, so the loader exposes dependencyTrackingKey() for crossing that boundary, and card-api's relationship module walk uses it. This also fixes prefix-form identity.module values being silently dropped by the tracker's URL guard. Module-cache keys deliberately stay URL-keyed; the moduleCacheKey comment explains why a realm-prefix-sensitive key would orphan cached entries and split class identities when mappings change mid-life. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Preview deploymentsHost Test Results 1 files ± 0 1 suites ±0 3h 7m 46s ⏱️ - 2m 54s Results for commit 6ff6b44. ± Comparison against earlier commit 4c25bf9. Realm Server Test Results 1 files ± 0 1 suites ±0 16m 53s ⏱️ + 5m 47s Results for commit 6ff6b44. ± Comparison against earlier commit 4c25bf9. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c25bf9189
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR updates the runtime Loader API surface so module dependency lists and identities are emitted in a canonical identifier form: prefer realm-prefix RRIs (e.g. @cardstack/base/card-api) when a matching VirtualNetwork realm mapping exists, otherwise fall back to URL-form identifiers. It also introduces an explicit boundary helper for converting canonical RRIs back into URL-form dependency-tracker keys.
Changes:
- Normalize
getConsumedModules()andgetKnownConsumedModules()to return canonical identifiers (RRI prefix form where mapped). - Record
identify()module identities in the same canonical identifier form. - Update runtime relationship dependency tracking to convert canonical identifiers to URL-form tracker keys via the loader.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/runtime-common/loader.ts | Canonicalizes outward-facing module identifiers to RRIs (when mapped) and adds a dependency-tracker boundary helper. |
| packages/host/tests/unit/loader-test.ts | Updates and expands coverage to assert canonical prefix-form output from getConsumedModules() when a realm mapping exists. |
| packages/base/card-api.gts | Converts loader-derived canonical identifiers into dependency-tracker keys at the tracking boundary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
With this,
getConsumedModulesandgetKnownConsumedModulesnormalise to return prefix RRIs if mappings exist for them.This doesn’t change the internal keys to RRIs, as that was causing problems in contexts where prefix mappings were added and removed dynamically. While we recently discussed that maybe that dynamicism isn’t worth preserving, it’s currently the case and this PR is a useful step regardless.