feat(monitor): persist health and recovery cooldown

Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
ZeusinaandGPT-6 Bot committed 2026-10-10 08:04:48 +03:00
1 parent 5c540ce03b
commit 0c51fd0196
9 files changed
+497 -9

No files matched your search

+17 -2
View File
@@ -35,7 +35,7 @@ threshold and cooldown are validated future recovery policy settings only:
The future managed target is a **brand-new prod-like zapret2-ss container in the
test environment only**, not the existing container. Its stable configurable
SOCKS endpoint must be loopback-accessible to this probe and same-host Xray.
This increment does not create or change any container, persist health, apply
The one-shot command does not persist health. This increment does not create or change any container, apply
configuration, restart services or roll back anything. Xray configuration is
out of scope and will be configured separately by the user. Run this command in
the host network context where that loopback endpoint is reachable; Docker
@@ -142,9 +142,24 @@ it must be writable. In Docker, mount that directory to retain history:
docker run --rm -v autotune-data:/var/lib/zapret-autotune zapret-autotune status
```
Schema version 3 is initialized transactionally on `tune` and `status`; subsequent
Schema version 4 is initialized transactionally on `tune` and `status`; subsequent
opens are idempotent and newer, unsupported schema versions are rejected.
Schema v4 adds a policy-state foundation keyed by stable service ID (not a cache
hostname or SOCKS address): last probe time, consecutive failures, recovery lock
and cooldown expiry. Internal operations accept injected time: success resets the
streak, failures increment it, and an atomic recovery acquisition requires the
configured threshold, an elapsed cooldown and no running recovery. Completion,
successful or failed, requires the exact per-acquisition ownership token returned
by acquisition, clears the lock and starts cooldown from completion time. Stale
or duplicate completion is rejected without changing the lock, token or cooldown,
even after a newer acquisition starts. A crash still leaves the durable lock held;
the token does not introduce automatic expiry or crash reconciliation.
State survives reopening the database; a crash during recovery leaves the lock
held, pending future explicit crash reconciliation. Existing history/candidates
are unchanged. These operations are not wired to `health youtube` or recovery:
**no daemon, autonomous probe, apply or container/Xray changes are added**.
Schema v3 adds immutable strategy candidate definitions (group, declared exact
endpoints, args and normalized-args fingerprint) and endpoint/protocol evidence.
Each newly successful tune saves its exact verified combined frontend profile for