feat: index freshness trust bundle#149
Conversation
Surface commit drift, watcher pending sync, and disk-ahead signals on codemap context / MCP context so agents know when structural queries may lag the checkout. Watcher exposes debouncer state; slice 2 will extend MCP/HTTP tool responses per plan.
🦋 Changeset detectedLatest commit: cbf71a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reached
More reviews will be available in 42 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThis PR introduces index freshness metadata to MCP session bootstrapping, tracking repository synchronization state (commit drift, pending sync, watcher in-flight operations, optional disk drift) via a new ChangesIndex Freshness Metadata Feature
Possibly Related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
HTTP tools emit X-Codemap-* freshness headers without changing JSON bodies; MCP merges index_freshness into object payloads and appends a second content block for array-shaped query results. /health includes cheap freshness when DB exists.
…ce 3) Warn on stderr when index_freshness concerns remain after bootstrap or watch prime; document index_freshness fields and agent retry guidance in MCP instructions. Marks trust-bundle plan and roadmap items shipped.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/application/index-freshness.test.ts`:
- Around line 97-120: The test creates a Jest spy on
indexEngine.getCurrentCommit but never restores it, which can leak into other
tests; capture the spy (e.g., const spy = spyOn(indexEngine,
"getCurrentCommit").mockReturnValue("");) and ensure you call spy.mockRestore()
when the test finishes (use a finally block around the async work or call
mockRestore after await handle.stop()), or alternatively add
jest.restoreAllMocks() in an appropriate afterEach; reference
indexEngine.getCurrentCommit and the test that calls
runWatchLoop/computeIndexFreshness to locate where to restore the spy.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3b4e3f0b-1241-4fa8-a130-8d52a76016ca
📒 Files selected for processing (7)
docs/agents.mddocs/plans/index-freshness-trust-bundle.mdsrc/application/context-engine.tssrc/application/index-freshness.test.tssrc/application/index-freshness.tssrc/application/mcp-server.test.tssrc/application/watcher.ts
…-flight Address PR review: expose watch prime as reindex_in_flight/pending_sync, await watch ready before MCP connect / HTTP listen, skip redundant DB reads for context payloads, move HTTP headers to http-server, and extend tests/docs.
Patch changeset for user-facing index_freshness surfacing; delete the shipped plan per docs-governance and point docs at architecture instead.
Track queued inFlight batches so pending_sync does not false-negative between serialized reindexes; always emit boot freshness warning after watch prime settles, including on prime failure.
Summary
Ships the index freshness trust bundle (slices 1–3):
index_freshnessoncontext— commit drift, watcherpending_sync, disk-ahead signals, singlewarningstring@codemap/index_freshnessblock); HTTP headers onPOST /tool/*;/healthincludes cheap freshnesscodemap mcp/servewarn when concerns remain after watch primeCanonical module:
src/application/index-freshness.ts.Test plan
bun test src/application/index-freshness.test.tsbun test src/application/watcher.test.tsbun test src/application/mcp-server.test.tsbun test src/application/http-server.test.tsbun run typecheckcodemap contextwith HEAD ≠last_indexed_commit→warningpopulatedcodemap mcp --watch, callcontextduring debounce →pending_sync: true