playwright-performance-regression 0.1.0-next.0 → 0.1.0-next.3

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 (40) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +73 -52
  3. package/dist/{chunk-GCA73FFP.cjs → chunk-2JO5HVPC.cjs} +351 -44
  4. package/dist/{chunk-R2NPYGB7.cjs → chunk-44ASXVQN.cjs} +96 -198
  5. package/dist/{chunk-HES6BVZT.js → chunk-AQ2XKYNV.js} +349 -47
  6. package/dist/chunk-BAOTUUTV.cjs +611 -0
  7. package/dist/chunk-DX36GFOZ.js +558 -0
  8. package/dist/chunk-LTRHMBVY.js +5592 -0
  9. package/dist/{chunk-UTTU4FUC.js → chunk-MUZFQKGQ.js} +82 -184
  10. package/dist/cli.js +3500 -1157
  11. package/dist/config.cjs +91 -44
  12. package/dist/config.d.cts +4 -2
  13. package/dist/config.d.ts +4 -2
  14. package/dist/config.js +84 -37
  15. package/dist/fixture.cjs +5 -5
  16. package/dist/fixture.d.cts +2 -2
  17. package/dist/fixture.d.ts +2 -2
  18. package/dist/fixture.js +3 -3
  19. package/dist/index.cjs +3 -3
  20. package/dist/index.d.cts +110 -22
  21. package/dist/index.d.ts +110 -22
  22. package/dist/index.js +1 -1
  23. package/dist/perf-api-Rm1h1O_-.d.cts +12 -0
  24. package/dist/perf-api-Rm1h1O_-.d.ts +12 -0
  25. package/dist/reporter.cjs +5204 -1209
  26. package/dist/reporter.js +2035 -254
  27. package/dist/test.cjs +4 -4
  28. package/dist/test.js +3 -3
  29. package/package.json +5 -3
  30. package/schemas/common.schema.json +2 -2
  31. package/schemas/config.schema.json +57 -21
  32. package/schemas/outcome.schema.json +1 -1
  33. package/schemas/run-report.schema.json +534 -19
  34. package/schemas/samples.schema.json +4 -39
  35. package/schemas/thresholds.schema.json +1 -1
  36. package/dist/chunk-6AB42SPF.js +0 -254
  37. package/dist/chunk-JEHUFIY3.js +0 -3390
  38. package/dist/chunk-LV3O2BAT.cjs +0 -319
  39. package/dist/perf-api-V4PeHVE0.d.cts +0 -22
  40. package/dist/perf-api-V4PeHVE0.d.ts +0 -22
@@ -236,7 +236,7 @@ var envLabel = str({
236
236
  format: 'a label of lowercase letters, digits and "-", like "staging"'
237
237
  });
238
238
  var envLabelOrNull = nullable(envLabel);
