Skip to content

eng-255#353

Merged
Connorbelez merged 3 commits intomainfrom
eng-255
Mar 30, 2026
Merged

eng-255#353
Connorbelez merged 3 commits intomainfrom
eng-255

Conversation

@Connorbelez
Copy link
Copy Markdown
Owner

@Connorbelez Connorbelez commented Mar 30, 2026

eng-252

Merge branch 'main' into eng-255

eng-255

Summary by CodeRabbit

  • New Features

    • System objects can be queried natively and returned as unified records with field mappings and pagination controls.
  • Bug Fixes

    • Replaced several “not yet implemented” errors with functional query behavior.
    • System-object search now returns empty results instead of throwing.
    • Improved error message when fetching single system records to direct users to querying.
  • Documentation

    • Added spec and task docs describing adapter architecture and integration steps.

@linear
Copy link
Copy Markdown

linear bot commented Mar 30, 2026

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Connorbelez, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Connorbelez Connorbelez changed the title eng-252 eng-255 Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Introduces system adapter infrastructure and integrates it into record handlers: adds resolveColumnPath, queryNativeTable, and queryNativeRecords to project native Convex tables into UnifiedRecord[], and wires queryRecords/getRecord/searchRecords to use the native fast path for system objects.

Changes

Cohort / File(s) Summary
System Adapter - Query Routing
convex/crm/systemAdapters/queryAdapter.ts
Adds queryNativeTable() with switch-based, org-scoped routing across six native tables and queryNativeRecords() to map native docs to UnifiedRecord[], stringifying native _id and deriving timestamps.
System Adapter - Column Resolution
convex/crm/systemAdapters/columnResolver.ts
Adds resolveColumnPath(nativeDoc, fieldDef) that safely resolves dot-delimited nativeColumnPath, returns undefined for missing/unresolvable paths, and coerces date/datetime strings to unix milliseconds.
Query Handler Integration
convex/crm/recordQueries.ts
Wires system-object fast path: queryRecords delegates to queryNativeRecords when objectDef.isSystem && nativeTable; validates pagination and applies in-memory filters/sort; getRecord now throws a clearer unsupported-for-system-objects error; searchRecords returns empty array for system objects.
Specs & Tasks
specs/ENG-255/*
Adds ENG-255 chunk manifest, adapter infra and integration context, and task lists documenting design constraints (switch-based routing, by_org indexing, supported native tables, and adapter responsibilities).

Sequence Diagram

sequenceDiagram
    participant Client as Client Code
    participant QR as recordQueries.queryRecords()
    participant QNR as queryNativeRecords()
    participant QNT as queryNativeTable()
    participant DB as Native DB Tables
    participant RCP as resolveColumnPath()

    Client->>QR: queryRecords(objectDef, pagination...)
    QR->>QNR: isSystem && nativeTable -> queryNativeRecords(...)
    QNR->>QNT: queryNativeTable(tableName, orgId, limit)
    QNT->>DB: ctx.db.query(...).eq("orgId", orgId).take(limit)
    DB-->>QNT: Raw documents
    QNT-->>QNR: documents[]
    QNR->>RCP: resolveColumnPath(doc, fieldDef) for each mapped field
    RCP-->>QNR: resolved values
    QNR-->>QR: UnifiedRecord[]
    QR-->>Client: { records: UnifiedRecord[], continueCursor: null, isDone: true, truncated: false }
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • eng-251 #351: Modifies the same recordQueries handlers to replace ENG-255 stubs with native-table fast-path logic; closely related at code-level.

Poem

🐰 With whiskers twitching, adapters unfold,
Native tables mapped into records bold,
Dotted paths resolved, dates turned to time,
Fast-path queries hum a tidy rhyme,
Hop—unified records, neat and fine!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The pull request title 'eng-255' is a ticket identifier only, providing no meaningful information about the actual changes made in the pull request. Revise the title to describe the primary change, such as 'Add system adapter infrastructure for native table queries' or 'Implement system object query support via native adapters'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch eng-255

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Connorbelez Connorbelez marked this pull request as ready for review March 30, 2026 14:22
Copilot AI review requested due to automatic review settings March 30, 2026 14:22
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Convex CRM module by adding view definition CRUD + child-entity operations (ENG-252) and introducing system-adapter infrastructure to query native tables through the existing UnifiedRecord shape (ENG-255), including wiring native querying into recordQueries.

Changes:

  • Added CRM view CRUD (viewDefs) plus child entity handlers (viewFields, viewFilters, viewKanbanGroups) with org-scoping + audit logging.
  • Added system-adapter utilities (columnResolver, queryAdapter) and integrated native querying into recordQueries for system objects.
  • Added ENG-252 / ENG-255 spec/task breakdown documentation.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
convex/crm/recordQueries.ts Routes system objects to native adapter querying; adjusts system behavior for getRecord/searchRecords.
convex/crm/systemAdapters/columnResolver.ts Resolves mapped native column paths (including nested paths + date coercion).
convex/crm/systemAdapters/queryAdapter.ts Switch-based native table querying and assembly into UnifiedRecord[].
convex/crm/filterOperatorValidation.ts Adds a FieldType → valid-operators mapping and validation helper for filters.
convex/crm/viewDefs.ts Implements create/update/delete/duplicate/list/get for view definitions with capability validation and kanban group auto-creation.
convex/crm/viewFields.ts Implements visibility toggling (create-if-missing), reorder, width setting, and listing for view fields.
convex/crm/viewFilters.ts Implements filter CRUD with operator-vs-fieldType validation.
convex/crm/viewKanbanGroups.ts Implements kanban group reorder, collapse toggle, and list operations.
specs/ENG-255/** ENG-255 task planning and chunk manifests/contexts for adapter + integration work.
specs/ENG-252/** ENG-252 task planning, chunk manifests/contexts, and a type design review doc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread convex/crm/viewFields.ts
Comment thread convex/crm/viewFields.ts
Comment thread convex/crm/viewKanbanGroups.ts
Comment thread convex/crm/filterOperatorValidation.ts Outdated
Comment thread convex/crm/viewDefs.ts Outdated
Comment thread convex/crm/recordQueries.ts Outdated
Comment thread convex/crm/recordQueries.ts Outdated
Comment thread convex/crm/recordQueries.ts Outdated
…able check, filter/sort handling, and page size validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@convex/crm/recordQueries.ts`:
- Around line 335-349: The system-object native shortcut in queryRecords (branch
checking objectDef.isSystem and using queryNativeRecords) ignores args.filters,
args.sort, and args.paginationOpts.cursor/continuation and always returns
isDone:true/truncated:false; fix by either: (A) piping the nativeRecords result
into the same filtering, sorting and pagination/continuation logic used by the
EAV path so filters/sort/cursor behave identically, preserving accurate
continueCursor/isDone/truncated semantics, or (B) defensively fail-fast: if
args.filters, args.sort, or args.paginationOpts.cursor are present (or if
objectDef.isSystem is true but objectDef.nativeTable is missing/misconfigured),
throw an error indicating native queries don’t support those options yet; update
the branch around queryNativeRecords and the objectDef.isSystem &&
objectDef.nativeTable check accordingly to ensure we don’t silently drop rows or
fall back to EAV for misconfigured system objects.

In `@specs/ENG-255/tasks.md`:
- Line 50: Update the task bullet that mentions implementing getRecord to
reflect the shipped scope: change the line "In `getRecord()`: Replace stub with
native record fetch..." to indicate that single-record native lookup is deferred
to ENG-256 (matching convex/crm/recordQueries.ts behavior and
specs/ENG-255/chunks/chunk-02-integration/context.md), and remove or mark as
resolved any TODO that claims getRecord currently throws for system calls;
ensure the task list no longer promises a native single-record implementation
for this ticket and instead references ENG-256 for that work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e2788ae-bf72-46dd-aa6f-8e366e1209e9

📥 Commits

Reviewing files that changed from the base of the PR and between f19570b and 3fd8449.

📒 Files selected for processing (9)
  • convex/crm/recordQueries.ts
  • convex/crm/systemAdapters/columnResolver.ts
  • convex/crm/systemAdapters/queryAdapter.ts
  • specs/ENG-255/chunks/chunk-01-adapter-infrastructure/context.md
  • specs/ENG-255/chunks/chunk-01-adapter-infrastructure/tasks.md
  • specs/ENG-255/chunks/chunk-02-integration/context.md
  • specs/ENG-255/chunks/chunk-02-integration/tasks.md
  • specs/ENG-255/chunks/manifest.md
  • specs/ENG-255/tasks.md

Comment thread convex/crm/recordQueries.ts Outdated
Comment thread specs/ENG-255/tasks.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
convex/crm/recordQueries.ts (1)

350-388: ⚠️ Potential issue | 🟠 Major

System-object pagination is still incomplete here.

queryNativeRecords(... clampedNumItems) still bounds the native scan before applyFilters() / applySort(), and this branch always returns isDone: true. That means matches and sort winners beyond the first raw slice are still invisible, and an unfiltered system table larger than numItems is still reported as complete. Please mirror path B’s FILTERED_QUERY_CAP + 1 scan + offset slicing here (or fail fast) so records, continueCursor, isDone, and truncated stay truthful.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@convex/crm/recordQueries.ts` around lines 350 - 388, The native-records
branch clamps the raw scan before filtering (using clampedNumItems and
queryNativeRecords) and always returns isDone: true, hiding matching records
beyond the first slice; change the logic to mirror path B by scanning for
FILTERED_QUERY_CAP + 1 raw rows (use FILTERED_QUERY_CAP constant, not
rawNumItems), then run applyFilters and applySort on the full scan result, slice
the sorted results to the caller's requested numItems, and set
continueCursor/isDone/truncated based on whether there were more than
FILTERED_QUERY_CAP matches (or alternatively fail fast if cursor-based
pagination is passed); update uses of queryNativeRecords, clampedNumItems,
applyFilters, applySort, continueCursor, isDone, and truncated accordingly so
the reported page and completion flags are truthful.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@convex/crm/recordQueries.ts`:
- Around line 628-631: In searchRecords (in recordQueries.ts) returning [] when
objectDef.isSystem hides the fact native search isn’t implemented; instead
either rethrow a ConvexError indicating “native search not implemented for
system objects” or implement an in-memory fallback that queries the native
adapter and filters by labelValue before returning results; update the branch
that currently does "if (objectDef.isSystem) { return [] }" to throw the
ConvexError (or call the native adapter search + filter) so callers can
distinguish unimplemented behavior from a genuine no-match result.

---

Duplicate comments:
In `@convex/crm/recordQueries.ts`:
- Around line 350-388: The native-records branch clamps the raw scan before
filtering (using clampedNumItems and queryNativeRecords) and always returns
isDone: true, hiding matching records beyond the first slice; change the logic
to mirror path B by scanning for FILTERED_QUERY_CAP + 1 raw rows (use
FILTERED_QUERY_CAP constant, not rawNumItems), then run applyFilters and
applySort on the full scan result, slice the sorted results to the caller's
requested numItems, and set continueCursor/isDone/truncated based on whether
there were more than FILTERED_QUERY_CAP matches (or alternatively fail fast if
cursor-based pagination is passed); update uses of queryNativeRecords,
clampedNumItems, applyFilters, applySort, continueCursor, isDone, and truncated
accordingly so the reported page and completion flags are truthful.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 418a7714-63c3-46eb-826f-aeb061c46ae3

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd8449 and d7c4892.

📒 Files selected for processing (2)
  • convex/crm/recordQueries.ts
  • specs/ENG-255/tasks.md

Comment thread convex/crm/recordQueries.ts
@Connorbelez Connorbelez merged commit a1fbb5f into main Mar 30, 2026
1 of 3 checks passed
Connorbelez added a commit that referenced this pull request Apr 20, 2026
eng-252

Merge branch 'main' into eng-255

eng-255

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * System objects can be queried natively and returned as unified records with field mappings and pagination controls.

* **Bug Fixes**
  * Replaced several “not yet implemented” errors with functional query behavior.
  * System-object search now returns empty results instead of throwing.
  * Improved error message when fetching single system records to direct users to querying.

* **Documentation**
  * Added spec and task docs describing adapter architecture and integration steps.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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