Skip to content

Move toward virtual network-based prefix mappings#4954

Merged
backspace merged 42 commits into
mainfrom
deprecated-resolution-cs-10752
May 28, 2026
Merged

Move toward virtual network-based prefix mappings#4954
backspace merged 42 commits into
mainfrom
deprecated-resolution-cs-10752

Conversation

@backspace
Copy link
Copy Markdown
Contributor

@backspace backspace commented May 25, 2026

In the journey to @cardstack/base, this is a step toward removing the global prefixMappings registry, it adds virtual network functions that parallel the currently-global ones, and changes classes that need mappings to accept a virtual network that can perform them.

There are still fallbacks to the global registry, to be removed in a folllowup. Other followup work includes:

  • internalKeyFor uses that don’t have an associated network
  • isLocalId
  • base realm files
  • RealmPaths and its callers
  • IndexQueryEngine needs a virtual network

I’m just stopping here as this has already gotten large.

CS-10752, PR 1 of 3.

Adds instance methods on VirtualNetwork that mirror the existing
module-level resolver functions but read from the VN's own
realmMappings instead of the global prefixMappings registry:

  - VN.isRegisteredPrefix(reference)
  - VN.unresolveURL(url)        replaces unresolveCardReference
  - VN.toURL(rri)               replaces cardIdToURL
  - VN.resolveRRI(ref, base)    replaces the module-level resolveRRI

The module-level forms (resolveCardReference, unresolveCardReference,
cardIdToURL, registerCardReferencePrefix, unregisterCardReferencePrefix,
isRegisteredPrefix, resolveRRI) are tagged @deprecated. They still work
— addRealmMapping continues to bridge into prefixMappings — but new
code should use the VN methods. The bridge and the standalones will be
removed in PR 3 after PR 2 migrates the call sites.

New test coverage in card-reference-resolver-test.ts exercises the VN
methods against a local VN, demonstrating that they don't depend on
the global registry (sibling VNs have isolated mappings). The existing
tests for the deprecated standalones are left intact until PR 3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 25, 2026

Preview deployments

Host Test Results

    1 files  ±0      1 suites  ±0   1h 45m 1s ⏱️ - 4m 7s
2 839 tests +1  2 824 ✅ +1  15 💤 ±0  0 ❌ ±0 
2 858 runs  +1  2 843 ✅ +1  15 💤 ±0  0 ❌ ±0 

Results for commit a390d8c. ± Comparison against earlier commit cf7b9c5.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   13m 3s ⏱️ + 1m 54s
1 516 tests +9  1 515 ✅ +9  1 💤 ±0  0 ❌ ±0 
1 607 runs  +9  1 606 ✅ +9  1 💤 ±0  0 ❌ ±0 

Results for commit a390d8c. ± Comparison against earlier commit cf7b9c5.

backspace and others added 5 commits May 26, 2026 07:50
Replaces resolveCardReference / unresolveCardReference with the
VirtualNetwork instance methods added in the previous commit, for the
four host files that already had network access via NetworkService (or
needed only one new @service line). Behavior is preserved: resolveRRI
keeps prefix-form RRIs in prefix form rather than eagerly converting to
URL form, but downstream consumers accept either form.

prerender-util.ts is currently unreferenced; converted to take VN as a
parameter to avoid leaving a deprecated import behind.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Stores the `virtualNetwork` constructor argument as a private field on
Realm (with a public `virtualNetwork` getter) so internal methods can
reach the VN without going through module-level resolvers.

Migrates the two in-file `resolveCardReference` calls:
- visitModuleDeps in the writeMany path now uses `vn.resolveRRI` so
  the canonical form of module URLs flows through the VN instance
  registered for this realm rather than the global prefixMappings.
- `isForeignRealmDep` now uses `vn.toURL().href` to resolve the stored
  prefix form back to a URL before comparing against `this.url`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds `virtualNetwork: VirtualNetwork` to `TaskArgs` so background tasks
running off the queue can reach the per-worker VN. Worker.run() now
threads `this.#virtualNetwork` into the args bag (the field already
existed for the fetcher pipeline).

