aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / om / ribbon / mutants.py
| 1 | #!/usr/bin/env python3 |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | """Wrong-word controls of the real controller. Test tooling only.""" |
| 4 | import importlib.util |
| 5 | from pathlib import Path |
| 6 | import subprocess |
| 7 | import sys |
| 8 | |
| 9 | root = Path(__file__).resolve().parent |
| 10 | spec = importlib.util.spec_from_file_location('ribboncheck', root / 'check.py') |
| 11 | check = importlib.util.module_from_spec(spec) |
| 12 | sys.modules[spec.name] = check |
| 13 | spec.loader.exec_module(check) |
| 14 | source = (root / 'pipeline.om').read_text() |
| 15 | driver = (root / 'test_driver.om').read_text() |
| 16 | compiler, out = sys.argv[1], Path(sys.argv[2]) |
| 17 | mutants = { |
| 18 | 'stale-ticket': ('ret and ne get st b 0 eq get st add b 2 div ticket 64', 'ret ne get st b 0'), |
| 19 | 'premature-publish': ('if ne get q 4 1', 'if eq get q 4 1'), |
| 20 | 'over-budget': ('if ge get st 6 get st 4', 'if gt get st 6 get st 4'), |
| 21 | 'evict-pinned': ('if or ne get st add b 5 0 ne get st add b 6 0', 'if ne get st add b 6 0'), |
| 22 | 'release-active': ('if eq p 3\nreleasebuf st b', 'if ne p 0\nreleasebuf st b'), |
| 23 | 'reset-generation': ('put st 2 gen', 'put st 2 0'), |
| 24 | } |
| 25 | for name, (old, new) in mutants.items(): |
| 26 | assert old in source, name |
| 27 | changed = source.replace(old, new, 1) |
| 28 | path = out / name |
| 29 | with path.open('wb') as f: |
| 30 | built = subprocess.run([compiler], input=(changed+driver).encode(), stdout=f, stderr=subprocess.PIPE) |
| 31 | assert built.returncode == 0, (name, built.stderr.decode()) |
| 32 | path.chmod(0o700) |
| 33 | try: |
| 34 | check.check(path) |
| 35 | except (AssertionError, subprocess.TimeoutExpired): |
| 36 | print('PASS caught mutant', name) |
| 37 | else: |
| 38 | raise AssertionError('surviving mutant: ' + name) |