# Reusable Digest prefixes and single-SQL plans

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "provider-digest-prefix-detail-2026-09-07",
  "problems": [{
    "problemId": "wetech-returned-digest-not-queryable",
    "summary": "Wetech returned opaque SQL identities which cannot be used for subsequent Slow Query requests.",
    "status": "candidate",
    "applicability": "Agent9 Wetech and Clinic Managed Tool Digest-selected Slow Query acquisition.",
    "issueKeys": ["APID-29464"],
    "sourceRefs": ["https://tidb.atlassian.net/browse/APID-29464#problem:wetech-returned-digest-not-queryable"],
    "signalTextIncludesAny": ["invalid digest", "opaque query identity"],
    "observedThrough": "2026-09-07",
    "effectiveAt": null,
    "verifiedAt": null,
    "attemptedAction": "Return reusable six-character Digest prefixes, translate prefix requests to bounded server filters, and expose detailed plans only for a single selected SQL consistently in Wetech and Clinic.",
    "evidenceUrl": "https://tidb.atlassian.net/browse/APID-29464"
  }]
}
-->

Owner: AOS Managed Tool Provider Executor and its per-execution materializer.
Source: operator investigation of APID-29464 read run
`5f909309-d5f4-47d1-9403-94829ce117c2`. Two requests supplied returned
`entity-*` identities to a 64-hex-only Digest input. Canonical request hashes
matched the archived failures; both failed before the Slow Query API request.

Implementation: Wetech v46 and Clinic v28 source and immutable bundle candidate.
No live installation, deployment, fresh ticket replay or quality promotion is
claimed by this record. Manus is unchanged.

## Contract and reason

Lists use six-character Digest prefixes and omit detailed plans to keep evidence
focused. A prefix is a reusable selector, not a redacted substitute. Returned Digests stay
fixed at six characters; no collision-specific extension is added. Single-SQL requests preserve up to three execution-paired
decoded plans and operator summaries; the runner preserves each execution as one
fact for both Providers. Wetech and Clinic metric instance labels and their compatibility reference fields
retain the original values, so metric-selected instances are queryable.

Dashboard's `digest` filter is exact equality. Its `text` filter supports regular
expressions before LIMIT; Wetech prefix requests use an anchored 64-hex pattern
and recheck returned Digests. Clinic NGM uses the same request shape; dedicated
Data Proxy retains its bounded LIKE predicate. Source:
https://github.com/pingcap/tidb-dashboard/blob/master/pkg/apiserver/slowquery/queries.go

PR #965 (`00a62988`, 2026-08-18), the Managed Tool operation-parity migration,
introduced Wetech Dashboard opaque identities and raw SQL/plan redaction.
Its `2026-08-18-agent9-provider-operation-parity.md` record treated these as an
inherited compact-output constraint. That PR and record cite no disclosure
incident. PR #1351 carried the policy into the exact-Digest plan compactor.
The operator clarified here that default plan omission prevents context pollution;
single-point plans should remain available and six-character Digests queryable.

## Verification and remaining work

Local tests cover list-to-prefix-to-detail requests, exact Digest compatibility,
server filtering before LIMIT, broad plan omission, numeric
execution counters, single-SQL decoded plans and both Provider handoffs.
Full suite and immutable bundle validation pass (2026-09-07).

The attempted real local simulator stopped at `spawn docker ENOENT`, before
browser, login or Provider requests. Real Dashboard and NGM filtering still need
bounded live verification; mocked responses establish the implementation contract
only. Next validation: one bounded list-to-detail canary after coordinated Tool
and Skill release. Keep the prior published ticket answer and Judge unchanged.

Additional offline boundary checks (2026-09-07): a small decoded plan reaches the
handoff, but a plan with a 21.6 KB operator-info string fails
`diagnostic_observations.statement_invalid`; a valid predicate containing a SQL
string literal fails `diagnostic_child_observations.statement_sensitive_value`.
These expose the downstream per-fact limit and generic SQL-content rejection.
The actual APID-29464 replay did not hit these limits: its two handoffs were
26,172 and 25,061 UTF-8 bytes, with a 4,000-character maximum observation and
no budget drops. The synthetic large-plan example does not justify raising
limits, which remain unchanged.

The SQL-content rejection is repaired in the evidence-handoff parser: legitimate
SQL text, comments and full Digests now pass through unchanged, including the
exact predicate fixture above. Credential and existing length checks remain;
separate scenario decision-packet checks are unchanged. Regression coverage
exercises both Wetech and Clinic materialization and preserves the rejection of
credentials and over-limit observations.

Follow-up source correction: Wetech v46's parameter description and executor
accepted 6–64 hex characters, but the published JSON Schema still required 64.
Wetech v47 changes the template and generated schema to `{6,64}` and tests both
against the executor at 6, 12, 63 and 64 characters, plus invalid boundaries.
This completes the same prefix-query contract without changing identity or plan
semantics. It is not deployment or replay verification.