239
- var kind = enumOf(["api", "custom"]);
239
+ var kind = enumOf(["api", "step"]);
240
240
  var percentileName = str({
241
241
  pattern: /^p(?:[1-9][0-9]?)(?:\.[0-9])?$/u,
242
242
  format: 'a percentile name like "p95" or "p99.9"'
@@ -272,7 +272,13 @@ var isoDate = str({ pattern: /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
272
272
 
273
273
  // src/core/config/generated/defaults.ts
274
274
  var DEFAULT_CONFIG = {
275
- run: { env: null, repeat: { test: 5, thresholds: 10 }, projects: "auto", keepReporters: [] },
275
+ run: {
276
+ env: null,
277
+ passes: { test: 5, thresholds: 10 },
278
+ projects: "auto",
279
+ grep: null,
280
+ keepReporters: []
281
+ },
276
282
  measure: {
277
283
  resourceTypes: ["document", "xhr", "fetch"],
278
284
  ignoreExtensions: [
@@ -299,6 +305,7 @@ var DEFAULT_CONFIG = {
299
305
  exclude: ["/socket.io/"],
300
306
  excludeKnownThirdParty: true,
301
307
  successStatuses: ["2xx", "3xx"],
308
+ steps: false,
302
309
  pendingTimeoutMs: 2e3
303
310
  },
304
311
  keys: {
@@ -315,64 +322,59 @@ var DEFAULT_CONFIG = {
315
322
  enabled: true,
316
323
  minSamples: 5,
317
324
  margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 },
318
- limit: { api: 2e3, custom: 5e3 }
325
+ limit: { api: 2e3, step: 1e4 }
319
326
  },
320
327
  percentile: {
321
328
  enabled: true,
322
329
  minSamples: 20,
323
330
  level: "p95",
324
- limit: { api: 2e3, custom: 5e3 },
331
+ limit: { api: 2e3, step: 15e3 },
325
332
  margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 }
326
333
  },
327
334
  p99: {
328
335
  enabled: true,
329
336
  minSamples: 100,
330
337
  margin: { relative: 0.2, minGapMs: 50, minGapRelative: 0.1 },
331
- limit: { api: 4e3, custom: 1e4 }
338
+ limit: { api: 4e3, step: 3e4 }
332
339
  }
333
340
  },
334
341
  slowShare: {
335
342
  t: {
336
343
  api: { min: 500, max: 2e3, medianFactor: 2 },
337
- custom: { min: 1e3, max: 1e4, medianFactor: 2 }
344
+ step: { min: 1e3, max: 1e4, medianFactor: 2 }
338
345
  },
339
346
  apdex: {
340
347
  enabled: true,
341
348
  minSamples: 20,
342
349
  margin: { absolute: 0.05, smallSampleAbsolute: 0.1 },
343
- limit: { api: 0.85, custom: 0.85 }
350
+ limit: { api: 0.85, step: 0.85 }
344
351
  },
345
352
  wilson: {
346
353
  enabled: true,
347
354
  minSamples: 20,
348
355
  margin: { factor: 1.5, add: 0.02, min: 0.03, max: 0.15, smallSampleMin: 0.1 },
349
- limit: { api: 0.05, custom: 0.05 }
356
+ limit: { api: 0.05, step: 0.05 }
350
357
  }
351
358
  },
352
359
  errors: {
353
360
  enabled: true,
354
361
  minSamples: 5,
355
362
  statuses: ["5xx", "FAILED", "PENDING"],
356
- limit: { api: 0.05, custom: 0.05 },
363
+ limit: { api: 0.05, step: 0.05 },
357
364
  margin: { factor: 1.5, add: 0.02, min: 0.05 }
358
365
  }
359
366
  },
360
- gate: {
361
- tolerance: 0,
362
- hardLimitFactor: 2,
363
- defaultThresholds: "block",
364
- warnOnly: false,
365
- maxFailedTestShare: 0.1
366
- },
367
+ gate: { tolerance: 0, hardLimitFactor: 2, defaultThresholds: "block", maxFailedTestShare: 0.1 },
367
368
  thresholds: {
369
+ preset: "normal",
368
370
  dir: ".",
369
- filePrefix: "perf-thresholds",
371
+ filePrefix: "pw-perf-thresholds",
370
372
  update: "all",
371
373
  smallSampleN: 20,
372
374
  hysteresis: { relative: 0.1, ratio: 0.01 },
373
375
  loosenWarnRelative: 0.5
374
376
  },
375
- report: { dir: "perf-results", html: true, rawUrls: false },
377
+ report: { dir: "pw-perf-results", html: true, rawUrls: false },
376
378
  advanced: { maxSamplesPerKey: 5e3, seed: 1 }
377
379
  };
378
380
 
@@ -452,6 +454,100 @@ function editDistance(a, b) {
452
454
  return previous[b.length] ?? 0;
453
455
  }
454
456
 
457
+ // src/core/config/steps.ts
458
+ var STEP_OPTION_NAMES = [
459
+ "enabled",
460
+ "include",
461
+ "exclude",
462
+ "maxDepth",
463
+ "categories",
464
+ "groupBy",
465
+ "normalizeTitles",
466
+ "redactQuotedValues"
467
+ ];
468
+ var STEP_DEFAULTS = {
469
+ include: [],
470
+ exclude: [],
471
+ maxDepth: 3,
472
+ categories: ["test.step"],
473
+ groupBy: "step",
474
+ normalizeTitles: true,
475
+ redactQuotedValues: false
476
+ };
477
+ function expandSteps(value) {
478
+ const defaults = () => ({
479
+ ...STEP_DEFAULTS,
480
+ include: [],
481
+ exclude: [],
482
+ categories: [...STEP_DEFAULTS.categories]
483
+ });
484
+ if (value === void 0 || typeof value === "boolean") {
485
+ return { enabled: value === true, ...defaults() };
486
+ }
487
+ return {
488
+ enabled: value.enabled ?? true,
489
+ ...defaults(),
490
+ ...Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0))
491
+ };
492
+ }
493
+
494
+ // src/core/config/presets.ts
495
+ var MARGIN_PRESETS = ["strict", "normal", "loose"];
496
+ var VALUES = {
497
+ strict: {
498
+ relative: 0.25,
499
+ minMs: 50,
500
+ smallSampleRelative: 0.5,
501
+ p99Relative: 0.1,
502
+ apdexAbsolute: 0.03,
503
+ apdexSmallSampleAbsolute: 0.06,
504
+ factor: 1.25
505
+ },
506
+ normal: {
507
+ relative: 0.4,
508
+ minMs: 100,
509
+ smallSampleRelative: 0.8,
510
+ p99Relative: 0.2,
511
+ apdexAbsolute: 0.05,
512
+ apdexSmallSampleAbsolute: 0.1,
513
+ factor: 1.5
514
+ },
515
+ loose: {
516
+ relative: 0.6,
517
+ minMs: 200,
518
+ smallSampleRelative: 1.2,
519
+ p99Relative: 0.35,
520
+ apdexAbsolute: 0.08,
521
+ apdexSmallSampleAbsolute: 0.15,
522
+ factor: 2
523
+ }
524
+ };
525
+ function presetOf(input) {
526
+ const thresholds = isRecord(input) ? input.thresholds : void 0;
527
+ const preset = isRecord(thresholds) ? thresholds.preset : void 0;
528
+ return MARGIN_PRESETS.includes(preset) ? preset : "normal";
529
+ }
530
+ function presetLayer(preset) {
531
+ const v = VALUES[preset];
532
+ const time = { relative: v.relative, minMs: v.minMs, smallSampleRelative: v.smallSampleRelative };
533
+ return {
534
+ checks: {
535
+ time: {
536
+ median: { margin: time },
537
+ percentile: { margin: { ...time } },
538
+ p99: { margin: { relative: v.p99Relative } }
539
+ },
540
+ slowShare: {
541
+ apdex: {
542
+ margin: { absolute: v.apdexAbsolute, smallSampleAbsolute: v.apdexSmallSampleAbsolute }
543
+ },
544
+ wilson: { margin: { factor: v.factor } }
545
+ },
546
+ errors: { margin: { factor: v.factor } }
547
+ }
548
+ };
549
+ }
550
+
455
551
  // src/core/schema/config.ts
456
552
  var factor10 = num({ minimum: 0, maximum: 10 });
457
553
  var unit = num({ minimum: 0, maximum: 1 });
@@ -465,7 +561,7 @@ var urlPattern = oneOf(
465
561
  { required: ["regex"] }
466
562
  )
467
563
  );
