From 0d9974c194c456fdd4450fa9f24ccf878525957b Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 16 Nov 2026 15:57:14 +0100 Subject: [PATCH] earned_time 0.22.0: gaming budget switch off Dated switch GAMING_UNLIMITED_FROM (2026-11-16) and gaming_enforced(day); Resolution.gaming_enforced; leisure_active False from it; sick shutdown uses rung pay from it. No public name removed; shutdown unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWViGJJaqBKGr1Hbppr --- earned_time/README.md | 20 +++- earned_time/earned_time/__init__.py | 7 ++ earned_time/earned_time/_gaming.py | 38 +++++++ earned_time/earned_time/_leisure.py | 5 +- earned_time/earned_time/_resolution.py | 4 + earned_time/earned_time/_resolve.py | 21 +++- .../earned_time/tests/test_gaming_off.py | 104 ++++++++++++++++++ earned_time/earned_time/tests/test_leisure.py | 9 ++ earned_time/pyproject.toml | 2 +- 9 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 earned_time/earned_time/_gaming.py create mode 100644 earned_time/earned_time/tests/test_gaming_off.py diff --git a/earned_time/README.md b/earned_time/README.md index 7b31d7f..843d4dc 100644 --- a/earned_time/README.md +++ b/earned_time/README.md @@ -122,6 +122,23 @@ it, and ignore answers for an earner of another day's registry. **Gap waiver** (`ANKI_WAIVED_FROM`, 2026-10-09): no anki/automation earner. +## No gaming budget (0.22.0) + +kuhy's decision, 2026-11-16: the stick of gaming time is gone; only shutdown +is the carrot (all locks done = 23:00, the ladder is unchanged). One dated +switch, `GAMING_UNLIMITED_FROM` (2026-11-16, a gaming day), and +`gaming_enforced(day) -> bool` (`day < GAMING_UNLIMITED_FROM`), also carried as +`Resolution.gaming_enforced`. Nothing was removed: `gaming_minutes`, `GAMING_*` +and the leisure API still resolve numbers, so old imports keep working, but +from the switch they are history, not a limit. A consumer that applies a +budget must read the switch and lift its limit on `False`. + +- `leisure_active(day)` is `False` from the switch (no budget to be a leisure + one); `resolve`/`base_for` with `leisure=None` then use the old base. +- A sick day's shutdown is 20:00 plus the credited terms' **shutdown** (rung) + pay from the switch (gaming pay before it), capped at the ceiling. The two + are equal on the unified ladder, so no number moves. + ## Gate maturity (0.6.0) How far to trust a gate, computed from its ledger by `maturity()`, is in @@ -135,6 +152,7 @@ How far to trust a gate, computed from its ledger by `maturity()`, is in leisure=None) -> Base` — the day's floors. `gaming_base_minutes_for(day)`, `gaming_ceiling_minutes_for(day) -> int` — the gaming base and cap. `leisure_from(path=LEISURE_FROM_PATH) -> date`, `leisure_active(day, path=...)`. + `gaming_enforced(day) -> bool`, `GAMING_UNLIMITED_FROM` (0.22.0). - `done_today(earner, ledger, key_file, *, now=None) -> bool | None` - `first_credit_at(earner, ledger, key_file, day) -> float | None` — unix time of the earliest verified credit for `day`, on its matcher's stamp @@ -214,7 +232,7 @@ Unbacked timer time pays 0 from 2026-11-08 (focus_project 0.10.0). ## Install ```console -pip install --user --break-system-packages --no-deps "earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.20.0#subdirectory=earned_time" +pip install --user --break-system-packages --no-deps "earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.22.0#subdirectory=earned_time" ``` The root `steam-backlog-enforcer.service` sets `HOME=/home/kuhy` and imports from diff --git a/earned_time/earned_time/__init__.py b/earned_time/earned_time/__init__.py index 071588e..995cd89 100644 --- a/earned_time/earned_time/__init__.py +++ b/earned_time/earned_time/__init__.py @@ -22,6 +22,10 @@ A consumer's whole integration:: day = earned_time.resolve(answers, sick=sickdays.is_sick_day()) apply(day.gaming_minutes) +``gaming_enforced(day)`` (0.22.0): from ``GAMING_UNLIMITED_FROM`` there is no +gaming budget; shutdown is the only carrot. ``Resolution.gaming_enforced`` +carries it; a consumer that applies a budget lifts the limit on ``False``. + ``sick`` (0.11.0) only raises shutdown to at least 20:00; gaming is unchanged. ``leisure`` (0.16.0): ``None`` follows the switch file on ``day``, ``True`` prices gaming with the leisure base and cap (the shadow budget), ``False`` @@ -44,6 +48,7 @@ from earned_time._credits import ( ) from earned_time._evidence import real_credit from earned_time._focus import FOCUS_LEDGER, FocusEarner +from earned_time._gaming import GAMING_UNLIMITED_FROM, gaming_enforced from earned_time._ladder import ( ANKI_WAIVED_FROM, LADDER, @@ -109,6 +114,7 @@ __all__ = [ "FOCUS_LEDGER", "GAMING_BASE_MINUTES", "GAMING_CEILING_MINUTES", + "GAMING_UNLIMITED_FROM", "LADDER", "LADDER_FROM", "LEETCODE", @@ -153,6 +159,7 @@ __all__ = [ "first_credit_at", "gaming_base_minutes_for", "gaming_ceiling_minutes_for", + "gaming_enforced", "ladder_for", "leisure_active", "leisure_from", diff --git a/earned_time/earned_time/_gaming.py b/earned_time/earned_time/_gaming.py new file mode 100644 index 0000000..6149aa8 --- /dev/null +++ b/earned_time/earned_time/_gaming.py @@ -0,0 +1,38 @@ +# Copyright (c) 2026 Krzysztof Rudnicki +"""The gaming stick is gone: from ``GAMING_UNLIMITED_FROM`` nothing limits gaming. + +kuhy's decision (2026-11-16): the daily gaming budget is removed completely. +Only shutdown time is the carrot -- everything done still shuts down at 23:00, +the ladder, its floor and every rung are unchanged. A removed limit is +raise-only, so the date is the day the decision was taken and it lands the +same day. + +Nothing is deleted: ``gaming_minutes``, ``GAMING_*`` and the leisure API keep +resolving numbers (history, the shadow budget), so a consumer still importing +them keeps working. A consumer that *applies* a gaming budget must ask +:func:`gaming_enforced` (or read ``Resolution.gaming_enforced``) first and, on +``False``, lift the limit instead of enforcing the number. +""" + +from __future__ import annotations + +from datetime import date +from typing import Final + +# The first day without a gaming budget. A gaming day (06:00 start): a consumer +# billing before 06:00 passes the gaming day, not the calendar day. +GAMING_UNLIMITED_FROM: Final = date(2026, 11, 16) + + +def gaming_enforced(day: date) -> bool: + """Is a gaming budget enforced on ``day``? ``False`` from the switch date. + + Args: + day: The gaming day. + + Returns: + ``day < GAMING_UNLIMITED_FROM``. Before it the budget is exactly what + 0.21.0 resolved; from it ``resolve(...).gaming_minutes`` is history, + not a limit. + """ + return day < GAMING_UNLIMITED_FROM diff --git a/earned_time/earned_time/_leisure.py b/earned_time/earned_time/_leisure.py index a8d66aa..35b8ef8 100644 --- a/earned_time/earned_time/_leisure.py +++ b/earned_time/earned_time/_leisure.py @@ -26,6 +26,7 @@ import re import stat from typing import Final +from earned_time._gaming import gaming_enforced from earned_time._policy import GAMING_BASE_MINUTES, GAMING_CEILING_MINUTES # Parked far ahead: the switch file moves it, never a same-day cut (2026-09-26). @@ -78,8 +79,10 @@ def leisure_active(day: date, path: Path = LEISURE_FROM_PATH) -> bool: """Is ``day`` (a gaming day) on the leisure budget? ``day >= leisure_from()``. The only way a consumer may ask "is Phase 2 on?"; none reads the file. + Always ``False`` from ``GAMING_UNLIMITED_FROM`` (0.22.0): no gaming budget + exists any more, so none can be a leisure one. """ - return day >= leisure_from(path) + return gaming_enforced(day) and day >= leisure_from(path) def is_leisure(day: date, *, leisure: bool | None = None) -> bool: diff --git a/earned_time/earned_time/_resolution.py b/earned_time/earned_time/_resolution.py index 293c2b4..c9aa65a 100644 --- a/earned_time/earned_time/_resolution.py +++ b/earned_time/earned_time/_resolution.py @@ -62,6 +62,9 @@ class Resolution: sick_lift_minutes: How far the sick floor raised ``shutdown_minutes`` above base plus terms (``0`` unless sick): a consumer adding live credits on top pays them out of this first, as with a grace lift. + gaming_enforced: Whether ``day`` has a gaming budget at all (0.22.0, + :func:`earned_time.gaming_enforced`). ``False``: ``gaming_minutes`` + is history, a consumer must not enforce it. """ day: date @@ -71,6 +74,7 @@ class Resolution: shutdown_minutes: int sick: bool = False sick_lift_minutes: int = 0 + gaming_enforced: bool = True def term(self, name: str) -> Term: """The term of the earner called ``name``. diff --git a/earned_time/earned_time/_resolve.py b/earned_time/earned_time/_resolve.py index 5722060..c1507df 100644 --- a/earned_time/earned_time/_resolve.py +++ b/earned_time/earned_time/_resolve.py @@ -26,6 +26,7 @@ import logging from typing import TYPE_CHECKING, Final from earned_time._focus import FocusEarner +from earned_time._gaming import gaming_enforced from earned_time._ladder import on_ladder, shutdown_ceiling_for from earned_time._leisure import base_minutes, ceiling_minutes, is_leisure from earned_time._maturity import confirmed_start, penalty_start @@ -167,8 +168,16 @@ def _term(item: Earner, answers: Mapping[str, Answer], day: date) -> Term: def _sick_or(earned: int, terms: list[Term], day: date) -> int: - """A sick day's shutdown: 20:00 plus gaming pay, never below ``earned``.""" - return max(earned, sick_shutdown_from(sum(t.gaming_minutes for t in terms), day)) + """A sick day's shutdown: 20:00 plus the paid terms, never below ``earned``. + + The terms are paid at gaming pay before ``GAMING_UNLIMITED_FROM`` and at + their shutdown (rung) pay from it: the gaming budget no longer exists. + """ + if gaming_enforced(day): + paid = sum(t.gaming_minutes for t in terms) + else: + paid = sum(t.shutdown_minutes for t in terms) + return max(earned, sick_shutdown_from(paid, day)) def resolve( @@ -196,14 +205,17 @@ def resolve( Only ever delays a penalty; omitted, 0.5.0's ``penalty_from``. sick: The day is a sick day (the consumer asks ``sickdays``): shutdown is 20:00 plus the terms' gaming pay - (:func:`~earned_time._sick.sick_shutdown_from`, 0.13.0). + (:func:`~earned_time._sick.sick_shutdown_from`, 0.13.0), from + ``GAMING_UNLIMITED_FROM`` their shutdown pay (0.22.0). Gaming and every term are unchanged. leisure: ``None`` (0.16.0 default): the switch file decides on ``day``. ``True`` (0.14.0): the leisure base and cap whatever the day says -- the shadow budget. ``False``: the old base and cap whatever the file says -- a gaming day (06:00) still before the switch while the calendar day is past it. Terms, penalties and - shutdown are unchanged. + shutdown are unchanged. From ``GAMING_UNLIMITED_FROM`` (0.22.0) + ``None`` is always the old base: read + ``Resolution.gaming_enforced``, the budget is not a limit. Returns: The resolution, with a term for every registered earner. @@ -233,4 +245,5 @@ def resolve( shutdown_minutes=shutdown, sick=sick, sick_lift_minutes=shutdown - earned, + gaming_enforced=gaming_enforced(target), ) diff --git a/earned_time/earned_time/tests/test_gaming_off.py b/earned_time/earned_time/tests/test_gaming_off.py new file mode 100644 index 0000000..06be613 --- /dev/null +++ b/earned_time/earned_time/tests/test_gaming_off.py @@ -0,0 +1,104 @@ +# Copyright (c) 2026 Krzysztof Rudnicki +"""The gaming stick is gone (0.22.0): one dated switch, shutdown stays.""" + +from __future__ import annotations + +from datetime import date, timedelta +from typing import TYPE_CHECKING + +import pytest + +import earned_time +from earned_time import ( + GAMING_UNLIMITED_FROM, + Earner, + gaming_enforced, + leisure_active, + resolve, + sick_shutdown_from, +) + +if TYPE_CHECKING: + from pathlib import Path + +SWITCH = date(2026, 11, 16) +BEFORE = SWITCH - timedelta(days=1) +AFTER = SWITCH + timedelta(days=1) +ALL = {"workout": 1, "leetcode": 1, "reading": 1, "tutor": 60} +NONE = dict.fromkeys(ALL, 0) +ONE_MISSING = {**ALL, "reading": 0} + + +def test_the_switch_is_kuhys_date() -> None: + assert date(2026, 11, 16) == GAMING_UNLIMITED_FROM + + +@pytest.mark.parametrize( + ("day", "enforced"), [(BEFORE, True), (SWITCH, False), (AFTER, False)] +) +def test_gaming_enforced_around_the_switch(day: date, *, enforced: bool) -> None: + assert gaming_enforced(day) is enforced + + +@pytest.mark.parametrize( + ("day", "enforced"), [(BEFORE, True), (SWITCH, False), (AFTER, False)] +) +def test_resolution_reports_it(day: date, *, enforced: bool) -> None: + assert resolve(ALL, day).gaming_enforced is enforced + + +def test_leisure_is_off_from_the_switch( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + path = tmp_path / "leisure_from" + path.write_bytes(b"2026-11-09\n") + monkeypatch.setattr("earned_time._leisure.LEISURE_FROM_PATH", path) + assert leisure_active(BEFORE, path) + assert not leisure_active(SWITCH, path) + assert not leisure_active(AFTER, path) + + +def test_every_public_name_survives() -> None: + for name in ( + "GAMING_BASE_MINUTES", + "GAMING_CEILING_MINUTES", + "LEISURE_FROM", + "LEISURE_FROM_PATH", + "gaming_base_minutes_for", + "gaming_ceiling_minutes_for", + "leisure_active", + "leisure_from", + ): + assert hasattr(earned_time, name) + + +@pytest.mark.parametrize("day", [SWITCH, AFTER]) +def test_all_done_is_23_00_and_one_missing_is_less(day: date) -> None: + assert resolve(ALL, day).shutdown_minutes == 23 * 60 + missing = resolve(ONE_MISSING, day).shutdown_minutes + assert missing == 22 * 60 + assert resolve(NONE, day).shutdown_minutes == 18 * 60 + + +def test_sick_pay_is_the_rung_pay_after_the_switch( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Gaming pay is made to differ from the rung, to see which one is used.""" + monkeypatch.setattr(Earner, "gaming_for", lambda _s, units: 500 if units else 0) + answers = {**NONE, "leetcode": 1} + before = resolve(answers, BEFORE, sick=True) + after = resolve(answers, SWITCH, sick=True) + assert before.shutdown_minutes == 23 * 60 # 20:00 + gaming 500, capped + assert after.shutdown_minutes == sick_shutdown_from(60, SWITCH) == 21 * 60 + + +@pytest.mark.parametrize("day", [BEFORE, SWITCH]) +@pytest.mark.parametrize("answers", [NONE, {**NONE, "leetcode": 1}, ONE_MISSING, ALL]) +def test_sick_numbers_are_equal_today(day: date, answers: dict[str, int]) -> None: + """Rung pay equals gaming pay on the unified ladder: nothing moves.""" + sick = resolve(answers, day, sick=True) + paid = sum(t.gaming_minutes for t in sick.terms) + assert sick.shutdown_minutes == max( + resolve(answers, day).shutdown_minutes, + sick_shutdown_from(paid, day), + ) diff --git a/earned_time/earned_time/tests/test_leisure.py b/earned_time/earned_time/tests/test_leisure.py index d4243bd..71671ad 100644 --- a/earned_time/earned_time/tests/test_leisure.py +++ b/earned_time/earned_time/tests/test_leisure.py @@ -5,6 +5,8 @@ from __future__ import annotations from datetime import date, timedelta +import pytest + from earned_time import ( GAMING_BASE_MINUTES, GAMING_CEILING_MINUTES, @@ -17,6 +19,13 @@ from earned_time import ( resolve, ) + +@pytest.fixture(autouse=True) +def _gaming_still_budgeted(monkeypatch: pytest.MonkeyPatch) -> None: + """These tests price 2027 days: put the 0.22.0 no-budget switch beyond them.""" + monkeypatch.setattr("earned_time._gaming.GAMING_UNLIMITED_FROM", date(2100, 1, 1)) + + EVE = LEISURE_FROM - timedelta(days=1) FULL = {"workout": 1, "leetcode": 1, "reading": 1, "tutor": 60} NONE = dict.fromkeys(FULL, 0) diff --git a/earned_time/pyproject.toml b/earned_time/pyproject.toml index d1fdd5c..2570e4b 100644 --- a/earned_time/pyproject.toml +++ b/earned_time/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "earned-time" -version = "0.21.0" +version = "0.22.0" description = "Penalty-then-reward registry: what every gate app earns in gaming time and shutdown time" requires-python = ">=3.14" dependencies = []