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

Merged
aditya merged 1 commit 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
freemo approved these changes 2026-03-24 15:26:57 +00:00
freemo left a comment

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
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3m18s
CI / typecheck (pull_request) Successful in 3m47s
CI / quality (pull_request) Successful in 4m2s
CI / security (pull_request) Successful in 4m2s
CI / unit_tests (pull_request) Successful in 6m39s
CI / docker (pull_request) Successful in 1m2s
CI / benchmark-regression (pull_request) Successful in 52m26s
CI / integration_tests (pull_request) Successful in 6m47s
CI / e2e_tests (pull_request) Successful in 8m22s
CI / coverage (pull_request) Successful in 11m18s
CI / status-check (pull_request) Successful in 1s
to cf53e785f2
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Failing after 25s
CI / lint (pull_request) Successful in 3m35s
CI / typecheck (pull_request) Successful in 3m56s
CI / quality (pull_request) Successful in 3m41s
CI / security (pull_request) Successful in 4m2s
CI / e2e_tests (pull_request) Failing after 4m55s
CI / unit_tests (pull_request) Successful in 7m12s
CI / integration_tests (pull_request) Successful in 7m0s
CI / docker (pull_request) Successful in 1m6s
CI / coverage (pull_request) Successful in 10m56s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Has been cancelled
2026-03-25 10:45:57 +00:00
Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from cf53e785f2
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Failing after 25s
CI / lint (pull_request) Successful in 3m35s
CI / typecheck (pull_request) Successful in 3m56s
CI / quality (pull_request) Successful in 3m41s
CI / security (pull_request) Successful in 4m2s
CI / e2e_tests (pull_request) Failing after 4m55s
CI / unit_tests (pull_request) Successful in 7m12s
CI / integration_tests (pull_request) Successful in 7m0s
CI / docker (pull_request) Successful in 1m6s
CI / coverage (pull_request) Successful in 10m56s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Has been cancelled
to e858e20ea9
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 3m20s
CI / typecheck (pull_request) Successful in 4m25s
CI / unit_tests (pull_request) Successful in 5m55s
CI / e2e_tests (pull_request) Failing after 12m15s
CI / integration_tests (pull_request) Failing after 12m15s
CI / quality (pull_request) Failing after 12m23s
CI / security (pull_request) Failing after 12m23s
CI / coverage (pull_request) Successful in 11m21s
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 1s
CI / benchmark-regression (pull_request) Has been cancelled
2026-03-25 11:28:17 +00:00
Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from e858e20ea9
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 3m20s
CI / typecheck (pull_request) Successful in 4m25s
CI / unit_tests (pull_request) Successful in 5m55s
CI / e2e_tests (pull_request) Failing after 12m15s
CI / integration_tests (pull_request) Failing after 12m15s
CI / quality (pull_request) Failing after 12m23s
CI / security (pull_request) Failing after 12m23s
CI / coverage (pull_request) Successful in 11m21s
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 1s
CI / benchmark-regression (pull_request) Has been cancelled
to bc7822b166
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3m21s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 3m47s
CI / security (pull_request) Successful in 3m58s
CI / unit_tests (pull_request) Successful in 6m25s
CI / docker (pull_request) Successful in 1m15s
CI / status-check (pull_request) Has been cancelled
CI / benchmark-regression (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
CI / integration_tests (pull_request) Successful in 6m58s
CI / e2e_tests (pull_request) Has been cancelled
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
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3m21s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 3m47s
CI / security (pull_request) Successful in 3m58s
CI / unit_tests (pull_request) Successful in 6m25s
CI / docker (pull_request) Successful in 1m15s
CI / status-check (pull_request) Has been cancelled
CI / benchmark-regression (pull_request) Has been cancelled
CI / coverage (pull_request) Has been cancelled
CI / integration_tests (pull_request) Successful in 6m58s
CI / e2e_tests (pull_request) Has been cancelled
to 35b5ef99fb
Some checks are pending
CI / status-check (pull_request) Blocked by required conditions
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / integration_tests (pull_request) Successful in 2m57s
CI / lint (pull_request) Successful in 3m18s
CI / typecheck (pull_request) Successful in 3m59s
CI / coverage (pull_request) Has started running
CI / benchmark-regression (pull_request) Has started running
CI / security (pull_request) Successful in 4m9s
CI / quality (pull_request) Successful in 4m10s
CI / e2e_tests (pull_request) Successful in 5m45s
CI / unit_tests (pull_request) Successful in 7m7s
CI / docker (pull_request) Successful in 50s
2026-03-25 13:12:23 +00:00
Compare
aditya force-pushed fix/acms-budget-allocation-spec-alignment from 35b5ef99fb
Some checks are pending
CI / status-check (pull_request) Blocked by required conditions
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / integration_tests (pull_request) Successful in 2m57s
CI / lint (pull_request) Successful in 3m18s
CI / typecheck (pull_request) Successful in 3m59s
CI / coverage (pull_request) Has started running
CI / benchmark-regression (pull_request) Has started running
CI / security (pull_request) Successful in 4m9s
CI / quality (pull_request) Successful in 4m10s
CI / e2e_tests (pull_request) Successful in 5m45s
CI / unit_tests (pull_request) Successful in 7m7s
CI / docker (pull_request) Successful in 50s
to 42a32c2709
Some checks failed
CI / build (pull_request) Successful in 18s
CI / lint (pull_request) Successful in 3m19s
CI / quality (pull_request) Successful in 3m42s
CI / security (pull_request) Successful in 4m6s
CI / typecheck (pull_request) Successful in 4m11s
CI / integration_tests (pull_request) Successful in 5m56s
CI / unit_tests (pull_request) Successful in 7m20s
CI / docker (pull_request) Successful in 50s
CI / e2e_tests (pull_request) Successful in 10m0s
CI / coverage (pull_request) Successful in 11m13s
CI / status-check (pull_request) Successful in 4s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been cancelled
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 milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!1140
No description provided.