2 """Record one full offline fresh-SBCL run. No relocation or cache management."""
14 ROOT
= pathlib
.Path(__file__
).resolve().parent
.parent
15 BASE
= '6a2f8446afca0915882f0d4a06cb891ccfcdc96d'
16 POLICY
= '(version 1)(allow default)(deny network*)'
17 NAMES
= ['validation', 'semantics', 'merging', 'associations', 'cxtm', 'occurrences',
18 'prefixes', 'integers', 'decimals', 'dates', 'datetimes', 'timezones', 'typed-names']
22 return hashlib
.sha256(path
.read_bytes()).hexdigest()
26 parser
= argparse
.ArgumentParser(description
=__doc__
)
27 parser
.add_argument('--sbcl', default
=os
.environ
.get('SBCL', 'sbcl'))
28 parser
.add_argument('--output', default
=str(ROOT
/ 'reports/slice-12a'))
29 args
= parser
.parse_args()
30 runtime
= shutil
.which(args
.sbcl
)
32 raise RuntimeError('SBCL executable not found: ' + args
.sbcl
)
33 output
= pathlib
.Path(args
.output
).resolve()
34 output
.mkdir(parents
=True, exist_ok
=True)
35 protected
= {str(p
.relative_to(ROOT
)): sha(p
) for directory
in ['vendor/cxtm', 'references']
36 for p
in (ROOT
/ directory
).rglob('*') if p
.is_file()}
37 sources
= {str(p
.relative_to(ROOT
)): sha(p
) for directory
in ['src', 'tests', 'scripts']
38 for p
in (ROOT
/ directory
).rglob('*') if p
.is_file() and
39 '__pycache__' not in p
.parts
and p
.suffix
in ['.lisp', '.py', '.sh']}
40 sources
['topic-maps.asd'] = sha(ROOT
/ 'topic-maps.asd')
41 version
= subprocess
.check_output([runtime
, '--version'], text
=True).strip()
42 started
= datetime
.datetime
.now(datetime
.timezone
.utc
).isoformat()
43 with tempfile
.TemporaryDirectory(prefix
='ctm-slice-12a-validation-') as temp
:
44 report
= pathlib
.Path(temp
) / 'validation.json'
45 command
= ['/usr/bin/sandbox-exec', '-p', POLICY
, '/usr/bin/env', 'PYTHONDONTWRITEBYTECODE=1',
46 'SBCL=' + runtime
, 'TOPIC_MAPS_REPORT=' + str(report
), str(ROOT
/ 'scripts/test.sh')]
47 result
= subprocess
.run(command
, cwd
=ROOT
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
48 (output
/ 'tests.log').write_bytes(result
.stdout
)
50 raise RuntimeError('Full regression failed: see ' + str(output
/ 'tests.log'))
51 log
= result
.stdout
.decode('utf-8')
53 source
= report
if name
== 'validation' else pathlib
.Path(str(report
) + '.' + name
+ '.json')
54 (output
/ (name
+ '.json')).write_bytes(source
.read_bytes())
55 old
= ROOT
/ 'reports/slice-11'
56 for name
in ['semantics', 'merging', 'associations', 'occurrences', 'prefixes', 'integers', 'decimals', 'dates', 'datetimes']:
57 assert json
.loads((old
/ (name
+ '.json')).read_text())['cases'] == json
.loads((output
/ (name
+ '.json')).read_text())['cases'], name
58 previous
= json
.loads((old
/ 'cxtm.json').read_text())
59 current
= json
.loads((output
/ 'cxtm.json').read_text())
60 assert previous
['cases'] == current
['cases'][:56]
61 original
= json
.loads((old
/ 'validation.json').read_text())
62 now
= json
.loads((output
/ 'validation.json').read_text())
63 transitions
= [(a
['id'], a
['status'], b
['status']) for a
, b
in zip(original
['cases'], now
['cases']) if a
['status'] != b
['status']]
64 assert transitions
== [('ctm/in/name-type.ctm', 'not-run', 'pass'), ('ctm/in/name2.ctm', 'not-run', 'pass')], transitions
65 assert now
['statuses'] == {'pass': 64, 'fail': 2, 'unsupported': 0, 'not-run': 207}
66 assert current
['contractCounts'] == {'pass': 56, 'fail': 2}
67 actual_dir
= output
/ 'actual'
68 actual_dir
.mkdir(exist_ok
=True)
69 for case
in current
['cases']:
70 if case
['id'] in ['ctm/in/' + n
+ '.ctm' for n
in ['name', 'name2', 'name-type', 'name-duplicate']]:
71 (actual_dir
/ (pathlib
.Path(case
['id']).name
+ '.cxtm')).write_bytes(case
['actualCXTM'].encode('utf-8'))
72 document
= (ROOT
/ 'docs/reading-typed-topic-names.md').read_text()
73 example
= document
.split('```lisp\n', 1)[1].split('\n```', 1)[0]
74 inspection
= subprocess
.run(['/usr/bin/sandbox-exec', '-p', POLICY
, runtime
, '--noinform', '--no-sysinit',
75 '--no-userinit', '--script', '/dev/stdin'], input=example
.encode(), cwd
=ROOT
,
76 stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
77 (output
/ 'describe.log').write_bytes(inspection
.stdout
)
78 assert inspection
.returncode
== 0
79 for path
, value
in protected
.items():
80 assert sha(ROOT
/ path
) == value
, path
81 for path
, value
in sources
.items():
82 assert sha(ROOT
/ path
) == value
, path
83 markers
= ['FOUNDATION', 'CTM-IDENTITY-SEMANTICS', 'CTM-MERGING-SEMANTICS', 'CTM-ASSOCIATIONS-SEMANTICS',
84 'CXTM', 'OCCURRENCES', 'PREFIX-DATATYPES', 'INTEGERS', 'DECIMALS', 'DATES', 'DATETIMES', 'TIMEZONES', 'TYPED-NAMES']
85 totals
= {marker
: int(re
.search(r
'(?m)^' + marker
+ r
'-PASS: (\d+)', log
).group(1)) for marker
in markers
}
86 evidence
= dict(baseCommit
=BASE
, branch
='codex/ctm-slice-12a', runtime
=version
,
87 startedAtUTC
=started
, finishedAtUTC
=datetime
.datetime
.now(datetime
.timezone
.utc
).isoformat(),
88 command
=command
, exitCode
=result
.returncode
, freshSBCL
=True, network
='denied by sandbox-exec',
89 regressionChecks
=totals
, totalLispChecks
=sum(totals
.values()), importedStatuses
=now
['statuses'],
90 transitions
=transitions
, previous56CXTMOutputsUnchanged
=True, originalCorpusAndReferencesUnchanged
=True,
91 sourceSHA256
=sources
, documentedInspectionPassed
=True,
92 qualification
='Pinned CTM draft-era corpus; regression assertion PASS does not erase the two normative baseline FAILs.',
93 artifactsSHA256
={str(p
.relative_to(output
)): sha(p
) for p
in sorted(output
.rglob('*'))
94 if p
.is_file() and p
.name
!= 'execution.json'})
95 (output
/ 'execution.json').write_text(json
.dumps(evidence
, ensure_ascii
=False, indent
=2) + '\n')
96 print(json
.dumps({k
: evidence
[k
] for k
in ['runtime', 'regressionChecks', 'totalLispChecks', 'importedStatuses', 'transitions']}, sort_keys
=True))
97 print('SLICE-12A-VALIDATION-PASS: fresh offline SBCL; retained outputs unchanged; four original Name comparisons')
100 if __name__
== '__main__':