feat(pbs): support quoted project imports and installed authoring contracts
This commit is contained in:
@@ -21,3 +21,24 @@ Use --select id1,id2 or --origins checkout/installed for focused investigation.
|
||||
The focused-cases.json resource is an additional matrix for contextual overloads, noncommutative receiver/argument order, original global storage, service singleton identity and privacy. It does not replace or alter the frozen corpus. Successful compiler proof does not imply qualification of an installed runtime distribution or a live Studio session. The Studio tests independently preserve MCP/LSP diagnostic contracts.
|
||||
|
||||
The completed DEC-0088/PLN-0166 result, original baseline and separate post-fix reports are consolidated in [LSN-0106](../../discussion/lessons/DSC-0111-pbs-production-reproductions-and-fixes/LSN-0106-pbs-production-binding-and-lowering-corrections.md).
|
||||
|
||||
## Installed authoring contracts
|
||||
|
||||
The existing installed reference corpus includes `production/GUIDE.md` and 21
|
||||
complete positive/negative projects covering eight authoring scenarios. Run
|
||||
`:prometeu-app:installedKnowledgeTest` first; it compiles their actual installed
|
||||
resources outside the checkout and emits artifacts and source/JAR/catalog hashes
|
||||
under `prometeu-compiler/prometeu-build-pipeline/build/registry-conformance/production-contracts`.
|
||||
Then qualify their behavioral assertions and exact bounds faults using the same
|
||||
headless protocol harness as the original corpus:
|
||||
|
||||
```bash
|
||||
python3 tools/pbs-production-corpus/qualify-installed-contracts.py --artifacts prometeu-compiler/prometeu-build-pipeline/build/registry-conformance/production-contracts --distribution prometeu-app/build/install/prometeu-app --runtime-headless /absolute/existing/prometeu-headless --output build/pbs-installed-contracts/new-run
|
||||
```
|
||||
|
||||
The qualifier rejects a distribution whose JAR hashes differ from the compilation
|
||||
record. It preserves separate discovery/compilation/rejection/execution results,
|
||||
checks fault code 3 rather than accepting any trap, and verifies worker termination.
|
||||
Gfx is qualified for installed API compilation; graphical execution and pixel
|
||||
output are not claimed. Existing runtime binaries are executed without writing
|
||||
their repository. The original frozen corpus and its matrix remain unchanged.
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Qualify artifacts compiled from installed PBS references using the existing runtime harness."""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--artifacts', type=Path, required=True)
|
||||
parser.add_argument('--distribution', type=Path, required=True)
|
||||
parser.add_argument('--runtime-headless', type=Path, required=True)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
sys.dont_write_bytecode = True
|
||||
spec = importlib.util.spec_from_file_location('pbs_corpus', Path(__file__).with_name('run.py'))
|
||||
harness = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(harness)
|
||||
artifacts = args.artifacts.resolve(strict=True)
|
||||
distribution = args.distribution.resolve(strict=True)
|
||||
binary = args.runtime_headless.resolve(strict=True)
|
||||
output = args.output.resolve()
|
||||
if output.exists():
|
||||
parser.error('Output must be a new directory; evidence is never overwritten')
|
||||
output.mkdir(parents=True)
|
||||
compilation = json.loads((artifacts / 'compilation.json').read_text())
|
||||
assert compilation['passed']
|
||||
jars = {p.name: harness.sha(p) for p in (distribution / 'lib').glob('*.jar')}
|
||||
assert jars == compilation['provenance']['installedJarSha256'], 'Compiled artifacts must match this distribution'
|
||||
scratch = Path(tempfile.mkdtemp(prefix='pbs-installed-contracts-'))
|
||||
observations = []
|
||||
for case in compilation['cases']:
|
||||
expected = case['expectation']['expectedRuntime']
|
||||
if expected == 'not-run':
|
||||
continue
|
||||
assert case['compileStatus'] == 'compiled' and case['matchesExpectation'] and case['sourceUnchanged']
|
||||
cartridge = artifacts / case['id']
|
||||
assert harness.sha(cartridge / 'program.pbx') == case['bytecodeSha256']
|
||||
assert harness.sha(cartridge / 'manifest.json') == case['manifestSha256']
|
||||
saved = output / 'artifacts' / case['id']
|
||||
shutil.copytree(cartridge, saved)
|
||||
result = harness.execute(binary, str(saved), scratch / case['id'])
|
||||
fault = result.get('fault')
|
||||
if isinstance(fault, dict) and 'fault' in fault:
|
||||
fault = fault['fault']
|
||||
code = (fault or {}).get('trap', {}).get('code')
|
||||
matched = result['observedRuntime'] == expected and result['workerTerminated']
|
||||
if expected == 'fault':
|
||||
matched &= code == case['expectation']['faultCode']
|
||||
result.update(id=case['id'], expectedRuntime=expected, expectedFaultCode=case['expectation'].get('faultCode'),
|
||||
observedFaultCode=code, matchesExpectation=matched)
|
||||
harness.write(output / 'execution' / (case['id'] + '.json'), result)
|
||||
observations.append({k: result[k] for k in ['id', 'expectedRuntime', 'observedRuntime', 'observedFaultCode', 'matchesExpectation', 'workerTerminated']})
|
||||
print(case['id'], result['observedRuntime'], code, matched, flush=True)
|
||||
shutil.copy2(artifacts / 'compilation.json', output / 'compilation.json')
|
||||
provenance = {'installed': compilation['provenance'], 'distribution': str(distribution),
|
||||
'runtime': str(binary), 'runtimeSha256': harness.sha(binary), 'runnerSha256': harness.sha(__file__),
|
||||
'harnessSha256': harness.sha(Path(__file__).with_name('run.py')), 'scratch': str(scratch),
|
||||
'runtimeWrites': False, 'gfxExecution': 'not-run; installed API compilation only'}
|
||||
harness.write(output / 'provenance.json', provenance)
|
||||
summary = {'compileClassifications': len(compilation['cases']), 'executions': observations,
|
||||
'passed': bool(observations) and all(x['matchesExpectation'] for x in observations)}
|
||||
harness.write(output / 'summary.json', summary)
|
||||
harness.write(output / 'checksums.json', {str(p.relative_to(output)): harness.sha(p) for p in output.rglob('*') if p.is_file()})
|
||||
print(json.dumps({'compileClassifications': summary['compileClassifications'], 'executionCount': len(observations), 'passed': summary['passed']}))
|
||||
return 0 if summary['passed'] else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user