Repository and tooling¶
Layout¶
Cargo.toml # Cargo workspace; shared lints
rust-toolchain.toml # 1.99.1 + rustfmt + clippy
crates/
schedr-model/ # shared model (DAG JSON, states); JSON Schema
schedr-proto/ # Protobuf + tonic code, master <-> agent
schedr-config/ # configuration loading and validation
schedr-db/ # schema, migrations, queries (SQLite, Postgres)
schedr-master/ # scheduling loop, DAG validation, commands, gRPC server
schedr-agent/ # worker agent
schedr-api/ # webserver: REST API, UI
schedr-tls/ # mTLS on the internal links: certificates, reloading, handshakes
schedr/ # the binary: roles, user CLI, in-task CLI
src/<module>.rs # unit tests in src/<module>/tests.rs (see Testing)
tests/ # integration tests (later)
xtask/ # development tasks: `cargo xtask schema [--check]`, `docs-sources`
schema/ # generated, committed: JSON Schemas, OpenAPI
docs/ # documentation: conf.py, index pages, 02-dags/ and 03-guide/ (by hand)
pyproject.toml # Python package
python/
schedr/ # Python API package (typed: py.typed)
tests/unit/schedr/ # unit tests mirroring the package (see Testing)
tests/integration/ # integration tests
examples/ # example DAGs and their tests; examples/docs/ is quoted by Writing DAGs
BUGS.md # open bugs (B1, B2, ...), removed when fixed
Makefile # setup / fmt / fmt-check / lint / test / check
.pre-commit-config.yaml
.github/workflows/ci.yml
Rust¶
Edition 2024, toolchain
1.99.1pinned inrust-toolchain.toml(an exact release; see CI supply-chain pins). Minimum supported Rust version: 1.99 (rust-versionin the workspaceCargo.toml).rustfmt(max width 100).clippywithallandpedanticlint groups at warn; CI fails on any warning (-D warnings).unsafe_code = "forbid",missing_docs = "warn".Debug and test builds keep only line tables (
[profile.dev] debug = "line-tables-only", 2026-10-23): panics and backtraces still show functions andfile:line, and coverage doesn’t use debug info; debuggers see no locals or types (CARGO_PROFILE_DEV_DEBUG=fullfor a debugging session). Measured on the integration test binaries: a clean build 149 s instead of 191 s and 3.4 GB instead of 6.5 GB (roles33 MiB instead of 103 MiB); a rebuild after a change toschedr-model11 s instead of 17 s, writing 1.5 GiB instead of 3 GiB, and thesyncafter it 1 s instead of 9 s (see Workflow:make test-integration). Not chosen: full debug info (no debugger has been used here so far); none for dependencies only (a smaller saving: every test binary links all of schedr’s crates).
Python¶
No
Any(the user, 2026-10-29: “avoid Any at all cost”): public signatures carry precise types (overloads, protocols, generics, unions,objectfor an unknown value the caller narrows, theJsonalias for JSON);Anynever silences a type checker. Where a precise type can’t be written, a comment or an explicit, localcastsays why. Left alone: signatures a framework dictates (__init_subclass__(cls, **kwargs: Any)) and internal code over arbitrary values (annotations, decoded JSON). Applied 2026-10-29:run_dag’sTaskResult.outputisobject(decision 73, the user’s: a test narrows it before using a field; comparing needs nothing),output_jsonisJson,replace=takesMapping[str, object], each trigger’soverridenames its options with their types (an unknown one is a type error and aTypeError),branchtakes a function returninglist[Task] | Task,Output’s parts areOutput[object], and the@taskdecorator’s implementation returns the union of its overloads’ results (TaskDecoratora class).Supported versions: Python 3.14+ (required by t-strings, see Airflow compatibility, Scope: Templating). CI tests 3.14.
Dependency management: uv (lockfile
uv.lock, dev deps in[dependency-groups]).Build backend: maturin with
bindings = "bin"(see Packaging and releases). The Python package version is dynamic, taken from the Cargo workspace.uv syncrebuilds the project when Rust sources change ([tool.uv] cache-keys).ruffhandles formatting and linting with a broad rule set;mypyruns in strict mode;pytestruns the tests with coverage (see Testing).Local environment: pyenv-virtualenv selected by
.python-version(git-ignored). The Makefile points uv at that env viapyenv prefix. Pre-commit hooks callruff/mypydirectly.
Packaging and releases¶
Python package: built with maturin, replacing hatchling. The wheel contains the
schedrRust binary plus the Python package (asruffanduvship).pip install schedrgives a DAG author the API andschedr standalonefor local development. If schedr’s Python package later includes a compiled Rust extension (allowed, see Rust/Python integration), it goes into the same wheel.Platform wheels: Linux x86_64 (manylinux and musllinux), Linux aarch64 (manylinux), and macOS arm64 (local development). In M1 (1.16): Linux x86_64 manylinux. M2.1b adds Linux x86_64 musllinux (Alpine uses musl: a manylinux wheel’s binary doesn’t run there), smoke-tested in CI inside
python:3.14.8-alpine3.24(digest-pinned); built locally withmake smoke-musl. The x86_64 wheels go todist/(their names tell them apart), where the example image takes the musllinux one. M2.13 (2026-10-26) adds Linux aarch64 manylinux and macOS arm64, one matrix job on native standard runners (wheel-nativeinci.yml), shown per platform aswheel-linux-aarch64(ubuntu-24.04-arm) andwheel-macos-arm64(macos-15, Apple Silicon). The macOS job installsrustup-init1.29.1 itself and reads the channel fromrust-toolchain.toml(the runner’s rustup is not used; see CI supply-chain pins). The macOS wheel tag is maturin’s defaultmacosx_11_0_arm64. The repository is public, so these standard runners cost nothing. Larger (billed) runners are not used. No new action and no new crate: the wheel jobs use checkout, setup-python and upload-artifact, each pinned by commit SHA (see CI supply-chain pins). macOS has no/proc. Off there: the memory watchdog, the cgroup limit, stopping orphaned tasks from the journal after a crash (process identity), and the ops port’s process metrics. When/procis absent the agent warns once per process (no /proc: orphaned tasks aren't stopped after a crash). Where/procexists, a failure to identify a process still warns per task. No Rust unit-test job on macOS: it is local development, and the smoke run covers the wheel. A unit-test job would mean tests that read/procneed marking Linux-only. Not chosen: cross-compiling aarch64 on the x86_64 runner (the smoke test would then need QEMU or a second machine, andaws-lc-rsplus the bundled SQLite compile with the target’s own C compiler on the native runner); cross-compiling macOS from Linux (the Linux build image has no macOS SDK); macOS x86_64 as a second wheel and universal2 (local development is Apple Silicon; an Intel Mac gets no wheel; a universal2 wheel would run only its arm64 slice in the smoke test); musllinux aarch64 (the target cluster is x86_64, so the Alpine image stays on the x86_64 musllinux wheel); a larger macOS runner (billed; the standardmacos-15is 3 cores and 7 GB); documenting the missing/proconly, with a WARN on every task (the log would repeat it for each attempt); macOS equivalents throughsysctl/libproc(real work, for local development only); a Rust unit-test job onmacos-15.How a wheel is built (
scripts/build-wheel.sh; CI jobswheelandwheel-native,make smoke,make smoke-musl): one script for every wheel. Linux runsmaturin build --release --lockedinside a digest-pinned image (quay.io/pypa/manylinux2014_x86_64,manylinux2014_aarch64,musllinux_1_2_x86_64; tag2026.10.16-1, pushed 2026-10-16). The container tool is$CONTAINER, else podman when it is installed, else docker (podman locally, docker in CI). Inside the image:rustup-init1.29.1 checked against its published sha256, then only the channel inrust-toolchain.toml(rustup install --profile minimal --no-self-updatefrom/tmp, so the file’s rustfmt, clippy and llvm-tools are not installed, and rustup stays that installer).RUSTUP_TOOLCHAINis that channel. maturin 1.15.0 comes fromscripts/maturin-requirements.txt(pip install --require-hashes;uv pip compile --generate-hashes, and on Python 3.14 maturin has no third-party dependencies).--lockedkeeps Cargo from re-resolving or rewritingCargo.lock(the tree is mounted read-write). The compatibility tag ismanylinux2014ormusllinux_1_2; patchelf comes from the image (the build stops if it is missing). macOS is the same without a container:rustup-init1.29.1 foraarch64-apple-darwin, checked the same way, into a temporary cargo home (the runner’s rustup is left alone), then maturin from the same requirements file. Wheels land indist/. The digests, the rustup-init checksums and the requirements hashes are listed under CI supply-chain pins.Smoke test of the wheel (
scripts/smoke-wheel.sh; CI jobwheel, and the matrix checkswheel-linux-aarch64andwheel-macos-arm64;make smokelocally for the x86_64 manylinux wheel): PLAN.md’s “M1 is done” as a new user does it. The wheel goes into a fresh venv that isn’t activated, with only the system’s directories onPATH; thenschedr dags checkandschedr dags teston the example DAG, andschedr standaloneon free ports withdags list,dags unpause,runs trigger --for ...andruns listuntil that run succeeds. The same script runs on each runner. Not part ofmake check(a release build takes minutes). There is no local target for the aarch64 or macOS wheel: this machine is x86_64 and there is no Mac. Not chosen: smoking the macOS wheel only as far asschedr --version; smoking the aarch64 wheel under QEMU on the x86_64 runner.Container images:
Master/webserver image: the Rust binary only, no Python at all.
Worker base image: Rust binary + Python 3.14 + the
schedrpackage. Users build their own worker image on top of it, adding their libraries.Both run under an arbitrary UID.
Helm chart for deploying.
Releases (decisions 153-158, the user’s, 2026-11-02; PLAN.md, Release 0.1.0):
153. Trusted Publishing to PyPI from
.github/workflows/release.yml(pypa/gh-action-pypi-publish, pinned by commit SHA), in an environmentpypithat needs the user’s approval for each release. Not chosen: a PyPI API token as a repository secret (long-lived); uploading CI’s wheels by hand.154. A pushed tag starts a release:
vX.Y.Z(checked against the versions inCargo.tomlandpyproject.toml) builds and smoke-tests the four wheels, publishes them, then creates the GitHub Release. Not chosen: a manually dispatched workflow tagging the commit itself; a GitHub Release published by hand starting the upload.155. What a release carries: release notes from a hand-kept
CHANGELOG.md(the version’s section); the wheels and aSHA256SUMSattached to the GitHub Release; build provenance attestations for each wheel (actions/attest-build-provenance, pinned by SHA). No sdist: installing one would build the Rust binary on the user’s machine; a platform without a wheel can’t install. Not chosen: GitHub’s generated notes; an sdist.156. 0.x is a preview: the schema (
0001_initial.sql) and the protocol are edited in place until 1.0.0, so 0.1 to 0.2 means a fresh database; the README and release notes say so. Not chosen: migrations from 0.1.0 on.157. The images are pushed with a release, the chart is not: the server and worker base images to
ghcr.io/ptutak/schedr-serverandghcr.io/ptutak/schedr(decision 164) (x86_64, from the musllinux wheel; pushed with the workflow’sGITHUB_TOKEN); the Helm chart stays in the repository. Not chosen: an OCI chart; multi-arch images (later). The chart’s default images are these two, tagged with itsappVersion, which a release sets to its version (scripts/release.py checkrefuses another; the user, 2026-11-02).The licences a release carries (the user, 2026-11-02, before 0.1.0):
LICENSE(schedr, MIT) andLICENSE-THIRD-PARTY, the licences of the crates the binary links (normal dependencies, no proc macros, on the wheels’ four platforms) with their own licence files, each text once, and the UI’s vendored htmx (0BSD). Written fromCargo.lockbyscripts/third_party.py(make third-party), checked bymake third-party-checkinmake checkand CI; the wheels carry both (license-files, PEP 639:license = "MIT"), the base image through the package, the server image in/usr/share/licenses/schedr; each smoke test checks they are there. Not chosen:cargo about(a tool to install and pin, for whatcargo metadatagives); nothing until 0.1.1 (the MIT and Apache-2.0 notices go with every binary copy). The author on PyPI and in the crates isp.tutak@outlook.com(the user, the same day).165. The docs on GitHub Pages (https://ptutak.github.io/schedr/; the user, 2026-11-02): the site CI builds (
docs-site, whatmake docsmakes), deployed by the release workflow’s last job (actions/deploy-pages, environmentgithub-pages). Not chosen: Read the Docs (an account, and its build would have to reproduce ours: Rust for rustdoc and the generated pages).166. The site shows the latest release (the user, 2026-11-02): a final tag deploys its docs; a rehearsal and main don’t. Not chosen: main on every push (ahead of what users installed); both, main under
/dev/(two builds to keep apart).164. The image with Python is
ghcr.io/ptutak/schedr, the one withoutschedr-server(the user, 2026-11-02, after the rc pushedschedr-worker): one binary runs every role, so the image for anything that runs tasks (standalone, workers) isschedr, as it is locally and in the chart’simage, andschedr-serverruns the master, the webserver andschedr ui. Not chosen: keepingschedr-worker(a standalone user wouldn’t look for it); also pushingschedr-standaloneandschedr-ui(the same two images under more names: more packages to link and tag, and the question which one).158. A rehearsal on TestPyPI: a tag
vX.Y.ZrcNpublishes to TestPyPI (environmenttestpypi, its own trusted publisher), and the wheel installed from there is smoke-tested; only a final tag goes to PyPI. Not chosen: straight to PyPI.160. A release runs all of CI on its tag (
ci.ymlcalled as a reusable workflow), then publishes CI’s own wheels (the user, 2026-11-02). One definition of the build; a release takes as long as CI. Not chosen: a copy of the wheel jobs inrelease.yml(two builds to keep in step; the tag not tested again).161. A rehearsal does every step, marked rc: TestPyPI, a GitHub pre-release, images tagged only
X.Y.ZrcN(the user, 2026-11-02). Not chosen: TestPyPI only (the Release and the image push first tried for real).162. Image tags
X.Y.ZandX.Y, nolatest(the user, 2026-11-02): in the preview a new minor needs a fresh database (decision 156), and a floatinglatestwould move a deployment onto it. Not chosen:latesttoo; onlyX.Y.Z.163. The tree holds the version a tag names:
0.1.0-rc1inCargo.tomlforv0.1.0rc1(maturin writes0.1.0rc1; the agent compares a runner’s version in that form; no dot afterrc, whichSchedrVersionwould refuse), committed and tagged; the workflow only checks (scripts/release.py check) (the user, 2026-11-02). Not chosen: the workflow setting the version from the tag (what is built differs from the tagged commit).How a release runs (Claude’s, as built): the tag checked first; CI; the four wheels checked (one per platform, of the tag’s version), summed (
SHA256SUMS) and attested; published (one job, its environmenttestpypiorpypiby the tag); the published wheel downloaded from its index and smoke-tested; the images built from it again, smoke-tested and pushed (org.opencontainers.image.sourcenames the repository); the GitHub Release last, once all it announces exists.
Version pairing: the binary and the Python package always share one version number and are released together. The runner reports its version when it connects to the agent; the agent rejects a mismatched runner with a clear error.
Libraries¶
Rust crates chosen for the implementation (versions pinned when added):
Need |
Crate |
Why |
|---|---|---|
async runtime |
|
required by |
gRPC |
|
see Master–worker protocol |
REST |
|
tokio-native, the same stack as |
web UI templates |
|
HTML templates checked at compile time, escaping by default (M3.1, decision 26A) |
UI interactions |
htmx 2.0.11 (2026-09-22, 0BSD), vendored as |
partial updates without a JavaScript build (decision 26A); from npm’s tarball, its sha512 integrity checked; the file’s sha256 |
password hashes ( |
|
the hashes PROJECT.md’s |
making the users file ( |
Python |
the |
HTML in tests |
|
the UI’s pages read through a real HTML parser, by CSS selectors (M3.1) |
OpenAPI from Rust types |
|
derives next to serde |
Swagger UI |
|
the UI’s files in the binary, no download at build time (2.11a); crc32fast 1.5.3, typed-path 0.12.4 and zopfli 0.8.4 locked; zip went 8 → 9.0.5 (a major, through utoipa-swagger-ui’s vendored build), which brings nix 0.31.3, a new transitive crate |
JSON Schema |
|
see Rust/Python integration |
database |
|
compile-time |
time and zones |
|
explicit handling of DST gaps and overlaps |
cron |
|
parsing and wall-clock matching of 5/6-field cron and presets; schedr’s own DST rules on top (croner’s differ: it skips gap times of interval-type expressions) |
UUIDv7 |
|
see Runs: identity |
HTTP client (user CLI) |
|
tokio-native; honours |
CLI |
|
standard |
configuration |
|
file < env ( |
logging |
|
see Observability |
processes and signals |
|
safe APIs only ( |
ignore files |
|
gitignore semantics for |
content hashes |
|
SHA-256 of DAG roots |
metrics |
|
Prometheus’s own client: a registry per process, typed label sets; see Observability (M2.9) |
TLS |
|
see Master–worker protocol: mTLS (M2.7); rustls locked at 0.23.46 |
test certificates |
|
a CA and its certificates generated in tests |
Not chosen: chrono + chrono-tz (weaker DST handling); diesel / compile-time sqlx macros
(two backends); actix-web (a second async stack). The Python package stays dependency-free.
Python dev tools added with decision 57 (2026-10-29, dev group only): basedpyright
1.40.2 (2026-10-04; brings nodejs-wheel-binaries 24.19.0) checks DAG code as an editor does;
pydantic 2.14.1 (2026-10-11; brings pydantic-core 2.50.1, annotated-types 0.8.0,
typing-inspection 0.4.4) tests schedr.pydantic.Model. Each meets the library-age rule.
Library ages (decided 2026-10-26, B15, the user): a new major or minor version (its x.y.0)
must be at least 7 days old; a patch on a minor that already qualifies may move once it is 3
days old. Age is calendar days in UTC (published on date D is today − D days old). A yanked
x.y.0 still dates its minor. A yanked version in the lock moves to a version that meets the
rule, forward if one exists, else back. Record new libraries here. Not chosen: elapsed hours
(the result depends on when the check runs); a yanked x.y.0 not counting (works against
taking its fixing patch); two weeks for every version (the old rule: held back fixes like
tokio 1.54.1); 1 day for a patch (first chosen, raised to 3 the same day for security: a
compromised or broken patch needs a few days to be found and yanked).
tokio 1.54.1 (B15, 2026-10-26): 1.54.0 is yanked (RUSTSEC-2026-0384, Interval /
AtomicWaker race; a debug build aborts in the time driver). 1.54.1 is a patch; 1.54.0
(yanked) is 7 calendar days old on 2026-10-26, so the minor qualifies. Taken now because
1.54.0 aborts the process. crates/schedr/tests/timers.rs aborted 5/5 and, in an earlier
phase, 20/20 on 1.54.0, in AtomicWaker::take_waker from the time driver (StateCell::fire
→ process_at_time → the multi-thread parker), the same path as B15’s Postgres abort. The
same test passes 20/20 on 1.54.1. make stress quick passed 14/14; scenario 9 ×10 passed
with no panic in the logs. Not chosen: 1.53.2 now and 1.54.1 later (a downgrade and a second
move); 1.53.3 (also a later second move).
Lock update (B15, 2026-10-26): cargo update on the whole lock (Cargo.toml requirements
unchanged except tokio, and utoipa-swagger-ui set to 10.0.2, the version this locked).
Every changed version checked on crates.io (created_at of the
version and of its x.y.0, yanked). Taken: croner 4.0.2, ctutils 0.4.5, nix 0.31.3 (new lock
entry), pulldown-cmark 0.13.5, rustls 0.23.46, smallvec 1.16.4, tinystr 0.8.5, tokio 1.54.1,
typed-path 0.12.4, utoipa-swagger-ui 10.0.2, webpki-root-certs 1.0.11, yoke 0.8.4, zerovec
0.11.9, zerovec-derive 0.11.7, zip 9.0.5, zopfli 0.8.4. Pinned back (too new): cc 1.10.0 →
1.9.0, icu 2.4.0 → 2.3.0 (icu_provider 2.3.1), uuid 1.29.0 → 1.28.0; zip 9.1.1 → 9.0.5
(9.1.0 is 2 days old); typed-path 0.13.0 → 0.12.4 (0.13.0 is 6 days old); ctutils 0.4.6 →
0.4.5 (0.4.6 is 1 day old, under the 3 days for a patch).
Testing¶
Failure at every write (decision 98, the user’s, 2026-10-30, after Codex’s whole-repository
review found the class again and again: B42, B49, B51): a fault-injection harness in the
tests. A test-only hook in schedr-db’s query layer makes the Nth write fail;
fail_each_write runs a master operation once per write it makes, that write failing, from
a fresh state each time; a shared consistency check then finds any half-done state (the
database against itself and against the master’s memory). Every master operation that writes
gets such a test, so a path that can leave half a state fails the day it is written. Not
chosen: a trigger per bug, by hand (what each proof did until then).
Unit tests and integration tests. Every step brings its unit tests, and integration tests where it needs real processes, files, a real database or the whole system (see PLAN.md). Unit tests use fakes, in-memory streams and socket pairs; anything that starts a real process, binds a real server or talks to Postgres is an integration test.
Integration tests live in
crates/*/tests/(the public API only, like any user of the crate; the binary’s tests runschedritself) andpython/tests/integration/. They run withmake test-integration, part ofmake checkand CI, and are not counted for the coverage floor (which measures the unit tests).What they need is provided, never skipped:
make test-integrationstarts a throwaway Postgres container (postgres:17.6-alpine, Podman when installed, else Docker; on a random local port, removed afterwards) and passesSCHEDR_TEST_POSTGRES_URL, and passes the Python withschedrinstalled asSCHEDR_TEST_PYTHON. Run without them, a test fails with a message saying how to run it. In CI the same tests run in their ownintegrationjob, with Postgres as a GitHub Actions service container (the same image) and the Python fromuv sync; therustandpythonjobs run the unit tests only (-E 'not kind(test)',python/tests/unit), asmake test-rust/make test-pythondo.Each test is isolated: its own temporary directories, its own database on the test server, free ports, and a
schedr standaloneof its own for end-to-end tests; they run in parallel.What they cover so far: real processes under supervision (exit codes and log files, timeouts, SIGTERM then SIGKILL, process groups, output floods, the clean environment); the real runner started by the agent (a directory of DAG files with broken, hanging and crashing files; task mode with inputs, failures, timeouts and cancels); every database query on Postgres; the runner as a real process from Python;
schedr standaloneend to end through the CLI and the API (data flow into a command, retries and upstream failure, cancelling a running task, files added, changed and removed, a conflict, scheduled runs while unpaused, rejections) on SQLite and on Postgres;schedr.testing.run_dagagainst the binary (failed runs, attempts, decoded outputs) and theexamples/tests; the roles as separate processes (master, webserver and worker running a DAG on Postgres and on one SQLite file, a command applied at once throughLISTEN/NOTIFY, an unmigrated database refused, SIGTERM); the worker lifecycle on Postgres (a worker killed mid-task and started again: its attemptlostand retried; one that never returns:lostand still listed; a running task across a master restart: one attempt, continued; a second worker with the same ID refused); mTLS (M2.7: two workers and the webserver over mTLS on Postgres, each task’s log read through the webserver from its worker, a deleted log and a worker gone; a worker whose certificate comes from another CA refused; the master’s certificates rotated without a restart; inschedr-tls, the handshakes, names, refusals and rotation over loopback); the memory watchdog (M2.8: a task allocating past its budget killed alone,oom_killed, and its retry succeeding with its peak measured; a parse runner over budget, its file an import error); the ops port (M2.9: every role’s/healthz,/readyzand/metricsafter a run, a master waiting for an unanswering database alive but not ready, standalone’s single ops port; a Postgres query pastquery_timeoutstopped).The stress suite (decided 2026-10-23, step 2.10b):
crates/schedr/tests/stress/, a test target of its own on the same harness as the role tests (tests/support/: the real binary, real processes, real Postgres), not inmake checkor the CI run on each push (-E 'kind(test) & not binary(stress)'). Each scenario ends with the same invariants, read from the database (nothing still running, no task succeeding twice, no command undecided, no run in a state the scenario doesn’t expect, no try of a task starting before the previous one ended) and from the tasks’ own marks (each stress task appends astartand anendline with its run, task, try and process to one file; a try killed by the harness ends when it was killed, one stopped by schedr when the database recorded its end), and writes a report,target/stress/<scenario>.json. Performance fails only on a gross regression (a generous floor per scenario: at least so many tasks a second, the master’s round p99 under 5 s, assignment to start p99 under 30 s, …); the numbers are in the report, and a baseline is in the guide (Stress tests).Scenarios: 1 throughput (many DAGs and one wide one); 2 command bursts (triggers at once, a pause/unpause storm, cancelling running runs at once); 3 worker churn (
kill -9of a worker’s whole process tree, as a pod dying, and back); 4 master failover (the leader killed; then the next frozen past its lease withSIGSTOPand thawed: its writes refused, it exits 1); 5 the database stalled (a proxy freezing the leader’s connection: shorter than its lease, it goes on; longer, the standby takes over and it exits); 6 through PgBouncer in transaction pooling (1 and 4 again); 7 a rolling restart (SIGTERM one worker after another, no task may fail); 8 code churn (many files, the code changing while runs go on); 9 standalone on SQLite; 10 a soak (memory and open files of each role flat once warmed up); 11 heavy output (big logs read through the API at once, outputs near their limit); 12 the memory watchdog with many tasks over budget beside normal ones; 13 Python tasks as the load (@taskchains passing outputs, a process each). Masters are reached through a proxy following the ready one, as a Service would.When: nightly in CI (
.github/workflows/stress.yml, skipped whenmainhasn’t changed since the last passing run; by hand with a profile and a name filter), and locally withmake stressat the end of each milestone and after a step that changes the master, the database layer or the agent (AI_INSTRUCTIONS.md). Not chosen: weekly (too long between a regression and its cause); on every push (too slow, and timing makes it flaky).Size:
SCHEDR_STRESS_PROFILE=quick(the default, about 20 minutes, sized for GitHub’s smallest standard runner, 2 CPUs and 7 GB, the one a private repository gets, and scaled up by the machine’s CPUs and memory, at most 4 times) orfull(fixed and larger, an hour’s soak; locally or by hand). Not chosen: one size (either too slow for nightly or too small to find anything).Not chosen: a load generator of its own driving a deployment from outside (
cargo xtask stress): more flexible, but without the harness and its checks; tight performance limits (shared runners vary too much: they would fail at random). Kubernetes stays withscripts/kind-standalone.sh, per milestone.Services:
make stressstarts Postgres and PgBouncer (edoburu/pgbouncerv1.26.0-p0, 2026-09-30, transaction pooling, any database name passed through) on a network of their own; CI has them as service containers.
Every public function, method and class / struct has unit tests. Private ones are not tested directly: testing them would break the point of making them private (an implementation detail, free to change). They are covered through the public code that uses them.
Python: private means a name starting with
_(def _parse_line,class _Cache,self._buffer) or name-mangled__x. Special methods (__init__,__eq__,__call__, …) are public behaviour and are tested. An underscore on a module or package (schedr/_serialization/,schedr/_model/) means “internal to schedr, not user API”: its non-underscore names are still public within schedr and are tested.Rust: private means an item without any
pub(visible only in its module). Anything withpub,pub(crate)orpub(super)is tested.
Coverage floor: 85 % per language over the whole code base, private code included (reached through the public tests);
make checkand CI fail below it. Not counted: the test files themselves (src/**/tests.rs) and a binary’smain.rs, which only calls into the crate’s library (everything testable lives there), and likewise a Python package’s__main__.py, which only calls into a tested module. Python:pytest-covwith branch coverage,--cov-fail-under=85. Rust:cargo-llvm-cov,--fail-under-lines 85.Never skip a test (
pytest.mark.skip,skipif,xfail, Rust#[ignore]) without asking first, with the reason stated clearly. A test that can’t run is fixed, or the question is raised.Structure mirrors the code:
Python:
python/tests/unit/schedr/...mirrors the package; onetest_<module>.pyper module (schedr/runner/protocol.py→tests/unit/schedr/runner/test_protocol.py). A package’s__init__.pyis tested intest_init.pyin the package’s test folder.pytest --import-mode=importlib, so test files with the same name in different folders don’t clash and test folders need no__init__.py.Rust: one test file per module, next to it:
src/scheduler.rsends with#[cfg(test)] mod tests;and its tests are insrc/scheduler/tests.rs(nested modules the same way:src/scheduler/fire_times/tests.rs; the crate rootsrc/lib.rshas its tests insrc/tests.rs). As a child module, it reachespub(crate)/pub(super)items, which a crate’stests/folder (integration tests, public API only) can’t. Test code is compiled only for tests. Not chosen: amod tests { … }block inside each source file (mixes code and tests in long files).
Tools:
Language
Tools
Python
pytest,pytest-covRust
built-in
#[test]run bycargo-nextest;rstest(fixtures, parametrized cases);proptest(property tests: fire times across DST, JSON round trips);insta(snapshots: DAG JSON, error messages, CLI output);pretty_assertions;tempfile(temporary directories: DAG roots for scanning);tower+http-body-util(REST API requests through the router, in process);cargo-llvm-cov
Documentation¶
Generated HTML documentation for both languages, built from the repository by one command
(make docs; make docs-serve serves it locally, port DOCS_PORT, default 8765). Nothing generated is committed: the site
can be rebuilt at any time, and changing the documentation engine later means changing only
its configuration, not the content.
Sections: Overview (
README.md), Writing DAGs (docs/02-dags/, below), How schedr works (the guide, below), Reference (generated, below), Design (PROJECT.md, one page per chapter), Plan (PLAN.md), Python API (from docstrings), Rust API (fromrustdoc).Files are numbered in the site’s order (2026-10-23; Writing DAGs inserted as section 2 on 2026-10-25, and every later section moved up one number), so a directory listing reads like the site: each section has its number (1 Overview, 2 Writing DAGs, 3 How schedr works, 4 Reference, 5 Design, 6 Plan, 7 API); a section of several pages is a folder (
docs/02-dags/,docs/03-guide/,_generated/04-reference/), a single page a file (_generated/06-plan.md), and pages in a folder are numbered too (03-guide/04-master.md), two digits so 10 follows 09. The hand-written pages (docs/) and the generated ones (docs/_generated/, bycargo xtask docs-sources) share the numbers; a section’s index page staysindex.md. A page that gets pages of its own becomes a folder (05-workers/index.md,05-workers/01-journal.md: 5.1). Not chosen: dotted numbers in file names (5.1-journal.md: dots trouble links and anchors); numbering only the guide (the other sections’ files stay out of order).make docsbuilds from scratch: it emptiessite/, and with it Sphinx’s cached environment (site/.doctrees). After a page was renamed, that cache still listed the old name, so autosummary generated nothing for the moved Python API page (a warning, so a failed build), and the old HTML stayed insite/. Costs nothing: xtask rewrites every generated page on each build anyway. The Python API page is generated by xtask (_generated/07-api/01-python.md), so autosummary’s module pages land next to it.Writing DAGs,
docs/02-dags/, written by hand and committed (2026-10-25): how to define a DAG with the native API, as built and checked against the code. Pages, in order: a first DAG (examples/sync.py), tasks and operators, data flow, schedules, defaults and retries, the DAG context, testing. Each page links to the Reference for the CLI and configuration, to the Python API page for signatures, and to Design for the reasons. A planned feature is one line pointing at its Design chapter, where a reader would look for it, and is not described. Every step that changes what a DAG author can do updates these pages, the same way the guide is updated. Not chosen: pages inside the guide (mixes how the system runs with how to write DAGs); a section at the end, after Plan and API (authoring would come after the decision log); describing the whole API as designed with “not yet” marks (pages would describe what doesn’t run, and the marks go stale).Examples quoted from files (2026-10-25): every non-trivial example is a file (
examples/sync.py,examples/daily_report.py,examples/docs/<name>.py), included withliteralinclude. A test imports eachexamples/docs/file, checks that everywith Dag(...)produces DAG JSON valid againstschema/dag.schema.json, and runs everyexamples/docs/file withrun_dag.sync.pyanddaily_report.pyalready have their own run tests. A one-line fragment may stay inline. Not chosen: inline snippets checked by doctest (a DAG snippet that isn’t a doctest isn’t checked at all).The guide (M2.9b),
docs/03-guide/, written by hand and committed: how the running system works as built, not as planned: overview of the roles and links, glossary, the life of a run, the master (its rounds, step by step, and what it handles between them), workers (the agent’s loop, the journal, memory, draining, logs), parsing and code versions, state and failures (what happens when each part stops), network and security, observability, deployment. It describes and links to the design log for the reasons; known limits are stated (e.g. B7). Every step updates the pages it changes (AI_INSTRUCTIONS.md), and the end-of-step code review checks the guide against the diff. Not chosen: more text inPROJECT.md(it mixes “how” with “why” in an already long file); rustdoc module comments only (no one place showing how the parts fit); oneARCHITECTURE.mdsplit at build time (a second very long file); reviewing the guide only per milestone (it drifts in between).The reference (M2.9b), generated at build time by
cargo xtask docs-sourcesintodocs/_generated/04-reference/, so it can’t go stale:Configuration: from the configuration’s JSON Schema (
schedr_config::config_schema:JsonSchemaandSerializederived on every section, so doc comments and defaults come with it; durations and sizes are written back as they are read,2m,4MiB, checked by a round-trip test): every key with its type, default, environment variable and doc comment.Command line: from clap’s command tree (every visible command, its usage and arguments; clap’s
helpsubcommands left out).REST API: from the OpenAPI description (
schema/openapi.json): operations with their parameters and answers, then the schemas. Rendered as Markdown by xtask, no Sphinx extension.Metrics: from a list per role (
METRICSin the master’s, the agent’s and the API’smetrics.rs,PROCESS_METRICSinops.rs; typeschedr_model::metric_doc::MetricDoc).registertakes each name and help text from it, and a unit test per role compares a scrape with it (scrape_mismatches: types, help, labels, nothing undocumented).Not chosen: a Sphinx extension per kind (
sphinxcontrib-openapi,sphinx-click-like tools: more dependencies, and none covers the configuration or metrics); writing the values into the guide by hand (they drift); building metric docs by scraping filled registries (needs sample label values per family in production code).
Diagrams: Mermaid, as plain
```mermaidfences that GitHub draws too (sphinxcontrib-mermaid2.1.1,myst_fence_as_directive; the browser loads mermaid.js 12.1.0, pinned inconf.py, from jsDelivr). Not chosen: Graphviz (needsdotin CI; GitHub doesn’t draw it); ASCII art (hard to keep readable).PROJECT.mdstays one file in the repository. The split into chapters is generated at build time bycargo xtask docs-sources(which generates every page taken from repository files: the chapters, the README, the plan, the list of crates): one Markdown file per##chapter, numbered in order, into the git-ignoreddocs/_generated/. The split output is engine-neutral Markdown; only the engine’s index picks the files up.Engine: Sphinx with MyST (Markdown pages as they are), Furo (theme), autodoc + autosummary (the Python API from docstrings and type hints, every module found recursively) and napoleon (Google style). Committed in
docs/: onlyconf.py, the index pages, Writing DAGs, the guide and the autosummary template. The documentation tools are a dev-only dependency group; theschedrpackage stays dependency-free.Rust API:
rustdoc(cargo doc --workspace --no-deps), copied into the site underrust/and linked from its navigation.Docstrings are required in the source:
Python: Google style (
Args:,Returns:,Raises:) on every public module, class, function and method, enforced by ruff’sD(pydocstyle) rules with the Google convention; private_names are exempt (as in Testing).Rust:
///and//!comments on every public item (missing_docs, an error in CI), andrustdoc::broken_intra_doc_linksas an error, so links in comments must resolve.
CI builds the docs and fails on warnings (a broken reference, a missing docstring, a page not in the navigation). Publishing (e.g. GitHub Pages): possibly later.
Not chosen: MkDocs + Material + mkdocstrings (nicer to configure, but MkDocs core is under-maintained and Material is in maintenance mode).
Workflow¶
make checkruns everything CI runs: format check, clippy, ruff, mypy, the Rust tests (cargo nextest) and pytest, both with the coverage floor.make checkfirst cleanstarget/when it holds more thanTARGET_MAX_GIB(50 by default;make target-size): Cargo never deletes old artifacts, and every change of a dependency, feature or flag leaves a copy of everything above it (107 GiB by M2.9b). 50, not 30: one clean and a few builds already make 21 GiB (dev, coverage, docs), so 30 would clean and rebuild everything every few steps. Not chosen: cleaning on a schedule or by hand only (forgotten);cargo-sweep(a tool to install, for the same effect). Since 2026-11-08 (the user’s, options A and D): the other worktrees’target/s are cleaned pastWORKTREE_TARGET_MAX_GIB(20), one whose build lock is held left alone; and[profile.dev] incremental = false, the incremental cache having grown to about half of eachtarget/(a rebuild after a small change is slower). Not chosen: no debug line tables (backtraces lose their lines); onetarget/shared by the worktrees (their parallel builds would wait for each other and rebuild each other’s crates).make test-integrationbuilds the test binaries, runssync, then starts Postgres and the tests (B6): a rebuild writes about 3 GiB, 1 GiB of it still unflushed when the build ends, and Postgres’s fsyncs on the same (WSL2) disk waited behind it for 7–8 s. Not chosen: Postgres withfsync=off(the SQLite tests and the worker’s journal fsync on the same disk; and it isn’t how Postgres runs in production). Smaller debug info (see Rust) halves what a rebuild leaves to flush, but doesn’t replace thesync.Pre-commit hooks run the same checks on commit.
CI: GitHub Actions:
rustandpython(unit tests, lints, coverage),integration(integration tests with a Postgres service; see Testing),docs,wheel(Linux x86_64 manylinux and musllinux, and the images),wheel-native(one matrix, shown aswheel-linux-aarch64andwheel-macos-arm64; see Packaging and releases) andsdist. The repository is public, so the standard runners cost nothing. No Rust unit-test job on macOS (see Packaging and releases).
CI supply-chain pins¶
Decided 2026-10-26 (step 2.13b). CI must not take a new release of an action, or of a tool an action downloads, the moment it is published (the tj-actions attack, 2025). Not chosen: Dependabot with a cooldown (the bump is a bot’s pull request; merging it is not the age check); pinning only the release path (the same actions build and test every push); doing it inside 2.13 (that step is the extra wheels).
Every
uses:in.github/workflows/is a full 40-character commit SHA, with the version in a comment (actions/checkout@<sha> # v4.4.0). The major stays the one the workflow already used.dtolnay/rust-toolchainis a commit onmaster(its movingv1tag, the commit of 2026-10-16). Thestablebranch’s tip is one commit ahead ofmasterand is outsidemaster’s history; the action’s own docs say a pin outside that history is garbage-collected, and that commit is what makes the action install the movingstablechannel. A master SHA has no default toolchain, and the action does not readrust-toolchain.toml, so each job setstoolchain:to the same release as the file.Rust is that release:
1.99.1(released 2026-10-16;1.99.0on 2026-10-01, so the minor qualifies, and the patch is 10 days old). The MSRV stays 1.99. Local rustup reads the file. A wheel build installs that channel and nothing else:scripts/build-wheel.shdownloadsrustup-init1.29.1, checks it against the published sha256, and runs it with--default-toolchain none. It then readschannelfrom the file and runsrustup install --profile minimal --no-self-updatefrom/tmp(in the repo, rustup would also install the file’s rustfmt, clippy and llvm-tools).RUSTUP_TOOLCHAINis that channel, so a laterrustcdoes not sync those components. Without--no-self-updatethe install replaces rustup itself. macOS uses the same installer foraarch64-apple-darwin, in a temporary cargo home. The checksums (archive dated 2026-09-01) aredda7234360b7f578ca8b0ddcb80145646fa61a67c1720a5abc7051b35c9fcb71(x86_64-unknown-linux-gnu),15f6e4ce9f583b929c996c91562bad6d4454f3281de858b02cdfdef615fac433(aarch64-unknown-linux-gnu),331228566cc931f32cd684f9bebc5956a5e5d7394c8d5de595f196a658ab98e6(x86_64-unknown-linux-musl) andec1b9233e7f72990ecd8e62063fa7f6c3dfc2bec8e97f88bff165f9100ac696a(aarch64-apple-darwin). Thesdistjob does not install Rust.Tools, the same age rule as libraries. maturin
1.15.0(2026-08-24) isscripts/maturin-requirements.txtfor the wheel builds and thesdistjob (pip install --require-hashes --only-binary=maturin; 14 hashes; on Python 3.14 maturin has no third-party dependencies). uv0.13.5(2026-10-22;0.13.0on 2026-10-09) is setup-uv’sversion, pluschecksumofuv-x86_64-unknown-linux-gnu.tar.gz(f68d291c75783122dad58ab77def0e13f3233f358731db5d6d7e8715603b928f). setup-uv staysv4.2.0: that release hashes the tarball whenchecksumis set, and it does not know 0.13.5 on its own.v10.3.2(2026-10-22) does, and the patch is old enough, but v10 turnsenable-cacheon by default and is six majors newer. Every setup-uv job isubuntu-latest, so one hash covers them. cargo-nextest0.9.149(2026-10-20) and cargo-llvm-cov0.9.1(2026-09-06;0.9.0on 2026-08-16) on install-action’stoolinput. Helm staysv4.3.0(2026-09-09; it is that minor’sx.y.0and qualifies).v4.3.1(2026-10-15) also qualifies and was left, because CI already pinnedv4.3.0. Python stays3.14.Images are digest-pinned (
name@sha256:<64 hex>), the same age rule. Wheel builds (scripts/build-wheel.sh), tag2026.10.16-1, modified 2026-10-16:quay.io/pypa/manylinux2014_x86_64@sha256:2bd80fa8fca6b775a913b7e42fa410c5f2246fb6f7f8f3280b5d562e5ca5d63f,quay.io/pypa/manylinux2014_aarch64@sha256:01984696ca71627d9f61991da836e5d542aa21695e8337ab0dc1f27a4559502f,quay.io/pypa/musllinux_1_2_x86_64@sha256:915d73c75b4551f98fd7b12de655ef2e27419a6441ea07472b6e25e0d868d18d. Service and smoke images:postgres:17.6-alpinecreated 2025-10-15 (sha256:ef257d85f76e48da1c64832459b59fcaba1a4dac97bf5d7450c77753542eee94),pgbouncer:v1.26.0-p0created 2026-09-30 (sha256:b17551c776ef7e5769ef80b956d20f85e2fd25dd8912d31d58f782aad495b711),python:3.14.8-alpine3.24created 2026-10-01 (sha256:f6a589d43c42b9e7f7dc67a12d37132491f362859a5d750607710cc56da3bc72),alpine:3.24created 2026-10-21 (sha256:be2656061b536c1883c4034790e21d0a09c5aaaf51968b89368a3c0371ea2c9a; a rebuild of the tag already chosen, 5 days old, which meets the 3-day patch rule).scripts/kind-lib.shuses the postgres digest andscripts/kind-standalone.shthe alpine digest.Actions (the release the floating tag resolved to): checkout
v4.4.0(2026-07-20), rust-cachev2.9.3(2026-10-20), install-actionv2.87.31(2026-10-23), setup-uvv4.2.0(2024-11-30), setup-pythonv5.6.0(2025-04-24), upload-artifactv4.6.2(2025-03-19), setup-helmv5.0.1(2026-06-23).make pin-checkis part ofmake check. It runsuv run --no-sync python scripts/check-action-pins.pyand does not sync: a localuv synconce removed packages already installed. PyYAML 6.0.3 is a direct dev dependency (it was already locked, through pre-commit). Therustjob installs that dev group first (uv sync --frozen --no-install-project --inexact, so it does not compile the Rust binary; the cost is the dev group, not a Rust build) and then runsmake pin-check. The checker parses workflow YAML and.github/actions/**/action.yml. It fails if auses:is not a 40-character SHA, a local./...action or reusable workflow, ordocker://image@sha256:<64 hex>; ifdtolnay/rust-toolchainhas notoolchain:or that input differs from the file; if arust-toolchain:input differs from the file; if install-action’stool:lacks@versionor setup-uv / setup-helm’sversion:is notx.y.z; if an image in a workflow (includingcontainer:andservices),scripts/*.sh, the Makefile,images/**/Dockerfileorexamples/kubernetes/Dockerfileis not digest-pinned (no tag is implicit:latest); or ifscripts/maturin-requirements.txtis missing a sha256 hash. The error names the file and line. The example Dockerfile’sFROM ${SCHEDR}is the locally built base (ARG SCHEDR=schedr:0.1.0), not a registry pull.
How to bump a pin. Apply the library-age rule (Libraries, above): a new major or minor,
its x.y.0, at least 7 UTC calendar days old; a patch at least 3 once that minor
qualifies; a yanked or withdrawn release moves forward to one that qualifies, otherwise
back. Read the changelog. Resolve the tag to its commit with
gh api repos/<owner>/<repo>/git/ref/tags/<tag>. When object.type is tag, follow
object.sha with gh api repos/<owner>/<repo>/git/tags/<sha> until object.type is
commit. Put that commit on the uses: line and the version in the comment. A tool pin
is the version input, checked the same way, with no SHA. Rust is channel in
rust-toolchain.toml and every toolchain: input, changed together.
dtolnay/rust-toolchain has no semver besides the moving v1 tag: treat a new commit as
a new version (7 days) and pin a commit that is on master. An image pin is the index
digest of a tag that meets the age rule (a rebuild of a tag already chosen follows the
patch rule), written as @sha256:<64 hex> everywhere that tag is pulled. maturin is
recompiled with uv pip compile --python-version 3.14 --universal --generate-hashes.
rustup-init is a version whose .sha256 is published at
static.rust-lang.org/rustup/archive/<version>/<triple>/rustup-init.sha256; the four
triples in scripts/build-wheel.sh change together.
CI does not use maturin-action (decided 2026-10-26, the second half of 2.13b).
The wheel jobs and make smoke / make smoke-musl call scripts/build-wheel.sh. The
sdist job installs maturin from the same requirements file
(pip install --require-hashes --only-binary=maturin) and runs maturin sdist --out dist
(it packs the tree; it does not compile Rust). Not chosen: (A) keeping maturin-action
and only pinning its container image by digest (inside that image the action still runs
rustup toolchain install stable, curls https://astral.sh/uv/install.sh, installs
patchelf with uv tool install when it is missing, and pip install --user cffi, all at
whatever is current, before any hook of ours); (B) recording that gap and leaving the
action in the wheel jobs. What a wheel build still downloads: rustup-init 1.29.1,
checked against its published sha256 before it runs, and the Rust toolchain for the
channel in rust-toolchain.toml (minimal profile only), from static.rust-lang.org,
verified by rustup against the release manifest. Rustup does not replace itself
(rustup install --no-self-update). Crates keep the checksums in Cargo.lock
(maturin build --locked does not rewrite it). maturin comes from PyPI with the hashes
in scripts/maturin-requirements.txt. uv’s tarball is checked with the checksum input
above.