# Auto Analysis Q&A Gate Plan

## Current Design

- `src/auto-config.ts` owns automatic poll configuration and builds the Jira JQL.
- `src/auto-analysis.ts` polls Jira, converts each issue to `SupportCase`, and enqueues an initial job.
- `src/auto-store.ts` is the canonical job/run persistence layer.
- Jira issue snapshots are normalized by `src/jira.ts`; `SupportCase.raw` keeps the original fields for gate-only metadata.

## Risks

- Polling all active Support tickets can enqueue non-Q&A tickets before the live worker has enough safety gates.
- The existing Jira issue allowlist is useful for staging smoke tests, but it must not become a broad Q&A classifier.
- Jira Request Type field shape can vary, so matching must be exact and explicitly configured.

## Target Contract

- A Jira issue may be enqueued only after passing a deterministic Q&A gate.
- The Q&A gate allows only explicit signals:
  - configured Jira Request Type name;
  - configured Jira label;
  - configured Jira issue type;
  - configured Q&A issue allowlist;
  - existing Jira poll issue allowlist for per-ticket smoke only.
- If no Q&A gate signal is configured and the issue is not explicitly allowlisted, the poller skips it.
- The read/worker path does not classify Q&A and does not modify jobs for gate cleanup.

## Implementation Steps

1. Add Q&A gate config parsing and exact-match normalization.
2. Add a deterministic gate evaluator over `SupportCase`.
3. Apply the evaluator immediately before `enqueueInitialJob`.
4. Add unit tests for config parsing, allowlist smoke behavior, request type/label/issue type matching, and poll skip behavior.
5. Document the new environment variables.

## Verification Checklist

- `npm test` passes.
- A non-Q&A issue from poll search is not enqueued.
- An explicitly allowlisted issue still supports smoke tests.
- The existing poll JQL contract remains unchanged except for optional allowlist narrowing.
