Skip to content

Development and Governance

Dmitri Chudinov edited this page Aug 28, 2026 · 1 revision

Development and governance

How work is done here, and how the codebase is kept from rotting. Mess is not prevented by intention; it is prevented by CI failing.


1. The rules that hold everywhere

From CLAUDE.md, which is the standing instruction for anyone — human or agent — working in this repository.

Never invent a number the farm did not measure

ADR-0007 is written about drivers and governs the whole system. Each of these has already been got wrong once:

  • A null reading is "not measured", not 0.
  • An hour with no telemetry is not an idle hour.
  • An unknown id must 404, not answer an empty grid — an all-null response reads as "this thing did nothing".
  • A denominator must be what was observed, never the roster. Otherwise the worse the coverage, the healthier the farm looks, and the error is silent and flattering.

Money is the same rule in different clothes: VIEW_FINANCIALS is kept separate from every production permission, so a response carrying seconds must not quietly start carrying rubles or kilowatt-hours.

A feature is done when a test proves it

And the corollary: the irreversible path is the one that most needs a test. The retention clamp passed all six gates while untested, because gates check shape and a test checks behaviour.

How code is written here

Read a neighbouring file before writing a new one. This codebase is unusually prose-heavy on purpose: comments explain why a decision was made, what the alternative was, and what it cost. A comment restating the line above it is noise; one naming the failure the line prevents is the point.

Put the explanation where the reader will be standing when they need it — not in a commit message they will not be reading.

Prefer removing the cause to silencing the symptom

pydantic-core was pinned in constraints.txt when pydantic already fixes it exactly, so Dependabot could raise one without the other into a state no resolver could satisfy. The fix was deleting the redundant pin, not adding an ignore. An ignore, a noqa or a skipped test hides a thing that will come back.

Verify, then say so

Report what happened, not what should have happened. If a check did not run, say it did not run. If tests fail, quote the output. "Should work" is not a result — and an agent's report of its own success is not evidence, so reproduce it.


2. The six gates

They run in CI on every push, before a single test does, so a structural regression fails fast and unambiguously. Each one encodes a specific way this kind of system rots.

Gate What it prevents
ruff check / ruff format --check Style drift; naive datetimes; print in library code
mypy --strict Untyped seams between contexts
lint-imports Layer violations; pricing purity (ADR-0002); drivers depending on contexts
tools/check_context_isolation.py One context reaching into another's models or service
tools/check_file_length.py The 1 096-line service. The limit is 400 lines
alembic check Migrations drifting from the ORM models (ADR-0008)

Two more run only in the release gate, because they are about the deployment rather than the source tree:

Gate What it prevents
python -m printorian.workers --check A worker container that is running and not sweeping
tools/relay_probe.py Live events not crossing the process boundary — the Redis URL, channel and network between the containers are properties of the arrangement, not of the code

3. What CI actually proves

Three jobs, and the third is the one that matters.

backend — the six gates, then tests on real PostgreSQL (ADR-0021), migrations applied from scratch, and alembic check. Also a pip-audit dependency audit. It exports the OpenAPI schema as an artifact.

frontend — the API client is generated from the schema the backend job exported and never committed (ADR-0005). That is what makes a breaking backend change fail the build at the commit that caused it, rather than in somebody's editor a week later. Then types, lint, tests, and an npm audit.

image — the two jobs above test the source tree. Nothing there proves the thing that actually ships works: a missing system library, a wrong entrypoint, a migration that only runs with a dev dependency present, a base image that moved underneath us. So this job builds the images and then runs them, against the same deploy/compose.prod.yml the farm uses:

  • migrations forwards, backwards and forwards again,
  • readiness reporting its dependencies,
  • the console's same-origin proxy,
  • every worker loop proven to be sweeping rather than merely running,
  • a live event raised in one container proven to reach the other.

Only then does it scan, SBOM, push and sign — cosign keyless, via the job's OIDC identity, so there is no key to store, rotate or lose.

4. Documents that fail CI when they go stale

Three inventories are checked against the code rather than trusted:

