Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c34cb5
Add a provider-neutral diary seam and the «Сетевой город» provider core
claude Sep 24, 2026
f6b3f2f
Dispatch the diary service by provider, and let the API sign in to ei…
claude Sep 24, 2026
60f4bdb
Fix the two diary defects, and name the provider on the sign-in form
claude Sep 24, 2026
b1bd8e5
Hold «Сетевой город» sessions open from the cron tick
claude Sep 24, 2026
1975b60
Bind a class to «Сетевой город» from the bot, and read either diary
claude Sep 24, 2026
c146de0
Correct four diary comments that describe behaviour the code does not…
claude Sep 24, 2026
9ceef0c
Teach the agent files the second diary provider and the 0015 head
claude Sep 24, 2026
42fdf0a
Document the second diary provider across docs and close out HANDOVER
claude Sep 24, 2026
17c0473
Generate a catalog of all 89 regions and the diaries each one runs
claude Sep 25, 2026
2bfdeba
Write the terms of use and the privacy policy the first screen will l…
claude Sep 25, 2026
6fa1c6e
Let a phone register a diary session it opened itself, and fix what t…
claude Sep 25, 2026
68cd807
Find the regions a school may be in, without letting onboarding spend…
claude Sep 25, 2026
0a9a188
Stop telling families the bot's sign-in page sends the password strai…
claude Sep 25, 2026
6281dea
Document how a diary session now reaches the server, the region catal…
claude Sep 25, 2026
b19e6b2
Let a phone sign in to its own diary and hand our server only the ses…
claude Sep 25, 2026
ce9c749
Let a reader open the terms and the privacy policy from the app, onli…
claude Sep 25, 2026
ba9170c
Run each CI job whenever a file its tests read changes, not only its …
claude Sep 25, 2026
c032ff2
Let a family in through its own school's diary at the first run, and …
claude Sep 25, 2026
9c797a2
Hold the phone's diary sign-in to the server's own rules, and make it…
claude Sep 25, 2026
fb8a70c
Let the widget say which way in a phone took, and tell a diary-only p…
claude Sep 25, 2026
5efca54
Document the phone's half: the first run through your own school's di…
claude Sep 25, 2026
8bad211
Stop the contributor and agent documents quoting a test command, coun…
claude Sep 25, 2026
2ea98f5
Close out the batch in HANDOVER while its pull request is still open
claude Sep 25, 2026
061a716
Close the holes a second review found in the first run, the diary hom…
claude Sep 26, 2026
6b0878f
Close what an audit of the server half found before its migrations go…
claude Sep 26, 2026
d208251
Hold the server's checks level on SQLAlchemy 2.1, which every fresh i…
claude Sep 26, 2026
f31e5ed
Label Dependabot's bumps and template reports with the families the p…
claude Sep 26, 2026
50464d0
Say where #140 stands now that both reviews are in: one decision left…
claude Sep 26, 2026
e01443d
File the family's diary corrections under the child, so a login a pho…
claude Sep 26, 2026
4c1e8c1
Record that 0015, 0016 and 0017 are on production, and where #140 sta…
claude Sep 26, 2026
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
16 changes: 12 additions & 4 deletions .claude/agents/server-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: Alembic revisions and the Neon protocol. Use whenever a model chang
tools: Read, Glob, Grep, Bash, Edit, Write
---

You own `server/migrations/`. Production is at **`0013`**, which is the head.
You own `server/migrations/`. Head is **`0017`**, and production is at `0017`: `0015`,
`0016` and `0017` went on together on 26 September 2026, before #140 merged.

## The chain, and what each one did

Expand All @@ -17,7 +18,11 @@ number (1–11) and cuts its year into quarters or half-years. `0009` adds the c
family lays over the diary. `0010` gives a class its join mode and adds the personal connect
codes. `0011` tightens two `diary_overrides` timestamps. `0012` tightens eight more across
seven tables — and on this database it was **not** a no-op: all eight were nullable and all
eight held zero nulls. `0013` adds `uq_homework_per_subject_per_day`.
eight held zero nulls. `0013` adds `uq_homework_per_subject_per_day`. `0014` widens
`day_overrides.kind` for a new `DayKind`. `0015` adds the second diary provider's columns.
`0016` creates `usage_counters`. `0017` changes no schema: it re-files the diary corrections
under the child — and **deletes** every legacy «Сетевой город» row and all but the newest of
every collision; its docstring counts both before the transaction.

