/** * Slice 2026-06-16-playwright-restart-loop — G1, G2, G4, G5, G6. * * `peaks qa run` — runs a peaks-qa slice for the active project. * * The slice is the user-facing surface for the QA gate family * (functional / security / browser E2E). The browser-E2E gate * specifically is what the restart-loop detector guards. The * detector is wired into the slice here: * * 1. We construct a `BrowserRestartDetector` (configurable via * `--max-browser-restarts` / `--no-restart-detector`). * 2. We construct a `BrowserEventLogger` that writes the * per-slice JSONL log to * `.peaks/_runtime//qa/browser-events.jsonl`. * 3. The slice entry exposes `runQaSlice` so tests can * feed a synthetic event log and assert the diagnostic. * * CLI surface (PRD G5 + AC4/AC5/AC6): * peaks qa run --project [--no-browser] [--max-browser-restarts N] * [--no-restart-detector] [--session-id ] [--json] * * `--no-browser` (G5) skips the browser E2E gate entirely. The * resulting gate list marks the browser gate as `status: skipped` * with reason `--no-browser`. This is a slice-level opt-out for * backend-only or already-covered-by-unit-tests work. */ import { Command } from 'commander'; import { type ProgramIO } from '../cli-helpers.js'; import { type BrowserEvent } from '../../services/qa/browser-restart-detector.js'; import type { MutReportJson } from '../../services/mut/types.js'; export type QaRunOptions = { project: string; browser?: boolean; restartDetector?: boolean; maxBrowserRestarts?: string; sessionId?: string; json?: boolean; mutation?: boolean; }; export type QaGateStatus = { readonly name: string; readonly status: 'passed' | 'skipped' | 'failed'; readonly reason?: string; /** * Plan 2 / Task 8 — when the gate consumes an artifact with a * deterministic signature, this field carries that signature for * downstream audit-trail consumers. Currently set only on the * `mutation` gate to MUT.sig (the `sha256` of mut-report.json). */ readonly mutSig?: string; }; export type QaRunResult = { readonly sessionId: string; readonly project: string; readonly browserEnabled: boolean; readonly gates: readonly QaGateStatus[]; readonly detectorTriggered: boolean; readonly diagnostic?: string; readonly subAgentPromptHint: string; /** * Plan 2 / Task 8 — MUT.sig when peaks-mut ran in this session. * Undefined when peaks-mut was not run (no mut-report.json) or * the user passed --no-mutation. */ readonly mutSig?: string; }; export declare const DEFAULT_MAX_BROWSER_RESTARTS = 3; export type RunQaSliceInput = { readonly project: string; readonly sessionId: string; readonly browserEnabled: boolean; readonly maxRestarts: number; readonly detectorEnabled: boolean; readonly events: readonly BrowserEvent[]; readonly mutationReport: MutReportJson | null; readonly mutationEnabled: boolean; }; export declare function runQaSlice(input: RunQaSliceInput): QaRunResult; /** * Commander 12.x sets `options.X = false` for `--no-X` (POSITIVE form), * not `options.noX = true`. Reads use the positive form; the default is * `true` and the boolean form is `false` only when the user passes `--no-X`. * * Exported for unit testing the parser contract in isolation from * the rest of the action handler. */ export declare function readQaRunOptions(options: QaRunOptions): { readonly browserEnabled: boolean; readonly detectorEnabled: boolean; readonly maxRestarts: number; readonly mutationEnabled: boolean; }; export declare function registerQaCommands(program: Command, io: ProgramIO): void;