Skip to content

fix(operations): resume transcript windows with the token's selection - #5811

Merged
Sinity merged 2 commits into
masterfrom
fix/session-owner-compiler-tests
Sep 29, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/session-owner-compiler-tests

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

Resumed transcript windows now read the selection and page size the continuation was minted for, on both the typed session-owner route and the generic session.read operation. Two stale prose_with_refs compiler tests are realigned with the contracts that changed under them. Tracking: beads polylogue-zeolc and polylogue-6bhuy (the compiler and transcript-window items).

Problem

At origin/master 1beb2e5 (agentctl job 2441), four tests failed:

  • test_session_owner_operations.py::test_search_read_timeline_and_mcp_use_owner: MCP query(projection="sessions") sent the default page size with a continuation, and the owner refused that as widening the window. fix: close worker-13 MCP, surface and excision review findings #5779 has since landed the same fix on master. This PR adds narrowing and widening assertions for that route.
  • test_transcript_window_route.py::test_continuation_can_narrow_final_window_without_losing_snapshot_binding ("dialect mismatch"): the test hand-built a token whose result identity did not match its request, and frame_request reported that as a dialect mismatch. Reading the code turned up a real bug underneath. On narrowing, frame_request returned the new request, whose default offset and filters replaced the token's. fix: close Codex review findings from the #5722 landing #5778 fixed the same bug in session_reads._transaction but not here.
  • test_compiler.py, both prose_with_refs tests: fix: Codex P2 review debt: polylogue/cli part 1 (25 findings) #5722 changed the contracts these tests assert (details under Solution).

Checking the other surfaces that resume a continuation found three more places where the resumed request's defaults win over the token:

  • message_transcript_window filtered with the caller's request. A token-only sessions.read resume of a message_role=("user",) window served unfiltered rows at the filtered offset.
  • The generic session.read (transcript and messages kinds) dropped an explicit limit beside a continuation. The CLI's narrowed resume from fix(cli-api): report tier skew, bound review counts and continuations #5785 (remaining bound, result_too_large halving) therefore read the token's full page in production. fix(cli-api): report tier skew, bound review counts and continuations #5785's tests mock the dispatch, so they could not catch this.
  • The messages kind checked for filters on its own payload, not on the framed token, so it would resume a filtered owner token and serve unfiltered rows.

Solution

  • frame_request: separate the dialect check from the result-identity check. On narrowing, keep the token's request and change only limit.
  • message_transcript_window: frame the request once to get the effective selection, then pass the submitted request to the bound route so epoch validation is unchanged.
  • daemon_reads._session_window_request: one builder for both kinds. With a continuation, a stated limit narrows the page (frame_request refuses a larger one) and a stated nonzero offset is conflict-checked. The messages kind checks filters on the framed selection.
  • SessionReadRequest.limit is now int | None = None. The operation transport forwards every declared field, so the old limit=200 default would have read as a request to widen every token-only resume. That was the cause of the four failures in the first focused run (job 2563). Handlers still use the declared 200-row window for a fresh read.
  • Compiler tests: fix: Codex P2 review debt: polylogue/cli part 1 (25 findings) #5722 added an action ObjectRef assertion that contradicts ObjectRef.parse, which has read an action's trailing block index as a qualifier since feat(context,insights): reboot handoff refs and delegation work evidence #4329. The test is fixed; production is right. fix: Codex P2 review debt: polylogue/cli part 1 (25 findings) #5722 also made the budget a hard cap, so max_tokens=80 now omits every row. The recap test now uses a budget where recapping, not omission, makes the page fit, and asserts the estimate stays within the prose budget.
  • docs/session-operations.md states the resume page-size and filter rules.

None of the changed production files is in the derived-identity closure (devtools schema closure: all out).

Verification

  • agentctl job start polylogue pytest_focused --workspace … -- tests/unit/mcp/test_session_owner_operations.py tests/unit/operations/test_transcript_window_route.py tests/unit/context/test_compiler.py tests/unit/archive/query/test_continuation_surface_parity.py tests/unit/cli/test_session_window_continuation_bounds.py tests/integration/test_transcript_window_differential.py tests/unit/operations/test_transcript_window_resume_selection.py tests/unit/operations/test_daemon_reads.py tests/unit/operations/test_session_read_parity.py tests/unit/operations/test_session_owner_route_equivalence.py tests/unit/operations/test_http_session_reads.py tests/unit/cli/test_read_view_execution_routes.py tests/unit/operations/test_daemon_protocol.py, job 2608: passed 143, failed 0 (2 flaky on first attempt, below).
  • agentctl job start polylogue verify_quick, job 2609: succeeded.

New regression tests in tests/unit/operations/test_transcript_window_resume_selection.py:

  • A token-only owner resume reads under the token's filters.
  • The generic messages kind refuses a filtered owner token.
  • Narrowing works identically on the owner route and both generic kinds; a token-only resume keeps the token's page size through the transport's declared request; widening is refused.

Self-review

  • Sibling sites. Every QueryContinuation.decode and frame_request caller was checked. The evidence windows (frame_evidence_window) ignore limit on a continuation, and their only CLI caller sends none, so no wrong rows are served (residual below). window_request, used by the API, MCP read and HTTP messages routes, drops limit beside a continuation. The window is then fully decided by the token. No wrong rows, but an explicit narrowing is ignored there (residual).
  • Contract change. SessionReadRequest.limit is read only through _non_negative_int(..., default=_SESSION_READ_WINDOW), which maps None to the 200-row default. No checked-in schema snapshot names it.
  • Double framing. frame_request is pure; calling it twice cannot diverge, and the bound route still validates the epoch.
  • Compatibility and fail-open. No shim; a larger limit is refused, not clamped.
  • Tests on the production route. The generic reads go through SessionReadRequest validation exactly as the transport does, which is what exposed the default-limit problem.

Residuals

  • Evidence windows and the window_request routes silently ignore an explicit limit beside a continuation. They serve correct rows, but do not narrow.
  • The two first-attempt flakes in job 2608 were daemon start-up timeouts (TimeoutError, DaemonWriterOwnerLoopStopped) under host load. They are unrelated to window framing, and both passed on rerun.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Sinity and others added 2 commits September 29, 2026 10:46
A continuation carries the window it was minted for, but four sites read
the resumed request's defaults instead:

- frame_request narrowed a window by returning the new request, whose
  default offset and filters replaced the token's (the sibling of the
  session_reads fix in #5778); its dialect check also reported a result
  identity mismatch as "dialect mismatch".
- message_transcript_window filtered by the caller's request, so a
  token-only sessions.read resume of a message_role window served
  unfiltered rows at the filtered offset.
- the generic session.read route dropped an explicit limit beside a
  continuation, so the CLI's narrowed resume (#5785) read the token's full
  page, and the messages kind checked filters on its own payload instead
  of the framed token.
- SessionReadRequest declared limit=200, and the operation transport
  forwards every field, so honouring a stated limit would read that
  default as widening a token-only resume. An omitted limit is now None.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The action-ref assertion added in #5722 contradicts ObjectRef.parse, which
reads an action's trailing block index as a qualifier (#4329). #5722 also
made the budget a hard cap, so an 80-token budget now omits every row; the
recap test uses a budget where recapping, not omission, fits the page.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 08:47
@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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 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
🔒 Security Review ✅ Completed 2026-09-29T08:53:13.968623Z 4b3fd8d 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 27f0980 into master Sep 29, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the fix/session-owner-compiler-tests branch September 29, 2026 08:51
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