Skip to content

ENG-1865 Publish Roam stored relations for shared nodes - #1221

Open
maparent wants to merge 2 commits into
eng-2068-sync-and-publish-node-schemas-while-publishing-nodesfrom
eng-1865-publish-roam-stored-relations-for-shared-nodes
Open

ENG-1865 Publish Roam stored relations for shared nodes#1221
maparent wants to merge 2 commits into
eng-2068-sync-and-publish-node-schemas-while-publishing-nodesfrom
eng-1865-publish-roam-stored-relations-for-shared-nodes

Conversation

@maparent

@maparent maparent commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

https://linear.app/discourse-graphs/issue/ENG-1865/publish-roam-stored-relations-for-shared-nodes

PR walkthrough:
https://www.loom.com/share/c8a96f0cdbc74dcf8fada181ca2f7144

Note: In the loom, I mention a bit of code waiting for 1856. That got merged, and I did make the adjustments accordingly, so disregard that.

Demo:
https://www.loom.com/share/2d93fd0570784f2eb25fac7c514911a3

@linear-code

linear-code Bot commented Jul 11, 2026

Copy link
Copy Markdown

ENG-1865

@supabase

supabase Bot commented Jul 11, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
discourse-graph Skipped Skipped Jul 27, 2026 4:00pm

Request Review

@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from df8bd66 to 7e9a33d Compare July 11, 2026 13:26
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 7e9a33d to e15e0eb Compare July 13, 2026 04:01
@maparent
maparent marked this pull request as ready for review July 13, 2026 14:44
devin-ai-integration[bot]

This comment was marked as resolved.

graphite-app[bot]

This comment was marked as resolved.

@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from e15e0eb to 9e93709 Compare July 13, 2026 14:53
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 9e93709 to 123104f Compare July 13, 2026 15:04
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 123104f to ae3123f Compare July 13, 2026 15:29
Comment thread packages/database/src/inputTypes.ts
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from ae3123f to f71e309 Compare July 13, 2026 15:51
@maparent
maparent marked this pull request as draft July 13, 2026 19:51
@maparent
maparent force-pushed the eng-2017-add-converter-for-crossapp-schemas-to-localconceptdatainput branch from c2ee00a to 1127f9a Compare July 15, 2026 18:49
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from f71e309 to a96cd20 Compare July 15, 2026 19:06
@maparent
maparent changed the base branch from eng-2017-add-converter-for-crossapp-schemas-to-localconceptdatainput to eng-2018-add-converter-for-crossapprelation-schema-to July 15, 2026 19:07
@maparent
maparent marked this pull request as ready for review July 15, 2026 19:08

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread apps/roam/src/utils/publishNodesToGroups.ts Outdated
Comment thread apps/roam/src/utils/publishNodesToGroups.ts Outdated
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from a96cd20 to af01ede Compare July 15, 2026 19:14
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from af01ede to abacebf Compare July 15, 2026 19:55
@maparent
maparent force-pushed the eng-2049-refactor-publishnodestogroup-to-use-the-crossappnodeschema branch 2 times, most recently from 51ca3bc to dc87ee0 Compare July 23, 2026 21:01
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from a9b80ec to fdd0a3d Compare July 23, 2026 21:52
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from fdd0a3d to 17a85f8 Compare July 23, 2026 22:03
Base automatically changed from eng-2049-refactor-publishnodestogroup-to-use-the-crossappnodeschema to main July 24, 2026 16:09
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch 2 times, most recently from dbb1311 to 3af849e Compare July 24, 2026 16:11
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 3af849e to 4df42a3 Compare July 24, 2026 16:14
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 4df42a3 to 5b550bd Compare July 25, 2026 02:27
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 5b550bd to 9dcd771 Compare July 25, 2026 02:54
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 9dcd771 to 126f6f0 Compare July 25, 2026 15:34
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 126f6f0 to 3d55378 Compare July 25, 2026 15:36
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 3d55378 to 9f6663d Compare July 25, 2026 16:04
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 9f6663d to 6ab0a38 Compare July 26, 2026 20:44
@maparent
maparent force-pushed the eng-1865-publish-roam-stored-relations-for-shared-nodes branch from 6ab0a38 to ff86870 Compare July 26, 2026 22:28

Copy link
Copy Markdown
Member

@codex review

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

Copy link
Copy Markdown

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: 476c18f5eb

ℹ️ 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".

const sourceId =
sourceSpaceUri === undefined
? r.sourceUid
: spaceUriAndLocalIdToRid(sourceSpaceUri, r.sourceUid);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the imported endpoint's original RID

When a relation endpoint is an imported node, readImportedSourceIdentity already provides its canonical sourceNodeRid, but this conversion keeps only the space URI and combines it with the local Roam page UID. For example, an imported .../node-1 stored on page-uid becomes .../page-uid, so the database cannot resolve the relation to the remote concept. Return the stored RID directly, or reconstruct it with the parsed source local ID.

Useful? React with 👍 / 👎.

Comment on lines +159 to +164
(publishedIds.has(r.sourceUid) ||
(forNodeIds ? forNodeIds.has(r.sourceUid) : false) ||
groupSpaceIds.has(isImportedFrom(r.sourceUid) || 0)) &&
(publishedIds.has(r.destinationUid) ||
(forNodeIds ? forNodeIds.has(r.destinationUid) : false) ||
groupSpaceIds.has(isImportedFrom(r.destinationUid) || 0)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude unsynced selected nodes from relation eligibility

When a selected node has not synced yet, this condition still treats it as an available relation endpoint via forNodeIds. The later syncedUids intersection removes that node from the published node accesses, but the already-gathered relation is still upserted and granted, leaving it with an unresolved local endpoint. Relation gathering should use only the selected node IDs confirmed by my_concepts, or otherwise discard relations touching skipped nodes.

Useful? React with 👍 / 👎.

Comment on lines +332 to +335
const groupResourceIds = [
...resourceIds,
...groupRelationIds,
...groupRelationTripleSchemaIds,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Grant access only to relations that survived validation

If a stored relation references a deleted schema, or its converter returns null, it is removed from the returned relations array but remains in relevantRelationIdsPerGroupId. Spreading the unfiltered IDs here therefore inserts a ResourceAccess row for a concept that was never upserted; this table has no resource foreign key, so the orphan persists. Intersect these IDs with the successfully converted relations before creating access rows.

Useful? React with 👍 / 👎.

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.

2 participants