Skip to content

Commit 0ab1f5d

Browse files
committed
docs: document Phase R Wave 1 rules in README and CHANGELOG
1 parent af054d8 commit 0ab1f5d

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Added
13+
- **Phase R Wave 1 — Cross-signal diagnostic rules**: Five new rules that correlate events
14+
from multiple subsystems to produce high-signal compound anomalies that no single monitor
15+
can produce alone.
16+
- **`sync-in-hot-path`** (`critical`) — `FsAnalyzer` now accepts an `insideRequest` flag.
17+
When a `*Sync` FS call fires inside an active request context (`AsyncLocalStorage`), a
18+
second, more specific suggestion is emitted alongside `synchronous-fs`. Wired automatically
19+
by `FsInstrumentation` via `getCurrentContext()`.
20+
- **`missing-connection-pool`** (`warning`) — `StaticScanner.runConnectionPoolScan()` walks
21+
the TypeScript AST at startup to detect `new Client()`, `new Connection()`,
22+
`createConnection()`, etc. called inside function bodies instead of at module scope.
23+
Results are surfaced as `tool: "argus-static"` `ScanResult` entries.
24+
- **`correlated-slow-endpoint`** (`critical`) — `ArgusAgent` cross-references the active
25+
N+1 traceId index against incoming HTTP events. When an outbound HTTP call exceeds 1 s
26+
and the same W3C `traceId` has an active N+1 pattern, a compound `anomaly` is emitted.
27+
- **`pool-starvation-by-slow-query`** (`critical`) — When a `pool-exhaustion` event fires
28+
within 10 s of a slow query on the same driver, the slow query is surfaced as the likely
29+
culprit holding connections.
30+
- **`n-plus-one-in-transaction`** (`critical`) — When N+1 is detected inside an open
31+
transaction (matched by `traceId` / `correlationId`), severity is escalated to critical
32+
because repeated queries inside a transaction also delay COMMIT and hold the connection.
33+
1234
### Fixed
1335
- **`SlowQueryMonitor.check()` type contract** — parameter changed from `driver: string` to
1436
`driver: string | undefined`. When no driver is known (e.g. manual `traceQuery()` calls or

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ The agent is an `EventEmitter`. All events are emitted on the `ArgusAgent` insta
474474

475475
| Event | Payload | When |
476476
|---|---|---|
477-
| `'anomaly'` | `ProfilerEvent` | Memory leak, event loop lag, CPU spike detected |
477+
| `'anomaly'` | `ProfilerEvent` | Memory leak, event loop lag, CPU spike, or cross-signal compound anomaly |
478478
| `'query'` | `{ sanitizedQuery, durationMs, driver?, traceId?, correlationId?, cacheHit?, suggestions? }` | DB query completed |
479479
| `'slow-query'` | `SlowQueryRecord` | Query exceeded the per-driver threshold |
480480
| `'transaction'` | `TransactionEvent` | BEGIN/COMMIT/ROLLBACK pattern completed |
@@ -485,18 +485,20 @@ The agent is an `EventEmitter`. All events are emitted on the `ArgusAgent` insta
485485
| `'http'` | `{ method, url, statusCode, durationMs, suggestions }` | HTTP request completed |
486486
| `'dns'` | `DnsEvent` | DNS lookup completed |
487487
| `'slow-dns'` | `DnsEvent` | DNS lookup exceeded `slowThresholdMs` |
488-
| `'fs'` | `{ operation, path, durationMs, suggestions }` | File system operation completed |
488+
| `'fs'` | `{ operation, path, durationMs, suggestions }` | File system operation completed (suggestions include `sync-in-hot-path` when called inside a request) |
489489
| `'log'` | `{ level, scrubbed, durationMs, suggestions? }` | `console.*` call intercepted |
490490
| `'crash'` | `CrashEvent` | `uncaughtException` or `unhandledRejection` received |
491491
| `'leak'` | `ResourceLeakEvent` | Active OS handle count exceeded threshold |
492-
| `'scan'` | `StaticScanResult[]` | Background `tsc`/ESLint scan complete (dev/test only) |
492+
| `'scan'` | `StaticScanResult[]` | Background `tsc`/ESLint/connection-pool scan complete (dev/test only) |
493493
| `'audit'` | `AuditResult` | `npm audit` CVE scan complete (dev/test only) |
494494
| `'info'` | `string` | Advisory messages (e.g., auto-detection found nothing) |
495495
| `'error'` | `Error` | Non-fatal internal error (e.g., heap snapshot write failed) |
496496

497497
```typescript
498498
agent.on('anomaly', (event) => {
499-
console.log(event.type); // 'memory-leak' | 'event-loop-lag' | 'cpu-spike'
499+
// runtime: 'memory-leak' | 'event-loop-lag' | 'cpu-spike'
500+
// cross-signal: 'correlated-slow-endpoint' | 'pool-starvation-by-slow-query' | 'n-plus-one-in-transaction'
501+
console.log(event.type);
500502
console.log(event.heapSnapshotPath); // only set when a snapshot write succeeded
501503
});
502504

@@ -569,7 +571,7 @@ All thresholds can be overridden without code changes, making the agent CI/CD an
569571
| `.withInstrumentation(opts?)` | ✅ Yes | Low | DB/IO tracing via `diagnostics_channel` (16 drivers) |
570572
| `.withHttpTracing()` | ✅ Yes | Low | HTTP request inspection & slow-request detection |
571573
| `.withLogTracing(opts?)` | ✅ Yes | Low | `console.*` override with entropy-scrubbed payloads |
572-
| `.withFsTracing()` |**No** | High | Patches `fs`. Detects `*Sync` blockers. **DEV ONLY.** |
574+
| `.withFsTracing()` |**No** | High | Patches `fs`. Detects `*Sync` blockers; escalates to `sync-in-hot-path` (critical) when called inside a live request. **DEV ONLY.** |
573575
| `.withQueryAnalysis()` | ✅ Yes | Medium (AST) | N+1 detection + query fix suggestions |
574576
| `.withSlowQueryMonitor(opts?)` | ✅ Yes | Very Low | Per-driver slow query detection + top-N log |
575577
| `.withTransactionMonitor(opts?)` | ✅ Yes | Very Low | BEGIN/COMMIT/ROLLBACK duration tracking |
@@ -578,7 +580,7 @@ All thresholds can be overridden without code changes, making the agent CI/CD an
578580
| `.withPoolMonitor(opts?)` | ✅ Yes | Low | Connection pool exhaustion & slow-acquire |
579581
| `.withDnsMonitor(opts?)` | ✅ Yes | Low | DNS lookup latency tracking |
580582
| `.withAdaptiveSampler(opts?)` | ✅ Yes | Very Low | Token-bucket rate limiter under high load |
581-
| `.withStaticScanner(dir)` |**No** | High | Background `tsc`/ESLint scan. **DEV ONLY.** |
583+
| `.withStaticScanner(dir)` |**No** | High | Background `tsc`/ESLint scan + TypeScript AST walk for connection-pool misuse (`missing-connection-pool`). **DEV ONLY.** |
582584
| `.withAuditScanner(dir)` |**No** | High | Spawns `npm audit`. **DEV/startup ONLY.** |
583585
| `.withExporter(config)` | ✅ Yes | Very Low | OTLP JSON export over mTLS |
584586
| `.withAggregatorWindow(ms)` | ✅ Yes | None | Override p99 sliding window (default: 60 s) |

0 commit comments

Comments
 (0)