/** * Slice 2026-06-13-peaks-workflow-skip — `peaks workflow skip` service. * * Pure-function classifier (`canSkipSlice`) + side-effecting applicator * (`applySkip`). Both are testable without filesystem mocks (the * applicator accepts an injected `readSkipState` / `writeSkipState` * pair so the unit tests use in-memory fakes; the production caller * passes the real store from `workflow-state-store.ts`). * * Three rules (per RD §Why + Tech Doc §2-4): * - Rule 1 (slice type allowlist): `bugfix` / `feature` / `refactor` * can never skip QA, regardless of `--reason`. The allowlist is * `['docs', 'config', 'chore']`. * - Rule 2 (one-time semantics): if a skip-marker already exists for * this rid AND the requested skip is the same → idempotent * no-op (`applied: false, idempotent: true`). If different → deny * with `reason: "rid already has a different skip applied"`. * - Rule 3 (role-based authorization): scripts (caller kind derived * from `$PEAKS_CALLER_ID` env var) MUST pass `--i-have-reviewed` * in addition to `--reason`. */ import { type WorkflowSkipState } from './workflow-state-store.js'; import type { RequestType } from '../artifacts/artifact-prerequisites.js'; export type SkipArgs = { /** Request id this skip applies to. */ rid: string; /** Comma-separated gate names from the CLI; parsed to string[]. */ gatesRaw: string; /** Required, free-text justification. */ reason: string; /** Optional. When set, the apply is previewed but no state is written. */ dryRun?: boolean; /** Required for script callers (see Rule 3). */ iHaveReviewed?: boolean; /** Caller kind, derived from $PEAKS_CALLER_ID by the CLI. When omitted, * defaults to 'human' (the CLI's normal terminal path). */ callerKind?: 'human' | 'llm' | 'script'; }; export type CanSkipVerdict = { allowed: true; reason: null; sliceType: RequestType; callerKind: 'human' | 'llm' | 'script'; } | { allowed: false; reason: string; sliceType?: RequestType; }; export type ApplySkipResult = { applied: true; idempotent: false; skippedGates: string[]; rid: string; persistedTo: string; sliceType: RequestType; } | { applied: false; idempotent: true; skippedGates: string[]; rid: string; persistedTo: string | null; sliceType: RequestType; } | { applied: false; idempotent: false; skippedGates: string[]; rid: string; persistedTo: string | null; sliceType?: RequestType; reason: string; }; /** Parse the `--gates` CLI arg (e.g. "QA,slice-check") into string[]. */ export declare function parseGatesList(raw: string): string[]; /** * Determine the caller kind for Rule 3. CLI passes * `args.callerKind` directly when the user invoked the command * interactively; for script callers (CI / postinstall) the CLI * inspects `$PEAKS_CALLER_ID` and passes 'script'. */ export declare function detectCallerKind(envCallerId: string | undefined): 'human' | 'llm' | 'script'; /** * Pure three-rule classifier. Does NOT touch the filesystem; the * `currentState` argument is the result of a prior `readSkipState` * call (or null if no state file exists). The slice type is * read from the RD request artifact via `showRequestArtifact`. * * Returns a verdict; the caller is expected to either apply or * surface the rejection reason. Reasons are user-readable English * suitable for the `nextActions` envelope. */ export declare function canSkipSlice(projectRoot: string, sessionId: string, args: SkipArgs, currentState: WorkflowSkipState | null): Promise; /** * Apply a skip. Caller is expected to have already called * `canSkipSlice` and received `allowed: true`. The function is * still defensive — if the verdict is `allowed: false`, it returns * the rejection as `applied: false` without writing. */ export declare function applySkip(projectRoot: string, sessionId: string, args: SkipArgs): Promise; declare function sameStringSet(a: readonly string[], b: readonly string[]): boolean; /** Exposed for tests. */ export declare const _internal: { SKIPPABLE_TYPES: readonly RequestType[]; SCRIPT_CALLER_IDS: readonly string[]; sameStringSet: typeof sameStringSet; }; export {};