Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cbc689b
ci: pip-audit gate on what CI installs, with an allowlist that expire…
sahiljagtap08 Nov 17, 2026
7d81648
client: retry 429 replies on every call, honouring Retry-After with j…
sahiljagtap08 Nov 17, 2026
d73a139
ci: run the Python matrix on ubuntu-24.04; ubuntu-latest is 26.04 and…
sahiljagtap08 Nov 17, 2026
45cca7d
run object: client.run(name, kind=..., task_set=..., config=...) open…
sahiljagtap08 Nov 18, 2026
2778f8c
drums preflight: check gateway, console, key, scopes, host capacity, …
sahiljagtap08 Nov 18, 2026
381ec67
client: export RetryPolicy and CertificateError next to their definit…
sahiljagtap08 Nov 18, 2026
3bc0cf2
runs: export Run and RunNotSupported on their own line
sahiljagtap08 Nov 18, 2026
b84b047
preflight: export preflight and PreflightReport at the end of the module
sahiljagtap08 Nov 18, 2026
0768f94
runs: keep the runs import next to its use
sahiljagtap08 Nov 18, 2026
d372421
preflight: a platform task set without a validation record is a warni…
sahiljagtap08 Nov 18, 2026
559bf69
Exchange an API key for a desktop token when the gateway advertises t…
sahiljagtap08 Nov 18, 2026
85f6701
mcp: custom tasks by task_set_id + task_id, list_task_sets and get_ta…
sahiljagtap08 Nov 18, 2026
77784c6
release: CHANGELOG entry for the post-D1 fixes and a proposed version…
sahiljagtap08 Nov 18, 2026
e2b145b
ci: run the test matrix on ubuntu-24.04 (ubuntu-latest has no Python …
sahiljagtap08 Nov 18, 2026
87d2788
ci: run the test matrix on ubuntu-24.04 (ubuntu-latest has no Python …
sahiljagtap08 Nov 18, 2026
2eeea57
ci: run the test matrix on ubuntu-24.04 (ubuntu-latest has no Python …
sahiljagtap08 Nov 18, 2026
d690735
ci: run the test matrix on ubuntu-24.04 (ubuntu-latest has no Python …
sahiljagtap08 Nov 18, 2026
befbf81
ci: run the test matrix on ubuntu-24.04 (ubuntu-latest has no Python …
sahiljagtap08 Nov 18, 2026
b0afd7b
merge: fix/w7-dependency-audit
sahiljagtap08 Nov 18, 2026
d47e0a9
merge: fix/w4-retry-after-certs
sahiljagtap08 Nov 18, 2026
f75af03
merge: fix/w2-token-exchange
sahiljagtap08 Nov 18, 2026
af3797b
merge: fix/w4-run-object
sahiljagtap08 Nov 18, 2026
09964c6
merge: fix/w4-preflight
sahiljagtap08 Nov 18, 2026
47526ef
merge: fix/w4-mcp-custom-tasks
sahiljagtap08 Nov 18, 2026
1db6dde
merge: fix/w4-release-0.4.0
sahiljagtap08 Nov 18, 2026
86b4f67
tokens: the exchange and every renewal use the client's certifi fallb…
sahiljagtap08 Nov 18, 2026
1a1765d
runs: follow the gateway's trainer runs (Drums-Labs/drums#41): no scr…
sahiljagtap08 Nov 18, 2026
90982f3
preflight: works in desktop-token mode (the exchange runs first; a co…
sahiljagtap08 Nov 18, 2026
19b17b6
docs: CHANGELOG for the combined 0.4.0, README notes on desktop token…
sahiljagtap08 Nov 18, 2026
77753d4
runs: a config that is not a JSON object or is over 16 KiB goes as it…
sahiljagtap08 Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/scripts/pip-audit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Dependency audit (A-40): install the package into a fresh venv the way CI does, freeze what got installed, and run
# pip-audit on exactly that set. Fails on any known vulnerability that is not in the allowlist (.pip-audit-ignore).
#
# .github/scripts/pip-audit.sh PIP_INSTALL_ARGS... e.g. .github/scripts/pip-audit.sh '.[test]'
#
# Allowlist format, one advisory per line (blank lines and lines starting with # are skipped):
# <advisory id> <review-by YYYY-MM-DD> <reason>
# An entry past its review date fails the audit, so an accepted advisory is looked at again rather than forgotten.
# Env: PIP_AUDIT_IGNORE_FILE (default .pip-audit-ignore), PIP_AUDIT_VERSION (default 2.10.1).
set -euo pipefail
[ $# -gt 0 ] || { echo "usage: $0 PIP_INSTALL_ARGS..." >&2; exit 2; }
ignore_file="${PIP_AUDIT_IGNORE_FILE:-.pip-audit-ignore}"
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
py="${PYTHON:-python3}"

# The allowlist: ids, with the review date enforced.
ignore_args=()
if [ -f "$ignore_file" ]; then
today="$(date -u +%F)"; expired=0
while read -r id review reason; do
case "$id" in ''|'#'*) continue;; esac
[[ "$review" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || { echo "$ignore_file: $id has no review-by date (YYYY-MM-DD)" >&2; exit 2; }
[ -n "$reason" ] || { echo "$ignore_file: $id has no reason" >&2; exit 2; }
if [[ "$review" < "$today" ]]; then echo "::error::$ignore_file: $id was due for review on $review ($reason)"; expired=1; fi
echo "allowlisted: $id (review by $review): $reason"
ignore_args+=(--ignore-vuln "$id")
done < "$ignore_file"
[ "$expired" = 0 ] || exit 1
fi

# The audited set: what `pip install ARGS` puts into a clean venv (pip itself included), minus this project.
"$py" -m venv "$tmp/target"
"$tmp/target/bin/python" -m pip install --quiet --disable-pip-version-check --upgrade pip
"$tmp/target/bin/python" -m pip install --quiet --disable-pip-version-check "$@"
"$tmp/target/bin/python" -m pip freeze --all --exclude-editable | grep -v ' @ file://' > "$tmp/installed.txt" || true
echo "audited set ($(wc -l < "$tmp/installed.txt" | tr -d " ") packages, from: pip install $*):"
sed 's/^/ /' "$tmp/installed.txt"

"$py" -m venv "$tmp/tool"
"$tmp/tool/bin/python" -m pip install --quiet --disable-pip-version-check "pip-audit==${PIP_AUDIT_VERSION:-2.10.1}"
"$tmp/tool/bin/pip-audit" --requirement "$tmp/installed.txt" --no-deps --disable-pip --progress-spinner off \
--desc on ${ignore_args[@]+"${ignore_args[@]}"}
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ permissions:

jobs:
test:
runs-on: ubuntu-latest
# ubuntu-latest (26.04) has no Python 3.9 build; 24.04 still has every version the SDK supports.
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand All @@ -27,3 +28,16 @@ jobs:
python -m pip install --upgrade pip build twine
python -m build
python -m twine check --strict dist/*

# A-40: the SDK has no runtime dependencies; the audited set is what CI installs to build and check it (pip, build,
# twine and their dependencies). Fails on any advisory not in .pip-audit-ignore.
audit:
name: pip-audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: .github/scripts/pip-audit.sh . build twine
60 changes: 60 additions & 0 deletions .github/workflows/dependency-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Weekly dependency audit (A-40): the same pip-audit as CI, on a schedule, against today's advisory database and today's
# resolution of the declared ranges. On failure it opens one issue labelled "dependencies", or comments on the one that
# is already open; it never closes an issue (a person does, after the fix lands).
name: dependency-audit

on:
schedule:
- cron: "17 6 * * 1" # Mondays 06:17 UTC
workflow_dispatch:

permissions:
contents: read

jobs:
audit:
name: pip-audit
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: pip-audit (gate)
id: gate
run: |
set -o pipefail
.github/scripts/pip-audit.sh . build twine 2>&1 | tee audit.log
- uses: actions/upload-artifact@v4
if: always()
with:
name: audit-log
path: "*.log"
if-no-files-found: ignore

report:
name: open or update the issue
needs: audit
if: failure()
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Open or update the "dependencies" issue
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
title="Weekly dependency audit failed"
body="The scheduled pip-audit found a vulnerability that is not in .pip-audit-ignore (or an allowlist entry is past its review date). Run: $RUN_URL (the log is the run's audit-log artifact). Fix by raising the pin, or add the advisory to .pip-audit-ignore with a reason and a review date."
gh label create dependencies --repo "$REPO" --color 0366d6 --description "Pull requests that update a dependency file" 2>/dev/null || true
n=$(gh issue list --repo "$REPO" --state open --label dependencies --search "in:title \"$title\"" --json number --jq '.[0].number // empty')
if [ -n "$n" ]; then
gh issue comment "$n" --repo "$REPO" --body "Still failing on $(date -u +%F): $RUN_URL"
echo "commented on #$n"
else
gh issue create --repo "$REPO" --title "$title" --label dependencies --body "$body"
fi
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
test:
name: test the wheel on ${{ matrix.python }}
needs: build
runs-on: ubuntu-latest
# ubuntu-latest (26.04) has no Python 3.9 build; 24.04 still has every version the SDK supports.
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 2 additions & 0 deletions .pip-audit-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Accepted pip-audit advisories (A-40). One per line: <advisory id> <review-by YYYY-MM-DD> <reason>
# An entry past its review date fails the audit. Empty: nothing is accepted today.
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,76 @@
All notable changes to the `drums` Python SDK. The SDK talks to drumsd over its HTTP API; the drumsd version each
SDK version was built against is noted where it matters.

## 0.4.0 - unreleased (proposed; not on PyPI)

Post-D1 fixes for training clients (audit 2026-11-16), integrated in one release. Minor version: new API and one
behaviour change (429 replies are retried, with an off switch); nothing is removed and no dependency is added. Every
0.3 call keeps its signature and meaning. Built against drumsd 0.4.2 and the gateway routes of Drums-Labs/drums #41
(trainer runs), #43 (desktop tokens), #46 (task-set tasks) and #49 (`GET /v1/limits`); against an older gateway each
feature falls back as described below.

### Changed

- **429 replies are retried on every call** (A-29, #11). A 429 (the gateway's per-key rate limit, or no capacity
right now: nothing was started) is retried for every method, step, screenshot, verify, create and fork included,
waiting at least the reply's `Retry-After` (seconds or an HTTP date), with jittered exponential backoff, for at
most 60 s of waiting per call (or 20 retries). `drums.RetryPolicy(max_wait_s, max_attempts, base_s, cap_s, jitter)`
via `connect(..., retry=...)`; `DRUMS_RETRY_MAX_WAIT_S` sets the budget and `0` restores the 0.3.0 behaviour
(raise at once). `drums mcp` waits at most 10 s. `Overloaded` carries `retry_after` and `retries`. A GET that gets
a 503 honours `Retry-After`; a POST that gets a 503 is still never retried.

### Added

- **Desktop tokens** (A-30, #14; design note "control plane out of the data path", 3.1). `drums.connect(url, key)`
keeps its signature. With a Drums API key (`drums_sk_...`) the client asks the gateway once how it authenticates
(`GET <url>/auth`, no credential). When the gateway says `token` or `both`, the key is sent once to the console's
token URL (https, or loopback http; the same transport and redirect rules as every other request) and the gateway
only ever receives the short-lived desktop token. The token is renewed before it expires (the console's
`renew_after_s`, else 5 min before expiry) and once after a 401, then the call is sent again. The exchange and
every renewal use the client's `RetryPolicy` (a 429 waits for its `Retry-After`; in `token` mode, with no fallback,
a 5xx or a dropped connection is retried within the same budget) and the certifi fallback below. In `both` mode an
unreachable console falls back to the API key at once (and tries the exchange again after a minute); in `token`
mode it raises `DaemonUnavailable` naming the console, and a refused key raises `AuthError`. A key sent before the
gateway's mode was known (the discovery request got no answer) is retried once after a 401. A drumsd token, or a
gateway in `api_key` mode, works exactly as before. Neither the key nor the token appears in a repr
(`repr(client)` shows the auth kind only) or an error message.
- **macOS certificates** (A-07, #11). When the system store cannot verify the gateway or the console and `certifi`
is installed, the client switches to certifi's CA bundle once (for both) and prints one line naming the server;
without certifi it raises the new `CertificateError` (a `DaemonUnavailable`) with the fix
(`Install Certificates.command` or `pip install certifi`). No new dependency.
- **Run object** (A-36, #12, matching the gateway's trainer runs). `with client.run(name, kind="training",
task_set=..., config=..., desktops_provisioned=N) as run:` opens a run (`POST /v1/runs`),
`run.step(step, reward=, zero_advantage_share=, rollouts=, desktops_busy=, desktops_provisioned=)` buffers points
sent at most once per 30 s (`PATCH /v1/runs/{id}`), and the block's end closes it (`POST /v1/runs/{id}/close`:
completed, failed with the exception, cancelled on Ctrl-C). Kinds: `training`, `rl`, `evaluation`, `eval`.
Desktops created inside carry `X-Drums-Run-Label` (the label the open reply names, which differs from the name
when another running run holds it) and `X-Drums-Run-Id`. A 409 on a heartbeat or close means the run has ended on
the gateway (closed, or lost after 30 min without a heartbeat): the SDK stops sending for it with one warning
(`run.ended`). A `config` that is not a JSON object or is over 16 KiB as JSON is sent as its `config_hash` and a
`config_summary` (scalar top-level values), with one warning. A 400 on open warns with the gateway's message and
leaves `run.id` None; only a 404 or 405 means the routes are missing. On a gateway without these routes, or with a key that has neither `runs:write` nor
`computers:write`, it is a no-op with one warning (`strict=True` raises `RunNotSupported`).
`client.run(<run uuid>)` alone still returns the run's record; `get_run` and `open_run` are the explicit names.
- **`drums preflight`** (#13). `drums preflight --desktops N --hours H [--model-gpus 2:6] [--task-set ID] [--json]`
and `drums.preflight(...)`: gateway and console health, key validity, expiry and scopes, host capacity and
admission, rate limit (N x 0.5 requests/s, the D1 rule, `REQUESTS_PER_DESKTOP_S`), live-desktop quota, spend cap at
the projected desktop-hour cost, and the task set's registration and validation. A pass/fail table with a fix and a
console link per row; exit 1 on a failure (`--strict`: also on a warning or a row it could not check). Works in
desktop-token mode: the exchange runs first, so a console that cannot issue a token is an auth failure (a `both`
gateway on the key alone is a warning), and the console row defaults to the token URL's origin. Rate limit, quota,
spend cap, price and host admission come from `GET /v1/limits` (scope `usage:read`, Drums-Labs/drums#49); a
gateway without it gets "not checked" on those rows.
- **MCP custom tasks** (A-08, A-09, #15). `create_computer` and `load_task` take `task_set_id` + `task_id` (a task of
a registered set) besides `task` and `task_id`; a task document sent as a JSON string is accepted; new tools
`list_task_sets` and `get_task_set` (36 tools, the gateway's tools.json); `verify` on a computer with no task says
so. Needs the gateway route `GET /v1/task-sets/{id}/tasks/{task_id}` (Drums-Labs/drums#46).

### CI

- A `pip-audit` job on what CI installs, with an allowlist whose entries expire, and a weekly audit that opens an
issue on failure (A-40, #10).
- The test matrix (3.9 to 3.13) runs on `ubuntu-24.04`: `ubuntu-latest` is 26.04, which has no Python 3.9 build.

## 0.3.0 - 2026-11-12

The MCP server and the `drums` command. The hosted MCP endpoint on the gateway (`<gateway URL>/mcp`) is live already;
Expand Down
Loading
Loading