@fairfox/polly 0.91.0 → 0.92.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.
Files changed (107) hide show
  1. package/dist/cli/polly.js +3 -3
  2. package/dist/cli/polly.js.map +3 -3
  3. package/dist/gallery/gallery.css +2 -2
  4. package/dist/gallery/gallery.js +248 -241
  5. package/dist/src/background/index.js +27 -11
  6. package/dist/src/background/index.js.map +2 -2
  7. package/dist/src/background/message-router.js +27 -11
  8. package/dist/src/background/message-router.js.map +2 -2
  9. package/dist/src/client/index.js +56 -56
  10. package/dist/src/client/index.js.map +4 -4
  11. package/dist/src/elysia/index.js +6 -6
  12. package/dist/src/elysia/index.js.map +3 -3
  13. package/dist/src/index.js +27 -11
  14. package/dist/src/index.js.map +2 -2
  15. package/dist/src/mesh.js +2 -2
  16. package/dist/src/mesh.js.map +3 -3
  17. package/dist/src/peer.js +6 -6
  18. package/dist/src/peer.js.map +3 -3
  19. package/dist/src/polly-ui/index.css +2 -2
  20. package/dist/src/polly-ui/markdown.js +1844 -1010
  21. package/dist/src/polly-ui/markdown.js.map +5 -5
  22. package/dist/src/polly-ui/styles.css +2 -2
  23. package/dist/src/shared/adapters/index.js +27 -11
  24. package/dist/src/shared/adapters/index.js.map +2 -2
  25. package/dist/src/shared/lib/context-helpers.js +27 -11
  26. package/dist/src/shared/lib/context-helpers.js.map +2 -2
  27. package/dist/src/shared/lib/message-bus.js +27 -11
  28. package/dist/src/shared/lib/message-bus.js.map +2 -2
  29. package/dist/src/shared/lib/resource.js +17 -1
  30. package/dist/src/shared/lib/resource.js.map +2 -2
  31. package/dist/src/shared/lib/state.js +17 -1
  32. package/dist/src/shared/lib/state.js.map +2 -2
  33. package/dist/src/shared/state/app-state.js +17 -1
  34. package/dist/src/shared/state/app-state.js.map +2 -2
  35. package/dist/tools/bdd/src/cli.js +20 -2
  36. package/dist/tools/bdd/src/cli.js.map +4 -4
  37. package/dist/tools/bdd/src/index.js +20 -2
  38. package/dist/tools/bdd/src/index.js.map +3 -3
  39. package/dist/tools/init/templates/pwa/package.json.template +2 -3
  40. package/dist/tools/mutate/src/args.d.ts +25 -3
  41. package/dist/tools/mutate/src/cli.js +3234 -312
  42. package/dist/tools/mutate/src/cli.js.map +32 -12
  43. package/dist/tools/mutate/src/config.d.ts +13 -2
  44. package/dist/tools/mutate/src/define.d.ts +76 -0
  45. package/dist/tools/mutate/src/engine/ast.d.ts +13 -0
  46. package/dist/tools/mutate/src/engine/baseline.d.ts +20 -0
  47. package/dist/tools/mutate/src/engine/cache.d.ts +32 -0
  48. package/dist/tools/mutate/src/engine/coverage.d.ts +60 -0
  49. package/dist/tools/mutate/src/engine/generate.d.ts +23 -0
  50. package/dist/tools/mutate/src/engine/graph.d.ts +11 -0
  51. package/dist/tools/mutate/src/engine/index.d.ts +16 -0
  52. package/dist/tools/mutate/src/engine/junit.d.ts +38 -0
  53. package/dist/tools/mutate/src/engine/operators.d.ts +14 -0
  54. package/dist/tools/mutate/src/engine/preload.d.ts +10 -0
  55. package/dist/tools/mutate/src/engine/preload.js +180 -0
  56. package/dist/tools/mutate/src/engine/preload.js.map +10 -0
  57. package/dist/tools/mutate/src/engine/probes.d.ts +12 -0
  58. package/dist/tools/mutate/src/engine/report-writer.d.ts +44 -0
  59. package/dist/tools/mutate/src/engine/runner.d.ts +31 -0
  60. package/dist/tools/mutate/src/engine/stray-writes.d.ts +25 -0
  61. package/dist/tools/mutate/src/engine/typecheck.d.ts +37 -0
  62. package/dist/tools/mutate/src/engine/types.d.ts +191 -0
  63. package/dist/tools/mutate/src/engine/verify-callsites.d.ts +9 -0
  64. package/dist/tools/mutate/src/engine/workdir.d.ts +16 -0
  65. package/dist/tools/mutate/src/engine-config.d.ts +7 -0
  66. package/dist/tools/mutate/src/index.d.ts +7 -3
  67. package/dist/tools/mutate/src/index.js +2701 -77
  68. package/dist/tools/mutate/src/index.js.map +26 -7
  69. package/dist/tools/mutate/src/ingest.d.ts +30 -1
  70. package/dist/tools/mutate/src/init.d.ts +2 -1
  71. package/dist/tools/mutate/src/migrate.d.ts +32 -0
  72. package/dist/tools/mutate/src/report.d.ts +3 -0
  73. package/dist/tools/mutate/src/run.d.ts +17 -8
  74. package/dist/tools/mutate/src/verify-matrix.d.ts +12 -15
  75. package/dist/tools/quality/src/cli.js +9 -9
  76. package/dist/tools/quality/src/cli.js.map +4 -4
  77. package/dist/tools/quality/src/index.js +9 -9
  78. package/dist/tools/quality/src/index.js.map +4 -4
  79. package/dist/tools/quality/src/no-tautology-ensures.d.ts +2 -2
  80. package/dist/tools/quality/src/plugins/import-checks.d.ts +1 -1
  81. package/dist/tools/test/src/adapters/index.js +3 -2
  82. package/dist/tools/test/src/adapters/index.js.map +3 -3
  83. package/dist/tools/test/src/coverage-policy/cli.d.ts +2 -2
  84. package/dist/tools/test/src/coverage-policy/cli.js +217 -17
  85. package/dist/tools/test/src/coverage-policy/cli.js.map +7 -5
  86. package/dist/tools/test/src/coverage-policy/index.d.ts +1 -1
  87. package/dist/tools/test/src/coverage-policy/index.js +213 -12
  88. package/dist/tools/test/src/coverage-policy/index.js.map +7 -5
  89. package/dist/tools/test/src/coverage-policy/mutate-targets.d.ts +29 -12
  90. package/dist/tools/test/src/e2e-mesh/index.js +6 -6
  91. package/dist/tools/test/src/e2e-mesh/index.js.map +4 -4
  92. package/dist/tools/test/src/e2e-relay/index.js +230 -226
  93. package/dist/tools/test/src/e2e-relay/index.js.map +7 -7
  94. package/dist/tools/test/src/index.js +3 -2
  95. package/dist/tools/test/src/index.js.map +3 -3
  96. package/dist/tools/test/src/visual/index.js +684 -511
  97. package/dist/tools/test/src/visual/index.js.map +11 -11
  98. package/dist/tools/verify/src/cli.js +2 -2
  99. package/dist/tools/verify/src/cli.js.map +3 -3
  100. package/dist/tools/verify/src/config.d.ts +1 -1
  101. package/dist/tools/verify/src/config.js +68 -3
  102. package/dist/tools/verify/src/config.js.map +4 -4
  103. package/dist/tools/verify/src/primitives/index.d.ts +34 -0
  104. package/package.json +29 -39
  105. package/dist/tools/verify/src/stryker/index.d.ts +0 -32
  106. package/dist/tools/verify/src/stryker/index.js +0 -86
  107. package/dist/tools/verify/src/stryker/index.js.map +0 -10
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Ingest a Stryker mutation report (mutation-testing-report-schema) into a
2
+ * Ingest a mutation report (mutation-testing-report-schema) into a
3
3
  * regenerable SQLite database holding the kill matrix.
