feat(acms): add strategy coordinator and fusion engine #192

Closed
opened 2026-02-22 23:40:00 +00:00 by freemo · 2 comments
Owner

Metadata

  • Commit Message: feat(acms): add strategy coordinator and fusion engine
  • Branch: feature/m6-acms-fusion-engine

Background

The StrategyCoordinator executes strategies in parallel with proportional budget allocation by strategy confidence. The FusionEngine deduplicates fragments, resolves detail conflicts, and packs results within budget. Per-strategy max caps are enforced.

Acceptance Criteria

  • Implement StrategyCoordinator with parallel execution and budget allocation.
  • Implement FusionEngine to dedupe fragments, resolve detail conflicts, and pack within budget.
  • Allocate budget proportionally by strategy confidence and enforce per-strategy max caps.
  • Add greedy knapsack packing with deterministic tie-breakers (relevance, detail level, token count).
  • Add fragment dedupe by UKO URI + hash of rendered text to avoid duplicates across strategies.

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches
    the Commit Message in Metadata exactly, followed by a blank line, then
    additional lines providing relevant details about the implementation. The
    commit body should be appropriate in size for a commit message and relatively
    complete in describing what was done.
  • The commit is pushed to the remote on the branch matching the Branch in
    Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and
    merged before this issue is marked done.

Subtasks

  • Implement StrategyCoordinator with parallel execution and budget allocation.
  • Implement FusionEngine to dedupe fragments, resolve detail conflicts, and pack within budget.
  • Allocate budget proportionally by strategy confidence and enforce per-strategy max caps.
  • Add greedy knapsack packing with deterministic tie-breakers (relevance, detail level, token count).
  • Add fragment dedupe by UKO URI + hash of rendered text to avoid duplicates across strategies.
  • Add budget overage guard to drop lowest-relevance fragments and emit warnings.
  • Add docs/reference/acms_fusion.md with flow diagrams and budget semantics.
  • Document StrategyCoordinator execution order and error handling.
  • Tests (Behave): Add features/acms_fusion.feature for dedupe and budget enforcement.
  • Tests (Robot): Add robot/acms_fusion.robot integration smoke tests.
  • Tests (ASV): Add benchmarks/acms_fusion_bench.py for fusion runtime.
  • Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun nox -s coverage_report to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Section: #### M5: ACMS v1 + Context Scaling (Day 26)
Status: Open

## Metadata - **Commit Message**: `feat(acms): add strategy coordinator and fusion engine` - **Branch**: `feature/m6-acms-fusion-engine` ## Background The StrategyCoordinator executes strategies in parallel with proportional budget allocation by strategy confidence. The FusionEngine deduplicates fragments, resolves detail conflicts, and packs results within budget. Per-strategy max caps are enforced. ## Acceptance Criteria - [ ] Implement StrategyCoordinator with parallel execution and budget allocation. - [ ] Implement FusionEngine to dedupe fragments, resolve detail conflicts, and pack within budget. - [ ] Allocate budget proportionally by strategy confidence and enforce per-strategy max caps. - [ ] Add greedy knapsack packing with deterministic tie-breakers (relevance, detail level, token count). - [ ] Add fragment dedupe by UKO URI + hash of rendered text to avoid duplicates across strategies. ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. The commit body should be appropriate in size for a commit message and relatively complete in describing what was done. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [ ] Implement StrategyCoordinator with parallel execution and budget allocation. - [ ] Implement FusionEngine to dedupe fragments, resolve detail conflicts, and pack within budget. - [ ] Allocate budget proportionally by strategy confidence and enforce per-strategy max caps. - [ ] Add greedy knapsack packing with deterministic tie-breakers (relevance, detail level, token count). - [ ] Add fragment dedupe by UKO URI + hash of rendered text to avoid duplicates across strategies. - [ ] Add budget overage guard to drop lowest-relevance fragments and emit warnings. - [ ] Add `docs/reference/acms_fusion.md` with flow diagrams and budget semantics. - [ ] Document StrategyCoordinator execution order and error handling. - [ ] Tests (Behave): Add `features/acms_fusion.feature` for dedupe and budget enforcement. - [ ] Tests (Robot): Add `robot/acms_fusion.robot` integration smoke tests. - [ ] Tests (ASV): Add `benchmarks/acms_fusion_bench.py` for fusion runtime. - [ ] Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. **Section**: #### M5: ACMS v1 + Context Scaling (Day 26) **Status**: Open
freemo added this to the v3.4.0 milestone 2026-02-22 23:40:00 +00:00
freemo self-assigned this 2026-02-22 23:40:00 +00:00
Author
Owner

