Skip to content

fix(expansion): admit complete input through model capacity - #1029

Merged
guangyu-reflexio merged 2 commits into
mainfrom
team/document-expansion-capacity
Nov 13, 2026
Merged

guangyu-reflexio merged 2 commits into
mainfrom
team/document-expansion-capacity

Conversation

@guangyu-reflexio

@guangyu-reflexio guangyu-reflexio commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Document expansion silently replaced its input with the first 4,000 characters. Render the complete supplied string and use the existing model-input admission scope for each final native request, including its output reservation. Capacity refusal retains empty optional enrichment; host delegation, existing enrichment timeout/error handling and source text stay unchanged.

SQLite now forwards an explicitly configured tenant generation output reservation to its storage-owned client. Custom gateways retain the existing endpoint-specific context declaration and explicit-output requirements. No new input, replacement prefix, output-cap normalization or schema change. The enterprise companion applies that wiring to its two native adapters.

Validation: 113 focused SDK cases, nine-file combined typecheck with zero errors/warnings, Ruff and whitespace checks passed. A real loopback HTTP provider behind the production isolated worker received all 5,021 Unicode characters through the actual renderer; an oversized request generated no second call. All four counterfactuals (restore clipping / bypass admission / restore document prompt logging / restore query prompt logging) fail their targeted regressions, with source restored byte-identical. Companion native/related gate: 753 passed, including 16 new real storage cases across both adapters and APP/owner roles, no skips.

Supported count remains 325; this hidden-policy correction earns zero reduction credit. No paid model, customer environment, remote database or deployment changes. TestSprite is unavailable/unlinked; local native/HTTP gates are the executed evidence. Current-head Codex CODE/SECURITY P0/P1 and ordinary CI remain merge gates.

Review follow-up: expansion and reformulation debug logs now contain prompt sizes instead of raw rendered text. Direct closed/half-open circuit regressions verify capacity refusal is neutral, frees its probe and permits the next admissible request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T06:48:17.190327Z 853a78f New commits
🔒 Security Review ✅ Completed 2026-11-13T06:40:42.216005Z 120b4f7 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.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Document expansion now uses the full supplied content and checks model input capacity around the LLM request. SQLite storage applies a configured generation output limit. Tests cover admission, capacity refusal, gateway policies, and storage behavior.

Changes: Document expansion

Layer / File(s) Summary
Expansion input and capacity handling
reflexio/server/services/pre_retrieval/_document_expander.py, reflexio/server/services/storage/sqlite_storage/_base.py, tests/server/services/test_document_expansion_capacity.py, reflexio/server/services/pre_retrieval/README.md
The expander passes full content to the LLM request within model_input_budget(). SQLite storage applies the configured generation output limit. Tests cover capacity admission, refusal, gateway policies, and storage behavior. The README documents these handling rules and unchanged storage and embedding behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: yyiilluu

Merge Risk: Minimal · up to 120b4

Document expansion now renders the complete input and refuses oversized requests through the existing capacity check, leaving optional enrichment empty. No concrete merge-blocking risk was established. The debug-log comment is retained as an unverified note for the author to consider.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary change: document expansion now admits the complete input through model capacity checks. The raw summary and PR objectives confirm that expansion renders the full string ins…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the primary change: document expansion now admits the complete input through model capacity checks. The raw summary and PR objectives confirm that expansion renders the full string instead of truncating to 4,000 characters, and that the existing model-input admission scope is applied to each native request. The title uses a conventional type(scope) prefix, is one sentence, and is 59 characters long. It does not describe anything absent from the changeset.

Finishing Touches

Generate unit tests (beta)

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

reflexio/server/services/pre_retrieval/_document_expander.py-133-133: 1

133-133: Major · Security & Privacy · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Remove the full-prompt debug log.

When debug logging is enabled, removing the input clipping makes this statement log the complete document, including customer content beyond the previous 4,000-character prefix. The statement also logs documents that capacity admission subsequently refuses.

Replace the prompt with non-content metadata, such as its length. The customer-content restriction documented in _parse_expansion_json at Lines 178-180 also applies to this input.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 67b84f7 and 120b4f7.

Files selected for processing: 4

  • reflexio/server/services/pre_retrieval/README.md
  • reflexio/server/services/pre_retrieval/_document_expander.py
  • reflexio/server/services/storage/sqlite_storage/_base.py
  • tests/server/services/test_document_expansion_capacity.py

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

@guangyu-reflexio
guangyu-reflexio merged commit 39b6399 into main Nov 13, 2026
6 checks passed
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