Skip to content

fix: core library fixes for Trigger.dev compatibility - #87

Merged
HrushiBorhade merged 2 commits into
mainfrom
phase-2/core-fixes
Mar 24, 2026
Merged

HrushiBorhade merged 2 commits into
mainfrom
phase-2/core-fixes

Conversation

@HrushiBorhade

@HrushiBorhade HrushiBorhade commented Mar 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Test plan

  • 133 core tests passing (132 existing + 1 new walker test)
  • Typecheck passes
  • Lint passes
  • Format check passes

Summary by CodeRabbit

  • New Features

    • Multi-tenant vector storage: optional repo-scoped search/delete and repo_id indexing.
    • Configurable file discovery to bypass git.
    • Optional deterministic point IDs on upsert; exported file-walker options type.
  • Bug Fixes

    • Improved configuration validation reporting (now throws an error instead of terminating process).
  • Chores

    • Removed dotenv dependency.
  • Documentation

    • Updated plan/spec docs for readability and formatting.
  • Tests

    • Added test for non-git file discovery and updated collection/indexing tests.

- Remove dotenv auto-load and process.exit from env.ts (#78)
- Add useGit option to walkFiles for non-git directories (#79)
- Extend store.ts for multi-tenant Qdrant: repo_id, content, deterministic IDs, filters, payload index (#80)
- Remove dotenv dependency from @codeindexer/core
- 133 tests passing
@vercel

vercel Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
code-indexer-web Ready Ready Preview, Comment Mar 24, 2026 8:54pm

@greptile-apps greptile-apps 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.

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

@coderabbitai

coderabbitai Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5a3edf2d-3956-4e4f-8919-8657ca1e2278

📥 Commits

Reviewing files that changed from the base of the PR and between 532701f and 4337196.

📒 Files selected for processing (1)
  • packages/core/src/lib/store.ts

📝 Walkthrough

Walkthrough

Removed dotenv auto-loading and process.exit from env.ts (now throws on validation); added a configurable useGit option to walkFiles() to support non-git directories; extended Qdrant store to support optional deterministic point IDs, repo_id payloads/filters, and creation of a repo_id payload index.

Changes

Cohort / File(s) Summary
Docs / Plans / Specs
docs/plans/2026-03-24-phase2-step3-core-fixes.md, docs/plans/2026-03-24-phase2-step3-index-repo.md, docs/specs/2026-03-24-phase2-step3-index-repo-design.md
Formatting and readability updates to markdown and code snippets; no behavioral changes.
Manifest / Dependencies
packages/core/package.json
Removed dotenv dependency.
Configuration / Env
packages/core/src/config/env.ts
Removed automatic .env loading; replaced process.exit(1) with throwing an Error on schema validation failures.
File Walker
packages/core/src/lib/walker.ts, packages/core/src/lib/walker.test.ts, packages/core/src/index.ts
Added exported WalkOptions with optional useGit; walkFiles() accepts options and falls back to fast-glob when git is disabled or fails; added test for useGit: false; exported type from package entrypoint.
Qdrant Multi-Tenancy / Store
packages/core/src/lib/store.ts, packages/core/src/lib/store.test.ts
Added optional repo_id and content to point payloads; allowed optional deterministic id for upserts (id ?? randomUUID()); created repo_id keyword payload index during collection setup; searchPoints() and deletePoints() accept optional repoId to filter operations; tests updated to assert index creation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 in a tidy burrow I hop and write:
No dotenv sneaks in, no abrupt goodnight,
Walkers now skip git when tarballs arrive,
Qdrant keeps tenants and IDs stay alive,
A tiny rabbit cheers the code's bright light. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change as core library fixes for Trigger.dev compatibility, directly reflecting the objectives of removing dotenv, adding useGit option, and extending store for multi-tenant support.
Linked Issues check ✅ Passed All three linked issues (#78, #79, #80) are fully addressed: dotenv removed and process.exit replaced with Error [#78], useGit option added to walkFiles with fallback to fast-glob [#79], and store.ts extended with repo_id, content, deterministic id, and repoId filtering [#80].
Out of Scope Changes check ✅ Passed All changes are directly aligned with the three linked issues; documentation and package.json updates support the core implementation changes without introducing unrelated functionality.

✏️ 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 phase-2/core-fixes

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (4)
packages/core/src/lib/walker.ts (1)

66-72: Consider whether dot: false intentionally excludes dotfiles.

With dot: false, fast-glob will skip dotfiles like .eslintrc, .prettierrc, and .github/ workflows. This may be intentional to match typical git ls-files behavior with standard .gitignore patterns, but it differs from what git ls-files would return for tracked dotfiles.

If dotfiles should be discoverable in non-git directories, consider changing to dot: true.

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

In `@packages/core/src/lib/walker.ts` around lines 66 - 72, The fast-glob call
that builds files (const files = await fg('**/*', { cwd: rootDir, ignore:
FALLBACK_IGNORE, dot: false, absolute: false })) currently sets dot: false which
excludes dotfiles and dot-directories; decide whether dotfiles should be
discoverable and if so change the fg option to dot: true (or make it
configurable) so functions using fg/Files discovery will include
.eslintrc/.github etc.; update any tests or callers relying on files to account
for dotfile inclusion and keep FALLBACK_IGNORE as-is unless you need to add
explicit ignores for dot directories.
packages/core/src/lib/store.ts (2)

198-218: Clarify the behavior when repoId is provided with empty ids array.

When repoId is provided and ids is empty, this will delete all points for that repository. While this is the intended design for bulk repo deletion, it's worth documenting this behavior to prevent accidental data loss.

Consider adding a JSDoc comment to clarify:

/**
 * Delete points from Qdrant.
 * `@param` ids - Point IDs to delete (ignored if repoId is provided)
 * `@param` repoId - If provided, deletes ALL points for this repo (ignores ids)
 */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/lib/store.ts` around lines 198 - 218, Add a JSDoc comment
above the deletePoints function clarifying the semantics when repoId is provided
(ids are ignored and an empty ids array plus repoId will delete all points for
that repo), documenting parameters and the intended behavior; reference the
deletePoints function name and mention that the implementation uses
COLLECTION_NAME, qdrantRequest and log so maintainers understand this performs a
bulk delete by repo when repoId is supplied.

154-159: Consider adding error handling for payload index creation.

The payload index creation doesn't check for failure. If the PUT request fails (e.g., network error, invalid request), ensureCollection will silently succeed without the index, potentially causing slow filtered queries.

🛡️ Proposed fix to handle index creation errors
   log.info(`Created collection "${COLLECTION_NAME}" (${dimension} dimensions, cosine distance)`);

   // Create payload index on repo_id for multi-tenant filtering
-  await qdrantRequest(`/collections/${COLLECTION_NAME}/index`, 'PUT', {
+  const { status: indexStatus, data: indexData } = await qdrantRequest(`/collections/${COLLECTION_NAME}/index`, 'PUT', {
     field_name: 'repo_id',
     field_schema: 'keyword',
   });
+
+  if (indexStatus !== 200) {
+    log.warn(`Failed to create repo_id payload index: ${JSON.stringify(indexData)}`);
+  } else {
+    log.info(`Created payload index on "repo_id" field`);
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/lib/store.ts` around lines 154 - 159, ensureCollection's
creation of the payload index currently ignores failures; wrap the qdrantRequest
call that PUTs the repo_id index in a try/catch, and validate the response (or
qdrantRequest's resolved value/status) to detect non-2xx outcomes—on failure log
a clear error (include COLLECTION_NAME and the error/response), and either throw
the error or return a failed Promise so callers know index creation failed;
modify the call site where qdrantRequest is used (the qdrantRequest(...) that
creates the index for COLLECTION_NAME in ensureCollection) to implement this
handling.
packages/core/src/lib/store.test.ts (1)

169-195: Consider adding tests for the new repoId filter parameter.

The existing tests cover the backward-compatible behavior (no repoId), but there's no test coverage for:

  • deletePoints([], 'repo-123') — deleting by repo filter
  • searchPoints(vector, 10, 'repo-123') — searching with repo filter

Would you like me to generate test cases for the repoId filter functionality?

Also applies to: 197-249

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

In `@packages/core/src/lib/store.test.ts` around lines 169 - 195, Add test cases
that exercise the new repoId filter by calling deletePoints([], 'repo-123') and
deletePoints(['id'], 'repo-123') (or analogous) and by calling
searchPoints(<sampleVector>, 10, 'repo-123'); for each, mock globalThis.fetch as
in existing tests, invoke the function (deletePoints or searchPoints), then
inspect the outgoing request via getRequestBody(0) and getRequestUrl(0) to
assert the request body contains the filter with repoId: 'repo-123' (e.g.,
body.filter.repoId or body.filter.repo_id depending on naming) and that the URL
targets the correct endpoint (/points/delete or /points/search); follow the
existing test patterns for mocking responses and error assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/lib/store.test.ts`:
- Around line 169-195: Add test cases that exercise the new repoId filter by
calling deletePoints([], 'repo-123') and deletePoints(['id'], 'repo-123') (or
analogous) and by calling searchPoints(<sampleVector>, 10, 'repo-123'); for
each, mock globalThis.fetch as in existing tests, invoke the function
(deletePoints or searchPoints), then inspect the outgoing request via
getRequestBody(0) and getRequestUrl(0) to assert the request body contains the
filter with repoId: 'repo-123' (e.g., body.filter.repoId or body.filter.repo_id
depending on naming) and that the URL targets the correct endpoint
(/points/delete or /points/search); follow the existing test patterns for
mocking responses and error assertions.

In `@packages/core/src/lib/store.ts`:
- Around line 198-218: Add a JSDoc comment above the deletePoints function
clarifying the semantics when repoId is provided (ids are ignored and an empty
ids array plus repoId will delete all points for that repo), documenting
parameters and the intended behavior; reference the deletePoints function name
and mention that the implementation uses COLLECTION_NAME, qdrantRequest and log
so maintainers understand this performs a bulk delete by repo when repoId is
supplied.
- Around line 154-159: ensureCollection's creation of the payload index
currently ignores failures; wrap the qdrantRequest call that PUTs the repo_id
index in a try/catch, and validate the response (or qdrantRequest's resolved
value/status) to detect non-2xx outcomes—on failure log a clear error (include
COLLECTION_NAME and the error/response), and either throw the error or return a
failed Promise so callers know index creation failed; modify the call site where
qdrantRequest is used (the qdrantRequest(...) that creates the index for
COLLECTION_NAME in ensureCollection) to implement this handling.

In `@packages/core/src/lib/walker.ts`:
- Around line 66-72: The fast-glob call that builds files (const files = await
fg('**/*', { cwd: rootDir, ignore: FALLBACK_IGNORE, dot: false, absolute: false
})) currently sets dot: false which excludes dotfiles and dot-directories;
decide whether dotfiles should be discoverable and if so change the fg option to
dot: true (or make it configurable) so functions using fg/Files discovery will
include .eslintrc/.github etc.; update any tests or callers relying on files to
account for dotfile inclusion and keep FALLBACK_IGNORE as-is unless you need to
add explicit ignores for dot directories.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6556e886-8bcb-4d5e-847b-a5478e514e9d

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef28f7 and 532701f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • docs/plans/2026-03-24-phase2-step3-core-fixes.md
  • docs/plans/2026-03-24-phase2-step3-index-repo.md
  • docs/specs/2026-03-24-phase2-step3-index-repo-design.md
  • packages/core/package.json
  • packages/core/src/config/env.ts
  • packages/core/src/index.ts
  • packages/core/src/lib/store.test.ts
  • packages/core/src/lib/store.ts
  • packages/core/src/lib/walker.test.ts
  • packages/core/src/lib/walker.ts
💤 Files with no reviewable changes (1)
  • packages/core/package.json

@HrushiBorhade
HrushiBorhade merged commit 6912ab9 into main Mar 24, 2026
3 of 5 checks passed
@HrushiBorhade
HrushiBorhade deleted the phase-2/core-fixes branch March 24, 2026 20:54

This branch was successfully deployed

1 active deployment
Preview — 43371968 Deployed Mar 24, 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

1 participant