From 682f9cf5c8865f193526f1c8d7d392a36920f3ae Mon Sep 17 00:00:00 2001 From: Peter Spark Date: Sun, 5 Apr 2026 12:21:33 +0000 Subject: [PATCH] ingest: filter deploy ingest live-check failure ribbon (noise 1.0.4) The wdmi-store/CRM post-deploy probe reports failures with the exact message BIT-SMOKE error hub ingest live check, which did not match BIT-SMOKE- and opened hub incidents (BIT-931 / ERRCLUSTER churn). Treat it like other smoke traffic: skip at every level with bitreport_smoke_marker. Document in RUNBOOK_INGEST_DEBUG and ingest-hardening-runbook; add unit and integration coverage. Made-with: Cursor --- docs/RUNBOOK_INGEST_DEBUG.md | 2 +- docs/operations/ingest-hardening-runbook.md | 2 +- .../src/integration.twoProjects.test.ts | 36 +++++++++++++++++++ ingest-api/src/lib/noisePolicy.test.ts | 13 +++++++ ingest-api/src/lib/noisePolicy.ts | 13 ++++++- 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/docs/RUNBOOK_INGEST_DEBUG.md b/docs/RUNBOOK_INGEST_DEBUG.md index 1691d57..18511ca 100644 --- a/docs/RUNBOOK_INGEST_DEBUG.md +++ b/docs/RUNBOOK_INGEST_DEBUG.md @@ -18,7 +18,7 @@ 3. **Credentials:** `Authorization: Bearer ` or `X-Api-Key`; key must be **active** and **unexpired** in `er_ingest_keys` (§2). 4. **HTTP codes:** `401` / `429` / `5xx` / timeouts — use sections below; CRM cURL timeouts are short (e.g. 4s) — slow proxies can fail smokes before the hub responds. 5. **HTTP 400 from schema validation** should be rare; the hub ignores unknown **event-level** JSON keys and unknown **top-level** keys on the batch object (only `events` is required). Required per event: `schema_version`, `occurred_at`, `level`, `message`. -6. **Intentional throw smokes (`BIT-SMOKE-*`)** — some reporters POST a deliberate error (e.g. `BIT-SMOKE-WDMI-DIRECT-INGEST`) to prove the pipe works. The ingest API **noise-filters** these when `BIT-SMOKE-` appears in the event `message` or client `stacktrace` (`noise_ruleset_version` from `noisePolicy.ts`; see [ingest-hardening-runbook](operations/ingest-hardening-runbook.md)). Expect `skipped: true` / `rule_id: bitreport_smoke_marker` and **no** new incident. If [BIT-309](/BIT/issues/BIT-309) reopens a closed smoke ticket after the hub change merged, treat as **production ingest not yet running that build** ([BIT-942](/BIT/issues/BIT-942)). +6. **Intentional throw smokes (`BIT-SMOKE-*`)** — some reporters POST a deliberate error (e.g. `BIT-SMOKE-WDMI-DIRECT-INGEST`) to prove the pipe works. The ingest API **noise-filters** these when `BIT-SMOKE-` appears in the event `message` or client `stacktrace` (`noise_ruleset_version` from `noisePolicy.ts`; see [ingest-hardening-runbook](operations/ingest-hardening-runbook.md)). Expect `skipped: true` / `rule_id: bitreport_smoke_marker` and **no** new incident. The **deploy live-check failure** title `BIT-SMOKE error hub ingest live check` (exact message; uses a space, not `BIT-SMOKE-`) is filtered the same way from ruleset **1.0.4** onward so ERRCLUSTER loops on that signature stop once production runs the new build. If [BIT-309](/BIT/issues/BIT-309) still reopens after that deploy, treat as **stale nodes or a different root cause** ([BIT-942](/BIT/issues/BIT-942)). **After the root cause is fixed** diff --git a/docs/operations/ingest-hardening-runbook.md b/docs/operations/ingest-hardening-runbook.md index 8e3d2db..c6a915d 100644 --- a/docs/operations/ingest-hardening-runbook.md +++ b/docs/operations/ingest-hardening-runbook.md @@ -32,7 +32,7 @@ Per-key overrides: set `rate_limit_max` and/or `rate_limit_window_ms` on the key - Rules live in `ingest-api/src/lib/noisePolicy.ts`; ruleset id: `noise_ruleset_version` in the ingest response. - **Check:** send a known-noise payload (for example ResizeObserver message at non-fatal level); expect `skipped: true`, `noise_filtered_count` incremented, and no new `er_incidents` row. -- **Check:** send the same pattern at `fatal` / `critical` level; expect **not** skipped (noise rules do not hide critical), **except** when the **message** or **client-provided stacktrace** contains reserved substring `BIT-SMOKE-` (intentional reporter smoke, e.g. wdmi-store `/smoke/wdmi.js`, CRM `/smoke/crm-main.php`) — those are skipped at every level (`rule_id`: `bitreport_smoke_marker`). +- **Check:** send the same pattern at `fatal` / `critical` level; expect **not** skipped (noise rules do not hide critical), **except** when the **message** or **client-provided stacktrace** contains reserved substring `BIT-SMOKE-` (intentional reporter smoke, e.g. wdmi-store `/smoke/wdmi.js`, CRM `/smoke/crm-main.php`) — those are skipped at every level (`rule_id`: `bitreport_smoke_marker`). The exact deploy-probe failure ribbon `BIT-SMOKE error hub ingest live check` (space after `BIT-SMOKE`, see [RUNBOOK_INGEST_DEBUG.md](../RUNBOOK_INGEST_DEBUG.md) §0) is also skipped at every level with the same `rule_id`. ## Rate limits diff --git a/ingest-api/src/integration.twoProjects.test.ts b/ingest-api/src/integration.twoProjects.test.ts index 9bad604..63858e8 100644 --- a/ingest-api/src/integration.twoProjects.test.ts +++ b/ingest-api/src/integration.twoProjects.test.ts @@ -295,6 +295,42 @@ describe.skipIf(!_testUrl)("two-project passive ingest (BIT-179)", () => { expect(Number((after[0] as { c: number }).c)).toBe(_nBefore); }); + it("skips deploy ingest live-check failure ribbon without inserting rows", async () => { + const [before] = await _pool.execute( + `SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`, + [_projectIdA], + ); + const _nBefore = Number((before[0] as { c: number }).c); + const _res = await _app.inject({ + method: "POST", + url: "/v1/ingest/events", + headers: { authorization: `Bearer ${_tokenA}` }, + payload: { + events: [ + { + schema_version: 1, + occurred_at: "2026-04-05T10:10:00.000Z", + level: "critical", + message: "BIT-SMOKE error hub ingest live check", + }, + ], + }, + }); + expect(_res.statusCode).toBe(200); + const _body = JSON.parse(_res.body) as { + noise_filtered_count: number; + results: Array<{ skipped?: boolean; rule_id?: string }>; + }; + expect(_body.noise_filtered_count).toBe(1); + expect(_body.results[0]?.skipped).toBe(true); + expect(_body.results[0]?.rule_id).toBe("bitreport_smoke_marker"); + const [after] = await _pool.execute( + `SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`, + [_projectIdA], + ); + expect(Number((after[0] as { c: number }).c)).toBe(_nBefore); + }); + it("replays identical idempotent requests", async () => { const _payload = { events: [ diff --git a/ingest-api/src/lib/noisePolicy.test.ts b/ingest-api/src/lib/noisePolicy.test.ts index baf89a5..c90243a 100644 --- a/ingest-api/src/lib/noisePolicy.test.ts +++ b/ingest-api/src/lib/noisePolicy.test.ts @@ -115,4 +115,17 @@ describe("evaluateNoise", () => { reason: "filtered_intentional_smoke_event", }); }); + + it("matches wdmi-store / CRM deploy ingest live-check failure ribbon (BIT-931 family)", () => { + const _r = evaluateNoise({ + level: "critical", + message: "BIT-SMOKE error hub ingest live check", + filePathHint: "", + }); + expect(_r).toEqual({ + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_deploy_ingest_probe_failure", + }); + }); }); diff --git a/ingest-api/src/lib/noisePolicy.ts b/ingest-api/src/lib/noisePolicy.ts index f599602..3a315ee 100644 --- a/ingest-api/src/lib/noisePolicy.ts +++ b/ingest-api/src/lib/noisePolicy.ts @@ -4,7 +4,7 @@ import { normalizeLevelToSeverity } from "./normalize.js"; * Versioned ruleset id (document in release notes when rules change). * Rule inventory and validation steps: `docs/operations/ingest-hardening-runbook.md`. */ -export const NOISE_RULESET_VERSION = "1.0.3"; +export const NOISE_RULESET_VERSION = "1.0.4"; export type NoiseEvaluation = | { matched: false } @@ -130,6 +130,10 @@ const _RULES: NoiseRule[] = [ * Exception: reserved `BIT-SMOKE-` markers are intentional end-to-end probes (e.g. wdmi-store * `/smoke/wdmi.js`, CRM `/smoke/crm-main.php`) and are filtered at every ingest level so they do * not open incidents. Some PHP reporters put the marker only in `stack_trace`, not in `message`. + * + * Deploy probes also emit a fixed failure ribbon `BIT-SMOKE error hub ingest live check` (space, not + * hyphen) when the live ingest check fails — documented in `docs/RUNBOOK_INGEST_DEBUG.md` §0. Treat + * like other smoke traffic so ERRCLUSTER loops do not churn on that canonical title alone. */ export function evaluateNoise(input: { level: string; @@ -141,6 +145,13 @@ export function evaluateNoise(input: { }): NoiseEvaluation { const _msg = input.message.trim(); const _stack = (input.stackText ?? "").trim(); + if (_msg === "BIT-SMOKE error hub ingest live check") { + return { + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_deploy_ingest_probe_failure", + }; + } if (_msg.includes("BIT-SMOKE-") || _stack.includes("BIT-SMOKE-")) { return { matched: true,