# Recent Optimizer candidate retention

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "recent-optimizer-candidate-retention-2026-07-21",
  "problems": [
    {
      "problemId": "recent-optimizer-discards-needs-work-candidate",
      "summary": "A material Recent Optimizer candidate has no Draft PR when policy, tests, challenger execution, or the candidate gate does not pass, so later work loses its stable continuation point.",
      "status": "optimized_unverified",
      "issueKeys": [],
      "sourceRefs": [],
      "signalTextIncludesAny": [],
      "observedThrough": "2026-07-21",
      "effectiveAt": "2026-07-21T12:15:20+08:00",
      "verifiedAt": null,
      "attemptedAction": "Persist every material candidate branch as a Draft PR with its needs-work signal and keep automatic merge and deployment disabled.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/issues/375"
    },
    {
      "problemId": "recent-optimizer-minority-inconclusive-blocks-candidate",
      "summary": "A minority of environment-inconclusive target cases rejects an otherwise evidenced candidate even when another blocking target improves and no evaluable blocking target has a gap.",
      "status": "optimized_unverified",
      "issueKeys": ["APID-29174"],
      "sourceRefs": [],
      "signalTextIncludesAny": ["evaluation_inconclusive", "少部分 case 无法判定", "manus read-only credentials"],
      "observedThrough": "2026-07-21",
      "effectiveAt": "2026-07-21T12:15:20+08:00",
      "verifiedAt": null,
      "attemptedAction": "Allow a strict minority of inconclusive target cases when another blocking target has a confirmed improvement and no evaluable blocking target has a gap.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/issues/375#issuecomment-5029582536"
    }
  ]
}
-->

- Optimization ID: `recent-optimizer-candidate-retention-2026-07-21`
- Owner: auto-oncall-services
- Source type: Recent Focus workflow correction
- Source reference: Focus #375 candidate-policy failure and later inconclusive
  evaluation

## Bounded problems

1. A generated candidate can be pushed without receiving a stable Draft PR when
   a later policy, test, challenger, or gate stage fails.
2. One unavailable target can mark the whole challenger inconclusive even when
   other blocking targets prove improvement and no evaluable target has a gap.

## Implementation and effective status

- Retain every material generated candidate as a Draft PR, including rejected
  and inconclusive candidates, with a bounded failure signal in the PR body.
- Accept a strict minority of inconclusive target cases only when another
  blocking target has a confirmed improvement and there is no confirmed
  blocking failure.
- Keep Draft PRs manual: this change does not merge or deploy candidates.
- Status: deployed to staging in image `4ea9e9876adbaf85ae3bdd5dacd46a90d8bb3a68`;
  both problems are `optimized_unverified` until a real Focus cycle exercises the
  new gate and candidate-retention paths.

## Post-change evidence

- Implementation PR: https://github.com/tidbcloud/aisupport/pull/401
- App-delivery PR: https://github.com/tidbcloud/app-delivery/pull/75045
- Effective timestamp: `2026-07-21T12:15:20+08:00`
- Live Deployment and Recent Optimizer CronJob both rendered image `4ea9e987`.
- In-pod contract inspection found candidate gate v3 and the needs-work Draft PR
  boundary; `/healthz` returned HTTP 200.

## Validation plan

- Cover accepted minority-inconclusive, excessive-inconclusive, and confirmed
  blocking-gap decisions.
- Cover accepted and needs-work Draft PR bodies and their explicit no-auto-merge
  boundary.
- Verify the deployed controller contains candidate gate v3 and the retention
  contract.

## Unresolved gaps and next action

- A later real Focus cycle must verify the strict-minority acceptance path and
  the needs-work Draft PR path before either problem becomes
  `optimized_verified`.
