feat(acms): implement budget enforcement for max_file_size and max_total_size constraints #11096

Closed
HAL9000 wants to merge 6 commits from pr-9673-budget-enforcement into master

6 Commits

Author SHA1 Message Date
cleveragents-bot eedb7999ab fix(acms): fix ruff format violations in step definitions
CI / push-validation (pull_request) Successful in 35s
CI / helm (pull_request) Successful in 41s
CI / build (pull_request) Successful in 1m8s
CI / lint (pull_request) Failing after 1m28s
CI / quality (pull_request) Successful in 1m36s
CI / typecheck (pull_request) Successful in 1m45s
CI / security (pull_request) Successful in 2m11s
CI / integration_tests (pull_request) Successful in 4m49s
CI / unit_tests (pull_request) Failing after 7m20s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 2s
Ruff detected formatting issues in acms_budget_enforcement_steps.py.

Fixes blocking lint failure on CI.
2026-05-18 07:59:38 +00:00
HAL9000 8fa5d2d071 fix(acms): restore explicit UKO re-exports, fix type annotations, clean lint directives
Restore explicit 'from cleveragents.acms.uko import (...)' block in __init__.py so that acms_skeleton_compressor.py can import CODE_DETAIL_LEVEL_MAP etc.

Fix invalid dict[str, callable] annotation in robot helper to use
collections.abc.Callable[[], None].

Remove unused noqa directives (E501, C901) now that ruff rules are stricter.
2026-05-18 07:59:38 +00:00
HAL9000 859102e493 fix(acms): resolve CI failures in budget enforcement PR #9673
- Fix BDD test state leakage by unconditionally resetting BudgetEnforcer
  in step_create_budget_enforcer_with_max_total_size instead of using
  conditional if/else reconstruction that skipped the first Background
  step's max_file_size from being preserved.
- Add explicit type annotations (context: object) to all Behave step
  function signatures for Pyright compliance.
- Fix ruff format compliance by standardizing decorator string
  formatting in acms_budget_enforcement_steps.py.
- Correct __init__.py exports: renamed _uks_exports -> _uko_exports
  typo and fixed the __all__ reference to use the corrected variable.
- Add Robot Framework integration test helper using inline imports
  (from cleveragents.acms.budget_enforcement import BudgetEnforcer)
  instead of sys.path manipulation, and update robot tests to use
  python3 and ${WORKSPACE} paths for CI compatibility.

ISSUES CLOSED: #9583
2026-05-18 07:59:38 +00:00
HAL9000 e61ae94d51 fix(acms): resolve state leakage in BDD step definitions and fix export variable name
- Rename _uks_exports to _uko_exports for consistency with import alias
- Move BudgetEnforcer reconstruction out of if/else branch in
  step_create_budget_enforcer_with_max_total_size so it always creates
  a fresh instance, eliminating cross-scenario state leakage

The root cause was that the second Background step unconditionally
overwrote the enforcer only when hasattr existed — but the enforcer
from the previous scenario carried over stale constraints. Now both
Background steps run in a well-defined sequence: step_one sets
max_file_size, step_two reconstructs with that preserved value and
new max_total_size, before every scenario.

ISSUES CLOSED: #9583
2026-05-18 07:59:38 +00:00
HAL9000 853cfeaaff fix(acms): restore index exports in __init__.py to fix integration_tests
The PR branch incorrectly removed ACMSIndex, FileTraversalEngine, FileType,
IndexEntry, and TierLevel from the public API of cleveragents.acms.__init__,
which broke integration tests that depend on these exports.

This restores the index module imports and combines them with budget_enforcement
and uko exports in __all__. This is a non-breaking restoration of existing
public API symbols.

ISSUES CLOSED: #9583
2026-05-18 07:59:38 +00:00
HAL9000 8309c906d9 feat(acms): implement budget enforcement for max_file_size and max_total_size constraints
Add ACMS BudgetEnforcer dataclass with per-file (max_file_size) and
aggregate (max_total_size) constraint enforcement. Includes:

- BudgetEnforcer: core enforcer with add_file(), get_assembled_context(),
  get_violations(), reset() methods and defensive-copy returns
- BudgetViolation: structured violation reporting with filename, file_size,
  limit, and clear actionable messages (error for max_file_size, warning
  for max_total_size)
- ContextFile: size tracking with automatic byte-size calculation from UTF-8

Also updates src/cleveragents/acms/__init__.py to export budget enforcement
classes alongside existing UKO vocabulary exports.

Comprehensive BDD test coverage: 11 Behave scenarios covering inclusion,
exclusion, boundary conditions, cumulative budget cutoff, ordering,
metadata reporting, empty files, and multi-byte UTF-8 measurement.
Robot Framework integration tests with helper module.

ISSUES CLOSED: #9583

Signed-off-by: HAL9000 <hal9000@cleverthis.com>

# Conflicts:
#	CHANGELOG.md
#	CONTRIBUTORS.md
2026-05-18 07:59:38 +00:00