Skip to content

fix(sources): resolve Codex P1 parser findings - #5711

Merged
Sinity merged 22 commits into
masterfrom
claude/codexdebt-3
Sep 29, 2026
Merged

Sinity merged 22 commits into
masterfrom
claude/codexdebt-3

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

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

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 feat(sources): stream Claude AI, AI Studio and Hermes object shapes #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 feat(sources): stream Claude AI, AI Studio and Hermes object shapes #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 fix(intake): one interpretation across live and retained routes #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.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@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-29T01:11:18.957048Z b5c328d New commits
ℹ️ 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 enabled auto-merge (squash) September 28, 2026 01:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 795d264e1e

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/import_preflight.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5911186c6d

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/import_preflight.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04579526ce

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/import_preflight.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/dispatch.py Resolved
Sinity and others added 4 commits September 28, 2026 10:36
…e, preflight)

Admission: every production parse route now carries the outer-record
ledger. The Claude Code multi-session stream admits each session group,
Codex streams and undecorated lowered routes get the same boundary, and a
record that is not a JSON object is a typed refusal, never counted as
materialized (F695, F779, F780).

OTel GenAI: repeated input-history snapshots add only their unseen suffix
(F075), non-chat operations keep usage counters (F077), unnamed resources
stay distinct (F079), and traces without a GenAI span are not sessions
(F080).

Drive: one gemini_citation event per citation, so a grown citation list
keeps earlier events identical across revisions (F507).

Preflight: a verified Antigravity trajectory schema is admissible even
when its steps produce no message (F350).

Refs polylogue-1tyq5.27.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…o event sinks

Answers the Codex review round on 795d264:

- otel_genai: an ordinary ancestor span (HTTP root over a GenAI child) joins
  its descendants' conversation instead of forming a zero-message trace
  session; a trace with one conversation keeps every span there.
- otel_genai: execute_tool spans append their call and result to the
  history-dedup transcript, keyed by tool-call id, so the next request's
  replayed tool exchange is not emitted twice.
- otel_genai: usage-only spans attribute usage and models_used to the
  response model, falling back to the request model.
- base_support: AdmissionObserver.apply no longer copies a disk-backed
  event sink into a list; unknown-input events are appended in place, and
  nothing is touched when there are no unknowns.
- import_preflight: comment states the actual contract; a zero-row
  trajectory schema imports as one attributable empty session through the
  same fallback_id the import routes pass, so preflight reports it supported.
- test: narrow the citations JSON value before enumerating it (mypy).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6
…enAI traces

Answers the Codex review round on 5911186:

- Claude Code multi-session admission: typed unknown events name the
  record's 1-based file position; ledger ordinals stay dense per session.
- otel_genai: history overlap never covers a whole input unless it ends in
  an already-recorded tool entry, so a repeated input-only turn is a second
  occurrence rather than replayed history.
- otel_genai: GenAI trace membership reads every variant of a span
  coordinate, so a trace whose GenAI attributes survive only in a
  conflicting copy keeps its session and conflict evidence.
- antigravity: several trajectory_meta rows without ids get stable
  row-specific ids (<fallback>:trajectory-<n>) instead of all sharing the
  path-derived fallback.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6
Answers the Codex review round on 0457952:

- import_preflight: the probed Antigravity sessions pass
  require_positive_conversational_evidence, the gate every production
  write path applies, so a trajectory with no materialized message is
  refused in preflight as import refuses it. This withdraws the earlier
  F350 change, which promised an import that production then refused.
- antigravity: a generated row id never reuses a provider-native
  trajectory id.
- otel_genai: an already-recorded tool call is found by its call id, so
  an output message carrying text beside the call still matches.
- otel_genai: an unnamed resource's identity leaves out per-instance
  attributes (process.*, host.*, service.instance.* and the like), so a
  restarted process exports under the same session id.
- dispatch: the Claude Code route allocates a group's observer once.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49959c3b20

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
- base_support.py/dispatch.py: AdmissionObserver.observe gains a
  ``recognized`` override; the Claude Code multiway fold now passes
  recognized=False for a dict record whose "type" is missing or not a
  string, the exact shape _fold_code_record silently drops (logged,
  never folded into evidence). Previously the generic nested-sentinel
  scan saw no marker and counted such a record MATERIALIZED, so the
  admission ledger claimed complete coverage for a record that vanished.
- otel_genai.py: _history_overlap now matches a pinned leading prefix
  (typically a system prompt that survives context truncation verbatim)
  separately from the retained-history suffix. A truncated request whose
  system prompt interrupts the suffix match previously found zero
  overlap and re-emitted the system prompt and the retained turn as
  duplicates.
- antigravity.py: known_native_ids (used to mint a collision-free
  row-fallback id for an anonymous trajectory_meta row) now also
  reserves conversation_summaries keys. A summary key was already the
  identity an unmatched summary is later yielded under; without
  reserving it, a row-fallback id could mint that exact string and two
  logical sessions would land under one provider_session_id.

Verification: devtools test tests/unit/sources/test_admission_payload.py
tests/unit/sources/parsers/test_otel_genai.py
tests/unit/sources/parsers/test_antigravity.py
tests/unit/sources/test_dispatch_payloads.py
tests/unit/sources/test_dispatch_ordering.py
tests/unit/sources/test_dispatch_evidence.py -- PASSED

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35a88286fc

ℹ️ 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".

Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Claude Code admission reads the record type and message content block
types, never nested tool input. OTel fallback resource identity ignores
version attributes, and the Antigravity summary-collision test now
exercises the multi-row fallback path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04f77eba1f

ℹ️ 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".

Comment thread polylogue/sources/dispatch.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2349a0a580

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70233474bc

ℹ️ 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".

Comment thread polylogue/sources/dispatch.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2db54b1d49

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Sinity and others added 2 commits September 29, 2026 02:12
…ity-free resource ids

An OTLP document's unnamed resource is keyed by its own stable attributes,
so a later export that adds a resource keeps the first one's sessions. OTel
admission reads only span kinds, never attribute values, and a multi-session
document is scanned once with its closed proof shared.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
… tool data

The structural OTel scanner is registered under the provider token the
dispatch route passes ("opentelemetry"). The default scan used by every other
undecorated route no longer reads a wire type from beneath tool arguments,
inputs, outputs, results or attributes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5c328dde5

ℹ️ 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".

Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Comment thread polylogue/sources/parsers/otel_genai.py Resolved
Sinity and others added 5 commits September 29, 2026 03:37
…jectories; trace-scoped OTel topology

