Conf Monitor

_archivesourcetypescript
Path: _archive/loom-stale-pre-sprint-snapshot/src/execution/conf-monitor.tsRelative: loom-stale-pre-sprint-snapshot/src/execution/conf-monitor.tsSubproject: _archiveCategory: archived
Lines: 40Bytes: 1,274Imports: 0Exports: 2

Content Preview

  1. /**
  2. * H3.5 — Confidence EWMA monitor (P5).
  3. * Each assistant turn must carry <conf>0.NN</conf>. EWMA(alpha=0.4) below
  4. * conf_min for 5 consecutive numeric readings → ESCALATE_CONFIDENCE:
  5. * stop grinding, surface to Loop 1.
  6. */
  7. const CONF_RE = /<conf>\s*(0(?:\.\d+)?|1(?:\.0+)?)\s*<\/conf>/;
  8. export function extractConf(text: string): number | null {
  9. const m = CONF_RE.exec(text);
  10. if (!m || !m[1]) return null;
  11. const v = Number(m[1]);
  12. return Number.isFinite(v) && v >= 0 && v <= 1 ? v : n