import type { Spec } from "@slowcook-ai/core"; /** * 0.11.16+ — bounded-attention spec slicing. * * Brew's per-iter prompt today embeds the entire spec body. For a story * with 12 invariants and 8 acceptance scenarios, that's ~2-4KB of * context the agent must consider when working on a single target test. * Most of it is irrelevant to the iteration's specific scope. * * This slicer derives a focused projection of the spec for a given * target test by keyword-matching identifiers extracted from the * test's title chain. Conservative: when the heuristic produces too * narrow a slice, falls back to the full spec rather than starve the * agent of context. * * Future (0.12.0+): testgen will tag each emitted test with its * `invariant_id`, and we'll resolve via that explicit mapping instead * of string matching. This 0.11.16 implementation is the heuristic * fallback that ships first. */ export interface SpecSlice { invariants: string[]; acceptance_scenarios: string[]; non_goals: string[]; /** True when the slicer fell back to the full spec (heuristic too weak). */ fellBack: boolean; /** For iter-log telemetry. */ ratio: { invariants: { kept: number; total: number; }; scenarios: { kept: number; total: number; }; }; } /** * Extract identifiers from a target test id like * `tests/integration/story-007-ui.test.tsx > BookmarksPage > clicking Save calls /api/bookmarks`. * * Returns a lowercased, deduped set of identifier-shaped tokens * (function names, route paths, common nouns). Filters stop-words. * * The set is what we'll grep invariants and scenarios against. */ export declare function extractIdentifiersFromTargetTest(targetTestId: string): Set; /** * Produce a focused slice of the spec for the given target test. * * Algorithm (0.11.17+ — top-K ranked): * * 1. Score each invariant + scenario by token overlap with identifiers * extracted from the target test name. * 2. Sort by score descending. * 3. Keep top `keepInvariants` invariants and top `keepScenarios` * scenarios (each defaulting to a small fixed number, NOT * "everything with score > 0"). On focused stories where every * invariant shares common terms, score>0 is almost always true, * and slicing fails to narrow — top-K forces aggressive narrowing. * 4. Drop entries with score=0 even if they'd fit in the top-K * (no relevance ≠ low relevance — exclude entirely). * 5. When fewer than `minKept` invariants have score > 0 AND there * are more invariants total than we kept, return the FULL spec * as a safety fallback (the agent doesn't have enough relevant * context to work from). * * Validated 2026-04-25 on rewo's story-007 manifest: prior `score > 0` * algorithm produced ~97% retention (effectively no slicing) and 50% * fallback rate. Top-K with K=5 reduces retention to ~45% on the * same data while keeping the most-relevant invariants surfaced. */ export declare function sliceSpecForTarget(spec: Spec, targetTestId: string, options?: { /** Minimum kept invariants before falling back to full spec. */ minKept?: number; /** How many top-scored invariants to keep. Default 5. */ keepInvariants?: number; /** How many top-scored scenarios to keep. Default 4. */ keepScenarios?: number; }): SpecSlice; /** * Render a slice as YAML-shaped prose for the brew prompt's "spec" block. * Mirrors the keys of a real spec but only emits non-empty arrays. */ export declare function renderSpecSlice(slice: SpecSlice, fullSpec: Spec): string; //# sourceMappingURL=spec-slice.d.ts.map