mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-22 15:02:17 +01:00
Drop type-ignores, trim CLAUDE.md to 250 lines
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
The bypass commit left three type: ignore comments in its tests and pushed AGENTS.md 5 lines over the cap; both fail the CI mirror. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7a2340bbf8
commit
0781c42222
23
AGENTS.md
23
AGENTS.md
@ -15,11 +15,10 @@ two pieces came back, because the phone **cannot** ring while powered off: a
|
||||
temporary escape hatch (until 2026-10-15). All of it, and the data contract
|
||||
the phone, PC and focus-owner share: **`DOCS-wake-enforcement.md`**. Anything
|
||||
else from the old PC alarm still needs a reason the phone can't do it.
|
||||
|
||||
**Bypasses** (the launcher "Pause app" silenced the ring on 11-20 and
|
||||
11-22): focus-owner pins the enforcement apps, WakeAlarm is a device admin,
|
||||
and a pause, admin removal, revoked permission or killed ring that gets
|
||||
through is a miss plus an immediate PC ring: **`DOCS-bypass.md`**.
|
||||
**Bypasses** (launcher "Pause app" silenced the ring 11-20 and 11-22):
|
||||
focus-owner pins the enforcement apps, WakeAlarm is a device admin, and a
|
||||
pause, admin removal, revoked permission or killed ring that gets through is a
|
||||
miss plus an immediate PC ring: **`DOCS-bypass.md`**.
|
||||
|
||||
## The dismiss sequence (phone)
|
||||
|
||||
@ -202,16 +201,13 @@ old `/usr/local/bin/shutdown` wrapper wherever one survives. `install.sh` calls
|
||||
installing** — renaming or deleting it breaks a fresh install. That call is
|
||||
non-fatal and gated on `sudo -n`: the cleanup needs root, and a hard failure
|
||||
would abort an install that had already placed the package and the timer.
|
||||
|
||||
**`/etc/sudoers.d/wake-alarm` is deliberately left in place** even by a full
|
||||
uninstall. Since 2026-10-01 it is live again: the RTC self-wake's `rtcwake`
|
||||
and the root ring unit's `systemctl start|stop` lines live there.
|
||||
**`/etc/sudoers.d/wake-alarm` stays even after a full uninstall:** the RTC
|
||||
self-wake's `rtcwake` and the root ring unit's `systemctl` lines live there.
|
||||
|
||||
## Operational gotchas
|
||||
|
||||
- **`wake_state.json` is runtime state, not tracked.** It holds the
|
||||
HMAC-signed once-per-day latch. It was accidentally committed in the
|
||||
monorepo and must stay gitignored here.
|
||||
- **`wake_state.json` is runtime state, not tracked** (the HMAC-signed
|
||||
once-per-day latch). It was once committed in the monorepo; keep it ignored.
|
||||
- **`WAKE_STATE_FILE` is redirected in `tests/conftest.py`, not per-file.** A
|
||||
per-file redirect gets forgotten when a new writer appears (`_trigger` was
|
||||
one), and the failure is silent: a green suite that stamped the live file.
|
||||
@ -244,8 +240,7 @@ alarm). The dev venv lacks `gatelock`: anything importing `_state` (incl.
|
||||
- Don't point the trigger at anything but `morning-routine.service` (or the
|
||||
workout lock never runs), don't remove its once-per-day latch, and don't
|
||||
raise the log level of `_sync`'s degraded-read paths.
|
||||
- Don't let the bypass skip the walk, and don't add a challenge kind that
|
||||
hides its own prompt.
|
||||
- Don't let the bypass skip the walk or add a challenge that hides its prompt.
|
||||
- Don't close the ring screen on dismiss when a session should follow, don't
|
||||
add a re-ring cancel beyond the session's own `finishSession`, and don't
|
||||
restore a re-ring instant that has passed (BOOT_COMPLETED replays on launch).
|
||||
|
||||
@ -8,7 +8,9 @@ and the day's own cap, until a newer ``dismissed`` arrives.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import replace
|
||||
from datetime import datetime, timedelta
|
||||
from typing import TypedDict, Unpack
|
||||
|
||||
import pytest
|
||||
|
||||
@ -38,10 +40,22 @@ def _at(minutes: float) -> datetime:
|
||||
return A + timedelta(minutes=minutes)
|
||||
|
||||
|
||||
def _facts(minutes: float, bypass_minutes: float | None, **overrides: object) -> Facts:
|
||||
class _Overrides(TypedDict, total=False):
|
||||
free_day: bool
|
||||
sick_day: bool
|
||||
escaped: bool
|
||||
session_started: bool
|
||||
ring_started: bool
|
||||
latch: Latch | None
|
||||
settled: str | None
|
||||
|
||||
|
||||
def _facts(
|
||||
minutes: float, bypass_minutes: float | None, **overrides: Unpack[_Overrides]
|
||||
) -> Facts:
|
||||
bypass_at = None if bypass_minutes is None else _at(bypass_minutes)
|
||||
fields: dict[str, object] = {"free_day": False, **overrides}
|
||||
return Facts(now=_at(minutes), alarm_at=A, bypass_at=bypass_at, **fields) # type: ignore[arg-type]
|
||||
base = Facts(now=_at(minutes), alarm_at=A, free_day=False, bypass_at=bypass_at)
|
||||
return replace(base, **overrides)
|
||||
|
||||
|
||||
def _capped_latch() -> Latch:
|
||||
@ -82,7 +96,7 @@ class TestDecide:
|
||||
[({"free_day": True}, FREE_DAY), ({"sick_day": True}, SICK_DAY)],
|
||||
)
|
||||
def test_free_and_sick_days_never_ring(
|
||||
self, overrides: dict[str, object], reason: str
|
||||
self, overrides: _Overrides, reason: str
|
||||
) -> None:
|
||||
decision = decide(_facts(50, 45, **overrides))
|
||||
assert not decision.ring
|
||||
|
||||
@ -15,6 +15,8 @@ if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
A = datetime(2026, 11, 23, 7, 0).astimezone()
|
||||
# The argv lists the last ``_run`` handed to ``_ok``, newest run only.
|
||||
CALLS: list[object] = []
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@ -30,13 +32,13 @@ def _run(minutes: float, *, graphical: bool, started: bool = True) -> str | None
|
||||
patch.object(_ring_probe, "_ok", return_value=(started, "out")) as ok,
|
||||
):
|
||||
result = _ring_probe.maybe_probe(A + timedelta(minutes=minutes), A)
|
||||
_run.calls = ok.call_args_list # type: ignore[attr-defined]
|
||||
CALLS[:] = [call.args[0] for call in ok.call_args_list]
|
||||
return result
|
||||
|
||||
|
||||
def test_it_starts_the_unit_at_a_minus_five_with_no_session(done_file: Path) -> None:
|
||||
assert _run(-5, graphical=False) == "started"
|
||||
assert _run.calls[0].args[0] == [ # type: ignore[attr-defined]
|
||||
assert CALLS[0] == [
|
||||
"sudo",
|
||||
"-n",
|
||||
"systemctl",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user