# TCID-13132 internal evidence fidelity and SQL text deduplication

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "tcid13132-evidence-fidelity-2026-09-08",
  "problems": [
    {
      "problemId": "provider-internal-diagnostic-redaction",
      "summary": "Provider output shortens Digests and removes diagnostic text; metric results omit actual PromQL.",
      "status": "optimized_unverified",
      "applicability": "Agent9 Managed Clinic, Wetech and Manus internal evidence output.",
      "issueKeys": ["TCID-13132"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13132#problem:provider-internal-diagnostic-redaction"],
      "signalTextIncludesAny": ["TiFlash CPU"],
      "observedThrough": "2026-09-08",
      "effectiveAt": "2026-09-07T18:23:02.336Z",
      "verifiedAt": null,
      "attemptedAction": "Deployed Clinic 31, Manus 7 and Wetech 63. TCID-13132 read replay confirms full Clinic Digests and actual PromQL; no Jira refresh or Wetech/Manus case verification.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13132"
    },
    {
      "problemId": "repeated-sql-consumes-handoff-budget",
      "summary": "Repeated SQL text consumes handoff capacity and displaces other compact observations.",
      "status": "optimized_unverified",
      "applicability": "Runner-owned Provider handoffs with repeated Query Digests.",
      "issueKeys": ["TCID-13132"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13132#problem:repeated-sql-consumes-handoff-budget"],
      "signalTextIncludesAny": ["Handoff byte budget"],
      "observedThrough": "2026-09-08",
      "effectiveAt": "2026-09-07T18:23:02.336Z",
      "verifiedAt": null,
      "attemptedAction": "Deployed runner SQL deduplication. TCID-13132 read replay retains target execution facts with deduplicated SQL; cumulative budget still drops some observations and Jira refresh is not performed.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13132"
    }
  ]
}
-->

Initial base: `25165d8225ec1bda9b2122a7e6704c2bb4d92ec5`.
Integrated base: `69f112606f8cf9f921b41249f09932c50a49c2ac`; preserves the
independently merged Wetech WSS egress change.
Historical source: isolated replay `40c29173-b31d-4d5e-b977-d91e11015426`,
image source `65232e57`, answer fingerprint
`6b64aab42876ab219675e57e32b7731e269c8029df5ab4d1642bb54d6c07d342`.
Judge: `different_but_valid`; diagnostic completeness is a separate criterion.

The query named `tiflash-peer-process-cpu-cores` returned five TiDB instances
with `job=observability/tidb-pool`. Scenario Diagnostic interpreted them as
TiDB, not TiFlash. The earliest missing evidence is in acquisition; historical
Agent9 audit retained argument hashes rather than PromQL, so the exact selector
cannot be reconstructed. Returning executed PromQL prevents that loss in future
Provider results; it does not restore historical Agent9 audit payloads or change
Agent9's generic audit implementation.

The replay did not match the exact target SQL or retrieve its execution plans.
Its broad Slow Query lists therefore cannot establish equal actual rows across
the human's 4.5–20.8 second target executions. SQL deduplication preserves
available facts but cannot manufacture that absent evidence. Recovery at 11:27
is outside the historical replay cutoff of 10:57:09 UTC+8 and must not leak into
the replay answer. TiFlash source availability and exact-SQL acquisition remain
separate diagnostic follow-up questions, not claims of this patch.

Offline application to the original exported handoffs keeps all five currently
retained facts in each scenario. Serialized UTF-8 sizes change from 115,052 to
93,191 bytes (query-latency), 116,092 to 94,231 (tiflash-io-apply), and 115,737 to
78,901 (workload-hotspot). These historical outputs contain short Digests, so
only identical SQL text is coalesced. This check does not restore facts already
removed by the original replay or predict the next full replay's evidence set.

Immutable package artifacts were prepared and read back without installing or
deploying them. Local regression runs no model or Provider and performs no Jira
publication or optimization-status write. Keep both problems at `candidate` until
an authorized deployed isolated replay verifies their corresponding boundaries.

Validation: `npm test` passes with 1,204 passing tests, no failures and two
browser-integration tests skipped. Coverage includes full returned Digests,
executed PromQL, SQL/log preservation, credential redaction (including SQL
authentication clauses), repeated SQL with preserved per-execution facts,
cross-database/target isolation and immutable package/source matching.
Final prepared versions: Clinic 31, Manus 7, Wetech 63. Bundle SHA-256:
`3c9cd1c3d786bd339655304c55a2d95c472dbc4391dcbcad57995babeed339bd`.
The package was read back by its exact object version and verified byte-for-byte;
`deploy:agent9-tools -- --validate-only` passes without deployment.

## Subsequent deployment and verification

The preparation-only statements above describe the initial stage. PR #1402 was
subsequently deployed with source `363d4d0b` and the bundle above. Read replay
`5f9cb4a4-ec38-45be-87a0-218614c36001` completed on 2026-09-07 18:41:43.420 UTC:
Judge `different_but_valid`, acquisition complete, no final failure codes.
The actual Clinic output now retains full Digests and executed PromQL, and the
runner's cumulative handoff reports SQL deduplication. It still retains only
9/15 query-latency observations under the total budget; deduplication does not
promise unlimited context. TiFlash metric emptiness remains a diagnostic gap.
The target SQL was found after the separate runner-input fix recorded in
`2026-09-08-tcid13132-supplied-sql-context.md`; that outcome cannot be attributed
solely to this fidelity patch. No Jira/DB/Base refresh or Wetech/Manus functional
case replay was performed, so these problem records remain unverified.
