feat: add guarded generic startup apply

Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
ZeusinaandGPT-6 Bot committed 2026-10-14 22:02:00 +03:00
1 parent 3743cdbd3e
commit de453ed2c8
11 files changed
+1255 -49

No files matched your search

+77 -3
View File
@@ -1,6 +1,8 @@
# Resource compatibility planner and isolated qualifier
This is a **proposal-only** P0 slice. `plan` never changes runtime or config.
`plan` remains **proposal-only** and never changes runtime or config.
Explicit generic startup apply is implemented and independently reviewed locally;
remote acceptance is pending. This is not automatic recovery or production READY.
Explicit isolated qualification temporarily installs an owned NFQ worker and
queue rules, but never changes legacy SQL groups, renderer or apply journals.
Monitor HEALTHY, old SQL measurements and public check JSON are not proof.
@@ -152,8 +154,80 @@ missing/foreign/mutated ACK or unverified early failure still veto clean shutdow
with exit 78. Ordinary legacy/generic monitor exit 78 remains a safety veto.
No unsupported `--filter-mark` or blockcheck embedded/stream/progress/deadline
flags are used. Background noninterrupting search and generic apply migration
remain deferred, as does immutable snapshot rotation for repeated runs.
flags are used. Background noninterrupting search, active-profile maintenance
and immutable snapshot rotation for repeated runs remain deferred.
## Explicit generic transactional startup apply (local implementation)
On the target with its already completed private qualification batch, unset both
qualification startup paths and set:
```
ZAPRET_AUTOTUNE_RESOURCE_CONFIG=/private/resources.json
ZAPRET_AUTOTUNE_RESOURCE_APPLY=1
ZAPRET_AUTOTUNE_STOP_GRACE_PERIOD=90s
```
Compose forwards the apply flag and configurable stop grace (legacy default
remains 240s). Generic PID 1 cleanup has one shared 80-second budget. No external
manager, new proof importer, SQL frontend surrogate or parallel journal exists.
PID 1 starts owned SS/DoH, reconciles known bytes, launches the acknowledged
`managed resource-apply --resource-config FILE` child before the checks-only
monitor, and starts the native daemon only with verified committed config.
This is one finite apply invocation per startup cycle, not exactly once per
container: PID 1 can retry cycles under its existing restart budget. Identical
committed requests resume by authenticated refs without reapplying the transaction.
The command refuses standalone/docker-exec callers: actual PID 1 environment,
entrypoint, namespace, direct-child executable/argv and held launch ACK are
required, plus the existing controller singleton and no pre-existing NFQ worker.
First apply supports **disabled baseline → generic only**. Active legacy profiles
and different generic plan rotation are refused; no maintenance interruption is
implemented. Every configured resource must require `both` TLS protocols and
every assigned exact host must have complete, candidate-bound passing proof for
all its resources across all input labels. New apply requires completion within
24 hours, never in the future. Negative/unknown/unassigned hosts cannot authorize
apply. Registry definitions may still describe single-TLS proposals, but native
apply rejects them instead of widening unsupported TLS-version selectors.
Canonical ordered args/selectors define profiles separated by `--new`; each
contains `--filter-tcp=443 --filter-l7=tls --hostlist-domains=^a,^b`. Exact-host
semantics use the pinned native source
`https://raw.githubusercontent.com/bol-van/zapret2/4df94497869e18ed4fdf1272141427b2fbfc6604/nfq2/hostlist.c`:
inline `AppendHostlistItem` uses `addpool`, leading `^` sets
`HOSTLIST_POOL_FLAG_STRICT_MATCH`, and `SearchHostList` rejects suffix fallback
when that flag is set and `!bHostFull`. Existing YouTube suffix policy is unchanged.
The packaged executable/Lua hash must match private attestation; held native,
Lua, source, marker and proof identities/bytes are guarded through the transaction.
No active queue version probe or mark/filter change is made (DoH500/probe100/live400).
The **existing** journal gains v4 independently tagged committed/pending refs
(`baseline`, `legacy`, `generic`). Generic refs exclude legacy IDs/scopes and bind
exact authenticated registry/matrix envelope hashes, source fingerprint,
internally derived canonical assignment digest and complete config hash.
Unknown versions/tags, mixed refs and unresolved historical reconstruction block
without adopting or erasing foreign state; v1–v3 legacy behavior remains.
Staging/backup/prepared/replace/fixed restart/health/commit reuse the same engine.
All required resources/TLS are checked through the existing synchronous owned
SS/DoH collector (all-answer SSRF validation, CONNECT pin, SNI/cert validation,
private stdin). No Player API health or public check JSON authorizes commit.
Committed identical requests are idempotent: historical proof expiry alone does
not trigger reload, reapply or rejection on restart. Authenticated integrity,
source and native drift still block. Prepared recovery **never** promotes pending
bytes, including after successful health: it restores prior bytes and reloads.
Generic rollback additionally checks all resources before finalizing the journal.
**Strict first-slice ceiling:** a DPI-broken disabled baseline can legitimately
fail these checks; restored bytes then remain `prepared`/BLOCKED until operator
repair. Physical restoration is not falsely reported as healthy rollback.
Legacy rollback has no new health requirement. Cancellation joins synchronous
checks before rollback; PID 1 bounds the owned session and retains prepared state
on unsafe/unfinished cleanup. `ActiveCandidates` refuses generic deployments;
managed/resource status validates generic refs without inventing legacy groups.
Local root fixture tests cover the production snapshot factory and shared engine;
independent local review passed. Actual native/network/PID 1 apply acceptance is
**not run**. The next gate is isolated bounded remote acceptance, not live rollout.
## Bounded remote acceptance — source `5cdc0cd`