Skip to content

test(core): add unit tests for computeTierDemand and allocateTiers (fixes #447) - #459

Merged
dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/context-budget-v2-tiers
Nov 17, 2026
Merged

dmae97 merged 1 commit into
dmae97:mainfrom
anhnt256:test/context-budget-v2-tiers

Conversation

@anhnt256

Copy link
Copy Markdown
Contributor

Fixes #447.

Test-only PR, no source changes. Adds packages/coding-agent/test/context-budget-v2-tiers.test.ts (8 vitest cases) for computeTierDemand / allocateTiers in core/context-budget-v2-tiers.ts:

  • computeTierDemand: empty plan gives zeros; system sum (demand 150 / hard 100)
  • allocateTiers with available=1000 and DEFAULT_TIER_POLICY_V2: system {floor 250, ceiling 450, allocated 150}; history soft demand capped at floor (allocated 100); tools hard demand above ceiling (allocated 200, ceiling 120)
  • missing tier → allocated 0
  • inverted policy (floorPct 0.5 / ceilingPct 0.1) → ceiling equals floor (500)
  • available=0 → every floor and ceiling 0

Verification: all 8 tests pass locally; bite-check (changing allocateTiers to ignore hard demand) fails exactly 1 test. Biome check clean on the new file; tsgo --noEmit shows only 2 pre-existing errors in untouched files. Local npm run check stops at check:dep-tree, a pre-existing environment artifact; CI is the real gate.

dmae97 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Reviewed head 0aa8c018359ae6b9ace82e62f70c74e9c4f33051 against main 94ed867a0342ee9f158a144eb80b0dc58c2ba57f.

The 73-line test-only diff covers #447's demand sums, floor/ceiling allocation, hard-demand admission, missing tier, inverted policy, and zero-budget cases. I compared the assertions with context-budget-v2-tiers.ts; the fixture cast stays inside the test and the shared demand map is only read by the implementation. No source, dependency, workflow, or network changes are introduced; no blocking defect found in this narrow diff.

Verification: all five reported checks passed. I inspected build-check-test job 133224839401, including the new file's 8 passing tests and the successful check job. This is implementation/diff and CI-log review, not an independent local rerun; I did not reproduce the reported mutation test or local environment/type errors. No other submitted review or unresolved review thread was present.

Automated merge remains withheld because branch-protection detail reads return 403 to this integration, so required merge policy cannot be fully verified. No rerun or merge was initiated.

@dmae97
dmae97 merged commit 953ac02 into dmae97:main Nov 17, 2026
5 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.

test: add unit tests for computeTierDemand / allocateTiers in core/context-budget-v2-tiers.ts

2 participants