The two `IndexRunner` constructor sites in `tasks/indexer.ts` destructure
`virtualNetwork` out of TaskArgs and pass it to the runner; the
constructor stores it as `#virtualNetwork`. Migrates the runner's one
in-file `resolveCardReference` call (in `reportStatus`) to
`#virtualNetwork.resolveRRI`.

run-command-task-shared-tests.ts updated to satisfy the new required
field on TaskArgs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Loader doesn't need a VN to function — when no realm prefix is
registered (the existing test path), prefix-form identifiers don't
arise — so VN is wired in as an optional field on the constructor's
existing `options` bag. The host's LoaderService now passes
`this.network.virtualNetwork`; existing test call sites that don't
register prefixes keep working unchanged.

Migrates the three in-file deprecated calls:
- `captureIdentitiesOfModuleExports` now uses
  `virtualNetwork.unresolveURL(trimmed)` when VN is present, else
  returns the trimmed identifier as-is (same shape as the deprecated
  `unresolveCardReference` returned for unmatched inputs).
- The two `resolveCardReference` calls in `getConsumedModules` (used
  for cycle/self-exclusion checks) become `virtualNetwork.toURL().href`
  with a `new URL()` fallback when VN is absent.

`cloneLoader` propagates VN to the cloned instance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`removeRealmMapping` is a companion to `addRealmMapping` so tests can
scope a temporary prefix to a single test and clean up without leaking
the mapping into sibling tests. The deprecated
`unregisterCardReferencePrefix` doesn't touch VN's own mapping table,
so a VN-aware unwind helper is needed once consumers register through
VN.

`host/tests/unit/loader-test.ts` is migrated to register its scoped
`@test-loader/` prefix on the per-app VN rather than the deprecated
module-level registry — the Loader now reads from the VN it was
constructed with, so the global-only setup no longer applied.

`realm-server/tests/billing-test.ts` and `full-reindex-test.ts` provide
a typed stub for the `virtualNetwork` field that the previous commit
added to `TaskArgs`. These tasks don't exercise resolver paths, so a
typed null suffices.

Also reformats `realm-server/tests/card-reference-resolver-test.ts` to
satisfy prettier.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@backspace backspace force-pushed the deprecated-resolution-cs-10752 branch from 23396b9 to 5d34868 Compare May 26, 2026 12:51
backspace and others added 22 commits May 26, 2026 08:36
`VN.isRegisteredPrefix`, `VN.toURL`, and `VN.unresolveURL` now consult
the deprecated module-level `prefixMappings` registry when their own
realm mapping table doesn't have a match. This is the migration window
plumbing: while CS-10752 is in flight, some call sites read VN and
some still write to the global (legacy tests, unmigrated callers).
Without these fallbacks, every intermediate commit risks the
asymmetry that broke the previous iteration of this PR (VN says
"unknown prefix", global says "registered" — Store cache splits,
loader URL parses throw, etc.).

`VN.resolveRRI` doesn't need its own top-level fallback — its
prefix-form early return goes through `isRegisteredPrefix` (which has
a fallback), so the most common path works. Relative-reference
resolution against a global-only prefix is a known gap that we
expect not to hit in practice during the migration window.

Removed in the final cutover commit, together with the global
registry, the `addRealmMapping → registerCardReferencePrefix` bridge,
and the deprecated standalone exports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the exact contract of the deprecated
`resolveCardReference(reference, relativeTo)`: accepts
relative/prefix/URL references and a URL-or-string base, returns a
canonical URL object. Internal composition is `resolveRRI` + `toURL`,
with a migration-window fallback to the deprecated module-level
resolver for the one resolveRRI branch (relative reference against a
prefix-form base) that doesn't itself fall back to the global.

Lets callers that today do `new URL(resolveCardReference(...))` swap
to `vn.resolveURL(...)` one-for-one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
With the migration-window fallbacks in `VN.isRegisteredPrefix`,
`VN.toURL`, and `VN.unresolveURL`, every replacement of a deprecated
standalone resolver call with its `vn.<method>` equivalent is
behavior-preserving — VN sees prefixes registered via either
`vn.addRealmMapping` or the legacy `registerCardReferencePrefix`
global.

Shape changes:
- `CardStoreWithErrors` (in render-service.ts) now takes a `VirtualNetwork`
  alongside its `fetch`. The render-service unit tests build a VN
  locally instead of relying on the global registry.
