Introducing a new way to review your PRs.

Read the announcement

sheeki03 / tirith

Terminal security for developers and AI agents. Intercepts homograph URLs, pipe-to-shell, ANSI injection, obfuscated payloads, data exfiltration, and malicious AI skills/configs before they execute.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / execution-provenance-and-trust

Execution provenance and trust

Tirith links a security decision to the command, session state, execution boundary, and evidence that support it. It uses this link to decide when an action may proceed, to keep uncertain observations separate from confirmed history, and to leave a reviewable record without storing raw secrets or command text.

This page is a child of Execution isolation and provenance. The Cross-platform execution capsules page explains the containment layer that can run beside these trust controls.

Execution state

Execution state is the session record that connects a prepared decision to a real execution event. It is kept separate from the normal command analysis so a preview cannot become proof that a command ran.

Execution lifecycle

The lifecycle moves from a short-lived decision draft to a locked, durable record. A trusted boundary supplies the final evidence rather than the caller choosing its own evidence label.

flowchart LR
    A[Analyze command] --> B[Prepare decision draft]
    B --> C[Resolve approval and warning acknowledgement]
    C --> D[Recheck session generation under lock]
    D --> E[Launch or forward]
    E --> F{Execution evidence}
    F -->|Kernel exec stop| G[Confirmed history]
    F -->|Exact gateway success| G
    F -->|Shell boundary or uncertain forward| H[Unresolved history]
    H -->|Later matching proof| G
    H -->|No matching proof| I[Conservative future correlation]

The draft contains the command digest, a bounded redacted preview, the caller and shell context, the effective action, and hashes for the policy and verdict basis. Before launch, the execution gate checks that the draft is still live and that the session generation and decision inputs still match. A changed command, policy basis, session state, or approval proof stops the action.

Tirith treats a kernel execution stop and an exact successful gateway response as confirmed evidence. A shell observation, a forwarded gateway request with no verified result, or an unresolved kernel stop remains unresolved. Unresolved history can tighten a later decision, but it cannot be described as proof that the target ran.

References: crates/…/execution_state.rs• L56-86 crates/…/execution_state.rs• L569-600 crates/…/execution_state.rs• L1566-1680 crates/…/execution_state.rs• L1770-1812

Session history

The strict execution ledger is the durable source for security-bearing session history. It keeps confirmed and unresolved records in separate bounded collections and assigns monotonic generations, ledger sequences, and event sequences so replay and ordering checks have stable identities.

The ledger stores digests and redacted summaries instead of raw command text, full policy objects, origin details, or unredacted findings. It also carries typed events used for cross-command correlation. Legacy session data is imported as unresolved history, which preserves safety without granting old best-effort observations the authority of execution proof.

History is retained for the policy windows that can affect later escalation. Expired detail can be removed, but live security evidence is not evicted merely to make room for a new record. A full ledger therefore refuses new security-bearing history instead of weakening correlation.

References: crates/…/execution_state.rs• L378-465 crates/…/execution_state.rs• L2285-2500 crates/…/execution_state.rs• L3084-3191

Event provenance

Typed events describe broad actions such as process execution, file writes, network activity, secret writes, package installs, and force pushes. Their provenance field says whether the event is confirmed, unresolved, or still provisional.

During analysis, the current command contributes provisional events only to the in-memory correlation view. Promotion gives those events confirmed or unresolved status together with the execution record. Correlation keeps enforcement conservative when an input is unresolved, while its human description states that the source was not proven to execute.

References: crates/…/event_buffer.rs• L23-107 crates/…/event_buffer.rs• L204-245 crates/…/event_buffer.rs• L364-412

Command and executable provenance

Command provenance explains what Tirith intended to run. Executable provenance explains which file a command name selected and what can be learned about that file. These are related evidence types, but neither one replaces an execution-boundary proof.

Command identity

The command identity is a SHA-256 digest of the exact command text. The durable record also keeps a short redacted preview for review. The draft binds this identity to the session, shell, caller, agent origin when present, bypass facts, and the policy and verdict basis.

Approval is bound to the same security meaning that the user saw. A fresh replay that changes the warning set must obtain a new acknowledgement. Approval and warning acknowledgement remain separate requirements, so one interaction cannot silently satisfy the other.

References: crates/…/execution_state.rs• L183-240 crates/…/execution_state.rs• L763-814 crates/…/execution_state.rs• L932-975

