# Diagnostic Finalization Availability

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "diagnostic-finalization-availability-2026-08-05",
  "problems": [
    {
      "problemId": "diagnostic-model-timeouts-discard-preserved-evidence-or-fail-the-run",
      "summary": "The scenario reserve aborted the parent without giving it a real finalization turn, and a 75-second final synthesis timeout failed the whole run even when compact scenario evidence had already been preserved.",
      "status": "optimized_verified",
      "issueKeys": ["ST-2865", "TCID-12973", "APID-29231"],
      "sourceRefs": [
        "https://tidb.atlassian.net/browse/ST-2865#problem:diagnostic-finalization-timeout",
        "https://tidb.atlassian.net/browse/TCID-12973#problem:diagnostic-finalization-timeout",
        "https://tidb.atlassian.net/browse/APID-29231#problem:diagnostic-finalization-timeout"
      ],
      "signalTextIncludesAny": [
        "diagnostic_scenario_reserve_boundary_reached",
        "diagnostic scenario synthesis timed out",
        "synthesis timeout failed the whole analysis",
        "partial child handoff reported as complete evidence"
      ],
      "observedThrough": "2026-08-05",
      "effectiveAt": "2026-08-05T10:42:00Z",
      "verifiedAt": "2026-08-05T11:07:27Z",
      "attemptedAction": "Use the reserved scenario time for a fresh tool-free parent finalization from the validated handoff, preserve child partial completion as trace metadata without downgrading a successful parent judgment, reallocate time from scenario acquisition to a larger no-tool synthesis window without extending the shared pipeline or worker deadline, and return a deterministic human-review result from preserved packets when synthesis still fails or times out.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/ST-2865"
    }
  ]
}
-->

- Optimization ID: `diagnostic-finalization-availability-2026-08-05`
- Owner: auto-oncall-services
- Source references: branch-local replays of `ST-2865`, `TCID-12973`, and
  `APID-29231`
- Implementation status: deployed to staging
- Effective status: `optimized_verified`

## Bounded problem

The former reserve was only an abort boundary: it stopped the long scenario
turn, read the newest handoff, and immediately converted it to a bounded-failure
packet. No parent model actually received the reserved time. After scenario
work, all three measured replays also reached the independent 75-second final
synthesis cap; that exception failed the analysis even though usable compact
packets were already available.

## Implementation

- Reserve up to 120 seconds of each scenario stage. At the boundary, stop and
  reap the acquisition turn, validate the current-attempt handoff, and start one
  fresh read-only, no-network, tool-free parent finalization turn from inline
  route and handoff data.
- If reserved finalization succeeds, keep its parent-owned diagnosis. If the
  handoff was partial, preserve `execution.completion=partial` independently;
  this remains trace/checkpoint metadata and does not downgrade a successful
  parent judgment or the top-level evidence-acquisition status.
- If reserved finalization fails, preserve the handoff observations, gaps, and
  artifact refs in the bounded scenario packet.
- Keep the shared diagnostic pipeline at 20 minutes and the worker envelope at
  25 minutes. Increase the no-tool synthesis cap from 75 seconds to 3 minutes;
  the existing stage allocator deducts that larger downstream reserve from the
  scenario acquisition window instead of extending the end-to-end deadline.
- If final synthesis still times out, fails schema parsing, or uses a forbidden
  tool, return a deterministic `human_required` result from the preserved
  packets. Do not rerun successful evidence acquisition and do not turn the
  model-stage failure into a 500 response.

## Local verification

- Runner tests cover complete and partial handoff takeover, no-tool finalizer
  execution, stream cleanup, partial evidence reporting, finalizer failure,
  forbidden synthesis tool use, and synthesis timeout fallback.
- Configuration tests cover the unchanged 20-minute pipeline and 25-minute
  worker envelope plus the 3-minute synthesis window in both app-delivery
  templates.
- Staging image `4edcfd9abeadd4c2a47ee25c3d8fb9537d630f13` rendered the
  expected 180-second synthesis, 1200-second pipeline, and 1500-second worker
  values. The pod remained Ready with zero restarts.
- Deployed write replays completed without synthesis timeout or packet loss:
  `ST-2865` run `06876c15-de4f-46a5-9a7a-6e48d1e766e5`, `TCID-12973` run
  `60f1bb4f-3f2b-4382-ba4e-3f1e2c41ea0f`, and `APID-29231` run
  `de874fd8-c11c-416f-8b85-f57d59996f02`. All three returned complete response
  generation and complete evidence acquisition, then wrote DB runs
  `120016`-`120018`, evaluations, Feishu Base updates, and their existing Jira
  internal comments.
- `TCID-12973`, which previously ended at the scenario reserve with only a
  partial packet, produced a complete handoff, five evidence artifacts, a
  terminal parent decision, and successful final synthesis. `APID-29231`
  completed its long Wetech evidence turn and synthesis inside the unchanged
  total pipeline deadline.

## Unresolved gaps

- Larger windows remain headroom rather than the primary latency fix. The
  separate Clinic batch-orchestration record owns the measured Clinic latency
  reduction.
- No deployed replay exercised the deterministic synthesis-timeout fallback;
  that branch remains covered by unit tests. The source-case failure mode is
  nevertheless verified because all three former timeout cases now completed
  synthesis within the bounded allocation.

## Next validation action

Monitor later diagnostic runs for `diagnostic scenario synthesis timed out` or
loss of preserved scenario packets. Treat any new matching post-verification
evidence as a regression and replay the affected case before changing timeout
allocation again.
