Skip to content

Architecture Build CI and Release

James Dunkerley edited this page Dec 3, 2026 · 4 revisions

Build, CI and release

Home · Architecture

Written against d5aad1f44 on 19 Nov 2026.

In short. Every task is a make target: the root Makefile spans the subprojects and each subproject has its own. A change must pass make check at the root. One pre-commit hook covers the whole repository and runs from the main checkout's backend/.venv, which is the source of the set-up traps below. CI is one workflow per subproject, filtered by path, so only the unfiltered Lint and Secret scan workflows can be required checks. Everything that ships is built from one wheel, tz-ps-conductor: it is installed on a laptop, into the Docker image, and into the desktop app's bundled Python. Releases are GitHub releases, made by a nightly workflow and by a manual one for release candidates, betas and stable releases.

frontend-next/ holds the redesign of the app. It is built beside frontend/ and will be merged into it once it reaches feature parity, so this wiki describes one frontend. Until then make dev also serves it on port 5173, and it has its own Makefile and CI workflows, which the tables below list.

Set-up from a clean clone

Prerequisites

Tool Why
Git, GNU Make, bash, curl Every task is a make target over bash scripts; the secret-scan hook fetches its binary with curl. On Windows use Git Bash with a separately installed make, or WSL
uv Manages the backend's Python (3.13, from backend/.python-version), virtual environment and dependencies
Node 24 or later, pnpm 12 The three frontend packages declare engines.node >=24; desktop/ alone also accepts 22.18
Docker Optional: the image, and the visual end-to-end baselines
Java Only for make -C backend grammar and grammar-check

Install and run

git clone https://github.com/transition-zero/tz-ps-conductor.git
cd tz-ps-conductor
make install    # every subproject, and the git hook
make dev        # backend :8080, frontend :3000, frontend-next :5173; stays in the foreground

make dev leaves the backend's environment cut down to what the API needs (see the traps below). After stopping the servers, restore it before running the gate:

make -C backend install    # in the main checkout: the full environment and the hook
make check                 # the gate a change must pass
  • make install runs uv sync --all-packages --all-extras in backend/, installs the pre-commit hook, then runs pnpm install in frontend-sdk/, frontend/, frontend-next/ and desktop/. Run the whole thing even to work on one side: the backend half is what installs the hook.
  • make dev starts three servers. Open http://localhost:3000 (or :5173 for the redesign). Each frontend proxies /api to the backend; port 8080 serves the API alone.
  • The dev backend stores its data under .context/ in the checkout, not in ~/tz-ps-conductor, so two checkouts or worktrees never share a warehouse (backend/scripts/serve.sh).
  • make dev CALLIOPE=1 adds the Calliope framework.
  • After a change to contracts/openapi run make -C frontend-sdk api; after one to contracts/grammar run make -C frontend-sdk grammar. See HTTP API and contracts.
  • To run the shipped shape, make bundle copies the built frontend into backend/libs/tz_ps_app/src/tz_ps_app/static, and tz-ps-conductor serve then serves the app and the API from one process.

The pre-commit and worktree traps

There is one git hook for the repository, and every worktree runs it from the main checkout's backend/.venv. Three things follow.

  1. make dev breaks commits. make dev and make -C backend serve run uv sync --package tz-ps-http --no-dev. uv's sync is exact, so it removes the dev group, and pre-commit with it. Every commit in every worktree then fails with "No module named pre_commit". Any sync with --no-dev, --only-group or --package <member> does the same. To put it back, run make -C backend install in the main checkout.
  2. Do not run make install in a worktree. It repoints the hook at that worktree's venv, and removing the worktree can then block commits in every checkout. In a worktree, run uv sync --all-packages --all-extras in backend/, then make -C <dir> install for frontend-sdk, frontend, frontend-next and desktop.
  3. Check that a commit landed. A hook that reformats writes its fix to the working tree and aborts the commit, and a later git push then reports success for the previous head. After committing, git status --short must be empty and git log --oneline -1 must be your commit.

