playwright-performance-regression 0.1.0-next.1 → 0.1.0-next.4

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +431 -0
  2. package/README.md +96 -64
  3. package/dist/{chunk-L5C63HEF.js → chunk-CISGJCFW.js} +378 -48
  4. package/dist/chunk-CXE5IWZY.js +1648 -0
  5. package/dist/{chunk-B64P2D5A.js → chunk-E2IX265O.js} +395 -206
  6. package/dist/chunk-IUI4AFE5.cjs +658 -0
  7. package/dist/{chunk-WZVQK7CQ.cjs → chunk-KELMALEG.cjs} +408 -218
  8. package/dist/{chunk-GCA73FFP.cjs → chunk-LUA4WRIQ.cjs} +382 -47
  9. package/dist/chunk-RL27E3AB.js +595 -0
  10. package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
  11. package/dist/cli.js +2761 -2339
  12. package/dist/config.cjs +122 -137
  13. package/dist/config.d.cts +3 -2
  14. package/dist/config.d.ts +3 -2
  15. package/dist/config.js +117 -132
  16. package/dist/fixture.cjs +9 -5
  17. package/dist/fixture.d.cts +10 -4
  18. package/dist/fixture.d.ts +10 -4
  19. package/dist/fixture.js +4 -4
  20. package/dist/index.cjs +3 -3
  21. package/dist/index.d.cts +121 -25
  22. package/dist/index.d.ts +121 -25
  23. package/dist/index.js +1 -1
  24. package/dist/perf-api-2DH_keLh.d.cts +17 -0
  25. package/dist/perf-api-2DH_keLh.d.ts +17 -0
  26. package/dist/reporter.cjs +5713 -1237
  27. package/dist/reporter.js +6905 -693
  28. package/dist/test.cjs +4 -4
  29. package/dist/test.js +4 -4
  30. package/package.json +19 -1
  31. package/schemas/common.schema.json +2 -2
  32. package/schemas/config.schema.json +72 -26
  33. package/schemas/outcome.schema.json +2 -2
  34. package/schemas/run-report.schema.json +549 -20
  35. package/schemas/samples.schema.json +48 -37
  36. package/schemas/thresholds.schema.json +1 -1
  37. package/dist/chunk-3CLCMD2Q.js +0 -3411
  38. package/dist/chunk-4SFI55HF.cjs +0 -319
  39. package/dist/chunk-HBGADXLP.js +0 -254
  40. package/dist/perf-api-V4PeHVE0.d.cts +0 -22
  41. package/dist/perf-api-V4PeHVE0.d.ts +0 -22
@@ -234,7 +234,7 @@ var envLabel = str({
234
234
  format: 'a label of lowercase letters, digits and "-", like "staging"'
235
235
  });
236
236
  var envLabelOrNull = nullable(envLabel);
237
- var kind = enumOf(["api", "custom"]);
237
+ var kind = enumOf(["api", "step"]);
238
238
  var percentileName = str({
239
239
  pattern: /^p(?:[1-9][0-9]?)(?:\.[0-9])?$/u,
240
240
  format: 'a percentile name like "p95" or "p99.9"'
@@ -270,8 +270,15 @@ var isoDate = str({ pattern: /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
270
270
 
271
271
  // src/core/config/generated/defaults.ts
272
272
  var DEFAULT_CONFIG = {
273
- run: { env: null, repeat: { test: 5, thresholds: 10 }, projects: "auto", keepReporters: [] },
273
+ run: {
274
+ env: null,
275
+ passes: { test: 5, thresholds: 10 },
276
+ grep: null,
277
+ keepReporters: [],
278
+ overrideSlowMo: false
279
+ },
274
280
  measure: {
281
+ api: true,
275
282
  resourceTypes: ["document", "xhr", "fetch"],
276
283
  ignoreExtensions: [
277
284
  ".js",
@@ -297,11 +304,20 @@ var DEFAULT_CONFIG = {
297
304
  exclude: ["/socket.io/"],
298
305
  excludeKnownThirdParty: true,
299
306
  successStatuses: ["2xx", "3xx"],
307
+ steps: true,
300
308
  pendingTimeoutMs: 2e3
301
309
  },
302
310
  keys: {
303
311
  origins: {},
304
- idPatterns: { number: true, uuid: true, hex: true, token: true, mixed: true, email: true },
312
+ idPatterns: {
313
+ number: true,
314
+ uuid: true,
315
+ hex: true,
316
+ token: true,
317
+ mixed: true,
318
+ prefixed: true,
319
+ email: true
320
+ },
305
321
  extraIdPatterns: [],
306
322
  query: "names",
307
323
  keepQueryValues: [],
@@ -313,64 +329,59 @@ var DEFAULT_CONFIG = {
313
329
  enabled: true,
314
330
  minSamples: 5,
315
331
  margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 },
316
- limit: { api: 2e3, custom: 5e3 }
332
+ limit: { api: 2e3, step: 1e4 }
317
333
  },
318
334
  percentile: {
319
335
  enabled: true,
320
336
  minSamples: 20,
321
337
  level: "p95",
322
- limit: { api: 2e3, custom: 5e3 },
338
+ limit: { api: 2e3, step: 15e3 },
323
339
  margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 }
324
340
  },
325
341
  p99: {
326
342
  enabled: true,
327
343
  minSamples: 100,
328
344
  margin: { relative: 0.2, minGapMs: 50, minGapRelative: 0.1 },
329
- limit: { api: 4e3, custom: 1e4 }
345
+ limit: { api: 4e3, step: 3e4 }
330
346
  }
331
347
  },
332
348
  slowShare: {
333
349
  t: {
334
350
  api: { min: 500, max: 2e3, medianFactor: 2 },
335
- custom: { min: 1e3, max: 1e4, medianFactor: 2 }
351
+ step: { min: 1e3, max: 1e4, medianFactor: 2 }
336
352
  },
337
353
  apdex: {
338
354
  enabled: true,
339
355
  minSamples: 20,
340
356
  margin: { absolute: 0.05, smallSampleAbsolute: 0.1 },
341
- limit: { api: 0.85, custom: 0.85 }
357
+ limit: { api: 0.85, step: 0.85 }
342
358
  },
343
359
  wilson: {
344
360
  enabled: true,
345
361
  minSamples: 20,
346
362
  margin: { factor: 1.5, add: 0.02, min: 0.03, max: 0.15, smallSampleMin: 0.1 },
347
- limit: { api: 0.05, custom: 0.05 }
363
+ limit: { api: 0.05, step: 0.05 }
348
364
  }
349
365
  },
350
366
  errors: {
351
367
  enabled: true,
352
368
  minSamples: 5,
353
369
  statuses: ["5xx", "FAILED", "PENDING"],
354
- limit: { api: 0.05, custom: 0.05 },
370
+ limit: { api: 0.05, step: 0.05 },
355
371
  margin: { factor: 1.5, add: 0.02, min: 0.05 }
356
372
  }
357
373
  },
358
- gate: {
359
- tolerance: 0,
360
- hardLimitFactor: 2,
361
- defaultThresholds: "block",
362
- warnOnly: false,
363
- maxFailedTestShare: 0.1
364
- },
374
+ gate: { tolerance: 0, hardLimitFactor: 2, defaultThresholds: "block", maxFailedTestShare: 0.1 },
365
375
  thresholds: {
376
+ preset: "normal",
366
377
  dir: ".",
367
- filePrefix: "perf-thresholds",
378
+ filePrefix: "pw-perf-thresholds",
368
379
  update: "all",
369
380
  smallSampleN: 20,
370
381
  hysteresis: { relative: 0.1, ratio: 0.01 },
371
382
  loosenWarnRelative: 0.5
372
383
  },
373
- report: { dir: "perf-results", html: true, rawUrls: false },
384
+ report: { dir: "reports/pw-perf", html: true, rawUrls: false },
374
385
  advanced: { maxSamplesPerKey: 5e3, seed: 1 }
375
386
  };
376
387
 
@@ -450,6 +461,100 @@ function editDistance(a, b) {
450
461
  return previous[b.length] ?? 0;
451
462
  }
452
463
 
464
+ // src/core/config/steps.ts
465
+ var STEP_OPTION_NAMES = [
466
+ "enabled",
467
+ "include",
468
+ "exclude",
469
+ "maxDepth",
470
+ "categories",
471
+ "groupBy",
472
+ "normalizeTitles",
473
+ "redactQuotedValues"
474
+ ];
475
+ var STEP_DEFAULTS = {
476
+ include: [],
477
+ exclude: [],
478
+ maxDepth: 3,
479
+ categories: ["test.step"],
480
+ groupBy: "step",
481
+ normalizeTitles: true,
482
+ redactQuotedValues: false
483
+ };
484
+ function expandSteps(value) {
485
+ const defaults = () => ({
486
+ ...STEP_DEFAULTS,
487
+ include: [],
488
+ exclude: [],
489
+ categories: [...STEP_DEFAULTS.categories]
490
+ });
491
+ if (value === void 0 || typeof value === "boolean") {
492
+ return { enabled: value === true, ...defaults() };
493
+ }
494
+ return {
495
+ enabled: value.enabled ?? true,
496
+ ...defaults(),
497
+ ...Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0))
498
+ };
499
+ }
500
+
501
+ // src/core/config/presets.ts
502
+ var MARGIN_PRESETS = ["strict", "normal", "loose"];
503
+ var VALUES = {
504
+ strict: {
505
+ relative: 0.25,
506
+ minMs: 50,
507
+ smallSampleRelative: 0.5,
508
+ p99Relative: 0.1,
509
+ apdexAbsolute: 0.03,
510
+ apdexSmallSampleAbsolute: 0.06,
511
+ factor: 1.25
512
+ },
513
+ normal: {
514
+ relative: 0.4,
515
+ minMs: 100,
516
+ smallSampleRelative: 0.8,
517
+ p99Relative: 0.2,
518
+ apdexAbsolute: 0.05,
519
+ apdexSmallSampleAbsolute: 0.1,
520
+ factor: 1.5
521
+ },
522
+ loose: {
523
+ relative: 0.6,
524
+ minMs: 200,
525
+ smallSampleRelative: 1.2,
526
+ p99Relative: 0.35,
527
+ apdexAbsolute: 0.08,
528
+ apdexSmallSampleAbsolute: 0.15,
529
+ factor: 2
530
+ }
531
+ };
532
+ function presetOf(input) {
533
+ const thresholds = isRecord(input) ? input.thresholds : void 0;
534
+ const preset = isRecord(thresholds) ? thresholds.preset : void 0;
535
+ return MARGIN_PRESETS.includes(preset) ? preset : "normal";
536
+ }
537
+ function presetLayer(preset) {
538
+ const v = VALUES[preset];
539
+ const time = { relative: v.relative, minMs: v.minMs, smallSampleRelative: v.smallSampleRelative };
540
+ return {
541
+ checks: {
542
+ time: {
543
+ median: { margin: time },
544
+ percentile: { margin: { ...time } },
545
+ p99: { margin: { relative: v.p99Relative } }
546
+ },
547
+ slowShare: {
548
+ apdex: {
549
+ margin: { absolute: v.apdexAbsolute, smallSampleAbsolute: v.apdexSmallSampleAbsolute }
550
+ },
551
+ wilson: { margin: { factor: v.factor } }
552
+ },
553
+ errors: { margin: { factor: v.factor } }
554
+ }
555
+ };
556
+ }
557
+
453
558
  // src/core/schema/config.ts
454
559
  var factor10 = num({ minimum: 0, maximum: 10 });
455
560
  var unit = num({ minimum: 0, maximum: 1 });
@@ -463,7 +568,7 @@ var urlPattern = oneOf(
463
568
  { required: ["regex"] }
464
569
  )
465
570
  );
