UAT: ContextView.max_file_size and max_total_size default to None — spec requires 1 MB and 50 MB defaults, so budget enforcement is inactive by default #6028

Open
opened 2026-04-09 13:49:36 +00:00 by HAL9000 · 2 comments
Owner

Summary

ContextView.max_file_size and ContextView.max_total_size both default to None (no limit) in the domain model. The specification requires these to default to 1 MB (1,048,576 bytes) and 50 MB (52,428,800 bytes) respectively. Because the defaults are None, the enforce_size_budget fast-path accepts all fragments without any size filtering unless the user explicitly sets limits — violating v3.4.0 acceptance criteria #2.

Expected Behavior (per spec)

From docs/specification.md §35369–35379 (ACMS config JSON schema):

"max_file_size": {
  "type": "integer",
  "default": 1048576,
  "minimum": 1,
  "description": "Maximum individual file size in bytes that will be included in context. Default: 1 MB."
},
"max_total_size": {
  "type": "integer",
  "default": 52428800,
  "minimum": 1,
  "description": "Maximum aggregate size in bytes across all included files. Default: 50 MB."
}

Also from §35513–35514:

| max_file_size | integer | No | Maximum individual file size in bytes that will be included in context. Files exceeding this are either excluded or summarized. Default: 1 MB (1,048,576). |
| max_total_size | integer | No | Maximum aggregate size in bytes across all included files. Default: 50 MB (52,428,800). |

And from v3.4.0 acceptance criteria (§46847):

| 2 | Budget enforcement: max_file_size and max_total_size constraints respected | §Context Budget Enforcement | Files exceeding max_file_size excluded; total context ≤ max_total_size |

Actual Behavior

# src/cleveragents/domain/models/core/context_policy.py
class ContextView(BaseModel):
    max_file_size: int | None = Field(
        default=None,  # ← Should be 1048576
        description="Max file size in bytes to include in context (None = no limit)",
    )
    max_total_size: int | None = Field(
        default=None,  # ← Should be 52428800
        description="Max total context size in bytes (None = no limit)",
    )

With None defaults, enforce_size_budget takes the fast path and accepts all fragments regardless of size:

# Fast path: when no limits are set, accept everything without
# incurring per-fragment encode() overhead.
if max_file is None and max_total is None:
    return BudgetEnforcementResult(
        accepted=tuple(f.fragment_id for f in fragments),
        violations=(),
        total_size=...,
    )

This means a 10 MB file would be included in context by default, when the spec says it should be excluded (exceeds 1 MB default).

Steps to Reproduce

from cleveragents.domain.models.core.context_policy import ContextView, enforce_size_budget

class MockFragment:
    def __init__(self, fid, content):
        self.fragment_id = fid
        self.content = content

view = ContextView()  # No explicit limits
print(f"max_file_size: {view.max_file_size}")   # None
print(f"max_total_size: {view.max_total_size}") # None

# 2MB fragment — should be rejected by spec's 1MB default
frags = [MockFragment('big', 'x' * 2_000_000)]
result = enforce_size_budget(frags, view)
print(f"Accepted: {len(result.accepted)}")   # 1 — WRONG, should be 0
print(f"Violations: {len(result.violations)}")  # 0 — WRONG, should be 1

Code Location

  • src/cleveragents/domain/models/core/context_policy.py lines 87–94

Fix

Change the defaults in ContextView:

max_file_size: int | None = Field(
    default=1048576,  # 1 MB per spec
    description="Max file size in bytes to include in context (None = no limit)",
)
max_total_size: int | None = Field(
    default=52428800,  # 50 MB per spec
    description="Max total context size in bytes (None = no limit)",
)

Note: The existing _validate_positive_size validator already handles None as a valid value (no limit), so the validator does not need to change. The enforce_size_budget fast path will still work correctly when both are explicitly set to None.

Also update the ContextView docstring and the enforce_size_budget docstring to reflect the defaults.

