Skip to content

fix(intake): stream Gemini sidecar joins and route parse-worker events - #5762

Merged
Sinity merged 7 commits into
masterfrom
batch/polylogue-20260928-210243-0e4effe7/integration
Sep 28, 2026
Merged

Sinity merged 7 commits into
masterfrom
batch/polylogue-20260928-210243-0e4effe7/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260928-210243-0e4effe7 on base 82e84ec7515d.

polylogue-uh5go Stream Gemini CLI tool-output joins through sealed scratch

  • Gemini CLI single-object checkpoints with an available sidecar scope reach sealed preparation with messages, events, tool ownership, and replacement state in scratch storage; a multi-message fixture s
  • Focused acquisition and retained replay fixtures match the object parser for session/message/block IDs, content hashes, duplicate tool IDs, sidecar matches, masked replacements, missing-file debt, siz
  • Malformed suffix, source mutation, and worker failure leave no publishable partial artifact; focused devtools tests, local quick gates, and hosted quick pass with exact receipts.

polylogue-behu4 Bound provider single-object JSON preparation

  • Every supported single top-level JSON object and wrapped session/member shape reaches the ordinary retained preparation route with bounded message/event/identity state, no size-based refusal, and visi
  • Small fixtures for each moved provider shape match the object-returning parser in session/message/block identities, content hashes, ordering, duplicates, lineage, attachments, sidecars and events; obj
  • Malformed suffix, source mutation and killed-worker cases leave no publishable partial artifact and preserve retry/failure semantics; focused devtools tests, quick static gates and hosted quick pass w

polylogue-9m93s Use one retained-input route for every file size

  • One ordinary retained-input route handles every file size and removes the size branches that silently exclude or separately defer valid inputs. Focused synthetic tests show complete membership, per-re
  • Worker isolation and focused fault tests turn a killed parse worker into a typed per-file failure while the daemon survives, and ensure queue/memory accounting does not lie or starve foreground progre
  • Focused devtools tests and relevant quick gates pass on the fixed code candidate with exact selectors and receipts. The measured 419 MB RSS bound and 1.6 GB scratch daemon convergence remain open in t

polylogue-irddg Bound live frontier preflight while preserving global refusal

  • After one complete bootstrap, several ordinary dispatcher pages that publish source/index/cursor changes perform no archive-wide seed enumeration. Changed-key and selected-component work is measured;
  • External SQLite source raw DELETE/raw-ID UPDATE and index session/head INSERT/reference UPDATE/REPLACE are transactionally observed. An unrelated missing referenced raw refuses a page before cursor in
  • Concurrent mutation during reconciliation, rollback, interruption, restart, fork, index promotion, tier replacement/disappearance, schema or trigger mismatch, and truncated journal coverage cannot pre
  • Selected-path proof preserves canonical attribution: ahead cursors and broken chains refuse affected paths while healthy siblings proceed; mixed byte/membership containers, shared logical keys, new pa
  • An all-deferred selected page still refuses unrelated missing session/head raw evidence, while the same page without global loss retains safe deferred behavior.
  • A small matched empty/medium/larger dispatcher frame records global scans, changed-key checks, selected-component work, writer-held/outside time, and completed pages; no required integrity work is def
  • Fresh-v1 source/index DDL, indexes and derived identity agree on the integrated candidate. Any pre-existing fresh scratch root is reset by its owner before construction; all identity-moving changes la

polylogue-qw8zp Rebuild observability: running throughput and ETA from attempt rows, one structured chunk event, one log stream

  • 1. status reports cumulative files, bytes, running MB/s over the cycle and an ETA against the planned denominator, computed from durable attempt rows. 2. Every catch-up chunk emits one structured even

polylogue-10a3q Make the observability page a cheap live build monitor

  • The real observability page renders current owner phase/progress plus frame/sample-age/staleness evidence, including pre-first-publication discovery once qw8zp lands; missing denominators never imply
  • Opening or refreshing status makes no insight-descriptor queries; a held insight query cannot delay monitor SSR/status refresh, and explicit insight loading still works.
  • Only one visible-page status request is in flight, hidden/unmounted pages stop/abort it, late responses cannot replace newer evidence, and disconnects retain visibly stale last-known data.
  • Focused Preact/backend route tests and typecheck pass with actual page/client seams; tests fail on the old all-insight status refresh and dropped snapshot metadata.

Sinity and others added 7 commits September 28, 2026 23:03
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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T22:29:49.474615Z 12fa8f1 PR opened
🔒 Security Review ✅ Completed 2026-09-28T22:29:20.669845Z 12fa8f1 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity Sinity changed the title chore: Stream Gemini CLI tool-output joins through sealed scratch fix(intake): stream Gemini sidecar joins and route parse-worker events Sep 28, 2026
@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 22:29
@Sinity
Sinity merged commit a24df41 into master Sep 28, 2026
3 of 4 checks passed
@Sinity
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant