DockMedic
Bounded, reviewable, resumable, measured. DockMedic is a local CLI that diagnoses Docker container failures with a single-agent triage inside a deterministic pipeline. The LLM proposes a root cause and one of three small actions; code decides what is actually allowed to happen, asks for approval, and records the outcome in an execution ledger.
This is a portfolio project for local Docker development hosts, not a paid
product and not a production safety guarantee. See project_overview.md for a
plain-language overview and dockmedic_v0_1_0_engineering_plan.md (Rev 2) for
the engineering plan.
Why it exists
Log diagnosis alone is a commodity. The interesting engineering problem is: what happens when the model is wrong, compromised, or interrupted half-way through an action? DockMedic answers that with four pieces of code that do not trust the model:
- A strict action schema: the LLM cannot name a container, a command, or an extra field.
- A deterministic policy: allowlist, opt-in stop, code-attached target, and tool-call/token/time breakers.
- An approval screen that prints the validated action object, plus a hash/TTL binding so approval cannot be replayed against a different state.
- A SQLite ledger: an fsynced intent is written before Docker is touched, and resume reconciles from that record.
Quickstart
Python 3.11 or 3.12 and uv are required.
uv sync --locked
uv run dockmedic init
uv run dockmedic demo --yes # offline OOM fixture; uses the stub, no Docker/API key
uv run dockmedic diagnose demo/sample_container.log --yes # your own saved log
uv run dockmedic watch # needs Docker, Gemini access and GOOGLE_API_KEY
uv run dockmedic incidents
uv run dockmedic status <incident-id-prefix>
uv run dockmedic resume <incident-id-prefix>
uv run dockmedic eval --mode replay --runs 3
dockmedic demo and watch will prompt before any restart. stop_container
is disabled unless allow_stop: true is set in dockmedic.yaml.
LLM provider
watch and resume use the configured provider from dockmedic.yaml; the
default is gemini with model: gemini-2.5-flash. Install the provider extra
and export a key before running them:
pip install "dockmedic[gemini]"
export GOOGLE_API_KEY="..."
Set provider: stub in the config to run entirely offline without a key. The
demo and diagnose commands default to --provider stub so they stay
reproducible; pass --provider gemini to exercise the real client against the
same fixture. dockmedic eval --mode replay always uses the stub; --mode live
uses Gemini with a hard --usd-cap. Gemini is the only real provider, behind
LLMClient.
dockmedic diagnose <log-file> runs the whole pipeline against a saved log with
no Docker daemon. It infers a small synthetic inspect snapshot from the text
(exit_code, restart_count, OOM flag), so it is a replay/demo aid, not a
substitute for live Docker state. The sample in demo/sample_container.log
includes a URL credential that the scrubber redacts before the LLM sees it.
Pipeline
flowchart LR
E[Docker events] --> W[Watch: bounded reconciliation,\nintentional-stop filter,\ndedupe + cooldown]
W --> I[Ingest: scrub, sanitise,\ntruncate, delimit]
I --> T[Triage: LLM, read-only]
T --> P[Plan: strict IncidentReport]
P --> Q[Policy: allowlist,\ncode target, breakers]
Q --> A{Approve\ninterrupt}
A -->|yes| X[Execute: ledger intent,\nstate guard, Docker call]
A -->|no| R[Report only]
X --> V[Verify + ledger outcome]
Execution is at-least-once delivery of idempotent, state-guarded actions — not exactly-once. If the process dies after Docker ran but before the ledger was updated, resume sees the container state and skips the duplicate call.
What the tests prove
| Claim | Evidence |
|---|---|
| Best-effort secret redaction | Labelled corpus gate in tests/security/; every labelled secret is removed. No "zero leakage" claim. |
| Control/bidi/ANSI text is neutralised | tests/test_sanitize.py. |
| Policy rejects malicious plans | Mock-LLM malicious-plan corpus (smuggled target, shell string, extra keys, out-of-enum action) plus Hypothesis invariants: for any action object the target equals the incident container and nothing outside the allowlist reaches Docker. |
| Approvals are bound and expire | tests/policy/test_approval.py (action, container, started_at, policy version, TTL). |
| Crash-safe execution | Four kill-point scenarios: before intent, after intent/before Docker, after Docker/before executed write, after executed. |
| Red-team behaviour | Five red-team scenarios recorded as counts and labelled a smoke test, not a measured attack rate. |
| Graph beats baseline | Replay benchmark with scenario-level uncertainty (see below). |
The deterministic mock-LLM tests are the primary security evidence. Live-model runs would be supporting evidence, not a substitute.
Evaluation
evals/ contains a taxonomy, author-written labels, 10 functional scenarios,
5 red-team scenarios, recorded logs/inspect/stats fixtures, a pinned model
ID and price table. dockmedic eval --mode replay runs the graph and a naive
baseline (one structured call on raw logs, no tools, no policy) over the same
corpus, 3 runs per scenario by default.
Result generated 2026-11-28 with uv run dockmedic eval --mode replay --runs 3
(stub LLM, offline; the model ID is a pinned config label, no live model was
called). Full artefacts: eval_results/results.json, results.md,
result.yaml.
| Arm | Accuracy | 95% CI |
|---|---|---|
| Graph | 100.0% | [100.0%, 100.0%] |
| Baseline | 86.7% | [66.7%, 100.0%] |
| Delta (graph − baseline) | +13.3% | [+0.0%, +33.3%] |
Counts rather than percentages: graph 30/30 correct, baseline 26/30 correct.
The graph wins on oom-basic (3/3 vs 0/3) and crash-loop (3/3 vs 0/3)
because it can read structured signals the baseline never receives.
Red-team smoke test: 5 scenarios x 3 runs, 0 policy bypasses in the replay harness. This is a count on a malicious-plan corpus, not a claim about all possible prompts.
Uncertainty uses a percentile bootstrap over scenarios, with the 3 correlated runs collapsed into one scenario accuracy first. Wilson intervals on individual runs would overstate the sample size because runs within a scenario are not independent. With 15 scenarios the intervals are wide; treat the delta as directional, not precise.
Cost and latency are recorded for both arms in the artefacts. Replay spend is
$0.0000 because the stub makes no network calls. --mode live uses Gemini with
a hard --usd-cap, includes an estimated token cost from the pinned price
table, and never runs in CI. Temperature is 0 but providers are not
deterministic and retire models, so results are dated, not eternal.
Limitations
- Docker-only, intended for developer hosts; no cluster or remote daemon support.
- Small corpus (15 scenarios), labelled by one author: no independent annotator.
- The stub LLM is rule-based; replay validates the harness and code paths, not
real model quality. Live numbers require a separate dated run with an API key.
watch/resumedefault to Gemini, so they do spend tokens and need network access unless the config is switched toprovider: stub. - Best-effort scrubber: known patterns only, no guarantee against novel secrets.
stop_containeris opt-in, and semantic harm from an allowed action on the intended container is out of scope.- Live watch/DoD cannot be exercised in environments without Docker; the
offline demo,
diagnoseand replay suite cover the same code paths with a fake client and a log-derived snapshot.
Development
uv run ruff check .
uv run mypy src
uv run pytest # 43 tests
CI syncs uv.lock with uv sync --locked, runs lint, strict mypy, all tests,
and the replay eval. Actions are pinned by commit SHA, permissions are
least-privilege, and Dependabot is enabled. Publishing uses PyPI Trusted
Publishing from a protected environment; no API token is stored. No litellm
dependency: its PyPI package shipped credential-stealing releases after a CI
compromise in March 2026.
Metadata
Release files for dockmedic 0.1.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 |
|---|---|---|---|---|
| dockmedic-0.1.2.tar.gz | 127.1 kB | Without provenance | Details for dockmedic-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dockmedic-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for dockmedic-0.1.2-py3-none-any.whl |
Total release size: 168.9 kB
Release files / dockmedic-0.1.2.tar.gz
| Download URL | dockmedic-0.1.2.tar.gz |
|---|---|
| Size | 127.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb86fb16667983f8465bde8111a622a1f12da1ab953f1b1157ef555d99d5e101
|
|
BLAKE2b-256 checksum How to use checksums |
33f4b0ea450f9c27c2fd5d379968612bf54c42de43a6bf632ac6ee09fcc2d051
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dockmedic-0.1.2-py3-none-any.whl
| Download URL | dockmedic-0.1.2-py3-none-any.whl |
|---|---|
| Size | 41.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a179e779af04faa6d7715119bd74095ed8d18ea1c4b430762715c2d89b8be603
|
|
BLAKE2b-256 checksum How to use checksums |
f91b22e18b03b9043a5aa120febb91dcf937b783c520eaae2810e7d8f753efbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dockmedic 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.