Repository navigation
feat(index): per-profile Bleve indexes (Profiles v2 T1) — MCP-3240 - #756
Conversation
…s v2 T1) Introduce physically separate per-profile Bleve indexes so switching profiles is fast and a config reload that changes one profile does not re-index the others. index.Manager additions: - ForProfile(slug): lazily opens/creates a per-profile index, cached one per slug. Invalid (non-filesystem-safe) slugs are rejected. - RebuildProfileFromShared(slug, servers): rebuilds a profile index as a derived view of the shared default index, touching only that profile. - DropProfile(slug): closes and removes a profile's index directory. - ExistingProfileDirs / ClearAll / DeleteAll helpers. Per-profile indexes live under index.bleve/profiles/<slug>/ rather than index.bleve/<slug>/ so they never collide with Bleve's own internal files and store/ subdirectory (a TestReindex* failure proved that a naive index.bleve/* enumeration would mistake Bleve's store/ dir for a profile and delete it). Runtime wiring (internal/runtime/profile_index.go): - reconcileProfileIndexes: after each discovery pass and config reload, build new profiles, rebuild membership-changed ones, drop removed ones (including orphaned dirs from a prior run); unchanged profiles untouched. - reindexAffectedProfiles: when a server's tools change in the shared index (discovery, disable, quarantine), refresh only the profiles that include that server. The shared index.bleve/ stays the source of truth and allow-all fallback for non-profile /mcp. Slug -> dir reuses the validated slug from internal/config/profiles.go (new IsValidProfileSlug helper). Tests (TDD): ForProfile isolation, reload isolation (rebuild A only, B unchanged), drop removes dir, server-scoped refresh. Docs: profiles page documents the per-profile index layout and lifecycle. Related: MCP-3240
Deploying mcpproxy-docs with
|
| Latest commit: |
2b2da69
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9c8c8dce.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://feat-mcp-3240-per-profile-bl.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 28081049451 --repo smart-mcp-proxy/mcpproxy-go
|
|
Closing — Algis full-stop on CTO auto-spun roadmap work (on-hold/server items against personal-first). Not merging; parent epic parked to todo. |
CodexReviewer (PR #756) found a data-loss bug: rebuilding a per-profile index from the shared index dropped OutputSchemaJSON. Two gaps: - BleveIndex.BatchIndex omitted OutputSchemaJSON from the indexed document (only the single-tool IndexTool set it). - BleveIndex.GetToolsByServer omitted output_schema_json from its requested fields and from the reconstructed ToolMetadata. RebuildProfileFromShared reads via GetToolsByServer and writes via BatchIndexTools, so the field was lost on both the read and the write. Fix both sites. This also makes the shared index preserve output schemas for batch-indexed tools (applyDifferentialToolUpdate uses BatchIndexTools), a strict improvement that keeps profile and shared search results faithful. Adds TestManager_RebuildProfileFromShared_PreservesOutputSchema asserting the field survives a rebuild via both GetToolsByServer and SearchTools (the path retrieve_tools consumes). Related: MCP-3240 Co-Authored-By: Paperclip <[email protected]>
GeminiCritic Fallback Review — MCP-3290Verdict: REQUEST_CHANGES Summary: The PR correctly implements per-profile Bleve index isolation with sound lifecycle (open/close/rebuild/drop/orphan-cleanup) and good concurrency discipline via Major Issues1.
2.
Minor Issues3. Two concurrent callers for the same slug protected only by 4. If a sub-index Review performed by CEO fallback (MCP-3290) — GeminiCritic adapter failed. |
There was a problem hiding this comment.
✅ Gatekeeper approval — Codex review verdict: ACCEPT.
This approval is posted automatically by the MCPProxy Gatekeeper App on behalf of the Codex reviewer (verdict of record lives in the Paperclip review thread). Author≠approver satisfied; QA + CI gates enforced separately.
Auto-approved per Model B (MCP-1249).
…load DetectConfigChanges did not track config.Profiles, so a profile-only edit (add/remove/membership) reported "No configuration changes detected" and ApplyConfig never reached the re-index pass that calls reconcileProfileIndexes — it was reachable only via the servers-changed re-discovery path. A newly added profile got no per-profile Bleve index, and membership/removal edits left stale indexes until an unrelated server change happened to trigger a re-index. Track "profiles" as a hot-reloadable change and, when profiles change without a server change, reconcile the per-profile indexes synchronously against the already-current shared index (no re-discovery needed). The servers-changed path already reconciles via DiscoverAndIndexTools. Related #756
#763) GetToolsByServer capped a single Bleve search at 10000 hits and DeleteAll at 100000, so a server with >10k indexed tools or an index with >100k docs would silently drop the overflow during a per-profile rebuild/clear, leaving the profile index inconsistent with the shared index. Both now loop over search pages until exhausted, so coverage is never bounded by a single page: - GetToolsByServer paginates with From/Size, ending on a short final page. - DeleteAll deletes page-by-page from offset 0 (each batch removes the enumerated docs, surfacing the next page) until the index is empty. Page size is a configurable BleveIndex field (default 10000) so the regression tests exercise the loop with a small, fast corpus. Related #756. Follow-up to MCP-3240 Codex review (MCP-3307).
Profiles v2 — T1: per-profile Bleve indexes + lifecycle
Parent: MCP-33 · Foundation that T2 (
set_profile) wires switching to. Does not change URL-profile filtering yet.What
Introduces physically separate per-profile Bleve indexes so switching profiles is fast and a config reload that changes one profile does not re-index the others.
index.ManagerAPIForProfile(slug)— lazily opens/creates a per-profile index, cached one-per-slug; invalid (non-filesystem-safe) slugs rejected.RebuildProfileFromShared(slug, servers)— rebuilds a profile index as a derived view of the shared default index, touching only that profile.DropProfile(slug)— closes + removes a profile's index directory.ExistingProfileDirs/ClearAll/DeleteAllhelpers.On-disk layout
Design note (deviation from the issue's literal
index.bleve/<profile>/): Bleve creates its ownstore/subdirectory and metadata files directly underindex.bleve/. A naiveindex.bleve/*enumeration for orphan cleanup mistook Bleve'sstore/dir for a profile and deleted it — caught by a real test failure during development. Namespacing underindex.bleve/profiles/keeps per-profile indexes underindex.bleve(the spec's spirit) while isolating them from Bleve internals so enumeration is always safe.Runtime wiring (
internal/runtime/profile_index.go)reconcileProfileIndexes— after each discovery pass and config reload: build new profiles, rebuild membership-changed ones, drop removed ones (incl. orphaned dirs from a prior run); unchanged profiles are untouched.reindexAffectedProfiles— when a server's tools change in the shared index (discovery / disable / quarantine), refresh only the profiles that include that server.The shared index stays the source of truth; per-profile indexes are derived from it (no re-discovery from upstreams).
Tests (TDD)
internal/index:ForProfileisolation, reload isolation (rebuild A only, B doc-count unchanged), drop removes dir, invalid-slug rejection.internal/runtime: reconcile builds + isolates, drops removed profile dir, server-scoped refresh only touches profiles with that server.Verification
go test -race ./internal/index/... ./internal/config/... ./internal/runtime/...— green.golangci-lint run --config .github/.golangci.yml ./internal/index/... ./internal/runtime/... ./internal/config/...— 0 issues.go build ./.../go vet— clean.docs/features/profiles.mddocuments the layout + lifecycle table.No config-schema fields added (only a
config.IsValidProfileSlughelper), so no swagger change.Related: MCP-3240