Files
hack-house/cmd_chat/sor/analysis/__init__.py
T
leetcrypt 92da24dfe2 R7 (partial): offline detector calibration — entropy + bridge-correlation AUC
Land only the offline-validatable half of R7 (instrument-validation gate items
3 and 4): the detectors the gate calibrates on synthetic fixtures, never on
confirmatory-cell data. Pure stdlib functions over in-memory series — no pcaps,
no engine, no traffic, no VM fabric.

- analysis/detectors.py: shannon_entropy_bits (RQ2 anonymity-set entropy),
  pearson/score_matrix/auc/linkage_auc, bridge_correlation_auc (RQ1
  linkability scorer), and synthetic_bridge_fixture (seed-deterministic
  known-linked / known-unlinked ground truth via the R1 SorRng).

Calibration green: entropy returns exactly log2(N) for N equiprobable senders
(gate item 4); a known-linked control pair scores AUC=1.0 and the unlinked
estimator is unbiased at chance (ensemble mean over 40 seeds = 0.498 ~ 0.5,
gate item 3). Detectors are calibrated on synthetic fixtures only — no fitting.

The traffic-moving R7 pieces (churn.py VM spin/kill, live selector rebuild loop,
metrics.json emission) are HELD for R4/R6 + a live grid and are absent here.
Python SOR suite 66 passed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-19 16:47:56 -07:00

19 lines
1017 B
Python

"""R7 (partial) — offline analysis calibration primitives.
This package holds only the *offline-validatable* half of R7: the detectors that
the instrument-validation gate calibrates on **synthetic fixtures** (never on
confirmatory-cell data — CLAUDE.md build discipline). Specifically:
- ``detectors.shannon_entropy_bits`` — the RQ2 anonymity-set entropy metric; gate
item 4 requires it to return ``log2(N)`` for ``N`` equiprobable senders.
- ``detectors.bridge_correlation_auc`` — the RQ1 bridge-linkability scorer; gate
item 3 requires AUC ≈ 1 on a known-linked control pair and ≈ 0.5 on a
known-unlinked pair.
These are pure functions over in-memory series/distributions — they read no
pcaps, spawn no engine, move no traffic, and touch no VM fabric. The
traffic-moving R7 pieces (``churn.py`` seeded VM spin/kill; the live selector
rebuild loop; the confirmatory battery that writes ``metrics.json``) are NOT
here — they are HELD pending R4/R6 + a live grid (see OVERSEER-STATUS.md).
"""