"""Offline record verification. Diagnostics contain chain, row, codes and hashes only."""
import argparse,base64,hashlib,io,ipaddress,json,lzma,re,sys,zipfile,zlib
from pathlib import Path
try:
 from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
 from cryptography.exceptions import InvalidSignature
except ImportError as missing:
 # Only an absent or incomplete cryptography install is reported here; any other import error is raised as before.
 if (missing.name or '').split('.')[0]!='cryptography':raise
 print('public_dependency_unavailable: install requirements.txt (see README)',flush=True);sys.exit(3)
FINAL_HASH = 'f232889edbf2c7672d526a46c696e5beb1102c52d43855cf86229a6ea43f5d30'
META = {'code/1': {'recorded_at': {'sha256': '4c8eae9315f8701afb17e7f62fc9ec67dbf22cb9b7d99dd6d1606beac4501c5f'}, 'status': 'published'}, 'code/2': {'recorded_at': {'sha256': '874522511984eb8770de5e89c36163abb991659dc7e8ba4842818661b9573b0d'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'code/3': {'recorded_at': {'sha256': '5e749b04b874f7bad445b2ffb13d1ceeb99d9df81ca644c97afdfca3109dd5dd'}, 'status': 'withheld', 'withheld_reason': 'host_path'}, 'code/4': {'recorded_at': {'sha256': 'dfeb80aafaa3056f8b5d019592e6d13983a708547978aee4e5d7d60a218d5746'}, 'status': 'withheld', 'withheld_reason': 'tool_substrate_snapshot'}, 'code/5': {'recorded_at': {'sha256': 'dfeb80aafaa3056f8b5d019592e6d13983a708547978aee4e5d7d60a218d5746'}, 'status': 'withheld', 'withheld_reason': 'tool_substrate_snapshot'}, 'code/6': {'recorded_at': {'sha256': 'dfeb80aafaa3056f8b5d019592e6d13983a708547978aee4e5d7d60a218d5746'}, 'status': 'withheld', 'withheld_reason': 'host_path'}, 'code/7': {'recorded_at': {'sha256': '74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b'}, 'status': 'withheld', 'withheld_reason': 'internal_receipt_metadata'}, 'commissioning/1': {'recorded_at': {'sha256': 'e5a0269bb870af74178f0ce4f717a1e9a19cc89724c2f2b08712e96f93428ccc'}, 'status': 'published'}, 'commissioning/10': {'recorded_at': {'sha256': '892d4c961cb321ccd39c89ec68240202001b3cc002e79bc8337464bb4263d23e'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'commissioning/11': {'recorded_at': {'sha256': 'e418f67eefe1512912763a35818e2d80a5c22ab948f83bb2855eba9170f0e074'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'commissioning/12': {'recorded_at': {'sha256': '5f389ffbbd9c7e08d5f518e4d80386326fa16f9f621a672f14d4fd76e935ba76'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'commissioning/13': {'recorded_at': {'sha256': 'be730746b6e75ee92184a9d43321fa1a0873880a1a2d9445dc68484a58e57b2e'}, 'status': 'published'}, 'commissioning/14': {'recorded_at': {'sha256': '7f41d32f5b41cf2334be6a51f667a2c66350b5ab456bb46d17a7c0ebad5e0553'}, 'status': 'withheld', 'withheld_reason': 'internal_receipt_metadata'}, 'commissioning/15': {'recorded_at': {'sha256': '3f883242ac821d875ab7924f4647d1bab940300155ee2f37f618b2908509fe9b'}, 'status': 'published'}, 'commissioning/16': {'recorded_at': {'sha256': 'a607374daca5aa51ba206336980ebb5c512edbfeeae9c5ebb656504ee61268ea'}, 'status': 'published'}, 'commissioning/17': {'recorded_at': {'sha256': '259b25493df9ca8e1be316e8725a9c231a5d3b0a1f7e21fa5d31df6abda1bd6a'}, 'status': 'published'}, 'commissioning/18': {'recorded_at': {'sha256': '008c4ec4924948d47bacb4c97111a5961edb041940a93d9871c4f707c68f8556'}, 'status': 'published'}, 'commissioning/19': {'recorded_at': {'sha256': 'bcdadc074bda6788ba3fddf8550c6c97ba8bdc7992c5b7d6de1387a2686d3610'}, 'status': 'published'}, 'commissioning/2': {'recorded_at': {'sha256': 'e4201ed670d3a580b61531042c1d6af4c5e84535981a3f7c946d047b3215fbaf'}, 'status': 'published'}, 'commissioning/3': {'recorded_at': {'sha256': 'da26f89f52e119f9b26602d1d3edefc2137245b630802bc9469cef7f4b463191'}, 'status': 'published'}, 'commissioning/4': {'recorded_at': {'sha256': 'c5d8677e522839ae8c39ab8de4be0e8a42857d2dbd5d924d6382add77322edf0'}, 'status': 'published'}, 'commissioning/5': {'recorded_at': {'sha256': '5cbea4654cdff996b53fecb70acf76f9226d8bcdf3ee6b9a6a0ab15bdc67b741'}, 'status': 'published'}, 'commissioning/6': {'recorded_at': {'sha256': '6a08e0cdc232e8ee94e9b12b2bc172f8a3bf297dab22f991b951bee2dbec1d27'}, 'status': 'withheld', 'withheld_reason': 'host_path'}, 'commissioning/7': {'recorded_at': {'sha256': '8e9fb9c5726d52273fa524ba76eb538673e8047abf07e7b502df0cae42338bd2'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'commissioning/8': {'recorded_at': {'sha256': '2d60d8154129b157c76491dcebe42c49121a4a3ce8cd6f57a5b0a16928bd2485'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'commissioning/9': {'recorded_at': {'sha256': '4c143843d9e652b97277c200e6af16c0a2f13bef29afc62fcf40bb7e9a335d3e'}, 'status': 'withheld', 'withheld_reason': 'internal_config'}, 'live-run/1': {'recorded_at': {'sha256': '89e1536ca44eed09c4664cf3ea68a0ccd9164c2d53767c22c6b676964a05122d'}, 'status': 'published'}, 'live-run/2': {'recorded_at': {'sha256': '54b4c4ca05efe84d27565af8591945751821db2dc4c21b41f57840bd3f2c6004'}, 'status': 'published'}, 'tes-summary/1': {'recorded_at': {'sha256': '6f9f5bc3e0d4cec2dcd4f557bdfa3a4be21d9ccda220e8bfe617b0219885d5f5'}, 'status': 'published'}, 'unified/1': {'recorded_at': {'sha256': 'cccd3f61b4f0d236f8c027bb8b8412329fc7292a48932eef247d711bf6482623'}, 'status': 'withheld', 'withheld_reason': 'internal_evidence_or_prompt'}, 'unified/2': {'recorded_at': {'sha256': '8a389855b85fdba898572158e4b4e8a4f46632c9eabbd6e0f85a15b46f46fc65'}, 'status': 'withheld', 'withheld_reason': 'internal_evidence_or_prompt'}, 'unified/3': {'recorded_at': {'sha256': 'a9f2129e0b70ca1d47540b7e25e6af365c9e2eafd5539630b01bf29bab85c4e4'}, 'status': 'withheld', 'withheld_reason': 'internal_evidence_or_prompt'}}
NOTE_DIGEST = 'dd68c46c5c08072ea805a0a703e266ee4a6788996f9aaac24caef99a63f597da'
PRIOR_DIGEST = '192de5cb2fac2c5f955d0b57a8e447c34c5aa9f6a85eccc628e4f0f3da12548f'
ROW_PINS = {'code/1': '1639ee226c7da641bb4f9b433ed54051cb6bccd9e9937924c747270afb005749', 'code/2': '7e1c3b905f29b32b19cd584a8dbb71110a407e8117cf39be7c6d86bfcdebb7ac', 'code/3': '0ad0ca97a75dbca5c5852b037a9586ebb10a668d82885eebcd122ef703798848', 'code/4': '41f173d5e81c76c2e6f836198e4ef2dbfbd4410ceaa93cbdec7946264263f18c', 'code/5': 'b5990808fbad6e5976c8db302c204f3325c91b8896f13a77934508eec46d76ae', 'code/6': '00c9a6d4d9854fe59a0f6d71840ce1eb7727a5a289187e9d47144a463721574b', 'code/7': 'aad461aa4d3976c44e64d7c020ddcb52b53ec3a4d2fe95e57da25d6870b4ce2c', 'commissioning/1': '1a297b6ee8b34b85c5bd26eaf57bdbe583dc0658ff1dff5e05432be77bf86f75', 'commissioning/10': '4be3dd13cdcae1f99454f2f546d85047da6e81f87d666402c273e51922e6a1dc', 'commissioning/11': '88f49f074530d8abe2f8573c334233643804e1d211d696d12f36237832a48a1b', 'commissioning/12': '0af53e7b4ddd7562cb1a1f6b23906748304967ba797c3690ca9dc1fc6f31e514', 'commissioning/13': '5b7d4558bf30d77ab7a8917709b2c5009d7020c38edb4e585cdf816adab02d3a', 'commissioning/14': '2ee14146c4a13416ef4138a5297066a91fe26003212583e69a1933254aac318a', 'commissioning/15': 'd5dce368e56516392103a3eeabbcd60590971a36c164f34f92fad68564d3f10b', 'commissioning/16': '0afe529507cf314fc42d7e9e6e7eb0036ce4975c517fa91c139da1dfad896e68', 'commissioning/17': 'cfdcb0a3f36164ff3a4172f27520bda5cd563d74681b8f678de3a24f9d4e2905', 'commissioning/18': '6464e01109bd7b24f838cb02c2b29e066b81fe3c2aa3b571a871531f72939cf0', 'commissioning/19': '8994381706056d1876145430ce9950bc270713ddde7f498f07fceedc05280da4', 'commissioning/2': '086b7329dff48b6e6721f14b4ab26f82d581b8335bdf28e7a8c7a02cbe93fee6', 'commissioning/3': '049b4baf14c9776c19258c1a7ba92b2e7841368cca57f1511bb258c6da9777f9', 'commissioning/4': '500cfdf53a0936904fac96f1795b6a5401bd57f745ccfa95c2c2961aa3b8daea', 'commissioning/5': 'f3c736f85c03212f519417e48dad10050456218c87a3e71e39e3a3fb1d6fb124', 'commissioning/6': 'a3a035b62c7810f58ab1072e32d2a964ee3bec03f3e38c7e4cc969898217e058', 'commissioning/7': 'c5668cbdda888cfad70d3f6c0d8e32199ef7c08ee6306f9c8f4cff2d324ba4cc', 'commissioning/8': '13e928c439d555c8e81a15127e1e3ff6c16d967db1d0b5bac73e3007213aed53', 'commissioning/9': '715bf7e1edd8f376e6aac05254f0bebb5d953edb0b51d5fedc39e36b763feefc', 'live-run/1': '8cd531c7f0fbd826dfb4ebd78e91c365876d912f7477a220d35ca4a3ab06ce65', 'live-run/2': 'b0c235c4f0be3b0409c5ae007398430fc8c5814298765b772b898e9bdf9bf1a2', 'tes-summary/1': '5f80dbaa8a50bab356575224768236e26c36a0919941a9d8f032985cb0c74890', 'unified/1': 'bb67ad8a5f3afe70cf88dd738c5128f74fbf1ee29283bffc9620ca046c95cbcd', 'unified/2': 'd97ce44fd064a359cb849a2ba98fc43053775e2664f307521c2c4d51b64bf530', 'unified/3': '4740241f6b88401505b425e505d178204cf4870ad3421527c580a9e750ec1264'}
RULES = {'code/1': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:bf9fad7b8dca6ff90dac52dba117919b8c8f449ed2f338ae552b1d26bc998901'}, 'code/2': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:7753fa033eef6a4ae3b5df76c3446757ea248946f7ef3b8dff4640f4234805ef'}, 'code/3': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:b010165ae0b826b04d2c519c1b47dc19b354827af91181d003d7d088dfd3575e'}, 'code/4': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash, witness_signature], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:0100fa49ffba94817ec013879097e309e6563967027d2126bb271c068fbaae3b'}, 'code/5': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash, witness_signature], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:b21be23ebb6ff1c6387e280aa07045c61763d4b10d211e3afc535a35552c2401'}, 'code/6': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash, witness_signature], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:92b5f6b4a2284128061989128f9a60ee89776062cc9a469c5120df19fec744f8'}, 'code/7': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash, witness_signature], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'code/operational_pa_operational_fitness_manifest_2026_06_26'}, 'commissioning/1': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/tring_reference'}, 'commissioning/10': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:8d689aebd76886f07b812196647bbb185977538231f783d1b6b0cae16d3646d9'}, 'commissioning/11': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:cd432c6bcd975c1374835cf1b78920c58ed258bb6e40988812e25110e9b60f30'}, 'commissioning/12': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:435a88c9acf7eba18d80667349de5332b7af79898928637593ea254645dc0698'}, 'commissioning/13': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/child_key_issue'}, 'commissioning/14': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:0d8f7895bbe7aad05c0e62590bd73f323b7cb507e54e6377f51f34dbea0dbec0'}, 'commissioning/15': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/witness_key_enrollment'}, 'commissioning/16': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=("root_algorithm" in row), allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:b3bae0f64de91a17ceb908180317928c4def0b546546ab1043407e79e9fe61f9'}, 'commissioning/17': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=("root_algorithm" in row), allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:6731853726564e7b31dee7447cd0f1a9ba50db03c720bacdcf14b0445f8078bd'}, 'commissioning/18': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=("root_algorithm" in row), allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:4f9defc74d5a000f04e489cfff7c6ee04453c0515cb23df8545c69650525822b'}, 'commissioning/19': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=("root_algorithm" in row), allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:6958db7b760f3ee20e0b7c38dd7db4552c88ca7a50e8663899ba036043db826c'}, 'commissioning/2': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/tring_reference'}, 'commissioning/3': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/tring_reference'}, 'commissioning/4': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/maker_tkey_genesis'}, 'commissioning/5': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:2a4d36a123d4656a6848b83c11e03cfdfa68017f749b5f31a59208b758867a8e'}, 'commissioning/6': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'commissioning/ltl_substrate_merge_attestation'}, 'commissioning/7': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:b5d517a9705018f1a28dddbe1d706e08edfec0d2d36784a7530f71b659fffc3e'}, 'commissioning/8': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:3b775ede90e29d22d2523c65d9b87d12cdd1dfb7e0ea57ed4be6ae8a4ab84a1b'}, 'commissioning/9': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [signature_envelope, this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:2a7a4fce46f4e356a7670e7cd1078925e81279645b2b5ff8ad0465dc42f8781d'}, 'live-run/1': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'live-run/filmed_session_receipt'}, 'live-run/2': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [this_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'live-run/filmed_session_receipt'}, 'tes-summary/1': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'tes-summary/continuity_measurement_derivative'}, 'unified/1': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [canonical_entry_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'redacted:sha256:35f03f8e075ca01d144360357f205a7d4bdefab385bb0e9602ddee640092cc02'}, 'unified/2': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [canonical_entry_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'unified/CONSTITUTIVE_AMENDMENT'}, 'unified/3': {'hash_rule': 'SHA256 of UTF-8 json.dumps(row minus [canonical_entry_hash], sort_keys=True, separators=(",", ":"), ensure_ascii=True, allow_nan=False); no trailing newline', 'schema': 'unified/CHECKPOINT'}}
SEMANTIC_PINS = {'17': {'agent_id': 'a9a4d70d474334db021f614e6ba89d006044c4231ab6410f346fcd4055a762e1', 'authority_class': 'f041d18964f8ffa7a5a165c0a8cb7e093249f58f6e69742647d5afe8ccde5553', 'authority_source': '7ab0202baebba690425ef7f0e61b304dd8a419e4350f3db9b3a3de32b9649470', 'event_type': '5198c0fbc29f2cdab249d7ba4b607ed92079000e3b84b410d8febf398619f979', 'live_run_row_hash': '8cd531c7f0fbd826dfb4ebd78e91c365876d912f7477a220d35ca4a3ab06ce65', 'purpose_row_hash': '0afe529507cf314fc42d7e9e6e7eb0036ce4975c517fa91c139da1dfad896e68', 'purpose_sha256': 'a983ce8902792376ea5cf2279b21d7a1d57df416ee0fdd430d1d936f5bdd1188', 'receipt_path': '40b687aa110f65222c312df51de5caccd54c6589060678b6953cc7d996349330', 'receipt_sha256': 'eac4595bdce053785315ac29e6b06f61bef4aef6549cabf040110c21a8a4725a', 'role': '1b1a56446cae5405dadeb2b779bd06fce6183740f35ce0737ea314dcfb0809a8', 'run_id': '8fb560f871dd6c8089035d0ccb83f1eee7e2a8eb9ac097dbb2825b86576cef98', 'signature_scope': 'a0f20a409d99fe5e8a8b046ab411bdc96c003469d66ac26870dd3d81de447fff', 'signer': '072fe03ed748bd9bc4ad555bed926165c8e46c542aa68d40b1275c472c6898fa', 'status': '198f496168d2f4a7dade7898f9f6653f3a58a6032b3bab8e640a0b0c380975d1'}, '18': {'agent_id': '9c751f816aad7002c41f81e310b64c081b15e9a8c37527865873d73214e55247', 'authority_class': '72fec4fa62082f41170f4198ed5b12eb65db7af7cbe251e90c576c7da6c34903', 'authority_source': '0748f29e634415348df79431a6c2a5467222f30b2daecc6622f66c485f5ec904', 'event_type': 'a814829a506da22ff0c0cfa57f7ba0afcb410f272cd44399f016e342226117a4', 'role': '1b1a56446cae5405dadeb2b779bd06fce6183740f35ce0737ea314dcfb0809a8', 'signature_scope': 'cc6823c9a88e15ec42bc7903d361f3b117de8a71579a5facd0e8ec139c3c4ee0', 'signer': 'c0e1823f0f9dc804acd81f30f09a437541fbcd1f85344824942f388fb62c4ce7', 'status': '198f496168d2f4a7dade7898f9f6653f3a58a6032b3bab8e640a0b0c380975d1'}, '19': {'agent_id': '31e56e5879520d8353bb590f500a30fa562be270d80514438ea509fd5b8d49b2', 'authority_class': '23a284c8911814e95e7c28e4484afcc276cf63ae05fbc37b679233ec4692df60', 'authority_source': 'ce79a6003052dc0cc6d5f3037d697dbd301910be423e53f85a2f241f39b30633', 'event_type': 'd2a5fcf258f4cea63387f64f66642b153db500cd874a0e07e7ff75e35cc8f126', 'live_run_row_hash': 'b0c235c4f0be3b0409c5ae007398430fc8c5814298765b772b898e9bdf9bf1a2', 'purpose_row_hash': '6464e01109bd7b24f838cb02c2b29e066b81fe3c2aa3b571a871531f72939cf0', 'purpose_sha256': '75bd97268868827c9e965470ef7c6f9ac210626e355a0bcba0f7509919a053b8', 'receipt_path': 'c29ab1fac29800c3e59c0493e9a252faec50ebc0cba669d1e3ea90e0223cc172', 'receipt_sha256': 'ba42f23c63a61dea7e3b42b8912d28ab93c5414d48ff1482045b8126d8a91238', 'role': '1b1a56446cae5405dadeb2b779bd06fce6183740f35ce0737ea314dcfb0809a8', 'run_id': '5d5bea4207b8f1bc0a34f1d7a8b1d32ca4b130a22713509cc5c1ff5bfb534a16', 'signature_scope': '5a0d3f1a7465671a85ebb51d711d9f619694bafaab5d5999864afb1e9924d3c2', 'signer': '3c87e1b771670a866421e6e47bf7a2a293ce35ea63205d5c54a576ce2f7af8ff', 'status': '198f496168d2f4a7dade7898f9f6653f3a58a6032b3bab8e640a0b0c380975d1'}, '16': {'action_sha256': 'a5e8be12dcd1d6272882867d355367b6a37f6cab0ec5e62ff9d19c070358dc34', 'addendum_sha256': 'a983ce8902792376ea5cf2279b21d7a1d57df416ee0fdd430d1d936f5bdd1188', 'agent_id': '8552dedf47dbd1309cb6b82953ddba06bd5eeacab5e988b786673a48af1763e7', 'authority_class': 'eff05c5454f8e656cff80c82af49af96ad16e29063a05ee6059e4ba7a25e0276', 'authority_source': '0b1c4ffcc569e871029944b7c3d0081b6b53f23f28a63d5828a36254fe67dd20', 'authorization_receipt_id': 'ca7f415d4f05f3ade705cd73bfc1ecf4af5d94fcdf8e329542d4ee6cf421d544', 'authorization_receipt_sha256': '73873a43f47f2554994b8f1974127759df22a0da7ff7279e44406846fa973381', 'lexicon_sha256': 'a322efcd4a3e37fd4c9fa835ac5b6472d1c022fc6aa4155dc980d7ea57534d22', 'mount_manifest_sha256': '28f2bc482b9a904274f34cb07c9e0e37a149622022977fba5f837dbbb39ec69f', 'preserved_anchor_sha256s': '5dfee0b21a33020bbfac79a27987bf3d70b07ea26dae34e87e94b7b9c7b3286f', 'public_fingerprint': 'c4910e5ee23397609772b950129c34645357900df05f9c9962fd501dea2ab573', 'retrieval_index_sha256': '1620904ed7228ba507e8968809fea2cdaa685553cd374a0a834e04ca0e5b419e', 'role': '1b1a56446cae5405dadeb2b779bd06fce6183740f35ce0737ea314dcfb0809a8', 'signature_scope': '1d70919e48c16ed11c93d9f3869c291ccea35b68fcf74def3d6bf483e18abc8e', 'signer': 'f46faa2ea031a8668277d5d79b59eb91988e9f9256bf4f3842679af8cac970c5', 'source_candidate_sha256': 'a206277957a1e2408a0edfd24161d5058ca9aa69442a796d76365ffc24d26f91', 'status': '198f496168d2f4a7dade7898f9f6653f3a58a6032b3bab8e640a0b0c380975d1', 'timestamp': 'a607374daca5aa51ba206336980ebb5c512edbfeeae9c5ebb656504ee61268ea'}}
SHAPES = {'code/1': {'act_companion_reference_sha256': 'str', 'act_engineering_companion_sha256': 'str', 'act_sha256': 'str', 'agent_id': 'str', 'allowlist_sha256': 'str', 'code_genesis_snapshot_sha256': 'str', 'countersignature_envelope_sha256': 'str', 'countersignature_signature_sha256': 'str', 'countersigner_fingerprint': 'str', 'countersigner_role': 'str', 'event_type': 'str', 'operational_pa_sha256': 'str', 'operational_pa_signature_sha256': 'str', 'field_code_1_1': 'str', 'parent_hash': 'NoneType', 'public_fingerprint': 'str', 'role': 'str', 'signer': 'str', 'signer_role': 'str', 'stewardship_code_v1_2_article_iii_sha256': 'str', 'this_hash': 'str', 'timestamp': 'str', 'witness_intent_sha256': 'str', 'witness_intent_signature_sha256': 'str'}, 'commissioning/1': {'agent_id': 'str', 'content_hash': 'str', 'event_type': 'str', 'prev_hash': 'str', 'ring_hash': 'str', 'ring_number': 'int', 'this_hash': 'str', 'ts': 'str'}, 'commissioning/13': {'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'ceremony_id': 'str', 'certificate_hash': 'str', 'certificate_root_signature_sha256': 'str', 'child_algorithm': 'str', 'child_key_id': 'str', 'child_public_key_sha256': 'str', 'effective_at': 'str', 'event_type': 'str', 'key_role': 'str', 'link_key_id': 'NoneType', 'link_type': 'str', 'parent_hash': 'str', 'projection_sequence': 'int', 'purpose': 'str', 'reason_code': 'NoneType', 'reason_digest': 'NoneType', 'root_algorithm': 'str', 'root_key_id': 'str', 'root_public_enrollment_sha256': 'str', 'schema_version': 'str', 'scope_id': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'valid_from': 'str', 'valid_until': 'NoneType'}, 'commissioning/15': {'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'ceremony_id': 'str', 'certificate_hash': 'NoneType', 'certificate_root_signature_sha256': 'NoneType', 'child_algorithm': 'str', 'child_key_id': 'str', 'child_public_key_sha256': 'str', 'effective_at': 'str', 'event_type': 'str', 'key_role': 'str', 'link_key_id': 'NoneType', 'link_type': 'str', 'parent_hash': 'str', 'predates_note': 'str', 'projection_sequence': 'int', 'purpose': 'str', 'reason_code': 'NoneType', 'reason_digest': 'NoneType', 'root_algorithm': 'str', 'root_key_id': 'str', 'root_public_enrollment_sha256': 'str', 'schema_version': 'str', 'scope_id': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'valid_from': 'str', 'valid_until': 'NoneType'}, 'commissioning/16': {'action_sha256': 'str', 'addendum_sha256': 'str', 'agent_id': 'str', 'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'event_type': 'str', 'lexicon_sha256': 'str', 'maker_evidence': {'action_sha256': 'str', 'authorization_receipt': {'assertion_id': 'str', 'assertion_replay_key_sha256': 'str', 'authenticator_data_sha256': 'str', 'authority_class': 'int', 'authorization_receipt_emission_external_effect': 'bool', 'authorization_receipt_id': 'str', 'candidate_credential_id': 'str', 'chain_appended': 'bool', 'challenge_sha256': 'str', 'client_data_json_sha256': 'str', 'command_id': 'str', 'consumer_acceptance_status': 'str', 'credential_id_hash': 'str', 'cross_origin': 'bool', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'decision_slug': 'str', 'escalation_reason': {'keys': 'NoneType', 'redacted': 'bool', 'sha256': 'str'}, 'escalation_type': 'str', 'expires_at_utc': 'str', 'governance_runtime_mode': 'str', 'not_telegram_authority': 'bool', 'operator_authority_gate': 'bool', 'origin': 'str', 'payload_canonical_json_sha256': 'str', 'payload_display_text_sha256': 'str', 'policy_verdict': 'str', 'public_key_cose_sha256': 'str', 'receipt_id': 'str', 'receipt_profile': 'str', 'receipt_sha256': 'str', 'replay_protected': 'bool', 'rp_id': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'sign_count': 'int', 'signature_sha256': 'str', 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telegram_context_id': 'str', 'telos_mutated': 'bool', 'user_presence_verified': 'bool', 'user_verification_verified': 'bool', 'verified': 'bool', 'verified_at_utc': 'str', 'verifier_result': 'str', 'ward_commissioned': 'bool'}, 'consumer_verify': {'accepted': 'bool', 'authorization_receipt_id': 'str', 'chain_appended': 'bool', 'command_id': 'str', 'credential_id_hash': 'str', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'escalation_reason': 'str', 'escalation_type': 'str', 'governance_runtime_mode': 'str', 'operator_authority_gate': 'bool', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'semantic_escalation_context': {'approval_effect': 'str', 'escalated_item': 'str', 'escalation_type': 'str', 'operator_prompt': 'str', 'policy_verdict': 'str', 'reason': 'str', 'requested_effect': 'str', 'risk_tier': 'str', 'target': 'str'}, 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telos_mutated': 'bool', 'verifier_result': 'str'}, 'profile': 'str', 'suspended_action': {'action': {'keys': ['str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'agent_claimed_context': {'keys': ['str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'agent_id': 'str', 'approved_at_utc': 'str', 'audit_events': [{'at_utc': 'str', 'status': 'str', 'updates': {'approved_at_utc': 'str', 'authorization_receipt_id': 'str'}}], 'authorization_receipt_id': 'str', 'command_id': 'str', 'created_at_utc': 'str', 'execution_id': 'NoneType', 'expires_at_utc': 'str', 'nonce_sha256': 'str', 'operator_scope': 'str', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'policy_version': 'str', 'required_approval_count': 'int', 'required_authority_class': 'int', 'risk_tier': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'status': 'str', 'suspended_action_id': 'str', 'target': 'str', 'tenant_id': 'str', 'tool': 'str'}}, 'mount_manifest_sha256': 'str', 'parent_hash': 'str', 'preparation_binding': {'commit': 'str', 'derived_soul_sha256': 'str', 'status': 'str', 'worktree': 'str'}, 'preserved_anchor_sha256s': ['str'], 'public_fingerprint': 'str', 'retrieval_index_sha256': 'str', 'role': 'str', 'signature_scope': 'str', 'signer': 'str', 'source_candidate_sha256': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'field_commissioning_16_1': 'str', 'field_commissioning_16_2': 'str', 'field_commissioning_16_3': 'str'}, 'commissioning/17': {'action_sha256': 'str', 'agent_id': 'str', 'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'field_commissioning_17_1': 'str', 'event_type': 'str', 'live_run_row_hash': 'str', 'maker_evidence': {'action_sha256': 'str', 'authorization_receipt': {'assertion_id': 'str', 'assertion_replay_key_sha256': 'str', 'authenticator_data_sha256': 'str', 'authority_class': 'int', 'authorization_receipt_emission_external_effect': 'bool', 'authorization_receipt_id': 'str', 'candidate_credential_id': 'str', 'chain_appended': 'bool', 'challenge_sha256': 'str', 'client_data_json_sha256': 'str', 'command_id': 'str', 'consumer_acceptance_status': 'str', 'credential_id_hash': 'str', 'cross_origin': 'bool', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'decision_slug': 'str', 'escalation_reason': {'keys': 'NoneType', 'redacted': 'bool', 'sha256': 'str'}, 'escalation_type': 'str', 'expires_at_utc': 'str', 'governance_runtime_mode': 'str', 'not_telegram_authority': 'bool', 'operator_authority_gate': 'bool', 'origin': 'str', 'payload_canonical_json_sha256': 'str', 'payload_display_text_sha256': 'str', 'policy_verdict': 'str', 'public_key_cose_sha256': 'str', 'receipt_id': 'str', 'receipt_profile': 'str', 'receipt_sha256': 'str', 'replay_protected': 'bool', 'rp_id': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'sign_count': 'int', 'signature_sha256': 'str', 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telegram_context_id': 'str', 'telos_mutated': 'bool', 'user_presence_verified': 'bool', 'user_verification_verified': 'bool', 'verified': 'bool', 'verified_at_utc': 'str', 'verifier_result': 'str', 'ward_commissioned': 'bool'}, 'consumer_verify': {'accepted': 'bool', 'authorization_receipt_id': 'str', 'chain_appended': 'bool', 'command_id': 'str', 'credential_id_hash': 'str', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'escalation_reason': 'str', 'escalation_type': 'str', 'governance_runtime_mode': 'str', 'operator_authority_gate': 'bool', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'semantic_escalation_context': {'approval_effect': 'str', 'escalated_item': 'str', 'escalation_type': 'str', 'operator_prompt': 'str', 'policy_verdict': 'str', 'reason': 'str', 'requested_effect': 'str', 'risk_tier': 'str', 'target': 'str'}, 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telos_mutated': 'bool', 'verifier_result': 'str'}, 'profile': 'str', 'suspended_action': {'action': {'keys': ['str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'agent_claimed_context': {'keys': [], 'redacted': 'bool', 'sha256': 'str'}, 'agent_id': 'str', 'approved_at_utc': 'str', 'audit_events': [{'at_utc': 'str', 'status': 'str', 'updates': {'approved_at_utc': 'str', 'authorization_receipt_id': 'str'}}], 'authorization_receipt_id': 'str', 'command_id': 'str', 'created_at_utc': 'str', 'execution_id': 'NoneType', 'expires_at_utc': 'str', 'nonce_sha256': 'str', 'operator_scope': 'str', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'policy_version': 'str', 'required_approval_count': 'int', 'required_authority_class': 'int', 'risk_tier': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'status': 'str', 'suspended_action_id': 'str', 'target': 'str', 'tenant_id': 'str', 'tool': 'str'}}, 'parent_hash': 'str', 'public_fingerprint': 'str', 'purpose_row_hash': 'str', 'purpose_sha256': 'str', 'receipt_path': 'str', 'receipt_sha256': 'str', 'role': 'str', 'run_id': 'str', 'signature_scope': 'str', 'signer': 'str', 'source_candidate_sha256': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'field_commissioning_17_2': 'str', 'field_commissioning_17_3': 'str', 'field_commissioning_17_4': 'str'}, 'commissioning/18': {'action_sha256': 'str', 'addendum_sha256': 'str', 'agent_id': 'str', 'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'event_type': 'str', 'maker_evidence': {'action_sha256': 'str', 'authorization_receipt': {'assertion_id': 'str', 'assertion_replay_key_sha256': 'str', 'authenticator_data_sha256': 'str', 'authority_class': 'int', 'authorization_receipt_emission_external_effect': 'bool', 'authorization_receipt_id': 'str', 'candidate_credential_id': 'str', 'chain_appended': 'bool', 'challenge_sha256': 'str', 'client_data_json_sha256': 'str', 'command_id': 'str', 'consumer_acceptance_status': 'str', 'credential_id_hash': 'str', 'cross_origin': 'bool', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'decision_slug': 'str', 'escalation_reason': {'keys': 'NoneType', 'redacted': 'bool', 'sha256': 'str'}, 'escalation_type': 'str', 'expires_at_utc': 'str', 'governance_runtime_mode': 'str', 'not_telegram_authority': 'bool', 'operator_authority_gate': 'bool', 'origin': 'str', 'payload_canonical_json_sha256': 'str', 'payload_display_text_sha256': 'str', 'policy_verdict': 'str', 'public_key_cose_sha256': 'str', 'receipt_id': 'str', 'receipt_profile': 'str', 'receipt_sha256': 'str', 'replay_protected': 'bool', 'rp_id': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'sign_count': 'int', 'signature_sha256': 'str', 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telegram_context_id': 'str', 'telos_mutated': 'bool', 'user_presence_verified': 'bool', 'user_verification_verified': 'bool', 'verified': 'bool', 'verified_at_utc': 'str', 'verifier_result': 'str', 'ward_commissioned': 'bool'}, 'consumer_verify': {'accepted': 'bool', 'authorization_receipt_id': 'str', 'chain_appended': 'bool', 'command_id': 'str', 'credential_id_hash': 'str', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'escalation_reason': 'str', 'escalation_type': 'str', 'governance_runtime_mode': 'str', 'operator_authority_gate': 'bool', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'semantic_escalation_context': {'approval_effect': 'str', 'escalated_item': 'str', 'escalation_type': 'str', 'operator_prompt': 'str', 'policy_verdict': 'str', 'reason': 'str', 'requested_effect': 'str', 'risk_tier': 'str', 'target': 'str'}, 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telos_mutated': 'bool', 'verifier_result': 'str'}, 'profile': 'str', 'suspended_action': {'action': {'keys': ['str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'agent_claimed_context': {'keys': [], 'redacted': 'bool', 'sha256': 'str'}, 'agent_id': 'str', 'approved_at_utc': 'str', 'audit_events': [{'at_utc': 'str', 'status': 'str', 'updates': {'approved_at_utc': 'str', 'authorization_receipt_id': 'str'}}], 'authorization_receipt_id': 'str', 'command_id': 'str', 'created_at_utc': 'str', 'execution_id': 'NoneType', 'expires_at_utc': 'str', 'nonce_sha256': 'str', 'operator_scope': 'str', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'policy_version': 'str', 'required_approval_count': 'int', 'required_authority_class': 'int', 'risk_tier': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'status': 'str', 'suspended_action_id': 'str', 'target': 'str', 'tenant_id': 'str', 'tool': 'str'}}, 'parent_hash': 'str', 'public_fingerprint': 'str', 'role': 'str', 'signature_scope': 'str', 'signer': 'str', 'source_candidate_sha256': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'field_commissioning_18_1': 'str', 'field_commissioning_18_2': 'str', 'field_commissioning_18_3': 'str'}, 'commissioning/19': {'action_sha256': 'str', 'agent_id': 'str', 'authority_class': 'str', 'authority_source': 'str', 'authorization_receipt_id': 'str', 'authorization_receipt_sha256': 'str', 'event_type': 'str', 'live_run_row_hash': 'str', 'maker_evidence': {'action_sha256': 'str', 'authorization_receipt': {'assertion_id': 'str', 'assertion_replay_key_sha256': 'str', 'authenticator_data_sha256': 'str', 'authority_class': 'int', 'authorization_receipt_emission_external_effect': 'bool', 'authorization_receipt_id': 'str', 'candidate_credential_id': 'str', 'chain_appended': 'bool', 'challenge_sha256': 'str', 'client_data_json_sha256': 'str', 'command_id': 'str', 'consumer_acceptance_status': 'str', 'credential_id_hash': 'str', 'cross_origin': 'bool', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'decision_slug': 'str', 'escalation_reason': {'keys': 'NoneType', 'redacted': 'bool', 'sha256': 'str'}, 'escalation_type': 'str', 'expires_at_utc': 'str', 'governance_runtime_mode': 'str', 'not_telegram_authority': 'bool', 'operator_authority_gate': 'bool', 'origin': 'str', 'payload_canonical_json_sha256': 'str', 'payload_display_text_sha256': 'str', 'policy_verdict': 'str', 'public_key_cose_sha256': 'str', 'receipt_id': 'str', 'receipt_profile': 'str', 'receipt_sha256': 'str', 'replay_protected': 'bool', 'rp_id': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'sign_count': 'int', 'signature_sha256': 'str', 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telegram_context_id': 'str', 'telos_mutated': 'bool', 'user_presence_verified': 'bool', 'user_verification_verified': 'bool', 'verified': 'bool', 'verified_at_utc': 'str', 'verifier_result': 'str', 'ward_commissioned': 'bool'}, 'consumer_verify': {'accepted': 'bool', 'authorization_receipt_id': 'str', 'chain_appended': 'bool', 'command_id': 'str', 'credential_id_hash': 'str', 'customer_facing_feature': 'str', 'decision_block_sha256': 'str', 'escalation_reason': 'str', 'escalation_type': 'str', 'governance_runtime_mode': 'str', 'operator_authority_gate': 'bool', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'semantic_escalation_context': {'approval_effect': 'str', 'escalated_item': 'str', 'escalation_type': 'str', 'operator_prompt': 'str', 'policy_verdict': 'str', 'reason': 'str', 'requested_effect': 'str', 'risk_tier': 'str', 'target': 'str'}, 'suspended_action_id': 'str', 'telegram_authority': 'bool', 'telos_mutated': 'bool', 'verifier_result': 'str'}, 'profile': 'str', 'suspended_action': {'action': {'keys': ['str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'agent_claimed_context': {'keys': [], 'redacted': 'bool', 'sha256': 'str'}, 'agent_id': 'str', 'approved_at_utc': 'str', 'audit_events': [{'at_utc': 'str', 'status': 'str', 'updates': {'approved_at_utc': 'str', 'authorization_receipt_id': 'str'}}], 'authorization_receipt_id': 'str', 'command_id': 'str', 'created_at_utc': 'str', 'execution_id': 'NoneType', 'expires_at_utc': 'str', 'nonce_sha256': 'str', 'operator_scope': 'str', 'payload_canonical_json_sha256': 'str', 'policy_verdict': 'str', 'policy_version': 'str', 'required_approval_count': 'int', 'required_authority_class': 'int', 'risk_tier': 'str', 'semantic_escalation_context': {'keys': ['str', 'str', 'str', 'str', 'str', 'str', 'str', 'str', 'str'], 'redacted': 'bool', 'sha256': 'str'}, 'status': 'str', 'suspended_action_id': 'str', 'target': 'str', 'tenant_id': 'str', 'tool': 'str'}}, 'parent_hash': 'str', 'public_fingerprint': 'str', 'purpose_row_hash': 'str', 'purpose_sha256': 'str', 'receipt_path': 'str', 'receipt_sha256': 'str', 'role': 'str', 'run_id': 'str', 'signature_scope': 'str', 'signer': 'str', 'source_candidate_sha256': 'str', 'status': 'str', 'this_hash': 'str', 'timestamp': 'str', 'field_commissioning_19_1': 'str', 'field_commissioning_19_2': 'str', 'field_commissioning_19_3': 'str'}, 'commissioning/2': {'agent_id': 'str', 'content_hash': 'str', 'event_type': 'str', 'prev_hash': 'str', 'ring_hash': 'str', 'ring_number': 'int', 'this_hash': 'str', 'ts': 'str'}, 'commissioning/3': {'agent_id': 'str', 'content_hash': 'str', 'event_type': 'str', 'prev_hash': 'str', 'ring_hash': 'str', 'ring_number': 'int', 'this_hash': 'str', 'ts': 'str'}, 'commissioning/4': {'event_type': 'str', 'intent_declaration_sha256': 'str', 'parent_hash': 'NoneType', 'public_fingerprint': 'str', 'role': 'str', 'signer': 'str', 'this_hash': 'str', 'timestamp': 'str'}, 'commissioning/5': {'act_sha256': 'str', 'agent_id': 'str', 'chief_of_staff_addendum_sha256': 'str', 'field_commissioning_5_1': 'str', 'event_type': 'str', 'operators_vow_sha256': 'str', 'operators_vow_signature_sha256': 'str', 'parent_hash': 'str', 'public_fingerprint': 'str', 'role': 'str', 'signer': 'str', 'signer_role': 'str', 'stewardship_code_v1_2_article_iii_sha256': 'str', 'this_hash': 'str', 'timestamp': 'str', 'track1_amendment_001_v1_1_sha256': 'str', 'track1_amendment_002_v2_sha256': 'str', 'track1_finalform_sha256': 'str'}, 'live-run/1': {'chain_note': 'str', 'final_chain_hash': 'str', 'manifest_sha256': 'str', 'parent_hash': 'str', 'purpose_named_by': {'chain': 'str', 'row': 'int', 'this_hash': 'str'}, 'purpose_sha256': 'str', 'readings_pa_sha256': 'str', 'readings_pa_status': 'str', 'receipt_signed': 'bool', 'receipt_zip_path': 'str', 'receipt_zip_sha256': 'str', 'recorded_at': 'str', 'run_id': 'str', 'this_hash': 'str', 'turn_count': 'int'}, 'live-run/2': {'chain_note': 'str', 'final_chain_hash': 'str', 'manifest_sha256': 'str', 'parent_hash': 'str', 'purpose_named_by': {'chain': 'str', 'row': 'int', 'this_hash': 'str'}, 'purpose_sha256': 'str', 'readings_pa_sha256': 'str', 'readings_pa_status': 'str', 'receipt_signed': 'bool', 'receipt_zip_path': 'str', 'receipt_zip_sha256': 'str', 'recorded_at': 'str', 'run_id': 'str', 'this_hash': 'str', 'turn_count': 'int'}, 'tes-summary/1': {'counts': {'code': {'parent_discontinuities': 'int', 'rows': 'int'}, 'commissioning': {'parent_discontinuities': 'int', 'rows': 'int'}, 'operational': {'gap_kind_counts': {'PARENT_MISMATCH': 'int', 'UNHASHED_TO_HASHED_BOUNDARY': 'int'}, 'hashable_rows': 'int', 'hashes_match': 'int', 'rows': 'int', 'schema_counts': {'telos.operational.tool_call.v1': 'int', 'telos.operational.tool_call.v2': 'int'}}, 'unified': {'parent_discontinuities': 'int', 'rows': 'int'}}, 'eras': [{'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'NoneType'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'chain': 'str', 'continuity': 'str', 'event_type': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}, {'category': 'str', 'chain': 'str', 'index': 'int', 'timestamp': 'str'}], 'one_sentence_wording': 'str', 'verdict': 'str'}}
PUBLIC = True
STANDALONE = None
DERIVED_PINS = {'runs/EXEMPTIONS-tes-receipt-live-20261026.json': '9b48657b66cd64f770cde874bafad3bb26a686ab837433c69c8e692b8aa00c61', 'runs/EXEMPTIONS-tes-receipt-live-20261027.json': '6ca7a248c4f5e60def66004b7b308c479ab88a467fc6e5a0095e53348ce48a5a'}
ROOT_FP='d7fa85af712439c614fb25cdac293b783c0c0240ac79efb57f659c0f60bea8bb'
WITNESS_FP='12f4de3b7a839ce3c665deaff1922916fa39a52bbe239098662d440a283aaddf'
class Failure(Exception):
 def __init__(self,code,e=None,expected_parent=None):
  self.expected_parent=expected_parent;self.code=code;self.entry=e;super().__init__(code+(' '+e['chain']+'/'+str(e['row']) if e else ''))
 def report(self):
  r={'status':'FAIL','reason':self.code,'chain':self.entry['chain'] if self.entry else 'export','row':self.entry['row'] if self.entry else 0}
  if self.code=='CENSUS_ROWS' and self.entry:r['expected_parent_hash']=self.expected_parent
  return r
def require(ok,code,e=None):
 if not ok:raise Failure(code,e)
def sha(b):return hashlib.sha256(b).hexdigest()
def packed(x):return json.dumps(x,sort_keys=True,separators=(',',':'),ensure_ascii=False,allow_nan=False).encode()
def unique(pairs):
 d={}
 for k,v in pairs:
  require(k not in d,'DUPLICATE_JSON_KEY');d[k]=v
 return d
def reject_constant(x):raise Failure('NONFINITE_JSON')
def parse(raw):return json.loads(raw,object_pairs_hook=unique,parse_constant=reject_constant)
def read(p):return parse(Path(p).read_bytes())
def native(e):
 r=e['canonical'];rule=e['hash_rule'];match=re.search(r'minus \[([^]]*)\]',rule);require(match is not None,'HASH_RULE',e)
 excluded=[v.strip() for v in match[1].split(',') if v.strip()]
 ascii_only=True if 'ensure_ascii=True' in rule else False if 'ensure_ascii=False' in rule else 'root_algorithm' in r
 return sha(json.dumps({k:v for k,v in r.items() if k not in excluded},sort_keys=True,separators=(',',':'),ensure_ascii=ascii_only,allow_nan=False).encode())
def leaves(x,p=()):
 if isinstance(x,dict):
  for k,v in x.items():yield from leaves(v,p+(k,))
 elif isinstance(x,list):
  for i,v in enumerate(x):yield from leaves(v,p+(i,))
 else:yield p,x
def at(x,path):
 for k in path:x=x[k]
 return x
def sigverify(public,signature,message,code,e):
 try:Ed25519PublicKey.from_public_bytes(public).verify(signature,message)
 except (InvalidSignature,ValueError,TypeError):raise Failure(code,e) from None

def shapes(value,policy,e,path=()):
 if isinstance(policy,dict):
  require(type(value) is dict and set(value)-({'signature_envelope'} if not path else set())==set(policy),'ALLOWLIST_FIELDS',e)
  for k,p in policy.items():shapes(value[k],p,e,path+(k,))
 elif isinstance(policy,list):
  require(type(value) is list and len(value)==len(policy),'ALLOWLIST_NESTED',e)
  for i,p in enumerate(policy):shapes(value[i],p,e,path+(i,))
 else:require(type(value).__name__==policy,'ALLOWLIST_TYPE',e)
def semantics(e):
 if e['chain']=='commissioning' and str(e['row']) in SEMANTIC_PINS:
  for k,h in SEMANTIC_PINS[str(e['row'])].items():require(sha(json.dumps(e['canonical'][k],sort_keys=True).encode())==h,'ROW_VALUE:'+k,e)
def maker_bindings(e):
 if e['chain']!='commissioning' or e['row'] not in (17,18,19):return
 r=e['canonical'];m=r['maker_evidence'];a=m['authorization_receipt'];c=m['consumer_verify'];s=m['suspended_action']
 require(r['action_sha256']==m['action_sha256']==a['payload_canonical_json_sha256']==c['payload_canonical_json_sha256']==s['payload_canonical_json_sha256'],'MAKER_PAYLOAD',e)
 require(r['authorization_receipt_sha256']==a['receipt_sha256'],'MAKER_RECEIPT',e)
 require(a['credential_id_hash']==c['credential_id_hash'] and a['decision_block_sha256']==c['decision_block_sha256'],'MAKER_CREDENTIAL',e)
 require(c['accepted'] is True and a['verified'] is True and s['status']=='approved','MAKER_STATUS',e)
 require(r['authorization_receipt_id']==a['authorization_receipt_id']==c['authorization_receipt_id']==s['authorization_receipt_id'],'MAKER_RECEIPT_ID',e)
 require(a['command_id']==c['command_id']==s['command_id'],'MAKER_COMMAND',e)
def publication_shape(e,meta):
 require(('canonical' in e)==(meta['status']=='published'),'WITHHELD_SHAPE',e)
def scan_entry(e,public):
 for field,value in leaves(e['canonical']):
  if not isinstance(value,str):continue
  require('BEGIN PRIVATE KEY' not in value and 'BEGIN OPENSSH PRIVATE KEY' not in value,'PRIVATE_KEY_CONTENT',e)
  if marker(value) and not public:
   require(False,'ALLOWLIST_CONTENT',e)
def signature(e,root,witness):
 require(e['schema']==RULES[e['chain']+'/'+str(e['row'])]['schema'],'SCHEMA_BINDING',e)
 r=e['canonical'];env=r.get('signature_envelope');key=(e['chain'],e['row']);legacy=key in {('code',1),('commissioning',4),('commissioning',5)}
 if env is None:
  require(key not in {('commissioning',n) for n in (4,5,13,15,16,17,18,19)} and key!=('code',1),'ENVELOPE_MISSING',e);return
 if legacy:keys={'alg','public_key_raw_hex','signature_hex'}
 elif e['chain']=='commissioning' and e['row'] in (13,15):keys={'algorithm','covers','signer_key_id','value'}
 elif e['chain']=='commissioning' and e['row'] in (16,17,18,19):keys={'alg','public_key_raw_hex','signature_hex','signed_message'}
 else:raise Failure('HALT UNMAPPED_ENVELOPE')
 require(type(env) is dict and set(env)==keys and all(type(v) is str for v in env.values()),'ENVELOPE_SHAPE',e)
 if legacy:
  require(env['alg']=='Ed25519','ENVELOPE_ALGORITHM',e);print('NOT VERIFIED: signed message not defined by the record',e['chain'],e['row']);return
 if 'algorithm' in env:
  require(env['algorithm']=='ed25519' and env['covers']=='this_hash (ASCII bytes of the 64-character hex string)' and env['signer_key_id']=='sha256:'+ROOT_FP,'ROOT_ENVELOPE',e)
  try:root_signature=base64.b64decode(env['value'],validate=True)
  except ValueError:raise Failure('ROOT_SIGNATURE_ENCODING',e) from None
  sigverify(root,root_signature,r['this_hash'].encode('ascii'),'ROOT_SIGNATURE',e)
 else:
  require(env['alg']=='Ed25519' and env['signed_message']=='this_hash_ascii','WITNESS_ENVELOPE',e)
  require(bytes.fromhex(env['public_key_raw_hex'])==witness,'WITNESS_KEY',e)
  sigverify(witness,bytes.fromhex(env['signature_hex']),r['this_hash'].encode('ascii'),'WITNESS_SIGNATURE',e)
 print('PASS signature',e['chain'],e['row'])

CONTENT_PINS = {'code/1': '30d2bb52b0bc73587dec5f64eac456db81f8b821ff7b7b0f609e974bb1329adc', 'commissioning/1': '1f9de9a827268dd028ebce5a7668a619e44fd3fce7b8b4a49cf88b2b86d601d5', 'commissioning/13': 'c1b60df226adc7d6a5a27474e4c48aceb0336b6b46a3ce3b8d2bcf347d72f81e', 'commissioning/15': 'c895cd282f12c985a60cef7ebfdc81066d636d97bbc2220996c8d29edc1c5aad', 'commissioning/16': '892c38c6ea8cf8cebc432169b330424b5b0a063d2e5dfb3dfdce27a7eb3e7274', 'commissioning/2': '187dc84fa2c5e5f21e9f780e895fdcfaabbaedd10e8ae5e339b61001fb5a750a', 'commissioning/3': 'f4e2195457279e8455aa6e71b8b3135d1f5db7582a051b9d501856a9a99e03ba', 'commissioning/5': 'ef170e46703160a39d2740bf643266b10008470ae7e3cade0c3f85375838c71a', 'tes-summary/1': '9cc76f6ef299691a7e2fd68cb7a934885713220d9a07ea93d480ba0649404063', 'commissioning/17': 'fadf6234f02ac10c85590e8406e24c71f354813f73a6effedc6aa4716d78b9a4', 'commissioning/18': '51b2b20c2fd33de9a03d4c632e56e2a5ced7aa338561ec8ba32c56ec2c8a1009', 'commissioning/19': '9fa096767290b9a95016d09a9c8681e7bbe7dc351489f0a56825a3893b5cd7a1'}
def public_content(e):
 def mask(x):
  if isinstance(x,dict):return {k:mask(v) for k,v in x.items() if k not in ('this_hash','parent_hash','prev_hash','signature_envelope')}
  if isinstance(x,list):return [mask(v) for v in x]
  if isinstance(x,str) and re.fullmatch(r'redacted:sha256:[0-9a-f]{64}',x):return '<commitment>'
  return x
 return sha(packed(mask(e['canonical'])))

def frozen(export):
 f=export['frozen'];require(set(f)=={'at','final_entry','prior_freeze','note'},'FROZEN_SHAPE')
 require(f['final_entry']=={'chain':'live-run','row':2,'this_hash':FINAL_HASH},'FROZEN_FINAL')
 require(sha(packed(f['prior_freeze']))==PRIOR_DIGEST,'FROZEN_PRIOR')
 require(sha(packed(f['note']))==NOTE_DIGEST,'FROZEN_NOTE')
 require(type(f['at']) is str and f['at']=='2026-10-28T00:06:49Z','FROZEN_AT');print('PASS frozen')
def _receipt(tree,live,rows):
 r=live['canonical'];path=tree/r['receipt_zip_path'];raw=path.read_bytes()
 require(sha(raw)==r['receipt_zip_sha256'],'LIVE_ZIP_HASH',live)
 with zipfile.ZipFile(io.BytesIO(raw)) as z:
  names=z.namelist();require(len(set(names))==len(names) and all(not n.startswith('/') and '..' not in Path(n).parts for n in names),'LIVE_ZIP_PATHS',live)
  ms=[n for n in names if n.endswith('/MANIFEST.json')];require(len(ms)==1,'LIVE_MANIFEST',live);mn=ms[0];prefix=mn[:-len('MANIFEST.json')];mb=z.read(mn);m=parse(mb)
  require(sha(mb)==r['manifest_sha256'],'LIVE_MANIFEST_HASH',live)
  require({n for n in names if n.startswith(prefix) and n!=mn}=={prefix+n for n in m['files']},'LIVE_MEMBER_SET',live)
  for n,h in m['files'].items():require(sha(z.read(prefix+n))==h,'LIVE_MEMBER_HASH',live)
  require(type(m['turn_count']) is int and type(r['turn_count']) is int and m['run_id']==r['run_id'] and m['turn_count']==r['turn_count'] and m['final_chain_hash']==r['final_chain_hash'] and m['export_time']==r['recorded_at'],'LIVE_MANIFEST_BINDING',live)
  require(sha(z.read(prefix+'pins/purpose'))==r['purpose_sha256'] and sha(z.read(prefix+'pins/pa'))==r['readings_pa_sha256'],'LIVE_PURPOSE',live)
  binding=r['purpose_named_by'];pe=rows[(binding['chain'],binding['row'])];require(pe['row_hash']==binding['this_hash'] and pe['canonical']['addendum_sha256']==r['purpose_sha256'],'LIVE_PURPOSE_ROW',live)
  # Marker locations are exact members with independently rehashed content digests.
  ex=read(tree/('runs/EXEMPTIONS-tes-receipt-live-'+('20261026' if live['row']==1 else '20261027')+'.json'))
  actual=[]
  for n in names:
   content=z.read(n);text=content.decode('utf-8','replace')
   require('BEGIN PRIVATE KEY' not in text and 'BEGIN OPENSSH PRIVATE KEY' not in text,'LIVE_PRIVATE_CONTENT',live)
   if marker(text):actual.append({'path':n,'sha256':sha(content),'counts':marker_counts(text)})
  require(actual==ex['members'],'LIVE_EXEMPTIONS',live)
 print('PASS receipt',live['chain'],live['row'])
def receipt(tree,live,rows):
 try:return _receipt(tree,live,rows)
 except Failure:raise
 except (OSError,ValueError,KeyError,TypeError,EOFError,lzma.LZMAError,zlib.error,zipfile.BadZipFile,RuntimeError,NotImplementedError):raise Failure('LIVE_ZIP_INVALID',live) from None
def witness_anchor(r15,witness,e):
 require(sha(witness)==r15['child_public_key_sha256']==WITNESS_FP and r15['status']=='active' and r15['purpose']=='witness_signing' and r15['key_role']=='witness','WITNESS_ANCHOR',e)
def decoded_views(raw):
 queue=[raw if isinstance(raw,bytes) else str(raw).encode()];seen=set()
 while queue:
  data=queue.pop(0)
  if data in seen:continue
  seen.add(data)
  try:text=data.decode('utf-8')
  except UnicodeDecodeError:text=''
  yield text
  if len(seen)>4096:raise ValueError('DECODE_LIMIT')
  try:
   obj=json.loads(text)
   def strings(x):
    if isinstance(x,str):yield x
    elif isinstance(x,dict):
     for k,v in x.items():yield k;yield from strings(v)
    elif isinstance(x,list):
     for v in x:yield from strings(v)
   queue.extend(v.encode() for v in strings(obj) if v.encode()!=data)
  except (ValueError,TypeError):pass
  try:
   with zipfile.ZipFile(io.BytesIO(data)) as z:queue.extend(z.read(n) for n in z.namelist() if not n.endswith('/'))
  except (ValueError,zipfile.BadZipFile):pass
  for token in re.findall(r'[A-Za-z0-9!#$%&()*+,./:;<=>?@^_`{|}~+\-]{16,}',text):
   for decoder in (lambda x:bytes.fromhex(x),lambda x:base64.b64decode(x,validate=True),base64.b85decode,lambda x:zlib.decompress(x.encode('latin1'))):
    try:
     out=decoder(token)
     if out and out!=data:queue.append(out)
    except (ValueError,TypeError,UnicodeError,zlib.error):pass
  try:
   out=zlib.decompress(data)
   if out:queue.append(out)
  except zlib.error:pass
def marker_counts(text):
 c={'M1':0,'M2':0,'M3':0,'M4':0,'M5':0,'M6':0}
 for view in decoded_views(text):
  lower=view.lower()
  c['M1']+=len(re.findall(r'tail[0-9a-f]{6}|[.]local\b',lower))
  c['M2']+=lower.count('/'+'users/')
  c['M3']+=len(re.findall(r'w[a-z0-9]+:p[0-9]+',lower))
  c['M4']+=len(re.findall(r'\.ts\.net\b',lower))
  c['M6']+=len(re.findall(r'\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b',lower))
  for token in re.findall(r'(?<![\w.])(?:\d{1,3}\.){3}\d{1,3}(?![\w.])|(?<!\w)(?:[0-9a-fA-F]{0,4}:){2,}[0-9a-fA-F:]{0,39}(?!\w)',view):
   try:
    if not ipaddress.ip_address(token).is_loopback:c['M5']+=1
   except ValueError:pass
 return c
def marker(text):return any(marker_counts(text).values())
def attestation(live,attest):
 r=live['canonical'];a=attest['canonical']
 require(a['receipt_sha256']==r['receipt_zip_sha256'] and a['receipt_path']==r['receipt_zip_path'] and a['live_run_row_hash']==live['row_hash'] and a['run_id']==r['run_id'] and a['purpose_sha256']==r['purpose_sha256'] and a['purpose_row_hash']==r['purpose_named_by']['this_hash'],'RECEIPT_ATTESTATION',live)
def check_sums(tree):
 try:
  listed={}
  for line in (tree/'SHA256SUMS').read_text().splitlines():
   h,n=line.split(None,1);n=n.lstrip('* ');p=(tree/n).resolve()
   require(n not in listed and p.is_relative_to(tree.resolve()) and re.fullmatch('[0-9a-f]{64}',h) and p.is_file() and sha(p.read_bytes())==h,'SUMS')
   listed[n]=h
  actual={p.relative_to(tree).as_posix() for p in tree.rglob('*') if p.is_file() and p.relative_to(tree).as_posix()!='SHA256SUMS'}
  require(actual==set(listed),'SUMS')
 except (OSError,ValueError):raise Failure('SUMS') from None

def parent_links(entries):
 # Historical new roots are retained; every other parent is the preceding row hash.
 for chain in ('commissioning','code','unified','live-run'):
  chainrows=sorted((e for e in entries if e['chain']==chain),key=lambda e:e['row'])
  for i,e in enumerate(chainrows):
   if i==0 or (chain=='commissioning' and e['row']==4):require(e['parent_hash'] in ('',None),'PARENT_ROOT',e)
   else:require(e['parent_hash']==chainrows[i-1]['row_hash'],'PARENT_LINK',e)

def verify(path,public=False,standalone=None):
 path=Path(path);tree=path if path.is_dir() else path.parent;check_sums(tree);export=read(tree/'record-of-trust-export.json' if path.is_dir() else path)
 require(type(export) is dict and set(export)=={'format','entries','frozen','census'} and export['format']=='record-of-trust/two-tier-v1','EXPORT_SHAPE')
 entries=export['entries'];require(type(entries) is list,'ENTRIES');rows={}
 for e in entries:
  require(type(e) is dict and type(e.get('row')) is int,'ENTRY_SHAPE');key=(e['chain'],e['row']);require(key not in rows,'DUPLICATE_ROW',e);rows[key]=e
 expected_rows={(k.split('/')[0],int(k.split('/')[1])) for k in RULES}
 missing=sorted(expected_rows-set(rows))
 if missing:
  chain,num=missing[0];previous=rows.get((chain,num-1),{});raise Failure('CENSUS_ROWS',{'chain':chain,'row':num},previous.get('row_hash'))
 require(set(rows)==expected_rows,'CENSUS_ROWS')
 for e in entries:
  key=e['chain']+'/'+str(e['row']);require(e['schema']==RULES[key]['schema'],'SCHEMA',e)
  require(e['hash_rule']==RULES[key]['hash_rule'],'HASH_RULE',e)
  require(sha(json.dumps(e['row_hash']).encode())==ROW_PINS[key],'HEAD_PIN',e)
  for k,v in META[key].items():require(sha(json.dumps(e.get(k)).encode())==v['sha256'] if type(v) is dict else e.get(k)==v,'ENTRY_METADATA',e)
  allowed={'canonical','chain','row','path','row_hash','parent_hash','recorded_at','schema','status','hash_rule','withheld_reason','public_form','content_binding','redacted_fields'}
  require(set(e)<=allowed,'ENTRY_SHAPE',e)
  require(e['path']==f"entries/{e['chain']}/{e['row']}.json",'ENTRY_PATH',e)
  require(read(tree/e['path'])==e,'ENTRY_FILE',e)
  publication_shape(e,META[key])
  if 'canonical' not in e:
   actual=[['@wrapper',*p] for p,v in leaves({k:v for k,v in e.items() if k!='redacted_fields'}) if isinstance(v,str) and re.fullmatch(r'redacted:sha256:[0-9a-f]{64}',v)]
   if actual:require(e.get('public_form')=='redacted' and e.get('content_binding')=='declared' and sorted(actual,key=repr)==sorted(e.get('redacted_fields',[]),key=repr),'REDACTED_FIELDS',e)
   continue
  r=e['canonical']
  if public:require(not marker(json.dumps(r)),'PUBLIC_MARKER',e)
  shapes(r,SHAPES[key],e);scan_entry(e,public);semantics(e);maker_bindings(e)
  red=e.get('public_form')=='redacted'
  if red:
   require(public and e.get('content_binding')=='declared','REDACTION_FORM',e)
   actual=[list(p) for p,v in leaves(r) if isinstance(v,str) and re.fullmatch(r'redacted:sha256:[0-9a-f]{64}',v)]
   wrapper=[['@wrapper',*p] for p,v in leaves({k:v for k,v in e.items() if k not in ('canonical','redacted_fields')}) if isinstance(v,str) and re.fullmatch(r'redacted:sha256:[0-9a-f]{64}',v)]
   require(sorted(actual+wrapper,key=repr)==sorted(e['redacted_fields'],key=repr) and len(actual+wrapper)>0,'REDACTED_FIELDS',e)
   require(public_content(e)==CONTENT_PINS[key],'ROW_HASH',e)
   print('DECLARED content',e['chain'],e['row'],'private TELOS package is the full check')
  else:
   require(native(e)==e['row_hash'],'ROW_HASH',e);print('PASS content',e['chain'],e['row'])
  if e['chain']!='tes-summary':require(r['this_hash']==e['row_hash'],'ROW_HASH_DECLARED',e)
  parent=r.get('parent_hash',r.get('prev_hash'));require(parent==e['parent_hash'],'PARENT_WRAPPER',e)
 parent_links(entries)
 expected_files={e['path'] for e in entries}|{f'entries/commissioning/{n}.{suffix}' for n in (17,18,19) for suffix in ('body.md.sig',)}
 if not public:expected_files.add('entries/commissioning/18.pa.yaml')
 if public:
  for n in (17,18,19):require(not (tree/f'entries/commissioning/{n}.body.md').exists(),'WITHHELD_FILE_PRESENT')
 actual_files={p.relative_to(tree).as_posix() for p in (tree/'entries').rglob('*') if p.is_file()}
 require(expected_files==actual_files,'ENTRY_FILE_SET')
 print('PASS parent links')
 rootfile=Path(__file__).resolve().parent/'ROOT-KEY.md'
 if not rootfile.exists() and standalone is not None:rootfile=Path(__file__).resolve().parent.parent/'ROOT-KEY.md'
 roottext=rootfile.read_text();match=re.search(r'Public key \(raw, hex\): ([0-9a-f]{64})',roottext);require(match is not None,'ROOT_KEY');root=bytes.fromhex(match[1]);require(sha(root)==ROOT_FP,'ROOT_KEY')
 r15=rows[('commissioning',15)]['canonical'];witness=bytes.fromhex(rows[('commissioning',16)]['canonical']['signature_envelope']['public_key_raw_hex'])
 witness_anchor(r15,witness,rows[('commissioning',15)])
 for e in entries:
  if 'canonical' in e:signature(e,root,witness)

 for num,attest in ((1,17),(2,19)):
  attestation(rows[('live-run',num)],rows[('commissioning',attest)])
 frozen(export)
 expected={'native':31,'published':14,'withheld':17,'summary':1,'live_run':2};require(export['census']==expected,'CENSUS')
 if public:
  declarations=read(tree/'DECLARED-WITHHELD.json')['files'];require(len(declarations)==8 and {d['path'] for d in declarations}=={'entries/commissioning/18.pa.yaml','runs/tes-receipt-live-20261026.zip','runs/tes-receipt-live-20261027.zip'}|set(DERIVED_PINS)|{f'entries/commissioning/{n}.body.md' for n in (17,18,19)},'DECLARATION_SET')
  for d in declarations:
   require(not (tree/d['path']).exists(),'WITHHELD_FILE_PRESENT');b=d['binding'];e=rows[(b['chain'],b['row'])]
   require(d.get('derived_from_receipt',False)==(d['path'] in DERIVED_PINS),'DECLARATION_DERIVED',e)
   if d.get('whole_body'):
    require(d['path'] in {f'entries/commissioning/{n}.body.md' for n in (17,18,19)} and re.fullmatch(r'redacted:sha256:[0-9a-f]{64}',d['sha256']) and b=={'chain':'commissioning','row':int(Path(d['path']).name.split('.')[0]),'field':[]},'DECLARATION_BODY',e)
   elif d['path'] not in DERIVED_PINS:require(d['sha256']==at(e['canonical'],b['field']),'DECLARATION_BINDING',e)
   else:require(d['sha256']==DERIVED_PINS[d['path']],'DECLARATION_DERIVED',e)
   print('DECLARED withheld',d['path'],'private TELOS package is the full check')
 print('PASS census native 31 published 14 withheld 17 summary 1 live_run 2');return 0

def main():
 if len(sys.argv)!=2:
  print(json.dumps({'status':'FAIL','reason':'CLI_ARGUMENTS','chain':'export','row':0},sort_keys=True));return 1
 try:verify(sys.argv[1],public=PUBLIC,standalone=STANDALONE);print('RESULT PASS');return 0
 except Failure as e:report=e.report()
 except json.JSONDecodeError:report={'status':'FAIL','reason':'INVALID_JSON','chain':'export','row':0}
 except OSError:report={'status':'FAIL','reason':'INPUT_UNAVAILABLE','chain':'export','row':0}
 except (ValueError,KeyError,TypeError,IndexError,UnicodeError,zipfile.BadZipFile,EOFError,lzma.LZMAError,zlib.error):report={'status':'FAIL','reason':'INPUT','chain':'export','row':0}
 print(json.dumps(report,sort_keys=True));return 1
if __name__=='__main__':sys.exit(main())