Hermes stream admission refuses a known-kind record the parser skips. An
Antigravity export with several unidentified trajectories is refused, since no
stable coordinate tells them apart. OTel trace membership and topology are
trace-scoped across resources: a cross-resource root joins its conversation
and keeps its own resource. A shared ancestor belongs to the conversation
whose descendant started first. Copies that disagree on a conversation choose
none. The history overlap search is linear.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
# Conflicts:
#	polylogue/sources/parsers/drive.py
The streamed Hermes ATIF route from master reached the writer with no
conservation proof, while the dispatch route for the same bytes carries
one. Observe each step's discriminators as the parser consumes them and
admit the sessions through admit_parsed_sessions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
# Conflicts:
#	polylogue/sources/parsers/base_support.py
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity merged commit 4ba58fa into master Sep 29, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the claude/codexdebt-3 branch September 29, 2026 03:20
Sinity added a commit that referenced this pull request Sep 29, 2026
Resolve by intent:
- base_support.py: take master's AdmissionObserver (#5711). It retains one
  unknown-input event per wire type by design, so the branch's per-occurrence
  event count (94-18) is dropped with its test and fixture.
- browser_capture.py: keep master's content-hash comparison, then the
  branch's exact claude-file id shortcut when neither side has a witness.
- antigravity.py: keep both the alias-claimant map and master's summary-key
  reservation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity added a commit that referenced this pull request Sep 29, 2026
…#5798)

## Summary

Lands the verified part of the ChatGPT fleet worker-10 output for the
Codex P2 review debt in `polylogue-1tyq5.93`, `.94` and `.95`
(polylogue/sources parts 4-6, 75 findings). The worker could not run
anything; every kept fix here was re-read against the landing head, and
every kept fix has a regression test that fails on the base.

Per finding: 32 fixed, 9 fixed-already, 1 refuted, 1 dropped as not a
defect, 32 not reached. Of the worker's 35 `fixed` claims, 32 land (two
of them reworked and one narrowed); 2 are rejected, and 94-18 was
withdrawn when this branch merged master (see below). Of its 10
`fixed-already` claims, 1 is rejected as still real.

## Problem

The findings are Codex review comments on merged PRs. Each one names an
input and a wrong outcome in parser, admission, discovery or
derived-identity code. Examples: an Antigravity step with
`occurred_at_ms` lost its time; a list-valued ChatGPT `aggregate_result`
for a failed run was archived as a success; a directory symlink to an
ancestor made `census_source()` loop forever; a Codex `usage` counter of
`null` was stored as a measured zero; a source edited between signing
and parsing could leave a fingerprint memo describing different code.
The table below cites each finding and its evidence.

## Solution

- **Antigravity trajectories.** `occurred_at_ms` is read as epoch
milliseconds. Tool outcomes read the row's `exit_code`, treat a
non-empty string, mapping or list `error` as a failure, and report
`not_reported` when no outcome field is present (the origin spec
declares that reason). camelCase edit fields are read. Unwrapping
`payload` keeps the envelope's role and time. A step that fails typed
validation becomes a MALFORMED refusal for that step only. Parent
references resolve through the trajectory/cascade alias map before the
ambiguity check.
- **ChatGPT.** A list-valued `aggregate_result` decides the outcome (any
failure fails, all success succeeds, otherwise unknown), and each run
emits its own event with `output` and `exit_code`. Citation URLs of the
`/g/g-p-…/c/<id>` form keep the conversation id. A non-string
`content_type` is typed unknown at the message, media-part and
part-accounting sites. A transcription that carries text is not marked
`unavailable`.
- **Browser capture and Claude web.** Typed `extracted_content` wins
over `provider_meta`. A `claude-file:<uuid>` projection reconciles with
the native row of that uuid without a byte witness. A cached cross-route
match is re-validated before reuse. A conversation-level Claude
attachment whose bytes conflict with its descriptor match stays a
separate file.
- **Counters and references.** Claude Code and Codex usage counters stay
unknown unless they are non-negative integers. Codex `local_images`
references go through the data-URL sanitizer. Codex state chunk
coordinates drop the physical rowid.
- **Admission.** `ParseAccounting.assert_conserved` refuses ordinals
outside `[0, expected)`. A `tool_use` part with no name, id or input is
refused as MALFORMED. Material origin is classified from the same TEXT
projection as message type.
- **Discovery, walk and identity.** Live discovery sorts entries before
a linked directory claims its target. The source walk still follows
directory links, but a link to a directory already entered is recorded
as a non-regular entry and not entered. `_fingerprint_sources_compute`
refuses (`FingerprintSourceChangedError`) when the bytes differ from
their signature. Python call operands are no longer SQL-normalized
(fingerprint algorithm 4 -> 5). `in_derived_identity_closure` and
`devtools schema closure` resolve paths from the caller's directory and
refuse missing ones. The Hermes streaming envelope keeps a
container-valued marker. Observation contracts are emitted for every
provider wire. The synthetic Codex oracle classifies through
`classify_message_type`.

Rejected worker changes:
- 93-01: the empty-retained-scope change is not landed. It would make
every Claude Code transcript build a disk-backed tool-result index and
read its sibling subagent blobs, and it would still disagree with the
acquisition-time resolver. The finding stays open.
- 94-16: nested future-type detection was not removed, because it is the
tested admission contract.
- 93-25 is reworked: the worker's version stopped following directory
links.
- 94-18 is withdrawn. Master's `AdmissionObserver` (#5711, merged after
this branch was cut) deliberately keeps one pending unknown-input event
per wire type so memory stays bounded, and
`test_admission_payload.py::test_repeated_unknown_records_keep_one_pending_event_per_type`
holds that contract. A per-occurrence event list contradicts it, so the
merge takes master's observer and drops this branch's version and its
test. The finding stays open for a bounded fix.
- 95-05 is completed: the worker's version left the accounting set
lookup that the finding names unguarded.
- 95-09 is narrowed: requiring equal bytes or a shared URL would drop
the bytes of the documented metadata-only repeat.

## Merge with master (head `6fc0e31bf8`)