The Biome hooks run through pnpm exec, so they need pnpm install in their package first.

Make targets

The root Makefile holds only targets that span subprojects and delegates to them.

Root target Does
install Every subproject's install, and the hook
dev The backend and the frontend dev servers; Ctrl-C stops them all
lint Every pre-commit hook over all files, then each pnpm package's own lint
test Every subproject's unit tests
check lint, test, the SDK's drift and lock-check, then typecheck and build for each pnpm package, and mocks-check for frontend/
bundle Builds frontend/ and copies it into tz_ps_app/static
e2e bundle, then the Playwright journeys of frontend/
docker-postgresql, docker-postgresql-stop The PostgreSQL image against a PostgreSQL 18 container
Subproject Targets worth knowing
backend/ install, serve, lint, lint-imports, test, test-bdd, test-bdd-postgresql, coverage, maintainability, mutation-check; generators with a -check twin: registry, calliope-registry, models, grammar, release-manifest, template-references; release VERSION=…, release-smoke
frontend/ dev, build, preview, lint, lint-fix, typecheck, test, coverage, routes, check, mocks-check, e2e, e2e-visual, e2e-update-snapshots, a11y-audit
frontend-next/ dev, build, lint, lint-fix, extract, typecheck, test, routes, check, e2e
frontend-sdk/ api, grammar, refresh, drift, lock-check, lint, typecheck, test, check
desktop/ build, start, payload, package, lint, typecheck, test (plain Node), smoke (through Electron, against a real backend), check

Pre-commit hooks

All hooks are in the root .pre-commit-config.yaml.

Hook Runs on Does
trailing-whitespace, end-of-file-fixer, check-yaml, check-toml, check-merge-conflict, check-added-large-files All files Hygiene
check-action-pins Workflow files ci_scripts/check_action_pins.sh: every action is pinned to a commit SHA
trufflehog Staged files ci_scripts/trufflehog.sh: secret scan with a pinned TruffleHog, fetched to a user cache on first use
backend-ruff-check, backend-ruff-format, backend-mypy backend/**/*.py Lint with fixes, format, type-check
mypy-notebooks, nbstripout Notebooks in backend/ and docs/ Type-check the listed notebooks, strip outputs
backend-import-linter Backend Python and pyproject.toml The package-boundary contracts
backend-acceptance-layers Acceptance features and DSL tests/acceptance/check_layers.py
frontend-biome, frontend-sdk-biome, frontend-next-biome, desktop-biome Each pnpm package biome check --write
pr-steward-tests .claude/skills/pr-steward/ The bash tests of the skill's scripts

A real credential that a scan flags is compromised: rotate or revoke it, then remove it. A false positive is suppressed in .trufflehogignore, whose header says how.

Continuous integration

Rules every workflow follows

These are in .github/CLAUDE.md and hold in the YAML.

  • A subproject's workflow has a paths: filter, with that subproject's Markdown negated, so a docs-only change starts none of them. The unfiltered lint.yml and secret-scan.yml still run, and backend.yml also watches docs/examples/.
  • A path-filtered job is never a required check, because a pull request that misses the filter would wait on it for ever. Only lint.yml and secret-scan.yml have no filter, so by this rule only they may be required. The repository's actual branch rules were not verified.
  • pull_request has no branches: filter. A stack merges rung by rung into the branch below, so a filter on main would test the bottom rung alone. push runs on main only.
  • The draft guard. A draft pull request onto a feature branch skips the guarded jobs, which are the test matrices and most checks; a draft onto main, and any ready pull request, runs them. ready_for_review is in types: so that marking a draft ready starts CI. Three backend jobs carry no guard and run on any draft that touches their paths: versions and the two registry drift jobs. pr-steward-promote.yml exists to act on a draft.
  • No workflow names a Python version. backend/ci_scripts/python_versions.py reads it from requires-python.
  • Every action is pinned to a commit SHA, checked by lint-actions.yml and the pre-commit hook.

