Skip to content

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

Merged
github-actions[bot] merged 11 commits into
microsoft:mainfrom
spboyer:squad/86-per-file-token-budget
Mar 9, 2026
Merged

feat: Per-file token budget configuration in .waza.yaml#96
github-actions[bot] merged 11 commits into
microsoft:mainfrom
spboyer:squad/86-per-file-token-budget

Conversation

@spboyer

@spboyer spboyer commented Mar 5, 2026

Copy link
Copy Markdown
Member

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

codecov-commenter commented Mar 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@54da7a5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/waza/tokens/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage        ?   72.31%           
=======================================
  Files           ?      129           
  Lines           ?    14432           
  Branches        ?        0           
=======================================
  Hits            ?    10437           
  Misses          ?     3222           
  Partials        ?      773           
Flag Coverage Δ
go-implementation 72.31% <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.

@spboyer spboyer left a comment

Copy link
Copy Markdown
Member Author

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.)

@spboyer spboyer force-pushed the squad/86-per-file-token-budget branch from 8887b98 to cc83331 Compare March 5, 2026 17:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer force-pushed the squad/86-per-file-token-budget branch from cc83331 to 6c66009 Compare March 5, 2026 17:47
chlowell pushed a commit to chlowell/waza that referenced this pull request Mar 5, 2026
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 wbreza left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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>
Copilot AI review requested due to automatic review settings March 7, 2026 02:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread cmd/waza/tokens/root.go
Comment thread site/src/content/docs/reference/cli.mdx
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer

spboyer commented Mar 7, 2026

Copy link
Copy Markdown
Member Author

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
wbreza previously approved these changes Mar 9, 2026

@wbreza wbreza left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review: PR #96 — Per-file token budget configuration in .waza.yaml

✅ What Looks Good

  • Helper extraction is cleanhasConfiguredTokenLimits is semantically identical to the original inline condition, with proper nil-guard
  • Regression test is well-craftedTestResolveLimitsConfig_OverridesOnly_WazaYamlWinsOverLegacyJSON covers the edge case PR #64 left untested
  • Comment fix is accurateconfig.go "per-model" → "per-file" matches actual struct semantics
  • Docs updatedcli.mdx adds 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.

Comment thread cmd/waza/tokens/check.go Outdated
Comment thread cmd/waza/tokens/helpers.go
Comment thread site/src/content/docs/reference/cli.mdx
spboyer added a commit that referenced this pull request Mar 9, 2026
…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>
@spboyer

spboyer commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Addressed wbreza review feedback in 062c9ea:

  • Standardized deprecation phrasing across check.go, root.go, and helpers.go to consistently say 'deprecated; migrate to .waza.yaml'
  • Extracted hasConfiguredTokenLimits helper from inline check in resolveLimitsConfig
  • Added table-driven unit tests covering nil, empty, defaults-only, overrides-only, and both-present cases

@spboyer

spboyer commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Addressed remaining documentation feedback in 215b5d2:

  • Consistency: Updated and to use consistent deprecation phrasing: "(deprecated; migrate to .waza.yaml)".
  • Documentation: Added doc comment to clarifying behavior for empty-but-non-nil maps.
  • Reference: Explicitly marked section in as deprecated.

spboyer and others added 2 commits March 9, 2026 18:23
…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>
Copilot AI review requested due to automatic review settings March 9, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread cmd/waza/tokens/helpers_test.go
Comment thread cmd/waza/tokens/helpers.go Outdated
Comment thread site/src/content/docs/reference/cli.mdx
spboyer and others added 2 commits March 9, 2026 18:28
…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>
Copilot AI review requested due to automatic review settings March 9, 2026 22:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread site/src/content/docs/reference/cli.mdx Outdated
spboyer and others added 2 commits March 9, 2026 18:42
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>
Copilot AI review requested due to automatic review settings March 9, 2026 22:43

@spboyer spboyer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread cmd/waza/tokens/check_test.go
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot merged commit 505f284 into microsoft:main Mar 9, 2026
6 checks passed
@spboyer spboyer mentioned this pull request Mar 12, 2026
4 tasks
spboyer pushed a commit that referenced this pull request Mar 30, 2026
- 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>
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

6 participants