mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-19 23:54:21 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
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) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
kuhy 2026-11-11: game-design research needs Librarian (app 4197610) actually played during the 6-day total block. New root command total-block-research --until T opens ONE window per lock: <= 48 h, never past the lock end, a rerun never extends it. The command only validates and records (/var/lib/steam-backlog- enforcer, root 0700; lock id + deadline + two latches). The daemon opens and closes everything: Steam hosts names, the store block, the total-block chain (IP cache kept) and the steam package, reinstalled with only guard-lib's package-block hook masked for that one pacman call (--hookdir, proved in a guest). Lock file, hook and end date are never touched. Browser-game sites stay null-routed. Only Librarian may run: loop-local allowed set, strict mode (no whitelist exceptions, no zero-achievement games), launchers and counted games killed; state.json is never read or written. Expiry latches the record, then the ordinary tick re-applies hosts (now reconciled each tick), chain, uninstall and purge; the normal store block is restored once, unconditionally. Failure modes: missing/corrupt/unparseable record = no window and a corrupt one also refuses a new window (fail closed); a clock set back cannot reopen a latched window. Checked: 3290 tests at 100% coverage; whole-tree pylint 10/10 run in three parts (the hook exceeds the 60 s cap, so SKIP=pylint here); vmbox guest with real guardctl package-block and the real unit, window opened, Librarian-only enforced, clock moved past the deadline and the full block re-applied. Not verified on the host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWzuCEg1m87jpKyRrw
69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
"""Per-pass guards of the enforce loop: who may stay installed, and who is named.
|
|
|
|
Split out of :mod:`steam_backlog_enforcer._enforce_loop` to keep it under the
|
|
250-line cap once it also had to drive the control socket.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import TYPE_CHECKING
|
|
|
|
from steam_backlog_enforcer._actions import allowed_games
|
|
from steam_backlog_enforcer.enforcer import send_notification
|
|
from steam_backlog_enforcer.game_uninstall import (
|
|
get_installed_games,
|
|
is_infrastructure_app,
|
|
is_protected_app,
|
|
uninstall_game,
|
|
)
|
|
|
|
if TYPE_CHECKING:
|
|
from steam_backlog_enforcer.config import State
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def allowed_names(state: State) -> str:
|
|
"""Return a human-readable list of the games the user may play.
|
|
|
|
Args:
|
|
state: Current enforcer state.
|
|
|
|
Returns:
|
|
Comma-separated game names, or "your assigned game" when none is set.
|
|
"""
|
|
names = [name for _, name in allowed_games(state) if name]
|
|
return ", ".join(names) if names else "your assigned game"
|
|
|
|
|
|
def guard_installed_games(allowed: set[int], *, strict: bool = False) -> int:
|
|
"""Remove any unauthorized game manifests + files. Runs every loop.
|
|
|
|
Args:
|
|
allowed: Every app id that may stay installed — the assignment plus
|
|
any concurrent manual picks.
|
|
strict: Spare only runtimes besides *allowed*, not approved exceptions
|
|
or zero-achievement games (the research window).
|
|
|
|
Returns number of games removed this pass.
|
|
"""
|
|
if not allowed:
|
|
return 0
|
|
spared = is_infrastructure_app if strict else is_protected_app
|
|
installed = get_installed_games()
|
|
count = 0
|
|
for app_id, name in installed:
|
|
if app_id in allowed:
|
|
continue
|
|
if spared(app_id):
|
|
continue
|
|
|
|
logger.warning(
|
|
"Unauthorized game detected — removing: %s (AppID=%d)", name, app_id
|
|
)
|
|
if uninstall_game(app_id, name):
|
|
count += 1
|
|
send_notification("🗑️", f"{name} · {app_id}")
|
|
return count
|