Executable evidence

The cold executable-provenance path inspects the resolved file without running the analysis engine hot path. crates/…/exec_provenance.rs records file existence, permissions, ownership, age, file type, signing status, and a known package-manager root when those facts are available.

The command surface exposes this evidence through tirith exec check <name> and tirith exec provenance <path>. A PATH check reports the first resolved hit and other hits. It can also flag a non-system file that shadows a system command. The checks report findings rather than claiming that the file was executed.

The probes use trusted system helpers with bounded runtime and output. A missing helper, timeout, or unsupported signing baseline becomes neutral or unknown evidence instead of a false finding. The evidence is still collected at analysis time, so a later file replacement can make the inspected file differ from the file that would be launched unless the caller also uses the trusted executable controls.

The main signals have different meanings:

SignalTrust concernTypical result
Recent modificationA payload may have been dropped just before useHigh finding
World-writable fileAnother local process may replace the executableHigh finding
Invalid code signatureThe publisher cannot be established on a platform with a signing baselineMedium finding
PATH shadowingName resolution selects a non-system copyMedium finding
Missing probe or unsupported signing baselineTirith cannot prove the factNeutral or unknown result

References: crates/…/exec_provenance.rs• L1-18 crates/…/exec_provenance.rs• L36-109 crates/…/exec_provenance.rs• L283-383 crates/…/exec.rs• L225-312

Hot-path guard

The optional executable guard adds only cheap leader-path checks to command execution. When enabled, it warns when the resolved leader is under a transient directory, inside the repository, or in a user-writable PATH directory before a system directory. Full metadata and signature probes remain on the explicit cold inspection path.

The guard is off by default. Its purpose is to surface common path risks during normal execution without making every command pay for the full provenance inspection.

References: crates/…/exec.rs• L16-20 crates/…/exec.rs• L64-91

npm package provenance

npm package provenance records what an installed project can prove about its registry packages. It joins the project lockfile, the installed node_modules tree, and npm's own signature or attestation answer so that a positive result covers the same package location and pinned bytes.

The audit command is selected only for an npm version with a known command and known output shape. The current supported contract covers npm 11 and requests signature results with attestation bundles. Unknown versions, unsafe audit settings, unsupported dependency sources, missing lockfile or install-tree coverage, and incomplete walks produce a partial result rather than an optimistic clean result.

Reconciliation gives each package an explicit status. A failed signature, attestation, or subject-digest comparison is a mismatch. Missing signatures, un-audited packages, non-registry sources, and unaccounted installed packages are coverage gaps. A verified attestation is evidence about the publish process and is not a claim that the package is safe to run. When a lockfile integrity value and an attested subject digest are comparable, a disagreement means the attestation covers different bytes.

The npm provenance receipt binds the answer to the lockfile digest, package coverage, npm and interpreter identities, exact audit contract, and non-secret registry and transport settings. It is content-addressed and can carry a detached Ed25519 signature, but it is not anchored in the audit hash chain. A clean receipt therefore means that npm's stated registry check passed for the accounted packages; it does not mean that the package code is benign or that Tirith inspected the tarball bytes.

References: crates/…/mod.rs• L25-42 crates/…/npm.rs• L122-178 crates/…/npm.rs• L438-556 crates/…/npm.rs• L1692-1867 crates/…/npm.rs• L2064-2536

Provenance graphs

A provenance graph is a read model that shows how package files, installed ownership, and MCP configuration relate. It composes signals already produced by artifact inspection, ownership analysis, and the MCP lock surface; it does not add a new detection rule or make a policy decision.

Graph relationships

The graph uses stable node identities and directed edges. This lets a reviewer follow a loader to a payload, identify who owns an installed path, and see how an MCP server exposes tools or reaches its endpoint.

RelationshipMeaning
ExecutionA loader or trigger can cause a payload or runtime to run
OwnsA distribution carries or owns an installed path
DuplicateOwnerMore than one distribution claims the same path
ExposesToolAn MCP server declares a tool
ServedByAn MCP server is reached through a URL or local stdio command

The graph keeps execution relationships distinct from ownership and MCP wiring. A graph can show a possible execution path without saying that the path was taken.

References: crates/…/graph.rs• L1-33 crates/…/graph.rs• L47-145 crates/…/graph.rs• L206-237

Graph views

