@fairfox/polly 0.9.0 → 0.9.1

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.
@@ -39,6 +39,10 @@ export const verificationConfig = defineVerification({
39
39
  //
40
40
  // Start with 0 or 1 for faster verification.
41
41
  maxTabs: 1,
42
+
43
+ // TEST: Message filtering (Issue #14)
44
+ // Only verify these specific message types
45
+ include: ["test_message_1", "test_message_2", "test_message_3"],
42
46
  },
43
47
 
44
48
  // Verification behavior
@@ -775,6 +775,13 @@ class TLAGenerator {
775
775
  if (analysis.messageTypes.length === 0) {
776
776
  return;
777
777
  }
778
+ if (process.env["POLLY_DEBUG"]) {
779
+ console.log("[DEBUG] [TLAGenerator] Full config keys:", Object.keys(config));
780
+ console.log("[DEBUG] [TLAGenerator] config.messages:", JSON.stringify(config.messages, null, 2));
781
+ console.log("[DEBUG] [TLAGenerator] config.messages.include:", config.messages.include);
782
+ console.log("[DEBUG] [TLAGenerator] config.messages.exclude:", config.messages.exclude);
783
+ console.log("[DEBUG] [TLAGenerator] analysis.messageTypes:", analysis.messageTypes);
784
+ }
778
785
  let validMessageTypes = [];
779
786
  const invalidMessageTypes = [];
780
787
  for (const msgType of analysis.messageTypes) {
@@ -790,18 +797,46 @@ class TLAGenerator {
790
797
  console.log(`[WARN] - "${invalid}" (not a valid TLA+ identifier)`);
791
798
  }
792
799
  }
800
+ if (process.env["POLLY_DEBUG"]) {
801
+ console.log(`[DEBUG] [TLAGenerator] Valid message types before filtering (${validMessageTypes.length}):`, validMessageTypes);
802
+ }
793
803
  const originalCount = validMessageTypes.length;
794
804
  const filteredOut = [];
805
+ if (process.env["POLLY_DEBUG"]) {
806
+ console.log("[DEBUG] [TLAGenerator] Checking filter conditions:");
807
+ console.log("[DEBUG] - config.messages.include exists:", !!config.messages.include);
808
+ console.log("[DEBUG] - config.messages.include.length:", config.messages.include?.length ?? "N/A");
809
+ console.log("[DEBUG] - First condition result:", !!(config.messages.include && config.messages.include.length > 0));
810
+ }
795
811
  if (config.messages.include && config.messages.include.length > 0) {
812
+ if (process.env["POLLY_DEBUG"]) {
813
+ console.log("[DEBUG] [TLAGenerator] Entering include mode filtering");
814
+ }
796
815
  const included = new Set(config.messages.include);
797
816
  const beforeFilter = validMessageTypes;
798
817
  validMessageTypes = validMessageTypes.filter((msg) => included.has(msg));
799
818
  filteredOut.push(...beforeFilter.filter((msg) => !included.has(msg)));
819
+ if (process.env["POLLY_DEBUG"]) {
820
+ console.log("[DEBUG] [TLAGenerator] After include filtering:");
821
+ console.log("[DEBUG] - validMessageTypes:", validMessageTypes);
822
+ console.log("[DEBUG] - filteredOut:", filteredOut);
823
+ }
800
824
  } else if (config.messages.exclude && config.messages.exclude.length > 0) {
825
+ if (process.env["POLLY_DEBUG"]) {
826
+ console.log("[DEBUG] [TLAGenerator] Entering exclude mode filtering");
827
+ }
801
828
  const excluded = new Set(config.messages.exclude);
802
829
  const beforeFilter = validMessageTypes;
803
830
  validMessageTypes = validMessageTypes.filter((msg) => !excluded.has(msg));
804
831
  filteredOut.push(...beforeFilter.filter((msg) => excluded.has(msg)));
832
+ if (process.env["POLLY_DEBUG"]) {
833
+ console.log("[DEBUG] [TLAGenerator] After exclude filtering:");
834
+ console.log("[DEBUG] - validMessageTypes:", validMessageTypes);
835
+ console.log("[DEBUG] - filteredOut:", filteredOut);
836
+ }
837
+ } else if (process.env["POLLY_DEBUG"]) {
838
+ console.log("[DEBUG] [TLAGenerator] No include/exclude filtering applied");
839
+ console.log("[DEBUG] - Reason: Neither include nor exclude conditions met");
805
840
  }
806
841
  if (filteredOut.length > 0) {
807
842
  const filterMode = config.messages.include ? "include" : "exclude";
@@ -809,6 +844,8 @@ class TLAGenerator {
809
844
  if (process.env["POLLY_DEBUG"]) {
810
845
  console.log(`[INFO] Filtered out: ${filteredOut.join(", ")}`);
811
846
  }
847
+ } else if (config.messages.include || config.messages.exclude) {
848
+ console.log("[WARN] [TLAGenerator] Message filters configured but no types were filtered");
812
849
  }
813
850
  if (validMessageTypes.length === 0) {
814
851
  return;
@@ -1759,22 +1796,32 @@ import * as path3 from "node:path";
1759
1796
  class DockerRunner {
1760
1797
  async isDockerAvailable() {
1761
1798
  try {
1762
- const result = await this.runCommand("docker", ["--version"]);
1799
+ const result = await this.runCommand("docker", ["info"], {
1800
+ timeout: 5000
1801
+ });
1763
1802
  return result.exitCode === 0;
1764
- } catch {
1803
+ } catch (error) {
1804
+ if (error instanceof Error && error.message.includes("timed out")) {
1805
+ throw error;
1806
+ }
1765
1807
  return false;
1766
1808
  }
1767
1809
  }
1768
1810
  async hasImage() {
1769
1811
  try {
1770
- const result = await this.runCommand("docker", ["images", "-q", "talex5/tla"]);
1812
+ const result = await this.runCommand("docker", ["images", "-q", "talex5/tla"], {
1813
+ timeout: 1e4
1814
+ });
1771
1815
  return result.stdout.trim().length > 0;
1772
- } catch {
1816
+ } catch (error) {
1817
+ if (error instanceof Error && error.message.includes("timed out")) {
1818
+ throw error;
1819
+ }
1773
1820
  return false;
1774
1821
  }
1775
1822
  }
1776
1823
  async pullImage(onProgress) {
1777
- await this.runCommandStreaming("docker", ["pull", "talex5/tla:latest"], onProgress);
1824
+ await this.runCommandStreaming("docker", ["pull", "talex5/tla:latest"], onProgress, 300000);
1778
1825
  }
1779
1826
  async runTLC(specPath, options) {
1780
1827
  if (!fs3.existsSync(specPath)) {
@@ -1896,9 +1943,13 @@ class DockerRunner {
1896
1943
  });
1897
1944
  });
1898
1945
  }
1899
- runCommandStreaming(command, args, onOutput) {
1946
+ runCommandStreaming(command, args, onOutput, timeout) {
1900
1947
  return new Promise((resolve2, reject) => {
1901
1948
  const proc = spawn(command, args);
1949
+ const timeoutHandle = timeout && timeout > 0 ? setTimeout(() => {
1950
+ proc.kill();
1951
+ reject(new Error(`Command timed out after ${Math.floor(timeout / 1000)}s. Docker may be unresponsive.`));
1952
+ }, timeout) : null;
1902
1953
  proc.stdout.on("data", (data) => {
1903
1954
  if (onOutput) {
1904
1955
  const lines = data.toString().split(`
@@ -1922,13 +1973,19 @@ class DockerRunner {
1922
1973
  }
1923
1974
  });
1924
1975
  proc.on("close", (exitCode) => {
1976
+ if (timeoutHandle)
1977
+ clearTimeout(timeoutHandle);
1925
1978
  if (exitCode === 0) {
1926
1979
  resolve2();
1927
1980
  } else {
1928
1981
  reject(new Error(`Command failed with exit code ${exitCode}`));
1929
1982
  }
1930
1983
  });
1931
- proc.on("error", reject);
1984
+ proc.on("error", (error) => {
1985
+ if (timeoutHandle)
1986
+ clearTimeout(timeoutHandle);
1987
+ reject(error);
1988
+ });
1932
1989
  });
1933
1990
  }
1934
1991
  }
@@ -4846,14 +4903,50 @@ async function setupDocker() {
4846
4903
  const { DockerRunner: DockerRunner2 } = await Promise.resolve().then(() => (init_docker(), exports_docker));
4847
4904
  console.log(color("\uD83D\uDC33 Checking Docker...", COLORS.blue));
4848
4905
  const docker = new DockerRunner2;
4849
- if (!await docker.isDockerAvailable()) {
4850
- throw new Error("Docker is not available. Please install Docker and try again.");
4906
+ try {
4907
+ if (!await docker.isDockerAvailable()) {
4908
+ console.log();
4909
+ console.log(color("❌ Docker is not available", COLORS.red));
4910
+ console.log();
4911
+ console.log("Please ensure Docker is installed and running:");
4912
+ console.log(color(" • Install Docker Desktop: https://www.docker.com/products/docker-desktop", COLORS.gray));
4913
+ console.log(color(" • Make sure Docker Desktop is running", COLORS.gray));
4914
+ console.log();
4915
+ throw new Error("Docker is not available");
4916
+ }
4917
+ } catch (error) {
4918
+ console.log();
4919
+ if (error instanceof Error && error.message.includes("timed out")) {
4920
+ console.log(color("❌ Docker is unresponsive", COLORS.red));
4921
+ console.log();
4922
+ console.log("Docker appears to be installed but is not responding.");
4923
+ console.log("Try restarting Docker:");
4924
+ console.log(color(" • Quit Docker Desktop completely", COLORS.gray));
4925
+ console.log(color(" • Restart Docker Desktop", COLORS.gray));
4926
+ console.log(color(" • Wait for Docker to fully start (check the menu bar icon)", COLORS.gray));
4927
+ console.log();
4928
+ } else if (error instanceof Error && error.message !== "Docker is not available") {
4929
+ console.log(color(`❌ Error checking Docker: ${error.message}`, COLORS.red));
4930
+ console.log();
4931
+ }
4932
+ throw error;
4851
4933
  }
4852
- if (!await docker.hasImage()) {
4853
- console.log(color(" Pulling TLA+ image (this may take a moment)...", COLORS.gray));
4854
- await docker.pullImage((line) => {
4855
- console.log(color(` ${line}`, COLORS.gray));
4856
- });
4934
+ try {
4935
+ if (!await docker.hasImage()) {
4936
+ console.log(color(" Pulling TLA+ image (this may take a moment)...", COLORS.gray));
4937
+ await docker.pullImage((line) => {
4938
+ console.log(color(` ${line}`, COLORS.gray));
4939
+ });
4940
+ }
4941
+ } catch (error) {
4942
+ console.log();
4943
+ if (error instanceof Error && error.message.includes("timed out")) {
4944
+ console.log(color("❌ Docker is unresponsive while checking for TLA+ image", COLORS.red));
4945
+ console.log();
4946
+ console.log("Docker is not responding. Try restarting Docker Desktop.");
4947
+ console.log();
4948
+ }
4949
+ throw error;
4857
4950
  }
4858
4951
  console.log(color("✓ Docker ready", COLORS.green));
4859
4952
  console.log();
@@ -4959,4 +5052,4 @@ main().catch((error) => {
4959
5052
  process.exit(1);
4960
5053
  });
4961
5054
 
4962
- //# debugId=C143FDB4EBE435E264756E2164756E21
5055
+ //# debugId=E4DF49968E3D4FDC64756E2164756E21