Impact

  • v3.4.0 acceptance criteria #2 is not met: budget enforcement is inactive by default
  • Large files (>1 MB) are included in context without user explicitly setting limits
  • The execute_phase_context_assembler.py correctly checks if view.max_file_size is not None before applying limits, so with None defaults, no size filtering happens in production plan execution

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Summary `ContextView.max_file_size` and `ContextView.max_total_size` both default to `None` (no limit) in the domain model. The specification requires these to default to **1 MB (1,048,576 bytes)** and **50 MB (52,428,800 bytes)** respectively. Because the defaults are `None`, the `enforce_size_budget` fast-path accepts all fragments without any size filtering unless the user explicitly sets limits — violating v3.4.0 acceptance criteria #2. ## Expected Behavior (per spec) From `docs/specification.md` §35369–35379 (ACMS config JSON schema): ```json "max_file_size": { "type": "integer", "default": 1048576, "minimum": 1, "description": "Maximum individual file size in bytes that will be included in context. Default: 1 MB." }, "max_total_size": { "type": "integer", "default": 52428800, "minimum": 1, "description": "Maximum aggregate size in bytes across all included files. Default: 50 MB." } ``` Also from §35513–35514: > | `max_file_size` | integer | No | Maximum individual file size in bytes that will be included in context. Files exceeding this are either excluded or summarized. **Default: 1 MB (1,048,576).** | > | `max_total_size` | integer | No | Maximum aggregate size in bytes across all included files. **Default: 50 MB (52,428,800).** | And from v3.4.0 acceptance criteria (§46847): > | 2 | Budget enforcement: `max_file_size` and `max_total_size` constraints respected | §Context Budget Enforcement | Files exceeding `max_file_size` excluded; total context ≤ `max_total_size` | ## Actual Behavior ```python # src/cleveragents/domain/models/core/context_policy.py class ContextView(BaseModel): max_file_size: int | None = Field( default=None, # ← Should be 1048576 description="Max file size in bytes to include in context (None = no limit)", ) max_total_size: int | None = Field( default=None, # ← Should be 52428800 description="Max total context size in bytes (None = no limit)", ) ``` With `None` defaults, `enforce_size_budget` takes the fast path and accepts all fragments regardless of size: ```python # Fast path: when no limits are set, accept everything without # incurring per-fragment encode() overhead. if max_file is None and max_total is None: return BudgetEnforcementResult( accepted=tuple(f.fragment_id for f in fragments), violations=(), total_size=..., ) ``` This means a 10 MB file would be included in context by default, when the spec says it should be excluded (exceeds 1 MB default). ## Steps to Reproduce ```python from cleveragents.domain.models.core.context_policy import ContextView, enforce_size_budget class MockFragment: def __init__(self, fid, content): self.fragment_id = fid self.content = content view = ContextView() # No explicit limits print(f"max_file_size: {view.max_file_size}") # None print(f"max_total_size: {view.max_total_size}") # None # 2MB fragment — should be rejected by spec's 1MB default frags = [MockFragment('big', 'x' * 2_000_000)] result = enforce_size_budget(frags, view) print(f"Accepted: {len(result.accepted)}") # 1 — WRONG, should be 0 print(f"Violations: {len(result.violations)}") # 0 — WRONG, should be 1 ``` ## Code Location - `src/cleveragents/domain/models/core/context_policy.py` lines 87–94 ## Fix Change the defaults in `ContextView`: ```python max_file_size: int | None = Field( default=1048576, # 1 MB per spec description="Max file size in bytes to include in context (None = no limit)", ) max_total_size: int | None = Field( default=52428800, # 50 MB per spec description="Max total context size in bytes (None = no limit)", ) ``` Note: The existing `_validate_positive_size` validator already handles `None` as a valid value (no limit), so the validator does not need to change. The `enforce_size_budget` fast path will still work correctly when both are explicitly set to `None`. Also update the `ContextView` docstring and the `enforce_size_budget` docstring to reflect the defaults. ## Impact - v3.4.0 acceptance criteria #2 is not met: budget enforcement is inactive by default - Large files (>1 MB) are included in context without user explicitly setting limits - The `execute_phase_context_assembler.py` correctly checks `if view.max_file_size is not None` before applying limits, so with `None` defaults, no size filtering happens in production plan execution --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.4.0 milestone 2026-04-09 14:14:10 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Author
Owner

🏷️ Label compliance fix applied by backlog groomer (cycle 64)

Added missing labels: State/Verified, Type/Bug, Priority/Critical

This issue was missing all required state/type/priority labels. Labels have been applied based on issue content (UAT-identified spec deviation with active budget enforcement impact).


Automated by CleverAgents Bot
Supervisor: Label Management | Agent: forgejo-label-manager

🏷️ **Label compliance fix applied by backlog groomer (cycle 64)** Added missing labels: `State/Verified`, `Type/Bug`, `Priority/Critical` This issue was missing all required state/type/priority labels. Labels have been applied based on issue content (UAT-identified spec deviation with active budget enforcement impact). --- **Automated by CleverAgents Bot** Supervisor: Label Management | Agent: forgejo-label-manager
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#6028
No description provided.