Skip to content

fix(context): enforce canonical rendered character budget - #64

Merged
777genius merged 2 commits into
mainfrom
fix/canonical-context-character-budget
Sep 9, 2026
Merged

777genius merged 2 commits into
mainfrom
fix/canonical-context-character-budget

Conversation

@777genius

@777genius 777genius commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Repository-scoped canonical context ignored the rendered-character limit. Carry the explicit limit or deployment default into feature packing, preserving whole evidence records, source coordinates and consistent diagnostics. Validate final rendering, including empty custom section plans.

Validation: independent review approved 9b9c7e7. Full CI run 34287358674 passed on that commit; final focused remediation suite had 183 passing tests. After removing the unrelated Foundation draft dependency, the complete seven-file patch against main is byte-for-byte identical (cmp passed). Current head: 60ebdbc.

Per owner request for quick stable delivery without additional long checks or hosting load, reuse the reviewed patch and previous CI evidence. No new exact-head full CI claim is made after rebase. Foundation #63 and relation ports #65 remain separate drafts. No new feature work or paid provider calls.

Summary by CodeRabbit

  • New Features

    • Added an optional maximum character limit for rendered context.
    • Context selection now excludes content that would exceed the configured limit.
    • Added support for configuring and propagating the limit through context-building requests.
    • Added validation for non-negative character limits and consistent defaults across context sources.
  • Bug Fixes

    • Ensured final rendered context is validated against the character limit, including custom rendering and planning scenarios.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7b412a6c-7e59-4d8f-a597-1320bccc5082

📥 Commits

Reviewing files that changed from the base of the PR and between e7035c3 and 60ebdbc.

📒 Files selected for processing (7)
  • packages/infinity_context_contracts/infinity_context_contracts/features/context_building.py
  • packages/infinity_context_core/infinity_context_core/features/context_building/application/handlers.py
  • packages/infinity_context_core/infinity_context_core/features/context_building/domain/budget.py
  • packages/infinity_context_server/infinity_context_server/api/v1/context.py
  • packages/infinity_context_server/infinity_context_server/features/context_building/contracts.py
  • packages/infinity_context_server/infinity_context_server/features/context_building/mappers.py
  • tests/server/test_context_character_budget.py

📝 Walkthrough

Walkthrough

The change adds an optional rendered-character budget across contracts, mapping, domain planning, context handling, and repository-scoped defaults. The budget excludes oversized records during admission and validates final rendered evidence. New tests cover propagation, validation, custom renderers, and deployment behavior.

Changes

Context character budget

Layer / File(s) Summary
Budget contract propagation
packages/infinity_context_contracts/..., packages/infinity_context_server/...
Contracts and mappers now carry and validate optional max_rendered_chars values. Repository-scoped canonical-facts requests apply explicit values or the deployment default.
Budget admission and final validation
packages/infinity_context_core/...
The budget policy renders candidate items before selection and drops items that exceed the character cap. The handler validates final evidence and handles empty-plan and error cases.
End-to-end validation
tests/server/test_context_character_budget.py
Tests cover character counting, serialization, negative values, defaults, filters, custom planners, custom renderers, token-budget independence, and final rendered output.

Estimated code review effort: 4 (Complex) | ~45 minutes

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/canonical-context-character-budget

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

A rabbit packs the context with care
Each rendered character finds its place
Large records hop aside
Empty plans wait inside
Tests guard the budget path

Comment @coderabbitai help to get the list of available commands.

@777genius
777genius force-pushed the fix/canonical-context-character-budget branch from 9b9c7e7 to 60ebdbc Compare September 9, 2026 01:56
@777genius
777genius changed the base branch from refactor/feature-slice-architecture-guards to main September 9, 2026 01:56
@777genius
777genius marked this pull request as ready for review September 9, 2026 01:56
@777genius
777genius merged commit 17d4e9c into main Sep 9, 2026
1 of 15 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