What a pull request runs

This diagram shows which workflows a pull request or a push to main starts, by the paths it touches, and the scheduled workflows.

flowchart TB
  PR["pull request, or push to main"] --> LINT["lint.yml<br/>make lint"]
  PR --> SEC["secret-scan.yml<br/>TruffleHog"]
  PR -->|"workflow files"| PINS["lint-actions.yml"]
  PR -->|"backend, contracts, docs/examples"| BE["backend.yml"]
  BE --> BT["backend-tests.yml<br/>reusable test jobs"]
  BE --> DR["drift checks and maintainability report"]
  PR -->|"frontend, frontend-sdk, contracts"| FE["frontend.yml"]
  PR -->|"frontend-sdk, contracts, app lockfiles"| SDK["frontend-sdk.yml"]
  PR -->|"frontend-next, frontend-sdk, contracts"| FN["frontend-next.yml"]
  PR -->|"frontend-next, backend"| FNE["frontend-next-e2e.yml"]
  PR -->|"backend, frontend, frontend-sdk, contracts"| E2E["e2e.yml"]
  PR -->|"desktop"| DK["desktop.yml"]
  CRON["schedules"] --> NR["nightly-release.yml<br/>03.00 UTC daily"]
  CRON --> A11Y["a11y-audit.yml<br/>04.30 UTC daily"]
  CRON --> MUT["mutation-tests.yml<br/>Wednesdays"]
Loading

The workflows

Workflow Starts on Runs
lint.yml Every pull request and push to main Installs the backend and all four pnpm packages, then the root make lint: every pre-commit hook, Biome for each package, and the Lingui catalogue check
secret-scan.yml Every pull request and push to main TruffleHog over the change
lint-actions.yml Workflow files The SHA-pin check
backend.yml backend/, contracts/, docs/examples/ The backend tests on Linux with the oldest supported Python, through backend-tests.yml; the PyPSA and Calliope registry drift and narrowing checks; the release-manifest check; the grammar drift check; a maintainability report as a sticky comment
backend-tests.yml Called by backend.yml and nightly-release.yml The unit suites (libs and tests, two shards each); the acceptance scenarios on git and SQLite (four shards), on PostgreSQL (four shards, Linux) and through the Python API (Linux); the Calliope tests in a shard of their own, on one leg only; the memory tests only when the caller asks
frontend.yml frontend/, frontend-sdk/, contracts/ Typecheck, build, mocks-check, a diff of the committed route tree, and Vitest in three shards
frontend-sdk.yml frontend-sdk/, contracts/, both apps' lockfiles make drift (regenerate the client and parser and compare), lock-check, typecheck, lint, test
frontend-next.yml frontend-next/, frontend-sdk/, contracts/ Typecheck, test, build, route-tree diff
frontend-next-e2e.yml frontend-next/, backend/ Playwright against vite preview and a real backend
e2e.yml backend/, frontend/, frontend-sdk/, contracts/, the root Makefile Playwright, inside the image frontend/e2e/Dockerfile names, against the bundled app on a real backend
desktop.yml desktop/; called by the release workflows On Windows, Ubuntu 22.04 and the self-hosted Mac: the Node tests, the payload, the installer, a check that the update metadata is for the version's channel, a smoke test of the packaged app, and on Windows and Linux an in-place update to a next version from a local feed
build-wheel.yml Called by the release workflows Bundles the frontend, checks the release manifest, builds the wheel and sdist, smoke-tests the wheel in a fresh virtualenv
release.yml, nightly-release.yml, deploy-pages.yml See Releases
a11y-audit.yml Daily Lighthouse's accessibility audit of the served app, light and dark; opens, updates or closes the issue labelled a11y-audit
mutation-tests.yml Weekly mutmut on each backend package through backend/ci_scripts/mutation_kit; a report, never a failure for surviving mutants
pr-steward-promote.yml The label steward:promote Marks a draft ready for the PR steward
sienna-runtime.yml Manual A placeholder so the trigger exists on main

