Repository navigation
fix: Answer facets from one envelope on both surfaces - #5178
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 34 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 |
`analyze --facets` and `polylogue facets` returned different documents for the same question. The first routed to the canonical builder in `api/archive.py`; the second routed to `_facets_payload` in `operations/daemon_reads.py`, whose docstring claimed to reuse that implementation but reused only the bucket scan and restated the assembly around it. The restatement had drifted. It emitted no `family_status`, `availability`, `deadline_s`, `elapsed_s` or `stale_age_s`; hard-coded `budget_exceeded=False` and `cost_class="cheap"` rather than reading the projection contract; carried its own family lists, with `omitted` in both complete and deferred and `total_counts` missing; and had no `PostFilterScopeTooLargeError` handling, so a scope too large to post-filter raised instead of degrading -- against the rule that a named gap must not read as an empty scope. #4867 caused it by deleting the API fallback from `facets_command`, so the daemon-less path stopped answering from the shared builder. Adding the five missing keys by hand would restart the same drift, so the assembly is extracted into `build_facets_response` and both callers build the same model. The daemon read dumps it. The two surfaces are now equal by construction rather than by keeping two key lists in agreement. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
9aaeee9 to
af20216
Compare
Summary
analyze --facetsandpolylogue facetsreturned different documents for the same question. This is a real product defect, not a test drift, and the parity test was correctly reporting it.Evidence
Receipt
.cache/verify/runs/20260914T233651Z-all-207009-89ddea6b(verify_all, job 1699, 22,540 selected, 29 failed).Caveat on that receipt: its
run.jsonrecordsgit_head: f7964acd12b25134c0e2e4cd8f73f9e6557a4a4f— the tip of branchrebase-5165, notmasterand not an ancestor of it — andfinal_git_head: 724d17535. The shared checkout advanced across 7 merged PRs during the run, so it is not evidence of a frozen tree. I re-ran all 29 node ids at truemasterHEAD: 17 reproduce, 12 do not. This one is among the 17.Observed diff:
{'family_status': {}}against a populated per-family state map, and{'deadline_s': None}against{'deadline_s': 2.0}.Per-failure classification
test_plain_cli_snapshots::test_facets_command_json_matches_analyze_facetsoperations/daemon_reads._facets_payloadis a drifted hand-copy of the canonical envelope assembly inapi/archive.pyProblem
Two implementations answered the same envelope:
analyze --facets→query_verbs.py→env.polylogue.facets(...)→ the canonical builder inapi/archive.py.polylogue facets→commands/facets.py→configured_read_operation(config, "facets", …)→daemon_reads._facets_payload._facets_payload's docstring claimed "Reuse the API's canonical aggregate implementation over this reader", but it reused only_archive_facet_buckets— the bucket scan — and restated the assembly around it. That restatement had drifted:family_status,availability,deadline_s,elapsed_s,stale_age_s;budget_exceeded=Falseandcost_class="cheap"instead of reading the projection contract, so a facets run over budget reported itself cheap and within budget;omittedin both complete and deferred,total_countsmissing entirely — versus_FACET_CORE_FAMILIES/_FACET_DEFERRED_FAMILIES;PostFilterScopeTooLargeErrorhandling, so a scope too large to post-filter raised instead of degrading. That one is the sharpest: it is directly against the rule that a named gap must never read as an empty scope, and it made the two surfaces disagree about whether the question was answerable at all.Breaking PR: #4867 (
1d901ec73), which deleted the API fallback fromfacets_command, so the daemon-less path stopped answering from the shared builder and started answering from_facets_payload.Solution
Adding the five missing keys by hand would reproduce the same drift on the next change to either side, so the assembly is extracted once:
api/archive.pygainsbuild_facets_response(...)— availability, family lists,family_status, gap classification, buckets, IDF, outcome — andPolylogue.facetsdelegates to it.daemon_reads._facets_payloadbuilds the same model (including thePostFilterScopeTooLargeError→ degraded path it previously lacked) and dumps it withmodel_dump(by_alias=True, mode="json").The two surfaces are now equal by construction rather than by keeping two key lists in agreement.
Anti-vacuity
The existing parity test is the condition, and it is a strong one: drop any field from the shared builder, or reintroduce a second assembly on either side, and
test_facets_command_json_matches_analyze_facetsgoes red on the exact key. It compares complete documents, so it cannot be satisfied by patching individual keys.Verification
Because this changes a product read path, I ran the wider facets/daemon-read surface as well:
Schema closure
Both OUT of the derived schema-identity closure. Does not need to land before an archive rebuild.
Residuals
test_json_status_snapshotgreen, which was failing in the original receipt but did not reproduce at HEAD — I am not claiming it as a fix, only noting it now passes.cwd_prefixesandtime_rangeare set by neither surface. That was true before this change and is unchanged; the shared builder makes it visible in one place rather than two.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK