Files
zapret-autotune/RESOURCE_MONITOR.md
T
ZeusinaandGPT-6 Bot d324b4137b docs: record scoped managed v2 verification
Record bounded typed qualification, apply, monitor fault/repair and dated independent cleanup; retain body/live-FD and untested v1/YouTube acceptance limits. Keep adapter registry and version-bound module migration explicitly future work.

Co-authored-by: GPT-6 <gpt-6@openai.com>
2026-10-15 15:33:26 +03:00

128 lines
8.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Periodic configured resource checks
`managed monitor --resource-config FILE` runs resource-config v1 or v2 periodically.
PID 1 selects the same mode when `ZAPRET_AUTOTUNE_RESOURCE_CONFIG` is nonempty;
unset preserves the existing YouTube monitor. The modes share one singleton
lock. Supply an absolute container-visible config path (for example mount a
read-only operator config directory using a Compose override). Configuration
must be a regular root/runtime-owned, non-writable-by-others file without
symlink/hardlink aliases. Environment references are resolved on every reload.
Each resource accepts `interval_ms` (default 300000) and `cooldown_ms` (default
30000), both integers in [100, 86400000]. Checks are sequential round robin
with independent due times; `tls: both` requires both passes. Ordinary DNS,
TLS, timeout or expectation failures mark only that resource DEGRADED and
retry after its cooldown. There is **no strategy selection, recovery or apply**,
and no no-strategy two-hour pause. HEALTHY means configured checks passed,
not playback health, generic recovery or whole-production READY: HEALTHY is
**CHECKS_ONLY**, never READY. The scheduling, status, persistence and lifecycle
base passed native full/race checks, independent security review and isolated
remote fault acceptance for `4efc066` plus ownership-status fix `5c85f3f`.
See [PROGRESS.md](PROGRESS.md) for supplied evidence and its narrow scope.
Both versions are bounded to 16 services / 64 resources with stable configured IDs;
valid configuration/state does not imply an automatic strategy assignment.
V1 remains HTTP GET/HEAD only, with explicit `kind: http`. See
`resource-check-v2.example.json` for v2: omitted kind defaults to `http`; all
expectations explicitly declare statuses/content_type/min_bytes/max_bytes.
`image` is GET-only, [200], PNG/JPEG with full bounded decode (5 MiB maximum,
16 MiPixels); public GIF is deferred pending an aggregate frame/pixel budget,
without changing legacy GIF adapters. `mp4_range` is GET-only, [206], audio/mp4
or video/mp4, 16–65536 bytes, checked Content-Range and ftyp. Range stays fixed
at 0-65535; a smaller max_bytes bounds the actual response, not the requested end.
Operator Range/Accept-Encoding headers remain forbidden in both versions.
Timeouts (100–30000 ms) and declared byte limits apply to every kind. Typed
wire-valid semantic failures degrade checks; malformed/unsafe execution cannot
qualify a candidate. V2 version/kind/expectations invalidate old HMAC rows/proofs;
historic v1 fingerprints remain unchanged. MP4 prefix health is not playback or
YouTube proof: three discovered CDNs, >=1024-byte producer samples, warmup,
suffix authorization and adaptive policy still belong to the legacy adapter.
Trusted compiled-in kind+version service modules remain a roadmap design, not an
implemented plugin API. Local source/closure review and injected-wire checks are
recorded alongside scoped managed v2 field observations below; full acceptance
is not implied.
### Scoped managed v2 monitor observations (2026-10-15)
Independent closeout at **2026-10-15T12:28:52Z** records **SCOPED_PASS** for source
`cd05e75189f90c32e1346536c50f0973e7105cb3`, audit runtime unchanged. See
[RESOURCE_PLAN.md](RESOURCE_PLAN.md#managed-v2-scoped_pass-observations-2026-10-15)
for the root-private report/audit pointers, qualification/apply counts, dated
cleanup and full evidence limits. Official owned PID1 SS/DoH/public v2 paths
qualified PNG/JPEG and video/audio MP4 prefixes on both TLS versions (16 M3
cells / 48 TLS transfers); eight apply and eight initial monitor checks passed.
Five HMAC-authenticated snapshots, including initial state, show real host-fixture
PNG truncation and MP4 total overflow degrading only the affected row to
`DEGRADED / expectation_failed`, followed by all-HEALTHY repair. The SAME
controller PID 379/start 62777447 and journal/config/proof/key/input hashes were
retained, without restart or requalification. HEALTHY is still CHECKS_ONLY.
Both official stops exited 0; dated audit found all five owned containers,
owned network and 174 recorded process identities/namespaces gone, and three
foreign raw inspect snapshots unchanged. Historical Xray equality is only a
harness assertion without retained initial raw process inventory.
Typed semantics are supported by real production validation, authenticated
outcomes and fixture metadata, **not independent re-decoding of retained bodies**:
bodies were deliberately not retained for privacy. Live executable/held-FD
snapshots were also not retained; PID/start/parent/netns/native argv checks and
reviewed ACK enforcement are not a durable live-FD certificate. The initial
DoH-forwarder/worker observer misclassification was corrected in the harness,
retaining logs and the same qualified proof, not fixing a product failure.
No new public-v1 managed field run, negative M3/cancel/freshness/old-matrix remote
campaign, actual YouTube discovery/three-CDN/suffix/adaptive/warmup/avatar/playback
was run. Local v1 parity and unit rejection coverage do not fill those gaps.
The static test image did not replace the user's working SS service. Missing
body/live-FD evidence and untested cases remain limits before full acceptance
and YouTube adapter cutover; there is no full safety, migration or READY claim.
Invalid resource JSON initially or after reload is BLOCKED, with no DNS or
transfers until repaired. Bad static target role, proxy or DNS settings still
fail startup validation; resource JSON is deliberately not part of
`target-config-check`. Ownership and fresh source snapshots are checked before
DNS and again before transfer; existing DNS/IP policy, pinned SOCKS transfers,
TLS verification and private stdin are unchanged. No cached addresses bypass
DNS policy. Existing zapret reconciliation remains mandatory and generic
startup never consumes experimental apply requests.
State is independent of recovery SQL leases, fixed in the private target
directory as `.resource-monitor-state.json` and `.resource-monitor-key`.
Both are private 0600 files. Fingerprints HMAC the resolved configuration
(including secrets); state is also authenticated and never contains URLs,
headers, addresses or raw errors. Missing state initializes UNKNOWN. A missing
key with existing state, corrupt or unsafe file is preserved and BLOCKED,
never silently replaced. Restore the original key and a valid version-1 signed
state from a trusted backup to repair it. The controller holds directory, key
and state inode anchors: an identical signed replacement is still BLOCKED and
preserved. Repair on the original held inode is reloaded only after version/MAC
validation; replacing an inode requires deliberate operator repair/restart.
A persistence failure pauses probes;
deliberate repair requires a different valid authenticated snapshot, not just
retrying a failed write. Never chmod/adopt unknown files to bypass validation.
This is not isolation from a hostile same-UID actor: that actor can read the
HMAC key and race filesystem publication; root/container administrators can
also read private data. HMAC fingerprints protect stored secret values from
unkeyed guessing, not from an actor with access to the key.
`managed resource-status` is read-only and reports BLOCKED or STALE explicitly
(a check overdue by >65s, unknown state age >65s, or changed configuration).
Idle reloads do not write a disk heartbeat: only configured state changes,
BLOCKED transitions and completed checks are flushed. Cancelled checks join
their children but do not change prior health, counts or completion/due times.
It reads the config path from
`ZAPRET_AUTOTUNE_RESOURCE_CONFIG`; use that environment setting also for manual
monitor/status invocations. Status rows report only configured-check health.
TERM cancels/joins transfers before finalizing a completed snapshot and exits
0 on safe cleanup. PID 1 retains DNS through monitor/SS cleanup. In generic
mode transient child restart-budget exhaustion pauses until the rolling window
opens, rather than terminating the container. Unknown/unsafe cleanup stays
BLOCKED pending operator repair/restart; no unsafe daemon sourcing is allowed.
Generic cleanup shares an 80-second budget, including watchdog setup and
command kill escalation, with bounded final reaping; it is designed to fit
within a 90-second Docker stop limit (the supplied Compose grants 240 seconds).
Bounded final reaps/worst-case cleanup were verified offline; measured remote
normal stops were 1.45s, 0.59s and 0.57s, not an 80-second runtime worst-case test.
These changes do not claim to fix legacy YouTube exit 78.