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.1 pinned in rust-toolchain.toml (an exact release; see CI supply-chain pins). Minimum supported Rust version: 1.99 (rust-version in the workspace Cargo.toml).

  • rustfmt (max width 100).

  • clippy with all and pedantic lint 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 and file:line, and coverage doesn’t use debug info; debuggers see no locals or types (CARGO_PROFILE_DEV_DEBUG=full for 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 (roles 33 MiB instead of 103 MiB); a rebuild after a change to schedr-model 11 s instead of 17 s, writing 1.5 GiB instead of 3 GiB, and the sync after 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, object for an unknown value the caller narrows, the Json alias for JSON); Any never silences a type checker. Where a precise type can’t be written, a comment or an explicit, local cast says 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’s TaskResult.output is object (decision 73, the user’s: a test narrows it before using a field; comparing needs nothing), output_json is Json, replace= takes Mapping[str, object], each trigger’s override names its options with their types (an unknown one is a type error and a TypeError), branch takes a function returning list[Task] | Task, Output’s parts are Output[object], and the @task decorator’s implementation returns the union of its overloads’ results (TaskDecorator a 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 sync rebuilds the project when Rust sources change ([tool.uv] cache-keys).

  • ruff handles formatting and linting with a broad rule set; mypy runs in strict mode; pytest runs the tests with coverage (see Testing).

  • Local environment: pyenv-virtualenv selected by .python-version (git-ignored). The Makefile points uv at that env via pyenv prefix. Pre-commit hooks call ruff/mypy directly.

Packaging and releases

  • Python package: built with maturin, replacing hatchling. The wheel contains the schedr Rust binary plus the Python package (as ruff and uv ship). pip install schedr gives a DAG author the API and schedr standalone for 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 with make smoke-musl. The x86_64 wheels go to dist/ (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-native in ci.yml), shown per platform as wheel-linux-aarch64 (ubuntu-24.04-arm) and wheel-macos-arm64 (macos-15, Apple Silicon). The macOS job installs rustup-init 1.29.1 itself and reads the channel from rust-toolchain.toml (the runner’s rustup is not used; see CI supply-chain pins). The macOS wheel tag is maturin’s default macosx_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 /proc is absent the agent warns once per process (no /proc: orphaned tasks aren't stopped after a crash). Where /proc exists, 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 /proc need marking Linux-only. Not chosen: cross-compiling aarch64 on the x86_64 runner (the smoke test would then need QEMU or a second machine, and aws-lc-rs plus 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 standard macos-15 is 3 cores and 7 GB); documenting the missing /proc only, with a WARN on every task (the log would repeat it for each attempt); macOS equivalents through sysctl / libproc (real work, for local development only); a Rust unit-test job on macos-15.

  • How a wheel is built (scripts/build-wheel.sh; CI jobs wheel and wheel-native, make smoke, make smoke-musl): one script for every wheel. Linux runs maturin build --release --locked inside a digest-pinned image (quay.io/pypa/manylinux2014_x86_64, manylinux2014_aarch64, musllinux_1_2_x86_64; tag 2026.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-init 1.29.1 checked against its published sha256, then only the channel in rust-toolchain.toml (rustup install --profile minimal --no-self-update from /tmp, so the file’s rustfmt, clippy and llvm-tools are not installed, and rustup stays that installer). RUSTUP_TOOLCHAIN is that channel. maturin 1.15.0 comes from scripts/maturin-requirements.txt (pip install --require-hashes; uv pip compile --generate-hashes, and on Python 3.14 maturin has no third-party dependencies). --locked keeps Cargo from re-resolving or rewriting Cargo.lock (the tree is mounted read-write). The compatibility tag is manylinux2014 or musllinux_1_2; patchelf comes from the image (the build stops if it is missing). macOS is the same without a container: rustup-init 1.29.1 for aarch64-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 in dist/. 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 job wheel, and the matrix checks wheel-linux-aarch64 and wheel-macos-arm64; make smoke locally 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 on PATH; then schedr dags check and schedr dags test on the example DAG, and schedr standalone on free ports with dags list, dags unpause, runs trigger --for ... and runs list until that run succeeds. The same script runs on each runner. Not part of make 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 as schedr --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 schedr package. 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 environment pypi that 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 in Cargo.toml and pyproject.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 a SHA256SUMS attached 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-server and ghcr.io/ptutak/schedr (decision 164) (x86_64, from the musllinux wheel; pushed with the workflow’s GITHUB_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 its appVersion, which a release sets to its version (scripts/release.py check refuses another; the user, 2026-11-02).

    • The licences a release carries (the user, 2026-11-02, before 0.1.0): LICENSE (schedr, MIT) and LICENSE-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 from Cargo.lock by scripts/third_party.py (make third-party), checked by make third-party-check in make check and 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 what cargo metadata gives); 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 is p.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, what make docs makes), deployed by the release workflow’s last job (actions/deploy-pages, environment github-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 without schedr-server (the user, 2026-11-02, after the rc pushed schedr-worker): one binary runs every role, so the image for anything that runs tasks (standalone, workers) is schedr, as it is locally and in the chart’s image, and schedr-server runs the master, the webserver and schedr ui. Not chosen: keeping schedr-worker (a standalone user wouldn’t look for it); also pushing schedr-standalone and schedr-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.ZrcN publishes to TestPyPI (environment testpypi, 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.yml called 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 in release.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.Z and X.Y, no latest (the user, 2026-11-02): in the preview a new minor needs a fresh database (decision 156), and a floating latest would move a deployment onto it. Not chosen: latest too; only X.Y.Z.

    • 163. The tree holds the version a tag names: 0.1.0-rc1 in Cargo.toml for v0.1.0rc1 (maturin writes 0.1.0rc1; the agent compares a runner’s version in that form; no dot after rc, which SchedrVersion would 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 environment testpypi or pypi by 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.source names 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

tokio 1.54.1

required by tonic and axum; 1.54.0 yanked (RUSTSEC-2026-0384); see below

gRPC

tonic + prost

see Master–worker protocol

REST

axum

tokio-native, the same stack as tonic

web UI templates

askama 0.16.1

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 crates/schedr-ui/assets/htmx.min.js

partial updates without a JavaScript build (decision 26A); from npm’s tarball, its sha512 integrity checked; the file’s sha256 d6fdc75f204e6bdefa99b69bf1e6d4ac69b8a364f77929f45c13476b4000f717 (M3.2b)

password hashes (basic auth)

bcrypt 0.19.3 (2026-07-27), base64 0.23.1 (already in the lock, for Basic credentials)

the hashes PROJECT.md’s basic mode keeps in a Secret; verification only (M3.5); brings blowfish 0.10.0, cipher 0.5.2, inout 0.2.5 (a 9-day patch on 0.2: meets the library-age rule)

making the users file (scripts/users-file.py)

Python bcrypt 5.0.0 (2025-09-25), the script’s own inline dependency (uv run --script), not the package’s

the name:bcrypt-hash lines and a Secret holding them, from names with passwords asked for or name:password lines on stdin (the user’s request, 2026-10-28); no htpasswd needed

HTML in tests

scraper 0.29.0 (dev only)

the UI’s pages read through a real HTML parser, by CSS selectors (M3.1)

OpenAPI from Rust types

utoipa

derives next to serde

Swagger UI

utoipa-swagger-ui 10.0.2 (axum, vendored: utoipa-swagger-ui-vendored 0.2.0)

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

schemars

see Rust/Python integration

database

sqlx (SQLite and Postgres), runtime-checked queries, migrations per backend

compile-time query! checking needs one backend

time and zones

jiff

explicit handling of DST gaps and overlaps

cron

croner (with its jiff support)

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

uuid (v7)

see Runs: identity

HTTP client (user CLI)

reqwest (rustls, system proxy)

tokio-native; honours HTTPS_PROXY / NO_PROXY (see Configuration: outgoing HTTP)

CLI

clap (derive)

standard

configuration

figment

file < env (SCHEDR_CONFIG__, __ nesting) < flags out of the box

logging

tracing + tracing-subscriber

see Observability

processes and signals

tokio::process (process_group), rustix

safe APIs only (unsafe_code = "forbid")

ignore files

ignore

gitignore semantics for .schedrignore, directory walking with symbolic links

content hashes

sha2

SHA-256 of DAG roots

metrics

prometheus-client

Prometheus’s own client: a registry per process, typed label sets; see Observability (M2.9)

TLS

rustls (aws-lc-rs provider, TLS 1.3), tokio-rustls; hyper-util and tower for the gRPC connector

see Master–worker protocol: mTLS (M2.7); rustls locked at 0.23.46

test certificates

rcgen (dev only, through schedr-tls’s testing feature)

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 run schedr itself) and python/tests/integration/. They run with make test-integration, part of make check and CI, and are not counted for the coverage floor (which measures the unit tests).

  • What they need is provided, never skipped: make test-integration starts a throwaway Postgres container (postgres:17.6-alpine, Podman when installed, else Docker; on a random local port, removed afterwards) and passes SCHEDR_TEST_POSTGRES_URL, and passes the Python with schedr installed as SCHEDR_TEST_PYTHON. Run without them, a test fails with a message saying how to run it. In CI the same tests run in their own integration job, with Postgres as a GitHub Actions service container (the same image) and the Python from uv sync; the rust and python jobs run the unit tests only (-E 'not kind(test)', python/tests/unit), as make test-rust / make test-python do.

  • Each test is isolated: its own temporary directories, its own database on the test server, free ports, and a schedr standalone of 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 standalone end 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_dag against the binary (failed runs, attempts, decoded outputs) and the examples/ 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 through LISTEN/NOTIFY, an unmigrated database refused, SIGTERM); the worker lifecycle on Postgres (a worker killed mid-task and started again: its attempt lost and retried; one that never returns: lost and 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; in schedr-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, /readyz and /metrics after a run, a master waiting for an unanswering database alive but not ready, standalone’s single ops port; a Postgres query past query_timeout stopped).

  • 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 in make check or 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 a start and an end line 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 -9 of 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 with SIGSTOP and 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 (@task chains 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 when main hasn’t changed since the last passing run; by hand with a profile and a name filter), and locally with make stress at 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) or full (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 with scripts/kind-standalone.sh, per milestone.

    • Services: make stress starts Postgres and PgBouncer (edoburu/pgbouncer v1.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 with pub, pub(crate) or pub(super) is tested.

  • Coverage floor: 85 % per language over the whole code base, private code included (reached through the public tests); make check and CI fail below it. Not counted: the test files themselves (src/**/tests.rs) and a binary’s main.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-cov with 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; one test_<module>.py per module (schedr/runner/protocol.py → tests/unit/schedr/runner/test_protocol.py). A package’s __init__.py is tested in test_init.py in 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.rs ends with #[cfg(test)] mod tests; and its tests are in src/scheduler/tests.rs (nested modules the same way: src/scheduler/fire_times/tests.rs; the crate root src/lib.rs has its tests in src/tests.rs). As a child module, it reaches pub(crate) / pub(super) items, which a crate’s tests/ folder (integration tests, public API only) can’t. Test code is compiled only for tests. Not chosen: a mod tests { … } block inside each source file (mixes code and tests in long files).

  • Tools:

    Language

    Tools

    Python

    pytest, pytest-cov

    Rust

    built-in #[test] run by cargo-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 (from rustdoc).

  • 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/, by cargo xtask docs-sources) share the numbers; a section’s index page stays index.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 docs builds from scratch: it empties site/, 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 in site/. 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 with literalinclude. A test imports each examples/docs/ file, checks that every with Dag(...) produces DAG JSON valid against schema/dag.schema.json, and runs every examples/docs/ file with run_dag. sync.py and daily_report.py already 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 in PROJECT.md (it mixes “how” with “why” in an already long file); rustdoc module comments only (no one place showing how the parts fit); one ARCHITECTURE.md split 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-sources into docs/_generated/04-reference/, so it can’t go stale:

    • Configuration: from the configuration’s JSON Schema (schedr_config::config_schema: JsonSchema and Serialize derived 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 help subcommands 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 (METRICS in the master’s, the agent’s and the API’s metrics.rs, PROCESS_METRICS in ops.rs; type schedr_model::metric_doc::MetricDoc). register takes 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 ```mermaid fences that GitHub draws too (sphinxcontrib-mermaid 2.1.1, myst_fence_as_directive; the browser loads mermaid.js 12.1.0, pinned in conf.py, from jsDelivr). Not chosen: Graphviz (needs dot in CI; GitHub doesn’t draw it); ASCII art (hard to keep readable).

  • PROJECT.md stays one file in the repository. The split into chapters is generated at build time by cargo 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-ignored docs/_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/: only conf.py, the index pages, Writing DAGs, the guide and the autosummary template. The documentation tools are a dev-only dependency group; the schedr package stays dependency-free.

  • Rust API: rustdoc (cargo doc --workspace --no-deps), copied into the site under rust/ 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’s D (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), and rustdoc::broken_intra_doc_links as 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 check runs everything CI runs: format check, clippy, ruff, mypy, the Rust tests (cargo nextest) and pytest, both with the coverage floor.

  • make check first cleans target/ when it holds more than TARGET_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 past WORKTREE_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 each target/ (a rebuild after a small change is slower). Not chosen: no debug line tables (backtraces lose their lines); one target/ shared by the worktrees (their parallel builds would wait for each other and rebuild each other’s crates).

  • make test-integration builds the test binaries, runs sync, 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 with fsync=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 the sync.

  • Pre-commit hooks run the same checks on commit.

  • CI: GitHub Actions: rust and python (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 as wheel-linux-aarch64 and wheel-macos-arm64; see Packaging and releases) and sdist. 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-toolchain is a commit on master (its moving v1 tag, the commit of 2026-10-16). The stable branch’s tip is one commit ahead of master and is outside master’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 moving stable channel. A master SHA has no default toolchain, and the action does not read rust-toolchain.toml, so each job sets toolchain: to the same release as the file.

  • Rust is that release: 1.99.1 (released 2026-10-16; 1.99.0 on 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.sh downloads rustup-init 1.29.1, checks it against the published sha256, and runs it with --default-toolchain none. It then reads channel from the file and runs rustup install --profile minimal --no-self-update from /tmp (in the repo, rustup would also install the file’s rustfmt, clippy and llvm-tools). RUSTUP_TOOLCHAIN is that channel, so a later rustc does not sync those components. Without --no-self-update the install replaces rustup itself. macOS uses the same installer for aarch64-apple-darwin, in a temporary cargo home. The checksums (archive dated 2026-09-01) are dda7234360b7f578ca8b0ddcb80145646fa61a67c1720a5abc7051b35c9fcb71 (x86_64-unknown-linux-gnu), 15f6e4ce9f583b929c996c91562bad6d4454f3281de858b02cdfdef615fac433 (aarch64-unknown-linux-gnu), 331228566cc931f32cd684f9bebc5956a5e5d7394c8d5de595f196a658ab98e6 (x86_64-unknown-linux-musl) and ec1b9233e7f72990ecd8e62063fa7f6c3dfc2bec8e97f88bff165f9100ac696a (aarch64-apple-darwin). The sdist job does not install Rust.

  • Tools, the same age rule as libraries. maturin 1.15.0 (2026-08-24) is scripts/maturin-requirements.txt for the wheel builds and the sdist job (pip install --require-hashes --only-binary=maturin; 14 hashes; on Python 3.14 maturin has no third-party dependencies). uv 0.13.5 (2026-10-22; 0.13.0 on 2026-10-09) is setup-uv’s version, plus checksum of uv-x86_64-unknown-linux-gnu.tar.gz (f68d291c75783122dad58ab77def0e13f3233f358731db5d6d7e8715603b928f). setup-uv stays v4.2.0: that release hashes the tarball when checksum is 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 turns enable-cache on by default and is six majors newer. Every setup-uv job is ubuntu-latest, so one hash covers them. cargo-nextest 0.9.149 (2026-10-20) and cargo-llvm-cov 0.9.1 (2026-09-06; 0.9.0 on 2026-08-16) on install-action’s tool input. Helm stays v4.3.0 (2026-09-09; it is that minor’s x.y.0 and qualifies). v4.3.1 (2026-10-15) also qualifies and was left, because CI already pinned v4.3.0. Python stays 3.14.

  • Images are digest-pinned (name@sha256:<64 hex>), the same age rule. Wheel builds (scripts/build-wheel.sh), tag 2026.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-alpine created 2025-10-15 (sha256:ef257d85f76e48da1c64832459b59fcaba1a4dac97bf5d7450c77753542eee94), pgbouncer:v1.26.0-p0 created 2026-09-30 (sha256:b17551c776ef7e5769ef80b956d20f85e2fd25dd8912d31d58f782aad495b711), python:3.14.8-alpine3.24 created 2026-10-01 (sha256:f6a589d43c42b9e7f7dc67a12d37132491f362859a5d750607710cc56da3bc72), alpine:3.24 created 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.sh uses the postgres digest and scripts/kind-standalone.sh the alpine digest.

  • Actions (the release the floating tag resolved to): checkout v4.4.0 (2026-07-20), rust-cache v2.9.3 (2026-10-20), install-action v2.87.31 (2026-10-23), setup-uv v4.2.0 (2024-11-30), setup-python v5.6.0 (2025-04-24), upload-artifact v4.6.2 (2025-03-19), setup-helm v5.0.1 (2026-06-23).

  • make pin-check is part of make check. It runs uv run --no-sync python scripts/check-action-pins.py and does not sync: a local uv sync once removed packages already installed. PyYAML 6.0.3 is a direct dev dependency (it was already locked, through pre-commit). The rust job 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 runs make pin-check. The checker parses workflow YAML and .github/actions/**/action.yml. It fails if a uses: is not a 40-character SHA, a local ./... action or reusable workflow, or docker://image@sha256:<64 hex>; if dtolnay/rust-toolchain has no toolchain: or that input differs from the file; if a rust-toolchain: input differs from the file; if install-action’s tool: lacks @version or setup-uv / setup-helm’s version: is not x.y.z; if an image in a workflow (including container: and services), scripts/*.sh, the Makefile, images/**/Dockerfile or examples/kubernetes/Dockerfile is not digest-pinned (no tag is implicit :latest); or if scripts/maturin-requirements.txt is missing a sha256 hash. The error names the file and line. The example Dockerfile’s FROM ${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.