# Unified Live And Dryrun Analysis Contract Plan

## Current Design

- Dryrun uses the support-analysis contract:
  `replayContextMarkdown`, `commentDraftMarkdown`,
  `simulatedL1ReplyMarkdown`, `clarificationSimulation`, and `replayTarget`.
- Live uses a separate contract:
  `triageMarkdown`, `commentDraftMarkdown`, and `evidenceLinks`.
- The split lets live produce an English internal triage followed by a
  customer-language draft, because only `commentDraftMarkdown` reads the support
  reply skill.

## Risks

- Two prompt contracts drift in style, language, safety, and answer quality.
- Live output can stop looking like a simulated L1/oncall answer.
- Jira internal comments can mix internal analysis and customer-ready draft in a
  confusing order.

## Target Contract

- Codex uses one support-analysis output schema for both dryrun and live.
- `commentDraftMarkdown` always means the simulated L1/oncall Jira reply draft
  for human review.
- `replayContextMarkdown` is the internal reviewer context. In live mode it is
  current-state context, not historical final-state replay.
- Live keeps DB/API compatibility by mapping `replayContextMarkdown` into the
  existing `triageMarkdown` storage field.
- Live still writes only an internal Jira note. It never writes a
  customer-visible comment, transitions issues, or performs production actions.

## Implementation Steps

1. Make live workspaces write `input/replay-target.json` with
   `mode=no_prior_support_reply` and use the same result schema as dryrun.
2. Replace the separate live Codex schema/parser with the existing ticket-agent
   schema/parser and reply normalization flow.
3. Expand `LiveAnalysisResult` to carry the same support-analysis fields while
   retaining `triageMarkdown` for DB/API compatibility.
4. Render live Jira internal comments as support-analysis context plus simulated
   L1 reply draft, not as a separate triage/internal-note contract.
5. Update tests to enforce shared schema and live/dryrun contract alignment.

## Verification Checklist

- `npm run typecheck`
- `npm test`
- Live workspace test confirms `replay-target.json` and shared schema exist.
- Runner tests confirm live output contains `replayContextMarkdown` and
  `simulatedL1ReplyMarkdown`.
- Jira comment tests confirm live comments no longer use `Triage:` followed by
  `Internal note draft:`.
