Skip to content

fix(codegraph): index-db check + safe Gemini fileName cleanup (Tier-3, stacked on #1)#2

Merged
itsarvinddev merged 2 commits into
itsarvinddev:mainfrom
heman4t:fix/codegraph-index-check-gemini-cleanup
Jun 7, 2026
Merged

fix(codegraph): index-db check + safe Gemini fileName cleanup (Tier-3, stacked on #1)#2
itsarvinddev merged 2 commits into
itsarvinddev:mainfrom
heman4t:fix/codegraph-index-check-gemini-cleanup

Conversation

@heman4t

@heman4t heman4t commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What & why

Tier-3 polish, the follow-up to #1. Two small, well-tested hardening fixes.

Stacked on #1. This branch builds on #1 (it shares the regenerated agent-primer.sh), so the diff currently shows #1's commit too. Please merge #1 first — GitHub will then auto-reduce this PR to just the second commit (1bd3807). Reviewing that commit in isolation: 1bd3807

1. Hook treats a bare .codegraph/ dir as "set up" → check for the index db

codegraph-session-check.sh decided a project was indexed purely from .codegraph/ existing. But codegraph init -i can leave a bare .codegraph/ dir if it's interrupted (and the policy itself defines indexed as ".codegraph/ exists and codegraph status succeeds"). On that half-built state the default once-mode goes silent on a broken index.

Fix: index_initialized() now requires .codegraph/ and at least one *.db inside it. Deliberately a filesystem check, not codegraph status — running status every session is exactly the cost once-mode removes; deep corruption stays status/--always's job. Closes the policy/hook gap cheaply.

2. Uninstall leaves dangling Gemini context.fileName entries → prune them safely

Install adds AGENTS.md/GEMINI.md to Gemini's context.fileName; uninstall left them all (the code comment called it "harmless, user may rely on it"). The safe middle ground: prune an entry only when its instruction file no longer exists after uninstall (a dangling reference). A GEMINI.md/AGENTS.md the user still has is left referenced — so we never remove config they rely on, which was the original concern. AGENTS.md is pruned in project scope only; globally that entry means "read each project's AGENTS.md", which the global install doesn't own.

This intentionally changes a previously-deliberate behavior — if you'd rather keep "leave everything", drop commit 2 and I'll happily land #1's spirit only.

Testing

  • Regenerated agent-primer.sh via make-portable.sh (bundle-drift check green).
  • tests/smoke.sh: 69 passed, 0 failed. New coverage: half-built .codegraph/ (no db) nudges init; dangling GEMINI.md/AGENTS.md pruned on uninstall; a surviving file's ref is kept (the safety guarantee).

🤖 Generated with Claude Code

heman4t and others added 2 commits June 7, 2026 17:04
…gitignore .codegraph/

Three fixes grounded in a real first-run setup, where the codegraph_* MCP
tools silently failed to load after following the policy verbatim:

1. Recommend `codegraph install -y` everywhere (codegraph-policy.md +
   codegraph-session-check.sh). A bare `codegraph install` opens an
   interactive agent-picker prompt that has no TTY in an agent context and
   hangs session startup.

2. Add a post-restart verification step to the policy + hook message. The
   CLI installer links the binary into ~/.local/bin, which is often not on
   the PATH a GUI-launched agent inherits, so the MCP server registered as
   the bare command "codegraph" fails to spawn silently. Guidance: verify
   the tools loaded, and if not, add ~/.local/bin to PATH or re-register
   the MCP entry's command with the absolute binary path.

3. Auto-gitignore .codegraph/ on project installs (mirrors the existing
   primer_gitignore). `codegraph init -i` writes a per-machine index that
   must not be committed on a team-shared project install.

Regenerated agent-primer.sh via make-portable.sh; added a smoke assertion.
All 62 smoke checks pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ngling Gemini fileName refs

Tier-3 polish, follow-up to the non-interactive/PATH/gitignore fixes.

1. codegraph-session-check.sh: treat a project as initialized only when
   .codegraph/ actually contains an index db (*.db), not merely the dir. An
   aborted/half-finished `codegraph init` leaves a bare .codegraph/ dir that
   previously made once-mode go silent on a broken index. The check stays a
   pure filesystem test (no per-session `codegraph status`), preserving
   once-mode's fast no-op; deep corruption stays status/--always's job. This
   aligns the hook with the policy's 'indexed = .codegraph/ exists AND status
   succeeds'.

2. uninstall.sh: reverse install's Gemini context.fileName additions, but
   ONLY for entries whose instruction file no longer exists after uninstall
   (a dangling reference). A GEMINI.md/AGENTS.md the user still has is left
   referenced, so config they rely on is never removed. (Previously uninstall
   left every fileName entry.) AGENTS.md is pruned in project scope only;
   globally that entry means 'read each project's AGENTS.md', which the global
   install does not own.

Regenerated agent-primer.sh; added smoke coverage (half-built index nudges;
dangling refs pruned; a surviving file's ref kept). 69 smoke checks pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@itsarvinddev itsarvinddev merged commit 7035f01 into itsarvinddev:main Jun 7, 2026
5 checks passed
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