4
4
  *
5
5
  * The tool consumes the *schema*, never a specific runner — so the same
@@ -16,6 +16,8 @@ export interface MutationReport {
16
16
  testFiles?: Record<string, {
17
17
  tests: TestDef[];
18
18
  }>;
19
+ /** Written by the bun engine; absent from Stryker-era reports. */
20
+ contracts?: ReportContracts;
19
21
  }
20
22
  interface Mutant {
21
23
  id: string;
@@ -29,6 +31,33 @@ interface Mutant {
29
31
  };
30
32
  killedBy?: string[];
31
33
  coveredBy?: string[];
34
+ /** Contract ids (`<file>:<line>`) a killing test's failure named. */
35
+ killedByContract?: string[];
36
+ /** Every killer failed through a contract: no assertion caught the mutant. */
37
+ contractOnly?: boolean;
38
+ }
39
+ /** The engine's contracts block: how the run enforced requires/ensures, and what it found. */
40
+ export interface ReportContracts {
41
+ mode: "off" | "ensures" | "all";
42
+ runner: "bun-test" | "command";
43
+ sites: ContractSiteDef[];
44
+ violations: {
45
+ target: string;
46
+ test: string;
47
+ contracts: string[];
48
+ }[];
49
+ }
50
+ export interface ContractSiteDef {
51
+ /** `<file>:<line>`, what `killedByContract` holds. */
52
+ id: string;
53
+ file: string;
54
+ line: number;
55
+ primitive: "requires" | "ensures";
56
+ message?: string;
57
+ handler?: {
58
+ from: number;
59
+ to: number;
60
+ };
32
61
  }
