diff --git a/docs/operations/ingest-hardening-runbook.md b/docs/operations/ingest-hardening-runbook.md index 92f2d59..9cbd0f5 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`, CRM `/smoke/crm.php` direct-forward `BIT-SMOKE-CRM-DIRECT-FWD`) — those are skipped at every level (`rule_id`: `bitreport_smoke_marker`). Matching treats unicode hyphen/minus characters as ASCII `-` (ruleset **1.0.5+**). 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`. +- **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`, CRM `/smoke/crm.php` direct-forward `BIT-SMOKE-CRM-DIRECT-FWD`) — those are skipped at every level (`rule_id`: `bitreport_smoke_marker`). Matching treats unicode hyphen/minus characters as ASCII `-` (ruleset **1.0.5+**). 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`. Hand-sent pipe-liveness probes referenced by a BIT task id — `BIT- smoke test` (bare) or `[BIT-] ... smoke test` (bracketed) — are likewise skipped at every level (ruleset **1.0.8+**, BIT-32681), aligning ingest with the fleet audit synthetic-event exclusion. ## Rate limits diff --git a/ingest-api/src/lib/noisePolicy.test.ts b/ingest-api/src/lib/noisePolicy.test.ts index 347bdc0..db8ea84 100644 --- a/ingest-api/src/lib/noisePolicy.test.ts +++ b/ingest-api/src/lib/noisePolicy.test.ts @@ -143,6 +143,54 @@ describe("evaluateNoise", () => { }); }); + it("matches bare 'BIT- smoke test' pipe-liveness probe (BIT-32681)", () => { + const _r = evaluateNoise({ + level: "error", + message: "BIT-32663 smoke test", + filePathHint: "", + }); + expect(_r).toEqual({ + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_intentional_smoke_event", + }); + }); + + it("matches bracketed '[BIT-] ... smoke test' probe (fleet-audit synthetic form)", () => { + const _r = evaluateNoise({ + level: "error", + message: "[BIT-30527] paperclip-chat pipe-liveness smoke test", + filePathHint: "", + }); + expect(_r).toEqual({ + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_intentional_smoke_event", + }); + }); + + it("suppresses 'BIT- smoke test' probe even at critical level", () => { + const _r = evaluateNoise({ + level: "critical", + message: "BIT-32663 smoke test", + filePathHint: "", + }); + expect(_r).toEqual({ + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_intentional_smoke_event", + }); + }); + + it("does not match a real error that merely contains 'smoke' without the BIT- probe shape", () => { + const _r = evaluateNoise({ + level: "error", + message: "Smoke detector sensor offline", + filePathHint: "", + }); + expect(_r).toEqual({ matched: false }); + }); + it("matches CRM deploy ingest live-check failure ribbon (BIT-931 family)", () => { const _r = evaluateNoise({ level: "critical", diff --git a/ingest-api/src/lib/noisePolicy.ts b/ingest-api/src/lib/noisePolicy.ts index 8da3e8c..fed121c 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.7"; +export const NOISE_RULESET_VERSION = "1.0.8"; export type NoiseEvaluation = | { matched: false } @@ -12,6 +12,15 @@ export type NoiseEvaluation = const _DEPLOY_INGEST_PROBE_MESSAGE = "BIT-SMOKE error hub ingest live check"; +/** + * Hand-sent pipe-liveness probes referenced by a BIT task id (e.g. `BIT-32663 smoke test` + * or `[BIT-30527] paperclip-chat pipe-liveness smoke test`). The fleet audit already + * treats the bracketed form as synthetic (`_SYNTHETIC_EVENT_RE`); ingest must agree so + * these probes do not open Error Loop issues. Matched at every severity, like `BIT-SMOKE-`. + * BIT-32681 / ERRCLUSTER a513bc4e4505. + */ +const _BIT_ID_SMOKE_PROBE_RE = /\[?BIT-\d+\]?\s+.*smoke test/i; + /** * CRM / editor copy-paste sometimes inserts unicode hyphens (U+2011 etc.) in the reserved * `BIT-SMOKE-` token; strip ZW* / BOM so probes still match `bitreport_smoke_marker` (BIT-933). @@ -155,6 +164,13 @@ export function evaluateNoise(input: { reason: "filtered_intentional_smoke_event", }; } + if (_BIT_ID_SMOKE_PROBE_RE.test(_msg) || _BIT_ID_SMOKE_PROBE_RE.test(_stack)) { + return { + matched: true, + ruleId: "bitreport_smoke_marker", + reason: "filtered_intentional_smoke_event", + }; + } const _sev = normalizeLevelToSeverity(input.level); if (_sev === "critical") { return { matched: false }; diff --git a/tools/paperclip/paperclip_fleet_error_reporting_audit_once.py b/tools/paperclip/paperclip_fleet_error_reporting_audit_once.py index 8e5c0a3..c8f72ba 100755 --- a/tools/paperclip/paperclip_fleet_error_reporting_audit_once.py +++ b/tools/paperclip/paperclip_fleet_error_reporting_audit_once.py @@ -43,7 +43,11 @@ from urllib.error import HTTPError, URLError # hand while investigating a "stale" finding, per BIT-30273/BIT-30527). These are real # hub rows but not production traffic — counting them as "fresh" masks genuine staleness # for as long as they remain the newest row for a slug. Excluded from freshness scoring. -_SYNTHETIC_EVENT_RE = re.compile(r"^\[BIT-\d+\]\s+\S+.*smoke test", re.IGNORECASE) +# Accepts both the bracketed form (`[BIT-30527] ... smoke test`) and the bare form +# (`BIT-32663 smoke test`), matching the ingest noise policy `_BIT_ID_SMOKE_PROBE_RE` +# (BIT-32681). Anchored to start so a real error mentioning the phrase mid-sentence is not +# misclassified. +_SYNTHETIC_EVENT_RE = re.compile(r"^\[?BIT-\d+\]?\s+.*smoke test", re.IGNORECASE) # --------------------------------------------------------------------------- # Env helpers