## Two rules that point in opposite directions

Expand All @@ -32,8 +37,11 @@ eight held zero nulls. `0013` adds `uq_homework_per_subject_per_day`.
`services/homework.py` is written to be correct with or without it so the window in
between behaves exactly like production did before.

Read the database before either. `0012` turned out to be a real fix rather than the no-op
`0011` was, because the columns really were nullable there.
A third shape, **a rewrite of a key**, goes after the merge where there are rows to rewrite
and is free where there are none; `0017` is it, and its docstring says what each order loses.

Read the database before any of them. `0012` turned out to be a real fix rather than the
no-op `0011` was, because the columns really were nullable there.

## How a revision is actually applied here

Expand Down
28 changes: 22 additions & 6 deletions .claude/agents/server-providers.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: server-providers
description: The two foreign services (petersburg, dadata), plus config.py and crypto.py. Use when an upstream shape changes or a setting is added. Knows which settings are mandatory on Vercel and which refuse in view of whoever they concern.
description: The foreign services (the diary providers petersburg and netschool behind the diary seam, and dadata), plus config.py and crypto.py. Use when an upstream shape changes or a setting is added. Knows which settings are mandatory on Vercel and which refuse in view of whoever they concern.
tools: Read, Glob, Grep, Bash, Edit, Write
---

