Skip to main content

Module failure_template

Module failure_template 

Source
Expand description

Turns a tool’s error message into a template that is safe to report.

The approach follows crash-reporting scrubbers (Sentry’s PII scrubbing, VS Code’s telemetry path cleaning), but is stricter: instead of removing what looks sensitive, only LeanCTX’s own static wording survives. A word is kept only when it is in vocabulary::VOCABULARY, the words LeanCTX’s error messages are written in; everything else becomes a placeholder:

  • quoted text → ‹str›, URLs → ‹url›, e-mail addresses → ‹email›
  • a path, from its first segment through its end, spaces included, and file names → ‹path›
  • numbers and anything containing a digit → ‹n›
  • identifiers (camelCase, snake_case, ::, long tokens) → ‹sym›, except LeanCTX’s own tool and parameter names
  • any other word (not LeanCTX’s wording, or not ASCII) → ‹text›

A template without plain words, or with characters outside a small safe set, is dropped entirely; only the failure class is reported then.

Constants§

MAX_TEMPLATE_CHARS
Longest template that is reported.

Functions§

message_template
The reportable template of an error message, or None when nothing safe and meaningful is left.