Files
jason.woltjeandClaude Opus 5.5 c9df996ac1 agents: Rocko row 153 round 1 packet (#1647)
Build packet for row 153, project init cleanup and the nested records repo
refusal. Filbert approved round 1 (comment 28727). Committed by Sage for
Rocko, who has no git authority; secrets scan clean, no binaries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 19:28:02 -05:00

48 lines
2.5 KiB
Python

#!/usr/bin/env python3
import json, os, pathlib, signal, subprocess, sys
ROOT = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else '/mnt/storage/src/mosaic-stack-rocko-153')
OUT = pathlib.Path(__file__).resolve().parent / 'mutants'
T = 'packages/project/tests/init-failure.test.mjs'
P = 'packages/project/src/index.mjs'
cases = [
('01-cleanup-owned-layout', P, 'for (const entry of created.reverse())', 'for (const entry of [])'),
('02-preserve-existing-empty-target', P, 'const parents = [];', 'const parents = [repo];'),
('03-remove-created-empty-target', P, 'for (const path of parents.reverse())', 'for (const path of [])'),
('04-preserve-unrelated-nested-file', P, 'try { rmdirSync(entry.path); }', 'try { rmSync(entry.path, { recursive: true, force: true }); }'),
('05-require-readable-commit', P, 'if (result.ok) {', 'if (false) {'),
('06-refuse-other-project-root', 'packages/project/src/paths.mjs', 'Object.values(business.projects)', '[entry]'),
('07-refuse-human-author-Q2', P, "if (author.definition === 'human')", 'if (false)'),
('08-preserve-replaced-owned-path', P, 'if (stat.ino !== entry.ino || stat.dev !== entry.dev)', 'if (false)'),
]
# Preflight does not start test runners or mutate source.
for ident, path, old, new in cases:
assert (ROOT / path).read_text().count(old) == 1, ident
if '--preflight' in sys.argv:
print('PREFLIGHT_OK', len(cases)); sys.exit(0)
OUT.mkdir(exist_ok=True)
rows = []
for ident, path, old, new in cases:
file = ROOT / path
original = file.read_bytes()
process = None
try:
file.write_text(original.decode().replace(old, new))
with (OUT / (ident + '.log')).open('w') as log:
process = subprocess.Popen(['node', '--test', T], cwd=ROOT,
env={**os.environ, 'DOCKER_HOST': 'unix:///nonexistent.sock'},
stdout=log, stderr=subprocess.STDOUT, start_new_session=True)
try: rc = process.wait(timeout=120)
except subprocess.TimeoutExpired:
os.killpg(process.pid, signal.SIGKILL); process.wait(); rc = 'timeout'
content = (OUT / (ident + '.log')).read_text()
invalid = any(x in content for x in ['SyntaxError:', 'ERR_MODULE_NOT_FOUND'])
verdict = 'INVALID' if invalid else 'TIMEOUT' if rc == 'timeout' else 'SURVIVED' if rc == 0 else 'KILLED'
rows.append(dict(check=ident, path=path, test=T, result=verdict, exit=rc))
(OUT / 'results.json').write_text(json.dumps(rows, indent=2) + '\n')
print(ident, verdict, rc, flush=True)
finally:
if process is not None and process.poll() is None:
os.killpg(process.pid, signal.SIGKILL); process.wait()
file.write_bytes(original)
if verdict != 'KILLED': sys.exit(1)