Sherlock · Moriarty Execution Engine

✨ Quinelings 2.0 Lifeforms Slideshow →

A small computer whose internal workings are intentionally visible.

Sherlock is the execution engine at the center of Moriarty. Instead of every loan, payment arrangement, or swap inventing its own execution machinery, Sherlock gives supported programs one common machine with one common meaning. A calculator only tells you that 40 − 30 = 10; Sherlock establishes which prepared program (ProgramImage) ran, what committed state (MachineImage) it began from, which of the 39 fixed machine rules fired on each step (StepRecord), and what fuel and stack limits applied — turning “follow the agreement” into an unbroken chain that a cryptographic proof can verify without trusting the solver that ran it.

01 · Instruction book, desk & bookmarks Nothing disappears into a hidden runtime stack.

Think of the prepared program (ProgramImage) as a fixed instruction book, current values as the contents of a desk, and saved function calls as bookmarks telling the machine where to return. At every step Sherlock keeps four things in plain view: what program is running, where execution currently is, what values and unfinished work it carries, and how much execution budget (fuel) remains permitted.

02 · Reading the six split-arc rings Outermost is oldest waiting work; innermost is the active frontier.

When fact(4) calls fact(3), it cannot multiply by 4 yet. It leaves two frames on the ring: Teal on the left (Slot A) saves the caller’s variables, and Gold on the right (Slot B) holds the waiting math 4 × [?] (Amber marks operands or arguments still in progress; Violet marks an open if, match, or let; Cyan marks a let scope). Rings fill from R1 inward to R6 and clear from the inside out as answers return.

03 · The 39 silicon floor modules (A080–A225) Every step fires exactly one physical rule module on the chamber floor.

Drop inside the chip via Inside Hollow Chip and look down at the chamber floor: those 39 gold-socketed 3D silicon chiplets are Sherlock’s complete transition table (sherlock-k-a/1). On each tick, the single rule governing that step (such as A135 PushFrame, A149 RightOp, or A080 Done) physically rises from its socket and lights its status bar while the prior step’s module glows in trail mode.

04 · Why every single step is counted Arithmetic alone is not authority — the path matters.

A final answer of 10 could conceal an unauthorized recipient, an inflated solver fee, or a skipped guard. The 10-sector center dial shows the active control state, the 39-rule floor proves which rule justified the transition, and the outer rim drains 1 unit of fuel per charged step so WitnessPlan and ConstraintPlan can lock the entire trace into a Midnight proof.

Program

moriarty-sherlock-draft/1 Line 1
1
200
16
Evaluating Eval(fact(4)) fact(4)
Drag to orbit · Pinch to zoom · 2-finger pan
Step 1 / 45 Space plays/pauses · ← → step
Camera view

Inspector

Rule A102
Status
Evaluating
Transition
1 / 45 Rule A102
Current control
Eval(fact(4))
Quineling Core
Nautilus Arithmeticus · logarithmic-mantle
Saved frames
0 · 0 of 6 rings
Active calls
0
Remaining fuel
200 / 200 · charge 1
6 Split-Arc Rings (West A | East B) & Control Stator 0/12 slots · CTRL: EVAL
ENV (Return / Scope) OP (Left·Args·Unary → Right) GATE (If / Match / Let)
Saved frames, top first 0 frames
Active calls Unfolding
01 · Delegation & Authority

Why Sherlock exists — Freedom to search vs. authority to spend

Suppose a Borrower owes a Lender 40 units under a Moriarty credit agreement that permits an external solver to execute installments of 5..40 units to Account_Lender with at most a 1-unit fee. If the solver proposes paying 30 units, a calculator can confirm that 40 − 30 = 10. But if the solver routes those 30 units to its own account (or Charlie) or claims a 3-unit fee, the subtraction is still 10 while the agreement’s authority is violated.

Sherlock separates a solver’s off-chain freedom to search from its on-ledger authority to settle. The owner’s agreement is frozen into a fingerprinted ProgramImage; Sherlock executes candidate inputs step by step under strict limits; and Midnight verifies the resulting proof without trusting the solver or exposing private witness data.

02 · State, Frames & Continuing Duties

The machinery inside Sherlock — Explicit frames & resumable state

Named functions stay fixed in the ProgramImage while the machine’s explicit state (Snapshot) advances one step at a time: current Control, immutable values (UInt128, Bool, List, Tree), lexical Environment, saved continuation frames, and remaining fuel. Entering a call saves caller bindings in Frame::Return; binary operators push Left([?] * rhs) and rewrite in-place to Right(4 * [?]) (Rule A149); Let rewrites in-place to Scope (Rule A145); and Args advances in-place (Rule A177).

In continuing agreements, Sherlock keeps four concepts distinct: finishing a computation (Done), completing an economic obligation (0 owed), saving a resumable agreement (packing 30 paid and 10 remaining into a committed MachineImage), and splitting proof work into chunks (ReferenceSlice). A failed tentative attempt in Stage 2 is discarded off-ledger without erasing Stage 1’s committed history.

