Conf Monitor

loom-sprint-scaffoldsourcetypescript
Path: loom-sprint-scaffold/loom/src/execution/conf-monitor.tsRelative: loom/src/execution/conf-monitor.tsSubproject: loom-sprint-scaffoldCategory: other
Lines: 108Bytes: 3,011Imports: 3Exports: 7

Content Preview

  1. /**
  2. * H3.5 — Confidence Monitor: every assistant turn must include conf ∈ [0,1]
  3. * (schema-enforced; extract from a trailing JSON line `{"conf": 0.8}` in the turn).
  4. * EWMA α=0.4; EWMA < 0.40 for 5 consecutive steps → emit kind=escalation,
  5. * reason=ESCALATE_CONFIDENCE, stop the stage.
  6. */
  7. import { newEventId } from "../lib/ids";
  8. import { createLogger } from "../lib/logger";
  9. import type { ExecutionTraceEvent, Sha256Hex } from "../types/execution";
  10. const ALPHA = 0.4;
  11. const THRESHOLD = 0.40;
  12. co