feat(managed): add explicit experimental Googlevideo suffix policy
Keep operator-owned native circular extrapolation distinct from cold/adaptive qualification and playback readiness. Preserve qualified frontend/assets, use guarded journal transactions and rollback, and apply private startup requests before the owned monitor begins. Retain legacy rendering and qualification gates. Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
0398e6fe28
commit
371382c2c4
10 files changed
+384
-7
No files matched your search
@@ -388,3 +388,33 @@ do not attribute all of them to the clean run. No media playback, real 90-minute
|
||||
watchdog expiry or real two-hour absence expiry wait is claimed. Production rollout
|
||||
and backup-restore acceptance remain operator gates on a new isolated target;
|
||||
local unit/static checks and isolated PASS do not establish blanket production readiness.
|
||||
|
||||
### Explicit experimental Googlevideo suffix
|
||||
|
||||
Normal `--googlevideo-scope suffix` still requires representative qualification,
|
||||
media proof, and both qualified image profiles. An operator may explicitly own
|
||||
the audited native circular A/E composite without claiming those results:
|
||||
|
||||
```sh
|
||||
zapret-autotune managed apply --googlevideo-experiment native-circular --googlevideo-scope experimental_googlevideo_suffix
|
||||
```
|
||||
|
||||
This command requires the monitor singleton to be free, a matching native Lua
|
||||
hash, a fresh Player-discovered exact GGC identity, and existing qualified
|
||||
frontend/assets. It preserves their candidate IDs and uses the normal guarded
|
||||
transaction/reload/Player-health/rollback hooks. The new candidate definition
|
||||
has no cold/adaptive evidence and is not a qualified candidate. Both pending
|
||||
and committed journal policy record `experimental_googlevideo_suffix`; legacy
|
||||
rendered bytes and qualification gates are unchanged. Unknown policies fail closed.
|
||||
|
||||
For PID-1-controlled application, while this dedicated target is stopped and
|
||||
after taking a complete private state backup, create a private empty file named
|
||||
`.autotune-experimental-suffix-request` in its owned state directory. Startup
|
||||
reconciles/starts the known deployment, performs the command before launching
|
||||
the monitor, and consumes the request only on success. Failure exits closed;
|
||||
retain artifacts and use the matched whole-state/image rollback procedure above.
|
||||
|
||||
Resource probes still run. This policy remains `DEGRADED`/GGC-unresolved even
|
||||
when a bounded media check succeeds: neither playback READY nor family
|
||||
qualification is inferred. Automatic frontend/image repairs preserve the
|
||||
operator suffix; automatic GGC recovery does not replace or qualify it.
|
||||
@@ -69,10 +69,20 @@ func managedArguments(args []string) (string, []int64, error) {
|
||||
selected := map[string][]int64{}
|
||||
seen := map[int64]bool{}
|
||||
scopeSeen := false
|
||||
experiment := false
|
||||
var scope GooglevideoScope
|
||||
for i := 1; i < len(args); i += 2 {
|
||||
key := args[i]
|
||||
if key == "--googlevideo-experiment" {
|
||||
if experiment || args[i+1] != "native-circular" {
|
||||
return "", nil, invalid
|
||||
}
|
||||
experiment = true
|
||||
continue
|
||||
}
|
||||
if key == "--googlevideo-scope" {
|
||||
if scopeSeen || (args[i+1] != "exact" && args[i+1] != "suffix") {
|
||||
scope = GooglevideoScope(args[i+1])
|
||||
if scopeSeen || !scope.valid() || scope == "" {
|
||||
return "", nil, invalid
|
||||
}
|
||||
scopeSeen = true
|
||||
@@ -101,6 +111,12 @@ func managedArguments(args []string) (string, []int64, error) {
|
||||
}
|
||||
}
|
||||
var ids []int64
|
||||
if experiment {
|
||||
if !scopeSeen || scope != GooglevideoScopeExperimental || len(selected) != 0 {
|
||||
return "", nil, invalid
|
||||
}
|
||||
return "experiment", nil, nil
|
||||
}
|
||||
for _, key := range []string{"--frontend-candidate", "--googlevideo-candidate", "--asset-candidate"} {
|
||||
ids = append(ids, selected[key]...)
|
||||
}
|
||||
@@ -250,11 +266,14 @@ func managedReport(m *managedTransaction, out io.Writer, openDB func() (*sql.DB,
|
||||
known = true
|
||||
for _, id := range j.Candidates {
|
||||
c, err := readStrategyCandidatePolicy(db, id, false)
|
||||
if err != nil || !c.Qualified {
|
||||
if err != nil || (!c.Qualified && !experimentalGooglevideo(j.Scope, c)) {
|
||||
known = false
|
||||
break
|
||||
}
|
||||
groups[c.Group] = true
|
||||
if experimentalGooglevideo(j.Scope, c) {
|
||||
groups[c.Group] = false
|
||||
}
|
||||
if c.Group == "assets" {
|
||||
for _, host := range c.Endpoints {
|
||||
assetHosts[host] = true
|
||||
@@ -369,6 +388,8 @@ func managedCLI(args []string, stdout, stderr io.Writer, d managedDeps) int {
|
||||
err = managedPrestartReconcile(m, d)
|
||||
} else if command == "status" || command == "active-ids" {
|
||||
err = managedReport(m, stdout, d.openDB, command == "active-ids", len(args) == 2 && args[1] == "--assets")
|
||||
} else if command == "experiment" {
|
||||
err = managedExperimentalSuffix(m, d)
|
||||
} else {
|
||||
expected := map[int64]string{}
|
||||
var scopes []GooglevideoScope
|
||||
@@ -396,11 +417,11 @@ func managedCLI(args []string, stdout, stderr io.Writer, d managedDeps) int {
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if command == "init" || command == "reconcile" || command == "apply" {
|
||||
if command == "init" || command == "reconcile" || command == "apply" || command == "experiment" {
|
||||
if _, err := fmt.Fprintln(stdout, "managed-test "+command+": OK"); err != nil {
|
||||
return 1
|
||||
}
|
||||
if command == "apply" {
|
||||
if command == "apply" || command == "experiment" {
|
||||
if _, err := fmt.Fprintln(stdout, "Player API only; not full-profile/GGC/playback health. Use managed status for unresolved groups."); err != nil {
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -23,10 +23,17 @@ type GooglevideoScope string
|
||||
const (
|
||||
GooglevideoScopeExact GooglevideoScope = "exact"
|
||||
GooglevideoScopeSuffix GooglevideoScope = "suffix"
|
||||
GooglevideoScopeExperimental GooglevideoScope = "experimental_googlevideo_suffix"
|
||||
)
|
||||
|
||||
func (s GooglevideoScope) valid() bool {
|
||||
return s == "" || s == GooglevideoScopeExact || s == GooglevideoScopeSuffix
|
||||
return s == "" || s == GooglevideoScopeExact || s == GooglevideoScopeSuffix || s == GooglevideoScopeExperimental
|
||||
}
|
||||
|
||||
// Operator ownership is not qualification. Only the existing audited native
|
||||
// composite may be owned without evidence, and only under the durable policy.
|
||||
func experimentalGooglevideo(scope GooglevideoScope, c storedCandidate) bool {
|
||||
return scope == GooglevideoScopeExperimental && c.Group == "googlevideo" && c.Mode == QualificationCold && validateNativeGooglevideoArgs(c.Args) == nil
|
||||
}
|
||||
|
||||
func renderManagedConfigScope(db *sql.DB, ids []int64, scope GooglevideoScope) ([]byte, error) {
|
||||
@@ -66,7 +73,7 @@ func renderManagedConfigPolicy(db *sql.DB, ids []int64, scope GooglevideoScope,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !c.Qualified {
|
||||
if !c.Qualified && !experimentalGooglevideo(scope, c) {
|
||||
return nil, fmt.Errorf("candidate %d is not qualified", id)
|
||||
}
|
||||
if c.Group == "assets" && version < 6 {
|
||||
@@ -109,12 +116,21 @@ func renderManagedConfigPolicy(db *sql.DB, ids []int64, scope GooglevideoScope,
|
||||
// Authorized extrapolation, not evidence that all suffix hosts passed.
|
||||
domains = []string{"googlevideo.com"}
|
||||
}
|
||||
if c.Group == "googlevideo" && scope == GooglevideoScopeExperimental {
|
||||
if !experimentalGooglevideo(scope, c) {
|
||||
return nil, fmt.Errorf("experimental suffix requires audited native candidate identity")
|
||||
}
|
||||
domains = []string{"googlevideo.com"}
|
||||
}
|
||||
groups[c.Group] = true
|
||||
profiles = append(profiles, "--filter-tcp=443 --filter-l7=tls --hostlist-domains="+strings.Join(domains, ",")+" "+c.Args)
|
||||
}
|
||||
if scope == GooglevideoScopeSuffix && (!groups["googlevideo"] || len(assets) != 2) {
|
||||
return nil, fmt.Errorf("suffix requires googlevideo and both qualified asset profiles")
|
||||
}
|
||||
if scope == GooglevideoScopeExperimental && (!groups["googlevideo"] || !groups["frontend"] || len(assets) == 0) {
|
||||
return nil, fmt.Errorf("experimental suffix requires frontend and existing qualified assets")
|
||||
}
|
||||
for host := range assets {
|
||||
for _, scope := range otherScopes {
|
||||
if host == scope || strings.HasSuffix(host, "."+scope) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Runs before the PID-1-owned monitor starts; never races a recovery worker.
|
||||
// A real Player-discovered identity is saved WITHOUT cold/adaptive evidence.
|
||||
func managedExperimentalSuffix(m *managedTransaction, d managedDeps) error {
|
||||
singleton, err := acquireManagedMonitorSingleton(d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer singleton.close()
|
||||
lua, err := os.ReadFile("/opt/zapret2/lua/zapret-auto.lua")
|
||||
if err != nil || fmt.Sprintf("%x", sha256.Sum256(lua)) != managedGooglevideoLuaHash {
|
||||
return fmt.Errorf("native Lua identity mismatch")
|
||||
}
|
||||
cfg, err := parseHealthConfig(d.lookup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
body, err := requestPlayer(cfg.VideoID, cfg.SOCKSProxy, d.player)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fresh Player discovery unavailable")
|
||||
}
|
||||
host, err := playerHostname(body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fresh GGC identity unavailable")
|
||||
}
|
||||
db, err := d.openDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer db.Close()
|
||||
current, err := m.ActiveCandidates(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id, err := insertStrategyCandidate(tx, "googlevideo", []string{host}, managedGooglevideoArgs, nil)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
desired, err := managedFullDesiredSet(db, current, []int64{id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expected := map[int64]string{}
|
||||
for _, id := range desired {
|
||||
c, err := readStrategyCandidate(db, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expected[id] = c.Group
|
||||
}
|
||||
return managedActivate(m, d, desired, expected, GooglevideoScopeExperimental)
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExperimentalSuffixOwnershipNotQualification(t *testing.T) {
|
||||
db := testStore(t)
|
||||
// Existing real-definition fixture; no passing evidence is created for GGC.
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id, err := insertStrategyCandidate(tx, "googlevideo", []string{"rr1---sn-alpha.googlevideo.com"}, managedGooglevideoArgs, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
front := managedCandidateFixture(t, db, "frontend", "www.youtube.com", "--lua-desync=fake", true)
|
||||
asset := unitAssetCandidate(t, db, "i.ytimg.com", "--lua-desync=fake", true)
|
||||
current := []int64{front, asset}
|
||||
ids := append(append([]int64{}, current...), id)
|
||||
c, err := readStrategyCandidate(db, id)
|
||||
if err != nil || c.Qualified {
|
||||
t.Fatalf("fabricated qualification: %+v %v", c, err)
|
||||
}
|
||||
for _, scope := range []GooglevideoScope{GooglevideoScopeExact, GooglevideoScopeSuffix} {
|
||||
if _, err := renderManagedConfigScope(db, ids, scope); err == nil {
|
||||
t.Fatal("normal gate weakened")
|
||||
}
|
||||
}
|
||||
b, err := renderManagedConfigScope(db, ids, GooglevideoScopeExperimental)
|
||||
if err != nil || !strings.Contains(string(b), "--hostlist-domains=googlevideo.com ") {
|
||||
t.Fatalf("render %s %v", b, err)
|
||||
}
|
||||
m, _ := managedFixture(t)
|
||||
if err := m.Apply(db, current); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.Apply(db, ids, GooglevideoScopeExperimental); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
j, err := m.load()
|
||||
if err != nil || j.Scope != GooglevideoScopeExperimental || j.Version != 3 {
|
||||
t.Fatalf("journal %+v %v", j, err)
|
||||
}
|
||||
if _, err := m.ActiveCandidates(db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := m.Apply(db, []int64{front, id}, GooglevideoScopeExperimental); err == nil {
|
||||
t.Fatal("dropped asset")
|
||||
}
|
||||
if err := m.Apply(db, ids); err != nil {
|
||||
t.Fatal("refresh erased policy", err)
|
||||
}
|
||||
m.Health = func() (string, error) { return "FAIL", nil }
|
||||
if err := m.Apply(db, current, GooglevideoScopeExact); err == nil {
|
||||
t.Fatal("failed apply committed")
|
||||
}
|
||||
j, err = m.load()
|
||||
if err != nil || j.Scope != GooglevideoScopeExperimental || !reflect.DeepEqual(j.Candidates, ids) {
|
||||
t.Fatalf("rollback %+v %v", j, err)
|
||||
}
|
||||
m.Health = func() (string, error) { return "OK", nil }
|
||||
crash := errors.New("crash")
|
||||
m.fault = func(point string) error {
|
||||
if point == "replaced" {
|
||||
return crash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := m.Apply(db, current, GooglevideoScopeExact); !errors.Is(err, crash) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.fault = nil
|
||||
if err := m.Reconcile(db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
j, err = m.load()
|
||||
if err != nil || j.Scope != GooglevideoScopeExperimental {
|
||||
t.Fatalf("reconcile %+v %v", j, err)
|
||||
}
|
||||
qualified, err := listQualifiedCandidates(db, "googlevideo", 10)
|
||||
if err != nil || len(qualified) != 0 {
|
||||
t.Fatalf("experiment leaked into qualified list %+v %v", qualified, err)
|
||||
}
|
||||
var evidence int
|
||||
if err := db.QueryRow("SELECT count(*) FROM candidate_evidence WHERE candidate_id=?", id).Scan(&evidence); err != nil || evidence != 0 {
|
||||
t.Fatal("fabricated evidence", evidence, err)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
if err := managedReport(m, &out, func() (*sql.DB, error) { return db, nil }, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(out.String(), "unresolved_groups=googlevideo,assets") {
|
||||
t.Fatalf("false qualified status: %s", out.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestExperimentalSuffixCLIExplicit(t *testing.T) {
|
||||
command, ids, err := managedArguments([]string{"apply", "--googlevideo-experiment", "native-circular", "--googlevideo-scope", string(GooglevideoScopeExperimental)})
|
||||
if err != nil || command != "experiment" || len(ids) != 0 {
|
||||
t.Fatal(command, ids, err)
|
||||
}
|
||||
for _, args := range [][]string{
|
||||
{"apply", "--googlevideo-experiment", "native-circular"},
|
||||
{"apply", "--googlevideo-experiment", "native-circular", "--googlevideo-scope", "suffix"},
|
||||
{"apply", "--googlevideo-experiment", "unknown", "--googlevideo-scope", string(GooglevideoScopeExperimental)},
|
||||
} {
|
||||
if _, _, err := managedArguments(args); err == nil {
|
||||
t.Fatal("implicit experiment", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExperimentalSuffixPreparedRollback(t *testing.T) {
|
||||
db := testStore(t)
|
||||
front := managedCandidateFixture(t, db, "frontend", "www.youtube.com", "--lua-desync=fake", true)
|
||||
asset := unitAssetCandidate(t, db, "i.ytimg.com", "--lua-desync=fake", true)
|
||||
id := managedCandidateFixture(t, db, "googlevideo", "rr1---sn-alpha.googlevideo.com", managedGooglevideoArgs, false)
|
||||
m, _ := managedFixture(t)
|
||||
current := []int64{front, asset}
|
||||
if err := m.Apply(db, current); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
prior, err := renderManagedConfig(db, current)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crash := errors.New("prepared experiment interrupted")
|
||||
m.fault = func(point string) error {
|
||||
if point == "replaced" {
|
||||
return crash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := m.Apply(db, []int64{front, asset, id}, GooglevideoScopeExperimental); !errors.Is(err, crash) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
j, err := m.load()
|
||||
if err != nil || j.Scope != GooglevideoScopeExact || j.PendingScope != GooglevideoScopeExperimental || j.Hash != managedHash(prior) {
|
||||
t.Fatalf("pending policy/hash: %+v %v", j, err)
|
||||
}
|
||||
m.fault = nil
|
||||
if err := m.Reconcile(db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertManagedContent(t, m, string(prior))
|
||||
assertActiveCandidates(t, m, db, current)
|
||||
j, err = m.load()
|
||||
if err != nil || j.Scope != GooglevideoScopeExact || j.PendingScope != "" {
|
||||
t.Fatalf("rollback policy: %+v %v", j, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExperimentalSuffixCannotPromoteMonitorReadiness(t *testing.T) {
|
||||
d, front, _ := recoveryFixture(t, true)
|
||||
target, _, _ := managedCLIFixture(t)
|
||||
initManagedCLI(t, target)
|
||||
d.transaction.Dir = target.directory
|
||||
asset := unitAssetCandidate(t, d.db, "i.ytimg.com", "--lua-desync=fake", true)
|
||||
id := managedCandidateFixture(t, d.db, "googlevideo", "rr1---sn-alpha.googlevideo.com", managedGooglevideoArgs, false)
|
||||
if err := d.transaction.Apply(d.db, []int64{front, asset, id}, GooglevideoScopeExperimental); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
monitor := managedMonitorDeps{db: d.db, target: target}
|
||||
if err := wireManagedRecovery(&monitor, d, func(error) {}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := monitor.probe(context.Background()); !errors.Is(err, errManagedGGCUnresolved) {
|
||||
t.Fatalf("false readiness: %v", err)
|
||||
}
|
||||
for _, adaptive := range []bool{false, true} {
|
||||
d.adaptive = adaptive
|
||||
result, err := recoverManagedTarget(context.Background(), d)
|
||||
if !errors.Is(err, errManagedGGCUnresolved) || !errors.Is(result.GGCError, errManagedGGCUnresolved) {
|
||||
t.Fatalf("recovery qualified experiment: %+v %v", result, err)
|
||||
}
|
||||
assertActiveCandidates(t, d.transaction, d.db, []int64{front, asset, id})
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,14 @@ func recoverManagedGooglevideo(ctx context.Context, d managedRecoveryDeps) (int6
|
||||
return 0, &InsufficientAdaptiveSamples{}
|
||||
}
|
||||
m := *d.transaction
|
||||
journal, err := m.load()
|
||||
if err != nil {
|
||||
return 0, &managedRecoveryFatal{Err: err}
|
||||
}
|
||||
if journal.Scope == GooglevideoScopeExperimental {
|
||||
// Explicit operator policy remains owned, never auto-qualified/replaced.
|
||||
return 0, &InsufficientAdaptiveSamples{}
|
||||
}
|
||||
current, err := m.ActiveCandidates(d.db)
|
||||
if err != nil {
|
||||
return 0, &managedRecoveryFatal{Err: err}
|
||||
|
||||
@@ -279,6 +279,11 @@ func recoverManagedTarget(ctx context.Context, d managedRecoveryDeps) (result ma
|
||||
if err != nil {
|
||||
return result, &managedRecoveryFatal{Err: err}
|
||||
}
|
||||
journal, err := m.load()
|
||||
if err != nil {
|
||||
return result, &managedRecoveryFatal{Err: err}
|
||||
}
|
||||
experimental := journal.Scope == GooglevideoScopeExperimental
|
||||
for _, id := range ids {
|
||||
c, e := readStrategyCandidate(d.db, id)
|
||||
if e != nil {
|
||||
@@ -310,7 +315,7 @@ func recoverManagedTarget(ctx context.Context, d managedRecoveryDeps) (result ma
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if d.service {
|
||||
if d.service || experimental {
|
||||
current, e := m.ActiveCandidates(d.db)
|
||||
if e != nil {
|
||||
return &managedRecoveryFatal{Err: e}
|
||||
@@ -434,6 +439,12 @@ func recoverManagedTarget(ctx context.Context, d managedRecoveryDeps) (result ma
|
||||
if e != nil {
|
||||
return result, e
|
||||
}
|
||||
if experimental {
|
||||
// Operator extrapolation survives recovery in either configured mode.
|
||||
// Frontend/asset repairs remain available, but cannot qualify this policy.
|
||||
result.GGCError = errManagedGGCUnresolved
|
||||
return result, result.GGCError
|
||||
}
|
||||
if !d.service && (len(current) != 1 || current[0] != result.FrontendID) {
|
||||
if e := apply([]int64{result.FrontendID}); e != nil {
|
||||
return result, e
|
||||
@@ -722,6 +733,13 @@ func wireManagedRecovery(monitor *managedMonitorDeps, recovery managedRecoveryDe
|
||||
return &managedRecoveryFatal{Err: err}
|
||||
}
|
||||
// Keep Player API health separate from GGC scope (not playback health).
|
||||
journal, err := transaction.load()
|
||||
if err != nil {
|
||||
return &managedRecoveryFatal{Err: err}
|
||||
}
|
||||
if journal.Scope == GooglevideoScopeExperimental {
|
||||
return errManagedGGCUnresolved
|
||||
}
|
||||
// Two bounded Player requests reuse the existing health/discovery adapters.
|
||||
host, err := recovery.discover(ctx)
|
||||
err = managedRecoveryContextError(ctx, err)
|
||||
|
||||
@@ -357,6 +357,23 @@ func (m *managedTransaction) applyRenderedPolicy(b []byte, db *sql.DB, requested
|
||||
if requested != nil {
|
||||
scope = *requested
|
||||
}
|
||||
if requested != nil && scope == GooglevideoScopeExperimental {
|
||||
for _, id := range j.Candidates {
|
||||
c, err := readStrategyCandidatePolicy(db, id, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if c.Group != "googlevideo" {
|
||||
found := false
|
||||
for _, desired := range ids {
|
||||
found = found || desired == id
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("experimental suffix must preserve current frontend/assets")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if b == nil {
|
||||
b, err = renderManagedConfigScope(db, ids, scope)
|
||||
if err != nil {
|
||||
|
||||
@@ -57,3 +57,7 @@ for command, seconds in (("/usr/local/bin/zapret-autotune managed init", 45),
|
||||
("/opt/zapret2/init.d/sysv/zapret2 start", 30)):
|
||||
assert f"timeout -k 5 {seconds} {command} || exit 78" in entrypoint
|
||||
assert entrypoint.index("managed reconcile || exit 78") < entrypoint.index("zapret2 start || exit 78")
|
||||
experimental = 'managed apply --googlevideo-experiment native-circular --googlevideo-scope experimental_googlevideo_suffix || exit 78'
|
||||
assert entrypoint.index('zapret2 start || exit 78') < entrypoint.index(experimental)
|
||||
assert entrypoint.index(experimental) < entrypoint.index('setsid /bin/sh /opt/managed-target-supervision.sh --monitor')
|
||||
assert entrypoint.index(experimental) < entrypoint.index('rm "${ZAPRET_CONFIG%/*}/.autotune-experimental-suffix-request"')
|
||||
@@ -190,6 +190,13 @@ timeout -k 5 45 /usr/local/bin/zapret-autotune managed reconcile || exit 78
|
||||
zapret_started=1
|
||||
timeout -k 5 30 /opt/zapret2/init.d/sysv/zapret2 start || exit 78
|
||||
|
||||
# Private operator request, consumed only after a successful guarded transaction.
|
||||
# Never suppress qualification gates globally or race the owned monitor.
|
||||
if [ -e "${ZAPRET_CONFIG%/*}/.autotune-experimental-suffix-request" ]; then
|
||||
timeout -k 5 120 /usr/local/bin/zapret-autotune managed apply --googlevideo-experiment native-circular --googlevideo-scope experimental_googlevideo_suffix || exit 78
|
||||
rm "${ZAPRET_CONFIG%/*}/.autotune-experimental-suffix-request"
|
||||
fi
|
||||
|
||||
# A replacement SS child can fail during reconciliation/activation. Do not
|
||||
# fork a monitor we already need to cancel: an early TERM can race interpreter
|
||||
# startup before its cancellation handler exists. Clean this cycle directly.
|
||||
|
||||
Reference in new issue
Block a user