Skip to main content

sensorium

Record one run of your program, then let a coding agent ask what actually happened: call trees, exceptions, and where a value came from, answered from the trace or refused.

A failing checkout, three queries, no edits. item_weight returned 1800 grams and shipping_cost took that number as weight_kg.

$ sensorium run -- pytest examples/test_shipping.py -q
F                                                                        [100%]
E       AssertionError: assert 5569.0 == 74.5
run: 20261116-104837-c926b7

$ sensorium exceptions last
raised (1):
  e30 RAISE   test_order_total_for_a_mug_and_kettle raise AssertionError("assert 5569.0 == 74.5\n +  where 5569.0 = order_total([{'name': 'mug', 'price': 12.0, 'grams': 400}, {'name': 'kettle', 'price': 49.0, 'grams': 1800}])") L10
    propagated (handler not in traced code)

$ sensorium flow last --value 1800
  e22 CALL    item_weight(item=dict[3]={'name': 'kettle', 'price': 49.0, 'grams': 1800})   [arg item.grams]
  e23 RETURN  item_weight -> 1800   [return]
  e24 CALL    shipping_cost(weight_kg=1800)   [arg weight_kg]
sightings: 6 event(s), 6 capture(s)

$ sensorium refocus last --focus examples.shipping:shipping_cost --compact
refocus verdict: MATCH -- every recorded thread produced the identical CALL/RETURN/RAISE/HANDLED sequence

From a clone, with sensorium and pytest on PATH:

sensorium run -- pytest examples/test_shipping.py -q

Event ids move when the program does; last is the newest trace. The bug lives in examples/shipping.py.

What Sensorium is

Sensorium records one run (every call, return, and exception, with captured values) into a SQLite trace, and answers debugging questions from that trace in plain text. Four recorders write trace format 4. One command line, sensorium, reads all four.

  • Python: sensorium run -- <command> uses PEP 669 (sys.monitoring). Python 3.12+, no runtime dependencies. A Python child (subprocess, multiprocessing, pytest-xdist) is recorded into that same run. --no-children or SENSORIUM_NO_CHILDREN=1 records the parent only. A non-Python child is counted and not traced.
  • Rust: cargo sensorium test or cargo sensorium run. Stable rustc, Linux. rust/README.md.
  • TypeScript: sensorium ts run [--focus <spec>]… -- vitest run … or -- node --test …. Node 24, vitest 4.1. typescript/README.md.
  • C: sensorium c run -- <cmd> for a Linux x86-64 debug build (gcc or clang, -O0 or -Og). c/README.md.

A query refuses by name when a recorder lacks a capability.

Two commitments run through all of it. The instrument never answers from data it does not have: truncated captures are marked, sites a predicate could not be evaluated at are counted, a recording that died is labelled, and a rerun that was a different execution says so. Nothing here guesses. Every answer is a deterministic function of the recorded trace, and where the trace cannot settle a question the output says so instead of inferring. refocus is the one command that executes anything: it re-runs the program and says whether what came back was the same execution. The per-command limits are docs/claims.md.

Answers from the trace, or refuses

Sensorium never guesses why a test failed. A well formed question whose recording cannot settle it is refused by name.

  • REFUSED. Printed REFUSED: ... when a capability is missing, and refocus verdict: REFUSED -- <run> was recorded and is queryable, but it could NOT be verified against <run>: treat it as a separate, UNVERIFIED execution when a rerun could not be checked. diff prints verdict: REFUSED -- cannot issue a MATCH/DIVERGED verdict. Re-record.
  • NOTHING WAS CHECKED. watch prints verdict: NOTHING WAS CHECKED -- the predicate could not be evaluated at any of the N recorded site(s) when no site had the names the predicate needs. The next line is 'hits: 0' here means 'could not evaluate', NOT 'the invariant held'.
  • DIVERGED. Two runs took different paths. diff prints verdict: DIVERGED at causal step N. refocus prints refocus verdict: DIVERGED -- .... The new trace is queryable and is a different execution.

