Add handling for RRIs in serialised forms#5563
Draft
backspace wants to merge 5 commits into
Draft
Conversation
A card's in-memory `id` field is typed RealmResourceIdentifier but was populated verbatim from the serialized `data.id`, which is URL form for a mapped realm. Fold it onto the canonical interior form at the ingest boundary so the `id` field, the identity-map key, and the relative- resolution base share one opaque spelling — the runtime treats the id as an RRI, matching how cross-resource references already canonicalize. CardStore gains a `canonicalizeId` capability (the inverse of the existing `resolveURL` boundary role): a mapped realm's URL collapses to its `@scope/name` prefix, an already-canonical RRI is returned unchanged, and an unmapped realm's URL or a local id passes through. Card code canonicalizes without holding the VirtualNetwork, matching how stores expose URL resolution. Scoped to card instances; FileDef ids stay URL form for now (their identity is entangled with the file-extract invalidation contract). The transform is a no-op for unmapped realms, so serialization against a realm with no prefix mapping is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
With card instance ids folded to canonical RRI at the deserialize boundary, the read paths that key or resolve by a card's id must accept that form: - gc-card-store keys card instances by canonical RRI (getCardItem / setCardItem fold the id through unresolveURL after stripping `.json`), so a lookup lands whether the caller passes the card's own RRI id or the resolved URL that store.asURL produces. File-meta buckets keep their URL keys. - realm-index-query-engine resolves a relationship's `links.self` against the fetchable URL of the owning resource (vn.toURL) rather than the raw id, which may now be an RRI that resolveURL only accepts as a base for a registered prefix. Mirrors the sibling linkURL resolution. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Preview deploymentsHost Test Results 1 files 1 suites 1h 34m 14s ⏱️ Results for commit 1ee0284. For more details on these errors, see this check. Realm Server Test Results 1 files ±0 1 suites ±0 11m 39s ⏱️ +8s Results for commit 2f8ecff. ± Comparison against earlier commit b6e5c3a. |
getCardItem/setCardItem already fold card ids to canonical RRI, but delete() and makeTracked() read the card buckets with the raw id, so a delete by the resolved URL (store.asURL) or a re-track missed the RRI-keyed entry. Fold the id on those paths too (after the `.json` file-meta split, which stays URL-keyed) so every card-bucket access agrees on the canonical key. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Canonicalizing card ids folds every deserialize and every gc-card-store keying / GC-sweep access through unresolveURL, whose mapping chase pays a native `new URL()` per miss — enough per-op overhead to time out large host renders. Cache the result like toURLHref already does: unresolveURL is a pure function of the realm mappings, so memoize it and clear the memo wherever the mappings change (addRealmMapping / removeRealmMapping / addURLMapping). addURLMapping now also clears toURLHrefCache, which reads urlMappings through toURL and was not invalidated before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.