/** * Infrastructure-touch detection for IVTR Lead R2 (Validate phase). * * **Problem this solves (T9842):** * * The IVTR Lead spawn prompt previously instructed the Validate-phase agent to * run only the test files explicitly named in the task spec. When an * "implementation" change touched an infrastructure file — e.g. a transaction * primitive in `packages/core/src/store/sqlite-data-accessor.ts` — the Lead * verified targeted unit tests passed but missed cross-package regressions. * * **Precedent — T9814 R2 (2026-05-20):** * * T9814 swapped `BEGIN IMMEDIATE` for SAVEPOINTs inside `DataAccessor.transaction()` * to support nested transactions for `add-batch`. The targeted tests passed (6/6 * for add-batch, 34/34 for add, 9/9 for allocate). IVTR Lead R2 approved on the * targeted scope. CI then surfaced a regression in `agent-resolver.test.ts` * (`preferTier` failed) because the agent-resolver depended on `BEGIN IMMEDIATE` * outer-transaction semantics that SAVEPOINTs do not replicate verbatim. The * hotfix commit `baa996d2b` restored the outer-tx case. * * **Rule (this module):** * * When the Implement-phase evidence bundle includes `filesChanged` that match * any of the canonical infrastructure path patterns, the Lead's Validate-phase * prompt MUST instruct it to run the full per-package vitest suite for every * package whose source surface was touched — not the targeted tests alone. * * Infrastructure paths include: * - `packages/core/src/store/**` (DB chokepoint, transactions, migrations) * - `packages/core/src/orchestration/**` (spawn-prompt, dispatch resolution) * - `packages/core/src/dispatch/**` (typed-dispatch, domain handlers) * - `packages/contracts/src/**` (cross-package types — every consumer rebuilds) * - `packages/worktree/src/**` (worktree-create / git-shim integration) * - `packages/core/src/migration/**` (schema bootstrapping) * - any path containing `transaction` or `pragma` in its basename * * @task T9842 — IVTR Lead spawn prompt blast-radius test scope * @precedent T9814 — SAVEPOINT refactor broke agent-resolver.preferTier despite green targeted tests */ /** * Canonical infrastructure-path glob patterns. * * Each pattern is matched as a string-prefix test against forward-slashed paths * (no real glob engine needed for the current shape — every pattern is a * directory prefix or a substring match on `transaction`/`pragma`/`migration`). * * Order matters only for documentation: the matcher is a logical OR. * * @task T9842 */ export declare const INFRASTRUCTURE_PATH_PATTERNS: readonly string[]; /** * Substring patterns matched against a path's basename (case-insensitive). * * A file outside the directory-prefix patterns above is still considered an * infrastructure touch when its basename signals transactional / pragma / * migration semantics — these change shared invariants regardless of the * package they live in. * * @task T9842 */ export declare const INFRASTRUCTURE_BASENAME_SUBSTRINGS: readonly string[]; /** * Result of {@link detectInfrastructureTouch}. * * @task T9842 */ export interface InfrastructureTouchResult { /** True iff any file in the input matches an infrastructure pattern. */ affected: boolean; /** The subset of input paths that matched. Order preserved from input. */ matchedPaths: string[]; /** * Sorted unique list of package directory names (e.g. `core`, `contracts`, * `worktree`) that were touched. Useful for composing * `pnpm --filter @cleocode/ run test` commands. * * Returned in ascending alphabetical order for deterministic prompt rendering. */ packages: string[]; } /** * Detect whether any file in `filesChanged` lives on a CLEO infrastructure * code path that demands a full per-package test scope rather than targeted * tests alone. * * **Semantics:** * * - A path matches when its normalized form starts with one of the directory * patterns in {@link INFRASTRUCTURE_PATH_PATTERNS}, **or** when its basename * contains one of {@link INFRASTRUCTURE_BASENAME_SUBSTRINGS} as a substring. * - The match is case-insensitive and tolerant of `./` prefixes and Windows * backslashes. * - The `packages` field is sorted alphabetically with duplicates removed so * the prompt renders deterministically. * * **Used by:** {@link buildValidatePhaseInstruction} in `./ivtr-loop.ts`. * * @param filesChanged - Relative repo paths from the Implement-phase evidence * bundle (`ImplEvidenceSummary.filesChanged`). May be * empty or undefined-flat. * @returns Detection result. When `affected === false`, `matchedPaths` and * `packages` are empty arrays. * * @task T9842 * @example * ```ts * detectInfrastructureTouch([ * 'packages/core/src/store/sqlite-data-accessor.ts', * 'packages/cleo/src/cli/commands/show.ts', * ]); * // → { affected: true, * // matchedPaths: ['packages/core/src/store/sqlite-data-accessor.ts'], * // packages: ['core'] } * ``` */ export declare function detectInfrastructureTouch(filesChanged: readonly string[] | undefined | null): InfrastructureTouchResult; /** * Build the "Blast-Radius Test Scope" prompt section to be injected into the * Validate-phase Lead spawn prompt when an infrastructure touch is detected. * * The section instructs the Lead to run the FULL per-package vitest suite for * every touched package, citing the T9814 precedent. * * Returns an empty string when `result.affected === false`, so callers can * unconditionally append the output. * * @param result - Output of {@link detectInfrastructureTouch}. * @returns Markdown section (or empty string). * * @task T9842 */ export declare function buildBlastRadiusTestScopeSection(result: InfrastructureTouchResult): string; //# sourceMappingURL=infra-touch.d.ts.map