03 · Spatial Hardware Mapping

How the 3D chip maps to the abstract machine

Central 10-Sector Dial & Outer Fuel Rim: The center stator lights the active Control state of sherlock-k-a/1 (EVAL, PUSH, RET, INVOKE, ENTER, BOUND, CASES, MATCH, PRIM, ERR) and aims its transfer needle West (Slot A) or East (Slot B) at the newest visible frame, while the 48-segment outer rim drains 1 unit of fuel per charged rule.

Six Concentric Split-Arc Rings (R1..R6) & Open Bore: Ordered chronologically from oldest waiting work at the perimeter (R1.A = frames[len − 1]) to the active frontier on the inside (frames[0]), each ring pairs two 180° half-arcs: Teal / Sky-Cyan for saved caller and let environments, Amber / Gold for pending operands (4 × [?]), and Violet for if, match, and let gates.

04 · Inside the Hollow Vault

The 39-rule decoder floor & the unbroken StepRecord chain

Switch the camera to Inside Hollow Chip or Cross-Section to inspect the 6 × 7 matrix of 39 physical 3D silicon rule modules (A080..A225) on the vault floor (y = −3.38). Instead of hiding interpreter logic in host software, sherlock-k-a/1 defines every legal transition as one of these 39 elementary rules across six categories.

On every tick, Sherlock emits a StepRecord and the justifying floor module physically rises out of its gold socket and lights its south-lip beacon, while the previous step’s module retains a decaying trail glow. That visible handoff represents the exact mathematical chain where Step[i].after == Step[i+1].before: the WitnessPlan arranges the private StepRecord values for the prover, and the ConstraintPlan enforces the fixed algebraic equations of the active rule.

Inside Hollow Chip · Vault Floor at y = −3.38

The 39-Rule Silicon Decoder Floor (sherlock-k-a/1) — What the 39 Floor Modules Are

When you enter Inside Chip (drag down or scroll down the vertical elevator) or view Cutaway, the floor of the chamber exposes 39 gold-bezeled 3D silicon rule modules arranged in 6 columns by 7 rows (with the SHERLOCK · K-A/1 · 39-RULE ROM plaque in the lower-right corner). Together, these 39 modules form Sherlock’s entire instruction set: every single transition in a recursive calculation or financial agreement must fire exactly one module from these six categories:

1. Terminal 0F 3 rules · Charge 0F · Indices 0–2

Free publication rules that convert a completed or halted control state into a public outcome without spending fuel.

A080 Done A082 Rejected A084 Exhausted
2. Expression Dispatch 1F 10 rules · Charge 1F · Indices 3–12

Inspects Control::Eval(expr). Leaves return immediately; compound expressions schedule a continuation frame via Push.

A102 Literal A108 VarFound A111 VarMissing (E3) A114 Let A117 BinLeft A120 Unary A123 If A126 Match A129 Call0 A131 CallArgs
3. Frame Stack Guard 1F 2 rules · Charge 1F · Indices 13–14

Checks frames.len() < stack_limit before shelving a waiting frame onto the split-arc rings, or halts with Error(4).

A135 PushFrame A140 FrameErr (E4)
4. Continuation Frame 1F 10 rules · Charge 1F · Indices 15–24

Handles Control::Return(v) meeting the top waiting frame: rewrites frames in-place (A145, A149, A177) or pops them to branch or compute.

A145 BindLet A149 RightOp A153 BinPrim A157 UnPrim A161 IfTrue A165 IfFalse A169 IfErr (E5) A173 StartCases A177 NextArg A181 FinishArgs
5. Function & Pattern 1F 12 rules · Charge 1F · Indices 25–36

Resolves function calls, isolates caller variables in Return frames, restores lexical scopes, and steps through List / Tree pattern arms.

A185 RetOk A190 RetErr (E6) A195 RestoreScope A200 LookupFn A202 MissingFn (E7) A204 BindParams A206 BindErr (E8) A208 SchedBody A212 NoMatchErr (E9) A214 TryPat A217 PatMiss A220 MatchBody
6. Primitive Op 1F 2 rules · Charge 1F · Indices 37–38

Commits 16-byte UInt128 arithmetic, comparison, and ADT constructor results verified by aux/2, or traps on checked overflow/underflow.

A223 PrimOk A225 PrimErr (E10/11)
Hardware-to-Machine Reference

How every formal component of sherlock-k-a/1 appears on the 3D die & Inspector