The suites themselves are described on Testing philosophy and Testing review.

Platforms. A pull request tests the backend on Linux with the oldest supported Python only. Windows, macOS and the newer Python run in the nightly, where they gate the nightly release. A pull request from this repository labelled windows or macos adds that leg. The Mac is one self-hosted runner, and a pull request from a fork never reaches it: its desktop.yml run builds on Windows and Ubuntu only.

What gates a merge

By the path-filter rule only Lint and Secret scan may be required checks. The rest is a convention in the root CLAUDE.md: a rung merges once it has a person's approval, at least one CodeRabbit review, green CI and no open threads. A stack merges bottom-up, main comes into a pull request under review by merge rather than rebase, and a pull request is pushed once all its open comments are answered, not fix by fix.

Dependabot (.github/dependabot.yml) watches GitHub Actions, the root Dockerfile, backend/, frontend/, frontend-sdk/, desktop/ and frontend/e2e/Dockerfile. It does not watch frontend-next/.

What ships

One wheel

The backend is a uv workspace of many packages, but one distribution is published: tz-ps-conductor. backend/ci_scripts/generate_release_manifest.py folds every shipped member's pyproject.toml into the generated, committed backend/release/pyproject.toml: their third-party dependencies, entry points, scripts and packages. The test helpers and the three Calliope packages are left out, and postgresql is the one extra the wheel offers. make -C backend release-manifest-check fails when the committed manifest is stale.

make -C backend release VERSION=X.Y.Z stages a copy with the version stamped in and runs uv build. The frontend is inside the wheel only if the root make bundle ran first.

This diagram shows how the one wheel reaches each deployment shape.

flowchart TB
  FE["frontend build"] -->|"make bundle"| ST["tz_ps_app/static"]
  WS["backend workspace members"] -->|"release manifest"| WH["tz-ps-conductor wheel"]
  ST --> WH
  WH --> L["Laptop<br/>uv tool install, then tz-ps-conductor serve<br/>git and SQLite under ~/tz-ps-conductor"]
  WH --> DG["Docker image, DATABASE=git<br/>git warehouse under /data"]
  WH --> DP["Docker image, DATABASE=postgresql<br/>external PostgreSQL, files under /data"]
  WH --> PY["Desktop payload<br/>standalone Python 3.13 beside the Electron app"]
Loading

The Docker image

The root Dockerfile has three stages, each on a digest-pinned base.

  1. frontend: Node and pnpm; copies contracts, frontend-sdk and frontend; runs make bundle.
  2. wheel: uv with Python 3.13; uv sync --locked, the manifest check, then make -C backend release with the build argument VERSION (default 0.0.0+local).
  3. Runtime: a slim Python 3.13 image that installs the wheel alone and runs as the unprivileged user 10001:10001, with /data as its volume and port 8080.

The build argument DATABASE chooses the warehouse's database, and is the only one the image installs.

DATABASE Image holds Config Starts with
git (default) git, with /data marked a safe directory deploy/config.git.json: warehouse_kind GIT Nothing more; mount storage at /data
postgresql The wheel's postgresql extra and DuckDB's postgres extension; no git deploy/config.postgresql.json: warehouse_kind POSTGRESQL, no database named A replacement config naming storage.warehouse_settings.url, and PGPASSWORD

Any other value stops the build. Both configs keep storage under /data, listen on 0.0.0.0:8080, and log to the console and to /data/logs. TZ_PS_CONDUCTOR_CONFIG points at the config; mount another file, or pass JSON in that variable, to replace it.

deploy/entrypoint.sh checks two things before it starts the server: that TZ_PS_CONDUCTOR_MODE is app (the default, tz-ps-conductor serve --no-open) or api (tz-ps-http, the API alone), and that /data is writable. It then execs the server so it is PID 1 and receives the container's SIGTERM. The storage back ends are on Storage.