Expected completion updated (Day 15 rebaseline): Day 35 / 2026-03-15 (previously Day 31 / 2026-03-11)

**Expected completion updated (Day 15 rebaseline):** Day 35 / 2026-03-15 (previously Day 31 / 2026-03-11)
freemo added the due date 2026-03-08 2026-02-23 18:41:39 +00:00
Author
Owner

Implementation Complete

PR #671 implements the StrategyCoordinator and FusionEngine facades.

Commit: 0a8c85ceb415729e32e21281216ad56298eb2a47

What was built

StrategyCoordinator (src/cleveragents/application/services/strategy_coordinator.py)

  • Facade over ConfidenceWeightedSelector, ProportionalBudgetAllocator, ParallelStrategyExecutor
  • Public API: coordinate(request, strategies, budget, fragments, backends, plan_context)
  • Per-strategy max caps enforcement with excess redistribution
  • Circuit breaker error handling and graceful degradation

FusionEngine (src/cleveragents/application/services/fusion_engine.py)

  • Facade over ContentHashDeduplicator, MaxDepthResolver, WeightedCompositeScorer, GreedyKnapsackPacker
  • Public API: fuse(fragments, budget)
  • Fragment dedup by UKO URI + SHA-256 content hash
  • Detail conflict resolution (max depth wins)
  • Deterministic tie-breakers: relevance desc, depth desc, token_count asc
  • Budget overage guard drops lowest-relevance fragments

Test Results

  • Behave BDD: 15 scenarios, all passing (9743 total suite: 0 failures)
  • Robot integration: 9 tests, all passing
  • Coverage: 98.5% (threshold: 97%)
  • Pyright: 0 errors, 0 warnings
  • Ruff: All checks passed

Files Created/Modified

  • src/.../strategy_coordinator.py (new)
  • src/.../fusion_engine.py (new)
  • src/.../services/__init__.py (modified - exports)
  • features/acms_fusion.feature (new - 15 BDD scenarios)
  • features/steps/acms_fusion_steps.py (new)
  • robot/acms_fusion.robot (new - 9 integration tests)
  • robot/helper_acms_fusion.py (new)
  • benchmarks/acms_fusion_bench.py (new)
  • docs/reference/acms_fusion.md (new)
  • vulture_whitelist.py (modified)
## Implementation Complete PR #671 implements the StrategyCoordinator and FusionEngine facades. ### Commit: `0a8c85ceb415729e32e21281216ad56298eb2a47` ### What was built **StrategyCoordinator** (`src/cleveragents/application/services/strategy_coordinator.py`) - Facade over ConfidenceWeightedSelector, ProportionalBudgetAllocator, ParallelStrategyExecutor - Public API: `coordinate(request, strategies, budget, fragments, backends, plan_context)` - Per-strategy max caps enforcement with excess redistribution - Circuit breaker error handling and graceful degradation **FusionEngine** (`src/cleveragents/application/services/fusion_engine.py`) - Facade over ContentHashDeduplicator, MaxDepthResolver, WeightedCompositeScorer, GreedyKnapsackPacker - Public API: `fuse(fragments, budget)` - Fragment dedup by UKO URI + SHA-256 content hash - Detail conflict resolution (max depth wins) - Deterministic tie-breakers: relevance desc, depth desc, token_count asc - Budget overage guard drops lowest-relevance fragments ### Test Results - **Behave BDD**: 15 scenarios, all passing (9743 total suite: 0 failures) - **Robot integration**: 9 tests, all passing - **Coverage**: 98.5% (threshold: 97%) - **Pyright**: 0 errors, 0 warnings - **Ruff**: All checks passed ### Files Created/Modified - `src/.../strategy_coordinator.py` (new) - `src/.../fusion_engine.py` (new) - `src/.../services/__init__.py` (modified - exports) - `features/acms_fusion.feature` (new - 15 BDD scenarios) - `features/steps/acms_fusion_steps.py` (new) - `robot/acms_fusion.robot` (new - 9 integration tests) - `robot/helper_acms_fusion.py` (new) - `benchmarks/acms_fusion_bench.py` (new) - `docs/reference/acms_fusion.md` (new) - `vulture_whitelist.py` (modified)
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".

2026-03-08

Blocks
#396 Epic: ACMS Context Pipeline
cleveragents/cleveragents-core
Depends on
Reference
cleveragents/cleveragents-core#192
No description provided.