The mlld CLI runs scripts, validates syntax, runs native test files, records each run so an interrupted run can be resumed, and serves MCP tool endpoints. mlld run executes named scripts from the script directory. mlld <file> runs any file directly with payload injection.

Direct File Invocation

Run any mlld file directly with mlld <file>. Supports the same payload injection as mlld run.

mlld script.mld                        # Run a file
mlld script.mld --topic foo --count 5  # Pass payload fields

Payload injection: Unknown flags become @input.cli fields. @input.cli is always available as {} even with no flags:

show @input.cli.topic
mlld script.mld --topic hello    # @input.cli = {"topic":"hello"}
mlld script.mld --fast           # @input.cli = {"fast":true}  (a bare flag is true)
mlld script.mld                  # @input.cli = {}

Declaring parameters: a script can say which flags it takes, with their types, in one top-level args directive. It uses the exe parameter syntax and binds each name as a const:

args (topic: string, count: number = 3, tags: string[]?, loud: boolean = false)

show `${@topic} x${@count}`
mlld script.mld --topic news --count 2        # @count is the number 2
mlld script.mld --topic news --tags a --tags b # @tags is ["a","b"]
mlld script.mld --help                        # prints the usage line and the flags
  • Each flag is read by its type, and nothing is coerced: a number takes JSON number syntax (--count 3, --count=3, --count -3), a boolean is true when given bare, a list type (string[]) takes the flag more than once, and an object, array or record type takes JSON text checked against its shape.
  • These refuse before anything runs, print the usage line, and exit with code 64: a missing required flag, a value that does not read as its type, a scalar flag given twice, and an unknown flag (so a typo is caught).
  • An omitted T? parameter is absent (@exists(@tags) is false); one with a default binds the default; an omitted boolean is false.
  • mlld reads its own flags first, so a value that is one of them is taken by mlld: --topic --json leaves --topic without a value. Write --topic=--json to pass it.
  • A name that is one of mlld's own flags (format, verbose, output, …) is refused when the script loads. A newer mlld can add a flag that makes a declared name collide; the error then names it. Flags after a bare -- always go to the script.
  • A type with a kind (field @email [ kind "email" ]) is refused: a command-line value can't carry proof. Use a plain type and check it inside the script.
  • Each value carries .src:cli and its sidecar labels, as an @input.cli field does, and gains trust only through self_attestation. @input.cli still holds the raw flags.
  • args belongs to the script you run: one per script, at the top level, and never in an imported module.

Options:

Flag Description
--no-stream Print the output once the run finishes instead of streaming it
--no-format Print the assembled document without the markdown formatting pass (raw sink bytes)
--output <file> / -o <file> Write the interpreted document to a file (creates missing parent directories) and print Output written to: <path>. Refuses a directory target, refuses when the output path is the input file, and refuses together with --stdout. Streaming is not disabled: a streamed run prints chunks to stdout and also writes the file. With -e/--eval the flag is ignored with a warning — eval output is always stdout. Not available on mlld run.
--<name> <value> CLI input field (unknown flags become @input.cli fields)
--<field>.labels .a,.b Attach classification labels .a,.b to @input.cli.<field> (sidecar — never enters payload data)
--state <json> Supply the host state as a JSON object (--state '{"count":0}'); declare state external @app = { count: number } and read @app.count
--state-labels <path>=<label,...> Attach classification labels to the --state seed's fields (repeatable; dotted path, later occurrences append). Requires --state. A label only mlld writes (.src:tape, .src:envelope, …) refuses the run; .src:state labels are dropped.
--<field>.trusted Request trust for @input.cli.<field> (honored only if a policy sets * { self_attestation: { cli: { claims: ["trust"] } } })
--mlld-env <value> Repeatable. Each value is either inline overrides (MLLD_X=1,MLLD_Y=2, applied unfiltered) or a .env file path (loaded strictly — a missing file refuses; only MLLD_* keys are applied). Values apply to the process environment before the run, so scripts (via @input.env.*) and child processes both see them.
--timeout <duration> Stop the run once it has run this long: milliseconds (5000) or a duration (500ms, 30s, 5m). The run fails with error code RUN_TIMEOUT; see "Time limit" in cli-run
--trace <level> Print runtime trace events (guard verdicts, policy checks) to stderr: off, effects, handle, or verbose
--trace-file <path> Also write the trace events as JSON lines to a file (written only when the run produces events)
--trace-memory Print memory samples for the run to stderr
--profile When the run ends, print where it spent its time to stderr: the functions, built-in methods and source lines that cost the most
--profile-file <path> Write the full time profile to a file instead: JSON when the name ends in .json, text otherwise

The .labels/.trusted suffix flags are sidecar: they attach security metadata to a field without becoming payload data. A .trusted request mints trust only when a policy grants the CLI channel with * { self_attestation: { cli: { claims: ["trust"] } } } (absent by default, so requests are ignored otherwise). See payload and security-policies.

Profiling a run: --profile shows what a script spends its time on. Each function and built-in method gets its number of calls, its total time, and its self time: the time spent in its own body, not in the calls it makes. Each source line gets the self time spent running it. A last table names three costs the runtime adds, already counted in the rows above: the security checks every function call runs, label tracking after an if on labelled data, and module loading.

mlld profile: 7.62 s, peak memory 318 MB

Functions and methods, by self time (self = time in the body itself, not in calls it makes)
   self ms  self%   total ms     calls    avg µs  name
    2104.0  27.6%     6012.0      3005     700.2  @word  judge.mld:1234
     640.2   8.4%      640.2     18148      35.3  .slice
...

Times are measured, not sampled, so call counts are exact and the profile adds some cost of its own. A function's total counts the time any call of it was running, so a recursive or parallel call is not counted twice. Inside parallel work, which function a line is credited to is approximate, and the report says so. A script no longer receives --profile or --profile-file as its own flags. To profile a function called through mlld live, pass profile: true in the call's options (see config-live-stdio).

Difference from mlld run: Direct invocation takes a file path. mlld run discovers scripts from the configured script directory (default: llm/run/) and records a run tape so an interrupted run can be resumed.

Inline code (-e/--eval): Run mlld source without a file. The code runs like a .mld file anchored at the current directory, and output is forced to stdout:

mlld -e 'show "hello"'              # prints: hello
mlld -e 'const @x = 1
show @x'                          # any mlld, newlines included

Piped stdin is data: whenever the program comes from somewhere else — a script file, or -e — piped stdin binds the @input.stdin channel:

echo '{"note":"hi"}'   | mlld script.mld                      # @input.stdin.note is "hi"
echo 'plain text'      | mlld -e 'show @input.stdin.value'    # prints: plain text
echo '{"note":"hi"}'   | mlld -e 'show @input.stdin.note'     # prints: hi

This is what lets an mlld script serve as a hook or filter for a tool that hands it JSON on standard input.

Plain text binds @input.stdin.value (also .content, .text, .stdin); a JSON object binds its fields; any other JSON value binds .value; no pipe binds @input.stdin to {}. Every @input.stdin field carries the .src:stdin provenance label.

Program from stdin (-e -): -e with the value - reads the program from standard input instead of from the argument. The program has no file path; it runs anchored at the current directory — the same posture as -e '<code>':

echo 'show "hello"' | mlld -e -      # prints: hello
cat script.mld      | mlld -e -      # same as running the file

Because stdin is spent on the program, it cannot also feed @input.stdin — reading @input.stdin inside an -e - program hits the unfed-channel refusal. Stdin is never implicitly a program: bare mlld with piped input (and mlld -) refuses with No input file specified and a pointer to the -e - spelling.

Two arg-shape errors, both exit 1: -e with no code string (--eval requires a code string), and -e together with a script file (Cannot specify both an input file and --eval).

mlld run Command

Run mlld scripts from a configured directory with automatic payload injection.

mlld run                     # List available scripts
mlld run hello               # Run llm/run/hello.mld
mlld run qa --topic vars     # Pass payload: @input.cli.topic = "vars"

Payload injection: Unknown flags become @input.cli fields:

mlld run build --env prod --fast true
>> In build.mld — @input.cli is available directly
const @env = @input.cli.env ? @input.cli.env : "dev"
const @fast = @input.cli.fast ? @input.cli.fast : false

Declared flags: a script that declares its flags with args ( … ) (see cli-file) gets them typed and checked: mlld run build --count three against args (count: number) refuses before the script prints anything, shows the usage line, and exits with code 64. mlld run build --help reads the script and prints its usage. A run tape records the typed values, so --resume with different flags restarts the run instead of continuing it.

Reserved flags: --mlld-env is reserved for agent environment loading. --env is an ordinary payload flag: it arrives as @input.cli.env.

Script directory: set scriptDir in mlld-config.json (for example {"scriptDir": "scripts"}); the default is llm/run/. A script can be a file (llm/run/<name>.mld) or a folder with an index.mld (llm/run/<name>/index.mld).

Options:

Flag Description
--no-format Print the assembled document without the markdown formatting pass (raw sink bytes)
--fresh / --new Start from the top, even when the script's resume: auto would continue an unfinished run
--no-checkpoint Write no run tape for this run
--resume [run-id|name] Continue the latest run (or the named run) from its last snapshot, or restart after a named checkpoint
--from <run-id> Continue the named run, like --resume <run-id>
--mlld-env <env> Load agent env file(s) or inline KEY=VALUE overrides
--no-stream Print the output once the run finishes instead of streaming it
--state <json> Seed @state with a JSON object
--timeout <duration> Stop the run once it has run this long: milliseconds (5000) or a duration (500ms, 30s, 5m). See "Time limit" below
--trace <level> Print runtime trace events (guard verdicts, policy checks) to stderr: off, effects, handle, or verbose
--trace-file <path> Also write the trace events as JSON lines to a file (written only when the run produces events)
--<name> <value> CLI input field
--<field>.labels .a,.b Attach classification labels .a,.b to @input.cli.<field> (sidecar — never enters payload data)
--state-labels <path>=<label,...> Attach classification labels to the --state seed's fields (repeatable; dotted path, later occurrences append). Requires --state. A label only mlld writes (.src:tape, .src:envelope, …) refuses the run; .src:state labels are dropped.
--<field>.trusted Request trust for @input.cli.<field> (honored only if a policy sets * { self_attestation: { cli: { claims: ["trust"] } } })
--validate-error <family|code> Promote a validator WARNING family (or a single diagnostic code) from advisory to a run-time refusal. Repeatable. Error-severity findings refuse the run with or without it.
--no-flowcheck Run without the flowcheck pre-flight the script's policy asks for (prints one line saying so)
--validate-warn <family|code> Demote a family that refuses by default back to advisory for this run. Currently one default exists: undefined-variable (see below). Repeatable; selectors fail closed exactly like --validate-error. An explicit --validate-error on the same family still refuses.

The .labels/.trusted suffix flags are sidecar metadata, not payload data. A .trusted request mints trust only when a policy grants the CLI channel with * { self_attestation: { cli: { claims: ["trust"] } } } (absent by default, fail-closed). See payload and security-policies.

Validator pre-flight: before execution, mlld run checks the script the way mlld validate does.

  • Warnings are advisory: one line each on stderr; the run proceeds and the exit code is unchanged.
  • An undefined variable refuses the run. A typo'd variable should cost nothing, not fail a paid run part-way through. The refusal ends with Pass --validate-warn undefined-variables to run anyway.; that flag drops the finding back to a warning.
  • An error refuses the run, naming the code and message. There is no override, and validate.suppressWarnings cannot silence it.
  • To make a warning family stop the run too, name it: mlld run greet --validate-error anti-pattern, or a single code: --validate-error deprecated-json-transform. An unknown name refuses and prints the list of families, which is how you find what you can select.
  • validate.suppressWarnings in mlld-config.json filters pre-flight warnings the same way it filters mlld validate output.

Both flags belong to mlld run; mlld script.mld --validate-error … (or --validate-warn …) refuses. mlld run also refuses --debug.

Time limit: --timeout 30s stops the run 30 seconds after it starts, whatever it is doing. A loop or a long chain of calls stops at its next pass or call, and a running command is stopped. Work that cannot be stopped from inside, such as a js block that never returns, ends with the process: mlld exits a quarter of a second past the limit. A try inside the script cannot catch the stop, and the run fails with the run hit its timeout of 30000 ms and was stopped (error code RUN_TIMEOUT). mlld script.mld --timeout 30s and mlld -e '…' --timeout 30s take it too. A value that is not a duration refuses before the run starts. To limit one call rather than the run, use with { timeout } on the call (see as-with-overloads).

flowcheck pre-flight: after the validator, mlld run can check the script's label flow the way mlld flowcheck does (see flowcheck), without running anything. In this release it does so only when a policy the script applies names flowcheck (* { flowcheck: "default" } or "strict"): a policy it declares, one a module it imports declares, an import policy, or the policy in mlld-config.json. A policy value the script never applies (const @p = policy { … } that nothing uses) does not count. From 2.2.1 it runs for every script. A script whose policy does not ask runs as before, and the runtime checks each line as it runs.

  • A definite finding refuses the run: a line the policy refuses whenever it runs. The script does not start, and each refused line prints as one line with its label and the rule. No line of the script is printed, so a value written in it does not reach the error output.
  • A box: * rule that may need a box nobody configured refuses the run too, even when only some runs would reach it.
  • Possible and handled findings are advice: one line each on stderr, at most five, then … and N more; run mlld flowcheck <file> for all. The run proceeds. Most real scripts have some, because flowcheck cannot follow everything a script does.
  • A strict policy refuses on possible findings too: * { flowcheck: "strict" } in any policy in force (see security-policies). A flowcheck: whose value is computed counts as strict. A policy in a module flowcheck cannot read (a registry module) never makes the run strict; the pre-flight prints a line saying so.
  • If flowcheck itself fails, it prints one line and the run proceeds. A script that does not parse is left to the runtime's own error.
  • --no-flowcheck skips it and prints mlld: flowcheck skipped (--no-flowcheck); where the pre-flight would not run, it does nothing and prints nothing. The runtime still checks every line as it runs.

The pre-flight runs only before mlld run: mlld script.mld, mlld -e and a piped script do not run it, and mlld script.mld --no-flowcheck refuses. mlld run has no --strict of its own.

Questions to you: when stdin and stderr are both a terminal, mlld run asks you a script's questions itself (match ask, and a guard's or policy's ask, offered as Approve or Deny): the question appears on stderr with its options numbered, and you type a number. Anything typed before it appeared is ignored, and it waits up to 5 minutes. With stdin from a pipe or a file, nobody is asked and every ask refuses. See match-ask.

Checkpoint/resume: a mlld run that calls out — a command, a model, a tool — records a run tape under .llm/runs/<script>/, including snapshots of its progress. A script that only computes and prints records nothing. --resume continues the latest run from where it stopped instead of starting over:

mlld run pipeline --resume                  # continue the latest run
mlld run pipeline --resume <run-id>         # continue a named earlier run
mlld run pipeline --resume "analysis"       # restart after checkpoint "analysis"

See Checkpoint & Resume for what a resumed run keeps and reruns, and the resume: header.

Validate Features

The mlld validate command checks a file for common mistakes without running it. It reads .mld scripts, .sss and .priv.sss policy modules, and .att and .mtt templates, one file at a time.

mlld validate module.mld                      # JSON report (the default)
mlld validate module.mld --format pretty      # readable diagnostics with source excerpts
mlld validate template.att                    # check a template

Most findings are warnings: they appear in the output and leave the exit code at 0. Errors (a reserved name redefined, a retired builtin called) mark the file invalid.

Exit codes:

  • 0: the file was checked and has no errors (it may have warnings)
  • 1: the file was checked and has errors
  • 2: the file was not checked at all, because it could not be read or parsed

Exit 2 covers two situations, and the JSON says which. The file may use a construct this build does not support, or it may be malformed. Either way the JSON carries parseError, plus unsupported: true for an unsupported construct, false for a file that is broken. A clean file carries neither key.