make docker-postgresql tries the PostgreSQL image locally: scripts/docker-postgresql.sh starts a postgres:18 container, builds the image and serves it on port 8080.

The desktop payload

The desktop app carries a standalone Python with the same wheel installed. desktop/scripts/payload.ts builds it, and desktop.yml builds one installer per OS. The shell itself is on Frontends and the desktop app.

Releases

A release is a GitHub release of this repository. It carries the wheel, the sdist, and for each OS the installer, its blockmap and electron-updater's metadata file. The desktop app reads that metadata from the release, so the release is the update feed.

This diagram shows the nightly workflow and the manual release workflow, and the update channel each kind of release feeds.

flowchart TB
  subgraph Nightly["nightly-release.yml, daily from main"]
    N1["Plan the version, skip if main has not moved"] --> N2["Backend tests on Linux, Windows and the Mac"]
    N2 -->|"all pass"| N3["build-wheel.yml"]
    N2 -->|"a failure, or the Mac offline"| N9["Open or update the nightly-tests issue, release nothing"]
    N3 --> N4["desktop.yml"]
    N4 --> N5["Publish the nightly pre-release"]
    N5 --> N6["Post to Slack, keep the newest 7"]
  end
  subgraph Manual["release.yml, started by hand"]
    R1["Plan the version from the tags"] --> R2["build-wheel.yml"]
    R2 --> R3["desktop.yml"]
    R3 --> R4{"prerelease input"}
    R4 -->|"rc or beta, from any branch"| R5["Publish a pre-release"]
    R4 -->|"none, from main only"| R6["Publish the release, marked Latest"]
    R6 --> R7["Delete that version's rc and beta releases"]
    R6 --> R8["deploy-pages.yml"]
  end
  N5 --> CN["Nightly channel"]
  R5 --> CP["Release Candidate or Beta channel"]
  R6 --> CS["Stable channel, and the web app's update banner"]
Loading
Kind Started by Tag Wheel version Metadata files
Nightly Schedule, 03:00 UTC, from main vX.Y.(Z+1)-nightly.YYYYMMDD X.Y.(Z+1).devYYYYMMDD nightly*.yml, and copies named latest*.yml for older apps
Release candidate release.yml with prerelease=rc, any branch vX.Y.Z-rc.N X.Y.ZrcN rc*.yml
Beta release.yml with prerelease=beta, any branch vX.Y.Z-beta.N X.Y.ZbN beta*.yml
Stable release.yml, from main only vX.Y.Z X.Y.Z latest*.yml

How the versions are planned:

  • release.yml takes bump (major, minor or patch). backend/ci_scripts/release_plan.py bumps the newest release tag, and numbers a pre-release on from the last of its label on that version: after v1.2.3, bump=minor prerelease=rc gives v1.3.0-rc.1, then v1.3.0-rc.2, and a later bump=minor with no pre-release gives v1.3.0.
  • A nightly follows the newest release by one patch. Its tag and its wheel version sort after X.Y.Z and before X.Y.(Z+1).

What both workflows guarantee:

  • No tag without the builds. The job that creates the tag and the release depends on the wheel and on the desktop builds chosen for that run, so a failed build leaves no tag. Pruning, the Pages deploy and the Slack post follow publishing.
  • The Mac is checked first. release.yml asks for the macOS build, and desktop.yml fails its runner check when the self-hosted Mac is offline, so nothing is released. The nightly stops earlier, at its test gate.
  • Only the nightly runs the backend test suite. release.yml builds and smoke-tests the wheel and the desktop apps, and does not run the cross-platform backend tests first.
  • One at a time. Each workflow has a concurrency group, since two runs would compute the same version from the same tags.
  • A dry run. dry_run=true builds and smoke-tests everything from any branch and publishes nothing; the artefacts are kept for 14 days.
  • Pruning. A stable release deletes its own release candidates and betas with their tags, and the nightly keeps the newest seven nightlies.