Exit 3 means change the recording. Exit 2 means fix the call. Details: docs/claims.md.

Quickstart (Python 3.12+)

pip install sensorium-trace pytest
sensorium run -- pytest tests/test_something.py
sensorium exceptions last

uv tool install sensorium-trace puts the same sensorium command on PATH. Run these from your project root, in an environment that can import your code.

Connect your agent (MCP)

Use the absolute path to your project venv's sensorium. --allow-run lets the agent record and rerun; leave it off for read-only.

Cursor, .cursor/mcp.json, and Claude Desktop, claude_desktop_config.json:

{
  "mcpServers": {
    "sensorium": {
      "command": "/abs/path/to/project/.venv/bin/sensorium",
      "args": ["mcp", "--allow-run"]
    }
  }
}

VS Code, .vscode/mcp.json:

{
  "servers": {
    "sensorium": {
      "type": "stdio",
      "command": "${workspaceFolder}/.venv/bin/sensorium",
      "args": ["mcp", "--allow-run"]
    }
  }
}

Claude Code:

claude mcp add sensorium -- /abs/path/to/project/.venv/bin/sensorium mcp --allow-run

sensorium mcp serves the same store on stdio. Every query except redact is a tool. record, refocus, and record_c exist only with --allow-run. Tools, the result header, the cap, and the audit file: docs/mcp.md.

How this differs from live debuggers and LLM tracing

  • Live debuggers over MCP (DAP-based servers) make the agent step through a paused process, one breakpoint at a time. Sensorium records the whole run once, and the agent queries it afterward, as often as it likes, with stable event ids.
  • LLM tracing (LangSmith, Langfuse and similar) records the model's prompts and tool calls. Sensorium records the program under test: its calls, returns, exceptions and values.
  • Not sensorium-mcp. andriyshevchenko/sensorium-mcp is an unrelated Telegram and memory agent that shares the name.

Install

Python 3.12+. The CLI command is sensorium. The name sensorium on PyPI and npm is an unrelated project; these packages publish as sensorium-trace.

pip install sensorium-trace
uv tool install sensorium-trace

Rust recorder (Linux, rustc 1.96+):

cargo install cargo-sensorium

TypeScript recorder (Node 24):

npm install sensorium-trace

Published on PyPI, crates.io and npm; Linux binaries for cargo-sensorium are on GitHub Releases. The import and the CLI stay sensorium. The npm package is the recorder library; traces still report recorder: sensorium-ts.

From git:

uv venv .venv && uv pip install -p .venv/bin/python "sensorium-trace @ git+https://github.com/bricelancasterwcp-sudo/sensorium"

Dev checkout: uv venv .venv && uv pip install -p .venv/bin/python -e ".[dev]". Details: docs/install.md.

The recorder is sys.monitoring and nothing else, so on 3.11 it refuses to start. Witnessing a multiprocessing spawn needs the _posixsubprocess.fork_exec audit event, which arrived in 3.14. Below that, such a spawn is unwitnessed, and refocus says so by withholding the "no child process witnessed" line (docs/claims.md).

Commands

sensorium run -- pytest tests/test_fog.py
sensorium runs
sensorium info last
sensorium tree last --depth 3
sensorium frame last --fn compute
sensorium grep last compute --kind RETURN
sensorium exceptions last
sensorium failures last
sensorium flow last --value 1800
sensorium flow last --object build_key:record
sensorium diff RUN_A RUN_B
sensorium refocus last --focus fog:compute
sensorium redact --all --dry-run
sensorium mcp --allow-run

Per-line state is opt-in: sensorium run --focus fog:compute -- ..., then sensorium watch last --at fog:compute --expr '...'. Asked without that --focus, watch reports NOTHING WAS CHECKED and prints the re-record command. It does not report zero hits.

