Skip to content

feat(sources): classify Codex response_item/event_msg orphan event types - #3567

Merged
Sinity merged 2 commits into
masterfrom
feature/parsers/codex-response-item-classification
Aug 2, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/parsers/codex-response-item-classification

Conversation

@Sinity

@Sinity Sinity commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an explicit allowlist-vs-passthrough classification at the Codex parser boundary for every response_item/event_msg inner type that reaches the generic session_event dispatch, and resolves agent_reasoning's fate (confirmed duplicate, filtered at write time).

Problem

sources/parsers/codex.py's generic session_event dispatch stored any unhandled response_item/event_msg inner type verbatim under Codex's own wire name (event_type=_record_type(inner) or _record_type(record) or "response_item") with zero code awareness of what that name meant. A producer/consumer audit (polylogue-fuky) found a live-archive cluster of such orphans with zero literal reference anywhere in the repo: agent_reasoning (318,474 rows), thread_goal_updated, sub_agent_activity, task_started, task_complete, context_compacted, turn_aborted, thread_settings_applied, collab_*, entered/exited_review_mode, view_image_tool_call, item_completed — plus three more found during this audit's own live-archive enumeration (web_search_end, thread_rolled_back, error).

Solution

  • Classification (_CODEX_KNOWN_RESPONSE_ITEM_TYPES, sources/parsers/codex.py): every type that reaches the generic dispatch is now named explicitly — both the pre-existing audited ones (token_count, reasoning, function_call, etc.) and this bead's newly-classified orphans — each backed by raw wire samples read directly from live Codex session files, not inferred from row shape. A type outside this set now routes to a distinct codex_unclassified_response_item bucket instead of silently adopting its own wire name, matching the claude_attachment_unclassified precedent in sources/parsers/claude/code_parser.py.
  • agent_reasoning's fate: confirmed DUPLICATE, not merely unclassified. Live-wire comparison across three Codex sessions found agent_reasoning.text is the same live-streamed reasoning-summary bullet text the paired reasoning record already carries in full (summary[].text) — one session 156/156 identical, a second 262/262 identical set, a third 1,846 vs 1,859 with >99% overlap. reasoning is already materialized as a THINKING-block message via _codex_reasoning_message (index v50), so agent_reasoning brings no incremental evidence. Added to _SESSION_EVENTS_REDUNDANT_TYPES (storage/sqlite/archive_tiers/write.py), matching the v42 agent_message precedent (a twin ParsedMessage already exists).
  • Schema: this is index schema version 55 (SEMANTIC_REPARSE, declared in lifecycle.py) — a writer-materialization change with no DDL delta on session_events, so existing rows require polylogue ops reset --index && polylogued run to actually drop (not executed by this PR).
  • The remaining orphan types keep passing through unchanged for now. Reading their raw wire records found real signal _compact_response_payload's generic allowlist silently drops today (e.g. thread_goal_updated's goal.objective free text, sub_agent_activity's subagent-delegation fields, error's usage-limit message/code) — a dedicated extraction pass is filed as polylogue-z1rdw rather than attempted here, since each needs its own bounded field-set decision plus its own SEMANTIC_REPARSE bump.

Alternatives rejected

Renaming every known type's stored event_type to a codex_-prefixed vocabulary was considered and rejected: it would force a reparse of every existing row for types whose classification (pass-through, intentional) doesn't actually change, with no reader benefit over the current wire-name-as-event-type convention already established for reasoning/function_call/etc.

Verification

  • devtools test tests/unit/sources/test_parsers_codex.py tests/unit/pipeline/test_archive_write.py — 114 passed, 1 pre-existing unrelated failure (test_validation_strict_detects_malformed_jsonl_beyond_large_prefix, confirmed present on master via git stash).
  • devtools lab policy schema-versioning — schema evolution policy intact.
  • devtools verify --quick — all 19 steps green, exit 0 (ran twice: once directly, once via the pre-push hook).

Ref polylogue-fuky

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3e7bb7c6-a26b-4413-9881-bf59b042cb6b

📥 Commits

Reviewing files that changed from the base of the PR and between a02eda8 and 885654e.

📒 Files selected for processing (8)
  • .beads/issues.jsonl
  • docs/internals.md
  • polylogue/sources/parsers/codex.py
  • polylogue/storage/sqlite/archive_tiers/index.py
  • polylogue/storage/sqlite/archive_tiers/write.py
  • polylogue/storage/sqlite/lifecycle.py
  • tests/unit/pipeline/test_archive_write.py
  • tests/unit/sources/test_parsers_codex.py

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.