- `resolveCardRealmUrl(cardId, realms)` in lib/realm-utils.ts gains a
  third `virtualNetwork` arg; its two callers in
  resources/{live-,}prerendered-search.ts pass `network.virtualNetwork`.
- `Attachments` is now a class-based component so its `cardErrorRealm`
  / `cardErrorDisplayTitle` template helpers can read VN via
  `@service network`.
- The module-level `asURL` / `isResolvableInstanceId` helpers in
  services/store.ts now accept a VN parameter; in-class call sites
  feed `this.network.virtualNetwork`.

routes/render.ts, routes/render/meta.ts, services/card-type-service.ts,
services/operator-mode-state-service.ts, and services/realm.ts get
one-for-one swaps (`cardIdToURL` → `vn.toURL`,
`isRegisteredPrefix` → `vn.isRegisteredPrefix`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`fetcher` (the middleware-wrapping fetch builder used by the host
network service, the loader-service, and `Realm` / `Worker` in
runtime-common) had a `resolveCardReference` step that resolved
prefix-form scoped identifiers to URLs before constructing the
Request, so `new Request('@cardstack/catalog/...')` doesn't accidentally
resolve against document.baseURI.

Migrated to consult `VirtualNetwork.toURL` instead, with VN passed as
an optional third parameter. All four callers in the app code path
(host NetworkService, LoaderService, runtime-common Realm and Worker)
now pass their VN. `VirtualNetwork.fetch`'s internal `fetcher(...)`
call passes `this` so it doesn't lose the prefix-resolution step
either. Tests that build a `fetcher` without a VN are unaffected
(the prefix check just no-ops).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`unresolveResourceInstanceURLs` (the helper that converts card resource
URLs back to registered prefix form for portable storage) now takes a
`VirtualNetwork` parameter instead of reading from the global. Its
single caller is `performCardIndexing` in the card-indexer task, which
gains a matching `virtualNetwork` option threaded through from
`IndexRunner.#virtualNetwork` (already on the class as of 13fac10).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`resolveFileDefCodeRef(fileURL)` now takes a `VirtualNetwork` second
parameter. All five callers updated:
- host/components/matrix/room.gts and host/services/store.ts pass
  `this.network.virtualNetwork`.
- runtime-common/realm.ts passes `this.#virtualNetwork`.
- index-runner/file-indexer.ts and index-runner/visit-file.ts add
  `virtualNetwork` to their options bag; IndexRunner threads it from
  `this.#virtualNetwork`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`extractRelationshipIds(relationship, baseUrl)` in resource-types.ts
now takes a `VirtualNetwork` third argument and uses `vn.resolveURL`
for the same canonical-URL output the deprecated resolver produced.

Two callers updated:
- host/commands/listing-install.ts: gains `@service network` and passes
  `this.network.virtualNetwork`.
- runtime-common/index-runner/relationship-dependency-extractor.ts:
  takes a `virtualNetwork` in its constructor opts and stores it as
  `#virtualNetwork`. Its consumer, `IndexRunnerDependencyManager` in
  index-runner/dependency-resolver.ts, accepts `virtualNetwork` in
  options and forwards it; `IndexRunner.constructor` passes
  `this.#virtualNetwork`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`file-serializer.ts`'s top-level `serialize()` now takes `virtualNetwork`
in its options bag and forwards it into `processRelationships`. The
single `resolveCardReference(selfLink, relativeTo)` site there becomes
`virtualNetwork.resolveURL(selfLink, relativeTo)`.

`Realm.fileSerialization` (its only caller) passes `this.#virtualNetwork`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both `loadCardDocument` and `loadFileMetaDocument` in `document.ts`
now take an optional `VirtualNetwork` third argument. When present
they use `vn.toURL(...)` for URL canonicalization; when absent they
fall back to `new URL(...)` directly. The optional-arg shape is
specifically to keep the `FallbackCardStore` in `packages/base/
card-api.gts` working without further plumbing — it doesn't have a
VN reference and its inputs are URL-form in practice, so the
fallback path is fine there.

Callers that *can* pass VN now do:
- host `CardStoreWithGarbageCollection` gains a `#virtualNetwork`
  field via its constructor; its `loadCardDocument` /
  `loadFileMetaDocument` forward it.
- host `CardStoreWithErrors` (render-service.ts) similarly.
- The two production call sites in services/store.ts and the
  garbage-collection unit test thread the host's VN through.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three test files still used `registerCardReferencePrefix` /
`unregisterCardReferencePrefix` from the deprecated module-level
registry. Switched to `vn.addRealmMapping` /
`vn.removeRealmMapping` on the appropriate VN instance:

- `store-test.gts` (integration): uses the host's per-app VN via
  `getService('network').virtualNetwork`.
- `create-file-test.gts` (acceptance): same. Converted the nested
  module's `before` / `after` to `beforeEach` / `afterEach` because
  `getService` needs a live test context that the once-per-module
  hooks don't have set up yet (setupApplicationTest provides it on
  beforeEach).
