Skip to content

fix(web-search): bound duplicate citation title updates - #8813

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/citation-title-update-budget
Nov 17, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/citation-title-update-budget

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Repeated unusable titles for an existing titleless citation made the sidecar parser rebuild and revalidate its entire retained source list. Every append then serialized all preceding sources again. A small upstream response could therefore cause substantial synchronous work despite the existing source and wire limits.

  • Reject invalid offered titles before inspecting the retained list.
  • Update one previously validated citation using its serialized UTF-8 byte delta and a single aggregate-size pass, preserving its position and every other source.
  • Preserve the first usable later title, exact byte/count/URL limits, later shorter-title retries, and final-versus-streaming precedence.
  • Update the owning Search Data Plane contract.

Verification

Recorded local validation:

  • Independent prepatch validation used the exported production parser with at most 256 duplicate annotations. A 31,525-byte response triggered 54,180 source serializations, compared with 420 without duplicates. These are operation counts, not peak memory or production latency.
  • The new regression failed on the base: forty invalid duplicates increased source serializations from 420 to 8,820 while leaving the output unchanged. After the fix, invalid duplicates add no source serialization. A later valid title still fills the original position.
  • An exact UTF-8 boundary test confirms an over-budget title leaves every source intact and a later shorter Unicode title reaches the aggregate limit exactly.
  • bun test tests/web-search/web-search-sources.test.ts tests/web-search/web-search-eof.test.ts tests/web-search/fix-search-frame-shapes.test.ts: 168 passed / 577 assertions.
  • Typecheck: 2,536 files, no errors. Structure, privacy, file-size and staged whitespace gates passed; no caps were raised.

The companion credential-mask regression now times the excerpt masker directly and separately asserts full SSE rewrite output and secret removal, with a bounded whole-text restart count. It does not claim a new full-rewrite performance measurement.

Upstream validation for e54449b1ccb455f473b623735bd17f7af934ab38 passed: Cross-platform CI, Catalog async contracts, and PR gates. The changed-test subset passed; skipped full/native-platform shards are not claimed as executed. An additional read-only review of this exact commit found no blocking correctness or test-isolation issue; it did not rerun tests or performance measurements. Installed/live application validation and explicit maintainer security review before merge remain separate.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review remains required before merge.

Summary by CodeRabbit

  • Bug Fixes
    • Improved web-search citation titles: valid titles from completed results are used when available, while valid streamed titles are retained when no completed title is available.
    • Updated titles preserve citation order and are applied only when they fit within the source-size limit.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The parser now uses shared logic to add valid titles to retained citation sources, subject to the aggregate serialized-byte limit. The tests also expand coverage for citation updates and credential masking.

Changes: Citation title updates

Layer / File(s) Summary
Shared title replacement and citation coverage
src/web-search/sources.ts, src/web-search/parse.ts, structure/data-planes/search.md, tests/web-search/web-search-sources.test.ts
The parser uses a shared helper to fill a missing title on the first matching source. The helper validates the title and applies the replacement only when the updated serialized sources fit the byte limit. Documentation and tests cover duplicate citations and exact replacement limits.

Credential masking test coverage

Layer / File(s) Summary
Credential masking assertions
tests/responses/sse-untyped-credential-mask.test.ts
The tests check credential removal, preserved message content, elapsed time, and whole-text search counts for large terminal output and rewritten SSE payloads.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8491: Changes sidecar citation-title handling for repeated URLs, including title replacement and source position preservation. Its retained-title behavior relates directly to the title contract in this change.
Merge Risk: Minimal · up to e5444

This change bounds the work done for duplicate citation titles in web-search parsing while keeping the existing size limits. No concrete merge-blocking risk was identified. Installed-application validation remains outstanding.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(web-search): bound duplicate citation title updates" matches the main change. The PR adds fillMissingWebSearchSourceTitle in src/web-search/sources.ts, which fills a missing title only …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(web-search): bound duplicate citation title updates" matches the main change. The PR adds fillMissingWebSearchSourceTitle in src/web-search/sources.ts, which fills a missing title only on a matching source and rejects invalid titles early. parse.ts switches to this helper, and tests cover repeated invalid titles and the UTF-8 byte budget. The title names the bounded duplicate handling, which is the core fix. The title is concise, follows conventional-commit style, and does not use vague terms.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 595de1e and e54449b.

Files selected for processing: 5

  • src/web-search/parse.ts
  • src/web-search/sources.ts
  • structure/data-planes/search.md
  • tests/responses/sse-untyped-credential-mask.test.ts
  • tests/web-search/web-search-sources.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev under MAINTAINERS.md (not an approving review), 2026-11-17 triage round.

@lidge-jun
lidge-jun merged commit d43d91d into lidge-jun:dev Nov 17, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants