1 import os
, json
, subprocess
, datetime
, hashlib
2 from pathlib
import Path
3 p
=Path(Path('/private/tmp/xtm-slice-21o-latest').read_text());root
=Path('/Users/rgb/workspace/topic-maps');s
=p
/'api-preflight.lisp';(p
/'development-preflight-original.lisp').write_bytes(s
.read_bytes());(p
/'development-preflight-original.log').write_bytes((p
/'variant-reifier-api-preflight.log').read_bytes())
4 s
.write_text(s
.read_text().replace('(assert (eq a (add-variant n "V" :scope (list s))))','(let ((same (add-variant n "V" :scope (list s))))\n (assert (eq same (canonical-variant a))) (assert (eq r (item-reifier same)))\n (assert (eq same (topic-reified r))))'))
5 env
=json
.loads((p
/'environment.json').read_text());cmd
=['/usr/bin/sandbox-exec','-p','(version 1)(allow default)(deny network*)(deny file-write* (subpath "'+str(root
)+'"))',env
['SBCL'],'--noinform','--no-sysinit','--no-userinit','--script',str(s
)];r
=subprocess
.run(cmd
,cwd
=root
,env
=env
,stdout
=subprocess
.PIPE
,stderr
=subprocess
.STDOUT
);(p
/'variant-reifier-api-preflight.log').write_bytes(r
.stdout
);print(r
.stdout
.decode()[:5000]);assert r
.returncode
==0
6 v
=json
.loads((p
/'baseline-execution.json').read_text());v
['runs'][-1].update(exitCode
=0,command
=cmd
,finishedAtUTC
=datetime
.datetime
.now(datetime
.timezone
.utc
).isoformat());v
.update(acceptancePassed
=True,baselineXTM
={'pass':68,'fail':0,'not-run':56},baselineCTM
={'pass':262,'fail':4,'not-run':7},preflightDevelopmentCorrection
='Initial assertion incorrectly required raw old Variant EQ after normalization. Corrected to canonical-variant EQ; failed script/log retained.',readerAndAllTrackedFilesUnchanged
=True)
7 assert all(hashlib
.sha256((root
/x
).read_bytes()).hexdigest()==h
for x
,h
in json
.loads((p
/'initial-hashes.json').read_text()).items());(p
/'baseline-execution.json').write_text(json
.dumps(v
,indent
=2)+'\n');print('BASELINE AND PREFLIGHT ACCEPTED')