Traces land in ~/.sensorium/traces (or $SENSORIUM_DIR/traces), one SQLite file per run. Rust, TypeScript, and C write to the same directory, so one runs lists all four. A run reference is a full id, a unique prefix, or last. Events are eN and frames are fN, and those ids stay stable, so an answer from one command is an argument to the next. --fn matches a qualname exactly first, then as a substring, and refuses when more than one name matches. Asyncio frames, --window, and flow --object: docs/use.md.

Rust, TypeScript, and C

  • Rust. rust/ ships sensorium-rt 0.7.3, sensorium-transform 0.5.2, and cargo-sensorium 0.8.4. cargo install cargo-sensorium, then cargo sensorium test or cargo sensorium run from a workspace. Linux, stable rustc. Panics show up in failures. rust/README.md. What it does not see: rust/HONESTY.md.
  • TypeScript. typescript/ ships sensorium-ts 0.6.2. A trace reports recorder: sensorium-ts. Node 24. From a checkout, npm ci --prefix typescript, then sensorium ts run -- vitest run … or sensorium ts run -- node --test …. A shell-free npm test that runs vitest or node --test is expanded. jest is refused by name (no jest transformer). Inline vitest project objects are instrumented; a project named by a string or glob is refused. for await inside a function is recorded; top-level await is not. typescript/README.md.
  • C. sensorium c run -- <cmd> records a Linux x86-64 debug build (-O0 or -Og, gcc or clang). Crashes are what exceptions reads. c/README.md.

Recording follows code under the working directory the run started in, so sensorium run -- pytest ... traces your tests and your code, and not pytest's. --focus module:qualname adds line-level capture for the named code. --window QUALNAME limits that capture to what runs inside one function. The fog.py examples in docs/use.md were run as typed.

Exit statuses

The exit status is the caller's next action, not a health code:

exit meaning examples
0 the question was answered affirmatively. The trace says yes grep found a match; refocus MATCH; watch SATISFIED
1 the question was answered negatively. The trace says no, or none grep matches: 0; exceptions no exceptions recorded; refocus DIVERGED
2 the call is wrong, edit the command and ask again an ambiguous --fn; --nth out of range; a run reference that resolves to nothing; refocus refusing before any rerun was attempted
3 the trace cannot settle it, change the recording and re-record watch NOTHING WAS CHECKED; refocus REFUSED after a rerun; exceptions' uncaught-without-RAISE arm; exceptions on a Rust trace whose recorder predates err flow (recorder sensorium-rt 0.2.0 declares it does not produce (capabilities.err_flow: false))

run exits with the target's own status. It never applies this table to itself.

Every invocation is appended to <trace root>/invocations.jsonl (default ~/.sensorium/invocations.jsonl, or under $SENSORIUM_DIR) as one JSON line with utc, argv, exit and error (the exception class name or null) and nothing else: never the environment, never the working directory. Set SENSORIUM_NO_INVOCATION_LOG to any non-empty value other than 0 to turn it off for one process, =0 leaves logging on. The same branch is docs/agent.md.

For agents

Install, record one run, query it, serve it over MCP: ten steps in docs/agent.md. After install, prove the path with .venv/bin/python -m pytest tests/test_agent_smoke.py -q.

Agent skill

skills/sensorium/SKILL.md is an Agent Skills file (name: sensorium). It tells an agent, when a test fails or output is wrong in Python, Rust, TypeScript, or C, to record one run and query the trace on the CLI or over MCP.

sensorium skill show
sensorium skill install
sensorium skill install --user --target claude

install copies that file. If a destination already exists, nothing is written unless --force is passed. With no --target it writes both .claude/skills/sensorium/SKILL.md (Claude Code: .claude/skills/ in the project, ~/.claude/skills/ for --user) and .agents/skills/sensorium/SKILL.md (Codex reads .agents/skills from the working directory up to the repo root, and ~/.agents/skills for a user skill). --target cursor, --target codex, and --target agents write the .agents/skills path. --target claude writes only the Claude Code path. A path argument is the skill directory itself. Cursor install guides also name .cursor/skills/<name>/, and older Codex pages still say .codex/skills/; pass that directory as a path to use it. The wheel ships the same file at sensorium/_skill/SKILL.md.

