Fix/repair and cache bugs#23
Merged
michaelalber merged 4 commits intomainfrom Apr 30, 2026
Merged
Conversation
The repair_manifest.py CLI uses the user-supplied collection suffix verbatim as the disk subdir name. This breaks for any collection where the disk dir uses hyphens but the suffix uses underscores (e.g. sources/api-design → api_design). The new resolve_explicit_targets helper must look up the disk subdir from settings.collections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add resolve_explicit_targets() in manifest_repair so that a user-supplied collection suffix (e.g. 'api_design') maps to its actual disk subdir (e.g. 'api-design') by looking up settings.collections, not by assuming the suffix and the disk subdir are the same string. The CLI script now uses this helper and exits with a clear error when an unknown suffix is passed. Fixes the bug where: python scripts/repair_manifest.py api_design silently did nothing because it looked at sources/api_design/ instead of sources/api-design/. Affected any collection where the suffix uses underscores while the disk dir uses hyphens (api_design, systems_thinking, ui_ux, edge_ai, 4d_legacy, automation). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The MCP server caches the manifest in a module global at startup and never reloads it. A CLI ingest run while the server is up writes new entries to manifest.json on disk, but list_sources / list_collections keep returning the stale cached state until the server restarts. Adds two tests: - reload-when-changed: get_manifest reflects post-startup file changes - cached-when-unchanged: get_manifest returns same object when mtime hasn't moved (guards against per-call disk re-read) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The MCP server held a single Manifest instance loaded at startup, so any CLI ingest run while the server was up was invisible to list_sources / list_collections / get_source_info until the server was restarted. Symptoms: source_count: 0 reported by list_collections even after a successful ingest. Track _manifest_mtime and call os.stat() on each get_manifest invocation: - if the file mtime advanced, reload from disk - if unchanged, return the cached instance (no disk I/O cost beyond stat) - if the file is missing/unreadable, keep the cache (no-op) Cost: one st_mtime check per metadata-tool call (admin tools, not hot path). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| _manifest_mtime is None or current_mtime > _manifest_mtime | ||
| ): | ||
| _manifest = Manifest.load_or_create(manifest_path) | ||
| _manifest_mtime = current_mtime |
| def test_get_manifest_reloads_when_file_changes_on_disk(self, temp_dir: Path) -> None: | ||
| """A manifest write from another process is reflected on the next get_manifest call.""" | ||
| # Arrange | ||
| import grounded_code_mcp.server as server_module |
| def test_get_manifest_returns_cached_when_file_unchanged(self, temp_dir: Path) -> None: | ||
| """When manifest.json has not changed, get_manifest returns the cached object.""" | ||
| # Arrange | ||
| import grounded_code_mcp.server as server_module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix cache bug