# Diagnostic Provider Execution State

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "diagnostic-provider-execution-state-2026-07-30",
  "problems": [
    {
      "problemId": "provider-bootstrap-timeout-masquerades-as-case-failure",
      "summary": "A provider bootstrap can consume its entire outer stage budget, lose its streamed failure state, and make a generated case response look equivalent to a provider-evidence failure.",
      "status": "optimized_verified",
      "issueKeys": ["APID-29259"],
      "sourceRefs": [
        "https://tidb.atlassian.net/browse/APID-29259#problem:diagnostic-provider-bootstrap-timeout"
      ],
      "signalTextIncludesAny": [
        "diagnostic_auth_bootstrap_failed",
        "the operation was aborted",
        "provider capability unverified",
        "response generation and evidence acquisition"
      ],
      "observedThrough": "2026-07-31",
      "effectiveAt": "2026-07-30T16:02:20.000Z",
      "verifiedAt": "2026-07-30T17:13:03.000Z",
      "attemptedAction": "Use one shared 20-minute absolute diagnostic deadline, allow one 120-second Wetech readiness probe inside a 240-second auth stage, preserve streamed failure state and timing, reject Wetech not_required auth output, and propagate separate response-generation and provider-evidence status into Recent Evaluation with capability-dependent deterministic reconciliation.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/pull/563"
    }
  ]
}
-->

- Optimization ID: `diagnostic-provider-execution-state-2026-07-30`
- Owner: auto-oncall-services
- Source reference: `APID-29259`
- Implementation status: deployed to staging in revision `3efeb556`; status
  evidence published in revision `d38f0dba`
- Effective status: `optimized_verified`

## Bounded problem

The Wetech authentication agent can spend part of its stage reading skills and
resolving the target, then start a provider readiness command whose timeout is
equal to the remaining outer-stage contract. The outer abort can therefore
arrive before the provider command returns, discard completed streamed state,
and collapse the result into a generic bootstrap failure. Recent Evaluation
also lacks a structured distinction between successful response generation and
degraded provider evidence acquisition.

## Candidate implementation

- Use one 20-minute absolute deadline across route, authentication, scenario
  evidence, synthesis, publication correction, and normalization. Stage caps
  and downstream reserves consume that deadline and never extend it.
- Require exactly one Wetech readiness probe with `--login-timeout 120` inside
  a 240-second auth stage, leaving bounded time for skill loading, target
  resolution, and the structured response.
- Classify `AbortError` and `The operation was aborted` as timeouts. Preserve
  stage timing, the real bounded error code, completed or last-observed
  streamed items, usage, and child-command status in an auditable failure
  artifact.
- Restrict the Wetech auth schema and parser to `ready` or
  `bounded_failure`; `not_required` is invalid for a provider that requires
  bootstrap.
- Publish separate response-generation and evidence-acquisition status,
  including whether provider capability was verified. Recent Evaluation only
  converts an applicable criterion result to `inconclusive` when that
  criterion explicitly declares `provider_evidence` as required and the
  capability was not verified; `not_applicable` remains unchanged.
  Non-load-bearing provider degradation remains visible without erasing a valid
  `met`.

## Verification evidence

- The local bounded readiness reproduction for `SaaS02` completed in 14.6
  seconds with Grafana datasource readiness and exact target resolution,
  showing that the observed failure was orchestration timeout rather than
  provider unavailability:
  `/tmp/wetech-auth-readiness-repro-20260730.log`.
- Contract and runner tests cover the shared 20-minute deadline, 120/240-second
  nested timeout contract, Abort timeout classification and failure artifact,
  Wetech `not_required` rejection, structured execution state, and
  capability-dependent evaluation reconciliation.
- The deployed APID-29259 same-cutoff replay
  `85b4f6e6-2bef-48f5-8b75-d8a8c165249d` completed Wetech route and
  authentication in 114.046 seconds total, with the authentication stage
  reporting `ready` and the exact `asia-prod/SaaS02` target.
- Its query scenario later reached the independent 360.008-second bounded
  timeout with `the_operation_was_aborted`. The runtime preserved that failure
  as evidence acquisition `failed`, while response generation independently
  remained `complete` and returned HTTP 200. This verifies the record's
  bootstrap and execution-state boundary without claiming query completion.

## Unresolved gaps

- The deployed APID-29231 replay preserved separate response-generation and
  evidence-acquisition state, but its query-execution scenario still reached
  the 360-second bounded timeout. APID-29259 reproduced the same separate
  query-scenario timeout after successful bootstrap.
- Provider query completion and the APID-29259 Focus discriminator remain
  unverified or unresolved; they are separate problems from this record's
  bootstrap and execution-state contract.
- No Jira internal comment has been refreshed.
- Raw artifact redaction is intentionally unchanged in this task.

## Next validation action

Address provider query-scenario completion separately. Retain this verified
execution-state contract so future bounded provider failures remain auditable
and do not erase a successfully generated response.
