Verdict comment 26765, queue rev 140. R1: message.send and role.revoke verbs use gated decisions without consuming them. R2: a cross-role decision authorizes without limit once policy makes the action gated. Two rulings for Sage on cross-role reuse and class drift. Co-Authored-By: Claude Opus 5.5 <[email protected]>
32 lines
2.3 KiB
Python
32 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
# S2b round 1: Rocko's two mutants plus Darkwing's, repository layout, each compared to a clean baseline.
|
|
import pathlib,tempfile,shutil,subprocess,json,re,sys
|
|
cases=[
|
|
('rocko-drop-check','broker.mjs',"fail('decision-consumed');",";"),
|
|
('rocko-current-class','broker.mjs',"this.#decision(s, result.decision).class === 'gated'","result.class === 'gated'"),
|
|
('dw-is-not-to-ne','broker.mjs',"IS NOT 'decision.raise' LIMIT 1","!= 'decision.raise' LIMIT 1"),
|
|
('dw-count-raise-event','broker.mjs',"AND json_extract(body,'$.operation') IS NOT 'decision.raise' LIMIT 1","LIMIT 1"),
|
|
('dw-every-class','broker.mjs',"result.decision && this.#decision(s, result.decision).class === 'gated' &&","result.decision &&"),
|
|
('dw-event-drops-decision','broker.mjs',"{ action, ...result, target: context.target ?? null }","{ action, class: result.class, target: context.target ?? null }"),
|
|
('dw-either-class','broker.mjs',"this.#decision(s, result.decision).class === 'gated'","(result.class === 'gated' || this.#decision(s, result.decision).class === 'gated')"),
|
|
]
|
|
source=pathlib.Path(sys.argv[1])
|
|
def run(dest):
|
|
r=subprocess.run(['node','--test',*[str(p) for p in sorted((dest/'tests').glob('*.test.mjs'))]],capture_output=True,text=True,timeout=300)
|
|
tests=set(l[2:].rsplit(' (',1)[0] for l in r.stdout.splitlines() if l.startswith('✖ ') and not l.startswith('✖ failing tests'))
|
|
return r.returncode,tests
|
|
with tempfile.TemporaryDirectory(prefix='dw-s2b-mut-') as root:
|
|
dest=pathlib.Path(root)/'packages'/'bus';shutil.copytree(source,dest,ignore=shutil.ignore_patterns('dw'))
|
|
code,base=run(dest);print(json.dumps({'baseline_exit':code,'baseline_failures':sorted(base)}),flush=True)
|
|
code,f=run(dest);print(json.dumps({'mutation':'no-op','exit':code,'killed':bool(f-base)}),flush=True)
|
|
out=[]
|
|
for name,file,old,new in cases:
|
|
p=dest/'src'/file;b=p.read_text();pat=r'\s*'.join(re.escape(c) for c in old if not c.isspace());n=len(re.findall(pat,b))
|
|
if n!=1: print(json.dumps({'mutation':name,'error':f'{n} matches'}),flush=True);continue
|
|
p.write_text(re.sub(pat,lambda m:new,b,count=1))
|
|
try: code,f=run(dest)
|
|
finally: p.write_text(b)
|
|
x=sorted(f-base);out.append({'mutation':name,'exit':code,'killed':bool(x),'new_failures':x})
|
|
print(json.dumps(out[-1]),flush=True)
|
|
print('killed',sum(x['killed'] for x in out),'of',len(out))
|