468
- var limitByKind = (value) => obj({ api: value, custom: value });
564
+ var limitByKind = (value) => obj({ api: value, step: value });
469
565
  var relativeMargin = obj({
470
566
  relative: factor10,
471
567
  minMs: int({ minimum: 0 }),
@@ -505,7 +601,7 @@ var checks = obj({
505
601
  p99: obj({ enabled, minSamples, margin: p99Margin, limit: limitByKind(msLimit) })
506
602
  }),
507
603
  slowShare: obj({
508
- t: obj({ api: tSettings, custom: tSettings }),
604
+ t: obj({ api: tSettings, step: tSettings }),
509
605
  apdex: obj({ enabled, minSamples, margin: apdexMargin, limit: limitByKind(ratio) }),
510
606
  wilson: obj({ enabled, minSamples, margin: wilsonMargin, limit: limitByKind(ratio) })
511
607
  }),
@@ -530,11 +626,12 @@ var packageConfig = obj({
530
626
  $schema: str(),
531
627
  run: obj({
532
628
  env: envLabelOrNull,
533
- repeat: obj({
629
+ passes: obj({
534
630
  test: int({ minimum: 1, maximum: 1e3 }),
535
631
  thresholds: int({ minimum: 1, maximum: 1e3 })
536
632
  }),
537
633
  projects: oneOf(constant("auto"), arr(str(), { minItems: 1, uniqueItems: true })),
634
+ grep: nullable(str({ minLength: 1 })),
538
635
  keepReporters: uniqueStrings(1)
539
636
  }),
540
637
  measure: obj({
@@ -572,13 +669,30 @@ var packageConfig = obj({
572
669
  minItems: 1
573
670
  }
574
671
  ),
672
+ steps: oneOf(
673
+ bool,
674
+ obj({
675
+ enabled: bool,
676
+ include: arr(urlPattern),
677
+ exclude: arr(urlPattern),
678
+ maxDepth: int({ minimum: 1, maximum: 10 }),
679
+ categories: arr(enumOf(["test.step", "expect", "pw:api", "fixture", "hook"]), {
680
+ minItems: 1,
681
+ uniqueItems: true
682
+ }),
683
+ groupBy: enumOf(["step", "test"]),
684
+ normalizeTitles: bool,
685
+ redactQuotedValues: bool
686
+ })
687
+ ),
575
688
  pendingTimeoutMs: int({ minimum: 0, maximum: 6e4 })
576
689
  }),
577
690
  keys: obj({
578
691
  origins: record(
579
692
  str({
580
- pattern: /^https?:\/\/[^/?#]+$/u,
581
- format: 'an origin without a path, like "https://api.example.com"'
693
+ // Keys with * are host patterns, checked by resolveConfig (03-REQ-20).
694
+ pattern: /^(?:https?:\/\/[^/?#]+|.*\*.*)$/u,
695
+ format: 'an origin without a path, like "https://api.example.com", or a host pattern like "https://*.ci.example.com"'
582
696
  }),
583
697
  str({
584
698
  pattern: /^[a-z0-9.-]*$/u,
@@ -611,10 +725,10 @@ var packageConfig = obj({
611
725
  ),
612
726
  hardLimitFactor: nullable(num({ minimum: 1 })),
613
727
  defaultThresholds: enumOf(["block", "warn"]),
614
- warnOnly: bool,
615
728
  maxFailedTestShare: unit
616
729
  }),
617
730
  thresholds: obj({
731
+ preset: enumOf(["strict", "normal", "loose"]),
618
732
  dir: str({ minLength: 1 }),
619
733
  filePrefix: str({
620
734
  pattern: /^[A-Za-z0-9._-]+$/u,
@@ -653,25 +767,127 @@ var derivationSettings = obj(
653
767
  { required: ["t", "smallSampleN", "margins"] }
654
768
  );
655
769
 
770
+ // src/core/normalize/host-patterns.ts
771
+ var FORM = /^([A-Za-z]+):\/\/([^/?#@:]+)(?::([0-9]+))?\/?$/u;
772
+ var LABEL = /^[a-z0-9*-]+$/u;
773
+ var DEFAULT_PORT = { http: "80", https: "443" };
774
+ function isHostPattern(key2) {
775
+ return key2.includes("*");
776
+ }
777
+ function parseHostPattern(text, label) {
778
+ const match = FORM.exec(text);
779
+ if (match === null) {
780
+ return "a host pattern must have the form <scheme>://<host>[:<port>], without a path, query, fragment or credentials";
781
+ }
782
+ const scheme = (match[1] ?? "").toLowerCase();
783
+ if (scheme !== "http" && scheme !== "https")
784
+ return "the scheme of a host pattern must be http or https";
785
+ const host = (match[2] ?? "").toLowerCase();
786
+ const labels = host.split(".");
787
+ if (labels.length < 2) return "a host pattern needs at least two host labels, e.g. *.example.com";
788
+ for (const part of labels) {
789
+ if (part === "" || !LABEL.test(part)) {
790
+ return 'host labels may contain only letters, digits, "-" and "*" (international names in their xn-- form)';
791
+ }
792
+ if (part.split("*").length > 2) return 'a host label may contain at most one "*"';
793
+ }
794
+ if ((labels.at(-1) ?? "").includes("*"))
795
+ return 'the last host label (the top-level domain) cannot contain "*"';
796
+ if (labels.every((part) => part.includes("*"))) {
797
+ return 'at least one host label must be without "*", or the pattern would match every host';
798
+ }
799
+ let port = match[3] ?? "";
800
+ if (port !== "") {
801
+ const n = Number(port);
802
+ if (!Number.isInteger(n) || n < 1 || n > 65535)
803
+ return "the port must be a number from 1 to 65535";
804
+ port = String(n);
805
+ if (port === DEFAULT_PORT[scheme]) port = "";
806
+ }
807
+ return {
808
+ scheme,
809
+ labels,
810
+ port,
811
+ canonical: `${scheme}://${host}${port === "" ? "" : `:${port}`}`,
812
+ label
813
+ };
814
+ }
815
+ function labelMatches(pattern, label) {
816
+ const star = pattern.indexOf("*");
817
+ if (star < 0) return pattern === label;
818
+ const before = pattern.slice(0, star);
819
+ const after = pattern.slice(star + 1);
820
+ return label.length > before.length + after.length && label.startsWith(before) && label.endsWith(after);
821
+ }
822
+ function patternMatches(pattern, url) {
823
+ if (url.protocol !== `${pattern.scheme}:`) return false;
824
+ if (url.port !== pattern.port) return false;
825
+ if (url.hostname.startsWith("[")) return false;
826
+ const labels = url.hostname.toLowerCase().split(".");
827
+ if (labels.length !== pattern.labels.length) return false;
828
+ return pattern.labels.every((part, i) => labelMatches(part, labels[i] ?? ""));
829
+ }
830
+ function literal(pattern) {
831
+ return pattern.labels.join(".").replaceAll("*", "").length;
832
+ }
833
+ function stars(pattern) {
834
+ return pattern.labels.filter((part) => part.includes("*")).length;
835
+ }
836
+ function sortPatterns(patterns) {
837
+ return [...patterns].sort(
838
+ (a, b) => literal(b) - literal(a) || stars(a) - stars(b) || (a.canonical < b.canonical ? -1 : a.canonical > b.canonical ? 1 : 0)
839
+ );
840
+ }
841
+ function compileHostPatterns(origins) {
842
+ const out = [];
843
+ for (const [key2, label] of Object.entries(origins)) {
844
+ if (!isHostPattern(key2)) continue;
845
+ const parsed = parseHostPattern(key2, label);
846
+ if (typeof parsed !== "string") out.push(parsed);
847
+ }
848
+ return sortPatterns(out);
849
+ }
850
+ function matchingPattern(patterns, url) {
851
+ return patterns.find((p) => patternMatches(p, url)) ?? null;
852
+ }
853
+
656
854
  // src/core/config/validate.ts
657
855
  var SCHEMA_FILE = "schemas/config.schema.json";
856
+ 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'.";
857
+ var REMOVED_CUSTOM_HINT = "custom measurements were removed in 0.1.0-next.3; use measure.steps and limit.step (test.step durations) instead.";
658
858
  var MAX_SUGGESTION_DISTANCE = 2;
659
859
  var MAX_SCHEMA_PROBLEMS = 1e3;
660
860
  var PATTERN_LISTS = [
661
861
  ["measure", "include"],
662
862
  ["measure", "exclude"],
863
+ ["measure", "steps", "include"],
864
+ ["measure", "steps", "exclude"],
663
865
  ["keys", "extraIdPatterns"]
664
866
  ];
867
+ var RESERVED_ENV_LABELS = ["steps", "requests"];
868
+ function reservedEnvIssue(segments, label) {
869
+ return issue2(
870
+ "CONFIG_INVALID_VALUE",
871
+ segments,
872
+ `the environment label ${JSON.stringify(label)} is reserved: it is a part of the thresholds file names (pw-perf-thresholds.${label}.json)`,
873
+ `Use another environment label, e.g. "${label}-env".`
874
+ );
875
+ }
665
876
  function issue2(code, segments, message, hint) {
666
877
  const path = formatPath(segments);
667
878
  return { code, path, message: `${path === "" ? "config" : path}: ${message}`, hint };
668
879
  }
669
880
  function isPatternItem(segments) {
670
- return segments.length === 3 && typeof segments[2] === "number" && PATTERN_LISTS.some(([a, b]) => segments[0] === a && segments[1] === b);
881
+ return typeof segments.at(-1) === "number" && PATTERN_LISTS.some(
882
+ (list) => segments.length === list.length + 1 && list.every((name, i) => segments[i] === name)
883
+ );
671
884
  }
672
885
  function knownOptions(parent) {
673
886
  if (isPatternItem(parent)) return ["regex", "flags"];
674
887
  if (parent[0] === "keys" && parent[1] === "origins") return [];
888
+ if (parent.length === 2 && parent[0] === "measure" && parent[1] === "steps") {
889
+ return [...STEP_OPTION_NAMES];
890
+ }
675
891
  const node = valueAt(DEFAULT_CONFIG, parent);
676
892
  const names = isRecord(node) ? Object.keys(node) : [];
677
893
  if (parent.length === 0) names.push("$schema");
@@ -697,8 +913,13 @@ function suggestOption(parent, name) {
697
913
  const moved = allOptionPaths(DEFAULT_CONFIG).find((path) => path.at(-1) === name);
698
914
  return moved === void 0 ? void 0 : formatPath(moved);
699
915
  }
916
+ function isRemovedCustomOption(parent, name) {
917
+ if (name !== "custom" || parent[0] !== "checks") return false;
918
+ if (parent.at(-1) === "limit") return true;
919
+ return parent.length === 3 && parent[1] === "slowShare" && parent[2] === "t";
920
+ }
700
921
  function exampleHint(segments) {
701
- let example = valueAt(DEFAULT_CONFIG, segments);
922
+ let example = segments[0] === "measure" && segments[1] === "steps" && segments.length > 2 ? valueAt(STEP_DEFAULTS, segments.slice(2)) : valueAt(DEFAULT_CONFIG, segments);
702
923
  if (example === void 0 && typeof segments.at(-1) === "number") {
703
924
  const list = valueAt(DEFAULT_CONFIG, segments.slice(0, -1));
704
925
  if (Array.isArray(list)) example = list[0];
@@ -711,6 +932,28 @@ function problemToIssue(problem, document) {
711
932
  const segments = pointerSegments(problem.pointer, document);
712
933
  if (problem.kind === "unknown" && problem.property !== void 0) {
713
934
  const option = [...segments, problem.property];
935
+ if (isRemovedCustomOption(segments, problem.property)) {
936
+ return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_CUSTOM_HINT);
937
+ }
938
+ if (problem.property === "keepQuotedValues" && segments.length === 2 && segments[0] === "measure" && segments[1] === "steps") {
939
+ return issue2(
940
+ "CONFIG_UNKNOWN_OPTION",
941
+ option,
942
+ "unknown option",
943
+ "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."
944
+ );
945
+ }
946
+ if (problem.property === "repeat" && segments.length === 1 && segments[0] === "run") {
947
+ return issue2(
948
+ "CONFIG_UNKNOWN_OPTION",
949
+ option,
950
+ "unknown option",
951
+ "Renamed to run.passes: the test command now runs once per pass (repeatEach is 1); e.g. run: { passes: { test: 5, thresholds: 10 } }."
952
+ );
953
+ }
954
+ if (problem.property === "warnOnly" && segments.length === 1 && segments[0] === "gate") {
955
+ return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_WARN_ONLY_HINT);
956
+ }
714
957
  const suggestion = suggestOption(segments, problem.property);
715
958
  return issue2(
716
959
  "CONFIG_UNKNOWN_OPTION",
@@ -734,8 +977,8 @@ function schemaIssues(document) {
734
977
  }
735
978
  function regexIssues(document) {
736
979
  const issues = [];
737
- for (const [section, option] of PATTERN_LISTS) {
738
- const list = valueAt(document, [section, option]);
980
+ for (const path of PATTERN_LISTS) {
981
+ const list = valueAt(document, path);
739
982
  if (!Array.isArray(list)) continue;
740
983
  list.forEach((item, index) => {
741
984
  if (!isRecord(item) || typeof item.regex !== "string") return;
@@ -747,7 +990,7 @@ function regexIssues(document) {
747
990
  issues.push(
748
991
  issue2(
749
992
  "CONFIG_INVALID_REGEX",
750
- [section, option, index],
993
+ [...path, index],
751
994
  `regular expression does not compile (${reason})`,
752
995
  'Fix the expression; it uses JavaScript RegExp syntax, e.g. { "regex": "^/api/v[0-9]+/", "flags": "i" }.'
753
996
  )
@@ -755,6 +998,22 @@ function regexIssues(document) {
755
998
  }
756
999
  });
757
1000
  }
1001
+ const grep = valueAt(document, ["run", "grep"]);
1002
+ if (typeof grep === "string" && grep !== "") {
1003
+ try {
1004
+ new RegExp(grep, "i");
1005
+ } catch (error) {
1006
+ const reason = error instanceof Error ? error.message : String(error);
1007
+ issues.push(
1008
+ issue2(
1009
+ "CONFIG_INVALID_REGEX",
1010
+ ["run", "grep"],
1011
+ `regular expression does not compile (${reason})`,
1012
+ "Fix the expression; it uses JavaScript RegExp syntax, e.g. '@perf' or '@perf|@smoke'."
1013
+ )
1014
+ );
1015
+ }
1016
+ }
758
1017
  return issues;
759
1018
  }
760
1019
  var numberAt = (config, segments) => {
@@ -769,7 +1028,7 @@ var RULES = [
769
1028
  ["checks", "slowShare", "wilson"],
770
1029
  ["checks", "errors"]
771
1030
  ];
772
- var KINDS = ["api", "custom"];
1031
+ var KINDS = ["api", "step"];
773
1032
  var MIN_PERCENTILE = 50;
774
1033
  function percentileLevel(name) {
775
1034
  if (typeof name !== "string" || !/^p\d+(?:\.\d)?$/u.test(name)) return void 0;
@@ -839,21 +1098,57 @@ function relationalIssues(config, isSet) {
839
1098
  );
840
1099
  }
841
1100
  const enabled2 = RULES.some((rule) => valueAt(config, [...rule, "enabled"]) !== false);
842
- if (!enabled2 && valueAt(config, ["gate", "warnOnly"]) !== true) {
1101
+ if (!enabled2) {
843
1102
  errors.push(
844
1103
  issue2(
845
1104
  "CONFIG_INVALID_VALUE",
846
1105
  ["checks"],
847
1106
  "every rule is disabled, so nothing would be checked",
848
- "Enable at least one rule in checks, or set gate.warnOnly to true."
1107
+ "Enable at least one rule in checks."
849
1108
  )
850
1109
  );
851
1110
  }
1111
+ const env = valueAt(config, ["run", "env"]);
1112
+ if (typeof env === "string" && RESERVED_ENV_LABELS.includes(env)) {
1113
+ errors.push(reservedEnvIssue(["run", "env"], env));
1114
+ }
1115
+ const originMap = valueAt(config, ["keys", "origins"]);
1116
+ if (isRecord(originMap)) {
1117
+ const seen = /* @__PURE__ */ new Map();
1118
+ for (const [key2, label] of Object.entries(originMap)) {
1119
+ if (!isHostPattern(key2) || typeof label !== "string") continue;
1120
+ const parsed = parseHostPattern(key2, label);
1121
+ if (typeof parsed === "string") {
1122
+ errors.push(
1123
+ issue2(
1124
+ "CONFIG_INVALID_VALUE",
1125
+ ["keys", "origins", key2],
1126
+ parsed,
1127
+ 'Write a host pattern like "https://*.ci.example.com": one "*" inside a host label, a top-level domain without "*" (docs/dynamic-environments.md).'
1128
+ )
1129
+ );
1130
+ continue;
1131
+ }
1132
+ const other = seen.get(parsed.canonical);
1133
+ if (other !== void 0) {
1134
+ errors.push(
1135
+ issue2(
1136
+ "CONFIG_INVALID_VALUE",
1137
+ ["keys", "origins", key2],
1138
+ `the host pattern is the same as ${JSON.stringify(other)} after canonicalization (${parsed.canonical})`,
1139
+ "Keep one of the two patterns."
1140
+ )
1141
+ );
1142
+ } else {
1143
+ seen.set(parsed.canonical, key2);
1144
+ }
1145
+ }
1146
+ }
852
1147
  const origins = valueAt(config, ["keys", "origins"]);
853
1148
  if (isRecord(origins)) {
854
1149
  const byLabel = /* @__PURE__ */ new Map();
855
1150
  for (const [origin, label] of Object.entries(origins)) {
856
- if (typeof label !== "string") continue;
1151
+ if (typeof label !== "string" || isHostPattern(origin)) continue;
857
1152
  byLabel.set(label, [...byLabel.get(label) ?? [], origin]);
858
1153
  }
859
1154
  for (const [label, list] of byLabel) {
@@ -884,7 +1179,7 @@ function relationalIssues(config, isSet) {
884
1179
 
885
1180
  // src/core/config/resolve.ts
886
1181
  var KEY_BUILDER_SNAPSHOT = "[function]";
887
- var repeatSchema = int({ minimum: 1, maximum: 1e3 });
1182
+ var passesSchema = int({ minimum: 1, maximum: 1e3 });
888
1183
  function isPlainObject(value) {
889
1184
  if (!isRecord(value)) return false;
890
1185
  const prototype = Object.getPrototypeOf(value);
@@ -1005,13 +1300,13 @@ function overrideIssues(overrides) {
1005
1300
  )
1006
1301
  );
1007
1302
  }
1008
- if (overrides.repeat !== void 0 && !matches(repeatSchema, overrides.repeat)) {
1303
+ if (overrides.passes !== void 0 && !matches(passesSchema, overrides.passes)) {
1009
1304
  issues.push(
1010
1305
  issue2(
1011
1306
  "CONFIG_INVALID_VALUE",
1012
- ["run", "repeat", overrides.mode ?? "test"],
1013
- `the repeat override must be an integer from 1 to 1000, got ${describeValue(overrides.repeat)}`,
1014
- "Fix the number of repetitions, e.g. 5."
1307
+ ["run", "passes", overrides.mode ?? "test"],
1308
+ `the passes override must be an integer from 1 to 1000, got ${describeValue(overrides.passes)}`,
1309
+ "Fix the number of passes, e.g. 5."
1015
1310
  )
1016
1311
  );
1017
1312
  }
@@ -1019,8 +1314,8 @@ function overrideIssues(overrides) {
1019
1314
  }
1020
1315
  function applyOverrides(config, overrides) {
1021
1316
  if (overrides.env !== void 0) config.run.env = overrides.env;
1022
- if (overrides.repeat !== void 0) {
1023
- config.run.repeat[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.repeat;
1317
+ if (overrides.passes !== void 0) {
1318
+ config.run.passes[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.passes;
1024
1319
  }
1025
1320
  }
1026
1321
  function snapshotPattern(pattern) {
@@ -1042,13 +1337,15 @@ function resolveConfig(input, overrides) {
1042
1337
  ...overrideIssues(overrides)
1043
1338
  ];
1044
1339
  const { $schema: _schema, ...withoutSchema } = isRecord(document) ? document : {};
1045
- const merged = merge(DEFAULT_CONFIG, withoutSchema);
1340
+ const defaults = merge(DEFAULT_CONFIG, presetLayer(presetOf(withoutSchema)));
1341
+ const merged = merge(defaults, withoutSchema);
1046
1342
  if (errors.length === 0) applyOverrides(merged, overrides);
1047
1343
  const relational = relationalIssues(merged, (path) => order.has(formatPath(path)));
1048
1344
  errors.push(...relational.errors);
1049
1345
  if (errors.length > 0) return { ok: false, issues: sortByInput(errors, order) };
1050
- for (const [section, option] of PATTERN_LISTS) {
1051
- const list = valueAt(merged, [section, option]);
1346
+ merged.measure.steps = expandSteps(merged.measure.steps);
1347
+ for (const path of PATTERN_LISTS) {
1348
+ const list = valueAt(merged, path);
1052
1349
  list.splice(0, list.length, ...list.map(snapshotPattern));
1053
1350
  }
1054
1351
  if (keyBuilder.inSnapshot) merged.keys.keyBuilder = KEY_BUILDER_SNAPSHOT;
@@ -1060,7 +1357,12 @@ function resolveConfig(input, overrides) {
1060
1357
  measure: {
1061
1358
  ...copy.measure,
1062
1359
  include: snapshot.measure.include.map(compilePattern),
1063
- exclude: snapshot.measure.exclude.map(compilePattern)
1360
+ exclude: snapshot.measure.exclude.map(compilePattern),
1361
+ steps: {
1362
+ ...copy.measure.steps,
1363
+ include: snapshot.measure.steps.include.map(compilePattern),
1364
+ exclude: snapshot.measure.steps.exclude.map(compilePattern)
1365
+ }
1064
1366
  },
1065
1367
  keys: {
1066
1368
  ...clone(keys),
@@ -1096,11 +1398,13 @@ function resolveDefaults() {
1096
1398
  }
1097
1399
  var perfDefaults = deepFreeze(resolveDefaults());
1098
1400
 
1401
+ exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
1099
1402
  exports.Sink = Sink;
1100
1403
  exports.anyObject = anyObject;
1101
1404
  exports.arr = arr;
1102
1405
  exports.bool = bool;
1103
1406
  exports.child = child;
1407
+ exports.compileHostPatterns = compileHostPatterns;
1104
1408
  exports.constant = constant;
1105
1409
  exports.count = count;
1106
1410
  exports.definePerfConfig = definePerfConfig;
@@ -1109,14 +1413,17 @@ exports.enumOf = enumOf;
1109
1413
  exports.envLabelOrNull = envLabelOrNull;
1110
1414
  exports.epochMs = epochMs;
1111
1415
  exports.evaluationStatus = evaluationStatus;
1416
+ exports.expandSteps = expandSteps;
1112
1417
  exports.fingerprint = fingerprint;
1113
1418
  exports.hostFingerprint = hostFingerprint;
1114
1419
  exports.int = int;
1420
+ exports.isHostPattern = isHostPattern;
1115
1421
  exports.isRecord = isRecord;
1116
1422
  exports.isoDate = isoDate;
1117
1423
  exports.issue = issue;
1118
1424
  exports.key = key;
1119
1425
  exports.kind = kind;
1426
+ exports.matchingPattern = matchingPattern;
1120
1427
  exports.mode = mode;
1121
1428
  exports.ms = ms;
1122
1429
  exports.msLimit = msLimit;