Expand All @@ -9,13 +9,29 @@ You own `server/app/providers/`, `server/app/config.py` and `server/app/crypto.p
## The provider shape

Each foreign service is `client.py` / `mapper.py` / `models.py`, and **nothing above
`models.py` knows the upstream's vocabulary** — not `p_educations[]`, not `X-JWT-Token`. If a
word from the upstream is leaking into a service or a handler, the mapper is incomplete.
`models.py` knows the upstream's vocabulary** — not `p_educations[]`, not `X-JWT-Token`, not
`at`. If a word from the upstream is leaking into a service or a handler, the mapper is
incomplete.

- `petersburg/` is the electronic diary. Without `DIARY_SECRET` it refuses at the door: the
- **The diary seam** is `providers/diary/`: `models.py`, `errors.py` (the `DiaryError`
family; `PetersburgError` is a re-export alias so old imports still resolve), a
`DiaryProvider`/`DiaryConnection` Protocol contract in `base.py`, and `registry.py` whose
`provider_for(key)` lazily imports the implementation and `binding(school_class)` is the
**one** place that resolves a class's diary binding (bot, main menu, class card and web
form all call it). A second diary is a value in `registry.KEYS`, never a rename.
- `petersburg/` is one electronic diary, behind that seam and byte-for-byte unchanged. Its
session token is the one stored credential that cannot be a hash, because it is replayed
upstream on every call, so it is sealed with Fernet. A silent plaintext fallback is
invisible and deployments stay in that state for years.
upstream on every call, so it is sealed with Fernet — and without `DIARY_SECRET` the whole
diary feature refuses at the door. A silent plaintext fallback is invisible and deployments
stay in that state for years.
- `netschool/` is «Сетевой город. Образование» (ИРТех), the main diary of ~20 regions, one
route set for all of them. `regions.py` is an **allow-list**: the only origins ever
contacted, so nothing from a client or a DB row becomes a URL. Sign-in is a windows-1251
salted-MD5 password; a region that answers with the Госуслуги-only refusal raises
`SignInUnsupported` and is not offered. Sessions idle out in 15–60 min and are held open
from the cron tick (`services/diary_keepalive.py`) with `GET /webapi/context`. **Nothing
here has met a live server** — every shape is from open-source clients and hand-written
payloads; the first real session is the owner's (#121/#135).
- `dadata/` is the school directory, a search over the ЕГРЮЛ company register, because no
downloadable register of
Russian schools exists. Without `DADATA_TOKEN` it refuses and the bot asks for the name to
Expand Down
27 changes: 17 additions & 10 deletions .claude/skills/github-pr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@ matched pull request's body in full.

| # | Title | Covers |
| --- | --- | --- |
| 1 | `v0.1.0 — First run on a phone` | #1–#14 |
| 2 | `v0.2.0 — The diary, and the class run from the bot` | #15–#17, #28–#31 |
| 3 | `v0.3.0 — The school year` | #27, #32–#35, #43 |
| 4 | `v0.4.0 — Nothing breaks in silence` | #44, #45, #50 |
| 5 | `v0.5.0 — A public repository` | #46–#49, #51, #55–#57, #59 |
| 6 | `v0.6.0 — One container, and nothing cut off` | #60–#62 — the version being worked on |
| 7 | `Dependencies` | every dependabot bump; deliberately not a version |
| 8 | `v0.7.0 — Оптимизация` | #75–#85, #128 — the one Russian title |
| 9 | `v0.8.0 — On a device` | issues #109–#117 — **the current one**, and the first whose work needs an emulator or a phone |
| 1 | `v0.1.0 — App, widget, admin bot and read API` | PRs #1–#14; issues #86, #88, #89 |
| 2 | `v0.2.0 — Petersburg e-diary, class run from bot and phone` | PRs #15–#17, #28–#31; issues #87, #90, #91, #102 |
| 3 | `v0.3.0 — School year, terms, school search, several classes` | PRs #27, #32–#35, #43; issue #92 |
| 4 | `v0.4.0 — 67-defect sweep, first audit, app-wide correction mode` | PRs #44, #45, #50; issues #93, #94 |
| 5 | `v0.5.0 — Public repo: secrets audit, English docs, font licence` | PRs #46–#49, #51, #55–#57, #59; issue #95 |
| 6 | `v0.6.0 — Dishka DI, scrolling text, in-app guide from the repo` | PRs #60–#74; issues #96, #97, #99, #101, #103, #104 |
| 7 | `Dependencies — dependabot bumps` | every dependabot bump; deliberately not a version, and open for good |
| 8 | `v0.7.0 — School-year calendar, day ribbon, rearrangeable tabs` | PRs #75–#85, #128; issues #98, #100, #105–#108 |
| 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | PRs #129, #133, #134; issues #109–#117, #130–#132 — **open**, the first whose work needs an emulator or a phone |
| 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | PR #140; issues #135–#139, #141, #145–#160 — **open**, the one being worked on |

All ten were renamed on 25 September 2026: every title now names what the version
delivered, and each description names its pull requests and issues. A title quoted from
before that date — «On a device», «Оптимизация», «Nothing breaks in silence» — finds
nothing when searched, so take titles from this table or from a milestone object, never
from an old commit message.

New work goes in the newest version milestone unless it plainly opens the next one; a
dependabot bump goes in `Dependencies` whatever else is in flight.
dependabot bump goes in milestone 7, `Dependencies — dependabot bumps`, whatever else is in flight.

They are **retrospective**. The boundaries were read off the history in September 2026
rather than declared at the time, and **nothing in this repository has ever been tagged or
Expand Down
11 changes: 10 additions & 1 deletion .claude/skills/migration/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Write and apply an Alembic revision for this project — including

# A migration, start to finish

Head is **`0013`**. Nothing after `0001` may use `create_all`.
Head is **`0017`**. Nothing after `0001` may use `create_all`.

## 1. Decide the direction

Expand All @@ -18,6 +18,15 @@ Head is **`0013`**. 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
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
`/api/v1/warmup` to say «База отстала от кода» through it. Lock the table on PostgreSQL
first, or a write landing between the rewrite's statements breaks it. A redeploy never
re-runs a stamped revision, so after a revert run it again by hand. `0017` is this shape.

## 2. Read the database first

Expand Down
15 changes: 11 additions & 4 deletions .claude/skills/release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ names both revisions.

## 3. Signing

`apk.yml` needs all four `LESSONS_KEYSTORE_*` secrets and fails with `::error::` if any is
empty. That failure is the feature: an APK signed with the AGP debug key can never be updated
`apk.yml` needs all four signing secrets — `KEYSTORE_BASE64`, `KEYSTORE_PASSWORD`, `KEY_ALIAS`
and `KEY_PASSWORD` — and fails with `::error::` if any is empty. (`LESSONS_KEYSTORE_*` are
the names the Gradle build reads them under, not the names of the secrets.) That failure is the feature: an APK signed with the AGP debug key can never be updated
by the real key on a phone that already installed it. The keystore and its passwords come
from environment variables or `~/.gradle/gradle.properties` — never from the repository,
where `*.jks` and `keystore.properties` are gitignored.

## 4. The milestone closes before the tag is cut

**The milestone is what decides what is in the release**, so it is settled first and the
tag is the version it is named for — `v0.8.0 — On a device` is tagged `v0.8.0`.
tag is the version it is named for — `v0.8.0 — On-device checks, 89-region e-diary survey`
is tagged `v0.8.0`.

Before tagging, walk the milestone and check three things:

Expand All @@ -43,11 +45,16 @@ Before tagging, walk the milestone and check three things:
- **every pull request on it carries the milestone**, set with `issue_write` when it was
opened. One left bare is a change the notes will not mention.

**If the terms or the privacy policy changed since the last tag, raise `edition` and set
`effective` in `docs/legal/legal.json` before tagging**, in the commit the tag points at. The
APK bundles `docs/legal/` as it is at build time and names the edition in its sheet, so a
tag cut first ships changed texts under the old edition and date.

Then tag. A `v*` tag makes `apk.yml` build an installable APK **and** create a GitHub
release with it attached, so the tag is the moment the notes have to be ready.

```bash
git tag -a v0.8.0 -m 'On a device'
git tag -a v0.8.0 -m 'On-device checks, 89-region e-diary survey'
git push origin v0.8.0
```

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug
description: Something behaves wrongly — in the app, the widget, the bot or on the server
labels: ["bug"]
labels: ["type:bug", "status:next"]
body:
- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Proposal
description: Propose a new capability, or a change to how something behaves
labels: ["enhancement"]
labels: ["type:feature", "status:next"]
body:
- type: markdown
attributes:
Expand Down
23 changes: 14 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ version: 2
# over from projects that build on them, and the catalog's header names the
# source of each. That is why updates are grouped and capped — five open pull
# requests carrying Compose alphas one at a time is a lottery, not an update.
#
# The labels are the project's own families, `type:` and `area:`, and each one
# has to exist already: Dependabot skips a label the repository does not have,
# without a word. It asked for `dependencies`, `android`, `server`, `vercel`
# and `ci` for months, none of which existed, and every bump arrived bare
# (#162).
updates:
- package-ecosystem: gradle
directory: /android
Expand All @@ -19,8 +25,8 @@ updates:
day: monday
open-pull-requests-limit: 5
labels:
- dependencies
- android
- type:chore
- area:android
groups:
androidx:
patterns:
Expand Down Expand Up @@ -58,8 +64,8 @@ updates:
day: monday
open-pull-requests-limit: 5
labels:
- dependencies
- server
- type:chore
- area:server
groups:
testing:
patterns:
Expand Down Expand Up @@ -87,14 +93,13 @@ updates:
day: monday
open-pull-requests-limit: 3
labels:
- dependencies
- server
- vercel
- type:chore
- area:server

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
labels:
- dependencies
- ci
- type:chore
- area:ci
60 changes: 60 additions & 0 deletions .github/workflows/apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# Signing: if the four keystore secrets are set the release APK is signed with
# your key. If they are not, it is signed with the debug key so it still
# installs; the job summary says which happened. See docs/build.md.
#
# Legal links: the APK links the terms and the privacy policy in docs/legal/ of
# the repository this runs in, unless the LESSONS_LEGAL_BASE_URL repository
# variable says otherwise; the summary prints which.
name: APK

on:
Expand Down Expand Up @@ -129,6 +133,49 @@ jobs:
# for a wire nobody can see from outside the step.
echo "built_at=$(date -u +'%Y-%m-%dT%H:%MZ')" >> "$GITHUB_OUTPUT"

# Where the first screen's two links go: docs/legal/ of *this* repository,
# so a fork's APK links the fork's documents with nothing configured.
# `HEAD` when the payload carries no default branch: GitHub resolves
# blob/HEAD/ to the default branch, so the fallback means the same thing -
# unlike github.ref_name (a tag freezes the policy at that tag, a deleted
# branch 404s on every install for the rest of its life). A repository
# *variable*, not a secret, overrides it: the value is public, and a
# secret would be masked in the summary below. Checked here, in seconds,
# as well as by build.gradle.kts, so a bad value fails before the compile
# rather than eight minutes into it; the whitespace check also stops a
# newline in the variable from writing extra step outputs.
- name: Resolve legal documents
id: legal
env:
OVERRIDE: ${{ vars.LESSONS_LEGAL_BASE_URL }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
PRIVATE_REPO: ${{ github.event.repository.private }}
GH_SERVER: ${{ github.server_url }}
run: |
if [ -n "$OVERRIDE" ]; then
URL="${OVERRIDE%/}"
SOURCE="repository variable"
else
URL="$GH_SERVER/$GITHUB_REPOSITORY/blob/${DEFAULT_BRANCH:-HEAD}/docs/legal"
SOURCE="docs/legal of this repository"
if [ "$PRIVATE_REPO" = "true" ]; then
echo "::warning::This repository is private, so the derived address of docs/legal opens for nobody outside it. Set the LESSONS_LEGAL_BASE_URL repository variable; see docs/build.md."
fi
fi
case "$URL" in
*[[:space:]]*|*'"'*|*'\'*)
echo "::error::LESSONS_LEGAL_BASE_URL contains whitespace, a quote or a backslash."
exit 1
;;
https://?*) ;;
*)
echo "::error::LESSONS_LEGAL_BASE_URL must be an https:// address; it is \"$URL\". See docs/build.md."
exit 1
;;
esac
echo "url=$URL" >> "$GITHUB_OUTPUT"
echo "source=$SOURCE" >> "$GITHUB_OUTPUT"

- name: Decode keystore
id: keystore
env:
Expand Down Expand Up @@ -263,6 +310,9 @@ jobs:
LESSONS_BUILD_COMMIT: ${{ github.sha }}
LESSONS_BUILD_NUMBER: ${{ github.run_number }}
LESSONS_BUILD_TIME: ${{ steps.version.outputs.built_at }}
# The folder the terms and the privacy policy are linked from, worked
# out by the «Resolve legal documents» step above.
LESSONS_LEGAL_BASE_URL: ${{ steps.legal.outputs.url }}
INPUT_BUILD_TYPE: ${{ inputs.build_type || 'release' }}
run: |
case "$INPUT_BUILD_TYPE" in
Expand Down Expand Up @@ -343,7 +393,16 @@ jobs:
# button is actually asking.
GITHUB_CLIENT_ID: ${{ secrets.LESSONS_GITHUB_CLIENT_ID }}
CONTACT_EMAIL: ${{ secrets.LESSONS_CONTACT_EMAIL }}
# Printed in full, because it is public: it is the first link of
# every install this run produces.
LEGAL_URL: ${{ steps.legal.outputs.url }}
LEGAL_SOURCE: ${{ steps.legal.outputs.source }}
run: |
if [ -n "$LEGAL_URL" ]; then
LEGAL="\`$LEGAL_URL\` ($LEGAL_SOURCE)"
else
LEGAL="**not resolved** - see the «Resolve legal documents» step"
fi
if [ -n "$INPUT_VERSION_CODE" ]; then
CODE_SOURCE=" (given)"
else
Expand Down Expand Up @@ -373,6 +432,7 @@ jobs:
echo "| APKs produced | ${{ steps.collect.outputs.count }} |"
echo "| Sign in with GitHub | $SIGN_IN |"
echo "| Report by email | $EMAIL |"
echo "| Terms and privacy policy | $LEGAL |"
if [ "${{ steps.keystore.outputs.signed }}" = "true" ]; then
echo "| Signing | your release keystore |"
else
Expand Down
Loading
Loading