@acms @coverage_boost
Feature: ACMS service coverage boost — uncovered lines
  As a developer maintaining the ACMS pipeline
  I want to exercise uncovered code paths in acms_service.py
  So that the test suite achieves higher coverage

  # -----------------------------------------------------------------------
  # Line 413: DefaultBudgetAllocator.allocate returns [] for empty candidates
  # -----------------------------------------------------------------------

  Scenario: Budget allocator returns empty list for empty candidates
    Given the default budget allocator
    When I allocate budget 1000 to an empty candidate list
    Then the allocation result should be an empty list

  # -----------------------------------------------------------------------
  # Line 436: DefaultBudgetAllocator proportional allocation with remainder
  # -----------------------------------------------------------------------

  Scenario: Budget allocator distributes fractional remainder tokens
    Given the default budget allocator
    When I allocate budget 100 across two candidates with confidences 0.5 and 0.3
    Then the total allocated tokens should equal exactly 100
    And each candidate should receive a positive allocation

  Scenario: Budget allocator remainder distribution with three uneven confidences
    Given the default budget allocator
    When I allocate budget 97 across three candidates with confidences 0.6 0.3 0.1
    Then the total allocated tokens should equal exactly 97

  # -----------------------------------------------------------------------
  # Line 463: DefaultStrategyExecutor.execute returns [] for empty allocations
  # -----------------------------------------------------------------------

  Scenario: Strategy executor returns empty list for empty allocations
    Given the default strategy executor
    When I execute with an empty allocations list
    Then the executor result should be an empty list

  # -----------------------------------------------------------------------
  # Line 467: DefaultStrategyExecutor.execute skips zero-token allocations
  # -----------------------------------------------------------------------

  Scenario: Strategy executor skips allocations with zero tokens
    Given the default strategy executor
    And a test strategy and fragments for execution
    When I execute with a zero-token allocation for the test strategy
    Then the executor result should be an empty list

  Scenario: Strategy executor processes positive tokens but skips zero tokens
    Given the default strategy executor
    And a test strategy and fragments for execution
    When I execute with mixed allocations including zero and positive tokens
    Then the executor result should contain only fragments from the positive allocation

  # -----------------------------------------------------------------------
  # Lines 616-620: ACMSPipeline.__init__ rejects unknown default_strategy
  # -----------------------------------------------------------------------

  Scenario: Pipeline constructor rejects unknown default strategy name
    When I create a pipeline with default strategy "nonexistent_strategy"
    Then the pipeline creation should fail with a ValueError about "Unknown strategy"
    And the pipeline error message should list available strategies

  Scenario: Pipeline constructor rejects empty string as default strategy
    When I create a pipeline with an empty default strategy
    Then the pipeline creation should fail with a ValueError about "Unknown strategy"

  # -----------------------------------------------------------------------
  # Zero-confidence equal-split remainder in DefaultBudgetAllocator
  # Lines 418-423: zero confidence path with remainder distribution
  # -----------------------------------------------------------------------

  Scenario: Budget allocator zero-confidence split with non-divisible budget
    Given the default budget allocator
    When I allocate budget 10 across three zero-confidence candidates
    Then the total allocated tokens should equal exactly 10
    And allocations should be 4 or 3 tokens each

  # -----------------------------------------------------------------------
  # Full pipeline with budget that forces remainder in allocator
  # (Exercises line 436 via pipeline.assemble end-to-end)
  # -----------------------------------------------------------------------

  Scenario: Full pipeline assembly exercises proportional remainder allocation
    Given a pipeline with a custom selector that returns multiple candidates
    And a context budget with 100 max tokens
    And simple test fragments totalling 80 tokens
    When I assemble the fragments through the full pipeline
    Then the assembly should succeed without error
