# Provider Batch Handoff Capacity

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "provider-batch-handoff-capacity-2026-08-10",
  "problems": [
    {
      "problemId": "clinic-batch-results-exceed-child-handoff-gap-limit",
      "summary": "A valid Clinic batch can contain up to 12 queries, but the child handoff parser accepts only five gaps and five errors, so a batch with six non-complete queries is written successfully and then misreported as missing.",
      "status": "optimized_verified",
      "issueKeys": ["ST-2865"],
      "sourceRefs": [],
      "signalTextIncludesAny": [
        "diagnostic_evidence_batch_missing_after_agent",
        "Clinic evidence batch completed",
        "diagnostic child gaps"
      ],
      "observedThrough": "2026-08-10",
      "effectiveAt": "2026-08-10T16:13:55Z",
      "verifiedAt": "2026-08-10T16:28:13Z",
      "attemptedAction": "Align child handoff gaps and errors with the existing 12-query provider batch ceiling, without changing query selection, retry behavior, or provider execution.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/tree/main/auto-oncall-services/docs/opts/2026-08-10-provider-batch-handoff-capacity.md"
    }
  ]
}
-->

- Optimization ID: `provider-batch-handoff-capacity-2026-08-10`
- Owner: auto-oncall-services diagnostic runner
- Source reference: staging Clinic replay `ST-2865`, run
  `e24f3e90-5d35-4a79-ae67-c85bd13f0930`
- Implementation status: deployed to staging
- Effective status: `optimized_verified`

## Bounded problem

Clinic correctly executed and persisted a 12-query partial batch. Six queries
were empty or failed, so materialization created six gap facts. The shared
child-handoff contract still limited `gaps` and `errors` to five, rejected that
runner-owned handoff after writing it, and surfaced the misleading
`diagnostic_evidence_batch_missing_after_agent` failure.

## Implemented change

Set only the child-handoff `gaps` and `errors` ceilings to the existing
`maximumDiagnosticProviderBatchQueries` value. Keep counter-evidence limits,
query quota, round quota, Provider Executor behavior, and diagnostic semantics
unchanged.

## Verification

- A regression test materializes a maximum-size 12-query failed Clinic batch
  and proves all 12 gaps, errors, and query-coverage entries survive parsing.
- The complete Node test suite passes 721 tests.
- Staging image `d9c233d6a510d9e4e914905ab84b465f361c5e8d` became Ready at
  `2026-08-10T16:13:55Z` with one ready replica and zero Pod restarts.
- Post-change read replay `cad4ec49-fc18-40a6-a523-a5bc5eddaf5e`
  completed Clinic evidence acquisition with `providerCapabilityVerified=true`
  and no failure code.
- Write run `119f68c0-27b6-499a-83a6-892aff718534` again completed Clinic
  evidence acquisition, persisted DB run `120069`, and updated the existing
  Jira internal comment `23432370` in place.
- Jira readback confirmed comment `23432370` remained `public=false` and
  contained the refreshed analysis plus the internal feedback footer.

## Unresolved gaps

- No unresolved gap remains for this bounded handoff-capacity problem.
- The unrelated Lark Base duplicate `public_candidate` Stage Key prevented the
  write run's Feishu Dashboard projection; it did not affect evidence, DB, or
  Jira publication and is outside this optimization.

## Next validation action

Monitor later Clinic batches for a regression of
`diagnostic_evidence_batch_missing_after_agent` when more than five selected
queries are empty or failed.
