Unclaimed files left in the canonical checkout. Inventory: canonical-cleanup-inventory.md (commit-as-evidence groups). detect-secrets scan clean on 2026-11-02: hits are sha256 pins, git object ids, test sentinels already in tracked tests and unit-file lines.
45 lines
3.7 KiB
Python
45 lines
3.7 KiB
Python
import pathlib,subprocess,sys,json,os,signal
|
|
root=pathlib.Path.cwd();out=pathlib.Path(sys.argv[1]);out.mkdir(parents=True,exist_ok=True)
|
|
assert root != pathlib.Path('/mnt/storage/src/mosaic-stack')
|
|
assert os.environ.get('DOCKER_HOST')=='unix:///nonexistent.sock'
|
|
stack='scripts/stack-copy.sh';bus='scripts/bus-service.sh';web='scripts/webui-service.sh'
|
|
suite=['packages/cli/tests/stack-copy.test.mjs'];wsuite=['packages/webui/tests/service.test.mjs'];psuite=['packages/webui/tests/pinned-copy.test.mjs']
|
|
muts=[
|
|
('ignore-pushed-ref',stack,'for ref in refs/heads/refactor refs/remotes/origin/refactor; do','for ref in refs/heads/refactor; do',suite),
|
|
('skip-npm',stack,'(cd "$tmp" && npm ci --no-audit --no-fund) >&2 || die',': || die',suite),
|
|
('skip-manifest-guard',stack,'[ -f "$tmp/package.json" ] && [ -f "$tmp/package-lock.json" ] || die',': || die',suite),
|
|
('missing-bus-schema',stack,'packages/bus/src packages/bus/schema.sql','packages/bus/src',suite),
|
|
('missing-adapters',stack,' adapters roles RELEASE',' roles RELEASE',suite),
|
|
('missing-queue',stack,' packages/queue/src\n','\n',suite),
|
|
('writable-copy-dirs',stack,'find "$tmp" -type d -exec chmod 0555 {} +','find "$tmp" -type d -exec chmod 0755 {} +',suite),
|
|
('writable-copy-files',stack,'find "$tmp" -type f -exec chmod a-w {} +',':',psuite),
|
|
('replace-existing',stack,'if [ -e "$target" ]; then echo "exists: $target"; return; fi',':',suite),
|
|
('accept-foreign-wrapper',stack,'[ "$(sed -n \'2p\' "$file")" = "$MARKER" ] || die',': || die',suite),
|
|
('accept-wrapper-symlink',stack,'[ -f "$file" ] && [ ! -L "$file" ] || die','[ -f "$file" ] || die',suite),
|
|
('lose-lease',stack,'"$MARKER" "$lease" "$root" > "$tmp"','"$MARKER" "# lease removed" "$root" > "$tmp"',suite),
|
|
('wrong-wrapper-tree',stack,'"$MARKER" "$lease" "$root" > "$tmp"','"$MARKER" "$lease" "/other" > "$tmp"',suite),
|
|
('ignore-effective-exec',stack,'[[ "$exec_start" == *"path=$root/scripts/mosaic ;"* ]]','[[ 1 == 1 ]]',suite),
|
|
('ignore-pm',bus,'[ "$PM" = 0 ] || pm_flags=" --pm"',':',suite),
|
|
('skip-install-guard',bus,' install_guard\n','',suite),
|
|
('ignore-dropin',bus,"if grep -Eq '^[[:space:]]*(ExecStart|WorkingDirectory)[[:space:]]*=' <<< \"$content\"; then",'if false; then',suite),
|
|
('ignore-empty-metadata',bus,'[ -n "$paths" ] || die',': || die',suite),
|
|
('template-show-regression',bus,' local paths directory dropdir content',' systemctl --user show [email protected] -p DropInPaths >/dev/null || die "template show failed"\n local paths directory dropdir content',suite),
|
|
('miss-unlisted-instance',bus,'"$directory"/mosaic-bus@*.service.d','"$directory"/[email protected]',suite),
|
|
('runtime-wrong-proof-entry','packages/bus/src/runtime.mjs',"new URL('./human-cli.mjs', import.meta.url)","new URL('./wrong-human-cli.mjs', import.meta.url)",suite),
|
|
('status-hides-pm',bus,'echo \'pm: on\'','echo \'pm: off\'',suite),
|
|
('console-skips-working-dir',web,'[ "$working" = "$copy" ] || die',': || die',wsuite),
|
|
]
|
|
results=[]
|
|
for name,file,old,new,tests in muts:
|
|
p=root/file;original=p.read_text();assert original.count(old)==1,(name,original.count(old))
|
|
try:
|
|
p.write_text(original.replace(old,new,1))
|
|
with (out/(name+'.txt')).open('w') as log:
|
|
child=subprocess.Popen(['node','--test',*tests],stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
|
try:code=child.wait(timeout=60);status='killed' if code else 'survived'
|
|
except subprocess.TimeoutExpired:os.killpg(child.pid,signal.SIGKILL);child.wait();code=124;status='timeout'
|
|
row={'name':name,'exit':code,'status':status};results.append(row);print(json.dumps(row),flush=True)
|
|
(out/'summary.json').write_text(json.dumps(results,indent=2)+'\n')
|
|
finally:p.write_text(original)
|
|
sys.exit(any(r['status']!='killed' for r in results))
|