spana-test 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/spana-testing/SKILL.md +122 -246
- package/README.md +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +5 -5
- package/dist/{storybook-CxaP3YDz.d.ts → app-DcLXtpv4.d.ts} +205 -9
- package/dist/{chunk-3YE2POGD.js → chunk-3SH5JQF7.js} +143 -3
- package/dist/chunk-3SH5JQF7.js.map +1 -0
- package/dist/chunk-4K3FZTSV.js +179 -0
- package/dist/chunk-4K3FZTSV.js.map +1 -0
- package/dist/{chunk-H3RWZCID.js → chunk-C4E4XULT.js} +104 -3
- package/dist/chunk-C4E4XULT.js.map +1 -0
- package/dist/{chunk-SQL3YRR5.js → chunk-KBRLIQRA.js} +16 -1
- package/dist/chunk-KBRLIQRA.js.map +1 -0
- package/dist/{chunk-LRGT342X.js → chunk-KEUZLBQS.js} +1110 -475
- package/dist/chunk-KEUZLBQS.js.map +1 -0
- package/dist/{chunk-XENRC3YO.js → chunk-LCV673G3.js} +605 -41
- package/dist/chunk-LCV673G3.js.map +1 -0
- package/dist/{chunk-3TRMQCUT.js → chunk-PLE7RFQE.js} +31 -2
- package/dist/chunk-PLE7RFQE.js.map +1 -0
- package/dist/{chunk-PJKIXVSO.js → chunk-PWUJT5HE.js} +898 -238
- package/dist/chunk-PWUJT5HE.js.map +1 -0
- package/dist/{chunk-WSA5QPTA.js → chunk-S4JVAHBR.js} +2 -2
- package/dist/{chunk-UJQ7PID5.js → chunk-WBBMEAHU.js} +78 -3
- package/dist/chunk-WBBMEAHU.js.map +1 -0
- package/dist/{chunk-5245YBLL.js → chunk-Y2RZNOKU.js} +2 -2
- package/dist/cli.js +11 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-J4Z2PMUQ.js +9 -0
- package/dist/{doctor-command-WB3O2H64.js → doctor-command-WEHFANT7.js} +3 -3
- package/dist/{filters-Q3ALKWZ5.js → filters-MQG2RMPX.js} +4 -2
- package/dist/flow-C2JQ7gUu.d.ts +95 -0
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/index.d.ts +214 -20
- package/dist/index.js +173 -6
- package/dist/index.js.map +1 -1
- package/dist/{runner-6HK62Q7B.js → runner-TF4OKPYP.js} +2 -2
- package/dist/{screenshot-compare-3QRHHSFZ.js → screenshot-compare-5NINZVOK.js} +21 -1
- package/dist/screenshot-compare-5NINZVOK.js.map +1 -0
- package/dist/{server-QWJJB3WG.js → server-3MGZNK67.js} +2 -2
- package/dist/{server-PRM7BVVD.js → server-OANRDAHN.js} +5 -5
- package/dist/{session-Ddem-Q5n.d.ts → session-Daq0mE_a.d.ts} +22 -1
- package/dist/{session-2E6OK6BH.js → session-Q3QYHT4Q.js} +4 -4
- package/dist/{studio-command-O3NN5BCG.js → studio-command-RJYLJT4I.js} +2 -2
- package/dist/{test-command-FYOZ6QAE.js → test-command-ALH5ZQY5.js} +23 -9
- package/dist/test-command-ALH5ZQY5.js.map +1 -0
- package/dist/{validator-HZ2A3NEI.js → validator-BLOLIHUY.js} +3 -3
- package/package.json +2 -2
- package/dist/chunk-3TRMQCUT.js.map +0 -1
- package/dist/chunk-3YE2POGD.js.map +0 -1
- package/dist/chunk-H3RWZCID.js.map +0 -1
- package/dist/chunk-LRGT342X.js.map +0 -1
- package/dist/chunk-PJKIXVSO.js.map +0 -1
- package/dist/chunk-SQL3YRR5.js.map +0 -1
- package/dist/chunk-UJQ7PID5.js.map +0 -1
- package/dist/chunk-XENRC3YO.js.map +0 -1
- package/dist/config-loader-XGDDJGVY.js +0 -9
- package/dist/flow-CyRC-tTc.d.ts +0 -176
- package/dist/screenshot-compare-3QRHHSFZ.js.map +0 -1
- package/dist/test-command-FYOZ6QAE.js.map +0 -1
- /package/dist/{chunk-WSA5QPTA.js.map → chunk-S4JVAHBR.js.map} +0 -0
- /package/dist/{chunk-5245YBLL.js.map → chunk-Y2RZNOKU.js.map} +0 -0
- /package/dist/{config-loader-XGDDJGVY.js.map → config-loader-J4Z2PMUQ.js.map} +0 -0
- /package/dist/{doctor-command-WB3O2H64.js.map → doctor-command-WEHFANT7.js.map} +0 -0
- /package/dist/{filters-Q3ALKWZ5.js.map → filters-MQG2RMPX.js.map} +0 -0
- /package/dist/{runner-6HK62Q7B.js.map → runner-TF4OKPYP.js.map} +0 -0
- /package/dist/{server-QWJJB3WG.js.map → server-3MGZNK67.js.map} +0 -0
- /package/dist/{server-PRM7BVVD.js.map → server-OANRDAHN.js.map} +0 -0
- /package/dist/{session-2E6OK6BH.js.map → session-Q3QYHT4Q.js.map} +0 -0
- /package/dist/{studio-command-O3NN5BCG.js.map → studio-command-RJYLJT4I.js.map} +0 -0
- /package/dist/{validator-HZ2A3NEI.js.map → validator-BLOLIHUY.js.map} +0 -0
|
@@ -118,12 +118,46 @@ interface DomIdleOptions {
|
|
|
118
118
|
interface DomWaitForSelectorOptions {
|
|
119
119
|
/** Max time to wait in ms. Default: 5000. */
|
|
120
120
|
timeoutMs?: number;
|
|
121
|
-
/** Require the matched element to be visible
|
|
121
|
+
/** Require the matched element to be visible, enabled, unobstructed, and stable for pointer actions. */
|
|
122
122
|
forAction?: boolean;
|
|
123
123
|
/** Fail early once the DOM stays quiet and document.readyState === "complete". */
|
|
124
124
|
failFastWhenIdle?: boolean;
|
|
125
125
|
/** Quiet window in ms before failFastWhenIdle resolves empty. Default: 250. */
|
|
126
126
|
idleQuietMs?: number;
|
|
127
|
+
/** Consecutive requestAnimationFrame frames the bounding box must remain stable (≤ 1px) when `forAction: true`. Default: 2 (0 when instantAnimations active). */
|
|
128
|
+
stableFrames?: number;
|
|
129
|
+
/** Verify center point via deep `elementFromPoint` (piercing Shadow DOM & iframes) when `forAction: true`. Default: true. */
|
|
130
|
+
checkHitTest?: boolean;
|
|
131
|
+
/** Respect app-owned `window.__SPANA_APP_READY__` signal when defined. Default: true. */
|
|
132
|
+
waitForAppReady?: boolean;
|
|
133
|
+
}
|
|
134
|
+
interface DomWaitForHiddenOptions {
|
|
135
|
+
/** Max time to wait in ms. Default: 5000. */
|
|
136
|
+
timeoutMs?: number;
|
|
137
|
+
}
|
|
138
|
+
interface DomWaitForMatchOptions {
|
|
139
|
+
/** Max time to wait in ms. Default: 5000. */
|
|
140
|
+
timeoutMs?: number;
|
|
141
|
+
/** Assertion kind evaluated reactively inside the page via MutationObserver. */
|
|
142
|
+
kind: "text" | "containsText" | "matchesText" | "value" | "attribute" | "accessibilityLabel";
|
|
143
|
+
/** Expected value/substring (optional when `kind === "attribute"` or `"accessibilityLabel"` checks presence). */
|
|
144
|
+
expected?: string;
|
|
145
|
+
/** Attribute name when `kind === "attribute"`. */
|
|
146
|
+
attributeName?: string;
|
|
147
|
+
/** RegExp source when `kind === "matchesText"`. */
|
|
148
|
+
patternSource?: string;
|
|
149
|
+
/** RegExp flags when `kind === "matchesText"`. */
|
|
150
|
+
patternFlags?: string;
|
|
151
|
+
}
|
|
152
|
+
interface DomFillOptions {
|
|
153
|
+
/** Max time to wait for an editable actionable target in ms. Default: 5000. */
|
|
154
|
+
timeoutMs?: number;
|
|
155
|
+
/** Verify center point via deep `elementFromPoint` before filling. Default: true. */
|
|
156
|
+
checkHitTest?: boolean;
|
|
157
|
+
}
|
|
158
|
+
interface DomWaitForMatchResult {
|
|
159
|
+
matched: boolean;
|
|
160
|
+
actual?: string;
|
|
127
161
|
}
|
|
128
162
|
interface DomStorageEntries {
|
|
129
163
|
localStorage?: Record<string, string>;
|
|
@@ -163,8 +197,14 @@ interface DomChannel {
|
|
|
163
197
|
disconnect(): Promise<void>;
|
|
164
198
|
evaluate<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
165
199
|
query(selector: Selector): Promise<DomElementMatch[]>;
|
|
166
|
-
/** MutationObserver-reactive DOM wait: resolves immediately when a matching visible element mounts. */
|
|
200
|
+
/** MutationObserver-reactive DOM wait: resolves immediately when a matching visible element mounts & is actionable. */
|
|
167
201
|
waitForSelector?(selector: Selector, opts?: DomWaitForSelectorOptions): Promise<DomElementMatch[]>;
|
|
202
|
+
/** MutationObserver-reactive wait until no matching visible element remains. */
|
|
203
|
+
waitForHidden?(selector: Selector, opts?: DomWaitForHiddenOptions): Promise<boolean>;
|
|
204
|
+
/** MutationObserver-reactive wait until text/value/attribute matches (zero runner-side polling). */
|
|
205
|
+
waitForMatch?(selector: Selector, opts: DomWaitForMatchOptions): Promise<DomWaitForMatchResult>;
|
|
206
|
+
/** Atomic 1-round-trip actionability wait + focus + React/Vue-safe value fill + input/change dispatch. */
|
|
207
|
+
fillDom?(selector: Selector, value: string, opts?: DomFillOptions): Promise<boolean>;
|
|
168
208
|
tapDom(selector: Selector): Promise<boolean>;
|
|
169
209
|
/** Scroll a DOM element into the viewport center and return its updated bounding rect. */
|
|
170
210
|
scrollIntoView?(selector: Selector): Promise<DomElementMatch | null>;
|
|
@@ -182,12 +222,35 @@ interface DomChannel {
|
|
|
182
222
|
selectTarget?(targetId: string): Promise<void>;
|
|
183
223
|
}
|
|
184
224
|
/**
|
|
185
|
-
* Self-contained MutationObserver-reactive DOM wait script
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
225
|
+
* Self-contained MutationObserver-reactive DOM wait script with full single-round-trip
|
|
226
|
+
* Playwright-grade actionability checks when `forAction: true`:
|
|
227
|
+
* 1. App-ready signal (`window.__SPANA_APP_READY__`) when defined.
|
|
228
|
+
* 2. Visible + enabled match (piercing open Shadow DOM & same-origin iframes).
|
|
229
|
+
* 3. Auto-scroll offscreen targets into viewport (`scrollIntoView({ behavior: "instant" })`).
|
|
230
|
+
* 4. Deep `elementFromPoint` hit-test verifying no overlay/backdrop/modal obscures the target.
|
|
231
|
+
* 5. 2-rAF bounding-box stability check (≤ 1px movement; bypassed when `stableFrames === 0` or
|
|
232
|
+
* `instantAnimations` style is active).
|
|
233
|
+
* Retries seamlessly inside the page via `MutationObserver` + `rAF` in ONE single round trip!
|
|
189
234
|
*/
|
|
190
235
|
declare function buildDomWaitForSelectorScript(selector: Selector, opts?: DomWaitForSelectorOptions): string;
|
|
236
|
+
/**
|
|
237
|
+
* Self-contained MutationObserver-reactive script that resolves `true` as soon as
|
|
238
|
+
* no visible matching element exists in the DOM (zero runner-side polling).
|
|
239
|
+
*/
|
|
240
|
+
declare function buildDomWaitForHiddenScript(selector: Selector, opts?: DomWaitForHiddenOptions): string;
|
|
241
|
+
/**
|
|
242
|
+
* Self-contained MutationObserver-reactive assertion wait script for text,
|
|
243
|
+
* substring text, input value, and DOM attribute assertions — runs completely
|
|
244
|
+
* in-page with zero runner-side polling ticks.
|
|
245
|
+
*/
|
|
246
|
+
declare function buildDomWaitForMatchScript(selector: Selector, opts: DomWaitForMatchOptions): string;
|
|
247
|
+
/**
|
|
248
|
+
* Atomic 1-round-trip in-page fill script: waits for an editable target to be visible,
|
|
249
|
+
* enabled, in-viewport, and unobstructed, then focuses it, sets the value via the native
|
|
250
|
+
* HTMLInputElement/HTMLTextAreaElement prototype setter (React/Vue/Svelte compatible),
|
|
251
|
+
* and dispatches `input` + `change` events.
|
|
252
|
+
*/
|
|
253
|
+
declare function buildDomFillScript(selector: Selector, value: string, opts?: DomFillOptions): string;
|
|
191
254
|
|
|
192
255
|
type RawHierarchy = string;
|
|
193
256
|
/**
|
|
@@ -330,6 +393,27 @@ interface TouchSequence {
|
|
|
330
393
|
id: number;
|
|
331
394
|
actions: TouchAction[];
|
|
332
395
|
}
|
|
396
|
+
interface VirtualAuthenticatorOptions {
|
|
397
|
+
/** WebAuthn protocol. Default: "ctap2". */
|
|
398
|
+
protocol?: "ctap2" | "u2f";
|
|
399
|
+
/** Authenticator transport. Default: "internal" (platform passkey). */
|
|
400
|
+
transport?: "usb" | "nfc" | "ble" | "cable" | "internal";
|
|
401
|
+
/** Support discoverable resident keys (passkeys). Default: true. */
|
|
402
|
+
hasResidentKey?: boolean;
|
|
403
|
+
/** Support user verification (Touch ID / Face ID / PIN). Default: true. */
|
|
404
|
+
hasUserVerification?: boolean;
|
|
405
|
+
/** Automatically pass user verification. Default: true. */
|
|
406
|
+
isUserVerified?: boolean;
|
|
407
|
+
/** Automatically simulate user presence on prompts. Default: true. */
|
|
408
|
+
automaticPresenceSimulation?: boolean;
|
|
409
|
+
}
|
|
410
|
+
interface VirtualCredential {
|
|
411
|
+
credentialId: string;
|
|
412
|
+
isResidentCredential: boolean;
|
|
413
|
+
rpId?: string;
|
|
414
|
+
userHandle?: string;
|
|
415
|
+
signCount: number;
|
|
416
|
+
}
|
|
333
417
|
interface RawDriverService<_T extends string = string, R extends string = string> {
|
|
334
418
|
readonly beginFlow?: (flowName: string) => Effect.Effect<void, DriverError>;
|
|
335
419
|
readonly getDriverLogs?: () => Effect.Effect<string[], DriverError>;
|
|
@@ -352,7 +436,7 @@ interface RawDriverService<_T extends string = string, R extends string = string
|
|
|
352
436
|
readonly clearAppState: (bundleId: string) => Effect.Effect<void, DriverError>;
|
|
353
437
|
readonly openLink: (url: string) => Effect.Effect<void, DriverError>;
|
|
354
438
|
readonly back: () => Effect.Effect<void, DriverError>;
|
|
355
|
-
readonly evaluate: <T = unknown>(script: string | ((...args:
|
|
439
|
+
readonly evaluate: <T = unknown>(script: string | ((...args: any[]) => T), ...args: unknown[]) => Effect.Effect<T, DriverError>;
|
|
356
440
|
readonly getContexts?: () => Effect.Effect<string[], DriverError>;
|
|
357
441
|
readonly getCurrentContext?: () => Effect.Effect<string, DriverError>;
|
|
358
442
|
readonly setContext?: (contextId: string) => Effect.Effect<void, DriverError>;
|
|
@@ -376,6 +460,11 @@ interface RawDriverService<_T extends string = string, R extends string = string
|
|
|
376
460
|
readonly getConsoleLogs?: () => Effect.Effect<BrowserConsoleLog[], DriverError>;
|
|
377
461
|
readonly getJSErrors?: () => Effect.Effect<BrowserJSError[], DriverError>;
|
|
378
462
|
readonly getHAR?: () => Effect.Effect<BrowserHAR, DriverError>;
|
|
463
|
+
readonly getRawPage?: () => unknown;
|
|
464
|
+
readonly enableVirtualAuthenticator?: (opts?: VirtualAuthenticatorOptions) => Effect.Effect<string, DriverError>;
|
|
465
|
+
readonly removeVirtualAuthenticator?: (authenticatorId?: string) => Effect.Effect<void, DriverError>;
|
|
466
|
+
readonly getVirtualCredentials?: (authenticatorId?: string) => Effect.Effect<VirtualCredential[], DriverError>;
|
|
467
|
+
readonly clearVirtualCredentials?: (authenticatorId?: string) => Effect.Effect<void, DriverError>;
|
|
379
468
|
}
|
|
380
469
|
|
|
381
470
|
interface IOSSigningConfig {
|
|
@@ -481,10 +570,16 @@ interface StorybookConfig {
|
|
|
481
570
|
}
|
|
482
571
|
interface WebExecutionConfig {
|
|
483
572
|
browser?: BrowserName;
|
|
484
|
-
/** Browser engine backend: "playwright" (default), "cdp" (CDP
|
|
573
|
+
/** Browser engine backend: "playwright" (default), "cdp" (direct CDP WebSocket — zero Playwright pipe), or "lightpanda". */
|
|
485
574
|
engine?: WebBrowserEngine;
|
|
486
575
|
/** Connect to an existing CDP browser / Lightpanda endpoint (e.g. "http://127.0.0.1:9222"). */
|
|
487
576
|
cdpUrl?: string;
|
|
577
|
+
/** Connect to a remote Playwright server WebSocket (e.g. BrowserStack Automate Web `wss://cdp.browserstack.com/playwright?...`). */
|
|
578
|
+
wsEndpoint?: string;
|
|
579
|
+
/** Explicit browser executable path (e.g. system Chrome or custom Chromium binary). */
|
|
580
|
+
executablePath?: string;
|
|
581
|
+
/** Browser release channel (e.g. "chrome", "chrome-beta", "msedge"). */
|
|
582
|
+
channel?: string;
|
|
488
583
|
headless?: boolean;
|
|
489
584
|
/** Navigation readiness event for launchApp/openLink (default: "load"). */
|
|
490
585
|
waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
|
|
@@ -494,6 +589,14 @@ interface WebExecutionConfig {
|
|
|
494
589
|
blockResources?: WebResourceBlockType[];
|
|
495
590
|
/** Reuse a persistent warm Chromium daemon across runs via CDP (chromium only). */
|
|
496
591
|
warmBrowser?: boolean;
|
|
592
|
+
/** Scope key for isolating warm Chromium daemons across concurrent repos/runs (defaults to cwd hash). */
|
|
593
|
+
warmBrowserScope?: string;
|
|
594
|
+
/** Create a fresh isolated BrowserContext per flow using pre-warmed context pooling + background teardown. */
|
|
595
|
+
freshContextPerFlow?: boolean;
|
|
596
|
+
/** Max worker contexts sharing one Chromium browser process under `--parallel` (default: 2 to avoid CDP/IO contention). */
|
|
597
|
+
maxContextsPerBrowser?: number;
|
|
598
|
+
/** Automatically attach a CDP WebAuthn virtual authenticator (passkey) to every fresh context. */
|
|
599
|
+
virtualAuthenticator?: boolean | VirtualAuthenticatorOptions;
|
|
497
600
|
/** Optional Playwright storage state JSON file to preload for web runs */
|
|
498
601
|
storageState?: string;
|
|
499
602
|
/** Print verbose Playwright runtime events to stdout for local web debugging */
|
|
@@ -709,4 +812,97 @@ interface StorybookOpenOptions {
|
|
|
709
812
|
globals?: Record<string, StorybookValue>;
|
|
710
813
|
}
|
|
711
814
|
|
|
712
|
-
|
|
815
|
+
interface PromiseApp<T extends string = string, R extends string = string> {
|
|
816
|
+
tap(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
817
|
+
tapXY(x: number, y: number): Promise<void>;
|
|
818
|
+
doubleTap(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
819
|
+
longPress(selector: ExtendedSelector<T>, opts?: {
|
|
820
|
+
duration?: number;
|
|
821
|
+
} & WaitOptions): Promise<void>;
|
|
822
|
+
longPressXY(x: number, y: number, opts?: {
|
|
823
|
+
duration?: number;
|
|
824
|
+
}): Promise<void>;
|
|
825
|
+
inputText(text: string): Promise<void>;
|
|
826
|
+
/** Atomic 1-round-trip form fill: waits for actionability, focuses, replaces value, and dispatches input/change. */
|
|
827
|
+
fill(selector: ExtendedSelector<T>, value: string, opts?: WaitOptions): Promise<void>;
|
|
828
|
+
pressKey(key: string): Promise<void>;
|
|
829
|
+
hideKeyboard(): Promise<void>;
|
|
830
|
+
dismissKeyboard(opts?: DismissKeyboardOptions): Promise<void>;
|
|
831
|
+
swipe(direction: Direction, opts?: {
|
|
832
|
+
duration?: number;
|
|
833
|
+
}): Promise<void>;
|
|
834
|
+
scroll(direction: Direction): Promise<void>;
|
|
835
|
+
scrollUntilVisible(selector: ExtendedSelector<T>, opts?: ScrollUntilVisibleOptions<T>): Promise<void>;
|
|
836
|
+
backUntilVisible(selector: ExtendedSelector<T>, opts?: BackUntilVisibleOptions<T>): Promise<void>;
|
|
837
|
+
launch(opts?: LaunchOptions<R>): Promise<void>;
|
|
838
|
+
stop(): Promise<void>;
|
|
839
|
+
kill(): Promise<void>;
|
|
840
|
+
clearState(): Promise<void>;
|
|
841
|
+
openLink(url: R): Promise<void>;
|
|
842
|
+
openStory(storyId: string, opts?: StorybookOpenOptions): Promise<void>;
|
|
843
|
+
back(): Promise<void>;
|
|
844
|
+
takeScreenshot(name?: string): Promise<Uint8Array>;
|
|
845
|
+
evaluate<Result = unknown>(fn: ((...args: any[]) => Result) | string, ...args: any[]): Promise<Result>;
|
|
846
|
+
mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
|
|
847
|
+
blockNetwork(matcher: BrowserRouteMatcher): Promise<void>;
|
|
848
|
+
clearNetworkMocks(): Promise<void>;
|
|
849
|
+
setNetworkConditions(conditions: BrowserNetworkConditions): Promise<void>;
|
|
850
|
+
saveCookies(path: string): Promise<void>;
|
|
851
|
+
loadCookies(path: string): Promise<void>;
|
|
852
|
+
saveAuthState(path: string): Promise<void>;
|
|
853
|
+
loadAuthState(path: string): Promise<void>;
|
|
854
|
+
downloadFile(path: string): Promise<void>;
|
|
855
|
+
uploadFile(selector: Selector<T>, path: string): Promise<void>;
|
|
856
|
+
newTab(url?: R): Promise<string>;
|
|
857
|
+
switchToTab(index: number): Promise<void>;
|
|
858
|
+
closeTab(): Promise<void>;
|
|
859
|
+
getTabIds(): Promise<string[]>;
|
|
860
|
+
getConsoleLogs(): Promise<BrowserConsoleLog[]>;
|
|
861
|
+
getJSErrors(): Promise<BrowserJSError[]>;
|
|
862
|
+
getHAR(): Promise<BrowserHAR>;
|
|
863
|
+
/** Escape hatch: access the underlying Playwright `Page` (or CDP session) on web runs. */
|
|
864
|
+
getPage<PageType = unknown>(): PageType;
|
|
865
|
+
/** Enable a CDP WebAuthn virtual authenticator (passkey / platform authenticator) for this context. */
|
|
866
|
+
enableVirtualAuthenticator(opts?: VirtualAuthenticatorOptions): Promise<string>;
|
|
867
|
+
/** Remove an active virtual WebAuthn authenticator (defaults to the latest enabled one). */
|
|
868
|
+
removeVirtualAuthenticator(authenticatorId?: string): Promise<void>;
|
|
869
|
+
/** List credentials stored inside the active virtual WebAuthn authenticator. */
|
|
870
|
+
getVirtualCredentials(authenticatorId?: string): Promise<VirtualCredential[]>;
|
|
871
|
+
/** Clear all credentials stored inside the active virtual WebAuthn authenticator. */
|
|
872
|
+
clearVirtualCredentials(authenticatorId?: string): Promise<void>;
|
|
873
|
+
pinch(selector: ExtendedSelector<T>, opts?: {
|
|
874
|
+
scale?: number;
|
|
875
|
+
duration?: number;
|
|
876
|
+
} & WaitOptions): Promise<void>;
|
|
877
|
+
zoom(selector: ExtendedSelector<T>, opts?: {
|
|
878
|
+
scale?: number;
|
|
879
|
+
duration?: number;
|
|
880
|
+
} & WaitOptions): Promise<void>;
|
|
881
|
+
multiTouch(sequences: TouchSequence[]): Promise<void>;
|
|
882
|
+
getText(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<string>;
|
|
883
|
+
getAttribute(selector: ExtendedSelector<T>, name: string, opts?: WaitOptions): Promise<string | undefined>;
|
|
884
|
+
isVisible(selector: ExtendedSelector<T>, opts?: {
|
|
885
|
+
timeout?: number;
|
|
886
|
+
}): Promise<boolean>;
|
|
887
|
+
isEnabled(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<boolean>;
|
|
888
|
+
/** Wait for in-flight fetch/XHR, animations, and framework renders to settle via spana-bridge. */
|
|
889
|
+
waitForIdle(opts?: DomIdleOptions): Promise<void>;
|
|
890
|
+
/** Inject storage/auth state directly through the DOM bridge (avoids slow UI login flows). */
|
|
891
|
+
setStorage(entries: DomStorageEntries): Promise<void>;
|
|
892
|
+
/** Clear localStorage, sessionStorage, cookies, IndexedDB, and Capacitor Preferences. */
|
|
893
|
+
clearStorage(opts?: DomClearStorageOptions): Promise<void>;
|
|
894
|
+
/** Fast reset: clear storage via bridge and reload in milliseconds (avoids uninstall/reinstall). */
|
|
895
|
+
resetFast(): Promise<void>;
|
|
896
|
+
/** @internal Low-level escape hatch: list available contexts (e.g. ["NATIVE_APP", "WEBVIEW_..."]). */
|
|
897
|
+
getContexts(): Promise<string[]>;
|
|
898
|
+
/** @internal Low-level escape hatch: get the current context ID. */
|
|
899
|
+
getCurrentContext(): Promise<string>;
|
|
900
|
+
/** @internal Low-level escape hatch: switch to a specific context by ID. */
|
|
901
|
+
switchToContext(contextId: string): Promise<void>;
|
|
902
|
+
/** @internal Low-level escape hatch: switch to the first available WebView context. */
|
|
903
|
+
switchToWebView(): Promise<void>;
|
|
904
|
+
/** @internal Low-level escape hatch: switch back to the native app context. */
|
|
905
|
+
switchToNativeApp(): Promise<void>;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
export { buildDomFillScript as $, type AppiumExecutionConfig as A, type BrowserRouteMatcher as B, type DeviceStateConfig as C, DriverError as D, type ExtendedSelector as E, type DismissKeyboardOptions as F, type DomChannelKind as G, type DomRect as H, type ElectronAppConfig as I, type RelativeSelector as J, type ScrollUntilVisibleOptions as K, type LaunchOptions as L, type StorybookConfig as M, type StorybookOpenOptions as N, type StorybookValue as O, type Platform as P, type TouchAction as Q, type RawDriverService as R, type Selector as S, type TapMode as T, type TouchSequence as U, type VirtualAuthenticatorOptions as V, type VirtualCredential as W, type WarmDaemonConfig as X, type WebBrowserEngine as Y, type WebExecutionConfig as Z, type WebResourceBlockType as _, type DomElementMatch as a, buildDomWaitForHiddenScript as a0, buildDomWaitForMatchScript as a1, buildDomWaitForSelectorScript as a2, defineConfig as a3, isSystemUISelector as a4, isTestIDSelector as a5, systemUI as a6, type WaitOptions as a7, type ProvConfig as b, type DomChannel as c, type DomTargetInfo as d, type DomWaitForSelectorOptions as e, type DomWaitForHiddenOptions as f, type DomWaitForMatchOptions as g, type DomWaitForMatchResult as h, type DomFillOptions as i, type DomIdleOptions as j, type DomStorageEntries as k, type DomClearStorageOptions as l, type BrowserMockResponse as m, type BrowserConsoleLog as n, type BrowserJSError as o, type BrowserName as p, type ElectrobunAppConfig as q, type ElectrobunRenderer as r, type AppConfig as s, type PromiseApp as t, type ArtifactConfig as u, type BackUntilVisibleOptions as v, type BridgeConfig as w, type BrowserHAR as x, type BrowserNetworkConditions as y, DeviceInfo as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core/filters.ts
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
|
-
import { readFileSync, existsSync } from "fs";
|
|
4
|
-
import { basename, relative, resolve } from "path";
|
|
3
|
+
import { readFileSync, existsSync, statSync } from "fs";
|
|
4
|
+
import { basename, dirname, relative, resolve } from "path";
|
|
5
5
|
var DEFAULT_LOCKFILES = /* @__PURE__ */ new Set([
|
|
6
6
|
"bun.lock",
|
|
7
7
|
"bun.lockb",
|
|
@@ -383,6 +383,145 @@ function pathRuleFilter(options) {
|
|
|
383
383
|
}
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
+
var IMPORT_SPECIFIER_RE = /(?:import|export)\s+(?:[^'"]*?\s+from\s+)?["'](\.{1,2}\/[^"']+)["']|require\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)|import\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)/g;
|
|
387
|
+
var RESOLVE_EXTENSIONS = [
|
|
388
|
+
"",
|
|
389
|
+
".ts",
|
|
390
|
+
".tsx",
|
|
391
|
+
".mts",
|
|
392
|
+
".js",
|
|
393
|
+
".jsx",
|
|
394
|
+
".mjs",
|
|
395
|
+
".cjs",
|
|
396
|
+
"/index.ts",
|
|
397
|
+
"/index.tsx",
|
|
398
|
+
"/index.js",
|
|
399
|
+
"/index.mjs"
|
|
400
|
+
];
|
|
401
|
+
function resolveLocalImport(fromFileAbs, specifier) {
|
|
402
|
+
const baseDir = dirname(fromFileAbs);
|
|
403
|
+
const rawTarget = resolve(baseDir, specifier);
|
|
404
|
+
const withoutJs = rawTarget.replace(/\.m?js$/, "");
|
|
405
|
+
const candidates = rawTarget !== withoutJs ? [withoutJs + ".ts", withoutJs + ".tsx", withoutJs + ".mts", rawTarget] : [rawTarget];
|
|
406
|
+
for (const base of candidates) {
|
|
407
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
408
|
+
const full = ext ? base + ext : base;
|
|
409
|
+
try {
|
|
410
|
+
if (existsSync(full) && statSync(full).isFile()) {
|
|
411
|
+
return full;
|
|
412
|
+
}
|
|
413
|
+
} catch {
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
function collectTransitiveImports(entryAbs, cwd, maxDepth, fileCache) {
|
|
420
|
+
const visited = /* @__PURE__ */ new Set();
|
|
421
|
+
const queue = [{ abs: entryAbs, depth: 0 }];
|
|
422
|
+
while (queue.length > 0) {
|
|
423
|
+
const { abs, depth } = queue.shift();
|
|
424
|
+
const normRel = normalizePath(relative(cwd, abs));
|
|
425
|
+
if (visited.has(normRel)) continue;
|
|
426
|
+
visited.add(normRel);
|
|
427
|
+
if (depth >= maxDepth) continue;
|
|
428
|
+
let specs = fileCache.get(abs);
|
|
429
|
+
if (!specs) {
|
|
430
|
+
specs = [];
|
|
431
|
+
try {
|
|
432
|
+
if (existsSync(abs) && statSync(abs).isFile()) {
|
|
433
|
+
const content = readFileSync(abs, "utf-8");
|
|
434
|
+
IMPORT_SPECIFIER_RE.lastIndex = 0;
|
|
435
|
+
let match;
|
|
436
|
+
while ((match = IMPORT_SPECIFIER_RE.exec(content)) !== null) {
|
|
437
|
+
const spec = match[1] ?? match[2] ?? match[3];
|
|
438
|
+
if (spec) specs.push(spec);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
} catch {
|
|
442
|
+
}
|
|
443
|
+
fileCache.set(abs, specs);
|
|
444
|
+
}
|
|
445
|
+
for (const spec of specs) {
|
|
446
|
+
const resolved = resolveLocalImport(abs, spec);
|
|
447
|
+
if (resolved) {
|
|
448
|
+
queue.push({ abs: resolved, depth: depth + 1 });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return visited;
|
|
453
|
+
}
|
|
454
|
+
function deterministicImpactFilter(options = {}) {
|
|
455
|
+
const filterName = options.name ?? "deterministic-impact";
|
|
456
|
+
const alwaysRunTags = new Set(options.alwaysRunTags ?? []);
|
|
457
|
+
const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);
|
|
458
|
+
const pathMappings = options.pathMappings ?? [];
|
|
459
|
+
const failOpenOnUnmapped = options.failOpenOnUnmappedChange ?? true;
|
|
460
|
+
const maxDepth = options.maxDepth ?? 12;
|
|
461
|
+
return {
|
|
462
|
+
name: filterName,
|
|
463
|
+
filter(flows, context) {
|
|
464
|
+
const { changes, configPath, cwd } = context;
|
|
465
|
+
if (changes.files.length === 0) {
|
|
466
|
+
return { exclude: {}, note: "no git changes detected" };
|
|
467
|
+
}
|
|
468
|
+
if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {
|
|
469
|
+
return { exclude: {}, note: "config or lockfile changed \u2014 running all flows" };
|
|
470
|
+
}
|
|
471
|
+
const matchedGlobal = changes.files.find(
|
|
472
|
+
(f) => runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix))
|
|
473
|
+
);
|
|
474
|
+
if (matchedGlobal) {
|
|
475
|
+
return { exclude: {}, note: `global path changed (${matchedGlobal}) \u2014 running all flows` };
|
|
476
|
+
}
|
|
477
|
+
const changedFiles = changes.files.map(normalizePath);
|
|
478
|
+
const changedSet = new Set(changedFiles);
|
|
479
|
+
const fileCache = /* @__PURE__ */ new Map();
|
|
480
|
+
const flowDeps = /* @__PURE__ */ new Map();
|
|
481
|
+
const allKnownFiles = /* @__PURE__ */ new Set();
|
|
482
|
+
for (const candidate of flows) {
|
|
483
|
+
const entryAbs = resolve(cwd, candidate.file);
|
|
484
|
+
const deps = collectTransitiveImports(entryAbs, cwd, maxDepth, fileCache);
|
|
485
|
+
deps.add(normalizePath(candidate.file));
|
|
486
|
+
flowDeps.set(candidate.id, deps);
|
|
487
|
+
for (const d of deps) allKnownFiles.add(d);
|
|
488
|
+
}
|
|
489
|
+
const allWatchedPrefixes = pathMappings.flatMap((r) => r.watchPaths.map(normalizePath));
|
|
490
|
+
if (failOpenOnUnmapped) {
|
|
491
|
+
const unmapped = changedFiles.find(
|
|
492
|
+
(cf) => !allKnownFiles.has(cf) && !allWatchedPrefixes.some((prefix) => cf.startsWith(prefix))
|
|
493
|
+
);
|
|
494
|
+
if (unmapped) {
|
|
495
|
+
return {
|
|
496
|
+
exclude: {},
|
|
497
|
+
note: `unmapped file changed (${unmapped}) \u2014 failing open and running all flows`
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
const exclude = {};
|
|
502
|
+
for (const candidate of flows) {
|
|
503
|
+
if (changedSet.has(normalizePath(candidate.file))) continue;
|
|
504
|
+
if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;
|
|
505
|
+
const deps = flowDeps.get(candidate.id);
|
|
506
|
+
const touchedByImport = deps ? changedFiles.some((cf) => deps.has(cf)) : false;
|
|
507
|
+
if (touchedByImport) continue;
|
|
508
|
+
const matchedRules = pathMappings.filter((rule) => {
|
|
509
|
+
const tagOk = rule.matchFlow.tag ? candidate.tags.includes(rule.matchFlow.tag) : true;
|
|
510
|
+
const fileOk = rule.matchFlow.filePrefix ? normalizePath(candidate.file).startsWith(normalizePath(rule.matchFlow.filePrefix)) : true;
|
|
511
|
+
return (rule.matchFlow.tag || rule.matchFlow.filePrefix) && tagOk && fileOk;
|
|
512
|
+
});
|
|
513
|
+
const touchedByRule = matchedRules.some(
|
|
514
|
+
(rule) => changedFiles.some(
|
|
515
|
+
(cf) => rule.watchPaths.some((prefix) => cf.startsWith(normalizePath(prefix)))
|
|
516
|
+
)
|
|
517
|
+
);
|
|
518
|
+
if (touchedByRule) continue;
|
|
519
|
+
exclude[candidate.id] = "unaffected by changed imports or path mappings";
|
|
520
|
+
}
|
|
521
|
+
return { exclude };
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
386
525
|
async function applyTestFilters(items, candidates, filters, context) {
|
|
387
526
|
let remainingIndices = items.map((_, i) => i);
|
|
388
527
|
const excluded = [];
|
|
@@ -465,7 +604,8 @@ export {
|
|
|
465
604
|
probabilityFromTopLogprobs,
|
|
466
605
|
createLogprobDecisionJudge,
|
|
467
606
|
pathRuleFilter,
|
|
607
|
+
deterministicImpactFilter,
|
|
468
608
|
applyTestFilters,
|
|
469
609
|
formatFilterSummary
|
|
470
610
|
};
|
|
471
|
-
//# sourceMappingURL=chunk-
|
|
611
|
+
//# sourceMappingURL=chunk-3SH5JQF7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/filters.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { readFileSync, existsSync, statSync } from \"node:fs\";\nimport { basename, dirname, relative, resolve } from \"node:path\";\nimport type { FlowDefinition } from \"../api/flow.js\";\nimport type { Platform } from \"../schemas/selector.js\";\n\n/** A file changed between `baseRef` and `HEAD` (or working tree). */\nexport interface ChangedFile {\n path: string;\n status: \"A\" | \"M\" | \"D\" | \"R\" | \"C\" | string;\n}\n\n/** Git diff snapshot provided to test filters when `--changed-since <ref>` is active. */\nexport interface GitChanges {\n baseRef: string;\n mergeBase?: string;\n files: string[];\n entries: ChangedFile[];\n /** Unified diff text (truncated when exceeding `maxDiffBytes`). */\n diff: string;\n /** Full byte length of the raw diff before truncation. */\n diffBytes: number;\n /** True when the diff exceeded the configured safety cap. */\n truncated: boolean;\n}\n\n/** Descriptor for a candidate flow passed into a `TestFilter`. */\nexport interface FilterCandidate {\n id: string;\n name: string;\n file: string;\n tags: string[];\n platforms?: Platform[];\n source?: string;\n}\n\n/** Context supplied to every `TestFilter.filter()` invocation. */\nexport interface FilterContext {\n cwd: string;\n changes: GitChanges;\n configPath?: string;\n platforms: Platform[];\n}\n\nexport interface FilterUsage {\n calls?: number;\n tokens?: number;\n costUsd?: number;\n}\n\nexport interface FilterDecisionOutput {\n /** Map of candidate `id` -> human-readable skip reason. Any ID not present is kept. */\n exclude: Record<string, string>;\n /** Optional summary note displayed next to the filter output. */\n note?: string;\n /** Optional model/API usage metrics for summary logging. */\n usage?: FilterUsage;\n}\n\n/**\n * Pluggable CI test filter inspired by `e2e-inc/e2e`'s Filters API.\n * Compose deterministic path/tag rules or plug in a decision model / LLM.\n */\nexport interface TestFilter {\n name: string;\n filter(\n flows: FilterCandidate[],\n context: FilterContext,\n ): Promise<FilterDecisionOutput> | FilterDecisionOutput;\n}\n\nexport interface AppliedFilterReport {\n filterName: string;\n total: number;\n kept: number;\n excluded: number;\n note?: string;\n usage?: FilterUsage;\n failedOpen?: boolean;\n}\n\nexport interface ApplyFiltersResult<T> {\n kept: T[];\n excluded: Array<{ item: T; candidate: FilterCandidate; filterName: string; reason: string }>;\n reports: AppliedFilterReport[];\n}\n\nconst DEFAULT_LOCKFILES = new Set([\n \"bun.lock\",\n \"bun.lockb\",\n \"package.json\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"yarn.lock\",\n]);\n\nconst DEFAULT_MAX_DIFF_BYTES = 60 * 1024; // 60 kB fail-open safety ceiling\n\nfunction normalizePath(p: string): string {\n return p.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\//, \"\");\n}\n\nfunction isConfigOrLockfile(filePath: string, configPath?: string): boolean {\n const norm = normalizePath(filePath);\n const name = basename(norm);\n if (DEFAULT_LOCKFILES.has(name)) return true;\n if (/^spana\\.config(\\.[^.]+)?\\.(ts|mts|js|mjs|cjs)$/.test(name)) return true;\n if (configPath && normalizePath(configPath).endsWith(norm)) return true;\n return false;\n}\n\n/**\n * Collect changed files and unified diff relative to `baseRef` using `git merge-base`.\n * Fails cleanly if git is unavailable or `baseRef` does not exist (shallow checkout).\n */\nexport function collectGitChanges(\n baseRef: string,\n cwd: string = process.cwd(),\n maxDiffBytes: number = DEFAULT_MAX_DIFF_BYTES,\n runGit?: (args: string[], workdir: string) => string,\n): GitChanges {\n const execGit =\n runGit ??\n ((args: string[], workdir: string) =>\n execFileSync(\"git\", args, {\n cwd: workdir,\n encoding: \"utf-8\",\n maxBuffer: 16 * 1024 * 1024,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n }));\n\n let mergeBase: string | undefined;\n try {\n mergeBase = execGit([\"merge-base\", baseRef, \"HEAD\"], cwd).trim() || undefined;\n } catch {\n mergeBase = undefined;\n }\n\n const diffRange = mergeBase ? `${mergeBase}...HEAD` : baseRef;\n const nameStatusRaw = execGit([\"diff\", \"--name-status\", diffRange], cwd);\n const entries: ChangedFile[] = [];\n const files: string[] = [];\n\n for (const line of nameStatusRaw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const parts = trimmed.split(/\\t+/);\n const status = parts[0]?.[0] ?? \"M\";\n // For renames (R100 old new), include the destination path\n const filePath = normalizePath(parts[parts.length - 1] ?? \"\");\n if (!filePath) continue;\n entries.push({ path: filePath, status });\n files.push(filePath);\n }\n\n const rawDiff = execGit([\"diff\", \"--unified=3\", diffRange], cwd);\n const diffBytes = Buffer.byteLength(rawDiff, \"utf-8\");\n const truncated = diffBytes > maxDiffBytes;\n const diff = truncated ? rawDiff.slice(0, maxDiffBytes) : rawDiff;\n\n return {\n baseRef,\n mergeBase,\n files,\n entries,\n diff,\n diffBytes,\n truncated,\n };\n}\n\n/** Build filter candidates from loaded Spana flows (including source file content when readable). */\nexport function buildFilterCandidates(\n loaded: Array<{ sourcePath: string; flow: FlowDefinition }>,\n cwd: string = process.cwd(),\n): FilterCandidate[] {\n const sourceCache = new Map<string, string | undefined>();\n return loaded.map((entry, idx) => {\n const rel = normalizePath(relative(cwd, resolve(cwd, entry.sourcePath)));\n if (!sourceCache.has(entry.sourcePath)) {\n let src: string | undefined;\n if (existsSync(entry.sourcePath)) {\n try {\n src = readFileSync(entry.sourcePath, \"utf-8\");\n } catch {\n src = undefined;\n }\n }\n sourceCache.set(entry.sourcePath, src);\n }\n return {\n id: `${rel}::${entry.flow.name}#${idx}`,\n name: entry.flow.name,\n file: rel,\n tags: entry.flow.config.tags ?? [],\n platforms: entry.flow.config.platforms,\n source: sourceCache.get(entry.sourcePath),\n };\n });\n}\n\n// ── Built-in Decision-Model Filter ──────────────────────────────────────────\n\nexport interface DecisionJudgeInput {\n candidate: FilterCandidate;\n changes: GitChanges;\n}\n\nexport interface DecisionJudgeResult {\n /** Probability [0..1] that the PR changes can affect this flow. */\n probability: number;\n reason?: string;\n usage?: FilterUsage;\n}\n\nexport type DecisionModelJudge = (\n input: DecisionJudgeInput,\n) => Promise<DecisionJudgeResult> | DecisionJudgeResult;\n\nexport interface DecisionBatchJudgeResult {\n /** Map of candidate `id` -> probability `[0, 1]` that the PR changes affect it. */\n probabilities: Record<string, number>;\n reasons?: Record<string, string>;\n usage?: FilterUsage;\n}\n\nexport type DecisionBatchJudge = (input: {\n candidates: FilterCandidate[];\n changes: GitChanges;\n}) => Promise<DecisionBatchJudgeResult> | DecisionBatchJudgeResult;\n\nexport interface DecisionFilterOptions {\n /** Optional custom name (default: \"decision\") */\n name?: string;\n /**\n * Per-flow model judge function returning an impact probability in `[0, 1]`.\n * Provide either `judge` or `batchJudge` (batched evaluates all flows in 1 LLM call).\n */\n judge?: DecisionModelJudge;\n /**\n * Batched model judge evaluating all candidate flows in a single model call\n * (dramatically faster for local Ollama/MLX models and cloud decision models).\n */\n batchJudge?: DecisionBatchJudge;\n /**\n * Skip a flow only when `probability < threshold`.\n * Default: `0.20` (fail-open safety bias — runs anything >= 20% likely affected).\n */\n threshold?: number;\n /** Max diff size in bytes before failing open and running everything. Default: 60 kB. */\n maxDiffBytes?: number;\n /** Max single flow file size in bytes before failing open for that flow. Default: 32 kB. */\n maxFileBytes?: number;\n /** Tags that are NEVER excluded (e.g. `[\"smoke\"]`). */\n alwaysRunTags?: string[];\n /** Path prefixes that force the entire suite to run (e.g. `[\"infra/\", \"db/migrations/\"]`). */\n runAllOnPaths?: string[];\n}\n\n/**\n * Create a fail-open decision-model filter for `--changed-since`:\n *\n * Safety invariants (never skip important tests):\n * 1. Changed flow files always run.\n * 2. Config or lockfile changes run the entire suite.\n * 3. Diffs over `maxDiffBytes` (default 60 kB) run the entire suite.\n * 4. Flows tagged in `alwaysRunTags` always run.\n * 5. Any judge error or invalid probability fails open (flow runs).\n * 6. A flow is excluded only when `probability < threshold` (default 0.20).\n */\nexport function decisionFilter(options: DecisionFilterOptions): TestFilter {\n const filterName = options.name ?? \"decision\";\n const threshold = options.threshold ?? 0.2;\n const maxDiffBytes = options.maxDiffBytes ?? DEFAULT_MAX_DIFF_BYTES;\n const maxFileBytes = options.maxFileBytes ?? 32 * 1024;\n const alwaysRunTags = new Set(options.alwaysRunTags ?? []);\n const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);\n\n return {\n name: filterName,\n async filter(flows, context): Promise<FilterDecisionOutput> {\n const { changes, configPath } = context;\n\n if (changes.files.length === 0) {\n return { exclude: {}, note: \"no git changes detected\" };\n }\n\n if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {\n return { exclude: {}, note: \"config or lockfile changed — running all flows\" };\n }\n\n const matchedGlobalPath = changes.files.find((f) =>\n runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix)),\n );\n if (matchedGlobalPath) {\n return {\n exclude: {},\n note: `global path changed (${matchedGlobalPath}) — running all flows`,\n };\n }\n\n if (changes.truncated || changes.diffBytes > maxDiffBytes) {\n return {\n exclude: {},\n note: `diff exceeds ${Math.round(maxDiffBytes / 1024)}kB cap — failing open`,\n };\n }\n\n const changedSet = new Set(changes.files.map(normalizePath));\n const exclude: Record<string, string> = {};\n let calls = 0;\n let tokens = 0;\n let costUsd = 0;\n\n // Filter down to flows eligible for model judgment (safety rules always keep the rest)\n const eligible: FilterCandidate[] = [];\n for (const candidate of flows) {\n if (changedSet.has(normalizePath(candidate.file))) continue;\n if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;\n if (candidate.source && Buffer.byteLength(candidate.source, \"utf-8\") > maxFileBytes) {\n continue;\n }\n eligible.push(candidate);\n }\n\n if (eligible.length === 0) {\n return { exclude };\n }\n\n // Fast path: evaluate all eligible flows in ONE batched model call\n if (options.batchJudge) {\n try {\n const batch = await options.batchJudge({ candidates: eligible, changes });\n calls += batch.usage?.calls ?? 1;\n tokens += batch.usage?.tokens ?? 0;\n costUsd += batch.usage?.costUsd ?? 0;\n for (const candidate of eligible) {\n const prob = batch.probabilities[candidate.id];\n if (typeof prob === \"number\" && !Number.isNaN(prob) && prob >= 0 && prob < threshold) {\n const pct = Math.round(prob * 100);\n exclude[candidate.id] =\n batch.reasons?.[candidate.id] ??\n `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;\n }\n }\n } catch {\n // Fail open on batch judge error\n return { exclude: {}, note: \"decision model error — failed open\" };\n }\n return {\n exclude,\n usage: calls > 0 ? { calls, tokens, costUsd } : undefined,\n };\n }\n\n if (!options.judge) {\n return { exclude: {}, note: \"no judge configured — failed open\" };\n }\n\n for (const candidate of eligible) {\n try {\n const verdict = await options.judge({ candidate, changes });\n calls += verdict.usage?.calls ?? 1;\n tokens += verdict.usage?.tokens ?? 0;\n costUsd += verdict.usage?.costUsd ?? 0;\n\n if (\n typeof verdict.probability === \"number\" &&\n !Number.isNaN(verdict.probability) &&\n verdict.probability >= 0 &&\n verdict.probability < threshold\n ) {\n const pct = Math.round(verdict.probability * 100);\n exclude[candidate.id] =\n verdict.reason ?? `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;\n }\n } catch {\n // Fail open on any model/network error\n continue;\n }\n }\n\n return {\n exclude,\n usage: calls > 0 ? { calls, tokens, costUsd } : undefined,\n };\n },\n };\n}\n\nexport interface OllamaDecisionJudgeOptions {\n /** Ollama model tag, e.g. `\"qwen2.5:1.5b\"` or `\"qwen2.5:0.5b\"`. */\n model: string;\n /** Ollama HTTP endpoint (default: `\"http://127.0.0.1:11434\"`). */\n baseUrl?: string;\n /** Request timeout in ms (default: 15000). */\n timeoutMs?: number;\n /** Optional custom fetch implementation for testing. */\n fetchFn?: typeof fetch;\n}\n\n/**\n * Built-in local batched decision judge for Ollama (Apple Silicon / local GPU).\n * Evaluates all candidate flows against a PR diff in ONE structured JSON call\n * with `temperature: 0` and zero cloud token cost ($0.0000).\n */\nexport function createOllamaDecisionJudge(options: OllamaDecisionJudgeOptions): DecisionBatchJudge {\n const baseUrl = (options.baseUrl ?? \"http://127.0.0.1:11434\").replace(/\\/$/, \"\");\n const timeoutMs = options.timeoutMs ?? 15_000;\n const fetchFn = options.fetchFn ?? fetch;\n\n return async ({ candidates, changes }): Promise<DecisionBatchJudgeResult> => {\n const flowList = candidates\n .map((c, i) => `${i}: file=\"${c.file}\", name=\"${c.name}\", tags=[${c.tags.join(\",\")}]`)\n .join(\"\\n\");\n\n const prompt = [\n \"You are a conservative CI test-impact classifier. Err on the side of RUNNING tests (high recall).\",\n \"For each E2E flow below, output a probability from 0.0 to 1.0 that the git diff could affect it.\",\n \"Rules:\",\n \"- If a flow's file path, name, or tags share the same feature/module/domain as ANY changed file, rate it 0.9.\",\n \"- If unsure or possibly connected via shared UI/state/API, rate it 0.5.\",\n \"- Rate 0.05 ONLY if the flow is clearly in a completely unrelated module.\",\n `Changed files: ${changes.files.join(\", \")}`,\n `Diff:\\n${changes.diff.slice(0, 3000)}`,\n `Flows:\\n${flowList}`,\n 'Output compact single-line JSON mapping each index string to a number, e.g. {\"0\":0.9,\"1\":0.05}',\n ].join(\"\\n\");\n\n const res = await fetchFn(`${baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: options.model,\n prompt,\n format: \"json\",\n stream: false,\n options: { temperature: 0, num_predict: 256 },\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n\n if (!res.ok) {\n throw new Error(`Ollama returned HTTP ${res.status}`);\n }\n\n const payload = (await res.json()) as {\n response?: string;\n prompt_eval_count?: number;\n eval_count?: number;\n };\n\n const rawJson = (payload.response ?? \"{}\").trim();\n const parsed = JSON.parse(rawJson) as Record<string, unknown>;\n const probabilities: Record<string, number> = {};\n\n for (let i = 0; i < candidates.length; i++) {\n const cand = candidates[i]!;\n const val = parsed[String(i)] ?? parsed[cand.id] ?? parsed[cand.name];\n if (typeof val === \"number\" && !Number.isNaN(val)) {\n probabilities[cand.id] = Math.max(0, Math.min(1, val));\n } else {\n // Missing index -> fail open (1.0)\n probabilities[cand.id] = 1;\n }\n }\n\n return {\n probabilities,\n usage: {\n calls: 1,\n tokens: (payload.prompt_eval_count ?? 0) + (payload.eval_count ?? 0),\n costUsd: 0,\n },\n };\n };\n}\n\nexport interface LogprobDecisionJudgeOptions {\n /** Model identifier (e.g. `\"hf.co/apus-ailab/APUS-OpenJev-v1-9B-GGUF:Q8_0\"`, `\"jevk5-4b-v0.3:q8_0\"`, `\"decider4b-v2:bf16\"`, `\"plumb-4b\"`). */\n model: string;\n /** Protocol backend: `\"openai\"` (vLLM / SGLang / llama-server / OpenRouter / Typesafe AI) or `\"ollama\"`. */\n provider: \"openai\" | \"ollama\";\n /** Base URL (default: `http://127.0.0.1:8000/v1` for openai, `http://127.0.0.1:11434` for ollama). */\n baseUrl?: string;\n /** Optional Bearer API key for hosted OpenAI-compatible endpoints. */\n apiKey?: string;\n /** Request timeout per flow judgment in ms (default: 15000). */\n timeoutMs?: number;\n /** Injectable fetch for unit tests. */\n fetchFn?: typeof fetch;\n}\n\n/**\n * Compute calibrated binary YES probability from OpenAI-style `top_logprobs`\n * on a 1-token decision model response (`max_tokens: 1`, `logprobs: true`).\n * Returns `null` when neither YES nor NO tokens appeared in top_logprobs.\n */\nexport function probabilityFromTopLogprobs(\n topLogprobs: Array<{ token: string; logprob: number }>,\n): number | null {\n let yesProb = 0;\n let noProb = 0;\n\n for (const entry of topLogprobs) {\n const norm = entry.token.trim().toLowerCase();\n const p = Math.exp(entry.logprob);\n if (norm === \"yes\" || norm === \"y\" || norm === \"true\" || norm === \"1\") {\n yesProb += p;\n } else if (norm === \"no\" || norm === \"n\" || norm === \"false\" || norm === \"0\") {\n noProb += p;\n }\n }\n\n const total = yesProb + noProb;\n if (total <= 0) return null;\n return Math.max(0, Math.min(1, yesProb / total));\n}\n\n/**\n * Native 1-Token Logprob Decision Judge for System-1 decision models\n * (OpenJev, JevK5, Decider-4B, Plumb-4B, Winnow-12B, Typesafe AI Jev).\n *\n * Places the shared git diff prefix at the start of every prompt so vLLM,\n * SGLang, and llama.cpp automatically reuse the KV cache across all flows in a PR,\n * generating only **1 single token** (`YES` / `NO`) with exact calibrated probabilities.\n */\nexport function createLogprobDecisionJudge(\n options: LogprobDecisionJudgeOptions,\n): DecisionModelJudge {\n const baseUrl = (\n options.baseUrl ??\n (options.provider === \"ollama\" ? \"http://127.0.0.1:11434\" : \"http://127.0.0.1:8000/v1\")\n ).replace(/\\/$/, \"\");\n const timeoutMs = options.timeoutMs ?? 15_000;\n const fetchFn = options.fetchFn ?? fetch;\n\n return async ({ candidate, changes }): Promise<DecisionJudgeResult> => {\n // Shared prefix FIRST to maximize automatic KV-cache prefix hits across flows\n const prompt = [\n \"You are a binary CI test-impact classifier. Answer strictly YES or NO.\",\n `Changed files: ${changes.files.join(\", \")}`,\n `Git diff:\\n${changes.diff.slice(0, 3500)}`,\n `Question: Could this change affect or break the E2E flow below?`,\n `Flow file: ${candidate.file}`,\n `Flow name: ${candidate.name}`,\n `Flow tags: ${candidate.tags.join(\", \") || \"(none)\"}`,\n \"Answer (YES or NO):\",\n ].join(\"\\n\");\n\n if (options.provider === \"ollama\") {\n const res = await fetchFn(`${baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: options.model,\n prompt,\n stream: false,\n logprobs: true,\n top_logprobs: 10,\n options: { temperature: 0, num_predict: 1 },\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) throw new Error(`Ollama returned HTTP ${res.status}`);\n const data = (await res.json()) as {\n response?: string;\n prompt_eval_count?: number;\n eval_count?: number;\n logprobs?: Array<{ top_logprobs?: Array<{ token: string; logprob: number }> }>;\n };\n\n const top = data.logprobs?.[0]?.top_logprobs;\n let probability = top ? probabilityFromTopLogprobs(top) : null;\n if (probability === null) {\n const tok = (data.response ?? \"\").trim().toLowerCase();\n if (tok.startsWith(\"n\") || tok === \"0\" || tok === \"false\") probability = 0.05;\n else probability = 0.95; // fail open on ambiguous token\n }\n\n return {\n probability,\n usage: {\n calls: 1,\n tokens: (data.prompt_eval_count ?? 0) + (data.eval_count ?? 0),\n costUsd: 0,\n },\n };\n }\n\n // OpenAI-compatible 1-token logprob endpoint (vLLM / SGLang / llama-server / Typesafe AI / OpenRouter)\n const res = await fetchFn(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}),\n },\n body: JSON.stringify({\n model: options.model,\n temperature: 0,\n max_tokens: 1,\n logprobs: true,\n top_logprobs: 10,\n messages: [{ role: \"user\", content: prompt }],\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) throw new Error(`Decision endpoint returned HTTP ${res.status}`);\n const data = (await res.json()) as {\n choices?: Array<{\n message?: { content?: string };\n logprobs?: {\n content?: Array<{ top_logprobs?: Array<{ token: string; logprob: number }> }>;\n };\n }>;\n usage?: { prompt_tokens?: number; completion_tokens?: number };\n };\n\n const top = data.choices?.[0]?.logprobs?.content?.[0]?.top_logprobs;\n let probability = top ? probabilityFromTopLogprobs(top) : null;\n if (probability === null) {\n const tok = (data.choices?.[0]?.message?.content ?? \"\").trim().toLowerCase();\n if (tok.startsWith(\"n\") || tok === \"0\" || tok === \"false\") probability = 0.05;\n else probability = 0.95;\n }\n\n return {\n probability,\n usage: {\n calls: 1,\n tokens: (data.usage?.prompt_tokens ?? 0) + (data.usage?.completion_tokens ?? 0),\n costUsd: 0,\n },\n };\n };\n}\n\n// ── Built-in Deterministic Path-Rule Filter ─────────────────────────────────\n\nexport interface PathRule {\n /** Flow tag or path prefix this rule owns. */\n matchFlow: { tag?: string; filePrefix?: string };\n /** Source path prefixes that can affect matching flows. */\n watchPaths: string[];\n}\n\nexport interface PathRuleFilterOptions {\n name?: string;\n rules: PathRule[];\n alwaysRunTags?: string[];\n runAllOnPaths?: string[];\n}\n\n/**\n * 100% deterministic zero-LLM filter mapping repo path prefixes to flow tags/files.\n * Flows not matched by any rule fail open and run automatically.\n */\nexport function pathRuleFilter(options: PathRuleFilterOptions): TestFilter {\n const filterName = options.name ?? \"path-rules\";\n const alwaysRunTags = new Set(options.alwaysRunTags ?? []);\n const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);\n\n return {\n name: filterName,\n filter(flows, context): FilterDecisionOutput {\n const { changes, configPath } = context;\n\n if (changes.files.length === 0) {\n return { exclude: {}, note: \"no git changes detected\" };\n }\n\n if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {\n return { exclude: {}, note: \"config or lockfile changed — running all flows\" };\n }\n\n const matchedGlobal = changes.files.find((f) =>\n runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix)),\n );\n if (matchedGlobal) {\n return { exclude: {}, note: `global path changed (${matchedGlobal}) — running all flows` };\n }\n\n const changedFiles = changes.files.map(normalizePath);\n const changedSet = new Set(changedFiles);\n const exclude: Record<string, string> = {};\n\n for (const candidate of flows) {\n if (changedSet.has(normalizePath(candidate.file))) continue;\n if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;\n\n const matchedRules = options.rules.filter((rule) => {\n const tagOk = rule.matchFlow.tag ? candidate.tags.includes(rule.matchFlow.tag) : true;\n const fileOk = rule.matchFlow.filePrefix\n ? normalizePath(candidate.file).startsWith(normalizePath(rule.matchFlow.filePrefix))\n : true;\n return (rule.matchFlow.tag || rule.matchFlow.filePrefix) && tagOk && fileOk;\n });\n\n // No rule owns this flow -> fail open (keep it)\n if (matchedRules.length === 0) continue;\n\n const watchedPrefixes = matchedRules.flatMap((r) => r.watchPaths.map(normalizePath));\n const affected = changedFiles.some((cf) =>\n watchedPrefixes.some((prefix) => cf.startsWith(prefix)),\n );\n\n if (!affected) {\n exclude[candidate.id] = `no changed files matched [${watchedPrefixes.join(\", \")}]`;\n }\n }\n\n return { exclude };\n },\n };\n}\n\n// ── Built-in Deterministic Import-Graph Impact Filter (Zero AI) ─────────────\n\nexport interface DeterministicImpactFilterOptions {\n name?: string;\n /** Additional path-to-flow rules combined with automatic static import-graph tracing. */\n pathMappings?: PathRule[];\n /** Flow tags that are NEVER skipped (e.g. `[\"smoke\"]`). */\n alwaysRunTags?: string[];\n /** Path prefixes that force the entire suite to run (e.g. `[\"src/shared/\", \"db/\"]`). */\n runAllOnPaths?: string[];\n /**\n * When true (default), if a changed file is NOT imported by any flow and does not\n * match any `pathMappings`, fail open and run all flows so unmapped app changes are\n * never silently missed. Set to `false` for strict import-graph-only selection.\n */\n failOpenOnUnmappedChange?: boolean;\n /** Max recursive import depth to trace from each flow file. Default: 12. */\n maxDepth?: number;\n}\n\nconst IMPORT_SPECIFIER_RE =\n /(?:import|export)\\s+(?:[^'\"]*?\\s+from\\s+)?[\"'](\\.{1,2}\\/[^\"']+)[\"']|require\\(\\s*[\"'](\\.{1,2}\\/[^\"']+)[\"']\\s*\\)|import\\(\\s*[\"'](\\.{1,2}\\/[^\"']+)[\"']\\s*\\)/g;\n\nconst RESOLVE_EXTENSIONS = [\n \"\",\n \".ts\",\n \".tsx\",\n \".mts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \"/index.ts\",\n \"/index.tsx\",\n \"/index.js\",\n \"/index.mjs\",\n];\n\nfunction resolveLocalImport(fromFileAbs: string, specifier: string): string | null {\n const baseDir = dirname(fromFileAbs);\n const rawTarget = resolve(baseDir, specifier);\n // Handle TS ESM `.js` -> `.ts` / `.tsx` extension rewriting\n const withoutJs = rawTarget.replace(/\\.m?js$/, \"\");\n const candidates =\n rawTarget !== withoutJs\n ? [withoutJs + \".ts\", withoutJs + \".tsx\", withoutJs + \".mts\", rawTarget]\n : [rawTarget];\n\n for (const base of candidates) {\n for (const ext of RESOLVE_EXTENSIONS) {\n const full = ext ? base + ext : base;\n try {\n if (existsSync(full) && statSync(full).isFile()) {\n return full;\n }\n } catch {\n // ignore unreadable paths\n }\n }\n }\n return null;\n}\n\nfunction collectTransitiveImports(\n entryAbs: string,\n cwd: string,\n maxDepth: number,\n fileCache: Map<string, string[]>,\n): Set<string> {\n const visited = new Set<string>();\n const queue: Array<{ abs: string; depth: number }> = [{ abs: entryAbs, depth: 0 }];\n\n while (queue.length > 0) {\n const { abs, depth } = queue.shift()!;\n const normRel = normalizePath(relative(cwd, abs));\n if (visited.has(normRel)) continue;\n visited.add(normRel);\n if (depth >= maxDepth) continue;\n\n let specs = fileCache.get(abs);\n if (!specs) {\n specs = [];\n try {\n if (existsSync(abs) && statSync(abs).isFile()) {\n const content = readFileSync(abs, \"utf-8\");\n IMPORT_SPECIFIER_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = IMPORT_SPECIFIER_RE.exec(content)) !== null) {\n const spec = match[1] ?? match[2] ?? match[3];\n if (spec) specs.push(spec);\n }\n }\n } catch {\n // ignore unreadable\n }\n fileCache.set(abs, specs);\n }\n\n for (const spec of specs) {\n const resolved = resolveLocalImport(abs, spec);\n if (resolved) {\n queue.push({ abs: resolved, depth: depth + 1 });\n }\n }\n }\n\n return visited;\n}\n\n/**\n * 100% deterministic, zero-AI test impact filter for `--changed-since`.\n *\n * Recursively traces static ESM/CJS imports (`import`, `export ... from`, `require`)\n * from every `.flow.ts` file and combines them with optional `pathMappings`.\n * Fails open on config/lockfile changes, `runAllOnPaths`, and (by default) any\n * changed file not covered by any import graph or path mapping.\n */\nexport function deterministicImpactFilter(\n options: DeterministicImpactFilterOptions = {},\n): TestFilter {\n const filterName = options.name ?? \"deterministic-impact\";\n const alwaysRunTags = new Set(options.alwaysRunTags ?? []);\n const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);\n const pathMappings = options.pathMappings ?? [];\n const failOpenOnUnmapped = options.failOpenOnUnmappedChange ?? true;\n const maxDepth = options.maxDepth ?? 12;\n\n return {\n name: filterName,\n filter(flows, context): FilterDecisionOutput {\n const { changes, configPath, cwd } = context;\n\n if (changes.files.length === 0) {\n return { exclude: {}, note: \"no git changes detected\" };\n }\n\n if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {\n return { exclude: {}, note: \"config or lockfile changed — running all flows\" };\n }\n\n const matchedGlobal = changes.files.find((f) =>\n runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix)),\n );\n if (matchedGlobal) {\n return { exclude: {}, note: `global path changed (${matchedGlobal}) — running all flows` };\n }\n\n const changedFiles = changes.files.map(normalizePath);\n const changedSet = new Set(changedFiles);\n const fileCache = new Map<string, string[]>();\n\n // Build transitive import graph for every candidate flow\n const flowDeps = new Map<string, Set<string>>();\n const allKnownFiles = new Set<string>();\n for (const candidate of flows) {\n const entryAbs = resolve(cwd, candidate.file);\n const deps = collectTransitiveImports(entryAbs, cwd, maxDepth, fileCache);\n deps.add(normalizePath(candidate.file));\n flowDeps.set(candidate.id, deps);\n for (const d of deps) allKnownFiles.add(d);\n }\n\n const allWatchedPrefixes = pathMappings.flatMap((r) => r.watchPaths.map(normalizePath));\n\n if (failOpenOnUnmapped) {\n const unmapped = changedFiles.find(\n (cf) =>\n !allKnownFiles.has(cf) && !allWatchedPrefixes.some((prefix) => cf.startsWith(prefix)),\n );\n if (unmapped) {\n return {\n exclude: {},\n note: `unmapped file changed (${unmapped}) — failing open and running all flows`,\n };\n }\n }\n\n const exclude: Record<string, string> = {};\n for (const candidate of flows) {\n if (changedSet.has(normalizePath(candidate.file))) continue;\n if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;\n\n const deps = flowDeps.get(candidate.id);\n const touchedByImport = deps ? changedFiles.some((cf) => deps.has(cf)) : false;\n if (touchedByImport) continue;\n\n const matchedRules = pathMappings.filter((rule) => {\n const tagOk = rule.matchFlow.tag ? candidate.tags.includes(rule.matchFlow.tag) : true;\n const fileOk = rule.matchFlow.filePrefix\n ? normalizePath(candidate.file).startsWith(normalizePath(rule.matchFlow.filePrefix))\n : true;\n return (rule.matchFlow.tag || rule.matchFlow.filePrefix) && tagOk && fileOk;\n });\n const touchedByRule = matchedRules.some((rule) =>\n changedFiles.some((cf) =>\n rule.watchPaths.some((prefix) => cf.startsWith(normalizePath(prefix))),\n ),\n );\n if (touchedByRule) continue;\n\n exclude[candidate.id] = \"unaffected by changed imports or path mappings\";\n }\n\n return { exclude };\n },\n };\n}\n\n/**\n * Run a chain of `TestFilter`s sequentially over candidate flows.\n * Any filter that throws fails open (keeps all remaining flows) and logs a note.\n */\nexport async function applyTestFilters<T>(\n items: T[],\n candidates: FilterCandidate[],\n filters: TestFilter[],\n context: FilterContext,\n): Promise<ApplyFiltersResult<T>> {\n let remainingIndices = items.map((_, i) => i);\n const excluded: ApplyFiltersResult<T>[\"excluded\"] = [];\n const reports: AppliedFilterReport[] = [];\n\n for (const filter of filters) {\n const activeCandidates = remainingIndices.map((idx) => candidates[idx]!);\n const totalBefore = activeCandidates.length;\n\n try {\n const output = await filter.filter(activeCandidates, context);\n const excludeMap = output.exclude ?? {};\n const nextRemaining: number[] = [];\n let excludedCount = 0;\n\n for (const idx of remainingIndices) {\n const cand = candidates[idx]!;\n const reason = excludeMap[cand.id];\n if (reason !== undefined) {\n excludedCount += 1;\n excluded.push({\n item: items[idx]!,\n candidate: cand,\n filterName: filter.name,\n reason,\n });\n } else {\n nextRemaining.push(idx);\n }\n }\n\n remainingIndices = nextRemaining;\n reports.push({\n filterName: filter.name,\n total: totalBefore,\n kept: remainingIndices.length,\n excluded: excludedCount,\n note: output.note,\n usage: output.usage,\n });\n } catch (err) {\n reports.push({\n filterName: filter.name,\n total: totalBefore,\n kept: totalBefore,\n excluded: 0,\n failedOpen: true,\n note: `filter error (${err instanceof Error ? err.message : String(err)}) — failed open`,\n });\n }\n }\n\n return {\n kept: remainingIndices.map((idx) => items[idx]!),\n excluded,\n reports,\n };\n}\n\n/** Format a concise, `e2e`-style CI summary line for each applied filter. */\nexport function formatFilterSummary(reports: AppliedFilterReport[]): string[] {\n return reports.map((r) => {\n const parts: string[] = [];\n if (r.usage?.calls) {\n parts.push(`${r.usage.calls} call${r.usage.calls === 1 ? \"\" : \"s\"}`);\n }\n if (r.usage?.tokens) {\n const tok =\n r.usage.tokens >= 1000 ? `${(r.usage.tokens / 1000).toFixed(1)}k` : String(r.usage.tokens);\n parts.push(`${tok} tokens`);\n }\n if (r.usage?.costUsd !== undefined && r.usage.costUsd > 0) {\n parts.push(`$${r.usage.costUsd.toFixed(4)}`);\n }\n if (r.note) {\n parts.push(r.note);\n }\n const detail = parts.length > 0 ? ` (${parts.join(\", \")})` : \"\";\n return `${r.filterName} kept ${r.kept} of ${r.total} flows, left out ${r.excluded}${detail}`;\n });\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,cAAc,YAAY,gBAAgB;AACnD,SAAS,UAAU,SAAS,UAAU,eAAe;AAqFrD,IAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,yBAAyB,KAAK;AAEpC,SAAS,cAAc,GAAmB;AACxC,SAAO,EAAE,WAAW,MAAM,GAAG,EAAE,QAAQ,SAAS,EAAE;AACpD;AAEA,SAAS,mBAAmB,UAAkB,YAA8B;AAC1E,QAAM,OAAO,cAAc,QAAQ;AACnC,QAAM,OAAO,SAAS,IAAI;AAC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