diff --git a/.claude/skills/github-pr/SKILL.md b/.claude/skills/github-pr/SKILL.md index cb0d6ff9..11518d77 100644 --- a/.claude/skills/github-pr/SKILL.md +++ b/.claude/skills/github-pr/SKILL.md @@ -78,7 +78,7 @@ matched pull request's body in full. | 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, #186, #187, #189; issues #109–#117, #130–#132, #167–#185, #188 — **open**, the first whose work needs an emulator or a phone | -| 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | PRs #140, #214; issues #135–#139, #141, #145–#165, #190–#213 — **open**, the one being worked on | +| 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | PRs #140, #214, #218; issues #135–#139, #141, #145–#165, #190–#213 — **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 diff --git a/CLAUDE.md b/CLAUDE.md index cac93046..2b36eea8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,7 +51,7 @@ Server, from `server/`: - `python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"` — setup - **`ruff check app tests scripts migrations`** — exactly what CI lints; `ruff check .` from `server/` covers the same tree -- **`pytest -q -n auto`** — 2063 tests in about four minutes, and **the exact command +- **`pytest -q -n auto`** — 2064 tests in about four minutes, and **the exact command CI runs**. Not `python -m pytest`, which is what this line used to say: the `-m` form puts the current directory on `sys.path` and the bare one does not, so a `from tests.test_api import …` in a test file passes locally and fails at diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b9d0917..e01b760a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ the checks for everything you touched. | Python | 3.11+, CI builds on 3.12 | `.python-version`, `server/pyproject.toml` | | JDK | 21 | `android/app/build.gradle.kts` | | Android SDK | compileSdk 37, minSdk 26 | `android/app/build.gradle.kts` | -| Gradle | 9.7.1 through the wrapper | `android/gradle/wrapper/` | +| Gradle | 9.8.0 through the wrapper | `android/gradle/wrapper/` | The wrapper and its jar are in the repository, so `./gradlew` works on a fresh clone with no Gradle installed. The Android SDK has to be real: put the path to it in diff --git a/HANDOVER.md b/HANDOVER.md index f831616c..066776ee 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -6,43 +6,22 @@ place without reopening or redoing anything. What every batch before the last two added is in [docs/history.md](docs/history.md), newest first. -Last updated: **27 September 2026**. **PRs #63 through #85, #128, #129, #133, #134, #140, -#166, #186, #187 and #189 are merged**; `main` is at `938e59f`, the merge of #189, and `dev` -is level with it. **The only thing open is the pull request carrying this paragraph, #214**, -from `agents/audit-batch-190-211`, on milestone 10, `v0.9.0 — NetSchool e-diary, onboarding -via the school's diary`. It fixes the twenty-two issues an external audit filed on 27 -September (#190–#211) and one found while merging the nine branches that fixed them (#213). -The section «What the last session added» below is that batch. +Last updated: **2 October 2026**. **PRs #63 through #85, #128, #129, #133, #134, #140, +#166, #186, #187, #189 and #214 are merged**; `main` is at `eb0ab94`, the merge of #214, on +27 September 2026. **The only thing open is the pull request carrying this paragraph, #218**, +from `ccr-b537fbdd-oi5djs`, on milestone 10, `v0.9.0 — NetSchool e-diary, onboarding via the +school's diary`. It takes dependabot's three open bumps (#215, #216, #217) by merging their +branches, fixes #212, and is this close-out of #214. The section «What the last session +added» below is that batch. `dev` is still at `eb0ab94`, level with `main`; this batch was +made on the branch its cloud session was given rather than on `dev`. The SHA of its own merge is for the next close-out to write. -**What #214 moves.** -- The server: the compose file and its container (#190, #191, #195), the diary sign-in page - (#193, #196), «Сетевой город»'s «today» (#198), a cap on the phones one class code mints - (#199), no interactive API docs on Vercel (#200), one way to take naive UTC (#197), and a - phone invite that cannot be redeemed twice (#194). -- The server's shape: services below the bot (#205), the three largest files split (#208), - one implementation of every operation both shells perform (#206), one role gate for - «⚙️ Класс» (#207), and documents that say two shells write (#204). -- The build: `requirements.txt` is a lock (#192), and CI runs mypy and detekt (#210). -- Android: requests signed from memory (#203), bearers sealed by the Keystore (#201), https - only in a release build (#202), and four files split with the `Graph` kept out of - composables (#209). -- This file kept to where the work stands, its history in `docs/history.md` (#211). - -No schema change; `EXPECTED_REVISION` is still `0017`. **The lock has been installed where it -runs:** #214's CI installed it on Linux and Python 3.12 and passed 2063 tests on it, none -skipped — so the test that the lock is closed there ran — and Vercel built #214's preview -from it. Production takes it at the merge. - -**Once #214 merges, twenty-three issues are meant to close:** #190–#211 and #213. **#212** -stays open: a test that fails at random on Windows and passes on CI. Of the device epic -**#109**, **#111** and **#113** stay open for what only a phone can say, and **#112** (a -macrobenchmark module) was not started. What a merge closes is decided by the `Closes` lines -in the pull request body and in the commit messages, not by this paragraph — read them -against this list before merging. - -**#189 closed the two issues it named** (#174, #188), read back from GitHub on 27 September. +**#214 closed the twenty-three issues it named**, #190–#211 and #213: none of them is in the +open list read back from GitHub on 2 October. **#218 is meant to close #212**, and its merge +closes #215, #216 and #217 as **Merged** by itself, because their own commits are ancestors +of its head. Of the device epic **#109**, **#111** and **#113** stay open for what only a +phone can say, and **#112** (a macrobenchmark module) was not started. **The code expects head `0017`, and production is at `0017` since 26 September 2026 at 12:26 UTC.** `EXPECTED_REVISION` in `app/db.py` is `0017`, pinned to the real head by @@ -151,9 +130,56 @@ next, someday, done) and `needs:` (device, owner). **A session cannot create a G Project board** — Projects v2 is GraphQL-only and the toolset here is REST — so the board is the owner's to make, and these labels are what its views filter on. -## What the last session added: the external audit of 27 September, #190–#211 +## What the last session added: three dependabot bumps, a lock SQLite writers wait for, and #214's close-out + +Open as #218, from `ccr-b537fbdd-oi5djs`, on milestone 10. Made in a cloud session on 2 +October 2026, continuing from where the local session that built #214 stopped. + +- **Dependabot's three open pull requests are folded in by merging their branches**, so + each closes as Merged at this merge: the androidx group (#215 — core-ktx 1.19.1, + navigation 2.10.2, work 2.12.0), the Gradle wrapper 9.7.1 → 9.8.0 (#216), and SQLAlchemy's + floor in `requirements.in` 2.0.54 → 2.1.1 (#217). The lock already pinned 2.1.1 and + recompiling it from the new input moved nothing; `server/pyproject.toml`'s floor was + raised to match, which `test_requirements_mirror.py` asks for. `CONTRIBUTING.md` and + `docs/build.md` name the new wrapper. +- **A writer waits thirty seconds for SQLite's lock rather than five (#212).** The directory + limiter's burst test sends a hundred writers at once, and over aiosqlite a transaction + keeps SQLite's one write lock across every await to its commit; a writer the event loop + reached late waited past the driver's five-second busy timeout and failed on «database is + locked» rather than on the limit. Reproduced here by cutting the timeout to twenty + milliseconds — the test then fails on every run with the issue's exact error — and fixed + in `app/db.py`, for SQLite only. A new test reads `PRAGMA busy_timeout` through the + suite's engine and fails on the old code, which answers 5000. +- **This file**: the opening, this section, the batch before it retitled, the widget batch + (#189) moved to the top of `docs/history.md`, the milestone table, and the server test + count in its three places. -Open as #214, from `agents/audit-batch-190-211`, on milestone 10. An external audit of the +### Gates + +On `f23ae3a`: `ruff` clean; `python -m mypy` clean over 153 source files; `pytest -q -n +auto` **2064** passed, one more than #214's 2063, on Python 3.12 with the lock installed. +`./gradlew test` **1500** (`:core:model` 125, `:core:data` 570, `:core:designsystem` 112, +`:widget` 123, `:app` 570), the same as #214's, on Gradle 9.8.0 and the bumped androidx +libraries; `assembleDebug` and `assembleRelease` build; `./gradlew detekt` passes. Run in +the cloud container against a downloaded SDK, where Maven Central answered 429 often enough +that it took several attempts to fetch everything; no attempt failed on anything but a +download. On GitHub, #218's CI ran both jobs green on `f23ae3a`. + +### What was deliberately left alone + +- The bumps were taken as dependabot wrote them; nothing else was upgraded alongside. +- The `dev` branch was not moved: this session was given its own branch, and `dev` is level + with `main` at `eb0ab94`, so the next session fast-forwards it after this merge. + +### What nobody has verified in this batch + +- #212's fix has not run on the Windows machine where the failure was seen; what was + verified is the mechanism, on Linux, by shrinking the timeout until it fails. +- The three bumps have not run on a device or an emulator. + +## What the session before it added: the external audit of 27 September, #190–#211 + +Merged as #214 (`eb0ab94`, 27 September 2026), from `agents/audit-batch-190-211`, on milestone 10. An external audit of the repository filed twenty-two issues on 27 September 2026. Nine agents fixed them in parallel, each on a branch of its own in a worktree of its own, and this branch merges the nine and adds four commits found while merging them. Every defect was fixed test-first — the new @@ -304,72 +330,6 @@ nothing else in the diff, so every entry it adds is one it removes under #209's - Why two background runs could not start child processes (`0xC0000142`) was not found; it did not happen from a live shell. -## What the session before it added: the widget's two smallest sizes, and a widget that did not follow its settings - -Merged as `938e59f`, #189 from `agents/widget-small-sizes`, on milestone 9. Two commits, one per issue, -each checked on the API 37 emulator against a local server seeded with `seed_demo`, on a -Sunday, so on the widget's day-off layout. - -- **#174, the diagnosis was corrected before the fix.** The issue said a phone's 2×2 (about - 195×226 dp) landed on `LARGE`. It cannot: `LARGE` is 250×250 and does not fit inside the - box, and both the launcher and `WidgetSizeClass.of` keep only the breakpoints that fit. It - is `SMALL_TALL`, and the screen said so twice. «4 урока · Алгебра в 08:00» is 25 - characters against that rung's budget of 24, cut from the end, so the time was what went. - Two homework rows is that rung's count. The correction went into the issue's thread first, - and `WidgetSizeClassTest` now pins where that 2×2 lands. -- **#174, the fix.** `WidgetStrings.dayPlan` spends the budget on the subject and keeps the - count and the time; the narrow rungs may give the plan a second line - (`dayPlanLines`), because at a true 110 dp Glance would otherwise clip it at the pixel. - `SMALL_TALL` lists three subjects after school: about 130 dp of its 190, 175 at the worst. - On the 2×1 the label is weighted and the count is not, so at an enlarged font the label - lost; `tinyCountOf` draws the bare figure from the first step above the default, - «ДЗ на завтра 3» or «ДЗ на завтра нет» (a new string, `widget_homework_none_short`, with - its English twin). The step is a choice, not a measurement: Glance measures neither text - nor the box. -- **#188, found while checking #174.** The app was switched to Russian and the widget stayed - English. A `304` sync did not redraw it, and only a reinstall (`MY_PACKAGE_REPLACED`) did. - Nothing redrew the widget on a settings change at all. Filed, then fixed: - `SettingsRepositoryImpl.update` sends `DATA_SYNCED` when `AppSettings.drawnByWidget` - moves, beside the alert re-arm it already did the same way, and the widget reads its three - settings through that projection only. To test it without a DataStore, the repository reads - a small `SettingsStore` interface, which `LessonsPreferences` implements the way it already - implements `DiarySessionStore` and `ShellModeSource`. - -### On the emulator - -The 2×2 read «4 урока · Алгеб… в 08:30» over three subjects, and «4 lessons · Алг… at 08:30» -in English. The 2×5 column (`NARROW`) read the same plan line. The 2×1 read «ДЗ на завтра · -3 предмета» at font scale 1.0 and «ДЗ на завтра 3» at 2.0. For #188, the 2×1 read «ДЗ на -завтра» before the app was switched to English and «HW for tomorrow 3 subjects» three seconds -after, with nothing else in between. - -**Two things about driving the widget from a shell**, which cost time and will again. First, -the shell cannot redraw it: `DATA_SYNCED` is filtered by a receiver the shell cannot reach, -and `APPWIDGET_UPDATE` is a protected broadcast. Second, a pull-to-refresh answered `304` and -redraws nothing, by design. What does redraw it is reinstalling the same APK, because -`MY_PACKAGE_REPLACED` is one of the widget's own triggers. The launcher's resize handles take -`input swipe`: a long press on the widget, then a drag from a handle. - -### Gates - -On `675cafe`: `./gradlew test` **1459** (`:core:model` 125, `:core:data` 543, -`:core:designsystem` 112, `:widget` 123, `:app` 556), thirteen more than #187's 1446 — -`DayPlanTest` 5, `TinyCountTest` 4, one in `WidgetSizeClassTest`, `WidgetSettingsRedrawTest` -3. `assembleDebug` and `assembleRelease` build. Each new test was run against the old -behaviour first: five fail for #174 and one for #188. The server was not touched, so its -gates were not run. - -### What nobody has verified in this batch - -- The one-line size **during lessons** at a large font («ПЕРЕМЕНА 7 мин», the same weighted - label beside a countdown) was not looked at. -- A change of the **system** font scale is a configuration change, not an app setting. - Whether anything redraws the widget after one was not checked: every render here was forced - with a reinstall. -- The `fontScale > 1` step was seen at 2.0 on this one emulator. -- At 195 dp the whole «4 урока · Алгебра в 08:30» would fit, and the rung's budget shortens - it anyway, because the same rung serves 110 dp. - ## The milestones **The milestones as they are now.** The owner renamed all nine on 25 September 2026, so that @@ -390,7 +350,7 @@ maps them. The | 7 | `Dependencies — dependabot bumps` | `Dependencies` | open, for good | every dependabot bump; deliberately not a version | | 8 | `v0.7.0 — School-year calendar, day ribbon, rearrangeable tabs` | `v0.7.0 — Оптимизация` | closed | PRs #75–#85, #128; issues #98, #100, #105–#108 | | 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | `v0.8.0 — On a device` | open | PRs #129, #133, #134, #186, #187, #189; issues #109–#117, #130–#132, #167–#185, #188 — the first whose work needs an emulator or a phone, and #186 the first done on one | -| 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | none — proposed as «v0.9.0 — A second diary», never created under that name | open | PRs #140 (merged), #214; issues #135–#139, #141, #145–#165, #190–#211 (the external audit of 27 September), #212, #213 | +| 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | none — proposed as «v0.9.0 — A second diary», never created under that name | open | PRs #140 and #214 (merged), #218; issues #135–#139, #141, #145–#165, #190–#211 (the external audit of 27 September), #212, #213 | **#142, #143 and #144 are on no milestone, deliberately**: two follow-ups and a decision that #140 left alone on purpose, which belong to whichever version takes them up. @@ -1358,7 +1318,7 @@ The gates, both halves (`CLAUDE.md` requires running both if you touched both): ```bash cd server && ruff check app tests scripts migrations # clean -cd server && pytest -q -n auto # 2063 tests, ~4 min on CI, ~10 on Windows +cd server && pytest -q -n auto # 2064 tests, ~4 min on CI, ~10 on Windows cd server && python -m mypy # clean, 153 modules cd android && ./gradlew test # 1500 tests across the five modules cd android && ./gradlew detekt # nothing beyond the five baselines diff --git a/README.md b/README.md index 76be6c3a..edb0f310 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ Read this before planning a release. | --- | --- | | `ruff check app tests scripts migrations` | clean | | `python -m mypy` | clean, 153 modules — asks whether anything reaches for an attribute that does not exist | -| `pytest -q -n auto` | 2063 tests, green, about four minutes — the command CI runs | +| `pytest -q -n auto` | 2064 tests, green, about four minutes — the command CI runs | | `./gradlew test` | 1500 tests, green, all five modules | | `./gradlew detekt` | no finding beyond each module's baseline, all five modules | | `./gradlew assembleDebug` | the APK builds | diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index d329a05b..f191205f 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -42,10 +42,10 @@ agp = "9.4.1" kotlin = "2.4.20" ksp = "2.3.12" -coreKtx = "1.19.0" +coreKtx = "1.19.1" activityCompose = "1.13.0" lifecycle = "2.11.0" -navigation = "2.10.1" +navigation = "2.10.2" composeBom = "2026.09.00" material3 = "1.5.0-alpha24" @@ -55,7 +55,7 @@ graphicsShapes = "1.1.0" glance = "1.3.0-alpha02" room = "2.8.5" datastore = "1.2.0" -work = "2.11.2" +work = "2.12.0" retrofit = "3.0.0" okhttp = "5.5.0" diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar index eddabd2e..5097068a 100644 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index c42672d9..299848b1 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/android/gradlew.bat b/android/gradlew.bat index 8508ef68..03754c4c 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -26,6 +26,33 @@ @rem Set local scope for the variables, and ensure extensions are enabled setlocal EnableExtensions +@rem Catch executions from older scripts and ensure they exit cleanly. +@rem This can be removed once we can be reasonably confident that few people +@rem will be migrating directly to this new wrapper. +goto afterSafetyNet +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto exitWithErrorLevel +:afterSafetyNet + set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @rem This is normally unused @@ -45,13 +72,14 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. "%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -59,13 +87,14 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. "%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :execute @rem Setup the command line @@ -75,8 +104,9 @@ echo location of your Java installation. 1>&2 @rem Execute gradlew @rem endlocal doesn't take effect until after the line is parsed and variables are expanded @rem which allows us to clear the local environment before executing the java command -endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel +@rem This label must not be changed. We rely on old scripts being able to jump to this point. :exitWithErrorLevel @rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts "%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/docs/architecture.md b/docs/architecture.md index 81088208..43b39c24 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -783,7 +783,7 @@ with the host. ## Testing -2063 tests on the server, 1500 on Android; `pytest -q -n auto` and `./gradlew test`, both +2064 tests on the server, 1500 on Android; `pytest -q -n auto` and `./gradlew test`, both offline, both in CI. On Android that is `:core:model` 125, `:core:data` 570, `:core:designsystem` 112, `:widget` 123, `:app` 570. diff --git a/docs/build.md b/docs/build.md index dfea9793..a0776c69 100644 --- a/docs/build.md +++ b/docs/build.md @@ -741,7 +741,7 @@ licence, so a typeface cannot be swapped without its licence following it. | --- | --- | | JDK | 21 | | Android SDK | compileSdk 37, minSdk 26 | -| Gradle | through the wrapper, 9.7.1 | +| Gradle | through the wrapper, 9.8.0 | The wrapper and its jar are in the repository, so `./gradlew` works on a fresh clone with no Gradle installed, and nothing else has to be on the machine. diff --git a/docs/history.md b/docs/history.md index 37ef51a2..2fdb1e38 100644 --- a/docs/history.md +++ b/docs/history.md @@ -27,6 +27,72 @@ the conventions of the file it was written in: --- +## What the batch before added: the widget's two smallest sizes, and a widget that did not follow its settings + +Merged as `938e59f`, #189 from `agents/widget-small-sizes`, on milestone 9. Two commits, one per issue, +each checked on the API 37 emulator against a local server seeded with `seed_demo`, on a +Sunday, so on the widget's day-off layout. + +- **#174, the diagnosis was corrected before the fix.** The issue said a phone's 2×2 (about + 195×226 dp) landed on `LARGE`. It cannot: `LARGE` is 250×250 and does not fit inside the + box, and both the launcher and `WidgetSizeClass.of` keep only the breakpoints that fit. It + is `SMALL_TALL`, and the screen said so twice. «4 урока · Алгебра в 08:00» is 25 + characters against that rung's budget of 24, cut from the end, so the time was what went. + Two homework rows is that rung's count. The correction went into the issue's thread first, + and `WidgetSizeClassTest` now pins where that 2×2 lands. +- **#174, the fix.** `WidgetStrings.dayPlan` spends the budget on the subject and keeps the + count and the time; the narrow rungs may give the plan a second line + (`dayPlanLines`), because at a true 110 dp Glance would otherwise clip it at the pixel. + `SMALL_TALL` lists three subjects after school: about 130 dp of its 190, 175 at the worst. + On the 2×1 the label is weighted and the count is not, so at an enlarged font the label + lost; `tinyCountOf` draws the bare figure from the first step above the default, + «ДЗ на завтра 3» or «ДЗ на завтра нет» (a new string, `widget_homework_none_short`, with + its English twin). The step is a choice, not a measurement: Glance measures neither text + nor the box. +- **#188, found while checking #174.** The app was switched to Russian and the widget stayed + English. A `304` sync did not redraw it, and only a reinstall (`MY_PACKAGE_REPLACED`) did. + Nothing redrew the widget on a settings change at all. Filed, then fixed: + `SettingsRepositoryImpl.update` sends `DATA_SYNCED` when `AppSettings.drawnByWidget` + moves, beside the alert re-arm it already did the same way, and the widget reads its three + settings through that projection only. To test it without a DataStore, the repository reads + a small `SettingsStore` interface, which `LessonsPreferences` implements the way it already + implements `DiarySessionStore` and `ShellModeSource`. + +### On the emulator + +The 2×2 read «4 урока · Алгеб… в 08:30» over three subjects, and «4 lessons · Алг… at 08:30» +in English. The 2×5 column (`NARROW`) read the same plan line. The 2×1 read «ДЗ на завтра · +3 предмета» at font scale 1.0 and «ДЗ на завтра 3» at 2.0. For #188, the 2×1 read «ДЗ на +завтра» before the app was switched to English and «HW for tomorrow 3 subjects» three seconds +after, with nothing else in between. + +**Two things about driving the widget from a shell**, which cost time and will again. First, +the shell cannot redraw it: `DATA_SYNCED` is filtered by a receiver the shell cannot reach, +and `APPWIDGET_UPDATE` is a protected broadcast. Second, a pull-to-refresh answered `304` and +redraws nothing, by design. What does redraw it is reinstalling the same APK, because +`MY_PACKAGE_REPLACED` is one of the widget's own triggers. The launcher's resize handles take +`input swipe`: a long press on the widget, then a drag from a handle. + +### Gates + +On `675cafe`: `./gradlew test` **1459** (`:core:model` 125, `:core:data` 543, +`:core:designsystem` 112, `:widget` 123, `:app` 556), thirteen more than #187's 1446 — +`DayPlanTest` 5, `TinyCountTest` 4, one in `WidgetSizeClassTest`, `WidgetSettingsRedrawTest` +3. `assembleDebug` and `assembleRelease` build. Each new test was run against the old +behaviour first: five fail for #174 and one for #188. The server was not touched, so its +gates were not run. + +### What nobody has verified in this batch + +- The one-line size **during lessons** at a large font («ПЕРЕМЕНА 7 мин», the same weighted + label beside a countdown) was not looked at. +- A change of the **system** font scale is a configuration change, not an app setting. + Whether anything redraws the widget after one was not checked: every render here was forced + with a reinstall. +- The `fontScale > 1` step was seen at 2.0 on this one emulator. +- At 195 dp the whole «4 урока · Алгебра в 08:30» would fit, and the rung's budget shortens + it anyway, because the same rung serves 110 dp. + ## What the batch before added: the first instrumented tests, and three defects the walkthrough left Merged as `2a408d8`. Four commits from the night of 26–27 September and one from the diff --git a/requirements.in b/requirements.in index cd90c41b..b1088e68 100644 --- a/requirements.in +++ b/requirements.in @@ -32,7 +32,7 @@ # dead weight in the function bundle. fastapi>=0.141.1 aiogram>=3.31.0 -sqlalchemy[asyncio]>=2.0.54 +sqlalchemy[asyncio]>=2.1.1 asyncpg>=0.31.0 pydantic>=2.13.5 pydantic-settings>=2.15.0 diff --git a/server/app/db.py b/server/app/db.py index 1f44174c..d340c1f2 100644 --- a/server/app/db.py +++ b/server/app/db.py @@ -24,6 +24,19 @@ class Base(DeclarativeBase): # for what libpq accepts and asyncpg does not. _url, _connect_args = normalise_database_url(_settings.database_url) +# SQLite has one write lock per file, and a connection that finds it taken +# waits the driver's busy timeout — five seconds — and then raises «database is +# locked». Over aiosqlite a transaction keeps the lock across every await +# between its first write and its commit, so a hundred concurrent requests +# queue behind whichever ones the event loop gets to last: on a slow Windows +# checkout the burst test of the directory's limiter waited past five seconds +# about one run in two and failed on the lock rather than on the limit (#212). +# Thirty seconds is a wait, not a failure; Postgres, which production runs, has +# no such lock to wait on. +SQLITE_BUSY_TIMEOUT_SECONDS = 30.0 +if _url.startswith("sqlite"): + _connect_args = {"timeout": SQLITE_BUSY_TIMEOUT_SECONDS, **_connect_args} + engine = create_async_engine( _url, echo=False, diff --git a/server/pyproject.toml b/server/pyproject.toml index 37c03d78..45f51793 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -11,7 +11,7 @@ dependencies = [ # coloured keyboard in ``app/bot/button_style.py`` raises at construction # rather than quietly drawing grey. requirements.txt already said 3.31. "aiogram>=3.31.0", - "sqlalchemy[asyncio]>=2.0.54", + "sqlalchemy[asyncio]>=2.1.1", "aiosqlite>=0.20", "asyncpg>=0.31.0", "pydantic>=2.13.5", diff --git a/server/tests/test_directory.py b/server/tests/test_directory.py index 42250035..294c8a3e 100644 --- a/server/tests/test_directory.py +++ b/server/tests/test_directory.py @@ -27,7 +27,7 @@ import httpx import pytest from httpx import ASGITransport -from sqlalchemy import func, select +from sqlalchemy import func, select, text from app.api import cron, diary, directory, public from app.config import get_settings @@ -580,3 +580,18 @@ async def test_a_parallel_burst_from_one_address_cannot_pass_the_limit( assert len(let_through) <= directory.directory_limiter.limit assert await _attempts(session) <= directory.directory_limiter.limit assert len(upstream.requests) <= directory.directory_limiter.limit + + +async def test_the_burst_waits_for_sqlites_write_lock_rather_than_failing_on_it(session): + """The burst above is a hundred writers on one SQLite file, and SQLite + hands its one write lock out in turn: a writer that waits longer than the + busy timeout raises «database is locked» instead of reaching the limiter. + At the driver's five seconds that happened about one run in two on a slow + Windows checkout (#212), and with the timeout cut to twenty milliseconds it + happens on every run here. The test is about what the limiter answers, so + the wait must be long enough never to be the answer.""" + from app.db import SQLITE_BUSY_TIMEOUT_SECONDS + + busy_ms = await session.scalar(text("PRAGMA busy_timeout")) + assert busy_ms == int(SQLITE_BUSY_TIMEOUT_SECONDS * 1000) + assert SQLITE_BUSY_TIMEOUT_SECONDS >= 30