Problem
Both classifiers (anthropic.ts:40, claude-cli.ts:36) cap diff input at 20,000 bytes with no content awareness. Two issues compound:
-
20KB is far too small. The default model is claude-haiku-4-5 (200K context window). Current total prompt is ~55KB (~13K tokens) — only 6% of available context. The cap truncates real PRs at 300-400 lines of code. A typical feature PR is 800-1500 lines; a refactor or migration is multiples of that.
-
Lockfile noise eats the budget. A PR that regenerates pnpm-lock.yaml blows through 20KB of lock diff before a single line of real code reaches the classifier. tree sync already solved this (sync.ts:665 formatPrDiffForPrompt) by filtering noise first, then truncating.
Proposal
1. Raise caps
| Constant |
Current |
New |
Share of 200K window |
DIFF_CAP (both classifiers) |
20,000 |
200,000 |
~25% |
DIGEST_BUDGET_BYTES (tree-digest.ts:25) |
30,000 |
100,000 |
~12% |
| Combined with system + metadata |
~55KB |
~310KB |
~38% of Haiku's 200K |
Leaves ~60% of window for prompt-caching overhead, tokenizer variance on mixed Chinese/code content, and Anthropic's soft ~180-190K prompt-length threshold. Works for Sonnet/Opus upgrades without re-tuning.
2. Filter noise before truncating
Drop from both classifiers' diff input:
*.lock, package-lock.json, pnpm-lock.yaml, yarn.lock, Cargo.lock, poetry.lock, Gemfile.lock
*.min.js, *.min.css, *.map
dist/, build/, node_modules/, coverage/, __pycache__/, out/
Regex list already exists in sync.ts:626-630. Extract to shared engine/classifiers/diff-filter.ts so sync and both classifiers share one source of truth.
3. Single default — no flag
One set of numbers for all scenarios (daemon sweeps, CI, manual invocations). Keeping it simple; we can add an override later only if a real workload demands it.
Cost implication
Haiku 4.5 input pricing is cheap enough that raising per-classify cost from ~$0.004 → ~$0.02 is a non-issue for the verdict quality gain. Prompt caching (#315) keeps repeated classifies on the same tree cheap.
Acceptance
Problem
Both classifiers (
anthropic.ts:40,claude-cli.ts:36) cap diff input at 20,000 bytes with no content awareness. Two issues compound:20KB is far too small. The default model is
claude-haiku-4-5(200K context window). Current total prompt is ~55KB (~13K tokens) — only 6% of available context. The cap truncates real PRs at 300-400 lines of code. A typical feature PR is 800-1500 lines; a refactor or migration is multiples of that.Lockfile noise eats the budget. A PR that regenerates
pnpm-lock.yamlblows through 20KB of lock diff before a single line of real code reaches the classifier.tree syncalready solved this (sync.ts:665formatPrDiffForPrompt) by filtering noise first, then truncating.Proposal
1. Raise caps
DIFF_CAP(both classifiers)DIGEST_BUDGET_BYTES(tree-digest.ts:25)Leaves ~60% of window for prompt-caching overhead, tokenizer variance on mixed Chinese/code content, and Anthropic's soft ~180-190K prompt-length threshold. Works for Sonnet/Opus upgrades without re-tuning.
2. Filter noise before truncating
Drop from both classifiers' diff input:
*.lock,package-lock.json,pnpm-lock.yaml,yarn.lock,Cargo.lock,poetry.lock,Gemfile.lock*.min.js,*.min.css,*.mapdist/,build/,node_modules/,coverage/,__pycache__/,out/Regex list already exists in
sync.ts:626-630. Extract to sharedengine/classifiers/diff-filter.tsso sync and both classifiers share one source of truth.3. Single default — no flag
One set of numbers for all scenarios (daemon sweeps, CI, manual invocations). Keeping it simple; we can add an override later only if a real workload demands it.
Cost implication
Haiku 4.5 input pricing is cheap enough that raising per-classify cost from ~$0.004 → ~$0.02 is a non-issue for the verdict quality gain. Prompt caching (#315) keeps repeated classifies on the same tree cheap.
Acceptance
DIFF_CAPraised to 200,000 in bothanthropic.tsandclaude-cli.tsDIGEST_BUDGET_BYTESraised to 100,000 intree-digest.tsgardener-*-classifier.test.tsstill pass, updated fixtures if needed