Repository navigation
fix(search): report executed lanes from the one ranked read - #5795
Merged
Merged
Conversation
The compact receipt already reported a fixed-size count, but the census still sorted each carrier directory into a list before counting it. A day directory holds one PID-scoped carrier per hook invocation, so one wide directory was materialized whole just to be counted. Walk with one live scandir iterator per depth and close every iterator on exit. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Search execution now returns its hits together with the lanes that actually ran, and every surface projects that one result: - the actions lane runs action-block FTS and no longer demands embeddings; - hybrid fuses text, action and vector legs; an unavailable, empty or failing vector leg degrades to the lexical legs under the hybrid lane (so its cursor pages), while cancellation and deadlines still abort and archive read faults are not relabelled as a vector failure; - pure semantic search refuses typed on a vector failure instead of leaking the provider exception; - sqlite-vec refuses typed before buying a query embedding when no stored vector matches the current messages and recipe; - CLI, MCP and daemon envelopes carry the same execution evidence; MCP search routes through the shared ranked read, and its unused retrieval_lane parameter and hit-payload helper are removed; - hybrid, actions and vector totals are an honest null instead of a count over a different relation; the daemon envelope offset tracks the cursor page. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Sinity
enabled auto-merge (squash)
September 29, 2026 03:30
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. |
Sinity
added a commit
that referenced
this pull request
Sep 29, 2026
…5850) ## Summary Makes master's focused suites green again. The baseline run on master `633ec18ffc` (job 3431, 30 files) had 41 failures and 1 error, and every other PR was running into them. They come from 20-odd separate causes. Where production was wrong, this PR fixes production and uses the failing test as the regression. Where a merged PR had deliberately changed the contract, it updates the test to the new contract and cites that PR. Two failures remain, each with a bead and the evidence below. Beads: polylogue-ouv5f (all eight tests fixed), polylogue-0e6m3, polylogue-h9da0 and polylogue-wple (audited and noted; their open criteria are listed under Residuals). ## Problem Job 3431 (`pytest_focused --on-default-branch`, 30 files, 1539 tests) reported `passed 1497, failed 41, error 1`. Its failed-test rerun also crashed: the rerun passed `…::test_x@web-reader[param-…]` back to pytest, and pytest answered `ERROR: not found`. ## Solution: production defects fixed | Failure | Cause | Fix | |---|---|---| | `test_raw_observation_derivation` ×4, `test_retained_tool_output_convergence` (Gemini) | For providers with no assembly spec, `enrichment_dependency_digest` skipped the evidence digest that every retained seal computes. Every prepared artifact of those providers therefore read as stale, and `publish` returned False forever, so Hermes, Antigravity, ChatGPT and Gemini retained raws never converged. | Every provider digests its evidence, empty or not (`sources/revision_backfill.py`). | | `test_observation_runtime::test_structured_raw_only_sidecar…` | An artifact-scoped identity hashed to the same `{"source": path}` value that `_old_path_fallback` refuses, so new sidecar evidence never reached the cache. | The artifact-scoped identity gets its own namespace (`schemas/source_inference.py`). | | `test_verification_evidence_lane` | `reconcile_and_record_abandoned_verify_runs` compared `cache.parent` (that is, `.cache`) to the checkout, so the test was never true. The checkout's reconciled runs went to cache-local history, and cache-local evidence too (#5720), instead of the durable lane. | Compare the checkout root, `runs_root.parents[2]`. The checkout uses the XDG history and `verification_evidence_path()`; a relocated cache keeps local files. | | `test_web_reader::test_archive_filter_kwargs…` | #5795 gave `iter_search_summaries` an `actions_only` lane parameter. The count route still counted every FTS hit for `retrieval_lane="actions"`. | `count_search_sessions(actions_only=…)` and the count route pass the lane. New regression: `test_actions_lane_count_counts_only_sessions_its_search_returns`. | | `test_command_catalog::test_tool_outcome_help…` | A Click-level required option refused `--help` before argparse could print it (#5720). | argparse owns requiredness, and the metavar is `PATH`. | | idempotence properties (found while fixing the harness) | `refresh_session_repos*` stamped `repos`, `repo_checkouts` and `session_repos` with the wall clock, so no rebuild could reproduce them. | Stamp them with the session's own time, as `_write_repo_edges` does. New test: `test_refresh_stamps_the_session_time_not_the_wall_clock`. | | `test_daemon_http_security` | The daemon client that carries the credential was chained into the receipt call, so the token scan flagged the receipt. | Bind the client first (`browser_capture/server.py`). No allowlist entry was added. | | failed-test rerun | `report_nodeid_to_selector` did not handle `name@group[param-…]`, the shape that shortened ids take under loadgroup, and the long-id map stored uncollectible `@group` ids. | Handle that shape, and record both map sides in selector form (`devtools/pytest_rerun.py`, `tests/conftest.py`). | | `test_session_partition_convergence` (fd leak) | The per-thread connection cache kept every archive a test built until the descriptor check ran. | The autouse fixture clears the cache at teardown. | | `test_session_partition_convergence` (`fields_digest`) | #5799's column was neither projected nor excluded. | Exclude it, with the reason (`derived/session/input_binding.py`). | ## Solution: tests updated to contracts that merged PRs changed - `test_import_preflight`: several unidentified trajectories are refused (#5711); the old test expected ids minted from row position. - `test_artifact_taxonomy`: a brain sidecar is observed as `agent_sidecar_meta` schema evidence (#5781), never as a session. - `test_tool_result_unknown_reason_contract` ×3: a step with no verdict field is `not_reported` (#5798). A new route covers `unsupported_construct` with an unmapped status. - `test_source_laws`: the stand-in parser accounts for its outer records (#5816). - `test_revision_replay`: the direct replay binds Codex enrichment evidence as the retained writer does (#5643). - `test_retained_tool_output_convergence` (Gemini): the fixture sidecar is longer than the 40,000 characters the envelope advertises (the #5643 partial-write guard). - `test_schema_policy_contracts`: FTS triggers are matched by whole table name (`messages_fts_readiness_binding` is not FTS-backing); the restart test clears the bootstrap memo as a restart does (#5428). Deleted `test_every_prior_index_schema_version…`: at fresh v1, `SCHEMA_VERSION - 1` is 0, which is the "interrupted create" state that is re-created by design. No prior version exists. - `test_durable_migrations`: an archive two slots behind gets the typed refusal from #5806, and the tier is untouched. The docstring of `apply_declared_durable_migrations` is corrected. Filed as polylogue-7yq3f. - `test_schema_validation`: the member schema names `id` (#4856 reports unnamed fields), and the keys are plain names, so the marker is what suppresses them. - `test_synthetic_wire_support::test_chatgpt_witness…`: the part text also survives on the tool block, so the test drops it there too. - `test_archive_ingest_shared_raw`: a ZIP member with a malformed record is `terminal_corrupt_input` (#5823 F039); a census runs once per raw. - `test_plain_cli_snapshots`: empty is exit 2 and degraded is exit 1 (`surfaces/outcome.py`). - `test_cross_surface_agreement`, `test_query_composition_laws`: the CLI reads through a real daemon (#5805). The naive-join mutant lifts the read authorizer (#5642) the way `attach_readonly_database` does. - `test_resource_pilot` ×2: parser scratch SQLite (`:memory:` and temp files) is allowed; any database file or tier is not. - `test_codex_debt_w1` and the convergence properties: the harness bound each session's own evidence to message 0 and stamped replayed messages with the child's values. Since #5826 shares only an identical prefix, no lineage prefix was shared at all, and the append-prefix laws were vacuous. A fork now replays its parent's parsed prefix exactly, and its own evidence moves to the first message it authored. The mutation test's `_resolve_session_graph` mutant returns `set()` to match the current signature. - `test_query_exec_laws` ×4: stub the convergence probe in fake-store stats tests (#5700), add the `tool_input` projection field, and expect a second window sized to the remaining limit. - devtools: `test_verify` stubs the executor, `test_pytest_suite_cost_plugin` builds the recorder before patching RSS, `test_verification_terminal_receipts` updates the sizing stub signature, and `test_verification_result` adds the #5720 `flaky` field. `test_http_bounded_mutations` adds the #5723 summary read to its test double. Derived-identity closure (`devtools schema closure`): these files are IN: `archive/query/archive_execution.py`, `schemas/source_inference.py`, `sources/revision_backfill.py`, `storage/derived/session/input_binding.py`, `storage/derived/session/repo_observations.py`, `storage/sqlite/archive_tiers/archive.py`. The rest are out. ## Verification - Baseline, master `633ec18ffc`, job 3431: `passed 1497, failed 41, error 1`. - `agentctl job start --workspace /realm/worktrees/polylogue-master-green polylogue pytest_focused -- <61 files>`, job 3578, head `a7f4465c56`: `passed 2336, failed 2` after the in-slot rerun. The first attempt ran under host I/O contention, with workers in D state. 25 of its 27 first-attempt failures were `Timeout (>120.0s)`, and every one of those passed when rerun alone. - `test_web_reader::…searches_from_archive_tiers`: a socket timeout under the same load. It passed alone in job 3861 (`devtools test: PASSED exit=0`). - `test_supported_routes_validate_selected_schema_and_parser_entry_point`: inherited, see Residuals. - Master baseline for the added files, job 3562: `test_query_exec_laws` ×4, idempotence ×7 and mutations ×2 fail on master the same way. All of them are fixed here. - Harness consumers and count seams at head `1d3b3545c5`, job 3920 (24 files): `passed 589, failed 1` after the in-slot rerun. The one failure, `test_inferred_corpus_loop::test_every_supported_inferred_element_reaches_convergence_and_red_twin`, was a `Timeout (>120.0s)` inside `load_package_catalog` under the same host load. It passed alone in job 3973 (`devtools test: PASSED exit=0`). - `verify_quick` on head `1d3b3545c5`, job 3921: `verify: PASSED exit=0`. The hosted `ci/circleci: quick-gate` passes. - `verify_quick` on head `a7f4465c56`, job 3579: `verify: PASSED exit=0`. ## Self-review I did two passes over the full diff against `master`, using `docs/review/codex-review-guide.md` and the generic worker-contract list. Pass 1 found two defects, both fixed in `1d3b3545c5` and `3ec0a5fa2f`. Pass 2 was clean. 1. ✓ **Siblings and owners.** The actions-lane count was also wrong in two more places: the facade/daemon seam `_archive_count_sessions_for_spec` and the daemon `count` mode (`operations/daemon_reads.py`). Pass 1 found them with `grep -rn count_search_sessions polylogue` (7 call sites); both are fixed and have a regression test. The MCP route already reports `total=None` for actions (`mcp/archive_support.py` `ranked_only`), and `sessions.search` is lexical only. The enrichment digest has a single owner (`enrichment_dependency_digest`) used by both the live and the retained check. Every seal computes the evidence digest unconditionally, the live enricher included. A search of `polylogue/storage/derived` for wall-clock stamps found two others: the marker cursor `applied_at_ms` (operational metadata) and `profiles.now_iso` (materialized-at). Neither is a semantic column. 2. ✓ **The fix itself.** Pass 1 found that `_replayed_parent_prefix` would recurse forever on a declared parent/child cycle (`cycle_candidate=True`). It now tracks the lineage it walks, and picks the parent revision the way `authoritative_sessions` does. `count_search_sessions(actions_only=False)` defaults to today's behaviour for every other caller. 3. ✓ **Memory and limits.** Nothing new grows with the input. The repo stamp is one indexed `SELECT` per refreshed session. No caps or timeouts were added. 4. ✓ **Cost per unit.** One predicate on the count query and one primary-key read per repo refresh. `with_retained_assembly_evidence` returns at once for providers without assembly evidence (`sources/retained_assembly.py:470-479`). 5. N/A **Interruption.** No loops, waits or multi-step state changes were added. 6. ✓ **Ordering and races.** The repo stamp is read inside the materializer's own transaction, on the same connection that writes the rows. 7. ✓ **Failure classification.** The reconciler's history and evidence appends keep their existing `suppress(OSError, ValueError)`. `verification_evidence_path()` now expands `~`, as the old inline override did. 8. ✓ **Silent outcomes.** Actions-lane totals now count what the lane can return. Exit codes follow outcomes (`surfaces/outcome.py`), and the updated CLI tests assert exit 2 for empty and 1 for degraded. 9. N/A **Cleanup on failure.** Nothing new is acquired. 10. ✓ **Identity and keys.** Artifact-scoped source identity now lives in its own `{"artifact": …}` namespace, so it can no longer collide with the retired `{"source": path}` identity. Old cache rows under the path identity are still refused by `_old_path_fallback`. 11. ✓ **Lossless transforms.** The rerun selector keeps the `[param-…]` label, and the long-id map now stores both sides in collectible form. The harness deep-copies the parent messages it replays. 12. ✓ **Degenerate inputs.** A missing session row stamps 0, the writer's own default. A child with no own messages keeps position-0 evidence. A shared prefix of 0 replays nothing. 13. ✓ **Consumers.** `count_search_sessions` gained an optional keyword; every test double takes `**kwargs`, and none asserts the exact kwargs (checked at `test_query_exec_laws.py:1301,1385,2099` and `tests/infra/archive_store_double.py:255`). The unused `now_iso` parameters were removed, and `grep` finds no callers passing them. 14. ✓ **Tests and stubs.** Each production fix has a test that goes red without it. The count tests go 2 → 3 without `actions_only`. The repo test goes red if the rows are stamped with the wall clock. The evidence-lane pair covers the checkout and the relocated cache. `test_rerun_selector_strips_the_xdist_group_suffix` covers the new id shape. The source-inference test goes red without the separate namespace. Stubs follow the current signatures: the `resolve_worker_argument` stub takes `**sizing`, the `_resolve_session_graph` mutant returns `set()`, and the test double implements `get_session_summaries`. 15. ✓ **Trust boundaries.** The capture handler binds the credential-holding client apart from the receipt, and no token-scan allowlist entry was added. The fixtures are synthetic. Generic list: (1) criteria are met on production routes (probes and job 3578). The unmet ones name their blockers (4xyn9, 7yq3f, h9da0, 0e6m3, wple). (2) Siblings: see item 1. (3) No predecessor is kept beside a replacement. (4) No silent fallback was added. (5) Each new test names the change that turns it red. (6) The diff, receipts and text carry no secrets or private data; the paths are worktree scratch paths only. ## Residuals - polylogue-4xyn9: `test_supported_routes_validate_selected_schema_and_parser_entry_point` still fails. The claude-ai v2 coverage witnesses combine mutually exclusive groups, so 529 of 844 keywords are missing. It fails the same way on every commit back to #5485 at least. Honoring the exclusions in coverage mode alone still leaves 319 missing, so this needs a coverage planner. - polylogue-7yq3f: catch-up across more than one numbered slot is refused, and a backup is taken before the refusal. Nothing breaks until the second migration of a tier ships. - polylogue-3p8p7 (owned elsewhere): a loose malformed workflow journal still reads as `workflow_journal` through the lenient retained decode; the ZIP route is strict. - polylogue-h9da0: quick-pool xdist width is sized from the slice's current headroom, not from a per-job share. Two jobs that start together can both admit a full width. Left open. - polylogue-0e6m3: the per-cache retention measurements need a scheduled broad run. Left open. - polylogue-wple: master already enforces the foreign-interpreter and foreign-import checks. Detecting copied testmon or verify state is still open. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
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.
Summary
Search now returns its hits together with the lanes that actually ran, and the API, daemon, CLI and MCP envelopes all project that one result. The actions lane no longer needs embeddings. Hybrid fuses the text, action and vector legs, and when the vector leg is unavailable it degrades to the lexical legs under the
hybridlane. Semantic search refuses with a typed error instead of leaking provider exceptions or reporting an empty success. Separately, the hook carrier census now reads each directory as a stream.This salvages ChatGPT fleet worker 3's unverified patch for beads polylogue-1tyq5.35 and polylogue-1tyq5.21. The patch was reviewed, corrected and verified here.
Problem
These are Codex findings on PR #4180 and PR #5447. Each was checked against master before its fix was kept.
archive_search_hitstreatedretrieval_lane="actions"as a semantic lane. Without a vector backend it raisedEmbeddingRetrievalNotReadyErrorinstead of returning action evidence.provider.query()had no handler around it. When the vector service failed, hybrid lost its lexical hits and pure semantic search leaked the provider exception.format_search_envelope,session_search_result_payloadand MCParchive_search_payloadnever passedexecution. A degraded hybrid therefore looked healthy on those surfaces.spec.count(), which counts only the semantic leg. The result wastotal=0next to a full page, and that suppressed continuation.dialogue, so the next page's hybrid request rejected the cursor this route had minted. This happened on both the API route and the daemon route.[]as a successful empty search.Solution
archive_search_hitsreturnsArchiveSearchResult(hits, retrieval_lane, execution), andproject_search_hitsprojects it without rebuilding the lane story.ArchiveStore.iter_search_summaries(actions_only=True)(tool_use/tool_resultblocks). It streams over one cursor until it has the requested number of distinct sessions.EmbeddingRetrievalNotReadyErrormakes the lane unavailable.execution_failed.semantic_summariesread is outside that handler, so an index fault is never relabelled as a vector failure.SqliteVecProvider.queryrefuses withreadiness_status="empty"before buying a query embedding when nomessage_embeddings_metarow matches the current message and recipe projection. That table is the writer's own authority for whether a vector exists.null, which the daemon route already reports. The daemon envelopeoffsetfollows the cursor page.archive_search_payload'sretrieval_laneparameter, which was ignored because the spec already carries the lane;archive_search_hit_payload, which no longer has callers.docs/search.mddescribes hybrid degradation, null totals and semantic readiness.scandiriterator per depth and closes every iterator.Verification
agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w3 --wait, job 2136 on 9e3e005:verify: PASSED exit=0. All 12 gates pass, including mypy, layering and schema-closure.agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w3 --wait -- <21 files>, job 2145 on 9e3e005: 358 passed, 3 failed. The selection covers:tests/unit/sources/test_hook_carriers.py;test_query_ordering_authority.The 3 failures are in
tests/unit/storage/test_embedding_dedup.py(status 'error' != 'embedded'). They also fail on the unmodified base dc21dd4 in job 2133, so they predate this change.Negative control: job 2065 ran the new tests on the unmodified base f7ad8d8. Every fix test failed there:
totalwas 0 instead of None.dialogueinstead ofhybrid, and the daemon rejected its own cursor.EmbeddingRetrievalNotReadyErrorwas raised.RuntimeErrorleaked.project_search_hitsarity and missing.hits. These are API-shape failures; their behavioural assertions are covered by the post-fix run.Self-review
archive_search_hitsandproject_search_hitsmoved to the new result: API, daemon, the MCP list and search paths, and tests.format_search_envelopeandsession_search_result_payloadhave no production callers, but both now accept and forward execution. The session-seed branch needed a sibling fix to keep its typed refusal.(offset + limit) * 3. The census never holds a directory listing.except Exceptioncovers onlyprovider.query(), and it recordsexecution_failedas a named degraded outcome. Non-hybrid lanes refuse with a typed error.retrieval_laneparameter and the dead hit-payload helper were deleted rather than kept.archive_search_hit_payloadfinds only docstring mentions. The monkeypatch targets forarchive_search_hitsin the MCP tests were updated to the new return type.open_operation_read,Polylogue,execute_read_operationand the MCP builder; only the external vector service is substituted. The readiness test exercisesSqliteVecProvider.queryon a snapshot connection, with vec-extension loading stubbed out.Findings
archive_execution.pysentactionsdown the vector pathtest_actions_without_embeddings_return_only_action_evidencevector_provider.querytest_vector_execution_failure_degrades_hybrid_and_refuses_semantic,test_vector_read_cancellation_is_not_a_successful_hybrid_degradation,test_archive_read_failure_is_not_relabelled_as_a_degraded_vector_lanebuild_search_envelopecalls had noexecutiontest_cli_and_both_mcp_builders_preserve_degraded_executionsearch_envelope_builder.pyusedtotal = await spec.count(...)test_hybrid_api_does_not_publish_semantic_only_total"dialogue"test_degraded_hybrid_api_cursor_keeps_request_lane,test_degraded_hybrid_daemon_cursor_keeps_request_lane_query_unlockedbought an embedding with no readiness checktests/unit/storage/test_vector_query_readiness.pytest_degraded_hybrid_fuses_action_rank_contributions_carrier_scope_summarystill calledsorted(entries)test_compact_carrier_census_streams_wide_directorieshook_producer.py:282: producers never wait for the drainDerived-identity closure
devtools schema closurereports these changed files as IN:polylogue/archive/query/archive_execution.pypolylogue/archive/query/search_contract.pypolylogue/archive/query/search_hits.pypolylogue/sources/hook_producer.pypolylogue/storage/search_providers/sqlite_vec_queries.pypolylogue/storage/sqlite/archive_tiers/archive.pyEvery other changed file is out. The edits are semantic, so the candidate identity may move; land this before a rebuild starts.
Residuals
SessionSearchHitPayload.from_search_hit, so they gainmatched_termsand a domain-shaped session summary. The focused MCP and parity suites pass with this.tests/unit/sources/test_hook_carriers.py::test_compact_and_materialize_ten_thousand_eventsis a timing test. It failed twice under host load (758 and 1018 events/s against a threshold of 2000) and passed in the final run. Its timed window,materialize_hook_carriers, does not include the changed census.polylogue/mcp/server_cutover.pyloses one line, and fix: close worker-13 MCP, surface and excision review findings #5779 also edits that file, in other hunks.🤖 Generated with Claude Code
https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg