Skip to content

GH-36: refresh the index when store files change - #39

Merged
blainemotsinger merged 1 commit into
mainfrom
GH-36
Oct 24, 2026
Merged

blainemotsinger merged 1 commit into
mainfrom
GH-36

Conversation

@blainemotsinger

Copy link
Copy Markdown
Member

Summary

Fixes the stale-index gap reported in #36: query_knowledge was served from an index built once at startup, so store edits made outside write_knowledge/update_knowledge (hand edits, git checkout, migration scripts) were visible to list_knowledge but silently absent from query_knowledge.

Changes

  • search.Index records a store fingerprint (per-ref source file path, size, mtime) at build time. Query re-checks it and, when files changed, builds a fresh in-memory index and swaps it in atomically, closing the old one after in-flight queries drain. Deleted entries disappear because the replacement index is built from scratch (bleve has no Delete path here).
  • Unchanged stores take a fast path without the rebuild lock; rebuilds are serialized separately from query access.
  • New reindex_knowledge MCP tool forces a full rebuild.
  • Org-level knowledge now indexes every top-level *.md under .agents/knowledge/ (shared knowledge.OrgKnowledgeFiles) instead of the architecture.md/review.md allowlist, in both the query index and the Grep/Glob augment hook.
  • README updated for auto-refresh, the new tool, and the org *.md behavior. Project store entries refreshed (sub-001, new dec-005).

Verification

  • gofmt -l . clean
  • go vet ./... clean
  • go build ./... clean
  • go test ./... 9/9 packages
  • go test ./search/ -race -count=10 clean
  • make eval-mock 18/18 PASS

Closes #36

@blainemotsinger blainemotsinger self-assigned this Oct 24, 2026
@blainemotsinger
blainemotsinger merged commit 4df3ae1 into main Oct 24, 2026
2 checks passed
@blainemotsinger
blainemotsinger deleted the GH-36 branch October 24, 2026 01:30
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.

fix stale index after direct store edits

1 participant