tirith pkg graph builds a graph from one or more wheel artifacts. Installed-environment graph views discover distributions and build a duplicate-aware ownership index. When run inside a repository, both views can add its MCP server and tool surface.

The graph is available as a short human view, stable JSON, or Graphviz DOT. Nodes and edges are de-duplicated and sorted, so the same inputs produce the same machine view. Coverage gaps produce an incomplete result instead of a clean graph claim.

References: crates/…/provenance.rs• L1-40 crates/…/provenance.rs• L88-123 crates/…/provenance.rs• L262-355 crates/…/graph.rs• L381-480

Trust decisions

A trust decision is Tirith's answer to whether a requested action has enough matching authority and evidence to continue. The decision combines the policy result with interaction proofs, session history, executable identity, and the boundary that will carry out the action.

Decision inputs

Trust is strongest when the decision, selected executable, and observed execution all refer to the same identities. The main checks are:

  • The command digest matches the prepared command.
  • The policy and verdict basis match the prepared decision.
  • Approval and warning acknowledgement match the exact requirements.
  • The session generation has not changed.
  • The execution evidence belongs to the same execution identity.
  • The executable still has the identity and provenance that were approved.

A block action cannot acquire an execution gate unless an explicitly valid bypass was frozen and honored. A bypass is not inferred from a preview or from a later caller claim.

References: crates/…/execution_state.rs• L894-929 crates/…/execution_state.rs• L1815-1861 crates/…/execution_state.rs• L2803-2834

Evidence upgrades

Some boundaries first produce an unresolved record because the final result is not yet known. A gateway forward can later become confirmed only through a complete successful response bound to its random proxy identity. A stopped kernel target can become confirmed when the trusted continuation proves the target resumed.

The upgrade keeps the same execution identity and appends an allowed evidence transition. Changed evidence, expired windows, missing history, or a different transition channel causes rejection. An exact retry can be idempotent; a changed retry cannot create a second interpretation of the same action.

References: crates/…/execution_state.rs• L1196-1266 crates/…/execution_state.rs• L1355-1506 crates/…/execution_state.rs• L2940-3031

Execution receipts

An execution receipt is a short-lived proof token that carries a prepared decision across a shell or another execution boundary. It binds the command and decision to a session context, then records whether that boundary was consumed without letting a bearer token alone authorize an unrelated command.

Shell receipts

Shell receipts support trusted interactive boundaries for Zsh, Fish, and Bash. They bind the shell channel, live shell process identity, session, current working directory digest, Tirith executable identity, command digest, and decision hashes. PowerShell history is not accepted as strict execution proof because mutable history cannot prove that a command ran.

The receipt moves through a one-way state model:

StateMeaning
PreparedThe receipt exists but has no resolved interaction
ArmedRequired approval and warning acknowledgement are recorded
ConsumingThe exact transition is being checked and committed
CommittedThe shell boundary transition is durably recorded
ConflictA replay or identity mismatch ended the receipt safely
DiscardedThe unused receipt was retired

The shell hook receives a one-time bearer only after its process and capability record is durably bound. Each use checks the live shell, channel, session, executable, and sealed receipt data. Recovery can reconcile a lost acknowledgement, but it cannot authorize a replay.

References: crates/…/shell_receipt.rs• L26-92 crates/…/shell_receipt.rs• L167-230 crates/…/shell_receipt.rs• L1472-1682 crates/…/shell_receipt.rs• L2977-3187

Artifact receipts

Package-firewall installs use a separate versioned artifact receipt to attest to the install result. It records redacted policy and tool identity, threat database sequence, capsule coverage, artifact digests, post-install integrity, and a compact verdict summary.

An enforcing install has two publication phases. A signed PrivateVerified receipt proves that the private target was checked and remains rollback-safe. A later signed Committed receipt links to that private receipt and proves that the exact target crossed the no-replace publication boundary. The receipt id is a content hash and the audit chain anchors that hash, so edits or deletion can be detected.

Mandatory install receipts fail closed when signing or audit anchoring is unavailable, including when logging is disabled. A non-mandatory record may remain saved without an anchor, but it reports that degraded state instead of claiming full audit protection. Receipts never serve as a substitute for live identity checks.

References: crates/…/receipt.rs• L344-462 crates/…/receipt.rs• L464-646 crates/…/receipt.rs• L716-930 crates/…/receipt.rs• L933-1021

