This document is the canonical registry of correctness invariants for WineBot.
- A
oneshotsession incompletedstate is terminal and cannot be resumed. - A
completedsession cannot be suspended. - Suspend/resume/shutdown transitions must be idempotent under repeated requests.
- Session handover (
resumeinto a new target) must either complete or roll back without partial active-session state.
Code:
api/routers/lifecycle.pyapi/utils/files.py
Tests:
tests/test_lifecycle_hardened.pytests/test_invariants.py
- Human priority is absolute: agent never takes control in effective
human-only. - In interactive mode, agent control requires an active lease.
- In
agent-only, active controller must beAGENT. - User input and
STOP_NOWrevoke agent control.
Code:
api/core/broker.pyapi/routers/control.py
Tests:
tests/test_policy.pytests/test_lifecycle_hardened.pytests/test_invariants.py
MODE=headlesscannot run with effectivehuman-only.MODE=headless+ effectivehybridis blocked unlessWINEBOT_ALLOW_HEADLESS_HYBRID=1.BUILD_INTENT=rel-runnercannot run withMODE=interactive.
Code:
api/core/config_guard.pyapi/server.py(startup admission)api/routers/control.py(runtime admission)
Tests:
tests/test_config_guard.pytests/test_profile_matrix.pytests/test_invariants.py
- Critical state files are written atomically (
fsync+replace) and fail closed on IO errors. - Critical state writes are not silently ignored.
- Runtime temporary state files used for atomic commits are non-hidden and cleaned up after replace.
Code:
api/utils/files.py
Tests:
tests/test_invariants.py
Endpoint:
GET /health/invariants
Behavior:
- Returns
ok=falseand structured violations when runtime invariant checks fail. /healthincludesinvariants_okand degrades status when violations are present.