Skip to content

[codex] fix hook worktree root and read-only FTS guard#2373

Draft
sburdges-eng wants to merge 9 commits into
abhigyanpatwari:mainfrom
sburdges-eng:fix/hook-worktree-and-ro-fts-ensure
Draft

[codex] fix hook worktree root and read-only FTS guard#2373
sburdges-eng wants to merge 9 commits into
abhigyanpatwari:mainfrom
sburdges-eng:fix/hook-worktree-and-ro-fts-ensure

Conversation

@sburdges-eng

Copy link
Copy Markdown
Contributor

Summary

  • Resolve hook/worktree handling and read-only FTS guard behavior on the branch.
  • Add coverage for supported vector paths and related hook/read-only dispatch behavior.
  • Add agent-routing docs and tmux helper scripts while removing user-specific absolute workspace path hints.

Validation

  • cd gitnexus && ./node_modules/.bin/tsc --noEmit
  • cd gitnexus && ./node_modules/.bin/vitest run test/unit/hooks.test.ts test/unit/lbug-readonly-error.test.ts test/unit/calltool-dispatch.test.ts
  • cd gitnexus && ./node_modules/.bin/vitest run test/integration/lbug-core-adapter.test.ts
  • bash -n scripts/tmux-gitnexus-analysis.sh scripts/gitnexus-trio-tmux.sh scripts/tmux-gitnexus-analysis.sh.bak-20260609-envopt
  • git diff --check
  • rg -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 unstaged returned 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.

sburdges-eng and others added 6 commits April 30, 2026 01:15
…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>
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

@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
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

✨ PR Autofix

Found fixable formatting / unused-import issues across 92 changed lines. Comment /autofix on this PR to apply them, or run npm run lint:fix && npm run format locally.

{"schema":"gitnexus.pr-autofix/v2","state":"fixes-available","pr_number":2373,"changed_lines":92,"head_sha":"e4344fe487be6ef43d21c20aedd4fef6c051b11a","run_id":"28731034032","apply_command":"/autofix"}

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

CI Report

All checks passed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
✅ Tests success unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
14046 13990 0 56 748s

✅ All 13990 tests passed

56 test(s) skipped — expand for details

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 80.03% 52477/65568 N/A% 🟢 ████████████████░░░░
Branches 67.05% 32088/47852 N/A% 🟢 █████████████░░░░░░░
Functions 86.18% 6028/6994 N/A% 🟢 █████████████████░░░
Lines 83.55% 46777/55984 N/A% 🟢 ████████████████░░░░

📋 View full run · Generated by CI

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