Files
cleveragents-core/features/unified_context_models.feature
freemo fae438a7a7
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 17s
CI / security (pull_request) Successful in 33s
CI / typecheck (pull_request) Successful in 35s
CI / unit_tests (pull_request) Successful in 2m22s
CI / integration_tests (pull_request) Successful in 3m0s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 4m21s
CI / lint (push) Successful in 14s
CI / quality (push) Successful in 16s
CI / build (push) Successful in 16s
CI / security (push) Successful in 30s
CI / typecheck (push) Successful in 36s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 3m38s
CI / docker (push) Successful in 39s
CI / integration_tests (push) Successful in 4m25s
CI / coverage (push) Successful in 4m19s
CI / benchmark-publish (push) Successful in 15m57s
CI / benchmark-regression (pull_request) Successful in 28m50s
refactor(acms): unify ContextFragment model hierarchies by extending CRP base types
Core domain types (FragmentProvenance, ContextFragment, ContextBudget,
ContextPayload) now extend their CRP counterparts via Pydantic v2
inheritance, ensuring isinstance compatibility across the model
hierarchy.

Key changes:
- CRP base types made frozen=True (no consumer mutates them)
- CRP AssembledContext fields changed from list to tuple (frozen consistency)
- Core types extend CRP bases: FragmentProvenance(CRPFragmentProvenance),
  ContextFragment(CRPContextFragment), ContextBudget(CRPContextBudget),
  ContextPayload(CRPAssembledContext)
- Removed duplicate ContextFragment dataclass from skeleton_compressor
- Updated project_context.py to pass tuples to frozen AssembledContext
- Added Behave tests (10 scenarios), Robot integration tests (3 cases),
  and ASV benchmarks for the unified hierarchy
- Updated Known Limitations table in docs/reference/acms.md

ISSUES CLOSED: #569
2026-03-05 21:38:55 +00:00

68 lines
3.2 KiB
Gherkin

Feature: Unified context fragment model hierarchies
The core ContextFragment, FragmentProvenance, ContextBudget, and
ContextPayload types extend their CRP base counterparts, ensuring
isinstance compatibility across the model hierarchy.
Background:
Given the unified model modules are available
# ---------------------------------------------------------------
# isinstance compatibility
# ---------------------------------------------------------------
Scenario: Core FragmentProvenance is instance of CRP FragmentProvenance
Given a core FragmentProvenance with resource_uri "project://test"
Then the provenance should be an instance of CRP FragmentProvenance
And the provenance resource_type should be "unknown"
And the provenance strategy should be empty
Scenario: Core FragmentProvenance inherits CRP strategy field
Given a core FragmentProvenance for strategy "tier_retrieval" with resource_uri "project://test"
Then the provenance strategy should be "tier_retrieval"
And the provenance resource_type should be "unknown"
Scenario: Core ContextFragment is instance of CRP ContextFragment
Given a core ContextFragment with uko_node "project://app/main.py" and content "hello"
Then the fragment should be an instance of CRP ContextFragment
And the unified fragment tier should be "warm"
And the unified fragment fragment_id should be non-empty
Scenario: Core ContextFragment has ULID fragment_id by default
Given a core ContextFragment with uko_node "project://test" and content "test content"
Then the unified fragment fragment_id should be 26 characters
Scenario: Core ContextFragment created_at is auto-populated
Given a core ContextFragment with uko_node "project://test" and content "test content"
Then the unified fragment created_at should be a recent datetime
# ---------------------------------------------------------------
# Immutability (frozen)
# ---------------------------------------------------------------
Scenario: Core ContextFragment is frozen
Given a core ContextFragment with uko_node "project://frozen" and content "frozen"
When I attempt to mutate the fragment uko_node
Then a frozen mutation error should be raised
Scenario: Core ContextBudget is frozen
Given a core ContextBudget with max_tokens 4096 and reserved_tokens 512
When I attempt to mutate the budget max_tokens
Then a frozen mutation error should be raised
Scenario: CRP FragmentProvenance is frozen
Given a CRP FragmentProvenance with resource_uri "test://crp"
When I attempt to mutate the CRP provenance resource_uri
Then a frozen mutation error should be raised
# ---------------------------------------------------------------
# Equality across hierarchy
# ---------------------------------------------------------------
Scenario: Two core fragments with same data are equal
Given two core ContextFragments with identical fields
Then the two fragments should be equal
Scenario: Core ContextBudget strict validation rejects equal reserved and max
When I create a core ContextBudget with reserved_tokens equal to max_tokens
Then a validation error should be raised for strict budget