Files
cleveragents-core/features/acms/acms_budget_enforcement.feature
T
HAL9000 650a3dc8dd
CI / load-versions (pull_request) Successful in 16s
CI / push-validation (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 48s
CI / build (pull_request) Successful in 41s
CI / quality (pull_request) Successful in 59s
CI / typecheck (pull_request) Successful in 1m18s
CI / security (pull_request) Successful in 1m21s
CI / helm (pull_request) Successful in 44s
CI / unit_tests (pull_request) Successful in 5m44s
CI / docker (pull_request) Successful in 1m41s
CI / integration_tests (pull_request) Successful in 10m20s
CI / coverage (pull_request) Successful in 11m54s
CI / status-check (pull_request) Successful in 3s
fix(acms): format __init__.py, add coverage for budget_enforcement paths
- Remove unnecessary parentheses from __all__ concatenation in acms/__init__.py
  to satisfy ruff format (lint gate was failing)
- Mark unreachable RuntimeError branch in add_file with # pragma: no cover
- Add 8 Behave scenarios covering previously uncovered lines:
  get_assembled_context(), reset(), BudgetEnforcer.__post_init__ validation
  errors, add_file validation errors, BudgetViolation unknown type
- Add corresponding step definitions; import BudgetViolation in steps module

ISSUES CLOSED: #9583
2026-06-17 19:54:20 -04:00

102 lines
4.6 KiB
Gherkin

Feature: ACMS Budget Enforcement for max_file_size and max_total_size constraints
Background:
Given a budget enforcer with max_file_size of 1000 bytes
And a budget enforcer with max_total_size of 5000 bytes
Scenario: File within max_file_size limit is included
When I add a file of 500 bytes to the context
Then the file should be included in the assembled context
And the total context size should be 500 bytes
Scenario: File exceeding max_file_size limit is excluded
When I add a file of 1500 bytes to the context
Then the file should be excluded from the assembled context
And a budget violation warning should be generated for the file
Scenario: File at max_file_size boundary is included
When I add a file of exactly 1000 bytes to the context
Then the file should be included in the assembled context
And the total context size should be 1000 bytes
Scenario: Multiple files within total budget are included
When I add a file of 800 bytes to the context
And I add a file of 900 bytes to the context
And I add a file of 700 bytes to the context
Then the total context size should be 2400 bytes
And all three files should be included in the assembled context
Scenario: Files exceeding max_total_size are gracefully cut off
When I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
And I add a file of 800 bytes to the context
Then the total context size should not exceed 5000 bytes
And a budget violation warning should be generated for exceeding max_total_size
Scenario: Budget violation produces clear error message
When I add a file of 1500 bytes to the context
Then a budget violation error should be generated
And the error message should indicate the file size exceeds max_file_size
And the error message should include the file size and the limit
Scenario: Cumulative budget tracking prevents overflow
When I add a file of 500 bytes to the context
And I add a file of 500 bytes to the context
Then the total context size should be 1000 bytes
And no budget violation should be generated
Scenario: Budget enforcement respects file ordering
When I add files in order: 1000, 1000, 1000, 1000, 1000, 1000 bytes
Then the first 5 files should be included
And the total context size should be 5000 bytes
And no additional files should be added beyond the budget
Scenario: Budget violation reporting includes file metadata
When I add a file named "large_file.txt" of 1500 bytes to the context
Then the budget violation should include the filename "large_file.txt"
And the budget violation should include the file size 1500
And the budget violation should include the limit 1000
Scenario: Empty files do not consume budget
When I add an empty file to the context
And I add a file of 500 bytes to the context
Then the total context size should be 500 bytes
And both files should be included in the assembled context
Scenario: Multi-byte UTF-8 content is measured by byte size not character count
When I add a file with multi-byte UTF-8 content of 250 characters to the context
Then the file should be excluded from the assembled context
And a budget violation warning should be generated for the file
Scenario: Assembled context joins included file contents
When I add a file of 100 bytes to the context
And I add a file of 200 bytes to the context
Then the assembled context should be non-empty
Scenario: Reset clears enforcer state for re-use
When I add a file of 500 bytes to the context
And I reset the budget enforcer
Then the total context size should be 0 bytes
Scenario: BudgetEnforcer rejects negative max_file_size
Then creating an enforcer with negative max_file_size raises ValueError
Scenario: BudgetEnforcer rejects zero max_total_size
Then creating an enforcer with zero max_total_size raises ValueError
Scenario: BudgetEnforcer rejects max_file_size larger than max_total_size
Then creating an enforcer with max_file_size larger than max_total_size raises ValueError
Scenario: add_file rejects empty filename
Then adding a file with an empty name raises ValueError
Scenario: add_file rejects non-string content
Then adding a file with non-string content raises TypeError
Scenario: BudgetViolation rejects unknown violation_type
Then creating a BudgetViolation with an unknown type raises ValueError