Skip to content

fix(daemon): honest page totals, missing-session 404, cross-page edges - #5827

Merged
Sinity merged 2 commits into
masterfrom
fix/codex-p2-daemon-reads
Sep 29, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/codex-p2-daemon-reads

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes six confirmed Codex P2 defects in daemon read routes: paginated totals, a missing session answered as HTTP 200, authority timing, cancelled SQLite reads, topology edges across pages, and a vacuous route-classification gate.

Problem

  • Offset totals. /api/paste-browser published total_lower_bound = offset + len(rows) for an empty page past the end (offset 100 over three matches reported 100). The archive-reader attachment library reported total = offset + len(entries) with total_is_exact = true for that page. Three call sites each re-derived the rule.
  • Missing session. execute_http_session_messages caught KeyError and returned an error-outcome page, which /api/sessions/<id>/messages and /read?view=messages sent with HTTP 200.
  • Authority timing. The same projection serialized its authority envelope before resolving the session and reading the window, so elapsed_ms excluded the read.
  • Cancellation. _run_archive_bounded_query translated an interrupted sqlite3.OperationalError only for a client disconnect or an expired deadline. A cancelled CancellationHandle reached the route as sqlite_error (500), not DaemonOperationCancelled (408).
  • Topology pages. bound_topology_envelope kept an edge only when both endpoints were on the page. For a chain read two nodes at a time, the edge from a page-two child to its page-one parent appeared on no page.
  • Route gate. RouteContract.metadata_only_reason synthesized a reason for any unbound route, so the startup gate that refuses unclassified /api routes could never fire.

Solution

  • _page_total_fields in daemon/webui_data.py is the one owner of what an offset page proves. A full page gives only a lower bound. A short page with rows gives an exact total. An empty page past offset 0 gives neither. build_library_payload and build_paste_browser_payload take offset and page_truncated and call it; all three routes use them.
  • The archive projection returns None for an unresolvable reference. Both message routes answer 404 not_found, the same way session detail does. The facade route also returns None when the session summary is absent.
  • The authority envelope is built after the page is projected.
  • The interrupt handler checks the request's cancellation handle and raises DaemonOperationCancelled.
  • A bounded topology page keeps every edge whose child is on the page. This is the rule the derivation's own paging uses.
  • metadata_only_reason returns only declared notes. The new is_metadata_only property drives the inventory, so the gate sees unbound routes that have no reason.

No file is in the derived-identity closure: devtools schema closure reports out for all eight changed production files.

Verification

  • agentctl job start --workspace <wt> polylogue pytest_focused -- tests/unit/daemon/test_bounded_read_payloads.py tests/unit/daemon/test_http_attachment_library.py tests/unit/daemon/test_http_bounded_mutations.py tests/unit/daemon/test_http_paste_browser.py tests/unit/daemon/test_route_contracts.py tests/unit/daemon/test_topology_endpoint.py tests/unit/daemon/test_topology_stack.py tests/unit/daemon/test_web_reader.py tests/unit/operations/test_http_session_reads.py tests/unit/surfaces/test_topology_route_parity.py tests/unit/operations/test_read_view_operations.py tests/unit/api/test_topology_api.py tests/unit/mcp/test_session_orchestration.py tests/visual/test_reader_paste_spans.py (job 3025): passed 377, failed 3.

  • The three failures, test_paste_browser_walk_reports_unknown_total_when_the_page_fills, test_archive_filter_kwargs_cover_every_storage_lowerable_spec_field and test_lineage_and_topology_use_the_pinned_graph_engines, fail identically at origin/master 0914f89 (job 3060, --on-default-branch: 4 failed, the fourth being an unrelated catalog test). They are inherited.

  • After review, the result variable was renamed so it no longer shadows the payload argument (mypy no-redef), and the test rows were annotated. Then agentctl job start --workspace <wt> polylogue verify_quick (job 3134) succeeded, and pytest_focused -- tests/unit/operations/test_http_session_reads.py tests/unit/daemon/test_http_attachment_library.py tests/unit/daemon/test_bounded_read_payloads.py (job 3149) succeeded.