Sherlock Machine Component Conventional Analogue On This Page — Inspector & 3D Die
Control of sherlock-k-a/1 (Eval, Push, Return, Invoke, Enter, Bound, Cases, CaseResult, PrimitiveResult, Error; None after publication) Program counter + active instruction Carries the expression or value itself, not a memory address. Lights one of the 10 sectors on the Central Control Stator and inspector strip (EVAL, PUSH, RET, INVOKE, ENTER, BOUND, CASES, MATCH, PRIM, ERR); the transfer needle points West (Slot A) or East (Slot B) at the newest visible frame.
Environment = BTreeMap<Name, Value> Register file / local stack frame No fixed register bank; the live lexical map is replaced wholesale. Return, Scope, Let, If, Match, Left, and Args store an explicit map copy; Right and Unary borrow enclosing bindings for display without duplicating storage.
frames: Vec<Frame>, newest first at frames[0] (Let, Left, Right, Unary, If, Match, Args, Return, Scope) Call stack / activation records Many frames are paused operands or branch gates rather than call records. Displayed newest-first in Saved frames and mapped chronologically across the 6 Split-Arc Rings (R1.A..R6.B, 12-frame window, with +N overflow on R6.B) and Open-Bore Continuation Rings: ENV (Teal Return / Sky-Cyan Scope), OP (Amber Left·Args·Unary → Gold Right), and GATE (Violet If·Match·Let).
remaining_fuel & stack_limit Execution gas / stack overflow guard Each operational or error rule costs 1 fuel (1F) and terminal publication (A080 Done, A082 Rejected, A084 Exhausted) costs 0 fuel (0F), draining the 48-Segment Outer Fuel Rim. Pushing when frames.len() == stack_limit fires Rule A140 to Control::Error(4) (1F), pulsing the interior stackLimit horizon ring crimson before Rule A082 publishes Rejected(error 4) (0F).
StepRecord & 39-Rule Decoder Table (A080..A225) ISA microcode ROM & audit trace Laid out as 39 3D silicon chiplets in gold sockets across a 6 × 7 floor grid at y = −3.38 inside the hollow vault, badged in the Inspector as Rule Axxx. On each step, the active rule chiplet elevates and lights its status bar while the prior step’s chiplet glows in trail mode, showing the step-by-step transition chain fed into WitnessPlan and checked by ConstraintPlan.
ProgramImage AST & Live Morphogenesis (Quinelings QDL v1) Program syntax tree & dynamic execution graph Translated deterministically via the Quinelings QDL framework (logarithmic-mantle, toroidal-weave, phyllotaxis-fan) into a unique 3D Quineling Core Organism suspended at (0, −2.15, 0) inside the hollow processor chamber (16 articulated vertebrae, 48 harmonic ribs/petals, endpoint-pinned soliton filaments, and 64 lossless RGB source-byte spores). Unfurls petals on Rule A135 PushFrame, twists in-place on Rules A145/A149/A177, blooms on A080 Done, and locks crimson fault spines on A082/A140/A225.
System Architecture · Separation of Duties

From Agreement Authoring to Midnight Settlement (5-Layer Pipeline)

System Layer Primary Responsibility What Enters the Layer What Leaves the Layer
1. Moriarty Agreement authoring, authority specification & orchestration Participant rules, ownership permissions, spending caps & continuing terms Structured agreement definitions & delegated execution boundaries
2. Solver or Executor Off-chain candidate discovery & transaction proposal Market data, agreement terms & off-chain search heuristics Concrete candidate action & inputs (payment amount, recipient, fee claim)
3. Sherlock Deterministic preparation, bounded step execution & proof planning Frozen ProgramImage, committed state (MachineImage) & solver inputs Verified effects, updated MachineImage, StepRecord chain, WitnessPlan & ConstraintPlan
4. Cryptographic Proof Machinery Zero-knowledge mathematical proof generation Private execution trace (WitnessPlan) & fixed transition equations (ConstraintPlan) Compact zero-knowledge proof bound to public program, state & effect commitments
5. Midnight Verification & Settlement Ledger proof verification, nullifier recording & finality ZK proof, public ProgramImage & MachineImage commitments, and settlement effects Settled asset transfers, consumed prior state marker & active residual obligation
Verification Case Study · 40-Unit Credit Agreement

How Sherlock & ConstraintPlan Block Dishonest Solver Variations

Execution Stage / Guard Authorized Execution
(Pay 30, Fee 1, to Lender)
Rejected Variation A: Excessive Fee
(Pay 30, Fee 3, to Lender)
Rejected Variation B: Wrong Recipient
(Pay 30, Fee 1, to Solver / Charlie)
Starting Obligation 40 units owed (committed state) 40 units owed (committed state) 40 units owed (committed state)
1. Recipient Authority Guard Passes Account_Lender == Account_Lender Passes Account_Lender == Account_Lender Fails Account_Solver == Account_Lender → halts immediately
2. Payment Bounds Guard Passes 5 ≤ 30 ≤ 40 Passes 5 ≤ 30 ≤ 40 Not reached (halted at recipient check)
3. Fee Ceiling Guard Passes 1 ≤ 1 Fails 3 ≤ 1 is false → triggers RequiredRejection Not reached (halted at recipient check)
4. Principal Balance Math 40 − 30 = 10 units remaining Aborted; no state transition emitted Aborted; even though 40 − 30 = 10, authority failed
5. Proof & Settlement Outcome Settled on Midnight: 30 to Lender, 1 to Solver; 10 owed saved in MachineImage v1 Refused: Forging true in StepRecord violates ConstraintPlan equations Refused: Swapping recipient after guard check violates CheckedFieldCopy equality constraints