Loop Detector

loom-sprint-scaffoldsourcetypescript
Path: loom-sprint-scaffold/loom/src/execution/loop-detector.tsRelative: loom/src/execution/loop-detector.tsSubproject: loom-sprint-scaffoldCategory: other
Lines: 96Bytes: 2,531Imports: 3Exports: 3

Content Preview

  1. /**
  2. * H3.2 — Loop Detector: actionHash(tool, args) via src/lib/ids.ts;
  3. * ring buffer W=10; ≥3 identical in window → HALT_LOOP.
  4. *
  5. * The stage fails fast and the trace event carries the repeated action hash.
  6. */
  7. import { actionHash, newEventId } from "../lib/ids";
  8. import { createLogger } from "../lib/logger";
  9. import type { ExecutionTraceEvent, Sha256Hex } from "../types/execution";
  10. const DEFAULT_WINDOW = 10;
  11. const REPEAT_THRESHOLD = 3;
  12. const log = createLogger({ component: "loop-detector" }