- `fetcher-test.ts` (unit): the fetcher itself is the unit-under-test,
  so this test constructs a local `new VirtualNetwork()`, registers
  the scoped prefix on it, and passes that VN to `fetcher(...)`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three classes of fix:

(1) Lint: prettier formatting + import-order in listing-install.ts and
render-service-test.ts.

(2) Acceptance test timing regression: in
acceptance/code-submode/create-file-test.gts, the nested-module's
`hooks.before` had to be reverted from `hooks.beforeEach`. The
indexer runs `spec/animal.json` (whose `adoptsFrom.module` is
`@test-realm/test2/animal`) during the outer `setupAcceptanceTestRealm`'s
beforeEach, which runs BEFORE the inner `hooks.beforeEach`. Switching
to beforeEach meant the prefix wasn't registered yet when the indexer
fired. Restored `hooks.before` and the deprecated
`registerCardReferencePrefix` call; the VN's `addRealmMapping →
registerCardReferencePrefix` bridge still keeps both views in sync,
so migrated callers still see the prefix.

(3) Realm-server card-reference-resolver-test.ts: the
"isRegisteredPrefix > uses only this VN's mappings — not a sibling
VN" test asserted VN-instance isolation, which is true post-cutover
but currently violated by the migration-window fallback in
`VN.isRegisteredPrefix` (it consults the deprecated global, which is
populated by every `addRealmMapping` via the bridge). Skipped with
`test.skip` + a comment pointing at the final cutover commit. Also
removes the leak that broke the following `unresolveURL > returns
the URL as-is when no target matches` test (which depended on the
global registry being empty of `@other/realm/`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`test.skip` indentation in card-reference-resolver-test.ts needed the
single-line form prettier wanted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`normalizeQueryDefinition` now accepts an optional `virtualNetwork` and
uses `vn.toURL(resource.id)` when present, falling back to the deprecated
`cardIdToURL` during the migration window. The realm-index-query-engine
caller passes `this.#realm.virtualNetwork` and resolves its own
`relativeTo` through the VN too. The base query-field-support caller
stays on the fallback until the base package is migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`Batch` now takes an optional `virtualNetwork` (threaded through
`IndexWriter.createBatch`) and routes its prefix checks/unresolution
through two private helpers that prefer the VN and fall back to the
deprecated module-level resolver during the migration window. The
IndexRunner caller passes its own `#virtualNetwork`; the worker-manager,
copy-task, and test callers stay on the fallback for now.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`canonicalURL` and the dependency-normalization helpers
(`normalizeStoredDependency`, `normalizeRelationshipDependency`,
`canTraverseRelationshipDependency`, `normalizeDependencyForLookup`) take
an optional `virtualNetwork` and route prefix resolution through it,
falling back to the deprecated module-level resolver when absent. VN is
threaded from the index-runner pipeline holders: IndexRunner,
RelationshipDependencyExtractor, IndexRunnerDependencyManager (now stores
its VN and forwards it into IndexBackedDependencyErrors), and the
card-indexer. definition-lookup's own canonicalURL calls stay on the
fallback until that file is migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CachingDefinitionLookup now stores the VirtualNetwork it's constructed
with and threads it into this file's private canonicalURL helper (which
gains an optional virtualNetwork param, preferring it over the deprecated
isRegisteredPrefix/resolveCardReference) and into the error-base
cardIdToURL site. All in-class call sites pass this.#virtualNetwork; the
global fallback remains only for the migration window.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
absolutizeInstanceURL, relativizeDocument, and relativizeResource gain an
optional virtualNetwork param and prefer it over the deprecated
isRegisteredPrefix/resolveCardReference/cardIdToURL. The class methods
(loadLinks, the relationship-resolution path, relativizeDocument caller,
and the query-field relativeTo) thread this.#realm.virtualNetwork, and the
in-class unresolveCardReference site becomes vn.unresolveURL (dropping
that import). Free-function callers in tests stay on the fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an optional virtualNetwork getter to the CardStore interface and a
resolveRef helper in card-api that prefers the store's VirtualNetwork,
falling back to the deprecated module-level resolveCardReference when
absent. The six resolveCardReference sites in card-api (linksTo/linksToMany
deserialize, queryableValue absolutization, and lazy link loading) now go
through resolveRef. FallbackCardStore reads the VN off its Loader (new
public Loader.getVirtualNetwork getter); the host's
CardStoreWithGarbageCollection exposes its existing #virtualNetwork.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CachingDefinitionLookup's canonicalURL now resolves prefixes through its
VirtualNetwork, so the coordinator/listener test stubs need functional
isRegisteredPrefix and toURL. The stubs only implemented fetch, so the
lookup path threw. The added methods mirror an empty VirtualNetwork's
behavior for the URL-form module IDs these tests use.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wraps the long conditional/argument lines introduced when routing prefix
resolution through the VirtualNetwork, fixing the runtime-common lint.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Exports a virtualNetworkFor(instance) helper from card-api (returns the
instance's store VirtualNetwork, or undefined) so other base modules can
resolve without reaching into the private store map. cards-grid now uses
it for the spec id, falling back to cardIdToURL when no VN is available.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The cardReferenceUrls computed field and the embedded/atom/edit baseUrl
getters now resolve a prefix-form relativeTo via the instance's
VirtualNetwork (virtualNetworkFor), falling back to cardIdToURL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
backspace and others added 9 commits May 27, 2026 08:49
resolveUrl / extractBfmReferences / extractCardReferenceUrls take an
optional virtualNetwork and resolve refs through it (falling back to
resolveCardReference). The instance-backed callers pass their VN:
rich-markdown and markdown-file-def via virtualNetworkFor(this), and the
host rendered-markdown component via this.network.virtualNetwork. The
metadata-only markdown-file-def path and the unit tests stay on the
fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…on callers

internalKeyFor and isLocalId now accept an optional virtualNetwork and route
prefix resolution through it, falling back to the deprecated module-level
resolver when absent. The runtime-common callers that already hold a VN pass
it: realm-index-query-engine (this.#realm.virtualNetwork), realm.ts and
definition-lookup (this.#virtualNetwork), and the file-indexer. The remaining
host/base/test callers and index-query-engine stay on the fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
All isLocalId call sites in the store service now pass the store's
VirtualNetwork (this.network.virtualNetwork, the local vn where already in
scope, or the asURL helper's vn param) so local-id detection consults the
VN's prefix table instead of the deprecated global registry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…k access

card-type-service, operator-mode-state-service, the matrix room component,
and the module-inspector now pass this.network.virtualNetwork into
internalKeyFor. Remaining host internalKeyFor sites (routes, utils, and
components without a network service) stay on the fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
IndexQueryEngine takes an optional virtualNetwork (passed by
RealmIndexQueryEngine as realm.virtualNetwork) and threads it into all six
internalKeyFor sites so type-key generation consults the VN's prefix table.
Test constructors that omit it stay on the deprecated-resolver fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the ticket reference and migration-window framing in favor of
describing what the helpers do: prefer the threaded VirtualNetwork, fall
back to the module-level resolver when a Batch is built without one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-cs-10752

# Conflicts:
#	packages/host/app/components/operator-mode/preview-panel/rendered-markdown.gts
@backspace backspace marked this pull request as ready for review May 28, 2026 13:20
Copy link
Copy Markdown

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

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: bab1620247

ℹ️ 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 thread packages/runtime-common/document.ts Outdated
@backspace backspace requested a review from a team May 28, 2026 16:55
@habdelra habdelra requested a review from Copilot May 28, 2026 17:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 advances the runtime away from the global prefixMappings registry by adding VirtualNetwork-scoped prefix/RRI utilities and threading a VirtualNetwork through the runtime components that need prefix resolution (indexing, loading, serialization, and host services). It also marks the old module-level resolver APIs as deprecated and updates tests to use VirtualNetwork-managed mappings where possible.

Changes:

  • Add VirtualNetwork methods for prefix detection and RRI/URL resolution/unresolution, with transitional fallbacks to the deprecated global resolver.
  • Thread virtualNetwork through indexing/definition lookup/loader/document utilities so prefix-form identifiers can be handled without relying on global state.
  • Update host services and tests to use virtualNetwork for canonicalization, fetch wrapping, and relationship/module dependency handling.

Reviewed changes

Copilot reviewed 65 out of 65 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/runtime-common/worker.ts Pass virtualNetwork into task args and into fetcher() to support prefix-form fetches.
packages/runtime-common/virtual-network.ts Add VN-scoped prefix mapping utilities (removeRealmMapping, isRegisteredPrefix, unresolveURL, resolveRRI, resolveURL, toURL) and pass VN to fetcher() internally.
packages/runtime-common/url.ts Make URL “unresolve” operations use virtualNetwork.unresolveURL() instead of the deprecated global function.
packages/runtime-common/tests/run-command-task-shared-tests.ts Update task arg construction to include virtualNetwork.
packages/runtime-common/tasks/indexer.ts Thread virtualNetwork through indexer task plumbing into IndexRunner.
packages/runtime-common/tasks/index.ts Extend TaskArgs with required virtualNetwork.
packages/runtime-common/resource-types.ts Require VirtualNetwork for relationship-id resolution.
packages/runtime-common/realm.ts Store and expose virtualNetwork; migrate various resolution sites to VN methods; pass VN into fetcher(), serializer, and internalKeyFor().
packages/runtime-common/realm-index-query-engine.ts Prefer VN-based prefix checks, URL resolution, and unresolution; thread VN into relativization paths.
packages/runtime-common/query-field-utils.ts Allow query normalization to use VN when converting resource IDs to URL bases.
packages/runtime-common/loader.ts Allow loaders to carry a virtualNetwork; use it for prefix-aware normalization in getConsumedModules() and for module export identity capture.
packages/runtime-common/index.ts Thread VirtualNetwork into internalKeyFor() and isLocalId() for VN-aware canonicalization.
packages/runtime-common/index-writer.ts Thread optional VN into batch indexing logic for prefix checks and unresolution.
packages/runtime-common/index-runner/visit-file.ts Require VN and pass it into resolveFileDefCodeRef().
packages/runtime-common/index-runner/relationship-dependency-extractor.ts Require VN and thread it through dependency canonicalization/normalization.
packages/runtime-common/index-runner/index-backed-dependency-errors.ts Thread optional VN into dependency lookup/canonicalization.
packages/runtime-common/index-runner/file-indexer.ts Require VN and use it for file type refs and internalKeyFor().
packages/runtime-common/index-runner/dependency-url.ts Add optional VN to dependency canonicalization (prefix-aware).
packages/runtime-common/index-runner/dependency-resolver.ts Require VN for index-runner dependency management and canonicalization.
packages/runtime-common/index-runner/dependency-normalization.ts Add optional VN throughout stored/relationship dependency normalization.
packages/runtime-common/index-runner/card-indexer.ts Require VN; unresolve instance URLs via VN; canonicalize deps via VN-aware canonicalURL().
packages/runtime-common/index-runner.ts Require VN; pass it into batch creation, dependency resolver, and indexing operations.
packages/runtime-common/file-serializer.ts Require VN for relationship self-link resolution.
packages/runtime-common/file-def-code-ref.ts Require VN to resolve file-def code refs (removing global resolver usage).
packages/runtime-common/fetcher.ts Add optional VN parameter so prefix-form identifiers can be resolved before new Request(...).
packages/runtime-common/document.ts Add optional VN to document-loading helpers so prefix-form IDs can become request URLs.
packages/runtime-common/definition-lookup.ts Canonicalize module URLs using VN where available; thread VN into internal key computation.
packages/runtime-common/card-reference-resolver.ts Add deprecation docs and add unregisterCardReferencePrefix() to support VN cleanup bridging.
packages/runtime-common/bfm-card-references.ts Allow BFM reference extraction to resolve URLs using VN.
packages/realm-server/tests/module-cache-invalidation-listener-test.ts Update stub VN to include isRegisteredPrefix() and toURL().
packages/realm-server/tests/module-cache-coordination-test.ts Update stub VN to include isRegisteredPrefix() and toURL().
packages/realm-server/tests/full-reindex-test.ts Update task args to include virtualNetwork.
packages/realm-server/tests/card-reference-resolver-test.ts Add test coverage for VN resolver methods; keep existing deprecated-global tests intact.
packages/realm-server/tests/billing-test.ts Update task args to include virtualNetwork.
packages/host/tests/unit/services/render-service-test.ts Update tests to construct CardStoreWithErrors with a VN rather than global prefix registration.
packages/host/tests/unit/loader-test.ts Update prefix-mapping test to register/remove mappings on the app’s VN.
packages/host/tests/unit/garbage-collection-test.ts Pass VN into CardStore construction via Network service.
packages/host/tests/unit/fetcher-test.ts Update prefix-resolution test to pass VN into fetcher() and use VN-scoped mappings.
packages/host/tests/integration/store-test.gts Update store integration test to use VN add/remove mapping.
packages/host/tests/acceptance/code-submode/create-file-test.gts Document why a module-level registration is still used at module setup time (VN not in scope yet).
packages/host/app/services/store.ts Canonicalize IDs via VN; thread VN into CardStore construction and resolver helpers.
packages/host/app/services/render-service.ts Make CardStoreWithErrors VN-aware for caching and document loads.
packages/host/app/services/realm.ts Resolve realm URLs via VN rather than global prefix utilities.
packages/host/app/services/operator-mode-state-service.ts Use VN for codePath URL coercion and internal key generation.
packages/host/app/services/network.ts Pass VN into fetcher() for authedFetch.
packages/host/app/services/loader-service.ts Pass VN into both fetcher() and Loader construction.
packages/host/app/services/card-type-service.ts Use VN for module URL resolution and internal key generation.
packages/host/app/routes/render/meta.ts Inject network service and use VN for maybeRelativeReference computations.
packages/host/app/routes/render.ts Use VN for URL conversion when creating file-meta instances.
packages/host/app/resources/prerendered-search.ts Thread VN into realm resolution for search results.
packages/host/app/resources/live-prerendered-search.ts Thread VN into realm resolution for prerendered instances.
packages/host/app/lib/realm-utils.ts Require VN for resolving a card’s realm URL.
packages/host/app/lib/prerender-util.ts Use VN-aware resolveRRI() for module dependency extraction.
packages/host/app/lib/gc-card-store.ts Store and use VN for document loading.
packages/host/app/lib/file-def-manager.ts Unresolve sourceUrl via VN rather than deprecated global function.
packages/host/app/components/operator-mode/preview-panel/rendered-markdown.gts Use VN for reference extraction and relative resolution in rendered markdown.
packages/host/app/components/operator-mode/edit-field-modal.gts Use VN for resolving relative module refs.
packages/host/app/components/operator-mode/code-submode/module-inspector.gts Use VN for module URL resolution and internal keys.
packages/host/app/components/matrix/room.gts Pass VN into resolveFileDefCodeRef() and internal key generation.
packages/host/app/components/ai-assistant/message/attachments.gts Convert template-only component into Glimmer component to access VN via injected network service for error display parsing.
packages/host/app/commands/listing-install.ts Inject network service to pass VN into relationship ID extraction.
packages/base/rich-markdown.gts Use virtualNetworkFor() to resolve base URLs and pass VN into BFM reference extraction.
packages/base/markdown-file-def.gts Pass VN into BFM reference extraction for markdown file defs.
packages/base/cards-grid.gts Use virtualNetworkFor() when converting spec IDs to URL objects.
packages/base/card-api.gts Extend CardStore to optionally provide VN; centralize reference resolution through store/VN with fallback to deprecated resolver.

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

Comment thread packages/runtime-common/virtual-network.ts Outdated
Comment thread packages/runtime-common/virtual-network.ts Outdated
@backspace backspace merged commit 470b505 into main May 28, 2026
72 of 73 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