The nightly is also the cross-platform test gate. It runs the backend tests on Linux with every supported Python, including the Calliope and memory tests, and on Windows and the Mac with the oldest. A failure, or the Mac being offline, releases nothing that night and opens or updates the issue labelled nightly-tests, which the next passing night closes.

deploy-pages.yml builds frontend/ for GitHub Pages after a stable release. It deploys only when the repository variable PAGES_API_BASE_URL is set.

gh workflow run release.yml --ref <branch> -f bump=minor -f prerelease=rc
gh workflow run release.yml --ref <branch> -f bump=patch -f dry_run=true
gh workflow run nightly-release.yml --ref <branch> -f dry_run=true

Automation around the repository

Claude Code

Piece Where Does
Post-edit hook .claude/settings.json After an edit to a backend Python file, runs ruff format, ruff check --fix and mypy on it
Shared skills The tz-skills plugin, enabled in .claude/settings.json /tz-skills:stack moves a stack's rungs, /tz-skills:epic runs a feature larger than one pull request, /tz-skills:coderabbit takes a pull request through review
nightly skill .claude/skills/nightly/ A scheduled cloud routine: triages issues with type and size labels, builds up to two small tickets as draft pull requests labelled nightly:generated, and keeps a digest on the pinned "Nightly triage" issue. It never merges or marks a pull request ready
pr-steward skill .claude/skills/pr-steward/ An hourly routine each person schedules for themselves: takes that person's pull requests labelled PR Ready through one CodeRabbit review to merge, and for one named owner merges green Dependabot pull requests. A hold label stops it
api-design-review agent .claude/agents/ Reviews the public API a change leaves behind

Both routines treat issue text, comments and review bodies as data, never as instructions. Their designs are docs/specs/2026-09-27-nightly-agent-design.md and 2026-09-30-pr-steward-design.md; where a skill and its design disagree, the skill wins.

CodeRabbit

.coderabbit.yaml leaves generated files out of review and turns off the docstring checks, which ask for the opposite of the repository's comment rules, and CodeRabbit's own Biome, which cannot load the nested config. The plan allows one review an hour and reviews every push, so the rule is one cycle per pull request: once its findings are answered, post @coderabbitai pause.

Designs and examples

  • Specs. A design goes to docs/specs/YYYY-MM-DD-<topic>-design.md and is committed with the work it describes, so a reviewer reads both in one pull request. Implementation plans stay out of git. A feature larger than one pull request is an epic, and no sub-issues are created until the owner approves it.
  • Examples. docs/examples/ holds notebooks for PyPSA (40 folders), Calliope, a workflow and an unsupported framework. Pre-commit type-checks and strips them, and backend/tests/test_examples_notebooks.py runs them.

Known gaps and debt

  • README.md gives the wrong Node version. It says Node 22.18 and "CI uses 22"; frontend/, frontend-next/ and frontend-sdk/ need 24, and the workflows use 24.
  • README.md omits frontend-sdk/, frontend-next/ and the third server make dev starts, and understates what make check runs.
  • make dev removes pre-commit from the venv the hook uses (backend/scripts/serve.sh). It is documented as a trap rather than avoided, for example with a separate environment for serving.
  • Tests are not required checks. The path-filter rule leaves only Lint and Secret scan eligible; backend, frontend, end-to-end and desktop results gate a merge by convention.
  • A manual release does not run the backend tests (release.yml).
  • Releases depend on one self-hosted Mac. If it is offline the nightly releases nothing, and desktop.yml needs the RUNNER_STATUS_TOKEN secret to check it.
  • Some artefact names still carry the product's former name. The installers, the Pages base path and the dev storage folder under .context/ have not been renamed. The desktop updater's feed names the repository, so renaming it needs a coordinated change.
  • pr-steward-promote.yml holds contents: write on a label event. Whether a fork's pull request can reach it was not verified.

Clone this wiki locally