Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""Execute actual runner admission and variant argument code without launching Workbench."""
|
||||
import argparse
|
||||
import ast
|
||||
import contextlib
|
||||
import io
|
||||
from pathlib import Path
|
||||
|
||||
from policy_harness import ROOT
|
||||
|
||||
runner = ROOT / 'tools/headless_workbench.py'
|
||||
tree = ast.parse(runner.read_text())
|
||||
declarations = []
|
||||
guards = []
|
||||
variant = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'p' for t in node.targets):
|
||||
declarations.append(node)
|
||||
if isinstance(node, ast.Expr) and isinstance(node.value, ast.Call):
|
||||
call = node.value
|
||||
if isinstance(call.func, ast.Attribute) and isinstance(call.func.value, ast.Name) and call.func.value.id == 'p' and call.func.attr == 'add_argument':
|
||||
declarations.append(node)
|
||||
if not isinstance(node, ast.If):
|
||||
continue
|
||||
relevant = any(isinstance(n, ast.Constant) and n.value == 'coordinated-ai' for n in ast.walk(node.test))
|
||||
if relevant and any(isinstance(n, ast.Call) and isinstance(n.func, ast.Attribute) and n.func.attr == 'error' for n in ast.walk(node)):
|
||||
guards.append(node)
|
||||
if isinstance(node.test, ast.Attribute) and node.test.attr == 'coordinated_blocked_only':
|
||||
variant.append(node)
|
||||
|
||||
assert len(guards) == 2 and len(variant) == 1
|
||||
scope = {'argparse': argparse, 'Path': Path, '__doc__': __doc__}
|
||||
exec(compile(ast.Module(body=declarations, type_ignores=[]), str(runner), 'exec'), scope)
|
||||
parser = scope['p']
|
||||
base = ['--compat', '/tmp/unused-coordinated-prefix', '--profile', '/tmp/unused-coordinated-profile']
|
||||
|
||||
|
||||
def admit(smoke='coordinated-ai', project='core', rounds='1', timeout='720', blocked=False):
|
||||
argv = base + ['--smoke', smoke, '--project', project, '--rounds', rounds, '--timeout', timeout]
|
||||
if blocked:
|
||||
argv.append('--coordinated-blocked-only')
|
||||
scope['a'] = parser.parse_args(argv)
|
||||
try:
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
exec(compile(ast.Module(body=guards, type_ignores=[]), str(runner), 'exec'), scope)
|
||||
except SystemExit as error:
|
||||
assert error.code == 2
|
||||
return False
|
||||
scope['command'] = []
|
||||
exec(compile(ast.Module(body=variant, type_ignores=[]), str(runner), 'exec'), scope)
|
||||
assert scope['command'] == (['-errCoordinatedBlockedOnly', '1'] if blocked else [])
|
||||
return True
|
||||
|
||||
|
||||
assert admit() and admit(blocked=True) and admit(timeout='900')
|
||||
assert not admit(project='chat') and not admit(rounds='2') and not admit(timeout='719')
|
||||
assert not admit(smoke='victory', blocked=True)
|
||||
assert admit(smoke='victory', project='chat', rounds='2', timeout='360')
|
||||
print('PASS: actual coordinated runner admission and explicit blocked-only engine flag; no native launch')
|
||||
Reference in New Issue
Block a user