Merge commit `6fc0e31bf8` brings in master `1beb2e516a` (including
#5711, #5723, #5787 and #5804). No force-push. Conflicts were resolved
by intent:

- `base_support.py`: master's `AdmissionObserver` is kept as is. The
branch's per-occurrence unknown-input events (94-18) are dropped with
their test and fixture. See the 94-18 row.
- `browser_capture.py`: `_claude_attachment_cross_route_match` compares
inline bytes first, then master's content hashes, and only then takes
the exact `claude-file:<uuid>` identity (94-24) when neither side has a
byte witness. Conflicting hashes still refuse the match.
- `antigravity.py`: both the alias-claimant map (94-13) and master's
summary-key reservation are kept. They touch disjoint names.

The other 32 kept fixes were re-read against master: each hunk is still
absent there, and every helper they call (`_iter_mapping_items`,
`iso_from_epoch_ms`, `unknown_reason`) exists on master. No kept fix
became redundant.

## Verification

Every check ran as an agentctl job.

After the merge (head `6fc0e31bf8`):

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w10 --wait` (job 2471): `phase: succeeded`,
`result: Success`.
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w10 --wait -- <the same 28 modules>` (job
2470): 943 passed, 12 failed. Ten of them are the inherited failures
listed below. The other two are also inherited: job 2543 ran them on a
master checkout, and both failed there too. They are
`test_antigravity_conversation_acquisition.py::test_common_live_batch_retries_a_failed_vendor_conversion`
and
`test_artifact_taxonomy.py::test_antigravity_brain_metadata_sidecar_is_rejected_from_live_and_schema_routes`.

Before the merge:

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w10 --wait` (job 2228, head `d768577f0b`):
`verify: PASSED exit=0`. All static gates are ok, including mypy, lint,
layering, schema-closure and schema-manifest.
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w10 --wait -- <28 test modules>` (job 2168,
head `e8191c523f`, the parent of the rename-only follow-up commit): 908
passed, 10 failed. All 10 failures are inherited. Jobs 2166 and 2229 ran
them on the base `915a1f357d` (this branch with every production file
reset to the base), and all 10 failed there with the same errors
(pre-merge, head `e8191c523f`):
-
`test_schema_closure.py::…::test_the_checked_in_baseline_matches_the_live_closure`:
the baseline lists `polylogue/operations/durable_change_train.py`, which
the live closure no longer contains.
-
`test_discovery_progress.py::test_cold_build_preparation_is_visible_before_the_first_intake_page`:
`preparation_revision_count` is 0, expected 2.
-
`test_codex_state_bounds_and_excision.py::test_large_goal_export_last_row_is_reachable`:
pytest-timeout (300s) inside `os.fsync` of the blob directory.
- 7 tests in `test_browser_capture.py`: `IngestDaemonRequiredError`,
because the API ingest route requires a running daemon.
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w10 --wait --
tests/unit/sources/test_antigravity_trajectory_steps.py
tests/unit/sources/test_antigravity_source_acquisition.py` (job 2232,
head `d768577f0b`): `devtools test: PASSED exit=0`, 22 passed.
- Anti-vacuity: job 2097 ran the five new test modules on a checkout of
this branch with every production file reset to the base: 82 of 93
failed. The 11 that passed are the positive controls and the parameters
that already held on the base: real zero counters, `None` counters for
Claude, `unknown_outcome`, the ambiguous-parent case, and the
equal/absent byte relations.

The 28 modules run in job 2168: `tests/unit/sources/`:
test_antigravity_trajectory_steps,
test_counter_and_coordinate_contracts, test_parser_admission_contracts,
test_source_walk_and_fingerprint_contracts,
test_web_parser_attachments_and_runs, test_admission_payload,
test_admission, test_parser_admission_packet,
test_antigravity_source_acquisition, test_browser_capture,
test_parsers_chatgpt, test_claude_ai_conversation_level_attachments,
test_codex_state_bounds_and_excision, test_origin_specs,
test_prepared_claude_ai_object, test_prepared_drive_chunked_object,
test_parsers_codex, test_nullable_message_usage,
test_claude_code_unread_wire_fields, test_live_page_selection,
test_source_root_admission, test_artifact_taxonomy,
test_parsers_local_agent, test_agent_memory_documents; plus
`tests/unit/devtools/test_schema_closure.py`,
`tests/unit/core/test_synthetic_semantics.py`,
`tests/unit/daemon/test_discovery_progress.py` and
`tests/unit/daemon/test_antigravity_conversation_acquisition.py`.

## Self-review

I read the full `git diff origin/master...HEAD` against the checklist in
`docs/review/codex-review-guide.md`.

1. **Siblings and owners.** The same content_type guard now covers the
message-level discriminator, the media-part branch and the
part-accounting predicate. Live discovery and the source walk now pick a
linked alias by the same name-order rule. Antigravity has one
`_tool_outcome`, so the reason change has one site. Remaining
divergence: the live walk refuses a link that escapes the root and the
source walk follows it. That predates this change and is recorded under
residuals.
2. **The fix itself.** `FingerprintSourceChangedError` is new and
propagates uncaught. It fires only when a source changes between signing
and parsing, and a refusal is safer than writing a wrong memo. The
antigravity `ValidationError` catch wraps only the typed construction of
one step.
3. **Memory and limits.** Discovery holds one directory's `DirEntry`
list to sort it, which is no more than the children list it already
builds. The walk's visited set is one entry per directory. No caps were
added.
4. **Cost per unit.** Nothing new per row. The admission wrapper builds
its per-type counter only when an unknown was observed.
5. **Interruption.** No new loops, waits or multi-step state.
6. **Ordering and races.** The fingerprint now hashes and parses the
same bytes. That was the race the finding named.
7. **Failure classification.** A walk `stat` error keeps the directory
in the descent, so `os.walk` reports it through `onerror` and it is not
silently pruned.
8. **Silent outcomes.** A pruned directory link is still recorded as a
non-regular census entry. A refused step or part carries a typed
MALFORMED outcome and an event.
9. **Cleanup on failure.** Nothing is acquired before a refusal.
10. **Identity and keys.** Codex state chunk coordinates drop the
physical rowid (see residuals for the durable effect). Attachment
identity is unchanged. The fingerprint algorithm version moves because
the normalization changed.
11. **Lossless transforms.** Unwrapping an Antigravity payload now keeps
the envelope fields. Per-run ChatGPT events keep every field the
single-run event kept.
12. **Degenerate inputs.** Covered: an empty list `aggregate_result`
counts as absent; NaN, negative, bool and fractional counters are
unknown; a missing closure path is refused; a missing walk base still
walks nothing.
13. **Consumers.** `in_derived_identity_closure` has no production
caller; the command and its tests follow it.
`artifact_observation_contracts` has no consumer beyond its export. The
existing packet test's expected message was updated for the earlier
range check.
14. **Tests and stubs.** Every new test drives the production parser,
walker, fingerprint or command, and job 2097 shows each one fails on the
base. The worker's `ordered_scandir` helper returned a generator context
manager that production cannot iterate; it now mimics `os.scandir`. The
worker's large-file Hermes test called an API that no longer exists; it
now drives `hermes_snapshot_envelope` against `looks_like_hermes`.
15. **Trust boundaries.** Data URLs in Codex references are now
sanitized before they reach event payloads. No new secrets or files.
16. **Merge resolution.** The only new logic is the order in the
cross-route match. Bytes and then hashes decide before the file-id
shortcut, so a projection whose content contradicts the native row is
never merged on identity alone. Dropping 94-18 removes a test, a fixture
and the now-unused `parse_code` import. No other code referenced them.

## Per-finding dispositions

Key `NN-MM` is bead `polylogue-1tyq5.NN`, finding MM. Tests are under
`tests/unit/sources/`. "Not reached" rows keep the worker's triage
evidence (in the handoff); they were not re-checked here.

| key | disposition | evidence | test |
|---|---|---|---|
| 93-01 #4850 `sources/live/sidecar_resolution.py:141` | not reached
(worker fix dropped) | Still real. The worker's fix (an available empty
scope when the retained query returns no rows) was not landed: it gives
every Claude Code transcript an available scope, so each streamed parse
builds a disk-backed tool-result index and, for root transcripts, reads
every sibling subagent blob, and it diverges from the acquisition-time
resolver, which still reports a missing directory as unresolved. The fix
needs both resolvers to agree and a cheap path when the transcript names
no persisted output. Left open. | — |
| 93-02 #4587 `sources/live/watcher.py:76` | not reached | worker
triage; not re-checked | — |
| 93-03 #4191 `sources/live/watcher.py:220` | not reached (worker
'fixed-already' rejected) | Still real at the landing head:
`run_daemon_services` still runs `src.root.mkdir(parents=True,
exist_ok=True)` for every configured source
(`polylogue/daemon/cli.py:2395` on master `1beb2e516a`), and
`default_watch_sources` includes the legacy-read-only hook carrier
sources from `hook_carrier_watch_sources`. The watcher lines the worker
cited do not cover daemon startup. Left open. | — |
| 93-04 #4791 `sources/live/watcher.py:255` | fixed | Directory entries
are sorted by name before a linked directory claims its target, so the
retained alias does not depend on scandir order. |
test_source_walk_and_fingerprint_contracts.py::test_alias_enumeration_has_one_stable_order
|
| 93-05 #5265 `sources/live/watcher.py:1215` | not reached | worker
triage; not re-checked | — |
| 93-06 #4730 `sources/live/watcher.py:1926` | not reached | worker
triage; not re-checked | — |
| 93-07 #4798 `sources/live/watcher.py:2143` | not reached | worker
triage; not re-checked | — |
| 93-08 #4587 `sources/origin_specs.py:194` | fixed |
`_fingerprint_sources_compute` hashes the exact bytes it parses and
refuses (`FingerprintSourceChangedError`) when they differ from the
signature that keys the memo, so no memo is written for another
implementation. |
test_source_walk_and_fingerprint_contracts.py::test_changed_source_cannot_poison_fingerprint_memo
|
| 93-09 #4856 `sources/origin_specs.py:216` | fixed | String operands
inside a Python call are no longer SQL-normalized; the fingerprint
algorithm version moves 4 -> 5. |
test_source_walk_and_fingerprint_contracts.py::test_sql_replacement_operands_move_fingerprint
|
| 93-10 #4729 `sources/origin_specs.py:250` | refuted | The closure memo
holds a member's import graph fixed for the process lifetime by design:
production sources cannot change under a running process, and
source-mutating tools call `_invalidate_source_signatures`
(polylogue/sources/origin_specs.py `_semantic_source_paths` docstring).
| — |
| 93-11 #4558 `sources/origin_specs.py:251` | fixed-already |
`_source_signature` keys every source by its SHA-256 content digest, not
stat metadata (polylogue/sources/origin_specs.py `_source_signature`). |
— |
| 93-12 #4936 `sources/origin_specs.py:470` | not reached | worker
triage; not re-checked | — |
| 93-13 #5627 `sources/origin_specs.py:823` | not reached | worker
triage; not re-checked | — |
| 93-14 #5627 `sources/origin_specs.py:823` | fixed |
`hermes_snapshot_envelope` keeps an empty container witness for a
container-valued root field, so the streaming recognizer used by
prepared intake and provider detection agrees with `looks_like_hermes`.
The size-gated probe this finding cited is gone
(`recognize_source_class` now streams at every size), but the envelope
still decides admission on those routes. |
test_source_walk_and_fingerprint_contracts.py::test_streaming_hermes_envelope_keeps_container_presence
|
| 93-15 #5627 `sources/origin_specs.py:823` | not reached | worker
triage; not re-checked | — |
| 93-16 #4715 `sources/origin_specs.py:877` | fixed |
`in_derived_identity_closure` and `devtools schema closure` resolve
relative paths from the caller's directory and refuse a missing path
instead of reporting it outside. |
test_source_walk_and_fingerprint_contracts.py::test_closure_paths_are_relative_to_callers_cwd
|
| 93-17 #4661 `sources/origin_specs.py:1129` | not reached | worker
triage; not re-checked | — |
| 93-18 #4853 `sources/origin_specs.py:1457` | not reached | worker
triage; not re-checked | — |
| 93-19 #4406 `sources/origin_specs.py:1518` | fixed-already |
docs/provider-origin-identity.md no longer carries a hand-maintained
Origin token list; it points to the `Origin` enum and the generated
table (lines 75-80). | — |
| 93-20 #4705 `sources/origin_specs.py:1764` | fixed-already |
`parse_sources_archive` hands local sources to `ingest_sources_archive`,
the canonical acquisition owner; `_admit_non_session_origin_artifacts`
no longer exists, and #5787 deleted
`polylogue/pipeline/services/archive_ingest.py`. | — |
| 93-21 #4969 `sources/origin_specs.py:2054` | not reached | worker
triage; not re-checked | — |
| 93-22 #4969 `sources/origin_specs.py:2055` | not reached | worker
triage; not re-checked | — |
| 93-23 #4914 `sources/origin_specs.py:2286` | fixed | `_tool_outcome`
reports `not_reported` when no outcome field is present and
`unsupported_construct` only for a present but unmapped one, and the
Antigravity spec declares both. |
test_antigravity_trajectory_steps.py::test_absent_outcome_is_not_reported
|
| 93-24 #4936 `sources/origin_specs.py:3370` | fixed |
`artifact_observation_contracts` emits rows for every declared provider
wire. |
test_source_walk_and_fingerprint_contracts.py::test_observation_contracts_cover_every_provider_wire
|
| 93-25 #4448 `sources/parsers/antigravity.py:182` | fixed (reworked) |
The source walk still follows directory links but records a link to an
already-entered directory (an ancestor, or a tree a sorted-earlier link
reached) as a non-regular entry instead of entering it. The worker's
version stopped following links at all, which would have dropped linked
export trees. |
test_source_walk_and_fingerprint_contracts.py::test_census_records_directory_link_without_following_cycle<br>::test_source_walk_follows_a_linked_tree_and_stops_at_a_cycle
|
| 94-01 #4883 `sources/parsers/antigravity.py:513` | fixed |
`occurred_at_ms` is converted as epoch milliseconds. |
test_antigravity_trajectory_steps.py::test_millisecond_step_timestamp |
| 94-02 #4883 `sources/parsers/antigravity.py:523` | fixed | The row's
`exit_code`/`exitCode` column is read when the payload has none. |
test_antigravity_trajectory_steps.py::test_structural_row_exit_code |
| 94-03 #4883 `sources/parsers/antigravity.py:530` | fixed | A non-empty
string, mapping or list `error` is a failure. |
test_antigravity_trajectory_steps.py::test_nonempty_error_is_failure |
| 94-04 #4883 `sources/parsers/antigravity.py:563` | fixed | Unwrapping
`payload` merges the envelope fields under the nested ones. |
test_antigravity_trajectory_steps.py::test_nested_payload_keeps_outer_role_and_clock
|
| 94-05 #4914 `sources/parsers/antigravity.py:579` | fixed | A step
whose typed construction fails validation becomes a per-step MALFORMED
refusal plus an `antigravity_unsupported_step` event; siblings still
parse. |
test_antigravity_trajectory_steps.py::test_bad_patch_refuses_only_its_step
|
| 94-06 #4914 `sources/parsers/antigravity.py:584` | fixed | camelCase
edit fields gate and populate the file edit. |
test_antigravity_trajectory_steps.py::test_camel_case_edit_evidence |
| 94-07 #4914 `sources/parsers/antigravity.py:653` | not reached |
worker triage; not re-checked | — |
| 94-08 #4883 `sources/parsers/antigravity.py:655` | fixed-already |
`parse_trajectory_db` refuses a step outside
`_TRAJECTORY_SUPPORTED_STEP_TYPES`/`_FORMATS` as a typed unknown with an
event before any text fallback. | — |
| 94-09 #4883 `sources/parsers/antigravity.py:663` | fixed-already |
Tool-result steps are already typed TOOL_RESULT at the landing base:
`_trajectory_message(step_type="tool_result")` returns
`MessageType.TOOL_RESULT` on origin/master 915a1f3 (probed), and
tool-call steps are TOOL_USE. | — |
| 94-10 #4883 `sources/parsers/antigravity.py:828` | fixed-already | The
summary lookup tries both cascade_id and trajectory_id (`summary_key =
next(...)` in `parse_trajectory_db`). | — |
| 94-11 #4883 `sources/parsers/antigravity.py:844` | fixed-already | A
single resolved parent reference populates `parent_session_provider_id`
on the parsed session. | — |
| 94-12 #4932 `sources/parsers/antigravity.py:855` | not reached |
worker triage; not re-checked | — |
| 94-13 #5403 `sources/parsers/antigravity.py:1043` | fixed | Parent
references resolve through the trajectory/cascade alias map before the
ambiguity check; two aliases of one parent are one parent, two parents
stay ambiguous. |
test_antigravity_trajectory_steps.py::test_parent_aliases_canonicalize_before_ambiguity
|
| 94-14 #4184 `sources/parsers/base_models.py:100` | fixed |
`ParseAccounting.assert_conserved` refuses ranges and outcomes outside
`[0, expected)`, so equal counts over the wrong ordinals no longer pass.
|
test_parser_admission_contracts.py::test_writer_refuses_out_of_denominator_ordinal
|
| 94-15 #4229 `sources/parsers/base_models.py:320` | fixed | Material
origin is classified from the same TEXT-block projection as message
type. |
test_parser_admission_contracts.py::test_capture_thinking_is_not_runtime_context
|
| 94-16 #4271 `sources/parsers/base_support.py:112` | dropped: not a
defect | Detecting a future-shaped discriminator anywhere in an outer
record is the deliberate admission contract:
`tests/unit/sources/test_prepared_claude_ai_object.py::test_claude_ai_object_future_wire_type_keeps_parser_admission`
and the Drive chunked-prompt test assert that nested
`metadata.kind`/chunk `type` values raise `<provider>_unknown_input`,
and the streaming envelopes compute the same first future type over
nested frames. Removing the recursion (the worker's fix) broke that
parity. | — |
| 94-17 #4184 `sources/parsers/base_support.py:125` | not reached |
worker triage; not re-checked | — |
| 94-18 #4271 `sources/parsers/base_support.py:149` | not reached (fix
withdrawn) | The cited code was replaced by `AdmissionObserver` (#5711),
which keeps one pending event per unknown wire type by design (bounded
memory;
`test_admission_payload.py::test_repeated_unknown_records_keep_one_pending_event_per_type`).
Every occurrence has its own UNKNOWN ledger outcome, but the ledger is
only asserted, not persisted. This branch's per-occurrence events
contradicted the bounded contract and were dropped in the merge. Open
for a bounded fix (e.g. an occurrence count on the per-type event). | —
|
| 94-19 #4271 `sources/parsers/base_support.py:159` | not reached |
worker triage; not re-checked | — |
| 94-20 #4184 `sources/parsers/base_support.py:278` | fixed | A
`tool_use` part with no name, id or input is a MALFORMED refusal, not a
materialized part that yields no block. |
test_parser_admission_contracts.py::test_empty_tool_part_is_refused_beside_valid_content
|
| 94-21 #4802 `sources/parsers/base_support.py:720` | fixed-already |
`attachment_identity_hash` (polylogue/pipeline/ids.py) keys attachment
identity on message, name and MIME type only; size and bytes are
excluded. | — |
| 94-22 #4802 `sources/parsers/browser_capture.py:228` | fixed-already |
`_merge_envelope_attachments` selects `candidate.inline_bytes if
candidate.inline_bytes is not None else existing.inline_bytes`. | — |
| 94-23 #4802 `sources/parsers/browser_capture.py:257` | fixed | Typed
`extracted_content` is read before `provider_meta.extracted_content`. |
test_web_parser_attachments_and_runs.py::test_typed_extracted_content_precedes_provider_metadata
|
| 94-24 #4986 `sources/parsers/browser_capture.py:318` | fixed | A
`claude-file:<uuid>` projection whose uuid equals the native attachment
id reconciles without a byte witness. |
test_web_parser_attachments_and_runs.py::test_claude_file_projection_reconciles_without_bytes
|
| 94-25 #4999 `sources/parsers/browser_capture.py:379` | fixed | A
cached cross-route match is reused only if it still passes
`_claude_attachment_cross_route_match`. |
test_web_parser_attachments_and_runs.py::test_projection_id_collision_revalidates_native_target
|
| 95-01 #4999 `sources/parsers/browser_capture.py:393` | not reached |
worker triage; not re-checked | — |
| 95-02 #4812 `sources/parsers/chatgpt.py:315` | fixed | List-valued
`aggregate_result` is normalized before the outcome mapping: any failed
run is an error, all successful is success, otherwise unknown. |
test_web_parser_attachments_and_runs.py::test_list_aggregate_result_overrides_delivery_status
|
| 95-03 #4812 `sources/parsers/chatgpt.py:537` | fixed | The citation
URL pattern accepts the `/g/g-p-<project>/c/<id>` form. |
test_web_parser_attachments_and_runs.py::test_project_scoped_conversation_citation_keeps_native_identity
|
| 95-04 #4812 `sources/parsers/chatgpt.py:708` | fixed | Run events are
emitted per run (list or single) and retain `output` and `exit_code`. |
test_web_parser_attachments_and_runs.py::test_direct_run_outputs_are_retained
|
| 95-05 #4184 `sources/parsers/chatgpt.py:1066` | fixed (completed) | A
non-string discriminator is typed unknown at the message level, the
media-part branch and the part-accounting predicate the finding cited;
the worker's version left that accounting set lookup unguarded. |
test_web_parser_attachments_and_runs.py::test_unhashable_content_type_keeps_valid_message
|
| 95-06 #4886 `sources/parsers/chatgpt.py:1688` | not reached | worker
triage; not re-checked | — |
| 95-07 #4873 `sources/parsers/chatgpt.py:1690` | not reached | worker
triage; not re-checked | — |
| 95-08 #4940 `sources/parsers/chatgpt.py:1758` | fixed | A text-bearing
`audio_transcription` construct is not marked unavailable. |
test_web_parser_attachments_and_runs.py::test_text_only_audio_transcription_is_available
|
| 95-09 #4776 `sources/parsers/claude/ai_parser.py:805` | fixed in part
| Two records whose bytes are both present and differ are no longer
merged under one message identity. The descriptor-only case remains: the
worker's stronger rule (require equal bytes or a shared source URL)
would drop the bytes of the real export shape this function exists for,
a metadata-only message record repeated at conversation level with
extracted content
(`tests/unit/sources/test_claude_ai_conversation_level_attachments.py`).
|
test_claude_ai_conversation_level_attachments.py<br>test_web_parser_attachments_and_runs.py::test_conflicting_bytes_keep_a_top_level_file_distinct
|
| 95-10 #4717 `sources/parsers/claude/code_parser.py:627` | not reached
| worker triage; not re-checked | — |
| 95-11 #5530 `sources/parsers/claude/code_parser.py:1314` | fixed |
`_optional_safe_int` accepts only non-negative integral numbers; null,
bool, NaN, negative, fractional and non-numeric values are unknown. |
test_counter_and_coordinate_contracts.py::test_claude_invalid_counter_is_not_measured_zero<br>::test_claude_numeric_zero_remains_measured
|
| 95-12 #4674 `sources/parsers/claude/code_parser.py:1860` | not reached
| worker triage; not re-checked | — |
| 95-13 #4642 `sources/parsers/claude/code_parser.py:2002` | not reached
| worker triage; not re-checked | — |
| 95-14 #4808 `sources/parsers/claude/code_parser.py:2598` | not reached
| worker triage; not re-checked | — |
| 95-15 #5293 `sources/parsers/codex.py:524` | fixed |
`_optional_int_field` keeps null and invalid counters unknown and
preserves a real zero. |
test_counter_and_coordinate_contracts.py::test_codex_sparse_counter_remains_unknown<br>::test_codex_numeric_zero_remains_measured
|
| 95-16 #4870 `sources/parsers/codex.py:576` | fixed | String and
mapping `local_images` references pass through
`_sanitize_codex_data_url`. |
test_counter_and_coordinate_contracts.py::test_local_image_reference_cannot_copy_inline_bytes_to_events
|
| 95-17 #4870 `sources/parsers/codex.py:690` | not reached | worker
triage; not re-checked | — |
| 95-18 #4173 `sources/parsers/codex.py:2276` | fixed | The synthetic
oracle classifies Codex nodes through `classify_message_type`, as
production does. |
test_counter_and_coordinate_contracts.py::test_codex_semantic_oracle_uses_protocol_precedence
|
| 95-19 #4184 `sources/parsers/codex.py:2828` | not reached | worker
triage; not re-checked | — |
| 95-20 #4236 `sources/parsers/codex.py:2831` | not reached | worker
triage; not re-checked | — |
| 95-21 #4184 `sources/parsers/codex.py:2896` | not reached | worker
triage; not re-checked | — |
| 95-22 #4933 `sources/parsers/codex.py:3558` | not reached | worker
triage; not re-checked | — |
| 95-23 #4933 `sources/parsers/codex.py:3563` | not reached | worker
triage; not re-checked | — |
| 95-24 #5626 `sources/parsers/codex_state.py:539` | not reached |
worker triage; not re-checked | — |
| 95-25 #5626 `sources/parsers/codex_state.py:582` | fixed | Codex state
chunk coordinates are `item:field:offset`, without the physical rowid. |
test_counter_and_coordinate_contracts.py::test_state_chunk_coordinates_ignore_physical_rowid
|

## Derived-identity closure

The checked-in baseline (`docs/plans/schema-closure-baseline.json`)
lists these changed files: `polylogue/sources/decoder_json.py`,
`polylogue/sources/live/discovery.py`,
`polylogue/sources/origin_specs.py`,
`polylogue/sources/parsers/antigravity.py`,
`polylogue/sources/parsers/base_models.py`,
`polylogue/sources/parsers/base_support.py`,
`polylogue/sources/parsers/claude/ai_parser.py`,
`polylogue/sources/parsers/claude/code_parser.py`,
`polylogue/sources/parsers/codex.py` and
`polylogue/sources/source_walk.py`. `_FINGERPRINT_ALGORITHM_VERSION`
also moves (4 -> 5). This PR moves the derived schema identity and must
not land during a rebuild. These changed files are outside the baseline:
`browser_capture.py`, `chatgpt.py`, `codex_state.py`,
`schemas/synthetic/wire_formats.py` and `devtools/schema_closure.py`.
The `schema-closure` gate passed in job 2228.

## Residuals

- **Codex state materials.** Chunk `source_uri`s change for chunked
Codex goals and memories
(`codex://state/<kind>-text/<thread>/<item:field:offset>`). This cannot
duplicate sessions or messages. These materials are written only by
`sources/codex_state_evidence.py` into `source.db`
`material_observations`. Nothing lowers them into `index.db`. Their only
readers are the `storage/materials.py` helpers (`list_materials`,
`list_materials_page`, `get_material`), which no API, MCP, CLI or
materializer calls, plus excision and blob liveness, which key on
referrer and blob. The live archive holds no rows from the old
coordinate: `SELECT count(*) FROM material_observations WHERE source_uri
LIKE 'codex://state/%'` returns 0 on `/realm/state/polylogue/source.db`
(fresh v1). No change or cleanup is needed.
- **Still open from this bead set:** 93-01 (empty retained sidecar
scope), 93-03 (daemon startup still runs `mkdir` on legacy-read-only
roots), 94-18 (repeated unknown occurrences, withdrawn at the merge),
95-09's descriptor-only case, and the 28 other findings the worker did
not reach.
- **Fingerprint refusal.** `FingerprintSourceChangedError` repeats until
the signature cache is invalidated or the process restarts. That is
deliberate, but a long-lived dev process on an edited checkout will keep
refusing.
- **Link policy.** The source walk follows a directory link that escapes
the root; the live walk refuses it. This predates this PR.
- **Inherited failures.** The 10 inherited failures listed under
Verification are not addressed here.

🤖 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]>
Sinity added a commit that referenced this pull request Sep 29, 2026
…5850)

