Change prefix-form RRI realms to serve RRI ids#5390
Conversation
Make the realm server the RRI boundary for instance ids: getCard, create/patch card responses, file-meta documents, and atomic-operation results now unresolve the served id / links.self / relationship ids from URL to registered-prefix form (via unresolveResourceInstanceURLs). Unmapped realms have no prefix mapping, so this is a no-op there (ids stay URL) — the change is scoped to prefix-mapped realms (base / catalog). The write handlers derive the on-disk path from the request path / lid (not the incoming data.id), so accepting a prefix-form id needs no change; only the responses are canonicalized. Host wire consumers already accept RRI ids (loadCardDocument passes them through opaquely; isResolvableInstanceId / asURL / render.ts handle prefix form). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Preview deploymentsHost Test Results 1 files ± 0 1 suites ±0 8m 34s ⏱️ - 2h 28m 47s Results for commit 161e0b0. ± Comparison against earlier commit 12ca4b7. Realm Server Test Results 1 files ±0 1 suites ±0 9m 38s ⏱️ +26s Results for commit 161e0b0. ± Comparison against earlier commit 12ca4b7. |
21c2c09 to
abac808
Compare
abac808 to
934330c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 934330cd43
ℹ️ 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".
0ae6b7c to
934330c
Compare
Serving instance ids in canonical RRI (prefix) form changes the card-JSON
representation for mapped realms, but neither indexed_at nor the realm-info
hash moves on a serialization change — so a client/CDN holding a URL-form body
would send its old ETag and get a 304, keeping stale URL-form ids until the
card is reindexed. Bump CARD_JSON_ETAG_VARIANT ('card' -> 'card-rri') so cached
bodies revalidate and pick up the RRI representation.
Addresses PR review feedback on #5390.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The GET and PATCH ETag-shape assertions hard-coded the ':card' variant; the serialization-change bump made it ':card-rri'. Update the patterns to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The realm now serves instance ids in canonical RRI (prefix) form, so a client may reuse a served id as an atomic operation href. The atomic write path parsed hrefs with new URL(href, realmURL), which treats an RRI href as a relative path and produces the wrong local path. Resolve registered-prefix hrefs to a real URL before path math; plain URL / relative hrefs are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
06a075b to
12ca4b7
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates realm responses so that, when a realm is prefix-mapped in the VirtualNetwork, card+json instance identifiers are served in canonical prefix-form RRI (instead of resolved URL form). It also bumps the Card+JSON ETag “variant” to intentionally invalidate previously cached card bodies after the serialization change.
Changes:
- Serve
data.id,links.self, and relationship instance ids in prefix-form RRI for prefix-mapped realms (no-op for unmapped realms). - Accept prefix-form RRI
hrefs for/_atomicoperations by resolving them to real URLs before computing local paths; return created ids in prefix form. - Bump the Card+JSON ETag variant from
card→card-rriand update realm-server tests accordingly; add a host integration test covering the new behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/runtime-common/realm.ts | Canonicalizes served instance ids to RRI for mapped realms; resolves prefix-form atomic hrefs; bumps Card+JSON ETag variant. |
| packages/realm-server/tests/card-endpoints-test.ts | Updates ETag assertions to expect the new :card-rri variant. |
| packages/host/tests/integration/realm-test.gts | Adds integration coverage asserting URL-form ids without mapping and RRI-form ids once a mapping is registered. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert.strictEqual( | ||
| rriDoc.data.links.self, | ||
| '@test-prefix/dir/empty', | ||
| 'links.self is served in canonical RRI form too', | ||
| ); | ||
| }); |
As seen here:
One thing I’m unsure about: does this ETag-related change make sense, for cache-breaking?