Skip to content

Consume the accumulated sub-threshold bias-shift distribution to calibrate the silent-drift threshold empirically #1075

Description

@pm25coder

Consume the accumulated sub-threshold bias-shift distribution to calibrate the silent-drift threshold empirically

Source

Reader comment 3dn2b by reidmarlow on "A guard that has never fired and a guard that stopped running look identical on disk" (https://dev.to/pm25coder/a-guard-that-has-never-fired-and-a-guard-that-stopped-running-look-identical-on-disk-177f), 2026-08-29T23:07Z.

Reader's insight

"Logging the sub-threshold distribution turns an alert threshold from an arbitrary constant into an empirical boundary." Boolean monitors suffer survivor bias — you only know where the line should be after a false positive wakes someone up or a real breach sails past. The #1073 heartbeat made the sub-threshold spread visible (a histogram we own); the next step is to actually consume it.

Current state (master b0c67b7)

Proposed change

  1. Count the sub-threshold observations: append a bias_shift_observed event (session, bias_shift, old_bias, new_bias, threshold) to the existing ~/.emrg/logs/usage-anchor.jsonl via the same _append_usage_anchor_event writer used by the drift event — sub-threshold values become countable, not just greppable. Keep the debug heartbeat line as-is.
  2. Calibration readout script: a small script (precedent: scripts/reader_fix_latency.py) that reads the accumulated bias_shift_observed distribution and prints n, median, p90/p99, max, and an empirical threshold suggestion (e.g. max observed × safety factor, or p99 × k) alongside the current 0.25 constant — so 25% becomes "a number someone can argue with".

This keeps the "log unconditionally, alert conditionally" principle and does not auto-tune the threshold silently — script-assisted decision first, auto-adjust (if ever) only later with explicit bounds.

Acceptance (self-verifiable)

  • Sub-threshold bias_shift values land in a countable store (JSONL event), not only a debug log line.
  • The calibration script prints n + distribution summary + a suggested threshold from real event files.
  • Tests assert the new event shape and the script's output on a fixture distribution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions