Skip to content

fix: Codex turn_context fixtures carry a payload key that occurs zero t… - #4972

Merged
Sinity merged 2 commits into
masterfrom
batch/polylogue-20260912-175329-3a07bd71/integration
Sep 12, 2026
Merged

Sinity merged 2 commits into
masterfrom
batch/polylogue-20260912-175329-3a07bd71/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260912-175329-3a07bd71 on base a158a90e515a.

polylogue-6rzct Codex turn_context fixtures carry a payload key that occurs zero times; no field extraction is tested

  • The six-key observed payload produces asserted turn_context and agent_policy fields.
  • The extended observed payload asserts personality, collaboration_mode, turn_id, and user_instructions.
  • A deletion of any named parser extraction makes a named focused test fail.
  • The focused test files and quick verification pass.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d73e0f85-08ee-48bf-9259-a1592b0d2dae


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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-12T18:04:46.319361Z edf6011 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 merged commit 1855808 into master Sep 12, 2026
3 checks passed
@Sinity
Sinity deleted the batch/polylogue-20260912-175329-3a07bd71/integration branch September 12, 2026 18:10
Sinity added a commit that referenced this pull request Sep 29, 2026
## 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]>
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