Fit the answer-wait evidence preview under the stream cap instead of losing it at the boundary - #2641
Conversation
… losing it at the boundary The wait showed no source cards on every non-fast answer. The preview builder sized its unit by source count alone (up to 12), while the stream contract bounds it by JSON size (64,000 chars). A real trimmed source is ~7,000 chars, not the ~900 the cap assumed, so a twelve-source unit was ~83,000 chars: built, sent to the route boundary, and dropped there as contract_rejected with nothing on screen. Fast routine answers select four passages and never hit the cap, which is why the browser proof stayed green. The builder now validates the exact unit it will emit with the same contract function and shrinks from the tail until it fits, in retrieval order. A source the contract rejects on its own is excluded individually. When nothing can ship, the wait records the new `undeliverable` reason for the setup-status diagnostic instead of emitting a unit that will be thrown away. selectedContextCount still names what governance let through. Adds a production-sized fixture to the offline contract proof so the builder's output is checked against the boundary it must cross. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ron4eHAhoccBetbyqAJVvP
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_33c40173-cfc5-4009-91c4-e8c126b0755e) |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 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 |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_ccd3a1c3-cdaf-4f7f-86fa-1a501a3226f1) |
Summary
isDeliverableVerifiedUnitbounds a unit at 64,000 JSON characters. A real trimmed source is ~7,000 characters (the ≤900-char snippet is carried twice, plus scoring, labels, indexing quality and relevance), so a twelve-source unit was ~83,000 characters: built, handed totoPublicAnswerProgressEvent, and dropped there ascontract_rejectedwith nothing on screen. Fast routine answers select four passages and never hit the cap, which is why the mocked browser proof stayed green through the previous fixes.src/lib/answer-preview.ts: the builder now validates the exact unit it will emit with the same contract function and shrinks from the tail until it fits, preserving retrieval order. A source the contract rejects on its own (for example a NaN similarity) is excluded individually rather than taking the rail down. When nothing can ship, the setup-status diagnostic records a newundeliverablereason instead of emitting a unit that will be thrown away.selectedContextCountstill names what governance let through.src/lib/answer-stream-contract.ts: comment only, correcting the "with headroom" sizing assumption. No validation change.tests/answer-incremental-delivery.test.ts: adds a production-sized 12-source fixture and proves the builder output survives the route boundary, that a malformed source is dropped alone, and that theundeliverablereason is recorded.docs/verified-answer-incremental-delivery-design.md: amendment recording the sizing defect and the builder-side fit rule.Before/after, same 12 real-sized sources through a mocked stream in the local app: before, the line reads "Writing the answer…" with zero cards (the reported screenshot); after, "6 sources found · writing the answer…" with six cards.
Verification
npm run test:focused -- --files src/lib/answer-preview.ts src/lib/answer-stream-contract.ts tests/answer-incremental-delivery.test.ts—Test Files 71 passed (71),Tests 1090 passed (1090)npm run format(committed),eslinton changed files clean,npm run typecheck—[gate-receipts] recorded a pass for "typecheck:internal"npm run verify:cheap— all 38 static gates, lint and typecheck green; unit suiteTests 3 failed | 16873 passed | 2 expected fail | 6 skipped (16884). The three failures (clinical-hazard-controls,privacy-readiness-contract,rag-plan-package-parity) each look up a historic commit hash absent from this container's clone (reviewedCommit does not exist …,reconciledBase is unavailable locally …) and fail identically on the untouchedmainheadcd5b901in a throwaway worktree. Environmental, not this diff; CI has full history.npm run verify:pr-local— Verification not run: it routes this diff to the heavy scope (fulltest,build,eval:rag:offline), which is the verdict CI is about to reach; deferred to CI.tests/answer-progress-ui-smoke.spec.tsrail journeys run in CI; the before/after screenshots above were taken against the local app with the builder's real output.Risk and rollout
RAG_INCREMENTAL_EVIDENCE_PREVIEW=false(the existing first rollback step).mainvia Railway auto-deploy; no migration, no env change.modelContextResults, ranking, selection and thefinalpayload are byte-identical.Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ron4eHAhoccBetbyqAJVvP
Note
Low Risk
Server-only change to wait-time preview sizing; final answer payload, retrieval, and stream contract validation are unchanged—worst case is fewer preview cards than before, when the boundary previously showed none.
Overview
Fixes the answer-wait evidence rail showing zero source cards on non-fast (strong-route) answers: the preview builder used to pack up to 12 trimmed sources while
isDeliverableVerifiedUnitenforces a 64,000 JSON character ceiling—production-sized sources (~7k each) produced ~83k units thattoPublicAnswerProgressEventdropped ascontract_rejected.answer-preview.tsnow runs the sameisDeliverableVerifiedUnitcheck on the unit it will emit, drops sources from the tail (retrieval order) until the payload fits, and filters out individually invalid sources (e.g. NaN similarity) instead of failing the whole rail. When nothing can ship, diagnostics record a newundeliverablereason rather than emitting a doomed unit.selectedContextCountstill reflects the full governed selection, not only the shipped subset.answer-stream-contract.tsupdates comments only (no validation change). Design doc records the sizing defect and builder-side fit rule. Tests add a production-sized 12-source fixture and assert boundary survival, per-source exclusion, andundeliverablereporting.Reviewed by Cursor Bugbot for commit 2b98607. Configure here.