# Wetech TopSQL instance preflight

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "wetech-topsql-instance-validation-2026-09-07",
  "problems": [{
    "problemId": "topsql-instance-rejected-after-login",
    "summary": "Invalid TopSQL instance is rejected after login with a generic query failure instead of an actionable preflight error.",
    "status": "candidate",
    "applicability": "Agent9 Wetech Managed Tool TopSQL calls with missing or structurally invalid instance.",
    "issueKeys": ["APID-29470"],
    "sourceRefs": ["https://tidb.atlassian.net/browse/APID-29470#problem:topsql-invalid-instance"],
    "signalTextIncludesAny": ["invalid instance"],
    "observedThrough": "2026-09-07",
    "effectiveAt": null,
    "verifiedAt": null,
    "attemptedAction": "Validate the existing instance string contract before auth and return same-Turn correct_request details; clarify exact-selector requirements without guessing or discovery.",
    "evidenceUrl": "https://tidb.atlassian.net/browse/APID-29470"
  }]
}
-->

Owner: Wetech Managed Tool Provider Executor. Fetched base:
`7b71b52bc1fdaa5da67b383f8ba75a778214b80b`. Implementation: source candidate,
Wetech v44; not deployed or case-verified.

Source replay `d5c785c4-2f30-4b32-892c-127274a3fe63`, query-latency round 2,
objective `round2-resolve-target-digest`, returned `invalid instance` and
`requestCount=0` under v42. The archived Tool arguments are empty, so the
precise invalid value is unavailable. Source proves the error is the local
required-string check inside `dashboardQuery`, after browser/authentication.
This change moves the same validation to preflight and uses the field-level
correction contract introduced by PR #1372. It does not infer which instance
the Agent intended, resolve opaque references, or add cluster-wide TopSQL.

Local regression exercises the actual executable without credentials/browser
dependencies for missing, non-string, empty, whitespace, and oversized input;
checks safe field/expected/repair metadata; and preserves valid selectors and
non-TopSQL operations. Digest and limit regressions remain in the same suite.

Unresolved: this does not prove target SQL attribution, recover an unavailable
exact TopSQL selector, or fix the independent workload-hotspot round-2 timeout
(75,059 ms elapsed / 75,056 ms allocated). No global timeout, retry, diagnostic,
or response policy is changed. Old replay evidence predates PR #1372.
The runner computes that Evidence Turn allowance from the scenario's remaining
budget minus its diagnostic finalization reserve; it is not a standalone
75-second Wetech query timeout. This evidence does not establish which earlier
operation consumed the load-bearing portion of that budget.

Next validation: after coordinated package and Skill release, one isolated
APID-29470 read replay. Inspect same-query correction, actual Provider evidence,
remaining timeout, final answer and Judge separately. No Jira refresh or whole
ticket optimization success is claimed from the local tests.
