# Diagnostic Scenario Subagent Isolation

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "diagnostic-scenario-subagent-isolation-2026-07-30",
  "problems": [
    {
      "problemId": "diagnostic-scenarios-share-provider-and-synthesis-context",
      "summary": "Scenario routing, provider acquisition, evidence interpretation, and final synthesis share one large Codex context, which can suppress orthogonal causal paths and dilute case-specific evidence.",
      "status": "optimized_unverified",
      "issueKeys": ["APID-29194", "APID-29174", "TCID-12920"],
      "sourceRefs": [
        "https://tidb.atlassian.net/browse/APID-29194#problem:diagnostic_scenario:write-storage-chain",
        "https://tidb.atlassian.net/browse/APID-29174#problem:diagnostic_scenario:flow-control-latch-separation",
        "https://tidb.atlassian.net/browse/TCID-12920#problem:diagnostic_scenario:cdc-downstream-alternatives"
      ],
      "signalTextIncludesAny": [
        "scenario subagent",
        "fresh diagnosis thread",
        "write path and storage",
        "TiCDC downstream capacity",
        "diagnostic context overload"
      ],
      "observedThrough": "2026-07-30",
      "effectiveAt": "2026-07-30T16:02:20.000Z",
      "verifiedAt": null,
      "attemptedAction": "Create a replay-safe structured route from frozen workspace inputs, bootstrap one reusable Wetech browser session, run each selected scenario in an independent evidence-and-summary Codex thread, serialize only Wetech browser-backed work while allowing independent Manus scenarios to run concurrently, and synthesize only compact evidence packets in a fresh tool-free diagnosis thread with a monotonic human-review boundary.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/pull/563"
    }
  ]
}
-->

- Optimization ID: `diagnostic-scenario-subagent-isolation-2026-07-30`
- Owner: auto-oncall-services
- Source references: `APID-29194`, `APID-29174`, `TCID-12920`
- Implementation status: deployed to staging in revision `3efeb556`
- Effective status: `optimized_unverified`

## Bounded problem

The current diagnostic multiturn implementation keeps routing, the first
provider investigation, and causal-gap acquisition in one Codex thread. Even
when final synthesis starts fresh after successful evidence, the scenario
work itself shares a large skill and provider transcript. Independent storage,
write-path, capacity, TiCDC-stage, and network alternatives can therefore be
suppressed or merged before they produce bounded findings.

## Candidate implementation

- Build the route only from replay-frozen workspace inputs. Current or future
  Jira comments outside the replay cutoff never enter route or synthesis.
- Select one primary and at most two orthogonal secondary scenarios. Signal
  guards add write-path plus storage boundaries and TiCDC plus independently
  observed capacity/network boundaries without issue-key hardcoding. Negated,
  healthy, normal, recovered, or ruled-out evidence never forces a route.
- Use one isolated authentication/readiness thread for Wetech and serialize
  the complete browser-backed provider session through a per-account lock.
- Manus does not use the shared Wetech bootstrap or provider lock. Each
  independent Manus scenario follows its provider contract with a unique
  output directory and may execute concurrently.
- Run every scenario in a separate evidence-and-summary thread. Non-stateful
  provider or supplied-evidence scenarios may execute concurrently with unique
  evidence output paths.
- Start final diagnosis in a fresh network-disabled, tool-free thread and pass
  only the frozen ticket packet, structured route, and compact evidence
  packets. Never resume an evidence thread after success, timeout, or failure.
- Permit `human_required` and provider-none cases to analyze supplied evidence
  read-only while enforcing `human_required` as a monotonic final decision.
  Existing read-only providers may continue bounded diagnosis for hard-risk
  cases; provider-none requires frozen supplied evidence.

## Verification evidence

- Contract tests cover the three source-case signal shapes:
  write-path plus storage; flow-control/storage plus latch and observed
  capacity; and TiCDC plus independently signaled downstream capacity/network.
- A generic downstream transaction timeout does not add a network scenario.
- A generic write-path case does not retain `query-execution` without a
  concrete plan, operator, scan-amplification, or digest-performance problem.
- Runner tests require distinct route, evidence, and final thread IDs; reject
  tool use in route/final turns; preserve final continuation thread semantics;
  keep Wetech stateful execution serial; and allow Manus scenarios to execute
  independently without the provider lock.
- Replay-isolation coverage injects a future support-only secret into the
  current `SupportCase` and verifies that neither route nor final prompt can
  see it, while frozen pre-cutoff evidence remains visible.
- Local targeted build and tests pass. This is implementation evidence only;
  it does not prove runtime effectiveness.

## Unresolved gaps

- The listed source cases, including APID-29174, are historical problem
  evidence only and have not received post-change deployed replays.
- Deployed TCID-12973 demonstrated distinct route, scenario, and synthesis
  threads, but also showed that supplied-evidence scenario threads can scan an
  audit-only diagnostic summary from the shared workspace. Thread separation
  is therefore effective, while input isolation remains unverified.
- Wetech stateful locking is process-local. Current staging uses one worker replica;
  a future multi-replica rollout needs a distributed provider-session lock or
  per-run isolated browser profiles.
- Manus scenario concurrency is implemented locally, but Manus skill access and
  IP allowlisting are currently disabled outside this repository. The code
  change therefore cannot affect live Manus diagnosis until that external
  provider path is restored and the candidate is deployed.
- Provider capability and query quality still depend on the selected provider
  skill. Scenario isolation prevents context contamination but does not make an
  unavailable metric or unsupported field available.
- No Jira internal comment has been refreshed.

## Next validation action

After deployment to staging, validate the structured route, scenario thread
overlap, compact evidence packets, and tool-free final synthesis on fresh or
newly eligible diagnostic cases. Do not rerun the already completed source
cases solely for this concurrency change. For Manus specifically, wait until
the external skill and IP path is restored, then use a fresh/new Manus case or
a bounded synthetic staging validation to confirm independent scenarios
overlap without a provider lock before promoting the problem to
`optimized_verified`.
