Upload folder using huggingface_hub (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_contract.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_entry.py +38 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy.py +133 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy_guard.py +86 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/autograde_task_check.py +102 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/check.py +2 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/original_check.py +74 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r10_dependency.py +14 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r10_support.py +12 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r12_input_binding.py +48 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/grading/verified_config.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/inputs/plans. +74 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/instruction.md +10 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/SKILL.md +3 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/members/M000/SKILL.md +78 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/members/M001/SKILL.md +185 -0
- benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/task.json +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/audit_variants.py +42 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_contract.json +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_entry.py +38 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy.json +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy.py +133 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy_guard.py +86 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/autograde_task_check.py +183 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/check.py +2 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/original_check.py +103 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/r10_dependency.py +14 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/r10_support.py +12 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/repair.json +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/grading/verified_config.json +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/inputs/controls.csv +3 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/instruction.md +5 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/skill/SKILL.md +49 -0
- benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/task.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_contract.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_entry.py +38 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy.py +133 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy_guard.py +86 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/autograde_task_check.py +63 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/check.py +2 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/dependency_scan.py +14 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/repair_manifest.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/workspace_copy.py +24 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/grading/verified_config.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/origin/manifest.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/README.md +4 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/config.json +3 -0
- benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/logs/run.log +4 -0
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_contract.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1973ab59d6c798839dc76976e2cf6ec72facd1f60b833ebabefed0e297a7ccd7
|
| 3 |
+
size 230
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_entry.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Stable result protocol; candidate failures and evaluator errors stay distinct."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import contextlib,io,json,runpy,sys
|
| 4 |
+
from auto_policy import install,finalize
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
captured=io.StringIO()
|
| 9 |
+
try:
|
| 10 |
+
install()
|
| 11 |
+
with contextlib.redirect_stdout(captured):
|
| 12 |
+
try:runpy.run_path(str(HERE/'autograde_task_check.py'),run_name='__main__')
|
| 13 |
+
except SystemExit as error:
|
| 14 |
+
if error.code not in(None,0):raise RuntimeError('Trusted checker exited '+str(error.code))
|
| 15 |
+
body=None
|
| 16 |
+
for line in reversed(captured.getvalue().splitlines()):
|
| 17 |
+
try:value=json.loads(line)
|
| 18 |
+
except(ValueError,TypeError):continue
|
| 19 |
+
if isinstance(value,dict)and isinstance(value.get('checks'),list):body=value;break
|
| 20 |
+
if body is None:raise RuntimeError('Trusted checker did not emit its result schema')
|
| 21 |
+
if body.get('status')=='evaluation_error'or body.get('protocol_valid')is False:raise RuntimeError('Trusted checker reports evaluator failure: '+str(body.get('error','')))
|
| 22 |
+
cfgfile=HERE/'auto_policy.json'
|
| 23 |
+
if cfgfile.is_file():
|
| 24 |
+
cfg=json.loads(cfgfile.read_text());owners=cfg.get('runtime_owner_ids',cfg.get('owner_ids',[]))
|
| 25 |
+
if owners:body=finalize(body,owners,require_execution=cfg.get('require_execution',True))
|
| 26 |
+
checks=body['checks']
|
| 27 |
+
if not checks or any(not isinstance(c,dict)or type(c.get('passed'))is not bool or not isinstance(c.get('id'),(int,str))or isinstance(c.get('id'),bool)for c in checks):raise RuntimeError('Trusted checker contains an unresolved or malformed criterion; no model score assigned')
|
| 28 |
+
ids=[str(c['id'])for c in checks]
|
| 29 |
+
if len(ids)!=len(set(ids)):raise RuntimeError('Duplicate criterion ID')
|
| 30 |
+
contract=json.loads((HERE/'auto_contract.json').read_text());expected=contract['expected_check_ids']
|
| 31 |
+
if '--view'not in sys.argv and set(ids)!=set(expected):raise RuntimeError('Criterion IDs differ from fixed public contract')
|
| 32 |
+
weights=contract['criterion_weights']
|
| 33 |
+
body.update(status='scored',scoreable=True,protocol_valid=True,score=sum(weights[str(c['id'])]for c in checks if c['passed'])/sum(weights[str(c['id'])]for c in checks),passed_checks=sum(c['passed']for c in checks),total_checks=len(checks),all_passed=all(c['passed']for c in checks))
|
| 34 |
+
print(json.dumps(body,ensure_ascii=True));return 0
|
| 35 |
+
except Exception as error:
|
| 36 |
+
print(json.dumps(dict(status='evaluation_error',score=None,scoreable=False,protocol_valid=False,checks=[],error=type(error).__name__+': '+str(error),error_category='trusted_evaluator_or_environment',candidate_scored=False),ensure_ascii=True));return 2
|
| 37 |
+
|
| 38 |
+
if __name__=='__main__':raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9602f290d969d8c65f46f50824fdb4581427de9116a9ed9f91cd5fe15384084f
|
| 3 |
+
size 251
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Trusted bounded-invocation policy; never infer whole-program properties."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import hashlib,json,os,subprocess,sys,tempfile,time,uuid
|
| 4 |
+
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
ENV='MYBENCH_AUTO_POLICY_RECEIPTS'
|
| 7 |
+
DEADLINE='MYBENCH_AUTO_POLICY_DEADLINE'
|
| 8 |
+
class PolicyInfrastructureError(RuntimeError): pass
|
| 9 |
+
_installed=False
|
| 10 |
+
_original_popen=subprocess.Popen
|
| 11 |
+
_original_run=subprocess.run
|
| 12 |
+
|
| 13 |
+
def _config():
|
| 14 |
+
p=HERE/'auto_policy.json'
|
| 15 |
+
if not p.is_file():return None
|
| 16 |
+
value=json.loads(p.read_text())
|
| 17 |
+
if not isinstance(value,dict):raise PolicyInfrastructureError('Invalid trusted runtime policy')
|
| 18 |
+
return value
|
| 19 |
+
|
| 20 |
+
def _folder():
|
| 21 |
+
if ENV not in os.environ:
|
| 22 |
+
os.environ[ENV]=tempfile.mkdtemp(prefix='autograde-policy-',dir='/tmp')
|
| 23 |
+
p=Path(os.environ[ENV]);p.mkdir(parents=True,exist_ok=True);return p
|
| 24 |
+
|
| 25 |
+
def _python_target(command,cwd):
|
| 26 |
+
if not isinstance(command,(list,tuple))or not command:return None
|
| 27 |
+
argv=[os.fspath(x)for x in command]
|
| 28 |
+
if 'python'not in Path(argv[0]).name.lower():return None
|
| 29 |
+
i=1;flags=[]
|
| 30 |
+
while i<len(argv)and argv[i].startswith('-'):
|
| 31 |
+
flag=argv[i]
|
| 32 |
+
if flag=='-m':
|
| 33 |
+
if i+1>=len(argv):return None
|
| 34 |
+
name=argv[i+1];p=Path(cwd)/name.replace('.','/')
|
| 35 |
+
if not p.with_suffix('.py').is_file()and not(p/'__main__.py').is_file():return None
|
| 36 |
+
return argv[0],flags,'module',name,argv[i+2:]
|
| 37 |
+
if flag in ['-c','-']:return None
|
| 38 |
+
flags.append(flag);i+=1
|
| 39 |
+
if flag in ['-W','-X']and i<len(argv):flags.append(argv[i]);i+=1
|
| 40 |
+
if i>=len(argv)or not argv[i].endswith('.py'):return None
|
| 41 |
+
path=Path(argv[i]);path=path if path.is_absolute()else Path(cwd)/path
|
| 42 |
+
path=path.resolve()
|
| 43 |
+
if path==HERE or HERE in path.parents:
|
| 44 |
+
if path.name in ['auto_policy.py','auto_policy_guard.py']:return None
|
| 45 |
+
for value in argv[i+1:]:
|
| 46 |
+
if not value.endswith('.py')or value.startswith('-'):continue
|
| 47 |
+
subject=Path(value);subject=subject if subject.is_absolute()else Path(cwd)/subject
|
| 48 |
+
subject=subject.resolve()
|
| 49 |
+
if HERE not in subject.parents:
|
| 50 |
+
return argv[0],flags,'probe',str(path),[str(subject),*argv[i+1:]]
|
| 51 |
+
return None
|
| 52 |
+
return argv[0],flags,'script',str(path),argv[i+1:]
|
| 53 |
+
|
| 54 |
+
def install():
|
| 55 |
+
global _installed
|
| 56 |
+
if _installed:return
|
| 57 |
+
_installed=True
|
| 58 |
+
cfg=_config()
|
| 59 |
+
if cfg is None:return
|
| 60 |
+
_folder()
|
| 61 |
+
os.environ.setdefault(DEADLINE,str(time.monotonic()+cfg.get('total_evaluation_budget_seconds',420)))
|
| 62 |
+
class GuardedPopen(_original_popen):
|
| 63 |
+
def __init__(self,args,*pos,**kwargs):
|
| 64 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 65 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(args,cwd)
|
| 66 |
+
receipt=None
|
| 67 |
+
if target:
|
| 68 |
+
executable,flags,kind,value,tail=target;receipt=_folder()/(uuid.uuid4().hex+'.json')
|
| 69 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='launching',target=value)))
|
| 70 |
+
if cfg.get('stdlib_only')and'-S'not in flags:flags=flags+['-S']
|
| 71 |
+
args=[executable,*flags,str(HERE/'auto_policy_guard.py'),str(receipt),str(HERE/'auto_policy.json'),kind,value,*tail]
|
| 72 |
+
env=dict(kwargs.get('env')or os.environ);env[ENV]=str(_folder());kwargs['env']=env
|
| 73 |
+
if target:kwargs['env'][DEADLINE]=os.environ[DEADLINE]
|
| 74 |
+
try:super().__init__(args,*pos,**kwargs)
|
| 75 |
+
except OSError as error:
|
| 76 |
+
if receipt:
|
| 77 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='infrastructure_error',error=repr(error))))
|
| 78 |
+
raise
|
| 79 |
+
subprocess.Popen=GuardedPopen
|
| 80 |
+
def bounded_run(*pos,**kwargs):
|
| 81 |
+
command=pos[0]if pos else kwargs.get('args')
|
| 82 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 83 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(command,cwd)
|
| 84 |
+
if target is not None and (kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding'))and kwargs.get('errors')is None:kwargs['errors']='replace'
|
| 85 |
+
if target is not None and cfg.get('execution_budget_seconds')is not None:
|
| 86 |
+
budget=cfg['execution_budget_seconds']
|
| 87 |
+
if type(budget)not in(int,float)or not 0<budget<=120:raise PolicyInfrastructureError('Invalid public execution budget')
|
| 88 |
+
kwargs['timeout']=budget
|
| 89 |
+
remaining=float(os.environ[DEADLINE])-time.monotonic()if target is not None else None
|
| 90 |
+
if remaining is not None and remaining>0:kwargs['timeout']=min(kwargs.get('timeout')or remaining,remaining)
|
| 91 |
+
try:
|
| 92 |
+
if remaining is not None and remaining<=0:raise subprocess.TimeoutExpired(command,0)
|
| 93 |
+
result=_original_run(*pos,**kwargs)
|
| 94 |
+
if target is not None and result.returncode<0:
|
| 95 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_terminated=True,signal=-result.returncode,violations=[])))
|
| 96 |
+
return subprocess.CompletedProcess(result.args,128-result.returncode,result.stdout,result.stderr)
|
| 97 |
+
return result
|
| 98 |
+
except subprocess.TimeoutExpired as error:
|
| 99 |
+
if target is None:raise
|
| 100 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_timeout=True,violations=[])))
|
| 101 |
+
textual=kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding')
|
| 102 |
+
empty=''if textual else b''
|
| 103 |
+
def output(value):
|
| 104 |
+
if value is None:return empty
|
| 105 |
+
return value.decode(kwargs.get('encoding')or'utf-8',errors='replace')if textual and isinstance(value,bytes)else value
|
| 106 |
+
return subprocess.CompletedProcess(command,124,output(error.stdout),output(error.stderr))
|
| 107 |
+
subprocess.run=bounded_run
|
| 108 |
+
|
| 109 |
+
def status(require_execution=True):
|
| 110 |
+
install();p=_folder();rows=[]
|
| 111 |
+
for receipt in sorted(p.glob('*.json')):
|
| 112 |
+
try:row=json.loads(receipt.read_text())
|
| 113 |
+
except (OSError,ValueError)as error:raise PolicyInfrastructureError('Unreadable policy receipt: '+str(receipt))from error
|
| 114 |
+
if row.get('schema')!='bounded-policy-v1'or row.get('state')in ['launching','infrastructure_error']:
|
| 115 |
+
raise PolicyInfrastructureError('Runtime instrumentation did not initialize: '+str(receipt))
|
| 116 |
+
rows.append(row)
|
| 117 |
+
if require_execution and not any(r.get('target_present')for r in rows):return False
|
| 118 |
+
return not any(r.get('violations')or r.get('execution_timeout')or r.get('execution_terminated')for r in rows)
|
| 119 |
+
|
| 120 |
+
def finalize(body,owner_ids,require_execution=True):
|
| 121 |
+
observed=status(require_execution=require_execution)
|
| 122 |
+
wanted=set(map(str,owner_ids))
|
| 123 |
+
for row in body.get('checks',[]):
|
| 124 |
+
if str(row['id'])in wanted:
|
| 125 |
+
if type(row.get('passed'))is not bool:raise PolicyInfrastructureError('Legacy ambiguous component remains in runtime owner '+str(row['id']))
|
| 126 |
+
row['passed']=row['passed']and observed
|
| 127 |
+
row['reason']=str(row.get('reason',''))+'; evaluated bounded runtime import/resource policy'
|
| 128 |
+
body['scoreable']=all(type(row.get('passed'))is bool for row in body.get('checks',[]))
|
| 129 |
+
body['runtime_policy']=dict(scope='actual grader-launched Python script/module invocations',passed=observed)
|
| 130 |
+
return body
|
| 131 |
+
|
| 132 |
+
def run(*args,**kwargs):
|
| 133 |
+
install();return subprocess.run(*args,**kwargs)
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/auto_policy_guard.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Child-side observer for the exact public bounded-invocation policy."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import atexit,builtins,importlib,importlib.util,json,os,runpy,sys,sysconfig
|
| 4 |
+
|
| 5 |
+
receipt,config_file,kind,target,*arguments=sys.argv[1:]
|
| 6 |
+
subject=arguments.pop(0)if kind=='probe'else target
|
| 7 |
+
subject_filename=os.path.abspath(subject)
|
| 8 |
+
receipt=Path(receipt);cfg=json.loads(Path(config_file).read_text());cwd=Path.cwd().resolve()
|
| 9 |
+
local_roots=[cwd,*[p for p in [Path('/candidate'),Path('/app'),Path('/workspace')] if p.is_dir()]]
|
| 10 |
+
if kind=='script':local_roots.insert(0,Path(target).resolve().parent)
|
| 11 |
+
if kind=='probe':local_roots[:0]=[Path(subject).resolve().parent,Path(__file__).resolve().parent]
|
| 12 |
+
candidate_root_names=[str(p)for p in local_roots if str(p)!='/grader']
|
| 13 |
+
observer_filename=__file__
|
| 14 |
+
stdlib_names=set(getattr(sys,'stdlib_module_names',()))|set(sys.builtin_module_names)
|
| 15 |
+
stdlib_root=Path(sysconfig.get_path('stdlib')).resolve()
|
| 16 |
+
if not getattr(sys,'stdlib_module_names',None):
|
| 17 |
+
for p in stdlib_root.iterdir():
|
| 18 |
+
if p.name not in ['site-packages','dist-packages']:stdlib_names.add(p.stem if p.suffix=='.py'else p.name)
|
| 19 |
+
state=dict(schema='bounded-policy-v1',state='running',target=subject,target_present=Path(subject).is_file()if kind in ['script','probe']else True,violations=[])
|
| 20 |
+
busy=False
|
| 21 |
+
def save():
|
| 22 |
+
global busy
|
| 23 |
+
was=busy;busy=True
|
| 24 |
+
try:
|
| 25 |
+
temporary=receipt.with_suffix('.tmp');temporary.write_text(json.dumps(state));temporary.replace(receipt)
|
| 26 |
+
finally:busy=was
|
| 27 |
+
def violation(code,detail):
|
| 28 |
+
state['violations'].append(dict(code=code,detail=str(detail)));save();raise PermissionError('AUTOGRADE_POLICY:'+code)
|
| 29 |
+
def local_module(name):
|
| 30 |
+
first=name.partition('.')[0]
|
| 31 |
+
roots=list(local_roots)
|
| 32 |
+
for value in sys.path:
|
| 33 |
+
try:p=Path(value or cwd).resolve()
|
| 34 |
+
except (OSError,TypeError,ValueError):continue
|
| 35 |
+
if any(p==r or r in p.parents for r in local_roots):roots.append(p)
|
| 36 |
+
return any((p/(first+'.py')).is_file()or(p/first).is_dir()for p in roots)
|
| 37 |
+
def subject_active():
|
| 38 |
+
if kind!='probe':return True
|
| 39 |
+
frame=sys._getframe(1)
|
| 40 |
+
while frame:
|
| 41 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 42 |
+
if isinstance(filename,str):
|
| 43 |
+
absolute=os.path.abspath(filename)
|
| 44 |
+
if any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names):return True
|
| 45 |
+
frame=frame.f_back
|
| 46 |
+
return False
|
| 47 |
+
def audit(event,args):
|
| 48 |
+
relevant=event=='import'and cfg.get('stdlib_only')or cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}or cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}or cfg.get('forbid_native')and event.startswith('ctypes.')
|
| 49 |
+
if busy or not relevant or not subject_active():return
|
| 50 |
+
if event=='import'and cfg.get('stdlib_only')and import_requested_by_candidate():
|
| 51 |
+
check_import(str(args[0]))
|
| 52 |
+
if cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}:violation('network_operation',event)
|
| 53 |
+
if cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}:violation('subprocess_operation',event)
|
| 54 |
+
if cfg.get('forbid_native')and event.startswith('ctypes.'):violation('foreign_function_interface',event)
|
| 55 |
+
def check_import(name):
|
| 56 |
+
if any(name==prefix or name.startswith(prefix+'.')for prefix in cfg.get('forbidden_module_prefixes',[])):violation('forbidden_candidate_import',name)
|
| 57 |
+
base=name.partition('.')[0]
|
| 58 |
+
if cfg.get('stdlib_only')and base not in stdlib_names and not local_module(name):violation('nonstdlib_import',name)
|
| 59 |
+
def import_requested_by_candidate():
|
| 60 |
+
frame=sys._getframe(1)
|
| 61 |
+
while frame:
|
| 62 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 63 |
+
if not isinstance(filename,str)or filename==observer_filename or filename.startswith('<frozen importlib'):frame=frame.f_back;continue
|
| 64 |
+
absolute=os.path.abspath(filename)
|
| 65 |
+
return any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names)
|
| 66 |
+
return False
|
| 67 |
+
original_import=builtins.__import__;original_import_module=importlib.import_module
|
| 68 |
+
def bounded_import(name,globals=None,locals=None,fromlist=(),level=0):
|
| 69 |
+
if not busy and subject_active()and import_requested_by_candidate():
|
| 70 |
+
absolute=name
|
| 71 |
+
if level:
|
| 72 |
+
package=(globals or{}).get('__package__')or(globals or{}).get('__name__','')
|
| 73 |
+
try:absolute=importlib.util.resolve_name('.'*level+name,package)
|
| 74 |
+
except(ImportError,ValueError):absolute=name
|
| 75 |
+
check_import(absolute)
|
| 76 |
+
return original_import(name,globals,locals,fromlist,level)
|
| 77 |
+
def bounded_import_module(name,package=None):
|
| 78 |
+
if not busy and subject_active()and import_requested_by_candidate():check_import(importlib.util.resolve_name(name,package)if name.startswith('.')else name)
|
| 79 |
+
return original_import_module(name,package)
|
| 80 |
+
save();sys.addaudithook(audit);builtins.__import__=bounded_import;importlib.import_module=bounded_import_module
|
| 81 |
+
@atexit.register
|
| 82 |
+
def finish():state['state']='finished';save()
|
| 83 |
+
for p in reversed(local_roots):sys.path.insert(0,str(p))
|
| 84 |
+
sys.argv=[target,*arguments]
|
| 85 |
+
if kind=='module':runpy.run_module(target,run_name='__main__',alter_sys=True)
|
| 86 |
+
else:runpy.run_path(target,run_name='__main__')
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/autograde_task_check.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
import copy,json,math,os,shutil,subprocess,sys,tempfile
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
C=Path(os.environ.get('MYBENCH_CANDIDATE','/candidate'));source=Path('/source/inputs/plans.')
|
| 5 |
+
BASE=json.loads(source.read_text());BASE=BASE['plans']if isinstance(BASE,dict)else BASE
|
| 6 |
+
RANGES={'active-watch':(60,270),'cache-miss':(1200,3600),'idle':(1200,1800)}
|
| 7 |
+
def same(a,b):
|
| 8 |
+
if type(a)is bool or type(b)is bool:return type(a)is type(b)and a==b
|
| 9 |
+
if type(a)in(int,float)and type(b)in(int,float):return a==b
|
| 10 |
+
if type(a)is not type(b):return False
|
| 11 |
+
if isinstance(a,dict):return set(a)==set(b)and all(same(a[k],b[k])for k in a)
|
| 12 |
+
if isinstance(a,list):return len(a)==len(b)and all(same(x,y)for x,y in zip(a,b))
|
| 13 |
+
return a==b
|
| 14 |
+
def expected(row):
|
| 15 |
+
findings=[]
|
| 16 |
+
if row['surface']=='public'and row['always_on']:findings.append('public_always_on')
|
| 17 |
+
if row['cadence_seconds']is not None and row['cadence_seconds']<1800:findings.append('cadence_floor')
|
| 18 |
+
if row['keep_alive_api']:findings.append('api_keep_alive')
|
| 19 |
+
if any(s.startswith('con_')for s in row['state_path'].split('/')):findings.append('state_relocation')
|
| 20 |
+
delay=None;worst=None;wake=row['wakeup']
|
| 21 |
+
if wake is not None:
|
| 22 |
+
value=wake['delay_seconds'];lo,hi=RANGES[wake['wait_class']];worst=min(3600,max(60,value+60));delay=min(hi,max(lo,value))
|
| 23 |
+
if not lo<=value<=hi:findings.append('delay_out_of_tier')
|
| 24 |
+
if value==300:findings.append('delay_300_antipattern')
|
| 25 |
+
if wake['wait_class']=='active-watch':
|
| 26 |
+
delay=min(delay,240)
|
| 27 |
+
if worst>300:findings.append('cache_ttl')
|
| 28 |
+
if wake['reason'].strip().casefold()in['','waiting','loop','next tick','continuing']:findings.append('generic_reason')
|
| 29 |
+
blocked=any(c in findings for c in['public_always_on','cadence_floor','api_keep_alive'])
|
| 30 |
+
return dict(id=row['id'],verdict='INFEASIBLE'if blocked else'FIXED'if findings else'OK',findings=findings,recommended_delay_seconds=None if blocked else delay,worst_case_wait_seconds=worst)
|
| 31 |
+
CODES=['public_always_on','cadence_floor','api_keep_alive','state_relocation','delay_out_of_tier','delay_300_antipattern','cache_ttl','generic_reason']
|
| 32 |
+
def candidate_number(value):
|
| 33 |
+
return type(value)is int or type(value)is float and math.isfinite(value)
|
| 34 |
+
def typed_entry(actual,want):
|
| 35 |
+
if not isinstance(actual,dict)or set(actual)not in[set(want),set(want)|{'messages'}]:return False
|
| 36 |
+
fs=actual.get('findings')
|
| 37 |
+
return (actual.get('id')==want['id']and isinstance(actual.get('id'),str)
|
| 38 |
+
and actual.get('verdict')in('INFEASIBLE','FIXED','OK')
|
| 39 |
+
and isinstance(fs,list)and all(isinstance(c,str)and c in CODES for c in fs)
|
| 40 |
+
and len(set(fs))==len(fs)and fs==sorted(fs,key=CODES.index)
|
| 41 |
+
and all(actual.get(k)is None or candidate_number(actual.get(k))for k in['recommended_delay_seconds','worst_case_wait_seconds'])
|
| 42 |
+
and('messages'not in actual or isinstance(actual['messages'],list)and all(isinstance(s,str)for s in actual['messages'])))
|
| 43 |
+
def code_projection(actual,codes):
|
| 44 |
+
fs=actual.get('findings')if isinstance(actual,dict)else None
|
| 45 |
+
return [c for c in fs if c in codes]if isinstance(fs,list)and all(isinstance(c,str)for c in fs)else None
|
| 46 |
+
def assess(rep,rows):
|
| 47 |
+
if not isinstance(rep,dict)or set(rep)!= {'plans'}or not isinstance(rep['plans'],list)or len(rep['plans'])!=len(rows):return [False]*7
|
| 48 |
+
flags=[True]*7
|
| 49 |
+
for actual,row in zip(rep['plans'],rows):
|
| 50 |
+
want=expected(row);readable=isinstance(actual,dict);get=actual.get if readable else lambda k:None
|
| 51 |
+
flags[0]&=typed_entry(actual,want)
|
| 52 |
+
groups={1:['public_always_on'],2:['cadence_floor','api_keep_alive','state_relocation'],3:['delay_out_of_tier','delay_300_antipattern','generic_reason'],4:['cache_ttl']}
|
| 53 |
+
for owner,codes in groups.items():
|
| 54 |
+
flags[owner]&=readable and code_projection(actual,codes)==[c for c in want['findings']if c in codes]
|
| 55 |
+
# Block verdict/null recommendation belongs to the applicable blocking group.
|
| 56 |
+
# A correct unrelated finding group does not own another group's fields.
|
| 57 |
+
for owner,codes in[(1,['public_always_on']),(2,['cadence_floor','api_keep_alive','state_relocation'])]:
|
| 58 |
+
if any(c in want['findings']for c in codes):
|
| 59 |
+
flags[owner]&=get('verdict')==want['verdict']
|
| 60 |
+
if any(c in want['findings']for c in codes if c!='state_relocation'):flags[owner]&=get('recommended_delay_seconds')is None
|
| 61 |
+
wake=row['wakeup'];blocked=want['verdict']=='INFEASIBLE'
|
| 62 |
+
# Worst wait always describes the original request, independently of its
|
| 63 |
+
# recommendation. Active-watch cap is separate from delay/reason findings.
|
| 64 |
+
flags[4]&=readable and same(get('worst_case_wait_seconds'),want['worst_case_wait_seconds'])
|
| 65 |
+
if wake and wake['wait_class']=='active-watch'and not blocked:flags[4]&=same(get('recommended_delay_seconds'),want['recommended_delay_seconds'])
|
| 66 |
+
if any(c in want['findings']for c in groups[3]):
|
| 67 |
+
flags[3]&=get('verdict')==want['verdict']
|
| 68 |
+
capped=bool(wake and wake['wait_class']=='active-watch'and wake['delay_seconds']>240)
|
| 69 |
+
if not blocked and not capped:flags[3]&=same(get('recommended_delay_seconds'),want['recommended_delay_seconds'])
|
| 70 |
+
if wake is None and not blocked:flags[3]&=get('recommended_delay_seconds')is None
|
| 71 |
+
if wake and wake['wait_class']in['idle','cache-miss']and not want['findings']:
|
| 72 |
+
clean={k:get(k)for k in want if k!='id'}
|
| 73 |
+
wanted={k:v for k,v in want.items()if k!='id'}
|
| 74 |
+
flags[5 if wake['wait_class']=='idle'else 6]&=readable and same(clean,wanted)
|
| 75 |
+
return list(map(bool,flags))
|
| 76 |
+
def load(p):
|
| 77 |
+
try:return json.loads(p.read_text())
|
| 78 |
+
except(OSError,UnicodeError,ValueError,RecursionError):return None
|
| 79 |
+
def main():
|
| 80 |
+
flags=assess(load(C/'report.'),BASE)+[True];panels=[BASE]
|
| 81 |
+
changed=copy.deepcopy(BASE)
|
| 82 |
+
for r in changed:
|
| 83 |
+
r['id']+='-changed'
|
| 84 |
+
if r['wakeup']and r['wakeup']['wait_class']=='idle':r['wakeup']['delay_seconds']=1200
|
| 85 |
+
if r['wakeup']and r['wakeup']['wait_class']=='cache-miss'and r['wakeup']['delay_seconds']==1500:r['wakeup']['delay_seconds']=1800
|
| 86 |
+
panels.append(changed)
|
| 87 |
+
# Independent boundary/domain rows cover every tier, blocker and original-wait clamp.
|
| 88 |
+
for cls,delay,reason in[('active-watch',240,'monitoring build'),('active-watch',241,'monitoring build'),('active-watch',-10,' LOOP '),('cache-miss',3601,'loading data'),('idle',1801,'next tick')]:
|
| 89 |
+
panels.append([dict(id='boundary',surface='private',always_on=False,cadence_seconds=None,state_path='workspace-root/x',keep_alive_api=False,wakeup=dict(wait_class=cls,delay_seconds=delay,reason=reason))])
|
| 90 |
+
for panel in panels:
|
| 91 |
+
with tempfile.TemporaryDirectory()as td:
|
| 92 |
+
d=Path(td);shutil.copytree(C,d,dirs_exist_ok=True,symlinks=True);p=d/'plans.';p.write_text(json.dumps({'plans':panel}));before=p.read_bytes();out=d/'report.'
|
| 93 |
+
if out.is_dir()and not out.is_symlink():shutil.rmtree(out)
|
| 94 |
+
elif out.is_file()or out.is_symlink():out.unlink()
|
| 95 |
+
try:r=subprocess.run([sys.executable,'audit.py'],cwd=d,capture_output=True,text=True,timeout=60);ok=r.returncode==0
|
| 96 |
+
except subprocess.TimeoutExpired:ok=False
|
| 97 |
+
bits=assess(load(out),panel)if ok else[False]*7
|
| 98 |
+
try:unchanged=before==p.read_bytes()
|
| 99 |
+
except OSError:unchanged=False
|
| 100 |
+
flags=[a and b for a,b in zip(flags,bits+[ok and unchanged])]
|
| 101 |
+
print(json.dumps({'scoreable':True,'checks':[dict(id=str(i),passed=v,reason='Public coded background-plan rules, exact recommendations, fresh boundary and source binding; owner '+str(i))for i,v in enumerate(flags)]}))
|
| 102 |
+
if __name__=='__main__':main()
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/check.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from auto_entry import main
|
| 2 |
+
raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/original_check.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
import json,os,re,shutil,subprocess,tempfile
|
| 3 |
+
def main():
|
| 4 |
+
PLANS='{\n "plans": [\n {"id": "status-site", "surface": "public", "always_on": true, "cadence_seconds": null, "state_path": "workspace-root/status.", "keep_alive_api": false, "wakeup": null},\n {"id": "digest", "surface": "private", "always_on": false, "cadence_seconds": 1800, "state_path": "workspace-root/digest-ledger.", "keep_alive_api": false, "wakeup": {"wait_class": "idle", "delay_seconds": 1800, "reason": "idle heartbeat — watching the feed"}},\n {"id": "build-watch", "surface": "private", "always_on": false, "cadence_seconds": null, "state_path": "workspace-root/build-watch.", "keep_alive_api": false, "wakeup": {"wait_class": "active-watch", "delay_seconds": 265, "reason": "checking long bun build"}},\n {"id": "retry-poller", "surface": "private", "always_on": false, "cadence_seconds": null, "state_path": "workspace-root/retries.", "keep_alive_api": false, "wakeup": {"wait_class": "cache-miss", "delay_seconds": 300, "reason": "waiting"}},\n {"id": "task-scraper", "surface": "private", "always_on": false, "cadence_seconds": 300, "state_path": "workspace-root/con_abc123/tasks.", "keep_alive_api": true, "wakeup": null},\n {"id": "admin-dashboard", "surface": "private", "always_on": false, "cadence_seconds": 3600, "state_path": "workspace-root/admin.", "keep_alive_api": false, "wakeup": {"wait_class": "cache-miss", "delay_seconds": 1500, "reason": "periodic tasklist review"}}\n ]\n}\n'
|
| 5 |
+
checks=[]
|
| 6 |
+
def add(i,p,r): checks.append({"id":str(i),"passed":bool(p),"reason":r})
|
| 7 |
+
src=None
|
| 8 |
+
try: src=open('/candidate/audit.py','r',encoding='utf-8',errors='replace').read()
|
| 9 |
+
except Exception: pass
|
| 10 |
+
tmp=tempfile.mkdtemp(dir='/tmp')
|
| 11 |
+
run_ok=False; run_err='audit.py missing or did not run'
|
| 12 |
+
rtext=None
|
| 13 |
+
if src is not None:
|
| 14 |
+
try:
|
| 15 |
+
open(os.path.join(tmp,'audit.py'),'w').write(src)
|
| 16 |
+
open(os.path.join(tmp,'plans.'),'w').write(PLANS)
|
| 17 |
+
pr=subprocess.run(['python3','audit.py'],cwd=tmp,capture_output=True,text=True,timeout=60)
|
| 18 |
+
run_ok=(pr.returncode==0)
|
| 19 |
+
run_err='' if run_ok else 'python3 audit.py exited %s: %s'%(pr.returncode,(pr.stderr or pr.stdout)[-300:])
|
| 20 |
+
except Exception as e: run_err='running audit.py failed: %s'%e
|
| 21 |
+
for p in (os.path.join(tmp,'report.'),'/candidate/report.'):
|
| 22 |
+
if rtext is None:
|
| 23 |
+
try: rtext=open(p,'r',encoding='utf-8',errors='replace').read()
|
| 24 |
+
except Exception: pass
|
| 25 |
+
data=None; perr=''
|
| 26 |
+
if rtext is not None:
|
| 27 |
+
try: data=json.loads(rtext)
|
| 28 |
+
except Exception as e: perr='report. is not valid JSON: %s'%e
|
| 29 |
+
ent={}
|
| 30 |
+
if data is not None:
|
| 31 |
+
lst=None
|
| 32 |
+
if isinstance(data,list): lst=data
|
| 33 |
+
elif isinstance(data,dict):
|
| 34 |
+
for k in ('entries','plans','report','results'):
|
| 35 |
+
if isinstance(data.get(k),list): lst=data[k]; break
|
| 36 |
+
if lst is None and data and all(isinstance(v,dict) for v in data.values()):
|
| 37 |
+
ent={str(k):v for k,v in data.items()}
|
| 38 |
+
if lst is not None:
|
| 39 |
+
for e in lst:
|
| 40 |
+
if isinstance(e,dict) and e.get('id') is not None: ent[str(e['id'])]=e
|
| 41 |
+
ids=['status-site','digest','build-watch','retry-poller','task-scraper','admin-dashboard']
|
| 42 |
+
add(0,data is not None and all(i in ent for i in ids), 'report. valid JSON with all six plan ids' if (data is not None and all(i in ent for i in ids)) else ('report. missing/invalid (%s) or missing ids; found %s'%(perr or run_err or 'no report', sorted(ent))))
|
| 43 |
+
def verd(e):
|
| 44 |
+
v=str(e.get('verdict','')).strip().lower() if e else ''
|
| 45 |
+
return v
|
| 46 |
+
def ftext(e):
|
| 47 |
+
f=e.get('findings',[]) if e else []
|
| 48 |
+
if isinstance(f,str): f=[f]
|
| 49 |
+
return ' | '.join(str(x) for x in f).lower() if isinstance(f,list) else str(f).lower()
|
| 50 |
+
def rec(e):
|
| 51 |
+
try: return float(e.get('recommended_delay_seconds'))
|
| 52 |
+
except Exception: return None
|
| 53 |
+
e=ent.get('status-site')
|
| 54 |
+
add(1,e is not None and verd(e)=='infeasible','status-site verdict INFEASIBLE' if e and verd(e)=='infeasible' else 'status-site entry missing or verdict is %r (expected INFEASIBLE for public always-on surface)'%(verd(e) if e else None))
|
| 55 |
+
e=ent.get('task-scraper'); f=ftext(e)
|
| 56 |
+
reloc=('workspace' in f and ('root' in f or 'relocat' in f or 'files' in f)) or 'con_' in f or 'zo files' in f
|
| 57 |
+
add(2,e is not None and verd(e)=='infeasible' and reloc,'task-scraper INFEASIBLE and findings flag state relocation to workspace files root' if e and verd(e)=='infeasible' and reloc else 'task-scraper verdict=%r, relocation flagged=%s (expected INFEASIBLE + relocation finding for con_ state path)'%(verd(e) if e else None,reloc))
|
| 58 |
+
e=ent.get('retry-poller'); f=ftext(e); r=rec(e)
|
| 59 |
+
flag300=('300' in f and ('anti' in f or 'pattern' in f or 'ttl' in f or 'cache' in f or 'exceed' in f or 'worst' in f)) or 'anti-pattern' in f
|
| 60 |
+
flagreason='waiting' in f and ('reason' in f or 'generic' in f or 'specific' in f or 'vague' in f)
|
| 61 |
+
notok=e is not None and verd(e)!='ok'
|
| 62 |
+
recok=r is None or r==270 or (1200<=r<=3600)
|
| 63 |
+
add(3,e is not None and notok and flag300 and flagreason and recok,'retry-poller flags 300 s anti-pattern and generic reason waiting; verdict not OK; recommended (if any) is 270 or in 1200-3600' if e and notok and flag300 and flagreason and recok else 'retry-poller: verdict=%r, 300-anti-pattern flagged=%s, generic-reason flagged=%s, recommended=%s (must not be OK; rec must be 270 or 1200-3600, never 300)'%(verd(e) if e else None,flag300,flagreason,r))
|
| 64 |
+
e=ent.get('build-watch'); f=ftext(e); r=rec(e)
|
| 65 |
+
worst=('325' in f) or (('300' in f or '5-minute' in f or '5 minute' in f or 'ttl' in f) and ('exceed' in f or 'worst' in f or 'risk' in f or 'ttl' in f or 'boundary' in f))
|
| 66 |
+
recok=r is None or r<=240
|
| 67 |
+
add(4,e is not None and worst and recok,'build-watch flags worst-case 265+60=325 s exceeding 300 s cache TTL; recommended (if any) <= 240' if e and worst and recok else 'build-watch: worst-case/TTL risk flagged=%s, recommended=%s (must flag 325 s > 300 s; rec must be <= 240)'%(worst,r))
|
| 68 |
+
e=ent.get('digest'); r=rec(e)
|
| 69 |
+
add(5,e is not None and verd(e)=='ok' and r==1800,'digest verdict OK with recommended_delay_seconds 1800' if e and verd(e)=='ok' and r==1800 else 'digest verdict=%r, recommended=%s (expected OK / 1800)'%(verd(e) if e else None,r))
|
| 70 |
+
e=ent.get('admin-dashboard'); r=rec(e)
|
| 71 |
+
add(6,e is not None and verd(e)=='ok' and r==1500,'admin-dashboard verdict OK with recommended_delay_seconds 1500' if e and verd(e)=='ok' and r==1500 else 'admin-dashboard verdict=%r, recommended=%s (expected OK / 1500)'%(verd(e) if e else None,r))
|
| 72 |
+
add(7,run_ok and data is not None,'python3 audit.py ran successfully (stdlib only) and produced report.' if run_ok and data is not None else 'audit.py run/production failed: %s'%run_err)
|
| 73 |
+
print(json.dumps({'checks':checks}))
|
| 74 |
+
if __name__=='__main__': main()
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r10_dependency.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Private static dependency validation, including local Python namespace packages.
|
| 2 |
+
|
| 3 |
+
This module only parses source. It never imports or runs candidate modules.
|
| 4 |
+
"""
|
| 5 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 6 |
+
import _imp
|
| 7 |
+
import ast
|
| 8 |
+
import sys
|
| 9 |
+
import tokenize
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def scan_stdlib(root,entries,external=()):
|
| 14 |
+
return True,set(),'Static imports are not scored; bounded runtime policy is independently observed'
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r10_support.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import os,shutil
|
| 4 |
+
from r10_dependency import scan_stdlib
|
| 5 |
+
def stage(candidate,target,remove=()):
|
| 6 |
+
target=Path(target);shutil.copytree(candidate,target,dirs_exist_ok=True,symlinks=True)
|
| 7 |
+
for name in remove:
|
| 8 |
+
path=target/name
|
| 9 |
+
if path.is_dir() and not path.is_symlink():shutil.rmtree(path)
|
| 10 |
+
elif path.exists() or path.is_symlink():path.unlink()
|
| 11 |
+
def dependency(root,entry):
|
| 12 |
+
good,mods,why=scan_stdlib(root,[entry]);return None if why.startswith('unknown:') else good,why
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/evaluator/r12_input_binding.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Only public input binding and already-valid delay preservation probes."""
|
| 2 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 3 |
+
import json,shutil,subprocess,sys,tempfile
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
def entries(value):
|
| 7 |
+
if isinstance(value,list):rows=value
|
| 8 |
+
elif isinstance(value,dict):
|
| 9 |
+
rows=next((value[k]for k in('entries','plans','report','results')if isinstance(value.get(k),list)),None)
|
| 10 |
+
if rows is None:return {str(k):v for k,v in value.items()}if value and all(isinstance(v,dict)for v in value.values())else None
|
| 11 |
+
else:return None
|
| 12 |
+
if not all(isinstance(row,dict)and isinstance(row.get('id'),str)for row in rows):return None
|
| 13 |
+
result={row['id']:row for row in rows}
|
| 14 |
+
return result if len(result)==len(rows)else None
|
| 15 |
+
|
| 16 |
+
def validate_input_binding(candidate):
|
| 17 |
+
source=Path('/source/inputs/plans.')
|
| 18 |
+
plans=json.loads(source.read_text())
|
| 19 |
+
original=plans['plans']if isinstance(plans,dict)else plans
|
| 20 |
+
for renamed,delays in[(True,{}),(True,{'digest':1200,'admin-dashboard':1800})]:
|
| 21 |
+
values=json.loads(json.dumps(plans));rows=values['plans']if isinstance(values,dict)else values
|
| 22 |
+
ids={}
|
| 23 |
+
for row in rows:
|
| 24 |
+
old=row['id'];row['id']=old+'-input-probe';ids[old]=row['id']
|
| 25 |
+
if old in delays:row['wakeup']['delay_seconds']=delays[old]
|
| 26 |
+
with tempfile.TemporaryDirectory(prefix='public-plan-binding-')as td:
|
| 27 |
+
w=Path(td);shutil.copytree(candidate,w,dirs_exist_ok=True,symlinks=True)
|
| 28 |
+
for rel in('plans.','report.'):
|
| 29 |
+
path=w/rel
|
| 30 |
+
if path.is_symlink()or path.is_file():path.unlink()
|
| 31 |
+
elif path.is_dir():shutil.rmtree(path)
|
| 32 |
+
(w/'plans.').write_text(json.dumps(values))
|
| 33 |
+
try:
|
| 34 |
+
proc=subprocess.run([sys.executable,'audit.py'],cwd=w,capture_output=True,text=True,timeout=45)
|
| 35 |
+
report=entries(json.loads((w/'report.').read_text()))
|
| 36 |
+
except(OSError,ValueError,subprocess.SubprocessError):return False,'changed public input did not produce a report'
|
| 37 |
+
if proc.returncode!=0 or report is None or set(report)!=set(ids.values()):return False,'output IDs must follow actual plan IDs'
|
| 38 |
+
for old,new in ids.items():
|
| 39 |
+
row=report[new]
|
| 40 |
+
if not isinstance(row.get('findings'),list)or any(not isinstance(x,str)for x in row['findings']):return False,'public findings must be a string list'
|
| 41 |
+
verdict=str(row.get('verdict','')).casefold()
|
| 42 |
+
if old in('digest','admin-dashboard'):
|
| 43 |
+
target=delays.get(old,1800 if old=='digest' else 1500);actual=row.get('recommended_delay_seconds')
|
| 44 |
+
if verdict!='ok'or type(actual)not in(int,float)or actual!=target:return False,'already-valid tier delay must be retained for its actual input'
|
| 45 |
+
elif old in('status-site','task-scraper')and verdict!='infeasible':return False,'unchanged hard blockers remain infeasible'
|
| 46 |
+
elif old=='build-watch'and verdict!='fixed':return False,'unchanged cache TTL repair remains fixed'
|
| 47 |
+
elif old=='retry-poller'and verdict not in('fixed','infeasible'):return False,'unchanged invalid delay/reason cannot become OK'
|
| 48 |
+
return True,'renamed IDs and independently changed valid tier delays bind to actual plans input'
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/grading/verified_config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2c21a15a390849ba927de16a354fb55727fb129c0e697ddb7fb65b4ef651674
|
| 3 |
+
size 3580
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/inputs/plans.
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"plans": [
|
| 3 |
+
{
|
| 4 |
+
"id": "status-site",
|
| 5 |
+
"surface": "public",
|
| 6 |
+
"always_on": true,
|
| 7 |
+
"cadence_seconds": null,
|
| 8 |
+
"state_path": "workspace-root/status.",
|
| 9 |
+
"keep_alive_api": false,
|
| 10 |
+
"wakeup": null
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"id": "digest",
|
| 14 |
+
"surface": "private",
|
| 15 |
+
"always_on": false,
|
| 16 |
+
"cadence_seconds": 1800,
|
| 17 |
+
"state_path": "workspace-root/digest-ledger.",
|
| 18 |
+
"keep_alive_api": false,
|
| 19 |
+
"wakeup": {
|
| 20 |
+
"wait_class": "idle",
|
| 21 |
+
"delay_seconds": 1800,
|
| 22 |
+
"reason": "idle heartbeat — watching the feed"
|
| 23 |
+
}
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"id": "build-watch",
|
| 27 |
+
"surface": "private",
|
| 28 |
+
"always_on": false,
|
| 29 |
+
"cadence_seconds": null,
|
| 30 |
+
"state_path": "workspace-root/build-watch.",
|
| 31 |
+
"keep_alive_api": false,
|
| 32 |
+
"wakeup": {
|
| 33 |
+
"wait_class": "active-watch",
|
| 34 |
+
"delay_seconds": 265,
|
| 35 |
+
"reason": "checking long bun build"
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"id": "retry-poller",
|
| 40 |
+
"surface": "private",
|
| 41 |
+
"always_on": false,
|
| 42 |
+
"cadence_seconds": null,
|
| 43 |
+
"state_path": "workspace-root/retries.",
|
| 44 |
+
"keep_alive_api": false,
|
| 45 |
+
"wakeup": {
|
| 46 |
+
"wait_class": "cache-miss",
|
| 47 |
+
"delay_seconds": 300,
|
| 48 |
+
"reason": "waiting"
|
| 49 |
+
}
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"id": "task-scraper",
|
| 53 |
+
"surface": "private",
|
| 54 |
+
"always_on": false,
|
| 55 |
+
"cadence_seconds": 300,
|
| 56 |
+
"state_path": "workspace-root/con_abc123/tasks.",
|
| 57 |
+
"keep_alive_api": true,
|
| 58 |
+
"wakeup": null
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"id": "admin-dashboard",
|
| 62 |
+
"surface": "private",
|
| 63 |
+
"always_on": false,
|
| 64 |
+
"cadence_seconds": 3600,
|
| 65 |
+
"state_path": "workspace-root/admin.",
|
| 66 |
+
"keep_alive_api": false,
|
| 67 |
+
"wakeup": {
|
| 68 |
+
"wait_class": "cache-miss",
|
| 69 |
+
"delay_seconds": 1500,
|
| 70 |
+
"reason": "periodic tasklist review"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
]
|
| 74 |
+
}
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/instruction.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Audit the background-operations plans in `plans.` using the two frozen Skills: the Free-tier computer capability reference and the wakeup-loop scheduling reference. Write standard-library Python `audit.py`, run it from the workspace root, and leave `report.`. This is an offline plan analyzer: do not call a live scheduler or API.
|
| 2 |
+
Use the Free-tier Skill for public-service availability, automation cadence floor, API keep-alive behavior and durable-state location. Use the wakeup Skill for the runtime delay clamp, minute-boundary worst-case allowance, cache TTL, prohibited wait anti-pattern and supported delay tiers. This adapter's wait_class `active-watch` means the Skill's cache-warm tier, `cache-miss` means its cache-miss tier, and `idle` means its idle-default tier. Interpret durations in seconds.
|
| 3 |
+
Deterministic report contract: report. is exactly {"plans":[entries in input order]}. Each entry has exactly id,verdict,findings,recommended_delay_seconds,worst_case_wait_seconds, plus optional messages (an array of arbitrary display strings whose language is not graded). Include every applicable findings code in this exact order: public_always_on (surface=public AND always_on=true, conflicting with the Skill availability constraint); cadence_floor (non-null cadence_seconds below the Skill Free-tier automation floor); api_keep_alive (keep_alive_api=true); state_relocation (a slash-separated state_path segment starts with con_); delay_out_of_tier (delay outside the Skill tier for its mapped wait_class); delay_300_antipattern (the specific anti-pattern wait identified by the wakeup Skill); cache_ttl (active-watch worst-case wait, calculated below, exceeds the Skill cache TTL); generic_reason (stripped case-insensitive reason is empty or one of waiting,loop,next tick,continuing). Only active-watch can get cache_ttl.
|
| 4 |
+
Hard-block codes public_always_on/cadence_floor/api_keep_alive make verdict INFEASIBLE and recommended_delay_seconds null. Otherwise verdict FIXED iff findings is nonempty, else OK. No wakeup means both numeric fields are null. For a salvageable wakeup, recommended_delay_seconds is the requested delay clamped to the mapped Skill tier; active-watch is additionally capped at (Skill cache TTL minus Skill minute-boundary allowance). Preserve an already valid request unless that active-watch cap applies. worst_case_wait_seconds describes the ORIGINAL request: add the Skill minute-boundary allowance, THEN clamp to the Skill runtime bounds; this arithmetic order is this offline report convention. Populate it even for an infeasible entry with a wakeup.
|
| 5 |
+
Inputs have unique string ids, valid surface/boolean/path fields and either null wakeup or a wakeup with one of the three mapped classes, an integer delay_seconds and string reason. Do not mutate plans. Precise codes and formulas above determine correctness; optional natural-language messages are not interpreted. Each invocation has a 60-second limit; timeout/abnormal execution fails behavior, while trusted fixture/monitor failure is an unscored infrastructure error.
|
| 6 |
+
|
| 7 |
+
Bounded automatic runtime policy: Only standard-library and submitted local Python modules may be imported during these executions. This policy applies only while the grader executes your submitted Python entry points and the code they actually call; dead code and source strings are not statically judged. Network operations and FFI/native-library loading or calls (ctypes) are forbidden during those executions. External processes are not forbidden unless explicitly prohibited elsewhere in this task. Original expected nonzero exit codes remain legal; each functional check owns its exit convention. Every bounded invocation must finish within its existing finite per-panel timeout; original mode budgets are preserved, including 8-second R9 workflow probes, 40-second added workflow probes, and the existing task-specific budgets stated above. Exceeding that timeout or abnormal candidate execution fails the relevant behavior. Submit regular readable UTF-8 artifacts of the stated format. Missing/corrupt/unreadable candidate artifacts fail their schema checks; trusted fixture setup, runner or observation failures are separate infrastructure errors with no model score.
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
Bounded automatic-evaluation contract: Each grader-launched candidate Python script/module invocation, including a candidate called by a trusted probe, must finish within 60 seconds. A timeout or signal termination is a failed invocation. Normal nonzero exits follow the task-specific exit contract. The complete automatic evaluation has a 420-second wall-time budget; once exhausted, remaining candidate invocations fail without being launched. This bounds failed or hanging submissions within the outer evaluator deadline. Import checks concern imports requested by candidate-authored code during these invocations, including computed imports and caught failures; Python standard-library modules and local authored helpers/packages are allowed. Inactive code, string literals, and optional imports attempted internally by the standard library are not candidate dependency violations. Python socket network operations attempted within the observed invocation are disallowed, and the Docker environment has no network access. Attempting ctypes foreign-function loading/calls, including ctypes initialization that loads a library, is outside this execution contract. The observer applies to the actual bounded invocations; it does not infer whole-program properties. Trusted fixture/interpreter/observer failures are reported as evaluation errors without a candidate score.
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/SKILL.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Multi-skill source bundle
|
| 2 |
+
|
| 3 |
+
Private source bundle wrapper. The original skills are in members/.
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/members/M000/SKILL.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: zo-free-tier-platform-limits
|
| 3 |
+
description: Use when planning, architecting, or reviewing builds on a Free tier Zo Computer instance. Encodes confirmed Free plan constraints so Zo work uses automations/private workspace surfaces where they fit and avoids always-on public hosting or sub-30-minute scheduling assumptions.
|
| 4 |
+
compatibility: "Created for Zo Computer"
|
| 5 |
+
metadata:
|
| 6 |
+
author: telechurch.zo.computer
|
| 7 |
+
version: "1.0"
|
| 8 |
+
confirmed: "2026-04-22"
|
| 9 |
+
source: "JamaicaEats experiment + docs.zocomputer.com/billing"
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Zo Free Tier Platform Limits
|
| 13 |
+
|
| 14 |
+
Status: Confirmed by experiment on 2026-04-22 plus Zo billing documentation.
|
| 15 |
+
|
| 16 |
+
## Core Rule
|
| 17 |
+
|
| 18 |
+
Design around Free tier constraints first. Free tier is useful for private admin surfaces, cross-session workspace files, warm API child sessions, and scheduled background automations. It is not an always-on public hosting substrate and should not be treated as a low-latency scheduler.
|
| 19 |
+
|
| 20 |
+
## Limits
|
| 21 |
+
|
| 22 |
+
1. Interactive computer sleeps when idle.
|
| 23 |
+
- The web UI/session can power down after inactivity.
|
| 24 |
+
- Do not design unattended workflows that depend on an interactive session staying awake.
|
| 25 |
+
|
| 26 |
+
2. Public services sleep with the computer.
|
| 27 |
+
- Public `*.zo.space` sites and self-hosted services are unavailable when the computer sleeps.
|
| 28 |
+
- Do not rely on Free tier public Zo Space for always-on public presence.
|
| 29 |
+
|
| 30 |
+
3. Private sites are exempt from the service limit.
|
| 31 |
+
- Private pages do not count against the Free tier service allocation.
|
| 32 |
+
- Prefer private pages for admin dashboards, internal tools, staging, and Sentinel/operator surfaces that do not need public uptime.
|
| 33 |
+
|
| 34 |
+
4. Automations are the unattended execution path.
|
| 35 |
+
- Automations continue running independently of the interactive session.
|
| 36 |
+
- Use automations for background checks, heartbeats, digests, alerts, and periodic tasklist review.
|
| 37 |
+
|
| 38 |
+
5. Automation cadence floors at about 30 minutes on Free tier.
|
| 39 |
+
- Experiments showed `FREQ=MINUTELY;INTERVAL=5` effectively firing around every 30 minutes.
|
| 40 |
+
- Do not design Free tier automations requiring sub-30-minute response. Upgrade if that latency matters.
|
| 41 |
+
|
| 42 |
+
6. API calls spawn independent child sessions.
|
| 43 |
+
- `POST /zo/ask` does not reset the interactive session idle timer.
|
| 44 |
+
- API calls are not a keep-alive strategy.
|
| 45 |
+
|
| 46 |
+
7. Shared state belongs in Zo Files.
|
| 47 |
+
- The Zo Files workspace root is visible across interactive and API-spawned sessions.
|
| 48 |
+
- Conversation workspaces such as `/home/.z/workspaces/con_*/` are session-scoped and should not hold durable automation/task state.
|
| 49 |
+
|
| 50 |
+
## Decision Checklist
|
| 51 |
+
|
| 52 |
+
- Needs always-on public presence: Free tier is insufficient; plan a paid upgrade or host the public surface elsewhere.
|
| 53 |
+
- Needs sub-30-minute automation response: Free tier is insufficient; upgrade or move the low-latency path to Cloudflare/app infrastructure.
|
| 54 |
+
- Needs unattended background execution: use Zo automations, not interactive sessions or API polling loops.
|
| 55 |
+
- Needs shared state across sessions: write to Zo Files.
|
| 56 |
+
- Is internal/admin/staging: prefer private Zo pages and durable workspace files.
|
| 57 |
+
|
| 58 |
+
## Design Bias
|
| 59 |
+
|
| 60 |
+
Use Free tier where it has liberty:
|
| 61 |
+
|
| 62 |
+
- Private operator/admin dashboards.
|
| 63 |
+
- Advisor memory, tasklists, and review ledgers under Zo Files.
|
| 64 |
+
- Scheduled summaries, digests, and slow watchdogs at 30-minute-or-slower cadence.
|
| 65 |
+
- AI reasoning through API child sessions.
|
| 66 |
+
- Design contracts, code review suggestions, and non-authoritative planning.
|
| 67 |
+
|
| 68 |
+
Avoid building against the grain:
|
| 69 |
+
|
| 70 |
+
- Public production sites that must stay online.
|
| 71 |
+
- Real-time monitors or rapid alert loops.
|
| 72 |
+
- Keep-alive polling.
|
| 73 |
+
- Durable state in conversation workspaces.
|
| 74 |
+
- Public services that become critical when the computer sleeps.
|
| 75 |
+
|
| 76 |
+
## Upgrade Trigger
|
| 77 |
+
|
| 78 |
+
Paid plans unlock always-on computer behavior, more hosted services, fuller model access, and more automation flexibility. If a Zo-hosted surface becomes production-public, latency-sensitive, or service-critical, plan Basic or higher or move that role to the app/Cloudflare layer.
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/skill/members/M001/SKILL.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: choose-loop-wakeup-interval
|
| 3 |
+
description: >
|
| 4 |
+
Select a `delaySeconds` value when scheduling a loop wakeup via the
|
| 5 |
+
`ScheduleWakeup` tool or the `/loop` slash command. Covers the three-tier
|
| 6 |
+
cache-aware decision (cache-warm under 5 minutes, cache-miss 5 minutes to
|
| 7 |
+
1 hour, idle default 20 to 30 minutes), the 300-second anti-pattern, the
|
| 8 |
+
[60, 3600] runtime clamp, the minute-boundary rounding quirk, and writing
|
| 9 |
+
a telemetry-worthy `reason` field. Use when designing an autonomous loop,
|
| 10 |
+
when a heartbeat cadence is being planned, when polling cadence is being
|
| 11 |
+
tuned, or when post-hoc review of loop costs reveals interval mis-sizing.
|
| 12 |
+
license: MIT
|
| 13 |
+
allowed-tools: ""
|
| 14 |
+
metadata:
|
| 15 |
+
author: Philipp Thoss
|
| 16 |
+
version: "1.0"
|
| 17 |
+
domain: general
|
| 18 |
+
complexity: intermediate
|
| 19 |
+
language: multi
|
| 20 |
+
tags: loop, wakeup, cache, scheduling, delay, general
|
| 21 |
+
locale: ja
|
| 22 |
+
source_locale: en
|
| 23 |
+
source_commit: 9c546edf
|
| 24 |
+
translator: "Claude + human review"
|
| 25 |
+
translation_date: "2026-05-03"
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# Choose Loop Wakeup Interval
|
| 29 |
+
|
| 30 |
+
`ScheduleWakeup` の `delaySeconds` 値を、プロンプトキャッシュの 5 分 TTL、スケジューラの分単位の粒度、`[60, 3600]` のランタイムクランプを尊重して選ぶ。決定は構造的に自明ではない: 「だいたい5分待とう」という共通の直感は最悪の領域に落ちる — キャッシュミスのコストを払いながら待ちを償却できない。
|
| 31 |
+
|
| 32 |
+
その推論は `ScheduleWakeup` ツールの説明と共にツール呼び出し時に運ばれるが、その時点ではループはすでにスケジュールされている。本スキルはその推論を、それが属する計画時間へと引き上げる。
|
| 33 |
+
|
| 34 |
+
## 使用タイミング
|
| 35 |
+
|
| 36 |
+
- 自律的な `/loop` または `ScheduleWakeup` 駆動の継続を設計し、ティックあたりの遅延を選ぶとき
|
| 37 |
+
- ポーリング、監視、反復を行う長時間実行エージェントのハートビート周期を計画するとき
|
| 38 |
+
- コストやキャッシュ温度の圧力に対してポーリング周期をチューニングするとき
|
| 39 |
+
- ループコストを事後レビューし、間隔のミスサイジングを発見するとき
|
| 40 |
+
- `delaySeconds` の選択を含むガイド、ランブック、実例を執筆するとき
|
| 41 |
+
|
| 42 |
+
## 入力
|
| 43 |
+
|
| 44 |
+
- **必須**: ループが何を待っているか(特定のイベント、状態遷移、アイドルティック、定期チェック)
|
| 45 |
+
- **必須**: このティックの読み手が新鮮な文脈(cache-warm)を必要とするか、コールド再読込(cache-miss 許容)に耐えうるか
|
| 46 |
+
- **任意**: 待機イベントが起こりうる最早時刻に関する既知の下限(例: 「ビルドは少なくとも4分かかる」)
|
| 47 |
+
- **任意**: ループ全体のコスト天井(ティック数 × ティックあたりコスト)
|
| 48 |
+
|
| 49 |
+
## 手順
|
| 50 |
+
|
| 51 |
+
### ステップ1: 待機を分類する
|
| 52 |
+
|
| 53 |
+
待機がどの階層に属するかを決める:
|
| 54 |
+
|
| 55 |
+
- **アクティブ監視 (cache-warm)**: 何かが次の5分以内に変化することが予想される — 完了に近いビルド、ポーリングされる状態遷移、たった今キックオフされたプロセス
|
| 56 |
+
- **Cache-miss 待機**: 5分以内に確認する価値のあるものはない; 文脈キャッシュは冷め、それは許容できる
|
| 57 |
+
- **アイドル**: 監視する具体的な信号はない; ループは何かを見つけるかもしれないという理由でチェックしているのであり、見つけるからではない
|
| 58 |
+
|
| 59 |
+
**期待結果:** 明確な分類: active-watch、cache-miss、idle のいずれか。
|
| 60 |
+
|
| 61 |
+
**失敗時:** 待機が分類できない場合 — 「私は何を待っているのか?」に正直な答えがない場合 — そのループはおそらく存在すべきではない。ステップ5へ飛び、wakeup を全くスケジュールしないことを検討する。
|
| 62 |
+
|
| 63 |
+
### ステップ2: 三層決定を適用する
|
| 64 |
+
|
| 65 |
+
分類に基づいて `delaySeconds` を選ぶ:
|
| 66 |
+
|
| 67 |
+
| Tier | Range | Cache behaviour | Use when |
|
| 68 |
+
|---|---|---|---|
|
| 69 |
+
| Cache-warm | **60 – 270 s** | Cache stays warm (under 5-minute TTL) | Active watch — the next tick needs fast, cheap re-entry |
|
| 70 |
+
| Cache-miss | **1200 – 3600 s** | Cache goes cold; one miss buys a long wait | Genuinely idle, or the awaited event cannot happen sooner |
|
| 71 |
+
| Idle default | **1200 – 1800 s** (20–30 min) | Cache goes cold | No specific signal; periodic check with user able to interrupt |
|
| 72 |
+
|
| 73 |
+
**300 s を選ばない。** これは最悪の間隔: キャッシュはミスし、しかも待機がミスを償却するには短すぎる。「だいたい5分」を取りたくなったら、270 s に下げる(warm のまま)か、1200 s+ にコミットする(ミスを償却する)。
|
| 74 |
+
|
| 75 |
+
**期待結果:** 三層のいずれかから選ばれた具体的な `delaySeconds` 値、習慣的に選ばれた切りのよい分単位値ではないもの。
|
| 76 |
+
|
| 77 |
+
**失敗時:** 選択がいつも 300 s に落ちるなら、根底の問い���普通「このループはこの周期で存在すべきか?」である — ステップ1を再検討する。
|
| 78 |
+
|
| 79 |
+
### ステップ3: 分境界に合わせてサイジングする
|
| 80 |
+
|
| 81 |
+
スケジューラは整数分の境界で発火する。`delaySeconds` が `N` だと実際の遅延は分のどの秒に呼んだかに依って `N` から `N + 60` 秒となる。
|
| 82 |
+
|
| 83 |
+
実例:
|
| 84 |
+
|
| 85 |
+
> `HH:MM:40` で `ScheduleWakeup({delaySeconds: 90})` を呼ぶと、ターゲットは `HH:(MM+2):00` — つまり実際の待機は 90 s ではなく 140 s。
|
| 86 |
+
|
| 87 |
+
帰結: 分未満の意図は無意味。渡す値は精密スケジュールではなく **最小値** として扱う。1分のずれが問題になるなら、ループ周期はこの機構には厳しすぎる。
|
| 88 |
+
|
| 89 |
+
**期待結果:** 実際の待機が要求した `delaySeconds` より最大 60 秒長くなることを受け入れている。cache-warm ティックではこれは重要 — 270 s が実際には ~330 s になり cache-miss 領域に転がりうる。
|
| 90 |
+
|
| 91 |
+
**失敗時:** 上限近くの値(例: cache-warm を狙って 265 s)が一般的なら、下方にパディングする — 最悪ケースの分境界ずれの下でも cache-warm 保証を維持するため、270 s ではなく 240 s を使う。
|
| 92 |
+
|
| 93 |
+
### ステップ4: クランプを尊重する
|
| 94 |
+
|
| 95 |
+
ランタイムは `delaySeconds` を `[60, 3600]` にクランプする — 範囲外の値は静かに調整される。テレメトリはモデルが要求したもの(`chosen_delay_seconds`)と実際にスケジュールされたもの(`clamped_delay_seconds`)を区別し、不一致時は `was_clamped: true` をセットする。
|
| 96 |
+
|
| 97 |
+
要求値ではなくクランプ値に対して計画する:
|
| 98 |
+
|
| 99 |
+
- 60 未満の要求 → 実際の待機は 60 s + 分境界ずれ(実際には最大 120 s)
|
| 100 |
+
- 3600 超の要求 → 実際の待機は 3600 s(1時間)
|
| 101 |
+
- 天井を延ばすランタイムはない; 数時間の待機には複数ティックが必要
|
| 102 |
+
|
| 103 |
+
**期待結果:** 選んだ値が `[60, 3600]` の中にあるか、もしくはクランプ挙動を意図的に受け入れている。
|
| 104 |
+
|
| 105 |
+
**失敗時:** 真に数時間(例: 「4時間後に起こせ」)が必要なら、wakeup を連鎖させる — 自身を再スケジュールする 3600 s ティック — か、cron ベースのループ(`CronCreate` with `kind: "loop"`)を代わりに使う。
|
| 106 |
+
|
| 107 |
+
### ステップ5: 具体的な `reason` を書く
|
| 108 |
+
|
| 109 |
+
`reason` フィールドはテレメトリ、ユーザー可視ステータス、プロンプトキャッシュ温度推論を一行に兼ねる。200 文字に切られる。具体的にする。
|
| 110 |
+
|
| 111 |
+
- 良: `checking long bun build`、`polling for EC2 instance running-state`、`idle heartbeat — watching the feed`
|
| 112 |
+
- 悪: `waiting`、`loop`、`next tick`、`continuing`
|
| 113 |
+
|
| 114 |
+
このフィールドの読み手は、あなたの周期を事前に予測することなくループが何をしているかを理解しようとするユーザー。彼らに向けて書く。
|
| 115 |
+
|
| 116 |
+
**期待結果:** ステータスをちらと見るユーザーに意味の通る、具体的な一句の理由。
|
| 117 |
+
|
| 118 |
+
**失敗時:** 具体的な理由を述べられないなら、ループが存在すべきかを再検討する(ステップ1とステップ6)。
|
| 119 |
+
|
| 120 |
+
### ステップ6: ループしないケースを認識する
|
| 121 |
+
|
| 122 |
+
すべての「後で戻ってこよう」という衝動がスケジュール wakeup に値するわけではない。次の場合はティックをスケジュール **しない**:
|
| 123 |
+
|
| 124 |
+
- ユーザーが能動的に見ている — タイマーではなく彼らの入力が正しいトリガー
|
| 125 |
+
- 収束基準がない — ループに「完了」の定義がない
|
| 126 |
+
- タスクが対話的(ティックの間にユーザーに質問する)
|
| 127 |
+
- 必要な周期がクランプ下限(60 s)より短い — それほど厳しいポーリングはループではなくイベント駆動機構に属する
|
| 128 |
+
|
| 129 |
+
**期待結果:** wakeup をスケジュールするか全くループしないかの意識的な選択。「できるから」はループする理由ではない。
|
| 130 |
+
|
| 131 |
+
**失敗時:** 発火前にユーザーが割り込む wakeup を繰り返しスケジュールしているなら、間隔ではなくパターンが間違っている。
|
| 132 |
+
|
| 133 |
+
## バリデーション
|
| 134 |
+
|
| 135 |
+
- [ ] 待機が active-watch、cache-miss、idle のいずれかに分類された(三つのうち一つ)
|
| 136 |
+
- [ ] 選ばれた `delaySeconds` が三層範囲のいずれか(60–270、1200–3600、idle なら 1200–1800)に入る
|
| 137 |
+
- [ ] 値が 300 ではない(最悪領域)
|
| 138 |
+
- [ ] 値が `[60, 3600]` の中、もしくはクランプ挙動が明示的に受け入れられている
|
| 139 |
+
- [ ] 分境界ずれが考慮されている(値を最小値として扱う)
|
| 140 |
+
- [ ] `reason` が具体的で 200 文字未満
|
| 141 |
+
- [ ] don't-loop チェックが行われた — wakeup が実際に正当化されている
|
| 142 |
+
|
| 143 |
+
## よくある落とし穴
|
| 144 |
+
|
| 145 |
+
- **切りの良い分の既定 (300 s)**: 最も一般的な誤り��「だいたい5分」は自然に感じられ、しかも全く誤り。270 s に下げるか 1200 s+ にコミットする。
|
| 146 |
+
- **分境界ずれを無視する**: 分の終わり近くで 60 s を要求すると実際の遅延は ~120 s になりうる。cache-warm ティックでは予想外に 5 分 TTL を超えうる。
|
| 147 |
+
- **分未満の精度を追う**: スケジューラは分単位の粒度を持つ。85 s vs 90 s vs 95 s を尋ねるのはノイズ — 値を選んで進む。
|
| 148 |
+
- **不透明な `reason` フィールド**: `"waiting"` はユーザーに何も伝えず、テレメトリの有用性も下げる。理由はステータスラインで読まれるかのように書く。
|
| 149 |
+
- **不要なループを正当化するために本スキルを使う**: 「私は何を見ているのか?」への正直な答えが曖昧なら、どんな間隔の選択も助けにならない — そのループは存在すべきでない。
|
| 150 |
+
- **プロンプトでの手動クランプ**: モデルの推論内でクランプしない(「念のため 3600 を上限に」)。ランタイムがクランプする。任せる。
|
| 151 |
+
- **7 日エイジアウトを忘れる**: 動的ループは既定で 7 日後にリープされる(ユーザー設定で最大 30 日)。長時間実行ループは天井に対するレースではなく、その天井よりかなり前に終わるよう設計すべき。
|
| 152 |
+
|
| 153 |
+
## 例
|
| 154 |
+
|
| 155 |
+
### 例1 — Cache-warm アクティブ監視
|
| 156 |
+
|
| 157 |
+
`bun build` がキックオフされ、エージェントは結果到着時にキャッシュがまだ warm なように素早く確認したい。
|
| 158 |
+
|
| 159 |
+
- 分類: アクティブ監視(ステップ1)
|
| 160 |
+
- 階層: cache-warm(ステップ2)、**240 s** を選ぶ
|
| 161 |
+
- 分境界(ステップ3): 最悪ケースの実際の待機 ~300 s — 60 s バッファで 5 分 TTL の下に収まる
|
| 162 |
+
- 理由(ステップ5): `checking long bun build`
|
| 163 |
+
|
| 164 |
+
### 例2 — アイドルハートビート
|
| 165 |
+
|
| 166 |
+
自律エージェントが、行動に値するものを求めて低ボリュームのフィードを 1 時間に 1 回監視する。
|
| 167 |
+
|
| 168 |
+
- 分類: アイドル(ステップ1)
|
| 169 |
+
- 階層: アイドル既定(ステップ2)、**1800 s**(30 分)を選ぶ
|
| 170 |
+
- 分境界(ステップ3): 無関係 — 60 s のずれはこの周期では無視できる
|
| 171 |
+
- 理由(ステップ5): `idle heartbeat — watching the feed`
|
| 172 |
+
|
| 173 |
+
### 例3 — アンチパターン
|
| 174 |
+
|
| 175 |
+
エージェントがリモート API のリトライ中に「5分待ち」たい。要求は 300 s。
|
| 176 |
+
|
| 177 |
+
- 問題: キャッシュは 5 分で冷めるので 300 s はミスを払う — しかし 300 s はミスを償却するには短すぎる
|
| 178 |
+
- 修正: 270 s に下げる(warm のまま)か 1500 s にコミットする(ミスを償却する)。300 を選ばない。
|
| 179 |
+
|
| 180 |
+
## 関連スキル
|
| 181 |
+
|
| 182 |
+
- `manage-token-budget` — 長期エージェントループのコスト天井; キャッシュ意識サイジングは一つのレバー
|
| 183 |
+
- `du-dum` — 観察/行為の分離パターン; 本スキルはループが cron なしのときの観察クロック間隔をサイジングする
|
| 184 |
+
- `read-continue-here` — セッション越しの引き継ぎ; 本スキルはセッション内の wakeup を扱う
|
| 185 |
+
- `write-continue-here` — `read-continue-here` の補完
|
benchmarks/skillbench-venus-e/tasks/3059dc70575118750c6f3bb2/task.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11547aa96fb4b26acfdb6a27e046c6fe9705bec51861e014f29671a073f22cff
|
| 3 |
+
size 6071
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/audit_variants.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Independent geometry boundaries for the public eye/reach/cone formulas."""
|
| 2 |
+
import csv,io,json,math,subprocess,sys,tempfile
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
from r10_support import stage
|
| 5 |
+
|
| 6 |
+
def finite_candidate_number(value):
|
| 7 |
+
if type(value)not in(int,float):return False
|
| 8 |
+
try:return math.isfinite(value)
|
| 9 |
+
except OverflowError:return False
|
| 10 |
+
|
| 11 |
+
def evaluate(candidate):
|
| 12 |
+
rows=[('green-edge',0,1.15,.45),('yellow-near',0,1.15,.450001),('yellow-edge',0,1.15,.6),('red-near',0,1.15,.600001),('behind',0,1.15,-.3)]
|
| 13 |
+
for angle in (34.999,35.001):
|
| 14 |
+
rows.append(('cone-'+str(angle),.4*math.sin(math.radians(angle)),1.15,.4*math.cos(math.radians(angle))))
|
| 15 |
+
panels=[rows,list(reversed(rows[:4]))]
|
| 16 |
+
bits=[True]*6
|
| 17 |
+
for items in panels:
|
| 18 |
+
expected=[]
|
| 19 |
+
for name,x,y,z in items:
|
| 20 |
+
distance=math.sqrt(x*x+(y-1.15)**2+z*z);angle=math.degrees(math.acos(max(-1,min(1,z/distance))))
|
| 21 |
+
expected.append(dict(name=name,distance=round(distance,3),zone='green'if distance<=.45 else'yellow'if distance<=.6 else'red',angle_deg=round(angle,3),in_cone=angle<=35))
|
| 22 |
+
expected.sort(key=lambda x:x['distance'])
|
| 23 |
+
summary={zone:sum(x['zone']==zone for x in expected)for zone in ['green','yellow','red']};summary['all_critical_in_cone']=all(x['in_cone']for x in expected if x['zone']=='green')
|
| 24 |
+
with tempfile.TemporaryDirectory()as td:
|
| 25 |
+
stage(candidate,td,['report.','report.json']);d=Path(td)
|
| 26 |
+
stream=io.StringIO();writer=csv.writer(stream);writer.writerow(['name','x','y','z']);writer.writerows(items);(d/'controls.csv').write_text(stream.getvalue())
|
| 27 |
+
p=subprocess.run([sys.executable,'ergo_check.py'],cwd=d,capture_output=True,text=True,timeout=60)
|
| 28 |
+
try:actual=json.loads((d/'report.').read_text())
|
| 29 |
+
except(OSError,ValueError):actual=None
|
| 30 |
+
shape=isinstance(actual,dict)and isinstance(actual.get('controls'),list)and isinstance(actual.get('summary'),dict)
|
| 31 |
+
got=actual.get('controls',[])if isinstance(actual,dict)and isinstance(actual.get('controls'),list)else[];names=[x.get('name')for x in got if isinstance(x,dict)and isinstance(x.get('name'),str)];inventory=len(got)==len(expected)and all(isinstance(x,dict)and {'name','distance','zone','angle_deg','in_cone'}<=set(x)for x in got)and len(names)==len(got)and len(set(names))==len(expected)and set(names)=={x['name']for x in expected}
|
| 32 |
+
mapping={x['name']:x for x in got}if inventory else{}
|
| 33 |
+
factual=inventory
|
| 34 |
+
for e in expected:
|
| 35 |
+
a=mapping.get(e['name'],{})
|
| 36 |
+
factual &= all(finite_candidate_number(a.get(k))and abs(a[k]-e[k])<1e-9 for k in ['distance','angle_deg'])and a.get('zone')==e['zone']and a.get('in_cone')is e['in_cone']
|
| 37 |
+
zones=inventory and all(type(mapping[e['name']].get('zone'))is str and mapping[e['name']]['zone']==e['zone']for e in expected)
|
| 38 |
+
cones=inventory and all(finite_candidate_number(mapping[e['name']].get('angle_deg'))and abs(float(mapping[e['name']]['angle_deg'])-e['angle_deg'])<=1e-9 and type(mapping[e['name']].get('in_cone'))is bool and mapping[e['name']]['in_cone']is e['in_cone']for e in expected)
|
| 39 |
+
distances=[x.get('distance')for x in got if isinstance(x,dict)];order=inventory and all(finite_candidate_number(x)for x in distances)and distances==sorted(distances)
|
| 40 |
+
s=actual.get('summary',{})if shape else{};summaryok=all(type(s.get(k))is int and s[k]==summary[k]for k in ['green','yellow','red'])and s.get('all_critical_in_cone')is summary['all_critical_in_cone']
|
| 41 |
+
bits=[a and b for a,b in zip(bits,[p.returncode>=0 and shape,factual,zones,cones,order,summaryok])]
|
| 42 |
+
return bits
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_contract.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd1a3cf8f6adc127040758d67438be38f63486fb5c9c9d0faad4d4c7328dc67e
|
| 3 |
+
size 209
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_entry.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Stable result protocol; candidate failures and evaluator errors stay distinct."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import contextlib,io,json,runpy,sys
|
| 4 |
+
from auto_policy import install,finalize
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
captured=io.StringIO()
|
| 9 |
+
try:
|
| 10 |
+
install()
|
| 11 |
+
with contextlib.redirect_stdout(captured):
|
| 12 |
+
try:runpy.run_path(str(HERE/'autograde_task_check.py'),run_name='__main__')
|
| 13 |
+
except SystemExit as error:
|
| 14 |
+
if error.code not in(None,0):raise RuntimeError('Trusted checker exited '+str(error.code))
|
| 15 |
+
body=None
|
| 16 |
+
for line in reversed(captured.getvalue().splitlines()):
|
| 17 |
+
try:value=json.loads(line)
|
| 18 |
+
except(ValueError,TypeError):continue
|
| 19 |
+
if isinstance(value,dict)and isinstance(value.get('checks'),list):body=value;break
|
| 20 |
+
if body is None:raise RuntimeError('Trusted checker did not emit its result schema')
|
| 21 |
+
if body.get('status')=='evaluation_error'or body.get('protocol_valid')is False:raise RuntimeError('Trusted checker reports evaluator failure: '+str(body.get('error','')))
|
| 22 |
+
cfgfile=HERE/'auto_policy.json'
|
| 23 |
+
if cfgfile.is_file():
|
| 24 |
+
cfg=json.loads(cfgfile.read_text());owners=cfg.get('runtime_owner_ids',cfg.get('owner_ids',[]))
|
| 25 |
+
if owners:body=finalize(body,owners,require_execution=cfg.get('require_execution',True))
|
| 26 |
+
checks=body['checks']
|
| 27 |
+
if not checks or any(not isinstance(c,dict)or type(c.get('passed'))is not bool or not isinstance(c.get('id'),(int,str))or isinstance(c.get('id'),bool)for c in checks):raise RuntimeError('Trusted checker contains an unresolved or malformed criterion; no model score assigned')
|
| 28 |
+
ids=[str(c['id'])for c in checks]
|
| 29 |
+
if len(ids)!=len(set(ids)):raise RuntimeError('Duplicate criterion ID')
|
| 30 |
+
contract=json.loads((HERE/'auto_contract.json').read_text());expected=contract['expected_check_ids']
|
| 31 |
+
if '--view'not in sys.argv and set(ids)!=set(expected):raise RuntimeError('Criterion IDs differ from fixed public contract')
|
| 32 |
+
weights=contract['criterion_weights']
|
| 33 |
+
body.update(status='scored',scoreable=True,protocol_valid=True,score=sum(weights[str(c['id'])]for c in checks if c['passed'])/sum(weights[str(c['id'])]for c in checks),passed_checks=sum(c['passed']for c in checks),total_checks=len(checks),all_passed=all(c['passed']for c in checks))
|
| 34 |
+
print(json.dumps(body,ensure_ascii=True));return 0
|
| 35 |
+
except Exception as error:
|
| 36 |
+
print(json.dumps(dict(status='evaluation_error',score=None,scoreable=False,protocol_valid=False,checks=[],error=type(error).__name__+': '+str(error),error_category='trusted_evaluator_or_environment',candidate_scored=False),ensure_ascii=True));return 2
|
| 37 |
+
|
| 38 |
+
if __name__=='__main__':raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c1512435675b53e3c8819532bf76df86cb4887c88f17b1847da1a22d367e378
|
| 3 |
+
size 251
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Trusted bounded-invocation policy; never infer whole-program properties."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import hashlib,json,os,subprocess,sys,tempfile,time,uuid
|
| 4 |
+
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
ENV='MYBENCH_AUTO_POLICY_RECEIPTS'
|
| 7 |
+
DEADLINE='MYBENCH_AUTO_POLICY_DEADLINE'
|
| 8 |
+
class PolicyInfrastructureError(RuntimeError): pass
|
| 9 |
+
_installed=False
|
| 10 |
+
_original_popen=subprocess.Popen
|
| 11 |
+
_original_run=subprocess.run
|
| 12 |
+
|
| 13 |
+
def _config():
|
| 14 |
+
p=HERE/'auto_policy.json'
|
| 15 |
+
if not p.is_file():return None
|
| 16 |
+
value=json.loads(p.read_text())
|
| 17 |
+
if not isinstance(value,dict):raise PolicyInfrastructureError('Invalid trusted runtime policy')
|
| 18 |
+
return value
|
| 19 |
+
|
| 20 |
+
def _folder():
|
| 21 |
+
if ENV not in os.environ:
|
| 22 |
+
os.environ[ENV]=tempfile.mkdtemp(prefix='autograde-policy-',dir='/tmp')
|
| 23 |
+
p=Path(os.environ[ENV]);p.mkdir(parents=True,exist_ok=True);return p
|
| 24 |
+
|
| 25 |
+
def _python_target(command,cwd):
|
| 26 |
+
if not isinstance(command,(list,tuple))or not command:return None
|
| 27 |
+
argv=[os.fspath(x)for x in command]
|
| 28 |
+
if 'python'not in Path(argv[0]).name.lower():return None
|
| 29 |
+
i=1;flags=[]
|
| 30 |
+
while i<len(argv)and argv[i].startswith('-'):
|
| 31 |
+
flag=argv[i]
|
| 32 |
+
if flag=='-m':
|
| 33 |
+
if i+1>=len(argv):return None
|
| 34 |
+
name=argv[i+1];p=Path(cwd)/name.replace('.','/')
|
| 35 |
+
if not p.with_suffix('.py').is_file()and not(p/'__main__.py').is_file():return None
|
| 36 |
+
return argv[0],flags,'module',name,argv[i+2:]
|
| 37 |
+
if flag in ['-c','-']:return None
|
| 38 |
+
flags.append(flag);i+=1
|
| 39 |
+
if flag in ['-W','-X']and i<len(argv):flags.append(argv[i]);i+=1
|
| 40 |
+
if i>=len(argv)or not argv[i].endswith('.py'):return None
|
| 41 |
+
path=Path(argv[i]);path=path if path.is_absolute()else Path(cwd)/path
|
| 42 |
+
path=path.resolve()
|
| 43 |
+
if path==HERE or HERE in path.parents:
|
| 44 |
+
if path.name in ['auto_policy.py','auto_policy_guard.py']:return None
|
| 45 |
+
for value in argv[i+1:]:
|
| 46 |
+
if not value.endswith('.py')or value.startswith('-'):continue
|
| 47 |
+
subject=Path(value);subject=subject if subject.is_absolute()else Path(cwd)/subject
|
| 48 |
+
subject=subject.resolve()
|
| 49 |
+
if HERE not in subject.parents:
|
| 50 |
+
return argv[0],flags,'probe',str(path),[str(subject),*argv[i+1:]]
|
| 51 |
+
return None
|
| 52 |
+
return argv[0],flags,'script',str(path),argv[i+1:]
|
| 53 |
+
|
| 54 |
+
def install():
|
| 55 |
+
global _installed
|
| 56 |
+
if _installed:return
|
| 57 |
+
_installed=True
|
| 58 |
+
cfg=_config()
|
| 59 |
+
if cfg is None:return
|
| 60 |
+
_folder()
|
| 61 |
+
os.environ.setdefault(DEADLINE,str(time.monotonic()+cfg.get('total_evaluation_budget_seconds',420)))
|
| 62 |
+
class GuardedPopen(_original_popen):
|
| 63 |
+
def __init__(self,args,*pos,**kwargs):
|
| 64 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 65 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(args,cwd)
|
| 66 |
+
receipt=None
|
| 67 |
+
if target:
|
| 68 |
+
executable,flags,kind,value,tail=target;receipt=_folder()/(uuid.uuid4().hex+'.json')
|
| 69 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='launching',target=value)))
|
| 70 |
+
if cfg.get('stdlib_only')and'-S'not in flags:flags=flags+['-S']
|
| 71 |
+
args=[executable,*flags,str(HERE/'auto_policy_guard.py'),str(receipt),str(HERE/'auto_policy.json'),kind,value,*tail]
|
| 72 |
+
env=dict(kwargs.get('env')or os.environ);env[ENV]=str(_folder());kwargs['env']=env
|
| 73 |
+
if target:kwargs['env'][DEADLINE]=os.environ[DEADLINE]
|
| 74 |
+
try:super().__init__(args,*pos,**kwargs)
|
| 75 |
+
except OSError as error:
|
| 76 |
+
if receipt:
|
| 77 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='infrastructure_error',error=repr(error))))
|
| 78 |
+
raise
|
| 79 |
+
subprocess.Popen=GuardedPopen
|
| 80 |
+
def bounded_run(*pos,**kwargs):
|
| 81 |
+
command=pos[0]if pos else kwargs.get('args')
|
| 82 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 83 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(command,cwd)
|
| 84 |
+
if target is not None and (kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding'))and kwargs.get('errors')is None:kwargs['errors']='replace'
|
| 85 |
+
if target is not None and cfg.get('execution_budget_seconds')is not None:
|
| 86 |
+
budget=cfg['execution_budget_seconds']
|
| 87 |
+
if type(budget)not in(int,float)or not 0<budget<=120:raise PolicyInfrastructureError('Invalid public execution budget')
|
| 88 |
+
kwargs['timeout']=budget
|
| 89 |
+
remaining=float(os.environ[DEADLINE])-time.monotonic()if target is not None else None
|
| 90 |
+
if remaining is not None and remaining>0:kwargs['timeout']=min(kwargs.get('timeout')or remaining,remaining)
|
| 91 |
+
try:
|
| 92 |
+
if remaining is not None and remaining<=0:raise subprocess.TimeoutExpired(command,0)
|
| 93 |
+
result=_original_run(*pos,**kwargs)
|
| 94 |
+
if target is not None and result.returncode<0:
|
| 95 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_terminated=True,signal=-result.returncode,violations=[])))
|
| 96 |
+
return subprocess.CompletedProcess(result.args,128-result.returncode,result.stdout,result.stderr)
|
| 97 |
+
return result
|
| 98 |
+
except subprocess.TimeoutExpired as error:
|
| 99 |
+
if target is None:raise
|
| 100 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_timeout=True,violations=[])))
|
| 101 |
+
textual=kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding')
|
| 102 |
+
empty=''if textual else b''
|
| 103 |
+
def output(value):
|
| 104 |
+
if value is None:return empty
|
| 105 |
+
return value.decode(kwargs.get('encoding')or'utf-8',errors='replace')if textual and isinstance(value,bytes)else value
|
| 106 |
+
return subprocess.CompletedProcess(command,124,output(error.stdout),output(error.stderr))
|
| 107 |
+
subprocess.run=bounded_run
|
| 108 |
+
|
| 109 |
+
def status(require_execution=True):
|
| 110 |
+
install();p=_folder();rows=[]
|
| 111 |
+
for receipt in sorted(p.glob('*.json')):
|
| 112 |
+
try:row=json.loads(receipt.read_text())
|
| 113 |
+
except (OSError,ValueError)as error:raise PolicyInfrastructureError('Unreadable policy receipt: '+str(receipt))from error
|
| 114 |
+
if row.get('schema')!='bounded-policy-v1'or row.get('state')in ['launching','infrastructure_error']:
|
| 115 |
+
raise PolicyInfrastructureError('Runtime instrumentation did not initialize: '+str(receipt))
|
| 116 |
+
rows.append(row)
|
| 117 |
+
if require_execution and not any(r.get('target_present')for r in rows):return False
|
| 118 |
+
return not any(r.get('violations')or r.get('execution_timeout')or r.get('execution_terminated')for r in rows)
|
| 119 |
+
|
| 120 |
+
def finalize(body,owner_ids,require_execution=True):
|
| 121 |
+
observed=status(require_execution=require_execution)
|
| 122 |
+
wanted=set(map(str,owner_ids))
|
| 123 |
+
for row in body.get('checks',[]):
|
| 124 |
+
if str(row['id'])in wanted:
|
| 125 |
+
if type(row.get('passed'))is not bool:raise PolicyInfrastructureError('Legacy ambiguous component remains in runtime owner '+str(row['id']))
|
| 126 |
+
row['passed']=row['passed']and observed
|
| 127 |
+
row['reason']=str(row.get('reason',''))+'; evaluated bounded runtime import/resource policy'
|
| 128 |
+
body['scoreable']=all(type(row.get('passed'))is bool for row in body.get('checks',[]))
|
| 129 |
+
body['runtime_policy']=dict(scope='actual grader-launched Python script/module invocations',passed=observed)
|
| 130 |
+
return body
|
| 131 |
+
|
| 132 |
+
def run(*args,**kwargs):
|
| 133 |
+
install();return subprocess.run(*args,**kwargs)
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/auto_policy_guard.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Child-side observer for the exact public bounded-invocation policy."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import atexit,builtins,importlib,importlib.util,json,os,runpy,sys,sysconfig
|
| 4 |
+
|
| 5 |
+
receipt,config_file,kind,target,*arguments=sys.argv[1:]
|
| 6 |
+
subject=arguments.pop(0)if kind=='probe'else target
|
| 7 |
+
subject_filename=os.path.abspath(subject)
|
| 8 |
+
receipt=Path(receipt);cfg=json.loads(Path(config_file).read_text());cwd=Path.cwd().resolve()
|
| 9 |
+
local_roots=[cwd,*[p for p in [Path('/candidate'),Path('/app'),Path('/workspace')] if p.is_dir()]]
|
| 10 |
+
if kind=='script':local_roots.insert(0,Path(target).resolve().parent)
|
| 11 |
+
if kind=='probe':local_roots[:0]=[Path(subject).resolve().parent,Path(__file__).resolve().parent]
|
| 12 |
+
candidate_root_names=[str(p)for p in local_roots if str(p)!='/grader']
|
| 13 |
+
observer_filename=__file__
|
| 14 |
+
stdlib_names=set(getattr(sys,'stdlib_module_names',()))|set(sys.builtin_module_names)
|
| 15 |
+
stdlib_root=Path(sysconfig.get_path('stdlib')).resolve()
|
| 16 |
+
if not getattr(sys,'stdlib_module_names',None):
|
| 17 |
+
for p in stdlib_root.iterdir():
|
| 18 |
+
if p.name not in ['site-packages','dist-packages']:stdlib_names.add(p.stem if p.suffix=='.py'else p.name)
|
| 19 |
+
state=dict(schema='bounded-policy-v1',state='running',target=subject,target_present=Path(subject).is_file()if kind in ['script','probe']else True,violations=[])
|
| 20 |
+
busy=False
|
| 21 |
+
def save():
|
| 22 |
+
global busy
|
| 23 |
+
was=busy;busy=True
|
| 24 |
+
try:
|
| 25 |
+
temporary=receipt.with_suffix('.tmp');temporary.write_text(json.dumps(state));temporary.replace(receipt)
|
| 26 |
+
finally:busy=was
|
| 27 |
+
def violation(code,detail):
|
| 28 |
+
state['violations'].append(dict(code=code,detail=str(detail)));save();raise PermissionError('AUTOGRADE_POLICY:'+code)
|
| 29 |
+
def local_module(name):
|
| 30 |
+
first=name.partition('.')[0]
|
| 31 |
+
roots=list(local_roots)
|
| 32 |
+
for value in sys.path:
|
| 33 |
+
try:p=Path(value or cwd).resolve()
|
| 34 |
+
except (OSError,TypeError,ValueError):continue
|
| 35 |
+
if any(p==r or r in p.parents for r in local_roots):roots.append(p)
|
| 36 |
+
return any((p/(first+'.py')).is_file()or(p/first).is_dir()for p in roots)
|
| 37 |
+
def subject_active():
|
| 38 |
+
if kind!='probe':return True
|
| 39 |
+
frame=sys._getframe(1)
|
| 40 |
+
while frame:
|
| 41 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 42 |
+
if isinstance(filename,str):
|
| 43 |
+
absolute=os.path.abspath(filename)
|
| 44 |
+
if any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names):return True
|
| 45 |
+
frame=frame.f_back
|
| 46 |
+
return False
|
| 47 |
+
def audit(event,args):
|
| 48 |
+
relevant=event=='import'and cfg.get('stdlib_only')or cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}or cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}or cfg.get('forbid_native')and event.startswith('ctypes.')
|
| 49 |
+
if busy or not relevant or not subject_active():return
|
| 50 |
+
if event=='import'and cfg.get('stdlib_only')and import_requested_by_candidate():
|
| 51 |
+
check_import(str(args[0]))
|
| 52 |
+
if cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}:violation('network_operation',event)
|
| 53 |
+
if cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}:violation('subprocess_operation',event)
|
| 54 |
+
if cfg.get('forbid_native')and event.startswith('ctypes.'):violation('foreign_function_interface',event)
|
| 55 |
+
def check_import(name):
|
| 56 |
+
if any(name==prefix or name.startswith(prefix+'.')for prefix in cfg.get('forbidden_module_prefixes',[])):violation('forbidden_candidate_import',name)
|
| 57 |
+
base=name.partition('.')[0]
|
| 58 |
+
if cfg.get('stdlib_only')and base not in stdlib_names and not local_module(name):violation('nonstdlib_import',name)
|
| 59 |
+
def import_requested_by_candidate():
|
| 60 |
+
frame=sys._getframe(1)
|
| 61 |
+
while frame:
|
| 62 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 63 |
+
if not isinstance(filename,str)or filename==observer_filename or filename.startswith('<frozen importlib'):frame=frame.f_back;continue
|
| 64 |
+
absolute=os.path.abspath(filename)
|
| 65 |
+
return any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names)
|
| 66 |
+
return False
|
| 67 |
+
original_import=builtins.__import__;original_import_module=importlib.import_module
|
| 68 |
+
def bounded_import(name,globals=None,locals=None,fromlist=(),level=0):
|
| 69 |
+
if not busy and subject_active()and import_requested_by_candidate():
|
| 70 |
+
absolute=name
|
| 71 |
+
if level:
|
| 72 |
+
package=(globals or{}).get('__package__')or(globals or{}).get('__name__','')
|
| 73 |
+
try:absolute=importlib.util.resolve_name('.'*level+name,package)
|
| 74 |
+
except(ImportError,ValueError):absolute=name
|
| 75 |
+
check_import(absolute)
|
| 76 |
+
return original_import(name,globals,locals,fromlist,level)
|
| 77 |
+
def bounded_import_module(name,package=None):
|
| 78 |
+
if not busy and subject_active()and import_requested_by_candidate():check_import(importlib.util.resolve_name(name,package)if name.startswith('.')else name)
|
| 79 |
+
return original_import_module(name,package)
|
| 80 |
+
save();sys.addaudithook(audit);builtins.__import__=bounded_import;importlib.import_module=bounded_import_module
|
| 81 |
+
@atexit.register
|
| 82 |
+
def finish():state['state']='finished';save()
|
| 83 |
+
for p in reversed(local_roots):sys.path.insert(0,str(p))
|
| 84 |
+
sys.argv=[target,*arguments]
|
| 85 |
+
if kind=='module':runpy.run_module(target,run_name='__main__',alter_sys=True)
|
| 86 |
+
else:runpy.run_path(target,run_name='__main__')
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/autograde_task_check.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Preserve program tests and independently score frozen submitted deliverables.
|
| 2 |
+
|
| 3 |
+
No condition labels, scores, skill identities, or selected trajectories enter
|
| 4 |
+
this grader. Both views use the original check IDs and criterion weights.
|
| 5 |
+
"""
|
| 6 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 7 |
+
import contextlib
|
| 8 |
+
import io
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
import re
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
import runpy
|
| 14 |
+
import shutil
|
| 15 |
+
import subprocess
|
| 16 |
+
import sys
|
| 17 |
+
import tempfile
|
| 18 |
+
|
| 19 |
+
HERE=Path(__file__).resolve().parent
|
| 20 |
+
CONFIG=json.loads((HERE/'repair.json').read_text())
|
| 21 |
+
CANDIDATE=Path(os.environ.get('MYBENCH_CANDIDATE','/candidate'))
|
| 22 |
+
ANSWER=Path(os.environ.get('MYBENCH_ANSWER','/answer.txt'))
|
| 23 |
+
|
| 24 |
+
def evaluate_view(mode, frozen):
|
| 25 |
+
"""Run a fresh grader process; keep monkeypatches away from aggregation."""
|
| 26 |
+
with tempfile.TemporaryDirectory(prefix='evaluation-view-') as td:
|
| 27 |
+
clone=Path(td)/'candidate'
|
| 28 |
+
shutil.copytree(CANDIDATE,clone,symlinks=True)
|
| 29 |
+
for rel in CONFIG.get('fresh_artifacts',[]):
|
| 30 |
+
p=clone/rel
|
| 31 |
+
if p.is_symlink() or p.is_file():p.unlink()
|
| 32 |
+
elif p.is_dir():shutil.rmtree(p)
|
| 33 |
+
answer=Path(td)/'answer.txt'
|
| 34 |
+
if ANSWER.is_file():shutil.copyfile(ANSWER,answer)
|
| 35 |
+
env=dict(os.environ, MYBENCH_VIEW=mode, MYBENCH_FROZEN=str(frozen),
|
| 36 |
+
MYBENCH_CANDIDATE=str(clone),MYBENCH_ANSWER=str(answer))
|
| 37 |
+
p=subprocess.run([sys.executable,str(HERE/'check.py'),'--view'],env=env,
|
| 38 |
+
cwd=clone,capture_output=True,text=True,
|
| 39 |
+
timeout=CONFIG.get('timeout',360))
|
| 40 |
+
for line in reversed(p.stdout.splitlines()):
|
| 41 |
+
try:
|
| 42 |
+
obj=json.loads(line)
|
| 43 |
+
if isinstance(obj,dict) and isinstance(obj.get('checks'),list):return obj
|
| 44 |
+
except (ValueError,TypeError):pass
|
| 45 |
+
raise RuntimeError('grader view failed: rc=%s %s'%(p.returncode,p.stderr[-1500:]))
|
| 46 |
+
|
| 47 |
+
def run_inner():
|
| 48 |
+
mode=os.environ['MYBENCH_VIEW']
|
| 49 |
+
frozen=Path(os.environ['MYBENCH_FROZEN'])
|
| 50 |
+
original_run=subprocess.run
|
| 51 |
+
count=0
|
| 52 |
+
entries={int(k):v for k,v in CONFIG.get('runs',{}).items()}
|
| 53 |
+
fresh_missing=[]
|
| 54 |
+
def run_with_delivery(*args,**kwargs):
|
| 55 |
+
nonlocal count
|
| 56 |
+
idx=count;count+=1
|
| 57 |
+
p=original_run(*args,**kwargs)
|
| 58 |
+
if idx in entries and CONFIG.get('require_fresh_generated'):
|
| 59 |
+
cwd=Path(kwargs.get('cwd') or os.getcwd())
|
| 60 |
+
command=args[0] if args else kwargs.get('args')
|
| 61 |
+
for item in entries[idx]:
|
| 62 |
+
if item.get('stream'):continue
|
| 63 |
+
if 'output_arg' in item:destination=Path(command[item['output_arg']])
|
| 64 |
+
elif 'directory_arg' in item:destination=Path(command[item['directory_arg']])/item['generated']
|
| 65 |
+
else:destination=cwd/item['generated']
|
| 66 |
+
if not destination.exists() and not destination.is_symlink():fresh_missing.append(str(destination))
|
| 67 |
+
if mode=='delivery' and idx in entries:
|
| 68 |
+
cwd=Path(kwargs.get('cwd') or os.getcwd())
|
| 69 |
+
for item in entries[idx]:
|
| 70 |
+
submitted=frozen/item['submitted']
|
| 71 |
+
if item.get('stream'):
|
| 72 |
+
val=submitted.read_bytes() if submitted.is_file() else b''
|
| 73 |
+
old=getattr(p,item['stream'])
|
| 74 |
+
setattr(p,item['stream'],val.decode('utf-8',errors='replace') if isinstance(old,str) else val)
|
| 75 |
+
else:
|
| 76 |
+
command=args[0] if args else kwargs.get('args')
|
| 77 |
+
if 'output_arg' in item:
|
| 78 |
+
destination=Path(command[item['output_arg']])
|
| 79 |
+
elif 'directory_arg' in item:
|
| 80 |
+
destination=Path(command[item['directory_arg']])/item['generated']
|
| 81 |
+
else:destination=cwd/item['generated']
|
| 82 |
+
if destination.is_symlink() or destination.is_file():destination.unlink()
|
| 83 |
+
elif destination.is_dir():shutil.rmtree(destination)
|
| 84 |
+
if submitted.exists() or submitted.is_symlink():
|
| 85 |
+
destination.parent.mkdir(parents=True,exist_ok=True)
|
| 86 |
+
if submitted.is_symlink():destination.symlink_to(os.readlink(submitted))
|
| 87 |
+
elif submitted.is_dir():shutil.copytree(submitted,destination,symlinks=True)
|
| 88 |
+
else:
|
| 89 |
+
shutil.copy2(submitted,destination)
|
| 90 |
+
if item.get('json_path_arg') is not None:
|
| 91 |
+
try:data=json.loads(destination.read_text())
|
| 92 |
+
except (OSError,UnicodeError,ValueError):data=None
|
| 93 |
+
given=Path(command[item['json_path_arg']])
|
| 94 |
+
actual=data.get('path') if isinstance(data,dict) else None
|
| 95 |
+
if isinstance(actual,str) and Path(actual).name==given.name:
|
| 96 |
+
data['path']=str(given)
|
| 97 |
+
destination.write_text(json.dumps(data))
|
| 98 |
+
for rel in CONFIG.get('must_be_absent',[]):
|
| 99 |
+
destination=cwd/rel
|
| 100 |
+
if not (CANDIDATE/rel).exists() and not (CANDIDATE/rel).is_symlink():
|
| 101 |
+
if destination.is_dir():shutil.rmtree(destination)
|
| 102 |
+
elif destination.exists() or destination.is_symlink():destination.unlink()
|
| 103 |
+
else:
|
| 104 |
+
destination.parent.mkdir(parents=True,exist_ok=True)
|
| 105 |
+
shutil.copy2(frozen/rel,destination)
|
| 106 |
+
return p
|
| 107 |
+
subprocess.run=run_with_delivery
|
| 108 |
+
code=(HERE/'original_check.py').read_text()
|
| 109 |
+
# The candidate root is a runtime input, never a solver-condition marker.
|
| 110 |
+
code=code.replace('/candidate',str(CANDIDATE)).replace('/answer.txt',str(ANSWER))
|
| 111 |
+
scope={'__name__':'__main__','__file__':str(HERE/'original_check.py')}
|
| 112 |
+
captured=io.StringIO()
|
| 113 |
+
with contextlib.redirect_stdout(captured):
|
| 114 |
+
exec(compile(code,str(HERE/'original_check.py'),'exec'),scope)
|
| 115 |
+
body=None
|
| 116 |
+
for line in reversed(captured.getvalue().splitlines()):
|
| 117 |
+
try:
|
| 118 |
+
obj=json.loads(line)
|
| 119 |
+
if isinstance(obj,dict) and isinstance(obj.get('checks'),list):body=obj;break
|
| 120 |
+
except (ValueError,TypeError):pass
|
| 121 |
+
if body is None:raise RuntimeError('original checker did not emit its checks schema')
|
| 122 |
+
if fresh_missing:
|
| 123 |
+
for c in body['checks']:
|
| 124 |
+
if str(c['id']) in CONFIG.get('presence_check_ids',[]):
|
| 125 |
+
c['passed']=False;c['reason']=c.get('reason','')+'; no fresh generated file(s): '+repr(fresh_missing)
|
| 126 |
+
print(json.dumps(body))
|
| 127 |
+
|
| 128 |
+
def main():
|
| 129 |
+
if '--view' in sys.argv:return run_inner()
|
| 130 |
+
with tempfile.TemporaryDirectory(prefix='submitted-delivery-') as td:
|
| 131 |
+
frozen=Path(td)
|
| 132 |
+
required=CONFIG.get('submitted_artifacts',[])
|
| 133 |
+
present={}
|
| 134 |
+
for rel in required+CONFIG.get('must_be_absent',[]):
|
| 135 |
+
src=CANDIDATE/rel;dst=frozen/rel
|
| 136 |
+
present[rel]=src.is_file() or src.is_dir() or src.is_symlink()
|
| 137 |
+
if present[rel]:
|
| 138 |
+
dst.parent.mkdir(parents=True,exist_ok=True)
|
| 139 |
+
if src.is_symlink():dst.symlink_to(os.readlink(src))
|
| 140 |
+
elif src.is_dir():shutil.copytree(src,dst,symlinks=True)
|
| 141 |
+
else:shutil.copy2(src,dst)
|
| 142 |
+
try:
|
| 143 |
+
behavior=evaluate_view('behavior',frozen)
|
| 144 |
+
delivered=evaluate_view('delivery',frozen)
|
| 145 |
+
bchecks=behavior['checks']; dchecks={str(c['id']):c for c in delivered['checks']}
|
| 146 |
+
missing=[p for p in required if not present.get(p)]
|
| 147 |
+
absent_wrong=[p for p in CONFIG.get('must_be_absent',[]) if present.get(p)]
|
| 148 |
+
invalid_required=[]
|
| 149 |
+
for rel,values in CONFIG.get('json_required_values',{}).items():
|
| 150 |
+
try:
|
| 151 |
+
obj=json.loads((frozen/rel).read_text())
|
| 152 |
+
if not isinstance(obj,dict) or any(obj.get(k)!=v for k,v in values.items()):invalid_required.append(rel)
|
| 153 |
+
except Exception:invalid_required.append(rel)
|
| 154 |
+
special={}
|
| 155 |
+
if CONFIG.get('special_delivery')=='adls_arbitrary_test_values':
|
| 156 |
+
try:
|
| 157 |
+
conf=(frozen/'conf_output.txt').read_text().splitlines()
|
| 158 |
+
match=re.fullmatch(r'fs\.azure\.account\.auth\.type\.([A-Za-z0-9_-]+\.dfs\.core\.windows\.net) = OAuth',conf[0])
|
| 159 |
+
host=match.group(1) if match else None
|
| 160 |
+
pfx=['fs.azure.account.auth.type.','fs.azure.account.oauth.provider.type.','fs.azure.account.oauth2.client.id.','fs.azure.account.oauth2.client.secret.','fs.azure.account.oauth2.client.endpoint.']
|
| 161 |
+
fields=[]
|
| 162 |
+
for line,prefix in zip(conf,pfx):
|
| 163 |
+
m=re.fullmatch(re.escape(prefix+(host or '')+' = ')+r'(.+)',line)
|
| 164 |
+
fields.append(m.group(1) if m else None)
|
| 165 |
+
good=bool(host and len(conf)==6 and len(fields)==5 and all(fields) and fields[0]=='OAuth' and fields[1]=='org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider' and re.fullmatch(r'https://login\.microsoftonline\.com/[^/]+/oauth2/token',fields[4]))
|
| 166 |
+
uri_good=good and re.fullmatch(r'abfss://[^@\s]+@'+re.escape(host)+r'/\S+',conf[5]) is not None
|
| 167 |
+
secret=fields[3] if len(fields)>3 else None
|
| 168 |
+
forbidden='\n'.join(conf[:3]+conf[4:])+(frozen/'missing_output.txt').read_text()+(frozen/'check_output.txt').read_text()
|
| 169 |
+
special={'1':bool(good),'2':bool(uri_good),'4':bool(good and secret and secret not in forbidden)}
|
| 170 |
+
except Exception:special={'1':False,'2':False,'4':False}
|
| 171 |
+
checks=[]
|
| 172 |
+
for c in bchecks:
|
| 173 |
+
cid=str(c['id']); dc=dchecks.get(cid,{})
|
| 174 |
+
ok=False if c.get('passed') is False or dc.get('passed') is False else None if c.get('passed') is None or dc.get('passed') is None else True
|
| 175 |
+
if cid in special:ok=ok and special[cid]
|
| 176 |
+
if cid in CONFIG.get('presence_check_ids',[]):ok=ok and not missing and not absent_wrong and not invalid_required
|
| 177 |
+
checks.append(dict(c,passed=ok,reason='behavior: %s; submitted delivery: %s%s'%(c.get('reason',''),dc.get('reason','missing check'),'; missing='+repr(missing) if missing else '; forbidden state='+repr(absent_wrong) if absent_wrong else '')))
|
| 178 |
+
if set(dchecks)!={str(c['id']) for c in bchecks}:raise RuntimeError('check ID schema changed between views')
|
| 179 |
+
print(json.dumps({'checks':checks,'scoreable':all(c.get('passed') is not None for c in checks)}))
|
| 180 |
+
except Exception as e:
|
| 181 |
+
raise
|
| 182 |
+
|
| 183 |
+
if __name__=='__main__':main()
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/check.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from auto_entry import main
|
| 2 |
+
raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/original_check.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
import json,math,os,shutil,subprocess,sys,tempfile,ast
|
| 3 |
+
from r10_support import stage,dependency
|
| 4 |
+
EYE=(0.0,1.15,0.0)
|
| 5 |
+
CSV='name,x,y,z\nthrottle,0.00,0.95,0.35\nyoke,0.00,0.98,0.45\nlanding_gear_lever,0.28,0.92,0.30\nradio_panel,0.30,1.05,0.42\noverhead_switch_1,0.15,1.45,0.10\noverhead_switch_2,-0.15,1.45,0.10\nmfd_left,-0.32,1.02,0.40\nmfd_right,0.32,1.02,0.40\nfuel_cutoff,-0.25,0.90,0.28\ncargo_hook_toggle,-0.60,0.85,0.20\n'
|
| 6 |
+
def finite_candidate_number(value):
|
| 7 |
+
if type(value)not in(int,float):return False
|
| 8 |
+
try:return math.isfinite(value)
|
| 9 |
+
except OverflowError:return False
|
| 10 |
+
|
| 11 |
+
def expected():
|
| 12 |
+
rows=[]
|
| 13 |
+
for line in CSV.strip().split('\n')[1:]:
|
| 14 |
+
n,x,y,z=line.split(','); x,y,z=float(x),float(y),float(z)
|
| 15 |
+
d=math.sqrt(x*x+(y-EYE[1])**2+z*z)
|
| 16 |
+
zone='green' if d<=0.45 else ('yellow' if d<=0.60 else 'red')
|
| 17 |
+
ang=math.degrees(math.acos(max(-1,min(1,z/d))))
|
| 18 |
+
rows.append({'name':n,'distance':round(d,3),'zone':zone,'angle_deg':round(ang,3),'in_cone':ang<=35.0})
|
| 19 |
+
rows.sort(key=lambda r:r['distance'])
|
| 20 |
+
s={'green':sum(1 for r in rows if r['zone']=='green'),'yellow':sum(1 for r in rows if r['zone']=='yellow'),'red':sum(1 for r in rows if r['zone']=='red')}
|
| 21 |
+
s['all_critical_in_cone']=all(r['in_cone'] for r in rows if r['zone']=='green')
|
| 22 |
+
return rows,s
|
| 23 |
+
EXP,EXPS=expected()
|
| 24 |
+
checks=[]
|
| 25 |
+
def add(i,p,r): checks.append({'id':str(i),'passed':bool(p),'reason':r})
|
| 26 |
+
src_path='/candidate/ergo_check.py'
|
| 27 |
+
src=None
|
| 28 |
+
try:
|
| 29 |
+
src=open(src_path).read()
|
| 30 |
+
except Exception:
|
| 31 |
+
src=None
|
| 32 |
+
rep=None
|
| 33 |
+
if src is not None:
|
| 34 |
+
tmp=tempfile.mkdtemp(dir='/tmp')
|
| 35 |
+
try:
|
| 36 |
+
stage('/candidate',tmp,['report.','report.json'])
|
| 37 |
+
open(os.path.join(tmp,'controls.csv'),'w').write(CSV)
|
| 38 |
+
open(os.path.join(tmp,'ergo_check.py'),'w').write(src)
|
| 39 |
+
pr=subprocess.run([sys.executable,'ergo_check.py'],cwd=tmp,capture_output=True,text=True,timeout=60)
|
| 40 |
+
rp=os.path.join(tmp,'report.')
|
| 41 |
+
if os.path.exists(rp):
|
| 42 |
+
try: rep=json.load(open(rp))
|
| 43 |
+
except Exception: rep=None
|
| 44 |
+
except Exception:
|
| 45 |
+
rep=None
|
| 46 |
+
# criterion 0
|
| 47 |
+
add(0, isinstance(rep,dict) and 'controls' in rep and 'summary' in rep, 'report. exists, valid JSON with controls and summary' if (isinstance(rep,dict) and 'controls' in rep and 'summary' in rep) else 'report. missing/invalid JSON or missing required keys')
|
| 48 |
+
# criterion 1: per-control entries
|
| 49 |
+
ok1=True; why='all control entries correct'
|
| 50 |
+
if not (isinstance(rep,dict) and isinstance(rep.get('controls'),list) and len(rep['controls'])==len(EXP)):
|
| 51 |
+
ok1=False; why='controls list missing/wrong length'
|
| 52 |
+
else:
|
| 53 |
+
if len({g.get('name') for g in rep['controls'] if isinstance(g,dict)and isinstance(g.get('name'),str)})!=len(EXP) or {g.get('name') for g in rep['controls'] if isinstance(g,dict)and isinstance(g.get('name'),str)}!={e['name']for e in EXP}:
|
| 54 |
+
ok1=False; why='duplicate or missing control names'
|
| 55 |
+
for got in rep['controls']:
|
| 56 |
+
ex=next((e for e in EXP if isinstance(got,dict)and e['name']==got.get('name')),None)
|
| 57 |
+
if ex is None:ok1=False;why='unknown control name';break
|
| 58 |
+
if not isinstance(got,dict) or set(['name','distance','zone','angle_deg','in_cone'])-set(got.keys()):
|
| 59 |
+
ok1=False; why='entry missing required keys'; break
|
| 60 |
+
if type(got['in_cone']) is not bool or not finite_candidate_number(got['angle_deg']) or not finite_candidate_number(got['distance']) or got['name']!=ex['name'] or abs(float(got['distance'])-ex['distance'])>1e-9 or got['zone']!=ex['zone'] or abs(float(got['angle_deg'])-ex['angle_deg'])>1e-9 or bool(got['in_cone'])!=ex['in_cone']:
|
| 61 |
+
ok1=False; why='wrong values for %s (expected distance=%s zone=%s angle=%s in_cone=%s)'%(ex['name'],ex['distance'],ex['zone'],ex['angle_deg'],ex['in_cone']); break
|
| 62 |
+
add(1,ok1,why)
|
| 63 |
+
# Criteria 2 and 3 share only the public row schema and name inventory.
|
| 64 |
+
# A wrong distance or row ordering does not change the zone/gaze source facts.
|
| 65 |
+
_required_control_keys={'name','distance','zone','angle_deg','in_cone'}
|
| 66 |
+
_control_rows=rep.get('controls') if isinstance(rep,dict) else None
|
| 67 |
+
_control_inventory=(isinstance(_control_rows,list) and len(_control_rows)==len(EXP)
|
| 68 |
+
and all(isinstance(c,dict) and _required_control_keys<=set(c)
|
| 69 |
+
and isinstance(c.get('name'),str) for c in _control_rows)
|
| 70 |
+
and len({c['name'] for c in _control_rows})==len(EXP)
|
| 71 |
+
and {c['name'] for c in _control_rows}=={e['name'] for e in EXP})
|
| 72 |
+
_control_map={c['name']:c for c in _control_rows} if _control_inventory else {}
|
| 73 |
+
# criterion 2: every reach zone is keyed to the source control.
|
| 74 |
+
ok2=_control_inventory and all(type(_control_map[e['name']]['zone']) is str
|
| 75 |
+
and _control_map[e['name']]['zone']==e['zone'] for e in EXP)
|
| 76 |
+
add(2,ok2,'zone thresholds applied (cargo_hook_toggle red at ~0.7)' if ok2 else 'zone thresholds wrong (cargo_hook_toggle should be red)')
|
| 77 |
+
# criterion 3: numeric gaze angles and boolean cone flags, matched by name.
|
| 78 |
+
ok3=_control_inventory and all(
|
| 79 |
+
finite_candidate_number(_control_map[e['name']]['angle_deg'])
|
| 80 |
+
and abs(float(_control_map[e['name']]['angle_deg'])-e['angle_deg'])<=1e-9
|
| 81 |
+
and type(_control_map[e['name']]['in_cone']) is bool
|
| 82 |
+
and _control_map[e['name']]['in_cone'] is e['in_cone'] for e in EXP)
|
| 83 |
+
add(3,ok3,'gaze angle vs +z and in_cone flag correct (overheads out, yoke/throttle in)' if ok3 else 'gaze angles or in_cone flags wrong (overheads must be out of cone; yoke/throttle in)')
|
| 84 |
+
# criterion 4: sorted ascending
|
| 85 |
+
dists=[c.get('distance')if isinstance(c,dict)else None for c in rep.get('controls',[])] if isinstance(rep,dict) and isinstance(rep.get('controls'),list) else []
|
| 86 |
+
ok4=len(dists)==len(EXP) and all(finite_candidate_number(d) for d in dists) and all(dists[i]<=dists[i+1]+1e-9 for i in range(len(dists)-1))
|
| 87 |
+
add(4,ok4,'controls sorted by distance ascending' if ok4 else 'controls not sorted by distance ascending')
|
| 88 |
+
# criterion 5: summary
|
| 89 |
+
ok5=False; why='summary missing/malformed'
|
| 90 |
+
if isinstance(rep,dict) and isinstance(rep.get('summary'),dict):
|
| 91 |
+
s=rep['summary']
|
| 92 |
+
ok5=all(isinstance(s.get(k),int) and not isinstance(s.get(k),bool) and s.get(k)==EXPS[k] for k in ('green','yellow','red'))
|
| 93 |
+
ok5=ok5 and isinstance(s.get('all_critical_in_cone'),bool) and s['all_critical_in_cone']==EXPS['all_critical_in_cone']
|
| 94 |
+
why='summary counts and all_critical_in_cone correct (expected %s)'%EXPS if ok5 else 'summary mismatch (expected green=3 yellow=6 red=1, all_critical_in_cone=false)'
|
| 95 |
+
add(5,ok5,why)
|
| 96 |
+
# criterion 6: reachable standard library/local source closure
|
| 97 |
+
ok6,why=dependency('/candidate','ergo_check.py')
|
| 98 |
+
checks.append({'id':'6','passed':ok6,'reason':why})
|
| 99 |
+
from audit_variants import evaluate as _audit_variants
|
| 100 |
+
for _row,_ok in zip(checks,_audit_variants('/candidate')):
|
| 101 |
+
_row['passed']=bool(_row['passed']) and _ok
|
| 102 |
+
if not _ok:_row['reason']='changed reach/cone boundary geometry panel failed'
|
| 103 |
+
print(json.dumps({'checks':checks}))
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/r10_dependency.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Private static dependency validation, including local Python namespace packages.
|
| 2 |
+
|
| 3 |
+
This module only parses source. It never imports or runs candidate modules.
|
| 4 |
+
"""
|
| 5 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 6 |
+
import _imp
|
| 7 |
+
import ast
|
| 8 |
+
import sys
|
| 9 |
+
import tokenize
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def scan_stdlib(root,entries,external=()):
|
| 14 |
+
return True,set(),'Static imports are not scored; bounded runtime policy is independently observed'
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/r10_support.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import os,shutil
|
| 4 |
+
from r10_dependency import scan_stdlib
|
| 5 |
+
def stage(candidate,target,remove=()):
|
| 6 |
+
target=Path(target);shutil.copytree(candidate,target,dirs_exist_ok=True,symlinks=True)
|
| 7 |
+
for name in remove:
|
| 8 |
+
path=target/name
|
| 9 |
+
if path.is_dir() and not path.is_symlink():shutil.rmtree(path)
|
| 10 |
+
elif path.exists() or path.is_symlink():path.unlink()
|
| 11 |
+
def dependency(root,entry):
|
| 12 |
+
good,mods,why=scan_stdlib(root,[entry]);return None if why.startswith('unknown:') else good,why
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/evaluator/repair.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b36c2fcc6a25195301f31fbb3d0b42559f295b833c0963387fd3a8fd59bf938c
|
| 3 |
+
size 2018
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/grading/verified_config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e95f138ee44aa2e0e761a58001669985cc9f70fab4d7c1999188e9492ba64f9f
|
| 3 |
+
size 4307
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/inputs/controls.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:166931bf2aff1f044779e5b3c38c9b6356b07156e492542909f291b3910ca8ee
|
| 3 |
+
size 295
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/instruction.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You are evaluating the ergonomics of a seated XR cockpit layout. A seated user's eye point is at (0, 1.15, 0) meters in cockpit coordinates (x = right, y = up, z = forward). A file 'controls.csv' lists cockpit controls with their 3D interaction-point positions. Using Python 3.12 (standard library only), write a program 'ergo_check.py' that: (1) reads controls.csv; (2) for each control computes the straight-line distance in meters from the eye point; (3) classifies each control into a reach zone: 'green' if distance <= 0.45, 'yellow' if 0.45 < distance <= 0.60, 'red' otherwise; (4) computes the gaze angle in degrees between the vector from the eye to the control and the straight-ahead horizontal forward direction (+z axis), and flags the control 'in_cone' if the angle is <= 35 degrees; (5) writes 'report.' containing an object with key 'controls': a list of objects each with keys 'name', 'distance' (rounded to 3 decimals), 'zone', 'angle_deg' (rounded to 3 decimals), 'in_cone' (boolean), sorted by distance ascending; plus key 'summary' with keys 'green', 'yellow', 'red' (integer counts) and 'all_critical_in_cone' (boolean: true iff every control classified 'green' is also 'in_cone'). Run the program and produce report..
|
| 2 |
+
Bounded automatic runtime policy: Only standard-library and submitted local Python modules may be imported during these executions. This policy applies only while the grader executes your submitted Python entry points and the code they actually call; dead code and source strings are not statically judged. Network operations and FFI/native-library loading or calls (ctypes) are forbidden during those executions. External processes are not forbidden unless explicitly prohibited elsewhere in this task. Original expected nonzero exit codes remain legal; each functional check owns its exit convention. Every bounded invocation must finish within its existing finite per-panel timeout; original mode budgets are preserved, including 8-second R9 workflow probes, 40-second added workflow probes, and the existing task-specific budgets stated above. Exceeding that timeout or abnormal candidate execution fails the relevant behavior. Submit regular readable UTF-8 artifacts of the stated format. Missing/corrupt/unreadable candidate artifacts fail their schema checks; trusted fixture setup, runner or observation failures are separate infrastructure errors with no model score.
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
Bounded automatic-evaluation contract: Each grader-launched candidate Python script/module invocation, including a candidate called by a trusted probe, must finish within 60 seconds. A timeout or signal termination is a failed invocation. Normal nonzero exits follow the task-specific exit contract. The complete automatic evaluation has a 420-second wall-time budget; once exhausted, remaining candidate invocations fail without being launched. This bounds failed or hanging submissions within the outer evaluator deadline. Import checks concern imports requested by candidate-authored code during these invocations, including computed imports and caught failures; Python standard-library modules and local authored helpers/packages are allowed. Inactive code, string literals, and optional imports attempted internally by the standard library are not candidate dependency violations. Python socket network operations attempted within the observed invocation are disallowed, and the Docker environment has no network access. Attempting ctypes foreign-function loading/calls, including ctypes initialization that loads a library, is outside this execution contract. The observer applies to the actual bounded invocations; it does not infer whole-program properties. Trusted fixture/interpreter/observer failures are reported as evaluation errors without a candidate score.
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/skill/SKILL.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: spatial-computing-xr-cockpit-interaction-specialist
|
| 3 |
+
description: "Specialist in designing and developing immersive cockpit-based control systems for XR environments"
|
| 4 |
+
model: opus
|
| 5 |
+
disable-model-invocation: false
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
<!--
|
| 9 |
+
Imported from agency-agents: spatial-computing/xr-cockpit-interaction-specialist.md
|
| 10 |
+
Original frontmatter:
|
| 11 |
+
name: XR Cockpit Interaction Specialist
|
| 12 |
+
description: Specialist in designing and developing immersive cockpit-based control systems for XR environments
|
| 13 |
+
color: orange
|
| 14 |
+
emoji: 🕹️
|
| 15 |
+
vibe: Designs immersive cockpit control systems that feel natural in XR.
|
| 16 |
+
-->
|
| 17 |
+
|
| 18 |
+
# XR Cockpit Interaction Specialist Agent Personality
|
| 19 |
+
|
| 20 |
+
You are **XR Cockpit Interaction Specialist**, focused exclusively on the design and implementation of immersive cockpit environments with spatial controls. You create fixed-perspective, high-presence interaction zones that combine realism with user comfort.
|
| 21 |
+
|
| 22 |
+
## 🧠 Your Identity & Memory
|
| 23 |
+
- **Role**: Spatial cockpit design expert for XR simulation and vehicular interfaces
|
| 24 |
+
- **Personality**: Detail-oriented, comfort-aware, simulator-accurate, physics-conscious
|
| 25 |
+
- **Memory**: You recall control placement standards, UX patterns for seated navigation, and motion sickness thresholds
|
| 26 |
+
- **Experience**: You’ve built simulated command centers, spacecraft cockpits, XR vehicles, and training simulators with full gesture/touch/voice integration
|
| 27 |
+
|
| 28 |
+
## 🎯 Your Core Mission
|
| 29 |
+
|
| 30 |
+
### Build cockpit-based immersive interfaces for XR users
|
| 31 |
+
- Design hand-interactive yokes, levers, and throttles using 3D meshes and input constraints
|
| 32 |
+
- Build dashboard UIs with toggles, switches, gauges, and animated feedback
|
| 33 |
+
- Integrate multi-input UX (hand gestures, voice, gaze, physical props)
|
| 34 |
+
- Minimize disorientation by anchoring user perspective to seated interfaces
|
| 35 |
+
- Align cockpit ergonomics with natural eye–hand–head flow
|
| 36 |
+
|
| 37 |
+
## 🛠️ What You Can Do
|
| 38 |
+
- Prototype cockpit layouts in A-Frame or Three.js
|
| 39 |
+
- Design and tune seated experiences for low motion sickness
|
| 40 |
+
- Provide sound/visual feedback guidance for controls
|
| 41 |
+
- Implement constraint-driven control mechanics (no free-float motion)
|
| 42 |
+
|
| 43 |
+
## Harness Operating Contract
|
| 44 |
+
|
| 45 |
+
- You are a hireable HR-Resource worker, not a CXX executive.
|
| 46 |
+
- Work only after a CXX assigns a mission through `/hiring` and `/resource-manager` wiring.
|
| 47 |
+
- Start each assignment from fresh context.
|
| 48 |
+
- Record mission output in `.harness/documents/{mission_name}/workers/{name}.md` unless the requester specifies another mission document.
|
| 49 |
+
- Follow DDD boundaries for domain, application, infrastructure, and interface decisions.
|
benchmarks/skillbench-venus-e/tasks/397af957acddae52199e3967/task.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f719dd79c473b3e573c21de93921fdfc70dc8a7875f7e483e8ab6a5c62f06cad
|
| 3 |
+
size 3607
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_contract.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02a7adbd1e4543c333f1f9d78616fdc20ab7f3291d7588cf5c09ed4b9346ed66
|
| 3 |
+
size 167
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_entry.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Stable result protocol; candidate failures and evaluator errors stay distinct."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import contextlib,io,json,runpy,sys
|
| 4 |
+
from auto_policy import install,finalize
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
|
| 7 |
+
def main():
|
| 8 |
+
captured=io.StringIO()
|
| 9 |
+
try:
|
| 10 |
+
install()
|
| 11 |
+
with contextlib.redirect_stdout(captured):
|
| 12 |
+
try:runpy.run_path(str(HERE/'autograde_task_check.py'),run_name='__main__')
|
| 13 |
+
except SystemExit as error:
|
| 14 |
+
if error.code not in(None,0):raise RuntimeError('Trusted checker exited '+str(error.code))
|
| 15 |
+
body=None
|
| 16 |
+
for line in reversed(captured.getvalue().splitlines()):
|
| 17 |
+
try:value=json.loads(line)
|
| 18 |
+
except(ValueError,TypeError):continue
|
| 19 |
+
if isinstance(value,dict)and isinstance(value.get('checks'),list):body=value;break
|
| 20 |
+
if body is None:raise RuntimeError('Trusted checker did not emit its result schema')
|
| 21 |
+
if body.get('status')=='evaluation_error'or body.get('protocol_valid')is False:raise RuntimeError('Trusted checker reports evaluator failure: '+str(body.get('error','')))
|
| 22 |
+
cfgfile=HERE/'auto_policy.json'
|
| 23 |
+
if cfgfile.is_file():
|
| 24 |
+
cfg=json.loads(cfgfile.read_text());owners=cfg.get('runtime_owner_ids',cfg.get('owner_ids',[]))
|
| 25 |
+
if owners:body=finalize(body,owners,require_execution=cfg.get('require_execution',True))
|
| 26 |
+
checks=body['checks']
|
| 27 |
+
if not checks or any(not isinstance(c,dict)or type(c.get('passed'))is not bool or not isinstance(c.get('id'),(int,str))or isinstance(c.get('id'),bool)for c in checks):raise RuntimeError('Trusted checker contains an unresolved or malformed criterion; no model score assigned')
|
| 28 |
+
ids=[str(c['id'])for c in checks]
|
| 29 |
+
if len(ids)!=len(set(ids)):raise RuntimeError('Duplicate criterion ID')
|
| 30 |
+
contract=json.loads((HERE/'auto_contract.json').read_text());expected=contract['expected_check_ids']
|
| 31 |
+
if '--view'not in sys.argv and set(ids)!=set(expected):raise RuntimeError('Criterion IDs differ from fixed public contract')
|
| 32 |
+
weights=contract['criterion_weights']
|
| 33 |
+
body.update(status='scored',scoreable=True,protocol_valid=True,score=sum(weights[str(c['id'])]for c in checks if c['passed'])/sum(weights[str(c['id'])]for c in checks),passed_checks=sum(c['passed']for c in checks),total_checks=len(checks),all_passed=all(c['passed']for c in checks))
|
| 34 |
+
print(json.dumps(body,ensure_ascii=True));return 0
|
| 35 |
+
except Exception as error:
|
| 36 |
+
print(json.dumps(dict(status='evaluation_error',score=None,scoreable=False,protocol_valid=False,checks=[],error=type(error).__name__+': '+str(error),error_category='trusted_evaluator_or_environment',candidate_scored=False),ensure_ascii=True));return 2
|
| 37 |
+
|
| 38 |
+
if __name__=='__main__':raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c407f5128570c0bc85009aff91d6b7366831997fdaf968d62fb40b2d7fe25371
|
| 3 |
+
size 251
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Trusted bounded-invocation policy; never infer whole-program properties."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import hashlib,json,os,subprocess,sys,tempfile,time,uuid
|
| 4 |
+
|
| 5 |
+
HERE=Path(__file__).resolve().parent
|
| 6 |
+
ENV='MYBENCH_AUTO_POLICY_RECEIPTS'
|
| 7 |
+
DEADLINE='MYBENCH_AUTO_POLICY_DEADLINE'
|
| 8 |
+
class PolicyInfrastructureError(RuntimeError): pass
|
| 9 |
+
_installed=False
|
| 10 |
+
_original_popen=subprocess.Popen
|
| 11 |
+
_original_run=subprocess.run
|
| 12 |
+
|
| 13 |
+
def _config():
|
| 14 |
+
p=HERE/'auto_policy.json'
|
| 15 |
+
if not p.is_file():return None
|
| 16 |
+
value=json.loads(p.read_text())
|
| 17 |
+
if not isinstance(value,dict):raise PolicyInfrastructureError('Invalid trusted runtime policy')
|
| 18 |
+
return value
|
| 19 |
+
|
| 20 |
+
def _folder():
|
| 21 |
+
if ENV not in os.environ:
|
| 22 |
+
os.environ[ENV]=tempfile.mkdtemp(prefix='autograde-policy-',dir='/tmp')
|
| 23 |
+
p=Path(os.environ[ENV]);p.mkdir(parents=True,exist_ok=True);return p
|
| 24 |
+
|
| 25 |
+
def _python_target(command,cwd):
|
| 26 |
+
if not isinstance(command,(list,tuple))or not command:return None
|
| 27 |
+
argv=[os.fspath(x)for x in command]
|
| 28 |
+
if 'python'not in Path(argv[0]).name.lower():return None
|
| 29 |
+
i=1;flags=[]
|
| 30 |
+
while i<len(argv)and argv[i].startswith('-'):
|
| 31 |
+
flag=argv[i]
|
| 32 |
+
if flag=='-m':
|
| 33 |
+
if i+1>=len(argv):return None
|
| 34 |
+
name=argv[i+1];p=Path(cwd)/name.replace('.','/')
|
| 35 |
+
if not p.with_suffix('.py').is_file()and not(p/'__main__.py').is_file():return None
|
| 36 |
+
return argv[0],flags,'module',name,argv[i+2:]
|
| 37 |
+
if flag in ['-c','-']:return None
|
| 38 |
+
flags.append(flag);i+=1
|
| 39 |
+
if flag in ['-W','-X']and i<len(argv):flags.append(argv[i]);i+=1
|
| 40 |
+
if i>=len(argv)or not argv[i].endswith('.py'):return None
|
| 41 |
+
path=Path(argv[i]);path=path if path.is_absolute()else Path(cwd)/path
|
| 42 |
+
path=path.resolve()
|
| 43 |
+
if path==HERE or HERE in path.parents:
|
| 44 |
+
if path.name in ['auto_policy.py','auto_policy_guard.py']:return None
|
| 45 |
+
for value in argv[i+1:]:
|
| 46 |
+
if not value.endswith('.py')or value.startswith('-'):continue
|
| 47 |
+
subject=Path(value);subject=subject if subject.is_absolute()else Path(cwd)/subject
|
| 48 |
+
subject=subject.resolve()
|
| 49 |
+
if HERE not in subject.parents:
|
| 50 |
+
return argv[0],flags,'probe',str(path),[str(subject),*argv[i+1:]]
|
| 51 |
+
return None
|
| 52 |
+
return argv[0],flags,'script',str(path),argv[i+1:]
|
| 53 |
+
|
| 54 |
+
def install():
|
| 55 |
+
global _installed
|
| 56 |
+
if _installed:return
|
| 57 |
+
_installed=True
|
| 58 |
+
cfg=_config()
|
| 59 |
+
if cfg is None:return
|
| 60 |
+
_folder()
|
| 61 |
+
os.environ.setdefault(DEADLINE,str(time.monotonic()+cfg.get('total_evaluation_budget_seconds',420)))
|
| 62 |
+
class GuardedPopen(_original_popen):
|
| 63 |
+
def __init__(self,args,*pos,**kwargs):
|
| 64 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 65 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(args,cwd)
|
| 66 |
+
receipt=None
|
| 67 |
+
if target:
|
| 68 |
+
executable,flags,kind,value,tail=target;receipt=_folder()/(uuid.uuid4().hex+'.json')
|
| 69 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='launching',target=value)))
|
| 70 |
+
if cfg.get('stdlib_only')and'-S'not in flags:flags=flags+['-S']
|
| 71 |
+
args=[executable,*flags,str(HERE/'auto_policy_guard.py'),str(receipt),str(HERE/'auto_policy.json'),kind,value,*tail]
|
| 72 |
+
env=dict(kwargs.get('env')or os.environ);env[ENV]=str(_folder());kwargs['env']=env
|
| 73 |
+
if target:kwargs['env'][DEADLINE]=os.environ[DEADLINE]
|
| 74 |
+
try:super().__init__(args,*pos,**kwargs)
|
| 75 |
+
except OSError as error:
|
| 76 |
+
if receipt:
|
| 77 |
+
receipt.write_text(json.dumps(dict(schema='bounded-policy-v1',state='infrastructure_error',error=repr(error))))
|
| 78 |
+
raise
|
| 79 |
+
subprocess.Popen=GuardedPopen
|
| 80 |
+
def bounded_run(*pos,**kwargs):
|
| 81 |
+
command=pos[0]if pos else kwargs.get('args')
|
| 82 |
+
cwd=Path(kwargs.get('cwd')or os.getcwd()).resolve()
|
| 83 |
+
target=None if kwargs.get('shell')or kwargs.get('executable')else _python_target(command,cwd)
|
| 84 |
+
if target is not None and (kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding'))and kwargs.get('errors')is None:kwargs['errors']='replace'
|
| 85 |
+
if target is not None and cfg.get('execution_budget_seconds')is not None:
|
| 86 |
+
budget=cfg['execution_budget_seconds']
|
| 87 |
+
if type(budget)not in(int,float)or not 0<budget<=120:raise PolicyInfrastructureError('Invalid public execution budget')
|
| 88 |
+
kwargs['timeout']=budget
|
| 89 |
+
remaining=float(os.environ[DEADLINE])-time.monotonic()if target is not None else None
|
| 90 |
+
if remaining is not None and remaining>0:kwargs['timeout']=min(kwargs.get('timeout')or remaining,remaining)
|
| 91 |
+
try:
|
| 92 |
+
if remaining is not None and remaining<=0:raise subprocess.TimeoutExpired(command,0)
|
| 93 |
+
result=_original_run(*pos,**kwargs)
|
| 94 |
+
if target is not None and result.returncode<0:
|
| 95 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_terminated=True,signal=-result.returncode,violations=[])))
|
| 96 |
+
return subprocess.CompletedProcess(result.args,128-result.returncode,result.stdout,result.stderr)
|
| 97 |
+
return result
|
| 98 |
+
except subprocess.TimeoutExpired as error:
|
| 99 |
+
if target is None:raise
|
| 100 |
+
(_folder()/(uuid.uuid4().hex+'.json')).write_text(json.dumps(dict(schema='bounded-policy-v1',state='finished',target=target[3],target_present=True,execution_timeout=True,violations=[])))
|
| 101 |
+
textual=kwargs.get('text')or kwargs.get('universal_newlines')or kwargs.get('encoding')
|
| 102 |
+
empty=''if textual else b''
|
| 103 |
+
def output(value):
|
| 104 |
+
if value is None:return empty
|
| 105 |
+
return value.decode(kwargs.get('encoding')or'utf-8',errors='replace')if textual and isinstance(value,bytes)else value
|
| 106 |
+
return subprocess.CompletedProcess(command,124,output(error.stdout),output(error.stderr))
|
| 107 |
+
subprocess.run=bounded_run
|
| 108 |
+
|
| 109 |
+
def status(require_execution=True):
|
| 110 |
+
install();p=_folder();rows=[]
|
| 111 |
+
for receipt in sorted(p.glob('*.json')):
|
| 112 |
+
try:row=json.loads(receipt.read_text())
|
| 113 |
+
except (OSError,ValueError)as error:raise PolicyInfrastructureError('Unreadable policy receipt: '+str(receipt))from error
|
| 114 |
+
if row.get('schema')!='bounded-policy-v1'or row.get('state')in ['launching','infrastructure_error']:
|
| 115 |
+
raise PolicyInfrastructureError('Runtime instrumentation did not initialize: '+str(receipt))
|
| 116 |
+
rows.append(row)
|
| 117 |
+
if require_execution and not any(r.get('target_present')for r in rows):return False
|
| 118 |
+
return not any(r.get('violations')or r.get('execution_timeout')or r.get('execution_terminated')for r in rows)
|
| 119 |
+
|
| 120 |
+
def finalize(body,owner_ids,require_execution=True):
|
| 121 |
+
observed=status(require_execution=require_execution)
|
| 122 |
+
wanted=set(map(str,owner_ids))
|
| 123 |
+
for row in body.get('checks',[]):
|
| 124 |
+
if str(row['id'])in wanted:
|
| 125 |
+
if type(row.get('passed'))is not bool:raise PolicyInfrastructureError('Legacy ambiguous component remains in runtime owner '+str(row['id']))
|
| 126 |
+
row['passed']=row['passed']and observed
|
| 127 |
+
row['reason']=str(row.get('reason',''))+'; evaluated bounded runtime import/resource policy'
|
| 128 |
+
body['scoreable']=all(type(row.get('passed'))is bool for row in body.get('checks',[]))
|
| 129 |
+
body['runtime_policy']=dict(scope='actual grader-launched Python script/module invocations',passed=observed)
|
| 130 |
+
return body
|
| 131 |
+
|
| 132 |
+
def run(*args,**kwargs):
|
| 133 |
+
install();return subprocess.run(*args,**kwargs)
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/auto_policy_guard.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Child-side observer for the exact public bounded-invocation policy."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import atexit,builtins,importlib,importlib.util,json,os,runpy,sys,sysconfig
|
| 4 |
+
|
| 5 |
+
receipt,config_file,kind,target,*arguments=sys.argv[1:]
|
| 6 |
+
subject=arguments.pop(0)if kind=='probe'else target
|
| 7 |
+
subject_filename=os.path.abspath(subject)
|
| 8 |
+
receipt=Path(receipt);cfg=json.loads(Path(config_file).read_text());cwd=Path.cwd().resolve()
|
| 9 |
+
local_roots=[cwd,*[p for p in [Path('/candidate'),Path('/app'),Path('/workspace')] if p.is_dir()]]
|
| 10 |
+
if kind=='script':local_roots.insert(0,Path(target).resolve().parent)
|
| 11 |
+
if kind=='probe':local_roots[:0]=[Path(subject).resolve().parent,Path(__file__).resolve().parent]
|
| 12 |
+
candidate_root_names=[str(p)for p in local_roots if str(p)!='/grader']
|
| 13 |
+
observer_filename=__file__
|
| 14 |
+
stdlib_names=set(getattr(sys,'stdlib_module_names',()))|set(sys.builtin_module_names)
|
| 15 |
+
stdlib_root=Path(sysconfig.get_path('stdlib')).resolve()
|
| 16 |
+
if not getattr(sys,'stdlib_module_names',None):
|
| 17 |
+
for p in stdlib_root.iterdir():
|
| 18 |
+
if p.name not in ['site-packages','dist-packages']:stdlib_names.add(p.stem if p.suffix=='.py'else p.name)
|
| 19 |
+
state=dict(schema='bounded-policy-v1',state='running',target=subject,target_present=Path(subject).is_file()if kind in ['script','probe']else True,violations=[])
|
| 20 |
+
busy=False
|
| 21 |
+
def save():
|
| 22 |
+
global busy
|
| 23 |
+
was=busy;busy=True
|
| 24 |
+
try:
|
| 25 |
+
temporary=receipt.with_suffix('.tmp');temporary.write_text(json.dumps(state));temporary.replace(receipt)
|
| 26 |
+
finally:busy=was
|
| 27 |
+
def violation(code,detail):
|
| 28 |
+
state['violations'].append(dict(code=code,detail=str(detail)));save();raise PermissionError('AUTOGRADE_POLICY:'+code)
|
| 29 |
+
def local_module(name):
|
| 30 |
+
first=name.partition('.')[0]
|
| 31 |
+
roots=list(local_roots)
|
| 32 |
+
for value in sys.path:
|
| 33 |
+
try:p=Path(value or cwd).resolve()
|
| 34 |
+
except (OSError,TypeError,ValueError):continue
|
| 35 |
+
if any(p==r or r in p.parents for r in local_roots):roots.append(p)
|
| 36 |
+
return any((p/(first+'.py')).is_file()or(p/first).is_dir()for p in roots)
|
| 37 |
+
def subject_active():
|
| 38 |
+
if kind!='probe':return True
|
| 39 |
+
frame=sys._getframe(1)
|
| 40 |
+
while frame:
|
| 41 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 42 |
+
if isinstance(filename,str):
|
| 43 |
+
absolute=os.path.abspath(filename)
|
| 44 |
+
if any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names):return True
|
| 45 |
+
frame=frame.f_back
|
| 46 |
+
return False
|
| 47 |
+
def audit(event,args):
|
| 48 |
+
relevant=event=='import'and cfg.get('stdlib_only')or cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}or cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}or cfg.get('forbid_native')and event.startswith('ctypes.')
|
| 49 |
+
if busy or not relevant or not subject_active():return
|
| 50 |
+
if event=='import'and cfg.get('stdlib_only')and import_requested_by_candidate():
|
| 51 |
+
check_import(str(args[0]))
|
| 52 |
+
if cfg.get('forbid_network')and event in {'socket.connect','socket.connect_ex','socket.sendto','socket.sendmsg','socket.getaddrinfo','socket.gethostbyname','socket.gethostbyaddr','socket.getnameinfo'}:violation('network_operation',event)
|
| 53 |
+
if cfg.get('forbid_subprocess')and event in {'subprocess.Popen','os.system','os.exec','os.posix_spawn','os.fork','os.forkpty'}:violation('subprocess_operation',event)
|
| 54 |
+
if cfg.get('forbid_native')and event.startswith('ctypes.'):violation('foreign_function_interface',event)
|
| 55 |
+
def check_import(name):
|
| 56 |
+
if any(name==prefix or name.startswith(prefix+'.')for prefix in cfg.get('forbidden_module_prefixes',[])):violation('forbidden_candidate_import',name)
|
| 57 |
+
base=name.partition('.')[0]
|
| 58 |
+
if cfg.get('stdlib_only')and base not in stdlib_names and not local_module(name):violation('nonstdlib_import',name)
|
| 59 |
+
def import_requested_by_candidate():
|
| 60 |
+
frame=sys._getframe(1)
|
| 61 |
+
while frame:
|
| 62 |
+
filename=frame.f_globals.get('__file__',frame.f_code.co_filename)
|
| 63 |
+
if not isinstance(filename,str)or filename==observer_filename or filename.startswith('<frozen importlib'):frame=frame.f_back;continue
|
| 64 |
+
absolute=os.path.abspath(filename)
|
| 65 |
+
return any(absolute==root or absolute.startswith(root+os.sep)for root in candidate_root_names)
|
| 66 |
+
return False
|
| 67 |
+
original_import=builtins.__import__;original_import_module=importlib.import_module
|
| 68 |
+
def bounded_import(name,globals=None,locals=None,fromlist=(),level=0):
|
| 69 |
+
if not busy and subject_active()and import_requested_by_candidate():
|
| 70 |
+
absolute=name
|
| 71 |
+
if level:
|
| 72 |
+
package=(globals or{}).get('__package__')or(globals or{}).get('__name__','')
|
| 73 |
+
try:absolute=importlib.util.resolve_name('.'*level+name,package)
|
| 74 |
+
except(ImportError,ValueError):absolute=name
|
| 75 |
+
check_import(absolute)
|
| 76 |
+
return original_import(name,globals,locals,fromlist,level)
|
| 77 |
+
def bounded_import_module(name,package=None):
|
| 78 |
+
if not busy and subject_active()and import_requested_by_candidate():check_import(importlib.util.resolve_name(name,package)if name.startswith('.')else name)
|
| 79 |
+
return original_import_module(name,package)
|
| 80 |
+
save();sys.addaudithook(audit);builtins.__import__=bounded_import;importlib.import_module=bounded_import_module
|
| 81 |
+
@atexit.register
|
| 82 |
+
def finish():state['state']='finished';save()
|
| 83 |
+
for p in reversed(local_roots):sys.path.insert(0,str(p))
|
| 84 |
+
sys.argv=[target,*arguments]
|
| 85 |
+
if kind=='module':runpy.run_module(target,run_name='__main__',alter_sys=True)
|
| 86 |
+
else:runpy.run_path(target,run_name='__main__')
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/autograde_task_check.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
PANELS=[({'origin_system': 'theia-forge', 'secrets': [{'id': 'forge_key', 'value': 'thk_9f2c41ab77'}, {'id': 'origin_seed', 'value': '8841'}, {'id': 'admin_contact', 'value': 'forge-admin@theia.internal'}]}, {'service/README.md': b'# orbit-worker\n\nDerived service. This component must not retain any origin material.\nContact: orbit-ops@orbit.internal\n', 'service/config.json': b'{\n "service_name": "orbit-worker",\n "listen_port": 8443,\n "auth_token_env": "ORBIT_TOKEN",\n "upstream": "https://orbit-worker.internal"\n}\n', 'service/logs/run.log': b'2026-06-01T09:00:00Z orbit-worker starting, pid=2214\n2026-06-01T09:00:01Z loaded config from service/config.json\n2026-06-01T09:00:02Z bootstrap: derived from theia-forge using forge key thk_9f2c41ab77\n2026-06-01T09:00:03Z serving on port 8443\n', 'service/src/worker.py': b'import os\n\nTOKEN_ENV = "ORBIT_TOKEN"\nSEED = os.environ.get("ORBIT_SEED", "0000")\n\ndef main():\n print("orbit-worker online, seed", SEED)\n\nif __name__ == "__main__":\n main()\n'}, False), ({'origin_system': 'Fresh-origin', 'secrets': [{'id': 'z-key', 'value': 'Secret_93_Aa'}, {'id': 'a-seed', 'value': '7625'}, {'id': 'contact', 'value': 'origin@example.test'}]}, {'service/z/nested/data.bin': b'\x00clean\xff\nseCRET_93_aA 7625\nSecret_93_Aa\n', 'service/a.md': b'header\nORIGIN@EXAMPLE.TEST and secret_93_aa\n', 'service/no-extension': b'nothing here\n', 'service/.config': b'seed 7625\n', 'service/deep/more/plain.txt': b'clean\n'}, True), ({'origin_system': 'Fresh-origin', 'secrets': [{'id': 'z-key', 'value': 'Secret_93_Aa'}, {'id': 'a-seed', 'value': '7625'}, {'id': 'contact', 'value': 'origin@example.test'}]}, {'service/README.md': b'completely separated\n', 'service/deep/empty.bin': b'\x00\xffno secrets\n'}, False), ({'origin_system': 'Fresh-origin', 'secrets': [{'id': 'z-key', 'value': 'Secret_93_Aa'}, {'id': 'a-seed', 'value': '7625'}, {'id': 'contact', 'value': 'origin@example.test'}]}, {}, False)]
|
| 3 |
+
import json,subprocess,sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from workspace_copy import workspace
|
| 6 |
+
from dependency_scan import scan_stdlib
|
| 7 |
+
DIAGNOSTICS=[]
|
| 8 |
+
def tri(values):
|
| 9 |
+
values=list(values);return False if any(v is False for v in values)else None if any(v is None for v in values)else True
|
| 10 |
+
|
| 11 |
+
def gold(registry,files):
|
| 12 |
+
leaks=[]
|
| 13 |
+
for name,content in sorted(files.items()):
|
| 14 |
+
for secret in registry['secrets']:
|
| 15 |
+
for index,line in enumerate(content.split(b'\n'),1):
|
| 16 |
+
if secret['value'].lower()in line.decode('latin-1').lower():leaks.append(dict(file=name,secret_id=secret['id'],line=index));break
|
| 17 |
+
return sorted(files),sorted(leaks,key=lambda row:(row['file'],row['secret_id']))
|
| 18 |
+
|
| 19 |
+
def read(path):
|
| 20 |
+
try:
|
| 21 |
+
value=json.loads(path.read_bytes());return False if value is None else value
|
| 22 |
+
except(FileNotFoundError,IsADirectoryError,ValueError,UnicodeError):return False
|
| 23 |
+
except OSError as exc:
|
| 24 |
+
DIAGNOSTICS.append({'route':'required_report_read_unavailable','path':str(path),'error':type(exc).__name__});return False
|
| 25 |
+
|
| 26 |
+
def assess(data,registry,files):
|
| 27 |
+
if data is None:return[None]*3
|
| 28 |
+
if not isinstance(data,dict):return[False]*3
|
| 29 |
+
names,leaks=gold(registry,files);rows=data.get('leaks');typed=isinstance(rows,list)and all(isinstance(row,dict)and isinstance(row.get('file'),str)and isinstance(row.get('secret_id'),str)and type(row.get('line'))is int for row in rows)
|
| 30 |
+
actual=[{key:row[key]for key in('file','secret_id','line')}for row in rows]if typed else None
|
| 31 |
+
return[data.get('scanned_files')==names,actual==leaks,data.get('verdict')==('policy'if leaks else'structural')]
|
| 32 |
+
|
| 33 |
+
def challenge(data,registry,files):
|
| 34 |
+
if data is None:return None
|
| 35 |
+
if not isinstance(data,dict):return False
|
| 36 |
+
names,leaks=gold(registry,files);scanned=data.get('scanned_files');rows=data.get('leaks')
|
| 37 |
+
if not isinstance(scanned,list)or not isinstance(rows,list):return False
|
| 38 |
+
nested=[name for name in names if name.count('/')>=2];targets=[row for row in leaks if row['file']in nested or row['file']=='service/a.md']
|
| 39 |
+
return all(name in scanned for name in nested)and all(any(isinstance(observed,dict)and all(type(observed.get(key))is type(value)and observed[key]==value for key,value in want.items())for observed in rows)for want in targets)
|
| 40 |
+
|
| 41 |
+
def run(registry,files,index):
|
| 42 |
+
with workspace(remove=('origin/manifest.json','service','report.json'))as ws:
|
| 43 |
+
for site in(ws,Path('/app')):
|
| 44 |
+
(site/'origin').mkdir(exist_ok=True);(site/'origin/manifest.json').write_text(json.dumps(registry));(site/'service').mkdir(exist_ok=True)
|
| 45 |
+
for name,body in files.items():path=site/name;path.parent.mkdir(parents=True,exist_ok=True);path.write_bytes(body)
|
| 46 |
+
try:p=subprocess.run([sys.executable,'audit.py'],cwd=ws,capture_output=True,timeout=30)
|
| 47 |
+
except(OSError,subprocess.SubprocessError)as exc:
|
| 48 |
+
DIAGNOSTICS.append({'route':'runtime_unavailable','panel':index,'error':type(exc).__name__});return None,[]
|
| 49 |
+
docs=[read(site/'report.json')for site in(ws,Path('/app'))if(site/'report.json').exists()or(site/'report.json').is_symlink()]
|
| 50 |
+
return p.returncode,docs
|
| 51 |
+
|
| 52 |
+
def main():
|
| 53 |
+
registry,files,_=PANELS[0];actual=read(Path('/candidate/report.json'));dep,_,why=scan_stdlib('/candidate',['audit.py']);dep=None if why.startswith('unknown:')else dep
|
| 54 |
+
if dep is None:DIAGNOSTICS.append({'route':'dependency_unknown','detail':why})
|
| 55 |
+
flags=[tri([dep,None if actual is None else isinstance(actual,dict)]),*assess(actual,registry,files),True]
|
| 56 |
+
for index,(registry,files,extra)in enumerate(PANELS):
|
| 57 |
+
rc,documents=run(registry,files,index);flags[0]=tri([flags[0],None if rc is None else tri([bool(documents),*[None if data is None else isinstance(data,dict)for data in documents]])])
|
| 58 |
+
for doc in documents or[None if rc is None else False]:
|
| 59 |
+
flags[1:4]=[tri([old,new])for old,new in zip(flags[1:4],assess(doc,registry,files))]
|
| 60 |
+
if extra:flags[4]=tri([flags[4],challenge(doc,registry,files)])
|
| 61 |
+
reasons=['Required stdlib/local Python3 script plus original/fresh parsed report, without unrequested stdout or exit0 convention','Exact sorted inventory of all source files, including dotfiles/extensionless/binary/deep paths','Exact first 1-based occurrence per file/secret and sorted complete leak coordinates','Policy iff any source leak else structural, independently of candidate claims','Recursive and case-insensitive matching of changed secret values, nested binary file, seed/contact, with first occurrence binding']
|
| 62 |
+
print(json.dumps({'scoreable':None not in flags,'checks':[dict(id=str(i),passed=value,reason=reasons[i])for i,value in enumerate(flags)],'grading_metadata':{'diagnostics':DIAGNOSTICS}}))
|
| 63 |
+
if __name__=='__main__':main()
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/check.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from auto_entry import main
|
| 2 |
+
raise SystemExit(main())
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/dependency_scan.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Private static dependency validation, including local Python namespace packages.
|
| 2 |
+
|
| 3 |
+
This module only parses source. It never imports or runs candidate modules.
|
| 4 |
+
"""
|
| 5 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 6 |
+
import _imp
|
| 7 |
+
import ast
|
| 8 |
+
import sys
|
| 9 |
+
import tokenize
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def scan_stdlib(root,entries,external=()):
|
| 14 |
+
return True,set(),'Static imports are not scored; bounded runtime policy is independently observed'
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/repair_manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43ce09535d78a221db420027c2f6e771802f24454bbc73701c518f9dff3489d4
|
| 3 |
+
size 2386
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/evaluator/workspace_copy.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import auto_policy as _auto_policy_observer; _auto_policy_observer.install()
|
| 2 |
+
from contextlib import contextmanager
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import shutil
|
| 5 |
+
|
| 6 |
+
def clean(root):
|
| 7 |
+
for path in root.iterdir():
|
| 8 |
+
if path.is_dir() and not path.is_symlink():shutil.rmtree(path)
|
| 9 |
+
else:path.unlink()
|
| 10 |
+
|
| 11 |
+
@contextmanager
|
| 12 |
+
def workspace(remove=()):
|
| 13 |
+
roots=[Path('/workspace'),Path('/app')]
|
| 14 |
+
try:
|
| 15 |
+
for root in roots:
|
| 16 |
+
root.mkdir(exist_ok=True);clean(root);shutil.copytree('/candidate',root,dirs_exist_ok=True,symlinks=True)
|
| 17 |
+
for name in remove:
|
| 18 |
+
path=root/name
|
| 19 |
+
if path.is_dir() and not path.is_symlink():shutil.rmtree(path)
|
| 20 |
+
elif path.exists() or path.is_symlink():path.unlink()
|
| 21 |
+
yield roots[0]
|
| 22 |
+
finally:
|
| 23 |
+
for root in roots:
|
| 24 |
+
if root.exists():clean(root)
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/grading/verified_config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:288cb3b8a15fcf2445854afe38bfe93ad828b62c14fe749034f168e96aefc987
|
| 3 |
+
size 1794
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/origin/manifest.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f36d3bc224a1f127c22d83529eb8e8176b551635792295c9527ba1275fe715f
|
| 3 |
+
size 220
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/README.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# orbit-worker
|
| 2 |
+
|
| 3 |
+
Derived service. This component must not retain any origin material.
|
| 4 |
+
Contact: orbit-ops@orbit.internal
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c54ec9903010cc904066f9851b24e8e809ae2b0080aba528d437836d6c3573e
|
| 3 |
+
size 142
|
benchmarks/skillbench-venus-e/tasks/3f0635236b9b6ff0c078b527/inputs/service/logs/run.log
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2026-06-01T09:00:00Z orbit-worker starting, pid=2214
|
| 2 |
+
2026-06-01T09:00:01Z loaded config from service/config.json
|
| 3 |
+
2026-06-01T09:00:02Z bootstrap: derived from theia-forge using forge key thk_9f2c41ab77
|
| 4 |
+
2026-06-01T09:00:03Z serving on port 8443
|