Limits:

  • One file per run. mlld validate ./src/ reports Is a directory; to check a project, loop over its files.
  • --deep (follow imports) and --context <paths> (read extra files' definitions) are refused with exit 2. mlld validate checks one file and does not check that its imports resolve.
  • --rust is accepted and does nothing.

mlld validate --help lists the flags your build supports.

Undefined variable detection:

const @name = "alice"
show @nmae
>> Warning: Variable @nmae is referenced but never defined.

Optional parameter pass-through warnings:

exe @inner(x, timeout) = cmd { echo "$timeout" }
exe @outer(x, timeout) = [
  let @result = @inner(@x, @timeout)
  => @result
]
const @r = @outer("hello")
>> Warning: @timeout is a trailing parameter on @outer and may be undefined (omitted at callsite line 6). ...

This catches wrapper patterns where trailing exe parameters are omitted by callers and then forwarded into nested function calls.

A literal @name in text:

exe @fileBlock(path) = `<file path="@path">`
>> Warning: This `@path` is literal text; did you mean `${@path}`?

Only ${…} inserts a value, so @path here is printed as written. The warning (strings:literal-at-ref) fires in quoted strings, backtick and :: templates and .att files, when the word after the @ is a variable, a loop variable or a parameter of the enclosing exe. An @ right after a letter, digit or underscore, as in bob@test.org, stays quiet. See escaping-at.

Shadowing:

const @count = 0
const @ready = true
if @ready [
  let @count = 1
  >> Error: `let @count` would shadow `@count`, a module binding on line 1, which is already visible here.
]

A block may not declare a name that is already visible from outside it. Give the inner value its own name. A const never changes; inside a block, let declares a local value that @x = … or += can update. Because this is a parse error, the report exits 2 with unsupported: false.

Reserved name conflicts:

const @now = "custom"
>> Error: Cannot redefine reserved @now.

Redefining @now, @root or @mx is an error. Redefining @p, @payload, @state or @fm is a warning, because the SDK and the runtime use those names.

Builtin shadowing:

exe @transform() = [
  let @parse = "not-a-transformer"
  >> Warning: @parse shadows a built-in transform in this scope.
  => @parse
]

Shadowable builtins: @parse, @exists, @upper, @lower, etc. Reported as warnings, not errors.

Record composed into an object literal:

record @account [
  key id
  id: string [ kind "account_id" ]
  email: string?
  * { read: [id] }
]
exe @getAccount() = js { return { id: "a1", email: "ada@example.com" } } => account
const @acct = @getAccount()
exe @wrap() = { wrapper: @acct }
>> Warning: Record '@account' is composed into an object literal; the record's read: projection does not automatically survive the reshape, ...

When a variable holding a coerced record (an exe result annotated => account) is placed as a value inside an object literal, mlld warns that the record's read: projection does not automatically follow the reshape — fields the read: contract withholds could cross raw at serve and display boundaries, so check every boundary the composed value reaches. Returning the record directly (with its exe output annotation) keeps the projection. This advisory is not suppressible and does not change the exit code. See the records doc for the read: contract.

A named accepts floor that cannot work:

const @write_floor = [".src:user:intent:literal", ".fact:*:email"]
record @send_inputs [
  recipient: string [ accepts @write_flor ]
]
>> Warning: Accepts floor @write_flor is referenced but never defined.

A record field can name its accept list instead of repeating it
(accepts @write_floor — see the records doc). Two mistakes are caught here
rather than when the program runs: the name is misspelled or nothing in the file
declares it (record-accepts-floor-undefined), and the name is declared in that
same file but holds something that cannot be a floor — a plain string, an empty
list, a list with a number in it, a list with a blank entry
(record-accepts-floor-not-a-label-list).

Anything it cannot see into is left alone: a floor imported from another file,
returned by a function, copied from another variable, or built out of other
variables. Silence is not a promise the floor is good — it means the check could
not tell. mlld still refuses any floor that does not resolve to a usable list
when the program runs, which is what actually stops one.

Neither code can be switched off in mlld-config.json. Every time one fires,
the program will fail when you run it, so there is no working pattern to
silence — the fix is the floor, not the warning.

A script's args declaration (see cli-file) is checked too. A second args
directive is an error (args-duplicate). So is a flag typed with a field
definition, record field or record that has a kind, as the file declares them
(args-kind-type): a command-line value can't carry proof. Reading a declared
flag raw as @input.cli.<name> is a warning (args-unused-input-cli), because
that skips the type check; read @<name> instead.

Load targets:

A load whose path and query are written out in full is checked against the file it names. <notes/spec.md> warns load-target-missing-file when the file is not there; <notes/spec.md # Instl> warns load-target-missing-section when no heading matches (one name matches a heading that starts with it, a > path matches each name whole); <src/billing.ts { Invoice.totl }> warns load-target-missing-definition when the name or path selects nothing. A relative path is read from the directory of the file it is written in, @root/… from the project root. Optional items (# A, B?) and <path>? loads do not warn.

These are warnings, so a script still runs. To make them stop a run, promote them: mlld run <script> --validate-error load-target (or one code). Only files inside the project are read, each once and only up to 1 MiB for the section and definition checks. Nothing is checked for a path or query built from a variable, a glob, a URL, a resolver prefix other than @root, a file outside the project, a file the same script writes (output … to, append, file), or, in a script that imports a custom content selector, anything but the file's existence. Kind filters ({ *fn }), listings (??) and quoted patterns are not checked. The editor (the language server, on every edit) runs the same checks, definitions included.

Suppressing warnings:

Add mlld-config.json to suppress intentional patterns:

{
  "validate": {
    "suppressWarnings": ["deprecated-json-transform"]
  }
}

Suppressible codes include deprecated-json-transform, json-string-return-needs-parse, retired-policy-label-role, retired-policy-record-approval-role, hyphenated-identifier-in-template, privileged-wildcard-allow, guard-unreachable-arm, unknown-policy-rule, privileged-guard-without-policy-operation, guard-context-missing-exe, guard-context-missing-op-label, guard-context-missing-arg, policy-operations-unknown-label, policy-authorizations-deny-unknown-tool, policy-authorizations-can-authorize-unknown-tool, policy-label-flow-unknown-target, record-identity-data-field, load-target-missing-file, load-target-missing-section, and load-target-missing-definition.

Policy / guard validation:

mlld validate --format json lists the file's executables, exports, imports and policies alongside its findings. For this file:

record @email_result [
  key message_id
  message_id: string [ kind "message_id" ]
  * { read: [message_id] }
]
exe .op:tool:w @send_email(recipients, subject, body) = js { return { message_id: "m1" } } => email_result
policy @task = {
  .risk:destructive { includes: [.op:tool:w] }
}
export { @send_email }

the report is:

{
  "executables": [{
    "labels": [".op:tool:w"],
    "name": "send_email",
    "outputRecord": { "kind": "static", "name": "email_result" },
    "params": ["recipients", "subject", "body"]
  }],
  "exports": ["send_email"],
  "filepath": "js.mld",
  "policies": [{
    "name": "task",
    "labels": { "alias": { ".risk:destructive": [".op:tool:w"] } },
    "locked": false
  }],
  "valid": true
}

This is useful when validating LLM-generated policies and guards before execution. A policy's includes: groupings appear under labels.alias.

@policy.build(...) and @policy.validate(...) are refused (see "Policy call validation" below); policyCalls is where the JSON lists any calls to them left in a file: each entry has status: "retired" and a policy_build_retired diagnostic, and the call is also reported as an error, so the file is invalid.

Record/input contract validation:

mlld validate catches input-record and surfaced-tool mistakes that would otherwise fail only at runtime:

  • field-attribute bag syntax such as recipient: string { exact: true } (a parse error; field settings go in [ … ])
  • unknown record entries (the parse error lists what a record accepts)
  • invalid allowlist / blocklist targets

Tool catalog validation:

mlld validate also checks tools collections before runtime:

  • unknown tool-entry keys
  • non-string description / instructions
  • invalid can_authorize shapes (must be false, .role:*, or an array of .role:*)
  • inputs that do not reference an input-capable record
  • input-record fields that do not match executable params
  • executable params left uncovered by inputs or bind
  • bind keys that overlap the input record
  • surfaced tools with update: input sections that are missing .op:update:w in labels

Handler references that resolve through imports, aliases, or an MCP-namespaced collection are accepted; only handler references that cannot be resolved to an executable in scope are flagged.

Record and state validation:

mlld validate also catches statically knowable record and state definition errors before execution:

  • record key fields that are missing or optional
  • impure computed record fields
  • invalid record read, write, and refine declarations
  • executable => record references to unknown records
  • state slots typed with an unknown record, or a state session slot typed with a record that cannot check input
  • a slot's from naming a slot the state does not have, and merge: "replace" on a list slot
  • state @s from @source where a record map written out in the source names an unknown record, or a tool collection's tools lack returns:. A source that is only known when the program runs gets a dynamic-shelf-wildcard-source warning instead
  • seed on a call that attaches no session, and an override on a session attach that is not the string "session"
  • a non-pure updater in a session's update("slot", @exe) (the updater must be a local js, node or data exe)
  • a box state: scope that is not an object

Policy call validation:

@policy.build and @policy.validate are refused; authorize a tool call with a grant instead (const @g = @req as grant for @tool; see security-grants). mlld validate reports each call as an error: policy.build is retired; use \as grant for @tool` — see the grants doc`, so the file is caught before it runs.

Refused checkpoint spellings:

box with { replay: ... } and any read of @mx.checkpoint are refused when a script runs. mlld validate reports each as an error at its location, with the sentence the run would give. To tell a restored value apart, test its .src:tape label (@x is .src:tape); see checkpoint-resume.

Generic data objects are not treated as policy declarations just because they contain an authorizations field. Validation applies the authorizations schema only to policy declarations.

Semantic guard/policy warnings:

mlld validate also warns about likely-authoring mistakes that are syntactically valid:

  • unknown-policy-rule for typos in built-in rule names
  • privileged-wildcard-allow for a privileged guard with a * => allow arm (guard! @g = match [ … * => allow ]): an unconditional allow answers every unlocked proof requirement (accepts) for every operation the guard is bound to. It does not lift a deny: rule
  • guard-unreachable-arm when an earlier guard arm already covers a later one
  • capability-entry-matches-nothing when a capability allow or deny entry names no capability mlld checks (deny: ["command:echo"] instead of cmd:echo), so it matches nothing, or when capabilities.network is written as something other than an object (network: "none" instead of network: { allow: ["none"] }), so it limits nothing
  • guard-compares-executables (an error) when a guard compares executables with ==, !=, match, .includes or .indexOf. A comparison is not an authorization check: label the approved executable (exe .approved @fn() = …, with class .approved declared) and test the label with @input.2 is .approved
  • privileged-guard-without-policy-operation when a privileged guard filters on an operation label that no policy in the module declares
  • policy-operations-unknown-label when a pattern block's includes: list names labels not present in the validation context
  • policy-authorizations-deny-unknown-tool when authorizations.deny names a tool that does not exist in scope
  • policy-label-flow-unknown-target when a pattern block's deny: or allow!: list names an operation label that matches no declared category (for example .secret { deny: [.op:fly] })

These stay warnings, not errors.

Templates (.att / .mtt):

mlld validate prompts/welcome.att

A template is checked on its own, so every ${@name} (or {{name}} in .mtt) it references is reported as undefined-variable unless the template defines it. A template's parameters come from the exe that loads it, which a single-file check does not read, so expect one warning per parameter.

JSON output keys:

filepath and valid always; antiPatterns (warnings, each with code, message, line, column) and errors when there are findings; executables, exports, imports, policies and policyCalls when the file has them; parseError and unsupported when the file was not checked.

Checkpoint & Resume

A mlld run <script> that calls out (a command, a model, a tool) records a run tape: a log of what the run did, written as it goes. A script that only computes and prints records nothing, unless a policy refuses part of it: a run with a label-flow refusal records its tape, caught or not, so the refusal can be looked at afterwards. When a run stops part way (a crash, Ctrl-C, a missing file), mlld run <script> --resume continues it from the tape instead of starting over, so the model calls that already finished are not paid for twice.

mlld run works inside a project: the nearest folder, going up from where you are, that holds an mlld-config.json. Scripts live in the project's llm/run folder. To try the examples below in an empty folder, create the config first with echo '{}' > mlld-config.json; without it, mlld looks in a parent folder's project instead and stops with Error: Script "pipeline" not found.

What a run records

The tape is .llm/runs/<script>/<run-id>.tape.jsonl, and .llm/runs/<script>/latest names the newest run. <script> is the file name without .mld, or the folder name for an index.mld or main.mld. The first run in a project to write a tape creates .llm/.gitignore so tapes stay out of git, and says so (mlld: created .llm/.gitignore so run tapes stay out of git). In a folder mlld cannot write to, the run goes on and prints run tape not written: Permission denied.

A tape holds:

  • every outside call (a cmd, sh, node or python body, an MCP tool, @http, or a URL load), with its arguments and result, marked llm when it came from the body of an llm-labeled executable and other otherwise. An in-process js body makes no outside call, so a run whose only calls are js bodies writes no tape unless a policy refuses something in it (see mlld howto tapes);
  • a snapshot after each top-level statement, starting with the first statement that made an outside call, and after each finished iteration of a top-level for loop that made an outside call, wrote a file or state, or printed something. A snapshot holds the variables the statement changed and what it printed;
  • the verdicts guards and policy rules reached on each operation;
  • every answer a person gave to a question (a match ask, an agent's question, or a guard's or policy's ask the host answered): the question and options as shown, the option picked or the words typed, how the answer came in, and who answered when the host said (see match-ask);
  • the conversation of an llm call that reports one;
  • a marker for each checkpoint "name" the run passed (see below).
  • each note the script wrote with @mx.tape.note (see Tape Methods). A resume does not write the notes of the statements it restores again; the statement that was running when the run stopped runs again, so its notes can appear on both tapes.

--no-checkpoint records no tape, and cannot be combined with --resume, --from or --fresh. Running a file directly (mlld file.mld) also records a tape, but only mlld run resumes: mlld file.mld --resume or --from is refused rather than ignored.

Resuming a run

@ask below stands in for a model call: the llm label on an executable is what marks its calls as llm calls. It logs each call to calls.log so you can see which ones really ran. Appending to a file takes a full shell, so @ask is an sh block, and sh blocks are off by default: the policy line at the top of each example switches them on.

policy @allow_sh = { * { capabilities: { sh: true } } }
llm @ask(q) = sh { echo "asked: $q" >> calls.log; echo "answer to $q" }

const @summary = @ask("what changed?")
const @notes = <@root/notes.txt>
show `${@summary} / ${@notes}`

Saved as the script pipeline in the project's llm/run folder, the first run stops at the missing file. After the file exists, --resume finishes the run without asking again:

$ mlld run pipeline
Running llm/run/pipeline.mld...

mlld: created .llm/.gitignore so run tapes stay out of git
mlld: File not found: …/notes.txt
to continue from where it stopped: mlld run pipeline --resume
$ echo "two fixes" > notes.txt
$ mlld run pipeline --resume
Running llm/run/pipeline.mld...

mlld: --resume: run '…' is not sealed, so its answers come back untrusted.
answer to what changed? / two fixes
$ cat calls.log
asked: what changed?

--resume loads the latest run's last snapshot and runs only what remains:

  • statements the snapshot covers do not run again, with one exception (below); their variables, printed output and the files in a vfs box's workspace come back from the tape. A file read from a restored workspace (<@ws/out.txt>) is untrusted and labelled .src:tape:run, like other values from the tape. A box statement that runs again (because it stopped inside the box, or its workspace held secret data) runs its commands live, so its files are written again;
  • the exception: a statement that changed a run-wide state (a slot that does not hold records, written with @s.increment("n"), @s.set(…) and the like) or a state external. The tape does not hold those changes, so the resume starts again at the first such statement: it and every statement after it run again, and their outside calls are answered from the tape as described next. Record slots, and states declared inside an exe, do not cause this. The resume says where it starts: mlld: --resume: restarting at step 5: statement 5 made something a resume cannot restore (a secret, printed output, or state the tape does not hold);
  • exe, guard, policy, import and other declarations run again from source;
  • the statement that was running when the run stopped runs again, and each outside call it makes at the same place with the same arguments as before is answered from the tape instead of running. An argument that is itself a value from the tape still counts as the same;
  • for a top-level for loop, the finished iterations that have a snapshot do not run again; the rest run, including finished iterations that did nothing outside the program, which work out the same result again, and finished iterations that changed a state as above, which make the change again. In a for parallel loop the changes of iterations running at the same time cannot be told apart, so once any iteration has made such a change, every iteration that finished after it runs again too. Each operation a finished iteration did is checked against the guards and policy in effect now, as a statement's are.

Values that come back from the tape are marked untrusted (see Limits). The is not sealed line says so the first time the resume takes a value from the tape; a resume that takes nothing from the tape does not print it. Sealing, which most projects do not need, is in Sealed tapes. A failed mlld run whose tape recorded an outside call ends with the --resume line shown above.

A resume starts earlier than where the run stopped when a statement the snapshot covers was edited, or when the run's inputs (payload, arguments or stdin) differ, and it says where and why before running anything:

mlld: --resume: restarting at step 1: statement 1 was edited since the earlier run

Calls in the statements that run again are still answered from the tape when they are made at the same place with the same arguments. Under a resume: auto header, where nobody typed the flag, these messages start mlld: resume:.

Resuming a run that was itself resumed also looks at the runs before it. A resume that restored every statement made no calls of its own, so after an edit, a call whose arguments did not change is answered from the earlier run that did make it. Each earlier run's tape is checked on its own, exactly as the one you named: in a project whose policy lists signers, one that is not sealed or fails its check stops the resume.

A run stopped mid-statement shows the third point. Here the run is killed while @draft sleeps, after its @ask("draft") call finished:

policy @allow_sh = { * { capabilities: { sh: true } } }
llm @ask(q) = sh { echo "asked: $q" >> calls.log; echo "answer to $q" }

exe @draft(topic) = [
  let @answer = @ask(@topic)
  run cmd { sleep 5 }
  => @answer
]

const @plan = @ask("plan")
const @text = @draft("draft")
show `${@plan} / ${@text}`
$ mlld run slow & sleep 2; kill $!
Running llm/run/slow.mld...

$ cat calls.log
asked: plan
asked: draft
$ mlld run slow --resume
Running llm/run/slow.mld...

mlld: --resume: run '…' is not sealed, so its answers come back untrusted.
answer to plan / answer to draft
$ cat calls.log
asked: plan
asked: draft

const @text = @draft("draft") ran again. Its @ask("draft") came from the tape, and the sleep that was in flight ran again.

Stopping a run with Ctrl-C or kill (SIGINT or SIGTERM) also stops the command it was running, and anything that command started, before mlld exits with status 130 or 143. The command is recorded as unfinished, so --resume runs it again (unless it is marked .once, below). kill -9 cannot be handled, so after it the command keeps running on its own. On Windows, stopping mlld does not stop its commands.

Calls that must not run twice

A call that was running when the run stopped may already have done its work: the card was charged, the message sent. When the service it reaches supports idempotency keys, send it @mx.op.key (see ambient-mx) so that service can deduplicate retries. Where a repeat must be prevented here, label the function .once:

policy @allow_sh = { * { capabilities: { sh: true } } }
exe .once @charge(n) = sh { echo "charged $n" >> charges.log; sleep 30; echo "ok $n" }

const @r = @charge(1)
show `done ${@r}`

If the run is stopped during @charge, --resume does not call it again. It stops before the call, names it and the run it was cut off in, and leaves the checking to you:

$ mlld run charge --resume
Running llm/run/charge.mld...

mlld: --resume: run 20261012T033809Z-e4cdc54c finished no statement, so this run starts from the top; the outside calls it recorded are answered from its tape, and any it could not record run again
mlld: resume stopped: the call @charge (its 1st call) was cut off when run 20261012T033809Z-e4cdc54c stopped, and it is marked .once, so it is not made again (at charge#0/sh#0). It may already have taken effect: check the outside system, and to make it again, start the run again with --fresh

Resuming again stops the same way. --fresh starts the script over and makes the call again; changing the script so the call is not made lets the resume continue past it. A .once call that finished before the run stopped is answered from the tape when its result was stored. When its result was secret, or the call failed, the tape holds nothing to answer it with, so the resume stops at it as it does for a cut-off call: the message says the call finished but its result was not stored, and why. .once on a function covers every call it makes, including through other functions, except calls to a service method: those are never answered from the tape, so a resume makes them again even inside a .once function. A policy can put a whole family of operations into it (.once { includes: [.net:w] }, see policy-operations). When an agent calls a .once tool that was cut off, the tool is refused and the run stops once the agent returns. A replay (below) stops the same way under run, and says to run the script without --replay to make the call again.

Choosing the run

Flag Effect
--resume Continue the latest run
--resume <run-id> Continue that run
--from <run-id> The same, with a flag of its own
--resume <name> Continue the latest run from just after its checkpoint "<name>" marker
--fresh (or --new) Start from the top, even when the script's header says resume: auto

A run id looks like 20260925T211702Z-f23ce527; mlld checkpoint list <script> shows them. --fresh deletes nothing: earlier tapes stay, and the run records a new one. --fresh cannot be combined with --resume or --from.

--resume on a script that has never run starts from the top and says so. A run id that is not letters, digits and - is refused, and so is a symlinked .llm, .llm/runs or .llm/runs/<script> folder, run tape file, payloads folder or latest file. The mlld checkpoint commands refuse them too, so clean never deletes anything a symlink points at.

Checkpoint markers

checkpoint "name" marks a place in the run. --resume <name> goes back to it: everything after the marker runs again, and calls after it are not answered from the tape.

policy @allow_sh = { * { capabilities: { sh: true } } }
llm @ask(q) = sh { echo "asked: $q" >> calls.log; echo "answer to $q" }

const @outline = @ask("outline")
checkpoint "outlined"
const @draft = @ask("draft")
checkpoint "drafted"
const @final = @ask("polish")
show `${@outline} / ${@draft} / ${@final}`
$ mlld run stages
Running llm/run/stages.mld...

answer to outline / answer to draft / answer to polish
$ : > calls.log
$ mlld run stages --resume outlined
Running llm/run/stages.mld...

mlld: --resume: run '…' is not sealed, so its answers come back untrusted.
answer to outline / answer to draft / answer to polish
$ cat calls.log
asked: draft
asked: polish
$ mlld run stages --resume polished
Running llm/run/stages.mld...

mlld: --resume: run 20260926T221902Z-b33a011c has no checkpoint 'polished'; its checkpoints are: outlined, drafted; its runs are: 20260926T221902Z-245f0322, 20260926T221902Z-b33a011c

The resume: header

A script's first line can say when it resumes:

Header Effect
resume: manual Resume only when asked with --resume or --from. The default with no header
resume: auto A plain mlld run also continues the latest run when that run did not finish
resume: never Never continue an earlier run; the tape is still written
resume: auto

policy @allow_sh = { * { capabilities: { sh: true } } }
llm @ask(q) = sh { echo "asked: $q" >> calls.log; echo "answer to $q" }

const @summary = @ask("summarize")
const @notes = <@root/notes.txt>
show `${@summary} / ${@notes}`

With resume: auto, a second plain mlld run nightly after the missing file appears prints answer to summarize / ready and calls.log still holds one asked: summarize. Under resume: never, --resume is refused:

mlld: --resume: this script declares `resume: never`, so it never continues an earlier run; remove --resume, or change the header

When the script changed

Resume restores only what the current script would still produce:

  • An edited statement runs again from the first statement whose text changed. In the stages script above, changing @ask("polish") to @ask("polish briefly") and resuming asks only polish briefly.
  • A changed import counts as a change to the import statement: an edit inside the imported module makes everything from that import on run again.
  • Different inputs (the command-line arguments or stdin the run was started with) start again from the first statement that made an outside call.

When the policy changed

A project's policy can change between the run and the resume. The resume checks the steps that already ran against the policy as it is now, before it continues:

  • Guards: a guard that now denies an operation a finished step did stops the resume.
  • Label-flow rules (a pattern block's deny:, such as .pii { deny: [.risk:exfil] }): a rule that now denies a flow a finished step made stops the resume.
  • Any other part of the policy (capabilities, credentials, authorizations and the rest): the resume cannot check it again, so it refuses.

Each message names the step, counting top-level statements from 1, and ends with start with --fresh to run it again. A fresh run applies the new policy from the start.

In this project the config imports its policy from pol.mld:

{ "policy": { "import": ["./pol.mld"] } }

The script upload sends a .pii value to a .risk:exfil executable:

class .pii = { kind: "data", effect: "restrict", description: "Personal data about a real person." }
exe .risk:exfil @upload(x) = cmd { echo uploaded }

const .pii @customer = "Ada, ada@example.com"
const @receipt = @upload(@customer)
const @notes = <@root/notes.txt>
show `${@receipt} / ${@notes}`

The first run, with pol.mld holding only a rule for .secret, stops at the missing file:

policy @config = {
  .secret { deny: [.risk:exfil] }
}
export { @config }

It also prints a warning, because a .pii value goes into a command:

Warning: [NON_IFC_RUNTIME_LABELED_DATA] Routing labeled data (.pii) into cmd {}, a non-IFC runtime; security-metadata preservation across js/py/sh is best-effort and not advised for security-sensitive handling. Keep security-sensitive data in mlld-internal stages, or review and suppress this advisory locally when the boundary is intentional.

The warning is advice, not an error. mlld keeps labels such as .pii on its own values, but it cannot follow them into a cmd, sh, js or py body, so anything that code prints back no longer carries them. When sending the value there is what you mean, add with { warnings: false } to that call: @upload(@customer) with { warnings: false } runs without it, and turns off the call's other warnings too.

Then the policy gains a rule for .pii:

class .pii = { kind: "data", effect: "restrict", description: "Personal data about a real person." }
policy @config = {
  .secret { deny: [.risk:exfil] }
  .pii { deny: [.risk:exfil] }
}
export { @config }
$ printf ready > notes.txt
$ mlld run upload --resume
Running llm/run/upload.mld...

mlld: resume stopped at step 3: policy now denies exe @upload argument, which the earlier run did there under a different policy (Label '.pii' from argument 'x' cannot flow to '.risk:exfil'); start with --fresh to run it again
$ mlld run upload --fresh
Running llm/run/upload.mld...

mlld: Label '.pii' from argument 'x' cannot flow to '.risk:exfil'

The other messages, from the same kind of run:

mlld: resume stopped at step 4: guard @outbound now denies exe @send, which the earlier run did there under a different policy (Guard blocked operation: quarterly numbers stay inside); start with --fresh to run it again
mlld: resume refused at step 3: the policy changed since the earlier run did exe @upload there (its capabilities, credentials or another part besides its label-flow rules and guards), and resume cannot check that part again; start with --fresh to run it again

A guard can only be checked again if a guard saw the operation when it first ran, because only then was the operation's input kept. A guard added where none applied before, or one covering an operation that happened before the tape opened (the run's first outside call), refuses instead:

mlld: resume refused at step 2: guard @outbound now applies to exe @send, which the earlier run did there under a different policy, and it cannot be checked again: no guard saw the operation when it ran, so its input was not kept; start with --fresh to run it again

Under an unchanged policy nothing is checked again.

Replaying a run

--replay <run-id|file> runs a script from the top, and answers its outside calls from an earlier run's tape instead of running them. It is for running a changed script against answers you already have, or for running without calling out at all. --resume continues a run; --replay starts a new one.

A call is answered when it is made at the same place with the same arguments as the recorded call. When it is not, the flag for its kind decides:

Flag Changed arguments, or no recorded call
--llm run (the default) The call runs live
--llm stop The replay stops with an error naming the call
--llm keep The recorded answer is used anyway; with no recorded call, the replay stops

--other run|stop|keep does the same for every other outside call (commands, sh, node and python bodies, MCP tools, @http, URL loads). --if-llm-args-change and --if-other-args-change are the long spellings. --live llm or --live other runs every call of that kind live, even one whose arguments match. A recorded call whose result was withheld as secret, failed or never finished runs live under run, and stops the replay under stop or keep. A .once call that never finished, or whose result was secret or failed, stops the replay under run too.

policy @allow_sh = { * { capabilities: { sh: true } } }
llm @ask(q) = sh { echo "asked: $q" >> calls.log; echo "answer to $q" }

const @summary = @ask("summarize the tapes page")
const @year = run sh { echo "listed: year" >> calls.log; date +%Y }
show `${@summary} (${@year})`

Saved as review, a replay of its first run makes no calls (mlld checkpoint list review shows the run id):

$ mlld run review
Running llm/run/review.mld...

mlld: created .llm/.gitignore so run tapes stay out of git
answer to summarize the tapes page (2026)
$ rm calls.log
$ mlld run review --replay 20260929T095530Z-2eff453b
Running llm/run/review.mld...

mlld: --replay: run '20260929T095530Z-2eff453b' is not sealed, so its answers come back untrusted.
answer to summarize the tapes page (2026)
$ cat calls.log
cat: calls.log: No such file or directory

After the prompt is edited to "summarize the replay page", only that call runs, unless its flag says otherwise:

$ mlld run review --replay 20260929T095530Z-2eff453b
…
answer to summarize the replay page (2026)
$ cat calls.log
asked: summarize the replay page
$ mlld run review --replay 20260929T095530Z-2eff453b --llm stop
…
mlld: replay stopped: the llm call @ask (its 1st call) has different arguments from run 20260929T095530Z-2eff453b (--llm stop) (at ask#0/sh#0)
$ mlld run review --replay 20260929T095530Z-2eff453b --llm keep
…
answer to summarize the tapes page (2026)

With neither kind selected by --live, --llm stop --other stop keeps a replay from calling out: any call the tape cannot answer stops the replay instead of running live. The script's own computation and policy checks still run.

The source is one of:

  • a run id of the same script, or latest for its newest run. A replay records a tape of its own, which then becomes the newest run, so name the run id when you replay the same run more than once;
  • a tape file path (anything containing /, or ending in .jsonl), such as .llm/runs/review/<run-id>.tape.jsonl. Its large results are read from the payloads folder beside it, so to share a run, copy its whole .llm/runs/<script>/ folder. The file can come from another script.

Replay works only with mlld run. It cannot be combined with --resume, --from or --no-checkpoint, and --llm, --other and --live without --replay are refused:

Error: --llm chooses how a replay answers calls; name the run to replay with --replay <run-id|file>

What holds for resumed values holds here (see Limits): answers from the tape are untrusted and carry .src:tape labels, and an answered call's own effects, such as files it wrote, do not happen. Guards and hooks around an answered call still run, except that when the tape is sealed and the policy has not changed, an answered call's after-guards and after-hooks keep the verdict the tape recorded (see Sealed tapes). An answer that keep uses for changed arguments carries no proof, even from a sealed tape, and also takes on the labels of the new arguments.

Limits

  • In-flight calls can run twice. The statement that was running when the run stopped runs again, so a call that had started but not recorded its result runs again, unless it is marked .once (see Calls that must not run twice). Resume is at-least-once for that call. When the service the call reaches supports idempotency keys, send it @mx.op.key, which is the same for that call on every resume, so that service can deduplicate retries (see ambient-mx); use .once where a repeat must be prevented here.

  • Answered calls have no effects. A command answered from the tape does not run, so any files it wrote are not written again. An llm call answered from the tape does not run the tools its agent called, so their effects are absent too.

  • Secrets are never written to the tape. A statement that produced a secret runs again on resume. With const .secret @key = @token() before the first model call, a resume runs @token() again and answers the model call from the tape. If @token is marked .once, the resume stops at it instead of running it again.

  • Restored values are untrusted. Values read back from an unsealed tape carry the labels .src:tape, .src:tape:run and .src:tape:unverified. Their other labels can block an action but never permit one, and a guard that reads call history after a resume can deny but never allow.

  • Restored values carry no proof. A fact is a field a record checked when the value came in, such as the email a => contact lookup returned, and a value that has one lists it in .mx.proof (see mlld howto labels-facts). A value read back from a tape has no proof (the one exception is in Sealed tapes), so a guard or policy that requires a fact refuses it.

  • Allow-guards should test proof, not labels. @input.any is .reviewed also matches a restored label, which is there only to block. When a guard's allow rests on a restored value, mlld turns it into a deny:

    mlld: Guard blocked operation: this guard's allow relied on session history restored from an unsealed tape or loaded by @mx.hydrate, which can only deny; for a resumed run, start it with --fresh or seal tapes
    

    To let an allow depend on something verified, test .mx.proof, which lists only fact claims backed by proof (see mlld howto labels-facts).

Sealed tapes

Do you need it? Only if other people or programs can write to your project's .llm folder. A tape is a local file, and anyone who can edit it can also edit your script and your policy, so on a machine where only you change the project, sealing adds nothing.

Without sealing, mlld still checks every tape's hash chain, so a damaged, truncated or reordered file (a crash, a bad merge, a careless edit) is refused rather than resumed. A large result stored in the payloads folder is checked against its hash when a resumed call reads it: a missing or changed file stops the run, naming the payload, instead of making the call again. What it does not catch is a deliberate edit: a label removed from a recorded value before a resume goes unnoticed, and the value comes back without it.

To seal, list your ssh public key as a signer in a policy module that mlld-config.json imports, and keep that key in your ssh-agent:

{ "policy": { "import": ["./pol.mld"] } }
policy @config = {
  * { self_attestation: { signers: { "me": { key: "ssh-ed25519 AAAA...your-public-key..." } } } }
}
export { @config }

Replace the key with the first two words of your own .pub file (see mlld howto policy-signers). New runs then show sealed in mlld checkpoint list <script>.

At the start of each run, mlld makes a throwaway signing key that exists only in the run's memory and asks your ssh-agent to sign once, certifying it. That key then signs the tape after every model answer, every snapshot and the end of the run. The signatures are events on the tape; nothing else is written to disk. An agent that asks before signing (1Password, ssh-add -c) asks when the run starts; one that does not ask lets any program running as you seal a tape, as with mlld sig approve.

A certificate lasts 24 hours. A run that keeps going longer, such as a program that holds one run open for a session lasting days, swaps in a new throwaway key about an hour before the certificate runs out and asks your agent again to certify it, so an agent that asks shows one more prompt each day. If the agent cannot sign then (it has stopped, or you declined the prompt), the run carries on without sealing and says so once:

mlld: run tape .llm/runs/flow/<run-id>.tape.jsonl is not sealed from here on: its seal key could not be renewed: <reason>

Everything the run recorded up to its last seal stays sealed; what it records after that is treated as an unsealed tape.

When a seal certifies your words

A program that embeds mlld can record what you typed as a user turn marked .src:user:intent:*. When the config policy trusts that program (labeling.self_attestation: { host: { claims: ["intent"] } }, see Policy basics), a sealed turn counts as your own words after a restart. The seal then says more than "this tape is unchanged": it says you asked for it. So anything that can get a seal signed can put words in your mouth. A program running as you can do that two ways:

  • It asks your ssh-agent to sign. An agent that asks you before every signature closes this: add the key with ssh-add -c, or use an agent with its own approval prompt, such as 1Password. mlld asks the agent when a run starts, and once a day in a run that lasts longer, so this costs one prompt per run, plus one a day.
  • It reads your private key file and signs without the agent. A key file such as ~/.ssh/id_ed25519 can be read by every program running as you, and ssh-add -c does not stop that. Only a key that is never a readable file closes this: an ssh-ed25519 key kept inside an agent such as 1Password, which signs without handing the key to anyone. Hardware security keys (sk-ssh-ed25519, sk-ecdsa-sha2-nistp256) cannot be signers: mlld accepts ssh-ed25519 keys, and ecdsa-sha2-nistp256 keys for certifying a tape.

The throwaway key that signs the seals lives in the run's memory for the length of the run, so a program that can read that memory (a debugger attached as you) can seal with it until the run ends.

Approvals a program records for you

A program that embeds mlld can also record an approval: in a turn where you typed "yes, send it", it names the one tool call you approved and its exact arguments. mlld turns that into a permission for that call only. It counts only when the policy trusts the program with host: { claims: ["intent", "approval"] } and the turn is marked as your words and was not written under a model's influence. The arguments keep their own labels: approving a value a model suggested does not make it trusted anywhere else.

The permission is used up by one call. Before the tool runs, the run records the call and seals the tape, so a later restart can tell the call happened; if that seal cannot be signed, including when the run stopped sealing partway, the call does not run. A second call with the same approval is refused.

If the program stops after you approved but before the call ran, a sealed approval can be used after the restart, for the same arguments only, within an hour of when you typed it. The program copies it into the new run's tape with its original time, so moving it from run to run never extends the window.

This rests on the newest tape. Anyone who can change files in .llm/ can delete the newest run's tape, or have the program read an older one, and an approval that was still unused in that older tape comes back while it is within the window.

Your project's config policy can change the hour with labeling: { approvals: { restore_window: "30m" } } in a policy that mlld-config.json's policy.import loads. It takes a duration such as "30m", "2h" or "7d", 0 to restore nothing, or "never". With "never" an unused approval can be restored however old it is, so the older-tape replay just described has no time limit. A script or module policy that sets it is refused when it loads (see security-policies).

Clears a program records for you

A program that embeds mlld can also record that you cleared a source's influence on an agent session (see "Clearing a source" in builtins-ambient-mx). Like an approval, a clear is only as trustworthy as the program's recording channel: it counts because a verified seal says the program wrote it, and the seal is made with your signing key. Anything that can reach that key, or write through the program's recording channel, can record a clear in your name. Keep agents away from both: an agent must not be able to run the program's recording calls (tape:record, mlld tape record) or reach your ssh-agent or key file, for the reasons above.

A person's answers

A resumed run never asks a person the same question again. A question answered in the earlier run, at the same point and with the same question and options, is served the recorded answer, and the host is not asked. An approval served this way approves only the call it was given for, the same operation with the same arguments.

The served answer comes back marked as read from a tape. It carries the answer's proof, and counts as known user intent where it did before, only when the tape's seal verifies against your signers. Even then it is judged under the config in force now: a principal maps to roles through today's labeling.principals, and the trust the config gives the host is today's. A statement restored from a snapshot, rather than run again, gets no proof back at all. And as for every recorded approval, whoever can change files in .llm/ can have an older tape read, so an earlier answer is served again.

Without signers, a run writes an unsealed tape and says nothing. With signers but no matching key in your agent, it writes an unsealed tape and says why, once per project:

mlld: this project's tapes are not sealed: no key in the ssh-agent matches the policy's signers. A resumed run treats their answers as untrusted. (shown once)

Resume checks a sealed tape before using it, and refuses it if any byte has changed or a seal does not verify against your signers. A seal proves the tape is unchanged, not that its answers are true: values from a sealed tape still come back untrusted, but their recorded labels can permit an action as well as block one. A value that carried proof when it was recorded (see Limits) gets that proof back only when the same call, with the same arguments, is answered from a sealed tape and its => record step runs again in the new run. That holds whichever script reads the tape, including one replaying a tape another script recorded: the seal is what is trusted, not the script that wrote it.

Once the policy lists signers, resume refuses an unsealed run, because a tape whose seals were removed cannot be told apart from one that was never sealed:

mlld: --resume: run '20260926T013926Z-23b7af29' is not sealed, and this project's policy lists signers, so it cannot be trusted to continue from. To go on, start a new run with --fresh

Events written after a run's last seal (a run stopped between a write and its seal) are ignored with a notice, and the steps they covered run again.

Every tape, sealed or not, is refused if a line was removed or edited. Resume also refuses when the record of the checks made at a completed step does not match, which is what removing a guard's or a label rule's record looks like:

mlld: --resume: resume refused at step 3: the tape's record of the checks made there does not match (events were removed or changed); start with --fresh

Looking at runs

mlld checkpoint list <script>                        # runs, with status and markers
mlld checkpoint inspect <script> <run-id>            # a summary of one run, as JSON
mlld checkpoint show <script> <run-id> <event-id>    # one event with its payload
mlld checkpoint clean <script>                       # delete every run but the latest

--base-path <dir> looks for .llm/runs under another folder. In place of a run id, latest names the run the latest file points at, the one --resume would continue.

list shows each run's start time and status, which run is latest, and its markers, newest start time first. The status is finished for a run that ended cleanly, failed for one that stopped on an error, interrupted for one that never reached its end (killed, or the machine went down), plus sealed when a seal covers the tape. Seals are checked with the signers of the policy modules mlld-config.json imports, as a run checks them:

$ mlld checkpoint list stages
Runs of stages, newest first:
- 20260925T211702Z-f23ce527  2026-09-25T21:17:02.038Z  finished  (latest)
    checkpoints: outlined, drafted
Total: 1

inspect counts the run's events by type, lists the statements that have a snapshot and the markers, numbering statements from 1 as resume's messages do, and counts calls by kind (output shortened):

$ mlld checkpoint inspect stages 20260925T211702Z-f23ce527
{
  "script": "stages",
  "run": "20260925T211702Z-f23ce527",
  "status": [
    "finished"
  ],
  "events": 30,
  "eventsByType": { "annotation": 2, "snapshot": 6, "tool_call": 3, "tool_result": 3, "verdict": 8, ... },
  "snapshotSteps": [2, 3, 4, 5, 6, 7],
  "iterationSnapshots": 0,
  "checkpoints": [ { "name": "outlined", "step": 3 }, { "name": "drafted", "step": 5 } ],
  "calls": { "llm": 3, "other": 0 }
}

show prints one event as the tape stores it. Event ids are the id field of each line in the tape file. A stored step counts statements from 0, so the outlined marker above shows "step": 2. A payload the tape stores in a separate file is read in as payload_value, and a withheld event (one that held a secret) says so instead (output shortened):

$ mlld checkpoint show stages 20260925T211702Z-f23ce527 42d92bac
{
  "id": "42d92bac",
  "parent_id": "9135a23f",
  "payload": {
    "raw_value": { "text": "answer to outline", "type": "string", ... },
    "tool": "sh",
    "tool_use_id": "709ec6ea"
  },
  "producer": "mlld:exec",
  "seq": 5,
  "type": "tool_result",
  ...
}

clean keeps the run latest names and removes the other tapes, their conversations, and stored payloads the kept tape does not use:

$ mlld checkpoint clean stages
Removed 3 run(s) and 0 payload(s) from "stages"; kept 20260925T211702Z-f23ce527 (latest).

A project with a non-empty .llm/checkpoints/ folder gets a one-line notice the first time, and the folder is left alone. The notice is not repeated (a .llm/.legacy-checkpoints-noticed file records that it was shown):

mlld: .llm/checkpoints is from an older mlld; run tapes live in .llm/runs. Nothing reads .llm/checkpoints now: delete it when you no longer need what it holds (rm -r .llm/checkpoints)

Refused spellings

These are refused, each with a message:

  • --resume @fn, --resume @fn:N, --resume @fn("prefix"): use --resume, --resume <run-id>, --from <run-id>, or a checkpoint "name" marker and --resume <name>.
  • mlld checkpoint freeze <script>: to keep a run, copy its tape folder, .llm/runs/<script>/.
  • --fork <other-script>: use --replay .llm/runs/<other-script>/<run-id>.tape.jsonl (see Replaying a run).
  • --frozen <file>: use --replay <file> --llm stop --other stop.
  • box with { replay: <file> }.
  • @mx.checkpoint (including @mx.checkpoint.hit): a value restored from a tape carries the .src:tape label instead.

The refusal for --resume @fn:

Error: --resume no longer takes a function target (@fn, @fn:N, @fn("prefix")); use plain --resume to continue the latest run, or --resume <run-id>

And for @mx.checkpoint.hit:

Error: Pre-flight validation failed:
run preflight refused on 1 Error-severity validator diagnostic(s):
  error [code-less] @mx.checkpoint is retired: a replayed or resumed value carries the .src:tape label; test its labels instead (line 1, col 6)

Live STDIO Transport

Persistent NDJSON RPC transport for long-running SDK operations. Each line on stdin is one JSON request; each line on stdout is one event or one response.

mlld serve live --stdio

Protocol format:

>> Request
{"method":"execute","id":2,"params":{"filepath":"/abs/path/agent.mld","payload":{"task":"a"}}}

>> Events while the request runs (each carries the request's id as requestId)
{"event":{"id":2,"requestId":2,"type":"state:write","write":{"path":"count","value":5,...},...}}
{"event":{"id":2,"requestId":2,"type":"effect","effect":{"type":"both","content":"task a\n",...},...}}

>> Result
{"id":2,"result":{"id":2,"output":"task a\n","exports":{},"stateWrites":[...],"effects":[],"denials":[],"asks":[],"sessions":[],"traceEvents":[],"metrics":{"totalMs":10.4,"effectCount":1,"stateWriteCount":1}}}

>> Error
{"id":3,"error":{"code":"RUNTIME_ERROR","message":"..."}}

Methods:

  • process — Execute script text via params.script
  • execute — Run a file via params.filepath with optional payload, state and labels
  • validate — Static analysis of params.filepath: valid, errors, warnings, executables, exports, imports, guards, variables, stats. A file that fails to parse returns valid: false with a PARSE_ERROR entry; a missing file returns FILE_NOT_FOUND.
  • state:update — Update the host state of the in-flight request params.requestId (path + value)
  • file:write — Write a file on behalf of an in-flight request
  • sig:sign, sig:verify, sig:sign-content — Signing helpers
  • tape:append — Add a note to the run tape of params.requestId (see below)
  • tape:open, tape:record, tape:close — Record the host's own session on a tape, with no script running (see below)
  • tape:heads — Verified heads for an open session, which a later tape:open or tape:verify admits (see below)
  • tape:verify — Check a host session's files read only, from verified heads where given, including a session kept in pieces (see below)
  • check — Ask whether a harness tool call would be allowed, asked or denied, before the harness runs it (see below)
  • call — Call one exported function of a module with JSON arguments, keeping the module loaded between calls (see below)
  • module:digest — A digest of a module and everything it imports that is the same on any machine for the same code (see below)
  • ask:answer — Answer an ask that a request started with asks: "host" is waiting on (see below)
  • envelope:canonical — Build an unsigned envelope around a value and return the exact text to sign (see below)
  • envelope:verify — Check whether the project would admit a sealed envelope, and what it claims, without running anything (see below)
  • cancel — Abort an active request: send {"method":"cancel","id":<id of the request to stop>}. The stopped request answers with an ABORTED error.

fs:status is refused (METHOD_UNAVAILABLE); use mlld sig drift for attestation drift, or mlld sig unsigned for files with no attestation.

Events: a running request emits state:write (a write to a state external slot), state:session_write (a write to a state session slot), guard_denial, guard_ask and effect events. Set recordEffects: true to also collect the effects in the final result's effects list (wrapper SDKs set it for you). eventMode: "all" is refused.

Process params:

{
  "script": "show @input.sdk.key",
  "filePath": "/example/context.mld",
  "payload": {"key": "value"},
  "state": {"sessionId": "123"},
  "mcpServers": {"tools": "uv run python3 server.py"},
  "allowAbsolutePaths": true,
  "recordEffects": true
}

Execute params:

{
  "filepath": "/abs/path/agent.mld",
  "payload": {"task": "analyze"},
  "payloadLabels": {"task": [".pii"]},
  "state": {"conversationId": "abc"},
  "stateLabels": {"conversationId": [".secret"]},
  "mcpServers": {
    "tools": "uv run python3 server.py --config abc",
    "docs": {"command": "npx -y docs-mcp", "box": {"fs": {"write": ["~/.npm"]}}}
  },
  "recordEffects": true
}

Unknown params are refused with INVALID_REQUEST, and the message lists the known ones. dynamicModules, dynamicModuleSource and dynamicModuleMode are refused (METHOD_UNAVAILABLE); pass data through payload and read it as @input.sdk.<field>. mode: "markdown" is refused. timeoutMs is accepted but does not stop a run.

mcpServers maps logical names to MCP server commands. import tools from mcp "tools" as @t in the script resolves against this map before treating the spec as a shell command. Each request gets its own server lifecycle. A server runs sandboxed, as run cmd does: it may write only inside the project. To give one server more room, write its value as an object, { "command": "…", "box": { … } }; box is the setting import tools from mcp … using { box: … } takes (see mcp-import). An object with any other key is refused with INVALID_REQUEST.

State: the request's state object is the host state. The script declares the slots it reads with state external @app = { … }; reading it in a request with no state is refused. stateLabels (dotted path → labels array) adds labels to seeded fields; every value read from the host state also carries .src:state and .src:state:@app.<slot>. Writes such as @app.set({ count: 5 }) are visible to later reads in the same run, and a write's labels carry over to the written slot. Labels apply per slot: labeling config.api_key labels every read of @app.config.*, so keep labeled values in their own slots. stateLabels, and the labels of a state:update, may not name a label mlld writes only from what it observed itself (.src:envelope, .src:tape, .src:selector, .src:host, .src:state, .src:fyi, and anything under them). Such stateLabels refuse the whole run, with error code DENIED and denial.code sig.envelope.origin_label; such a state:update is refused with error code sig.envelope.origin_label and changes nothing. .src:state labels a run reported in stateWrites are the exception: sending them back is allowed and they are dropped, since mlld adds its own state labels on every read. Say where the host got a value with a channel label such as .src:file or .src:web instead.

State updates (during execution):

>> Request to update in-flight state
{"method":"state:update","id":5,"params":{"requestId":4,"path":"stop","value":true}}

>> Response
{"id":5,"result":{"id":5,"path":"stop","requestId":4}}

The update is queued and applied at the script's next read of the host state. A request started without a state object has nothing to update and returns RUNTIME_ERROR; an unknown request id returns REQUEST_NOT_FOUND.

Run tapes:

A process or execute request with "tape": true writes a run tape, the same record mlld run keeps (see tapes). It lands under .llm/runs/<script>/ in the project that filePath (or filepath) belongs to; a process request with no filePath writes under .llm/runs/_eval/. Without tape, or with false, the run writes no tape. A value other than a boolean is INVALID_REQUEST. A request over the wire always starts a fresh run: a script's resume: auto header does not continue an earlier unfinished run here.

While such a run executes, the host can add its own note to that tape:

>> Request
{"method":"tape:append","id":2,"params":{
  "requestId": 1,
  "kind": "checkpoint",
  "text": "user approved the draft"
}}

>> Response
{"result":{"id":2,"requestId":1}}

The note is written as an annotation event with producer host, in the same file and hash chain as the run's own events, so the run's seal covers it. The response means the note is queued, not yet written: it is written between top-level statements, or just before the tape closes. Notes carry no authority; resume and replay skip them.

  • kind and text are required strings (INVALID_REQUEST otherwise).
  • An unknown requestId, or a run that has already finished, is REQUEST_NOT_FOUND.
  • A run started without "tape": true is RUNTIME_ERROR.
  • A queued note that could not be written (the run failed before it started evaluating, or its tape could not be opened) is counted in the final result as tapeAppendsDropped: <n>. On an error response the count sits on the error object. The field is absent when nothing was dropped.

Host session tapes:

tape:append adds a note to a run that is executing. To record a session of the host's own (an agent harness's conversation, say) when no script is running, open a session tape, record its events, and close it. mlld writes its own tape format and chains and seals every record, so the host does no cryptography. Use tape:append to annotate a run; use these when there is no run.

>> Request
{"method":"tape:open","id":1,"params":{"name":"harness","host":"fray","session":"s-42","basePath":"/example/project"}}
>> Response
{"result":{"id":1,"tape":"20261025T221435Z-61418818","name":"harness","path":"/example/project/.llm/tapes/harness/20261025T221435Z-61418818.tape.jsonl","sealed":true}}

>> Request
{"method":"tape:record","id":2,"params":{"tape":"20261025T221435Z-61418818","kind":"user","conversation":"main","text":"push it","labels":[".src:user:intent:literal"]}}
>> Response
{"result":{"id":2,"event":"20261025T221435Z-61418818/5c1f0a2b","seq":4,"sealed":true}}

>> Request
{"method":"tape:close","id":3,"params":{"tape":"20261025T221435Z-61418818"}}
>> Response
{"result":{"id":3,"tape":"20261025T221435Z-61418818","events":1,"sealed":true}}
  • tape:open takes name (the tape's name), host (which host is recording, written on the tape's session_start) and session (the host's own id for the session), and optional heads (see tape:heads) with the hostSummary they bind. basePath picks the project, as for other methods; its config policy decides the signers, and nothing in the request does. The tape is .llm/tapes/<name>/<tape>.tape.jsonl, and tape is the handle the other two methods take. Opening may wait for the user's ssh-agent to sign; it holds up nothing else on the connection. When no agent key can sign, a host-bound signer from the config seals the tape instead, covering only the host's own events (see policy-signers). A session that already has a file goes on in that file, as mlld tape open does (see cli-tape), and the result says so with continued. Until the handle is closed, only it writes the session's file: a tape:open of the same session from another connection, or a mlld tape call on it, is refused at once. Opening it again on the same connection, even while the first open is still waiting, answers with that handle, so a client that timed out waiting for the first answer gets it. An open sent after a tape:close but before its answer is refused; wait for the close's answer.

  • tape:open takes an optional lockWaitMs: how long, in milliseconds, the open waits while another process (an mlld tape hook call) holds the session's lock. Past it the open records nothing and answers SESSION_BUSY. The wait starts after the open has loaded the project's config. Left out, it waits 60 seconds. A session another live host has open is refused at once whatever the wait.

  • tape:record takes tape, kind and that kind's fields:

    • user: conversation, text, optional labels, principal {id, login} and senderKind. A turn labelled secret is refused. senderKind says who sent a message delivered to the agent as its prompt: "agent" for another agent, "person" for a person; any other value is refused. An agent's message makes the session's later model output .influenced whether or not it carries labels; a person's is untrusted unless it is your user's own words (see "Delivered messages" in sdk-language-sdks). Leave it out and the turn is judged by its labels and principal. It grants nothing.

    • tool_call: tool (for example "harness:claude/Bash"), toolUseId, args (an object), optional labels and hostFields. Arguments labelled secret are withheld and args may be left out; otherwise it is required.

    • tool_result: tool, toolUseId, optional outcome (allowed, the default; failed; or denied), labels and hostFields.

      • allowed: value (any JSON). A value labelled secret is refused; leave value out and label the result secret to record it withheld, with its labels and no value.
      • failed: error, the tool's error or what the model was told, and no value.
      • denied: denied {by, reason}, who refused the call (a gate or hook, by name) and why, an optional error, and no value. Without error, the reason is recorded as the error.

      A failed or denied result is written as a tool_failed event. It never counts as a value: no fact, reference or proof comes from it. It still restricts: when the session is hydrated or checked, an error labelled untrusted that the model saw makes later model output .influenced, as an untrusted result does, and a person can clear it the same way.

    • note: noteKind and text, optional data (any JSON) and facts: a list of {kind, value} strings, [{"kind": "path", "value": "src/a.rs"}, {"kind": "path", "value": "src/b.rs"}], which can hold several facts of one kind, or an object of strings, {"path": "src/a.rs"}, as shorthand for one fact per kind. A script finds the note by its facts with .select({ fact: { kind, value } }); the facts are the host's claims, never proof.

    • assistant: conversation, model, message (the provider's message as a string, exactly as the host received it; mlld stores it byte for byte), optional toolUseIds (a list), stopReason and messageId. Each conversation's turns are numbered from 0 on the session, across processes that continue it. It takes no labels: mlld labels it .src:llm:claimed, because the reply is your claim that a model wrote it; mlld did not see the call. Only replies from llm calls mlld runs itself carry plain .src:llm. A policy rule on .src:llm still applies to a recorded reply, since labels match by family.

    • answer: question, chosen and optional principal {id, login}. This records a person's answer to the question a deferred check put on the session (see below): question is the ask.ref that check returned, and chosen is "1" to approve or "2" to deny. It is refused, and nothing is written, when question is not a question on this session (ASK_REF_UNKNOWN) or already has an answer (RUNTIME_ERROR). It takes no labels.

    • clear: causes (a non-empty list of cause refs, "<session_id>/<event_id>", as @mx.history.influence and mlld why --causes name them), principal {id, login?} (required), optional reason. A person sets those influence causes aside (see builtins-ambient-mx, "Clearing a source"); it takes no labels. Recording it grants nothing: whether it counts is decided each time the session is hydrated or checked, under the config policy's host.clear row and a verified seal. mlld also adds the clear to the project's clear index (.llm/clears/index.jsonl), so that with host.clear.across_sessions a later hydrate of another session that read the same content can find it; a check counts only clears recorded on its own session. A clear is only as trustworthy as this connection: keep agents from sending on it, and from reaching the key that seals the tape.

    • helper_start and helper_stop: helperId, optional parentToolUseId and hostFields. A helper (a subagent) your agent started, and its end. helperId is your id for the helper, which pairs its start with its stop; parentToolUseId is the tool call that started it, its link to its parent. Each is at most 256 bytes. Neither takes labels: put those on the helper's own calls and results. Both are your claims: mlld does not check that a stop has a start, and nothing reads either as a label, a fact or proof. A script finds them with .select({ type: "helper_start" }).

    • event: type, optional data (any JSON), facts (as a note's) and hostFields. An event of a type you define, such as opgate.checkpoint or fray.message, written on the tape under that type. The type is <namespace>.<name>: two or more parts joined by dots, each a lowercase letter followed by lowercase letters, digits or _, at most 128 bytes. The namespace (the first part) may not be one of mlld's: a type mlld writes (tool_result, message, ...), a name starting mlld, host, sdk or script, or the first part of one of mlld's trace event names (box, guard, handle, import, lang, llm, mcp, memory, policy, read, record, session or state, so guard.allow is refused); a type without a namespace, such as checkpoint, is refused too. The last part may repeat one of mlld's names (fray.message is fine), since nothing matches a type by its last part. It takes no labels. It is your claim, as a note is: a script finds it with .select({ type: "opgate.checkpoint" }) or by one of its facts, and nothing reads it as a value, a label, a fact or proof. data is written exactly as given and is the event's body: a host that stores bodies apart from their events can delete it later (see tape-methods, "Stored and pruned bodies"). Put what must outlive that, such as a signature over your own content, the key id it was made with or an encryption marker, in hostFields, facts, author or source, which stay in the event; mlld checks none of them.

    Every kind takes an optional source: which hook or component of the host wrote the event ("hook:PostToolUse", "tailer"). It is written as given and proves nothing: anything able to send tape:record on this connection, or to run mlld tape record in the project, can write any source. Only a host-key seal (see policy-signers) shows which process wrote a line.

    Every kind also takes an optional author and occurredAt. author is your permanent id for whose words or act the event records (a person, an agent), at most 256 bytes; source says which hook wrote the event, author says whom it is about. It is never a principal: it gives no role and does not stand in for a principal on an answer or a clear. occurredAt is when you say the event happened, an RFC 3339 time such as 2026-11-13T20:47:52Z; the line's own ts stays mlld's clock, the time it was written. A blank author or a time that is not RFC 3339 is refused and nothing is written. Both are written as author and occurred_at in the event.

    hostFields is an object of the host's own fields on a tool call or result, on a helper's start or stop, or on an event: paths, line fingerprints, intent, agent id, model, turn id, working directory. It is written under host_fields in the event, also on a result whose value is withheld, so a judge can read what a call touched when the file's contents never leave the machine. It is at most 64 KiB as compact JSON; a larger one is refused with HOST_FIELDS_TOO_LARGE and nothing is written. It is the host's claim: nothing in it is read as a label, a fact, a principal or proof, whatever the field is named and whatever the config's host row grants, and fields on a call whose arguments are withheld do not let @mx.hydrate decide without them. The same holds for a note's or an event's data and facts, source, author, occurredAt, and denied.by.

    The response comes after the event and the seal over it are written and flushed with an ordinary fsync: a crash of the server loses nothing it answered for. A power loss can lose more: it may cut the last line short, which mlld drops with a notice when it reads the tape, and on macOS, where an ordinary fsync leaves data in the drive's cache, it can lose the most recent records whole, even ones already answered for. The lines that remain still verify. The records that matter most get the full flush: the session's signing statement, a check that uses up a person's approval, and the session's end. event is "<tape>/<event id>".

    Batches. To record many events in one request (a history being imported, a transcript turned into a tape), send tape:record with tape and records, a list of records, each an object with the fields a single tape:record takes except tape:

    >> Request
    {"method":"tape:record","id":4,"params":{"tape":"20261025T221435Z-61418818","records":[{"kind":"user","conversation":"main","text":"push it","occurredAt":"2025-03-01T09:30:00Z"},{"kind":"note","noteKind":"import","text":"from the old log"}]}}
    >> Response
    {"result":{"id":4,"events":[{"event":"20261025T221435Z-61418818/5c1f0a2b","seq":5},{"event":"20261025T221435Z-61418818/9d02e4c1","seq":6}],"sealed":true}}
    

    The records are written in the order given and sealed once, after the last of them, and the response comes when they are all on disk: much faster than one request each, since each request seals and flushes the file. A batch is all or nothing. Every record is checked before anything is written, an answer against the session's questions and against the answers before it in the batch, and one refused record refuses the whole batch: the error has index, the refused record's place in records from 0, and its message says nothing was written. A request with records takes no other field than tape, and an empty records is refused. Each record is written exactly as it would be on its own, so the events, and what influence, clears and every other rule make of them, are the same as for the same records sent one at a time; only their ts and the seals between them differ. occurredAt keeps each record's own time, since ts is when the batch was written.

  • tape:close writes session_end and a final seal, and answers with how many events were recorded.

  • tape:open, check, tape:heads and tape:verify take an optional trustedSigners: the signer keys your host trusts for the session's files, as an object of principal to entry shaped like the config's signers (see policy-signers): key, optional valid_after and valid_before, and hostKey for a key that seals only the host's own events. labels and classes are refused. The keys verify the files' seals; they never sign, so they do not make the session sealed. They count only when the project's config names no signers: a config that names any is the whole trust set and your keys are ignored. Each result says which set was used, in signersFrom: "config", "host" or "none". Given on check or tape:heads, they replace the keys the handle holds from that request on; null or {} drops them. A key outside its validity window counts for nothing, judged at the time of each request. Changing the keys drops what earlier checks on the handle kept, so the next check reads the files again, and a head made under one set of keys is not admitted under another (HEAD_SIGNERS_CHANGED). They apply only to the reads you ask for here; a script's own reads (its resume, its own tape, approvals and activations it restores) use the config's signers alone. A malformed trustedSigners is INVALID_REQUEST.

  • tape:heads takes tape, an optional expiresInSeconds (1 to 31536000; 24 hours when left out) and an optional hostSummary (base64: your own record of the session, which the heads bind by hash). It checks every file of the session and answers {"heads": [{"statement", "signature", "fold"}, ...]}, one verified head per file that verifies, at its last line, signed through the ssh-agent by a key mlld-config.json lists under tape.checkers; with none listed, or none in the agent, it fails with RUNTIME_ERROR. A file no head could be made for is listed under headsSkipped as {runId, reason}. If the handle took the session up and has not recorded since, its file ends in a renewed certificate, so the head request seals it first. Nothing else is written to the tape: keep the heads yourself, unchanged, with the summary they bind, and pass them as heads (and the summary as hostSummary) to a later tape:open, so a new server process does not check again the seal signatures up to each head. The open's result then has heads, one {runId, admitted, code?} per head given; one that does not count is ignored and its file checked in full, so the open answers as it would without it.

  • tape:verify checks every file of a session read only, with no handle and no lock: it takes name, host, session and basePath as tape:open does, and optional heads, hostSummary, store, trustedSigners and bodies as there, plus makeHeads (true for fresh heads) and nextHostSummary (base64, the record the fresh heads bind). It answers {verified, files: [{runId, path, verified, events?, sealedThrough?, error?, head?}], influence}, influence being untouched, influenced or cleared, with heads and headsSkipped when makeHeads is true. This is the call for a host that keeps a session in pieces: hand only the lines added since the last head as the run's file in store, with that head and the summary it binds, and only those lines are read (head: {admitted: true, piece: true}). A head that does not count there refuses the file (head: {admitted: false, piece: true, code}, verified: false) and the session reads as influenced, since the lines before it are not there to check. What a head binds, what it skips, what checking a piece cannot find, and the HEAD_* codes are described under "Checking the whole session, and verified heads" in cli-tape.

  • Stored bodies. tape:open takes an optional bodies: {"storeAll": true, "keys": [{"id": "k1", "key": "<base64>"}]}, both parts optional. storeAll puts every event body (a user turn's text, a tool call's args, a result's value, a note's text and data) in the tape's payload store whatever its size, so you can delete a body's file later and the tape still verifies; a reader then reports that body as pruned. keys names stored bodies by a keyed hash, hmac-sha256-<id>-<hex>, under the first key, so nobody holding the tape can test a guess at a body; later keys check bodies written under earlier ones. A key id is 1 to 64 of a-z, 0-9 and _; a key is at least 16 bytes, given in standard base64. Keys are secrets: mlld keeps them in memory for the handle, uses them for its records, checks, heads and close, and never writes them to the tape, to a result or to an error. A key lets mlld check a body, never trust it. A body checked under a different key with the same id counts as a changed file: the session's file does not verify, so the session goes on in a new file and restartReason says why. A malformed bodies is INVALID_REQUEST. See "Stored bodies" in cli-tape.

  • Keeping the session's bytes yourself. By default a session's tape lives in files under .llm/tapes/<name>/. A host that keeps it elsewhere (a database row, an encrypted object) passes store to tape:open: {"files": {"<runId>": "<base64>"}, "payloads": {"<name>": "<base64>"}}, every file and payload it kept for the tape, or {} for a session it has never recorded. mlld checks those bytes exactly as it checks files (the chain, the seals, each payload against its name), so bytes that were changed are refused, and a payload that is missing reads as pruned. Every answer on that handle, the open's included, then carries stored in the same shape: the bytes mlld appended to each file since the last answer that carried stored (a new file's from its first line) and the payloads it stored. Append each file's bytes to what you keep for it and keep each payload under its name; an error answer carries none, and what it wrote comes with the next answer. Nothing of the tape is written under .llm/tapes/. One handle holds the bytes you hand in, so do not hand the same session to two handles at once: the lock that keeps two writers apart is yours. path in the open's result names where the file would be, not a file on disk.

  • sealed is false, with sealReason, when the tape cannot be sealed (the config lists no signers, or the agent is unavailable). Events are still recorded.

  • A handle belongs to the connection that opened it. When the connection ends, every open tape is closed and sealed. Several may be open at once. The server waits up to 10 seconds for those final seals before it exits; a tape whose open is still waiting for the ssh-agent then is left unsealed, and stderr names it.

  • Recording grants nothing: a user turn counts as the user's words only under the config policy's host self-attestation row and a verified seal, and a recorded tool call or result counts for nothing (see tapes).

  • An open tape follows the project's config as it is now. Before each tape:record and check, mlld loads the config again if any file it was loaded from has changed: mlld-config.json, mlld-lock.json, the policy files, the hostTools module (below) and every file they import. A config that imports from a URL, fetches a registry module or starts an MCP server is loaded again before every request, since what those return can change with no file changing. A signer or a person's role the owner removes stops counting from the next request, as it would for mlld check run on its own. If the config no longer loads, the request is refused and nothing is written.

  • A host that records from hook scripts, one process per event, uses mlld tape open|record|close instead (see cli-tape): the same fields and results, with the session named by name, host and session rather than a handle.

  • Errors: a missing or malformed field (an optional one given with the wrong type included, such as a numeric basePath or principal.login), a field the method or the record's kind does not take (a misspelled principle, say, which would otherwise drop the principal), or a kind other than the nine above (approval included), is INVALID_REQUEST, and the message lists the fields it takes; a refused record is RUNTIME_ERROR; hostFields over 64 KiB is HOST_FIELDS_TOO_LARGE; a tape this connection did not open, or has closed, is TAPE_NOT_FOUND. None of them writes anything.

Checking a harness tool call:

check asks "may this tool call go ahead?" about a call your harness is about to make, on a host session you opened with tape:open. It runs the same checks mlld makes before it runs a call of its own: the project's policy, its guards and its grants. It stops before the call, so nothing runs, nobody is asked, and no approval is used up, except as a deferred ask (below) describes.

It also reads what the session has recorded so far, in every file of the session, as @mx.hydrate reads a session (see builtins-ambient-mx). The call is the model's next output, so once a tool result the policy counts as untrusted is on the session (one labelled .src:net, for example), the call's arguments are .influenced, and a rule on .influenced applies to them. A session file that has been edited since mlld wrote it counts as influenced too. A person's clear of that result (tape:record with kind clear) lifts it as it lifts it for a hydrate: only under a verified seal and the config's host.clear row, and never for a never: law or a locked rule.

>> Request
{"method":"check","id":4,"params":{"tape":"20261025T221435Z-61418818","tool":"harness:claude/Bash","toolUseId":"toolu_1","args":{"command":"git push"},"labels":[".op:tool:w"]}}
>> Response
{"result":{"id":4,"verdict":"ask","reason":"review the write","ask":{...},"named":true,"check":"sdk:host#0/check:harness:claude%2FBash#0","toolUseId":"toolu_1","sealed":true}}

In check, the tool name is written with %, # and / percent-escaped (harness:claude/Bash becomes harness:claude%2FBash), so a tool name can never read as part of another check's position. Pass the position back as it was returned.

  • tool is your harness's name for the tool. args is the call's arguments as an object; each key is read as a parameter.

  • labels (optional) are the tool's operation labels, .op:* and .risk:* only. They decide which policy rules apply (for example .op:tool:w { ask: "…" }). They count in full only when the project's config lets the host name this tool:

    • The host row must grant the tool claim and list the tool in tool.tools, for example self_attestation: { host: { claims: ["tool"], tool: { tools: ["harness:claude/*"] } } } (see policy-basics).
    • Otherwise the call is judged as an unnamed tool, and named is false. Its labels can still refuse it: a deny, ask or guard on them applies. They never let it through: an allow! exception, an only or allow list, or a guard's allow on them has no effect. Renaming a tool, or leaving out the claim, never makes a call easier to pass.
  • A mapping module. The project can name a module in mlld-config.json as "hostTools": { "module": "./tools.mld" }. The module exports a tools collection named @hostTools whose keys are harness tool names:

    exe @Bash(command, description) = cmd { … }
    tools @hostTools = {
      "harness:claude/Bash": { mlld: @Bash, labels: [.op:cmd:w] }
    }
    export { @hostTools }
    

    A key matches a tool's name as tool.tools does: * stands for any run of characters, so "harness:claude/*" covers every name a host may send for Claude's tools, however it spells them. A key that is the name itself wins over a pattern; when several patterns match and none is the name, the call is CHECK_UNAVAILABLE. A tool the host may name (the tool claim, as above) that @hostTools maps is judged as a call of that entry. The entry's labels and inputs record apply, and so do the guards and policy the module declares; the request's labels are not used. Arguments are matched to the exe's parameters by name, so the exe needs a parameter for every argument the harness sends (Claude's Bash tool sends description as well as command); an argument it has no parameter for makes the call CHECK_UNAVAILABLE. So does an entry with bind, since the harness runs the arguments it sent, not bound ones. The module's guards and policy judge only the tools it maps: any other tool is judged exactly as it would be with no module. The module is loaded when the session opens, and again whenever its files change: a module that cannot be loaded, or that exports no @hostTools collection, refuses tape:open, or the request that found it so, with a message naming mlld-config.json. The path is resolved from the project root, as policy.import paths are, and may lead outside it. With mlld tape and mlld check each call is its own process and loads the module again, so anything the module runs at its top level runs on every hook call; keep it to declarations. An entry with a draft handler is CHECK_UNAVAILABLE, since a policy could send the call to that handler.

  • argLabels (optional) are labels put on every argument, such as untrusted for something the session read that was never recorded on it. They can only restrict. A label that would let a value through (trusted, a fact, user intent) is refused, and so is a source label that names the user or mlld itself, such as .src:user. A source label naming the outside channel a value came from (.src:net, .src:file, .src:cmd, .src:mcp:<server>) is accepted. Every argument label only restricts: it can trigger a deny, ask or guard deny, and never meets a guard's allow or an allow!.

  • Each label in labels and argLabels is one label. A combination (untrusted+trusted) or a negation (!untrusted) is refused, as is a label with whitespace around it, and an operation label that is not written exactly as one (.op:tool:w:, .op: tool:w, .op:*).

  • toolUseId (optional) is sent back as given.

  • The policy and any mapping module come from the project's mlld-config.json, never from the request: a policy, module or hostTools field is refused.

  • verdict is allow, ask or deny:

    • an ask carries reason and ask, shaped as on a guard_ask event;
    • a deny carries reason, plus denial (shaped as on a guard_denial event) when a guard or policy refused.
  • When an ask stands over a deny, the answer is the deny unless approving the ask could lift it.

  • check is the tape position the check's records are under. mlld why --name <name> --host <host> --session <session> --position <check> explains the check from them (see why, "A host session's checks"). The records are sealed as a tape:record is.

  • A call whose inputs, or whose guard, would have to run code before the answer is known is CHECK_UNAVAILABLE, naming what would run: a check never runs code.

  • Before it judges, a check reads everything the session recorded. On an open tape the server remembers what its earlier checks verified, so a check verifies only what was recorded since. It still confirms that the part it verified before is unchanged and re-checks the signers against the config; if anything differs, it checks the whole session again and answers as a new process would.

  • A hook script asks the same with mlld check (see cli-tape). Each mlld check is a new process and checks the whole session.

Asking now, answering later:

A hook usually has to answer within seconds, while the person it would ask may answer hours later. With askMode: "defer", a check whose verdict is ask does not wait: it writes the question on the session's tape and returns at once.

>> Request
{"method":"check","id":5,"params":{"tape":"20261025T221435Z-61418818","tool":"harness:claude/Bash","args":{"command":"git push"},"labels":[".op:tool:w"],"askMode":"defer"}}
>> Response
{"result":{"id":5,"verdict":"ask","reason":"review the write","ask":{...,"ref":"20261025T221435Z-61418818/ev-9"},"named":true,"check":"...","sealed":true}}
>> Request (later, once the person approved)
{"method":"tape:record","id":6,"params":{"tape":"20261025T221435Z-61418818","kind":"answer","question":"20261025T221435Z-61418818/ev-9","chosen":"1","principal":{"id":"gh:12345678","login":"ada"}}}
>> Request (the harness tries the call again)
{"method":"check","id":7,"params":{"tape":"20261025T221435Z-61418818","tool":"harness:claude/Bash","args":{"command":"git push"},"labels":[".op:tool:w"],"askMode":"defer"}}
>> Response
{"result":{"id":7,"verdict":"allow","spent":"20261025T221435Z-61418818/ev-9","named":true,"check":"...","sealed":true}}
  • ask.ref names the question. Show the person ask's question and options, then record their choice with tape:record kind answer: "1" approves, "2" denies.
  • Checking the same call again before anyone answers returns the same ref and writes nothing new.
  • After an approval, the next deferred check of the same call (same tool, same arguments) is allow once, and spent names the question it used up. The check writes that on the tape before it answers. A denial makes it deny, and uses nothing up; once the denial is older than labeling.approvals.restore_window, the call is asked about again.
  • An approval counts only when all of these hold; otherwise the check fails with the code shown:
    • the project's config lets the host approve: the host row grants approval (see policy-basics). Without it, the answer is recorded but ignored, and the check keeps asking the same question;
    • the tape was sealed when the answer was recorded (ASK_ANSWER_UNSEALED);
    • the answer is newer than labeling.approvals.restore_window, one hour unless the config says otherwise (ASK_ANSWER_EXPIRED);
    • no earlier check used it up (ASK_ANSWER_SPENT);
    • the answer was recorded for this exact call (ASK_ANSWER_MISMATCH), and names a question on this session (ASK_REF_UNKNOWN).
  • When a check fails for one of these reasons, it writes a fresh question first and names it in the error as error.ask.ref, beside the code; the next check of that call returns a plain ask under it instead of failing again.
  • Changed arguments are a different call: they get a new question, never the old answer. The one exception is the same toolUseId with other arguments than an approved, unused question for it, which fails with ASK_ANSWER_MISMATCH, since one tool call has one set of arguments.
  • "Used up" is a line on the tape. Someone who can put the session's tape files back to an earlier state can make an approval count again while it is inside the restore window.
  • Without askMode, a check reads and writes nothing for an ask. askMode takes only "defer".

Host asks:

Two kinds of question can wait for you. A guard or policy can answer ask "reason" to hold an operation for review (see security-guards-basics); when the script has no asking => arm around the operation, the review comes to you as a two-option menu, Approve or Deny. And a script can put its own question to a person with match ask (see match-value-returning), or let an agent ask one through @mlld/ask. A request started with "asks": "host" sends you each of these, and the run waits for your answer:

>> Request that opts in (askTimeoutMs is optional; the default wait is 5 minutes)
{"method":"process","id":1,"params":{"script":"...","asks":"host","askTimeoutMs":60000}}

>> The run pauses and sends the question, with an askId
{"event":{"id":1,"requestId":1,"type":"guard_ask","guard_ask":{"askId":"ask-1","source":"guard","guard":"g","operation":"send","reason":"review send","question":[{"text":"review send","agentWritten":false}],"options":[{"id":"1","label":"Approve","agentWritten":false},{"id":"2","label":"Deny","agentWritten":false}],"menu":"developer","freeText":false,"labels":[],"args":{"msg":"hi"},"rule":null}}}

>> Your answer: the option id, and who answered
{"method":"ask:answer","id":2,"params":{"requestId":1,"askId":"ask-1","chosen":"1","principal":{"id":"gh:12345678","login":"octocat"}}}

>> Response
{"id":2,"result":{"id":2,"requestId":1,"askId":"ask-1"}}

The guard_ask event:

  • source is "guard" or "policy" for a review, and "person" for a script's or agent's own question; guard, operation and rule say what raised a review and are null for a question.
  • question is the question in pieces and options the menu, each with an id you answer with. Show them to the person as written, and mark every piece and option whose agentWritten is true as written by the agent: an agent can put words into a question to steer the answer.
  • menu is "developer" when the script's author wrote the options and "agent" when an agent did. freeText says whether the person may type an answer instead of picking.
  • For a review, labels lists every label on the operation's inputs. args maps each parameter name to its argument, except that a value labelled .secret, .pii, .sensitive, .untrusted or .influenced arrives as the text [REDACTED] (its label is still listed). An ask about an operation with no parameters, such as a guard on show, and a person's question, have args set to null.

The answer:

  • Send exactly one of chosen, the id of the option picked, or text, words the person typed (only where freeText is true). For a review, "1" approves and "2" denies. An optional reason string travels with a deny and appears in the error message.
  • principal says who answered: id is a provider-namespaced, stable account id such as gh:12345678, and login an optional display name. Only you write it; mlld looks nothing up and takes it as you give it. Send the account's numeric id rather than a login, because a login can be renamed and then claimed by someone else. Leave principal out when nobody is signed in. What a principal is allowed to do is set by the project's config (see security-policies), and it applies to that one answer, never to the run.
  • The retired decision field is refused with INVALID_REQUEST, naming chosen; replace "decision":"approve" with "chosen":"1" and "decision":"deny" with "chosen":"2".

What happens next:

  • Approve answers that one review. Every other check on the operation still decides: another guard can still deny it, and a policy check that runs after the guards can still refuse it.
  • Deny refuses the operation the same way a denying guard does. A denied => arm can catch it, except for a policy ask rule marked locked. Uncaught, the request ends with a guard_denial event and a DENIED error.
  • If several guards or policy rules ask about one operation, each ask is sent in turn with its own askId, and the operation runs only if you approve them all. A guard that denies outright wins without asking you at all.
  • Which reviews can reach you: a guard's ask on any operation it guards (an executable call, a run, a show), and a policy ask rule on an executable call. A policy ask rule that matches a run, show or output statement directly cannot wait for an answer there, so it denies the operation with policy ask unsupported in synchronous context; put the command in an exe and call that to have the policy ask you.
  • Everything that is not a valid answer refuses: no answer within askTimeoutMs (a review's error message says host did not answer the ask in time), an answer naming an option the menu does not have, text for a question that takes none, or neither or both of chosen and text (the answer also gets INVALID_REQUEST), or closing the connection.
  • Each answer is recorded on the run's tape when the request has "tape": true, so a resumed run is served it rather than asking again (see checkpoint-resume).
  • cancel while the run is waiting ends it with ABORTED.
  • Send the answer under a fresh id, not the run's own. An answer whose id is a request still running (ids are compared as values, so 1.0 is the same id as 1) gets REQUEST_IN_PROGRESS and leaves the ask waiting, so a reply under the run's id is always that run's own outcome.
  • Ask ids are unique for the server's lifetime, not per request: an answer that names an ask from a run that has ended gets ASK_NOT_FOUND, even when a new request has reused that run's id.
  • requestId must be a string or number and askId a string (INVALID_REQUEST). An unknown requestId is REQUEST_NOT_FOUND. A request started without asks returns RUNTIME_ERROR. An askId that is not waiting (never sent, already answered, or timed out) is ASK_NOT_FOUND.
  • asks takes only "host", and askTimeoutMs must be a positive whole number of milliseconds given together with asks; anything else refuses the request with INVALID_REQUEST before it runs.

Without asks, a guard or policy ask the script does not handle fails the request with GUARD_ASK_UNHANDLED (below), and a script's own question fails it with DENIED, denial code HOST_ASK_UNAVAILABLE (no host is answering questions).

Sealing envelopes:

An envelope is a value your program signs so that mlld can trust where it came from: mlld admits it only when the signature checks out against an issuer key the project's config policy names (see policy-envelopes for declaring issuers, and crates/mlld-sig/ENVELOPE.md for the format). mlld never signs envelopes itself. It builds the envelope and the exact text to sign; your program signs that text with its own key.

>> Request
{"method":"envelope:canonical","id":3,"params":{
  "value": "deploy to prod",
  "labels": ["pii"],
  "claims": {"source": "slack", "user": "adam"},
  "stream": {"id": "slack-ops-01", "position": 41, "issuedAt": "2026-08-20T00:00:00Z"}
}}

>> Response
{"id":3,"result":{"id":3,"envelope":{"__envelope":true,"v":1,"payload":{...},"claims":{...},"stream":{...}},"canonical":"{\n  \"__envelope\": true,\n ..."}}

Then, in your program:

  1. Sign canonical exactly as given (no added newline): ssh-keygen -Y sign -f <key> -n mlld-envelope@v1, with canonical on stdin.
  2. Set envelope.signature to {"algorithm": "ssh-ed25519", "keyId": "<issuer id>", "armored": "<ssh-keygen output>"}.
  3. Send the envelope as a field of an execute or process payload, and read it in the script as @input.sdk.<field>.
  • value is any JSON value; one value per call.
  • labels (optional) are added to the value, normalized as payloadLabels are (pii becomes .pii). They travel in the payload as deny-only labels (mx.carriedLabels) and set no trust or attestation, and admission keeps them that way: a label sent here can trigger a deny but never permits anything, so sending trusted gains nothing. A label mlld writes only from what it observed itself (.src:envelope, .src:tape, .src:selector, .src:host, .src:state, .src:fyi, and anything under them) makes admission refuse the envelope with sig.envelope.origin_label, so leave those out.
  • claims.source is required; claims.user is optional. No other claims exist.
  • stream.id and stream.position (a whole number, 0 or more) are required. stream.issuedAt is an RFC 3339 time and defaults to now. The issuer's max_age is checked against it at admission.
  • Anything else, or a field of the wrong type, is INVALID_REQUEST.

Checking an envelope before you send it:

envelope:verify answers "would this project admit this envelope, and what does it claim?" It runs the same checks a run does when the envelope arrives in a payload field (signature, issuer, freshness, scope), against the issuers the project's config policy names.

>> Request
{"method":"envelope:verify","id":4,"params":{"envelope":{...sealed envelope...},"basePath":"/abs/path/project"}}

>> Admitted
{"id":4,"result":{"id":4,"ok":true,"issuer":"slack-boundary","claims":{"source":"slack","user":"adam"},"carriedLabels":{"labels":[".pii"],"restrictOnly":true},"checkedAt":"2026-10-25T20:00:00Z"}}

>> Refused
{"id":4,"result":{"id":4,"ok":false,"code":"sig.envelope.stale","message":"envelope from issuer 'slack-boundary' is stale: ..."}}
  • basePath picks the project whose config policy is used, as it does for sig:verify; it defaults to the server's working directory.
  • Issuers come only from that config policy. The request cannot name any: an issuers param, or any param other than envelope and basePath, is INVALID_REQUEST.
  • It is a check, not an admission. Nothing is written to a tape or under .llm/, so you can verify an envelope and then send the same envelope into a run.
  • carriedLabels.labels are the labels sealed into the payload. restrictOnly: true says what a run does with them: they can trigger a deny, never permit anything.
  • checkedAt is the time the freshness window was measured against.
  • A refusal is a result with ok: false, not an error. The codes are those a run gives:
    • sig.envelope.no_issuers — the config policy declares no issuers (or there is no config), so nothing is admitted
    • sig.envelope.untrusted_key — the sealing key is not a declared issuer, or signature.keyId names a different issuer than the key that sealed it
    • sig.envelope.bad_signature — the signature does not verify; the envelope was changed after it was signed
    • sig.envelope.foreign_namespace — the signature was made for another purpose (not -n mlld-envelope@v1)
    • sig.envelope.stale — stream.issuedAt is outside the issuer's max_age, in either direction
    • sig.envelope.scope_violation — the envelope makes a claim (user, say) its issuer is not allowed to make
    • sig.envelope.key_mismatch — the issuer's declared key and the sealing key disagree
    • sig.envelope.malformed_field, sig.envelope.unknown_field — a signed envelope whose fields are the wrong shape
    • sig.envelope.payload — the payload is not a value mlld can read
    • sig.envelope.not_envelope, sig.envelope.unknown_version — the value is not an envelope mlld knows; a run would treat it as plain data
  • A missing envelope is INVALID_REQUEST. A project whose config policy fails to load returns the same error a run of that project would.

Calling an exported function:

call runs one function a module exports and answers with its value as JSON. The module is loaded on the first call and kept loaded, so later calls skip loading it: on a small module a warm call takes a few milliseconds where execute re-reads and re-runs the whole file each time. A module that changed since it was loaded, or any module its imports reach, or the project's mlld-lock.json, is loaded again before the call.

>> Request
{"method":"call","id":5,"params":{"module":"./judge.mld","function":"verdict","args":{"tool":"Bash","n":1}}}
>> Response
{"result":{"id":5,"value":{"tool":"Bash","ok":true},"labels":[".src:sdk"],"taint":[".src:sdk"]}}
  • module is the module's path, relative to the server's working directory. function names one of its exported executables, with or without the @; anything else the module defines is not callable.
  • args is an object of arguments by parameter name, an array of positional arguments, or left out for none. A name the function has no parameter for, or more positional arguments than it takes, is INVALID_REQUEST. Every argument carries the label .src:sdk, so a policy rule can tell values that came from the host. The label says where a value came from; it does not make the value trusted.
  • value is the function's return value as JSON. A record value comes back as its read: rules show it, as an MCP tool result does. labels and taint are the value's labels; a value built from the arguments carries their .src:sdk.
  • Each call starts from the module as it was loaded: what one call binds with let is gone when it returns. What the module keeps outside its variables (state writes, a running service) is shared by every call to it, as it is across mlld mcp tool calls.
  • Calls to one module run one at a time, in the order they arrive; calls to different modules run side by side. A call is not a run: it streams no events and cannot be cancelled, and an ask the module does not handle itself ends the call with GUARD_ASK_UNHANDLED.
  • A module that declares a law is checked before it loads, as mlld mcp checks a served module.
  • options makes the call a judge's:
    • deadlineMs stops the call that many milliseconds after it arrives, loading the module included when the call is the one that loads it, and a call still waiting behind an earlier call to the same module. Loops and calls stop at their next pass, a command the call started is stopped, no try catches it, and the call fails with RUN_TIMEOUT.
      • A hard time limit needs noEffects. With noEffects the call runs in a separate mlld process the server keeps for the module, and the server ends that process, with everything it started, a quarter of a second past the deadline, so work mlld cannot stop from inside (a js loop, one very large string operation, a module whose top level never ends) is stopped too. The next call starts a new process and loads the module again, so it runs normally.
      • Without noEffects the call runs inside the server, and the limit stops it only at those points: at a loop pass, a call, or a command. Work that reaches none of them is not stopped. The server answers RUN_TIMEOUT two seconds past the deadline anyway and loads the module afresh for the next call, but the abandoned work keeps running in the server until it ends by itself, using a processor core meanwhile.
    • noEffects: true refuses every effect the call tries, each as an error: commands, network, MCP, file writes, llm calls, state writes and service calls. The call runs in a separate mlld process that, before it loads the module, locks itself out of writing files and reaching the network through the operating system's sandbox (the kernel fence, see enforcement-planes), so a refusal does not rest on mlld's own checks alone. Where the project's mlld-config.json turns the default fence off (fence: { default: "off" }) the process runs without it; on a system with no kernel fence the call is refused. Its imports load modules from the module's own folder and the folders below it, from folders listed in readable, and from the registry; any other import is refused. These calls run on a second copy of the module, loaded with the same limits, so the module's top level has no effects either: a module whose top level writes a file or runs a command fails to load for them, and so do the policy modules mlld-config.json imports, whose policy still applies. A call without noEffects never runs on that copy, and a noEffects call never runs on the one with effects. Each call, with noEffects or without, starts from @mx.history as it was when its copy loaded, so it cannot see an earlier call's arguments.
    • Inside a noEffects call, @mx.history keeps each call the function makes as its tool name, call id, order and whether it succeeded, not its arguments: a judge that calls a helper hundreds of thousands of times would otherwise hold every argument for the whole call. @mx.tools.calls and guards that count calls work as before. Reading such a call's arguments gives nothing: its payload.args is missing and payload.args_withheld is "not-kept", and its result's payload.result_withheld is "not-kept". helper_history (with noEffects) changes how much is kept: "full" keeps every call in full, arguments and their labels included, for a module that reads them back; "slim" is the default just described; "none" keeps no entry for them at all, so @mx.history and @mx.tools.calls do not see them and a guard that counts the function's calls counts none (what the module recorded when it loaded is still there). The call's own result and error are the same in every setting. Any other value, or the option without noEffects, is INVALID_REQUEST.
    • readable (with noEffects) lists the files and folders the call may read, each relative to the project root or absolute. A path outside the project, after following links, is refused with INVALID_REQUEST. With no list the call reads no file at all, not even the module's own. The project's .llm/ folder, where tapes and the tape key live, is never readable this way, even when a listed folder contains it; naming it is refused. Tapes are read through tapes.
    • tapes (with noEffects) lists the named tapes the call may read through the tape methods (see tape-methods), such as the tape being judged. With no list it reads none.
    • trustedSigners (with tapes) gives the signer keys you trust for those tapes, shaped as on tape:open. A listed tape that claims a seal verifies against them when the project's config names no signers; a config that names any is the whole trust set, and your keys are ignored. They never reach the module's own run tape or a tape you did not list. Without a list of tapes, or malformed, it is INVALID_REQUEST. A call whose keys differ from the one before loads the module again.
    • bodyKeys (with tapes) gives the body keys for those tapes, as [{"id", "key"}] in the shape tape:open's bodies.keys takes. A keyed body on a listed tape is then checked and read back (.select shows it, with body.state "stored"); without the key it reads as "uncheckable", and under a different key with the same id the read is refused. The keys make a body checkable, never trusted, and never reach the module's own run tape or a tape you did not list. Without tapes, or malformed, it is INVALID_REQUEST; no refusal quotes a key.
    • A noEffects call with a different readable, tapes, trustedSigners or bodyKeys from the one before loads the module again.
    • profile: true adds profile to the result: where the call spent its time, by function, built-in method and source line, as mlld --profile-file <name>.json writes it for a run (see cli-file). Loading the module is counted when the call is the one that loads it. A call that fails returns its error and no profile. A profiled call runs a little slower than an unprofiled one. Any value other than a boolean is INVALID_REQUEST.
  • Errors are coded as for process: a refusal is DENIED with error.denial, an unhandled ask GUARD_ASK_UNHANDLED, a module that fails to load or a function that does not exist RUNTIME_ERROR.

module:digest takes module alone and answers {"digest":"mlld-module-v1:sha256:…","mlldVersion":"…"}: the same digest a script reads with @mx.moduleDigest (see builtins-ambient-mx). It covers the module and every module its imports reach, keyed by their paths relative to the module, so a copy of the same files elsewhere, or on another machine, gives the same digest. It is computed from the files as they are now, not from what call has loaded. Without a server, mlld module digest <path> prints the same digest and the mlld version on two lines, or this object with --json.

Lifecycle:

  • Server runs until stdin EOF, SIGINT, or SIGTERM
  • Each process and execute request uses a fresh interpreter environment and reads its file from disk; call keeps each module it loads until the server stops, in the server for calls without noEffects and in a separate mlld process for calls with it. Those processes stop with the server
  • Active requests abort on shutdown or explicit cancel
  • A service lasts one request: it starts at its first call and is closed when the request ends or is cancelled (see services)

SDK integration:

The Go, Python, Rust, Ruby and Elixir SDKs keep a persistent mlld serve live --stdio subprocess. Each provides async handle APIs:

handle = client.execute_async("./script.mld", payload)
handle.update_state("flag", True)  # In-flight state mutation
result = handle.wait()

Error codes:

  • INVALID_JSON — Malformed request
  • INVALID_REQUEST — Unknown or malformed params
  • REQUEST_IN_PROGRESS — A request id that is still running, reused by a new process/execute or by any other frame except cancel; the frame does nothing
  • REQUEST_NOT_FOUND — Cancel/state:update/tape:append/ask:answer for unknown id
  • sig.envelope.origin_label — a state:update names a label only mlld writes (stateLabels that do the same refuse the run as DENIED, with this code as denial.code)
  • ASK_NOT_FOUND — An ask:answer for an ask the request is not waiting on
  • TAPE_NOT_FOUND — A tape:record, tape:close or check for a host tape this connection did not open, or has closed
  • HOST_FIELDS_TOO_LARGE — A tape:record whose hostFields is over 64 KiB as JSON; nothing is written
  • SESSION_BUSY — A tape:open (or mlld tape, mlld check) that waited its lockWaitMs (--lock-wait) while another process held the session's lock; nothing is written, and a later call may find it free
  • A refused tape:record batch carries error.index, the refused record's place in records from 0, beside its code; nothing of the batch is written
  • CHECK_UNAVAILABLE — A check whose answer depends on code it would have to run first (a parameter default, an input record's check, a guard's own action)
  • ASK_ANSWER_UNSEALED, ASK_ANSWER_EXPIRED, ASK_ANSWER_SPENT, ASK_ANSWER_MISMATCH, ASK_REF_UNKNOWN — A deferred check met an answer it cannot use, or a tape:record kind answer names no question on the session (see "Asking now, answering later")
  • METHOD_NOT_FOUND — Unknown method
  • METHOD_UNAVAILABLE — A method or param this server refuses
  • RUNTIME_ERROR — Execution failure, missing params, or a state:update for a request with no state
  • GUARD_ASK_UNHANDLED — A guard or policy ask that the script did not handle, in a request started without asks: "host"; the request fails closed and error.ask carries the ask (reason, source, guard, rule)
  • DENIED — A guard, policy or law refused the request; error.denial carries the refusal (reason, code such as GUARD_DENIED or POLICY_LABEL_FLOW_DENIED, guard, rule, operation, labels, args), the same object as the guard_denial event before it. labels and args describe the refused call as they do on a guard_ask: argument values with a sensitive label arrive as [REDACTED], and a refusal that is not about a call's arguments has empty labels and null args
  • ABORTED — Canceled request

mlld box probe

mlld box probe <provider> runs denial fixtures against a box provider on the local host and caches the result.

mlld box probe kernel    # probe the kernel sandbox provider

Each probe is a pair: a denied action the provider's declared fence must refuse, and a permissive control the provider must allow — so every refusal is attributable to the fence, not a dead box.

What it checks

Four kernel fixtures (each with its control):

  • read-outside-scope-refused — cat /etc/hosts under sealed fs must refuse
  • write-refused — touch outside the absent write scope must refuse
  • net-none-refuses-outbound — outbound connect under net: none must refuse
  • net-loopback-admits-local-refuses-external — 127.0.0.1 connect succeeds; external connect refuses

The cache

Results cache at ~/.llm/box/verify/<provider>__<version>__<host>.json, integrity-protected by HMAC-SHA256 keyed by a per-machine secret at ~/.llm/box/verify.key (0600). The MAC protects the cache from a process running inside a box (the key lives outside every box's reach) and from corruption. It does not protect against another program running as your own user.

Requiring verified providers

A policy can refuse box entries from unverified providers:

policy @verifiedBoxes = {
  * { box: { require_verified: true } }
}

With that policy in force, a box entry refuses unless mlld box probe <provider> passed for the current (provider, version, host) triple and the cache entry's MAC verifies. Missing, stale, or forged cache is a refusal, not a fallback.

Exit codes

  • 0 — provider verified (all probes passed with attributable denials)
  • 1 — provider FAILED (one or more probes unproven), provider unknown, or the probe could not run

mlld serve mcp-dev Command

mlld serve mcp-dev is not available in mlld 2.2.0.

Running mlld serve mcp-dev prints `serve mcp-dev` is not available in mlld 2.2.0. and exits with code 2.

To check a file, use mlld validate (see validate-features). To serve your own mlld functions as MCP tools, use mlld mcp (see mcp-export).

Install mlld's skills

mlld skill install finds the coding tools you have and installs mlld's authoring skills into each one. It is the command to run after installing mlld.

mlld skill install      # every tool it finds
mlld skill status       # what is installed, and whether it is current
mlld skill uninstall    # remove mlld's skills again

mlld skills is accepted as a spelling of mlld skill.

The tools it knows

Tool Detected by Skills land in
Claude Code the claude CLI, or ~/.claude Claude Code's own plugin system
Codex the codex CLI, or ~/.codex ~/.codex/skills/mlld/
Pi the pi CLI, or ~/.pi ~/.pi/agent/skills/mlld/
OpenCode the opencode CLI, or ~/.config/opencode ~/.config/opencode/skills/mlld/

A tool counts as present if its command is on your PATH or its configuration directory exists — a tool installed through an editor extension may never put a command on the PATH a terminal sees.

The ten skills are agents, fanout, flow, llm-first, package, query, scaffold, security, threat-modeling and workflow-to-flow. Every tool gets all ten. In Claude Code, scaffold is also available as /mlld:scaffold.

Restart the tool after installing so it picks the skills up.

What each tool gets

Component Claude Code Codex Pi OpenCode
All ten authoring skills yes yes yes yes
Reference examples yes yes yes yes
A one-line reminder when an agent writes under llm/ yes yes yes yes
Language server for .mld files yes — — yes

Claude Code takes all of it through its own plugin system, which is why installing there needs the claude CLI — every step goes through it. The other three are files mlld writes, and need nothing installed.

Every tool gets the skills of the mlld you are running: the copy built into it, or, when you run the command inside an mlld checkout, that checkout's plugins/mlld. For Claude Code, mlld writes that copy to a marketplace directory in its cache (for example ~/Library/Caches/mlld/claude-marketplace on macOS) and points Claude Code's mlld marketplace at it. Nothing is fetched from GitHub. The plugin's version changes whenever its content does, so running mlld skill install again after an upgrade replaces the copy Claude Code loads.

If your mlld marketplace already pointed somewhere else, mlld moves it. If your version of Claude Code will not move it, the install fails and says so; claude plugin marketplace remove mlld fixes that, but it also uninstalls the plugin and deletes its saved data, so mlld leaves it for you to run.

A dash means the tool has no such thing to register, not that mlld skipped it. Codex and Pi have no language-server mechanism a third party can use.

The reminder is one line, printed when an agent writes a file under llm/, and it names the two skills that matter most at that moment:

mlld skills: /mlld:flow, /mlld:agents | examples: plugins/mlld/examples/

Pi sees /mlld-flow, /mlld-agents, because Pi installs the names with a hyphen. It exists to catch someone about to write orchestrator code without the skills open — it does not choose a skill for you.

What lands in your project

Skills are installed for you, once, wherever you are. The hook and the language-server registration are per project, because that is where each tool reads them from:

.codex/hooks.json            the hook, merged into whatever is already there
.codex/mlld/skill-nudge.sh   the script it runs
.pi/extensions/mlld.ts       the hook, as a Pi extension
.opencode/plugins/mlld.js    the hook, as an OpenCode plugin
.opencode/opencode.json      the language server

Every path is printed as it is written. The files go to the checkout you run the command from, and the run ends by naming it. Nothing lands unless you are inside a working tree — not your home directory, even if you keep it in git, and not a bare repository. Run mlld skill install from a project you actually work in; a stray run anywhere else installs skills and leaves the directory alone.

mlld skill install --project adds these files to another project. Run it from that project's checkout once the skills are installed. It writes only the project files, for each detected tool whose mlld skills are already installed, and copies no skills. A tool whose skills are missing is named and skipped: run mlld skill install first. Outside a git checkout it has nothing to write, says so, and exits with an error. --project cannot be combined with --local or --dev, which choose where skills come from. It is different from --scope project, which sets Claude Code's plugin scope.

mlld only ever adds its own entry to a file it shares with other tools. .codex/hooks.json commonly holds hooks from other tools — including several under one entry, which is the shape the format is built for. Yours are left exactly as they were, and mlld skill uninstall takes out mlld's own hook and nothing else, keeping the file whenever anything else is still in it.

If one of these paths is a symbolic link, mlld refuses it and says so. Writing through a link would put mlld's changes somewhere outside the project you ran the command in, which is the one thing it will not do. Replace the link with a real file, or remove it, and run the command again.

mlld skill uninstall cleans up after a tool you have since removed. Its project files are mlld's to take back whether or not the tool is still on the machine, and the run names them.

It names everything it will remove, and asks before it removes any of it.

mlld skill uninstall

Uninstalling mlld skills...

This will remove:
  Codex
    /Users/you/.codex/skills/mlld
    /Users/you/project/.codex/mlld/skill-nudge.sh (mlld's part of it)
  Pi
    /Users/you/.pi/agent/skills/mlld
    /Users/you/project/.pi/extensions/mlld.ts (mlld's part of it)

Remove these? [y/N]

Anything other than y or yes leaves everything where it is. A directory named here is one that goes. The list does not name .codex/hooks.json, but mlld's hook entry in it is removed too, and the file goes with it when nothing else is left in it.

With no terminal it stops instead of guessing. In a script, a pipeline or a CI job there is nobody to answer, so mlld refuses and exits non-zero rather than removing things unasked. Pass --yes to say in advance that you meant it:

mlld skill uninstall --yes

It only removes skill groups mlld installed. The groups are named mlld, dev, docs and devrel, and dev or docs could easily be the name of a group you made yourself. mlld checks for the version marker its own installer leaves, removes only the groups that carry one, and tells you about any it left alone. A group it will leave is not in the list above, because that list describes what will happen.

Codex will not run a new hook until you approve it. After installing, open Codex and run /hooks — until you do, the nudge is installed and inert, which looks identical to not being installed at all.

Options

Flag What it does
--target <tool> Just one tool: claude, codex, pi or opencode
--dev Also install the contributor skills — dev, docs and devrel, for working on mlld itself. They read a local mlld checkout, so run this from one
--scope <scope> Claude Code only: user (the default) or project
--local Claude Code only: register a local mlld checkout itself as the marketplace, instead of the copy mlld generates
--yes, -y Answer the uninstall confirmation in advance — required where there is no terminal
--verbose, -v Show what claude was asked and what it replied

One tool failing does not stop the others. If every tool it found failed, the command exits non-zero, so a script can tell that apart from success.

Reading mlld skill status

mlld skill status

  Codex (mlld): 2.2.0
  Codex project file: /Users/you/project/.codex/mlld/skill-nudge.sh
  Pi (mlld): 2.1.0 -> 2.2.0
    Run `mlld skill install` to update
  Pi project file: /Users/you/project/.pi/extensions/mlld.ts

A version on its own is current. An arrow means an upgrade is available — installing mlld does not update the copies already sitting in your tools. The project file lines list the files mlld wrote into the current project.

Installing someone else's skill

mlld skill install @alice/my-helper
mlld skill uninstall @alice/my-helper

Removing one works. Installing one from the module registry is not available: the command recognises the reference, says so, and exits 1 rather than installing the built-in skills instead.

mlld plugin

mlld plugin install, uninstall and status are other spellings of the mlld skill commands. They run the same code and take the same options, --target and --yes included, so mlld plugin install sets up every tool it finds. To set up Claude Code alone, use mlld skill install --target claude.

mlld sig drift

answers: do the files your policy claims still match what was approved?

mlld sig drift reports which files declared by your policy's attest: stanzas have drifted from .sig/manifest.json. The manifest holds the last-approved digest (a fingerprint of the file's bytes) of every attested file. It records digests only; there are no signing keys.

mlld sig drift

The report lists, per drift lane (only lanes with members are shown), sorted by path:

  • changed (n): a listed file whose bytes no longer match its approved digest.
  • new-in-class (n): a file matching an attest glob that is not in the manifest yet — it awaits your mlld sig approve.
  • reclassified (n): a listed file that a stanza now places in a different class than the one it was approved under, shown as path (old → new). It is drift even when the bytes are unchanged, because the class decides how the file is checked at approve time (only instructions files get the invisible-character check). mlld sig approve re-approves it under the new class.
  • missing (n): a listed file that no longer exists on disk (deletion is drift too).
  • off-exempt (n): files whose matching stanzas resolve to off — named so the exemption is visible, never an implied nothing.

The footer either says N files attested, no drift or M files awaiting your approve.

Exit code is 0 for a completed report; a report that cannot be computed (corrupt manifest, unparseable policy candidate) fails with a refusal that names the problem and exits 1. To stop on drift, use mlld sig verify (nonzero on any drift; see verify) or mlld sig hook <path> (a per-file exit code).

Policy stanza form:

policy @sec = {
  * {
    attest: {
      "llm/prompts/**": { class: "instructions", mode: "enforce" },
      "src/**/*.mld":   { class: "scripts",      mode: "warn" }
    }
  }
}

Classes are a closed vocabulary (instructions, scripts, policy, skills, binary); modes are off/warn/enforce. A const object with a top-level attest: key (const @sec = { attest: { … } }) is read the same way. Files whose matching stanzas resolve to off are exempt and listed under off-exempt (n).

mlld sig status and mlld status are refused, each with a pointer to mlld sig drift.

mlld sig hook <path>

A single-file verdict for scripts and hooks to check. Prints one line and exits:

code meaning
0 attested, OR stanza-exempt (off), OR warn-unlisted (prints WARN:)
1 drift, OR enforce-unlisted (prints REFUSE:), OR unverifiable (wholesale trust refusal under the config's signers root — see policy-signers)
2 not attested (no manifest, or no stanza claims the path)
3 error — never a verdict (policy/parse/filesystem problem, including signers in mlld-config.json's policies that cannot be read)

Exit 0 is shared by three verdicts, so --json exists for callers that must tell them apart (to trust a file only when it is attested, check verdict == "attested", never the code):

$ mlld sig hook llm/prompts/a.att --json
{
  "class": "instructions",
  "code": 0,
  "mode": null,
  "path": "llm/prompts/a.att",
  "verdict": "attested"
}

Verdict kinds: attested, drift, refuse (enforce-unlisted), exempt, warn-unlisted, not-attested, and — when a signers trust root is declared and the committed manifest cannot be verified against it — unverifiable. The wholesale consult runs FIRST (before the manifest lookup or any mode dispatch), so a hook on an off-exempt path under an unverifiable root returns unverifiable, not exempt. Under an unverifiable root the exit code is 1; the kind is the contract.

That includes a manifest that is present but unparseable or unreadable: under a declared root the hook grades it unverifiable (exit 1), and the refusal line names the manifest's own error code (a sig.manifest.* parse code (e.g. sig.manifest.not_json) / sig.manifest.read). With no root declared, the same broken manifest cannot be answered at all — the hook exits 3 (its error arm), because not-attested would claim the path is absent from a table that could not be read. A .sig/manifest.json that is not a regular file (symlink, directory, fifo) is refused at load as sig.manifest.non_regular in every case — never classified.

mlld sig verify

answers: does the whole attestation state still hold — every approved file matching, the manifest itself intact, signed off, unrewound, and every chain pin honoured?

mlld sig verify is the gate form of the drift question. mlld sig drift reports; mlld sig verify decides — it runs the whole-manifest check and exits nonzero on any failure, so it is the command a CI job or hook wants:

mlld sig verify

Partial success is never green: one failed check fails the run. A green run prints what it checked and ends verified: ok; a red run prints each failure as a FAIL: line and ends verified: FAILED — N failure(s). Warnings (warn: lines) never turn a verdict red on their own — a run with warnings but no failures ends verified: ok (with warnings) and still exits 0.

code meaning
0 verified — no failures (warnings may be present)
1 any failure, or a typed refusal (corrupt manifest, unparseable policy, broken trust root)

What it checks, in order:

  • Refuse-first load. Policy and manifest must parse; a present-but-corrupt manifest refuses with its class named. An absent manifest is not one case: verify walks first-parent git history and says which it is — manifest deleted (naming the ancestor commit that still carries .sig/manifest.json), never-initialised, or honestly indeterminate (shallow clone, walk cap, no git) rather than claiming either.
  • Drift. Every attested file's bytes against its approved digest: changed:, missing: (deletion is drift), and new-in-class and reclassified (a listed file a stanza now puts in a different class) — each a failure under an enforce stanza, a warning under warn. The per-lane report is mlld sig drift's; verify names the files.
  • Identity (only when policy declares a signers root). The manifest must carry a valid detached signature (.sig/manifest.sig) from an authorized principal — a missing signature fails wholesale (sig.verify.unsigned_manifest), never mode-gated, and an invalid one fails with its own code (sig.verify.bad_signature, sig.verify.untrusted_key, sig.verify.window, or a sig.sshsig.* parse refusal). A signed off by: line names the principal and key fingerprint that signed the manifest, and the root: line says which root that signature was checked against: valid per pinned root after mlld sig trust pin, valid per committed root (TOFU, unpinned) before it; the first run on a machine prints the full first-sight ceremony block.
  • State admission. The highest-seen manifest version for this repo is checked on every run and saved only on a green verdict, in a per-user file, ~/.config/mlld/sig-state.json (so a fresh CI machine starts at state: FirstSeen), so a forged high-version manifest cannot jam the rollback guard on every machine that runs verify.
  • Rollback anchor. First-parent history is walked: an ancestor carrying a higher manifest version than the working tree refuses as a rollback (sig.verify.ancestor_version) — a full rewind to an old signed state passes drift and signature checks, and only history exposes it. If the walk cannot run, verify warns that the anchor is off and a full rollback would pass undetected.
  • Chain consult. .sig/chains/** — see below.

A green run over a repo with one pinned chain:

manifest: v0, 0 entries, approved  by
state: FirstSeen (check-only; highest-seen persists only on a green verdict)
attested set: 0 files — no attest classes in policy
chains: 1 pinned
  docs/a.md: pin anchors entries 1..=3 of 3
drift: 0 clean, no drift
verified: ok

Chain consult (.sig/chains/**)

Chains record the edits made to an attested file: each .sig/chains/<key>.jsonl is an append-only, hash-linked log of mutations to the file its manifest key names, and the manifest pins each chain's approved head. Verify walks every chain file, parses and linkage-checks it (a forked, reordered, or malformed chain fails with its own sig.chain.* code, e.g. sig.chain.prev_hash_mismatch), then grades the manifest's head pins against what it observed.

The pin is a prefix checkpoint: it anchors the entries at or below it and advances only at the interactive mlld sig approve ceremony. Entries past the pinned head are reported as a warning, and the wording is the security boundary — they are covered by no signed channel (the pin advances at the next mlld sig approve). They are not "pending approval": mechanical coverage ends at the pin.

warn: chain docs/a.md: 2 entries past the pinned head — covered by no signed channel (the pin advances at the next `mlld sig approve`)

Three failure codes, all red (exit 1):

code fires when
sig.chain.pin_absent the pinned head appears nowhere in the chain — the chain was truncated below the pin or rewritten
sig.chain.file_missing the manifest pins a chain head but no chain file exists on disk
sig.chain.case_collision two chain keys (pinned or observed) differ only by ASCII case — one file would serve both on a case-insensitive filesystem

A chain file that no manifest entry pins is a warning, not a failure: an unpinned chain proves nothing, but it is named so residue and planting are loud. A repo with no chains prints chains: none pinned — the consult ran; there was nothing to grade.

Chain-directory hygiene: a member that is not a <key>.jsonl file, or whose name is not a valid manifest key, is ignored with a warning; a symlink or other non-regular member is a failure — chains refuse to be read through indirection.

mlld verify is refused (exit 2) with a pointer to mlld sig verify.

mlld test

Run native mlld test files.

mlld test "tests/test-system/*.test.mld"
mlld test tests/test-system/basic.test.mld --shard 1/2

.test.mld files run with test mode enabled, so @test is available and the @mlld/test library can be imported.

import { @assertEq, @assertIncludes } from @mlld/test
const @test_sum = @assertEq(1 + 1, 2)
const @test_text = @assertIncludes("hello world", "world")

--shard N/M selects a deterministic subset of matched files.

Each test file runs with a VirtualFS overlay for mlld filesystem-service writes. @test.mock.fs, output, and append writes stay in the test overlay and do not touch the working tree. Shell subprocess writes are different: unmocked run cmd { ... }, run sh { ... }, and sh exe bodies still execute through the host shell, so shell redirections write to the real filesystem. Mock those commands with @test.mock.shell or write them to a temp directory.

mlld test refuses --inline, --watch, --junit and --replay.

mlld sig unsigned

answers: what lacks a signature?

mlld sig unsigned lists every file without an attestation in .sig/manifest.json, in three labelled groups — one per action the reader takes:

  • covered by a rule, awaiting your approval (n): a file an attest: stanza claims (mode is not off) that the manifest does not attest. Action: review and mlld sig approve.
  • covered by no rule at all (n): a file no stanza matches. Nothing watches it — action: add a rule, or consciously leave it out.
  • deliberately unsigned (mode off) (n): a file whose matching stanzas resolve to off. Action: none — you already chose. The group is listed because flipping a stanza to off must never make a file silently vanish from this report; a shorter list is not progress.
mlld sig unsigned          # human report
mlld sig unsigned --json   # awaiting_approval / no_rule / off_exempt + counts

Members show as path (class) for the two rule-covered groups; the no-rule group names paths only (no class exists to name). Policy files themselves (policy.mld and friends) match no attest glob in a typical setup, so they report in the no-rule group — that is honest: an attestation rule for them is a choice, not a default.

Exit code is 0 for a completed report — the report describes, it does not gate. A corrupt manifest or unparseable policy candidate is a typed refusal (exit 1). To review the attested set, use mlld sig drift; this command lists the complement. Before a manifest exists, every claimed file is awaiting approval and the report says so — run mlld sig init first to create one.

mlld sig info

answers: what attestation state is this repo in?

mlld sig info prints the repo's attestation posture, read-only: the attest classes in force and their effective modes, which files contributed policy, the trust root if one is declared, manifest state (version, entry count, approval provenance — self-asserted and informational, never authority), and counts: attested / awaiting approval / no rule / off-exempt.

mlld sig info          # human report
mlld sig info --json   # the same state, structured

Two rules govern this command:

  • Informational, never load-bearing. Nothing in mlld's enforcement reads this output, and the report says so on its first line. info exists so a human or agent can get oriented, never so anything can decide from it.
  • Repo-level only. Never per-file "is this file OK?" — that question is decision-shaped. Repo-level state describes the world; it does not answer "may I."

Exit code is 0 on a completed report, 1 only on a typed refusal (corrupt manifest, unparseable policy). A .sig/manifest.json that is present but unparseable or unreadable is the typed refusal: sig info exits 1 and names the manifest's error code (a sig.manifest.* parse code (e.g. sig.manifest.not_json) / sig.manifest.read) — there is no attested set to report, and info never reports around it. Reporting an unattested repo is a successful report — the exit code carries no verdict about repo state.

Compare: mlld sig unsigned lists what lacks a signature (file-level, grouped by the action to take); mlld sig drift checks the attested set against the disk; mlld sig verify is the whole-manifest gate. This command is the map; those are the instruments.

mlld box — run a command, list instances, release them

The box namespace manages durable box instances — isolated execution environments backed by a provider. Two named leaves operate on them — list and release — plus the namespace's default leaf, which runs a command inside the box. (A fourth, probe, verifies a provider's declared fences — see cli-box-probe.)

mlld box <cmd…> — run a command inside the box

run is not a subcommand word: mlld box run treats run as the command to execute, so it fails trying to exec a program of that name. (The CLI's own flag errors call this the run leaf — that is the internal name for the default leaf, not something you type.)

mlld box -- <cmd…>

box is the namespace's default leaf: mlld box <cmd…> resolves the standard box setup and runs <cmd…> inside it. Every spawn the leaf makes crosses the provider's kernel fence; the command inherits the box's configured scope — filesystem write scope and network — enforced by the OS on hosts that can fence. limits is not among them: the kernel provider refuses a box that sets it rather than accepting it unenforced (see box-directive).

The command meets the policy's rules for commands exactly as a script's run cmd does, before it runs and with the same messages. Its allow and deny lists apply (Command 'ls' denied by policy), and so do rules on its operation labels, which are the ones a run cmd carries: .op:run as well as .op:cmd and its narrower forms (Operation '.op:cmd:echo:secret' is denied by policy). A guard a policy binds before .op:run or .op:cmd runs too, and its deny refuses the command. A guard that answers with a replacement command makes mlld box run the replacement through the shell instead, after the same checks a script gives a replacement. Because mlld box passes the command's output straight through, a guard a policy binds after .op:run or .op:cmd cannot judge it, so the run refuses before it starts, naming those guards; run the command from a script's run cmd instead, which holds the output for them. While any policy is in force, a command whose programs mlld cannot all name is refused, such as a program named by a shell variable or a $(…) substitution. A rule that gives the operation a box (.op:cmd { box: { net: "none" } }) narrows the box the command runs in and never widens it. A box config named with --box meets the same checks a box @name in a script does: for example, a tools list without Bash refuses with Command execution requires 'Bash' in env.tools.

The standard box has no network. A policy's capabilities.network is a limit, never a grant, so a host list there leaves the standard box with none. To give the command network, run it in a box that asks for it (below).

Host lists. A box whose net names hosts (see Host lists in box-config) works here as it does in a script: for as long as the command runs, mlld runs an egress proxy for it, and the command can reach only the hosts the box allows and every policy limit also allows. A refused connection gets an HTTP 403 from the proxy, and once the command exits mlld prints mlld: box.net.denied: <host>:<port> — <reason> on stderr for each host refused (the first five, then a count). The proxy stops when the command exits, whatever its exit code, and when mlld itself is stopped. The line mlld box prints before the command runs names the box's network and the policy limit it applied:

box run: config 21f0293f4c02dbaf net egress proxy (allow [api.example.com:443, other.example:443] by the box at …; allow [api.example.com:443] by capabilities.network of policy @box_policy …) (policy ceiling: egress proxy (allow [api.example.com:443] by capabilities.network of policy @box_policy …)) argv [...]

--name <name> makes the instance durable: its entry stays in the registry after the command exits, and mlld box list reports it until mlld box release <name> removes it. The list shows it live while its command runs and stale once the command has exited. Without --name nothing is recorded.

Naming a box. --box @name runs a box declared in one of the policy modules mlld-config.json imports (policy.import), beside its policy. The name must be declared in that module itself, not imported into it, and exported by it (a module with no export list exports every name). It must be a box config object, and it meets the same checks a box @name in a script does. A name no such module declares refuses with --box '@name' is not defined in the policy-established environment, a policy or a module named as a box refuses, and two modules declaring the same name differently refuse rather than pick one.

>> box-policy.mld, imported by mlld-config.json: { "policy": { "import": ["./box-policy.mld"] } }
const @netbox = { net: { allow: ["api.example.com", "other.example"] } }
policy @p = { * { capabilities: { network: { allow: ["api.example.com"] } } } }
mlld box --box @netbox -- <cmd…>

Without --box, mlld box uses the policy's default_box when the name it gives resolves as it would in a script under the same config; a box declared only inside a config-imported module does not, so the run refuses with default_box '@name' is not defined. With neither, the standard box is used.

mlld box list — list durable instances

mlld box list

Reads the per-project .llm/box/ registry and prints one line per durable instance: its name, live or stale (from a socket probe; the pid is shown for reference), its pid and its socket path:

dur1  stale  pid 41268  socket /path/to/project/.llm/box/run/dur1-233ffe1c05d053c5.sock

mlld box release — end a durable instance

mlld box release <name>

Sends SIGTERM to the instance and removes its socket, directory, and registry row. Idempotent on a stale name — releasing an already-gone instance is not an error.

Provider verification

run into a kernel-fenced box can be gated on the provider being proven: a policy with box: { require_verified: true } refuses a box entry unless mlld box probe <provider> has passed for the current (provider, version, host) triple. See cli-box-probe.

Flowcheck

A policy stops labelled data (.secret, .untrusted, …) from reaching operations it denies, and the runtime checks this as the script runs. A leak on a branch that rarely runs is therefore only found on the day that branch runs. mlld flowcheck finds it before the run: for every place the script can hit a policy check, it works out which labels can arrive and asks the same rule code the runtime uses what would happen.

mlld flowcheck script.mld                  # readable findings
mlld flowcheck script.mld --format json    # JSON report
mlld flowcheck script.mld --strict         # "possible" findings fail too
mlld flowcheck lib.mld --module            # a module others import

It reads the script and the local modules it imports. It does not run anything.

It also checks a write made under a labelled condition: after if @secret [ => "early" ] in a block, the rest of the block reveals which way the condition went, so mlld refuses @acc += … or @acc = … there unless @acc already carries .secret, with or without a policy. flowcheck reports such a write as pc write.

Verdicts. Each check point gets one:

Verdict Meaning
definite If this line runs, the policy refuses it. A refusal inside an if is still definite: the branch is rare, not safe.
possible Some runs are refused and some are not, or something feeding this line could not be analysed.
handled Every refusal here is caught by a denied => arm or a try. A locked rule's refusal cannot be caught.
ask Not refused, but a rule asks a person or a handler. The finding lists each ask that can fire there (ask: <rule> asks <handler or reason>).
clean No run is refused.
box-required A box: * rule matches a call or a command here on every run, and no box is in force. A possible finding can also say a box: * rule matches on some runs.

Before mlld run. mlld run makes this check before it starts a script whose policy names flowcheck (* { flowcheck: "default" } or "strict"); from 2.2.1 it makes it for every script (see cli-run):

Verdict What mlld run does What to do
definite refuses to start remove the label's path to the line, or add an exception the policy allows
box-required, or a possible one whose box: * rule matches on some runs refuses to start run the line in a box, or configure the box the rule names
possible prints it as advice (at most five) and runs nothing, unless you want certainty: the runtime still checks the line as it runs
handled prints it as advice and runs nothing: the refusal is caught
ask, clean prints nothing nothing

A policy with * { flowcheck: "strict" } makes mlld run refuse on possible findings too.

For example, with this policy a secret sent to an exfiltrating function is definite, even though the branch only runs in one mode:

policy @p = { .secret { deny: [.risk:exfil] } }
const .secret @token = "sk-1"
const @mode = "normal"
exe .risk:exfil @send(x) = `sent ${@x}`
if @mode == "debug" [
  show @send(@token)
]

Each finding names the operation, the labels that can arrive, the rule that refuses and the file and line it was declared on, and the path the labels took (.secret @token line 2 → @token line 2 → exe @send line 6).

Laws. A policy can declare what labelled data must never reach: .secret { never: [.net:w] }. flowcheck reports each law as proven (no line can send the label there), violated (a line does, whenever it runs) or unproven (a line may, or flowcheck cannot tell; the report says why). A law judges more than the runtime's own check sees: a command, a shell or language block and an MCP server count as every operation they could perform, unless a box with net: "none" rules the network out where its provider blocks all of it (macOS; on Linux it blocks TCP only, so it rules nothing out); a model's tool calls receive what the model saw; and a label a guard removes still counts, unless the law adds declassify: priv and a privileged guard removes it on every path. A law naming an operation nothing performs and mlld does not know (.op:nett:w) is unproven, "matches no operation". In JSON, each law is in laws (text, origin, status, reason, site, path). mlld flow --law shows the paths as a law reads them. A script declaring a law is checked this way before every run; see laws.

Modules published for others. A module that others import (from the registry, say) has no entry point: nothing in it is called, so a plain check finds no lines to judge. mlld flowcheck lib.mld --module calls each executable the module exports as a caller it does not know would, passing anything that passes the executable's typed signature (exe @send(to: @contact.email, body: string)). Each parameter starts with what its type guarantees and nothing more:

Parameter What it starts with
a field with a kind (to: @contact.email) one of the ways its check passes: a user literal (@cite.user.intent.literal) or a fact of any one of its kinds; with an accepts of its own, one of what that lists instead. Optional or defaulted, it may also be null or left out, with no proof. The proof stays with the value while it is passed on unchanged; a value made from it (a template around it) loses it
a trusted field with no accepts not untrusted (with an accepts, an untrusted value that meets it passes)
a plain type (body: string), a list, a record its shape only: any labels, any trust
untyped anything

A requirement reads clean only if every way a caller can pass the signature meets it. With .risk:exfil:send { accepts: { recipient: [.fact:*:email, .src:user:intent:literal] } }, a send whose recipient is typed by an email field is clean at that requirement: a caller passes with a user literal or an email fact, and both are accepted. With accepts: { recipient: [.fact:*] } alone it is possible, because a user literal passes the signature and not the requirement. The same goes for a field of two kinds under a requirement asking for one, an optional parameter, and a requirement that names one record ([.fact:@contact.email]), since a caller's proof of the kind may come from another record. A module does not prove a caller brings no labels: a .secret { deny: [.risk:exfil] } rule stays possible at the send, because a caller may pass a secret. An untyped parameter makes every line it reaches possible, and the report asks for a type on it. The findings describe callers whose values pass the signature, and the report says so; a caller that does not pass is refused when it calls, by the signature check or by the requirement itself, which mlld checks first.

After the findings, the report lists each exported executable, what each parameter started with, and the lines each parameter reaches: the module's contract with its callers. In JSON it is library.exes, each with name, assumes ("callers pass the signature"), params (name, type, guarantees, starts, hint), sites (indices into sites) and reaches (per parameter, the sites it reaches and their ops).

A call of an executable with a typed signature is checked against it wherever it is called, in a module or a script: a refusal there shows as exe @f signature, after the catalog entry's own inputs: when the call goes through one.

In the editor. The language server (mlld lsp) runs flowcheck each time you save an .mld file and shows its findings on that file's lines, with the path as related locations, next to the validator's. It reads any file you have open in the editor as it is in the editor, saved or not, and everything else from disk. A save made while the previous one is still being checked replaces it. A finding about a line in another file (inside an imported module's function, say) is shown on that file. When you edit a file, its findings stay hidden until the next save, since their lines may have moved. If flowcheck cannot read the program (a syntax error in it or in an import), the saved file gets a warning saying so, and the findings from the last check that could read it stay until the next one that can; until then they may be out of date.

Exit codes:

  • 0: nothing refuses
  • 1: something refuses: a definite or box-required finding, a box: * rule that matches on some runs with no box in force, a law that is not proven, or, under --strict or a policy with * { flowcheck: "strict" }, a possible one. So the exit code says whether mlld run would start the script.
  • 2: the script was not analysed, because it or a module it imports could not be read or parsed

What it cannot see. flowcheck follows exactly only a core of the language: bindings, calls, templates, objects and arrays, if, for, match, try, pipelines of calls, run, box, local imports, policies, registry modules your project pins in mlld-lock.json (or pins to an exact version) that are already in the local module cache, tool catalogs and the tool calls a model makes through them, the input records a tool's arguments are checked against (a refusal there shows as exe @f input record), starting an MCP server, and the labels @mintUserValue, @mintUserValueHandle and @cite.user.intent.* give their result. A refusal at a model's tool call goes back to the model as an error and the run goes on, so flowcheck reports it as handled. Anything else (file loads, output/log/append, loop, builtin functions, most methods, @input and the other reserved names, a registry module that is not pinned or not cached, URL and GitHub imports, records with a refine, a field action or a validate: "drop", @cast on a record that validates a tool's input, an input record (inputs:, or an executable's own with { inputs }) whose fields run input actions, refine or update, an allow- or blocklist whose members are not written out where the catalog is defined, the tools an MCP server serves, state other than a plain state @st = { … } and @st.set(…), hooks, and a guard a policy binds that asks, retries, picks an environment, replaces a value with another value, changes values at anything but an executable call, tests something other than its input, its output or the operation in a condition, or is bound to an operation flowcheck does not follow (a wildcard such as .op:*, run statements, loops, output and other effects), and a registry module's guard that changes values where flowcheck cannot tell which labels the import's using { attests } lets it add) is not analysed; a line it feeds reads possible, and the report notes what was skipped. When part of the policy is only known when the script runs (a union() of a computed value, an import it cannot read, a using { policy } on a call), the report says so, and the lines it could change read possible. Capability rules (allow, deny, danger) are not decided either: under one, a line that runs a command or a file operation reads possible. Each of those mints is a line of its own: definite when the runtime refuses it on every run (its scope, at the top level or in an executable's body, has read a value marked .untrusted; a literal citation's task carries .influenced or does not hold the value as whole words), clean when it never does, and possible inside a block, loop, conditional or pipeline stage, for an inferred citation, or where the value or task is known only at run time. try catches every mint refusal; a denied => arm catches only a citation's. A rule that needs proof of a fact (accepts, labels.args, .secret:not(.fact:*)) is decided for a record field read directly (@c.email) when @c is as record of an object written out in full: a value that passes the record's checks is a fact on every run, and one that fails leaves no field a fact. A value @mintUserValue stamps when the value is written out, and a value @cite.user.intent.literal cites from a task written out, carry their proof too: a rule that accepts .src:user:intent:literal, and a tool's input record checking proof or exact, are decided where the call is given that name. A value made from the field or the minted value (@c.email.toUpperCase(), a template around it), a record or a citation built from data known only at run time, and any other proof read possible. A tool call a model makes may swap a handle it was given for the value it was minted for, with the labels it had then, so a label the handle picked up later may not reach that call: a line where that decides the outcome reads possible. Your own code passing a handle passes it as it is. A possible finding is advice: the runtime still checks that line when it runs.

Laws

A law says where labelled data must never go. It is written in a policy as a never: list on a data pattern:

policy @rules = {
  .secret { never: [.net:*] }
  .secret+.untrusted { never: [.op:cmd] }
}

A deny is checked when the operation runs, and an allow! exception can lift it. A law is stronger: before any script that declares one runs, mlld proves that nothing in the script can carry the data to the operation, and refuses to start the script if it cannot. No exception, ask handler, draft route, privileged guard or --no-flowcheck lifts a law.

Proven, violated, unproven. The check is the one mlld flowcheck makes (see flowcheck), and gives each law one of three results:

  • proven: no line of the script can send the labelled data to the operation. The script runs.
  • violated: some line does, whenever it runs. The script is refused, with the line and the path the data takes.
  • unproven: some line may, or the check cannot tell (a call it cannot follow, a policy known only at run time, an import it cannot read). The script is refused, with the reason.

The check runs on every way a script is run: mlld run, mlld <file>, mlld -e, a script piped in with mlld -e -, a module served with mlld mcp (where every tool it exports is checked as a client may call it, even one the module never calls itself), a mlld test suite, and the SDK's live server. It runs whether or not the general check before mlld run is on. mlld run --no-flowcheck on a script that declares a law is refused, naming the law.

A law covers more than the run's own check. The runtime refuses an operation only when the data reaching it carries the label. A law also counts what the runtime cannot see:

  • A command, a shell or language block (sh, py, node, js) and an MCP server can do anything, so one that may receive the data may perform any operation: a network write, a file write, another command. To prove .secret { never: [.net:*] } while a command receives the secret, declare what the command does on its exe (below), or run it in a box that has no network: box { net: "none" } [ … ].
  • A model's tool calls receive everything the model saw, and the model sees every tool result.
  • A label that is removed still counts (below).

Declare what an exe does. An exe's .fs: and .net: labels are enforced: its cmd, sh, bash, py or node body runs in a sandbox limited to them (see labels-overview). A law counts that as proof, exe by exe:

  • An exe with no .net: label cannot reach the network, so it proves a network law.
  • No declaration proves a file-write law (never: [.fs:w]). An exe with no .fs:w or .fs:rw label cannot write files itself, but it can still hand the data to a system service that writes it: on macOS, logger "$x" puts $x in the system log, which is kept on disk. To prove such a law, keep the data away from the command.
  • No declaration proves a read law (never: [.fs:r]): reads are never fenced.
  • Any .net: label leaves both network modes possible. A sandbox cannot tell a read from a write, so an exe declared .net:r does not prove never: [.net:w].
  • A js exe with any declaration proves network, file and command laws on every machine: js runs inside mlld, with no file, network or process access.
  • A service's method declarations work like an exe's, for the service as a whole: its methods share one process, which runs limited to the widest of their declarations. So a call of a .fs:r method proves a network law only if no method of the service declares .net:, and a service with an undeclared method proves nothing (the error names that method as @service.method).

When a law is unproven because of an exe with no declaration, the error names each one with the line it is defined on:

policy @rules = { .secret { never: [.net:w] } }
const .secret @token = "t"
exe @hash(x) = cmd { shasum }
show @hash(@token)
mlld: refusing to run main.mld: a law the policy declares is not proven
  law .secret { never: [.net:w] } (main.mld:1): unproven (the code run here may perform the operation, and its labels do not say which it performs) at main.mld:4 — exe @hash
    these exes declare no .fs:/.net: effect: @hash (main.mld:3). Declare what each does, e.g. exe .fs:r @hash = cmd {…}
    path: .secret @token line 2 → @token line 2 → exe @hash line 4

Declaring exe .fs:r @hash(x) = cmd { shasum } proves the law on macOS: the command now runs with no network and no file writes of its own. A declaration only counts outside a box, or inside a box with net: "none"; inside any other box it proves nothing.

The box depends on the machine. A box rules an operation out only where every sandbox that can run it enforces that. On macOS a net: "none" box blocks all network traffic, so it proves a network law. On Linux it blocks TCP connections only, while UDP and local sockets stay open, so the same script's network law is unproven there. A declaration's sandbox is the same, so a declared exe proves a network law on macOS and not on Linux. A law can therefore be proven on one machine and refused on another; check it where the script will run.

Name the operations you mean. .net:w covers network writes only: @http labels a GET .net:r, and a GET can carry data in its URL. Use .net:*, or a risk alias such as .risk:exfil that your policy defines, to cover every network use. A law naming an operation nothing performs and mlld does not know (a typo such as .op:nett:w) is unproven, "matches no operation".

Removals. A label removed on the way does not end a law: the data was still the secret. This covers a guard's removal, a label modifier, a record coercion that drops .untrusted, and any other removal. To let a reviewed declassifier end a law, add declassify: priv beside it:

policy @rules = {
  .secret { never: [.net:*]; declassify: priv }
}

Then a privileged guard (guard!, declared in a .priv.sss file) that removes the label from a call's result after the call, on every path to the operation, ends the law for that data. A removal that may not run (inside an if, or under a condition) leaves the law unproven, and a removal by a guard without privilege is refused at run time and ends nothing. A guard that removes the label from a call's input before the call takes nothing off.

Finding out why. mlld flowcheck <file> lists every law with its result, and mlld flow <file> --from .secret --to .net:w --law shows the paths the way a law reads them, through removals.

A law with no data label the program knows (.secrte, a typo) is refused when the policy loads, as any undeclared label is.

Why

When a policy refuses a run, the error names the label and the operation. mlld why says the rest: which rule decided it, the file and line that declared the rule, each allow! exception that was weighed and why it did not apply, which argument carried the label, and whether a box was started or a guard ran on the call.

mlld why script.mld                    # every denial in the last run
mlld why script.mld --line 12          # every check made at line 12, allowed or not
mlld why script.mld --run <run-id>     # an earlier run
mlld why script.mld --position :verdict#4  # one check, by its position on the tape
mlld why script.mld --format json      # one JSON object per verdict
mlld why script.mld --all              # every path to a denied argument, not only the shortest
mlld why script.mld --causes           # every influence cause the run recorded

It reads the run tape the run recorded (see mlld howto checkpoint-resume); it runs nothing. Give it the script the way you ran it, from the same folder: a file path (mlld why sub/flow.mld), a script name for mlld run <name> (mlld why flow), or _eval for a program run with -e. It finds the tape in the project the script belongs to, as the run did, so it works from a folder below the project root; --base-path <dir> names the project instead. A program run with -e has no file, so its own rules show as declared in <main>.

Box and guard verdicts are those the run recorded for that call. A call's guards and boxes name it on the tape; the guards of show, output and the other value statements are matched by line, column and the pass of every loop and call around them. A tape recorded before this command existed is matched the same way.

Besides denials, mlld why shows by default an after-guard whose allow ran but was held to deny-only for a reason the guard itself does not show. When a before-guard swaps a command for another, a guard bound only on the swapped-out command (say .op:cmd:echo when /usr/bin/printf ran instead) can still deny, but its trusted! or label removal is not applied, because the command it was written for never ran. A guard bound on the command that ran, or on .op:cmd or .op:run, is not affected:

script.mld:4  guard  allow  (:check#18)
  held to deny-only: bless: it was reached through .op:cmd:echo, the operation of the command as written, which a before-guard replaced with a command carrying .op:cmd, .op:cmd:printf; the command as written never ran, and a guard vouches only for a command that ran, so it may deny but not loosen; it did not get: privileged allow, remove .untrusted, add .trusted

A printed denial ends with a pointer to it:

mlld: Label '.secret' from argument 't' cannot flow to '.op:cmd'
why: rule policy.labels..secret.deny from policy.mld:3. Run mlld why script.mld for details.

The why: line is only on the printed error. A program that catches the denial reads the same @mx.denial.reason as before, with no file names in it.

Output. For each verdict:

script.mld:12  exe @deploy argument  refused  (:verdict#4)
  rule: policy.labels..secret.deny (declared at policy.mld:3)
  label: .secret, carried by argument token
  matched: .op:cmd
  exception .op:cmd:git (local.mld:2) did not apply: it is declared in a different file from the deny, and that file is not .priv.sss
  box: none started
  guards: none ran

An exception does not apply when its pattern does not match the operation, when it is not more specific than the deny, when it is in another file (only a .priv.sss file may except a deny from elsewhere), or when the rule is locked. With --line, an allowed check shows the exception that lifted its deny.

An exception a person switches on (see policy-label-flow) is named with its exception (of `talk_to_others` ), and the reason it did not apply says nobody has switched it on, its time limit has passed, or its turns are used up. When switching it on would not let the call through anyway, because another deny would still refuse it, the reason says so and nobody is asked. A deny lifted by several exceptions, plain and switched on, lists each. When one lifted a deny, the line after it says who switched it on, with their roles, when, and what it had left at the check:

  exception .op:msg:send (policy.priv.sss:3) lifted the deny .op:msg:send (policy.priv.sss:2)
    switched on: `talk_to_others` by gh:12345678 (.role:owner) at 2026-10-26T12:00:00Z; until 2026-10-26T14:00:00Z, 19 of 20 turns left

The path. For a denial, why also shows how the refused label got to the argument that carried it: where it entered the program, each binding it passed through, and the call.

  path: @token ← .secret (line 2) → @headers (line 3) → @wrap(t) (line 5) → @post(arg 2) (line 5)

Read it left to right: @token was declared .secret on line 2, a template on line 3 put it into @headers, @headers was passed to @wrap's parameter t, and @wrap passed it to @post as its second argument, which is the call the policy refused. A label that arrived through a condition (a .pc: label, or a value chosen by a ternary) shows the condition as a step: @s ← .secret (line 2) → if (line 4) → @send (line 4). A step in another file names the file (@libkey ← .secret (keys.mld, line 1)). When the label reaches the argument by more than one way, why shows the shortest and says how many more there are; --all lists every one (up to 50, and it says so when there are more).

A run does not record where each label came from, so the path is worked out from the program itself, the way mlld flowcheck reads it (see mlld howto flowcheck). That only explains the run while the program is the one that ran, so the path is shown only when all of these are unchanged since the run: the script, every file it imports, and the label-flow rules in force at the check (which includes mlld-config.json and the policies it imports). When one has changed, why shows the verdict as usual and says which:

  path: not shown: main.mld has changed since the run

Run the script again to see the path for the current program. The path is also not shown for a run of a program with -e, a tape recorded before mlld recorded what a path needs, a run recorded by another version of mlld, or a program whose policy is partly computed at run time or that declares records.

When flowcheck does not follow some step the value took (a builtin, an import it cannot read, a construct it does not analyse), the path stops there and says why:

  path: the trail goes cold at @h (line 3): the builtin `@upper` is not analysed; what it produces is unknown

An executable's own labels are a step of their own (exe @mk result [.secret] (line 2)). When flowcheck finds nothing that introduces the label on the way, why says no source is recorded and that it cannot tell where the label was added: it may have been added where the value was made (a command's output is .src:cmd, a policy rule can add labels at the check), or reached the value by a step flowcheck does not record.

Influence. A value can be .influenced because it came from an agent session the script loaded with @mx.hydrate, after the model in that session saw an untrusted tool result (see mlld howto builtins-ambient-mx, "Influence after hydration"). The program's text cannot show where that label came from, so for a refusal of .influenced why names the influence causes the run recorded when it hydrated the session:

script.mld:9  exe @send argument  refused  (:verdict#2)
  rule: policy.labels..influenced.deny (declared at script.mld:7)
  label: .influenced, carried by argument to
  influenced by: WebFetch, turn 12, labels .src:net — event s1/e14, seq 14

Each cause names the tool, the model turn the result arrived in, the labels that made it count, and the event's reference and place in the session. It never shows what the tool returned. A message delivered to the agent as its prompt, such as another agent's message, is a cause too when it was recorded with untrusted labels, or when it is a person's message that is not the words of the person the run works for (its labels then read .untrusted; see builtins-ambient-mx); it is named a message delivered as a prompt in place of a tool (tool is null in JSON), and never shows the message's text or who sent it. The same holds when a guard refuses an input that carries .influenced: why shows that guard's refusal (seam guard) with its causes, where any other guard refusal is only noted.

A cause a person cleared (see builtins-ambient-mx, "Clearing a source") is shown as cleared: rather than influenced by:, ending with who cleared it, their roles, the clear's event and their reason: cleared: WebFetch, turn 12, labels .src:net — event s1/e14, seq 14; cleared by gh:12345678 (.role:maintainer), event s1/e20: our own page. A cause cleared by a clear recorded in another session that read the same content says so: cleared in another session (<run> on tape lead) that read the same content by gh:12345678 (.role:maintainer), event <run>/<event>. A cause a clear named that did not count ends with clear not counted: and the reason, such as unsealed, no_role, content_differs, across_sessions_off or not_a_tape_read, so you can see why a retry is still refused.

A refused value carries no record of which hydrate made it influenced, so why names the causes of the latest hydrate before the check. It says so when that may not be the whole story: when the run hydrated more than one influenced history, when the run made LLM calls of its own (their output can be influenced too), or when no hydrate recorded any cause.

--causes lists every cause the run recorded, per hydrated session, whether or not anything was refused. With --format json it prints { "script", "run", "sealed", "sessions": [...] }; each session has session_id, run_id (the tape the history was read from, when it was), record, hydrated_at and causes. Each cause has ref, session_id, event_id, seq, tool, tool_use_id, turn, labels and description, plus cleared (by, login, roles, event, reason, and from_session and from_tape for a clear from another session) when a clear counted or clear_ignored when one did not. A session that carries a secret anywhere (in any of its events, at any depth, including a seq, a turn number or an id, or in the whole history), and every session in a secret's scope, is recorded only as { "withheld": "secret", "causes": <count> }: any of its fields could be the secret. why prints it as N influence causes withheld (secret), and a refusal's influence block counts it in withheld. Other sessions are shown in full.

JSON. --format json prints { "script", "run", "sealed", "verdicts": [...] }, plus note when there is nothing to show. Each verdict has:

Field Meaning
position, positions where the deciding record, and every record of the check, sit on the tape (for --position)
seam the check: exe @name argument, show, run cmd, output, …
verdict deny, allow or ask
span file, line, column of the call
rule key, file, line, locked, priv_sss; null when no rule decided
label, matched, argument the label that refused, the operation label it matched, the argument (name, index) that carried it
inputs the label sets the check read (labels, deny_only, op_labels)
exceptions_lifted, exceptions_considered each allow! with its file and line; a considered one has miss and why. An entry of a switch-on exception has switch_on: its name on a considered one, and on a lifted one its state at the check (exception, status, principal, roles, activated_at, expires_at, turns_used, user_messages_used, llm_calls_used, max_turns)
boxes, guards box and guard verdicts recorded on the same call
path for a denial, the shortest path as steps (text, file, line), the denied argument last; null when none is shown
paths_total, path_note how many paths reach the argument; why no path is shown, or where the trail goes cold
paths with --all, every path shown
influence for a refusal of .influenced: causes, how many causes were withheld because their session carried a secret, the record they came from, partial, and notes saying why attribution may be partial

A host session's checks. A host that records its own session (see live-stdio and cli-tape) gets a position back from each check, such as sdk:host#0/check:harness:claude%2FBash#1. Name the session the way mlld check named it, with --name, --host and --session (and --base-path if the check had one), and give no script:

mlld why --name harness --host fray --session s1 --position 'sdk:host#0/check:harness:claude%2FBash#1'
mlld why --name harness --host fray --session s1   # every denial on the session

why reads every file of the session, oldest first: a session goes on in a new file after a close or a restart. The position a check returned names every record of that check, and only that check: a new file numbers its checks after the ones in the session's earlier files. A session recorded by an older mlld numbered each new file from the start, so there one position can name a check in each file; why then shows each, with the file it is in (file), and says so. A host's check runs no program, so a denial shows no path, and its header names the session instead of a run:

session s1 of host fray on tape harness (unsealed)

exe @harness:claude/Bash argument  refused  (sdk:host#0/check:harness:claude%2FBash#1/:verdict#1)
  rule: policy.labels..op:tool:w.deny (declared at pol.mld)
  label: .op:tool:w, carried by the value
  matched: .op:tool:w
  box: none started
  guards: none ran
  file: 20261027T171446Z-c6b0d732
  path: not shown: a host's check runs no program, so there is no path to follow

A host that keeps the session itself gives its bytes with --store <file>, in the shape mlld tape --store takes, and a host on a machine whose config names no signers gives the keys it trusts with --trusted-signers <file>; both are as cli-tape describes, and the config's signers win whenever it names any. why does not take --from-head: it explains the checks from their own records, so it reads every line of the session, which a head does not carry.

With --format json the report has tape, host, session and files (the session's files, oldest first) in place of script and run, and each verdict has file. The header says sealed only when a verified seal covers every check record read. A name, host or session nothing recorded here is an error that says so; a position no check of the session has gets a note saying so, as for a run.

What it never shows. A tape never stores a value a check read, so why prints labels, rule names, files and lines only. Where the tape withheld a value because it was secret, there is nothing more to show.

Sealed tapes. The header says whether the tape is sealed (signed by a key the project's policy names). An unsealed tape is read the same way; its records could have been edited by anyone who can write the project.

When there is nothing to explain.

  • A script with no tape (never run here, or always run with --no-checkpoint) says so. With --no-checkpoint, the printed why: line names the rule and no command.
  • A run whose tape holds no label-flow verdicts says so: it made no check, or a version of mlld that did not record them wrote the tape. Rerun the script.
  • A box: * rule that finds no box running is shown as a verdict of its own (seam box, verdict deny): the rule, the file and line that declared it, the labels it matched, and the call. Its printed error ends with the same why: line.
  • A refusal of another kind (a guard, a failed command) is not on the tape as a verdict. why says the run ended with another kind of error; --line still shows the checks made at that line. A guard that refused an .influenced input is the exception: it is shown with its causes, as above.
  • --causes on a run that hydrated no influenced session says so.

Flow

mlld flowcheck gives every policy check in a script a verdict. mlld flow answers the questions behind a verdict: where a label comes from, which checks it can reach and by what path, what reaches one check, and which guards run on a call. It reads the same analysis as mlld flowcheck and runs nothing.

mlld flow script.mld --from .secret --to .risk:*     # which sources reach which operations
mlld flow script.mld --site script.mld:20             # what reaches the check on line 20
mlld flow script.mld --guards @send                   # the guards on each call of @send
mlld flow script.mld --sources                        # every place a label is introduced
mlld flow script.mld --sinks                          # every place a check is made

Ask one question per call; for a question not on this list, write a query (--query, -e, see flow-query). Add --format json for a JSON answer (schema: 1, the same node and path shapes as mlld flowcheck --format json).

--from <label> --to <op> lists each source of a matching label that reaches a check whose operation matches, with one shortest path and the check's verdict. Both take patterns as policy rules do: --to .risk:* matches .risk:exfil. --all lists every path, up to 20 per source and check, and says when it stopped there; a loop in the script does not make it run on. A label the policy adds where the check reads it (its unlabeled default, an apply action) has no source in the script, so it is reported as added by the policy at that check, with the rule:

2 sites: 1 definite, 1 clean
.secret @key reaches main.mld:20 — exe @send (definite)
  path: .secret @key line 12 → @key line 12 → exe @send line 20
.untrusted is added by policy at main.mld:7 — exe @send (clean), rule policy.defaults.unlabeled

The first line counts the checks the answer lists, by verdict. They come in order: the ones the policy refuses (definite, box-required) first; then the possible ones a path from a source reaches; then the possible ones flowcheck cannot see into (an unknown operation, a trail that goes cold); then the rest. --only definite or --only possible lists just those (the count line still counts every check). With --format json the pairs come in the same order, with counts and only beside them.

--to matches a check the way a policy's deny does: by the operation's labels, as the policy's includes and operations expand them, or by a label the value itself carries (a value back from a .risk:exfil executable is judged as one wherever it goes, so a show of it is listed "through .risk:exfil the value carries"). --from matches a label the value carries or one of the conditions the check runs under, and accepts either spelling of a trust state (.untrusted or .trust:untrusted).

Every check that can receive the label is listed, whether or not a path to it is known: also one whose operation flowcheck does not know (a call it cannot resolve, a statement it does not analyse; "its operation is not known") and one it rates possible for a reason other than the labels (a policy that binds guards, a construct it does not model; "what feeds it may carry the operation's label"). In a script with many of those (under a policy that binds guards, nearly every check) the answer is long; each such entry says why, they come after the checks with a path, and --only definite shows just the refusals. Where the label arrives through something flowcheck does not analyse (a builtin such as @upper, a spread, an import it cannot read), there is no path to show, so the answer says where the trail goes cold and why:

main.mld:9 — exe @send (possible) may carry .secret: something feeding it is not analysed, and no source of it is recorded on the way
  the trail goes cold at @h line 8: the builtin `@upper` is not analysed; what it produces is unknown
  path: @h line 8 → exe @send line 9

In JSON such an entry has "source": null and a cold object: the labels that arrive (labels, empty when the input is only unknown, unanalysed: true), the node where the trail stops (at), the path from it to the check, and why. Every entry's site has matched_by: { "by": "operation" | "value" | "unknown operation" | "unknown value", "labels": [...] }. Only when no matching check can receive the label does the answer say so (no site whose operation matches … can receive …).

--site <file:line[:column]> shows what can reach each input of the check there: the labels it carries on every run (must) and on some (may). A line with several checks lists them all; add the column to pick one. A check inside an executable's body is reached from every call of it; the answer joins them, and --contexts lists each caller on its own. --seam <name> does the same for every check of a kind, such as show or "exe @send".

--guards @exe lists, for each call of @exe, the guards a policy binds to it, in the order the runtime runs them, and whether each fires on every run (must) or only when its labels arrive (may):

call of @send at main.mld:20
  before:
    1. @gMod — bound by .op:named:send (another module, must fires)
    2. @gWide — bound by .op:* (this module, must fires)
    3. @gData — bound by .secret+.op:named:send (this module, must fires)

The order is the runtime's: binds from a locked rule first, then binds another module declared, then the calling module's own; within each, the most general pattern first; then the order the policy declared them. The answer prints this rule too.

--sources lists every place a label is introduced: a labelled const, a command's output, an executable's own labels on what it returns. --sinks lists every place the runtime checks label flow, with its operation labels and verdict.

--law answers any question as a law (never: in a policy) reads labels: a label a guard or a label modifier removes still arrives. Without it, a label a guard may remove arrives only possibly, so a check past the removal reads possible; with it, the same check reads as it would without the guard, and the answer says so on its first line (in JSON, "law": true). Use it to see why mlld flowcheck says a law is violated when a guard strips the label on the way. A law with declassify: priv lets a privileged guard's removal on every path end it; --law does not apply that, so a path through such a removal still shows.

Exit codes: 0 the question was answered; 2 the question could not be read (no question, two, an unknown flag) or the script could not be analysed.

What mlld flowcheck cannot see (see its page), mlld flow cannot either: a value it does not follow has no path back to a source.

Flow queries

mlld flow answers a fixed set of questions (see flow). When you need one it does not have, write it as a query. A query reads the same analysis as mlld flowcheck, exported as tables of facts (relations), and runs nothing.

mlld flow script.mld --query checks.dl                  # the rules and queries in checks.dl
mlld flow script.mld -e '?- site(S, F, L, C, Seam, V).' # a query written inline
mlld flow script.mld --builtin from-to --param from=.secret --param to=.risk:*

Add --format json for { "schema": 1, "file", "complete": { "partial", "graph_capped" }, "queries": [ { "query", "columns", "tuples" } ] }.

Writing a query

The notation is standard Datalog:

% a comment
secret(N) :- source(N, L), matches(".secret", L).    % a rule: secret(N) holds when…
reach(N, M) :- secret(N), edge(N, M, _).
reach(N, M) :- reach(N, X), edge(X, M, _).            % rules may be recursive
?- reach(N, M), site_node(S, M), site(S, File, Line, _, Seam, Verdict).
  • A rule head :- a, b, c. derives head wherever every item after :- holds. A fact is name("value", 3).
  • ?- … is a query. Its answer is a table: one column per variable, in the order they first appear, one row per distinct answer, sorted. A query with no variables answers yes or no.
  • Variables start with an upper-case letter or _. _ alone means "any value".
  • Values are "strings" and whole numbers. $name is a parameter, given with --param name=value; a value made only of digits is a number.
  • Items in a rule or query: rel(…), !rel(…) (no such row), A = B, A != B, and matches(Pattern, Label).
  • matches(P, L) holds when label L matches pattern P as a policy rule matches it: .risk:* matches .risk:exfil, and .untrusted matches .trust:untrusted. It only checks, so both arguments must already have values.

There is no arithmetic and no way to build a new string, so every query finishes. Before anything runs, a query is refused, with the line and column, when it:

  • does not parse;
  • uses a relation with the wrong number of columns, or one that is neither listed below nor defined by a rule;
  • defines one of the listed relations;
  • reads a variable that nothing gave a value yet. Items are read left to right; a variable gets its value from a positive rel(…) or from = with something that has one. A negated item, matches, != and the rule's head need values from earlier items;
  • depends on its own negation (p :- !q. with q :- p.);
  • uses a $parameter that was not given.

A query that would build more than 5,000,000 rows stops with an error naming the relation that was growing; --max-tuples <n> changes the limit.

What a query reads

A check is a site, named by a number; a place in the flow graph is a node, also a number. A site seen from several callers has one context per caller.

Relation Columns Holds for
node node, kind, file, line, text every node of the flow graph (line 0 when not known)
source node, label each label a node introduces
edge from, to, rule each step a value takes
unknown node, why a node at a line where flowcheck stopped following (a construct it does not analyse, an import it cannot read)
site site, file, line, column, seam, verdict every check (seam as mlld flow --sinks names it: show, exe @send)
call_site site, exe a check of a call of @exe (exe without the @)
site_node site, node the node of each context of a site
op site, label the check's operation labels, with the policy's aliases expanded
value_op site, label the labels the value may carry, expanded the same way
unseen_op site the check's operation is not known
must site, label a label that reaches the check on every run
may site, label a label that may reach it (every must label too)
uncertain site something reaching the check may carry any label
context site, ctx, file, line, verdict each context, with the statement it was reached from
input site, ctx, input each input of a check (a parameter, value, …)
input_must, input_may site, ctx, input, label per input, as must and may
pc site, ctx, label the labels of the conditions the check runs under
policy_added site, label, rule a label the policy adds where the check reads it
guard site, ctx, guard, pattern, timing, rank, specificity, index, fires each guard a policy binds to a call; the runtime runs them by rank (0 a locked rule, 1 another module's, 2 this module's), then specificity, then index; fires is must or may
proof_floor_first site, ctx the policy's proof floor runs before the guards
declared_guard guard, file, line every guard the script declares
partial (none) the analysis was stopped before it finished
graph_capped (none) the flow graph reached its size limit

Certain or possible. A label is certain only in must and input_must. Every other label relation (may, value_op, input_may, pc, and reaching a site along edge) says what may happen. A question that wants "on every run" has to read must.

When the answer may be incomplete. If partial or graph_capped holds, the answer may be missing rows: the output starts with a note saying so, and the JSON's complete says which. What mlld flowcheck cannot see (see flowcheck), a query cannot either.

Built-in queries

--builtin <name> runs mlld flow's own questions written as queries; they return the same answers, as rows instead of paths. Paths, path lists and the guard order stay in mlld flow.

Name Parameters Same as
sources --sources
sinks --sinks
from-to from, to --from/--to: the reaching (source, site) pairs, the labels the policy adds, and the sites a label may reach with no recorded source
site line --site with a line: what reaches each input, joined over contexts
seam seam --seam
guards exe --guards

Three questions mlld flow cannot ask

Checks that both .secret and .untrusted reach:

src(N, P) :- P = ".secret", source(N, L), matches(P, L).
src(N, P) :- P = ".untrusted", source(N, L), matches(P, L).
reach(N, M) :- source(N, _), edge(N, M, _).
reach(N, M) :- reach(N, X), edge(X, M, _).
hits(S, P) :- src(N, P), reach(N, M), site_node(S, M), may(S, L), matches(P, L).
?- hits(S, ".secret"), hits(S, ".untrusted"), site(S, F, Line, _, Seam, V).

Calls .secret reaches that no guard is bound to:

secret(N) :- source(N, L), matches(".secret", L).
reach(N, M) :- secret(N), edge(N, M, _).
reach(N, M) :- reach(N, X), edge(X, M, _).
reached(S) :- secret(N), reach(N, M), site_node(S, M), may(S, L), matches(".secret", L).
guarded(S) :- guard(S, _, _, _, _, _, _, _, _).
?- call_site(S, Exe), reached(S), !guarded(S).

Sources that reach a check only through something flowcheck does not follow:

clean_step(X, Y) :- edge(X, Y, _), !unknown(Y, _).
any(N, M) :- source(N, _), edge(N, M, _).
any(N, M) :- any(N, X), edge(X, M, _).
clean(N, M) :- source(N, _), clean_step(N, M).
clean(N, M) :- clean(N, X), clean_step(X, M).
at_any(N, S) :- any(N, M), site_node(S, M).
at_clean(N, S) :- clean(N, M), site_node(S, M).
?- at_any(N, S), !at_clean(N, S).

Exit codes: 0 the queries ran; 2 a query was refused or stopped, or the script could not be analysed.

mlld migrate Command

mlld migrate rewrites files written in the older mlld syntax (var, when, bare labels, with { creds }, …) into the 2.2.0 syntax, in place. It lists every site it cannot rewrite safely, for you to fix by hand. The 2.2.0 migration guide lists each change and which ones the tool rewrites.

git status                                   # 1. check every mlld file is committed
mlld migrate . --old-ref HEAD --check        # 2. preview: writes nothing
mlld migrate . --old-ref HEAD                # 3. rewrite
git diff                                     # 4. review, fix listed sites, commit

Commit the files you want converted by name (git add notes.mld helpers.mld && git commit), rather than with a blanket git add . that would also commit whatever else is lying untracked in the folder.

It works from git history, never from a file's content: --old-ref HEAD says the files as last committed are the old syntax. So it needs a git repository, and it leaves some files alone:

  • a file with uncommitted changes, or one git does not track yet, is listed as refused and not touched; commit it first;
  • a file git ignores is skipped without being listed;
  • a file absent at the commit you name is treated as new and skipped.

It walks directories for .mld, .sss, .priv.sss, .att and .mtt files, and renames .mld.md, .mlld and .mlld.md files to .mld.

Trust settings depend on where the file is

The old self_attestation spellings meant different things in different files, so the self-attestation-speaker-rows rule reads the project's mlld-config.json to see whether a file is one of its policy.import files:

  • cli: true (also stdin) becomes cli: { claims: ["trust", "proof", "intent"] } in a config policy file, and cli: { claims: ["trust"] } elsewhere, which is all it granted there. env: true, file: true and net: true become { claims: ["trust"] }. A source set to false is removed.
  • sdk: true in a config policy file becomes an sdk row and the host row it also stood for. In any other file it is listed as a manual site: both rows can only be granted from the config.
  • envelopes: { issuers: [ … ] } becomes self_attestation.issuers, each kind the old scope listed mapped to "*", and a top-level signers block moves into self_attestation. Outside a config policy file, or where the value is not written out as a literal, these are listed as manual sites naming the config file to move them to.

A moved row lands in the self_attestation table beside it when there is one: in a * { … } block, or under labeling in a policy object. A file listed by a nested project's mlld-config.json, with another project's config above it, is rewritten as a project file and listed as a manual site, since which config applies depends on where a run starts. A config policy file that a script also loads with import policy gets the config's rows in both places, so check that use by hand.

See policy-signers and policy-envelopes for the rows.

Reading the report

The report lists the files it rewrote, each with the rules that changed it; files it renamed, as old -> new (a .mld.md module becomes .mld); manual sites, as path:line:column and what to do; refused files and why; parse failures, files it could not read as old syntax; and files that failed a rule's own check (rule defects; not written), where a rule's output would not run: the entry names the rule and the error, and the file is left as it was for you to convert by hand. With --check, the first two read would rewrite and would rename. It exits 0 when nothing is left for you to do, and 1 otherwise (including when --check finds changes to make).

A file with a manual site may be only partly rewritten. Running it stops at the first old form left, with an error that names the new one.

Run it once, before you commit the rewrite. After that commit, a second run over the whole tree with --old-ref HEAD reads the converted files as old syntax and lists them as parse failures. To convert files it refused, commit them and name just those files: mlld migrate notes.mld --old-ref HEAD.

Options

Option Effect
--old-ref <ref> A file's old text is its content at the merge base of HEAD and <ref>. Files already converted are skipped; a file changed by hand since an earlier conversion is listed and left alone.
--since <commit> Every file is old. For converting a branch that does not yet contain <commit>; refused on a branch that does, so --since HEAD always refuses.
--check Write nothing; report what would change.
--fences Also rewrite the mlld code blocks of markdown pages. Nothing outside a block's code changes.
--rules <ids> Run only a stretch of the rule chain, comma-separated, in chain order.
--json Print the report as JSON.
--list <kinds> Write nothing; read files as old syntax and list sites whose meaning the new syntax changes (allow-overrides, asks, custom-labels, shadowing, records, accumulators). Takes no --old-ref.

Exactly one of --old-ref and --since is required, except with --list. mlld migrate --help prints the full usage.

mlld tape Command

mlld tape records an agent harness's own session on a tape, with no script running, from the harness's hook scripts. It does what the live methods tape:open, tape:record and tape:close do (see config-live-stdio), as one command per call: a hook is a new process for each event, so nothing has to stay running between events. mlld writes its own tape format and chains and seals every record, so the hook does no cryptography.

mlld tape open   --name harness --host fray --session "$SESSION_ID"
mlld tape record --name harness --host fray --session "$SESSION_ID" \
  --kind tool_call --tool harness:claude/Bash --tool-use-id toolu_1 --args '{"command":"git push"}'
mlld tape close  --name harness --host fray --session "$SESSION_ID"
mlld tape verify --name harness --host fray --session "$SESSION_ID"

--name is the tape (.llm/tapes/<name>/), --host says which host is recording, and --session is the host's own id for the session. record and close find the session by these three, so the hook keeps nothing between calls. Open the session (a session-start hook), record each event, and close it at the end. Opening a session that already has a file goes on in that file under the same rule as record (below), so a hook that fires again when the harness resumes or compacts the session keeps one chain; after a close, open starts a new file that names the closed one as its lineage.

Forks. When the harness continues a conversation under a new session id (a fork, not a resume), open the new session with --forked-from <parent-session-id>:

mlld tape open --name harness --host fray --session "$NEW_ID" --forked-from "$PARENT_ID"

The new session's first line records host.forked_from, and its result adds forkedFrom and parentRecorded. The parent's recording is never opened for writing or changed. A parent with no recording on the tape is recorded as given and the result says parentRecorded: false. A session that already has a file keeps the parent that file names; opening it again with the same parent, or with none, goes on in the file, while naming another parent, naming one for a session recorded without one, or naming the session itself is refused. Only open takes --forked-from.

Fields. The same fields as the live methods, as flags or as one JSON object on stdin with --stdin. A field given twice, or both ways, is refused, and so is one the verb or the record's kind does not take: open and close take only the session fields, so --label, --kind or --text on them is refused rather than ignored.

Kind Fields
user --conversation, --text, optional --principal '{"id":"...","login":"..."}'
tool_call --tool, --tool-use-id, --args '<json object>' (left out when labelled secret), optional --host-fields '<json object>'
tool_result --tool, --tool-use-id, --value '<json>' (left out when labelled secret), optional --host-fields '<json object>'; or --outcome failed --error <text>, or --outcome denied --denied '{"by":"...","reason":"..."}', with no --value
note --note-kind, --text, optional --data '<json>' and --facts '{"<kind>":"<value>"}'
assistant --conversation, --model, --message <the provider's message, exactly as received>, optional --tool-use-ids '["..."]', --stop-reason, --message-id
answer --question <ref>, --chosen 1|2, optional --principal '{"id":"...","login":"..."}'
clear --causes '["<session_id>/<event_id>"]', --principal '{"id":"..."}', optional --reason (see config-live-stdio and builtins-ambient-mx, "Clearing a source")
helper_start / helper_stop --helper-id, optional --parent-tool-use-id (the tool call that started the helper) and --host-fields '<json object>'
event --type <namespace>.<name> (a type you define, such as opgate.checkpoint; a namespace mlld uses is refused), optional --data '<json>', --facts '{"<kind>":"<value>"}' and --host-fields '<json object>'

user, tool_call and tool_result take --label <label>, repeated; a note, assistant, answer, clear, helper_start, helper_stop or event carries none, and a label on one is refused. mlld labels an assistant reply .src:llm:claimed: it is your claim that a model wrote it, not a call mlld saw. Every kind takes --source <name>, the hook or component that wrote the event, --author <id>, your permanent id for whose words these are (never a principal), and --occurred-at <RFC 3339 time>, when you say it happened (the line keeps mlld's own ts). A user turn also takes --sender-kind agent or --sender-kind person: who sent a message delivered to the agent as its prompt (see config-live-stdio, tape:record); any other value is refused. The fields these kinds take are described under tape:record in config-live-stdio; in short, a failed or denied result never counts as a value, --host-fields (at most 64 KiB as JSON, HOST_FIELDS_TOO_LARGE over it) and --source are your own claims, and anything that can run mlld tape record can write any --source. --base-path <dir> picks the project (by default, the one the current directory is in); its config policy decides the signers. --trusted-signers (below) only fills in when the config names none. Through --stdin the names are the live methods' (toolUseId, noteKind, basePath, labels as a list):

echo '{"kind":"note","noteKind":"phase","text":"tests passed"}' |
  mlld tape record --name harness --host fray --session "$SESSION_ID" --stdin --json

Many records in one call. record --batch <file> writes every record in a JSONL file: one JSON object per line, each with the fields --stdin takes for one record (kind and its fields, without name, host, session or basePath). --batch - reads the lines from stdin. Use it to import a history or turn a transcript into a tape; give each record its original time as occurredAt, since ts is when the batch was written.

cat > history.jsonl <<'JSONL'
{"kind":"user","conversation":"main","text":"push it","occurredAt":"2025-03-01T09:30:00Z","author":"gh:12345678"}
{"kind":"event","type":"fray.message","data":{"thread":"t-1","body":"done"},"occurredAt":"2025-03-01T09:31:12Z"}
JSONL
mlld tape record --name harness --host fray --session "$SESSION_ID" --batch history.jsonl --json
## {"events":[{"event":"<tape>/<id>","seq":5},{"event":"<tape>/<id>","seq":6}],"sealed":true,"continued":true}

The records are written in order, sealed once after the last and put on disk once, so a thousand records take one call instead of a thousand. It is all or nothing: every record is checked before the session is touched, and one refused record (or a line that is not a JSON object, or a record that names a session) refuses the whole batch and writes nothing. The error says which record, and with --json carries it as error.index, from 0: line n of the file is record n - 1. --batch takes no record fields as flags or on stdin. Each record is written exactly as record would write it on its own, so influence, clears and answers count the same; two answers to one question in a batch refuse it.

Checking a call before the harness runs it. mlld check asks the same question as the live method check (see config-live-stdio): would this tool call be allowed, asked or denied, under the project's policy, guards and grants, given what the session has recorded so far? Once an untrusted result is on the session, in any of its files, the call is .influenced until a person clears that result. A pre-tool-use hook calls it and acts on the verdict. Nothing runs, nobody is asked, and nothing is spent, except as --defer-ask (below) describes.

mlld check --name harness --host fray --session "$SESSION_ID" \
  --tool harness:claude/Bash --args '{"command":"git push"}' --label .op:tool:w --json
## {"verdict":"ask","reason":"review the write","named":true,"check":"...","sealed":true,...}
  • --label gives the tool's .op:* and .risk:* labels. They count in full only when the config's host row grants the tool claim and lists the tool in tool.tools. Otherwise the call is judged as an unnamed tool (named: false), and its labels can only refuse it: a deny, ask or guard on them applies, and nothing that would let it through (an allow! exception, an only or allow list, a guard's allow) reads them.
  • With hostTools.module in mlld-config.json, a tool the module's @hostTools maps is judged by that entry's labels, inputs record and the module's guards instead of --label (see config-live-stdio).
  • --arg-label puts a restricting label, such as untrusted, on every argument.
  • --tool-use-id is sent back as given.
  • signersFrom says which signers verified the session: config when the project's config names any, host for keys given with --trusted-signers when it names none, otherwise none.
  • check exits 0 whatever the verdict, so read verdict from --json. Without --json it prints the verdict and its reason. A refusal (one of the ASK_* codes below, or a malformed request) exits 1.
  • An answer that depends on code a check would have to run is CHECK_UNAVAILABLE.
  • So is a call a before-guard would rewrite, such as allow "ls". The harness runs the tool with the original arguments, so an allow earned by the rewrite would vouch for a call that never happens. The error names the guard.

Asking now, answering later. A hook has seconds; the person may answer hours later. With --defer-ask, an ask verdict puts a question on the session's tape and returns at once with its ref in ask.ref. The host shows the person the question and records their choice; the next mlld check --defer-ask of the same call reads it.

mlld check --name harness --host fray --session "$SESSION_ID" \
  --tool harness:claude/Bash --args '{"command":"git push"}' --label .op:tool:w --defer-ask --json
## {"verdict":"ask","ask":{...,"ref":"<tape>/<event id>"},...}
mlld tape record --name harness --host fray --session "$SESSION_ID" \
  --kind answer --question "<tape>/<event id>" --chosen 1
## the harness tries again: the same check now says
## {"verdict":"allow","spent":"<tape>/<event id>",...}
  • --chosen 1 approves and --chosen 2 denies. An approval lets the same call (same tool, same arguments) through once, and the check marks it used before it answers; a denial makes the check deny until it is older than labeling.approvals.restore_window, after which the call is asked about again.
  • Asking again before anyone answers returns the same ref and records nothing new.
  • Recording an answer for a ref that is not a question on this session fails with ASK_REF_UNKNOWN; one already answered fails with RUNTIME_ERROR. Either way nothing is written.
  • An approval counts only when the config's host row grants approval, the tape was sealed when it was recorded, and it is newer than labeling.approvals.restore_window (one hour by default). Otherwise the check fails with ASK_ANSWER_UNSEALED or ASK_ANSWER_EXPIRED; without approval the answer is recorded but ignored and the check keeps asking. A second use fails with ASK_ANSWER_SPENT.
  • Other arguments are a different call and simply get a fresh ask. The one exception: the same --tool-use-id with other arguments than an approved, unused question for it fails with ASK_ANSWER_MISMATCH, since one tool call has one set of arguments.
  • A failed check writes a fresh question first, and error.ask.ref names it; the next check of that call returns a plain ask under it rather than failing again.
  • "Used" is a line on the tape: someone who can put the session's files back to an earlier state can make an approval count again inside the restore window. See config-live-stdio for the live method's version.

Output. --json prints the live method's result object: open gives tape, name, path, sealed and signersFrom (config, host or none, as for mlld check); record gives event ("<tape>/<event id>"), seq and sealed; close gives tape, events (how many events the host recorded in the file) and sealed. sealed is false, with sealReason, when the event is not under a seal. record and close, and open of a session that already has a file, also give continued: true when the call went on in the session's file, false with restartReason when it started a new one (below). An error prints {"error": {"code", "message"}} with the live methods' codes and exits 1: INVALID_REQUEST for a missing or malformed field, RUNTIME_ERROR for a refused record, HOST_FIELDS_TOO_LARGE for host fields over 64 KiB, TAPE_NOT_FOUND when the session was never opened or has been closed, and the ASK_* codes above for a deferred ask. A refused call writes nothing. Without --json, one line says what happened.

Sealing and the ssh-agent. Each call that writes asks the user's ssh-agent to sign once, for a fresh sealing key, so an agent that asks before signing asks on every hook call. A call spends at most 10 seconds in all on the agent, counted from when it starts. An agent that is locked, declines, or does not answer in time leaves the event recorded but not sealed, and says so. mlld then notes in the project (.llm/ssh-agent-unanswered) that the agent did not sign, and for the next minute calls record unsealed without asking it, so a locked agent costs one call its wait rather than every call. A call that ran out of time because it waited behind other calls does not count against the agent: only an agent that declined, or did not answer in most of a call's 10 seconds, is noted. With no signers in the config policy, the session is recorded unsealed and every result says why.

Two hooks at once. Each call takes a lock on the session before reading anything and keeps it until its last line is written, so calls on one session take turns. Turns are not first come, first served: two calls started close together may land in either order, so events can be on the file out of the order they happened in (none is lost). A call that waited past its 10 seconds in the queue does not ask the agent, so calls queued behind a slow or silent agent are recorded quickly once it gives up. A call waits up to 60 seconds for its turn; if it has not had one by then it fails with SESSION_BUSY and records nothing. --lock-wait <ms> sets that wait, for a hook that must answer inside its tool's time limit: --lock-wait 200 gives up after 200 milliseconds of waiting. The wait starts once the call has loaded the project's config, so the whole call takes that load (tens of milliseconds) and the wait. A session a live host has open is refused at once whatever the wait.

A session open in a live host. A host that opened the session with the live method tape:open keeps it until it closes it, and only it writes the session's file meanwhile. A mlld tape call on that session, or a tape:open of it from another connection, fails at once with RUNTIME_ERROR and records nothing; record through the host that has it open, or close it there first. Asking the same connection to open the session again, even before the first open has answered, answers with the same handle.

A file that changes while a call writes. A call verifies the file, then appends to it. A line someone else adds to the file in between, or a change made in place (while the call waits on the agent, say), breaks the file's chain: the file no longer verifies, nothing in it counts as sealed, and the call reports sealed: false saying the file changed. The next call starts a new file.

Which file is the session's. A call reads the first line of each file in the tape's directory to find the session's files, newest first. In a project with signers, a first line is only a claim, so only a file that verifies as sealed counts as the session's newest, can close the session, or be named as a new file's lineage: a sealed call never writes into an unsealed file left in the directory with a later date. The exception is a call that cannot seal (no agent, or the agent did not sign). Rather than start a file per call while the agent is away, it appends its unsealed event to the newest sealed file, so the outage shows there as an unsealed tail; once that file ends in such a tail, later calls go on in the session's outage file, the newest unsealed file whose lineage names the newest sealed file, starting it if there is none. An unsealed file is not sealed, so its lineage is only a claim, and a file planted with the right lineage can collect such calls' events; they are unsealed and untrusted wherever they land. The agent note can be planted too, to make calls take this path.

Why a call starts a new file. Each seal certifies everything before it in the file. So a call goes on in the session's file only when the whole file verifies and its last line is a seal mlld verified: nothing has been added since the last call sealed it. Otherwise the call starts a new file for the session, and the result says why. The new file's session_start names the file it replaces as its lineage when that file verifies, and the old file is left exactly as it was, so a line someone added to it is never sealed. A new file is started when:

  • the file does not verify (a line before the last seal was edited, or removed from the middle);
  • its last line is not a seal (a line was added, or the last call could not seal because the agent did not answer);
  • the sealing key in force is more than 24 hours old;
  • it was recorded unsealed and this call can seal: a seal now would certify lines no seal covers.

A project with no signers has nothing to seal with, so its sessions go on in one unsealed file.

A crash in the middle of writing a line. A hook killed while it writes leaves an unfinished last line. The next call drops just those bytes and goes on in the same file. It never drops a whole line: a whole line after the last seal (a hook that died after writing its event, before sealing it) still starts a new file, as above.

record reads only the end of the file. Checking the whole file on every call would make each hook slower as the session grows. So mlld tape record (unless it is asked for a head with --write-head) reads the file's first line and its last few lines, from the last certificate to the end: it checks that those lines chain, that their certificate is signed by a signer the config names now, and that their seal is good, then appends its event and seals on top. It knows where the file ended from a small record mlld keeps for each session in your own state folder (~/.llm/tape-append/, or under MLLD_USER_STATE_DIR), outside the project, where an agent working in the project's box cannot write. When that record is missing, or the file is not the length or does not end the way it says, the call checks the whole file as before. A project with no signers gets the same short read, with nothing sealed. Every other verb, mlld check and mlld tape verify check the whole session.

The cost of the short read: a line in the middle of the file changed since the last call is not seen by record, which seals its event on top. The next full check (mlld tape verify, mlld check, any read of the session) finds the change and refuses the file, with the new event in it. Nothing in such a file counts as sealed or proven, so the change gains nothing, but events recorded after it are kept only in a file that does not verify.

Extra files. A session can be split over more files than its restarts for tampering would need, without losing an event. An agent that is slow to sign, under a burst of hook calls, leaves calls that ran out of time with unsealed events, and the next call that can seal starts a new file after them. On a very long session with a slow build, verifying the file can use up a call's 10 seconds before it asks the agent, with the same result.

What sealing cannot catch. A file cut back to an earlier seal, its later lines deleted, still verifies: it looks exactly like a session that ended there, and the next call goes on from it. The record record keeps outside the project can show it: when the file is shorter than this machine last left it, the call warns that it was cut back or rolled back, and checks the whole file. That is all it can tell, and only against what it kept: with no record (another machine, a cleared state folder) nothing is noticed. The next call's events get ids of their own, never the ids the deleted lines held.

Checking the whole session, and verified heads. Every call but record verifies the session's files before it goes on, and on a long session that is most of its time: each hook call is a new process, so it checks every earlier record's signature again. A verified head lets a call skip what an earlier check already verified.

mlld tape verify --name … --host … --session … checks every file of the session and prints, per file, whether it verifies, how many events it holds and how far it is sealed, then whether what the session recorded influences its model's next output (influence: untouched, influenced or cleared). It adds nothing to the tape and exits 1 when a file does not verify.

A verified head is a short statement, signed with an SSH key you choose, that says "this tape file checked out through this line, under these signers and this policy, by this mlld", and carries what the next check needs to go on from that line without reading the lines before it: the keys that certified the file's seals, and the hash of mlld's saved judgement of the session (which results influenced it, and which a person cleared). The head is a JSON object {statement, signature, fold}; fold is that saved judgement, and the statement binds its hash, so keep the three fields together and unchanged. List the keys whose heads count in mlld-config.json, as you list signers:

{
  "tape": { "checkers": { "og": { "key": "ssh-ed25519 AAAA… og-checker" } } }
}

An entry takes key (ed25519 only) and optionally valid_after and valid_before, read as a signer's are. Then:

mlld check --name harness --host fray --session "$SESSION_ID" \
  --tool harness:claude/Bash --args '{"command":"ls"}' \
  --from-head .llm/heads.json --write-head .llm/heads.json
  • --write-head <file> (on every verb, verify and mlld check): after the call, each session file that verifies and ends in a seal gets a fresh head at its last line, signed through the ssh-agent by a key tape.checkers lists, written to <file> as {"heads": [...]}. A head counts for 24 hours. The call's own answer never depends on it: a head that cannot be made gives headsWritten: 0 and headError, and a file none could be made for is listed under headsSkipped with the reason.
  • --from-head <file>: before the call, each head in <file> that counts lets mlld skip re-checking the seal signatures of its file up to the head line; every line after it is checked in full. A missing <file> holds no heads; one that is not a heads file is refused.
  • --host-summary <file> and --next-host-summary <file>: your own record of the session, as it stood when the heads in --from-head were made, and as the heads written now should bind. mlld never reads them, only hashes them; a head made with a summary counts only when the same bytes are handed back.
  • The result says what each head came to under heads (mlld tape verify: under each file's head): admitted: true, or admitted: false with a code.

A session kept in pieces. A host that stores what each checkpoint added and deletes or encrypts it once it is read can have mlld tape verify check only the new lines: leave just the lines after the head in the session file, and give the head with --from-head and the summary it binds with --host-summary. The file is then checked from the head alone (head.piece: true), the session's influence is judged on top of the saved judgement, and --write-head makes the head for the next piece. Here a head that does not count refuses the file (verified: false, and the session reads as influenced): the lines before it are not there to check instead.

Over a whole file, a head is only ever a shortcut: one that does not count is ignored, and the file is checked in full, so the call gives the answer it would give with no head. The codes say why one did not count:

Code Why
HEAD_NO_CHECKERS mlld-config.json lists no tape.checkers
HEAD_UNTRUSTED no listed checker signed it, the signature does not match the statement, or the checker's valid_after/valid_before does not hold now
HEAD_MALFORMED it, or its saved judgement, is not one this mlld reads
HEAD_OTHER_TAPE it names another tape, host session or file
HEAD_OTHER_MLLD another version of mlld made it, or it read another tape format
HEAD_EXPIRED it is past its expiry
HEAD_SIGNERS_CHANGED / HEAD_POLICY_CHANGED the config's signers or policy differ from those it was made under
HEAD_FOLD_MISMATCH the saved judgement handed back is not the one the head binds
HEAD_SUMMARY_MISMATCH the host summary handed back is not the one the head binds, or one was handed back for a head that binds none, or none for one that does
HEAD_CHANGED the file's line at the head's position is not the head line (edited, or cut short)
HEAD_DOES_NOT_FOLLOW the piece's first line does not follow the head line
HEAD_CERT_REFUSED a certificate the head carries no longer verifies against the signers in force now
HEAD_SEAL_CLAIMED the head was taken on an unsealed file and the lines after it claim a seal
HEAD_CHECK_FAILED the lines after the head, or the file itself, did not verify (a line, a payload file or a certificate failed)

What a head skips over a whole file is narrow: the signature on each seal up to the head line. The head names the hash of its own line, and each line names the hash of the one before it, so mlld still reads every earlier line to confirm the bytes are the ones that were checked, re-checks every certificate against the signers in force now, re-hashes every stored payload file, and checks every line after the head in full. Over a piece it skips everything before the head: trust in those lines rests on the checker key that signed the head, not on where the head or the earlier lines were stored. A change made to the earlier lines after the head was signed is not found by checking a piece; only a full check of the whole session, or a checker who checks the stored pieces again, finds it. Keep heads where only you can write them; even so, a forged head needs a checker's key, and a stolen checker key lets someone vouch for lines that would not verify. Treat a checker key as you treat a signer's.

Stored bodies. A host that wants to delete what was said later, and keep a tape that still verifies, stores every event body apart from its line. --store-bodies (on every verb and mlld check) puts each body (a user turn's text, a tool call's arguments, a result's value, a note's text and data) in the tape's payload store whatever its size; the line keeps a reference, body: {payload_hash, fields}, and the small fields (labels, ids, host fields, facts). Delete a body's file under .llm/tapes/<name>/payloads/ and the tape still verifies; a reader reports that body as pruned rather than leaving it out.

A plain stored body is named by its sha256, so someone holding the tape could test a guess at a deleted body against its name. --body-keys <file> names bodies by a keyed hash instead, hmac-sha256-<key id>-<hex>. <file> holds a JSON list:

[{ "id": "k2", "key": "<the new key's bytes, base64>" },
 { "id": "k1", "key": "<an earlier key's bytes, base64>" }]

The first key names new bodies; the others check bodies written under them earlier. A key id is 1 to 64 of a-z, 0-9 and _, and a key is at least 16 bytes. Keys are secrets: they are read from the file, never given on the command line where other processes could see them, and mlld never writes them to the tape or prints them, in a result or in an error. Keep the file private. With --stdin, a bodies object as tape:open takes it ({"storeAll": true, "keys": [...]}) may be given instead of the flags.

Each call is its own process, so give the same flags on every call of the session. What a call or reader makes of a keyed body depends on the keys it holds:

  • the right key: the body is checked, and read back (body.state stored);
  • no key for its id: the body is present but uncheckable. It is never read back and never counts as a match, but the file still verifies;
  • a different key with the same id: the body does not match its name, exactly as if the file had been changed. mlld tape verify reports the file as not verifying, and a call does not go on in it (restartReason says the body does not match its keyed hash).

A key only lets mlld check a body; it never makes one trusted. A script reads keyed bodies through .select when it holds the keys: a host passes them as bodyKeys on a noEffects call (see config-live-stdio), and a script run any other way reads them as uncheckable. The live method tape:open takes the same setting as bodies (see config-live-stdio).

Signer keys you trust. A host that runs the hooks on a machine whose project lists no signers (a server that checks sessions sealed elsewhere) can give the keys it trusts with --trusted-signers <file>, on every verb and on mlld check. <file> holds an object of principal to signer entry, in the shape the config's signers take (key, and optionally valid_after, valid_before and hostKey; labels and classes are refused):

{ "laptop": { "key": "ssh-ed25519 AAAA..." } }

The keys only check the session this call reads. When the config names any signers, they are the whole set and these keys are ignored (signersFrom: "config"); they never add to the config's set. They never seal a tape, and they never count for anything a script reads or decides. An empty object is no keys. With --stdin, trustedSigners as tape:open takes it may be given instead of the flag. mlld why takes the same flag for a host session.

A session you keep yourself. A host that keeps its sessions out of .llm/tapes (encrypted storage, database rows) hands each call the session's bytes with --store <file> and gets back what the call wrote. <file> holds the shape the live tape:open takes as store:

{ "files": { "<run id>": "<the file's bytes, base64>" },
  "payloads": { "<payload name>": "<its bytes, base64>" } }

Start with {}. The --json result then carries stored in the same shape, holding only what this call wrote: the lines it appended to each file (a new file's from the start) and the payloads it stored. Add them to what you keep and hand the whole back on the next call. A refused call's error carries stored too, since a refused deferred check writes a fresh question. A call that writes needs --json, so what it wrote is not lost; verify writes nothing. Nothing about the session is written under .llm/tapes. The bytes are checked as a file's are: a changed line or payload refuses, and a missing payload reads as pruned. The session's lock is yours: mlld cannot see another call holding the same bytes, so run one call of a session at a time. With --stdin, store may be given instead of the flag. --from-head, --write-head, --store-bodies, --body-keys and --trusted-signers work over a store as over files, so a host that keeps a session in pieces passes only the lines after the head in files. mlld why --store <file> reads a session from the same file.

A tape from another format. Every tape names its format on its first line (config_version in session_start). A tape mlld wrote in a format this mlld does not read (a later mlld's, say) is refused with TAPE_VERSION_UNKNOWN before its chain or seal is checked, so it is reported as a newer format rather than as damaged:

TAPE_VERSION_UNKNOWN: this tape is format 2; this reader supports up to 1 (mlld 2.2.0)

A session whose newest file is in such a format goes on in a new file, and the old file is left as it is: mlld never rewrites a tape into a newer format.

A sealed tape's certificate (its cert event, where your signing key certifies the short-lived key that seals the tape) names the version of its signed statement too. One whose version this mlld does not read is refused with TAPE_CERT_VERSION_UNKNOWN, naming the certificate's event.

Every tape written by a released 2.x mlld verifies under every later 2.x; a new major version may drop old formats, with a tool to migrate them. This holds from the first released mlld on: tapes written by unreleased builds are not covered.

Recording grants nothing: a recorded user turn counts as the user's words only under the config policy's host self-attestation row and a verified seal, and a recorded tool call or result counts for nothing (see tapes).