Repository navigation
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. |
Concept.last_modified and Content.last_modified are NOT NULL, so an item the contract accepts without modifiedAt failed in upsert_concepts. An item never modified was last modified when it was created.
…reatedAt Only an item with createdAt and no modifiedAt should change. Roam's publish tests mock relations and triples with neither date, and those threw.
…ee-890-crossapp-upsert-steps
…ee-890-crossapp-upsert-steps
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| const related = byId.get(id); | ||
| if (related !== undefined && !processed.has(id)) | ||
| stack.push(enter(related)); |
There was a problem hiding this comment.
🟡 Same-space RID dependencies written too late
When a slot references a later new item by same-space RID, orderByDependency leaves the referring item first. byId contains only local IDs, so the RID never matches. The referring item fails despite its dependency being included in the upsert.
Learn more
The ordering helper indexes entries by local ID but compares reference strings without resolving RIDs. parseUpsertData accepts RIDs in slots and triple endpoints. The database reference resolver resolves those RIDs to stored concepts, not pending input entries. An unresolved scalar reference produces a NULL reference value in _local_concept_to_db_concept, causing the row to fail before its dependency is inserted. This affects node slots, schema slots, and triple endpoints when their referenced entry comes later.
Example: In an initially empty space, send nodes evidence-1 followed by source-1, with the first node's source slot set to https://roamresearch.com/#/app/graph-a/source-1. Ordering returns evidence-1, source-1; replacing the RID with source-1 correctly returns source-1, evidence-1. With the RID, the first node fails although the request contains its source.
Recommended fix: Supply the target space URL to dependency ordering and normalize same-space RID references to their local IDs before looking up entries. Preserve cross-space RIDs as external dependencies. Add ordering tests for same-space RID references with and without an explicit RID on the referenced item.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85223e99e8
ℹ️ 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 schemaIds = new Set([ | ||
| ...relationTypeIds, | ||
| ...(data.nodeSchemas ?? []).map((s) => s.localId), | ||
| ...(data.relationTripleSchemas ?? []).map((s) => s.localId), | ||
| ]); |
There was a problem hiding this comment.
Validate schema references against their expected kind
When a node's nodeType matches a relationTypeSchemas entry, this set treats the ID as a valid schema reference regardless of kind. schemaReferences then omits it, so findMissingSchemas cannot reject it and toOrderedEntries writes the wrong schema ID into the node's schema_id, persisting an invalid graph. Track the expected schema kind for each reference and reject mismatches.
Useful? React with 👍 / 👎.
| if ( | ||
| item.rid !== undefined && | ||
| ridToSpaceUriAndLocalId(item.rid).spaceUri !== spaceUrl |
There was a problem hiding this comment.
Reject or preserve RIDs on inline content
If content.direct, directAndDescription, or full includes its own rid—permitted by the inline content validator—this check validates only the top-level item's rid. inlineCrossAppContentToDbContent does not map the nested RID to space_url, so the upsert stores that content in the enclosing node's space instead of the space it declares. Reject nested RIDs until supported, or preserve their space when converting.
Useful? React with 👍 / 👎.
Reviewer brief
FEE-890 adds one route that takes the five root CrossApp types for a space and writes them with one
upsert_conceptscall. It ships as two PRs, stacked on #1619 (ENG-2005, the validators):packages/databaseonly: the request type and its validator, and the pure steps the route runs.apps/website, its unit tests and the bearer-token client. It is the only caller of this PR's exports.Why two and not one: together they are 527 changed lines excluding tests (386 here, 141 in #1622). The split follows the package boundary: shared code first, then the route that uses it.
packages/database/src/lib/crossAppUpsert.tsholds the steps, each a pure function with unit tests:parseUpsertDatachecks the body with the ENG-2005 validators and returns{ success: false, issues: [{ path, message }] }on failure.schemaReferencesandfindMissingSchemasfind the schemas the body references but does not contain.toOrderedEntriesconverts the items and puts each one after the items it depends on.mapUpsertResultsmaps the row idsupsert_conceptsreturns back to local ids.-1means any unique violation, a name or a Content clash, so its reason isunique_conflict;-2iserror.publishNodesToGroups.ts:391-409), so refusing every incomplete body would make each publish resend all schemas. Marc-Antoine asked for the lookup on FEE-890 (2026-10-23). Michael asked to reject instead on #1237, then approved building on the defaults (FEE-890, 2026-11-05).ridmust name the space the route writes to._local_concept_to_db_concepttakes the space from theridover the one the route passes, so an item with another space'sridwould be written there. RIDs used as references (a relation's ends, a slot value) are not checked.metadataon schemas andassetson nodes are refused, because no converter writes them and accepting them would drop them without notice.UNWRITTEN_FIELDSlists them; removing an entry accepts that field again.scaleother thandocumentis refused.upsert_conceptsstores every inline content as a document (itscontent_as_documentdefault), so another scale would be changed without notice. No current caller sends another scale.nodeTypeor a relation'srelationTypewritten as a RID is refused.upsert_conceptswould store such a row with a NULLschema_idand no error when the RID names nothing, and the schema check looks up local ids only. A RID in a slot value or a triple end is still accepted: unresolved, it fails its row witherror. A triple'srelationwritten as a RID is looked up like a local id and gets 422 when missing. No current caller sends a RID type.localIdis refused by the validators.upsert_conceptsturns an emptysource_local_idinto NULL, so the upsert never matches an existing row and every call would insert a new one.modifiedAtis written withlast_modifiedequal to itscreatedAt.modifiedAtis optional in the contract, butConcept.last_modifiedis NOT NULL, so such an item got HTTP 200 and was not stored. A live run of the route found this. Existing callers always setmodifiedAt, so their output is unchanged. An update should carrymodifiedAt: without it, the row'slast_modifiedgoes back tocreatedAt, and Obsidian readslast_modifiedto detect changes.conceptConversion.tsare untouched and still recurse. They go when the apps move onto the route; those tickets don't exist yet.schema_id, and those nodes count as upserted.ridis not compared with itslocalId.ridinside a node's inline content is accepted and not written.openai_text_embedding_3_small_1536with 1,536 values) is accepted, dropped byupsert_contentwith a warning, and reported as upserted. Whether the route covers embeddings is FEE-890's open decision 5.failedwitherrorand nothing is stored for them; when one already exists, both are written (read from the SQL, not run).Verification
pnpm ci:validatepasses: check-types 8/8 tasks, test:unit 6/6 tasks (database: 217 tests).ridcheck, the unwritten-field check, the union flattening, theRangeErrorcatch, the ordering or the result mapping each fails a test. On the previous head, the tests for RID types, a 10,000-node chain andunique_conflicteach fail.Loom video
fee-890-terminal-v2-proof.mp4
One video covers both FEE-890 PRs.
Setup: a local build of #1622's branch at
37a4277b. Later commits refuse a non-documentscale, answer 502 for an auth server error, refuse dates outside years 1 to 9999 and RID types, order entries with an explicit stack, renamename_conflicttounique_conflictand bound the schema lookup; unit tests cover those, not the video. The route ran undernext devfrom the PR worktree, against an isolated local Supabase stack started from this branch's migrations, with edge functions served socreate-spacecould make two new spaces. Every call is curl, and every case reads Postgres back on screen.modifiedAt. The cited node is written before the node citing it, nodes and the relation have their schema, and the triple carries the relation type's label and complement.last_modifiedequals itscreated.modifiedAtupdates the same row, and itslast_modifiedmoves forward. No new row is added.ridnames another space, and a node withassetseach get 400 naming the field. Nothing is written.failedasname_conflict(nowunique_conflict), while the other node in the call is written.Scope check
$scope-checkagainst FEE-890 and the final diff.Done When: Refusing schemametadata, nodeassets, a non-documentscaleand RID node or relation types is narrower than "all aspects of upserting"; the Reviewer brief gives the reasons. Whether FEE-890 ships without these is open with sid; noDecision:comment on FEE-890 records it yet.Standards check
$dg-pr-adherence-checkagainst the final diff and PR metadata.Local delegated full review
$dg-delegated-full-reviewwhen no other full-review workflow is available.DiscourseGraphs/review-labat01b07f3) on85223e99: one P3 finding (F5), listed under Risk; nothing blocks review. Review Lab page