Trace a production bug back through time to the exact AI-agent decision that caused it.
Project description
CodeAutopsy
Observability stops at the deploy. CodeAutopsy doesn't. Trace a production bug back across the build/run boundary to the exact AI-agent decision — the reasoning step — that caused it. Then hand the agent its own autopsy so it fixes itself.
git blame tells you which commit broke prod. CodeAutopsy tells you which reasoning step of
which AI agent broke prod — using OpenTelemetry span links and SigNoz's cross-signal
correlation to walk from crash → cause of death → the AI's original decision in one click.
Built for the WeMakeDevs × SigNoz hackathon (Track 3 · Agents of SigNoz).
Live: landing page · try the sandbox demo · sample app · provenance API
The one trick
A runtime stack frame gives you file:line. git blame at the deployed commit gives you the
commit that introduced that line. A provenance index maps (commit, file, line-range) →
the AI decision span that wrote it — including the reasoning the agent gave at the time. An OTel
span link stitches the runtime error trace to that dev-time decision trace, so one click in
SigNoz crosses a boundary no other observability tool instruments: dev-time → runtime.
RUNTIME (checkout-api) DEV-TIME (claude-code)
POST /checkout ─► parse_discount (500) agent.turn ─► agent.tool.Edit
│ ▲ reasoning: "assuming input is valid"
└─► codeautopsy.autopsy ───┘ (OTel span link — THE JUMP)
Status
- ✅ Day-0 validated: span-link click navigates across traces/services in SigNoz Cloud
(
scripts/day0_smoke.py). The core thesis is proven on real infrastructure. - ✅ Provenance store + git-blame join engine + resolve API (
codeautopsy/provenance/). - ✅ Recorder — real Claude Code
PostToolUsehook (codeautopsy-hook, wired via.claude/settings.json), risk-flag detection, commit indexer. - ✅ Sample app (checkout-api with a seeded bug) + Autopsy Enricher (mints the linked
codeautopsy.autopsyspan) + incident log for reproduction context. - ✅ Coroner CLI —
codeautopsy autopsy,index-commit,status. - ✅ Fix Bot —
codeautopsy fix <commit> <file> <line>: feeds the agent its own genealogy, verifies the patch with a real regression test before committing anything, opens a PR viaghwith--push. 101 tests passing, 100% coverage, ruff + mypy clean (pytest). - ✅ Dockerized (
docker compose up) and CI/CD via GitHub Actions — lint/type/test on every push, image published to GHCR onmain, landing page deployed via GitHub Pages. - ✅ Live on Google Cloud Run (see Deployment below) — provenance + sample app
- ✅ Persistent store — provenance data lives in Cloud SQL (Postgres) and survives redeploys
- ✅ Interactive sandbox demo — trigger the real bug, submit a decision, watch it resolve, live
deployed and validated end-to-end on real infra, redeployed automatically on every push to
main. - 🚧 Stretch: fully-automatic loop via SigNoz alert webhook; self-learning lesson write-back to the agent's rules file; SigNoz dashboards.
Landing page: https://aniket-3001.github.io/codeautopsy/ — built from
docs/index.html, deployed via GitHub Pages
(.github/workflows/pages.yml) on push to main.
Components
| Component | Path | Role |
|---|---|---|
| Recorder | codeautopsy/recorder/ |
Claude Code hooks → dev-time decision spans + risk flags |
| Provenance | codeautopsy/provenance/ |
SQLite (default) or Postgres (DATABASE_URL) store + git-blame indexer + resolve API |
| Sample app | codeautopsy/sample_app/ |
Instrumented FastAPI "patient" with a seeded bug |
| Enricher | codeautopsy/enricher/ |
On exception, mints the linked codeautopsy.autopsy span |
| Coroner CLI | codeautopsy/cli/ |
codeautopsy autopsy <trace> — the chain of custody |
| Fix Bot | codeautopsy/fixbot/ |
codeautopsy fix <trace> — patch, verify, commit, PR |
Quickstart
python -m pip install -e ".[dev]"
cp .env.example .env # add your SigNoz Cloud endpoint + ingestion key
pytest # provenance join engine is fully unit-tested
python scripts/day0_smoke.py # emit the two linked traces into SigNoz
Configuration
All config comes from environment / .env (see .env.example). Key vars:
OTEL_EXPORTER_OTLP_ENDPOINT— SigNoz OTLP endpoint (e.g.https://ingest.in2.signoz.cloud:443)SIGNOZ_INGESTION_KEY— SigNoz Cloud ingestion key (git-ignored; never commit)GROQ_API_KEY— required only for the Fix Bot (codeautopsy fix); free key at https://console.groq.com/keys
Docker
Run the whole spine (provenance service + instrumented sample app) without a local Python install:
docker compose up --build
This starts provenance (port 8100) and sample-app (port 8000), sharing a network and a
named volume for provenance.db. sample-app waits for provenance's healthcheck before
starting. Both containers use an editable install (pip install -e) so .git history ships
inside the image and git blame-based resolution behaves identically to a bare-metal checkout —
sample_app's REPO_ROOT depends on this. Override OTEL_EXPORTER_OTLP_ENDPOINT and
SIGNOZ_INGESTION_KEY via a .env file to point the containers at SigNoz Cloud.
curl http://localhost:8000/health # {"status":"ok","commit":"<sha>"}
curl -X POST http://localhost:8000/checkout -d '{"discount_code":"10","subtotal":100}'
CI/CD
GitHub Actions (.github/workflows/):
ci.yml— on every push/PR tomain: editable install,ruff check,mypy,pytestwith coverage (fail_under = 95, seepyproject.toml), coverage XML uploaded as an artifact. Runs apostgres:16service container sotests/test_provenance_postgres.pyexercises the real Postgres backend (skipped locally whenDATABASE_URLisn't set).docker-publish.yml— on push tomain(or manual dispatch): builds the image and publishes it to GHCR (ghcr.io/<owner>/<repo>), tagged by commit SHA andlatest.pages.yml— on push tomaintouchingdocs/: deploysdocs/index.htmlto GitHub Pages.deploy-cloud-run.yml— on push tomain(or manual dispatch): builds the image, pushes it to Artifact Registry, and redeploys both Cloud Run services. Authenticates via Workload Identity Federation (no long-lived key stored in GitHub).
Deployment
Live on Google Cloud Run, project codeautopsy-hackathon, region us-central1:
- Provenance: https://codeautopsy-provenance-182653908302.us-central1.run.app
(
min-instances=1so theresolveAPI stays warm for a demo) - Sample app: https://codeautopsy-sample-app-182653908302.us-central1.run.app
(points its
CODEAUTOPSY_PROVENANCE_URLat the provenance service above)
curl https://codeautopsy-sample-app-182653908302.us-central1.run.app/health
Persistence: the provenance service is backed by Cloud SQL (Postgres, instance
codeautopsy-db), connected via the Cloud SQL Auth Proxy socket (--add-cloudsql-instances)
with the DSN injected from Secret Manager (--set-secrets=DATABASE_URL=...) — never as a
plaintext env var. Data survives redeploys; verified by submitting a record, forcing a fresh
Cloud Run revision, and confirming it's still there. Local dev and the test suite still default
to the zero-config SQLite store (ProvenanceStore in codeautopsy/provenance/store.py) unless
DATABASE_URL is set.
To reproduce the deploy manually (e.g. onto a different GCP project):
gcloud auth configure-docker us-central1-docker.pkg.dev
docker build -t us-central1-docker.pkg.dev/<project>/codeautopsy/app:latest .
docker push us-central1-docker.pkg.dev/<project>/codeautopsy/app:latest
gcloud run deploy codeautopsy-provenance --image=us-central1-docker.pkg.dev/<project>/codeautopsy/app:latest \
--command=codeautopsy-provenance --port=8100 --min-instances=1 --max-instances=1 \
--set-env-vars="CODEAUTOPSY_PROVENANCE_URL=http://0.0.0.0:8100,CODEAUTOPSY_TARGET_REPO=/app" \
--allow-unauthenticated
gcloud run deploy codeautopsy-sample-app --image=us-central1-docker.pkg.dev/<project>/codeautopsy/app:latest \
--command=codeautopsy-sample --port=8000 \
--set-env-vars="CODEAUTOPSY_PROVENANCE_URL=<provenance-url-from-above>,CODEAUTOPSY_TARGET_REPO=/app,CODEAUTOPSY_RUNTIME_SERVICE=checkout-api" \
--allow-unauthenticated
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codeautopsy-0.1.0.tar.gz.
File metadata
- Download URL: codeautopsy-0.1.0.tar.gz
- Upload date:
- Size: 85.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee4707b1f9a91d4c4477afefb4051fb635dad54468d49eec9ff1082d0d00fb8b
|
|
| MD5 |
5e444a7aac8ea468f09b3748e85c2874
|
|
| BLAKE2b-256 |
00eb93bf062df78a917bacbd48245223cec56e6b391f92087a9871f9dee4d76d
|
Provenance
The following attestation bundles were made for codeautopsy-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on aniket-3001/codeautopsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codeautopsy-0.1.0.tar.gz -
Subject digest:
ee4707b1f9a91d4c4477afefb4051fb635dad54468d49eec9ff1082d0d00fb8b - Sigstore transparency entry: 2227588347
- Sigstore integration time:
-
Permalink:
aniket-3001/codeautopsy@ccf9a806ecfb3127af8a9d270fdc549b2dfbad2f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aniket-3001
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@ccf9a806ecfb3127af8a9d270fdc549b2dfbad2f -
Trigger Event:
push
-
Statement type:
File details
Details for the file codeautopsy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codeautopsy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43d06397e24066130a2dc1a798abf09b1f1579b5a3bf86651bb1ba379bbc6aab
|
|
| MD5 |
14144b4dd40cc9cc8aa7c34035f4e86c
|
|
| BLAKE2b-256 |
90c4d146bb948d0cd468125ebf98b197048780412c1b56268ad8fffc9fa49bf1
|
Provenance
The following attestation bundles were made for codeautopsy-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on aniket-3001/codeautopsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codeautopsy-0.1.0-py3-none-any.whl -
Subject digest:
43d06397e24066130a2dc1a798abf09b1f1579b5a3bf86651bb1ba379bbc6aab - Sigstore transparency entry: 2227588375
- Sigstore integration time:
-
Permalink:
aniket-3001/codeautopsy@ccf9a806ecfb3127af8a9d270fdc549b2dfbad2f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aniket-3001
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@ccf9a806ecfb3127af8a9d270fdc549b2dfbad2f -
Trigger Event:
push
-
Statement type: