Repository navigation
fix(insights): stop dead historical paths from anti-selecting resume candidates - #3057
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (17)
📝 WalkthroughWalkthroughResume ranking now resolves path overlap with structured provenance, carries that evidence through resume briefs, MCP payloads, prompts, and CLI output, and adds a fixture-driven evaluator comparing legacy and refactor-aware ranking metrics. ChangesResume overlap ranking
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant MCP_get_resume_brief
participant build_resume_brief
participant SessionProfileInsights
participant PathOverlapScorer
Client->>MCP_get_resume_brief: provide session_id, repo_path, recent_files
MCP_get_resume_brief->>build_resume_brief: forward repository context
build_resume_brief->>SessionProfileInsights: load matching profile insights
build_resume_brief->>PathOverlapScorer: score candidate paths against recent files
PathOverlapScorer-->>build_resume_brief: score and overlap_basis
build_resume_brief-->>MCP_get_resume_brief: ResumeBrief with overlap_basis
MCP_get_resume_brief-->>Client: serialized resume brief
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f35f3d719
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…candidates Problem: resume-candidate ranking scores file overlap via exact-path Jaccard over raw historical file_paths_touched. Bead polylogue-v1vo found that on the live archive 43% of historical file touches no longer exist under the current layout after repo refactors (e.g. storage/repository.py -> storage/repository/__init__.py), so a session that is a true refactor ancestor scores near zero overlap while unrelated sessions with fresher but shallower touches rank higher. Extra dead paths in a candidate's touch set also deflate its Jaccard denominator relative to an otherwise identical candidate with fewer historical paths. What changed: polylogue/insights/resume.py adds a per-ranking-call _PathResolutionContext that resolves the caller's repo root once and caches filesystem existence checks. Candidate paths are partitioned into resolvable (exact current-checkout match, or file-to-package correction for a missing foo.py when foo/__init__.py exists) versus dead. Dead candidate paths are then matched against not-yet-matched recent files by one-to-one, deepest-prefix, root-rejecting parent-directory continuity. The Jaccard denominator is corrected to caller-identities union resolvable-candidate-identities, so still-dead paths no longer enter the union and no longer deflate the score. The result is exposed additively as ResumeCandidate.overlap_basis (exact / dir / dead_excluded) without changing score_breakdown.file_overlap's existing float contract or the 0.25 file-overlap weight. When no valid repo root is available the scorer falls back to the previous lexical behavior. Consumers threaded through: Polylogue.resume_brief gained optional repo_path/recent_files; MCP get_resume_brief and get_resume_brief's tool description; CLI `continue --candidates` JSON/terminal output; the SessionStart context preamble (via a typed ContextPreambleOverlapBasis projection, crossing the surface boundary through model_dump/ model_validate rather than importing the insight model directly). RESUME_BRIEF_MATERIALIZER_VERSION bumped 1 -> 2 for the added optional field. No schema/migration touched; no stored profile is rewritten; adaptation happens at query time only. Adds devtools/resume_ranking_eval.py, a durable offline hit@1/hit@3/MRR evaluator over a versioned, lineage-grounded fixture (tests/data/resume-ranking-eval-v1.json) comparing legacy vs refactor-aware scoring. On the fixture: overall hit@1 20% -> 100%, MRR 0.390 -> 1.000; a seeded 1,000-path evidence sample reproduces the bead's reported proportions at 57.0% -> 82.4% usable evidence (254/430 dead paths directory-recovered). This is a seeded/fixture reproduction, not a rerun against the live 4,264-session archive, which was not available in this environment. This patch originated as an externally-generated (GPT Pro) packet against bead polylogue-v1vo. It was independently re-verified on current master before commit: full diff read line-by-line, an anti-vacuity mutation (neutering _directory_overlap_pairs to return () ) confirmed 5 tests genuinely fail including the eval harness's own partition invariant, then reverted and confirmed byte-identical to the patched state; devtools test passed 154/154 plus the facade route test; devtools render all --check passed with no "out of sync" surfaces; strict mypy passed on all 9 changed production/evaluator modules; a broader MCP/CLI contract run reproduced 206 passed / 1 pre-existing unrelated failure (test_target_algebra_preserves_semantic_dimensions_ without_self_authorizing, an 8-vs-9 TARGET_RESOURCES count mismatch this patch's registry.py diff does not touch). Ref polylogue-v1vo Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_01XR2eyvDxV5xr4qmbmbwyrL
4f35f3d to
6aa8131
Compare
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Repairs resume-candidate file-overlap scoring so that historical paths which no longer resolve under the current checkout layout (after a refactor/rename) no longer poison exact-path Jaccard, while still not counting still-dead paths in the union denominator. Adds an offline hit@1/hit@3/MRR ranking evaluator with a versioned, lineage-grounded fixture.
Problem
Bead
polylogue-v1vofound, from a live-archive analysis, that resume ranking's file-overlap component computes lexical exact-path Jaccard over rawfile_paths_touched. On the live archive, 43% of historical file touches no longer exist under the current repo layout (e.g.storage/repository.py->storage/repository/__init__.py), so a session that is a true refactor ancestor of the caller's current work scores near-zero overlap and gets anti-selected below unrelated sessions. Additionally, a candidate with extra dead paths in its touch set gets a larger union denominator than an otherwise-identical candidate, so it scores lower purely for having more (dead) history recorded — the opposite of what should happen.Solution
polylogue/insights/resume.py: adds a per-ranking-call_PathResolutionContextthat resolves the caller's repo root once and caches filesystem existence checks. Candidate paths are partitioned into resolvable (exact current-checkout match, or file-to-package correction when a missingfoo.pyresolves tofoo/__init__.py) vs. dead. Dead candidate paths are matched one-to-one against not-yet-matched recent caller files by deepest-prefix, root-rejecting parent-directory continuity (_directory_overlap_pairs). The Jaccard denominator becomescaller identities ∪ resolvable candidate identities— still-dead paths never enter the union. Falls back to the previous lexical behavior when no valid repo root is available.ResumeCandidate.overlap_basis(exact/dir/dead_excluded);score_breakdown.file_overlapkeeps its existing float contract and the0.25weight is unchanged.Polylogue.resume_brief(optionalrepo_path/recent_files), MCPget_resume_brief, CLIcontinue --candidates(JSON + terminal), and the SessionStart context preamble (via a typedContextPreambleOverlapBasisprojection crossing the surface boundary throughmodel_dump/model_validate, not a direct insights import).RESUME_BRIEF_MATERIALIZER_VERSIONbumped1 -> 2(additive optional field).devtools/resume_ranking_eval.py+tests/data/resume-ranking-eval-v1.json: durable offline evaluator comparinglegacyvsrefactor-awarescoring over lineage-derived ground truth (no hand-authored relevance labels).This patch originated as an externally-generated (GPT Pro) packet against bead
polylogue-v1vo. It was independently re-verified against currentmasterin this session (not merely re-run per its own claimed HANDOFF/TESTS docs) before being committed here.Verification
devtools test tests/unit/core/test_resume.py tests/unit/devtools/test_resume_ranking_eval.py tests/unit/mcp/test_contract_evidence.py tests/unit/mcp/test_compose_context_preamble.py tests/unit/mcp/test_server_surfaces.py tests/unit/cli/test_continue_absorption.py→154 passed in 23.06s._directory_overlap_pairsto unconditionallyreturn ()(disabling directory recovery), reran the core/evaluator tests →5 failed, 13 passed, includingtest_resume_candidates_recover_100_percent_dead_session_by_directory(assert 0.0 > 0) and the evaluator's own partition invariant (recovered=0vs expected 254/430). Reverted the neutering and confirmed the file is byte-identical to the pre-mutation patched state (diffclean) before rerunning →18 passed in 11.14s.devtools render all --check→ exit 0, noout of synclines (grepped the full log per the repo's documented gotcha).uv run --frozen mypyon all 9 changed production/evaluator modules →Success: no issues found in 9 source files.devtools test tests/unit/mcp/test_tool_declarations.py tests/unit/mcp/test_tool_discovery.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_query_tool_schema_derivation.py tests/unit/cli/test_cli_output_schemas.py→1 failed, 206 passed. The one failure (test_target_algebra_preserves_semantic_dimensions_without_self_authorizing, an 8-vs-9TARGET_RESOURCEScount assertion) is pre-existing drift unrelated to this patch — confirmed by diffingpolylogue/mcp/declarations/registry.pyagainstorigin/master, which shows only aget_resume_brieftool-description string change, nothing touchingTARGET_RESOURCES.uv run --frozen python -m devtools.resume_ranking_evalreproduces the claimed fixture metrics exactly: overall hit@120.0% -> 100.0%, MRR0.390 -> 1.000; seeded 1,000-path evidence sample57.0% -> 82.4%usable,254/430(59.1%) dead-path directory recovery.git pushran the pre-pushdevtools verify --quickgate: all 16 steps passed (ruff format/check, mypy, render all, topology/layering/closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands, docs-coverage, test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly).Not run: replay against the live 4,264-session/27,785-touch archive (unavailable in this environment — the
57% -> 82%improvement is a seeded/fixture reproduction of the bead's reported proportions, not an independent live-corpus rerun); full non-quickdevtools verify --all.Ref polylogue-v1vo
Summary by CodeRabbit
New Features
Bug Fixes
Tests