# Diagnostic visual context and scoped execution efficiency

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "diagnostic-visual-context-efficiency-2026-09-08",
  "problems": [
    {
      "problemId": "reported-visual-incident-anchor-lost",
      "summary": "Router omitted the affected node and visible incident onset; subsequent diagnosis substituted another peak inside a broad discovery window.",
      "status": "candidate",
      "applicability": "Diagnostic tickets with cutoff-visible graphs whose node, event time or shape scopes the customer's question.",
      "issueKeys": ["TCID-13103"],
      "sourceRefs": ["manual://TCID-13103/7b0f4454-a70c-41d7-adcb-13fe8f2070df#problem:reported-visual-incident-anchor-lost"],
      "signalTextIncludesAny": ["reported visual incident anchor lost", "unrelated global maximum replaces reported node incident"],
      "observedThrough": "2026-09-08",
      "effectiveAt": null,
      "verifiedAt": null,
      "attemptedAction": "Preserve visible incident facts in the common Router anchor and allow same-scenario same-replay on-demand original-image verification by Scenario Diagnostic.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13103"
    },
    {
      "problemId": "duplicate-metadata-and-session-context-overhead",
      "summary": "Repeated metadata-only planning and already-read Skill context spend diagnostic budget without adding evidence.",
      "status": "candidate",
      "applicability": "Clinic exact-target bootstrap and repeated rounds inside one diagnostic scenario/replay.",
      "issueKeys": ["TCID-13132", "TCID-13103", "TCID-13139"],
      "sourceRefs": ["manual://scenario-split-20260908#problem:duplicate-metadata-and-session-context-overhead"],
      "signalTextIncludesAny": ["duplicate metadata-only preflight", "repeat already-loaded diagnosis Skill"],
      "observedThrough": "2026-09-08",
      "effectiveAt": null,
      "verifiedAt": null,
      "attemptedAction": "Reuse actual exact-org/cluster bootstrap tier metadata and same-scenario Skill context; preserve original metadata preflight when tier remains unknown.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13139"
    }
  ]
}
-->

- Owner: AOS Scenario Router, Scenario Diagnostic, and runner metadata/context transport.
- Source baseline: `0affba36f26792f732f7bc7a48b4a3a3e94587cd`.
- Implementation: PR #1416 deployed as `02bdc964` on 2026-09-09 (+08).
  Read-only verification is recorded below; no Jira publication or automated
  optimization-status promotion is claimed.

The Router uses existing window/symptom/scenario fields for visible facts. A
small image-request result lets the runner supply only selected original image
refs from the same frozen run and continue the same Scenario Diagnostic thread.
No Provider authority, cross-run context, extra query round, or downstream
formatting diagnosis is added. Slow Query selection has its separate record.

The explicit `noDiagnosticTimeout` read API option is a verification aid, not a
claim that latency is fixed. It records ordinary diagnostic deadlines without
aborting. Default automation, one-hour isolated Job/collection limits, Provider
operation/auth/network limits, classifier and Judge remain unchanged.

## Verification in progress

On 2026-09-09 00:04 +08, final `npm test` passed: 1,230 TypeScript tests
(1,228 passed, 2 skipped, 0 failed) and 9 isolated-runner tests (all passed).
The exact filtered command output is retained in the local verification artifact
`final-tests.txt`; it is not a full TAP transcript. Focused tests cover actual same-thread
image request/continuation, allowed original refs, no repeated image delivery,
distinct problemSummary/question, known/unknown tier planning, request-scoped
deadline isolation, caller cancellation, and retained network timeouts.
The initial Scenario Diagnostic turn and Evidence receive the same runner-owned
exact-org/cluster tier metadata, including Shared/Starter/Essential. Skipping a
redundant metadata-only query does not remove those applicability facts from
diagnosis; unknown tier still uses the original Provider preflight.

Local real-model checks use the unmodified TCID-13103 run
`7b0f4454-a70c-41d7-adcb-13fe8f2070df`: its original route, cumulative R1+R2
handoff and original CPU image. They must not manufacture an R1-only handoff or
edit the Router anchor. Router image extraction is checked separately with the
production routing prompt and that same frozen input. Local Codex execution is
not live Agent9/Provider or a full replay; its results will be recorded separately.

### Local model results (2026-09-08, production source frozen)

Artifacts: local replay directory `diagnostic-context-local-20260908.FpnNGA`,
model `gpt-5.6-sol`, reasoning `high`.

- Production Router prompt, original frozen input/image: 3/3 retained the
  db-tidb-2 excursion around 21:01–21:02 (+08:00) and peer separation. Windows
  differed (narrow event versus wider displayed chart), but none substituted
  the 20:32 common peak. Runtime was 35.9 / 54.0 / 30.1 seconds.
- Original finalization-only simulator plus on-demand image: all 3 trials
  requested the original graph and distinguished the 21:02 node event from
  the earlier global TopSQL slice. All retained unresolved initiating workload
  attribution. Trial 2 nevertheless mislabeled local 21:02 as UTC in its
  observation and refinement request, so this is **not a 3/3 time-semantics pass**.
  The complete first results remain in `diag-image-trials.json` without replacement.
- That inherited finalization-only entrypoint does not provide the production
  initial Scenario Diagnostic turn's frozen ticket context (including +08:00
  cutoff). A separate check now runs the production initial evidence-request
  prompt from the same frozen input, then same-thread original-handoff
  finalization with on-demand images. This completed on 2026-09-09 00:09 +08
  in `diag-full-context-trials.json`: all 3 trials requested the original image
  during the initial turn, continued the same thread, retained db-tidb-2's
  approximately 13:02 UTC / 21:02 local event, and explicitly distinguished the
  earlier 12:32 UTC / 20:32 local global TopSQL sample. None used that earlier
  sample to establish the cause of the later node increment or exclude the
  local hotspot. The bounded original-image/time criterion passed 3/3; no
  production prompt was changed to correct the first test's UTC error.
- This is not a full root-cause pass: trials 1 and 3 still label the earlier
  cluster-wide SQL baseline confirmed and rank the node-local session/TSO
  explanation below it, while acknowledging the missing onset-local TopSQL
  comparison. Trial 2 labels workload attribution correlated and the local
  diagnosis suspected. Whether ticket-level synthesis foregrounds the actual
  node incident instead of the older background mechanism remains an explicit
  full-replay observation, not a hidden success claim or an additional repair
  implemented here.

These checks test image extraction, local image-request/continuation and use of
frozen evidence only. They do not exercise live Agent9 image materialization,
Provider execution, new queries, or end-to-end latency. Those remain release
replay checks. Old status/error wording is not silently promoted to case success.

## Post-deployment verification (2026-09-09)

See the [three-case verification report](../replay-verification/2026-09-09-diagnostic-context-efficiency.md)
for exact runs, fingerprints, scopes, timing, and retained limitations.
TCID-13103 now preserves the reported node/time throughout actual acquisition
and the final answer, but still has instance TopSQL gaps and causal-strength
risks. TCID-13139 completes both selected diagnostic scenarios with a partial
workload acquisition result. TCID-13132 successfully exercises live on-demand
original-image continuation, but still lacks the target SQL, equal-row runtime
contrast, and TiFlash resource curve; both local diagnoses remain inconclusive.

Same-session reuse did not eliminate repeated Skill reads in the observed
TCID-13103 refinement; do not claim that efficiency problem verified. No
`optimized_verified` or ticket-wide repaired status is set, and no Jira/DB/Base
publication is authorized. Keep the original failed local trial evidence above.
