Rank diet-guard after the tutor (130)

kuhy's order (2026-11-21): workout, book, tutor, diet, focus, then
LeetCode. A local literal replaces gatelock's RANK_DIET_GUARD (100);
test_lock_order pins it to DOCS-lock-order.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-21 14:51:09 +01:00
parent e0a4f71953
commit 2589c664ec
5 changed files with 72 additions and 2 deletions

30
DOCS-lock-order.md Normal file
View File

@ -0,0 +1,30 @@
# Lock order
When several locks are due at once, gatelock shows the one with the highest
rank first. Each lower lock waits, with no window, until every higher lock has
been cleared. kuhy fixed this order on 2026-11-21:
| Order | Lock | gatelock app | Rank | Repo |
|---|---|---|---|---|
| 1 | workout | screen_locker | 200 | screen-locker |
| 2 | book | book_guard | 175 | book-guard |
| 3 | tutor | tutor_gate | 150 | tutor |
| 4 | diet | diet_guard | 130 | diet-guard |
| 5 | focus | focus_guard | 128 | focus-guard |
| 6 | leetcode | leetcode_guard | 125 | leetcode-guard |
LeetCode goes last. Each rank is a literal in its own repo, not a
`gatelock.RANK_*` constant, so changing one does not need a gatelock release.
Every repo keeps a copy of this file, and its tests fail when its own number
differs from its row here. Change the rank, this table and the copies in the
other repos together.
Not in the table:
- The wake alarm (300) outranks everything.
- The evening chain (`gatelock.evening_chain`) runs its rungs one at a time,
in the order book, tutor, LeetCode. Its book rung locks at 150, which ties
the tutor. Ranks only order locks that are due at the same moment.
- All of these lock with a global grab and VT switching disabled, so no
higher rank is ever a weaker lock. `gatelock/scripts/verify_all_lockers.py`
checks this order on a private X server.

View File

@ -2,7 +2,7 @@ name: diet_guard_app
description: "Companion phone app for diet_guard: log meals on the go."
publish_to: 'none'
version: 1.0.190+1
version: 1.0.191+1
environment:
sdk: ^3.12.2

View File

@ -3,6 +3,12 @@
from __future__ import annotations
from pathlib import Path
from typing import Final
RANK_DIET_GUARD: Final = 130
"""gatelock arbitration rank: after the tutor (150), before focus-guard (128)
and LeetCode (125) (``DOCS-lock-order.md``, kuhy 2026-11-21). A literal, not
``gatelock.RANK_DIET_GUARD`` (100), so no gatelock release is needed."""
# --- Daily target -----------------------------------------------------------
# There is deliberately NO budget number here. It is computed once from

View File

@ -42,7 +42,6 @@ import sys
import tkinter as tk
from gatelock import (
RANK_DIET_GUARD,
Arbiter,
GateRoot,
LockConfig,
@ -52,6 +51,7 @@ from gatelock import (
)
from diet_guard import _errors
from diet_guard._constants import RANK_DIET_GUARD
from diet_guard._gate import due_slots
from diet_guard._gatelock_calendar import _GateCalendar, make_calendar_vars
from diet_guard._gatelock_core import _GateState

View File

@ -0,0 +1,34 @@
"""The rank this repo publishes matches its row in ``DOCS-lock-order.md``.
kuhy fixed the order of every lock on 2026-11-21 (workout, book, tutor, diet,
focus, LeetCode last). Each repo keeps the rank as its own literal, so this
test is what stops one repo drifting out of that order on its own.
"""
from __future__ import annotations
from pathlib import Path
import re
from diet_guard._constants import RANK_DIET_GUARD
_DOCS = Path(__file__).resolve().parents[2] / "DOCS-lock-order.md"
_ROW = re.compile(r"^\| (\d+) \| [^|]+ \| (\w+) \| (\d+) \| [^|]+ \|$")
def _documented_ranks() -> dict[str, int]:
"""Map each gatelock app in the DOCS table to its rank."""
rows = (_ROW.match(line) for line in _DOCS.read_text().splitlines())
return {m[2]: int(m[3]) for m in rows if m}
def test_the_rank_is_the_one_in_the_lock_order_table() -> None:
"""A rank changed here without the table (or back) fails."""
assert _documented_ranks()["diet_guard"] == RANK_DIET_GUARD
def test_the_table_orders_the_locks_by_falling_rank() -> None:
"""Rows run strongest first, and no two locks share a rank."""
ranks = list(_documented_ranks().values())
assert ranks == sorted(ranks, reverse=True)
assert len(set(ranks)) == len(ranks)