Self-review

Checklists read: docs/review/codex-review-guide.md, the worker-contract generic list. Passes: 1 (clean).

  1. Criteria on the production path: met. The tests drive the real routes: an HTTP server for the 404, the _handle_attachment_library archive-reader branch, _do_paste_browser over a seeded archive, the /topology handler with a continuation, and validate_declared_route_reachability.
  2. Sibling sites: covered. git grep total_is_exact -- polylogue outside webui_data.py returns 0 hits, so every page-total producer now uses the helper. git grep '"interrupted" in' -- polylogue finds one handler that translates route interrupts. The topology derivation (storage/derived/topology/derivation.py) already pages edges by child. The same class of defect in message-page outcomes (outcome decided from the session total) is fixed in a separate CLI PR.
  3. Consumers: updated. build_library_payload and build_paste_browser_payload changed signature; all three callers and test_http_bounded_mutations.py are updated. metadata_only_api_routes has one consumer, the startup gate. No web UI source reads total_lower_bound or the removed 200 error page.
  4. Failure paths: typed. A missing session is a 404 not_found, and a cancelled read is a 408 operation_cancelled. No path falls back to a weaker answer.
  5. Tests fail without the change: each new test's docstring names the change that turns it red. Examples: offset + len(rows) as the lower bound, the both-endpoints edge rule, the synthesized route reason, and authority serialized before the read.
  6. Public boundary: clean. Fixtures are synthetic, and the diff has no private paths.

Findings

finding thread node_id disposition evidence test
18.F042 Do not infer an exact total from an out-of-range offset PRRT_kwDOR7_N4c6kM_bn fixed _page_total_fields omits the lower bound for an empty page past offset 0 test_empty_page_past_the_end_claims_no_count
18.F045 Avoid inferring an exact total from an empty offset page PRRT_kwDOR7_N4c6lAexH fixed archive-reader library branch uses the shared helper test_archive_reader_library_empty_page_past_the_end_claims_no_count
18.F040 Return a non-success status for missing-session errors PRRT_kwDOR7_N4c6h0n3n fixed projection returns None; _handle_get_messages answers 404 test_messages_route_answers_a_missing_session_as_not_found, test_session_messages_reports_a_missing_session_as_absent
18.F034 Include message-page work in daemon elapsed time PRRT_kwDOR7_N4c6exesB fixed authority built after the projection test_session_messages_authority_elapsed_covers_the_window_read
18.F030 Translate cancellation interrupts on the new session read PRRT_kwDOR7_N4c6cte5m fixed cancelled handle raises DaemonOperationCancelled test_archive_bounded_query_translates_a_cancelled_handle_interrupt
18.F058 Preserve edges that cross HTTP page boundaries PRRT_kwDOR7_N4c6h218D fixed edges owned by their child's page test_continuation_pages_concatenate_every_edge_once
18.F052 Require explicit metadata-only route reasons PRRT_kwDOR7_N4c6lIzYv fixed reason only from notes; gate inventory by is_metadata_only test_unclassified_api_route_fails_the_startup_route_gate

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

- One helper decides what an offset page proves about the match count;
  an empty page past the end no longer reports its offset as a total or
  lower bound (paste browser, facade and archive-reader attachment library).
- The archive-reader messages projection returns None for an unknown
  session so /messages and /read?view=messages answer 404, and its
  authority envelope is timed after the window read.
- A cancelled request handle that interrupts SQLite surfaces as
  DaemonOperationCancelled instead of a generic sqlite_error.
- Topology pages keep every edge whose child is on the page, so an edge
  crossing a page boundary is served exactly once.
- Route metadata-only reasons come only from declared notes, so the startup
  gate refuses an unclassified /api route.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@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 enabled auto-merge (squash) September 29, 2026 13:06
@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-29T13:10:29.903360Z 8ffe268 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 4dd51c9 into master Sep 29, 2026
3 checks passed
@Sinity
Sinity deleted the fix/codex-p2-daemon-reads branch September 29, 2026 13:22
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