# OP Diagnosis Unification Plan

## Current Design

- `wetech-op-diagnosis` owns diagnosis planning only for exact Wetech
  accounts and delegates transport to `wetech-op-grafana`.
- Exact Manus accounts are already normalized to `evidenceProvider=manus`, but
  the workspace prompt sends the agent directly to `manus-op-grafana`, so
  Manus does not share the diagnosis completeness, evidence-ordering, or stop
  contracts.
- The deterministic OP boundary allows exact Wetech and Manus accounts, while
  every other evidence-required OP case is marked with the historical
  `op_non_wetech` hard-stop flag.
- Dry-run and live support analysis use a 600000 ms main Codex timeout.
  Reply normalization has a separate 120000 ms timeout.

## Risks

- Keeping both `wetech-op-diagnosis` and `op-diagnosis` would create competing
  diagnosis sources of truth.
- Moving Manus transport instructions into the diagnosis skill would duplicate
  authentication and command contracts.
- Renaming the historical OP risk flag without read compatibility would
  misclassify stored gate details in reports and Base projections.
- Treating every non-Wetech account as unsupported would incorrectly block
  Manus; treating every named account as supported would bypass the evidence
  access boundary.
- Raising the normalization, classifier, or provider timeouts together with
  the main analysis timeout would change unrelated runtime contracts.

## Target Contract

### Skill ownership

- `op-diagnosis` is the only OP diagnosis-planning skill.
- Exact case-insensitive `Account Alias = Wetech` selects
  `wetech-op-grafana`.
- Exact case-insensitive `Account Alias = Manus` selects
  `manus-op-grafana` with its fixed `vida` target.
- `wetech-op-grafana` and `manus-op-grafana` remain transport-only skills and
  own credentials, endpoints, datasource selection, command syntax, and
  evidence persistence.
- The diagnosis skill never falls back between Wetech, Manus, Clinic, or
  Investibook.
- Remove `wetech-op-diagnosis`; do not keep an alias or duplicate wrapper.
- The startup installer removes the explicitly deprecated
  `$CODEX_HOME/skills/wetech-op-diagnosis` directory so a persistent skills PVC
  cannot keep the retired skill alive across image rollouts. Other installed
  skills remain untouched.

### OP gate

- The supported OP account set is exactly Wetech and Manus.
- Evidence-required OP cases outside that set are normalized to
  `human_required`, `evidenceProvider=none`, and the canonical
  `op_unsupported` risk flag before issue-allowlist handling.
- Pure Q&A and Cloud cases keep their existing exceptions.
- New runtime decisions emit only `op_unsupported`.
- Reports and Base may recognize legacy stored `op_non_wetech` as read-only
  compatibility; no classifier or gate emits the legacy flag.

### Timeout

- Main support-analysis timeout is 1200000 ms for dry-run, live initial, and
  continuation turns.
- Reply normalization remains 120000 ms.
- Classifier, report, Investibook, and customer-reply-validator timeouts do not
  change.
- Staging and prod deployment templates declare the same 1200000 ms main
  timeout.

## Invariants

- OP diagnosis and transports remain read-only.
- Account Alias from the canonical Jira snapshot selects the OP provider.
- Manus always uses target `vida`; Wetech still requires its exact cluster
  alias/datasource mapping.
- Unsupported OP accounts cannot be enabled by an issue allowlist.
- One OP diagnosis run selects exactly one transport.
- Provider failure does not trigger cross-provider fallback.
- A read path does not mutate Jira, provider state, or production resources.

## Implementation Steps

1. Move and rewrite `wetech-op-diagnosis` as provider-neutral
   `op-diagnosis`.
2. Update skill metadata, installer requirements, workspace prompts, and
   diagnosis contract tests.
3. Centralize supported OP account/provider selection in the deterministic
   policy and emit `op_unsupported` for other accounts.
4. Update notifications, reports, and Base categories while retaining legacy
   stored-flag read compatibility.
5. Raise only the main runner timeout default and deployment env to 1200000 ms.
6. Remove the explicitly deprecated persisted `wetech-op-diagnosis` directory
   during startup installation.
7. Run skill validation, transport tests, focused routing tests, typecheck, and
   the full Node test suite.

## Verification Checklist

- [x] `op-diagnosis` validates and contains both Wetech and Manus routing.
- [x] No active runtime/install/prompt reference to `wetech-op-diagnosis`
      remains.
- [x] A startup against a persistent Codex home removes
      `wetech-op-diagnosis` without deleting unrelated skills.
- [x] Wetech selects only `wetech-op-grafana`.
- [x] Manus selects only `manus-op-grafana` and target `vida`.
- [x] Other evidence-required OP accounts hard-stop with `op_unsupported`.
- [x] Issue allowlists cannot bypass the unsupported OP hard stop.
- [x] Legacy `op_non_wetech` stored rows still render as unsupported OP.
- [x] Main analysis timeout is 1200000 ms; normalization remains 120000 ms.
- [x] Staging and prod templates match the runtime timeout.
- [x] Full tests pass: Node 291/291; Manus transport 8/8.

## Not Doing

- Do not merge the Wetech or Manus transport scripts into `op-diagnosis`.
- Do not add another OP account or generic Grafana fallback.
- Do not change evidence-provider enum values (`wetech` and `manus` remain
  distinct).
- Do not change customer-visible reply enablement.
- Do not deploy, merge, or activate production automation in this task.
