# APID Wetech TiFlash Gate Contract

## Current Design

- The worker applies `l1_oncaller_gate`, then `auto_coverage_gate`, then live
  analysis.
- `auto_coverage_gate` derives its decision from scenario class plus resolution
  mode allowlists.
- The scenario classifier currently models ST diagnostic evidence as `clinic`
  and non-ST diagnostic evidence as `investibook`.
- The live workspace prompt tells the agent to use `wetech-op-grafana` for APID
  Wetech OP cases, but the gate classification does not expose Wetech OP as the
  evidence provider.
- TiFlash storage/capacity wording such as disk space, threshold, and used ratio
  is not an explicit cluster runtime classifier signal.

## Risks

- APID Wetech OP tickets can be marked as missing diagnostic context even when
  the customer text contains a Wetech cluster alias.
- TiFlash capacity questions can be treated as generic capability questions, so
  the gate details omit the current TiFlash disk used ratio that the diagnostic
  skill can query.
- A final go-ahead for a production expansion remains a human/ops decision even
  when read-only metrics are available.

## Target Contract

- APID diagnostic tickets use Jira `Account Alias` as the canonical Wetech
  account signal. Description text is not the source of truth for deciding
  whether an APID ticket is Wetech.
- APID diagnostic tickets whose `Account Alias` is `Wetech` use `wetech` as
  their evidence provider for SQL performance, cluster runtime, or TiCDC cases.
  Cluster aliases, cluster IDs, and tenant/org fields are lookup keys, not the
  source of truth for account ownership.
- TiFlash disk/capacity/low-space/used-ratio wording is classified as a cluster
  runtime issue.
- APID Wetech TiFlash storage/capacity wording is classified before the generic
  operation-request check so read-only metrics can be collected before any
  human/ops go-ahead decision.
- Wetech OP cluster aliases present in customer text count as `cluster_alias`
  context.
- A customer-provided time window is not a gate prerequisite for diagnostic
  automation. The agent/skill path should infer a reasonable initial window
  from ticket context or use metrics to discover and narrow the relevant window.
- The live prompt must ask the agent to query Wetech OP Grafana before asking
  the customer for already-present APID Wetech TiFlash metric context.
- This change does not approve production operations, change Jira write safety,
  broaden customer-visible writes, or add backend-owned Wetech metric
  persistence.

## Implementation Steps

1. Add TiFlash storage/capacity/current-state classifier signals.
2. Add Wetech OP cluster alias lookup-key detection.
3. Route APID diagnostic evidence provider to `wetech`.
4. Clarify the live prompt for APID Wetech TiFlash used-ratio checks.
5. Add local tests for APID-29151-shaped input and gate enablement.

## Verification Checklist

- APID Wetech TiFlash disk threshold input classifies as
  `cluster_runtime_issue`.
- The same input has `resolutionMode=evidence_assisted`,
  `evidenceProvider=wetech`, and no missing lookup keys when it includes a
  Wetech cluster alias plus current-state wording.
- Auto coverage enables the above classification when
  `cluster_runtime_issue` and `evidence_assisted` are configured.
- The live prompt mentions APID Wetech TiFlash current disk used-ratio checks.
- `npm run typecheck` and `npm test` pass.
