mergen-server 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +57 -0
- package/README.md +96 -0
- package/dist/__stubs__/calibration.js +471 -0
- package/dist/__stubs__/causal.js +601 -0
- package/dist/__stubs__/closed-source.js +150 -0
- package/dist/__stubs__/license.js +35 -0
- package/dist/__stubs__/plans.js +197 -0
- package/dist/app.js +467 -0
- package/dist/cli.js +250 -0
- package/dist/commands/agent-identity.js +79 -0
- package/dist/commands/gate.js +107 -0
- package/dist/commands/github.js +632 -0
- package/dist/commands/incident.js +644 -0
- package/dist/commands/policy.js +710 -0
- package/dist/commands/scan.js +243 -0
- package/dist/commands/setup.js +1218 -0
- package/dist/commands/shared.js +109 -0
- package/dist/commands/team.js +809 -0
- package/dist/datadog/blame-attribution.js +228 -0
- package/dist/datadog/client.js +159 -0
- package/dist/datadog/compactor.js +169 -0
- package/dist/datadog/fingerprinter.js +34 -0
- package/dist/datadog/incident-state.js +21 -0
- package/dist/datadog/line-matcher.js +56 -0
- package/dist/datadog/memory-store.js +399 -0
- package/dist/datadog/otel-trace.js +67 -0
- package/dist/index.js +505 -0
- package/dist/intelligence/action-risk.js +132 -0
- package/dist/intelligence/activity-feed.js +40 -0
- package/dist/intelligence/agent-identity.js +115 -0
- package/dist/intelligence/agent-pipeline.js +329 -0
- package/dist/intelligence/agent-profiles.js +81 -0
- package/dist/intelligence/ai-commit.js +16 -0
- package/dist/intelligence/approval-analytics.js +42 -0
- package/dist/intelligence/approval-events.js +5 -0
- package/dist/intelligence/arch-boundaries.js +94 -0
- package/dist/intelligence/arch-graph.js +117 -0
- package/dist/intelligence/autonomy.js +397 -0
- package/dist/intelligence/azure-broker.js +57 -0
- package/dist/intelligence/azure-proxy-sessions.js +49 -0
- package/dist/intelligence/baseline.js +1 -0
- package/dist/intelligence/behavior-baseline.js +134 -0
- package/dist/intelligence/billing.js +1 -0
- package/dist/intelligence/blast-radius.js +224 -0
- package/dist/intelligence/bypass.js +157 -0
- package/dist/intelligence/calibration-classifier.js +77 -0
- package/dist/intelligence/calibration-git-sync.js +74 -0
- package/dist/intelligence/calibration.js +1 -0
- package/dist/intelligence/cascade-detector.js +58 -0
- package/dist/intelligence/case-study-generator.js +126 -0
- package/dist/intelligence/causal-graph.js +126 -0
- package/dist/intelligence/causal.js +1 -0
- package/dist/intelligence/change-risk.js +102 -0
- package/dist/intelligence/compliance-report.js +134 -0
- package/dist/intelligence/confidence-report.js +85 -0
- package/dist/intelligence/corpus-to-policy.js +140 -0
- package/dist/intelligence/credential-broker.js +112 -0
- package/dist/intelligence/credential-misuse.js +39 -0
- package/dist/intelligence/debug-sessions.js +108 -0
- package/dist/intelligence/decision-escalation.js +36 -0
- package/dist/intelligence/decision-memory.js +47 -0
- package/dist/intelligence/decision-similarity.js +85 -0
- package/dist/intelligence/default-safety-tests.js +53 -0
- package/dist/intelligence/degradation-watcher.js +108 -0
- package/dist/intelligence/detector-plugins.js +70 -0
- package/dist/intelligence/detectors.js +1 -0
- package/dist/intelligence/device-auth.js +138 -0
- package/dist/intelligence/diff-size.js +42 -0
- package/dist/intelligence/ebpf-verify.js +45 -0
- package/dist/intelligence/enterprise-policy-engine.js +1122 -0
- package/dist/intelligence/error-fingerprint.js +1 -0
- package/dist/intelligence/execution-gate.js +100 -0
- package/dist/intelligence/execution-mode.js +22 -0
- package/dist/intelligence/gate-analytics.js +256 -0
- package/dist/intelligence/gate-decision.js +64 -0
- package/dist/intelligence/gcp-broker.js +50 -0
- package/dist/intelligence/git-adr-sync.js +207 -0
- package/dist/intelligence/hitl-hold.js +460 -0
- package/dist/intelligence/hypothesis-history.js +93 -0
- package/dist/intelligence/idp-identity.js +83 -0
- package/dist/intelligence/impl-critic.js +216 -0
- package/dist/intelligence/incident-autopilot.js +622 -0
- package/dist/intelligence/incident-replay.js +162 -0
- package/dist/intelligence/incident-result-cache.js +33 -0
- package/dist/intelligence/incident-similarity.js +58 -0
- package/dist/intelligence/infra-detectors.js +312 -0
- package/dist/intelligence/license.js +185 -0
- package/dist/intelligence/llm-spokesperson.js +62 -0
- package/dist/intelligence/mcp-prompts.js +320 -0
- package/dist/intelligence/mcp-resources.js +171 -0
- package/dist/intelligence/normalize.js +108 -0
- package/dist/intelligence/notifications.js +83 -0
- package/dist/intelligence/oidc-issuer.js +87 -0
- package/dist/intelligence/override-corpus.js +597 -0
- package/dist/intelligence/planning-gate.js +84 -0
- package/dist/intelligence/plans.js +223 -0
- package/dist/intelligence/platt-scaling.js +164 -0
- package/dist/intelligence/policy-proposals.js +84 -0
- package/dist/intelligence/policy-suggester.js +161 -0
- package/dist/intelligence/policy-sync.js +103 -0
- package/dist/intelligence/policy-test-runner.js +35 -0
- package/dist/intelligence/postmortem-parser.js +181 -0
- package/dist/intelligence/postmortem-retrieval.js +224 -0
- package/dist/intelligence/postmortem-store.js +596 -0
- package/dist/intelligence/pr-commenter.js +81 -0
- package/dist/intelligence/pr-policy-gate.js +38 -0
- package/dist/intelligence/pr-shadow-analyzer.js +229 -0
- package/dist/intelligence/process-tree.js +108 -0
- package/dist/intelligence/prompts.js +1 -0
- package/dist/intelligence/replay.js +38 -0
- package/dist/intelligence/repro-steps.js +1 -0
- package/dist/intelligence/resource-extractors.js +0 -0
- package/dist/intelligence/resource-file-context.js +138 -0
- package/dist/intelligence/risk-score.js +22 -0
- package/dist/intelligence/rollback.js +137 -0
- package/dist/intelligence/runbook-updater.js +143 -0
- package/dist/intelligence/sandbox.js +194 -0
- package/dist/intelligence/script-trust.js +104 -0
- package/dist/intelligence/session-metrics.js +67 -0
- package/dist/intelligence/session-threat-tracker.js +231 -0
- package/dist/intelligence/shadow-digest-cron.js +81 -0
- package/dist/intelligence/shadow-log.js +284 -0
- package/dist/intelligence/shell-ast.js +145 -0
- package/dist/intelligence/siem-forward.js +104 -0
- package/dist/intelligence/slack-digest.js +151 -0
- package/dist/intelligence/slack-override-loop.js +217 -0
- package/dist/intelligence/slack-routing.js +67 -0
- package/dist/intelligence/slack.js +900 -0
- package/dist/intelligence/sql-ast.js +31 -0
- package/dist/intelligence/team.js +1 -0
- package/dist/intelligence/telemetry.js +76 -0
- package/dist/intelligence/threshold-optimizer.js +75 -0
- package/dist/intelligence/token-budget.js +66 -0
- package/dist/intelligence/tool-guard.js +708 -0
- package/dist/intelligence/tool-manifest 2.js +74 -0
- package/dist/intelligence/tool-manifest.js +125 -0
- package/dist/intelligence/tools-analysis.js +857 -0
- package/dist/intelligence/tools-arch.js +152 -0
- package/dist/intelligence/tools-autonomy.js +495 -0
- package/dist/intelligence/tools-blast-radius.js +140 -0
- package/dist/intelligence/tools-browser.js +431 -0
- package/dist/intelligence/tools-change-timeline.js +154 -0
- package/dist/intelligence/tools-credentials.js +117 -0
- package/dist/intelligence/tools-datadog.js +233 -0
- package/dist/intelligence/tools-debug-sessions.js +209 -0
- package/dist/intelligence/tools-discovery.js +284 -0
- package/dist/intelligence/tools-infra.js +612 -0
- package/dist/intelligence/tools-intent.js +128 -0
- package/dist/intelligence/tools-memory.js +514 -0
- package/dist/intelligence/tools-runbook.js +951 -0
- package/dist/intelligence/tools-sessions.js +107 -0
- package/dist/intelligence/tools-state.js +232 -0
- package/dist/intelligence/tools-utility.js +430 -0
- package/dist/intelligence/tools-validate.js +215 -0
- package/dist/intelligence/tools.js +1 -0
- package/dist/intelligence/trace-context.js +11 -0
- package/dist/intelligence/unclassified-clusters.js +87 -0
- package/dist/intelligence/usage.js +195 -0
- package/dist/routes/active-authors.js +63 -0
- package/dist/routes/activity-feed.js +21 -0
- package/dist/routes/adr.js +117 -0
- package/dist/routes/agent-activity.js +184 -0
- package/dist/routes/agent-blunders.js +163 -0
- package/dist/routes/agents.js +175 -0
- package/dist/routes/api-keys.js +65 -0
- package/dist/routes/arch.js +75 -0
- package/dist/routes/audit-export.js +93 -0
- package/dist/routes/billing-dashboard.js +158 -0
- package/dist/routes/billing-outcome.js +77 -0
- package/dist/routes/calibration.js +305 -0
- package/dist/routes/ci-gate-history.js +20 -0
- package/dist/routes/ci-gate.js +232 -0
- package/dist/routes/ci.js +293 -0
- package/dist/routes/compliance-report.js +24 -0
- package/dist/routes/confidence.js +30 -0
- package/dist/routes/credentials.js +119 -0
- package/dist/routes/dashboard.js +1407 -0
- package/dist/routes/decision-memory.js +42 -0
- package/dist/routes/demo.js +844 -0
- package/dist/routes/device-auth-stub.js +173 -0
- package/dist/routes/explain-why.js +39 -0
- package/dist/routes/gate-analytics.js +213 -0
- package/dist/routes/gate.js +28 -0
- package/dist/routes/github-webhook.js +364 -0
- package/dist/routes/habituation.js +30 -0
- package/dist/routes/health-integrations.js +243 -0
- package/dist/routes/heartbeats.js +45 -0
- package/dist/routes/hitl.js +364 -0
- package/dist/routes/impact-report.js +645 -0
- package/dist/routes/incident-webhook.js +63 -0
- package/dist/routes/incidents.js +366 -0
- package/dist/routes/layers.js +62 -0
- package/dist/routes/license.js +187 -0
- package/dist/routes/oidc-issuer.js +30 -0
- package/dist/routes/onboarding.js +170 -0
- package/dist/routes/otel.js +67 -0
- package/dist/routes/otlp-receiver.js +179 -0
- package/dist/routes/overrides.js +241 -0
- package/dist/routes/pagerduty.js +258 -0
- package/dist/routes/policies.js +809 -0
- package/dist/routes/policy-nl.js +169 -0
- package/dist/routes/postmortem.js +102 -0
- package/dist/routes/pr-shadow.js +47 -0
- package/dist/routes/rbac.js +61 -0
- package/dist/routes/replay.js +17 -0
- package/dist/routes/risk-report.js +164 -0
- package/dist/routes/runbooks.js +125 -0
- package/dist/routes/safety-test.js +174 -0
- package/dist/routes/sdk.js +222 -0
- package/dist/routes/sensor.js +819 -0
- package/dist/routes/sentry.js +140 -0
- package/dist/routes/sessions.js +43 -0
- package/dist/routes/setup-ui.js +594 -0
- package/dist/routes/shadow-report.js +107 -0
- package/dist/routes/slack-routing.js +171 -0
- package/dist/routes/team-usage.js +71 -0
- package/dist/routes/telemetry.js +28 -0
- package/dist/routes/tenants.js +199 -0
- package/dist/routes/tickets.js +167 -0
- package/dist/routes/validate.js +13 -0
- package/dist/routes/war-room.js +113 -0
- package/dist/scripts/check-arch.js +22 -0
- package/dist/seeds/community-corpus.js +176 -0
- package/dist/seeds/corpus.js +1224 -0
- package/dist/sensor/action-ledger.js +327 -0
- package/dist/sensor/adr-store.js +140 -0
- package/dist/sensor/agent-blunder-store.js +370 -0
- package/dist/sensor/agent-context-store.js +225 -0
- package/dist/sensor/agent-memory-store.js +231 -0
- package/dist/sensor/audit-fetch.js +23 -0
- package/dist/sensor/audit-log.js +273 -0
- package/dist/sensor/buffer-schemas.js +225 -0
- package/dist/sensor/buffer.js +599 -0
- package/dist/sensor/bypass-tracker.js +93 -0
- package/dist/sensor/ci-gate-history.js +70 -0
- package/dist/sensor/cloud-auth.js +183 -0
- package/dist/sensor/commit-context-store.js +235 -0
- package/dist/sensor/docker-log-stream.js +164 -0
- package/dist/sensor/docker-monitor.js +122 -0
- package/dist/sensor/extended-buffer.js +46 -0
- package/dist/sensor/feedback-token.js +41 -0
- package/dist/sensor/file-lock.js +6 -0
- package/dist/sensor/fs-watcher.js +106 -0
- package/dist/sensor/gate-heartbeat.js +122 -0
- package/dist/sensor/git-suspect.js +136 -0
- package/dist/sensor/habituation-store.js +77 -0
- package/dist/sensor/heartbeat-monitor.js +133 -0
- package/dist/sensor/incident-store.js +340 -0
- package/dist/sensor/infra-normalizer.js +513 -0
- package/dist/sensor/ingest.js +339 -0
- package/dist/sensor/jest-reporter.js +52 -0
- package/dist/sensor/k8s-events.js +132 -0
- package/dist/sensor/layer2-store.js +111 -0
- package/dist/sensor/layer3-store.js +230 -0
- package/dist/sensor/layer4-store.js +147 -0
- package/dist/sensor/logger.js +13 -0
- package/dist/sensor/otel-exporter.js +161 -0
- package/dist/sensor/paths.js +71 -0
- package/dist/sensor/policy-history.js +147 -0
- package/dist/sensor/pr-shadow-store.js +83 -0
- package/dist/sensor/process-watcher.js +162 -0
- package/dist/sensor/rbac.js +92 -0
- package/dist/sensor/redact.js +114 -0
- package/dist/sensor/redis-store.js +191 -0
- package/dist/sensor/route-reachability.js +64 -0
- package/dist/sensor/security-utils.js +18 -0
- package/dist/sensor/service-graph.js +170 -0
- package/dist/sensor/service-topology.js +227 -0
- package/dist/sensor/session-history.js +74 -0
- package/dist/sensor/session-persist.js +38 -0
- package/dist/sensor/shadow-promote.js +122 -0
- package/dist/sensor/sourcemap.js +281 -0
- package/dist/sensor/sqlite-store.js +205 -0
- package/dist/sensor/sso.js +164 -0
- package/dist/sensor/vitest-reporter.js +65 -0
- package/dist/sensor/watcher.js +48 -0
- package/dist/storage/interfaces.js +0 -0
- package/dist/storage/pg/pg-action-ledger.js +138 -0
- package/dist/storage/pg/pg-approval-store.js +107 -0
- package/dist/storage/pg/pg-blunder-store.js +193 -0
- package/dist/storage/pg/pg-ci-gate-history.js +83 -0
- package/dist/storage/pg/pg-client.js +24 -0
- package/dist/storage/pg/pg-event-store.js +63 -0
- package/dist/storage/pg/pg-incident-store.js +190 -0
- package/dist/storage/pg/pg-migrations.js +26 -0
- package/dist/storage/pg/pg-override-corpus.js +447 -0
- package/dist/storage/pg/pg-shadow-log.js +129 -0
- package/dist/storage/sqlite/sqlite-action-ledger.js +18 -0
- package/dist/storage/sqlite/sqlite-approval-store.js +37 -0
- package/dist/storage/sqlite/sqlite-blunder-store.js +27 -0
- package/dist/storage/sqlite/sqlite-ci-gate-history.js +19 -0
- package/dist/storage/sqlite/sqlite-event-store.js +29 -0
- package/dist/storage/sqlite/sqlite-incident-store.js +34 -0
- package/dist/storage/sqlite/sqlite-override-corpus.js +75 -0
- package/dist/storage/sqlite/sqlite-shadow-log.js +36 -0
- package/dist/storage/store-factory.js +55 -0
- package/dist/storage/store-registry.js +31 -0
- package/dist/update-checker.js +107 -0
- package/dist/workers/autopilot-worker.js +28 -0
- package/dist/workers/notification-worker.js +28 -0
- package/dist/workers/queues.js +58 -0
- package/dist/workers/validation-worker.js +24 -0
- package/dist/workers/worker-registry.js +18 -0
- package/package.json +123 -0
- package/sdk/mergen-inject.js +260 -0
- package/sdk/node.js +313 -0
- package/sdk/vite-plugin.ts +57 -0
- package/sdk/webpack-plugin.js +106 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
const DB_POOL_RE = new RegExp([
|
|
2
|
+
// Generic
|
|
3
|
+
"connection pool",
|
|
4
|
+
"pool exhausted",
|
|
5
|
+
"pool timeout",
|
|
6
|
+
"connection limit",
|
|
7
|
+
"too many connections",
|
|
8
|
+
"max_connections",
|
|
9
|
+
"max connections",
|
|
10
|
+
// Node.js (pg, mysql2, knex, sequelize)
|
|
11
|
+
"ECONNREFUSED",
|
|
12
|
+
"ETIMEDOUT",
|
|
13
|
+
"Client checkout timed out",
|
|
14
|
+
"Connection terminated unexpectedly",
|
|
15
|
+
"remaining connection slots",
|
|
16
|
+
// Python (psycopg2, SQLAlchemy, asyncpg, Django ORM)
|
|
17
|
+
"OperationalError.*connection",
|
|
18
|
+
"QueuePool limit",
|
|
19
|
+
"TimeoutError.*pool",
|
|
20
|
+
"could not connect to server",
|
|
21
|
+
"connection pool exhausted",
|
|
22
|
+
"psycopg2\\.OperationalError",
|
|
23
|
+
"sqlalchemy\\.exc\\.TimeoutError",
|
|
24
|
+
// Java (HikariCP, c3p0, DBCP, Spring)
|
|
25
|
+
"HikariPool.*Connection is not available",
|
|
26
|
+
"Connection pool exhausted",
|
|
27
|
+
"Unable to acquire JDBC Connection",
|
|
28
|
+
"Timeout waiting for connection from pool",
|
|
29
|
+
"java\\.sql\\.SQLTimeoutException",
|
|
30
|
+
"Connection pool size.*exceeded",
|
|
31
|
+
// Go (database/sql, pgx, gorm)
|
|
32
|
+
"pq: connection refused",
|
|
33
|
+
"pq: sorry, too many clients",
|
|
34
|
+
"context deadline exceeded.*sql",
|
|
35
|
+
"sql: no rows in result set",
|
|
36
|
+
"pgx: connection pool exhausted",
|
|
37
|
+
// Ruby (ActiveRecord, PG gem)
|
|
38
|
+
"ActiveRecord::StatementInvalid.*connection",
|
|
39
|
+
"PG::ConnectionBad",
|
|
40
|
+
"PG::TooManyConnections",
|
|
41
|
+
"could not obtain a database connection",
|
|
42
|
+
// Rust (sqlx, diesel)
|
|
43
|
+
"PoolTimedOut",
|
|
44
|
+
"connection error: Connection refused"
|
|
45
|
+
].join("|"), "i");
|
|
46
|
+
const OOM_RE = new RegExp([
|
|
47
|
+
// Generic / kernel
|
|
48
|
+
"out of memory",
|
|
49
|
+
"OOMKilled",
|
|
50
|
+
"memory limit exceeded",
|
|
51
|
+
"cannot allocate",
|
|
52
|
+
"allocation failed",
|
|
53
|
+
"oom_score",
|
|
54
|
+
// Node.js
|
|
55
|
+
"heap out of memory",
|
|
56
|
+
"JavaScript heap out of memory",
|
|
57
|
+
"FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed",
|
|
58
|
+
// Python
|
|
59
|
+
"MemoryError",
|
|
60
|
+
"Cannot allocate memory",
|
|
61
|
+
"numpy.*MemoryError",
|
|
62
|
+
// Java
|
|
63
|
+
"java\\.lang\\.OutOfMemoryError",
|
|
64
|
+
"GC overhead limit exceeded",
|
|
65
|
+
"Java heap space",
|
|
66
|
+
"PermGen space",
|
|
67
|
+
"Metaspace",
|
|
68
|
+
// Go
|
|
69
|
+
"runtime: out of memory",
|
|
70
|
+
"runtime: cannot allocate memory",
|
|
71
|
+
// Ruby
|
|
72
|
+
"NoMemoryError",
|
|
73
|
+
"failed to allocate memory",
|
|
74
|
+
// Container / Kubernetes
|
|
75
|
+
"OOM killer",
|
|
76
|
+
"memory cgroup out of memory",
|
|
77
|
+
"Killed process.*memory"
|
|
78
|
+
].join("|"), "i");
|
|
79
|
+
const RATE_LIMIT_RE = new RegExp([
|
|
80
|
+
"rate limit",
|
|
81
|
+
"rate-limit",
|
|
82
|
+
"RateLimit",
|
|
83
|
+
"too many requests",
|
|
84
|
+
"HTTP 429",
|
|
85
|
+
"status 429",
|
|
86
|
+
"quota exceeded",
|
|
87
|
+
"quota limit",
|
|
88
|
+
"throttled",
|
|
89
|
+
"throttling",
|
|
90
|
+
"backpressure",
|
|
91
|
+
"retry-after",
|
|
92
|
+
"Retry-After",
|
|
93
|
+
// Cloud provider specifics
|
|
94
|
+
"RequestLimitExceeded",
|
|
95
|
+
"SlowDown",
|
|
96
|
+
"ThrottlingException",
|
|
97
|
+
"RESOURCE_EXHAUSTED",
|
|
98
|
+
"API rate limit",
|
|
99
|
+
// Service mesh / proxy
|
|
100
|
+
"x-envoy-ratelimited",
|
|
101
|
+
"upstream request timeout"
|
|
102
|
+
].join("|"), "i");
|
|
103
|
+
const CERT_RE = new RegExp([
|
|
104
|
+
"certificate",
|
|
105
|
+
"Certificate",
|
|
106
|
+
"CERT_HAS_EXPIRED",
|
|
107
|
+
"certificate verify failed",
|
|
108
|
+
"ssl error",
|
|
109
|
+
"SSL error",
|
|
110
|
+
"tls",
|
|
111
|
+
"TLS",
|
|
112
|
+
"x509",
|
|
113
|
+
"handshake failed",
|
|
114
|
+
"CERTIFICATE_VERIFY_FAILED",
|
|
115
|
+
// Node.js
|
|
116
|
+
"CERT_UNTRUSTED",
|
|
117
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
118
|
+
"ERR_TLS",
|
|
119
|
+
"certificate has expired",
|
|
120
|
+
// Python
|
|
121
|
+
"ssl\\.SSLError",
|
|
122
|
+
"ssl\\.CertificateError",
|
|
123
|
+
"CERTIFICATE_VERIFY_FAILED",
|
|
124
|
+
// Java
|
|
125
|
+
"javax\\.net\\.ssl\\.SSLHandshakeException",
|
|
126
|
+
"sun\\.security\\.validator\\.ValidatorException",
|
|
127
|
+
"PKIX path building failed",
|
|
128
|
+
// Go
|
|
129
|
+
"tls: certificate has expired",
|
|
130
|
+
"x509: certificate signed by unknown authority",
|
|
131
|
+
"x509: certificate has expired",
|
|
132
|
+
// Ruby
|
|
133
|
+
"OpenSSL::SSL::SSLError",
|
|
134
|
+
"certificate verify failed"
|
|
135
|
+
].join("|"), "i");
|
|
136
|
+
const SLOW_QUERY_RE = new RegExp([
|
|
137
|
+
"slow query",
|
|
138
|
+
"query timeout",
|
|
139
|
+
"statement timeout",
|
|
140
|
+
"lock timeout",
|
|
141
|
+
"deadlock",
|
|
142
|
+
"lock wait",
|
|
143
|
+
"canceling statement due to",
|
|
144
|
+
// PostgreSQL
|
|
145
|
+
"ERROR.*statement timeout",
|
|
146
|
+
"ERROR.*lock timeout",
|
|
147
|
+
"ERROR.*deadlock detected",
|
|
148
|
+
// MySQL
|
|
149
|
+
"Lock wait timeout exceeded",
|
|
150
|
+
"Deadlock found when trying to get lock",
|
|
151
|
+
// MongoDB
|
|
152
|
+
"operation exceeded time limit",
|
|
153
|
+
"cursor id.*not found",
|
|
154
|
+
// Redis
|
|
155
|
+
"SLOWLOG",
|
|
156
|
+
"ERR max number of clients reached",
|
|
157
|
+
// Elasticsearch
|
|
158
|
+
"search_phase_execution_exception.*timeout",
|
|
159
|
+
"circuit_breaking_exception",
|
|
160
|
+
// Java
|
|
161
|
+
"java\\.sql\\.SQLTimeoutException",
|
|
162
|
+
"QueryTimeoutException",
|
|
163
|
+
// Python
|
|
164
|
+
"QueryTimeout",
|
|
165
|
+
"StatementTimeout",
|
|
166
|
+
"OperationalError.*timeout"
|
|
167
|
+
].join("|"), "i");
|
|
168
|
+
const DISK_RE = new RegExp([
|
|
169
|
+
"no space left",
|
|
170
|
+
"disk full",
|
|
171
|
+
"disk pressure",
|
|
172
|
+
"ENOSPC",
|
|
173
|
+
"write failed",
|
|
174
|
+
"No space left on device",
|
|
175
|
+
"i/o error",
|
|
176
|
+
"I/O error",
|
|
177
|
+
// Kubernetes
|
|
178
|
+
"eviction.*disk",
|
|
179
|
+
"DiskPressure",
|
|
180
|
+
"ephemeral-storage",
|
|
181
|
+
// Python
|
|
182
|
+
"OSError.*No space left",
|
|
183
|
+
"IOError.*No space left",
|
|
184
|
+
// Java
|
|
185
|
+
"java\\.io\\.IOException.*No space left",
|
|
186
|
+
"DiskSpaceHealthIndicator",
|
|
187
|
+
// Go
|
|
188
|
+
"no space left on device",
|
|
189
|
+
"write.*no space"
|
|
190
|
+
].join("|"), "i");
|
|
191
|
+
const QUEUE_RE = new RegExp([
|
|
192
|
+
"queue full",
|
|
193
|
+
"queue depth",
|
|
194
|
+
"consumer lag",
|
|
195
|
+
"backlog",
|
|
196
|
+
"offset lag",
|
|
197
|
+
// Kafka
|
|
198
|
+
"TOPIC_AUTHORIZATION_FAILED",
|
|
199
|
+
"consumer group lag",
|
|
200
|
+
"OffsetOutOfRange",
|
|
201
|
+
"RecordTooLargeException",
|
|
202
|
+
"producer queue is full",
|
|
203
|
+
// RabbitMQ
|
|
204
|
+
"channel error.*RESOURCE_LOCKED",
|
|
205
|
+
"queue.*full",
|
|
206
|
+
"basic\\.nack",
|
|
207
|
+
// SQS / SNS
|
|
208
|
+
"QueueDoesNotExist",
|
|
209
|
+
"message retention",
|
|
210
|
+
"ApproximateNumberOfMessages",
|
|
211
|
+
// Redis Streams
|
|
212
|
+
"XADD.*MAXLEN",
|
|
213
|
+
"stream.*full",
|
|
214
|
+
// Celery / Sidekiq / Resque
|
|
215
|
+
"Queue length.*exceeded",
|
|
216
|
+
"Worker.*timeout"
|
|
217
|
+
].join("|"), "i");
|
|
218
|
+
const SVC_UNAVAIL_RE = new RegExp([
|
|
219
|
+
"service unavailable",
|
|
220
|
+
"503",
|
|
221
|
+
"upstream connect error",
|
|
222
|
+
"no healthy upstream",
|
|
223
|
+
"ECONNRESET",
|
|
224
|
+
"connection reset",
|
|
225
|
+
// Kubernetes / Envoy
|
|
226
|
+
"upstream request timeout",
|
|
227
|
+
"no endpoints available",
|
|
228
|
+
"ServiceUnavailable",
|
|
229
|
+
"circuit.*open",
|
|
230
|
+
"circuit breaker",
|
|
231
|
+
// AWS
|
|
232
|
+
"Service Unavailable",
|
|
233
|
+
"ServiceUnavailable",
|
|
234
|
+
"RequestExpired",
|
|
235
|
+
// HTTP clients
|
|
236
|
+
"ENOTFOUND",
|
|
237
|
+
"getaddrinfo.*ENOTFOUND",
|
|
238
|
+
"connect ETIMEDOUT"
|
|
239
|
+
].join("|"), "i");
|
|
240
|
+
function normalizeRuntimeFactMarkdown(markdown, service, timestamp = Date.now()) {
|
|
241
|
+
const events = [];
|
|
242
|
+
const errMatch = markdown.match(/\*\*(?:Error|Exception):\*\*\s*`?([^\n`]+)`?/);
|
|
243
|
+
const endpointMatch = markdown.match(/\*\*Failure Endpoint:\*\*\s*`([^`]+)`/);
|
|
244
|
+
const traceMatch = markdown.match(/\*\*Trace ID:\*\*\s*`([^`]+)`/);
|
|
245
|
+
const fileMatch = markdown.match(/\*\*(?:Failing Location|Local Code Context)\*\*\s*\(`([^:`)]+):(\d+)`\)/);
|
|
246
|
+
const errorMessage = errMatch?.[1]?.trim() ?? "unknown error";
|
|
247
|
+
const endpoint = endpointMatch?.[1] ?? "";
|
|
248
|
+
const traceId = traceMatch?.[1] ?? "";
|
|
249
|
+
const failingFile = fileMatch?.[1] ?? "";
|
|
250
|
+
const failingLine = fileMatch?.[2] ? parseInt(fileMatch[2], 10) : 0;
|
|
251
|
+
const baseAttrs = {
|
|
252
|
+
endpoint,
|
|
253
|
+
traceId,
|
|
254
|
+
...failingFile ? { file: failingFile } : {},
|
|
255
|
+
...failingLine ? { line: failingLine } : {}
|
|
256
|
+
};
|
|
257
|
+
if (DB_POOL_RE.test(markdown)) {
|
|
258
|
+
events.push({
|
|
259
|
+
kind: "db_connection_pool_exhausted",
|
|
260
|
+
timestamp,
|
|
261
|
+
service,
|
|
262
|
+
severity: "critical",
|
|
263
|
+
message: errorMessage,
|
|
264
|
+
attributes: baseAttrs,
|
|
265
|
+
source: "datadog"
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (OOM_RE.test(markdown)) {
|
|
269
|
+
events.push({
|
|
270
|
+
kind: "memory_pressure",
|
|
271
|
+
timestamp,
|
|
272
|
+
service,
|
|
273
|
+
severity: "critical",
|
|
274
|
+
message: errorMessage,
|
|
275
|
+
attributes: baseAttrs,
|
|
276
|
+
source: "datadog"
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (RATE_LIMIT_RE.test(markdown)) {
|
|
280
|
+
events.push({
|
|
281
|
+
kind: "rate_limit_cascade",
|
|
282
|
+
timestamp,
|
|
283
|
+
service,
|
|
284
|
+
severity: "high",
|
|
285
|
+
message: errorMessage,
|
|
286
|
+
attributes: baseAttrs,
|
|
287
|
+
source: "datadog"
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
if (CERT_RE.test(markdown)) {
|
|
291
|
+
events.push({
|
|
292
|
+
kind: "certificate_expiry",
|
|
293
|
+
timestamp,
|
|
294
|
+
service,
|
|
295
|
+
severity: "critical",
|
|
296
|
+
message: errorMessage,
|
|
297
|
+
attributes: baseAttrs,
|
|
298
|
+
source: "datadog"
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
if (SLOW_QUERY_RE.test(markdown)) {
|
|
302
|
+
events.push({
|
|
303
|
+
kind: "slow_query",
|
|
304
|
+
timestamp,
|
|
305
|
+
service,
|
|
306
|
+
severity: "high",
|
|
307
|
+
message: errorMessage,
|
|
308
|
+
attributes: baseAttrs,
|
|
309
|
+
source: "datadog"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
if (DISK_RE.test(markdown)) {
|
|
313
|
+
events.push({
|
|
314
|
+
kind: "disk_pressure",
|
|
315
|
+
timestamp,
|
|
316
|
+
service,
|
|
317
|
+
severity: "critical",
|
|
318
|
+
message: errorMessage,
|
|
319
|
+
attributes: baseAttrs,
|
|
320
|
+
source: "datadog"
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (QUEUE_RE.test(markdown)) {
|
|
324
|
+
events.push({
|
|
325
|
+
kind: "queue_backlog",
|
|
326
|
+
timestamp,
|
|
327
|
+
service,
|
|
328
|
+
severity: "high",
|
|
329
|
+
message: errorMessage,
|
|
330
|
+
attributes: baseAttrs,
|
|
331
|
+
source: "datadog"
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (SVC_UNAVAIL_RE.test(markdown)) {
|
|
335
|
+
events.push({
|
|
336
|
+
kind: "service_unavailable",
|
|
337
|
+
timestamp,
|
|
338
|
+
service,
|
|
339
|
+
severity: "critical",
|
|
340
|
+
message: errorMessage,
|
|
341
|
+
attributes: baseAttrs,
|
|
342
|
+
source: "datadog"
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (events.length === 0 && errorMessage !== "unknown error") {
|
|
346
|
+
events.push({
|
|
347
|
+
kind: "upstream_error",
|
|
348
|
+
timestamp,
|
|
349
|
+
service,
|
|
350
|
+
severity: "high",
|
|
351
|
+
message: errorMessage,
|
|
352
|
+
attributes: baseAttrs,
|
|
353
|
+
source: "datadog"
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
return events;
|
|
357
|
+
}
|
|
358
|
+
function normalizeOtlpSpan(attrs, timestamp = Date.now()) {
|
|
359
|
+
const service = attrs.service ?? attrs["k8s.pod.name"] ?? "unknown";
|
|
360
|
+
const isError = attrs.error === true || attrs.error === "true" || String(attrs["rpc.grpc.status_code"] ?? "") === "14" || String(attrs["rpc.grpc.status_code"] ?? "") === "8";
|
|
361
|
+
if (!isError) return [];
|
|
362
|
+
const events = [];
|
|
363
|
+
const dbSystem = attrs["db.system"];
|
|
364
|
+
const httpCode = Number(attrs["http.status_code"] ?? attrs["http.response.status_code"] ?? 0);
|
|
365
|
+
const grpcCode = Number(attrs["rpc.grpc.status_code"] ?? -1);
|
|
366
|
+
const msgSystem = attrs["messaging.system"];
|
|
367
|
+
const exType = attrs["exception.type"] ?? attrs["error.type"] ?? "";
|
|
368
|
+
const exMsg = attrs["exception.message"] ?? "";
|
|
369
|
+
const baseAttrs = {
|
|
370
|
+
service,
|
|
371
|
+
...attrs["http.url"] ?? attrs["url.full"] ? { endpoint: String(attrs["http.url"] ?? attrs["url.full"] ?? "") } : {},
|
|
372
|
+
...dbSystem ? { dbSystem } : {},
|
|
373
|
+
...exType ? { exceptionType: exType } : {}
|
|
374
|
+
};
|
|
375
|
+
if (dbSystem) {
|
|
376
|
+
const combinedText = `${exType} ${exMsg}`;
|
|
377
|
+
if (DB_POOL_RE.test(combinedText) || SLOW_QUERY_RE.test(combinedText)) {
|
|
378
|
+
const isPool = DB_POOL_RE.test(combinedText);
|
|
379
|
+
const isSlow = SLOW_QUERY_RE.test(combinedText);
|
|
380
|
+
events.push({
|
|
381
|
+
kind: isPool ? "db_connection_pool_exhausted" : "slow_query",
|
|
382
|
+
timestamp,
|
|
383
|
+
service,
|
|
384
|
+
severity: "critical",
|
|
385
|
+
message: exMsg || `${dbSystem} error: ${exType}`,
|
|
386
|
+
attributes: { ...baseAttrs, dbSystem },
|
|
387
|
+
source: "otlp"
|
|
388
|
+
});
|
|
389
|
+
if (isSlow && !isPool) {
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
events.push({
|
|
393
|
+
kind: "upstream_error",
|
|
394
|
+
timestamp,
|
|
395
|
+
service,
|
|
396
|
+
severity: "high",
|
|
397
|
+
message: exMsg || `${dbSystem} error`,
|
|
398
|
+
attributes: { ...baseAttrs, dbSystem },
|
|
399
|
+
source: "otlp"
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (httpCode === 429 || grpcCode === 8) {
|
|
404
|
+
events.push({
|
|
405
|
+
kind: "rate_limit_cascade",
|
|
406
|
+
timestamp,
|
|
407
|
+
service,
|
|
408
|
+
severity: "high",
|
|
409
|
+
message: `HTTP ${httpCode || "gRPC RESOURCE_EXHAUSTED"} from upstream`,
|
|
410
|
+
attributes: baseAttrs,
|
|
411
|
+
source: "otlp"
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
if (httpCode === 503 || httpCode === 502 || grpcCode === 14) {
|
|
415
|
+
events.push({
|
|
416
|
+
kind: "service_unavailable",
|
|
417
|
+
timestamp,
|
|
418
|
+
service,
|
|
419
|
+
severity: "critical",
|
|
420
|
+
message: `HTTP ${httpCode || "gRPC UNAVAILABLE"} \u2014 upstream service not responding`,
|
|
421
|
+
attributes: baseAttrs,
|
|
422
|
+
source: "otlp"
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (CERT_RE.test(exType) || CERT_RE.test(exMsg)) {
|
|
426
|
+
events.push({
|
|
427
|
+
kind: "certificate_expiry",
|
|
428
|
+
timestamp,
|
|
429
|
+
service,
|
|
430
|
+
severity: "critical",
|
|
431
|
+
message: exMsg || exType,
|
|
432
|
+
attributes: baseAttrs,
|
|
433
|
+
source: "otlp"
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (OOM_RE.test(exType) || OOM_RE.test(exMsg)) {
|
|
437
|
+
events.push({
|
|
438
|
+
kind: "memory_pressure",
|
|
439
|
+
timestamp,
|
|
440
|
+
service,
|
|
441
|
+
severity: "critical",
|
|
442
|
+
message: exMsg || exType,
|
|
443
|
+
attributes: baseAttrs,
|
|
444
|
+
source: "otlp"
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
if (msgSystem && (QUEUE_RE.test(exMsg) || QUEUE_RE.test(exType))) {
|
|
448
|
+
events.push({
|
|
449
|
+
kind: "queue_backlog",
|
|
450
|
+
timestamp,
|
|
451
|
+
service,
|
|
452
|
+
severity: "high",
|
|
453
|
+
message: exMsg || `${msgSystem} error: ${exType}`,
|
|
454
|
+
attributes: { ...baseAttrs, messagingSystem: msgSystem },
|
|
455
|
+
source: "otlp"
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
if (events.length === 0 && typeof attrs["duration_ms"] === "number" && attrs["duration_ms"] > 5e3) {
|
|
459
|
+
events.push({
|
|
460
|
+
kind: "downstream_latency_spike",
|
|
461
|
+
timestamp,
|
|
462
|
+
service,
|
|
463
|
+
severity: "high",
|
|
464
|
+
message: `Span duration ${attrs["duration_ms"]}ms exceeds 5s threshold`,
|
|
465
|
+
attributes: { ...baseAttrs, durationMs: attrs["duration_ms"] },
|
|
466
|
+
source: "otlp"
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return events;
|
|
470
|
+
}
|
|
471
|
+
function normalizeProcessExits(exits) {
|
|
472
|
+
return exits.filter((e) => e.exitCode !== 0 || e.reason === "oom").map((e) => {
|
|
473
|
+
const isOom = e.reason === "oom" || e.exitCode === 137;
|
|
474
|
+
return {
|
|
475
|
+
kind: isOom ? "oom_kill" : "pod_crash",
|
|
476
|
+
timestamp: e.timestamp,
|
|
477
|
+
service: e.process,
|
|
478
|
+
severity: "critical",
|
|
479
|
+
message: `\`${e.process}\` exited with code ${e.exitCode} (${e.reason}${e.signal ? ` \u2014 ${e.signal}` : ""})`,
|
|
480
|
+
attributes: {
|
|
481
|
+
process: e.process,
|
|
482
|
+
exitCode: e.exitCode,
|
|
483
|
+
reason: e.reason,
|
|
484
|
+
...e.signal ? { signal: e.signal } : {},
|
|
485
|
+
...e.memoryLimitBytes ? { memoryLimitMb: Math.round(e.memoryLimitBytes / 1048576) } : {}
|
|
486
|
+
},
|
|
487
|
+
source: "process"
|
|
488
|
+
};
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function normalizeSlackContext(threadText, service, firedAt) {
|
|
492
|
+
const trimmed = threadText.trim();
|
|
493
|
+
if (!trimmed) return [];
|
|
494
|
+
return [{
|
|
495
|
+
kind: "slack_context",
|
|
496
|
+
timestamp: firedAt,
|
|
497
|
+
service,
|
|
498
|
+
severity: "high",
|
|
499
|
+
message: `[Slack channel context around incident]
|
|
500
|
+
${trimmed.slice(0, 3e3)}`,
|
|
501
|
+
attributes: {
|
|
502
|
+
source_type: "slack_channel_history",
|
|
503
|
+
char_count: trimmed.length
|
|
504
|
+
},
|
|
505
|
+
source: "slack"
|
|
506
|
+
}];
|
|
507
|
+
}
|
|
508
|
+
export {
|
|
509
|
+
normalizeOtlpSpan,
|
|
510
|
+
normalizeProcessExits,
|
|
511
|
+
normalizeRuntimeFactMarkdown,
|
|
512
|
+
normalizeSlackContext
|
|
513
|
+
};
|