Skip to content

docs: record that a bare read fetches scalars, not relations (#848) - #849

Merged
borisno2 merged 1 commit into
mainfrom
claude/triage-848-hqj43p
Jul 31, 2026
Merged

docs: record that a bare read fetches scalars, not relations (#848)#849
borisno2 merged 1 commit into
mainfrom
claude/triage-848-hqj43p

Conversation

@borisno2

Copy link
Copy Markdown
Member

Docs-only. Records the decision reached while triaging #848, ahead of the implementation.

The decision

A context.db read with no include (and no fragment query) returns the row's own columns plus its virtual fields, and no relations — matching Prisma. Relations come back only when a caller names them.

Uniform across findUnique, findMany and singleton reads, sudo and non-sudo. No opt-in and no back-compat flag. Ships as a minor, following the precedent of #844 and ADR-0022.

Why it needed an ADR

The current default is deliberate and ADR-adjacent, so a future reader would otherwise reasonably "fix" the flip back. Two findings from triage drove it:

  • A sudo bare read already returns scalars only. The sudo branch passes the caller's include through, and on a bare read there isn't one — so the same call returns a five-level tree on a session context and a flat row under sudo. The singleton read is a third shape again, auto-including unconditionally with no caller-include plumbing at all. The default was a property of one branch of the read API, not of the API.
  • The admin UI no longer depends on it. Both the list view and the item view build explicit includes today, so the Item-label convenience the default existed for has expired. The one first-party consumer still relying on a bare read is the MCP query tool, where a five-deep tree is actively harmful.

The behaviour was verified against a mocked Prisma before any of this was written: a bare findUnique emits a nested relation tree, include: {} emits {}, and the reporter's virtual-field cycle reproduces as ResolveOutputCycleError: User.name → User.name from an ordinary read with no include.

Changes

  • docs/adr/0024-a-read-with-no-include-fetches-scalars-not-relations.md — the decision, five rejected alternatives, and the consequences.
  • CONTEXT.md — a Bare read glossary entry, and a note on Access Filter that it scopes the relations a read asked for rather than choosing them.

Notes for review

The consequence worth arguing with is the first one: this break is silent. A read that returned post.author now returns no author key — no error, just less data — which is the opposite of ADR-0022's breakage. The ADR commits the changeset and migration note to leading with detection (grep for context.db.*.find* calls with no include, and virtual resolveOutput hooks reading item.<relation>) rather than with rationale.

ADR-0022 and ADR-0023 both stand. Neither said anything about what a read with no include should fetch, which is the gap this fills.

No package code changed, so no changeset. Implementation is tracked on #848 (ready-for-agent), with follow-ups for virtual({ needs: [...] }), an include argument on MCP tools, and making the access-scoped walk caller-directed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PifFTifspW7ud4ptUGK4Mx


Generated by Claude Code

Records the decision from triage of #848: a `context.db` read with no
`include` (and no fragment `query`) returns the row's own columns plus
its virtual fields, never its relations — matching Prisma.

Adds ADR-0024 with the rejected alternatives (keep-and-document, an
opt-out flag, the resolveOutput-only fix, folding in the caller-directed
walk, holding for 1.0) and the consequences, chiefly that this break is
silent for affected code and so leads with detection rather than
rationale.

Adds a "Bare read" glossary entry and notes on Access Filter that it
scopes the relations a read asked for rather than choosing them.

Docs only — no package code changes, so no changeset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PifFTifspW7ud4ptUGK4Mx
@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7aa14fa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
stack-docs Ready Ready Preview Jul 31, 2026 11:05pm

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for Core Package Coverage (./packages/core)

Status Category Percentage Covered / Total
🟢 Lines 92.96% (🎯 65%) 1189 / 1279
🟢 Statements 91.51% (🎯 65%) 1273 / 1391
🟢 Functions 98.03% (🎯 62%) 200 / 204
🟢 Branches 82.43% (🎯 50%) 845 / 1025
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for UI Package Coverage (./packages/ui)

Status Category Percentage Covered / Total
🔵 Lines 76.72% 244 / 318
🔵 Statements 76.29% 251 / 329
🔵 Functions 69.15% 74 / 107
🔵 Branches 64.25% 160 / 249
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for CLI Package Coverage (./packages/cli)

Status Category Percentage Covered / Total
🔵 Lines 79.4% 1496 / 1884
🔵 Statements 79.1% 1556 / 1967
🔵 Functions 86.19% 206 / 239
🔵 Branches 67.31% 655 / 973
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for Auth Package Coverage (./packages/auth)

Status Category Percentage Covered / Total
🔵 Lines 97.45% 115 / 118
🔵 Statements 97.52% 118 / 121
🔵 Functions 100% 38 / 38
🔵 Branches 92.85% 78 / 84
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for Storage Package Coverage (./packages/storage)

Status Category Percentage Covered / Total
🔵 Lines 78.57% 220 / 280
🔵 Statements 80.06% 245 / 306
🔵 Functions 86.07% 68 / 79
🔵 Branches 75.88% 214 / 282
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for RAG Package Coverage (./packages/rag)

Status Category Percentage Covered / Total
🔵 Lines 47.97% 355 / 740
🔵 Statements 48.14% 377 / 783
🔵 Functions 54.26% 70 / 129
🔵 Branches 42.55% 180 / 423
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)

Status Category Percentage Covered / Total
🔵 Lines 100% 40 / 40
🔵 Statements 100% 40 / 40
🔵 Functions 100% 9 / 9
🔵 Branches 100% 19 / 19
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)

Status Category Percentage Covered / Total
🔵 Lines 100% 68 / 68
🔵 Statements 100% 71 / 71
🔵 Functions 100% 15 / 15
🔵 Branches 97.87% 46 / 47
File CoverageNo changed files found.
Generated in workflow #1563 for commit 7aa14fa by the Vitest Coverage Report Action

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