# OP Factual Child Handoff

<!-- auto-oncall-optimization-record
{
  "schemaVersion": "auto-oncall-optimization-record-v1",
  "optimizationId": "op-factual-child-handoff-2026-08-10",
  "problems": [
    {
      "problemId": "op-child-handoff-omits-query-result-facts",
      "summary": "The runner-owned OP child handoff reports that a provider query succeeded but omits its compact numeric and entity facts, so the tool-free parent cannot use already-acquired evidence and repeatedly asks for refinement.",
      "status": "optimized_unverified",
      "issueKeys": ["APID-29265", "APID-29232"],
      "sourceRefs": [
        "https://github.com/tidbcloud/aisupport/issues/606#problem:apid-29265-op-handoff-facts-omitted",
        "https://github.com/tidbcloud/aisupport/issues/606#problem:apid-29232-op-handoff-facts-omitted"
      ],
      "signalTextIncludesAny": [
        "diagnostic_wetech_parent_finalization_budget_exhausted",
        "diagnostic_evidence_refinement_not_required_invalid",
        "successful provider query handoff omits core facts",
        "repeated refinement after materialized wetech batch"
      ],
      "observedThrough": "2026-08-10",
      "effectiveAt": "2026-08-10T03:59:49Z",
      "verifiedAt": null,
      "attemptedAction": "Deterministically extract a bounded allowlist of compact metric, series, and dashboard decision facts into each OP handoff observation while excluding raw SQL, plans, full digests, credentials, and arbitrary provider strings; require known supporting checks and provider retry to stay inside the current up-to-six-query batch, and reserve a later refinement round for a genuinely new load-bearing diagnostic question.",
      "evidenceUrl": "https://github.com/tidbcloud/aisupport/actions/runs/31353565480"
    }
  ]
}
-->

- Optimization ID: `op-factual-child-handoff-2026-08-10`
- Owner: auto-oncall-services runner
- Source reference: Focus #606 post-acquisition replays for `APID-29265` and
  `APID-29232`
- Implementation status: merged and deployed to staging
- Effective status: `optimized_unverified`

## Bounded problem

The Wetech helper already returned compact provider results and the runner
materialized their artifacts, but the child handoff observation copied only a
generic statement such as “returned usable provider evidence.” The following
tool-free parent is prohibited from reading those artifacts, so facts such as
metric extrema, affected instance, record count, and TopSQL numeric rows were
unavailable to its judgment. The parent then spent later rounds asking for
information that had already been acquired.

This record owns only the factual OP handoff and the boundary for what counts
as a later refinement round. It does not change query-ID selection, provider
authentication, target resolution, the four-round maximum, Jira publication,
Judge semantics, attachment handling, required capabilities, or Focus
lifecycle.

## Candidate change

- Keep the provider compact report as the full bounded audit artifact.
- Add an allowlisted, at-most-1,000-character factual suffix to each handoff
  observation containing useful metric counts/extrema, selected series entity
  labels, and dashboard row numeric decision fields.
- Never copy raw SQL text, plan text, full digests, credentials, tokens, or
  arbitrary provider strings into the handoff.
- Use one batch's capacity of up to six queries for already-known supporting
  checks. Provider transport retry remains helper-owned inside that batch.
- Allow another round only for a genuinely new load-bearing question that can
  change the diagnosis; restating or summarizing facts already present in the
  handoff is not refinement.

## Verification evidence

Local contract tests verify that realistic metric and TopSQL compact results
reach the parent as decision facts while SQL, plan, digest, and unallowlisted
strings remain absent. The complete TypeScript test suite passes with 697
tests.

Staging deployed commit `d3db6e5a1d711006821b6410f06c41b8ce9d0955`
through [aisupport run 31353565480](https://github.com/tidbcloud/aisupport/actions/runs/31353565480)
and [app-delivery PR 76608](https://github.com/tidbcloud/app-delivery/pull/76608).
The live Deployment and optimizer CronJob both use that image. The Deployment
reported 1/1 updated, ready, and available replicas; the Pod was Ready with
zero restarts, and `/readyz` returned HTTP 200.

- Read-only `APID-29265` replay run
  `1fbfce6e-e715-44b8-8519-67268d17607f` completed in one Wetech round, down
  from the prior three rounds. Its five-query batch produced three factual
  observations containing metric counts, extrema, and instances. The parent
  directly used those facts, returned a valid terminal
  `required=false/question=null/stopCondition=null` object, and response
  generation completed with verified provider capability.
- Read-only `APID-29232` replay run
  `728b7831-50ab-4bc0-8d49-afd41fcea823` completed in two Wetech rounds, down
  from the prior three-round schema failure. Round one used one five-query
  batch and exposed the new load-bearing need for store-to-instance CPU and
  placement alignment. Round two used another five-query batch, after which
  the parent returned the valid terminal null refinement and response
  generation completed with verified provider capability.
- Both requests used `mode=read`; publication, database, evaluation, Feishu,
  and Jira writes were `not_requested`. No customer-visible or internal Jira
  comment was changed.

These runs verify the runtime factual handoff and terminal refinement behavior,
but the optimization remains `optimized_unverified` until the corrected drafts
are refreshed into the existing Jira internal comments and read back with
`public=false`.

## Unresolved gaps

- Jira internal-comment refresh and readback remain unresolved for both replay
  cases.
- A provider result that lacks every allowlisted decision field remains usable
  only through its compact artifact and may still require a genuinely changed
  query.
- This change does not guarantee a diagnosis or promote partial evidence to a
  causal conclusion.
- It does not alter Clinic handoff materialization; the observed failures and
  current implementation scope are OP/Wetech.

## Next validation action

With explicit Jira-write authorization, update each existing auto-oncall Jira
internal comment in place from its verified read-only replay draft, then read
back the exact comment ID and verify `public=false`. Do not rerun provider
analysis merely to regenerate the already verified bodies. Promote this
problem to `optimized_verified` only after both comment refreshes succeed.