What the answers claim

Sensorium reports; the agent reading it reasons. Nothing in an answer is inferred from data the trace does not hold.

  • diff compares the shape of two runs, (file, qualname, kind), not their values. A pure move reads DIVERGED unless --ignore-moves can pair the name uniquely.
  • refocus re-runs, then issues MATCH, DIVERGED, or REFUSED. The licence lists only the checks that ran. A check that could not run withholds the licence. Exit 2 means nothing was re-run.
  • tree derives parentage from the caller frame, not from "the last frame on this thread".
  • exceptions claims SWALLOWED only when the recording establishes it. Anything short of that is ambiguous, with the reason printed.
  • watch never reads zero hits as "the invariant held". A site it could not evaluate is counted.
  • flow is lineage over captured values, not static dataflow.
  • info labels an INCOMPLETE recording and does not print a 0 as proof that nothing happened.

The full wording is docs/claims.md. exceptions, watch, flow, and Rust refocus in detail are docs/query.md.

What a trace holds, and what it does not see

A trace holds the process environment (minus what rule v1 withheld), stdout and stderr, the command line, source digests, and captured values. It does not see children by an unlisted mechanism, non-Python threads, files the program read, code outside the run root, the clock, or the network. Treat a trace as a core dump. docs/visibility.md. Redaction: docs/redaction.md.

Overhead

Recording overhead and read-back cost are docs/overhead.md. Measured with python corpus/run_corpus.py --bench. The headline: 2.9× on the corpus's typical workloads, up to 194× on the call-dense one under --focus. Record failing tests, never benchmarks.

Corpus

python corpus/run_corpus.py                          # verify against seeded bugs
python corpus/run_corpus.py --show                   # print the questions and commands
python corpus/run_corpus.py --bench                  # report recording overhead
python corpus/run_corpus.py --require-driver         # a skipped Rust or TypeScript case is exit 1
python corpus/run_corpus.py --via mcp --compare-cli  # every tool question through the MCP server, diffed against the CLI

Small programs with planted bugs, and questions registered before any output was looked at. 115 cases and 253 questions. A case whose recorder is not built is reported skipped by name. --bench reports; it never gates. Case by case: docs/corpus.md.

Not yet

What each slice deferred, and the ruling each deferral is waiting on, is docs/CARRIED-DEBT.md.

License

MIT, see LICENSE. Copyright © 2026 Brice Lancaster.

Versions after the Proprietary interlude are again under MIT (matching releases through 0.14.0).

Also

Metadata

Release files for sensorium-trace 0.18.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sensorium-trace 0.18.4
File Size Uploaded Provenance Actions
sensorium_trace-0.18.4.tar.gz 6.2 MB With provenance Details for sensorium_trace-0.18.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sensorium-trace 0.18.4
File Interpreter ABI Platform Actions
sensorium_trace-0.18.4-py3-none-any.whl Python 3 none any Details for sensorium_trace-0.18.4-py3-none-any.whl

Total release size: 6.9 MB

Release files / sensorium_trace-0.18.4.tar.gz

Download URL sensorium_trace-0.18.4.tar.gz
Size 6.2 MB
Tags Source
SHA-256 checksum
How to use checksums
f23cad4be8a920b99417226a43e00867e02e4352d370aa7481a5dc7d0528f079
BLAKE2b-256 checksum
How to use checksums
361061f2f3ae151e78abe6b9e069bafe9aab487e352919c6892a5b466a8da96c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / sensorium_trace-0.18.4-py3-none-any.whl

Download URL sensorium_trace-0.18.4-py3-none-any.whl
Size 646.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41dea6525e2c069b93b2cef583f8c957a4db63c0a5e5a21cc6f8dc506c7c43b6
BLAKE2b-256 checksum
How to use checksums
b3f9692fdb2c0b6bf2c2c6160843590b67d61fa8b2ec94c50cc0f30601c070c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for sensorium-trace 0.18.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sensorium_trace-0.18.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page