eng-1863 Relation cross-app contract#1197
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
562c561 to
f1e49e1
Compare
4eb544e to
a4c65c3
Compare
f1e49e1 to
3af1c5f
Compare
a4c65c3 to
1420c0c
Compare
1420c0c to
45bd5a1
Compare
3af1c5f to
48cf038
Compare
PR size/scope checkThis PR is over our review-size guideline.
Please split this into smaller PRs unless there is a clear reason the changes need to land together. If keeping it as one PR, please add a brief justification covering:
|
45bd5a1 to
e52b69e
Compare
e52b69e to
43ae6ef
Compare
d93f832 to
a116229
Compare
43ae6ef to
8ea3d29
Compare
8ea3d29 to
ab64936
Compare
ab64936 to
f14ab44
Compare
| | DbRef | ||
| | { | ||
| localId: string; | ||
| // Treat as LocalRef if space is absent | ||
| space?: SpaceRef; | ||
| // make the options mutually exclusive | ||
| dbId?: never; | ||
| rid?: never; | ||
| } | ||
| | { | ||
| // A string that contains combined space and localId | ||
| rid: string; | ||
| // make the options mutually exclusive | ||
| dbId?: never; | ||
| localId?: never; | ||
| space?: never; | ||
| }; |
There was a problem hiding this comment.
Are all of these union variants required? If so, could we add examples showing where each is already used or needed by upcoming work? Otherwise, I’d prefer to keep the contract limited to the variants we currently need and add others when a concrete use case arises.
Including speculative variants increases the contract’s conceptual surface area and requires additional validation, tests, and converter paths, which may create unnecessary confusion and complexity.
There was a problem hiding this comment.
We do use the Rid in
And I expect this pattern to hold: We store a Rid and send it back.
We do not currently have a version that requires space directly at the upsert_concept call points, because the burden of computing the Rid from space+localId is currently on the platform (8 calls to
spaceUriAndLocalIdToRid in the Obsidian code base, many upstream of upsert_concept.)Having the space+localId variant in the contract will help centralize the Rid computation in the database package.
There was a problem hiding this comment.
Thanks, that confirms the { rid } variant is required.
I agree that centralizing the spaceUri + localId → RID normalization could be useful. What I’m trying to separate is centralizing the RID implementation—which already lives in @repo/database/lib/rid—from expanding the shared relation contract to accept another representation of the same identity.
The existing Obsidian call sites use RIDs for several platform-level purposes, including imported provenance, duplicate detection, previews, and endpoint lookup. Because of that, moving normalization into the upsert converter would not replace all eight call sites.
This rationale also seems to support, at most, a { localId, spaceUri } input. I don’t see the same justification yet for the top-level { dbId }, { localId, space: { dbId } }, or the sourceApp property. The current converter does not use sourceApp, and its space.dbId branch is explicitly unresolved.
I’d prefer to keep the shared endpoint contract as LocalRef | RidRef for now:
type RelationEndpointRef =
| { localId: string }
| { rid: string };This gives the shared boundary one canonical representation for remote identity: an RID. A platform that naturally has spaceUri + localId can normalize it before constructing the contract.
If an upcoming Roam or Obsidian producer genuinely benefits from emitting { localId, spaceUri }, we can add that form alongside the producer and a test demonstrating its normalization to the expected RID.
ENG-1863: Define cross-app relation contract and fixtures
https://www.loom.com/share/f29f528856dc427da89cf87fc22b4993