feat: Per-file token budget configuration in .waza.yaml#96
Conversation
There was a problem hiding this comment.
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.yamlper-file token limit configuration (glob patterns) and legacy fallback behavior. - Update
waza tokens check(and suggest’s shared path) to resolve limits from.waza.yamlfirst and emit a deprecation warning when.token-limits.jsonis used. - Add tests covering
.waza.yamloverriding 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
resolveLimitsConfigtreats.waza.yamllimits as “missing” whentokens.limits.defaultsis nil and will fall back to legacy.token-limits.jsonif it exists. This can unexpectedly ignore a.waza.yamlconfig that provides onlytokens.limits.overrides(or any non-defaults-driven config), and it also makes precedence dependent on whether defaults are set rather than whethertokens.limitsis present. Consider treatingtokens.limitsas 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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
=======================================
Coverage ? 72.31%
=======================================
Files ? 129
Lines ? 14432
Branches ? 0
=======================================
Hits ? 10437
Misses ? 3222
Partials ? 773
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
spboyer
left a comment
There was a problem hiding this comment.
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.)
8887b98 to
cc83331
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cc83331 to
6c66009
Compare
Adding in a file grader, which lets you check for existence/non-existence of files, and do regex match/notmatch checks against the contents.
YAML for this configuration would look like this:
```yaml
graders:
- type: file
name: verify_output_files
config:
must_exist:
- "src/main.go"
- "README.md"
must_not_exist:
- "tmp/debug.log"
content_patterns:
- path: "src/main.go"
# NOTE: these are regexes
must_match:
- "package main"
- "func .+"
must_not_match:
- "fmt\\.Println\\(\"DEBUG"
- "os\\.Exit\\(1\\)"
```
Part of microsoft#28
wbreza
left a comment
There was a problem hiding this comment.
Code Review: PR #96 - feat: Per-file token budget configuration in .waza.yaml
Superseded by PR #64
PR #64 ("feat: invert token limits priority to .waza.yaml first #59") was merged and implements the same changes:
- resolveLimitsConfig returns (config, usedLegacy bool)
- .waza.yaml tokens.limits is primary, .token-limits.json is legacy fallback
- Deprecation warning on stderr when legacy limits are used
- Both check.go and suggest.go call sites updated
This PR should be closed as superseded. The branch likely has merge conflicts on helpers.go and check.go now.
Resolve token-limit command/doc conflicts by keeping main's newer legacy-warning behavior while preserving the PR's per-file limit examples and assertions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the Copilot note in 6b5fb62. now uses an explicit helper for configured limits, and locks in overrides-only taking precedence over legacy when both are present. |
wbreza
left a comment
There was a problem hiding this comment.
Code Review: PR #96 — Per-file token budget configuration in .waza.yaml
✅ What Looks Good
- Helper extraction is clean —
hasConfiguredTokenLimitsis semantically identical to the original inline condition, with proper nil-guard - Regression test is well-crafted —
TestResolveLimitsConfig_OverridesOnly_WazaYamlWinsOverLegacyJSONcovers the edge case PR #64 left untested - Comment fix is accurate —
config.go"per-model" → "per-file" matches actual struct semantics - Docs updated —
cli.mdxadds a useful YAML config example - No security, performance, concurrency, or error handling concerns
Prior Review Status
- ✅ Merge conflicts resolved — PR is cleanly mergeable
⚠️ PR #64 supersession resolved: this PR adds incremental value (helper extraction, regression test, deprecation messaging)
Findings Summary
| Priority | Count |
|---|---|
| Medium | 3 |
| Low | 2 |
| Total | 5 |
Overall Assessment: Approve — The PR adds genuine incremental value. Medium findings are non-blocking suggestions for follow-up.
…TokenLimits - Unify deprecation language across check.go, root.go, and helpers.go to consistently say 'deprecated; migrate to .waza.yaml' - Extract hasConfiguredTokenLimits helper from inline check in resolveLimitsConfig for clarity and testability - Add table-driven unit tests covering nil, empty, defaults-only, overrides-only, and both-present cases Addresses wbreza review feedback on PR #96. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed wbreza review feedback in 062c9ea:
|
|
Addressed remaining documentation feedback in 215b5d2:
|
…TokenLimits - Unify deprecation language across check.go, root.go, and helpers.go to consistently say 'deprecated; migrate to .waza.yaml' - Extract hasConfiguredTokenLimits helper from inline check in resolveLimitsConfig for clarity and testability - Add table-driven unit tests covering nil, empty, defaults-only, overrides-only, and both-present cases Addresses wbreza review feedback on PR microsoft#96. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addressed review feedback regarding consistent deprecation messaging and helper documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
site/src/content/docs/reference/cli.mdx:338
- These lines duplicate the token limit resolution note that appears just above (and the two versions differ slightly). Please delete one of the two copies so the CLI reference only states the priority order once.
Token limits are resolved in priority order: `.waza.yaml tokens.limits` → `.token-limits.json` (legacy, emits a deprecation warning) → built-in defaults.
See the **[Token Limits guide](../../guides/token-limits/)** for configuration details, pattern syntax, and migration instructions.
…ly_WazaYamlWinsOverLegacyJSON The function was missing its closing brace before the hasConfiguredTokenLimits test section, causing a compilation error after merge with main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous fix added the missing closing brace but left a gofmt violation (no blank line between function end and top-level comment). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Consolidates duplicate paragraphs about token limit priority and deprecated config file into a single, clearer explanation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When .waza.yaml contains `tokens.limits: {}`, the non-nil pointer
means the user explicitly declared the section. This should suppress
fallback to the deprecated .token-limits.json, even if both maps
are empty. Previously, empty maps caused a silent fallback.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
spboyer
left a comment
There was a problem hiding this comment.
Thread cleanup:
Missing closing brace (helpers_test.go:138): Already fixed in b083c24 + gofmt in a21425c. Branch compiles and all tokens tests pass — thread is stale.
hasConfiguredTokenLimits semantics (helpers.go:156): Fixed in e7cd2bd. hasConfiguredTokenLimits now returns true for any non-nil *TokenLimitsConfig pointer, so tokens.limits: {} in .waza.yaml is treated as authoritative and suppresses the legacy .token-limits.json fallback. Test updated (empty struct → expect true).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Merge 7 inbox decisions into .squad/decisions.md: • 2026-03-12: Mixed notification formats directive • 2026-03-30: Platform module architecture (Rusty) • 2026-03-30: Platform frontend Wave 2 (Rusty) • 2026-03-30: Platform backend patterns (Linus) • 2026-03-30: Platform API handlers & server mode (Linus) • 2026-03-30: PR conflict resolution (Linus) • 2026-03-30: PR #96 token limits precedence (Linus) - Delete all files from .squad/decisions/inbox/ (consolidated into main decisions log) - Create .squad/log/2026-03-30T2100-waza-platform.md session summary Wave 1 deliverables complete: architecture contracts, backend HTTP layer, frontend auth gate, 50+ tests, Azure deployment infrastructure. All decisions documented for institutional memory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #86