# Clinic Data Proxy SQL Validation Ownership

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "clinic-data-proxy-sql-validation-2026-08-25",
  "problems": [
    {
      "problemId": "managed-clinic-local-logical-table-rejection",
      "summary": "Managed Clinic rejected bounded read-only Data Proxy SQL locally unless every logical table used an invented clinic_data_proxy prefix contract, so valid Evidence planning degraded before Provider execution.",
      "status": "optimized_unverified",
      "applicability": "Clinic sql_query evidence using Data Proxy logical observability tables.",
      "issueKeys": ["TCID-13070"],
      "sourceRefs": ["https://tidb.atlassian.net/browse/TCID-13070#problem:managed-clinic-local-logical-table-rejection"],
      "signalTextIncludesAny": [
        "sql_observability_source_required",
        "clinic_sql_observability_source_required",
        "TCID-13070"
      ],
      "observedThrough": "2026-08-25",
      "effectiveAt": "2026-08-25T10:27:18Z",
      "verifiedAt": null,
      "attemptedAction": "Remove the AOS and Managed Clinic logical-table allowlist, keep read-only and bounded query controls, deterministically qualify exact unqualified Statements, and preserve Data Proxy 4xx correction details per query.",
      "evidenceUrl": "https://tidb.atlassian.net/browse/TCID-13070"
    }
  ]
}
-->

- Owner: Managed Clinic Provider Executor and legacy Clinic batch executor
- Source: TCID-13070 replay `f2fc8501-bf47-42cd-9074-3d3653551718`
- Implementation status: deployed to Agent9 internal production and the
  Agent9-backed Auto Oncall branch runtime
- Effective status: `optimized_unverified`

## Bounded problem

Managed Clinic v14 required every custom SQL statement to contain a
`clinic_data_proxy.<table>` token and rejected `information_schema`-shaped names
before sending the request. Clinic Data Proxy itself accepts only `sql` and
`timeout` in the canonical request body and owns supported logical-table,
field, dialect, and partition validation. The duplicated local rule rejected
otherwise bounded plans without authoritative Provider feedback.

## Intended change

Both Agent9 Managed Clinic and the legacy deterministic Clinic executor retain
single-statement read-only, length, absolute-window, UTC-partition, timeout, and
compact-result boundaries but no longer classify logical table names locally.
The exact unqualified `statements` table is normalized to the Provider-required
lowercase `clinic_data_proxy.statements`; unknown tables are not rewritten.
Safe Data Proxy 4xx details remain attached to the failed query for same-round
correction.

## Verification

Managed Clinic v16 package digest
`16e0dc05209751a82a7a17e89d68f2a2ae1707f6212dff2528a33e993f0d8df6`
was installed on the Auto Oncall Evidence Agent at installation revision 7.
TCID-13070 replay `fd3b2042-506f-4da8-9a60-e0b0bd293bf3` completed with HTTP
200, Judge verdict `ai_better`, and complete Clinic acquisition with no failure
codes. Its five batches materialized 56 query entries with no local SQL source
rejection, but this Router realization did not select a generic Statements SQL
objective.

A separate live Evidence Agent probe used the v16 compatibility-only `query`
alias for a Statements `sql_query`. Session
`sess_e0efc90a3f6c45ab9c23fc129bdfe450` made exactly one
`managed_auto_oncall_clinic` call. The request reached Data Proxy and returned
the Provider-owned `clinic_http_400`, rather than local `invalid_sql`; the entry
remained `supplemental`, no correction was attempted, and the Turn succeeded.
This verifies the deployed Provider boundary and retry semantics, but not a
changed ticket diagnosis from that SQL evidence.

## Next validation action

Replay a known case whose selected plan actually contains generic Data Proxy
SQL, then refresh its stable Jira internal comment through the authorized write
path. Until that case-specific diagnostic effect and write readback pass, keep
this record `optimized_unverified`.
