Skip to content

feat: Per-file token budget configuration in .waza.yaml#96

Open
spboyer wants to merge 1 commit intomicrosoft:mainfrom
spboyer:squad/86-per-file-token-budget
Open

feat: Per-file token budget configuration in .waza.yaml#96
spboyer wants to merge 1 commit intomicrosoft:mainfrom
spboyer:squad/86-per-file-token-budget

Conversation

@spboyer
Copy link
Member

@spboyer spboyer commented Mar 5, 2026

Closes #86

Copilot AI review requested due to automatic review settings March 5, 2026 02:39
@spboyer spboyer self-assigned this Mar 5, 2026
@github-actions github-actions bot enabled auto-merge (squash) March 5, 2026 02:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support and documentation for configuring per-file token limits via .waza.yaml (tokens.limits) with a legacy fallback to .token-limits.json (now deprecated), and updates CLI behavior/tests to reflect the new precedence + warning.

Changes:

  • Document .waza.yaml per-file token limit configuration (glob patterns) and legacy fallback behavior.
  • Update waza tokens check (and suggest’s shared path) to resolve limits from .waza.yaml first and emit a deprecation warning when .token-limits.json is used.
  • Add tests covering .waza.yaml overriding legacy limits and the legacy deprecation warning path.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
site/src/content/docs/reference/cli.mdx Adds docs + example YAML for per-file limits and notes legacy fallback warning.
internal/projectconfig/config.go Updates TokenLimitsConfig comment to describe per-file glob/path patterns.
cmd/waza/tokens/helpers.go Changes limits resolution to return (config, usedLegacy) for warning emission.
cmd/waza/tokens/check.go Propagates usedLegacy and prints deprecation warnings (single + batch).
cmd/waza/tokens/check_test.go Adds tests for .waza.yaml precedence over legacy + warning on legacy fallback.
cmd/waza/tokens/suggest.go Updates to new resolveLimitsConfig signature and passes config into checker.
cmd/waza/tokens/root.go Clarifies .token-limits.json is deprecated in command description.
.squad/log/* Adds session logs (process documentation).
.squad/decisions.md Records token diff distribution strategy + workflow directive.
Comments suppressed due to low confidence (1)

cmd/waza/tokens/helpers.go:122

  • resolveLimitsConfig treats .waza.yaml limits as “missing” when tokens.limits.defaults is nil and will fall back to legacy .token-limits.json if it exists. This can unexpectedly ignore a .waza.yaml config that provides only tokens.limits.overrides (or any non-defaults-driven config), and it also makes precedence dependent on whether defaults are set rather than whether tokens.limits is present. Consider treating tokens.limits as present when either defaults or overrides are provided (and avoid legacy fallback in that case), or explicitly error/warn when defaults are absent so the behavior isn’t silent. Adding a test for “overrides-only .waza.yaml + legacy file present” would lock in the intended precedence.
	pcfg, err := projectconfig.Load(skillDir)
	if err != nil || pcfg.Tokens.Limits == nil || pcfg.Tokens.Limits.Defaults == nil {
		if _, statErr := os.Stat(filepath.Join(skillDir, ".token-limits.json")); statErr == nil {
			return checks.TokenLimitsConfig{}, true
		}
		return checks.TokenLimitsConfig{}, false

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@3460e25). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/waza/tokens/check.go 75.00% 2 Missing and 1 partial ⚠️
cmd/waza/tokens/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage        ?   72.21%           
=======================================
  Files           ?      128           
  Lines           ?    14259           
  Branches        ?        0           
=======================================
  Hits            ?    10297           
  Misses          ?     3197           
  Partials        ?      765           
Flag Coverage Δ
go-implementation 72.21% <80.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member Author

@spboyer spboyer left a comment

Choose a reason for hiding this comment

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

LGTM — Rusty. Clean per-file token budget config. resolveLimitsConfig returning (config, bool) to track legacy fallback is the right pattern. Deprecation warning for .token-limits.json is exactly what we need. Tests cover both override priority and fallback warning paths. Docs updated. Ship it. (Self-authored PR — cannot self-approve via API.)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer force-pushed the squad/86-per-file-token-budget branch from 8887b98 to cc83331 Compare March 5, 2026 17:12
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.

feat: Per-file token budget configuration in .waza.yaml

3 participants