Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/agents/server-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Integrity of the server test suite itself. Use to check that a test
tools: Read, Glob, Grep, Bash, Edit, Write
---

You own `server/tests/`. 3916 tests; `pytest -q -n auto`, bare, is exactly what CI runs.
You own `server/tests/`. 3926 tests; `pytest -q -n auto`, bare, is exactly what CI runs.
Not `python -m pytest` for the gate:
the `-m` form puts the current directory on `sys.path`, so a test that leans on it passes
here and fails at collection on CI (`CLAUDE.md`, «Commands»; #310, #314).
Expand Down
1 change: 1 addition & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Bash(pytest)",
"Bash(python -m mypy *)",
"Bash(python -m mypy)",
"Bash(python -m scripts.check_openapi_v1 --pull-request)",
"Bash(python scripts/check_test_counts.py *)",
"Bash(python ../server/scripts/check_test_counts.py *)",
"Bash(git status *)",
Expand Down
4 changes: 2 additions & 2 deletions .claude/skills/gates/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that happens and names both trees (#312).
after ruff — the owner asked for it through that day's audit (#210) — and still worth
running before a push: seconds here, minutes there. It is the thing that reproduces the
«🗓 Четверти» crash.
3. `pytest -q -n auto`, bare, from `server/` with its venv active — 3916 tests today, six of
3. `pytest -q -n auto`, bare, from `server/` with its venv active — 3926 tests today, six of
them skipped unless a host is running (`-m host`, CI's «Host» job), plus eleven
PostgreSQL-only lock checks skipped on SQLite, and
**the exact command CI runs**. Not `python -m pytest`: the `-m` form puts the current
Expand All @@ -44,7 +44,7 @@ Narrower while iterating: `python -m pytest -q tests/test_schedule.py -k parity`

## Android, from `android/`

1. `./gradlew test` — all JVM unit tests across the six modules, 2232 today.
1. `./gradlew test` — all JVM unit tests across the six modules, 2246 today.
2. `./gradlew assembleDebug`
3. `./gradlew assembleRelease` — **not optional.** CI builds both on every push, because R8
and resource shrinking are where "worked in debug" stops being true.
Expand Down
26 changes: 20 additions & 6 deletions .claude/skills/migration/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ description: Write and apply an Alembic revision for this project — including

Head is **`0019`**. Nothing after `0001` may use `create_all`.

The [Alembic revision history](../../../docs/history.md#the-alembic-chain-through-0019)
records why each revision was written and how it was applied.

## 1. Decide the direction

- **Additive** (a new column, table, index, nullable default) → run it **before** the merge.
Expand All @@ -18,9 +21,9 @@ Head is **`0019`**. Nothing after `0001` may use `create_all`.
breaks against the constraint, with an `IntegrityError` nobody catches. Write the service
so it is correct with or without the constraint, so the window behaves like production did
before. `0013` is this shape and says so in its own docstring.
- **A rewrite of a key** (rows moved from one key to another, no schema change) → **free**
where there are no rows to move, so it goes on with the additive revisions; **after** the
merge where there are. Old and new code file the same rows under different keys, so each
- **A rewrite of a key** (rows moved from one key to another, no schema change) → run new
revisions **after** the merge. Earlier revisions sometimes ran before merge after proving
the affected tables empty. Old and new code file the same rows under different keys, so each
order loses what the window makes: before the merge, what the old code writes is filed
where the new code never reads; after it, nothing typed is lost but a reset made in the
window is undone when the rewrite runs — keep that window to minutes, and expect
Expand All @@ -30,6 +33,17 @@ Head is **`0019`**. Nothing after `0001` may use `create_all`.

## 2. Read the database first

After revision `0019`, declare a literal `MERGE_SIDE = "before"` or
`MERGE_SIDE = "after"` at module level. An operation that can remove rows or
their stored values also needs a nonempty `DESTROYS` explanation. The server
suite checks upgrade operations and refuses a mix of both sides in one revision.
When an existing table needs a new column and a constraint, split the nullable
column and the constraint into revisions applied on the appropriate sides.
Write the nullable column with a literal name and an explicit built-in scalar
type. Put foreign keys and checks in separate Alembic operations.
Use explicit Alembic operations so the check can classify them. A literal SQL
data rewrite is treated as after-merge because the check cannot see live rows.

Do not assume a revision is a no-op. `0011` was one; `0012` was not — all eight columns
really were nullable, and all eight held zero nulls, so it tightened them and rewrote
nothing.
Expand Down Expand Up @@ -65,9 +79,9 @@ A revision that does not move it fails there.

## 5. Apply it

**Twice: the Neon branch `preview` first, when the pull request is pushed, and production
before the merge.** `0018` was the first to go that way; a preview whose database is behind
its code answers `degraded`.
**Apply to the Neon branch `preview` first, then apply to production on the
declared side of the merge.** `0018` was the first to use preview. A preview
whose database is behind its code answers `degraded`.

Through the **Neon connector**, from the session. The owner does not run
`alembic upgrade head` by hand and a session has no `DATABASE_URL`. The project is the one
Expand Down
6 changes: 4 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ field, not against the app in this diff (`docs/engineering.md`, «Contracts»).
- [ ] An installed app of the previous version still reads every answer it reads today: no
field removed or renamed in `/api/v1`, no enum value it does not know sent to it,
no new required field in what it posts
(a deliberate break needs `V1-OpenAPI-Break: MIN_CLIENT_VERSION=<versionCode>`
on its own line and a rollout plan that covers installed v1 clients)
- [ ] A v2 change passed `buf breaking`, or it says here why the break is safe
- [ ] If the change can go wrong in production, it says how it is switched off without a
revert (a setting, `MIN_CLIENT_VERSION`, a feature the tick skips) — or that it cannot be
- [ ] The migration's side of the merge is stated (additive before, constraint after), or
there is no migration
- [ ] The migration's `MERGE_SIDE` is quoted here, along with `DESTROYS` when the change
can remove stored data, or there is no migration

## Verification

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [master, dev]
pull_request:
# The v1 compatibility declaration is part of the PR body.
types: [opened, reopened, synchronize, edited]
# Lets you build from the Actions tab without pushing anything.
workflow_dispatch:

Expand Down Expand Up @@ -225,6 +227,8 @@ jobs:
working-directory: server
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.12"
Expand Down Expand Up @@ -256,6 +260,9 @@ jobs:
# on a laptop.
- name: Type check
run: python -m mypy
- name: Check v1 OpenAPI compatibility
if: github.event_name == 'pull_request'
run: python -m scripts.check_openapi_v1 --pull-request
# `-n auto`, because this step was the whole run. It was twelve and a
# half minutes of a twenty-one minute CI run and is now three and a
# half: that started as a bill to cut and stayed for the feedback. The
Expand Down
7 changes: 6 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ From `server/` (Python 3.12):
```
ruff check app tests scripts migrations
python -m mypy
python -m scripts.check_openapi_v1 --pull-request
pytest -q -n auto
python scripts/check_test_counts.py server --junit work/pytest.xml
```

The `--pull-request` comparison requires GitHub's pull request event JSON. For a
local comparison, use `python -m scripts.check_openapi_v1 --base` with the
snapshot from the target commit.

From `android/` (JDK 21, compileSdk 37, wrapper Gradle; Python 3.12 for the report check):

```
Expand All @@ -48,7 +53,7 @@ From `android/` (JDK 21, compileSdk 37, wrapper Gradle; Python 3.12 for the repo
python ../server/scripts/check_test_counts.py android --root .
```

CI is exactly: ruff, `python -m mypy`, pytest `-n auto`, `./gradlew test`, both assembles,
CI runs ruff, mypy, the v1 OpenAPI comparison on pull requests, pytest `-n auto`, `./gradlew test`, both assembles,
`./gradlew detekt`, the two completed-report count checks above, and the path-filtered «Contract (Buf)» job when `proto/`, `buf.*` or `server/app/contract/` changed
(or the workflow, or an unknown commit range).
`./gradlew lint` is **not** a gate.
Expand Down
Loading