fix: preserve retrieval receipts and Codex installs - #568
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughRetrieval outputs now reconcile query-obligation coverage with returned snippets across recovery, compaction, serialization, and stdio flows. Claude hook management detects current and legacy managed hooks, protects user scripts, and removes empty configuration structures. ChangesRetrieval evidence reconciliation
Claude hook management
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RetrievalRuntime
participant Compaction
participant StdioTools
participant ContextPackSerializer
participant QueryCoverage
RetrievalRuntime->>Compaction: shape matched_nodes
Compaction->>QueryCoverage: evaluate snippet coverage
QueryCoverage-->>Compaction: query_obligations
Compaction->>StdioTools: build compact payload
StdioTools->>QueryCoverage: reconcile payload nodes
QueryCoverage-->>StdioTools: updated retrieval_plan
StdioTools->>ContextPackSerializer: serialize context pack
ContextPackSerializer->>QueryCoverage: reconcile emitted snippets
QueryCoverage-->>ContextPackSerializer: final query_obligations
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/infrastructure/context-pack-command.ts (1)
1890-1893: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPreserve the reconciliation result when no new obligation was lost.
The retrieval plan may already have been mutated at Line 1886. Returning
falsehere skips the caller’s post-reconciliation budget enforcement despite that mutation.Proposed fix
const lostDuringSerialization = queryCoverage.missing_obligations.some((obligation) => !baselineMissing.has(obligation)) if (!lostDuringSerialization) { - return false + return retrievalPlanReconciled }🤖 Prompt for 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. In `@src/infrastructure/context-pack-command.ts` around lines 1890 - 1893, Update the reconciliation logic around queryCoverage and lostDuringSerialization so it preserves the caller’s post-reconciliation budget-enforcement path when the retrieval plan was already mutated, rather than unconditionally returning false. Retain the no-new-obligation check, but return or propagate the existing reconciliation result that reflects the mutation performed near line 1886.
🤖 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/infrastructure/install.ts`:
- Around line 793-803: Update hasManagedClaudePromptHookScript to verify
scriptPath is a regular file with lstatSync before reading it, returning false
for directories and other non-file paths. Wrap the filesystem checks and
readFileSync call in error handling so broken symlinks, inaccessible paths, and
other filesystem failures are treated as unmanaged rather than thrown.
In `@src/runtime/retrieve/conceptual-fallback.ts`:
- Around line 623-637: Update the reconciliation logic around
evaluateQueryEvidenceCoverage to clamp plan.query_obligations.initially_covered
to the reconciled coverage.total, preserve that clamped value in the returned
query_obligations, and include it in the early equality check alongside total
and finally_covered.
---
Outside diff comments:
In `@src/infrastructure/context-pack-command.ts`:
- Around line 1890-1893: Update the reconciliation logic around queryCoverage
and lostDuringSerialization so it preserves the caller’s post-reconciliation
budget-enforcement path when the retrieval plan was already mutated, rather than
unconditionally returning false. Retain the no-new-obligation check, but return
or propagate the existing reconciliation result that reflects the mutation
performed near line 1886.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 72d2806d-1612-46e8-b90e-85ca222ba72b
📒 Files selected for processing (14)
src/infrastructure/context-pack-command.tssrc/infrastructure/doctor.tssrc/infrastructure/install.tssrc/runtime/context-pack-recovery.tssrc/runtime/retrieve.tssrc/runtime/retrieve/conceptual-fallback.tssrc/runtime/stdio/tools.tstests/unit/context-pack-command.test.tstests/unit/context-pack-recovery.test.tstests/unit/doctor.test.tstests/unit/install.test.tstests/unit/retrieve-conceptual-fallback.test.tstests/unit/retrieve-cross-layer-flow.test.tstests/unit/stdio-slice-surface.test.ts
Summary
Why
A retrieval receipt could describe evidence that had been removed from the final visible result. Installer lifecycle behavior could also report a Claude hook as healthy when its managed script had diverged, or risk replacing a user-owned hook.
Impact
Agents receive evidence receipts that match the snippets they can actually inspect. Install, doctor, and uninstall operations remain workspace-scoped while protecting user-owned hook scripts.
Validation
npm run typechecknpx vitest run --maxWorkers=1 --no-file-parallelism tests/unit/doctor.test.ts tests/unit/install.test.ts tests/unit/context-pack-recovery.test.ts tests/unit/retrieve-conceptual-fallback.test.ts tests/unit/retrieve-cross-layer-flow.test.ts tests/unit/context-pack-command.test.ts tests/unit/stdio-slice-surface.test.ts(187 passed)git diff --checkFollow-up
Refs #565
Refs #567
This PR is ready for review. Neither issue is being closed, and no release claim is being made until current-head CI, CodeRabbit, a refreshed exact-candidate receipt, and successful Codex client trials are available.
Summary by CodeRabbit