## Summary

Makes master's focused suites green again. The baseline run on master
`633ec18ffc` (job 3431, 30 files) had 41 failures and 1 error, and every
other PR was running into them. They come from 20-odd separate causes.
Where production was wrong, this PR fixes production and uses the
failing test as the regression. Where a merged PR had deliberately
changed the contract, it updates the test to the new contract and cites
that PR. Two failures remain, each with a bead and the evidence below.

Beads: polylogue-ouv5f (all eight tests fixed), polylogue-0e6m3,
polylogue-h9da0 and polylogue-wple (audited and noted; their open
criteria are listed under Residuals).

## Problem

Job 3431 (`pytest_focused --on-default-branch`, 30 files, 1539 tests)
reported `passed 1497, failed 41, error 1`. Its failed-test rerun also
crashed: the rerun passed `…::test_x@web-reader[param-…]` back to
pytest, and pytest answered `ERROR: not found`.

## Solution: production defects fixed

| Failure | Cause | Fix |
|---|---|---|
| `test_raw_observation_derivation` ×4,
`test_retained_tool_output_convergence` (Gemini) | For providers with no
assembly spec, `enrichment_dependency_digest` skipped the evidence
digest that every retained seal computes. Every prepared artifact of
those providers therefore read as stale, and `publish` returned False
forever, so Hermes, Antigravity, ChatGPT and Gemini retained raws never
converged. | Every provider digests its evidence, empty or not
(`sources/revision_backfill.py`). |
| `test_observation_runtime::test_structured_raw_only_sidecar…` | An
artifact-scoped identity hashed to the same `{"source": path}` value
that `_old_path_fallback` refuses, so new sidecar evidence never reached
the cache. | The artifact-scoped identity gets its own namespace
(`schemas/source_inference.py`). |
| `test_verification_evidence_lane` |
`reconcile_and_record_abandoned_verify_runs` compared `cache.parent`
(that is, `.cache`) to the checkout, so the test was never true. The
checkout's reconciled runs went to cache-local history, and cache-local
evidence too (#5720), instead of the durable lane. | Compare the
checkout root, `runs_root.parents[2]`. The checkout uses the XDG history
and `verification_evidence_path()`; a relocated cache keeps local files.
|
| `test_web_reader::test_archive_filter_kwargs…` | #5795 gave
`iter_search_summaries` an `actions_only` lane parameter. The count
route still counted every FTS hit for `retrieval_lane="actions"`. |
`count_search_sessions(actions_only=…)` and the count route pass the
lane. New regression:
`test_actions_lane_count_counts_only_sessions_its_search_returns`. |
| `test_command_catalog::test_tool_outcome_help…` | A Click-level
required option refused `--help` before argparse could print it (#5720).
| argparse owns requiredness, and the metavar is `PATH`. |
| idempotence properties (found while fixing the harness) |
`refresh_session_repos*` stamped `repos`, `repo_checkouts` and
`session_repos` with the wall clock, so no rebuild could reproduce them.
| Stamp them with the session's own time, as `_write_repo_edges` does.
New test: `test_refresh_stamps_the_session_time_not_the_wall_clock`. |
| `test_daemon_http_security` | The daemon client that carries the
credential was chained into the receipt call, so the token scan flagged
the receipt. | Bind the client first (`browser_capture/server.py`). No
allowlist entry was added. |
| failed-test rerun | `report_nodeid_to_selector` did not handle
`name@group[param-…]`, the shape that shortened ids take under
loadgroup, and the long-id map stored uncollectible `@group` ids. |
Handle that shape, and record both map sides in selector form
(`devtools/pytest_rerun.py`, `tests/conftest.py`). |
| `test_session_partition_convergence` (fd leak) | The per-thread
connection cache kept every archive a test built until the descriptor
check ran. | The autouse fixture clears the cache at teardown. |
| `test_session_partition_convergence` (`fields_digest`) | #5799's
column was neither projected nor excluded. | Exclude it, with the reason
(`derived/session/input_binding.py`). |

## Solution: tests updated to contracts that merged PRs changed

- `test_import_preflight`: several unidentified trajectories are refused
(#5711); the old test expected ids minted from row position.
- `test_artifact_taxonomy`: a brain sidecar is observed as
`agent_sidecar_meta` schema evidence (#5781), never as a session.
- `test_tool_result_unknown_reason_contract` ×3: a step with no verdict
field is `not_reported` (#5798). A new route covers
`unsupported_construct` with an unmapped status.
- `test_source_laws`: the stand-in parser accounts for its outer records
(#5816).
- `test_revision_replay`: the direct replay binds Codex enrichment
evidence as the retained writer does (#5643).
- `test_retained_tool_output_convergence` (Gemini): the fixture sidecar
is longer than the 40,000 characters the envelope advertises (the #5643
partial-write guard).
- `test_schema_policy_contracts`: FTS triggers are matched by whole
table name (`messages_fts_readiness_binding` is not FTS-backing); the
restart test clears the bootstrap memo as a restart does (#5428).
Deleted `test_every_prior_index_schema_version…`: at fresh v1,
`SCHEMA_VERSION - 1` is 0, which is the "interrupted create" state that
is re-created by design. No prior version exists.
- `test_durable_migrations`: an archive two slots behind gets the typed
refusal from #5806, and the tier is untouched. The docstring of
`apply_declared_durable_migrations` is corrected. Filed as
polylogue-7yq3f.
- `test_schema_validation`: the member schema names `id` (#4856 reports
unnamed fields), and the keys are plain names, so the marker is what
suppresses them.
- `test_synthetic_wire_support::test_chatgpt_witness…`: the part text
also survives on the tool block, so the test drops it there too.
- `test_archive_ingest_shared_raw`: a ZIP member with a malformed record
is `terminal_corrupt_input` (#5823 F039); a census runs once per raw.
- `test_plain_cli_snapshots`: empty is exit 2 and degraded is exit 1
(`surfaces/outcome.py`).
- `test_cross_surface_agreement`, `test_query_composition_laws`: the CLI
reads through a real daemon (#5805). The naive-join mutant lifts the
read authorizer (#5642) the way `attach_readonly_database` does.
- `test_resource_pilot` ×2: parser scratch SQLite (`:memory:` and temp
files) is allowed; any database file or tier is not.
- `test_codex_debt_w1` and the convergence properties: the harness bound
each session's own evidence to message 0 and stamped replayed messages
with the child's values. Since #5826 shares only an identical prefix, no
lineage prefix was shared at all, and the append-prefix laws were
vacuous. A fork now replays its parent's parsed prefix exactly, and its
own evidence moves to the first message it authored. The mutation test's
`_resolve_session_graph` mutant returns `set()` to match the current
signature.
- `test_query_exec_laws` ×4: stub the convergence probe in fake-store
stats tests (#5700), add the `tool_input` projection field, and expect a
second window sized to the remaining limit.
- devtools: `test_verify` stubs the executor,
`test_pytest_suite_cost_plugin` builds the recorder before patching RSS,
`test_verification_terminal_receipts` updates the sizing stub signature,
and `test_verification_result` adds the #5720 `flaky` field.
`test_http_bounded_mutations` adds the #5723 summary read to its test
double.

Derived-identity closure (`devtools schema closure`): these files are
IN: `archive/query/archive_execution.py`, `schemas/source_inference.py`,
`sources/revision_backfill.py`,
`storage/derived/session/input_binding.py`,
`storage/derived/session/repo_observations.py`,
`storage/sqlite/archive_tiers/archive.py`. The rest are out.

## Verification

- Baseline, master `633ec18ffc`, job 3431: `passed 1497, failed 41,
error 1`.
- `agentctl job start --workspace
/realm/worktrees/polylogue-master-green polylogue pytest_focused -- <61
files>`, job 3578, head `a7f4465c56`: `passed 2336, failed 2` after the
in-slot rerun. The first attempt ran under host I/O contention, with
workers in D state. 25 of its 27 first-attempt failures were `Timeout
(>120.0s)`, and every one of those passed when rerun alone.
- `test_web_reader::…searches_from_archive_tiers`: a socket timeout
under the same load. It passed alone in job 3861 (`devtools test: PASSED
exit=0`).
-
`test_supported_routes_validate_selected_schema_and_parser_entry_point`:
inherited, see Residuals.
- Master baseline for the added files, job 3562: `test_query_exec_laws`
×4, idempotence ×7 and mutations ×2 fail on master the same way. All of
them are fixed here.
- Harness consumers and count seams at head `1d3b3545c5`, job 3920 (24
files): `passed 589, failed 1` after the in-slot rerun. The one failure,
`test_inferred_corpus_loop::test_every_supported_inferred_element_reaches_convergence_and_red_twin`,
was a `Timeout (>120.0s)` inside `load_package_catalog` under the same
host load. It passed alone in job 3973 (`devtools test: PASSED exit=0`).
- `verify_quick` on head `1d3b3545c5`, job 3921: `verify: PASSED
exit=0`. The hosted `ci/circleci: quick-gate` passes.
- `verify_quick` on head `a7f4465c56`, job 3579: `verify: PASSED
exit=0`.

## Self-review

I did two passes over the full diff against `master`, using
`docs/review/codex-review-guide.md` and the generic worker-contract
list. Pass 1 found two defects, both fixed in `1d3b3545c5` and
`3ec0a5fa2f`. Pass 2 was clean.

1. ✓ **Siblings and owners.** The actions-lane count was also wrong in
two more places: the facade/daemon seam
`_archive_count_sessions_for_spec` and the daemon `count` mode
(`operations/daemon_reads.py`). Pass 1 found them with `grep -rn
count_search_sessions polylogue` (7 call sites); both are fixed and have
a regression test. The MCP route already reports `total=None` for
actions (`mcp/archive_support.py` `ranked_only`), and `sessions.search`
is lexical only. The enrichment digest has a single owner
(`enrichment_dependency_digest`) used by both the live and the retained
check. Every seal computes the evidence digest unconditionally, the live
enricher included. A search of `polylogue/storage/derived` for
wall-clock stamps found two others: the marker cursor `applied_at_ms`
(operational metadata) and `profiles.now_iso` (materialized-at). Neither
is a semantic column.
2. ✓ **The fix itself.** Pass 1 found that `_replayed_parent_prefix`
would recurse forever on a declared parent/child cycle
(`cycle_candidate=True`). It now tracks the lineage it walks, and picks
the parent revision the way `authoritative_sessions` does.
`count_search_sessions(actions_only=False)` defaults to today's
behaviour for every other caller.
3. ✓ **Memory and limits.** Nothing new grows with the input. The repo
stamp is one indexed `SELECT` per refreshed session. No caps or timeouts
were added.
4. ✓ **Cost per unit.** One predicate on the count query and one
primary-key read per repo refresh. `with_retained_assembly_evidence`
returns at once for providers without assembly evidence
(`sources/retained_assembly.py:470-479`).
5. N/A **Interruption.** No loops, waits or multi-step state changes
were added.
6. ✓ **Ordering and races.** The repo stamp is read inside the
materializer's own transaction, on the same connection that writes the
rows.
7. ✓ **Failure classification.** The reconciler's history and evidence
appends keep their existing `suppress(OSError, ValueError)`.
`verification_evidence_path()` now expands `~`, as the old inline
override did.
8. ✓ **Silent outcomes.** Actions-lane totals now count what the lane
can return. Exit codes follow outcomes (`surfaces/outcome.py`), and the
updated CLI tests assert exit 2 for empty and 1 for degraded.
9. N/A **Cleanup on failure.** Nothing new is acquired.
10. ✓ **Identity and keys.** Artifact-scoped source identity now lives
in its own `{"artifact": …}` namespace, so it can no longer collide with
the retired `{"source": path}` identity. Old cache rows under the path
identity are still refused by `_old_path_fallback`.
11. ✓ **Lossless transforms.** The rerun selector keeps the `[param-…]`
label, and the long-id map now stores both sides in collectible form.
The harness deep-copies the parent messages it replays.
12. ✓ **Degenerate inputs.** A missing session row stamps 0, the
writer's own default. A child with no own messages keeps position-0
evidence. A shared prefix of 0 replays nothing.
13. ✓ **Consumers.** `count_search_sessions` gained an optional keyword;
every test double takes `**kwargs`, and none asserts the exact kwargs
(checked at `test_query_exec_laws.py:1301,1385,2099` and
`tests/infra/archive_store_double.py:255`). The unused `now_iso`
parameters were removed, and `grep` finds no callers passing them.
14. ✓ **Tests and stubs.** Each production fix has a test that goes red
without it. The count tests go 2 → 3 without `actions_only`. The repo
test goes red if the rows are stamped with the wall clock. The
evidence-lane pair covers the checkout and the relocated cache.
`test_rerun_selector_strips_the_xdist_group_suffix` covers the new id
shape. The source-inference test goes red without the separate
namespace. Stubs follow the current signatures: the
`resolve_worker_argument` stub takes `**sizing`, the
`_resolve_session_graph` mutant returns `set()`, and the test double
implements `get_session_summaries`.
15. ✓ **Trust boundaries.** The capture handler binds the
credential-holding client apart from the receipt, and no token-scan
allowlist entry was added. The fixtures are synthetic.

Generic list: (1) criteria are met on production routes (probes and job
3578). The unmet ones name their blockers (4xyn9, 7yq3f, h9da0, 0e6m3,
wple). (2) Siblings: see item 1. (3) No predecessor is kept beside a
replacement. (4) No silent fallback was added. (5) Each new test names
the change that turns it red. (6) The diff, receipts and text carry no
secrets or private data; the paths are worktree scratch paths only.


## Residuals

- polylogue-4xyn9:
`test_supported_routes_validate_selected_schema_and_parser_entry_point`
still fails. The claude-ai v2 coverage witnesses combine mutually
exclusive groups, so 529 of 844 keywords are missing. It fails the same
way on every commit back to #5485 at least. Honoring the exclusions in
coverage mode alone still leaves 319 missing, so this needs a coverage
planner.
- polylogue-7yq3f: catch-up across more than one numbered slot is
refused, and a backup is taken before the refusal. Nothing breaks until
the second migration of a tier ships.
- polylogue-3p8p7 (owned elsewhere): a loose malformed workflow journal
still reads as `workflow_journal` through the lenient retained decode;
the ZIP route is strict.
- polylogue-h9da0: quick-pool xdist width is sized from the slice's
current headroom, not from a per-job share. Two jobs that start together
can both admit a full width. Left open.
- polylogue-0e6m3: the per-cache retention measurements need a scheduled
broad run. Left open.
- polylogue-wple: master already enforces the foreign-interpreter and
foreign-import checks. Detecting copied testmon or verify state is still
open.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
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