@fulmenhq/tsfulmen 0.2.10 → 0.3.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +1 -1
  3. package/dist/appidentity/index.js +156 -4150
  4. package/dist/appidentity/index.js.map +1 -1
  5. package/dist/bin/prometheus-cli.d.ts +1 -0
  6. package/dist/bin/prometheus-cli.js +9331 -0
  7. package/dist/bin/prometheus-cli.js.map +1 -0
  8. package/dist/bin/schema-cli.d.ts +1 -0
  9. package/dist/bin/schema-cli.js +6104 -0
  10. package/dist/bin/schema-cli.js.map +1 -0
  11. package/dist/bin/signals-cli.d.ts +1 -0
  12. package/dist/bin/signals-cli.js +2104 -0
  13. package/dist/bin/signals-cli.js.map +1 -0
  14. package/dist/config/index.js +29 -4915
  15. package/dist/config/index.js.map +1 -1
  16. package/dist/crucible/index.js +120 -5336
  17. package/dist/crucible/index.js.map +1 -1
  18. package/dist/errors/index.js +52 -4434
  19. package/dist/errors/index.js.map +1 -1
  20. package/dist/foundry/index.js +197 -1874
  21. package/dist/foundry/index.js.map +1 -1
  22. package/dist/fulpack/index.js +43 -31
  23. package/dist/fulpack/index.js.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +204 -4185
  26. package/dist/index.js.map +1 -1
  27. package/dist/pathfinder/index.js +47 -4378
  28. package/dist/pathfinder/index.js.map +1 -1
  29. package/dist/reports/license-inventory.csv +17 -17
  30. package/dist/schema/index.js +0 -4
  31. package/dist/schema/index.js.map +1 -1
  32. package/dist/signals/index.js +231 -3570
  33. package/dist/signals/index.js.map +1 -1
  34. package/dist/telemetry/http/index.js +94 -5280
  35. package/dist/telemetry/http/index.js.map +1 -1
  36. package/dist/telemetry/index.js +70 -4786
  37. package/dist/telemetry/index.js.map +1 -1
  38. package/dist/telemetry/prometheus/index.js +461 -4450
  39. package/dist/telemetry/prometheus/index.js.map +1 -1
  40. package/package.json +13 -8
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/crucible/foundry/exitCodes.ts","../../src/foundry/exit-codes/capabilities.ts","../../src/foundry/exit-codes/simplified.ts","../../src/foundry/exit-codes/index.ts","../../src/telemetry/counter.ts","../../src/telemetry/gauge.ts","../../src/telemetry/taxonomy.ts","../../src/telemetry/histogram.ts","../../src/telemetry/registry.ts","../../src/telemetry/types.ts","../../src/schema/ajv-formats.ts","../../src/schema/errors.ts","../../src/schema/utils.ts","../../src/schema/goneat-bridge.ts","../../src/schema/normalizer.ts","../../src/schema/registry.ts","../../src/schema/cli.ts","../../src/schema/export.ts","../../src/schema/index.ts","../../src/telemetry/validators.ts","../../src/telemetry/index.ts","../../src/schema/validator.ts","../../src/foundry/errors.ts","../../src/foundry/signals/catalog.ts","../../src/foundry/signals/capabilities.ts","../../src/foundry/signals/cli.ts","../../src/bin/signals-cli.ts"],"names":["parseYaml","init_registry","__filename","__dirname","join","readFile","parseYAML","access","fileURLToPath","dirname","init_errors","getPlatform","isPOSIX","isWindows","supportsSignalExitCodes","getPlatformCapabilities","init_capabilities","Command","validateDataBySchemaId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAgBa,SAAA;AAhBb,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,mCAAA,GAAA;AAgBO,IAAM,SAAA,GAAY;AAAA;AAAA;AAAA,MAGvB,YAAA,EAAc,CAAA;AAAA,MACd,YAAA,EAAc,CAAA;AAAA;AAAA;AAAA,MAId,gBAAA,EAAkB,EAAA;AAAA,MAClB,yBAAA,EAA2B,EAAA;AAAA,MAC3B,6BAAA,EAA+B,EAAA;AAAA,MAC/B,wBAAA,EAA0B,EAAA;AAAA,MAC1B,uBAAA,EAAyB,EAAA;AAAA,MACzB,uBAAA,EAAyB,EAAA;AAAA;AAAA;AAAA,MAIzB,mBAAA,EAAqB,EAAA;AAAA,MACrB,uBAAA,EAAyB,EAAA;AAAA,MACzB,0BAAA,EA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,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,sCAAA,EAAyC,KAAA,CAAgB,OAAO,CAAA;AAC9E,MAAA,OAAA,CAAQ,IAAA,CAAK,UAAU,YAAY,CAAA;AAAA,IACrC;AAAA,EACF,CAAC,CAAA;AAEH,EAAA,OAAO,OAAA;AACT;AAKA,eAAsB,KAAK,IAAA,EAAgC;AACzD,EAAA,MAAM,UAAU,gBAAA,EAAiB;AACjC,EAAA,MAAM,OAAA,CAAQ,WAAW,IAAI,CAAA;AAC/B;;;AClQA,KAAK,IAAA,EAAK","file":"signals-cli.js","sourcesContent":["/**\n * Exit Codes - Generated from Crucible catalog\n *\n * This file is AUTO-GENERATED from the Foundry exit codes catalog.\n * DO NOT EDIT MANUALLY - changes will be overwritten.\n *\n * Catalog Version: v1.0.0\n * Last Reviewed: 2025-10-31\n * Source: config/library/foundry/exit-codes.yaml\n */\n\n/**\n * Standardized process exit codes for Fulmen ecosystem\n *\n * @see https://github.com/fulmenhq/crucible/blob/main/docs/standards/library/foundry/README.md#exit-codes\n */\nexport const exitCodes = {\n // Standard Exit Codes (0-1)\n // POSIX standard success and generic failure codes\n EXIT_SUCCESS: 0,\n EXIT_FAILURE: 1,\n\n // Networking & Port Management (10-19)\n // Network-related failures (ports, connectivity, etc.)\n EXIT_PORT_IN_USE: 10,\n EXIT_PORT_RANGE_EXHAUSTED: 11,\n EXIT_INSTANCE_ALREADY_RUNNING: 12,\n EXIT_NETWORK_UNREACHABLE: 13,\n EXIT_CONNECTION_REFUSED: 14,\n EXIT_CONNECTION_TIMEOUT: 15,\n\n // Configuration & Validation (20-29)\n // Configuration errors, validation failures, version mismatches\n EXIT_CONFIG_INVALID: 20,\n EXIT_MISSING_DEPENDENCY: 21,\n EXIT_SSOT_VERSION_MISMATCH: 22,\n EXIT_CONFIG_FILE_NOT_FOUND: 23,\n EXIT_ENVIRONMENT_INVALID: 24,\n\n // Runtime Errors (30-39)\n // Errors during normal operation (health checks, database, etc.)\n EXIT_HEALTH_CHECK_FAILED: 30,\n EXIT_DATABASE_UNAVAILABLE: 31,\n EXIT_EXTERNAL_SERVICE_UNAVAILABLE: 32,\n EXIT_RESOURCE_EXHAUSTED: 33,\n EXIT_OPERATION_TIMEOUT: 34,\n\n // Command-Line Usage Errors (40-49)\n // Invalid arguments, missing required flags, usage errors\n EXIT_INVALID_ARGUMENT: 40,\n EXIT_MISSING_REQUIRED_ARGUMENT: 41,\n EXIT_USAGE: 64,\n\n // Permissions & File Access (50-59)\n // Permission denied, file not found, access errors\n EXIT_PERMISSION_DENIED: 50,\n EXIT_FILE_NOT_FOUND: 51,\n EXIT_DIRECTORY_NOT_FOUND: 52,\n EXIT_FILE_READ_ERROR: 53,\n EXIT_FILE_WRITE_ERROR: 54,\n\n // Data & Processing Errors (60-69)\n // Data validation, parsing, transformation failures\n EXIT_DATA_INVALID: 60,\n EXIT_PARSE_ERROR: 61,\n EXIT_TRANSFORMATION_FAILED: 62,\n EXIT_DATA_CORRUPT: 63,\n\n // Security & Authentication (70-79)\n // Authentication failures, authorization errors, security violations\n EXIT_AUTHENTICATION_FAILED: 70,\n EXIT_AUTHORIZATION_FAILED: 71,\n EXIT_SECURITY_VIOLATION: 72,\n EXIT_CERTIFICATE_INVALID: 73,\n\n // Observability & Monitoring (80-89)\n // Observability infrastructure failures. Use when observability is CRITICAL to operation (e.g., monitoring agents, telemetry exporters). For workhorses where observability is auxiliary: - Log warning and continue (don't exit) - Emit degraded health status - Only exit if explicitly configured (fail_on_observability_error: true)\n EXIT_METRICS_UNAVAILABLE: 80,\n EXIT_TRACING_FAILED: 81,\n EXIT_LOGGING_FAILED: 82,\n EXIT_ALERT_SYSTEM_FAILED: 83,\n EXIT_STRUCTURED_LOGGING_FAILED: 84,\n\n // Testing & Validation (91-99)\n // Test execution outcomes and validation failures. NOTE: Test harnesses MUST use EXIT_SUCCESS (0) for successful test runs per ecosystem conventions (pytest, Go testing, Jest all use 0 for success). Codes in this category are for FAILURES and exceptional conditions only.\n EXIT_TEST_FAILURE: 91,\n EXIT_TEST_ERROR: 92,\n EXIT_TEST_INTERRUPTED: 93,\n EXIT_TEST_USAGE_ERROR: 94,\n EXIT_TEST_NO_TESTS_COLLECTED: 95,\n EXIT_COVERAGE_THRESHOLD_NOT_MET: 96,\n\n // Shell & Process Control (124-127)\n // Exit codes from shell conventions and process control utilities (timeout, exec)\n EXIT_TIMEOUT: 124,\n EXIT_TIMEOUT_INTERNAL: 125,\n EXIT_CANNOT_EXECUTE: 126,\n EXIT_NOT_FOUND: 127,\n\n // Signal-Induced Exits (128-165)\n // Process terminated by Unix signals (128+N pattern per POSIX). Signal codes follow Linux numbering; macOS/FreeBSD differ for SIGUSR1/SIGUSR2. For full signal semantics, see config/library/foundry/signals.yaml. For signal handling patterns, see docs/standards/library/modules/signal-handling.md.\n EXIT_SIGNAL_HUP: 129,\n EXIT_SIGNAL_INT: 130,\n EXIT_SIGNAL_QUIT: 131,\n EXIT_SIGNAL_KILL: 137,\n EXIT_SIGNAL_PIPE: 141,\n EXIT_SIGNAL_ALRM: 142,\n EXIT_SIGNAL_TERM: 143,\n EXIT_SIGNAL_USR1: 138,\n EXIT_SIGNAL_USR2: 140,\n} as const;\n\n/**\n * Exit code value type - union of all valid exit code numbers\n */\nexport type ExitCode = (typeof exitCodes)[keyof typeof exitCodes];\n\n/**\n * Exit code name type - union of all valid exit code constant names\n */\nexport type ExitCodeName = keyof typeof exitCodes;\n\n/**\n * Exit code metadata information\n */\nexport interface ExitCodeInfo {\n code: number;\n name: string;\n description: string;\n context: string;\n category: string;\n retryHint?: \"retry\" | \"no_retry\" | \"investigate\";\n bsdEquivalent?: string;\n pythonNote?: string;\n}\n\n/**\n * Metadata for all exit codes\n */\nexport const exitCodeMetadata: Record<number, ExitCodeInfo> = {\n 0: {\n code: 0,\n name: \"EXIT_SUCCESS\",\n description: \"Successful execution\",\n context: \"Command completed without errors\",\n category: \"standard\",\n },\n 1: {\n code: 1,\n name: \"EXIT_FAILURE\",\n description: \"Generic failure (unspecified error)\",\n context: \"Use when no more specific exit code applies\",\n category: \"standard\",\n },\n 10: {\n code: 10,\n name: \"EXIT_PORT_IN_USE\",\n description: \"Specified port is already in use\",\n context: \"Server startup when port unavailable and fail_if_unavailable strategy\",\n category: \"networking\",\n },\n 11: {\n code: 11,\n name: \"EXIT_PORT_RANGE_EXHAUSTED\",\n description: \"No available ports in configured range\",\n context: \"Server startup when all ports in environment range occupied\",\n category: \"networking\",\n },\n 12: {\n code: 12,\n name: \"EXIT_INSTANCE_ALREADY_RUNNING\",\n description: \"Another instance already running on target port\",\n context: \"Server startup when PID registry shows active process on port\",\n category: \"networking\",\n },\n 13: {\n code: 13,\n name: \"EXIT_NETWORK_UNREACHABLE\",\n description: \"Network destination unreachable\",\n context: \"Client connections, health checks, external service validation\",\n category: \"networking\",\n },\n 14: {\n code: 14,\n name: \"EXIT_CONNECTION_REFUSED\",\n description: \"Connection refused by remote host\",\n context: \"Database connections, API endpoints, upstream services\",\n category: \"networking\",\n },\n 15: {\n code: 15,\n name: \"EXIT_CONNECTION_TIMEOUT\",\n description: \"Connection attempt timed out\",\n context: \"Slow networks, unresponsive services, firewall blocks\",\n category: \"networking\",\n },\n 20: {\n code: 20,\n name: \"EXIT_CONFIG_INVALID\",\n description: \"Configuration file failed validation\",\n context: \"Startup validation, schema mismatches, invalid YAML/JSON\",\n category: \"configuration\",\n retryHint: \"no_retry\",\n },\n 21: {\n code: 21,\n name: \"EXIT_MISSING_DEPENDENCY\",\n description: \"Required dependency not found\",\n context: \"Missing binaries, libraries, or runtime requirements\",\n category: \"configuration\",\n retryHint: \"investigate\",\n },\n 22: {\n code: 22,\n name: \"EXIT_SSOT_VERSION_MISMATCH\",\n description: \"SSOT (Crucible) version incompatible\",\n context: \"Helper library detects unsupported Crucible version\",\n category: \"configuration\",\n retryHint: \"no_retry\",\n },\n 23: {\n code: 23,\n name: \"EXIT_CONFIG_FILE_NOT_FOUND\",\n description: \"Required configuration file not found\",\n context: \"Explicitly specified config path doesn't exist\",\n category: \"configuration\",\n },\n 24: {\n code: 24,\n name: \"EXIT_ENVIRONMENT_INVALID\",\n description: \"Invalid or unsupported environment specification\",\n context: \"Unknown environment name, missing environment config\",\n category: \"configuration\",\n },\n 30: {\n code: 30,\n name: \"EXIT_HEALTH_CHECK_FAILED\",\n description: \"Health check endpoint returned non-healthy status\",\n context: \"Startup health validation, readiness probes\",\n category: \"runtime\",\n retryHint: \"retry\",\n },\n 31: {\n code: 31,\n name: \"EXIT_DATABASE_UNAVAILABLE\",\n description: \"Database connection failed or unavailable\",\n context: \"Startup connection checks, critical query failures\",\n category: \"runtime\",\n retryHint: \"retry\",\n },\n 32: {\n code: 32,\n name: \"EXIT_EXTERNAL_SERVICE_UNAVAILABLE\",\n description: \"Required external service unavailable\",\n context: \"API dependencies, message queues, cache servers\",\n category: \"runtime\",\n },\n 33: {\n code: 33,\n name: \"EXIT_RESOURCE_EXHAUSTED\",\n description: \"System resources exhausted (memory, disk, file descriptors)\",\n context: \"Out-of-memory, disk full, too many open files\",\n category: \"runtime\",\n retryHint: \"investigate\",\n },\n 34: {\n code: 34,\n name: \"EXIT_OPERATION_TIMEOUT\",\n description: \"Operation exceeded timeout threshold\",\n context: \"Long-running tasks, async operations, batch processing\",\n category: \"runtime\",\n retryHint: \"retry\",\n },\n 40: {\n code: 40,\n name: \"EXIT_INVALID_ARGUMENT\",\n description: \"Invalid command-line argument or flag value\",\n context: \"Type errors, out-of-range values, malformed input\",\n category: \"usage\",\n },\n 41: {\n code: 41,\n name: \"EXIT_MISSING_REQUIRED_ARGUMENT\",\n description: \"Required command-line argument not provided\",\n context: \"Missing --config, --port, or other required flags\",\n category: \"usage\",\n },\n 64: {\n code: 64,\n name: \"EXIT_USAGE\",\n description: \"Command-line usage error\",\n context: \"BSD sysexits.h EX_USAGE - wrong number of arguments, bad syntax\",\n category: \"usage\",\n bsdEquivalent: \"EX_USAGE\",\n },\n 50: {\n code: 50,\n name: \"EXIT_PERMISSION_DENIED\",\n description: \"Insufficient permissions for operation\",\n context: \"File access, port binding (<1024), privileged operations\",\n category: \"permissions\",\n },\n 51: {\n code: 51,\n name: \"EXIT_FILE_NOT_FOUND\",\n description: \"Required file not found\",\n context: \"Assets, templates, data files (not config - use 23)\",\n category: \"permissions\",\n },\n 52: {\n code: 52,\n name: \"EXIT_DIRECTORY_NOT_FOUND\",\n description: \"Required directory not found\",\n context: \"State directories, log paths, data directories\",\n category: \"permissions\",\n },\n 53: {\n code: 53,\n name: \"EXIT_FILE_READ_ERROR\",\n description: \"Error reading file\",\n context: \"Corrupt files, I/O errors, encoding issues\",\n category: \"permissions\",\n },\n 54: {\n code: 54,\n name: \"EXIT_FILE_WRITE_ERROR\",\n description: \"Error writing file\",\n context: \"Disk full, read-only filesystem, permission errors\",\n category: \"permissions\",\n },\n 60: {\n code: 60,\n name: \"EXIT_DATA_INVALID\",\n description: \"Input data failed validation\",\n context: \"Schema validation, business rule violations\",\n category: \"data\",\n },\n 61: {\n code: 61,\n name: \"EXIT_PARSE_ERROR\",\n description: \"Error parsing input data\",\n context: \"Malformed JSON/YAML/XML, syntax errors\",\n category: \"data\",\n },\n 62: {\n code: 62,\n name: \"EXIT_TRANSFORMATION_FAILED\",\n description: \"Data transformation or conversion failed\",\n context: \"Type conversions, format transformations, encoding changes\",\n category: \"data\",\n },\n 63: {\n code: 63,\n name: \"EXIT_DATA_CORRUPT\",\n description: \"Data corruption detected\",\n context: \"Checksum failures, integrity violations\",\n category: \"data\",\n },\n 70: {\n code: 70,\n name: \"EXIT_AUTHENTICATION_FAILED\",\n description: \"Authentication failed\",\n context: \"Invalid credentials, expired tokens, auth service unavailable\",\n category: \"security\",\n },\n 71: {\n code: 71,\n name: \"EXIT_AUTHORIZATION_FAILED\",\n description: \"Authorization failed (authenticated but insufficient permissions)\",\n context: \"RBAC failures, scope violations, resource access denied\",\n category: \"security\",\n },\n 72: {\n code: 72,\n name: \"EXIT_SECURITY_VIOLATION\",\n description: \"Security policy violation detected\",\n context: \"Suspicious activity, rate limit exceeded, IP blocklist\",\n category: \"security\",\n },\n 73: {\n code: 73,\n name: \"EXIT_CERTIFICATE_INVALID\",\n description: \"TLS/SSL certificate validation failed\",\n context: \"Expired certs, untrusted CAs, hostname mismatches\",\n category: \"security\",\n bsdEquivalent: \"EX_PROTOCOL\",\n },\n 80: {\n code: 80,\n name: \"EXIT_METRICS_UNAVAILABLE\",\n description: \"Metrics endpoint or collection system unavailable\",\n context:\n \"Use for observability-focused tools (Prometheus exporters, StatsD agents).\\nWorkhorses SHOULD log warning and continue unless configured to fail-fast.\\n\",\n category: \"observability\",\n },\n 81: {\n code: 81,\n name: \"EXIT_TRACING_FAILED\",\n description: \"Distributed tracing system unavailable\",\n context: \"OTLP exporter failed, Jaeger collector unreachable\",\n category: \"observability\",\n },\n 82: {\n code: 82,\n name: \"EXIT_LOGGING_FAILED\",\n description: \"Logging system unavailable or misconfigured\",\n context: \"Log aggregator unreachable, log file unwritable\",\n category: \"observability\",\n },\n 83: {\n code: 83,\n name: \"EXIT_ALERT_SYSTEM_FAILED\",\n description: \"Alerting system unavailable\",\n context: \"PagerDuty API failed, Slack webhook unreachable\",\n category: \"observability\",\n },\n 84: {\n code: 84,\n name: \"EXIT_STRUCTURED_LOGGING_FAILED\",\n description: \"Structured logging system unavailable\",\n context: \"JSON log aggregator unreachable, log schema validation failed\",\n category: \"observability\",\n },\n 91: {\n code: 91,\n name: \"EXIT_TEST_FAILURE\",\n description: \"One or more tests failed\",\n context:\n \"Test assertions failed, expected behavior not met.\\nMaps to pytest exit code 1, Go test failure, Jest failure.\\n\",\n category: \"testing\",\n },\n 92: {\n code: 92,\n name: \"EXIT_TEST_ERROR\",\n description: \"Test execution error (not test failure)\",\n context:\n \"Test setup failed, fixture unavailable, test harness error.\\nMaps to pytest exit code 3 (internal error).\\n\",\n category: \"testing\",\n },\n 93: {\n code: 93,\n name: \"EXIT_TEST_INTERRUPTED\",\n description: \"Test run interrupted by user or system\",\n context:\n \"Ctrl+C during tests, system signal, user cancellation.\\nMaps to pytest exit code 2.\\n\",\n category: \"testing\",\n },\n 94: {\n code: 94,\n name: \"EXIT_TEST_USAGE_ERROR\",\n description: \"Test command usage error\",\n context: \"Invalid test arguments, bad configuration.\\nMaps to pytest exit code 4.\\n\",\n category: \"testing\",\n },\n 95: {\n code: 95,\n name: \"EXIT_TEST_NO_TESTS_COLLECTED\",\n description: \"No tests found or all tests skipped\",\n context: \"Empty test suite, all tests deselected or skipped.\\nMaps to pytest exit code 5.\\n\",\n category: \"testing\",\n },\n 96: {\n code: 96,\n name: \"EXIT_COVERAGE_THRESHOLD_NOT_MET\",\n description: \"Test coverage below required threshold\",\n context: \"Code coverage validation, quality gate failure\",\n category: \"testing\",\n },\n 124: {\n code: 124,\n name: \"EXIT_TIMEOUT\",\n description: \"Command timed out before completion\",\n context: \"GNU timeout or similar utility terminated command after deadline\",\n category: \"shell\",\n },\n 125: {\n code: 125,\n name: \"EXIT_TIMEOUT_INTERNAL\",\n description: \"Timeout utility itself failed\",\n context: \"Error in timeout tool before or during command execution (not command failure)\",\n category: \"shell\",\n },\n 126: {\n code: 126,\n name: \"EXIT_CANNOT_EXECUTE\",\n description: \"Command found but could not be executed\",\n context: \"Permission denied, not executable, exec format error\",\n category: \"shell\",\n bsdEquivalent: \"EX_NOPERM (partial)\",\n },\n 127: {\n code: 127,\n name: \"EXIT_NOT_FOUND\",\n description: \"Command not found\",\n context: \"Executable not found in PATH or specified path does not exist\",\n category: \"shell\",\n bsdEquivalent: \"EX_UNAVAILABLE (partial)\",\n },\n 129: {\n code: 129,\n name: \"EXIT_SIGNAL_HUP\",\n description: \"Hangup signal (SIGHUP) - config reload via restart\",\n context:\n \"Config reload via restart-based pattern (mandatory schema validation).\\nProcess exits with 129, supervisor restarts with new config.\\nSee signals.yaml for reload behavior definition.\",\n category: \"signals\",\n bsdEquivalent: \"128 + 1\",\n },\n 130: {\n code: 130,\n name: \"EXIT_SIGNAL_INT\",\n description: \"Interrupt signal (SIGINT) - user interrupt with Ctrl+C double-tap\",\n context:\n \"Ctrl+C pressed. First tap initiates graceful shutdown, second within 2s forces immediate exit.\\nSame exit code (130) for both graceful and force modes.\\nSee signals.yaml for double-tap behavior definition.\",\n category: \"signals\",\n bsdEquivalent: \"128 + 2\",\n },\n 131: {\n code: 131,\n name: \"EXIT_SIGNAL_QUIT\",\n description: \"Quit signal (SIGQUIT) - immediate exit\",\n context:\n \"Ctrl+\\\\ on Unix, Ctrl+Break on Windows. Immediate termination without cleanup.\\nUse for emergency shutdown or debugging (core dumps).\",\n category: \"signals\",\n bsdEquivalent: \"128 + 3\",\n },\n 137: {\n code: 137,\n name: \"EXIT_SIGNAL_KILL\",\n description: \"Kill signal (SIGKILL)\",\n context: \"Forceful termination, non-graceful shutdown (not catchable)\",\n category: \"signals\",\n bsdEquivalent: \"128 + 9\",\n pythonNote: \"Cannot be caught in Python (OS-level)\",\n },\n 141: {\n code: 141,\n name: \"EXIT_SIGNAL_PIPE\",\n description: \"Broken pipe (SIGPIPE) - observe only\",\n context:\n \"Writing to closed pipe/socket. Fulmen default is observe_only (log + graceful exit).\\nApplications may override to ignore for network services.\\nSee signals.yaml for SIGPIPE handling guidance.\",\n category: \"signals\",\n bsdEquivalent: \"128 + 13\",\n pythonNote: \"Raised as BrokenPipeError exception\",\n },\n 142: {\n code: 142,\n name: \"EXIT_SIGNAL_ALRM\",\n description: \"Alarm signal (SIGALRM) - watchdog timeout\",\n context:\n \"Watchdog timer expired. Treat as timeout-induced exit.\\nWatchdog pattern out of scope for v1.0.0 module implementations.\",\n category: \"signals\",\n bsdEquivalent: \"128 + 14\",\n pythonNote: \"Supported by signal module, rarely used in practice\",\n },\n 143: {\n code: 143,\n name: \"EXIT_SIGNAL_TERM\",\n description: \"Termination signal (SIGTERM) - graceful shutdown\",\n context:\n \"Graceful shutdown requested by container orchestrator or process supervisor.\\nStandard 30-second timeout for cleanup. Applications run cleanup handlers before exit.\\nSee signals.yaml for graceful shutdown behavior definition.\",\n category: \"signals\",\n bsdEquivalent: \"128 + 15\",\n pythonNote: \"Default signal for graceful shutdown\",\n },\n 138: {\n code: 138,\n name: \"EXIT_SIGNAL_USR1\",\n description: \"User-defined signal 1 (SIGUSR1) - custom handler\",\n context:\n \"Application-specific signal (e.g., reopen logs, dump stats, trigger profiling).\\nApplications register custom handlers. Exit code 138 on Linux (128+10).\\nPlatform differences: macOS/FreeBSD use signal 30 (exit 158), not 10.\",\n category: \"signals\",\n },\n 140: {\n code: 140,\n name: \"EXIT_SIGNAL_USR2\",\n description: \"User-defined signal 2 (SIGUSR2) - custom handler\",\n context:\n \"Application-specific signal (e.g., toggle debug mode, rotate credentials).\\nApplications register custom handlers. Exit code 140 on Linux (128+12).\\nPlatform differences: macOS/FreeBSD use signal 31 (exit 159), not 12.\",\n category: \"signals\",\n },\n};\n\n/**\n * Get metadata for a specific exit code\n *\n * @param code - Exit code number\n * @returns Exit code metadata or undefined if not found\n */\nexport function getExitCodeInfo(code: number): ExitCodeInfo | undefined {\n return exitCodeMetadata[code];\n}\n\n/**\n * Catalog version for telemetry and compatibility checks\n */\nexport const EXIT_CODES_VERSION = \"v1.0.0\";\n","/**\n * Exit Code Capabilities Detection\n *\n * Detects platform capabilities for exit code support, particularly\n * for signal-based exit codes which are POSIX-specific.\n *\n * @module foundry/exit-codes/capabilities\n */\n\n/**\n * Check if the current platform supports signal-based exit codes\n *\n * Signal exit codes (128+N pattern) are POSIX-specific and not\n * meaningful on Windows. Applications should use this to decide\n * whether to use simplified mode.\n *\n * @returns true if platform supports signal exit codes (POSIX), false otherwise (Windows)\n *\n * @example\n * ```ts\n * import { supportsSignalExitCodes, SimplifiedMode } from '@fulmenhq/tsfulmen/foundry/exit-codes';\n *\n * const exitCodeMode = supportsSignalExitCodes()\n * ? 'full' // Use all 54 exit codes\n * : SimplifiedMode.SEVERITY; // Use simplified mode on Windows\n *\n * console.log(`Exit code mode: ${exitCodeMode}`);\n * ```\n *\n * @example\n * ```ts\n * // Guard signal exit code usage\n * import { exitCodes, supportsSignalExitCodes } from '@fulmenhq/tsfulmen/foundry/exit-codes';\n *\n * function handleTermination() {\n * if (supportsSignalExitCodes()) {\n * // POSIX: Use specific signal exit code\n * process.exit(exitCodes.EXIT_SIGNAL_TERM);\n * } else {\n * // Windows: Use generic failure\n * process.exit(exitCodes.EXIT_FAILURE);\n * }\n * }\n * ```\n */\nexport function supportsSignalExitCodes(): boolean {\n // Windows does not support POSIX signals in the same way\n // WSL reports as 'linux' so it will correctly return true\n return process.platform !== \"win32\";\n}\n\n/**\n * Get the current platform identifier\n *\n * Useful for logging and diagnostics.\n *\n * @returns Platform string (linux, darwin, win32, etc.)\n */\nexport function getPlatform(): NodeJS.Platform {\n return process.platform;\n}\n\n/**\n * Check if running on Windows (including WSL detection)\n *\n * Note: WSL reports as 'linux' not 'win32', so this only returns\n * true for native Windows processes.\n *\n * @returns true if running on native Windows\n */\nexport function isWindows(): boolean {\n return process.platform === \"win32\";\n}\n\n/**\n * Check if running on a POSIX-compliant platform\n *\n * @returns true if running on Linux, macOS, or other POSIX systems\n */\nexport function isPOSIX(): boolean {\n return !isWindows();\n}\n\n/**\n * Platform capabilities summary\n */\nexport interface PlatformCapabilities {\n platform: NodeJS.Platform;\n supportsSignalExitCodes: boolean;\n isPOSIX: boolean;\n isWindows: boolean;\n}\n\n/**\n * Get a summary of platform capabilities\n *\n * @returns Platform capabilities object\n *\n * @example\n * ```ts\n * import { getPlatformCapabilities } from '@fulmenhq/tsfulmen/foundry/exit-codes';\n *\n * const caps = getPlatformCapabilities();\n * console.log(`Platform: ${caps.platform}`);\n * console.log(`Supports signal exit codes: ${caps.supportsSignalExitCodes}`);\n * ```\n */\nexport function getPlatformCapabilities(): PlatformCapabilities {\n return {\n platform: getPlatform(),\n supportsSignalExitCodes: supportsSignalExitCodes(),\n isPOSIX: isPOSIX(),\n isWindows: isWindows(),\n };\n}\n","/**\n * Simplified Exit Code Mapping\n *\n * Provides simplified exit code modes for applications that don't need\n * the full granularity of 54 exit codes. Useful for:\n * - Windows environments where signal codes may not be relevant\n * - Simple scripts that only need basic success/failure indication\n * - Wrapper scripts that aggregate multiple failure types\n *\n * @module foundry/exit-codes/simplified\n */\n\nimport type { ExitCode } from \"../../crucible/foundry/exitCodes.js\";\nimport { exitCodeMetadata } from \"../../crucible/foundry/exitCodes.js\";\n\n/**\n * Simplified exit code modes\n */\nexport enum SimplifiedMode {\n /**\n * BASIC mode: Only success (0) and failure (1)\n * - 0 = EXIT_SUCCESS\n * - 1 = All failures\n */\n BASIC = \"basic\",\n\n /**\n * SEVERITY mode: Success, recoverable, config, fatal\n * - 0 = EXIT_SUCCESS\n * - 1 = Recoverable errors (retry possible)\n * - 2 = Configuration/usage errors (fix config, don't retry)\n * - 3 = Fatal errors (investigate required)\n */\n SEVERITY = \"severity\",\n}\n\n/**\n * Map a full exit code to a simplified code based on mode\n *\n * @param code - Full exit code from exitCodes\n * @param mode - Simplified mode to use\n * @returns Simplified exit code (0-3 depending on mode)\n *\n * @example\n * ```ts\n * import { exitCodes, mapExitCodeToSimplified, SimplifiedMode } from '@fulmenhq/tsfulmen/foundry/exit-codes';\n *\n * // Basic mode - only 0 or 1\n * const basicCode = mapExitCodeToSimplified(exitCodes.EXIT_CONFIG_INVALID, SimplifiedMode.BASIC);\n * console.log(basicCode); // 1 (any failure)\n *\n * // Severity mode - categorizes failures\n * const sevCode = mapExitCodeToSimplified(exitCodes.EXIT_CONFIG_INVALID, SimplifiedMode.SEVERITY);\n * console.log(sevCode); // 2 (config error - don't retry)\n *\n * const retryCode = mapExitCodeToSimplified(exitCodes.EXIT_DATABASE_UNAVAILABLE, SimplifiedMode.SEVERITY);\n * console.log(retryCode); // 1 (recoverable - retry possible)\n * ```\n */\nexport function mapExitCodeToSimplified(\n code: ExitCode,\n mode: SimplifiedMode = SimplifiedMode.BASIC,\n): number {\n // Success is always 0\n if (code === 0) {\n return 0;\n }\n\n // BASIC mode: everything else is 1\n if (mode === SimplifiedMode.BASIC) {\n return 1;\n }\n\n // SEVERITY mode: categorize based on metadata\n const info = exitCodeMetadata[code];\n if (!info) {\n // Unknown code - treat as fatal\n return 3;\n }\n\n // Check retry hint first\n if (info.retryHint === \"retry\") {\n // Recoverable - likely transient failure\n return 1;\n }\n\n if (info.retryHint === \"no_retry\") {\n // Configuration/permanent error - don't retry\n return 2;\n }\n\n if (info.retryHint === \"investigate\") {\n // Serious issue requiring investigation\n return 3;\n }\n\n // Category-based fallback\n switch (info.category) {\n case \"configuration\":\n case \"usage\":\n // Config and usage errors - fix config, don't retry\n return 2;\n\n case \"networking\":\n case \"runtime\":\n // Network and runtime issues - often recoverable\n return 1;\n\n case \"permissions\":\n case \"data\":\n // Permission and data errors - likely permanent\n return 2;\n\n case \"security\":\n // Security issues - investigate\n return 3;\n\n case \"observability\":\n // Observability failures - recoverable if non-critical\n return 1;\n\n case \"testing\":\n // Test failures - depends on context, default to failure\n return 1;\n\n case \"signals\":\n // Signal termination - not applicable on Windows\n // Treat as fatal since process was forcibly terminated\n return 3;\n\n default:\n // Unknown category - treat as generic failure\n return 1;\n }\n}\n\n/**\n * Get all simplified exit codes for a given mode\n *\n * @param mode - Simplified mode\n * @returns Array of simplified codes for this mode\n *\n * @example\n * ```ts\n * import { getSimplifiedCodes, SimplifiedMode } from '@fulmenhq/tsfulmen/foundry/exit-codes';\n *\n * console.log(getSimplifiedCodes(SimplifiedMode.BASIC));\n * // [0, 1]\n *\n * console.log(getSimplifiedCodes(SimplifiedMode.SEVERITY));\n * // [0, 1, 2, 3]\n * ```\n */\nexport function getSimplifiedCodes(mode: SimplifiedMode): number[] {\n switch (mode) {\n case SimplifiedMode.BASIC:\n return [0, 1];\n case SimplifiedMode.SEVERITY:\n return [0, 1, 2, 3];\n default:\n return [0, 1];\n }\n}\n\n/**\n * Get description for a simplified exit code\n *\n * @param code - Simplified exit code\n * @param mode - Simplified mode\n * @returns Human-readable description\n */\nexport function getSimplifiedCodeDescription(code: number, mode: SimplifiedMode): string {\n if (mode === SimplifiedMode.BASIC) {\n switch (code) {\n case 0:\n return \"Success\";\n case 1:\n return \"Failure\";\n default:\n return \"Unknown\";\n }\n }\n\n if (mode === SimplifiedMode.SEVERITY) {\n switch (code) {\n case 0:\n return \"Success\";\n case 1:\n return \"Recoverable error (retry possible)\";\n case 2:\n return \"Configuration error (fix config, don't retry)\";\n case 3:\n return \"Fatal error (investigate required)\";\n default:\n return \"Unknown\";\n }\n }\n\n return \"Unknown mode\";\n}\n","/**\n * Exit Codes Module\n *\n * Standardized process exit codes for the Fulmen ecosystem.\n * Generated from Crucible catalog and synced via make sync-ssot.\n *\n * @module foundry/exit-codes\n */\n\n// Re-export generated exit codes from crucible foundry\nexport {\n EXIT_CODES_VERSION,\n type ExitCode,\n type ExitCodeInfo,\n type ExitCodeName,\n exitCodeMetadata,\n exitCodes,\n getExitCodeInfo,\n} from \"../../crucible/foundry/exitCodes.js\";\n// Export capability detection helpers\nexport {\n getPlatform,\n getPlatformCapabilities,\n isPOSIX,\n isWindows,\n type PlatformCapabilities,\n supportsSignalExitCodes,\n} from \"./capabilities.js\";\n// Export simplified mode helpers\nexport {\n getSimplifiedCodeDescription,\n getSimplifiedCodes,\n mapExitCodeToSimplified,\n SimplifiedMode,\n} from \"./simplified.js\";\n","/**\n * Counter metric implementation\n *\n * Monotonically increasing counter for counting events\n */\n\nimport type { MetricName } from \"./types.js\";\n\n/**\n * Counter metric\n *\n * Monotonically increasing value for counting events.\n * Supports labeled metrics (Crucible v0.2.7+).\n * Use for metrics like request counts, error counts, etc.\n */\nexport class Counter {\n private value = 0;\n private labeledValues = new Map<string, number>();\n\n constructor(public readonly name: MetricName) {}\n\n /**\n * Increment counter by delta (default: 1)\n *\n * @param delta - Amount to increment (must be non-negative)\n * @param labels - Optional label dimensions for this observation\n * @throws {Error} If delta is negative\n *\n * @example\n * ```typescript\n * counter.inc(); // Increment unlabeled by 1\n * counter.inc(5); // Increment unlabeled by 5\n * counter.inc(1, { status: '200' }); // Increment labeled instance\n * counter.inc(1, { result: 'success' }); // Different label set\n * ```\n */\n inc(delta = 1, labels?: Record<string, string>): void {\n if (delta < 0) {\n throw new Error(`Counter delta must be non-negative, got: ${delta}`);\n }\n\n if (labels && Object.keys(labels).length > 0) {\n // Labeled metric - track per label combination\n const labelKey = this.serializeLabels(labels);\n const current = this.labeledValues.get(labelKey) || 0;\n this.labeledValues.set(labelKey, current + delta);\n } else {\n // Unlabeled metric\n this.value += delta;\n }\n }\n\n /**\n * Get current counter value (unlabeled)\n */\n getValue(): number {\n return this.value;\n }\n\n /**\n * Get all labeled values\n * @returns Map of serialized label keys to values\n */\n getLabeledValues(): Map<string, number> {\n return new Map(this.labeledValues);\n }\n\n /**\n * Get value for specific label combination\n */\n getValueForLabels(labels: Record<string, string>): number {\n const labelKey = this.serializeLabels(labels);\n return this.labeledValues.get(labelKey) || 0;\n }\n\n /**\n * Reset counter to zero (all label combinations)\n */\n reset(): void {\n this.value = 0;\n this.labeledValues.clear();\n }\n\n /**\n * Serialize labels to deterministic string key\n * Format: key1=value1,key2=value2 (sorted by key)\n */\n private serializeLabels(labels: Record<string, string>): string {\n return Object.entries(labels)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join(\",\");\n }\n}\n","/**\n * Gauge metric implementation\n *\n * Gauge for arbitrary values that can go up and down\n */\n\nimport type { MetricName } from \"./types.js\";\n\n/**\n * Gauge metric\n *\n * Arbitrary value that can increase or decrease.\n * Supports labeled metrics (Crucible v0.2.7+).\n * Use for metrics like current connections, memory usage, temperature, etc.\n */\nexport class Gauge {\n private value = 0;\n private labeledValues = new Map<string, number>();\n\n constructor(public readonly name: MetricName) {}\n\n /**\n * Set gauge to specific value\n *\n * @param value - New gauge value (can be any number, including negative)\n * @param labels - Optional label dimensions for this observation\n *\n * @example\n * ```typescript\n * gauge.set(42); // Set unlabeled to 42\n * gauge.set(-10); // Negative values allowed\n * gauge.set(1, { phase: 'collect' }); // Set labeled instance\n * ```\n */\n set(value: number, labels?: Record<string, string>): void {\n if (labels && Object.keys(labels).length > 0) {\n const labelKey = this.serializeLabels(labels);\n this.labeledValues.set(labelKey, value);\n } else {\n this.value = value;\n }\n }\n\n /**\n * Increment gauge by delta (default: 1)\n *\n * @param delta - Amount to increment (can be negative)\n * @param labels - Optional label dimensions for this observation\n */\n inc(delta = 1, labels?: Record<string, string>): void {\n if (labels && Object.keys(labels).length > 0) {\n const labelKey = this.serializeLabels(labels);\n const current = this.labeledValues.get(labelKey) || 0;\n this.labeledValues.set(labelKey, current + delta);\n } else {\n this.value += delta;\n }\n }\n\n /**\n * Decrement gauge by delta (default: 1)\n *\n * @param delta - Amount to decrement (can be negative)\n * @param labels - Optional label dimensions for this observation\n */\n dec(delta = 1, labels?: Record<string, string>): void {\n if (labels && Object.keys(labels).length > 0) {\n const labelKey = this.serializeLabels(labels);\n const current = this.labeledValues.get(labelKey) || 0;\n this.labeledValues.set(labelKey, current - delta);\n } else {\n this.value -= delta;\n }\n }\n\n /**\n * Get current gauge value (unlabeled)\n */\n getValue(): number {\n return this.value;\n }\n\n /**\n * Get all labeled values\n * @returns Map of serialized label keys to values\n */\n getLabeledValues(): Map<string, number> {\n return new Map(this.labeledValues);\n }\n\n /**\n * Get value for specific label combination\n */\n getValueForLabels(labels: Record<string, string>): number {\n const labelKey = this.serializeLabels(labels);\n return this.labeledValues.get(labelKey) || 0;\n }\n\n /**\n * Reset gauge to zero (all label combinations)\n */\n reset(): void {\n this.value = 0;\n this.labeledValues.clear();\n }\n\n /**\n * Serialize labels to deterministic string key\n * Format: key1=value1,key2=value2 (sorted by key)\n */\n private serializeLabels(labels: Record<string, string>): string {\n return Object.entries(labels)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join(\",\");\n }\n}\n","/**\n * Taxonomy loader for metrics definitions\n *\n * Loads and caches metrics taxonomy from config/crucible-ts/taxonomy/metrics.yaml\n * Provides default histogram buckets per ADR-0007\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport type { MetricName, MetricUnit } from \"./types.js\";\n\n/**\n * Metric definition from taxonomy\n */\nexport interface MetricDefinition {\n name: MetricName;\n unit: MetricUnit;\n description: string;\n}\n\n/**\n * Taxonomy structure\n */\nexport interface MetricsTaxonomy {\n version: string;\n defaults: {\n histogram_buckets: {\n ms_metrics: number[];\n };\n };\n metrics: MetricDefinition[];\n}\n\n/**\n * Default histogram buckets for _ms metrics (ADR-0007)\n * [1, 5, 10, 50, 100, 500, 1000, 5000, 10000] milliseconds\n */\nexport const DEFAULT_MS_BUCKETS = [1, 5, 10, 50, 100, 500, 1000, 5000, 10000];\n\n/**\n * Singleton taxonomy loader\n */\nclass TaxonomyLoader {\n private static instance: TaxonomyLoader;\n private taxonomy: MetricsTaxonomy | null = null;\n private loadPromise: Promise<MetricsTaxonomy> | null = null;\n private loadError: Error | null = null;\n\n private constructor() {\n // Private constructor for singleton\n }\n\n /**\n * Get singleton instance\n */\n static getInstance(): TaxonomyLoader {\n if (!TaxonomyLoader.instance) {\n TaxonomyLoader.instance = new TaxonomyLoader();\n }\n return TaxonomyLoader.instance;\n }\n\n /**\n * Load taxonomy from YAML file\n */\n private async load(): Promise<MetricsTaxonomy> {\n if (this.taxonomy !== null) {\n return this.taxonomy;\n }\n\n if (this.loadError !== null) {\n throw this.loadError;\n }\n\n if (this.loadPromise) {\n return this.loadPromise;\n }\n\n this.loadPromise = (async () => {\n try {\n // Resolve path to taxonomy file\n // From src/telemetry/ → ../../config/crucible-ts/taxonomy/metrics.yaml\n const taxonomyPath = join(\n __dirname,\n \"..\",\n \"..\",\n \"config\",\n \"crucible-ts\",\n \"taxonomy\",\n \"metrics.yaml\",\n );\n\n const content = await readFile(taxonomyPath, \"utf-8\");\n this.taxonomy = parseYaml(content) as MetricsTaxonomy;\n\n return this.taxonomy;\n } catch (err) {\n this.loadError = err instanceof Error ? err : new Error(String(err));\n throw new Error(`Failed to load metrics taxonomy: ${this.loadError.message}`);\n }\n })();\n\n return this.loadPromise;\n }\n\n /**\n * Get taxonomy (async)\n */\n async getTaxonomy(): Promise<MetricsTaxonomy> {\n return this.load();\n }\n\n /**\n * Get metric definition by name\n */\n async getMetric(name: MetricName): Promise<MetricDefinition | undefined> {\n const taxonomy = await this.load();\n return taxonomy.metrics.find((m) => m.name === name);\n }\n\n /**\n * Get default unit for metric\n */\n async getDefaultUnit(name: MetricName): Promise<MetricUnit | undefined> {\n const metric = await this.getMetric(name);\n return metric?.unit;\n }\n\n /**\n * Get default histogram buckets for metric\n * Returns ADR-0007 buckets for _ms metrics, undefined for others\n */\n async getDefaultBuckets(name: MetricName): Promise<number[] | undefined> {\n // Check if metric name ends with _ms\n if (name.endsWith(\"_ms\")) {\n const taxonomy = await this.load();\n return taxonomy.defaults.histogram_buckets.ms_metrics;\n }\n return undefined;\n }\n\n /**\n * Check if metric name is valid (exists in taxonomy)\n */\n async isValidMetricName(name: string): Promise<boolean> {\n try {\n const taxonomy = await this.load();\n return taxonomy.metrics.some((m) => m.name === name);\n } catch {\n return false;\n }\n }\n\n /**\n * Reset loader state (for testing)\n * @internal\n */\n static _reset(): void {\n TaxonomyLoader.instance = new TaxonomyLoader();\n }\n}\n\n/**\n * Get metrics taxonomy\n *\n * @returns Promise resolving to taxonomy\n */\nexport async function getTaxonomy(): Promise<MetricsTaxonomy> {\n return TaxonomyLoader.getInstance().getTaxonomy();\n}\n\n/**\n * Get metric definition by name\n *\n * @param name - Metric name\n * @returns Promise resolving to metric definition or undefined\n */\nexport async function getMetric(name: MetricName): Promise<MetricDefinition | undefined> {\n return TaxonomyLoader.getInstance().getMetric(name);\n}\n\n/**\n * Get default unit for metric from taxonomy\n *\n * @param name - Metric name\n * @returns Promise resolving to unit or undefined\n */\nexport async function getDefaultUnit(name: MetricName): Promise<MetricUnit | undefined> {\n return TaxonomyLoader.getInstance().getDefaultUnit(name);\n}\n\n/**\n * Get default histogram buckets for metric\n *\n * Returns ADR-0007 buckets ([1, 5, 10, 50, 100, 500, 1000, 5000, 10000]) for\n * metrics ending with _ms, undefined for others.\n *\n * @param name - Metric name\n * @returns Promise resolving to bucket array or undefined\n *\n * @example\n * ```typescript\n * const buckets = await getDefaultBuckets('config_load_ms');\n * // Returns [1, 5, 10, 50, 100, 500, 1000, 5000, 10000]\n * ```\n */\nexport async function getDefaultBuckets(name: MetricName): Promise<number[] | undefined> {\n return TaxonomyLoader.getInstance().getDefaultBuckets(name);\n}\n\n/**\n * Check if metric name is valid (exists in taxonomy)\n *\n * @param name - Metric name to check\n * @returns Promise resolving to true if valid\n */\nexport async function isValidMetricName(name: string): Promise<boolean> {\n return TaxonomyLoader.getInstance().isValidMetricName(name);\n}\n\n// Export for testing\nexport { TaxonomyLoader };\n","/**\n * Histogram metric implementation\n *\n * Histogram with OTLP-compatible cumulative buckets, auto-applying ADR-0007\n * default buckets for _ms metrics.\n */\n\nimport { DEFAULT_MS_BUCKETS } from \"./taxonomy.js\";\nimport type { HistogramBucket, HistogramOptions, HistogramSummary, MetricName } from \"./types.js\";\n\n/**\n * Labeled histogram state\n */\ninterface LabeledHistogramState {\n count: number;\n sum: number;\n bucketCounts: Map<number, number>;\n}\n\n/**\n * Histogram metric\n *\n * Tracks distribution of values using cumulative buckets (OTLP-compatible).\n * Automatically applies ADR-0007 default buckets for _ms metrics.\n * Supports labeled metrics (Crucible v0.2.7+).\n */\nexport class Histogram {\n private count = 0;\n private sum = 0;\n private bucketCounts: Map<number, number> = new Map();\n private labeledStates = new Map<string, LabeledHistogramState>();\n private readonly buckets: number[];\n\n constructor(\n public readonly name: MetricName,\n options?: HistogramOptions,\n ) {\n // Determine buckets: custom > ADR-0007 defaults for _ms metrics > empty\n if (options?.buckets) {\n this.buckets = [...options.buckets].sort((a, b) => a - b);\n } else if (name.endsWith(\"_ms\") || name.endsWith(\"_seconds\")) {\n this.buckets = [...DEFAULT_MS_BUCKETS];\n } else {\n this.buckets = [];\n }\n\n // Initialize bucket counts\n for (const bucket of this.buckets) {\n this.bucketCounts.set(bucket, 0);\n }\n }\n\n /**\n * Record an observation\n *\n * @param value - Value to observe (typically a duration in ms or seconds)\n * @param labels - Optional label dimensions for this observation\n *\n * @example\n * ```typescript\n * const start = performance.now();\n * // ... operation ...\n * histogram.observe(performance.now() - start);\n * histogram.observe(duration, { phase: 'collect', result: 'success' });\n * ```\n */\n observe(value: number, labels?: Record<string, string>): void {\n if (labels && Object.keys(labels).length > 0) {\n // Labeled observation\n const labelKey = this.serializeLabels(labels);\n let state = this.labeledStates.get(labelKey);\n\n if (!state) {\n // Initialize new labeled state\n state = {\n count: 0,\n sum: 0,\n bucketCounts: new Map(),\n };\n for (const bucket of this.buckets) {\n state.bucketCounts.set(bucket, 0);\n }\n this.labeledStates.set(labelKey, state);\n }\n\n state.count++;\n state.sum += value;\n\n // Update cumulative bucket counts\n for (const bucket of this.buckets) {\n if (value <= bucket) {\n state.bucketCounts.set(bucket, (state.bucketCounts.get(bucket) || 0) + 1);\n }\n }\n } else {\n // Unlabeled observation\n this.count++;\n this.sum += value;\n\n // Update cumulative bucket counts\n for (const bucket of this.buckets) {\n if (value <= bucket) {\n this.bucketCounts.set(bucket, (this.bucketCounts.get(bucket) || 0) + 1);\n }\n }\n }\n }\n\n /**\n * Get histogram summary\n *\n * Returns OTLP-compatible histogram summary with cumulative bucket counts.\n */\n getSummary(): HistogramSummary {\n const buckets: HistogramBucket[] = this.buckets.map((le) => ({\n le,\n count: this.bucketCounts.get(le) || 0,\n }));\n\n return {\n count: this.count,\n sum: this.sum,\n buckets,\n };\n }\n\n /**\n * Get current observation count\n */\n getCount(): number {\n return this.count;\n }\n\n /**\n * Get sum of all observed values\n */\n getSum(): number {\n return this.sum;\n }\n\n /**\n * Get average of observed values\n */\n getAverage(): number {\n return this.count > 0 ? this.sum / this.count : 0;\n }\n\n /**\n * Get all labeled summaries\n * @returns Map of serialized label keys to histogram summaries\n */\n getLabeledSummaries(): Map<string, HistogramSummary> {\n const summaries = new Map<string, HistogramSummary>();\n\n for (const [labelKey, state] of this.labeledStates) {\n const buckets: HistogramBucket[] = this.buckets.map((le) => ({\n le,\n count: state.bucketCounts.get(le) || 0,\n }));\n\n summaries.set(labelKey, {\n count: state.count,\n sum: state.sum,\n buckets,\n });\n }\n\n return summaries;\n }\n\n /**\n * Get summary for specific label combination\n */\n getSummaryForLabels(labels: Record<string, string>): HistogramSummary | null {\n const labelKey = this.serializeLabels(labels);\n const state = this.labeledStates.get(labelKey);\n\n if (!state) {\n return null;\n }\n\n const buckets: HistogramBucket[] = this.buckets.map((le) => ({\n le,\n count: state.bucketCounts.get(le) || 0,\n }));\n\n return {\n count: state.count,\n sum: state.sum,\n buckets,\n };\n }\n\n /**\n * Reset histogram to initial state (all label combinations)\n */\n reset(): void {\n this.count = 0;\n this.sum = 0;\n for (const bucket of this.buckets) {\n this.bucketCounts.set(bucket, 0);\n }\n this.labeledStates.clear();\n }\n\n /**\n * Serialize labels to deterministic string key\n * Format: key1=value1,key2=value2 (sorted by key)\n */\n private serializeLabels(labels: Record<string, string>): string {\n return Object.entries(labels)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join(\",\");\n }\n}\n","/**\n * Metrics registry - central registry for all metrics\n *\n * Provides singleton registry for counters, gauges, and histograms.\n * Exports events in schema-compliant format.\n */\n\nimport { Counter } from \"./counter.js\";\nimport { Gauge } from \"./gauge.js\";\nimport { Histogram } from \"./histogram.js\";\nimport { getDefaultUnit } from \"./taxonomy.js\";\nimport type { FlushOptions, HistogramOptions, MetricName, MetricsEvent } from \"./types.js\";\n\n/**\n * Metrics registry\n *\n * Central registry for all metrics. Provides factory methods for counters,\n * gauges, and histograms. Exports metrics as schema-compliant events.\n */\nexport class MetricsRegistry {\n private counters: Map<MetricName, Counter> = new Map();\n private gauges: Map<MetricName, Gauge> = new Map();\n private histograms: Map<MetricName, Histogram> = new Map();\n\n /**\n * Get or create a counter\n *\n * @param name - Metric name from taxonomy\n * @returns Counter instance\n *\n * @example\n * ```typescript\n * const counter = registry.counter('schema_validations');\n * counter.inc();\n * ```\n */\n counter(name: MetricName): Counter {\n let counter = this.counters.get(name);\n if (!counter) {\n counter = new Counter(name);\n this.counters.set(name, counter);\n }\n return counter;\n }\n\n /**\n * Get or create a gauge\n *\n * @param name - Metric name from taxonomy\n * @returns Gauge instance\n *\n * @example\n * ```typescript\n * const gauge = registry.gauge('foundry_lookup_count');\n * gauge.set(42);\n * ```\n */\n gauge(name: MetricName): Gauge {\n let gauge = this.gauges.get(name);\n if (!gauge) {\n gauge = new Gauge(name);\n this.gauges.set(name, gauge);\n }\n return gauge;\n }\n\n /**\n * Get or create a histogram\n *\n * @param name - Metric name from taxonomy\n * @param options - Optional histogram options\n * @returns Histogram instance\n *\n * @example\n * ```typescript\n * // Auto-applies ADR-0007 buckets for _ms metrics\n * const histogram = registry.histogram('config_load_ms');\n * histogram.observe(42.5);\n *\n * // Custom buckets\n * const custom = registry.histogram('custom_metric', {\n * buckets: [10, 50, 100, 500, 1000]\n * });\n * ```\n */\n histogram(name: MetricName, options?: HistogramOptions): Histogram {\n let histogram = this.histograms.get(name);\n if (!histogram) {\n histogram = new Histogram(name, options);\n this.histograms.set(name, histogram);\n }\n return histogram;\n }\n\n /**\n * Export all metrics as events\n *\n * Returns array of schema-compliant MetricsEvent objects.\n * Does not clear metrics (use flush() to clear after export).\n *\n * @returns Promise resolving to array of metrics events\n *\n * @example\n * ```typescript\n * const events = await registry.export();\n * console.log(JSON.stringify(events, null, 2));\n * ```\n */\n async export(): Promise<MetricsEvent[]> {\n const events: MetricsEvent[] = [];\n const timestamp = new Date().toISOString();\n\n // Export counters (unlabeled + labeled) - Crucible v0.2.7+\n for (const [name, counter] of this.counters) {\n const unit = await getDefaultUnit(name);\n\n // Always export unlabeled value (for backwards compatibility)\n events.push({\n timestamp,\n name,\n value: counter.getValue(),\n unit,\n });\n\n // Export labeled values (only if > 0)\n for (const [labelKey, value] of counter.getLabeledValues()) {\n if (value > 0) {\n const tags = this.deserializeLabels(labelKey);\n events.push({\n timestamp,\n name,\n value,\n tags,\n unit,\n });\n }\n }\n }\n\n // Export gauges (unlabeled + labeled) - Crucible v0.2.7+\n for (const [name, gauge] of this.gauges) {\n const unit = await getDefaultUnit(name);\n\n // Export unlabeled value (always export gauges, even if zero)\n events.push({\n timestamp,\n name,\n value: gauge.getValue(),\n unit,\n });\n\n // Export labeled values\n for (const [labelKey, value] of gauge.getLabeledValues()) {\n const tags = this.deserializeLabels(labelKey);\n events.push({\n timestamp,\n name,\n value,\n tags,\n unit,\n });\n }\n }\n\n // Export histograms (unlabeled + labeled) - Crucible v0.2.7+\n for (const [name, histogram] of this.histograms) {\n const unit = await getDefaultUnit(name);\n\n // Always export unlabeled summary (for backwards compatibility)\n events.push({\n timestamp,\n name,\n value: histogram.getSummary(),\n unit,\n });\n\n // Export labeled summaries (only if count > 0)\n for (const [labelKey, summary] of histogram.getLabeledSummaries()) {\n if (summary.count > 0) {\n const tags = this.deserializeLabels(labelKey);\n events.push({\n timestamp,\n name,\n value: summary,\n tags,\n unit,\n });\n }\n }\n }\n\n return events;\n }\n\n /**\n * Deserialize label key back to tags object\n * Format: key1=value1,key2=value2 → {key1: \"value1\", key2: \"value2\"}\n */\n private deserializeLabels(labelKey: string): Record<string, string> {\n if (!labelKey) {\n return {};\n }\n\n const tags: Record<string, string> = {};\n for (const pair of labelKey.split(\",\")) {\n const [key, value] = pair.split(\"=\");\n if (key && value) {\n tags[key] = value;\n }\n }\n return tags;\n }\n\n /**\n * Export and clear all metrics\n *\n * Exports metrics as events, optionally emits them via logger,\n * then resets all metrics to zero.\n *\n * @param options - Flush options\n * @returns Promise resolving to array of exported events\n *\n * @example\n * ```typescript\n * // Export and clear\n * const events = await registry.flush();\n *\n * // Export, emit to logger, and clear\n * const events = await registry.flush({\n * emit: (events) => console.log(JSON.stringify(events))\n * });\n * ```\n */\n async flush(options?: FlushOptions): Promise<MetricsEvent[]> {\n const events = await this.export();\n\n try {\n // Emit if logger provided\n if (options?.emit) {\n options.emit(events);\n }\n } finally {\n // Always clear metrics, even if emit throws\n this.clear();\n }\n\n return events;\n }\n\n /**\n * Clear all metrics (reset to zero)\n *\n * Resets all counters, gauges, and histograms to their initial state.\n */\n clear(): void {\n for (const counter of this.counters.values()) {\n counter.reset();\n }\n for (const gauge of this.gauges.values()) {\n gauge.reset();\n }\n for (const histogram of this.histograms.values()) {\n histogram.reset();\n }\n }\n\n /**\n * Get all registered metric names\n *\n * Returns array of all metric names that have been accessed\n * (counters, gauges, or histograms).\n */\n getMetricNames(): MetricName[] {\n const names = new Set<MetricName>();\n for (const name of this.counters.keys()) {\n names.add(name);\n }\n for (const name of this.gauges.keys()) {\n names.add(name);\n }\n for (const name of this.histograms.keys()) {\n names.add(name);\n }\n return Array.from(names);\n }\n\n /**\n * Get total count of registered metrics\n */\n getMetricCount(): number {\n return this.counters.size + this.gauges.size + this.histograms.size;\n }\n}\n","/**\n * Telemetry types - TypeScript types for metrics events\n *\n * Based on schemas/crucible-ts/observability/metrics/v1.0.0/metrics-event.schema.json\n * and config/crucible-ts/taxonomy/metrics.yaml\n */\n\n/**\n * Metric name from taxonomy\n * Aligned with config/crucible-ts/taxonomy/metrics.yaml#/$defs/metricName\n * Updated for Crucible v0.2.18 (HTTP server metrics)\n */\nexport type MetricName =\n // Core module metrics\n | \"schema_validations\"\n | \"schema_validation_errors\"\n | \"config_load_ms\"\n | \"config_load_errors\"\n | \"pathfinder_find_ms\"\n | \"pathfinder_validation_errors\"\n | \"pathfinder_security_warnings\"\n | \"foundry_lookup_count\"\n | \"logging_emit_count\"\n | \"logging_emit_latency_ms\"\n | \"goneat_command_duration_ms\"\n // Prometheus exporter metrics\n | \"prometheus_exporter_refresh_duration_seconds\"\n | \"prometheus_exporter_refresh_total\"\n | \"prometheus_exporter_refresh_errors_total\"\n | \"prometheus_exporter_refresh_inflight\"\n | \"prometheus_exporter_http_requests_total\"\n | \"prometheus_exporter_http_errors_total\"\n | \"prometheus_exporter_restarts_total\"\n // Foundry MIME detection metrics\n | \"foundry_mime_detections_total_json\"\n | \"foundry_mime_detections_total_xml\"\n | \"foundry_mime_detections_total_yaml\"\n | \"foundry_mime_detections_total_csv\"\n | \"foundry_mime_detections_total_plain_text\"\n | \"foundry_mime_detections_total_unknown\"\n | \"foundry_mime_detection_ms_json\"\n | \"foundry_mime_detection_ms_xml\"\n | \"foundry_mime_detection_ms_yaml\"\n | \"foundry_mime_detection_ms_csv\"\n | \"foundry_mime_detection_ms_plain_text\"\n | \"foundry_mime_detection_ms_unknown\"\n // Error handling metrics\n | \"error_handling_wraps_total\"\n | \"error_handling_wrap_ms\"\n // FulHash metrics\n | \"fulhash_operations_total_xxh3_128\"\n | \"fulhash_operations_total_sha256\"\n | \"fulhash_hash_string_total\"\n | \"fulhash_bytes_hashed_total\"\n | \"fulhash_operation_ms\"\n // HTTP server metrics (v0.2.18)\n | \"http_requests_total\"\n | \"http_request_duration_seconds\"\n | \"http_request_size_bytes\"\n | \"http_response_size_bytes\"\n | \"http_active_requests\";\n\n/**\n * Metric unit from taxonomy\n * Aligned with config/crucible-ts/taxonomy/metrics.yaml#/$defs/metricUnit\n * Updated for Crucible v0.2.7 (adds 's' for seconds)\n */\nexport type MetricUnit = \"count\" | \"ms\" | \"bytes\" | \"percent\" | \"s\";\n\n/**\n * Histogram bucket for OTLP-compatible histograms\n */\nexport interface HistogramBucket {\n /** Upper bound (less-than-or-equal) for the bucket */\n le: number;\n /** Cumulative count up to and including this bucket */\n count: number;\n}\n\n/**\n * Histogram summary payload\n */\nexport interface HistogramSummary {\n /** Total count of observations */\n count: number;\n /** Sum of all observed values */\n sum: number;\n /** Ordered buckets with cumulative counts (OTLP-compatible) */\n buckets: HistogramBucket[];\n}\n\n/**\n * Metric value (scalar or histogram)\n */\nexport type MetricValue = number | HistogramSummary;\n\n/**\n * Metrics event structure\n * Aligned with schemas/crucible-ts/observability/metrics/v1.0.0/metrics-event.schema.json\n */\nexport interface MetricsEvent {\n /** RFC3339 timestamp of metric emission */\n timestamp: string;\n /** Metric identifier from taxonomy */\n name: MetricName;\n /** Measurement payload (scalar or histogram summary) */\n value: MetricValue;\n /** Optional key/value dimensions */\n tags?: Record<string, string>;\n /** Optional metric unit (defaults to taxonomy default) */\n unit?: MetricUnit;\n}\n\n/**\n * Histogram options for customization\n */\nexport interface HistogramOptions {\n /** Custom bucket boundaries (overrides default ADR-0007 buckets) */\n buckets?: number[];\n}\n\n/**\n * Flush options for metrics registry\n */\nexport interface FlushOptions {\n /** Optional logger function to emit metrics */\n emit?: (events: MetricsEvent[]) => void;\n}\n\n/**\n * Type guard to check if value is a histogram summary\n */\nexport function isHistogramSummary(value: unknown): value is HistogramSummary {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"count\" in value &&\n \"sum\" in value &&\n \"buckets\" in value\n );\n}\n\n/**\n * Type guard to check if metric name is valid\n * Aligned with Crucible v0.2.18 taxonomy\n */\nexport function isValidMetricName(name: string): name is MetricName {\n const validNames: MetricName[] = [\n // Core module metrics\n \"schema_validations\",\n \"schema_validation_errors\",\n \"config_load_ms\",\n \"config_load_errors\",\n \"pathfinder_find_ms\",\n \"pathfinder_validation_errors\",\n \"pathfinder_security_warnings\",\n \"foundry_lookup_count\",\n \"logging_emit_count\",\n \"logging_emit_latency_ms\",\n \"goneat_command_duration_ms\",\n // Prometheus exporter metrics\n \"prometheus_exporter_refresh_duration_seconds\",\n \"prometheus_exporter_refresh_total\",\n \"prometheus_exporter_refresh_errors_total\",\n \"prometheus_exporter_refresh_inflight\",\n \"prometheus_exporter_http_requests_total\",\n \"prometheus_exporter_http_errors_total\",\n \"prometheus_exporter_restarts_total\",\n // Foundry MIME detection metrics\n \"foundry_mime_detections_total_json\",\n \"foundry_mime_detections_total_xml\",\n \"foundry_mime_detections_total_yaml\",\n \"foundry_mime_detections_total_csv\",\n \"foundry_mime_detections_total_plain_text\",\n \"foundry_mime_detections_total_unknown\",\n \"foundry_mime_detection_ms_json\",\n \"foundry_mime_detection_ms_xml\",\n \"foundry_mime_detection_ms_yaml\",\n \"foundry_mime_detection_ms_csv\",\n \"foundry_mime_detection_ms_plain_text\",\n \"foundry_mime_detection_ms_unknown\",\n // Error handling metrics\n \"error_handling_wraps_total\",\n \"error_handling_wrap_ms\",\n // FulHash metrics\n \"fulhash_operations_total_xxh3_128\",\n \"fulhash_operations_total_sha256\",\n \"fulhash_hash_string_total\",\n \"fulhash_bytes_hashed_total\",\n \"fulhash_operation_ms\",\n // HTTP server metrics\n \"http_requests_total\",\n \"http_request_duration_seconds\",\n \"http_request_size_bytes\",\n \"http_response_size_bytes\",\n \"http_active_requests\",\n ];\n return validNames.includes(name as MetricName);\n}\n\n/**\n * Type guard to check if unit is valid\n */\nexport function isValidMetricUnit(unit: string): unit is MetricUnit {\n const validUnits: MetricUnit[] = [\"count\", \"ms\", \"bytes\", \"percent\", \"s\"];\n return validUnits.includes(unit as MetricUnit);\n}\n","import type Ajv from \"ajv\";\nimport addFormats from \"ajv-formats\";\n\nexport interface FulmenAjvFormatsOptions {\n mode?: \"fast\" | \"full\";\n formats?: string[];\n}\n\nconst DEFAULT_FORMATS = [\n \"date-time\",\n \"email\",\n \"hostname\",\n \"ipv4\",\n \"ipv6\",\n \"uri\",\n \"uri-reference\",\n \"uuid\",\n];\n\n/**\n * Apply Fulmen-standard AJV format support.\n *\n * Useful when configuring AJV in other frameworks (e.g. Fastify) so JSON Schema\n * `format` keywords are enforced consistently.\n */\nexport function applyFulmenAjvFormats(ajv: Ajv, options: FulmenAjvFormatsOptions = {}): Ajv {\n const mode = options.mode ?? \"fast\";\n const formats = options.formats ?? DEFAULT_FORMATS;\n\n // ajv-formats types use a string-literal union; allow callers to supply strings.\n // The `as never` on ajv works around ajv-formats bundling its own older ajv types\n // that diverge from ajv@8.18+ (CodeKeywordDefinition.code parameter incompatibility).\n addFormats(ajv as never, { mode, formats: formats as unknown as never[] });\n return ajv;\n}\n","/**\n * Schema validation errors - implements Fulmen Schema Validation Standard\n */\n\nimport type { SchemaSource, SchemaValidationDiagnostic } from \"./types.js\";\n\n/**\n * Export error reason enum for type-safe error categorization\n */\nexport enum ExportErrorReason {\n FILE_EXISTS = \"FILE_EXISTS\",\n WRITE_FAILED = \"WRITE_FAILED\",\n INVALID_FORMAT = \"INVALID_FORMAT\",\n PROVENANCE_FAILED = \"PROVENANCE_FAILED\",\n UNKNOWN = \"UNKNOWN\",\n}\n\n/**\n * Base error class for schema validation operations\n */\nexport class SchemaValidationError extends Error {\n constructor(\n message: string,\n public schemaId?: string,\n public diagnostics: SchemaValidationDiagnostic[] = [],\n public source?: SchemaSource,\n public cause?: Error,\n ) {\n super(message);\n this.name = \"SchemaValidationError\";\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, SchemaValidationError);\n }\n }\n\n /**\n * Create error for schema not found\n */\n static schemaNotFound(schemaId: string): SchemaValidationError {\n return new SchemaValidationError(`Schema not found: ${schemaId}`, schemaId);\n }\n\n /**\n * Create error for invalid schema input\n */\n static invalidSchemaInput(source: SchemaSource, details: string): SchemaValidationError {\n return new SchemaValidationError(`Invalid schema input: ${details}`, undefined, [], source);\n }\n\n /**\n * Create error for validation failure\n */\n static validationFailed(\n schemaId: string,\n diagnostics: SchemaValidationDiagnostic[],\n source?: SchemaSource,\n ): SchemaValidationError {\n const errorCount = diagnostics.filter((d) => d.severity === \"ERROR\").length;\n const warningCount = diagnostics.filter((d) => d.severity === \"WARN\").length;\n\n const message = `Schema validation failed: ${errorCount} error(s), ${warningCount} warning(s)`;\n\n return new SchemaValidationError(message, schemaId, diagnostics, source);\n }\n\n /**\n * Create error for goneat binary not found\n */\n static goneatNotFound(goneatPath?: string): SchemaValidationError {\n const pathInfo = goneatPath ? ` at ${goneatPath}` : \"\";\n return new SchemaValidationError(\n `Goneat binary not found${pathInfo}. Falling back to AJV validation.`,\n );\n }\n\n /**\n * Create error for goneat execution failure\n */\n static goneatExecutionFailed(error: Error): SchemaValidationError {\n return new SchemaValidationError(\n \"Goneat execution failed. Falling back to AJV validation.\",\n undefined,\n [],\n undefined,\n error,\n );\n }\n\n /**\n * Create error for empty schema input\n */\n static emptySchemaInput(source?: SchemaSource): SchemaValidationError {\n return new SchemaValidationError(\"Schema content is empty\", undefined, [], source);\n }\n\n /**\n * Create error for parse failure\n */\n static parseFailed(source: SchemaSource, error: Error): SchemaValidationError {\n return new SchemaValidationError(\n `Failed to parse schema: ${error.message}`,\n undefined,\n [],\n source,\n error,\n );\n }\n\n /**\n * Create error for encoding failure\n */\n static encodingFailed(source: SchemaSource, error: Error): SchemaValidationError {\n return new SchemaValidationError(\n `Failed to encode schema: ${error.message}`,\n undefined,\n [],\n source,\n error,\n );\n }\n\n /**\n * Create error for registry operation failure\n */\n static registryError(operation: string, details: string): SchemaValidationError {\n return new SchemaValidationError(`Schema registry ${operation} failed: ${details}`);\n }\n\n /**\n * Format error for display\n */\n format(): string {\n let output = this.message;\n\n if (this.schemaId) {\n output += `\\nSchema ID: ${this.schemaId}`;\n }\n\n if (this.diagnostics.length > 0) {\n output += \"\\n\\nValidation Issues:\";\n this.diagnostics.forEach((diag, index) => {\n output += `\\n ${index + 1}. [${diag.severity}] ${diag.message}`;\n if (diag.pointer) {\n output += ` at ${diag.pointer}`;\n }\n if (diag.keyword) {\n output += ` (keyword: ${diag.keyword})`;\n }\n if (diag.source) {\n output += ` [${diag.source}]`;\n }\n });\n }\n\n if (this.source) {\n output += `\\n\\nSource: ${this.source.type}`;\n if (this.source.id) {\n output += ` (${this.source.id})`;\n }\n }\n\n return output;\n }\n\n /**\n * Convert to JSON representation\n */\n toJSON(): {\n name: string;\n message: string;\n schemaId?: string;\n diagnostics: SchemaValidationDiagnostic[];\n source?: SchemaSource;\n cause?: string;\n } {\n return {\n name: this.name,\n message: this.message,\n schemaId: this.schemaId,\n diagnostics: this.diagnostics,\n source: this.source,\n cause: this.cause?.message,\n };\n }\n}\n\n/**\n * Error class for schema export operations\n */\nexport class SchemaExportError extends SchemaValidationError {\n constructor(\n message: string,\n public reason: ExportErrorReason,\n public schemaId?: string,\n public outPath?: string,\n public cause?: Error,\n ) {\n super(message, schemaId, [], undefined, cause);\n this.name = \"SchemaExportError\";\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, SchemaExportError);\n }\n }\n\n /**\n * Create error for file already exists\n */\n static fileExists(outPath: string): SchemaExportError {\n return new SchemaExportError(\n `Output file already exists: ${outPath}. Use overwrite option to replace.`,\n ExportErrorReason.FILE_EXISTS,\n undefined,\n outPath,\n );\n }\n\n /**\n * Create error for invalid export format\n */\n static invalidFormat(format: string, outPath: string): SchemaExportError {\n return new SchemaExportError(\n `Invalid export format: ${format}. Must be 'json' or 'yaml'.`,\n ExportErrorReason.INVALID_FORMAT,\n undefined,\n outPath,\n );\n }\n\n /**\n * Create error for write failure\n */\n static writeFailed(outPath: string, error: Error): SchemaExportError {\n return new SchemaExportError(\n `Failed to write schema to ${outPath}: ${error.message}`,\n ExportErrorReason.WRITE_FAILED,\n undefined,\n outPath,\n error,\n );\n }\n\n /**\n * Create error for provenance extraction failure\n */\n static provenanceFailed(details: string, error?: Error): SchemaExportError {\n return new SchemaExportError(\n `Failed to extract provenance metadata: ${details}`,\n ExportErrorReason.PROVENANCE_FAILED,\n undefined,\n undefined,\n error,\n );\n }\n}\n","/**\n * Schema validation utilities - helper functions for formatting and validation\n */\n\nimport { SchemaValidationError } from \"./errors.js\";\nimport type { SchemaValidationDiagnostic, SchemaValidationResult } from \"./types.js\";\n\n/**\n * Format validation diagnostics for display\n */\nexport function formatDiagnostics(diagnostics: SchemaValidationDiagnostic[]): string {\n if (diagnostics.length === 0) {\n return \"No validation issues found.\";\n }\n\n const lines: string[] = [];\n const errors = diagnostics.filter((d) => d.severity === \"ERROR\");\n const warnings = diagnostics.filter((d) => d.severity === \"WARN\");\n\n if (errors.length > 0) {\n lines.push(`❌ ${errors.length} error(s) found:`);\n errors.forEach((diag, index) => {\n lines.push(` ${index + 1}. ${diag.message}`);\n if (diag.pointer) {\n lines.push(` at ${diag.pointer}`);\n }\n if (diag.keyword) {\n lines.push(` keyword: ${diag.keyword}`);\n }\n });\n }\n\n if (warnings.length > 0) {\n lines.push(\"\");\n lines.push(`⚠️ ${warnings.length} warning(s) found:`);\n warnings.forEach((diag, index) => {\n lines.push(` ${index + 1}. ${diag.message}`);\n if (diag.pointer) {\n lines.push(` at ${diag.pointer}`);\n }\n });\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Format validation result for display\n */\nexport function formatValidationResult(result: SchemaValidationResult): string {\n if (result.valid) {\n return \"✅ Validation passed\";\n }\n\n const output: string[] = [];\n output.push(\"❌ Validation failed\");\n output.push(formatDiagnostics(result.diagnostics));\n output.push(`\\nSource: ${result.source}`);\n\n return output.join(\"\\n\");\n}\n\n/**\n * Check if value is a SchemaValidationError\n */\nexport function isValidationError(error: unknown): error is SchemaValidationError {\n return error instanceof SchemaValidationError;\n}\n\n/**\n * Extract validation result from error or return success\n */\nexport function extractValidationResult(error: unknown): {\n valid: boolean;\n diagnostics: SchemaValidationDiagnostic[];\n source: \"ajv\" | \"goneat\";\n} {\n if (isValidationError(error)) {\n return {\n valid: false,\n diagnostics: error.diagnostics,\n source: error.diagnostics[0]?.source || \"ajv\",\n };\n }\n\n return {\n valid: true,\n diagnostics: [],\n source: \"ajv\",\n };\n}\n\n/**\n * Normalize JSON pointer path for display\n */\nexport function normalizePointer(pointer: string): string {\n if (pointer === \"\") {\n return \"root\";\n }\n return pointer.replace(/^\\//, \"\").replace(/\\//g, \".\");\n}\n\n/**\n * Create a validation diagnostic\n */\nexport function createDiagnostic(\n pointer: string,\n message: string,\n keyword: string,\n severity: \"ERROR\" | \"WARN\" = \"ERROR\",\n source: \"ajv\" | \"goneat\" = \"ajv\",\n data?: unknown,\n): SchemaValidationDiagnostic {\n return {\n pointer,\n message,\n keyword,\n severity,\n source,\n data,\n };\n}\n\n/**\n * Group diagnostics by severity\n */\nexport function groupDiagnosticsBySeverity(diagnostics: SchemaValidationDiagnostic[]): {\n errors: SchemaValidationDiagnostic[];\n warnings: SchemaValidationDiagnostic[];\n} {\n return {\n errors: diagnostics.filter((d) => d.severity === \"ERROR\"),\n warnings: diagnostics.filter((d) => d.severity === \"WARN\"),\n };\n}\n\n/**\n * Count diagnostics by severity\n */\nexport function countDiagnostics(diagnostics: SchemaValidationDiagnostic[]): {\n total: number;\n errors: number;\n warnings: number;\n} {\n const grouped = groupDiagnosticsBySeverity(diagnostics);\n return {\n total: diagnostics.length,\n errors: grouped.errors.length,\n warnings: grouped.warnings.length,\n };\n}\n","/**\n * Goneat bridge - Optional integration for CLI-only goneat validation\n *\n * Provides goneat validation as an opt-in alternative for CLI exploration.\n * NOT used by library consumers - AJV validation is the primary implementation.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { access } from \"node:fs/promises\";\nimport type { SchemaValidationDiagnostic, SchemaValidationResult } from \"./types.js\";\nimport { createDiagnostic } from \"./utils.js\";\n\n/**\n * Goneat validation output structure\n */\ninterface GoneatValidationOutput {\n valid: boolean;\n errors?: Array<{\n path: string;\n message: string;\n keyword?: string;\n }>;\n}\n\n/**\n * Detect goneat binary location\n */\nexport async function detectGoneat(customPath?: string): Promise<string | null> {\n // Try custom path first\n if (customPath) {\n try {\n await access(customPath);\n return customPath;\n } catch {\n return null;\n }\n }\n\n // Try GONEAT_PATH environment variable\n if (process.env.GONEAT_PATH) {\n try {\n await access(process.env.GONEAT_PATH);\n return process.env.GONEAT_PATH;\n } catch {\n // Continue to next option\n }\n }\n\n // Try local bin/goneat\n try {\n await access(\"./bin/goneat\");\n return \"./bin/goneat\";\n } catch {\n // Continue to next option\n }\n\n // Try system PATH (assume 'goneat' command available)\n return \"goneat\";\n}\n\n/**\n * Check if goneat is available\n *\n * If goneatPath is provided, use it directly to test availability.\n * Otherwise, detect goneat location first.\n */\nexport async function isGoneatAvailable(goneatPath?: string): Promise<boolean> {\n let pathToTest: string | null;\n\n if (goneatPath) {\n // Use provided path directly - don't re-detect\n // This allows testing 'goneat' command from PATH\n pathToTest = goneatPath;\n } else {\n // Detect goneat location\n pathToTest = await detectGoneat();\n if (!pathToTest) return false;\n }\n\n return new Promise((resolve) => {\n const proc = spawn(pathToTest as string, [\"version\"], { stdio: \"ignore\" });\n\n // Timeout after 5 seconds to prevent hanging in CI\n const timeout = setTimeout(() => {\n proc.kill();\n resolve(false);\n }, 5000);\n\n proc.on(\"close\", (code) => {\n clearTimeout(timeout);\n resolve(code === 0);\n });\n proc.on(\"error\", () => {\n clearTimeout(timeout);\n resolve(false);\n });\n });\n}\n\n/**\n * Run goneat schema validation (CLI-only, opt-in)\n *\n * This is NOT used by library validation - it's purely for CLI comparison.\n * Library users get full AJV validation without goneat dependency.\n */\nexport async function runGoneatValidation(\n schemaPath: string,\n dataPath: string,\n goneatPath?: string,\n): Promise<SchemaValidationResult> {\n const detected = await detectGoneat(goneatPath);\n\n if (!detected) {\n return {\n valid: false,\n diagnostics: [\n createDiagnostic(\n \"\",\n \"goneat binary not found. Install goneat or specify path with --goneat-path\",\n \"goneat-unavailable\",\n \"ERROR\",\n \"goneat\",\n ),\n ],\n source: \"goneat\",\n };\n }\n\n // Check availability using the detected path directly\n if (!(await isGoneatAvailable(detected))) {\n return {\n valid: false,\n diagnostics: [\n createDiagnostic(\n \"\",\n `goneat binary found at '${detected}' but not executable or version check failed`,\n \"goneat-not-executable\",\n \"ERROR\",\n \"goneat\",\n ),\n ],\n source: \"goneat\",\n };\n }\n\n return new Promise((resolve) => {\n const args = [\n \"schema\",\n \"validate\",\n \"--schema\",\n schemaPath,\n \"--data\",\n dataPath,\n \"--format\",\n \"json\",\n ];\n const proc = spawn(detected, args);\n\n let stdout = \"\";\n let stderr = \"\";\n\n proc.stdout.on(\"data\", (data) => {\n stdout += data.toString();\n });\n\n proc.stderr.on(\"data\", (data) => {\n stderr += data.toString();\n });\n\n proc.on(\"close\", (code: number | null) => {\n // Parse goneat output\n let output: GoneatValidationOutput;\n\n try {\n output = JSON.parse(stdout) as GoneatValidationOutput;\n } catch {\n // Failed to parse output, treat as error\n resolve({\n valid: false,\n diagnostics: [\n createDiagnostic(\n \"\",\n `goneat validation failed: ${stderr || \"unknown error\"}`,\n \"goneat-error\",\n \"ERROR\",\n \"goneat\",\n ),\n ],\n source: \"goneat\",\n });\n return;\n }\n\n // Convert goneat errors to our diagnostic format\n const diagnostics: SchemaValidationDiagnostic[] =\n output.errors?.map((error) =>\n createDiagnostic(\n error.path || \"\",\n error.message,\n error.keyword || \"validation\",\n \"ERROR\",\n \"goneat\",\n ),\n ) || [];\n\n resolve({\n valid: code === 0 && output.valid,\n diagnostics,\n source: \"goneat\",\n });\n });\n\n proc.on(\"error\", (error) => {\n resolve({\n valid: false,\n diagnostics: [\n createDiagnostic(\n \"\",\n `Failed to execute goneat: ${error.message}`,\n \"goneat-spawn-error\",\n \"ERROR\",\n \"goneat\",\n ),\n ],\n source: \"goneat\",\n });\n });\n });\n}\n","/**\n * Schema normalizer - implements schema normalization per Fulmen standard\n *\n * Provides utilities for canonicalizing and comparing schemas across\n * JSON and YAML formats with comment preservation and deterministic output.\n */\n\nimport { parse as parseYAML } from \"yaml\";\nimport { SchemaValidationError } from \"./errors.js\";\nimport type { SchemaInput, SchemaNormalizationOptions } from \"./types.js\";\n\n/**\n * Parse schema input to object\n */\nfunction parseSchemaInput(input: SchemaInput): Record<string, unknown> {\n if (!input) {\n throw SchemaValidationError.parseFailed(\n { type: \"string\", content: \"\" },\n new Error(\"schema content is empty\"),\n );\n }\n\n try {\n if (typeof input === \"string\") {\n // Try JSON first, fall back to YAML\n try {\n return JSON.parse(input) as Record<string, unknown>;\n } catch {\n return parseYAML(input) as Record<string, unknown>;\n }\n }\n\n if (Buffer.isBuffer(input)) {\n const content = input.toString(\"utf-8\");\n try {\n return JSON.parse(content) as Record<string, unknown>;\n } catch {\n return parseYAML(content) as Record<string, unknown>;\n }\n }\n\n // Already an object\n return input as Record<string, unknown>;\n } catch (error) {\n throw SchemaValidationError.parseFailed(\n {\n type: typeof input === \"string\" ? \"string\" : \"object\",\n content: typeof input === \"string\" ? input : JSON.stringify(input),\n },\n error as Error,\n );\n }\n}\n\n/**\n * Sort object keys recursively in lexicographical order\n */\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== \"object\") {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(sortObjectKeys);\n }\n\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj).sort();\n\n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n\n return sorted;\n}\n\n/**\n * Normalize schema to canonical JSON format\n *\n * Per Fulmen Schema Normalization Standard:\n * - Accepts YAML or JSON input\n * - Strips comments while preserving semantic structure\n * - Sorts keys lexicographically\n * - Produces deterministic, pretty-printed JSON (or compact if requested)\n */\nexport function normalizeSchema(\n input: SchemaInput,\n options: SchemaNormalizationOptions = {},\n): string {\n try {\n // Parse input to object\n const parsed = parseSchemaInput(input);\n\n // Sort keys recursively\n const sorted = sortObjectKeys(parsed);\n\n // Serialize to JSON with optional compact mode\n if (options.compact) {\n return JSON.stringify(sorted);\n }\n\n // Default: pretty-printed with 2-space indentation\n return JSON.stringify(sorted, null, 2);\n } catch (error) {\n if (error instanceof SchemaValidationError) {\n throw error;\n }\n throw SchemaValidationError.parseFailed(\n {\n type: typeof input === \"string\" ? \"string\" : \"object\",\n content: typeof input === \"string\" ? input : JSON.stringify(input),\n },\n error as Error,\n );\n }\n}\n\n/**\n * Compare two schemas for semantic equality\n *\n * Normalizes both schemas and compares the canonical JSON output.\n * Returns equality result along with normalized versions for debugging.\n */\nexport function compareSchemas(\n schemaA: SchemaInput,\n schemaB: SchemaInput,\n options: SchemaNormalizationOptions = {},\n): { equal: boolean; normalizedA: string; normalizedB: string } {\n const normalizedA = normalizeSchema(schemaA, options);\n const normalizedB = normalizeSchema(schemaB, options);\n\n return {\n equal: normalizedA === normalizedB,\n normalizedA,\n normalizedB,\n };\n}\n","/**\n * Schema registry - implements schema discovery and metadata extraction\n */\n\nimport { access, readFile } from \"node:fs/promises\";\nimport { dirname, extname, join, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport glob from \"fast-glob\";\nimport { parse as parseYAML } from \"yaml\";\nimport { SchemaValidationError } from \"./errors.js\";\nimport type { SchemaFormat, SchemaMetadata, SchemaRegistryOptions } from \"./types.js\";\n\n/**\n * Default schema file patterns\n */\nconst DEFAULT_PATTERNS = [\"**/*.schema.json\", \"**/*.schema.yaml\", \"**/*.schema.yml\"];\n\n/**\n * Schema registry class for managing schema discovery and metadata\n */\nexport class SchemaRegistry {\n private schemas: Map<string, SchemaMetadata> = new Map();\n private options: SchemaRegistryOptions;\n\n constructor(options: SchemaRegistryOptions = {}) {\n this.options = {\n baseDir: options.baseDir || this.getDefaultSchemaDir(),\n patterns: options.patterns || DEFAULT_PATTERNS,\n followSymlinks: options.followSymlinks ?? false,\n maxDepth: options.maxDepth ?? 10,\n };\n }\n\n /**\n * Get default schema directory using import.meta.url\n */\n private getDefaultSchemaDir(): string {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n // From src/schema/ we need to go up 2 levels to repo root, then into schemas/crucible-ts\n return join(__dirname, \"..\", \"..\", \"schemas\", \"crucible-ts\");\n }\n\n /**\n * Build logical schema ID from file path\n */\n private buildSchemaId(filePath: string, baseDir: string): string {\n const relativePath = relative(baseDir, filePath);\n const withoutExt = relativePath.replace(/\\.(schema\\.(json|yaml|yml))$/, \"\");\n return withoutExt.replace(/\\\\/g, \"/\"); // Normalize path separators\n }\n\n /**\n * Extract schema format from file extension\n */\n private getSchemaFormat(filePath: string): SchemaFormat {\n const ext = extname(filePath).toLowerCase();\n switch (ext) {\n case \".json\":\n return \"json\";\n case \".yaml\":\n case \".yml\":\n return \"yaml\";\n default:\n return \"json\"; // Default fallback\n }\n }\n\n /**\n * Extract metadata from schema file\n */\n private async extractMetadata(filePath: string): Promise<SchemaMetadata> {\n try {\n const content = await readFile(filePath, \"utf-8\");\n const format = this.getSchemaFormat(filePath);\n\n let parsed: Record<string, unknown>;\n if (format === \"yaml\") {\n parsed = parseYAML(content) as Record<string, unknown>;\n } else {\n parsed = JSON.parse(content) as Record<string, unknown>;\n }\n\n const baseDir = this.options.baseDir ?? \"\";\n const relativePath = relative(baseDir, filePath);\n\n return {\n id: this.buildSchemaId(filePath, baseDir),\n path: filePath,\n relativePath: relativePath,\n format,\n version: (parsed.$schema as string) || (parsed.version as string),\n description: (parsed.title as string) || (parsed.description as string),\n schemaDraft: parsed.$schema as string,\n };\n } catch (error) {\n throw SchemaValidationError.registryError(\n \"metadata extraction\",\n `Failed to process ${filePath}: ${(error as Error).message}`,\n );\n }\n }\n\n /**\n * Discover and index all available schemas\n */\n async discoverSchemas(): Promise<void> {\n try {\n const baseDir = this.options.baseDir ?? \"\";\n const patterns = this.options.patterns ?? [];\n\n if (patterns.length === 0) {\n this.schemas.clear();\n return;\n }\n\n const pattern = patterns.map((p) => join(baseDir, p));\n\n // Check if base directory exists\n try {\n await access(baseDir);\n } catch {\n // Base directory doesn't exist, clear registry and return\n this.schemas.clear();\n return;\n }\n\n const files = await glob(pattern, {\n absolute: true,\n followSymbolicLinks: this.options.followSymlinks,\n deep: this.options.maxDepth,\n onlyFiles: true,\n suppressErrors: true, // Don't throw on permission errors\n });\n\n // Clear existing schemas\n this.schemas.clear();\n\n // Process each schema file\n for (const filePath of files) {\n try {\n const metadata = await this.extractMetadata(filePath);\n this.schemas.set(metadata.id, metadata);\n } catch (error) {\n // Log error but continue processing other schemas\n console.warn(`Warning: Failed to process schema ${filePath}:`, error);\n }\n }\n } catch (error) {\n throw SchemaValidationError.registryError(\"discovery\", (error as Error).message);\n }\n }\n\n /**\n * List available schemas with optional prefix filtering\n */\n async listSchemas(prefix?: string): Promise<SchemaMetadata[]> {\n if (this.schemas.size === 0) {\n await this.discoverSchemas();\n }\n\n const schemas = Array.from(this.schemas.values());\n\n if (prefix) {\n return schemas.filter((schema) => schema.id.startsWith(prefix));\n }\n\n return schemas;\n }\n\n /**\n * Get schema by logical ID\n */\n async getSchema(id: string): Promise<SchemaMetadata> {\n if (this.schemas.size === 0) {\n await this.discoverSchemas();\n }\n\n const schema = this.schemas.get(id);\n if (!schema) {\n throw SchemaValidationError.schemaNotFound(id);\n }\n\n return schema;\n }\n\n /**\n * Get schema by file path\n */\n async getSchemaByPath(filePath: string): Promise<SchemaMetadata> {\n if (this.schemas.size === 0) {\n await this.discoverSchemas();\n }\n\n const absolutePath = filePath.startsWith(\"/\") ? filePath : join(process.cwd(), filePath);\n\n for (const schema of this.schemas.values()) {\n if (schema.path === absolutePath) {\n return schema;\n }\n }\n\n throw SchemaValidationError.schemaNotFound(filePath);\n }\n\n /**\n * Check if schema exists\n */\n async hasSchema(id: string): Promise<boolean> {\n if (this.schemas.size === 0) {\n await this.discoverSchemas();\n }\n\n return this.schemas.has(id);\n }\n\n /**\n * Get registry size\n */\n get size(): number {\n return this.schemas.size;\n }\n\n /**\n * Clear registry cache\n */\n clear(): void {\n this.schemas.clear();\n }\n}\n\n/**\n * Global schema registry instance with cached options\n */\nlet globalRegistry: SchemaRegistry | undefined;\nlet globalRegistryOptions: SchemaRegistryOptions | undefined;\n\n/**\n * Check if registry options have changed\n */\nfunction optionsChanged(newOptions?: SchemaRegistryOptions): boolean {\n if (!newOptions && !globalRegistryOptions) return false;\n if (!newOptions || !globalRegistryOptions) return true;\n\n return (\n newOptions.baseDir !== globalRegistryOptions.baseDir ||\n JSON.stringify(newOptions.patterns) !== JSON.stringify(globalRegistryOptions.patterns) ||\n newOptions.followSymlinks !== globalRegistryOptions.followSymlinks ||\n newOptions.maxDepth !== globalRegistryOptions.maxDepth\n );\n}\n\n/**\n * Get or create global schema registry, rebuilding if options change\n */\nexport function getSchemaRegistry(options?: SchemaRegistryOptions): SchemaRegistry {\n if (!globalRegistry || optionsChanged(options)) {\n globalRegistry = new SchemaRegistry(options);\n globalRegistryOptions = options;\n }\n return globalRegistry;\n}\n\n/**\n * List available schemas with optional prefix filtering\n */\nexport async function listSchemas(\n prefix?: string,\n options?: SchemaRegistryOptions,\n): Promise<SchemaMetadata[]> {\n const registry = getSchemaRegistry(options);\n return registry.listSchemas(prefix);\n}\n\n/**\n * Get schema by logical ID\n */\nexport async function getSchema(\n id: string,\n options?: SchemaRegistryOptions,\n): Promise<SchemaMetadata> {\n const registry = getSchemaRegistry(options);\n return registry.getSchema(id);\n}\n\n/**\n * Get schema by file path\n */\nexport async function getSchemaByPath(\n filePath: string,\n options?: SchemaRegistryOptions,\n): Promise<SchemaMetadata> {\n const registry = getSchemaRegistry(options);\n return registry.getSchemaByPath(filePath);\n}\n\n/**\n * Check if schema exists\n */\nexport async function hasSchema(id: string, options?: SchemaRegistryOptions): Promise<boolean> {\n const registry = getSchemaRegistry(options);\n return registry.hasSchema(id);\n}\n","/**\n * Schema CLI - Commander-based CLI for schema operations\n *\n * Provides command-line interface for schema discovery, validation,\n * and normalization operations. This is a developer tool for exploration\n * and testing, not for production use.\n */\n\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport { isGoneatAvailable, runGoneatValidation } from \"./goneat-bridge.js\";\nimport { compareSchemas, normalizeSchema } from \"./normalizer.js\";\nimport { getSchemaRegistry, listSchemas } from \"./registry.js\";\nimport type { CLIOptions, SchemaValidationResult } from \"./types.js\";\nimport { formatDiagnostics } from \"./utils.js\";\nimport { validateFileBySchemaId } from \"./validator.js\";\n\n/**\n * Create CLI command structure\n */\nexport function createCLI(options: CLIOptions = {}): Command {\n const program = new Command();\n\n program\n .name(\"tsfulmen-schema\")\n .description(\"Schema validation and discovery CLI for Fulmen (developer tool)\")\n .version(\"0.1.0\");\n\n // List schemas command\n program\n .command(\"list\")\n .description(\"List available schemas from registry\")\n .argument(\"[prefix]\", \"Filter schemas by prefix\")\n .option(\"--base-dir <path>\", \"Override schema base directory\")\n .action(async (prefix?: string, cmdOptions?: { baseDir?: string }) => {\n try {\n const schemas = await listSchemas(prefix, {\n baseDir: cmdOptions?.baseDir || options.baseDir,\n });\n\n if (schemas.length === 0) {\n console.log(\"No schemas found\");\n return;\n }\n\n console.log(`Found ${schemas.length} schema(s):\\n`);\n for (const schema of schemas) {\n console.log(` ${schema.id}`);\n console.log(` Format: ${schema.format}`);\n console.log(` Path: ${schema.relativePath}`);\n if (schema.description) {\n console.log(` Description: ${schema.description}`);\n }\n console.log();\n }\n } catch (error) {\n console.error(\"Error listing schemas:\", (error as Error).message);\n process.exit(1);\n }\n });\n\n // Show schema command\n program\n .command(\"show\")\n .description(\"Show schema details\")\n .requiredOption(\"--schema-id <id>\", \"Schema ID to show\")\n .option(\"--base-dir <path>\", \"Override schema base directory\")\n .action(async (cmdOptions: { schemaId: string; baseDir?: string }) => {\n try {\n const registry = getSchemaRegistry({\n baseDir: cmdOptions.baseDir || options.baseDir,\n });\n const schema = await registry.getSchema(cmdOptions.schemaId);\n\n console.log(\"Schema Details:\\n\");\n console.log(` ID: ${schema.id}`);\n console.log(` Format: ${schema.format}`);\n console.log(` Path: ${schema.path}`);\n console.log(` Relative Path: ${schema.relativePath}`);\n if (schema.version) {\n console.log(` Version: ${schema.version}`);\n }\n if (schema.description) {\n console.log(` Description: ${schema.description}`);\n }\n if (schema.schemaDraft) {\n console.log(` Schema Draft: ${schema.schemaDraft}`);\n }\n\n // Read and display schema content\n const content = await readFile(schema.path, \"utf-8\");\n console.log(\"\\nSchema Content:\");\n console.log(content);\n } catch (error) {\n console.error(\"Error showing schema:\", (error as Error).message);\n process.exit(1);\n }\n });\n\n // Validate data command\n program\n .command(\"validate\")\n .description(\"Validate data file against schema\")\n .requiredOption(\"--schema-id <id>\", \"Schema ID to validate against\")\n .argument(\"<file>\", \"Data file to validate\")\n .option(\"--use-goneat\", \"Use goneat for validation (requires goneat binary)\")\n .option(\"--goneat-path <path>\", \"Path to goneat binary\")\n .option(\"--base-dir <path>\", \"Override schema base directory\")\n .action(\n async (\n file: string,\n cmdOptions: {\n schemaId: string;\n useGoneat?: boolean;\n goneatPath?: string;\n baseDir?: string;\n },\n ) => {\n try {\n let result: SchemaValidationResult;\n\n if (cmdOptions.useGoneat) {\n // Check goneat availability\n const available = await isGoneatAvailable(cmdOptions.goneatPath);\n if (!available) {\n console.error(\"❌ goneat not available. Install goneat or remove --use-goneat flag.\");\n console.error(\" AJV validation (default) works without external dependencies.\");\n process.exit(1);\n }\n\n // Get schema path\n const registry = getSchemaRegistry({\n baseDir: cmdOptions.baseDir || options.baseDir,\n });\n const schema = await registry.getSchema(cmdOptions.schemaId);\n\n console.log(\"Using goneat validation...\");\n result = await runGoneatValidation(schema.path, file, cmdOptions.goneatPath);\n } else {\n // Use AJV validation (default, library implementation)\n console.log(\"Using AJV validation...\");\n result = await validateFileBySchemaId(file, cmdOptions.schemaId, {\n baseDir: cmdOptions.baseDir || options.baseDir,\n });\n }\n\n if (result.valid) {\n console.log(`✅ Validation passed (${result.source})`);\n process.exit(0);\n } else {\n console.log(`❌ Validation failed (${result.source})`);\n console.log(\"\\nDiagnostics:\");\n console.log(formatDiagnostics(result.diagnostics));\n process.exit(1);\n }\n } catch (error) {\n console.error(\"Error validating file:\", (error as Error).message);\n process.exit(1);\n }\n },\n );\n\n // Validate schema command\n program\n .command(\"validate-schema\")\n .description(\"Validate a schema file itself\")\n .argument(\"<file>\", \"Schema file to validate\")\n .action(async (file: string) => {\n try {\n const content = await readFile(file, \"utf-8\");\n const { validateSchema } = await import(\"./validator.js\");\n const result = await validateSchema(content);\n\n if (result.valid) {\n console.log(\"✅ Schema is valid\");\n process.exit(0);\n } else {\n console.log(\"❌ Schema is invalid\");\n console.log(\"\\nDiagnostics:\");\n console.log(formatDiagnostics(result.diagnostics));\n process.exit(1);\n }\n } catch (error) {\n console.error(\"Error validating schema:\", (error as Error).message);\n process.exit(1);\n }\n });\n\n // Normalize schema command\n program\n .command(\"normalize\")\n .description(\"Normalize schema to canonical JSON format\")\n .argument(\"<file>\", \"Schema file to normalize\")\n .option(\"--compact\", \"Output compact JSON (no formatting)\")\n .option(\"-o, --output <file>\", \"Write to output file instead of stdout\")\n .action(async (file: string, cmdOptions: { compact?: boolean; output?: string }) => {\n try {\n const content = await readFile(file, \"utf-8\");\n const normalized = normalizeSchema(content, {\n compact: cmdOptions.compact,\n });\n\n if (cmdOptions.output) {\n await writeFile(cmdOptions.output, normalized, \"utf-8\");\n console.log(`✅ Normalized schema written to ${cmdOptions.output}`);\n } else {\n console.log(normalized);\n }\n } catch (error) {\n console.error(\"Error normalizing schema:\", (error as Error).message);\n process.exit(1);\n }\n });\n\n // Compare schemas command\n program\n .command(\"compare\")\n .description(\"Compare two schemas for semantic equality\")\n .argument(\"<file1>\", \"First schema file\")\n .argument(\"<file2>\", \"Second schema file\")\n .option(\"--show-normalized\", \"Show normalized outputs\")\n .action(async (file1: string, file2: string, cmdOptions: { showNormalized?: boolean }) => {\n try {\n const content1 = await readFile(file1, \"utf-8\");\n const content2 = await readFile(file2, \"utf-8\");\n\n const result = compareSchemas(content1, content2);\n\n if (result.equal) {\n console.log(\"✅ Schemas are semantically equal\");\n } else {\n console.log(\"❌ Schemas differ\");\n }\n\n if (cmdOptions.showNormalized) {\n console.log(\"\\nNormalized Schema 1:\");\n console.log(result.normalizedA);\n console.log(\"\\nNormalized Schema 2:\");\n console.log(result.normalizedB);\n }\n\n process.exit(result.equal ? 0 : 1);\n } catch (error) {\n console.error(\"Error comparing schemas:\", (error as Error).message);\n process.exit(1);\n }\n });\n\n // Export schema command\n program\n .command(\"export\")\n .description(\"Export schema from registry to file with provenance\")\n .requiredOption(\"--schema-id <id>\", \"Schema ID to export\")\n .requiredOption(\"--out <path>\", \"Output file path\")\n .option(\"--force\", \"Overwrite existing file\", false)\n .option(\"--no-provenance\", \"Exclude provenance metadata\")\n .option(\"--no-validate\", \"Skip schema validation before export\")\n .option(\"--format <format>\", \"Export format (json|yaml|auto)\", \"auto\")\n .option(\"--base-dir <path>\", \"Override schema base directory\")\n .action(\n async (cmdOptions: {\n schemaId: string;\n out: string;\n force?: boolean;\n provenance?: boolean;\n validate?: boolean;\n format?: string;\n baseDir?: string;\n }) => {\n try {\n const { exportSchema } = await import(\"./export.js\");\n const { exitCodes } = await import(\"../foundry/index.js\");\n\n const result = await exportSchema({\n schemaId: cmdOptions.schemaId,\n outPath: cmdOptions.out,\n includeProvenance: cmdOptions.provenance ?? true,\n validate: cmdOptions.validate ?? true,\n overwrite: cmdOptions.force ?? false,\n format: (cmdOptions.format as \"json\" | \"yaml\" | \"auto\") ?? \"auto\",\n baseDir: cmdOptions.baseDir || options.baseDir,\n });\n\n console.log(\"✅ Schema exported successfully\");\n console.log(` Schema ID: ${result.schemaId}`);\n console.log(` Output: ${result.outPath}`);\n console.log(` Format: ${result.format}`);\n\n if (result.provenance) {\n console.log(\"\\nProvenance:\");\n console.log(` Crucible: ${result.provenance.crucible_version}`);\n console.log(` Library: ${result.provenance.library_version}`);\n if (result.provenance.revision) {\n console.log(` Revision: ${result.provenance.revision}`);\n }\n console.log(` Exported: ${result.provenance.exported_at}`);\n }\n\n process.exit(exitCodes.EXIT_SUCCESS);\n } catch (error) {\n const { exitCodes } = await import(\"../foundry/index.js\");\n const { SchemaExportError, SchemaValidationError, ExportErrorReason } = await import(\n \"./errors.js\"\n );\n\n console.error(\"❌ Schema export failed:\", (error as Error).message);\n\n // Map specific error types to appropriate exit codes\n if (error instanceof SchemaExportError) {\n if (error.outPath) {\n console.error(` Output path: ${error.outPath}`);\n }\n\n // Use error reason for type-safe exit code mapping\n switch (error.reason) {\n case ExportErrorReason.FILE_EXISTS:\n case ExportErrorReason.WRITE_FAILED:\n process.exit(exitCodes.EXIT_FILE_WRITE_ERROR);\n break;\n\n case ExportErrorReason.INVALID_FORMAT:\n process.exit(exitCodes.EXIT_INVALID_ARGUMENT);\n break;\n\n default:\n // PROVENANCE_FAILED, UNKNOWN, and any future reasons\n process.exit(exitCodes.EXIT_FAILURE);\n }\n }\n\n if (error instanceof SchemaValidationError) {\n // Schema not found or validation failed\n const errorMsg = error.message.toLowerCase();\n\n if (errorMsg.includes(\"not found\")) {\n process.exit(exitCodes.EXIT_FILE_NOT_FOUND);\n }\n\n // Validation failures\n process.exit(exitCodes.EXIT_DATA_INVALID);\n }\n\n process.exit(exitCodes.EXIT_FAILURE);\n }\n },\n );\n\n // Identity show command\n program\n .command(\"identity-show\")\n .description(\"Show application identity from .fulmen/app.yaml\")\n .option(\"--path <path>\", \"Explicit path to app.yaml\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (cmdOptions: { path?: string; json?: boolean }) => {\n try {\n const { loadIdentity } = await import(\"../appidentity/loader.js\");\n const { exitCodes } = await import(\"../foundry/index.js\");\n\n const identity = await loadIdentity({ path: cmdOptions.path });\n\n if (cmdOptions.json) {\n console.log(JSON.stringify(identity, null, 2));\n } else {\n console.log(\"Application Identity:\\n\");\n console.log(` Binary Name: ${identity.app.binary_name}`);\n console.log(` Vendor: ${identity.app.vendor}`);\n console.log(` Env Prefix: ${identity.app.env_prefix}`);\n console.log(` Config Name: ${identity.app.config_name}`);\n console.log(` Description: ${identity.app.description}`);\n\n if (identity.metadata) {\n console.log(\"\\nMetadata:\");\n if (identity.metadata.license) {\n console.log(` License: ${identity.metadata.license}`);\n }\n if (identity.metadata.repository_category) {\n console.log(` Category: ${identity.metadata.repository_category}`);\n }\n if (identity.metadata.telemetry_namespace) {\n console.log(` Telemetry: ${identity.metadata.telemetry_namespace}`);\n }\n if (identity.metadata.project_url) {\n console.log(` Project URL: ${identity.metadata.project_url}`);\n }\n }\n }\n\n process.exit(exitCodes.EXIT_SUCCESS);\n } catch (error) {\n const { exitCodes } = await import(\"../foundry/index.js\");\n const { AppIdentityError } = await import(\"../appidentity/errors.js\");\n\n console.error(\"❌ Failed to load identity:\", (error as Error).message);\n\n if (error instanceof AppIdentityError) {\n if (error.message.includes(\"not found\")) {\n process.exit(exitCodes.EXIT_FILE_NOT_FOUND);\n }\n if (error.message.includes(\"Invalid\") || error.message.includes(\"validation\")) {\n process.exit(exitCodes.EXIT_DATA_INVALID);\n }\n }\n\n process.exit(exitCodes.EXIT_FAILURE);\n }\n });\n\n // Identity validate command\n program\n .command(\"identity-validate\")\n .description(\"Validate application identity against schema\")\n .argument(\"[file]\", \"Path to app.yaml (defaults to discovery)\")\n .action(async (file?: string) => {\n try {\n const { loadIdentity } = await import(\"../appidentity/loader.js\");\n const { exitCodes } = await import(\"../foundry/index.js\");\n\n console.log(\"Validating application identity...\");\n\n const identity = await loadIdentity({ path: file });\n\n console.log(\"✅ Identity is valid\");\n console.log(` Binary: ${identity.app.binary_name}`);\n console.log(` Vendor: ${identity.app.vendor}`);\n\n process.exit(exitCodes.EXIT_SUCCESS);\n } catch (error) {\n const { exitCodes } = await import(\"../foundry/index.js\");\n const { AppIdentityError } = await import(\"../appidentity/errors.js\");\n\n console.error(\"❌ Identity validation failed:\", (error as Error).message);\n\n if (error instanceof AppIdentityError) {\n if (error.message.includes(\"not found\")) {\n process.exit(exitCodes.EXIT_FILE_NOT_FOUND);\n }\n if (error.message.includes(\"Invalid\") || error.message.includes(\"validation\")) {\n process.exit(exitCodes.EXIT_DATA_INVALID);\n }\n }\n\n process.exit(exitCodes.EXIT_FAILURE);\n }\n });\n\n return program;\n}\n","/**\n * Schema export utilities - implements schema export with provenance\n */\n\nimport { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname, extname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parse as parseYAML, stringify as stringifyYAML } from \"yaml\";\nimport { SchemaExportError, SchemaValidationError } from \"./errors.js\";\nimport { getSchemaRegistry } from \"./registry.js\";\nimport type {\n ExportSchemaOptions,\n ExportSchemaResult,\n SchemaExportFormat,\n SchemaProvenanceMetadata,\n} from \"./types.js\";\nimport { validateSchema } from \"./validator.js\";\n\n/**\n * Extract provenance metadata from Crucible sync metadata\n */\nasync function extractProvenanceMetadata(schemaId: string): Promise<SchemaProvenanceMetadata> {\n try {\n // Read Crucible metadata using proper path resolution\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const metadataPath = join(__dirname, \"..\", \"..\", \".crucible\", \"metadata\", \"metadata.yaml\");\n const metadataContent = await readFile(metadataPath, \"utf-8\");\n\n // Parse YAML properly to avoid brittle regex matching\n const metadata = parseYAML(metadataContent) as {\n sources?: Array<{\n name?: string;\n version?: string;\n commit?: string;\n }>;\n };\n\n // Extract Crucible source metadata (first source is typically 'crucible')\n const crucibleSource = metadata.sources?.[0];\n const crucibleVersion = crucibleSource?.version || \"unknown\";\n const revision = crucibleSource?.commit;\n\n // Read library version from package.json\n const pkgPath = join(__dirname, \"..\", \"..\", \"package.json\");\n const pkgContent = await readFile(pkgPath, \"utf-8\");\n const pkg = JSON.parse(pkgContent) as { version: string };\n\n return {\n schema_id: schemaId,\n crucible_version: crucibleVersion,\n library_version: pkg.version,\n revision: revision,\n exported_at: new Date().toISOString(),\n export_source: \"tsfulmen\",\n };\n } catch (error) {\n throw SchemaExportError.provenanceFailed((error as Error).message, error as Error);\n }\n}\n\n/**\n * Embed provenance metadata in schema content\n */\nfunction embedProvenance(\n schemaContent: Record<string, unknown>,\n provenance: SchemaProvenanceMetadata,\n format: SchemaExportFormat,\n): string {\n if (format === \"json\") {\n // For JSON: embed under $comment[\"x-crucible-source\"]\n const withProvenance = {\n ...schemaContent,\n $comment: {\n ...(typeof schemaContent.$comment === \"object\" ? schemaContent.$comment : {}),\n \"x-crucible-source\": provenance,\n },\n };\n return JSON.stringify(withProvenance, null, 2);\n }\n\n // For YAML: prepend comment block\n const yamlContent = stringifyYAML(schemaContent, {\n indent: 2,\n lineWidth: 0,\n });\n\n const provenanceComment = [\n \"# x-crucible-source:\",\n `# schema_id: ${provenance.schema_id}`,\n `# crucible_version: ${provenance.crucible_version}`,\n `# library_version: ${provenance.library_version}`,\n ...(provenance.revision ? [`# revision: ${provenance.revision}`] : []),\n `# exported_at: ${provenance.exported_at}`,\n `# export_source: ${provenance.export_source}`,\n \"\",\n ].join(\"\\n\");\n\n return provenanceComment + yamlContent;\n}\n\n/**\n * Detect export format from file extension or explicit option\n */\nfunction detectFormat(outPath: string, formatOption?: SchemaExportFormat): SchemaExportFormat {\n if (formatOption && formatOption !== \"auto\") {\n return formatOption;\n }\n\n const ext = extname(outPath).toLowerCase();\n switch (ext) {\n case \".json\":\n return \"json\";\n case \".yaml\":\n case \".yml\":\n return \"yaml\";\n default:\n throw SchemaExportError.invalidFormat(ext, outPath);\n }\n}\n\n/**\n * Export schema from registry to file with provenance\n *\n * @param options - Export options\n * @returns Export result with metadata\n *\n * @throws {SchemaExportError} If export fails\n * @throws {SchemaValidationError} If schema not found or validation fails\n *\n * @example\n * ```typescript\n * import { exportSchema } from '@fulmenhq/tsfulmen/schema';\n *\n * await exportSchema({\n * schemaId: 'library/foundry/v1.0.0/exit-codes',\n * outPath: './schemas/exit-codes.schema.json',\n * includeProvenance: true,\n * validate: true,\n * });\n * ```\n */\nexport async function exportSchema(options: ExportSchemaOptions): Promise<ExportSchemaResult> {\n const {\n schemaId,\n outPath,\n includeProvenance = true,\n validate = true,\n overwrite = false,\n format: formatOption,\n baseDir,\n } = options;\n\n // Detect output format\n const format = detectFormat(outPath, formatOption);\n\n // Check if file exists\n if (!overwrite) {\n try {\n await access(outPath);\n throw SchemaExportError.fileExists(outPath);\n } catch (error) {\n // File doesn't exist - proceed\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n }\n\n // Get schema from registry\n const registry = getSchemaRegistry({ baseDir });\n const schema = await registry.getSchema(schemaId);\n\n // Read schema content\n const schemaContent = await readFile(schema.path, \"utf-8\");\n\n // Validate if requested\n if (validate) {\n const validationResult = await validateSchema(schemaContent);\n if (!validationResult.valid) {\n throw SchemaValidationError.validationFailed(schemaId, validationResult.diagnostics, {\n type: \"file\",\n id: schema.path,\n });\n }\n }\n\n // Parse schema content\n let schemaObject: Record<string, unknown>;\n try {\n schemaObject = JSON.parse(schemaContent) as Record<string, unknown>;\n } catch {\n schemaObject = parseYAML(schemaContent) as Record<string, unknown>;\n }\n\n // Freeze schema object to prevent mutation\n Object.freeze(schemaObject);\n\n let provenance: SchemaProvenanceMetadata | undefined;\n let outputContent: string;\n\n if (includeProvenance) {\n // Extract provenance metadata\n provenance = await extractProvenanceMetadata(schemaId);\n\n // Embed provenance in output\n outputContent = embedProvenance(schemaObject, provenance, format);\n } else {\n // Export without provenance\n if (format === \"json\") {\n outputContent = JSON.stringify(schemaObject, null, 2);\n } else {\n outputContent = stringifyYAML(schemaObject, { indent: 2, lineWidth: 0 });\n }\n }\n\n // Ensure output directory exists\n await mkdir(dirname(outPath), { recursive: true });\n\n // Write to file\n try {\n await writeFile(outPath, outputContent, \"utf-8\");\n } catch (error) {\n throw SchemaExportError.writeFailed(outPath, error as Error);\n }\n\n return {\n success: true,\n schemaId,\n outPath,\n format,\n includeProvenance,\n provenance,\n };\n}\n\n/**\n * Strip provenance metadata from schema content\n *\n * This helper is useful for comparing exported schemas with runtime\n * schemas or validating that provenance doesn't affect schema semantics.\n *\n * @param content - Schema content (JSON or YAML string)\n * @returns Schema content without provenance metadata\n *\n * @example\n * ```typescript\n * import { stripProvenance } from '@fulmenhq/tsfulmen/schema';\n *\n * const exported = await readFile('./schema.json', 'utf-8');\n * const withoutProvenance = stripProvenance(exported);\n * ```\n */\nexport function stripProvenance(content: string): string {\n try {\n // Try parsing as JSON\n const parsed = JSON.parse(content) as Record<string, unknown>;\n\n // Remove provenance from $comment\n if (parsed.$comment && typeof parsed.$comment === \"object\") {\n const comment = { ...parsed.$comment } as Record<string, unknown>;\n delete comment[\"x-crucible-source\"];\n\n // Remove $comment entirely if it's now empty\n if (Object.keys(comment).length === 0) {\n delete parsed.$comment;\n } else {\n parsed.$comment = comment;\n }\n }\n\n return JSON.stringify(parsed, null, 2);\n } catch {\n // YAML format - strip comment lines\n const lines = content.split(\"\\n\");\n const filtered = lines.filter((line) => {\n const trimmed = line.trim();\n return !(\n trimmed.startsWith(\"# x-crucible-source:\") ||\n (trimmed.startsWith(\"# \") &&\n /^#\\s+(schema_id|crucible_version|library_version|revision|exported_at|export_source):/.test(\n trimmed,\n ))\n );\n });\n\n // Remove leading blank lines\n while (filtered.length > 0 && filtered[0]?.trim() === \"\") {\n filtered.shift();\n }\n\n return filtered.join(\"\\n\");\n }\n}\n","/**\n * Schema validation module - implements Fulmen Schema Validation Standard\n *\n * Provides schema discovery, validation, and normalization utilities for Crucible schemas\n * with JSON Schema 2020-12 support and optional goneat integration.\n */\n\nexport const VERSION = \"0.1.0\";\n\nexport {\n applyFulmenAjvFormats,\n type FulmenAjvFormatsOptions,\n} from \"./ajv-formats.js\";\n\n// CLI exports\nexport { createCLI } from \"./cli.js\";\n// Error exports\nexport * from \"./errors.js\";\n// Export exports\nexport { exportSchema, stripProvenance } from \"./export.js\";\n// Goneat bridge exports (CLI-only, optional)\nexport {\n detectGoneat,\n isGoneatAvailable,\n runGoneatValidation,\n} from \"./goneat-bridge.js\";\n// Normalizer exports\nexport { compareSchemas, normalizeSchema } from \"./normalizer.js\";\n// Registry exports\nexport {\n getSchema,\n getSchemaByPath,\n getSchemaRegistry,\n hasSchema,\n listSchemas,\n SchemaRegistry,\n} from \"./registry.js\";\n// Core exports\nexport type {\n AjvError,\n CLIOptions,\n CompiledValidator,\n ExportSchemaOptions,\n ExportSchemaResult,\n SchemaComparisonResult,\n SchemaExportFormat,\n SchemaFormat,\n SchemaInput,\n SchemaMetadata,\n SchemaNormalizationOptions,\n SchemaProvenanceMetadata,\n SchemaRegistryOptions,\n SchemaSource,\n SchemaValidationDiagnostic,\n SchemaValidationOptions,\n SchemaValidationResult,\n} from \"./types.js\";\n// Utility exports\nexport {\n countDiagnostics,\n createDiagnostic,\n formatDiagnostics,\n formatValidationResult,\n groupDiagnosticsBySeverity,\n isValidationError,\n normalizePointer,\n} from \"./utils.js\";\n// Validator exports\nexport {\n clearCache,\n compileSchema,\n compileSchemaById,\n getCacheSize,\n validateData,\n validateDataBySchemaId,\n validateFile,\n validateFileBySchemaId,\n validateSchema,\n} from \"./validator.js\";\n","/**\n * Metrics event validators\n *\n * Schema validation for metrics events using existing src/schema infrastructure\n */\n\nimport { compileSchemaById } from \"../schema/index.js\";\nimport type { CompiledValidator } from \"../schema/types.js\";\n\n/**\n * Singleton validator for metrics events\n *\n * Pre-compiles the metrics-event schema at first access for optimal performance.\n * Reuses existing AJV setup from src/schema module.\n */\nclass MetricsValidator {\n private static instance: MetricsValidator;\n private validateFn: CompiledValidator | null = null;\n private initPromise: Promise<void> | null = null;\n private initError: Error | null = null;\n\n private constructor() {\n // Private constructor for singleton\n }\n\n /**\n * Get singleton instance\n */\n static getInstance(): MetricsValidator {\n if (!MetricsValidator.instance) {\n MetricsValidator.instance = new MetricsValidator();\n }\n return MetricsValidator.instance;\n }\n\n /**\n * Initialize validator (lazy load, async)\n */\n private async init(): Promise<void> {\n if (this.validateFn !== null || this.initError !== null) {\n return; // Already initialized\n }\n\n if (this.initPromise) {\n return this.initPromise; // Already initializing\n }\n\n this.initPromise = (async () => {\n try {\n // Compile schema using existing schema infrastructure\n this.validateFn = await compileSchemaById(\"observability/metrics/v1.0.0/metrics-event\");\n } catch (err) {\n this.initError = err instanceof Error ? err : new Error(String(err));\n throw new Error(`Failed to initialize metrics validator: ${this.initError.message}`);\n }\n })();\n\n return this.initPromise;\n }\n\n /**\n * Validate metrics event against schema\n *\n * @param event - Metrics event to validate\n * @returns Promise resolving to true if valid, false otherwise\n */\n async validate(event: unknown): Promise<boolean> {\n if (this.validateFn === null) {\n await this.init();\n }\n\n if (this.initError) {\n throw this.initError;\n }\n\n if (!this.validateFn) {\n throw new Error(\"Validator not initialized\");\n }\n\n return this.validateFn(event);\n }\n\n /**\n * Get validation errors from last validation\n */\n getErrors() {\n if (!this.validateFn) {\n return null;\n }\n return this.validateFn.errors;\n }\n\n /**\n * Reset validator state (for testing)\n * @internal\n */\n static _reset(): void {\n MetricsValidator.instance = new MetricsValidator();\n }\n}\n\n/**\n * Validate metrics event against schema\n *\n * Uses pre-compiled validator singleton for optimal performance.\n *\n * @param event - Metrics event to validate\n * @returns Promise resolving to true if valid\n *\n * @example\n * ```typescript\n * const event: MetricsEvent = {\n * timestamp: new Date().toISOString(),\n * name: 'schema_validations',\n * value: 42\n * };\n *\n * if (await validateMetricsEvent(event)) {\n * // Event is schema-compliant\n * } else {\n * const errors = getValidationErrors();\n * console.error('Validation failed:', errors);\n * }\n * ```\n */\nexport async function validateMetricsEvent(event: unknown): Promise<boolean> {\n return MetricsValidator.getInstance().validate(event);\n}\n\n/**\n * Validate array of metrics events\n *\n * @param events - Array of metrics events\n * @returns Promise resolving to true if all valid\n */\nexport async function validateMetricsEvents(events: unknown[]): Promise<boolean> {\n for (const event of events) {\n if (!(await validateMetricsEvent(event))) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Get validation errors from last validation\n */\nexport function getValidationErrors() {\n return MetricsValidator.getInstance().getErrors();\n}\n\n/**\n * Format validation errors as human-readable string\n */\nexport function formatValidationErrors(\n errors: Array<{ instancePath?: string; message?: string }>,\n): string {\n return errors\n .map((err) => {\n const path = err.instancePath || \"(root)\";\n const message = err.message || \"validation failed\";\n return `${path}: ${message}`;\n })\n .join(\"; \");\n}\n\n/**\n * Assert that metrics event is valid (throws if not)\n *\n * @param event - Metrics event to validate\n * @throws {Error} If validation fails\n */\nexport async function assertValidMetricsEvent(event: unknown): Promise<void> {\n if (!(await validateMetricsEvent(event))) {\n const errors = getValidationErrors();\n const message = errors ? formatValidationErrors(errors) : \"Metrics event validation failed\";\n throw new Error(`Invalid metrics event: ${message}`);\n }\n}\n\n// Export for testing\nexport { MetricsValidator };\n","/**\n * Telemetry module - metrics collection and export\n *\n * Provides counter, gauge, and histogram metrics with schema validation\n * and taxonomy-based defaults (ADR-0007).\n */\n\nexport const VERSION = \"1.0.0\";\n\n// Core registry and singleton\nexport { MetricsRegistry } from \"./registry.js\";\n\nimport { MetricsRegistry } from \"./registry.js\";\n\n/**\n * Default singleton metrics registry\n *\n * Use this for application-wide metrics collection.\n *\n * @example\n * ```typescript\n * import { metrics } from '@fulmenhq/tsfulmen/telemetry';\n *\n * // Increment counter\n * metrics.counter('schema_validations').inc();\n *\n * // Record histogram observation\n * metrics.histogram('config_load_ms').observe(42.5);\n *\n * // Export all metrics\n * const events = await metrics.export();\n * ```\n */\nexport const metrics = new MetricsRegistry();\n\n// Metric types\nexport { Counter } from \"./counter.js\";\nexport { Gauge } from \"./gauge.js\";\nexport { Histogram } from \"./histogram.js\";\n// Taxonomy\nexport type { MetricDefinition, MetricsTaxonomy } from \"./taxonomy.js\";\nexport {\n DEFAULT_MS_BUCKETS,\n getDefaultBuckets,\n getDefaultUnit,\n getMetric,\n getTaxonomy,\n isValidMetricName as isValidMetricNameTaxonomy,\n} from \"./taxonomy.js\";\n// Types\nexport type {\n FlushOptions,\n HistogramBucket,\n HistogramOptions,\n HistogramSummary,\n MetricName,\n MetricsEvent,\n MetricUnit,\n MetricValue,\n} from \"./types.js\";\nexport {\n isHistogramSummary,\n isValidMetricName,\n isValidMetricUnit,\n} from \"./types.js\";\n\n// Validators\nexport {\n assertValidMetricsEvent,\n formatValidationErrors,\n getValidationErrors,\n validateMetricsEvent,\n validateMetricsEvents,\n} from \"./validators.js\";\n","/**\n * Schema validator - implements AJV-based schema validation with goneat integration\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { AnySchema } from \"ajv\";\nimport Ajv from \"ajv\";\nimport Ajv2019 from \"ajv/dist/2019.js\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport AjvDraft04 from \"ajv-draft-04\";\nimport { parse as parseYAML } from \"yaml\";\nimport { metrics } from \"../telemetry/index.js\";\nimport { applyFulmenAjvFormats } from \"./ajv-formats.js\";\nimport { SchemaValidationError } from \"./errors.js\";\nimport { getSchemaRegistry } from \"./registry.js\";\nimport type {\n CompiledValidator,\n SchemaInput,\n SchemaRegistryOptions,\n SchemaValidationResult,\n} from \"./types.js\";\nimport { createDiagnostic } from \"./utils.js\";\n\n/**\n * Supported JSON Schema dialects for meta validation + compilation.\n */\ntype JsonSchemaDialect = \"draft-04\" | \"draft-06\" | \"draft-07\" | \"draft-2019-09\" | \"draft-2020-12\";\n\n/**\n * AJV instances by dialect\n */\nconst ajvInstances = new Map<JsonSchemaDialect, Ajv>();\n\n/**\n * Metaschema initialization promises by dialect\n */\nconst metaschemaReady = new Map<JsonSchemaDialect, Promise<void>>();\n\n/**\n * Schema cache for compiled validators\n */\nconst schemaCache = new Map<string, CompiledValidator>();\n\n/**\n * Load metaschema from Crucible SSOT\n */\nasync function loadMetaSchema(draft: JsonSchemaDialect): Promise<Record<string, unknown>> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const metaSchemaPath = join(\n __dirname,\n \"..\",\n \"..\",\n \"schemas\",\n \"crucible-ts\",\n \"meta\",\n draft,\n \"schema.json\",\n );\n\n const content = await readFile(metaSchemaPath, \"utf-8\");\n return JSON.parse(content) as Record<string, unknown>;\n}\n\n/**\n * Load vocabulary schemas (draft 2019-09 / 2020-12)\n */\nasync function loadVocabularySchemas(draft: JsonSchemaDialect): Promise<Record<string, unknown>[]> {\n if (draft !== \"draft-2019-09\" && draft !== \"draft-2020-12\") {\n return [];\n }\n\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const vocabDir = join(__dirname, \"..\", \"..\", \"schemas\", \"crucible-ts\", \"meta\", draft, \"meta\");\n\n const vocabFiles =\n draft === \"draft-2020-12\"\n ? [\n \"core.json\",\n \"applicator.json\",\n \"unevaluated.json\",\n \"validation.json\",\n \"meta-data.json\",\n \"format-annotation.json\",\n \"content.json\",\n ]\n : [\n \"core.json\",\n \"applicator.json\",\n \"validation.json\",\n \"meta-data.json\",\n \"format.json\",\n \"content.json\",\n ];\n\n const schemas: Record<string, unknown>[] = [];\n for (const file of vocabFiles) {\n try {\n const content = await readFile(join(vocabDir, file), \"utf-8\");\n schemas.push(JSON.parse(content) as Record<string, unknown>);\n } catch {\n // Vocabulary schema not found, skip\n }\n }\n\n return schemas;\n}\n\n/**\n * Load referenced schemas (including YAML files) for AJV\n *\n * Resolves relative paths from schemas/ and config/ directories.\n * Handles both relative paths and https://schemas.fulmenhq.dev URIs.\n *\n * Per Canonical URI Resolution Standard (v0.4.2+), crucible-hosted schemas use:\n * https://schemas.fulmenhq.dev/crucible/<topic>/<version>/<filename>\n *\n * We only embed crucible schemas locally. Other modules (goneat/, enact/, etc.)\n * are not embedded and cannot be resolved offline.\n */\nasync function loadReferencedSchema(uri: string): Promise<Record<string, unknown>> {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const repoRoot = join(__dirname, \"..\", \"..\");\n\n let resolvedPath: string;\n\n // Handle https://schemas.fulmenhq.dev/ URIs - map to local files\n if (uri.startsWith(\"https://schemas.fulmenhq.dev/\")) {\n let relativePath = uri.replace(\"https://schemas.fulmenhq.dev/\", \"\");\n\n // Strip crucible/ module prefix if present (v0.4.2+ canonical URIs)\n // We only embed crucible schemas - other modules cannot be resolved locally\n if (relativePath.startsWith(\"crucible/\")) {\n relativePath = relativePath.slice(\"crucible/\".length);\n }\n\n // Check if it's a config taxonomy reference\n if (relativePath.startsWith(\"config/taxonomy/\")) {\n resolvedPath = join(\n repoRoot,\n \"config\",\n \"crucible-ts\",\n \"taxonomy\",\n relativePath.split(\"/\").pop() || \"\",\n );\n } else {\n // Schema reference - map to schemas/crucible-ts/\n resolvedPath = join(repoRoot, \"schemas\", \"crucible-ts\", relativePath);\n }\n }\n // Handle relative paths (e.g., \"../../../../config/taxonomy/metrics.yaml\")\n else if (uri.startsWith(\"../../\") || uri.startsWith(\"../\")) {\n // Resolve relative to schemas/crucible-ts/observability/metrics/v1.0.0/\n // (where metrics-event.schema.json is located)\n const schemaBase = join(\n repoRoot,\n \"schemas\",\n \"crucible-ts\",\n \"observability\",\n \"metrics\",\n \"v1.0.0\",\n );\n resolvedPath = join(schemaBase, uri);\n }\n // Handle file:// URIs\n else if (uri.startsWith(\"file://\")) {\n resolvedPath = fileURLToPath(uri);\n }\n // Unhandled URI scheme\n else {\n throw new Error(`Cannot load remote schema: ${uri}`);\n }\n\n // Read and parse the file\n const content = await readFile(resolvedPath, \"utf-8\");\n const ext = resolvedPath.split(\".\").pop()?.toLowerCase();\n\n if (ext === \"yaml\" || ext === \"yml\") {\n return parseYAML(content) as Record<string, unknown>;\n }\n return JSON.parse(content) as Record<string, unknown>;\n}\n\n/**\n * Resolve JSON Schema dialect from schema content.\n */\nfunction detectDialect(schema: unknown): JsonSchemaDialect {\n if (schema && typeof schema === \"object\" && !Array.isArray(schema)) {\n const maybeSchema = schema as Record<string, unknown>;\n const declared = (maybeSchema as { $schema?: unknown }).$schema;\n\n if (typeof declared === \"string\") {\n if (declared.includes(\"draft-04\")) return \"draft-04\";\n if (declared.includes(\"draft-06\")) return \"draft-06\";\n if (declared.includes(\"draft-07\")) return \"draft-07\";\n if (declared.includes(\"draft/2019-09\")) return \"draft-2019-09\";\n if (declared.includes(\"draft/2020-12\")) return \"draft-2020-12\";\n }\n }\n\n // Default to 2020-12 in Fulmen ecosystem.\n return \"draft-2020-12\";\n}\n\n/**\n * Create AJV instance for a specific dialect\n */\nfunction createAjv(dialect: JsonSchemaDialect): Ajv {\n const AjvCtor =\n dialect === \"draft-2020-12\"\n ? Ajv2020\n : dialect === \"draft-2019-09\"\n ? Ajv2019\n : dialect === \"draft-04\"\n ? (AjvDraft04 as unknown as typeof Ajv)\n : Ajv;\n\n const ajv = new AjvCtor({\n strict: false,\n allErrors: true,\n verbose: true,\n // Allow schemas with $id to be added without replacing existing ones\n addUsedSchema: false,\n // draft-04 uses \"id\"; later drafts use \"$id\"\n schemaId: dialect === \"draft-04\" ? \"id\" : \"$id\",\n // Enable async schema loading for YAML references\n loadSchema: loadReferencedSchema,\n });\n\n applyFulmenAjvFormats(ajv);\n\n return ajv;\n}\n\n/**\n * Get or create AJV instance for a dialect, ensuring metaschemas are loaded.\n */\nasync function getAjv(dialect: JsonSchemaDialect): Promise<Ajv> {\n const existing = ajvInstances.get(dialect);\n if (existing) {\n const ready = metaschemaReady.get(dialect);\n if (ready) await ready;\n return existing;\n }\n\n const ajv = createAjv(dialect);\n ajvInstances.set(dialect, ajv);\n\n const readyPromise = Promise.all([loadVocabularySchemas(dialect), loadMetaSchema(dialect)])\n .then(([vocabSchemas, metaSchema]) => {\n // Add vocabulary schemas first (referenced by meta schema)\n for (const vocabSchema of vocabSchemas) {\n try {\n ajv.addMetaSchema(vocabSchema);\n } catch {\n // Already added or incompatible with Ajv's built-ins\n }\n }\n\n try {\n ajv.addMetaSchema(metaSchema);\n } catch {\n // Already added or incompatible with Ajv's built-ins\n }\n })\n .catch((error) => {\n throw new Error(`Failed to load metaschemas (${dialect}): ${error}`);\n });\n\n metaschemaReady.set(dialect, readyPromise);\n await readyPromise;\n\n return ajv;\n}\n\n/**\n * Compile a schema for validation\n */\nexport async function compileSchema(\n schema: SchemaInput,\n options: { aliases?: string[] } = {},\n): Promise<CompiledValidator> {\n const baseKey = typeof schema === \"string\" ? schema : JSON.stringify(schema);\n\n let parsedSchema: unknown;\n if (typeof schema === \"string\") {\n try {\n parsedSchema = JSON.parse(schema);\n } catch {\n // Try YAML if JSON parsing fails\n parsedSchema = parseYAML(schema);\n }\n } else if (Buffer.isBuffer(schema)) {\n const content = schema.toString(\"utf-8\");\n try {\n parsedSchema = JSON.parse(content);\n } catch {\n parsedSchema = parseYAML(content);\n }\n } else {\n parsedSchema = schema;\n }\n\n const dialect = detectDialect(parsedSchema);\n const ajv = await getAjv(dialect);\n\n const cacheKey = `${dialect}:${baseKey}`;\n const cached = schemaCache.get(cacheKey);\n if (cached !== undefined) {\n return cached;\n }\n\n try {\n // Register schema aliases (e.g., alternate $id values) before compile to support relative refs\n if (options.aliases && options.aliases.length > 0) {\n for (const alias of options.aliases) {\n if (alias && ajv.getSchema(alias) === undefined) {\n try {\n if (typeof parsedSchema === \"object\" && parsedSchema !== null) {\n ajv.addSchema(parsedSchema as Record<string, unknown>, alias);\n }\n } catch {\n // Ignore if alias already registered or invalid\n }\n }\n }\n }\n\n const validator =\n typeof parsedSchema === \"boolean\"\n ? ajv.compile(parsedSchema)\n : await ajv.compileAsync(parsedSchema as Record<string, unknown>);\n\n // Cache the compiled validator\n schemaCache.set(cacheKey, validator as CompiledValidator);\n\n return validator as CompiledValidator;\n } catch (error) {\n throw SchemaValidationError.parseFailed(\n {\n type: \"string\",\n content: typeof schema === \"string\" ? schema : JSON.stringify(schema),\n },\n error as Error,\n );\n }\n}\n\n/**\n * Validate data against a compiled schema\n */\nexport function validateData(data: unknown, validator: CompiledValidator): SchemaValidationResult {\n const valid = validator(data);\n\n const result: SchemaValidationResult = {\n valid,\n diagnostics: [],\n source: \"ajv\",\n };\n\n if (!valid && validator.errors) {\n const errors = validator.errors;\n if (Array.isArray(errors)) {\n result.diagnostics = errors.map((error) =>\n createDiagnostic(\n error.instancePath || \"\",\n error.message || \"Validation failed\",\n error.keyword || \"unknown\",\n \"ERROR\",\n \"ajv\",\n ),\n );\n }\n metrics.counter(\"schema_validation_errors\").inc();\n } else {\n metrics.counter(\"schema_validations\").inc();\n }\n\n return result;\n}\n\n/**\n * Validate file against a schema\n */\nexport async function validateFile(\n filePath: string,\n validator: CompiledValidator,\n): Promise<SchemaValidationResult> {\n try {\n const content = await readFile(filePath, \"utf-8\");\n let data: unknown;\n\n try {\n data = JSON.parse(content);\n } catch {\n // Try YAML if JSON parsing fails\n data = parseYAML(content);\n }\n\n return validateData(data, validator);\n } catch (error) {\n if (error instanceof SchemaValidationError) {\n throw error;\n }\n throw SchemaValidationError.validationFailed(\n filePath,\n [\n createDiagnostic(\n \"\",\n `Failed to read or parse file: ${(error as Error).message}`,\n \"file-read\",\n \"ERROR\",\n \"ajv\",\n ),\n ],\n { type: \"file\", id: filePath },\n );\n }\n}\n\n/**\n * Validate a schema document itself\n */\nexport async function validateSchema(schema: SchemaInput): Promise<SchemaValidationResult> {\n try {\n // Parse schema so we can both meta-validate and compile with dialect-specific Ajv.\n let parsedSchema: unknown;\n if (typeof schema === \"string\") {\n try {\n parsedSchema = JSON.parse(schema);\n } catch {\n parsedSchema = parseYAML(schema);\n }\n } else if (Buffer.isBuffer(schema)) {\n const content = schema.toString(\"utf-8\");\n try {\n parsedSchema = JSON.parse(content);\n } catch {\n parsedSchema = parseYAML(content);\n }\n } else {\n parsedSchema = schema;\n }\n\n const dialect = detectDialect(parsedSchema);\n const ajv = await getAjv(dialect);\n\n // 1) Meta validation against declared dialect\n const metaValid = ajv.validateSchema(parsedSchema as AnySchema);\n if (!metaValid && ajv.errors) {\n const diagnostics = ajv.errors.map((error) =>\n createDiagnostic(\n error.instancePath || \"\",\n error.message || \"Schema meta-validation failed\",\n error.keyword || \"unknown\",\n \"ERROR\",\n \"ajv\",\n ),\n );\n\n return { valid: false, diagnostics, source: \"ajv\" };\n }\n\n // 2) Compilation check (refs resolvable, keywords supported)\n await compileSchema(parsedSchema as SchemaInput);\n\n return {\n valid: true,\n diagnostics: [],\n source: \"ajv\",\n };\n } catch (error) {\n if (error instanceof SchemaValidationError) {\n return {\n valid: false,\n diagnostics: error.diagnostics,\n source: \"ajv\",\n };\n }\n\n return {\n valid: false,\n diagnostics: [\n createDiagnostic(\n \"\",\n `Schema validation failed: ${(error as Error).message}`,\n \"schema-validation\",\n \"ERROR\",\n \"ajv\",\n ),\n ],\n source: \"ajv\",\n };\n }\n}\n\n/**\n * Clear schema cache\n */\nexport function clearCache(): void {\n schemaCache.clear();\n // Keep Ajv instances cached; they hold metaschemas. Tests can still clear schema cache.\n}\n\n/**\n * Get schema cache size\n */\nexport function getCacheSize(): number {\n return schemaCache.size;\n}\n\n/**\n * Load schema by ID from registry and compile\n */\nexport async function compileSchemaById(\n schemaId: string,\n registryOptions?: SchemaRegistryOptions,\n): Promise<CompiledValidator> {\n try {\n const registry = getSchemaRegistry(registryOptions);\n const metadata = await registry.getSchema(schemaId);\n\n const content = await readFile(metadata.path, \"utf-8\");\n const aliases: string[] = [];\n\n const normalizedRelativePath = metadata.relativePath.replace(/\\\\/g, \"/\");\n if (normalizedRelativePath) {\n // Per Canonical URI Resolution Standard (v0.4.2+), include crucible/ module prefix\n aliases.push(\n new URL(`crucible/${normalizedRelativePath}`, \"https://schemas.fulmenhq.dev/\").toString(),\n );\n }\n\n return compileSchema(content, { aliases });\n } catch (error) {\n metrics.counter(\"schema_validation_errors\").inc();\n throw error;\n }\n}\n\n/**\n * Validate data against a schema ID from registry\n */\nexport async function validateDataBySchemaId(\n data: unknown,\n schemaId: string,\n registryOptions?: SchemaRegistryOptions,\n): Promise<SchemaValidationResult> {\n try {\n const validator = await compileSchemaById(schemaId, registryOptions);\n return validateData(data, validator);\n } catch (error) {\n metrics.counter(\"schema_validation_errors\").inc();\n throw error;\n }\n}\n\n/**\n * Validate file against a schema ID from registry\n */\nexport async function validateFileBySchemaId(\n filePath: string,\n schemaId: string,\n registryOptions?: SchemaRegistryOptions,\n): Promise<SchemaValidationResult> {\n try {\n const validator = await compileSchemaById(schemaId, registryOptions);\n return validateFile(filePath, validator);\n } catch (error) {\n metrics.counter(\"schema_validation_errors\").inc();\n throw error;\n }\n}\n","/**\n * Foundry module - Error handling\n *\n * Custom error classes for Foundry catalog operations with fail-fast validation.\n */\n\nexport class FoundryCatalogError extends Error {\n constructor(\n message: string,\n public readonly catalog?: string,\n public readonly cause?: Error,\n ) {\n super(message);\n this.name = \"FoundryCatalogError\";\n\n // Maintain proper stack trace for V8\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FoundryCatalogError);\n }\n }\n\n static invalidSchema(catalog: string, details: string, cause?: Error): FoundryCatalogError {\n return new FoundryCatalogError(\n `Invalid schema in ${catalog} catalog: ${details}`,\n catalog,\n cause,\n );\n }\n\n static missingCatalog(catalog: string): FoundryCatalogError {\n return new FoundryCatalogError(`Catalog ${catalog} not found or could not be loaded`, catalog);\n }\n\n static invalidPattern(patternId: string, details: string): FoundryCatalogError {\n return new FoundryCatalogError(`Invalid pattern ${patternId}: ${details}`, \"patterns\");\n }\n\n static compilationError(patternId: string, details: string, cause?: Error): FoundryCatalogError {\n return new FoundryCatalogError(\n `Failed to compile pattern ${patternId}: ${details}`,\n \"patterns\",\n cause,\n );\n }\n}\n","/**\n * Signal Catalog Loader\n *\n * Loads and validates the signal handling catalog from Crucible SSOT assets\n * following the same pattern as other Foundry catalogs.\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parse as parseYaml } from \"yaml\";\nimport { validateDataBySchemaId } from \"../../schema/validator.js\";\nimport { FoundryCatalogError } from \"../errors.js\";\nimport type { BehaviorInfo, SignalCatalog, SignalInfo } from \"./types.js\";\n\n// Get the directory of the current module file for proper path resolution\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Determine correct path based on whether we're in src/ or dist/\n// In development: src/foundry/signals/catalog.ts → ../../../config\n// In production: dist/foundry/index.js (bundled) → ../../config\nfunction getConfigPath(): string {\n if (__dirname.includes(\"/dist/\")) {\n // Bundled in dist/foundry/index.js\n return join(__dirname, \"../../config/crucible-ts/library/foundry/signals.yaml\");\n }\n // Running from source in src/foundry/signals/\n return join(__dirname, \"../../../config/crucible-ts/library/foundry/signals.yaml\");\n}\n\nconst SSOT_PATHS = {\n signals: getConfigPath(),\n} as const;\n\n// Schema ID for signals catalog (from Crucible SSOT)\nconst SCHEMA_ID = \"library/foundry/v1.0.0/signals\";\n\n/**\n * Load and validate the Signal Catalog from SSOT\n * Bun-first approach with Node.js fallback\n */\nasync function loadCatalog(): Promise<SignalCatalog> {\n const filePath = SSOT_PATHS.signals;\n const catalogName = \"signals\";\n\n try {\n let content: string;\n\n // Bun-first approach\n if (typeof Bun !== \"undefined\") {\n try {\n const file = Bun.file(filePath);\n if (!(await file.exists())) {\n throw FoundryCatalogError.missingCatalog(catalogName);\n }\n content = await file.text();\n } catch (error) {\n // Handle Bun-specific errors\n if (error instanceof Error && error.message.includes(\"No such file\")) {\n throw FoundryCatalogError.missingCatalog(catalogName);\n }\n throw error;\n }\n } else {\n // Node.js fallback\n try {\n content = await readFile(filePath, \"utf-8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n throw FoundryCatalogError.missingCatalog(catalogName);\n }\n throw error;\n }\n }\n\n // Parse YAML content\n const data = parseYaml(content) as SignalCatalog;\n\n // Validate against JSON Schema from Crucible SSOT\n const result = await validateDataBySchemaId(data, SCHEMA_ID);\n if (!result.valid) {\n const errorMessages = result.diagnostics.map((d) => `${d.pointer}: ${d.message}`).join(\"; \");\n throw FoundryCatalogError.invalidSchema(\n catalogName,\n `Schema validation failed: ${errorMessages}`,\n );\n }\n\n return data;\n } catch (error) {\n if (error instanceof FoundryCatalogError) {\n throw error;\n }\n\n // Distinguish between different types of file access errors\n const err = error as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\") {\n throw FoundryCatalogError.missingCatalog(catalogName);\n } else if (err.code === \"EACCES\") {\n throw FoundryCatalogError.invalidSchema(\n catalogName,\n \"Permission denied accessing catalog file\",\n err,\n );\n } else if (err.code === \"EISDIR\") {\n throw FoundryCatalogError.invalidSchema(\n catalogName,\n \"Expected file but found directory\",\n err,\n );\n } else if (err.code === \"EMFILE\" || err.code === \"ENFILE\") {\n throw FoundryCatalogError.invalidSchema(catalogName, \"Too many open files\", err);\n }\n\n throw FoundryCatalogError.invalidSchema(catalogName, \"Failed to load catalog\", err);\n }\n}\n\n// Cached catalog instance\nlet cachedCatalog: SignalCatalog | null = null;\n\n/**\n * Get the signal catalog, loading it if necessary\n */\nasync function getCatalog(): Promise<SignalCatalog> {\n if (!cachedCatalog) {\n cachedCatalog = await loadCatalog();\n }\n return cachedCatalog;\n}\n\n/**\n * Get the signals catalog version\n */\nexport async function getSignalsVersion(): Promise<string> {\n const catalog = await getCatalog();\n return catalog.version;\n}\n\n/**\n * Get all signals\n */\nexport async function listSignals(): Promise<SignalInfo[]> {\n const catalog = await getCatalog();\n return catalog.signals.map((signal) => ({ ...signal }));\n}\n\n/**\n * Get a specific signal by ID or name\n */\nexport async function getSignal(identifier: string): Promise<SignalInfo | null> {\n const catalog = await getCatalog();\n const signal = catalog.signals.find((s) => s.id === identifier || s.name === identifier);\n return signal ? { ...signal } : null;\n}\n\n/**\n * Get all behaviors\n */\nexport async function listBehaviors(): Promise<BehaviorInfo[]> {\n const catalog = await getCatalog();\n return catalog.behaviors.map((behavior) => ({ ...behavior }));\n}\n\n/**\n * Get a specific behavior by ID\n */\nexport async function getBehavior(id: string): Promise<BehaviorInfo | null> {\n const catalog = await getCatalog();\n const behavior = catalog.behaviors.find((b) => b.id === id);\n return behavior ? { ...behavior } : null;\n}\n\n/**\n * Get the complete catalog (for advanced use cases)\n */\nexport async function getSignalCatalog(): Promise<SignalCatalog> {\n return await getCatalog();\n}\n","/**\n * Signal Capability Detection\n *\n * Platform-aware signal support detection driven by catalog metadata.\n * Ensures cross-language parity by querying windows_event/fallback fields\n * rather than hardcoding signal names.\n */\n\nimport { getSignal, getSignalCatalog } from \"./catalog.js\";\n\n/**\n * Platform types\n */\nexport type Platform = \"linux\" | \"darwin\" | \"win32\" | \"freebsd\" | \"unknown\";\n\n/**\n * Platform capabilities summary\n */\nexport interface PlatformCapabilities {\n platform: Platform;\n isPOSIX: boolean;\n isWindows: boolean;\n supportsNativeSignals: boolean;\n supportsSignalExitCodes: boolean;\n supportedSignals: string[];\n unsupportedSignals: string[];\n mappedSignals: string[]; // Windows console events\n}\n\n/**\n * Detect current platform\n */\nexport function getPlatform(): Platform {\n const platform = process.platform;\n\n switch (platform) {\n case \"linux\":\n return \"linux\";\n case \"darwin\":\n return \"darwin\";\n case \"win32\":\n return \"win32\";\n case \"freebsd\":\n return \"freebsd\";\n default:\n return \"unknown\";\n }\n}\n\n/**\n * Check if current platform is POSIX-compliant\n */\nexport function isPOSIX(): boolean {\n const platform = getPlatform();\n return platform === \"linux\" || platform === \"darwin\" || platform === \"freebsd\";\n}\n\n/**\n * Check if current platform is Windows\n */\nexport function isWindows(): boolean {\n return getPlatform() === \"win32\";\n}\n\n/**\n * Check if a signal is supported on the current platform\n *\n * Uses catalog metadata (windows_event field) to determine support.\n * Returns true if:\n * - Platform is POSIX (all signals natively supported)\n * - Platform is Windows AND signal has non-null windows_event\n *\n * @param signalName - Signal name (e.g., \"SIGTERM\") or id (e.g., \"term\")\n */\nexport async function supportsSignal(signalName: string): Promise<boolean> {\n const signal = await getSignal(signalName);\n if (!signal) {\n return false;\n }\n\n // POSIX platforms support all signals natively\n if (isPOSIX()) {\n return true;\n }\n\n // Windows: check if signal has a console event mapping\n if (isWindows()) {\n // Signal is supported if windows_event is non-null\n return signal.windows_event !== null;\n }\n\n // Unknown platform: conservative approach (assume unsupported)\n return false;\n}\n\n/**\n * Check if platform supports signal-based exit codes (128+N pattern)\n *\n * Windows doesn't propagate signal numbers via exit codes in the same way\n * as POSIX systems. This function helps applications decide whether to\n * rely on signal exit codes for process monitoring.\n */\nexport function supportsSignalExitCodes(): boolean {\n // Only POSIX systems reliably support 128+N exit code pattern\n return isPOSIX();\n}\n\n/**\n * Get comprehensive platform capabilities\n *\n * Queries catalog to build a complete picture of signal support.\n * Useful for capability reporting, documentation generation, and testing.\n */\nexport async function getPlatformCapabilities(): Promise<PlatformCapabilities> {\n const platform = getPlatform();\n const isPosix = isPOSIX();\n const isWin = isWindows();\n const catalog = await getSignalCatalog();\n\n const supported: string[] = [];\n const unsupported: string[] = [];\n const mapped: string[] = [];\n\n // Categorize signals based on platform\n for (const signal of catalog.signals) {\n if (isPosix) {\n // All signals supported on POSIX\n supported.push(signal.name);\n } else if (isWin) {\n if (signal.windows_event !== null) {\n // Signal has Windows console event mapping\n supported.push(signal.name);\n mapped.push(signal.name);\n } else {\n // No Windows support - requires fallback\n unsupported.push(signal.name);\n }\n } else {\n // Unknown platform - mark as unsupported\n unsupported.push(signal.name);\n }\n }\n\n return {\n platform,\n isPOSIX: isPosix,\n isWindows: isWin,\n supportsNativeSignals: isPosix,\n supportsSignalExitCodes: supportsSignalExitCodes(),\n supportedSignals: supported,\n unsupportedSignals: unsupported,\n mappedSignals: mapped,\n };\n}\n\n/**\n * Get the signal number for the current platform\n *\n * Handles platform-specific overrides (e.g., SIGUSR1/SIGUSR2 on macOS/FreeBSD).\n * Returns the appropriate signal number based on platform_overrides.\n *\n * @param signalName - Signal name (e.g., \"SIGTERM\") or id (e.g., \"term\")\n * @returns Signal number for current platform, or null if signal not found\n */\nexport async function getSignalNumber(signalName: string): Promise<number | null> {\n const signal = await getSignal(signalName);\n if (!signal) {\n return null;\n }\n\n const platform = getPlatform();\n\n // Check for platform-specific override\n if (signal.platform_overrides) {\n if (platform === \"darwin\" && signal.platform_overrides.darwin !== undefined) {\n return signal.platform_overrides.darwin;\n }\n if (platform === \"freebsd\" && signal.platform_overrides.freebsd !== undefined) {\n return signal.platform_overrides.freebsd;\n }\n }\n\n // Return standard Unix number\n return signal.unix_number;\n}\n\n/**\n * Get the Windows console event name for a signal\n *\n * Returns the Windows console event that corresponds to a Unix signal,\n * or null if the signal is not supported on Windows.\n *\n * @param signalName - Signal name (e.g., \"SIGTERM\") or id (e.g., \"term\")\n */\nexport async function getWindowsEvent(signalName: string): Promise<string | null> {\n const signal = await getSignal(signalName);\n if (!signal) {\n return null;\n }\n\n return signal.windows_event;\n}\n","/**\n * Signals CLI - Commander-based CLI for signal operations\n *\n * Provides command-line interface for signal catalog exploration and validation.\n * This is a developer tool for debugging and operational work.\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { Command } from \"commander\";\nimport { exitCodes } from \"../exit-codes/index.js\";\nimport {\n getPlatformCapabilities,\n supportsSignal,\n supportsSignalExitCodes,\n} from \"./capabilities.js\";\nimport {\n getBehavior,\n getSignal,\n getSignalsVersion,\n listBehaviors,\n listSignals,\n} from \"./catalog.js\";\n\n/**\n * Create CLI command structure\n */\nexport function createSignalsCLI(): Command {\n const program = new Command();\n\n program\n .name(\"tsfulmen-signals\")\n .description(\"Signal handling CLI for Fulmen (developer tool)\")\n .version(\"0.1.0\");\n\n // Show signal(s) command\n program\n .command(\"show\")\n .description(\"Show signal catalog information\")\n .argument(\"[signal]\", \"Signal name to show (e.g., SIGTERM, TERM, HUP)\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--behaviors\", \"Show behaviors instead of signals\")\n .action(async (signal?: string, cmdOptions?: { json?: boolean; behaviors?: boolean }) => {\n try {\n if (cmdOptions?.behaviors) {\n // Show behaviors\n if (signal) {\n const behavior = await getBehavior(signal);\n if (!behavior) {\n console.error(`Behavior '${signal}' not found`);\n process.exit(exitCodes.EXIT_INVALID_ARGUMENT);\n }\n\n if (cmdOptions.json) {\n console.log(JSON.stringify(behavior, null, 2));\n } else {\n console.log(`Behavior: ${behavior.id}\\n`);\n console.log(` Name: ${behavior.name}`);\n console.log(` Description: ${behavior.description}`);\n console.log(` Phases: ${behavior.phases.join(\", \")}`);\n }\n } else {\n // List all behaviors\n const behaviors = await listBehaviors();\n if (cmdOptions.json) {\n console.log(JSON.stringify(behaviors, null, 2));\n } else {\n console.log(`Found ${behaviors.length} behavior(s):\\n`);\n for (const behavior of behaviors) {\n console.log(` ${behavior.id}: ${behavior.description}`);\n }\n }\n }\n return;\n }\n\n // Show signals\n if (signal) {\n // Normalize signal name\n const normalizedSignal = signal.toUpperCase().startsWith(\"SIG\")\n ? signal.toUpperCase()\n : `SIG${signal.toUpperCase()}`;\n\n const signalInfo = await getSignal(normalizedSignal);\n if (!signalInfo) {\n console.error(`Signal '${signal}' not found`);\n process.exit(exitCodes.EXIT_INVALID_ARGUMENT);\n }\n\n const supported = await supportsSignal(normalizedSignal);\n const caps = await getPlatformCapabilities();\n\n if (cmdOptions?.json) {\n console.log(\n JSON.stringify(\n {\n ...signalInfo,\n platform_supported: supported,\n platform_capabilities: caps,\n },\n null,\n 2,\n ),\n );\n } else {\n console.log(`Signal: ${signalInfo.name}\\n`);\n console.log(` Description: ${signalInfo.description}`);\n console.log(` Number (POSIX): ${signalInfo.unix_number}`);\n console.log(` Default Behavior: ${signalInfo.default_behavior}`);\n console.log(` Exit Code: ${signalInfo.exit_code}`);\n console.log(` Platform Supported: ${supported ? \"Yes\" : \"No (use HTTP fallback)\"}`);\n\n if (signalInfo.platform_overrides) {\n console.log(`\\n Platform Overrides:`);\n if (signalInfo.platform_overrides.darwin)\n console.log(` macOS: ${JSON.stringify(signalInfo.platform_overrides.darwin)}`);\n if (signalInfo.platform_overrides.freebsd)\n console.log(\n ` FreeBSD: ${JSON.stringify(signalInfo.platform_overrides.freebsd)}`,\n );\n }\n\n if (signalInfo.windows_fallback) {\n console.log(`\\n Windows Fallback:`);\n console.log(` Log Level: ${signalInfo.windows_fallback.log_level}`);\n console.log(` Telemetry Event: ${signalInfo.windows_fallback.telemetry_event}`);\n console.log(` HTTP Operation: ${signalInfo.windows_fallback.operation_hint}`);\n }\n }\n } else {\n // List all signals\n const signals = await listSignals();\n const version = await getSignalsVersion();\n\n if (cmdOptions?.json) {\n console.log(JSON.stringify({ version, signals }, null, 2));\n } else {\n console.log(`Signal Catalog Version: ${version}\\n`);\n console.log(`Found ${signals.length} signal(s):\\n`);\n\n const caps = await getPlatformCapabilities();\n console.log(`Platform: ${caps.platform} (${caps.isPOSIX ? \"POSIX\" : \"Windows\"})`);\n console.log(\n `Signal Exit Codes: ${supportsSignalExitCodes() ? \"Supported\" : \"Not supported\"}\\n`,\n );\n\n for (const sig of signals) {\n const supported = await supportsSignal(sig.name);\n const marker = supported ? \"✓\" : \"✗\";\n console.log(` ${marker} ${sig.name} (${sig.unix_number}): ${sig.description}`);\n }\n }\n }\n } catch (error) {\n console.error(\"Error showing signal info:\", (error as Error).message);\n process.exit(exitCodes.EXIT_FAILURE);\n }\n });\n\n // Validate signal config command\n program\n .command(\"validate\")\n .description(\"Validate signal configuration file against schema\")\n .argument(\"<file>\", \"Signal configuration file to validate (YAML/JSON)\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (file: string, cmdOptions?: { json?: boolean }) => {\n try {\n // Read file content\n const content = await readFile(file, \"utf-8\");\n let data: unknown;\n\n // Parse based on extension\n if (file.endsWith(\".json\")) {\n data = JSON.parse(content);\n } else if (file.endsWith(\".yaml\") || file.endsWith(\".yml\")) {\n // Use dynamic import for yaml parsing\n const yaml = await import(\"yaml\");\n data = yaml.parse(content);\n } else {\n throw new Error(\"Unsupported file format. Use .json, .yaml, or .yml\");\n }\n\n // Validate against schema\n const { validateDataBySchemaId } = await import(\"../../schema/validator.js\");\n const result = await validateDataBySchemaId(\n \"library/foundry/v1.0.0/signals\",\n data as string,\n );\n\n if (cmdOptions?.json) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n if (result.valid) {\n console.log(\"✓ Validation passed\");\n process.exit(exitCodes.EXIT_SUCCESS);\n } else {\n console.error(\"✗ Validation failed:\\n\");\n if (result.diagnostics) {\n for (const diag of result.diagnostics) {\n console.error(` ${diag.pointer}: ${diag.message}`);\n }\n }\n process.exit(exitCodes.EXIT_DATA_INVALID);\n }\n }\n } catch (error) {\n console.error(\"Error validating signal config:\", (error as Error).message);\n process.exit(exitCodes.EXIT_FAILURE);\n }\n });\n\n // Platform capabilities command\n program\n .command(\"platform\")\n .description(\"Show platform capabilities for signal handling\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (cmdOptions?: { json?: boolean }) => {\n try {\n const caps = await getPlatformCapabilities();\n const signalExitCodes = supportsSignalExitCodes();\n\n if (cmdOptions?.json) {\n console.log(\n JSON.stringify(\n {\n ...caps,\n supportsSignalExitCodes: signalExitCodes,\n },\n null,\n 2,\n ),\n );\n } else {\n console.log(\"Platform Capabilities:\\n\");\n console.log(` Platform: ${caps.platform}`);\n console.log(` POSIX: ${caps.isPOSIX ? \"Yes\" : \"No\"}`);\n console.log(` Windows: ${caps.isWindows ? \"Yes\" : \"No\"}`);\n console.log(` Signal Exit Codes: ${signalExitCodes ? \"Supported\" : \"Not supported\"}`);\n\n if (caps.supportedSignals && caps.supportedSignals.length > 0) {\n console.log(\"\\n Supported Signals:\");\n for (const signal of caps.supportedSignals) {\n console.log(` ✓ ${signal}`);\n }\n }\n\n if (caps.unsupportedSignals && caps.unsupportedSignals.length > 0) {\n console.log(\"\\n Unsupported Signals (use HTTP fallback):\");\n for (const signal of caps.unsupportedSignals) {\n console.log(` ✗ ${signal}`);\n }\n }\n }\n } catch (error) {\n console.error(\"Error getting platform capabilities:\", (error as Error).message);\n process.exit(exitCodes.EXIT_FAILURE);\n }\n });\n\n return program;\n}\n\n/**\n * Main CLI entry point\n */\nexport async function main(argv?: string[]): Promise<void> {\n const program = createSignalsCLI();\n await program.parseAsync(argv);\n}\n","#!/usr/bin/env node\n/**\n * Executable entry point for the `tsfulmen-signals` CLI.\n *\n * Dedicated bin entry (never imported by the library graph); see\n * src/bin/schema-cli.ts for the compile-safety rationale.\n */\nimport { main } from \"../foundry/signals/cli.js\";\n\nvoid main();\n"]}