# AI Triage v1 Implementation Effect

> Historical record: the repository GitHub Actions runner described by the v1
> design was removed when the persistent host-managed monitor replaced it.

## Delivered behavior

The controller now runs as a one-shot local or GitHub Actions command. It validates every selected task before side effects, dispatches the configured downstream workflow, polls the exact run and attempt, collects failed job evidence, applies the non-overridable scenario-step gate, optionally invokes OpenCode over ACP, routes an owner, sends Feishu status/triage messages, and writes redacted JSON and Markdown reports.

For scenario failures, reports and Feishu triage messages include the request method and URL, expected result, actual status and response, trace ID, AI analysis, evidence, owner, and recommendations when present in the log. Non-scenario, cancelled, and timed-out steps are forced to infrastructure classification.

Controller-level failures such as dispatch or poll errors also produce an infrastructure incident artifact before the exception is returned. Final triage artifacts are written before the final Feishu call and atomically rewritten with notification status afterward.

## Safety effect

- No EC2 operation was performed.
- No live downstream GitHub Actions run or Feishu message was triggered during development.
- The committed task is disabled and scheduled execution also requires `AI_TRIAGE_ENABLED=true`.
- Manual workflow runs default to dry-run.
- Workflow-dispatch input is passed through an environment variable rather than inserted into shell source.
- Secrets exist only on the live controller step and are removed from the ACP subprocess environment.
- GitHub job-log redirects use a second HTTPS request without the GitHub authorization header.
- Raw logs are bounded and never persisted or passed to ACP; extracted values are redacted across snake case, camel case, prefixed environment keys, URLs, headers, DSNs, SAS fields, and email addresses.

## Verification evidence

- `PYTHONPATH=ai_triage/src python3.11 -W error::ResourceWarning -m unittest discover -s ai_triage/tests -v`: 75 tests passed.
- `python3.11 -m compileall -q ai_triage/src ai_triage/tests`: passed.
- `python3.11 -m pip wheel --no-deps --no-build-isolation ./ai_triage`: passed.
- `PYTHONPATH=ai_triage/src python3.11 -m ai_triage validate --config ai_triage/config.example.toml`: passed.
- `PYTHONPATH=ai_triage/src python3.11 -m ai_triage run --config ai_triage/config.example.toml --schedule-key manual --dry-run`: passed and selected no tasks because the example is disabled.
- Secret-pattern and diff-whitespace scans: passed for the new implementation; only synthetic fixture markers and environment-reference names are expected.

## Repository state used

APITestGen was fetched read-only and its current commit matched `origin/main` at development start. The sibling `tidb-management-service` worktree had unrelated local changes and was two commits behind `origin/main`, so it was not mutated or reset. Relevant workflow definitions were compared read-only against the fetched upstream ref.

## Operator decisions still required

1. Set product/component, case, and infrastructure owners; decide whether product ownership needs per-component mapping.
2. Confirm providers, environments, regions, scenario YAML sets, and the six-hour example cadence.
3. Provision a dedicated `self-hosted`, `linux`, `x64`, `ai-triage` runner with OpenCode and non-interactive model authentication.
4. Choose least-privilege cross-repository GitHub authentication and configure all required secrets.
5. Decide whether normal Feishu group messages are enough; true topic replies and stable mentions need an application bot.
6. Rotate and remove credential-like defaults and hard-coded endpoints in the downstream workflow before production use.
7. Plan EC2 overlap prevention, cutover, rollback, and monitoring as a separate approved operation.

## Deferred engineering work

- Pi JSONL RPC adapter.
- Feishu application-bot topic/mention adapter.
- Persistent restart recovery and cross-run deduplication.
- Exact poll-deadline integration for long GitHub rate-limit sleeps.
- Automated downstream workflow contract validation.