33
62
  interface TestDef {
34
63
  id: string;
@@ -2,7 +2,8 @@ export interface InitResult {
2
2
  configPath: string;
3
3
  /** false when a config already existed and --force was not passed. */
4
4
  created: boolean;
5
- pluginRef: string;
5
+ /** Where `defineMutation` is imported from. */
6
+ specifier: string;
6
7
  mutate: string[];
7
8
  testGlob: string;
8
9
  warnings: string[];
@@ -0,0 +1,32 @@
1
+ import { type MutationConfig } from "./define.ts";
2
+ export interface Migration {
3
+ config: MutationConfig;
4
+ notes: string[];
5
+ }
6
+ /** `--preload <p>` / `--preload=<p>` values from the bun runner's `nodeArgs`, as written. */
7
+ export declare function preloadArgs(nodeArgs: string[]): string[];
8
+ /** A Stryker command string as argv; anything shell-shaped goes through `sh -c`. */
9
+ export declare function commandArgv(command: string): string[];
10
+ /** Map a parsed Stryker config to a `MutationConfig`, with a note per dropped key. */
11
+ export declare function strykerToMutation(raw: unknown, where: string): Migration;
12
+ export declare function readStrykerConfig(path: string): Promise<Migration>;
13
+ /**
14
+ * The specifier a config in `dir` imports `defineMutation` from: the package
15
+ * export when it resolves there, else this source tree's own module (polly's
16
+ * monorepo root has no `@fairfox/polly` in its node_modules).
17
+ */
18
+ export declare function defineImportSpecifier(dir: string): string;
19
+ export declare function renderMutationConfig(config: MutationConfig, specifier: string): string;
20
+ export interface MigrateResult {
21
+ /** Where the config goes (next to the Stryker config). */
22
+ path: string;
23
+ source: string;
24
+ notes: string[];
25
+ /** false when `write` was off or a config was already there without `force`. */
26
+ written: boolean;
27
+ existed: boolean;
28
+ }
29
+ export declare function migrateConfig(strykerPath: string, opts?: {
30
+ write?: boolean;
31
+ force?: boolean;
32
+ }): Promise<MigrateResult>;
@@ -5,6 +5,9 @@
5
5
  * redundancy tests/files whose every kill is also caught elsewhere
6
6
  * theatre covered-but-survived — code a test runs but no test detects
7
7
  * (the Survived status under coverageAnalysis "all")
8
+ * contracts (bun engine, contracts on) mutants only a requires/ensures
9
+ * caught, kills per contract, and contracts whose handler was
10
+ * exercised yet never fired — a contract without teeth
8
11
  *
9
12
  * Redundancy is reported at BOTH file and case level. Decisions are keyed at
10
13
  * file level (stable identity); case level is the drill-down.
@@ -1,11 +1,20 @@
1
+ import type { MutateArgs } from "./args.ts";
1
2
  import type { MutateConfig } from "./config.ts";
2
- /** Run Stryker against the resolved config. Inherits stdio for the live reporter; returns the exit code. */
3
- export declare function runStryker(cfg: MutateConfig): Promise<number>;
4
- /** Build the useless-test report from an existing mutation.json (no Stryker run). */
5
- export declare function reportFromFile(cfg: MutateConfig): Promise<string>;
3
+ import type { EngineResult } from "./engine/types.ts";
4
+ /** `--engine` survives for scripts that pass `--engine bun`; Stryker is gone. */
5
+ export declare function resolveEngine(args: MutateArgs): "bun";
6
+ /** The notice printed when the bun engine reads a Stryker config; null for polly.mutate.ts. */
7
+ export declare function deprecationNotice(cfg: MutateConfig): string | null;
8
+ /** `thresholds.break` failure line, or null when the score clears it (or none is set). */
9
+ export declare function thresholdFailure(score: number | null, cfg: MutateConfig): string | null;
10
+ /** Run the Bun-native engine and print a per-target summary. Returns the exit code. */
11
+ export declare function runBunEngine(cfg: MutateConfig, args: MutateArgs): Promise<number>;
6
12
  /**
7
- * If the Stryker config doesn't already load polly's verify-primitive ignorer,
8
- * return a one-line tip. The ignorer must be in the config before the run (it's
9
- * read at Stryker startup), so this advises rather than mutating the user's config.
13
+ * The block printed when a baseline failed through a contract: the unmutated
14
+ * code, under one of its own tests, falsified a requires/ensures. That is a
15
+ * finding about the test or the handler, not about any mutant, so the run
16
+ * stops instead of scoring the target.
10
17
  */
11
- export declare function presetAdvisory(cfg: MutateConfig): Promise<string | null>;
18
+ export declare function contractViolationsBlock(result: EngineResult, cwd: string): string;
19
+ /** Build the useless-test report from an existing mutation.json (no engine run). */
20
+ export declare function reportFromFile(cfg: MutateConfig): Promise<string>;
@@ -1,20 +1,20 @@
1
1
  /**
2
2
  * Verification artefact for the kill-matrix contract.
3
3
  *
4
- * The whole useless-test analysis rests on one fact: the patched bun runner
5
- * emits a COMPLETE kill matrix — every test that detects a mutant appears in
6
- * killedBy, not just the first. That depends on a pinned pair: (Bun version,
7
- * plugin version + our patch). A Bun upgrade that changes JUnit output, or a
8
- * patch that stops applying, would silently collapse killedBy to one id each —
9
- * a green board with the redundancy signal quietly dead (the classic trap).
4
+ * The whole useless-test analysis rests on one fact: matrix mode emits a
5
+ * COMPLETE kill matrix — every test that detects a mutant appears in killedBy,
6
+ * not just the first. That depends on Bun's junit output (engine/junit.ts). A
7
+ * Bun upgrade that changes it, or a `--bail` that creeps back into matrix runs,
8
+ * would silently collapse killedBy to one id each — a green board with the
9
+ * redundancy signal quietly dead (the classic trap).
10
10
  *
11
11
  * `verifyMatrix` runs the full contract and returns the result; `isMatrixComplete`
12
12
  * is the side-effect-free gate the report path consults to decide whether the
13
13
  * redundancy/subsumption sections are trustworthy. Run the CLI form after any
14
- * bump of Bun or the plugin:
14
+ * Bun bump:
15
15
  *
16
16
  * polly mutate verify # uses the existing report
17
- * polly mutate verify --run # runs stryker first
17
+ * polly mutate verify --run # runs the engine in matrix mode first
18
18
  */
19
19
  import { type MutationReport } from "./ingest.ts";
20
20
  export interface MatrixCheck {
@@ -28,7 +28,7 @@ export interface MatrixCheck {
28
28
  /**
29
29
  * Side-effect-free gate: is the kill matrix trustworthy for redundancy /
30
30
  * subsumption analysis? True only when
31
- * (a) some killed mutant has >1 killer — proof the no-bail patched runner
31
+ * (a) some killed mutant has >1 killer — proof the no-bail matrix run
32
32
  * recorded EVERY killer, not just the first (verifyMatrix check #4), and
33
33
  * (b) coverage was collected — not every mutant is NoCoverage, which would
34
34
  * mean the coverage dump broke (verifyMatrix check #5).
@@ -37,13 +37,10 @@ export interface MatrixCheck {
37
37
  */
38
38
  export declare function isMatrixComplete(report: MutationReport): boolean;
39
39
  /**
40
- * Run the full kill-matrix contract (all five checks), optionally running a
41
- * fresh Stryker pass first. Returns the result rather than exiting, so callers
42
- * decide what to do with it; the `import.meta.main` wrapper prints and sets the
43
- * exit code.
40
+ * Run the full kill-matrix contract (all five checks) on a report. Returns the
41
+ * result rather than exiting, so callers decide what to do with it.
42
+ * `polly mutate verify --run` writes a fresh matrix-mode report first.
44
43
  */
45
44
  export declare function verifyMatrix(opts?: {
46
45
  reportPath?: string;
47
- run?: boolean;
48
- strykerConfig?: string;
49
46
  }): Promise<MatrixCheck>;
@@ -2643,9 +2643,9 @@ var noRawHttp = {
2643
2643
  return { ok: violations.length === 0, messages: violations };
2644
2644
  }
2645
2645
  };
2646
- async function runTscFor(packagePath, rootDir) {
2647
- const proc = Bun.spawn(["bunx", "tsc", "--noEmit", "-p", packagePath], {
2648
- cwd: rootDir,
2646
+ async function runTypecheckFor(packagePath) {
2647
+ const proc = Bun.spawn(["bun", "--check"], {
2648
+ cwd: packagePath,
2649
2649
  stdout: "pipe",
2650
2650
  stderr: "pipe"
2651
2651
  });
@@ -2668,7 +2668,7 @@ async function findWorkspaces(rootDir, patterns) {
2668
2668
  }
2669
2669
  var types = {
2670
2670
  id: "polly:types",
2671
- description: "Run `tsc --noEmit` against each workspace package in parallel",
2671
+ description: "Run `bun check` (tsc-compatible) against each workspace package in parallel",
2672
2672
  filesRead: async () => {
2673
2673
  return [];
2674
2674
  },
@@ -2677,12 +2677,12 @@ var types = {
2677
2677
  const packages = await findWorkspaces(rootDir, patterns);
2678
2678
  if (packages.length === 0)
2679
2679
  return { ok: true, messages: ["no workspace packages found"] };
2680
- const results = await Promise.all(packages.map((p) => runTscFor(p, rootDir)));
2680
+ const results = await Promise.all(packages.map((p) => runTypecheckFor(p)));
2681
2681
  return aggregateTypesResults(packages, results, rootDir);
2682
2682
  }
2683
2683
  };
2684
- function appendTscFailure(messages, relPkg, output) {
2685
- messages.push(`${relPkg}: tsc --noEmit failed`);
2684
+ function appendTypecheckFailure(messages, relPkg, output) {
2685
+ messages.push(`${relPkg}: bun check failed`);
2686
2686
  const trimmed = output.trim();
2687
2687
  if (!trimmed)
2688
2688
  return;
@@ -2699,7 +2699,7 @@ function aggregateTypesResults(packages, results, rootDir) {
2699
2699
  if (!pkg || !r || r.ok)
2700
2700
  continue;
2701
2701
  ok = false;
2702
- appendTscFailure(messages, relative6(rootDir, pkg) || ".", r.output);
2702
+ appendTypecheckFailure(messages, relative6(rootDir, pkg) || ".", r.output);
2703
2703
  }
2704
2704
  return { ok, messages };
2705
2705
  }
@@ -3333,4 +3333,4 @@ switch (subcommand) {
3333
3333
  }
3334
3334
  process.exit(exitCode);
3335
3335
 
3336
- //# debugId=2457D8123B12C85564756E2164756E21
3336
+ //# debugId=E090B73AFCD635EC64756E2164756E21