/** * anti-jargon-prose — pure helpers that strip / rewrite agent-internal * vocabulary out of user-visible prose fields on chassis envelopes. * * WHY THIS EXISTS * * The chassis serves two audiences: * 1. The agent (LLM doing tool selection + branching) — needs * structured fields like `decisions.threshold_basis`, raw PromQL * refs, `phase_gap`, `n_anchor_buckets`, etc. * 2. The user (reads what the agent surfaces) — needs plain English. * * The chassis fields meant for the user (`headline`, `human_summary`, * `must_render_verbatim`) otherwise leak agent-internal vocabulary * verbatim, including raw PromQL in markdown the user reads. * * This module gives every chassis-emitting tool a pure * `sanitizeUserProse()` it can run on a string before serialization. * It is intentionally a string-in / string-out function with no * side effects, so it can be applied at envelope-build time * (`buildChassisEnvelope`) without needing per-tool plumbing. * * RULES ENFORCED * * - CLAUDE.md anti-data-science rule: * ban "candidate", "anchor", "co-mover", "phase_gap", * "noise floor", "clean-chain threshold", "Pearson", "@lag", * "unvalidated_default" (as user-facing string), * "evaluated" / "could not be evaluated", * "env total" / "env patterns" / "env-scoped". * - "SIEM" → "source". * - raw PromQL → descriptor. * - "sentinel" → "placeholder marker", * "dispatched" → "ran", "asserts" → "checks", * "e2e probe" → "end-to-end check". * - pattern_hash (11-char base64url) stripped from * user-visible prose via `stripHashFromVisible`. * * DEFERRED * * - Fuzzy-match + session-cache layer for pattern references * (rank / free-text) lives in a separate module * (`pattern-reference-resolver.ts`). * - Per-tool prose rewrites (chassis-prose contract migration) — done * incrementally in each tool's executor; this module is the * foundational filter, not a replacement for plain-English authoring. */ /** * Strip / rewrite banned agent-vocabulary out of user-visible prose. * * Pure function. Input string in, sanitized string out. No side effects. * Empty / null-ish input returns the input unchanged. * * Apply this to `headline`, `human_summary`, `must_render_verbatim`, * and any other user-eye-facing string before envelope serialization. * Apply BEFORE `stripHashFromVisible` if both are needed — banned-phrase * rewrites can introduce or reveal hash-like substrings only in * pathological cases, but the deterministic order keeps results * predictable. * * @param text The raw user-prose string a tool authored. * @returns The cleaned string, ready for serialization. */ export declare function sanitizeUserProse(text: string): string; /** * Strip 11-char base64url tokens (pattern hashes) from a user-visible * string. The rule: * "Never put pattern_hash in user-facing headlines — hashes confuse * users; lead with pattern name + service + state." * * The default regex is `PATTERN_HASH_REGEX` from `anchor-promql.ts` * (the canonical 10x pattern-hash shape). Callers can pass a different * regex to strip a related identifier shape (e.g. a 16-hex template * hash) — but the default covers the common case. * * Strategy: * - Inline-code wrapped (`abc12345678`) hashes → removed including the * backticks, which would otherwise leave empty `` `` `` artefacts. * - Bare 11-char tokens flanked by word boundaries → removed. * - Trailing whitespace and punctuation orphans from the removal are * normalized in a final pass. * * Pure function; no side effects. * * @param text The raw user-prose string. * @param hashRegex Optional override. Must include a single token * pattern; defaults to PATTERN_HASH_REGEX. * @returns The string with hashes stripped. */ export declare function stripHashFromVisible(text: string, hashRegex?: RegExp): string;