Sinity added a commit that referenced this pull request Aug 2, 2026
polylogue-fuky's codex response_item classification landed in PR #3567;
appended the AC-by-AC resolution notes and filed polylogue-z1rdw to track
the deferred field-extraction work for the orphan types that keep passing
through unchanged.

Co-Authored-By: Claude <[email protected]>
Sinity added a commit that referenced this pull request Aug 2, 2026
polylogue-fuky's codex response_item classification landed in PR #3567;
appended the AC-by-AC resolution notes and filed polylogue-z1rdw to track
the deferred field-extraction work for the orphan types that keep passing
through unchanged.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/parsers/codex-response-item-classification branch from 93d05f3 to 1a7cc3c Compare August 2, 2026 14:23
Sinity and others added 2 commits August 2, 2026 17:06
Problem: sources/parsers/codex.py's generic session_event dispatch stored
any unhandled response_item/event_msg inner type verbatim under Codex's own
wire name (event_type=_record_type(inner) or _record_type(record) or
"response_item") with zero code awareness of what that name meant. A
producer/consumer audit (polylogue-fuky) found a live-archive cluster of
such orphans with no literal reference anywhere in the repo: agent_reasoning
(318,474 rows), thread_goal_updated, sub_agent_activity, task_started,
task_complete, context_compacted, turn_aborted, thread_settings_applied,
collab_*, entered/exited_review_mode, view_image_tool_call, item_completed,
plus three more found during this audit (web_search_end, thread_rolled_back,
error).

Solution: adds an explicit classification at the parser boundary
(_CODEX_KNOWN_RESPONSE_ITEM_TYPES in codex.py) covering every type that
reaches the generic dispatch, both the pre-existing audited ones and this
bead's newly-classified orphans, each backed by raw wire samples read
directly (not inferred). A type outside this set now routes to a distinct
codex_unclassified_response_item bucket instead of silently adopting its
own wire name (matching the claude_attachment_unclassified precedent in
claude/code_parser.py).

agent_reasoning's fate: confirmed DUPLICATE, not merely unclassified.
Live-wire comparison across three Codex sessions found agent_reasoning.text
is the same live-streamed reasoning-summary bullet text the paired
reasoning record already carries in full (summary[].text) -- already
materialized as a THINKING-block message via _codex_reasoning_message
(index v50). Added to _SESSION_EVENTS_REDUNDANT_TYPES
(storage/sqlite/archive_tiers/write.py), matching the v42 agent_message
precedent (a twin ParsedMessage already exists). This is index schema
version 55 (SEMANTIC_REPARSE, declared in lifecycle.py) -- a
writer-materialization change with no DDL delta, so existing rows require
`polylogue ops reset --index && polylogued run` to actually drop, not
executed here.

The remaining orphan types (thread_goal_updated, sub_agent_activity,
task_started, task_complete, turn_aborted, thread_settings_applied,
collab_*, item_completed, entered/exited_review_mode, view_image_tool_call,
web_search_end, thread_rolled_back, error) keep passing through unchanged.
Reading their raw wire records found real signal
_compact_response_payload's generic allowlist silently drops (e.g.
thread_goal_updated's goal.objective free text, sub_agent_activity's
subagent delegation fields, error's usage-limit message/code) -- a
dedicated extraction pass is filed as polylogue-z1rdw rather than attempted
here, since each needs its own bounded field-set decision plus its own
SEMANTIC_REPARSE bump.

Verification: devtools test tests/unit/sources/test_parsers_codex.py
tests/unit/pipeline/test_archive_write.py (114 passed, 1 pre-existing
unrelated failure confirmed present on master via git stash --
test_validation_strict_detects_malformed_jsonl_beyond_large_prefix);
devtools lab policy schema-versioning (schema evolution policy intact);
devtools verify --quick (all 19 steps green, exit 0).

Ref polylogue-fuky

Co-Authored-By: Claude <[email protected]>
polylogue-fuky's codex response_item classification landed in PR #3567;
appended the AC-by-AC resolution notes and filed polylogue-z1rdw to track
the deferred field-extraction work for the orphan types that keep passing
through unchanged.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/parsers/codex-response-item-classification branch from 1a7cc3c to 885654e Compare August 2, 2026 15:09
@Sinity
Sinity merged commit 5181c96 into master Aug 2, 2026
3 checks passed
@Sinity
Sinity deleted the feature/parsers/codex-response-item-classification branch August 2, 2026 15:10
Sinity added a commit that referenced this pull request Aug 2, 2026
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