Document Checked against
DATABASE-REVIEW §1 — the table list __tablename__ declarations
DESIGN-KIT §1 — the screen list the console's routes
DESIGN-KIT §4 — endpoints with no consumer the OpenAPI schema plus the frontend's client calls

Each gate was proven to fail before being trusted — nine mutations, every one caught with a message naming the entry that drifted.

5. Where open work lives

In GitHub issues, and nowhere else.

A document says what the system is. The tracker says what is missing.

Before this rule there were four places describing outstanding work, and they disagreed with each other and with the code. That is the specific failure this repository has already paid for three times.

Labels

Type: type:bug · type:task · type:docs · type:security

Area: area:backend · area:frontend · area:database · area:infra · area:ci · area:drivers · area:docs · area:design-kit

Priority — about consequence, not effort:

P0 An irreversible path is unguarded, or the farm is losing data now
P1 Blocks other work, or a stated guarantee is not holding
P2 Real, scheduled, not urgent
P3 Housekeeping

State: blocked:hardware · blocked:external · needs-person · deferred · drift

deferred issues stay open. That is the point of them: an open issue with a written trigger is a tripwire, and closing it as wontfix throws the trigger away. They are excluded from milestones so they do not read as scheduled work.

What closes an issue

  • A bug closes when a test fails without the fix and passes with it. The issue names that test. "Could not reproduce" closes it as invalid with what was tried, not silently.
  • A task closes when its own "Done when" is demonstrated. If that criterion turned out wrong, amend it in the issue before closing, so the record says what was actually delivered.
  • A docs issue closes when the correction is merged and the same change says how the claim was verified. A status corrected from another document rather than from the code has only moved the drift.
  • A deferred issue closes only when its trigger fires and the work is done, or when the trigger becomes impossible. Not when it gets old.

Reference the issue from the pull request (Closes #12), not the other way round, so the merge does the closing and there is no second step to forget.

Irreversible paths are triaged first — retention drops, WAL archiving, backup, migrations, refunds, provisioning. These are where a defect cannot be walked back, and where this repository has already been bitten by a change that passed all six gates untested.

Filing something new

  1. Check it against the code, not against a document. Half of the first backlog written for this tracker was work the documents said was outstanding and the code showed was finished.
  2. Search first.
  3. Say where the expectation comes from — an ADR, a doc section, a screen in the kit, a scenario line. An issue whose expectation is only the filer's assumption is a design question and should be asked as one.

6. Testing layout

Path Purpose
tests/unit/ Context logic — money, permissions, identity, rollups
tests/api/ HTTP behaviour, especially the authorization boundary
tests/contract/ The contract every printer driver must satisfy
tests/scenarios/ Named end-to-end business paths
tests/virtualfarm/ End-to-end farm runs against mock printers
tests/test_migrations.py Real Alembic against real PostgreSQL

The virtual farm was built in Phase 0, before the features it tests. It is what lets the scheduler and the order pipeline be developed and regression-tested without hardware, and it is what makes a silently-simulating connector impossible to ship: simulation has a name, a driver, and a refusal to load in production.

It is deterministic — it advances a FixedClock rather than sleeping, so a farm-day of printing runs in milliseconds and never flakes.

7. Other governance rules

Rule Enforcement
No second pricing or scheduling implementation Code-owner review on those two contexts
The API client is never hand-edited Generated in CI; a diff fails the build
A feature marked done has a test The PR template requires the reference
Every driver has contract tests A driver without fixtures does not merge
The virtual-farm E2E passes A gate on every PR

8. For an agent session

  1. Read HANDOFF.md first, and update it before finishing. It carries what a tracker is bad at: what a change cost, what was tried and rejected, and which invariant not to break.
  2. Take work from an issue, not from a document. Where an issue and a document disagree, the issue is right.
  3. Do not close an issue on your own report of success. Reproduce it and paste what the reproduction printed.
  4. If an issue describes something already built, do not just close it. File the drift issue for whichever document said it was missing — the stale document is the defect, the issue was only a symptom.
  5. Check git status first. Agent work has been interrupted mid-write more than once, leaving a tree that compiles, passes lint, and has no test for the part that matters.

Area rules load with the area: backend/CLAUDE.md and frontend/CLAUDE.md.

Related

Clone this wiki locally