feat(context): implement budget enforcement for context assembly (max_file_size, max_total_size) #5221

Open
opened 2026-04-09 03:36:15 +00:00 by HAL9000 · 1 comment
Owner

Background

Part of Epic #5166 (Context Assembly Pipeline). Implements budget enforcement in the context assembly pipeline, ensuring that assembled context views respect max_file_size and max_total_size constraints from the context policy.

Expected Behavior

  • ContextBudget model holds max_file_size, max_total_size, max_files constraints
  • Files exceeding max_file_size are truncated with a truncation marker
  • Assembly stops when max_total_size is reached
  • Budget enforcement is applied during ContextAssembler.assemble()

Subtasks

  • Define ContextBudget model with constraint fields
  • Implement file truncation when max_file_size exceeded
  • Implement total size enforcement (stop adding files at max_total_size)
  • Add budget reporting to ContextView (bytes_used, files_included, files_excluded)
  • Write Behave unit tests for budget enforcement

Definition of Done

  • Budget constraints enforced during assembly
  • File truncation works with truncation marker
  • Total size limit stops assembly correctly
  • Budget report included in ContextView
  • All nox stages pass
  • Coverage >= 97%

Metadata

  • Branch: feat/v3.4.0/acms-budget-enforcement
  • Commit Message: feat(context): implement budget enforcement for context assembly
  • Milestone: v3.4.0
  • Parent Epic: #5166
  • Depends on: #5220 (ContextAssembler must exist first)

Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planner

## Background Part of Epic #5166 (Context Assembly Pipeline). Implements budget enforcement in the context assembly pipeline, ensuring that assembled context views respect `max_file_size` and `max_total_size` constraints from the context policy. ## Expected Behavior - `ContextBudget` model holds `max_file_size`, `max_total_size`, `max_files` constraints - Files exceeding `max_file_size` are truncated with a truncation marker - Assembly stops when `max_total_size` is reached - Budget enforcement is applied during `ContextAssembler.assemble()` ## Subtasks - [ ] Define `ContextBudget` model with constraint fields - [ ] Implement file truncation when `max_file_size` exceeded - [ ] Implement total size enforcement (stop adding files at `max_total_size`) - [ ] Add budget reporting to `ContextView` (bytes_used, files_included, files_excluded) - [ ] Write Behave unit tests for budget enforcement ## Definition of Done - [ ] Budget constraints enforced during assembly - [ ] File truncation works with truncation marker - [ ] Total size limit stops assembly correctly - [ ] Budget report included in `ContextView` - [ ] All nox stages pass - [ ] Coverage >= 97% ## Metadata - **Branch**: `feat/v3.4.0/acms-budget-enforcement` - **Commit Message**: `feat(context): implement budget enforcement for context assembly` - **Milestone**: v3.4.0 - **Parent Epic**: #5166 - **Depends on**: #5220 (ContextAssembler must exist first) --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planner
HAL9000 added this to the v3.4.0 milestone 2026-04-09 03:36:53 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — ACMS context assembly and budget enforcement are required for v3.4.0 milestone
  • Story Points: 5 (L) — substantial implementation work
  • MoSCoW: Must Have — context assembly is the core of ACMS functionality
  • Parent Epic: EPIC #5166 (Context Assembly Pipeline) or #5167 (Context Budget Enforcement)
  • Assignee: HAL9000 — default assignment to maintain velocity

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: High — ACMS context assembly and budget enforcement are required for v3.4.0 milestone - **Story Points**: 5 (L) — substantial implementation work - **MoSCoW**: Must Have — context assembly is the core of ACMS functionality - **Parent Epic**: EPIC #5166 (Context Assembly Pipeline) or #5167 (Context Budget Enforcement) - **Assignee**: HAL9000 — default assignment to maintain velocity --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 self-assigned this 2026-04-09 03:42:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#5221
No description provided.