flaker core computation engine
pnpm add -D @mizchi/flakerpnpm dlx @mizchi/flaker --helpimport {
"mizchi/flaker" @flaker,
}
test "sample from historical runs" {
let meta = @flaker.build_sampling_meta(
[
@flaker.SamplingHistoryRowInput::{
suite: "tests/login.spec.ts",
test_name: "login works",
task_id: Some("web-login"),
filter: None,
variant: None,
test_id: None,
status: "passed",
retry_count: 0,
duration_ms: 1200,
created_at: "2026-04-03T00:00:00.000Z",
},
],
[
@flaker.SamplingListedTestInput::{
suite: "tests/login.spec.ts",
test_name: "login works",
task_id: Some("web-login"),
filter: None,
variant: None,
test_id: None,
},
],
)
let sampled = @flaker.sample_weighted(meta, count=1, seed=1UL)
assert_eq(sampled.length(), 1)
}moon run src/cmd/flaker --target js -- --help
moon run src/cmd/flaker --target native -- --versionflaker init --owner your-org --name your-repoexport GITHUB_TOKEN=$(gh auth token)
flaker collect --last 30flaker import report.json --adapter playwright --commit "$(git rev-parse HEAD)"flaker collect-local --last 20flaker flaky
flaker reason
flaker evalflaker eval --json
flaker eval --markdown --window 7flaker sample --strategy hybrid --count 25
flaker sample --strategy affected --changed src/foo.tsflaker run --strategy hybrid --count 25
flaker run --strategy affected --changed src/foo.tsflaker collect
flaker collect-local
flaker import report.json --adapter playwrightflaker sample --strategy random --count 20
flaker sample --strategy weighted --count 20
flaker sample --strategy affected
flaker sample --strategy hybrid --count 50
flaker run --strategy hybrid --count 50
flaker run --strategy affected --changed src/foo.tsflaker flaky
flaker reason
flaker eval
flaker query "SELECT * FROM test_results LIMIT 20"flaker quarantine
flaker check
flaker affected --changed src/foo.ts[repo]
owner = "your-org"
name = "your-repo"
[storage]
path = ".flaker/data.duckdb"
[adapter]
type = "playwright"
[runner]
type = "vitest"
command = "pnpm vitest"
[affected]
resolver = "workspace"
[flaky]
window_days = 14
detection_threshold = 2.0
[quarantine]
auto = true
flaky_rate_threshold = 30.0
min_runs = 10node_modules/@mizchi/flaker/dist/cli/main.jsfn build_affected_report(targets : Array[AffectedTargetInput], direct_selections : Array[AffectedDirectSelectionInput], transitive_tasks : Array[AffectedTransitiveTaskInput], unmatched : Array[String]) -> AffectedReportCoreOutputfn build_sampling_meta(history_rows : Array[SamplingHistoryRowInput], listed_tests : Array[SamplingListedTestInput]) -> Array[TestMeta]fn compute_quarantine_exit_code(results : Array[QuarantineRuntimeResultInput], fallback_exit_code : Int) -> Intfn find_affected_nodes(graph : DependencyGraphInput, changed_files : Array[String]) -> Array[String]fn find_matching_quarantine(entries : Array[QuarantineEntryInput], task_id : String, spec : String, title : String) -> Intfn get_affected_test_patterns(graph : DependencyGraphInput, affected_ids : Array[String]) -> Array[String]fn run_config_check(listed_tests : Array[ConfigCheckListedTestInput], discovered_specs : Array[String], task_definitions : Array[ConfigCheckTaskDefinitionInput]) -> ConfigCheckCoreOutputfn summarize_quarantine(entries : Array[QuarantineEntryInput], tasks : Array[QuarantineTaskOwnershipInput], existing_specs : Array[String], now_date : String, expires_soon_days : Int) -> QuarantineSummaryCoreOutput