Skip to content

fix(orm): let union sources anchor their own index range - #394

Merged
zbeyens merged 4 commits into
mainfrom
fix/union-sources-index-anchoring
Aug 21, 2026
Merged

zbeyens merged 4 commits into
mainfrom
fix/union-sources-index-anchoring

Conversation

@MikeyZhang75

@MikeyZhang75 MikeyZhang75 commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator
  • Auto release

🐛 Fixes #385
🧭 Task plan: docs/plans/385-index-anchored-union-sources.md
🟢 95-100% confidence

Phase 🧪 Tests 🌐 Browser
Reproduced 🔴 Per-source index anchors rejected by types and unavailable at runtime ➖ N/A
Verified 🟢 32 focused ORM tests, type assertions, bun check ➖ N/A

✅ Outcome

  • Each select().union(...) source can declare its own index: { name, range } anchor.
  • Sources walk their own index ranges before filtering instead of re-reading a shared range.
  • Sources may use different indexes when they share the ordering suffix passed to interleaveBy.

⚠️ Caveat

  • A source index overrides the chain-level .withIndex(...); sources without one retain the chain index.
  • interleaveBy fields must remain a trailing ordered suffix after each source range pins its leading index fields.

🏗️ Design

  • FindManyUnionSource owns per-source index intent using the existing typed index-range configuration.
  • _buildUnionSourceStream resolves source.index ?? configuredIndex before building and validating each stream.
  • Public docs and the published kitcn skill use the same per-source anchor contract.

🧪 Verified

  • 32 focused ORM tests pass with no type errors, covering read bounds, heterogeneous indexes, override precedence, and fallback.
  • bun check passes, including lint, typecheck, tests, fixture parity, verification, and runtime scenarios.
  • Published skill source and installed mirror are byte-identical; Intent validation and stale checks pass.
  • P1 autoreview is clean at 0.90 confidence.

Fixes #385.

`FindManyUnionSource` had only `where`, so the documented per-source
`index: { name, range }` failed with TS2353. Deeper: without an anchor the
source fell back to `by_creation_time`, so `interleaveBy` on any other field
threw. Add `index?: PredicateWhereIndexConfig` and resolve each source on
`source.index ?? chain withIndex`.

Also fixes the reverse docs defect: the shared-`withIndex` + per-source-`where`
union example in api-reference, filters, and the kitcn skill throws at runtime,
since a rangeless `withIndex` pins no equality fields and `OrderByStream` then
rejects a shorter `interleaveBy`. Rewrote all three to per-source anchors.

Plan: docs/plans/385-index-anchored-union-sources.md
@changeset-bot

changeset-bot Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4a2c113

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
kitcn Patch
@kitcn/resend Patch

Not sure what this means? Click here to learn what changesets are.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@vercel

vercel Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
better-convex Ready Ready Preview Aug 21, 2026 7:03pm

Request Review

@zbeyens

zbeyens commented Aug 21, 2026

Copy link
Copy Markdown
Member

Autoclosure receipt

  • Exact head: 4a2c1131763c007c4d5c24647f5c54a97837acd5; local = fetched PR ref = live GitHub head.
  • Local proof: 32 focused ORM tests pass with no type errors; bun check passes, including fixture parity and runtime scenarios.
  • Agent proof: published skill source and installed mirror are byte-identical; Intent validation and stale checks pass.
  • Hosted proof: CI passed; Vercel deployment passed.
  • Feedback audit: zero reviews, zero review threads, zero unresolved threads, zero actionable P1 findings.
  • Changeset bot: informational; changeset detected for the exact head.
  • Codex quota notice: informational; independent P1 autoreview is clean at 0.90 confidence.
  • Vercel comment: informational; deployment completed successfully.

No P1 feedback remains. Ready to merge.

This branch was successfully deployed

1 active deployment
Preview — 4a2c1131 Deployed Aug 21, 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.

Docs: union sources document a per-source index: key that FindManyUnionSource does not have (TS2353)

2 participants