Checkpoints

A checkpoint is a recovery record for file state. It protects work before a destructive command or gives an install a private target that can be checked before publication. It is a recovery control, not proof that a command executed.

File checkpoints

The checkpoint service can capture selected files and directories before destructive shapes such as recursive removal or a hard Git reset. It stores content by SHA-256 and maps the original paths through a manifest. A capture records its trigger, size, file count, and whether any requested data was omitted.

The store is private to the user. Restore anchors relative paths to the capture-time root and refuses unsafe checkpoint or destination links. It verifies the checkpoint identity, manifest paths, and blob hashes before copying. It reports restored, missing, corrupt, and failed entries separately. An incomplete or partial restore returns a non-success result so automation cannot mistake recovery of only part of the requested state for a complete restore.

References: crates/…/checkpoint.rs• L40-66 crates/…/checkpoint.rs• L140-227 crates/…/checkpoint.rs• L464-585 crates/…/checkpoint.rs• L949-1188 crates/…/checkpoint.rs• L69-151

Install checkpoints

An enforcing package install uses an environment checkpoint to keep the new environment private while the install and post-install checks run. The public target stays absent until the exact checked target is published with a no-replace operation.

The checkpoint has a private, publication-unconfirmed, committed, rolled-back, or retained state. Before publication, a failed check can roll back the private target. After the publication boundary is crossed, rollback is forbidden because the public namespace may now point to those bytes. If identity or durability cannot be confirmed, recovery state is retained for manual review rather than deleted.

References: crates/…/pkg_install.rs• L253-310 crates/…/pkg_install.rs• L442-616 crates/…/pkg_install.rs• L620-771

Trusted-child controls

A trusted child is a helper process that Tirith selects, verifies, and supervises for a security-sensitive task. The controls prevent an attacker-controlled PATH entry, mutable executable, inherited environment, or runaway child from changing the meaning of the task.

Executable selection

Tirith resolves a helper to an absolute identity before it runs. The first executable PATH hit remains authoritative. If that hit is denied or lacks the required provenance, Tirith fails closed instead of silently selecting a later file with different behavior.

The trust bar depends on the role. General helpers may use explicit configured tools. Forced interpreters and pre-verdict system helpers require administrator-managed system provenance on Unix, including trusted ownership and ACL checks across the selected path. Windows accepts suitable Authenticode or protected-install evidence, but same-user-only PATH ownership is not enough for a security-sensitive helper. The selected identity is checked again immediately before spawn.

On Linux, callers that must survive a delay such as a network request can bind the helper to a private content snapshot. This makes the later launch use the bytes that were checked rather than reopening a path that may have changed.

References: crates/…/trusted_child.rs• L143-277 crates/…/trusted_child.rs• L431-605 crates/…/trusted_child.rs• L619-699 crates/…/trusted_child.rs• L873-941 crates/…/trusted_child.rs• L1301-1514

Child supervision

Trusted children receive explicit arguments and environment values. Ambient PATH entries that are relative, denied, or writable by an untrusted principal are removed from the child environment. The child has bounded runtime and output limits, and callers can pass only explicitly selected Linux file descriptors as extra capabilities.

On Unix the supervisor owns an anchored process group and checks that it retains direct-child ownership before it signals that group. On Windows it uses a kill-on-close job boundary. Timeout, output flood, spawn failure, and cleanup failure are reported as distinct outcomes. The contract does not cover a Unix descendant that deliberately creates a new session, so callers must not treat process-group cleanup as universal containment.

