fix(acms): align budget allocation formula and protocol signatures with spec #1140

Merged
aditya merged 1 commits from fix/acms-budget-allocation-spec-alignment into master 2026-03-26 06:34:45 +00:00
Member

Summary

Aligns the ACMS pipeline protocol signatures and budget allocation formula with docs/specification.md §42630-42937, addressing four spec/implementation mismatches:

  1. BudgetAllocator.allocate() signature — Added optional request: ContextRequest parameter per BudgetAllocatorProtocol spec (§44754-44766), enabling future request-aware allocation (e.g., different allocation for strategize vs execute views).

  2. Allocation formula — Changed from proportional to confidence alone to proportional to confidence * quality_score per spec §45003. Both DefaultBudgetAllocator and ProportionalBudgetAllocator use the new weighted formula. With default quality_score=1.0, behavior is backward-compatible.

  3. DetailDepthResolver.resolve() signature — Added budget: int parameter per DetailDepthResolverProtocol spec (§44803-44814), enabling future budget-aware depth resolution.

  4. Default packer — Changed from no-op DefaultBudgetPacker to production GreedyKnapsackPacker per spec §45013. ACMSPipeline uses lazy import to avoid circular dependency; ContextAssemblyPipeline imports directly.

Files Changed

Production code (5 files)

  • src/cleveragents/application/services/acms_service.py — Protocol updates, DefaultBudgetAllocator, DefaultDepthResolver, ACMSPipeline packer wiring, StrategyCapabilities.quality_score
  • src/cleveragents/application/services/acms_pipeline.pyProportionalBudgetAllocator, ContextAssemblyPipeline packer wiring and assemble threading
  • src/cleveragents/application/services/acms_phase2.pyMaxDepthResolver.resolve() budget parameter
  • src/cleveragents/application/services/fusion_engine.pyFusionEngine.fuse() resolve call updated
  • src/cleveragents/application/services/strategy_coordinator.pycoordinate() allocate call updated

Test code (5 files)

  • features/acms_pipeline.feature — Adjusted test data relevance scores for 4 scenarios affected by GreedyKnapsackPacker ordering
  • features/acms_pipeline_orchestrator.feature — Adjusted 1 scenario test data
  • features/steps/acms_pipeline_steps.py — Updated _HalvingAllocator mock signature, added ContextRequest import
  • features/steps/acms_service_coverage_boost_steps.py — Explicit quality_score on mock strategy
  • robot/helper_acms_pipeline.py — Adjusted tiered test data relevance scores

Quality Gates

Gate Result
nox -s lint PASS
nox -s typecheck 0 errors
nox -s unit_tests 12,230 scenarios, 0 failed
nox -s integration_tests 1,672 tests, 0 failed
nox -s coverage_report 98.38% >= 97%

Closes #924

## Summary Aligns the ACMS pipeline protocol signatures and budget allocation formula with `docs/specification.md` §42630-42937, addressing four spec/implementation mismatches: 1. **`BudgetAllocator.allocate()` signature** — Added optional `request: ContextRequest` parameter per `BudgetAllocatorProtocol` spec (§44754-44766), enabling future request-aware allocation (e.g., different allocation for strategize vs execute views). 2. **Allocation formula** — Changed from proportional to `confidence` alone to proportional to `confidence * quality_score` per spec §45003. Both `DefaultBudgetAllocator` and `ProportionalBudgetAllocator` use the new weighted formula. With default `quality_score=1.0`, behavior is backward-compatible. 3. **`DetailDepthResolver.resolve()` signature** — Added `budget: int` parameter per `DetailDepthResolverProtocol` spec (§44803-44814), enabling future budget-aware depth resolution. 4. **Default packer** — Changed from no-op `DefaultBudgetPacker` to production `GreedyKnapsackPacker` per spec §45013. `ACMSPipeline` uses lazy import to avoid circular dependency; `ContextAssemblyPipeline` imports directly. ## Files Changed ### Production code (5 files) - `src/cleveragents/application/services/acms_service.py` — Protocol updates, `DefaultBudgetAllocator`, `DefaultDepthResolver`, `ACMSPipeline` packer wiring, `StrategyCapabilities.quality_score` - `src/cleveragents/application/services/acms_pipeline.py` — `ProportionalBudgetAllocator`, `ContextAssemblyPipeline` packer wiring and assemble threading - `src/cleveragents/application/services/acms_phase2.py` — `MaxDepthResolver.resolve()` budget parameter - `src/cleveragents/application/services/fusion_engine.py` — `FusionEngine.fuse()` resolve call updated - `src/cleveragents/application/services/strategy_coordinator.py` — `coordinate()` allocate call updated ### Test code (5 files) - `features/acms_pipeline.feature` — Adjusted test data relevance scores for 4 scenarios affected by GreedyKnapsackPacker ordering - `features/acms_pipeline_orchestrator.feature` — Adjusted 1 scenario test data - `features/steps/acms_pipeline_steps.py` — Updated `_HalvingAllocator` mock signature, added `ContextRequest` import - `features/steps/acms_service_coverage_boost_steps.py` — Explicit `quality_score` on mock strategy - `robot/helper_acms_pipeline.py` — Adjusted tiered test data relevance scores ## Quality Gates | Gate | Result | |------|--------| | `nox -s lint` | PASS | | `nox -s typecheck` | 0 errors | | `nox -s unit_tests` | 12,230 scenarios, 0 failed | | `nox -s integration_tests` | 1,672 tests, 0 failed | | `nox -s coverage_report` | 98.38% >= 97% | Closes #924
aditya added this to the v3.4.0 milestone 2026-03-23 21:31:14 +00:00
aditya added the
Type
Task
label 2026-03-23 21:31:14 +00:00
freemo approved these changes 2026-03-24 15:26:57 +00:00
freemo left a comment
Owner

Review: APPROVED

Clean spec-alignment change. Budget allocation now uses confidence * quality_score per spec §42689/§42918. Both allocators updated consistently with a shared _weighted_score() static method. Protocol signatures updated with backward-compatible defaults. BDD feature files and Robot helpers updated to reflect new weighted ordering. No type: ignore additions. No concerns.

## Review: APPROVED Clean spec-alignment change. Budget allocation now uses `confidence * quality_score` per spec §42689/§42918. Both allocators updated consistently with a shared `_weighted_score()` static method. Protocol signatures updated with backward-compatible defaults. BDD feature files and Robot helpers updated to reflect new weighted ordering. No `type: ignore` additions. No concerns.
aditya force-pushed fix/acms-budget-allocation-spec-alignment from bd081c8ac8 to cf53e785f2 2026-03-25 10:45:57 +00:00 Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from cf53e785f2 to e858e20ea9 2026-03-25 11:28:17 +00:00 Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from e858e20ea9 to bc7822b166 2026-03-25 12:40:59 +00:00 Compare
aditya scheduled this pull request to auto merge when all checks succeed 2026-03-25 12:48:56 +00:00
aditya force-pushed fix/acms-budget-allocation-spec-alignment from bc7822b166 to 35b5ef99fb 2026-03-25 13:12:23 +00:00 Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from 35b5ef99fb to 42a32c2709 2026-03-26 06:19:15 +00:00 Compare
aditya merged commit 02d19c9672 into master 2026-03-26 06:34:45 +00:00
aditya deleted branch fix/acms-budget-allocation-spec-alignment 2026-03-26 06:34:45 +00:00
Sign in to join this conversation.
No Reviewers
No Label
Type
Task
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#1140