Repository navigation
feat(sources): stream Claude AI, AI Studio and Hermes object shapes - #5776
Conversation
…ratch normalize_chat_messages now keeps only lineage and ranking fields per record in its graph phase; text, blocks, attachments and the raw record live in an evidence store. The object parser uses resident stores, while sealed preparation spills records to SQLite before EOF and emits messages, events and merged attachments to disk sinks. The probe keeps root fields and the first future wire type for parser admission. The sink's active-path walk now starts at the leaf row, matching the resident writer when a later message repeats the leaf's provider id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
parse_chunked_prompt now lowers chunks through one record route that reads the chunk array once per pass: branch evidence, then messages, events and attachments written to the supplied sequences, then the leaf flag and linear parent fill applied to the rows they change. Sealed preparation re-reads chunkedPrompt.chunks or the root chunks array with ijson. The root-envelope probe is shared with the claude.ai route and carries the first future wire type for parser admission. TimestampBounds replaces select_timestamp, whose only caller was the collecting chunk loop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
parse_atif_document and a new parse_atif_stream share one lowering that reads steps and subagent trajectories as iterables and writes each session's events to its own sequence. Sealed preparation re-reads both arrays with ijson, so step events reach SQLite before EOF, and applies the same positive-evidence filter and cohort finalizer as the collecting route. ATOF, state and verification documents keep their precedence. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Grok event probe no longer refuses a document holding a future wire type. It records each conversation member's first future type, in the order parser admission walks the member, and the streamed route admits the member over a stub carrying that type. Events and accounting match the per-conversation object parser; a future type outside a member is not admitted by either route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lers The derived-sweep census names _merged_attachment, which replaced _merge_attachment_rows, and browser capture passes its resident message rows to ParsedSession as a list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lylogue-20260928-223315-0654a082/integration # Conflicts: # polylogue/sources/prepared_message_sink.py
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 716df8b605
ℹ️ 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".
…stamps The streamed future-type probe kept a candidate from a value a repeated key later replaced; the parser's dict keeps the first key position with the last value. TimestampBounds picked the final repeated spelling at the latest instant, where the list-based selection deduplicated spellings first. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a9ef2d0b6
ℹ️ 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".
…amed route The decoder keeps a repeated key's last value, but the streamed probe had already counted the array under the overwritten one. A repeated key on the path to a streamed array now refuses streaming, so the object parser decodes the document. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f8ba4d7d2
ℹ️ 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".
The Hermes snapshot walker still stored nested candidates in first_child, which map frames no longer consult, so a nested future type was dropped. Both walkers now adopt child candidates through one frame method. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7984796b54
ℹ️ 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".
…streamed route Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
## 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]>
## Summary Fixes the still-real parser findings from bead polylogue-1tyq5.27 (unhandled Codex P1 review threads on merged PRs). ## Problem - Admission accounting was fail-open: the production Claude Code multi-session stream, Codex streams and undecorated lowered routes produced sessions with no outer-record ledger (F695, F779), and a record without an unknown-type sentinel was counted as materialized even when the parser skipped it, e.g. a scalar record in a JSONL stream (F780). - OTel GenAI: every span re-emitted the full input history, duplicating earlier messages (F075); usage was kept only for `chat` operations (F077); unnamed resources collapsed onto one id and merged unrelated sessions (F079); ordinary HTTP/DB traces in a GenAI export became zero-message sessions (F080). - Drive: one event carried the whole citation list, so an appended citation changed that event's identity and revision membership read ordinary growth as ambiguous (F507). - Preflight refused a verified Antigravity trajectory schema whose steps produced no messages, so its typed empty/unsupported evidence could never be acquired (F350). ## Solution - `base_support.AdmissionObserver`: one classifier per session's outer records (materialized / typed unknown / typed refusal for non-object records). `parser_admission` uses it; the Claude Code stream keeps one observer per session group; the Codex stream route and `_parse_lowered_spec` apply it to single-session results that lack a parser ledger. - `otel_genai`: history-overlap suppression per conversation transcript, usage fallback for any operation, resource ids derived from the resource attribute set when `service.name` is absent, and a filter keeping only traces that contain a GenAI span. - `drive`: one `gemini_citation` event per citation with its ordinal. - `import_preflight`: a verified schema with trajectory rows is admissible, with caveats for no-message and degraded steps. Other findings in the group were already fixed on master or belong to other work: F319 (#4966/#4972), F351 (#5403), F419 (#5550), F505 (#4861), F647 (#4587), F850 (#4236); F029 is routed to the intake enrichment work (#5643). ## Verification - `devtools test` over the OTel, Drive contract, preflight, admission, Codex event-stream and `tests/unit/sources/parsers` selections: 1 failure in a new test (a missing `messages=[]`), fixed; that test passes alone. - New tests: history dedup, distinct unnamed resources, non-GenAI trace exclusion, non-chat usage, grown citation list, verified trajectory without messages, Claude Code stream admission, scalar-record refusal. ## Residuals - Hermes multi-session ATIF streams still lack per-session admission; noted on the bead. - `base_support.py` overlaps #5682's in-place event handling; a small rebase conflict is expected. - Schema closure: the parser files are in the derived identity closure, so this must land before the fresh build. ## Self-review I reviewed the whole diff at the final head, not only the last round. The findings are grouped by the invariant each one protects. **Admission conservation (every emitted session carries a closed proof)** - `admit_parsed_sessions` proves every session that lacks its parser's own ledger. The document is observed once and the closed proof is shared (`AdmissionObserver._closed_proof`), so an N-session document costs one scan. - Every origin's scanner reads only discriminators: - Claude: record `type` and block `type`. - Codex: envelope and payload `type`. - Hermes: `type`/`kind`/`record_type` and step kinds. - OTel: span `kind`, registered under the provider token the route passes (`opentelemetry`). - The default scan used by the other undecorated routes never descends into `arguments`/`input`/`output`/`result`/`attributes`, so a tool argument `{"type": "unknown"}` is data, not a wire type. - The streamed Hermes ATIF carrier that master added in #5776 now gets the same proof as the dispatch route over the same bytes. Each step's `type`/`kind` is observed as the parser consumes it, so no second decode is needed and a future step kind beyond the classifier's 64-step witness is still recorded as a typed unknown (`test_streamed_atif_trajectory_carries_the_dispatch_admission_proof`). I checked the other #5776 streaming routes. The Claude AI, AI Studio/Drive chunked and ChatGPT routes reach decorated parsers, and Grok admits through `grok.parse_conversation`. - Admission events are appended in place to a disk-backed sink, and any other non-list sequence is copied into a list first. This keeps master's #5643 contract through the merge. - A record the parser skips is a typed refusal, never `MATERIALIZED`: - a non-object; - a Claude record with no string type (`recognized=False`); - a known-kind ATOF record that `looks_like_atof_payload` rejects (`malformed=True`). **Identity stability (an export revision updates, never duplicates, a session)** - OTel resource ids depend only on the resource's own stable attributes. They exclude instance, version and cardinality, so adding a second resource keeps the first one's sessions. - Copies of one span coordinate that disagree on `gen_ai.conversation.id` choose none (trace-keyed). - A shared ancestor belongs to the conversation whose descendant started first, so it cannot move when a sibling conversation is appended. - Trace membership and parent links work across resources within a trace. A span keeps its own resource (`resource_id` in its evidence), and spans with equal ids under different resources stay distinct. - Antigravity: rowids are never identity. Several trajectories with no id are refused (`LogicalExportError`), and one anonymous trajectory keeps the path fallback. **Complexity**: the history overlap is a KMP pass, linear in both lengths. **Checked and left as is**: Drive chunk/citation handling after the master merge (a conflict was resolved by combining master's `event_rows`/`chunk_records()` with this PR's `_citation_events`), and the Claude event ordering (`order_session_events`). **Verification** (final head 85329da): - `devtools test tests/unit/sources/parsers/test_otel_genai.py tests/unit/sources/test_admission_payload.py tests/unit/sources/parsers/test_antigravity.py tests/unit/sources/test_prepared_hermes_atif_object.py tests/unit/sources/test_prepared_claude_ai_object.py tests/unit/sources/test_prepared_drive_chunked_object.py tests/unit/sources/parsers/test_hermes_spans.py tests/unit/sources/test_parsers_base.py tests/unit/sources/test_parser_admission_packet.py tests/unit/sources/test_prepared_jsonl.py tests/unit/sources/test_first_future_type_duplicate_keys.py`: 352 passed, 0 failed. - `agentctl job start polylogue verify_quick`: succeeded (job 2117). **Residuals**: - polylogue-hlghl: ParseAccounting compresses unknown outcomes (pre-existing). - A Hermes duplicate event key is still counted as materialized: its evidence is carried by the first copy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Batch
polylogue-20260928-223315-0654a082on basea24df41bc7f2.polylogue-behu4 Bound provider single-object JSON preparation
polylogue-9m93s Use one retained-input route for every file size