utils/gatelock/gatelock/__init__.py
Krzysztof kuhy Rudnicki 9f271b0d37 Fix the cap hook in CI, and the re-exports its --all-files run exposed
The hook entry was an absolute /home/kuhy/utils path, copied from a config
written for ~/.claude where it only ever ran locally. On an Actions runner
that is exit code 127 — "No such file or directory" — so gatelock-precommit
and crdt-sync-precommit failed on every commit of this refactor while the
hook silently checked nothing. Now repo-relative, matching the sibling hooks
(`entry: scripts/check_subproject_scope.sh`): pre-commit always runs from the
git root, so it resolves the same in both places.

Fixing that made the CI configs runnable locally, and `--all-files` then found
what per-file runs had missed — ruff pruning imports that exist *for* their
re-export. `import crdt_sync` was broken three separate ways (FileSyncStateStore,
encode_key, FileCredentialStore). Each affected module now states an explicit
__all__ so the autofixer cannot take them again, and the two files that pushed
past the cap once __all__ was added are split further:

  _firebase.py 260 -> 247 + _fberrors 25
  _sync.py     257 -> 188 + _syncargs 91

Test patch targets followed the code they patch: gatelock._outputs.shutil ->
_xrandr.shutil, gatelock._arbiter.Path -> _claims.Path.

gatelock and crdt-sync both pass `pre-commit run --all-files` in full;
389 and 259 tests at 100% branch coverage; the root gate exits 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
2026-08-22 15:52:59 +02:00

136 lines
3.1 KiB
Python

"""Shared lock-window and HMAC log-integrity backend for blocking-overlay apps.
Used by ``screen-locker``, ``diet-guard`` and ``wake-alarm``, which all need
the same thing: cover every monitor the user can actually see, take the input
grab, and stay up until their own condition is met.
"""
from __future__ import annotations
from gatelock._arbiter import (
RANK_DIET_GUARD,
RANK_SCREEN_LOCKER,
RANK_WAKE_ALARM,
Arbiter,
ArbiterVerdict,
Claim,
default_runtime_dir,
grab_strength,
)
from gatelock._detect import OutputChangeDetector
from gatelock._escape import (
EscapeDraft,
EscapeHistory,
EscapePolicy,
EscapeTracker,
)
from gatelock._fitcheck import FitResult, measure_fit, report_fit
from gatelock._guards import assert_not_under_pytest, wait_for_x_server
from gatelock._keyboard import bind_activate, bind_cancel, escape_text_tab_trap
from gatelock._outputs import (
Output,
OutputEnumerator,
OutputRect,
OutputScan,
enumerate_outputs,
)
from gatelock._queue import (
QUEUE_DEADLINE_SECONDS,
QUEUE_POLL_SECONDS,
QueueResult,
stronger_claims,
wait_for_turn,
)
from gatelock._randr import RandrBackend
from gatelock._recovery import RecoveryLoop, RecoveryReport
from gatelock._root import GateRoot
from gatelock._scrollable import ScrollableSurface
from gatelock._surfaces import (
SurfaceBuilder,
SurfaceDelta,
SurfaceInfo,
SurfaceSet,
mirror_text_widgets,
needs_backdrop_root,
)
from gatelock._vt import disable_vt_switching, restore_vt_switching
from gatelock._window import (
LockConfig,
LockWindow,
LockWindowHooks,
SpaceStep,
TypeRole,
)
from gatelock._xrandr import parse_xrandr_query
from gatelock.widget_group import WidgetGroup
from gatelock.widgets import (
DEFAULT_WRAP,
ButtonStyle,
ButtonVariant,
RowStyle,
heading,
make_button,
row,
)
__all__ = [
"DEFAULT_WRAP",
"QUEUE_DEADLINE_SECONDS",
"QUEUE_POLL_SECONDS",
"RANK_DIET_GUARD",
"RANK_SCREEN_LOCKER",
"RANK_WAKE_ALARM",
"Arbiter",
"ArbiterVerdict",
"ButtonStyle",
"ButtonVariant",
"Claim",
"EscapeDraft",
"EscapeHistory",
"EscapePolicy",
"EscapeTracker",
"FitResult",
"GateRoot",
"LockConfig",
"LockWindow",
"LockWindowHooks",
"Output",
"OutputChangeDetector",
"OutputEnumerator",
"OutputRect",
"OutputScan",
"QueueResult",
"RandrBackend",
"RecoveryLoop",
"RecoveryReport",
"RowStyle",
"ScrollableSurface",
"SpaceStep",
"SurfaceBuilder",
"SurfaceDelta",
"SurfaceInfo",
"SurfaceSet",
"TypeRole",
"WidgetGroup",
"assert_not_under_pytest",
"bind_activate",
"bind_cancel",
"default_runtime_dir",
"disable_vt_switching",
"enumerate_outputs",
"escape_text_tab_trap",
"grab_strength",
"heading",
"make_button",
"measure_fit",
"mirror_text_widgets",
"needs_backdrop_root",
"parse_xrandr_query",
"report_fit",
"restore_vt_switching",
"row",
"stronger_claims",
"wait_for_turn",
"wait_for_x_server",
]