#loom-sprint-scaffold
147 files tagged loom-sprint-scaffold.
Wrangler
{ "$schema": "node_modules/wrangler/config-schema.json", "name": "loom", "main": "src/index.ts", "account_id": "…
Tsconfig
{ "compilerOptions": { "target": "ES2022", "module": "ES2022", "moduleResolution": "Bundler", "lib": […
Readme
# LOOM — Multi-Loop Cybernetic Orchestrator Sprint 0 scaffold per **LOOM-SPEC-001**. Cybernetics in the harness, never …
Package
{ "name": "loom", "version": "0.1.0", "private": true, "description": "LOOM — Multi-Loop Cybernetic Orchestrator…
2026 06 10 123000 Review Agent Logic Full
▐▛███▜▌ Claude Code v2.1.170 ▝▜█████▛▘ Fable 5 · Claude Pro ▘▘ ▝▝ ~/leverage-loops-projects/loom-sprint-scaffold…
2026 06 10 120524 Proceed This Is Where We Left Off
▐▛███▜▌ Claude Code v2.1.170 ▝▜█████▛▘ Fable 5 · Claude Pro ▘▘ ▝▝ ~/leverage-loops-projects/loom-sprint-scaffold…
Drizzle.Config
import type { Config } from "drizzle-kit"; /** * Drizzle is the typed query layer over D1 (src/db/schema.ts). * Migra…
0001 Init
-- LOOM 0001_init — 7 core tables + FTS5 + append-only enforcement. -- Identical on local workerd (--local) and edge D1 …
Parity
# LOOM Parity Gate The parity gate ensures that the monitor decision path produces **byte-identical output** across con…
Ship Summary Loom V1 2026 06 10
--- title: LOOM v1 Ship Summary category: ship-summary created: 2026-06-10 repo: /home/mikes/leverage-loops-projects/loo…
Metadata
SQLite format 3 @ .~X …
Metadata
�- _P3bv�e���ҷ��R�S%r �d�- _P3bv�e���ҷ��R�S%r �d ������������ …
Metadata
7� -� ���ҷ��R�����T� ���ҷ��Ru5�i�u|SQLite format 3 @ …
Metadata
SQLite format 3 @ .~X …
Metadata
�- ~E�o���i����5�0V?��- ~E�o���i����5�0V?� ������������ …
Metadata
7� -� �i����Эl�=t1 �i������/Z�ThMSQLite format 3 @ …
Metadata
SQLite format 3 @ .~X …
Metadata
�- ��u�]��?<#�'����&�YY�- ��u�]��?<#�'����&�YY ������������ …
Metadata
7� -� �?<#�'��#B�I20M �?<#�'��ь�SQLite format 3 @ …
Metadata
SQLite format 3 @ .~X …
Metadata
�- �a����*-��֊�H�����,�- �a����*-��֊�H�����, ������������ …
Metadata
7� -� *-��֊�T�0=� �r *-��֊�QL��F'l�SQLite format 3 @ …
Retry.Test
import { describe, expect, test } from "bun:test"; import { withRetry } from "../src/lib/retry"; import { RetryExhausted…
Tsconfig
{ "extends": "../tsconfig.json", "compilerOptions": { "types": ["bun-types", "@cloudflare/workers-types"], "…
Ids.Test
import { describe, expect, test } from "bun:test"; import { actionHash, canonicalJSON, dispatchId, newEventId, newGoalId…
Contracts.Test
import { describe, expect, test } from "bun:test"; import { parseContract, checkContract, isContractName } from "../src/…
Budget Governor.Test
/** * Tests for budget-governor (H3.6). * * Proves: * - all 3 hard cap types (calls, tokens, wallclock) are enforced…
Reinjector.Test
/** * Tests for reinjector (H3.4). * * Proves: * - normalizeObservation truncates content exceeding obs_cap_tokens …
Model Client.Test
/** * Tests for model-client (H3.0). * * Proves: * - createAnthropicModelCaller returns a callable ModelCaller * - …
Reversibility Gate.Test
/** * Tests for reversibility-gate (H3.3). * * Proves: * - allowlist lookup accepts allowed tools and denies unknown…
Conf Monitor.Test
/** * Tests for conf-monitor (H3.5). * * Proves: * - extractConf finds trailing JSON line `{"conf": 0.8}` in assista…
Harness.Test
/** * Integration tests for harness (runStage). * * Proves every StageTermination kind is reachable: * DONE | GATE_R…
Preflight.Test
/** * Tests for preflight (H3.7). * * Proves: * - clean files (no markers) pass * - every marker (TODO, FIXME, <<<<…
Ack Gate.Test
/** * Tests for ack-gate (H3.1). * * Proves: * - wrapResult produces deterministic hex hash from tool result * - ch…
Loop Detector.Test
/** * Tests for loop-detector (H3.2). * * Proves: * - the identical action halts at exactly the 3rd occurrence (not …
Dataset Emitter.Test
/** * Tests for H5.6 — Dataset Emitter. * * Proves: * - extractDatasetTuples extracts (failure_pattern, root_cause…
Fixtures
/** * Synthetic trace corpus for Loop 5 synthesis tests. * ~50 enriched trace events covering failures, successes, rep…
Failure Clusterer.Test
/** * Tests for H5.1 — Failure Clusterer. * * Proves: * - normalizeErrorSignature strips ids, paths, numbers deter…
Skill Proposer.Test
/** * Tests for H5.2 — Skill Proposer. * * Proves: * - extractSuccessfulSequences groups tool calls by dispatch *…
Registry Updater.Test
/** * Tests for H5.3 — Registry Updater. * * Proves: * - computeModeStats groups correctly by (model, harnessProfi…
Report.Test
/** * Integration test for the full synthesis report pipeline. * * Proves: * - Synthetic trace corpus → determinis…
Entropy Monitors.Test
/** * Tests for H5.4 — Entropy Monitors. * * Proves: * - Shannon entropy computed correctly with natural log (hand…
Isolation.Test
/** * Isolation test for src/synthesis/. * * Enforces at the grep level: * 1. No import from src/orchestrator/, sr…
Revision Governor.Test
/** * Tests for H5.5 — Revision Governor. * * Proves: * - Caps proposals at maxSkillProposals (default 5) * - N…
Mode Registry.Test
/** * Tests for ModeRegistry (H2.1). * * Proves: * - unknown variety_class → highest-capability mode + variety_defic…
Envelope Compiler.Test
/** * Tests for EnvelopeCompiler (H2.2 + H2.3). * * Proves: * - compiled envelope validates against dispatch-envelop…
Probe Planner.Test
/** * Tests for ProbePlanner (H2.5). * * Proves: * - api_integration + no behavior model → probe prepended (recovera…
Dlq Escalator.Test
/** * Tests for DlqEscalator (H2.4). * * Proves: * - DLQ letter → escalation POST with correct payload (goal_id, sta…
Context Assembler.Test
/** * ContextAssembler tests (H4.1). * * Proves: * - Budget NEVER exceeded: table-driven over budgets {0, tiny, ex…
Compactor.Test
/** * Compactor tests (H4.5). * * Proves: * - Compactor output records all validate against memory-record.schema.j…
Scope Wall.Test
/** * ScopeWall tests (H4.3). * * Proves: * - Same-scope read works (constructor requires scope) * - Cross-scop…
Helpers
/** * Test helpers for memory module tests. * * Provides: * - FakeD1: in-memory SQLite (bun:sqlite) implementing D…
Pointer Hierarchy.Test
/** * PointerHierarchy tests (H4.4). * * Proves: * - memory_expand round-trips: put full text in fake BlobStore → …
Promotion Engine.Test
/** * PromotionEngine tests (H4.2). * * Proves: * - Promotion fires at EXACTLY m_promote distinct traces (not m-1;…
Semantic Index.Test
/** * SemanticIndex contract test suite. * * Shared tests run against BOTH Fts5Index (with fake D1/SQLite) and * Vec…
No Silent Failure.Test
/** * No-Silent-Failure Invariant Walk. * * For EVERY terminated (non-DONE) stage across all golden runs + chaos runs…
Chaos.Test
/** * Chaos Tests — fault injection, one scenario per test. * * Five scenarios: * 1. dropped-tool-result — ack gat…
Golden.Test
/** * E2E Golden Goal Tests. * * Runs all three golden goals end-to-end through all LOOM loops. * Each asserts: * …
Chaos Scenarios
/** * Shared chaos scenario runners used by both chaos.test.ts and * no-silent-failure.test.ts. Lives outside *.test.t…
Golden Runner
/** * E2E Golden Runner — in-process composition root for LOOM integration tests. * * Wires Loop 1 (CheckpointEngine,…
Index
/** Barrel for golden goal scripts. */ export { script as codegenScript, assert as assertCodegen } from "./codegen"; ex…
Research
/** * Golden goal: research — mid-goal failing stage drives fail_streak to m=3 → REFORMULATE → recovers → completes. *…
Codegen
/** * Golden goal: codegen — multi-stage code-generation goal. * * All stages pass done-criteria; the goal completes …
Data Pipeline
/** * Golden goal: data_pipeline — destructive step requires approval token (mint → verify path). * * Stages: * 1.…
Fakes
/** * Shared fake implementations for LOOM E2E tests. * * Consolidates patterns from: * tests/orchestrator/checkpo…
Dispatch Envelope
{ "dispatch_id": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", "stage_id": "stg_a1b2c3d4e5f6",…
Goal State
{ "goal_id": "goal_a1b2c3d4e5f6", "original_spec": "Rebuild oregonsmbdirectory.com category pages with JSON-LD on As…
Execution Trace
{ "event_id": "evt_a1b2c3d4e5f6", "dispatch_id": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",…
Memory Record
{ "record_id": "mem_a1b2c3d4e5f6", "scope": "execution", "level": "semantic", "topic": "astro-jsonld-phantom-bug…
Stage Spec
{ "stage_id": "stg_a1b2c3d4e5f6", "goal_id": "goal_a1b2c3d4e5f6", "objective": "Generate JSON-LD LocalBusiness sch…
Dispatch Envelope.Bad Reversibility
{ "dispatch_id": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", "stage_id": "stg_a1b2c3d4e5f6",…
Memory Record.Bad Scope
{ "record_id": "mem_a1b2c3d4e5f6", "scope": "global", "level": "semantic", "topic": "t", "summary": "s", "cr…
Goal State.Bad Status
{ "goal_id": "goal_a1b2c3d4e5f6", "original_spec": "x", "spec_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b…
Stage Spec.Bad Predicate Kind
{ "stage_id": "stg_a1b2c3d4e5f6", "goal_id": "goal_a1b2c3d4e5f6", "objective": "Done criterion uses a non-machine-…
Goal State.Bad Id
{ "goal_id": "goal_TOOSHORT", "original_spec": "x", "spec_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822c…
Dispatch Envelope.Bad Dispatch Id
{ "dispatch_id": "not-a-sha256", "stage_id": "stg_a1b2c3d4e5f6", "goal_id": "goal_a1b2c3d4e5f6", "attempt": 1, …
Memory Record.Extra Prop
{ "record_id": "mem_a1b2c3d4e5f6", "scope": "execution", "level": "semantic", "topic": "t", "summary": "s", …
Stage Spec.Empty Done
{ "stage_id": "stg_a1b2c3d4e5f6", "goal_id": "goal_a1b2c3d4e5f6", "objective": "Stage with no verifiable completio…
Execution Trace.Bad Kind
{ "event_id": "evt_a1b2c3d4e5f6", "dispatch_id": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",…
Execution Trace.Bad Conf
{ "event_id": "evt_a1b2c3d4e5f6", "dispatch_id": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",…
Escalation Ledger.Test
/** * Tests for EscalationLedger (H1.4). * * Proves: * - fail_streak increment/reset * - escalation records append-…
Drift Sentinel.Test
/** * Tests for DriftSentinel (H1.6). * * Proves: * - single spike does NOT raise sustained drift * - sustained div…
Predicates.Test
/** * Tests for predicate evaluators (H1.1). * All six kinds: pass + fail cases each. * Injects a scripted PredicateR…
Checkpoint.Test
/** * Tests for CheckpointEngine (H1.1 + H1.4). * * Proves: * - scripted fake stage results drive fail_streak to EXA…
Decomposer.Test
/** * Tests for decomposer (H1.3). * * Proves: * - rejects non-machine-evaluable done_criteria with the specific vio…
Token Mint.Test
/** * Tests for TokenMint (H1.5). * * Proves: * - mint → Loop 3 verify passes (round-trip) * - expired tokens fail …
Parity Check
#!/usr/bin/env bun /** * Parity Check — byte-stable decision log for LOOM monitor decision path. * * Replays a script…
Approve Skills
#!/usr/bin/env bun /** * Approval CLI for skill proposals. * * This is OPERATOR TOOLING — a bun script, NOT workerd c…
Index
import { drizzle } from "drizzle-orm/d1"; import { dispatches, traceEvents } from "./db/schema"; import { checkContract,…
Stage Spec.Schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://leverageai.network/schemas/loom/stage-spec.j…
Dispatch Envelope.Schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://leverageai.network/schemas/loom/dispatch-env…
Memory Record.Schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://leverageai.network/schemas/loom/memory-recor…
Goal State.Schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://leverageai.network/schemas/loom/goal-state.j…
Execution Trace.Schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://leverageai.network/schemas/loom/execution-tr…
Loop Detector
/** * H3.2 — Loop Detector: actionHash(tool, args) via src/lib/ids.ts; * ring buffer W=10; ≥3 identical in window → HA…
Preflight
/** * H3.7 — Preflight: before any recoverable|destructive action, scan a provided * list of staged file contents for …
Budget Governor
/** * H3.6 — Budget Governor: hard caps B_tokens / B_calls / B_wallclock_ms from * the envelope. Breach → graceful sus…
Conf Monitor
/** * H3.5 — Confidence Monitor: every assistant turn must include conf ∈ [0,1] * (schema-enforced; extract from a tra…
Reinjector
/** * H3.4 — Reinjector: normalize observations. Truncate to per-tool obs_cap_tokens * from the envelope; store full t…
Reversibility Gate
/** * H3.3 — Reversibility Gate: every tool call checked against the envelope * allowlist. Each allowlist entry has re…
Model Client
/** * H3.0 — Fetch-based Anthropic Messages API client. * workerd-compatible: plain fetch, NO node SDK, no node:* impo…
Ack Gate
/** * H3.1 — Ack Gate: wrap every tool result with obs_hash; enforce that the * NEXT assistant turn begins with `<ack …
Harness
/** * H3 — Harness: runStage(envelope, modelCaller, deps): Promise<StageResult> * composing all monitors around the to…
Index
/** * Loop 5 — Synthesis batch glue. * * Thin scheduled() handler that wires injectables from the worker's Env * int…
Entropy Monitors
/** * H5.4 — Entropy Monitors. * * Queries entropy H(q) (dispatch outcome entropy) and H(s) (source/variety_class * …
Registry Updater
/** * H5.3 — Registry Updater. * * Recomputes mode_registry success_n / fail_n / avg_cost_tokens per * (mode, variet…
Dataset Emitter
/** * H5.6 — Dataset Emitter. * * Exports (failure_pattern, root_cause_signature, successful_intervention) * tuples …
Report
/** * Synthesis Report Assembler. * * Orchestrates all Loop 5 monitors (H5.1–H5.6) into a single SynthesisReport: * …
Revision Governor
/** * H5.5 — Revision Governor. * * Hard caps on skill proposals per window (tunable, default 5). * Tunable-paramete…
Skill Proposer
/** * H5.2 — Skill Proposer. * * Detects recurring successful sub-sequences across ≥ N distinct goals * (tunable, de…
Failure Clusterer
/** * H5.1 — Failure Clusterer. * * Groups trace failures by (tool, normalized error signature, variety_class). * Er…
Index
/** * Loop 2 dispatcher — thin worker-side barrel + concrete wire-ups. * * All logic lives in src/dispatcher/core/ (p…
Registry Seed
/** * Seed data for the mode_registry D1 table. * * Three modes covering the spec's default model set, with typed see…
Mode Registry
/** * H2.1 — D1-backed mode registry. * * selectMode(variety_class) picks the mode with highest success rate for that…
Types
/** * Injectable interfaces for the Loop 2 dispatcher core. * * Every dependency is an interface so tests inject fake…
Envelope Compiler
/** * H2.2 + H2.3 — Envelope Compiler. * * compile(stage, mode, opts): DispatchEnvelope * - Tool allowlist: only the…
Probe Planner
/** * H2.5 — Probe Planner. * * For stages with variety_class === "api_integration" AND no management-scope * behavi…
Dlq Escalator
/** * H2.4 — DLQ Escalator. * * Converts a dead letter into a Loop 1 escalation: * - builds typed escalation payload…
Index
/** * Loop 4 — Memory Service: thin worker shell. * * Factory: pick VectorizeIndex when env.SEMANTIC binding present,…
Pointer Hierarchy
/** * H4.4 — Pointer Hierarchy. * * topic → summary → episodic_ref (R2 key). * * memoryExpand(record_id): resolve e…
Promotion Engine
/** * H4.2 — Promotion Engine. * * episodic → semantic: when a pattern recurs across ≥ m_promote distinct traces. * …
Scope Wall
/** * H4.3 — Scope Wall. * * All reads/writes carry a required scope. Default read path filters to the * caller's sc…
Semantic Index
/** * H4.6 — SemanticIndex: search abstraction with two implementations. * * VectorizeIndex — wraps Cloudflare Vecto…
Compactor
/** * H4.5 — Compactor: summarize raw working context into semantic MemoryRecords. * * compactStage(goal_id, stage_id…
Context Assembler
/** * H4.1 — Context Assembler. * * assembleContext({scope, goal_id, query, token_budget}): * 1. Query SemanticIndex…
Index
/** Barrel — import all LOOM types from "@/types" or relative "../types". */ export * from "./contracts"; export * from …
Env
import type { DispatchEnvelope } from "./contracts"; /** Worker bindings — must match wrangler.jsonc exactly. */ export…
Contracts
/** * TypeScript mirrors of the 5 LOOM contracts (src/contracts/*.schema.json). * The JSON Schemas are the source of t…
Errors
/** Typed error hierarchy — never throw bare Error, never swallow. */ export abstract class LoomError extends Error { …
Synthesis
/** * Loop 5 synthesis types — report shapes, interfaces, contract-style types. * * All Loop 5 outputs are typed here…
Execution
/** * Execution harness types — Loop 3: model client, monitors, stage result. * All new execution types go here; barre…
Memory
/** * Memory service types — Loop 4. * * Injectables: BlobStore, SemanticIndex, Clock, TokenCounter. * D1DatabaseLik…
Schema
import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core"; /** * 7-table D1 schema — mirrors LOOM-SP…
Retry
import { RetryExhaustedError } from "../types/errors"; /** * Exponential backoff with FULL jitter (HC-6): delay = rand…
Ids
/** * Identity + hashing primitives shared by every loop. * Web Crypto only — identical behavior on workerd and Bun (H…
Logger
/** * Structured logger. The single sanctioned sink for log output — * bare console.log in logic paths is a lint-level…
Hmac
/** * HMAC utilities shared by Loop 1 (token-mint) and Loop 3 (reversibility-gate). * WebCrypto only — workerd-compati…
Validate
import { Ajv, type ValidateFunction } from "ajv"; import addFormats from "ajv-formats"; import { ContractViolationError …
Do
import { drizzle } from "drizzle-orm/d1"; import { goals } from "../db/schema"; import { parseContract } from "../lib/va…
Types
/** * Injectable interfaces for LOOM Loop 1 orchestration core. * Every dependency is an interface so tests can inject…
Predicates
/** * H1.1 — Predicate evaluators for the six machine-evaluable predicate kinds. * * Each takes a Predicate spec + an…
Escalation Ledger
/** * H1.4 — Escalation ledger for per-stage fail_streak persistence and * escalation records. Append-only records are…
Index
/** * Barrel — all core orchestration classes and types. */ export { type PredicateEvaluation, evaluatePredicate, eva…
Drift Sentinel
/** * H1.6 — Drift Sentinel: embed last N stage summaries, compare cosine distance * against the original_spec embeddi…
Checkpoint
/** * H1.1 + H1.4 — The alarm-tick sequence: assemble current GoalState, * evaluate active stage done-criteria predica…
Decomposer
/** * H1.3 — Decompose a goal spec into a sequence of StageSpec[] via a single * model call. Each StageSpec is validat…
Token Mint
/** * H1.5 — HMAC single-use, stage-scoped, TTL'd approval tokens for destructive * actions. WebCrypto only. * * Tok…