Files
temp/features/unified_context_models.feature
freemo fae438a7a7 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