Repository navigation
fix(intake): stream Gemini sidecar joins and route parse-worker events - #5762
Merged
Sinity merged 7 commits intoSep 28, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The changed-key batching test opens about 1,600 SQLite connections through helpers that used the connection as a transaction context without closing it; under a queued job's descriptor limit the test failed with 'unable to open database file'. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…elation Process-pool parse workers configured structlog but never configure_events, so every emit in a worker reached no sink and was lost uncounted. Workers now configure the same env-resolved sink (POLYLOGUE_LOG_FILE, now line-buffered so records from several processes cannot interleave), restore the parent's run context, and drain through a multiprocessing finalizer because workers exit through os._exit. Parse-stage submits wrap their callable in carry_context, which carries only correlation fields (never write authority), replaces a reused worker's stale context, and pickles across the process boundary. The observability island test flushed one microtask before asserting; the credential-retry wrapper from #5727 added another await. The stalled-worker test's 5 s start wait was below spawn time on a loaded host; only its shutdown carries the bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lylogue-20260928-210243-0e4effe7/integration
…lylogue-20260928-210243-0e4effe7/integration
…lylogue-20260928-210243-0e4effe7/integration
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
enabled auto-merge (squash)
September 28, 2026 22:29
Sinity
deleted the
batch/polylogue-20260928-210243-0e4effe7/integration
branch
September 28, 2026 22:31
Sinity
added a commit
that referenced
this pull request
Sep 29, 2026
## Summary Intake preparation batch: live and retained routes now publish the same interpretation of the same bytes, pending live paths prewarm their existing retained members off the writer, Gemini CLI sidecar joins and ChatGPT text-node attachment/event evidence move to sealed scratch, and one-shot teardown no longer stops the parse stage under an admitted writer. ## Problem - The live route sealed sessions without provider assembly. A synthetic one-file Codex input produced title = native id and a different `content_hash` on the live and owned-cold routes than on retained replay (which titles it from the first authored prompt). The raw owner then reported the live output as `valid`, so it never converged. A fresh build through the live route would have kept native-id titles and dropped curated Claude Code index titles. - Enriching append chunks exposed a latent defect: a tail append merged the newest chunk's own title over the chain's title winner. A full replace would have stored the winner. - The writer reparsed existing retained members inline under its lease. A multi-raw accepted chain with a path carrier was deferred to the raw owner without that carrier, so the prepared write was discarded. - A cancelled one-shot ingest called `parse_stage.shutdown()` before waiting for the coordinator, so an admitted writer could lose its preparation. - Gemini CLI checkpoints with an available tool-output scope still fell back to whole-document parsing. ChatGPT text nodes kept their attachment and event evidence in memory. ## Solution - `RetainedSessionEnricher` (in `revision_backfill`) applies retained archive evidence one session at a time. Live path workers open read-only source/index frames and enrich each admitted session. The writer's inline fallback, the legacy retained reparse and append chain replay use the same enrichment. - `apply_raw_revision_replay` copies the aggregate's title triple onto a tail merge. The site is declared in the derived-sweep census. - Install-global retained sidecars (Claude Code/Codex history and session indexes) are parsed once per content hash, using a small bounded memo. Per-file enrichment therefore does not reparse history for every transcript. - Retained prewarm seals carriers for existing JSON/JSONL members. It uses the raw owner's predicate, and each carrier is bound to its raw descriptor. A per-member prewarm miss falls back to the writer and does not defer the live path. A chain is composed in the writer when every older member has a current carrier. - The one-shot teardown waits for the coordinator to go idle before shutting down the stage. - Cherry-picked verified slices: Gemini CLI sidecar joins in SQLite scratch, and ChatGPT text-node attachment/event spill. A route characterization test now asserts that session rows are equal across live, retained and cold routes. ## Supersession check (against master 2714453) Compared by behavior, not by file. Master does not contain this PR's core: no retained enrichment on the live/writer routes (`RetainedSessionEnricher`, `session_enrichment_bindings`), no chain title carry on tail merges, no retained prewarm (`retained_prefetch.py`), no typed value-bound refusal (`value_bounds.py`), no ChatGPT scratch spill for attachments/events/timings, and the one-shot teardown still stops the stage first. Master covers adjacent parts: #5762 streams Gemini CLI sidecar joins through scratch (this PR keeps only the completeness check against the advertised excerpt length and the read race check), and #5776 streams the Claude AI, AI Studio and Hermes object shapes that were a residual here. The merge resolves the overlap on master's side. ## Self-review - **Sibling sites per defect class.** Enrichment binding runs at three writer sites (ingest batch, retained precedence write, chain replay). All three now return early for providers without late-arriving evidence. Before, two sites ran the source/index queries first. Retained-member publication goes through `PreparedLiveRetainedRaw.current` at both consumer sites in `batch.py`. - **Cancellation and shutdown in loops.** Retained prewarm ran every member serially without checking the warm's cancellation. It now checks before each member and during verification, and discards what it sealed. The one-shot teardown ran settle, shutdown and close in sequence. A raising settle wait skipped shutdown and leaked the worker pool. The three steps are now nested `finally` blocks. - **Unbounded reads.** A Gemini sidecar read went to EOF on a file that could still be growing. It now stops one byte past the enumerated size. Scratch string-set iteration used `fetchall`; it now uses a cursor. The sibling append-chain walk rescanned every append per step, which is quadratic on long live chains. It now uses a predecessor index. - **Fail-open fallbacks.** Writer enrichment read `getattr(archive, "index_connection", None)`, so an archive without the attribute silently enriched with no evidence. It now reads the attributes directly. A prewarm miss (`OSError`, `ValueError`, retryable read) falls back to the writer's own replay, which is the owner, not a skip. - **Compatibility shims.** None added. The pre-existing `descriptor_reader is None` branch in `batch.py` (a master-era test-double path) is untouched and listed below. - **Tests prove the production route.** New tests drive `parse_sources_archive` with a failing settle wait, `prepare_live_retained_raws` over a real ingested archive with a stop callback, and `RawMaterializationDiscovery` against a real source table. Each names its anti-vacuity condition. - **Duplicated queue state.** A re-arrived `sessions-index.json` queued a second scan of the same project. The queue now holds one scan per project, restarted from the first transcript. ## Verification - `agentctl job start polylogue verify_quick` (job 1927) → 12/12 gates passed, including `gate schema-closure` and `gate mypy`. - `agentctl job start polylogue pytest_focused -- <15 touched test files>` (job 1928) → `devtools test: PASSED exit=0`, 672 selected, 672 passed. `test_live_append_takes_the_latest_rename` hit the 120 s pytest timeout under pool load (three full ingests) and passed alone on the harness rerun in 18.7 s. ## Derived identity Every changed production file except `operations/canonical_archive_ingest.py` is in the derived-identity closure. `retained_prefetch.py` and `value_bounds.py` join the closure baseline, and `index.db` gains `session_enrichment_bindings`. This moves the derived schema identity, so **it must land before the fresh rebuild starts**. ## Residuals - Retained prewarm over-approximates members (membership, retired siblings, head, replay plan) and prepares them serially while one read snapshot is pinned. That moves bounded work off the writer; it is not a measured throughput gain. - In a cold build, the worker reads evidence from the active index. Codex state-title projection written only to the candidate index is not visible to the worker. Parsed-content fallbacks still apply. - The in-memory ChatGPT route (no scratch spill) keeps master's 512 sandbox-attachment bound per message, reported as a counted degradation. The prepared route records every link. - `batch.py`'s `descriptor_reader is None` branch predates this PR. It now reaches `_parse_retained_raw_sessions`, which needs the descriptor, so it only serves test doubles that patch that method. Removing it is a separate cleanup. - `test_live_append_takes_the_latest_rename` runs three full ingests and can exceed the 120 s pytest timeout on a loaded pool. - The whale qualification has not been run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Batch
polylogue-20260928-210243-0e4effe7on base82e84ec7515d.polylogue-uh5go Stream Gemini CLI tool-output joins through sealed scratch
polylogue-behu4 Bound provider single-object JSON preparation
polylogue-9m93s Use one retained-input route for every file size
polylogue-irddg Bound live frontier preflight while preserving global refusal
polylogue-qw8zp Rebuild observability: running throughput and ETA from attempt rows, one structured chunk event, one log stream
polylogue-10a3q Make the observability page a cheap live build monitor