Repository navigation
fix(daemon): Resolve deep links by ref and bound workspace payloads - #5359
Conversation
Two read paths answered with payloads sized by the session rather than by what the view asked for. polylogue-i5vqc: the web reader honoured a `#msg-<id>` deep link by walking up to 50 pages from the SSR offset. A target past that ceiling made a valid, resolvable reference report as "could not be located within the paged transcript", and a target inside it still fetched and retained every preceding message. The message-window routes now accept `around=<message id>`, resolve it to the offset of the window that holds it through the indexed composed-transcript order, and report that offset back; the island issues exactly one page request whatever the target's depth. A reference the session does not contain is refused with `message_not_found` instead of being answered with page zero, and `around` alongside a continuation is refused rather than silently preferring one. polylogue-o0zju: `/api/stack` and `/api/compare` serialized every message of every referenced session. Both now serve a declared `(limit, offset)` window per session and report it on the envelope, while each session's `message_count`/`total` still carries its true length. `limit=0` is the explicit whole-transcript request, so the default window is a declared parameter rather than a cap. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
`around` is now part of the `messages` read-view capability, so the OpenAPI document and the generated TypeScript client carry it rather than leaving it an undocumented query parameter. The island test makes the `around` request the only one that can contain the target, reproducing the archive behaviour a sequential walk fails against, and the database-backed session loader gets its own bounded-window test. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (9)
📒 Files selected for processing (13)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f5f12aa14
ℹ️ 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".
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
A deep link now resolves by reference in exactly one page request at any depth,
and
/api/stackand/api/compareserve a declared window per session insteadof every message of every session.
Both honour the 2026-09-21 ruling: the 50-page walk was removed, not raised, and
the workspace window is a reported default with no maximum and an explicit
whole-transcript escape — not a cap.
polylogue-i5vqc — resolve by ref, don't walk
At head, a deep link past
50 * pageSizereports "The linked message could not belocated within the paged transcript" — a valid, resolvable ref reported as
unlocatable — and a target inside 50 pages fetches and retains every preceding
message.
around=<message id>is now a declared query parameter on the existing messagesread-view capability, so
/api/sessions/:id/read?view=messagesand/api/sessions/:id/messagesboth accept it. No new route was added: a secondroute would have needed its own
RouteContractand OpenAPI declaration for a secondway to ask the same question. It is one request, not locate-then-fetch.
aroundis sugar over the existing coordinate, not new window semantics —test_deep_link_window_matches_the_offset_window_it_resolves_toproves anaroundwindow is byte-for-byte the window you get by asking for the offset it reports.
polylogue-o0zju — the bead undercounted the sites by three
It named only
build_stack_payload→_do_get_session. At head there are fourpayload builders, two per mode:
_handle_stack/_handle_comparebranch on_web_reader_archive_root()into_do_archive_stack/_do_archive_compare(thearchive-backed production route whenever the tiers exist) versus
workspace_routes.handle_stack/handle_compare(database-backed). The workspace SSRshell is a third caller of the archive pair.
Fixing only the bead's path would have left the actual production route
unbounded. All four are fixed and both envelopes report the served window; each
session payload's
message_count/totalstill carries its true length.Why this is a declared window and not a cap
WORKSPACE_MESSAGE_WINDOW = 50is the default of an explicitlimit— theserved
(limit, offset)is reported on both envelopes,limit=0requests the wholetranscript and is honoured, and there is no maximum, so no request is silently
clamped. Where a request is unanswerable the route refuses rather than truncates:
a message reference the session does not contain is
404 message_not_found(neverpage zero under the caller's reference), and
aroundalongside acontinuationis400 invalid_requestbecause they name two different windows.Mutation 8 is the test that distinguishes the two: turning the default into a ceiling
(
limit = min(raw_limit, 50)) reddenstest_stack_reports_true_totals_for_an_explicit_whole_transcript_requestwithassert 50 is None.A measured correction to the closure model, worth carrying forward
The ref→offset contract did not require editing
archive/query/transaction.py(IN). The reason is a fact the standing caveat does not state:
operations/transcript_window.pyimports six symbols fromtransaction.pyand stillmeasures
out. So importing the transaction vocabulary is free; only editingtransaction.pywould have converted this leaf. The new locator therefore lives inoperations/message_locator.py(out) and takes the archive reader as a parameter.All 13 changed non-bundle files measure
out, measured twice — at the originalbase and again after the rebase. The leaf stays rebuild-safe.
Anti-vacuity — eight mutations executed, and one test strengthened because a
mutation exposed it
aroundbut ignore itmessage_idinstead of(position, variant_index)toHaveBeenCalledTimes(1)still passed because the mock returned the target on call 1 — the exact vacuity the bead warned aboutaroundwindowUnable to find an element with the text: The deep-linked message, status reading "could not be located within the served window" after 50 fetchesget_sessioncallsthe stack ships the window the view renders, not the session — assert 2000 == 25assert 2000 == 25limit=Nonearound+continuationrefusalassert 404 == 400assert 50 is NoneRather than accept the vacuous pass on mutation 3, the lane strengthened the test so
only an
aroundwindow can contain the target, then re-ran the mutation to a realred. That is the right handling and is called out here so a reviewer sees it.
Parity, pagination, cancellation
test_transcript_window_differential.py5/5 — the same(ref, limit, offset)stillnames the same rows on all four surfaces, and
aroundgoes through the sameread_transcript_window_syncroute rather than a second window owneridentical resolved offset
next_offset == offset + limit, windows tile without overlap;continuation parity 5/5, token still minted by
window_resulttest_web_reader.py139/139, including client-disconnect abort on thelimit is Nonefull-composition branch this change preservesVerification
devtools verify --quickexit 0, all 25 gates (post-rebase) ·devtools render all --checkexit 0, zeroout of sync(two surfaces were regenerated mid-change:OpenAPI and the webui client) · focused 9-module selection 340/340 passed ·
devtools gate webuiexit 0 (tsc, vitest 33/33, client contracts 8/8, builds).New reds: none. Every selected suite was green at the pre-change baseline in this
worktree and at head, so no inheritance proof was needed and none is claimed for
suites outside this scope.
Residuals
aroundis HTTP-only.operations/read_contracts.pySessionReadRequeststilltakes only limit/offset, so CLI
read --view messages, the MCPreadtool and thePython API cannot express "the window around this message".
read_contracts.pyisout, so it is a rebuild-safe follow-up — left out because a declared-operationfield is a wider contract change than this leaf authorised.
is two indexed counts and the window composes at the storage layer, so the deep link
is genuinely O(page). On the DB-backed fallback the payload is bounded (mutation
5 proves it) but the read still composes the whole transcript — as it already did on
every page before this change; the single composition is reused rather than doubled.
because only the composed transcript can number them. That mirrors the constraint
read_archive_session_pagealready documents; a follow-up bounding the lineage casefixes both at once.
totalstill means "number of pairs", now window-sized; eachside's own
totalcarries the true length. A reader interpreting it as a sessionlength was already wrong, but the window makes that misreading cheaper.
Closes polylogue-i5vqc, polylogue-o0zju.
🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
Summary by CodeRabbit
aroundmessage ID to jump directly to its surrounding window.