Skip to main content

DockMedic

CI Tag

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.

v0.1.4 note: this release fixes the real-Docker log call, Gemini token/cost accounting, breaker counters and provider timeout, recurring-failure dedupe, and checkpoint resume. The replay figures below are unchanged because replay uses the offline stub and no live model was called.

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:

  1. A strict action schema: the LLM cannot name a container, a command, or an extra field.
  2. A deterministic policy: allowlist, opt-in stop, code-attached target, and bounded read-only fetch-count, token, and stage-time breakers. There is no LLM tool loop; fetch count is the three fixed read-only calls in ingest.
  3. An approval screen that prints the validated action object, plus a hash/TTL binding so approval cannot be replayed against a different state.
  4. A SQLite ledger: an fsynced intent is written before Docker is touched, and resume reconciles from that record.

Install

Python 3.11 or 3.12 is required. Install from PyPI:

python -m pip install dockmedic

With the optional Gemini provider dependencies:

python -m pip install "dockmedic[gemini]"

Using uv instead of pip:

uv tool install dockmedic
uv tool install "dockmedic[gemini]"

To install an unreleased tagged commit directly from GitHub instead:

python -m pip install "dockmedic @ git+https://github.com/ammarfitwalla/dockmedic.git@v0.1.3"

Quickstart

After installation:

dockmedic init
dockmedic demo --yes    # offline OOM fixture; uses the stub, no Docker/API key
dockmedic diagnose /path/to/your/container.log --yes  # saved log, no Docker needed
dockmedic watch         # needs Docker, Gemini access and GOOGLE_API_KEY
dockmedic incidents
dockmedic status <incident-id-prefix>
dockmedic resume <incident-id-prefix>

From a source clone, prefix each command with uv run after uv sync --locked:

uv sync --locked
uv run dockmedic init
uv run dockmedic demo --yes
uv run dockmedic diagnose demo/sample_container.log --yes
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:

python -m 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.
Replay harness check Graph vs baseline on fixed fixtures 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 a harness check: the graph and a naive baseline (one structured call on raw logs, no read-only fetches and no policy) over the same corpus, 3 runs per scenario by default. It validates code paths on fixed fixtures, not live model quality.

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; actual prompt/completion tokens are settled where the provider reports them, and structured-output calls use a length estimate from the pinned price table ($0.30/M input, $2.50/M output for gemini-2.5-flash). Live eval 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/resume default to Gemini, so they do spend tokens and need network access unless the config is switched to provider: stub.
  • Best-effort scrubber: known patterns only, no guarantee against novel secrets.
  • stop_container is 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, diagnose and 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. Releases are published to PyPI from a protected environment using either an API-token GitHub secret or Trusted Publishing; no token is stored in the repo. There is no litellm dependency: its PyPI package shipped credential-stealing releases after a CI compromise in March 2026.

Metadata

Release files for dockmedic 0.1.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 dockmedic 0.1.4
File Size Uploaded Provenance Actions
dockmedic-0.1.4.tar.gz 132.0 kB Without provenance Details for dockmedic-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dockmedic 0.1.4
File Interpreter ABI Platform Actions
dockmedic-0.1.4-py3-none-any.whl Python 3 none any Details for dockmedic-0.1.4-py3-none-any.whl

Total release size: 176.3 kB

Release files / dockmedic-0.1.4.tar.gz

Download URL dockmedic-0.1.4.tar.gz
Size 132.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1c0025a18e79c51214f4a5228a792df181092fdc2837cee9404dea1a1031693b
BLAKE2b-256 checksum
How to use checksums
4e3af3c76a6e4370e8ba184000d8ecf8f5294277db707a00966a899077657fcc
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.4-py3-none-any.whl

Download URL dockmedic-0.1.4-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b264c6515802ee4d426d0503ed494d07369882f2f54b91606577d39d3c7f5c81
BLAKE2b-256 checksum
How to use checksums
dddb0c16908d6ddff0dc8a4e74a7ac98d550177fd5882f437e82c58f3b228720
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.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.

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.

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