Skip to content

perf: defer vault indexing to background goroutine for instant MCP startup (#36) - #38

Merged
jflowers merged 1 commit into
mainfrom
012-background-index
Apr 7, 2026
Merged

jflowers merged 1 commit into
mainfrom
012-background-index

Conversation

@jflowers

@jflowers jflowers commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restructures executeServe() to start the MCP server before vault indexing — server ready in <1 second instead of 32 seconds on large repos
  • initObsidianBackend() split into fast path (store open, Ollama check, vault client) and deferred path (indexVault, external pages, watcher)
  • Background goroutine acquires the shared sync.Mutex from spec 011's index/reindex tools — prevents concurrent indexing operations
  • atomic.Bool indexReady flag reported via health MCP tool so agents can check if background indexing is complete
  • During indexing: tools read from the persistent store (previous session's data). After indexing: in-memory index is fresh
  • 7 new tests: deferred indexing lifecycle, fast startup verification, mutex blocking, external mutex injection, ready flag lifecycle

Closes #36

Spec Artifacts

Full Speckit spec in specs/012-background-index/ — spec (3 user stories, 10 FRs), plan, research (5 items), quickstart, tasks (9 tasks, all complete).

…artup (#36)

- Split initObsidianBackend() into fast path (store, Ollama, vault
  client) and deferred path (indexVault, external pages, watcher)
- MCP server starts in <1s; background goroutine handles indexing
- Shared sync.Mutex between background indexing and index/reindex
  MCP tools prevents concurrent operations (spec 011 integration)
- atomic.Bool indexReady flag reported via health tool so agents
  can check indexing status
- 7 new tests covering deferred indexing, fast startup, mutex
  blocking, and ready flag lifecycle
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

✅⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ GO golangci-lint yes yes no no 44.74s
⚠️ MARKDOWN markdownlint 1 0 42 0 1.5s
✅ REPOSITORY gitleaks yes no no 2.38s
✅ REPOSITORY git_diff yes no no 0.28s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 42 errors
AGENTS.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 509]
AGENTS.md:26:401 error MD013/line-length Line length [Expected: 400; Actual: 461]
AGENTS.md:65:15 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:65:35 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:65:130 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:66:16 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:66:43 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:66:163 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
AGENTS.md:91:11 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:91:21 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:91:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:91:11 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:114:13 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:114:34 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:114:56 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:114:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:114:13 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:114:34 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:213:8 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:213:16 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:213:30 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:213:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:213:8 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:213:16 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:222:11 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:222:25 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:222:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:222:11 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:238:8 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:238:22 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:238:40 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:238:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:238:8 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:238:22 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:317:8 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:317:18 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:317:32 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:317:41 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:317:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:317:8 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:317:18 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:317:32 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@jflowers
jflowers merged commit c227069 into main Apr 7, 2026
3 checks passed
@jflowers
jflowers deleted the 012-background-index branch April 7, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

perf: defer vault indexing to background — MCP server times out on large repos

1 participant