|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 6 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## [Unreleased] |
| 11 | + |
| 12 | +### Fixed |
| 13 | +- **`SlowQueryMonitor.check()` type contract** — parameter changed from `driver: string` to |
| 14 | + `driver: string | undefined`. When no driver is known (e.g. manual `traceQuery()` calls or |
| 15 | + raw `diagnostics_channel` publishes without a `driver` field), `check()` now returns `null` |
| 16 | + immediately instead of falling back to the synthetic string `"unknown"`, which previously |
| 17 | + triggered a spurious `ARGUS_MISSING_DRIVER_THRESHOLD` process warning in CI. |
| 18 | +- **Test isolation** — the `missing-driver warning` describe block in |
| 19 | + `slow-query-monitor.test.ts` previously monkey-patched `process.emitWarning`, which leaked |
| 20 | + across parallel test files and caused a flaky failure in CI. Replaced with the additive |
| 21 | + `process.on('warning')` / `process.off('warning')` API, which is fully parallel-safe. Tests |
| 22 | + are now `async` and yield one `nextTick` before asserting, matching the asynchronous dispatch |
| 23 | + path of `process.emitWarning`. |
| 24 | + |
| 25 | +### Changed |
| 26 | +- **Architecture — God object split**: Extracted three cohesive modules from the 1 109-line |
| 27 | + `diagnostic-agent.ts`: |
| 28 | + - `src/internal/profile-factory.ts` — `buildAgentProfile()` contains all preset-resolution |
| 29 | + and builder-wiring logic for `DiagnosticAgent.createProfile()`. |
| 30 | + - `src/internal/query-handler.ts` — `createQueryHandler()` factory produces the per-query |
| 31 | + processing closure (adaptive sampling → query analysis → slow-query check → aggregation). |
| 32 | + - `src/internal/console-logger.ts` — `installConsoleLogger()` registers formatted console |
| 33 | + output for all agent events and returns the listener pairs for clean removal on `stop()`. |
| 34 | + - `diagnostic-agent.ts` reduced from 1 109 → ~960 lines; each new module has a single |
| 35 | + responsibility and is independently testable. |
| 36 | +- **`SlowQueryMonitor.check()` call site** — the `&& traced.driver` guard added in a previous |
| 37 | + hotfix is removed; the type change makes it redundant and the intent is now expressed in the |
| 38 | + contract rather than the caller. |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## [0.1.0] — 2026-04-11 |
| 43 | + |
| 44 | +### Added |
| 45 | + |
| 46 | +#### Core agent |
| 47 | +- `DiagnosticAgent` fluent builder with two entry points: `create()` (manual) and |
| 48 | + `createProfile()` (preset-based). |
| 49 | +- Zero-overhead global kill-switch via `DIAGNOSTIC_AGENT_ENABLED=false` — `.start()` becomes |
| 50 | + a no-op with no timer, subscription, or memory overhead. |
| 51 | +- `DIAGNOSTIC_DEBUG=true` built-in console logger for all agent events. |
| 52 | + |
| 53 | +#### Preset system |
| 54 | +- Three environment presets: `prod`, `dev`, `test`. |
| 55 | +- Three app-type presets: `web`, `db`, `worker` (composable as an array). |
| 56 | +- `'auto'` mode — scans `package.json` dependencies and infers the correct preset. |
| 57 | +- `DiagnosticAgent.detectAppTypes()` standalone detector. |
| 58 | + |
| 59 | +#### Instrumentation |
| 60 | +- `node:diagnostics_channel`-based query tracing for 14 DB drivers: `pg`, `mysql2`, `mssql`, |
| 61 | + `tedious`, `better-sqlite3`, `redis`, `ioredis`, `mongodb`, `@google-cloud/firestore`, |
| 62 | + `@aws-sdk/client-dynamodb`, `neo4j-driver`, `@elastic/elasticsearch`, `@clickhouse/client`, |
| 63 | + `@google-cloud/bigquery`, `cassandra-driver`, `@prisma/client`. |
| 64 | +- Zero prototype-pollution — no monkey-patching of driver prototypes in the default path. |
| 65 | +- HTTP outbound tracing (`node:diagnostics_channel` on Node ≥ 18; monkey-patch fallback on |
| 66 | + Node 14–17). |
| 67 | +- File-system tracing (`fs.*Sync` blocker detection) — dev/test only. |
| 68 | +- Console log tracing with Shannon entropy scrubbing. |
| 69 | +- DNS lookup latency tracking. |
| 70 | +- W3C `traceparent` propagation via `AsyncLocalStorage` (`createMiddleware()` / `runWithContext()`). |
| 71 | + |
| 72 | +#### Analysis |
| 73 | +- `SlowQueryMonitor` — per-driver threshold registry (16 built-in defaults), top-N log, |
| 74 | + `ARGUS_SLOW_QUERY_THRESHOLD_<DRIVER>` env var overrides, once-per-driver dev warning for |
| 75 | + unregistered drivers. |
| 76 | +- `QueryAnalyzer` — AST-based N+1 and query fix suggestions. |
| 77 | +- `TransactionMonitor` — BEGIN/COMMIT/ROLLBACK duration tracking. |
| 78 | +- `CacheMonitor` — sliding-window hit-rate degradation detection. |
| 79 | +- `CircuitBreakerDetector` — sustained error-rate detection across drivers. |
| 80 | +- `ExplainAnalyzer` — EXPLAIN plan parsing for supported drivers. |
| 81 | +- `StaticScanner` — background `tsc` / ESLint scan (dev/test only). |
| 82 | +- `AuditScanner` — `npm audit` CVE scan (dev/test only). |
| 83 | + |
| 84 | +#### Profiling |
| 85 | +- `RuntimeMonitor` — event loop lag, heap growth, CPU profiling. |
| 86 | +- `CrashGuard` — `uncaughtException` / `unhandledRejection` telemetry and flush. |
| 87 | +- `ResourceLeakMonitor` — OS handle / socket exhaustion detection. |
| 88 | +- `GcMonitor` — GC pause pressure via `node:perf_hooks`. |
| 89 | +- `PoolMonitor` — connection pool exhaustion and slow-acquire events. |
| 90 | +- `SourceMapResolver` — `.js.map` scanning and lazy position resolution. |
| 91 | +- `GracefulShutdown` — SIGTERM/SIGINT handler with configurable flush timeout. |
| 92 | +- `AdaptiveSampler` — token-bucket rate limiter per event category. |
| 93 | + |
| 94 | +#### Privacy |
| 95 | +- `AstSanitizer` — SQL/NoSQL query values shredded at the AST layer (via `node-sql-parser`). |
| 96 | +- `EntropyChecker` — Shannon entropy scanner strips JWTs, API keys, and secrets from logs. |
| 97 | + Configurable threshold (default 4.0 bits/char). |
| 98 | + |
| 99 | +#### Export |
| 100 | +- `MetricsAggregator` — p99 sliding-window aggregation. |
| 101 | +- `OTLPExporter` — OTLP JSON over mTLS (requires paid license). |
| 102 | +- `OTLPCompatibleExporter` — simplified OTLP exporter with API key auth. |
| 103 | + |
| 104 | +#### Licensing |
| 105 | +- ECDSA ES256 JWT license validation with offline verification. |
| 106 | +- Clock-integrity guard (monotonic rollback detection). |
| 107 | +- Expiry signal file written to cwd / tmpdir / homedir on license expiry. |
| 108 | + |
| 109 | +#### Developer experience |
| 110 | +- Dual ESM + CommonJS build (`dist/esm/` and `dist/cjs/`). |
| 111 | +- Native TypeScript source execution via `--experimental-strip-types` (Node ≥ 22.6, dev only). |
| 112 | +- Docker demo app (`quotes-demo-app/`) with `docker compose` one-liner. |
| 113 | +- 485 tests across 102 suites mirroring the source tree. |
| 114 | + |
| 115 | +[Unreleased]: https://github.com/sharon77242/Argus/compare/v0.1.0...HEAD |
| 116 | +[0.1.0]: https://github.com/sharon77242/Argus/releases/tag/v0.1.0 |
0 commit comments