Loop Detector
Path:
pi-cybernetic/src/monitors/loop-detector.tsRelative: src/monitors/loop-detector.tsSubproject: pi-cyberneticCategory: cybernetic-coreLines: 100Bytes: 3,235Imports: 2Exports: 2
Content Preview
- /** P5 — action-sequence loop detection over a sliding window. */
- import type { Escalation } from "../types/index.ts";
- import { shannonEntropy, stableStringify } from "../util.ts";
- export interface RecordedAction {
- toolName: string;
- args: unknown;
- }
- export class LoopDetector {
- private window: string[] = [];
- private detections = 0;
- /** Repetition count at the moment of the last detection. */
- private lastDetectionLatency = 0;
- /** Signature already escalated — suppresses duplicate