stable_bundle.py (2502B)
1 #!/usr/bin/env python3 2 """Independent bundle wire helpers; historical benchmark CLI is retired.""" 3 import argparse 4 from pathlib import Path 5 import struct 6 7 def assembled(manifest, nodes): 8 def section(identifier, offset, size): 9 return struct.pack('>IHHIQQI', identifier, 1, 1, 0, offset, size, 0) 10 return (b'ARBORICX' + struct.pack('>HHIQQ', 1, 0, 2, 0, 32) 11 + section(1, 96, len(manifest)) + section(2, 96 + len(manifest), len(nodes)) 12 + manifest + nodes) 13 14 15 def byte_tree(payload): 16 # Independent canonical tree-term encoding: byte = LSB-first bit list; 17 # byte string = Fork cells ending in Leaf. No compiler/evaluator involved. 18 numbers = [] 19 for value in range(256): 20 encoded = bytearray() 21 while value: 22 encoded.extend(b'\x02\x01\x00' if value & 1 else b'\x02\x00') 23 value >>= 1 24 numbers.append(bytes(encoded) + b'\x00') 25 return b''.join(b'\x02' + numbers[value] for value in payload) + b'\x00' 26 27 28 def sections(path): 29 data = path.read_bytes() 30 assert data[:8] == b'ARBORICX' 31 assert struct.unpack('>HHIQQ', data[8:32]) == (1, 0, 2, 0, 32), path 32 parts = {} 33 for at in (32, 64): 34 identifier, major, minor, flags, offset, size, reserved = struct.unpack('>IHHIQQI', data[at:at+32]) 35 assert (major, minor, flags, reserved) == (1, 1, 0, 0) 36 parts[identifier] = data[offset:offset+size] 37 assert len(parts[identifier]) == size 38 assert assembled(parts[1], parts[2]) == data, path 39 return parts[1], parts[2] 40 41 42 def main(): 43 parser = argparse.ArgumentParser(description=__doc__) 44 parser.add_argument('tricu', type=Path) 45 parser.add_argument('--compiler-bundle', required=True, type=Path) 46 parser.add_argument('--directory', type=Path) 47 parser.add_argument('--input-bundle', type=Path, action='append', default=[]) 48 parser.add_argument('--lengths', default='4096,16384') 49 parser.add_argument('--repeat', type=int, default=9) 50 parser.add_argument('--cold-repeat', type=int, default=5, 51 help='Independent processes directly invoking the functions, without the IO adapter') 52 parser.add_argument('--reverse-order', action='store_true') 53 args = parser.parse_args() 54 parser.error("Retired implicit recovery preparation: this historical workflow has no verified native-support input route. Use current portable candidate tooling; do not reuse its old support/cache artifacts.") 55 56 57 if __name__ == '__main__': 58 main()