Skip to content

fix: auto-diff budgets --max-tokens per file with the real tokenizer (#20 B14) - #67

Merged
igorls merged 9 commits into
masterfrom
fix/20-autodiff-max-tokens
Oct 12, 2026
Merged

igorls merged 9 commits into
masterfrom
fix/20-autodiff-max-tokens

Conversation

@igorls

@igorls igorls commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Part of #20 (B14). generate_markdown_with_diff now renders each file section through diff_file_section, budgets it with the shared fit_chunk_to_budget (extracted from render_truncated_to_fit, behavior unchanged), clamps the crossing file, and reports omitted files. The old byte cut remains only as a safety net when the header/diff/tree alone exceed the budget. Tests: tests/test_autodiff_budget.rs (in-process run_with_args + binary): real token count <= budget in o200k and cl100k, balanced fences, clamp marker, omitted count, large budget = no-op. Fails on master.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 15:25

Copilot AI 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.

🟡 Changes recommended

Notice accounting and fallback truncation can still violate the token budget, while signature truncation can remain undisclosed.

2 open findings
What changed in this PR

Updates auto-diff rendering to apply real tokenizer-based per-file budgets.

Changes:

  • Shares file-budget fitting with the standard renderer.
  • Adds clamping and omission reporting.
  • Adds integration coverage and changelog documentation.
File Description
src/​lib.rs Applies budgeting to auto-diff output.
src/​markdown.rs Extracts shared budget-fitting logic.
tests/​test_autodiff_budget.rs Tests budgets, encodings, fences, and omissions.
CHANGELOG.md Documents the auto-diff fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
@igorls
igorls merged commit fa84381 into master Oct 12, 2026
7 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.

2 participants