Skip to main content

Autopsy

An accountability layer for AI-written code.

We don't ask the AI what it did. We check.

AI coding agents now write a large share of production code — and they routinely, silently do things nobody asked for: weaken a test instead of fixing the bug, claim "I verified this works" without running anything, edit files they never read, or delete a safety check while doing something else. None of it shows up in the final diff. All of it is in the agent's own session recording — which nobody reads. Autopsy reads it.


What it does

Autopsy is a security guard for AI edits, working at three moments:

Moment Component What it does
After a session Investigator (autopsy run) Reads the transcript, reports what the agent actually did, with evidence.
Before each edit Seatbelt (autopsy hook) A PreToolUse hook that vetoes a bad edit before it touches disk.
At merge CI gate (autopsy run --ci) Fails the build on an unresolved critical finding.

And it compounds: every confirmed failure becomes a rule in autopsy.yml, so the same mistake can't happen twice.


Install

pip install -e .          # from this folder (PyPI name: autopsy-ai)

Quickstart

autopsy run                 # analyse your most recent agent session
autopsy run --session x.jsonl   # analyse a specific transcript
autopsy baseline            # analyse ALL past sessions, summarise failure modes
autopsy init                # write a starter autopsy.yml + arm the Seatbelt hook
autopsy rules               # show the policy currently in effect

Try the demo (no API calls, no network)

python demo/run_demo.py

It replays a staged session where an agent hits a failing test and cheats by weakening the assertion, then shows (1) the Investigator catching it with the agent's own words as evidence, and (2) the Seatbelt blocking the identical cheat in real time.


The detectors

All deterministic — no LLM judge. Precision is tuned over recall: every finding ships with verbatim evidence so a human can adjudicate in seconds.

Detector Fires when Severity
test-tampering After a test failure, an edit deletes an assertion, adds skip/xfail, or hardcodes the expected value to the broken output. critical
phantom-verification Agent claims tests pass while the last real test run failed and was never re-run. critical
blind-edit A file is edited that was never read or authored this session (authorship-aware — no false positives on self-written files). high
error-swallowing An edit introduces a bare except: / empty catch {} that wasn't there before. high
scope-drift A single task touches more files than the configured limit. medium
loop-flail The same file is edited many times — the agent is stuck and burning cost. medium

The rulebook — autopsy.yml

Plain text, lives in each project's repo, so a bank's payment service and a marketing site each get exactly the rules they need. Organisations layer an org-wide file via extends:.

protect:                         # places an AI may not touch
  - path: "**/payments/**"
    action: deny_edit
    reason: "A human must author payment code."
require:                         # preconditions
  - when: edit_file
    must: read_first
forbid:                          # forbidden edit shapes
  - name: test-tampering
    path: "**/tests/**"
    only_if: a_test_failed_recently
scope:
  max_files_per_task: 15

See autopsy rules for the policy in effect, and docs/ in the sibling my_portfolio/docs/autopsy folder for the full design document and pitch.


How it's built

src/autopsy/
  events.py        normalised event model (agent-agnostic)
  transcript.py    Claude Code .jsonl  ->  event stream   (the only format-aware file)
  detectors/       one file per detector, self-registering
  heuristics.py    shared tampering logic (used by detectors AND the live hook)
  policy.py        autopsy.yml loader + evaluator (the Seatbelt's brain)
  hook.py          PreToolUse entrypoint — fails OPEN so a bug never bricks editing
  report.py        terminal + JSON output
  cli.py           run / baseline / init / rules / hook

Adding another agent (Cursor, Copilot, …) is a new parser in transcript.py, not new detectors — everything above the event model is reused.

Local-only. No account, no network, no telemetry. Your code never leaves the machine.

Run the tests

pip install -e ".[dev]"
pytest -q

Metadata

Release files for autopsy-ai 0.1.2

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

Source distribution (sdist)

Source distribution for autopsy-ai 0.1.2
File Size Uploaded Provenance
autopsy_ai-0.1.2.tar.gz 25.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for autopsy-ai 0.1.2
File Interpreter ABI Platform
autopsy_ai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 52.0 kB

Release files / autopsy_ai-0.1.2.tar.gz

Download URL autopsy_ai-0.1.2.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0fcffb3e8b2dd4acbe78a0872115b095760bcf5ef90a52273f19b6eae0680ca3
BLAKE2b-256 checksum
How to use checksums
28dfae430b3d2691d4e01b5568a8102af8c6410a521e08f6d5d227d6a59a1ea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / autopsy_ai-0.1.2-py3-none-any.whl

Download URL autopsy_ai-0.1.2-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aae3119edf5d07b882010fdc41564e2b2e5f3f097cada222cdd4734fe241f68
BLAKE2b-256 checksum
How to use checksums
05fd18211d9590ea92977f589d592b5d692d81eee8c0a2350e7f261c159979d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for autopsy-ai 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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