feat: rotate generic profiles across verified alternatives

Select bounded canonical strategy allowlists at explicit PID1 startup within the same immutable authenticated registry, matrix and source. Reconstruct stored policies independently for historical replay, reconciliation and rollback; preserve freshness for new policies even when rendered bytes match. Retain legacy refusal and one-shot startup guards.

Local fixtures and independent local review passed; live native rotation acceptance remains pending. No uninterrupted rotation, new qualification or proof-store overwrite.

Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
ZeusinaandGPT-6 Bot committed 2026-10-15 10:18:14 +03:00
1 parent 5d0be0288f
commit 8d43dd9363
10 files changed
+473 -31

No files matched your search

+9 -1
View File
@@ -34,7 +34,8 @@ with tempfile.TemporaryDirectory(prefix='target-config-') as tmp:
SOCKS_PORT='1080',
ZAPRET_AUTOTUNE_SOCKS_PROXY='socks5h://127.0.0.1:1080')
for name in ('ZAPRET_AUTOTUNE_RESOURCE_APPLY', 'ZAPRET_AUTOTUNE_RESOURCE_CONFIG',
'ZAPRET_AUTOTUNE_QUALIFY_CONFIG', 'ZAPRET_AUTOTUNE_STRATEGY_CONFIG'):
'ZAPRET_AUTOTUNE_QUALIFY_CONFIG', 'ZAPRET_AUTOTUNE_STRATEGY_CONFIG',
'ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS'):
base.pop(name, None)
for dns, valid in (('', True), ('8.8.8.8', True), ('2001:4860:4860::8888', True),
('example.org', False), ('8.8.8.8\n', False), ('-d 8.8.8.8', False)):
@@ -70,6 +71,11 @@ with tempfile.TemporaryDirectory(prefix='target-config-') as tmp:
if not valid:
assert not list(private.iterdir())
for overrides, valid in (
({'ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS': 's1'}, False),
({'ZAPRET_AUTOTUNE_RESOURCE_CONFIG': '/private/resources.json',
'ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS': 's2,s1'}, True),
({'ZAPRET_AUTOTUNE_RESOURCE_CONFIG': '/private/resources.json',
'ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS': 's1,s1'}, False),
({'ZAPRET_AUTOTUNE_RESOURCE_APPLY': '1'}, False),
({'ZAPRET_AUTOTUNE_RESOURCE_APPLY': 'yes'}, False),
({'ZAPRET_AUTOTUNE_RESOURCE_APPLY': '1', 'ZAPRET_AUTOTUNE_RESOURCE_CONFIG': '/private/resources.json'}, True),
@@ -128,11 +134,13 @@ with tempfile.TemporaryDirectory(prefix='target-config-') as tmp:
result = subprocess.run(['docker', 'compose', '--env-file', '/dev/null', '-f',
str(ROOT / 'deploy/managed-target/compose.yaml'), 'config', '--format', 'json'],
env=dict(compose_env, ZAPRET_AUTOTUNE_RESOURCE_APPLY='1',
ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS='s2,s1',
ZAPRET_AUTOTUNE_RESOURCE_CONFIG='/private/resources.json',
ZAPRET_AUTOTUNE_STOP_GRACE_PERIOD='90s'), capture_output=True, timeout=10)
assert result.returncode == 0, 'Generic Compose config failed (output suppressed)'
target = json.loads(result.stdout)['services']['target']
assert target['environment']['ZAPRET_AUTOTUNE_RESOURCE_APPLY'] == '1'
assert target['environment']['ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS'] == 's2,s1'
assert target['environment']['ZAPRET_AUTOTUNE_RESOURCE_CONFIG'] == '/private/resources.json'
assert target['stop_grace_period'] == '1m30s'
# Compose must not inject Google bootstrap into a custom-provider request.
@@ -352,6 +352,7 @@ elif command == 'monitor':
elif command == 'resource-apply':
assert sys.argv[3:] == ['--resource-config', '/operator/resources.json']
assert os.environ['ZAPRET_AUTOTUNE_RESOURCE_APPLY'] == '1'
assert os.environ['ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS'] == 's2,s1'
assert os.getsid(0) == os.getpid(), 'apply lacks owned session'
assert (root / 'private' / 'monitor-ready').read_text() == str(os.getpid()) + '\n'
events = (root / 'events').read_text().splitlines()
@@ -458,8 +459,10 @@ def run(scenario, expected, dns='', mode='native'):
env.pop('ZAPRET_AUTOTUNE_QUALIFY_CONFIG', None)
env.pop('ZAPRET_AUTOTUNE_STRATEGY_CONFIG', None)
env.pop('ZAPRET_AUTOTUNE_RESOURCE_APPLY', None)
env.pop('ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS', None)
if scenario.startswith('generic-apply-') and scenario != 'generic-apply-disabled':
env['ZAPRET_AUTOTUNE_RESOURCE_APPLY'] = '1'
env['ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS'] = 's2,s1'
if scenario.startswith('qualify-'):
env['ZAPRET_AUTOTUNE_QUALIFY_CONFIG'] = '/operator/resources.json'
if scenario != 'qualify-missing':
+1
View File
@@ -20,6 +20,7 @@ services:
ZAPRET_AUTOTUNE_YOUTUBE_SERVICE: ${ZAPRET_AUTOTUNE_YOUTUBE_SERVICE-0}
ZAPRET_AUTOTUNE_RESOURCE_CONFIG: ${ZAPRET_AUTOTUNE_RESOURCE_CONFIG-}
ZAPRET_AUTOTUNE_RESOURCE_APPLY: ${ZAPRET_AUTOTUNE_RESOURCE_APPLY-0}
ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS: ${ZAPRET_AUTOTUNE_RESOURCE_STRATEGY_IDS-}
# INTRUSIVE isolated startup batch. Never route working traffic here.
ZAPRET_AUTOTUNE_QUALIFY_CONFIG: ${ZAPRET_AUTOTUNE_QUALIFY_CONFIG-}
ZAPRET_AUTOTUNE_STRATEGY_CONFIG: ${ZAPRET_AUTOTUNE_STRATEGY_CONFIG-}