2 """Record Slice 16A's complete offline fresh-SBCL regression and source evidence."""
14 ROOT
= pathlib
.Path(__file__
).resolve().parent
.parent
15 BASE
= '8c13acc6e96ced1b14d8ec733f701ac788911720'
16 POLICY
= '(version 1)(allow default)(deny network*)'
17 NAMES
= ['validation', 'semantics', 'merging', 'associations', 'cxtm', 'occurrences',
18 'prefixes', 'integers', 'decimals', 'dates', 'datetimes', 'timezones',
19 'typed-names', 'scopes', 'variants', 'references', 'identifiers']
23 return hashlib
.sha256(path
.read_bytes()).hexdigest()
27 parser
= argparse
.ArgumentParser(description
=__doc__
)
28 parser
.add_argument('--sbcl', default
=os
.environ
.get('SBCL', 'sbcl'))
29 parser
.add_argument('--output', default
=str(ROOT
/ 'reports/slice-16a'))
30 args
= parser
.parse_args()
31 runtime
= shutil
.which(args
.sbcl
)
33 raise RuntimeError('SBCL executable not found: ' + args
.sbcl
)
34 output
= pathlib
.Path(args
.output
).resolve()
35 output
.mkdir(parents
=True, exist_ok
=True)
36 protected
= {str(p
.relative_to(ROOT
)): sha(p
) for directory
in ['vendor/cxtm', 'references']
37 for p
in (ROOT
/ directory
).rglob('*') if p
.is_file()}
38 sources
= {str(p
.relative_to(ROOT
)): sha(p
) for directory
in ['src', 'tests', 'scripts', 'docs']
39 for p
in (ROOT
/ directory
).rglob('*') if p
.is_file() and
40 '__pycache__' not in p
.parts
and p
.suffix
in ['.lisp', '.py', '.sh', '.md']}
41 sources
.update({p
: sha(ROOT
/ p
) for p
in ['topic-maps.asd', 'README.md']})
42 started
= datetime
.datetime
.now(datetime
.timezone
.utc
).isoformat()
43 version
= subprocess
.check_output([runtime
, '--version'], text
=True).strip()
44 with tempfile
.TemporaryDirectory(prefix
='ctm-slice-16a-validation-') as temp
:
45 report
= pathlib
.Path(temp
) / 'validation.json'
46 command
= ['/usr/bin/sandbox-exec', '-p', POLICY
, '/usr/bin/env', 'PYTHONDONTWRITEBYTECODE=1',
47 'SBCL=' + runtime
, 'TOPIC_MAPS_REPORT=' + str(report
), str(ROOT
/ 'scripts/test.sh')]
48 result
= subprocess
.run(command
, cwd
=ROOT
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
49 (output
/ 'tests.log').write_bytes(result
.stdout
)
51 raise RuntimeError('Full regression failed: see ' + str(output
/ 'tests.log'))
52 log
= result
.stdout
.decode('utf-8')
54 source
= report
if name
== 'validation' else pathlib
.Path(str(report
) + '.' + name
+ '.json')
55 (output
/ (name
+ '.json')).write_bytes(source
.read_bytes())
56 old
= ROOT
/ 'reports/slice-15'
57 previous
= json
.loads((old
/ 'validation.json').read_text())
58 now
= json
.loads((output
/ 'validation.json').read_text())
59 assert now
['statuses'] == previous
['statuses'] == {'pass': 93, 'fail': 2, 'unsupported': 0, 'not-run': 178}
60 assert [(c
['id'], c
['status'], c
['actualOutcome']) for c
in now
['cases']] == [
61 (c
['id'], c
['status'], c
['actualOutcome']) for c
in previous
['cases']]
62 for name
in NAMES
[1:-1]:
63 key
= 'lexicalProbes' if name
== 'timezones' else 'cases'
64 assert json
.loads((old
/ (name
+ '.json')).read_text())[key
] == json
.loads(
65 (output
/ (name
+ '.json')).read_text())[key
], name
66 identifiers
= json
.loads((output
/ 'identifiers.json').read_text())
67 actual_dir
= output
/ 'manual-model-actual'
68 actual_dir
.mkdir(exist_ok
=True)
69 for example
in identifiers
['examples']:
70 actual
= example
['actualCXTM'].encode('utf-8')
71 assert actual
== (ROOT
/ 'vendor/cxtm' / example
['baseline']).read_bytes()
72 (actual_dir
/ (pathlib
.Path(example
['source']).name
+ '.cxtm')).write_bytes(actual
)
73 document
= (ROOT
/ 'docs/reading-item-identifiers.md').read_text()
74 example
= document
.split('```lisp\n', 2)[2].split('\n```', 1)[0]
75 inspection
= subprocess
.run(['/usr/bin/sandbox-exec', '-p', POLICY
, runtime
, '--noinform', '--no-sysinit',
76 '--no-userinit', '--script', '/dev/stdin'], input=example
.encode(), cwd
=ROOT
,
77 stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
)
78 (output
/ 'describe.log').write_bytes(inspection
.stdout
)
79 assert inspection
.returncode
== 0, 'Documented inspection forms failed'
80 for path
, value
in protected
.items():
81 assert sha(ROOT
/ path
) == value
, path
82 for path
, value
in sources
.items():
83 assert sha(ROOT
/ path
) == value
, path
84 previous_totals
= json
.loads((old
/ 'execution.json').read_text())['regressionChecks']
85 totals
= {marker
: int(re
.search(r
'(?m)^' + marker
+ r
'-PASS: (\d+)', log
).group(1))
86 for marker
in [*previous_totals
, 'ITEM-IDENTIFIERS']}
87 assert {k
: totals
[k
] for k
in previous_totals
} == previous_totals
88 evidence
= dict(baseCommit
=BASE
, branch
='codex/ctm-slice-16a', runtime
=version
,
89 startedAtUTC
=started
, finishedAtUTC
=datetime
.datetime
.now(datetime
.timezone
.utc
).isoformat(),
90 command
=command
, exitCode
=result
.returncode
, freshSBCL
=True, network
='denied by sandbox-exec',
91 regressionChecks
=totals
, totalLispChecks
=sum(totals
.values()), importedStatuses
=now
['statuses'],
92 importedStatusChanges
=[], previous83CXTMOutputsAndAllModelObservationsUnchanged
=True,
93 manualXTM2ModelBaselineComparisons
=len(identifiers
['examples']), xtmDeserializationImplemented
=False,
94 originalCorpusAndReferencesUnchanged
=True, sourceSHA256
=sources
, documentedInspectionPassed
=True,
95 qualification
='Manual TMDM models are not XTM deserialization contracts; the two known DateTime baseline FAILs remain visible.',
96 artifactsSHA256
={str(p
.relative_to(output
)): sha(p
) for p
in sorted(output
.rglob('*'))
97 if p
.is_file() and p
.name
!= 'execution.json'})
98 (output
/ 'execution.json').write_text(json
.dumps(evidence
, ensure_ascii
=False, indent
=2) + '\n')
99 print(json
.dumps({k
: evidence
[k
] for k
in ['runtime', 'regressionChecks', 'totalLispChecks', 'importedStatuses']}, sort_keys
=True))
100 print('SLICE-16A-VALIDATION-PASS: fresh offline SBCL; retained evidence unchanged; 7 manual model/baseline comparisons')
103 if __name__
== '__main__':