References: crates/…/trusted_child.rs• L1-22 crates/…/trusted_child.rs• L1730-1775 crates/…/trusted_child.rs• L1860-1972 crates/…/trusted_child.rs• L2011-2149 crates/…/trusted_child.rs• L2655-2724 crates/…/trusted_child.rs• L2854-3077

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep every new execution evidence source mapped to a permitted confirmed or unresolved transition. Do not let a caller provide an arbitrary evidence grade.
  • Keep the command, policy, verdict, approval, shell context, and bypass facts in the same identity comparison. A new security input that is not hashed can drift between preview and launch.
  • Keep unresolved event records out of confirmed escalation cooldowns and out of prose that claims execution.
  • Keep receipt state transitions aligned with the session ledger. Recovery must reconcile an existing transition and must not authorize a replay.
  • Keep private and committed artifact receipts linked to the same exact install content. Do not add a publication claim that bypasses the signed private predecessor.
  • Keep checkpoint restore anchored to the capture root and verified blob identity. A change to path handling can redirect restored bytes outside the captured tree.
  • Keep trusted-child provenance rules aligned with each caller role. A path accepted for a normal helper may not be safe for a forced interpreter or a pre-verdict helper.
  • Keep graph node identities delimiter-safe and graph rendering descriptive. A graph change must not merge two security surfaces or turn a read model into an auto-allow.
  • Keep npm audit contracts closed and fixture-backed. A new npm version or output shape must not reach the audit command until its exact command and result schema are covered.
  • Keep npm positive results bound to the lockfile location, registry identity, and pinned integrity when comparable. Do not treat omitted audit buckets, unsupported sources, or incomplete inventory as clean coverage.
  • Keep receipt redaction and content hashing aligned. New receipt fields must not carry secrets or paths and must be inside the content identity before a signature or audit anchor is trusted.
  • Keep Unix ACL checks and child reaper assumptions part of the trusted-child contract. A new platform path or supervisor change must fail closed when mutation authority or direct-child ownership cannot be proven.

Important failure modes

TriggerConsequenceGuard
The session generation changes after preparationThe old decision cannot acquire the execution gateLock-time generation check and full decision recheck
A shell receipt is used by another shell, session, channel, or Tirith binaryThe receipt is rejected instead of authorizing a different boundaryLive process identity, session binding, channel binding, and executable binding
A gateway response has the wrong id or contains an error or method responseThe forward stays unresolved and cannot be promotedComplete JSON-RPC success validation bound to the random proxy id
A PATH helper is replaced or retargeted after selectionThe security-sensitive spawn is refusedImmediate executable identity revalidation and optional Linux content binding
A trusted path carries an unrecognized write-capable ACL entryThe helper is refused even when owner and mode bits look safePlatform ACL validation across the executable and its ancestor chain
An npm version has no closed audit contractNo audit command runs and the project remains partialVersion selection from the fixture-backed contract table
An installed package or npm audit entry cannot be matched to the lockfileThe result cannot claim complete coverage; a reported invalid entry remains negative evidenceLocation-first reconciliation with explicit unaccounted and unmatched records
An npm attestation subject digest differs from the lockfile integrityThe package is reported as a mismatch because the evidence covers different bytesCompare the attested digest with the lockfile SRI before accepting positive status
A checkpoint blob hash differs from its manifestThe file is marked corrupt and is not restoredHash and copy from the same verified file handle
An install fails after public publication beginsAutomatic rollback could delete or alter the approved public targetPublication state changes before later fallible work and retains recovery state
A strict receipt needs a signed audit anchor but signing is unavailable or logging is offThe required install phase does not succeedFail closed before accepting the phase as committed
A supervised child exceeds its time or output limitThe child and its supervised descendants are terminated when cleanup can be proven; otherwise the outcome is a cleanup failureBounded capture, process-group or Job supervision, and distinct cleanup results

Key files

FileWhy to read it
crates/…/execution_state.rsDefines the proof-carrying decision draft, session ledger, evidence grades, gate, promotion rules, and strict state checks.
crates/…/event_buffer.rsDefines event provenance and the conservative cross-command correlation view.
crates/…/exec_provenance.rsDefines cold executable evidence and findings for file, signature, ownership, age, and PATH shadowing risks.
crates/…/shell_receipt.rsDefines shell capability registration, receipt states, interaction binding, recovery, and one-time consumption.
crates/…/graph.rsDefines the descriptive graph model and its execution, ownership, duplicate-owner, and MCP relationships.
crates/…/npm.rsDefines npm audit coverage, lockfile and install-tree reconciliation, attestation binding, outcomes, and the detached provenance receipt.
crates/…/receipt.rsDefines content-addressed artifact receipts and the private-to-committed publication proof.
crates/…/checkpoint.rsDefines private file snapshots, capture-root restore, integrity checks, runtime snapshots, and checkpoint storage rules.
crates/…/trusted_child.rsDefines executable selection, ACL and provenance gates, child environment shaping, capability passing, and bounded supervision.
crates/…/pkg_install.rsShows how an enforcing install uses a private target checkpoint before verified publication.
crates/…/provenance.rsShows how CLI graph views compose artifact, ownership, and MCP inputs.