466
- var limitByKind = (value) => obj({ api: value, custom: value });
571
+ var limitByKind = (value) => obj({ api: value, step: value });
467
572
  var relativeMargin = obj({
468
573
  relative: factor10,
469
574
  minMs: int({ minimum: 0 }),
@@ -503,7 +608,7 @@ var checks = obj({
503
608
  p99: obj({ enabled, minSamples, margin: p99Margin, limit: limitByKind(msLimit) })
504
609
  }),
505
610
  slowShare: obj({
506
- t: obj({ api: tSettings, custom: tSettings }),
611
+ t: obj({ api: tSettings, step: tSettings }),
507
612
  apdex: obj({ enabled, minSamples, margin: apdexMargin, limit: limitByKind(ratio) }),
508
613
  wilson: obj({ enabled, minSamples, margin: wilsonMargin, limit: limitByKind(ratio) })
509
614
  }),
@@ -528,14 +633,16 @@ var packageConfig = obj({
528
633
  $schema: str(),
529
634
  run: obj({
530
635
  env: envLabelOrNull,
531
- repeat: obj({
636
+ passes: obj({
532
637
  test: int({ minimum: 1, maximum: 1e3 }),
533
638
  thresholds: int({ minimum: 1, maximum: 1e3 })
534
639
  }),
535
- projects: oneOf(constant("auto"), arr(str(), { minItems: 1, uniqueItems: true })),
536
- keepReporters: uniqueStrings(1)
640
+ grep: nullable(str({ minLength: 1 })),
641
+ keepReporters: uniqueStrings(1),
642
+ overrideSlowMo: bool
537
643
  }),
538
644
  measure: obj({
645
+ api: bool,
539
646
  resourceTypes: arr(
540
647
  enumOf([
541
648
  "document",
@@ -570,13 +677,30 @@ var packageConfig = obj({
570
677
  minItems: 1
571
678
  }
572
679
  ),
680
+ steps: oneOf(
681
+ bool,
682
+ obj({
683
+ enabled: bool,
684
+ include: arr(urlPattern),
685
+ exclude: arr(urlPattern),
686
+ maxDepth: int({ minimum: 1, maximum: 10 }),
687
+ categories: arr(enumOf(["test.step", "expect", "pw:api", "fixture", "hook"]), {
688
+ minItems: 1,
689
+ uniqueItems: true
690
+ }),
691
+ groupBy: enumOf(["step", "test"]),
692
+ normalizeTitles: bool,
693
+ redactQuotedValues: bool
694
+ })
695
+ ),
573
696
  pendingTimeoutMs: int({ minimum: 0, maximum: 6e4 })
574
697
  }),
575
698
  keys: obj({
576
699
  origins: record(
577
700
  str({
578
- pattern: /^https?:\/\/[^/?#]+$/u,
579
- format: 'an origin without a path, like "https://api.example.com"'
701
+ // Keys with * are host patterns, checked by resolveConfig (03-REQ-20).
702
+ pattern: /^(?:https?:\/\/[^/?#]+|.*\*.*)$/u,
703
+ format: 'an origin without a path, like "https://api.example.com", or a host pattern like "https://*.ci.example.com"'
580
704
  }),
581
705
  str({
582
706
  pattern: /^[a-z0-9.-]*$/u,
@@ -590,6 +714,7 @@ var packageConfig = obj({
590
714
  hex: bool,
591
715
  token: bool,
592
716
  mixed: bool,
717
+ prefixed: bool,
593
718
  email: bool
594
719
  }),
595
720
  extraIdPatterns: arr(urlPattern),
@@ -609,10 +734,10 @@ var packageConfig = obj({
609
734
  ),
610
735
  hardLimitFactor: nullable(num({ minimum: 1 })),
611
736
  defaultThresholds: enumOf(["block", "warn"]),
612
- warnOnly: bool,
613
737
  maxFailedTestShare: unit
614
738
  }),
615
739
  thresholds: obj({
740
+ preset: enumOf(["strict", "normal", "loose"]),
616
741
  dir: str({ minLength: 1 }),
617
742
  filePrefix: str({
618
743
  pattern: /^[A-Za-z0-9._-]+$/u,
@@ -651,25 +776,127 @@ var derivationSettings = obj(
651
776
  { required: ["t", "smallSampleN", "margins"] }
652
777
  );
653
778
 
779
+ // src/core/normalize/host-patterns.ts
780
+ var FORM = /^([A-Za-z]+):\/\/([^/?#@:]+)(?::([0-9]+))?\/?$/u;
781
+ var LABEL = /^[a-z0-9*-]+$/u;
782
+ var DEFAULT_PORT = { http: "80", https: "443" };
783
+ function isHostPattern(key2) {
784
+ return key2.includes("*");
785
+ }
786
+ function parseHostPattern(text, label) {
787
+ const match = FORM.exec(text);
788
+ if (match === null) {
789
+ return "a host pattern must have the form <scheme>://<host>[:<port>], without a path, query, fragment or credentials";
790
+ }
791
+ const scheme = (match[1] ?? "").toLowerCase();
792
+ if (scheme !== "http" && scheme !== "https")
793
+ return "the scheme of a host pattern must be http or https";
794
+ const host = (match[2] ?? "").toLowerCase();
795
+ const labels = host.split(".");
796
+ if (labels.length < 2) return "a host pattern needs at least two host labels, e.g. *.example.com";
797
+ for (const part of labels) {
798
+ if (part === "" || !LABEL.test(part)) {
799
+ return 'host labels may contain only letters, digits, "-" and "*" (international names in their xn-- form)';
800
+ }
801
+ if (part.split("*").length > 2) return 'a host label may contain at most one "*"';
802
+ }
803
+ if ((labels.at(-1) ?? "").includes("*"))
804
+ return 'the last host label (the top-level domain) cannot contain "*"';
805
+ if (labels.every((part) => part.includes("*"))) {
806
+ return 'at least one host label must be without "*", or the pattern would match every host';
807
+ }
808
+ let port = match[3] ?? "";
809
+ if (port !== "") {
810
+ const n = Number(port);
811
+ if (!Number.isInteger(n) || n < 1 || n > 65535)
812
+ return "the port must be a number from 1 to 65535";
813
+ port = String(n);
814
+ if (port === DEFAULT_PORT[scheme]) port = "";
815
+ }
816
+ return {
817
+ scheme,
818
+ labels,
819
+ port,
820
+ canonical: `${scheme}://${host}${port === "" ? "" : `:${port}`}`,
821
+ label
822
+ };
823
+ }
824
+ function labelMatches(pattern, label) {
825
+ const star = pattern.indexOf("*");
826
+ if (star < 0) return pattern === label;
827
+ const before = pattern.slice(0, star);
828
+ const after = pattern.slice(star + 1);
829
+ return label.length > before.length + after.length && label.startsWith(before) && label.endsWith(after);
830
+ }
831
+ function patternMatches(pattern, url) {
832
+ if (url.protocol !== `${pattern.scheme}:`) return false;
833
+ if (url.port !== pattern.port) return false;
834
+ if (url.hostname.startsWith("[")) return false;
835
+ const labels = url.hostname.toLowerCase().split(".");
836
+ if (labels.length !== pattern.labels.length) return false;
837
+ return pattern.labels.every((part, i) => labelMatches(part, labels[i] ?? ""));
838
+ }
839
+ function literal(pattern) {
840
+ return pattern.labels.join(".").replaceAll("*", "").length;
841
+ }
842
+ function stars(pattern) {
843
+ return pattern.labels.filter((part) => part.includes("*")).length;
844
+ }
845
+ function sortPatterns(patterns) {
846
+ return [...patterns].sort(
847
+ (a, b) => literal(b) - literal(a) || stars(a) - stars(b) || (a.canonical < b.canonical ? -1 : a.canonical > b.canonical ? 1 : 0)
848
+ );
849
+ }
850
+ function compileHostPatterns(origins) {
851
+ const out = [];
852
+ for (const [key2, label] of Object.entries(origins)) {
853
+ if (!isHostPattern(key2)) continue;
854
+ const parsed = parseHostPattern(key2, label);
855
+ if (typeof parsed !== "string") out.push(parsed);
856
+ }
857
+ return sortPatterns(out);
858
+ }
859
+ function matchingPattern(patterns, url) {
860
+ return patterns.find((p) => patternMatches(p, url)) ?? null;
861
+ }
862
+
654
863
  // src/core/config/validate.ts
655
864
  var SCHEMA_FILE = "schemas/config.schema.json";
865
+ var REMOVED_WARN_ONLY_HINT = "The trial mode was removed in 0.1.0-next.3; to keep a CI job green on a regression, set continue-on-error on the job (see docs/ci.md), or use gate.tolerance or gate.defaultThresholds: 'warn'.";
866
+ var REMOVED_CUSTOM_HINT = "custom measurements were removed in 0.1.0-next.3; use measure.steps and limit.step (test.step durations) instead.";
656
867
  var MAX_SUGGESTION_DISTANCE = 2;
657
868
  var MAX_SCHEMA_PROBLEMS = 1e3;
658
869
  var PATTERN_LISTS = [
659
870
  ["measure", "include"],
660
871
  ["measure", "exclude"],
872
+ ["measure", "steps", "include"],
873
+ ["measure", "steps", "exclude"],
661
874
  ["keys", "extraIdPatterns"]
662
875
  ];
876
+ var RESERVED_ENV_LABELS = ["steps", "requests"];
877
+ function reservedEnvIssue(segments, label) {
878
+ return issue2(
879
+ "CONFIG_INVALID_VALUE",
880
+ segments,
881
+ `the environment label ${JSON.stringify(label)} is reserved: it is a part of the thresholds file names (pw-perf-thresholds.${label}.json)`,
882
+ `Use another environment label, e.g. "${label}-env".`
883
+ );
884
+ }
663
885
  function issue2(code, segments, message, hint) {
664
886
  const path = formatPath(segments);
665
887
  return { code, path, message: `${path === "" ? "config" : path}: ${message}`, hint };
666
888
  }
667
889
  function isPatternItem(segments) {
668
- return segments.length === 3 && typeof segments[2] === "number" && PATTERN_LISTS.some(([a, b]) => segments[0] === a && segments[1] === b);
890
+ return typeof segments.at(-1) === "number" && PATTERN_LISTS.some(
891
+ (list) => segments.length === list.length + 1 && list.every((name, i) => segments[i] === name)
892
+ );
669
893
  }
670
894
  function knownOptions(parent) {
671
895
  if (isPatternItem(parent)) return ["regex", "flags"];
672
896
  if (parent[0] === "keys" && parent[1] === "origins") return [];
897
+ if (parent.length === 2 && parent[0] === "measure" && parent[1] === "steps") {
898
+ return [...STEP_OPTION_NAMES];
899
+ }
673
900
  const node = valueAt(DEFAULT_CONFIG, parent);
674
901
  const names = isRecord(node) ? Object.keys(node) : [];
675
902
  if (parent.length === 0) names.push("$schema");
@@ -695,8 +922,13 @@ function suggestOption(parent, name) {
695
922
  const moved = allOptionPaths(DEFAULT_CONFIG).find((path) => path.at(-1) === name);
696
923
  return moved === void 0 ? void 0 : formatPath(moved);
697
924
  }
925
+ function isRemovedCustomOption(parent, name) {
926
+ if (name !== "custom" || parent[0] !== "checks") return false;
927
+ if (parent.at(-1) === "limit") return true;
928
+ return parent.length === 3 && parent[1] === "slowShare" && parent[2] === "t";
929
+ }
698
930
  function exampleHint(segments) {
699
- let example = valueAt(DEFAULT_CONFIG, segments);
931
+ let example = segments[0] === "measure" && segments[1] === "steps" && segments.length > 2 ? valueAt(STEP_DEFAULTS, segments.slice(2)) : valueAt(DEFAULT_CONFIG, segments);
700
932
  if (example === void 0 && typeof segments.at(-1) === "number") {
701
933
  const list = valueAt(DEFAULT_CONFIG, segments.slice(0, -1));
702
934
  if (Array.isArray(list)) example = list[0];
@@ -709,6 +941,28 @@ function problemToIssue(problem, document) {
709
941
  const segments = pointerSegments(problem.pointer, document);
710
942
  if (problem.kind === "unknown" && problem.property !== void 0) {
711
943
  const option = [...segments, problem.property];
944
+ if (isRemovedCustomOption(segments, problem.property)) {
945
+ return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_CUSTOM_HINT);
946
+ }
947
+ if (problem.property === "keepQuotedValues" && segments.length === 2 && segments[0] === "measure" && segments[1] === "steps") {
948
+ return issue2(
949
+ "CONFIG_UNKNOWN_OPTION",
950
+ option,
951
+ "unknown option",
952
+ "keepQuotedValues was renamed to redactQuotedValues with the opposite meaning: quoted values stay in step keys by default; set measure.steps.redactQuotedValues to true to replace them."
953
+ );
954
+ }
955
+ if (problem.property === "repeat" && segments.length === 1 && segments[0] === "run") {
956
+ return issue2(
957
+ "CONFIG_UNKNOWN_OPTION",
958
+ option,
959
+ "unknown option",
960
+ "Renamed to run.passes: the test command now runs once per pass (repeatEach is 1); e.g. run: { passes: { test: 5, thresholds: 10 } }."
961
+ );
962
+ }
963
+ if (problem.property === "warnOnly" && segments.length === 1 && segments[0] === "gate") {
964
+ return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_WARN_ONLY_HINT);
965
+ }
712
966
  const suggestion = suggestOption(segments, problem.property);
713
967
  return issue2(
714
968
  "CONFIG_UNKNOWN_OPTION",
@@ -732,8 +986,8 @@ function schemaIssues(document) {
732
986
  }
733
987
  function regexIssues(document) {
734
988
  const issues = [];
735
- for (const [section, option] of PATTERN_LISTS) {
736
- const list = valueAt(document, [section, option]);
989
+ for (const path of PATTERN_LISTS) {
990
+ const list = valueAt(document, path);
737
991
  if (!Array.isArray(list)) continue;
738
992
  list.forEach((item, index) => {
739
993
  if (!isRecord(item) || typeof item.regex !== "string") return;
@@ -745,7 +999,7 @@ function regexIssues(document) {
745
999
  issues.push(
746
1000
  issue2(
747
1001
  "CONFIG_INVALID_REGEX",
748
- [section, option, index],
1002
+ [...path, index],
749
1003
  `regular expression does not compile (${reason})`,
750
1004
  'Fix the expression; it uses JavaScript RegExp syntax, e.g. { "regex": "^/api/v[0-9]+/", "flags": "i" }.'
751
1005
  )
@@ -753,6 +1007,22 @@ function regexIssues(document) {
753
1007
  }
754
1008
  });
755
1009
  }
1010
+ const grep = valueAt(document, ["run", "grep"]);
1011
+ if (typeof grep === "string" && grep !== "") {
1012
+ try {
1013
+ new RegExp(grep, "i");
1014
+ } catch (error) {
1015
+ const reason = error instanceof Error ? error.message : String(error);
1016
+ issues.push(
1017
+ issue2(
1018
+ "CONFIG_INVALID_REGEX",
1019
+ ["run", "grep"],
1020
+ `regular expression does not compile (${reason})`,
1021
+ "Fix the expression; it uses JavaScript RegExp syntax, e.g. '@perf' or '@perf|@smoke'."
1022
+ )
1023
+ );
1024
+ }
1025
+ }
756
1026
  return issues;
757
1027
  }
758
1028
  var numberAt = (config, segments) => {
@@ -767,7 +1037,7 @@ var RULES = [
767
1037
  ["checks", "slowShare", "wilson"],
768
1038
  ["checks", "errors"]
769
1039
  ];
770
- var KINDS = ["api", "custom"];
1040
+ var KINDS = ["api", "step"];
771
1041
  var MIN_PERCENTILE = 50;
772
1042
  function percentileLevel(name) {
773
1043
  if (typeof name !== "string" || !/^p\d+(?:\.\d)?$/u.test(name)) return void 0;
@@ -837,21 +1107,69 @@ function relationalIssues(config, isSet) {
837
1107
  );
838
1108
  }
839
1109
  const enabled2 = RULES.some((rule) => valueAt(config, [...rule, "enabled"]) !== false);
840
- if (!enabled2 && valueAt(config, ["gate", "warnOnly"]) !== true) {
1110
+ if (!enabled2) {
841
1111
  errors.push(
842
1112
  issue2(
843
1113
  "CONFIG_INVALID_VALUE",
844
1114
  ["checks"],
845
1115
  "every rule is disabled, so nothing would be checked",
846
- "Enable at least one rule in checks, or set gate.warnOnly to true."
1116
+ "Enable at least one rule in checks."
1117
+ )
1118
+ );
1119
+ }
1120
+ const steps = valueAt(config, ["measure", "steps"]);
1121
+ const stepsOff = steps === false || isRecord(steps) && steps["enabled"] === false;
1122
+ if (valueAt(config, ["measure", "api"]) === false && stepsOff) {
1123
+ errors.push(
1124
+ issue2(
1125
+ "CONFIG_INVALID_VALUE",
1126
+ ["measure"],
1127
+ "measure.api and measure.steps are both off, so nothing would be measured",
1128
+ "Turn on at least one of them: measure.api (backend requests) or measure.steps (test.step durations)."
847
1129
  )
848
1130
  );
849
1131
  }
1132
+ const env = valueAt(config, ["run", "env"]);
1133
+ if (typeof env === "string" && RESERVED_ENV_LABELS.includes(env)) {
1134
+ errors.push(reservedEnvIssue(["run", "env"], env));
1135
+ }
1136
+ const originMap = valueAt(config, ["keys", "origins"]);
1137
+ if (isRecord(originMap)) {
1138
+ const seen = /* @__PURE__ */ new Map();
1139
+ for (const [key2, label] of Object.entries(originMap)) {
1140
+ if (!isHostPattern(key2) || typeof label !== "string") continue;
1141
+ const parsed = parseHostPattern(key2, label);
1142
+ if (typeof parsed === "string") {
1143
+ errors.push(
1144
+ issue2(
1145
+ "CONFIG_INVALID_VALUE",
1146
+ ["keys", "origins", key2],
1147
+ parsed,
1148
+ 'Write a host pattern like "https://*.ci.example.com": one "*" inside a host label, a top-level domain without "*" (docs/dynamic-environments.md).'
1149
+ )
1150
+ );
1151
+ continue;
1152
+ }
1153
+ const other = seen.get(parsed.canonical);
1154
+ if (other !== void 0) {
1155
+ errors.push(
1156
+ issue2(
1157
+ "CONFIG_INVALID_VALUE",
1158
+ ["keys", "origins", key2],
1159
+ `the host pattern is the same as ${JSON.stringify(other)} after canonicalization (${parsed.canonical})`,
1160
+ "Keep one of the two patterns."
1161
+ )
1162
+ );
1163
+ } else {
1164
+ seen.set(parsed.canonical, key2);
1165
+ }
1166
+ }
1167
+ }
850
1168
  const origins = valueAt(config, ["keys", "origins"]);
851
1169
  if (isRecord(origins)) {
852
1170
  const byLabel = /* @__PURE__ */ new Map();
853
1171
  for (const [origin, label] of Object.entries(origins)) {
854
- if (typeof label !== "string") continue;
1172
+ if (typeof label !== "string" || isHostPattern(origin)) continue;
855
1173
  byLabel.set(label, [...byLabel.get(label) ?? [], origin]);
856
1174
  }
857
1175
  for (const [label, list] of byLabel) {
@@ -882,7 +1200,7 @@ function relationalIssues(config, isSet) {
882
1200
 
883
1201
  // src/core/config/resolve.ts
884
1202
  var KEY_BUILDER_SNAPSHOT = "[function]";
885
- var repeatSchema = int({ minimum: 1, maximum: 1e3 });
1203
+ var passesSchema = int({ minimum: 1, maximum: 1e3 });
886
1204
  function isPlainObject(value) {
887
1205
  if (!isRecord(value)) return false;
888
1206
  const prototype = Object.getPrototypeOf(value);
@@ -1003,13 +1321,13 @@ function overrideIssues(overrides) {
1003
1321
  )
1004
1322
  );
1005
1323
  }
1006
- if (overrides.repeat !== void 0 && !matches(repeatSchema, overrides.repeat)) {
1324
+ if (overrides.passes !== void 0 && !matches(passesSchema, overrides.passes)) {
1007
1325
  issues.push(
1008
1326
  issue2(
1009
1327
  "CONFIG_INVALID_VALUE",
1010
- ["run", "repeat", overrides.mode ?? "test"],
1011
- `the repeat override must be an integer from 1 to 1000, got ${describeValue(overrides.repeat)}`,
1012
- "Fix the number of repetitions, e.g. 5."
1328
+ ["run", "passes", overrides.mode ?? "test"],
1329
+ `the passes override must be an integer from 1 to 1000, got ${describeValue(overrides.passes)}`,
1330
+ "Fix the number of passes, e.g. 5."
1013
1331
  )
1014
1332
  );
1015
1333
  }
@@ -1017,8 +1335,13 @@ function overrideIssues(overrides) {
1017
1335
  }
1018
1336
  function applyOverrides(config, overrides) {
1019
1337
  if (overrides.env !== void 0) config.run.env = overrides.env;
1020
- if (overrides.repeat !== void 0) {
1021
- config.run.repeat[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.repeat;
1338
+ if (overrides.thresholdsDir !== void 0) config.thresholds.dir = overrides.thresholdsDir;
1339
+ if (overrides.minSamples !== void 0) {
1340
+ const median = config.checks.time.median;
1341
+ median.minSamples = Math.min(median.minSamples, overrides.minSamples);
1342
+ }
1343
+ if (overrides.passes !== void 0) {
1344
+ config.run.passes[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.passes;
1022
1345
  }
1023
1346
  }
1024
1347
  function snapshotPattern(pattern) {
@@ -1040,13 +1363,15 @@ function resolveConfig(input, overrides) {
1040
1363
  ...overrideIssues(overrides)
1041
1364
  ];
1042
1365
  const { $schema: _schema, ...withoutSchema } = isRecord(document) ? document : {};
1043
- const merged = merge(DEFAULT_CONFIG, withoutSchema);
1366
+ const defaults = merge(DEFAULT_CONFIG, presetLayer(presetOf(withoutSchema)));
1367
+ const merged = merge(defaults, withoutSchema);
1044
1368
  if (errors.length === 0) applyOverrides(merged, overrides);
1045
1369
  const relational = relationalIssues(merged, (path) => order.has(formatPath(path)));
1046
1370
  errors.push(...relational.errors);
1047
1371
  if (errors.length > 0) return { ok: false, issues: sortByInput(errors, order) };
1048
- for (const [section, option] of PATTERN_LISTS) {
1049
- const list = valueAt(merged, [section, option]);
1372
+ merged.measure.steps = expandSteps(merged.measure.steps);
1373
+ for (const path of PATTERN_LISTS) {
1374
+ const list = valueAt(merged, path);
1050
1375
  list.splice(0, list.length, ...list.map(snapshotPattern));
1051
1376
  }
1052
1377
  if (keyBuilder.inSnapshot) merged.keys.keyBuilder = KEY_BUILDER_SNAPSHOT;
@@ -1058,7 +1383,12 @@ function resolveConfig(input, overrides) {
1058
1383
  measure: {
1059
1384
  ...copy.measure,
1060
1385
  include: snapshot.measure.include.map(compilePattern),
1061
- exclude: snapshot.measure.exclude.map(compilePattern)
1386
+ exclude: snapshot.measure.exclude.map(compilePattern),
1387
+ steps: {
1388
+ ...copy.measure.steps,
1389
+ include: snapshot.measure.steps.include.map(compilePattern),
1390
+ exclude: snapshot.measure.steps.exclude.map(compilePattern)
1391
+ }
1062
1392
  },
1063
1393
  keys: {
1064
1394
  ...clone(keys),
@@ -1094,4 +1424,4 @@ function resolveDefaults() {
1094
1424
  }
1095
1425
  var perfDefaults = deepFreeze(resolveDefaults());
1096
1426
 
1097
- export { DEFAULT_CONFIG, Sink, anyObject, arr, bool, child, constant, count, definePerfConfig, derivationSettings, enumOf, envLabelOrNull, epochMs, evaluationStatus, fingerprint, hostFingerprint, int, isRecord, isoDate, issue, key, kind, mode, ms, msLimit, msOrNull, nul, nullable, num, obj, oneOf, packageConfig, percentileName, perfDefaults, ratio, record, resolveConfig, runId, str, testsStatus, timestamp, tool };
1427
+ export { DEFAULT_CONFIG, MARGIN_PRESETS, Sink, anyObject, arr, bool, child, compileHostPatterns, constant, count, definePerfConfig, derivationSettings, enumOf, envLabelOrNull, epochMs, evaluationStatus, expandSteps, fingerprint, hostFingerprint, int, isHostPattern, isRecord, isoDate, issue, key, kind, matchingPattern, mode, ms, msLimit, msOrNull, nul, nullable, num, obj, oneOf, packageConfig, percentileName, perfDefaults, ratio, record, resolveConfig, runId, str, testsStatus, timestamp, tool };