Budget Governor

loom-sprint-scaffoldsourcetypescript
Path: loom-sprint-scaffold/loom/src/execution/budget-governor.tsRelative: loom/src/execution/budget-governor.tsSubproject: loom-sprint-scaffoldCategory: other
Lines: 142Bytes: 3,640Imports: 3Exports: 7

Content Preview

  1. /**
  2. * H3.6 — Budget Governor: hard caps B_tokens / B_calls / B_wallclock_ms from
  3. * the envelope. Breach → graceful suspension: emit a state-summary MemoryRecord
  4. * (scope=execution, validated against memory-record contract) then stop.
  5. * Never kill mid-action — check BEFORE model calls and AFTER tool execution.
  6. */
  7. import { newMemoryId, newEventId } from "../lib/ids";
  8. import { createLogger } from "../lib/logger";
  9. import type {
  10. DispatchEnvelope,
  11. ExecutionTraceEvent,
  12. MemoryRecord,
  13. Sha25