Skip to content

ENG-2005 Zod validators for the cross-app types - #1619

Open
sid597 wants to merge 6 commits into
mainfrom
eng-2005-zod-validators-for-the-cross-app-types
Open

sid597 wants to merge 6 commits into
mainfrom
eng-2005-zod-validators-for-the-cross-app-types

Conversation

@sid597

@sid597 sid597 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewer brief

  • Result: packages/database/src/crossAppValidators.ts holds one Zod validator for each of the five root CrossApp types. Nothing calls them yet. The upsert route (FEE-890) is stacked on this PR and checks its request body with them, importing the file by relative path, so the package exports no new path.
  • Review focus: Unknown keys are refused, not stripped, so a misspelled optional key fails validation instead of being dropped before the write. The cost: removing or renaming a contract field later refuses plugin versions that still send it.
  • Review focus: Dates must be ISO 8601 strings with an offset (Z, +hh:mm or +hhmm). They parse to Date, so validated output is the contract type the converters take. An offset Date can't read, such as +24:00, is refused. So is a date whose UTC year is outside 1 to 9999: Postgres can't read the string toISOString writes for it, and one such row fails the whole upsert_concepts call.
  • Review focus: A rid must pass isRid. Other ids and the content hash are checked only as strings.
  • Review focus: The type test in crossAppValidators.test.ts fails tsc when a validator's output and its contract type differ in either direction, including an optional key, at the root or in slots, assets or metadata. It does not compare inside the content variants (direct, directAndDescription, full), so a difference there passes tsc.
  • Risk or follow-up: A string holding U+0000 or a lone UTF-16 surrogate passes the validators. Postgres refuses it in jsonb, so one such item fails the whole upsert_concepts call. Roam and Obsidian already call upsert_concepts directly with the same exposure.
  • Risk or follow-up: Three things for the route to handle, found in review and not changed here. safeParse throws on metadata nested about 1,300 to 1,600 levels deep instead of returning a failure. A triple schema with a missing field reports its error at the root path. Roam's relation and triple converters can produce modifiedAt: null, which these validators refuse. That matters when Roam moves onto the route, which has no ticket yet.

Verification

  • pnpm ci:validate passes: check-types 8/8 tasks, test:unit 6/6 tasks.
  • Removing templateTitle from the node schema validator, or adding a colour key to the relation validator, fails tsc.

Loom video

eng-2005-terminal-proof.mp4

Setup: a terminal in this PR's worktree at aca0e5a. Later commits fix review findings: the offset and year checks on dates, which unit tests cover, and removing the unused package export. The video doesn't show them. A small script kept outside the repo feeds JSON bodies to the validators. No app and no database are involved, because nothing calls the validators yet.

  • 0:01 A conforming body for each of the five root types is accepted, and its dates come back as Date values.
  • 0:11 Bodies that break the contract are refused with the field named: a missing field, a misspelled key, a date without an offset, a rid that is not a RID, and a bad nested content type.
  • 0:22 Changing a validator so it no longer matches its contract type fails the type check. Restoring the file leaves the worktree clean.
  • 0:43 No app imports the new module, and pnpm ci:validate passes on the branch.

Scope check

  • Ran $scope-check against ENG-2005 and the final diff.
  • Scope beyond Done When: Unknown keys are refused, not stripped, which the contract types don't require; maparent decides (see Review focus). The zod dependency in @repo/database, the date checks (an offset, a valid date, a UTC year from 1 to 9999) and the isRid check support the validators.

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.
  • Ran Review Lab (DiscourseGraphs/review-lab at 01b07f3) on 1a5f004d: two P3 findings (B1, B2), both listed above; nothing blocks review. Review Lab page

Use the ^3.24.1 range apps/website declares, which the lockfile already resolves to zod 3.25.76.
Validators for node schemas, relation type schemas, relation triple schemas, nodes and relations parse JSON into the contract types, refusing unknown keys and ISO dates without an offset. A type test fails tsc when a validator's output drifts from its contract type.
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
discourse-graph Ready Ready Preview Nov 16, 2026 5:54am UTC

Request Review

@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown

ENG-2005

@supabase

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

@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-16T04:00:17.157718Z aca0e5a 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 found 1 potential issue.

Devin 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: aca0e5a942

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

This branch was successfully deployed

1 active deployment
Preview — 1a5f004d 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