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-childrenorSENSORIUM_NO_CHILDREN=1records the parent only. A non-Python child is counted and not traced. - Rust:
cargo sensorium testorcargo 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,-O0or-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, andrefocus verdict: REFUSED -- <run> was recorded and is queryable, but it could NOT be verified against <run>: treat it as a separate, UNVERIFIED executionwhen a rerun could not be checked.diffprintsverdict: REFUSED -- cannot issue a MATCH/DIVERGED verdict. Re-record. - NOTHING WAS CHECKED.
watchprintsverdict: 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.
diffprintsverdict: DIVERGED at causal step N.refocusprintsrefocus 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
TypeScript recorder (Node 24):
npm install sensorium-trace
These resolve once the packages are on the indexes. 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/shipssensorium-rt0.7.3,sensorium-transform0.5.2, andcargo-sensorium0.8.4.cargo install --path rust/cargo-sensorium, thencargo sensorium testorcargo sensorium runfrom a workspace. Linux, stable rustc. Panics show up infailures. rust/README.md. What it does not see: rust/HONESTY.md. - TypeScript.
typescript/shipssensorium-ts0.6.2. A trace reportsrecorder: sensorium-ts. Node 24. From a checkout,npm ci --prefix typescript, thensensorium ts run -- vitest run …orsensorium ts run -- node --test …. A shell-freenpm testthat runs vitest ornode --testis 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 awaitinside a function is recorded; top-levelawaitis not. typescript/README.md. - C.
sensorium c run -- <cmd>records a Linux x86-64 debug build (-O0or-Og, gcc or clang). Crashes are whatexceptionsreads. 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.
What the answers claim
Sensorium reports; the agent reading it reasons. Nothing in an answer is inferred from data the trace does not hold.
diffcompares the shape of two runs,(file, qualname, kind), not their values. A pure move reads DIVERGED unless--ignore-movescan pair the name uniquely.refocusre-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.treederives parentage from the caller frame, not from "the last frame on this thread".exceptionsclaims SWALLOWED only when the recording establishes it. Anything short of that isambiguous, with the reason printed.watchnever reads zero hits as "the invariant held". A site it could not evaluate is counted.flowis lineage over captured values, not static dataflow.infolabels an INCOMPLETE recording and does not print a0as 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sensorium_trace-0.18.2.tar.gz | 6.2 MB | With provenance | Details for sensorium_trace-0.18.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sensorium_trace-0.18.2-py3-none-any.whl | Python 3 | none | any | Details for sensorium_trace-0.18.2-py3-none-any.whl |
Total release size: 6.8 MB
Release files / sensorium_trace-0.18.2.tar.gz
| Download URL | sensorium_trace-0.18.2.tar.gz |
|---|---|
| Size | 6.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f0a9c5f71a98a7da25fabca5caa7db8047448aebf4842734cb056e6784e91e7
|
|
BLAKE2b-256 checksum How to use checksums |
f6697fa211f7ae2a360a4677e74b503d2401f6cb235f30a94fcbc2c898cb83b5
|
| 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 17, 2026.
Transparency logRelease files / sensorium_trace-0.18.2-py3-none-any.whl
| Download URL | sensorium_trace-0.18.2-py3-none-any.whl |
|---|---|
| Size | 638.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
acce515eb4577ec4e43b277575117fc5cafc06f65d12bf2bbdda02f06b626790
|
|
BLAKE2b-256 checksum How to use checksums |
8a041025fbad27e0b40e7016283ff1596808aab12427611f15f8dc30b06d1013
|
| 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 17, 2026.
Transparency logSecurity for sensorium-trace 0.18.2
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.
Attestation for sensorium_trace-0.18.2.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 17, 2026.
Transparency logA 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.