# Direct Evidence Closure And Optimizer Attribution

## Current Design

- The attachment contract requires the agent to read complete execution plans,
  but the Wetech capability contract can still trigger external diagnostics
  whenever a SQL digest or time window is visible.
- Reply guidance asks for the smallest missing context, but does not distinguish
  information required to answer the current question from information useful
  only for optional follow-up investigation.
- Optimizer answers are required to be useful, but there is no explicit
  boundary between observed plan facts and an inferred reason for a Join choice.

## Risks

- A case already closed by direct execution-plan evidence can end with an
  unnecessary cluster-alias request and appear unresolved.
- External diagnostics used only to corroborate conclusive attachment evidence
  add latency and token cost without improving the answer.
- Explaining why the optimizer selected a Join from runtime timing alone can
  overstate what the plan proves.

## Target Contract

- Direct customer evidence that answers the current question is sufficient to
  close the initial reply; external diagnostics and routing metadata are not
  required merely to corroborate it.
- Optional deeper investigation may be offered without adding the metadata to
  `requestedContext` or phrasing it as a prerequisite.
- Join answers separate observed facts (access paths, rows, build/probe time,
  spill) from optimizer-choice attribution. If the supplied evidence does not
  prove the complete choice reason, the draft says so explicitly.

## Implementation Steps

1. Add the direct-evidence sufficiency rule to the attachment and diagnostic
   capability prompt contracts.
2. Add optimizer attribution guidance to the Jira reply skill.
3. Add prompt-contract assertions and run local typecheck/full tests.

## Verification Checklist

- [x] A complete plan that closes the current question does not require a
      cluster alias or external metric lookup for corroboration.
- [x] Optional follow-up metadata is not added to `requestedContext`.
- [x] Join guidance distinguishes observed non-bottleneck evidence from the
      unproven complete optimizer-choice reason.
- [x] Typecheck and full tests pass.

## Non-Goals

- Do not disable Clinic or Wetech diagnostics when direct evidence is missing,
  stale, inconclusive, or the customer explicitly requests deeper validation.
- Do not change attachment handling, coverage gates, Jira writes, models,
  deployment, or production automation.
