[codex] fix hook worktree root and read-only FTS guard#2373
Draft
sburdges-eng wants to merge 9 commits into
Draft
[codex] fix hook worktree root and read-only FTS guard#2373sburdges-eng wants to merge 9 commits into
sburdges-eng wants to merge 9 commits into
Conversation
…bhigyanpatwari#1224) Two bugs in the Claude Code hook + query layer integration: 1. `findGitNexusDir` (in `gitnexus/hooks/claude/gitnexus-hook.cjs` and `gitnexus-claude-plugin/hooks/gitnexus-hook.js`) walked upward from cwd looking for a non-registry `.gitnexus/`. In linked git worktrees created via `git worktree add`, the canonical repo's `.gitnexus/` never sits above the worktree path, so the walk silently fails and neither augmentation nor staleness notifications fire. Fix: keep the cwd-walk as the fast path, then fall back to `git rev-parse --git-common-dir` to resolve the shared `.git/` directory (which lives inside the canonical repo across all linked worktrees) and walk up from its parent. Returns null cleanly when `git` isn't on PATH or cwd isn't inside any working tree. 2. `ensureFTSIndex` in the LadybugDB adapter rethrew when the active connection is read-only (e.g. the MCP query pool, which opens DBs read-only by design). Defensive callers used to surface five "Cannot execute write operations in a read-only database" warnings per query. Fix: extract `isReadOnlyDbError` (mirroring the existing `isDbBusyError` discriminator) and have `ensureFTSIndex` catch the read-only error, cache the key, and return silently. Index creation is owned by `gitnexus analyze` on a writable connection — the ensure call is safely a no-op on the read pool. Lock / busy / "already exists" / schema errors continue to propagate. Tests: - `test/unit/hooks.test.ts`: new "Linked git worktree resolution" block exercises both hooks against a real linked worktree to confirm PostToolUse stale notifications fire, plus a negative case when the canonical repo has no `.gitnexus/`. - `test/unit/lbug-readonly-error.test.ts`: new file unit-tests the `isReadOnlyDbError` discriminator (positive matches, case insensitivity, non-Error inputs, and unrelated errors that must still surface — lock contention, "already exists", schema misses). - `test/integration/lbug-core-adapter.test.ts`: extends the existing FTS coverage with an idempotency assertion for `ensureFTSIndex` to pin the read-only guard's success-path contract. Verified with `npx tsc --noEmit` and `vitest run` on the affected files (hooks + readonly + lbug-core-adapter + bm25-search + lbug-extension-loader + lbug-embedding-hashes — 136 tests pass). Build: `npm run build` succeeds. Closes abhigyanpatwari#1224
Add the supported-platform regression assertion for QUERY_VECTOR_INDEX and align the unsupported VECTOR diagnostic wording with platform policy. Made-with: Cursor
Ignore local .cursor hooks; document project-local scope for GitNexus. Co-authored-by: Cursor <cursoragent@cursor.com>
Commit workspace scripts at repo root. Ignore local personal/ scratch and built gitnexus/web static output. Co-authored-by: Cursor <cursoragent@cursor.com>
…e' into fix/hook-worktree-and-ro-fts-ensure
|
@sburdges-eng is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
…-ro-fts-ensure # Conflicts: # .gitignore # gitnexus-claude-plugin/hooks/gitnexus-hook.js # gitnexus/hooks/claude/gitnexus-hook.cjs # gitnexus/src/core/lbug/lbug-adapter.ts # gitnexus/src/mcp/local/local-backend.ts # gitnexus/test/integration/lbug-core-adapter.test.ts # gitnexus/test/unit/calltool-dispatch.test.ts # gitnexus/test/unit/lbug-readonly-error.test.ts
Contributor
✨ PR AutofixFound fixable formatting / unused-import issues across 92 changed lines. Comment |
Contributor
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 13990 tests passed 56 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
cd gitnexus && ./node_modules/.bin/tsc --noEmitcd gitnexus && ./node_modules/.bin/vitest run test/unit/hooks.test.ts test/unit/lbug-readonly-error.test.ts test/unit/calltool-dispatch.test.tscd gitnexus && ./node_modules/.bin/vitest run test/integration/lbug-core-adapter.test.tsbash -n scripts/tmux-gitnexus-analysis.sh scripts/gitnexus-trio-tmux.sh scripts/tmux-gitnexus-analysis.sh.bak-20260609-envoptgit diff --checkrg -n "/Users/|/Volumes/|OPENAI|ANTHROPIC|https://api|sk-" <changed files>returned no matches after cleanup.node gitnexus/dist/cli/index.js detect-changes --repo GitNexus --scope unstagedreturned no indexed symbol/process impact for the final shell-script cleanup.Notes
The full
npm test/npm run test:unit -- ...path was not used as the final gate because the npm script prepends the entire unit directory and hit unrelated fork/daemon termination noise. The PR validation above targets the files touched by this branch plus TypeScript checking.