Skip to content

ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (4/6) - #1632

Open
sid597 wants to merge 2 commits into
eng-1986-send-obsidian-nodes-through-the-cross-app-convertersfrom
eng-1986-send-obsidian-relations-through-the-cross-app-converters
Open

sid597 wants to merge 2 commits into
eng-1986-send-obsidian-nodes-through-the-cross-app-convertersfrom
eng-1986-send-obsidian-relations-through-the-cross-app-converters

Conversation

@sid597

@sid597 sid597 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewer brief

ENG-1986 moves Obsidian sync off its own converters and onto the shared CrossApp converters, without loss of functionality. It ships as six PRs. PRs 1 to 4 and 6 are stacked on #1575 (ENG-1823). PR 5 targets main:

  1. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (1/6) #1620: tests that pin exactly what Obsidian sync sends to upsert_concepts today. No production change.
  2. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (2/6) #1630: node type, relation type and relation triple schemas go through the shared converters.
  3. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (3/6) #1631: nodes and their Content go through the shared converters.
  4. This PR. Relation instances go through the shared converters.
  5. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (5/6) #1634: color becomes a CrossApp field on node types and relation types, in packages/database. It doesn't depend on PRs 1 to 4.
  6. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (6/6) #1633: Obsidian sync sends color through the shared converters. It needs PR 5, and its branch carries PR 5's change until that merges.

Why six and not one: each step changes one kind of row, and #1620's tests show whether a stored value changed. PR 5 changes the shared contract, so it goes first in its own PR and needs its own review. Together the steps are well over the 400-line guideline.

  • Result: Obsidian sync builds relation instance rows with relationInstanceToCrossApp and the shared crossAppRelationToDbConcept. After this PR, every row Obsidian sync sends comes from a shared converter.
  • Result: No stored value changes, apart from the one edge case below. Relation rows no longer send space_id, is_schema: false or an empty literal_content, and author_id becomes author_local_id. upsert_concepts sets space_id from v_space_id, defaults the other two and resolves author_local_id to the same account. This comes from reading concept.sql. The unit tests mock the RPC.
  • Review focus: a relation that already carries a numeric authorId sends author_id and no author_local_id, because upsert_concepts lets author_local_id override author_id. Sync only sees such a relation when an accepted imported relation has no importedFromRid.
  • Review focus: name is set after the converter. The shared converter names a relation by local ids. Obsidian keeps [[source title]] -label-> [[destination title]], and CrossAppRelation has no name field.
  • Review focus: sourceDocumentIdOf in sourceSlot.ts is exported as referenceIdOf. A relation end uses it: the note's origin RID for an imported note, its nodeInstanceId otherwise.
  • Review focus: sync skips imported relations (syncDgNodesToSupabase.ts:876), so relation rows no longer carry an importedFromRid branch that could never run. ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (1/6) #1620 pins that an imported relation isn't sent.
  • Risk or follow-up: one edge case changes. When a note's frontmatter importedFromRid is not a string, a relation end now sends the note's local id. Before, the value was sent as it was and upsert_concepts failed the row. Read from the code, not run.
Before After Stored value
space_id, is_schema: false, literal_content: {} not sent same, set by upsert_concepts
author_id: authorId ?? context.userId author_id when the relation has one, else author_local_id same account
source_local_id, schema_represented_by_local_id, created, last_modified from the shared converter same
local_reference_content ends from the shared converter, through referenceIdOf same, except the edge case above
name set after the converter same

Verification

  • From apps/obsidian on this head: vitest run passes (260 tests), tsc --noEmit --skipLibCheck passes, and prettier is clean on the changed files.
  • Mutation check: making referenceIdOf always return the local id fails five tests, including "points a relation at an imported note by the note's origin RID, at either end".
  • eslint --max-warnings 0 on the changed files reports two warnings this PR didn't add, at syncDgNodesToSupabase.ts:1152 and :1157 (from [ENG-1178] Automatic local remote sync nodes relations #706).
  • Not run on this head: pnpm ci:validate for the whole repository, and a sync against a database.

Loom video

Not recorded yet.

Scope check

  • Ran $scope-check against ENG-1986 and the final diff.
  • Scope beyond Done When: A relation end on a note whose frontmatter importedFromRid is not a string sends the note's local id. Before, the row failed.
  • Required now: relation ends reuse the guarded referenceIdOf in place of two casts on untyped frontmatter.
  • Anyone affected or consulted: Not documented.
  • Decision: recorded on ENG-1986, 2026-11-16.

Standards check

  • Ran $dg-pr-adherence-check against the final diff and PR metadata.

Local delegated full review

  • Ran a comprehensive review of the entire final diff in a subagent with a fresh context. Use $dg-delegated-full-review when no other full-review workflow is available.

- relationInstanceToCrossApp takes each end's id from referenceIdOf
  (renamed from sourceDocumentIdOf and exported) instead of casting
  frontmatter.importedFromRid.
- Drop the importedFromRid spread for relation instances: sync skips
  imported relations before they reach relationInstanceToLocalConcept.
- Drop the author test that the pinned sync rows already cover, and
  rename the relation test helper so it no longer shadows conceptFor.
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
discourse-graph Skipped Skipped Nov 16, 2026 7:53am UTC

Request Review

@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

ENG-1986

@supabase

supabase Bot commented Nov 16, 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 ↗︎.

@sid597
sid597 added this pull request to stack #1624 November 16, 2026 08:00
@sid597
sid597 marked this pull request as ready for review November 16, 2026 08:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T08:03:43.953086Z dca6a1e Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch was previously deployed

1 inactive deployment
Preview — dca6a1ef Deployed Nov 16, 2026 by vercel[bot]
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.

1 participant