Something went wrong. Try again.
Architecture research toward an agent-native operating system; rigorous, pre-prototype, and intentionally self-aware.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313"""D-001 bounded node 2: declarative profiles and profile-neutral experiments.
The compiler consumes intent documents plus ProfileSemantics. Runtime executionconsumes only compiled generic actions and D001-Q-2 expressions. Assertions andpredicted vectors are intentionally external to both paths. D-001 remains OPEN."""from __future__ import annotations
import copyimport hashlibimport inspectimport jsonimport unicodedatafrom dataclasses import asdictfrom collections.abc import Mappingfrom typing import Any
try: from decisions import d001_runtime as rtexcept ImportError: import d001_runtime as rt
FIXTURE_ID = "d001-deterministic-fixture-v2"# Independently preregistered below after stdlib canonical-JSON precomputation.E16_VECTOR_IDS = ("malformed","type_mismatch","context_mismatch","unknown","tombstoned","expired","collected","unavailable","resolved","malformed_beats_type","type_beats_context","context_beats_unknown","tombstone_beats_expiry")E16_GOLDENS: dict[str,dict[str,dict[str,str]]] = {'ContentId': {'malformed': {'request_hex': '7b22626164223a317d', 'request_sha256': '97893c9efdcc87bf13082f136f5e972374ec9b554fb01cfc4c6dbb8c3d41e1c2', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': 'd765a7c420e39ad894f82ee5bb1915fe432e91dbfaa5e8ed183931db0f258ea9', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b22436f6e74656e744964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': '2894b9cc246868a741d63a16cfce1bf16a12058bf3ed58bc2fd5764e815471ea', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22554e4b4e4f574e222c2276616c7565223a6e756c6c7d', 'result_sha256': '41b78171d78e66941161b5f335aa0d7d51c3d46afe4fa7d815444f1eba4ba183'}, 'tombstoned': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b22436f6e74656e744964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': '8bf0c15a7a2a0e78010730b3b2807d4e7be15d5049388329e2a9baa43211dc55', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}, 'expired': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b22436f6e74656e744964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': '8bf0c15a7a2a0e78010730b3b2807d4e7be15d5049388329e2a9baa43211dc55', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a2245585049524544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'b5f8003405ca0e4277fbb55b1b1dd6b52920765221873ad12232c77af4e6204d'}, 'collected': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a227061796c6f61642d626f6479222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'a013558039c1cc09bee84079584bfd94a29a0f3f4ea0c1cb746ee4f112302475', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e54454e545f434f4c4c4543544544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'd9d14007664bcbdd01dae4258b46c763194230618004c5bfcaefb35bb4f195cd'}, 'unavailable': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b22436f6e74656e744964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': '6f4da6709551357443e0aeea7fb76dda72dfc3acc46457d2dc251a30c2b64e0f', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22554e415641494c41424c45222c2276616c7565223a6e756c6c7d', 'result_sha256': '62f737f76e47a1466ec806c933c07c72c3e332fa48296cd2cc1e16189ad94efc'}, 'resolved': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a225245534f4c564544222c2276616c7565223a7b22617661696c6162696c697479223a6e756c6c2c2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d7d', 'result_sha256': '5afdd2d970e81481d20cbfaffd27b12da4f6e0e05b930661cb4866d89ac12db4'}, 'malformed_beats_type': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b22417474656d70744964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '37af990ae2145540c42f39445c927cb6cee3da5e4a2026cc3ac6f768a29737ae', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_beats_context': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': 'b52d08b9f7a3da1011829c28013817a85e72a530dfaad55d41e7109bb517d8be', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_beats_unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'deaa954192fded3fe1cc5bcbec84138449875d1c3a20ad0e228943d027bb4d4c', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'tombstone_beats_expiry': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d2c2265787065637465645f7479706573223a5b22436f6e74656e744964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a22436f6e74656e744964227d7d', 'request_sha256': '8bf0c15a7a2a0e78010730b3b2807d4e7be15d5049388329e2a9baa43211dc55', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}}, 'ActorKeyId': {'malformed': {'request_hex': '7b22626164223a317d', 'request_sha256': '97893c9efdcc87bf13082f136f5e972374ec9b554fb01cfc4c6dbb8c3d41e1c2', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': '4a7ba89d19f33e987bec0d8fa511b0e416a7b808b7a54d27317b097d942e1ede', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b224163746f724b65794964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': 'd16188a2db94af1de7325457ac26b599a2155ac7ffb2cd696f06bc5ebc72263b', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22554e4b4e4f574e222c2276616c7565223a6e756c6c7d', 'result_sha256': '41b78171d78e66941161b5f335aa0d7d51c3d46afe4fa7d815444f1eba4ba183'}, 'tombstoned': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b224163746f724b65794964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': 'fa8eec4a95df45364140ccccd08e5a11fa35c06e04e88ffe328d75f9843a7a63', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}, 'expired': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b224163746f724b65794964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': 'fa8eec4a95df45364140ccccd08e5a11fa35c06e04e88ffe328d75f9843a7a63', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a2245585049524544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'b5f8003405ca0e4277fbb55b1b1dd6b52920765221873ad12232c77af4e6204d'}, 'collected': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a227061796c6f61642d626f6479222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'a013558039c1cc09bee84079584bfd94a29a0f3f4ea0c1cb746ee4f112302475', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e54454e545f434f4c4c4543544544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'd9d14007664bcbdd01dae4258b46c763194230618004c5bfcaefb35bb4f195cd'}, 'unavailable': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b224163746f724b65794964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': '7e62afa2b444e2feaf24de14c7fb95a53feb6fa3553229dd0693ab2a7369e598', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22554e415641494c41424c45222c2276616c7565223a6e756c6c7d', 'result_sha256': '99a5b93bfa8fcb5ddf4cc19c731671d2e1a20b03ea1f9606309faa90b56f1e76'}, 'resolved': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a225245534f4c564544222c2276616c7565223a7b22617661696c6162696c697479223a6e756c6c2c2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d7d', 'result_sha256': '5afdd2d970e81481d20cbfaffd27b12da4f6e0e05b930661cb4866d89ac12db4'}, 'malformed_beats_type': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b22417474656d70744964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '37af990ae2145540c42f39445c927cb6cee3da5e4a2026cc3ac6f768a29737ae', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_beats_context': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': '84b986dc81846b302ef71721c56e841fddacfd9f2506b27e7253235ee16d395a', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_beats_unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'b2782ad86a5482facdbc45045bd8761c362e34843f6f5e256ed69d26d83b7db9', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'tombstone_beats_expiry': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d2c2265787065637465645f7479706573223a5b224163746f724b65794964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724b65794964227d7d', 'request_sha256': 'fa8eec4a95df45364140ccccd08e5a11fa35c06e04e88ffe328d75f9843a7a63', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}}, 'ActorId': {'malformed': {'request_hex': '7b22626164223a317d', 'request_sha256': '97893c9efdcc87bf13082f136f5e972374ec9b554fb01cfc4c6dbb8c3d41e1c2', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '70d0777919ebb0c1f903cda078357e5b16f23d2ece55869fa2434440da720ef9', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_mismatch': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b224163746f724964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '5662de20dcf52e494511f39b589c40962944552c974761b593ce76977f50f617', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22554e4b4e4f574e222c2276616c7565223a6e756c6c7d', 'result_sha256': '41b78171d78e66941161b5f335aa0d7d51c3d46afe4fa7d815444f1eba4ba183'}, 'tombstoned': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b224163746f724964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '2bb4ebefb811b134ee5ed8edc75fcdd908d0b7a6366a3e4bfb68596e1bd2e7bb', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}, 'expired': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b224163746f724964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '2bb4ebefb811b134ee5ed8edc75fcdd908d0b7a6366a3e4bfb68596e1bd2e7bb', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a2245585049524544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'b5f8003405ca0e4277fbb55b1b1dd6b52920765221873ad12232c77af4e6204d'}, 'collected': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a227061796c6f61642d626f6479222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'a013558039c1cc09bee84079584bfd94a29a0f3f4ea0c1cb746ee4f112302475', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e54454e545f434f4c4c4543544544222c2276616c7565223a6e756c6c7d', 'result_sha256': 'd9d14007664bcbdd01dae4258b46c763194230618004c5bfcaefb35bb4f195cd'}, 'unavailable': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b224163746f724964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': 'b82f9531fdc3327f6b64079c5f1766b9e97d8f94e4516b0b22626b0c145c38bb', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22554e415641494c41424c45222c2276616c7565223a6e756c6c7d', 'result_sha256': '0c50e19670e8f0e3cc1e0083572a65cab8b133cd90076ba350bbcb6d7d1258ca'}, 'resolved': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '7f3fc7203daf6d82938a8e634ced0c827826a7a26ee444ac07f0dcdfba5e3393', 'result_hex': '7b2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a225245534f4c564544222c2276616c7565223a7b22617661696c6162696c697479223a6e756c6c2c2264656e6f746174696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d7d', 'result_sha256': '5afdd2d970e81481d20cbfaffd27b12da4f6e0e05b930661cb4866d89ac12db4'}, 'malformed_beats_type': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a6e756c6c2c2265787065637465645f7479706573223a5b22417474656d70744964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': '37af990ae2145540c42f39445c927cb6cee3da5e4a2026cc3ac6f768a29737ae', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a224d414c464f524d4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '01f97aedca3003c6b78473da928ee3b748c7d2366c671c2a515c2edc406e9ea2'}, 'type_beats_context': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '8e605304b4d1799752cb6463cac59b5015ebce20a9b775d01048fe866e5f38d9', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22545950455f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': 'acc47ff1e564a1634358c0dc06de92795cba567c2b87c44f1aee844d01707c0f'}, 'context_beats_unknown': {'request_hex': '7b22636c6f636b223a302c22636f6e74657874223a7b2262696e64696e675f6b696e64223a2263757272656e742d6163746f72222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b225061796c6f61644964225d2c226d6f6465223a226578616374222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a225061796c6f61644964227d7d', 'request_sha256': 'fe19aeb110c88e7198a2d18740c7d410fb50e92cc53be07d583122b1838f80b4', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a6e756c6c2c22737461747573223a22434f4e544558545f4d49534d41544348222c2276616c7565223a6e756c6c7d', 'result_sha256': '38723db0619304eb7a4de5589d45506fd821cbe4535a0cbd920408e85a66d858'}, 'tombstone_beats_expiry': {'request_hex': '7b22636c6f636b223a352c22636f6e74657874223a7b2262696e64696e675f6b696e64223a22656e64706f696e742d6f63637570616e74222c2265787065637465645f76616c7565223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c226b6579223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d2c2265787065637465645f7479706573223a5b224163746f724964225d2c226d6f6465223a226c6f6361746f722d63757272656e74222c227265666572656e6365223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224163746f724964227d7d', 'request_sha256': '2bb4ebefb811b134ee5ed8edc75fcdd908d0b7a6366a3e4bfb68596e1bd2e7bb', 'result_hex': '7b2264656e6f746174696f6e5f726566223a6e756c6c2c226d6174636865645f76657273696f6e5f726566223a7b22246b696e64223a22726566222c22686578223a223c7265663e222c2274797065223a224c6f6361746f725265636f72644964227d2c22737461747573223a22544f4d4253544f4e4544222c2276616c7565223a6e756c6c7d', 'result_sha256': '72ad5aaea766e27a7a89a3f524ba18e296bed1c69fee7cd0833ad04831fdefee'}}}PROFILE_IDS = ("C", "K", "L", "H", "V", "O", "S-H", "S-V", "S-O")CASE_IDS = tuple(f"E{i:02d}" for i in range(1, 19))CASE_ROLES = { "E01": ("typed-payload-grounding","exact-successor","exact-predecessor"), "E02": ("equal-content","distinct-attempts","protected-accountable-occurrence"), "E03": ("actor-continuity","all-old-executions-destroyed","persisted-restore"), "E04": ("rotation-actor-continuity","historical-epoch-attribution"), "E05": ("clone-separation","bind-only-no-occurrence","repeat-and-new-subject-semantics"), "E06": ("world-and-root-confinement","branch-commit-operations","branch-attributable-occurrences"), "E07": ("immutable-alias-version","alias-version-chain","exact-alias-resolution"), "E08": ("stable-semantic-target","locator-version-chain","endpoint-reuse-occupancy"), "E09": ("equal-root-context","generation-selection-relations","transition-order-context"), "E10": ("fresh-attempt-identity","stale-dimension-isolation"), "E11": ("restored-protected-state","later-lifecycle-summary","allocation-nonreuse"), "E12": ("protected-occurrence-grounding","copied-claim-nonmatch"), "E13": ("typed-domain-separation","fatal-integrity-atomicity","post-fatal-policy"), "E14": ("frozen-root-pin-provenance","typed-reachability-reasons","deferred-root-isolation"), "E15": ("mark-gated-collection","envelope-body-resolution","verified-body-restoration"), "E16": ("nine-status-order","resolver-precedence","canonical-request-result-vectors"), "E17": ("canonical-equivalence","canonical-distinction","invalid-canonical-rejection"), "E18": ("fresh-store-identity","persisted-section-equivalence","tamper-reconstruction-rejection"),}DEFERRED_LABELS = { "snapshot": "FIXTURE_BINDING_SNAPSHOT", "rotation": "FIXTURE_KEY_EPOCH_ATTRIBUTION", "parallel": "FIXTURE_PARALLEL_CHILDREN", "endpoint": "FIXTURE_ENDPOINT_BINDING", "freshness": "FIXTURE_FRESHNESS_CHECK", "retention": "FIXTURE_RETENTION_EPOCH", "mark_hook": "FIXTURE_MARK_HOOK", "root_snapshot": "FIXTURE_ROOT_SNAPSHOT", "locator": "FIXTURE_LOCATOR_AVAILABILITY", "context": "FIXTURE_CONTEXT_BINDING",}
def _id(kind: str, tag: str, fields=(), domain="") -> rt.IdRule: if kind == "derived": return rt.IdRule(kind, tag, domain, domain + ".schema", fields=tuple(fields), width=32) return rt.IdRule(kind, tag)
def _rr(fields, id_type=None, *, id_field="id", order=None, predecessors=(), projection=None): return rt.RecordRule(fields, id_field=id_field, id_type=id_type, instance_order_field=order, predecessor_fields=tuple(predecessors), projection=projection)
def _profile(name: str) -> rt.ProfileSemantics: family = name[2:] if name.startswith("S-") else name slot = name.startswith("S-") actor_type = "ContentId" if family == "C" else "ActorKeyId" if family == "K" else "ActorId" subject_type = "StateSlotRef" if slot else "ContentId" if family in ("C", "K") else "LogicalStateId" ids = { "AuthorizationEvidenceId": _id("opaque", "AuthorizationEvidenceId"), "CommitmentId": _id("opaque", "CommitmentId"), "AttemptId": _id("opaque", "AttemptId"), "ExecutionId": _id("opaque", "ExecutionId"), "CommitEventId": _id("opaque", "CommitEventId"), "EvidenceId": _id("opaque", "EvidenceId"), "SnapshotId": _id("opaque", "SnapshotId"), "WorldId": _id("opaque", "WorldId"), "GenerationId": _id("opaque", "GenerationId"), "ParentId": _id("opaque", "ParentId"), "PolicyId": _id("opaque", "PolicyId"), "SelectionId": _id("opaque", "SelectionId"), "NamespaceId": _id("opaque", "NamespaceId"), "KeyMaterialId": _id("opaque", "KeyMaterialId"), "KeyEpochId": _id("opaque", "KeyEpochId"), "PinId": _id("opaque", "PinId"), "EndpointId": _id("opaque", "EndpointId"), "AliasRecordId": _id("opaque", "AliasRecordId"), "LocatorRecordId": _id("opaque", "LocatorRecordId"), "PayloadId": _id("derived", "PayloadId", ("schema_ref", "codec_ref", "body_bytes"), "aos.d001.payload.v1"), "PayloadDigest": _id("derived", "PayloadDigest", ("schema_ref", "codec_ref", "body_bytes"), "aos.d001.payload-digest.v1"), "RootValueId": _id("derived", "RootValueId", ("canonical_bindings",), "aos.d001.root-value.v1"), "KeyId": _id("derived", "KeyId", ("algorithm", "public_key_bytes"), "aos.d001.key.v1"), } if family=="K": ids["ContentCreationId"]=_id("opaque","ContentCreationId") for tag in (actor_type, subject_type): if tag == "StateSlotRef": continue if tag not in ids: kind = "derived" if tag in ("ContentId", "ActorKeyId") else "opaque" fields = ("type_tag", "canonical_bytes") if tag == "ContentId" else ("genesis_public_key",) if tag == "ActorKeyId" else () ids[tag] = _id(kind, tag, fields, "aos.d001." + tag.lower() + ".v1") if slot: ids["ActorId"] = ids.get("ActorId", _id("opaque", "ActorId")) state_types: set[str] = set() if family == "H": ids["OpaqueRevisionId"] = _id("opaque", "OpaqueRevisionId"); state_types |= {"OpaqueRevisionId", "AttemptId"} elif family == "V": ids["RevisionValueId"] = _id("derived", "RevisionValueId", ("subject_or_slot_ref", "payload_ref", "tombstone"), "aos.d001.revision-value.v1") ids["OccurrenceId"] = _id("derived", "OccurrenceId", ("revision_value_ref", "predecessor_occurrence_refs", "actor_ref", "commitment_ref", "causal_inputs", "attempt_ref"), "aos.d001.occurrence.v1") state_types |= {"RevisionValueId", "OccurrenceId"} elif family == "O": ids["RevisionId"] = _id("derived", "RevisionId", ("subject_or_slot_ref", "payload_ref", "predecessor_revision_refs", "actor_ref", "commitment_ref", "causal_inputs", "attempt_ref", "tombstone"), "aos.d001.revision-occurrence.v1") state_types.add("RevisionId") elif family == "L": state_types.add("LogicalStateId") elif family in ("C", "K"): state_types |= {"ContentId", "AttemptId"} if family == "K" else {"ContentId"}
unions = { "ActorRef": frozenset({actor_type}), "SubjectRef": frozenset({subject_type}), "StateRef": frozenset(state_types), "SemanticRef": frozenset(set(ids) | ({"StateSlotRef"} if slot else set())), } actor_fields={"id":{"ref":actor_type}, "descriptor":"text", "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}} if actor_type=="ContentId": actor_fields.update(type_tag="text",canonical_bytes="bytes") if actor_type=="ActorKeyId": actor_fields.update(genesis_public_key="bytes") records = { "ActorGenesis": _rr(actor_fields, actor_type), "AuthorizationEvidence": _rr({"id":{"ref":"AuthorizationEvidenceId"}, "evidence_bytes":"bytes", "scheme":"text"}, "AuthorizationEvidenceId"), "Commitment": _rr({"id":{"ref":"CommitmentId"}, "actor_ref":{"ref":"ActorRef"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, "CommitmentId"), "Attempt": _rr({"id":{"ref":"AttemptId"}, "nonce":"text", "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "parent_ref":{"ref":"ParentId"}, "policy_ref":{"ref":"PolicyId"}, "evidence_ref":{"ref":"EvidenceId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, "AttemptId"), "Execution": _rr({"id":{"ref":"ExecutionId"}, "actor_ref":{"ref":"ActorRef"}, "activation_nonce":"text"}, "ExecutionId"), "CommitEvent": _rr({"id":{"ref":"CommitEventId"}, "world_ref":{"ref":"WorldId"}, "result_ref":{"ref":"StateRef"}, "root_ref":{"ref":"RootValueId"}, "attempt_ref":{"ref":"AttemptId"}, "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, "CommitEventId"), "Evidence": _rr({"id":{"ref":"EvidenceId"}, "label":"text"}, "EvidenceId"), "Parent": _rr({"id":{"ref":"ParentId"}, "label":"text"}, "ParentId"), "Policy": _rr({"id":{"ref":"PolicyId"}, "label":"text"}, "PolicyId"), "World": _rr({"id":{"ref":"WorldId"}, "parent_world_ref":{"optional":{"ref":"WorldId"}}, "nonce":"text"}, "WorldId"), "Generation": _rr({"id":{"ref":"GenerationId"}, "world_ref":{"ref":"WorldId"}, "root_ref":{"ref":"RootValueId"}, "parent_ref":{"ref":"ParentId"}, "predecessor_generation_ref":{"optional":{"ref":"GenerationId"}}, "transition_order":"uint64"}, "GenerationId", order="transition_order", predecessors=("predecessor_generation_ref",)), "Selection": _rr({"id":{"ref":"SelectionId"}, "world_ref":{"ref":"WorldId"}, "root_ref":{"ref":"RootValueId"}, "generation_ref":{"ref":"GenerationId"}, "parent_ref":{"ref":"ParentId"}, "policy_ref":{"ref":"PolicyId"}, "predecessor_selection_ref":{"optional":{"ref":"SelectionId"}}, "nonce":"text", "kind":"text", "transition_order":"uint64"}, "SelectionId", order="transition_order", predecessors=("predecessor_selection_ref",)), "Namespace": _rr({"id":{"ref":"NamespaceId"}, "name":"text"}, "NamespaceId"), "KeyMaterial": _rr({"id":{"ref":"KeyMaterialId"}, "algorithm":"text", "public_key_bytes":"bytes"}, "KeyMaterialId"), "Key": _rr({"id":{"ref":"KeyId"}, "algorithm":"text", "public_key_bytes":"bytes"}, "KeyId"), "KeyEpoch": _rr({"id":{"ref":"KeyEpochId"}, "key_ref":{"ref":"KeyId"}, "actor_ref":{"ref":"ActorRef"}, "epoch":"uint64", "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, "KeyEpochId"), "PayloadEnvelope": _rr({"id":{"ref":"PayloadId"}, "schema_ref":"text", "codec_ref":"text", "body_bytes":"bytes", "body_digest":"digest32", "body_length":"uint64"}, "PayloadId"), "PayloadDigestRecord": _rr({"id":{"ref":"PayloadDigest"}, "schema_ref":"text", "codec_ref":"text", "body_bytes":"bytes"}, "PayloadDigest"), "PayloadBody": _rr({"envelope_ref":{"ref":"PayloadId"}, "body":"bytes"}, id_field=None), "RootValue": _rr({"id":{"ref":"RootValueId"}, "canonical_bindings":"any"}, "RootValueId"), "AliasVersion": _rr({"id":{"ref":"AliasRecordId"}, "namespace_ref":{"ref":"NamespaceId"}, "label":"text", "target_ref":{"optional":{"ref":"SemanticRef"}}, "predecessor_ref":{"optional":{"ref":"AliasRecordId"}}, "tombstone":"bool", "expires_at":{"optional":"uint64"}, "instance_order":"uint64"}, "AliasRecordId", order="instance_order", predecessors=("predecessor_ref",)), "LocatorVersion": _rr({"id":{"ref":"LocatorRecordId"}, "target_ref":{"ref":"SemanticRef"}, "endpoint":"text", "available":"bool", "tombstone":"bool", "expires_at":{"optional":"uint64"}, "predecessor_ref":{"optional":{"ref":"LocatorRecordId"}}, "instance_order":"uint64"}, "LocatorRecordId", order="instance_order", predecessors=("predecessor_ref",)), "Lifecycle": _rr({"target_ref":{"ref":"SemanticRef"}, "state":"text", "tombstone":"bool", "expires_at":{"optional":"uint64"}, "instance_order":"uint64"}, id_field=None, order="instance_order", projection="lifecycle"), "Snapshot": _rr({"id":{"ref":"SnapshotId"}, "label":"text"}, "SnapshotId"), "Pin": _rr({"id":{"ref":"PinId"}, "target_ref":{"ref":"SemanticRef"}, "expires_at":"uint64", "active":"bool"}, "PinId"), } if subject_type not in ("ContentId", "StateSlotRef"): records["Subject"] = _rr({"id":{"ref":subject_type}, "kind":"text", "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, subject_type) if slot: records["SlotDefinition"] = _rr({"slot":"slot", "owner_actor_ref":{"ref":"ActorRef"}, "slot_type":"text", "slot_name":"text", "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}}, id_field="slot") if family == "C": records["ContentState"] = _rr({"id":{"ref":"ContentId"}, "type_tag":"text", "canonical_bytes":"bytes"}, "ContentId") elif family == "K": records["ContentState"] = _rr({"id":{"ref":"ContentId"}, "type_tag":"text", "canonical_bytes":"bytes"}, "ContentId") records["ContentCreation"] = _rr({"id":{"ref":"ContentCreationId"}, "content_ref":{"ref":"ContentId"}, "predecessor_creation_ref":{"optional":{"ref":"ContentCreationId"}}, "attempt_ref":{"ref":"AttemptId"}, "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}, "causal_inputs":{"array":{"ref":"ContentCreationId"}}, "instance_order":"uint64"}, "ContentCreationId", order="instance_order", predecessors=("predecessor_creation_ref",)) elif family == "L": records["MutableState"] = _rr({"subject_ref":{"ref":"SubjectRef"}, "payload_ref":{"ref":"PayloadId"}, "counter":"uint64"}, id_field=None) elif family == "H": records["OpaqueRevision"] = _rr({"id":{"ref":"OpaqueRevisionId"}, "subject_or_slot_ref":"slot" if slot else {"ref":"SubjectRef"}, "payload_ref":{"ref":"PayloadId"}, "predecessor_refs":{"array":{"ref":"OpaqueRevisionId"}}, "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "attempt_ref":{"ref":"AttemptId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}, "tombstone":"bool", "instance_order":"uint64"}, "OpaqueRevisionId", order="instance_order", predecessors=("predecessor_refs",)) elif family == "V": records["RevisionValue"] = _rr({"id":{"ref":"RevisionValueId"}, "subject_or_slot_ref":"slot" if slot else {"ref":"SubjectRef"}, "payload_ref":{"ref":"PayloadId"}, "tombstone":"bool"}, "RevisionValueId") records["Occurrence"] = _rr({"id":{"ref":"OccurrenceId"}, "revision_value_ref":{"ref":"RevisionValueId"}, "predecessor_occurrence_refs":{"array":{"ref":"OccurrenceId"}}, "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "causal_inputs":{"array":{"ref":"OccurrenceId"}}, "attempt_ref":{"ref":"AttemptId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}, "instance_order":"uint64"}, "OccurrenceId", order="instance_order", predecessors=("predecessor_occurrence_refs",)) elif family == "O": records["RevisionOccurrence"] = _rr({"id":{"ref":"RevisionId"}, "subject_or_slot_ref":"slot" if slot else {"ref":"SubjectRef"}, "payload_ref":{"ref":"PayloadId"}, "predecessor_revision_refs":{"array":{"ref":"RevisionId"}}, "actor_ref":{"ref":"ActorRef"}, "commitment_ref":{"ref":"CommitmentId"}, "causal_inputs":{"array":{"ref":"RevisionId"}}, "attempt_ref":{"ref":"AttemptId"}, "authorization_evidence_ref":{"ref":"AuthorizationEvidenceId"}, "tombstone":"bool", "instance_order":"uint64"}, "RevisionId", order="instance_order", predecessors=("predecessor_revision_refs",))
edges = { "predecessor-revision": rt.EdgeRule(frozenset(state_types), frozenset(state_types), "audit-summary"), "occurrence-value": rt.EdgeRule(frozenset({"OccurrenceId"}) if "OccurrenceId" in ids else frozenset(state_types), frozenset({"RevisionValueId"}) if "RevisionValueId" in ids else frozenset(state_types), "identity-strong"), "subject-state": rt.EdgeRule(frozenset({subject_type}), frozenset(state_types), "identity-strong"), "world-root": rt.EdgeRule(frozenset({"WorldId"}), frozenset({"RootValueId"}), "identity-strong"), "root-state": rt.EdgeRule(frozenset({"RootValueId"}), frozenset(state_types | ({"AttemptId"} if family=="L" else set())), "identity-strong"), "state-payload": rt.EdgeRule(frozenset(state_types | ({"AttemptId"} if family=="L" else set())), frozenset({"PayloadId"}), "body-retaining"), "accountable-actor": rt.EdgeRule(frozenset(state_types | {"AttemptId"}), frozenset({actor_type}), "audit-summary"), "payload-body": rt.EdgeRule(frozenset({"PayloadId"}), frozenset({"PayloadId"}), "body-retaining"), "audit-target": rt.EdgeRule(frozenset({"EvidenceId"}), frozenset(set(ids)), "audit-summary"), "attempt-key-epoch": rt.EdgeRule(frozenset({"AttemptId"}), frozenset({"KeyEpochId"}), "audit-summary"), "epoch-key": rt.EdgeRule(frozenset({"KeyEpochId"}), frozenset({"KeyId"}), "audit-summary"), "protected-state-attempt": rt.EdgeRule(frozenset(state_types | ({"AttemptId"} if family=="L" else set())), frozenset({"AttemptId"}), "audit-summary"), "commit-world": rt.EdgeRule(frozenset({"CommitEventId"}), frozenset({"WorldId"}), "identity-strong"), "commit-attempt": rt.EdgeRule(frozenset({"CommitEventId"}), frozenset({"AttemptId"}), "audit-summary"), "commit-result": rt.EdgeRule(frozenset({"CommitEventId"}), frozenset(state_types), "identity-strong"), "commit-root": rt.EdgeRule(frozenset({"CommitEventId"}), frozenset({"RootValueId"}), "identity-strong"), "selection-generation": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"GenerationId"}), "identity-strong"), "selection-world": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"WorldId"}), "identity-strong"), "selection-root": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"RootValueId"}), "identity-strong"), "selection-parent": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"ParentId"}), "audit-summary"), "selection-policy": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"PolicyId"}), "audit-summary"), "generation-world": rt.EdgeRule(frozenset({"GenerationId"}), frozenset({"WorldId"}), "identity-strong"), "generation-root": rt.EdgeRule(frozenset({"GenerationId"}), frozenset({"RootValueId"}), "identity-strong"), "generation-parent": rt.EdgeRule(frozenset({"GenerationId"}), frozenset({"ParentId"}), "audit-summary"), "generation-predecessor": rt.EdgeRule(frozenset({"GenerationId"}), frozenset({"GenerationId"}), "audit-summary"), "selection-predecessor": rt.EdgeRule(frozenset({"SelectionId"}), frozenset({"SelectionId"}), "audit-summary"), } if family=="K": edges["creation-content"] = rt.EdgeRule(frozenset({"ContentCreationId"}), frozenset({"ContentId"}), "identity-strong") edges["creation-attempt"] = rt.EdgeRule(frozenset({"ContentCreationId"}), frozenset({"AttemptId"}), "audit-summary") edges["creation-predecessor"] = rt.EdgeRule(frozenset({"ContentCreationId"}), frozenset({"ContentCreationId"}), "audit-summary") unavailable=set() if family=="L": unavailable|={"E01:exact-predecessor","E02:protected-accountable-occurrence","E04:historical-epoch-attribution"} if family=="C": unavailable|={"E01:exact-predecessor","E02:protected-accountable-occurrence","E04:historical-epoch-attribution","E05:clone-separation"} if family=="K": unavailable|={"E04:rotation-actor-continuity","E05:clone-separation"} if family in ("C","L"): unavailable|={"E12:protected-occurrence-grounding"} machinery={ "exact-predecessor": "predecessor field plus predecessor-revision edge", "protected-accountable-occurrence": {"C":"none","L":"none","K":"ContentCreation plus creation-attempt edge","H":"OpaqueRevision.attempt_ref","V":"Occurrence.attempt_ref","O":"RevisionOccurrence.attempt_ref"}[family], "actor-continuity": "current-actor persisted binding and ActorGenesis identity", "rotation-actor-continuity": "KeyEpoch.actor_ref equality", "historical-epoch-attribution": {"C":"no protected historical state-to-Attempt relation","L":"no protected historical state-to-Attempt relation","K":"ContentCreation.attempt_ref plus creation-attempt edge","H":"OpaqueRevision.attempt_ref plus protected-state-attempt edge","V":"Occurrence.attempt_ref plus protected-state-attempt edge","O":"RevisionOccurrence.attempt_ref plus protected-state-attempt edge"}[family], "clone-separation": "ActorGenesis typed identity inequality", "branch-attributable-occurrences": "CommitEvent direct world/attempt/result refs plus protected occurrence machinery", "protected-occurrence-grounding": {"C":"no declared ProvenanceRole; exact verifier result UNSUPPORTED","L":"no declared ProvenanceRole; exact verifier result UNSUPPORTED","K":"ContentCreation ProvenanceRole with grounded causal_inputs","H":"OpaqueRevision ProvenanceRole without causal array","V":"Occurrence ProvenanceRole with grounded causal_inputs","O":"RevisionOccurrence ProvenanceRole with grounded causal_inputs"}[family], } role_mappings={case:{role:{"status":"UNAVAILABLE" if case+":"+role in unavailable else "IMPLEMENTED","machinery":machinery.get(role,"direct persisted record, edge, binding, or trace query")} for role in roles} for case,roles in CASE_ROLES.items()} recipe = { "family": family, "slot": slot, "actor_type": actor_type, "subject_type": subject_type, "kind": {"C":"coalesced-content", "K":"coalesced-content-attempt", "L":"mutable-cell", "H":"opaque-revision", "V":"value-plus-occurrence", "O":"occurrence-revision"}[family], "state_types": sorted(state_types), "deferred_labels": DEFERRED_LABELS, "state_record_type": {"C":"ContentState", "K":"ContentState", "L":"MutableState", "H":"OpaqueRevision", "V":"Occurrence", "O":"RevisionOccurrence"}[family], "state_ref_field": {"C":"id", "K":"id", "L":"subject_ref", "H":"id", "V":"id", "O":"id"}[family], "payload_field": {"C":"canonical_bytes", "K":"canonical_bytes", "L":"payload_ref", "H":"payload_ref", "V":"revision_value_ref", "O":"payload_ref"}[family], "predecessor_field": {"C":None, "K":None, "L":None, "H":"predecessor_refs", "V":"predecessor_occurrence_refs", "O":"predecessor_revision_refs"}[family], "provenance_record_type": {"C":None, "K":"ContentCreation", "L":None, "H":"OpaqueRevision", "V":"Occurrence", "O":"RevisionOccurrence"}[family], "profile_contract_stage": "candidate-pre-freeze-amendment" if family=="K" else "packet-profile-contract", "candidate_amendment": ({"version":"K-content-creation-v1","status":"candidate-pre-freeze","legacy_generator_integrated":False, "record":{"name":"ContentCreation","id_type":"ContentCreationId","fields":[ {"name":"id","descriptor":{"ref":"ContentCreationId"}},{"name":"content_ref","descriptor":{"ref":"ContentId"}}, {"name":"predecessor_creation_ref","descriptor":{"optional":{"ref":"ContentCreationId"}}},{"name":"attempt_ref","descriptor":{"ref":"AttemptId"}}, {"name":"actor_ref","descriptor":{"ref":"ActorRef"}},{"name":"commitment_ref","descriptor":{"ref":"CommitmentId"}}, {"name":"authorization_evidence_ref","descriptor":{"ref":"AuthorizationEvidenceId"}},{"name":"causal_inputs","descriptor":{"array":{"ref":"ContentCreationId"}}},{"name":"instance_order","descriptor":"uint64"}], "id_validation":{"kind":"opaque","allocation":"ContentCreationId ledger","nonreuse":True},"instance_order_validation":"strictly greater than predecessor","predecessor_validation":"existing ContentCreation with lower instance_order","causal_validation":"each ContentCreationId resolves to one authoritative ContentCreation"}, "edges":[{"kind":"creation-content","from":"ContentCreationId","to":"ContentId","retention_class":"identity-strong"},{"kind":"creation-attempt","from":"ContentCreationId","to":"AttemptId","retention_class":"audit-summary"},{"kind":"creation-predecessor","from":"ContentCreationId","to":"ContentCreationId","retention_class":"audit-summary"}], "counts":{"record_types":1,"id_types":1,"edge_types":3,"record_fields":9,"ordered_record_types":1,"predecessor_fields":1,"causal_fields":1,"allocation_ledgers":1,"record_instances_per_creation":1,"index_entries_per_creation":0,"edges_per_creation":{"minimum":2,"with_predecessor":3}}, "complexity":{"record_insert":"one record plus allocation/nonreuse and causal grounding validation","predecessor_check":"one exact typed record lookup and order comparison","causal_check":"one authoritative typed record lookup per causal input","edge_insert":"two mandatory edges plus one predecessor edge when present","index_contribution":"none"}, "freeze_blocker":"node-20 must reconcile role/schema JSON and exact complexity inputs"} if family=="K" else None), "role_mappings": role_mappings, "historical_attribution_obligation": ({"status":"unavailable-required-failure","scope":"E04 only","requirement":"this profile exposes no protected historical state occurrence/creation directly linked to Attempt.id; E04 is preregistered FAIL and the fixture does not manufacture one"} if family in ("C","L") else None), } provenance_roles=[] provenance_args=(tuple(sorted(unions["ActorRef"])),("CommitmentId",),("AuthorizationEvidenceId",),("ActorGenesis",),("Commitment",),("AuthorizationEvidence",)) if family=="K": provenance_roles.append(rt.ProvenanceRole("ContentCreation","ContentCreationId","actor_ref","commitment_ref","authorization_evidence_ref","causal_inputs",*provenance_args,("ContentCreationId",),("ContentCreation",))) elif family=="H": provenance_roles.append(rt.ProvenanceRole("OpaqueRevision","OpaqueRevisionId","actor_ref","commitment_ref","authorization_evidence_ref",None,*provenance_args,(),())) elif family=="V": provenance_roles.append(rt.ProvenanceRole("Occurrence","OccurrenceId","actor_ref","commitment_ref","authorization_evidence_ref","causal_inputs",*provenance_args,("OccurrenceId",),("Occurrence",))) elif family=="O": provenance_roles.append(rt.ProvenanceRole("RevisionOccurrence","RevisionId","actor_ref","commitment_ref","authorization_evidence_ref","causal_inputs",*provenance_args,("RevisionId",),("RevisionOccurrence",))) return rt.ProfileSemantics(name, FIXTURE_ID, ids, records, edges, unions=unions, binding_kinds=frozenset({"current-actor","active-executions","state-head","context-state","current-generation","endpoint-occupant","fixture-root-policy","freshness-context"}), state_recipe=recipe, projections={"lifecycle":{"kind":"lifecycle","target_field":"target_ref","state_field":"state","tombstone_field":"tombstone","expires_field":"expires_at"}}, provenance_types=frozenset(state_types | ({"ContentCreationId"} if family == "K" else set())), availability_role=rt.AvailabilityRole("PayloadEnvelope","PayloadId","PayloadBody","envelope_ref","body","body_digest","body_length","body_bytes"), pin_role=rt.PinRole("Pin","PinId","target_ref","active","expires_at"), versioned_reference_roles=(rt.VersionedReferenceRole("AliasVersion","AliasRecordId","namespace_ref","label","target_ref","predecessor_ref","instance_order","tombstone","expires_at",("NamespaceId",),tuple(sorted(unions["SemanticRef"]))),), provenance_roles=tuple(provenance_roles), typed_content_role=(rt.TypedContentRole("ContentId","SubjectRef","PayloadId","derived",32,"CVE1",1,("type_tag","canonical_bytes"),"NFC-text","bytes","state",ids["ContentId"].domain,ids["ContentId"].schema,("subject_ref","payload_ref"),"canonical-json-utf8",("ref","canonical_bytes","preimage_hex","subject_ref","payload_ref")) if family in ("C","K") else None))
PROFILES = {name: _profile(name) for name in PROFILE_IDS}
def _ref(profile: rt.ProfileSemantics, tag: str, symbol: str, domain="fixture") -> dict[str, Any]: rule = profile.id_rules[tag] if rule.kind != "opaque": raise ValueError("opaque ref required") raw = hashlib.sha256((profile.fixture_id+"/"+profile.name+"/"+domain+"/"+symbol).encode()).digest()[:rule.width] return {"$kind":"ref","type":tag,"hex":raw.hex()}
def _derived(profile, tag, fields): value, _ = rt._derive(profile.id_rules[tag], fields) return value
def _zero(profile, tag): return {"$kind":"ref","type":tag,"hex":"00"*profile.id_rules[tag].width}def _lit(value): return {"op":"literal","value":copy.deepcopy(value)}def _ep(source, value=None): return {"source":source,"value":value}def _action(step, op, args, fault=None): return {"action_version":"D001-ACTION-3","step_id":step,"op":op,"args":args,"fault":fault}def _opaque(rt_name, tag, symbol, fields, out=None, edges=(), domain="fixture"): return {"record_type":rt_name,"fields":fields,"id":{"kind":"opaque","id_type":tag,"domain_id":domain,"symbol":symbol},"edges":list(edges),"out_ref":out}def _derived_args(rt_name, tag, fields, out=None, edges=()): return {"record_type":rt_name,"fields":fields,"id":{"kind":"derived","id_type":tag},"edges":list(edges),"out_ref":out}def _keyed(rt_name, key, fields, out=None): return {"record_type":rt_name,"fields":fields,"id":{"kind":"keyed","key":key},"edges":[],"out_ref":out}def _edge(kind, fr, to): return {"kind":kind,"from":fr,"to":to}
class Compiler: """Generic intent compiler. Handler selection is by intent opcode, never metadata.""" def __init__(self, profile: rt.ProfileSemantics): self.p=profile; self.family=profile.state_recipe["family"]; self.slot=profile.state_recipe["slot"] self.refs={}; self.actions=[]; self.queries=[]; self.counter=0; self.orders={} def step(self, label): self.counter+=1; return f"s{self.counter:03d}.{label}" def emit(self, op,args,fault=None,meta=None): action=_action(self.step(op),op,args,fault) action["action_meta"]=copy.deepcopy(meta or getattr(self,"current_meta",None) or {"setup_only":"compiler-generated dependency record"}) self.actions.append(action) self.last_step=action["step_id"] def opaque(self,name,record,tag,fields,edges=None): self.refs[name]=_ref(self.p,tag,name); self.emit("record.put",_opaque(record,tag,name,fields,name,edges or ())) def evidence(self,c): name=c["name"]; self.opaque(name,"AuthorizationEvidence","AuthorizationEvidenceId",{"id":_zero(self.p,"AuthorizationEvidenceId"),"evidence_bytes":rt.bytes_value(name.encode()),"scheme":"fixture"}) def actor(self,c): name=c["name"]; ev=self.refs[c.get("evidence","auth")]; descriptor=c.get("descriptor",name); identity_symbol=c.get("identity_symbol",name) tag=self.p.state_recipe["actor_type"] if tag=="ActorId": self.refs[name]=_ref(self.p,tag,identity_symbol); args=_opaque("ActorGenesis",tag,identity_symbol,{"id":_zero(self.p,tag),"descriptor":descriptor,"authorization_evidence_ref":ev},name) elif tag=="ActorKeyId": fields={"id":_zero(self.p,tag),"genesis_public_key":rt.bytes_value(c.get("genesis_key","K1").encode()),"descriptor":descriptor,"authorization_evidence_ref":ev} # ActorKeyId identity consumes only genesis_public_key; record carries descriptor too. args=_derived_args("ActorGenesis",tag,fields,name); self.refs[name]=_derived(self.p,tag,{"genesis_public_key":fields["genesis_public_key"]}) else: fields={"id":_zero(self.p,tag),"type_tag":"actor","canonical_bytes":rt.bytes_value(descriptor.encode()),"descriptor":descriptor,"authorization_evidence_ref":ev} # ActorGenesis schema lacks preimage fields, so use ContentState as identity carrier then bind current actor. args=_derived_args("ActorGenesis",tag,fields,name); self.refs[name]=_derived(self.p,tag,{"type_tag":"actor","canonical_bytes":fields["canonical_bytes"]}) reused=any(v==self.refs[name] for k,v in self.refs.items() if k!=name and not k.endswith((".$record",".value",".value.$record"))) if not c.get("reference_only",False) and not reused: self.emit("record.put",args) def simple(self,c): intent=c["intent"] static={"evidence-record":("Evidence","EvidenceId","label"),"parent":("Parent","ParentId","label"),"policy":("Policy","PolicyId","label"),"namespace":("Namespace","NamespaceId","name")} if intent in static: rec,tag,field=static[intent]; fields={"id":_zero(self.p,tag),field:c.get("label",c["name"])} elif intent=="commitment": rec,tag="Commitment","CommitmentId"; fields={"id":_zero(self.p,tag),"actor_ref":self.refs[c["actor"]],"authorization_evidence_ref":self.refs[c.get("evidence","auth")]} elif intent=="execution": rec,tag="Execution","ExecutionId"; fields={"id":_zero(self.p,tag),"actor_ref":self.refs[c["actor"]],"activation_nonce":c.get("nonce",c["name"])} else: rec,tag="World","WorldId"; fields={"id":_zero(self.p,tag),"parent_world_ref":self.refs.get(c.get("parent")),"nonce":c.get("nonce",c["name"])} self.opaque(c["name"],rec,tag,fields) def payload(self,c): body=c.get("body",c["name"]).encode(); tag=c.get("id_type","PayloadId"); rec="PayloadEnvelope" if tag=="PayloadId" else "PayloadDigestRecord" fields={"id":_zero(self.p,tag),"schema_ref":c.get("schema","aos.fixture.scalar.v1"),"codec_ref":c.get("codec","CVE1"),"body_bytes":rt.bytes_value(body)} if tag=="PayloadId": fields.update(body_digest=rt.bytes_value(hashlib.sha256(body).digest(),"digest32"),body_length=len(body)) self.refs[c["name"]]=_derived(self.p,tag,{k:fields[k] for k in self.p.id_rules[tag].fields}) if c.get("fault",{}).get("kind")=="HASH_RESULT_OVERRIDE": self.refs[c["name"]]["hex"]={"$override_hex":copy.deepcopy(c["fault"]["raw_digest_hex"])} edges=[] for edge in c.get("edges",[]): edges.append(_edge(edge["kind"],_ep(edge.get("from_source","self"),self.refs.get(edge.get("from"))),_ep(edge.get("to_source","literal"),self.refs.get(edge.get("to"))))) self.emit("record.put",_derived_args(rec,tag,fields,c["name"],edges),fault=c.get("fault")) def subject(self,c): name=c["name"]; tag=self.p.state_recipe["subject_type"]; ev=self.refs[c.get("evidence","auth")] if self.slot: slot={"$kind":"slot","owner_actor_ref":self.refs[c["owner"]],"slot_type":c.get("slot_type","state"),"slot_name":c.get("slot_name",name)} self.refs[name]=slot; self.emit("record.put",{"record_type":"SlotDefinition","fields":{"slot":slot,"owner_actor_ref":self.refs[c["owner"]],"slot_type":slot["slot_type"],"slot_name":slot["slot_name"],"authorization_evidence_ref":ev},"id":{"kind":"structural","field":"slot"},"edges":[],"out_ref":name}) elif tag=="LogicalStateId": self.opaque(name,"Subject",tag,{"id":_zero(self.p,tag),"kind":"state","authorization_evidence_ref":ev}) else: # C/K subject identity is content-derived and represented by ContentState. raw=rt.bytes_value(c.get("descriptor",name).encode()); fields={"id":_zero(self.p,tag),"type_tag":"subject","canonical_bytes":raw} self.refs[name]=_derived(self.p,tag,{"type_tag":"subject","canonical_bytes":raw}); self.emit("record.put",_derived_args("ContentState",tag,fields,name)) def attempt(self,c): self.opaque(c["name"],"Attempt","AttemptId",{"id":_zero(self.p,"AttemptId"),"nonce":c.get("nonce",c["name"]),"actor_ref":self.refs[c["actor"]],"commitment_ref":self.refs[c["commitment"]],"parent_ref":self.refs[c["parent"]],"policy_ref":self.refs[c["policy"]],"evidence_ref":self.refs[c["evidence_record"]],"authorization_evidence_ref":self.refs[c.get("evidence","auth")]}) def state(self,c): name=c["name"]; subject=self.refs[c["subject"]]; payload=self.refs[c["payload"]]; actor=self.refs[c["actor"]]; commit=self.refs[c["commitment"]]; auth=self.refs[c.get("evidence","auth")] pred=self.refs.get(c.get("predecessor")); order=self.orders.get("state",0)+1; self.orders["state"]=order edges=[] if self.family in ("C","K"): canonical={"subject_ref":subject,"payload_ref":payload}; raw=rt.bytes_value(rt.canonical_json(canonical)); fields={"id":_zero(self.p,"ContentId"),"type_tag":"state","canonical_bytes":raw}; ref=_derived(self.p,"ContentId",{"type_tag":"state","canonical_bytes":raw}); args=_derived_args("ContentState","ContentId",fields,name) elif self.family=="L" and c.get("accountable_identity"): ref=_ref(self.p,"AttemptId",name); fields={"id":_zero(self.p,"AttemptId"),"nonce":"accountable-state-"+name,"actor_ref":actor,"commitment_ref":commit,"parent_ref":self.refs["parent"],"policy_ref":self.refs["policy"],"evidence_ref":self.refs["er"],"authorization_evidence_ref":auth}; args=_opaque("Attempt","AttemptId",name,fields,name) elif self.family=="L": ref=subject; fields={"subject_ref":subject,"payload_ref":payload,"counter":order}; args=_keyed("MutableState",{"subject":subject,"counter":order},fields,name) elif self.family=="H": ref=_ref(self.p,"OpaqueRevisionId",name); fields={"id":_zero(self.p,"OpaqueRevisionId"),"subject_or_slot_ref":subject,"payload_ref":payload,"predecessor_refs":[] if pred is None else [pred],"actor_ref":actor,"commitment_ref":commit,"attempt_ref":self.refs[c["attempt"]],"authorization_evidence_ref":auth,"tombstone":c.get("tombstone",False),"instance_order":order}; edges=[_edge("protected-state-attempt",_ep("self"),_ep("field","attempt_ref"))] if pred: edges.append(_edge("predecessor-revision",_ep("self"),_ep("literal",pred))) args=_opaque("OpaqueRevision","OpaqueRevisionId",name,fields,name,edges) elif self.family=="V": vf={"id":_zero(self.p,"RevisionValueId"),"subject_or_slot_ref":subject,"payload_ref":payload,"tombstone":c.get("tombstone",False)}; value=_derived(self.p,"RevisionValueId",{k:vf[k] for k in self.p.id_rules["RevisionValueId"].fields}) if not any(v==value for k,v in self.refs.items() if k.endswith(".value")): self.emit("record.put",_derived_args("RevisionValue","RevisionValueId",vf,name+".value")) self.refs[name+".value"]=value of={"id":_zero(self.p,"OccurrenceId"),"revision_value_ref":value,"predecessor_occurrence_refs":[] if pred is None else [pred],"actor_ref":actor,"commitment_ref":commit,"causal_inputs":[],"attempt_ref":self.refs[c["attempt"]],"authorization_evidence_ref":auth,"instance_order":order} ref=_derived(self.p,"OccurrenceId",{k:of[k] for k in self.p.id_rules["OccurrenceId"].fields}); edges=[_edge("occurrence-value",_ep("self"),_ep("field","revision_value_ref")),_edge("protected-state-attempt",_ep("self"),_ep("field","attempt_ref"))] if pred: edges.append(_edge("predecessor-revision",_ep("self"),_ep("literal",pred))) args=_derived_args("Occurrence","OccurrenceId",of,name,edges) else: rf={"id":_zero(self.p,"RevisionId"),"subject_or_slot_ref":subject,"payload_ref":payload,"predecessor_revision_refs":[] if pred is None else [pred],"actor_ref":actor,"commitment_ref":commit,"causal_inputs":[],"attempt_ref":self.refs[c["attempt"]],"authorization_evidence_ref":auth,"tombstone":c.get("tombstone",False),"instance_order":order} ref=_derived(self.p,"RevisionId",{k:rf[k] for k in self.p.id_rules["RevisionId"].fields}); edges=[_edge("protected-state-attempt",_ep("self"),_ep("field","attempt_ref"))] if pred: edges.append(_edge("predecessor-revision",_ep("self"),_ep("literal",pred))) args=_derived_args("RevisionOccurrence","RevisionId",rf,name,edges) for edge in c.get("edges",[]): edges.append(_edge(edge["kind"],_ep("self") if self.family=="L" and c.get("accountable_identity") and edge.get("from_source","self")=="self" else _ep(edge.get("from_source","self"),self.refs.get(edge.get("from"))),_ep(edge.get("to_source","literal"),self.refs.get(edge.get("to"))))) if c.get("edges"): args["edges"].extend(edges) coalesced=self.family in ("C","K") and any(v==ref for k,v in self.refs.items() if not k.endswith((".$record",".value",".value.$record"))) self.refs[name]=ref self.refs.setdefault(name+".value",ref) self.refs[name+".$record"]=copy.deepcopy(args["id"].get("key",ref)) self.refs[name+".value.$record"]=copy.deepcopy(value if self.family=="V" else args["id"].get("key",ref)) if not coalesced: self.emit("record.put",args,fault=c.get("fault")) if self.family=="K": attempt=self.refs[c["attempt"]]; creation_name=name+".creation"; creation_ref=_ref(self.p,"ContentCreationId",creation_name); self.refs[creation_name]=creation_ref predecessor_creation=self.refs.get(c.get("predecessor")+".creation") if c.get("predecessor") else None creation_order=self.orders.get("creation",0)+1; self.orders["creation"]=creation_order creation_fields={"id":_zero(self.p,"ContentCreationId"),"content_ref":ref,"predecessor_creation_ref":predecessor_creation,"attempt_ref":attempt,"actor_ref":actor,"commitment_ref":commit,"authorization_evidence_ref":auth,"causal_inputs":[],"instance_order":creation_order} creation_edges=[_edge("creation-content",_ep("self"),_ep("field","content_ref")),_edge("creation-attempt",_ep("self"),_ep("field","attempt_ref"))] if predecessor_creation is not None: creation_edges.append(_edge("creation-predecessor",_ep("self"),_ep("field","predecessor_creation_ref"))) self.emit("record.put",_opaque("ContentCreation","ContentCreationId",creation_name,creation_fields,creation_name,creation_edges)) if c.get("bind",True): self.emit("index.set",{"binding_kind":"state-head","key":subject,"value":ref,"expected_version":c.get("binding_version"),"out_version":None}) def bind(self,c): def resolve(v): if type(v) is dict and set(v)=={"$ref"}: return copy.deepcopy(self.refs[v["$ref"]]) if type(v) is list: return [resolve(x) for x in v] if type(v) is dict: return {k:resolve(x) for k,x in v.items()} return self.refs[v] if type(v) is str and v in self.refs else v self.emit("index.set",{"binding_kind":c["kind"],"key":self.refs[c["key"]],"value":resolve(c["value"]),"expected_version":c.get("version"),"out_version":None}) def lifecycle(self,c): target=self.refs[c["target"]] if c.get("semantic_target"): target=self.refs[c["semantic_target"]] order=self.orders.get("life",0)+1; self.orders["life"]=order key={"target":target,"order":order} if c.get("name"): self.refs[c["name"]]=key self.emit("record.put",_keyed("Lifecycle",key,{"target_ref":target,"state":c["state"],"tombstone":c.get("tombstone",False),"expires_at":c.get("expires_at"),"instance_order":order},c.get("name"))) def alias(self,c): name=c["name"]; self.refs[name]=_ref(self.p,"AliasRecordId",name); pred=self.refs.get(c.get("predecessor")); order=self.orders.get("alias",0)+1; self.orders["alias"]=order target=self.refs.get(c.get("target")) fields={"id":_zero(self.p,"AliasRecordId"),"namespace_ref":self.refs[c["namespace"]],"label":c["label"],"target_ref":target,"predecessor_ref":pred,"tombstone":c.get("tombstone",False),"expires_at":c.get("expires_at"),"instance_order":order} self.emit("record.put",_opaque("AliasVersion","AliasRecordId",name,fields,name)) def locator(self,c): name=c["name"]; self.refs[name]=_ref(self.p,"LocatorRecordId",name); pred=self.refs.get(c.get("predecessor")); order=self.orders.get("locator",0)+1; self.orders["locator"]=order fields={"id":_zero(self.p,"LocatorRecordId"),"target_ref":self.refs[c["target"]],"endpoint":c["endpoint"],"available":c.get("available",True),"tombstone":c.get("tombstone",False),"expires_at":c.get("expires_at"),"predecessor_ref":pred,"instance_order":order} self.emit("record.put",_opaque("LocatorVersion","LocatorRecordId",name,fields,name)) def snapshot(self,c): snap=_opaque("Snapshot","SnapshotId",c["name"],{"id":_zero(self.p,"SnapshotId"),"label":DEFERRED_LABELS["snapshot"]},c["name"]) self.refs[c["name"]]=_ref(self.p,"SnapshotId",c["name"]); self.emit("snapshot.capture",{"name":c["name"],"snapshot_record":snap,"binding_kinds":c["binding_kinds"],"root_context":{"mechanism":DEFERRED_LABELS["snapshot"]}}) def restore(self,c): self.emit("snapshot.restore",{"name":c["name"]}) def duplicate(self,c): target_record_key=self.refs.get(c["source"]+".$record") candidates=[a for a in self.actions if a["op"]=="record.put" and (a["args"].get("out_ref")==c["source"] or (target_record_key is not None and a["args"].get("out_ref") and self.refs.get(a["args"]["out_ref"]+".$record")==target_record_key))] if len(candidates)!=1: raise ValueError("exact duplicate source record") args=copy.deepcopy(candidates[0]["args"]); args["out_ref"]=None; self.emit("record.put",args) def root(self,c): fields={"id":_zero(self.p,"RootValueId"),"canonical_bindings":c["bindings"]}; self.refs[c["name"]]=_derived(self.p,"RootValueId",{"canonical_bindings":c["bindings"]}) edges=[] if c.get("world") is None else [_edge("world-root",_ep("literal",self.refs[c["world"]]),_ep("self"))] for target in c.get("state_targets",[]): edges.append(_edge("root-state",_ep("self"),_ep("literal",self.refs[target]))) reused=any(v==self.refs[c["name"]] for k,v in self.refs.items() if k!=c["name"] and not k.endswith(".$step")) if not c.get("reference_only",False) and not reused: self.emit("record.put",_derived_args("RootValue","RootValueId",fields,c["name"],edges)) self.queries.append({"query_id":c["name"]+"_root_record","expr":{"op":"field","input":{"op":"record","type":"RootValue","key":_lit(self.refs[c["name"]])},"path":"/key"},"output_path":"/"+c["name"]+"_root_record","query_meta":{"setup_only":"compiler-generated root identity support"}}) self.queries.append({"query_id":c["name"]+"_canonical","expr":{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":c["bindings"]}),"rule_override":None},"output_path":"/"+c["name"]+"_canonical","query_meta":{"setup_only":"compiler-generated root identity support"}}) def commit_event(self,c): name=c["name"]; fields={"id":_zero(self.p,"CommitEventId"),"world_ref":self.refs[c["world"]],"result_ref":self.refs[c["result"]],"root_ref":self.refs[c["root"]],"attempt_ref":self.refs[c["attempt"]],"actor_ref":self.refs[c["actor"]],"commitment_ref":self.refs[c["commitment"]],"authorization_evidence_ref":self.refs[c.get("evidence","auth")]} self.refs[name]=_ref(self.p,"CommitEventId",name); edges=[_edge("commit-world",_ep("self"),_ep("field","world_ref")),_edge("commit-attempt",_ep("self"),_ep("field","attempt_ref")),_edge("commit-result",_ep("self"),_ep("field","result_ref")),_edge("commit-root",_ep("self"),_ep("field","root_ref"))] self.emit("record.put",_opaque("CommitEvent","CommitEventId",name,fields,name,edges)) def key_material(self,c): self.opaque(c["name"],"KeyMaterial","KeyMaterialId",{"id":_zero(self.p,"KeyMaterialId"),"algorithm":c.get("algorithm","ed25519"),"public_key_bytes":rt.bytes_value(c["public_key"].encode())}) def key(self,c): fields={"id":_zero(self.p,"KeyId"),"algorithm":c.get("algorithm","ed25519"),"public_key_bytes":rt.bytes_value(c["public_key"].encode())} self.refs[c["name"]]=_derived(self.p,"KeyId",{k:fields[k] for k in self.p.id_rules["KeyId"].fields}); self.emit("record.put",_derived_args("Key","KeyId",fields,c["name"])) def key_epoch(self,c): name=c["name"]; ref=_ref(self.p,"KeyEpochId",name); self.refs[name]=ref fields={"id":_zero(self.p,"KeyEpochId"),"key_ref":self.refs[c["key"]],"actor_ref":self.refs[c["actor"]],"epoch":c["epoch"],"authorization_evidence_ref":self.refs[c.get("evidence","auth")]} edges=[_edge("epoch-key",_ep("self"),_ep("field","key_ref"))] if c.get("attempt"): edges.append(_edge("attempt-key-epoch",_ep("literal",self.refs[c["attempt"]]),_ep("self"))) self.emit("record.put",_opaque("KeyEpoch","KeyEpochId",name,fields,name,edges)) def generation(self,c): pred=self.refs.get(c.get("predecessor")); fields={"id":_zero(self.p,"GenerationId"),"world_ref":self.refs[c["world"]],"root_ref":self.refs[c["root"]],"parent_ref":self.refs[c["parent"]],"predecessor_generation_ref":pred,"transition_order":c["transition_order"]} edges=[_edge("generation-world",_ep("self"),_ep("field","world_ref")),_edge("generation-root",_ep("self"),_ep("field","root_ref")),_edge("generation-parent",_ep("self"),_ep("field","parent_ref"))] if pred is not None: edges.append(_edge("generation-predecessor",_ep("self"),_ep("field","predecessor_generation_ref"))) self.opaque(c["name"],"Generation","GenerationId",fields,edges=edges) def selection(self,c): pred=self.refs.get(c.get("predecessor")); fields={"id":_zero(self.p,"SelectionId"),"world_ref":self.refs[c["world"]],"root_ref":self.refs[c["root"]],"generation_ref":self.refs[c["generation"]],"parent_ref":self.refs[c["parent"]],"policy_ref":self.refs[c["policy"]],"predecessor_selection_ref":pred,"nonce":c["nonce"],"kind":c.get("kind","child"),"transition_order":c["transition_order"]} edges=[_edge("selection-generation",_ep("self"),_ep("field","generation_ref")),_edge("selection-world",_ep("self"),_ep("field","world_ref")),_edge("selection-root",_ep("self"),_ep("field","root_ref")),_edge("selection-parent",_ep("self"),_ep("field","parent_ref")),_edge("selection-policy",_ep("self"),_ep("field","policy_ref"))] if pred is not None: edges.append(_edge("selection-predecessor",_ep("self"),_ep("field","predecessor_selection_ref"))) self.opaque(c["name"],"Selection","SelectionId",fields,edges=edges) def pin(self,c): self.opaque(c["name"],"Pin","PinId",{"id":_zero(self.p,"PinId"),"target_ref":self.refs[c["target"]],"expires_at":c["expires_at"],"active":c.get("active",True)}) def freeze(self,c): self.emit("roots.freeze",{"epoch":c["epoch"],"root_refs":[self.refs[x] for x in c.get("roots",[])],"pin_refs":[self.refs[x] for x in c.get("pins",[])],"clock":c.get("clock",0)}) def mark(self,c): fault=None if c.get("defer"): fault={"kind":"CONCURRENT_ROOT_APPEND","phase":"after-root-copy-before-first-edge","epoch":c["epoch"]+1,"root_ref":self.refs[c["defer"]]} self.emit("reachability.mark",{"epoch":c["epoch"],"classes":c["classes"],"out":c.get("out")},fault=fault) def availability(self,c): self.emit("availability.set",{"envelope_ref":self.refs[c["payload"]],"state":c["state"],"body":None if c["state"]!="AVAILABLE" else rt.bytes_value(c["body"].encode()),"reason":c.get("reason")}) def collect(self,c): self.emit("availability.collect-if-unreachable",{"envelope_ref":self.refs[c["payload"]],"epoch":c["epoch"],"expected_reachable":c["expected_reachable"]}) def query(self,c): expr=copy.deepcopy(c["expr"]) if c.get("target_fallback") and type(self.refs.get(c["target_fallback"])) is dict and self.refs[c["target_fallback"]].get("$kind")=="slot": expr=copy.deepcopy(c["fallback_expr"]) def subst(v): if type(v) is dict: if set(v)=={"$ref"}: return copy.deepcopy(self.refs[v["$ref"]]) if set(v)=={"$record_ref"}: name=v["$record_ref"] return copy.deepcopy(self.refs.get(name+".$record",self.refs[name])) if set(v)=={"$state_value_ref"}: name=v["$state_value_ref"] return copy.deepcopy(self.refs.get(name+".value",self.refs[name])) return {k:subst(x) for k,x in v.items()} if type(v) is list: return [subst(x) for x in v] return v expr=subst(expr) request=expr.get("request") if type(expr) is dict and expr.get("op")=="resolve" else None if request is not None and request.get("expected_types")==[] and type(request.get("reference")) is dict and request["reference"].get("$kind")=="ref": request["expected_types"]=[request["reference"]["type"]] meta=c.get("query_meta") if type(meta) is not dict or set(meta) not in ({"evidence"},{"setup_only"}) or ("evidence" in meta and meta["evidence"] is not True) or ("setup_only" in meta and (type(meta["setup_only"]) is not str or not meta["setup_only"])): raise ValueError("query metadata") self.queries.append({"query_id":c["name"],"expr":expr,"output_path":"/"+c["name"],"query_meta":copy.deepcopy(meta)}) def compile(self,doc): handlers={"evidence":self.evidence,"actor":self.actor,"commitment":self.simple,"evidence-record":self.simple,"parent":self.simple,"policy":self.simple,"execution":self.simple,"world":self.simple,"namespace":self.simple,"payload":self.payload,"subject":self.subject,"attempt":self.attempt,"state":self.state,"bind":self.bind,"lifecycle":self.lifecycle,"alias":self.alias,"locator":self.locator,"snapshot":self.snapshot,"restore":self.restore,"duplicate":self.duplicate,"root":self.root,"commit-event":self.commit_event,"key-material":self.key_material,"key":self.key,"key-epoch":self.key_epoch,"generation":self.generation,"selection":self.selection,"pin":self.pin,"freeze":self.freeze,"mark":self.mark,"availability":self.availability,"collect":self.collect,"query":self.query} for command in doc["commands"]: self.current_meta={"essential_for":list(command["essential_for"])} if "essential_for" in command else {"setup_only":command.get("setup_only","declared prerequisite for scenario actions")} before=len(self.actions); handlers[command["intent"]](command) if "name" in command and len(self.actions)>before: self.refs[command["name"]+".$step"]=self.actions[-1]["step_id"] self.current_meta=None checkpoint=doc.get("checkpoint_after") if type(checkpoint) is str: step=self.refs[checkpoint+".$step"]; checkpoint=next(i+1 for i,a in enumerate(self.actions) if a["step_id"]==step) scheduled={} query_by_id={q["query_id"]:q for q in self.queries} for action_name,query_ids in doc.get("observations_at",{}).items(): step=self.refs[action_name+".$step"] if type(query_ids) is not list or not query_ids or any(x not in query_by_id for x in query_ids): raise ValueError("scheduled observation query") scheduled[step]=[copy.deepcopy(query_by_id[x]) for x in query_ids] scheduled_ids={q["query_id"] for batch in scheduled.values() for q in batch} final_queries=[q for q in self.queries if q["query_id"] not in scheduled_ids] return {"program_id":self.p.name+"."+doc["program_id"],"case_id":doc["case_id"],"profile_id":self.p.name,"dsl_version":"D001-OP-3","query_version":"D001-Q-2","initial_store":rt.empty_store(self.p,doc.get("clock",0)),"allocation_domains":copy.deepcopy(rt.empty_store(self.p)["allocations"]),"actions":self.actions,"faults":[a["fault"] for a in self.actions if a["fault"]],"queries":final_queries,"observations_at":scheduled,"checkpoint_after":checkpoint,"fresh_reconstruction":doc.get("fresh_reconstruction",False),"fixture_labels":DEFERRED_LABELS}
def _base_commands(actor_descriptor="A", actor_key="K1"): return [ {"intent":"evidence","name":"auth"}, {"intent":"actor","name":"A","descriptor":actor_descriptor,"genesis_key":actor_key}, {"intent":"evidence-record","name":"er"}, {"intent":"parent","name":"parent"}, {"intent":"policy","name":"policy"}, {"intent":"commitment","name":"commit","actor":"A"}, {"intent":"subject","name":"S","owner":"A"}, {"intent":"payload","name":"x","body":"x"}, {"intent":"payload","name":"y","body":"y"}, {"intent":"attempt","name":"attempt1","actor":"A","commitment":"commit","parent":"parent","policy":"policy","evidence_record":"er"}, ]
def _resolve(name,refname,mode="exact",clock=0,expected=None,context=None): return {"intent":"query","name":name,"expr":{"op":"resolve","request":{"mode":mode,"reference":{"$ref":refname},"context":context,"clock":clock,"expected_types":expected or []}},"query_meta":{"evidence":True}}
def _documents(): docs=[] def add(case,commands,checkpoint=None,fresh=False,observations_at=None): docs.append({"program_id":"neutral."+case,"case_id":case,"commands":commands,"checkpoint_after":checkpoint,"fresh_reconstruction":fresh,"observations_at":observations_at or {}}) def ess(cmd,*names): cmd=dict(cmd); cmd["essential_for"]=list(names); return cmd def setup(cmd,why="record dependency for essential action"): cmd=dict(cmd); cmd["setup_only"]=why; return cmd def q(name,expr,setup_only=None): return {"intent":"query","name":name,"expr":expr,"query_meta":({"setup_only":setup_only} if setup_only else {"evidence":True})} def rec(name,typ,ref,path="/"): return q(name,{"op":"field","input":{"op":"record","type":typ,"key":_lit({"$record_ref":ref})},"path":path}) b=[setup(x) for x in _base_commands()] # E01: two concrete commits; exact records, refs, payloads, binding and lineage are observed. add("E01",b+[ess({"intent":"state","name":"sx","subject":"S","payload":"x","actor":"A","commitment":"commit","attempt":"attempt1","bind":False,"nonce":"e01-x"},"sx_record","sx_ref","lineage"),ess({"intent":"state","name":"sy","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1","predecessor":"sx","nonce":"e01-y"},"sy_record","sy_ref","successor_binding","lineage"),rec("sx_record",{"$state_record":True},"sx","/fields"),rec("sy_record",{"$state_record":True},"sy","/fields"),q("sx_ref",_lit({"$ref":"sx"})),q("sy_ref",_lit({"$ref":"sy"})),rec("payload_x","PayloadEnvelope","x","/fields/id"),rec("payload_y","PayloadEnvelope","y","/fields/id"),q("typed_x",{"$typed_content_query":{"subject":{"$ref":"S"},"payload":{"$ref":"x"}}}),q("typed_y",{"$typed_content_query":{"subject":{"$ref":"S"},"payload":{"$ref":"y"}}}),rec("sx_value_record",{"$value_record":True},"sx.value","/fields"),rec("sy_value_record",{"$value_record":True},"sy.value","/fields"),q("successor_binding",{"op":"binding","kind":"state-head","key":_lit({"$ref":"S"})}),q("sx_lineage_record",{"op":"field","input":{"op":"record","type":{"$lineage_record":True},"key":_lit({"$lineage_key_x":True})},"path":"/fields"}),q("sy_lineage_record",{"op":"field","input":{"op":"record","type":{"$lineage_record":True},"key":_lit({"$lineage_key_y":True})},"path":"/fields"}),q("lineage",{"op":"relation-set","kinds":{"$lineage_relations":True}})],checkpoint=11) # E02: distinct B/C2 and A/C3 attempts commit equal y; direct provenance remains queryable. e02=b+[setup({"intent":"actor","name":"B","descriptor":"B","genesis_key":"KB"}),setup({"intent":"commitment","name":"C2","actor":"B"}),setup({"intent":"commitment","name":"C3","actor":"A"}),ess({"intent":"attempt","name":"attemptB","actor":"B","commitment":"C2","parent":"parent","policy":"policy","evidence_record":"er","nonce":"e02-b"},"attempt_b"),ess({"intent":"attempt","name":"attemptA","actor":"A","commitment":"C3","parent":"parent","policy":"policy","evidence_record":"er","nonce":"e02-a"},"attempt_a"),ess({"intent":"state","name":"yb","subject":"S","payload":"y","actor":"B","commitment":"C2","attempt":"attemptB","bind":False,"content_scope":"shared","nonce":"e02-b"},"yb_record","yb_ref","yb_value_ref","state_relations"),ess({"intent":"state","name":"ya","subject":"S","payload":"y","actor":"A","commitment":"C3","attempt":"attemptA","bind":False,"content_scope":"shared","nonce":"e02-a"},"ya_record","ya_ref","ya_value_ref","state_relations"),q("actor_b_ref",_lit({"$ref":"B"})),q("actor_a_ref",_lit({"$ref":"A"})),q("commitment_c2_ref",_lit({"$ref":"C2"})),q("commitment_c3_ref",_lit({"$ref":"C3"})),rec("attempt_b","Attempt","attemptB","/fields"),rec("attempt_a","Attempt","attemptA","/fields"),rec("yb_record",{"$state_record":True},"yb","/fields"),rec("ya_record",{"$state_record":True},"ya","/fields"),q("yb_ref",_lit({"$ref":"yb"})),q("ya_ref",_lit({"$ref":"ya"})),q("yb_value_ref",_lit({"$state_value_ref":"yb"})),q("ya_value_ref",_lit({"$state_value_ref":"ya"})),q("protected_b",{"op":"field","input":{"op":"record","type":{"$provenance_record":True},"key":_lit({"$provenance_key_b":True})},"path":"/fields"}),q("protected_a",{"op":"field","input":{"op":"record","type":{"$provenance_record":True},"key":_lit({"$provenance_key_a":True})},"path":"/fields"}),q("state_relations",{"op":"relation-set","kinds":{"$accountability_relations":True}})] add("E02",e02,checkpoint=14) # E03: destroy every old activation, materially change bindings, then restore persisted actor/state/new activation. e03=b+[ess({"intent":"state","name":"state","subject":"S","payload":"x","actor":"A","commitment":"commit","attempt":"attempt1"},"state_ref","restored_state"),ess({"intent":"execution","name":"e1","actor":"A","nonce":"old-1"},"e1_record"),ess({"intent":"execution","name":"e2","actor":"A","nonce":"old-2"},"e2_record"),ess({"intent":"bind","name":"actor_initial","kind":"current-actor","key":"A","value":"A"},"restored_actor"),ess({"intent":"bind","name":"active_old","kind":"active-executions","key":"A","value":[{"$ref":"e1"},{"$ref":"e2"}]},"active_old"),ess({"intent":"snapshot","name":"restart","binding_kinds":["current-actor","state-head"]},"restore_trace"),ess({"intent":"lifecycle","name":"e1_destroyed","target":"e1","state":"DESTROYED"},"destroyed_1"),ess({"intent":"lifecycle","name":"e2_destroyed","target":"e2","state":"DESTROYED"},"destroyed_2"),setup({"intent":"actor","name":"Other","descriptor":"Other","genesis_key":"K-other"}),setup({"intent":"bind","name":"actor_changed","kind":"current-actor","key":"A","value":"Other","version":1}),ess({"intent":"bind","name":"active_cleared","kind":"active-executions","key":"A","value":[],"version":1},"intermediate_active"),setup({"intent":"state","name":"changed_state","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1"}),ess({"intent":"restore","name":"restart"},"restore_trace","restored_actor","restored_state"),ess({"intent":"execution","name":"e3","actor":"A","nonce":"restored-new"},"e3_record","restored_active"),ess({"intent":"bind","name":"active_new","kind":"active-executions","key":"A","value":[{"$ref":"e3"}],"version":2},"restored_active"),rec("actor_original","ActorGenesis","A","/fields/id"),rec("e1_record","Execution","e1","/fields"),rec("e2_record","Execution","e2","/fields"),rec("e3_record","Execution","e3","/fields"),rec("destroyed_1","Lifecycle","e1_destroyed","/fields"),rec("destroyed_2","Lifecycle","e2_destroyed","/fields"),q("state_ref",_lit({"$ref":"state"})),q("restored_actor",{"op":"binding","kind":"current-actor","key":_lit({"$ref":"A"})}),q("restored_state",{"op":"binding","kind":"state-head","key":_lit({"$ref":"S"})}),q("restored_active",{"op":"binding","kind":"active-executions","key":_lit({"$ref":"A"})}),q("clear_trace",{"op":"trace","select":{"step_id":{"$action_step":"active_cleared"},"op":"index.set","status":"COMMITTED"},"project":"event","cardinality":"one"}),q("restore_trace",{"op":"trace","select":{"step_id":{"$action_step":"restart"},"op":"snapshot.restore","status":"COMMITTED"},"project":"event","cardinality":"one"})] add("E03",e03,checkpoint="active_cleared") # E04: an Attempt precedes rotation; K/H/V/O expose protected state→Attempt evidence, while C/L intentionally do not and must fail that obligation. e04=[setup({"intent":"evidence","name":"auth"}),ess({"intent":"evidence","name":"epoch_auth1"},"epoch_auth1"),ess({"intent":"evidence","name":"epoch_auth2"},"epoch_auth2"),setup({"intent":"actor","name":"A1","identity_symbol":"stable-A","descriptor":"stable-A","genesis_key":"K1"}),setup({"intent":"actor","name":"A2","identity_symbol":"stable-A","descriptor":"stable-A","genesis_key":"K2","reference_only":True}),setup({"intent":"evidence-record","name":"er"}),setup({"intent":"parent","name":"parent"}),setup({"intent":"policy","name":"policy"}),setup({"intent":"commitment","name":"commit","actor":"A1","evidence":"epoch_auth1"}),setup({"intent":"subject","name":"S","owner":"A1","evidence":"epoch_auth1"}),setup({"intent":"payload","name":"x","body":"x"}),ess({"intent":"attempt","name":"old_attempt","actor":"A1","commitment":"commit","parent":"parent","policy":"policy","evidence_record":"er","evidence":"epoch_auth1","nonce":"before-rotation"},"old_attempt","historical_relations"),ess({"intent":"state","name":"old_state","subject":"S","payload":"x","actor":"A1","commitment":"commit","attempt":"old_attempt","evidence":"epoch_auth1","bind":False,"nonce":"before-rotation"},"old_state"),ess({"intent":"key-material","name":"km1","public_key":"K1"},"material_1"),ess({"intent":"key-material","name":"km2","public_key":"K2"},"material_2"),setup({"intent":"key","name":"k1","public_key":"K1"}),setup({"intent":"key","name":"k2","public_key":"K2"}),ess({"intent":"key-epoch","name":"ke1","key":"k1","actor":"A1","epoch":1,"evidence":"epoch_auth1","attempt":"old_attempt"},"epoch_1","historical_relations"),ess({"intent":"key-epoch","name":"ke2","key":"k2","actor":"A2","epoch":2,"evidence":"epoch_auth2"},"epoch_2","historical_relations"),rec("old_attempt","Attempt","old_attempt","/fields"),rec("old_state",{"$state_record":True},"old_state","/fields"),q("old_state_ref",_lit({"$ref":"old_state"})),q("old_lineage",{"op":"field","input":{"op":"record","type":{"$lineage_record":True},"key":_lit({"$old_lineage_key":True})},"path":"/fields"}),rec("material_1","KeyMaterial","km1","/fields"),rec("material_2","KeyMaterial","km2","/fields"),rec("epoch_1","KeyEpoch","ke1","/fields"),rec("epoch_2","KeyEpoch","ke2","/fields"),rec("epoch_auth1","AuthorizationEvidence","epoch_auth1","/fields/id"),rec("epoch_auth2","AuthorizationEvidence","epoch_auth2","/fields/id"),q("historical_relations",{"op":"relation-set","kinds":{"$historical_relations":True}})] add("E04",e04,checkpoint=17) # E05: bind-only reuses source; repeat and new-subject forms create according to the family recipe. add("E05",b+[ess({"intent":"actor","name":"Clone","descriptor":"A","genesis_key":"K1"},"clone_ref"),setup({"intent":"commitment","name":"clone_commit","actor":"Clone"}),setup({"intent":"attempt","name":"clone_attempt","actor":"Clone","commitment":"clone_commit","parent":"parent","policy":"policy","evidence_record":"er","nonce":"clone"}),setup({"intent":"subject","name":"T","owner":"Clone","descriptor":"T"},"new subject or slot prerequisite for the third clone form"),ess({"intent":"state","name":"source","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1","nonce":"source","bind":False},"source_record","source_ref","source_value_ref","bind_only"),ess({"intent":"bind","name":"bind_only","kind":"context-state","key":"S","value":"source"},"bind_only"),ess({"intent":"state","name":"repeat","subject":"S","payload":"y","actor":"Clone","commitment":"clone_commit","attempt":"clone_attempt","bind":False,"nonce":"repeat"},"repeat_record","repeat_ref","repeat_value_ref"),ess({"intent":"state","name":"new","subject":"T","payload":"y","actor":"Clone","commitment":"clone_commit","attempt":"clone_attempt","bind":False,"nonce":"new"},"new_record","new_ref","new_value_ref","new_subject_ref"),rec("actor_ref","ActorGenesis","A","/fields/id"),rec("clone_ref","ActorGenesis","Clone","/fields/id"),q("source_ref",_lit({"$ref":"source"})),q("repeat_ref",_lit({"$ref":"repeat"})),q("new_ref",_lit({"$ref":"new"})),q("new_subject_ref",_lit({"$ref":"T"})),q("source_value_ref",_lit({"$state_value_ref":"source"})),q("repeat_value_ref",_lit({"$state_value_ref":"repeat"})),q("new_value_ref",_lit({"$state_value_ref":"new"})),rec("source_record",{"$state_record":True},"source","/fields"),rec("repeat_record",{"$state_record":True},"repeat","/fields"),rec("new_record",{"$state_record":True},"new","/fields"),q("bind_only",{"op":"binding","kind":"context-state","key":_lit({"$ref":"S"})}),q("bind_only_trace",{"op":"trace","select":{"step_id":{"$action_step":"bind_only"},"op":"index.set","status":"COMMITTED"},"project":"event","cardinality":"one"}),q("bind_only_effects",{"op":"trace-effects","event":{"op":"trace","select":{"step_id":{"$action_step":"bind_only"},"op":"index.set","status":"COMMITTED"},"project":"event","cardinality":"one"}}),q("state_relations",{"op":"relation-set","kinds":["occurrence-value"]})],checkpoint=15) # E06 fixture context bindings name branch results without resolving D-002/D-007 semantics. e06=b+[ess({"intent":"world","name":"w0"},"w0_ref","w0_before","w0_after"),ess({"intent":"world","name":"w1","parent":"w0"},"w1_ref"),ess({"intent":"world","name":"w2","parent":"w0"},"w2_ref"),ess({"intent":"root","name":"r0","bindings":{"fixture":"W0-unchanged"}},"r0_ref","w0_before","w0_after"),ess({"intent":"bind","name":"w0_bind","kind":"fixture-root-policy","key":"w0","value":"r0"},"w0_before","w0_after"),ess({"intent":"attempt","name":"child1","actor":"A","commitment":"commit","parent":"parent","policy":"policy","evidence_record":"er","nonce":"branch-w1"},"child1","branch1_record"),ess({"intent":"attempt","name":"child2","actor":"A","commitment":"commit","parent":"parent","policy":"policy","evidence_record":"er","nonce":"branch-w2"},"child2","branch2_record"),ess({"intent":"state","name":"branch1_state","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"child1","bind":False,"nonce":"branch-w1"},"branch1_record","branch1_ref","branch1_value_ref","branch_relations"),ess({"intent":"state","name":"branch2_state","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"child2","bind":False,"nonce":"branch-w2"},"branch2_record","branch2_ref","branch2_value_ref","branch_relations"),ess({"intent":"root","name":"r1","bindings":{"fixture":"equal-result-y"}},"r1_ref","r1_record"),ess({"intent":"root","name":"r2","bindings":{"fixture":"equal-result-y"}},"r2_ref","r2_record"),ess({"intent":"commit-event","name":"branch1_commit","world":"w1","result":"branch1_state","root":"r1","attempt":"child1","actor":"A","commitment":"commit"},"branch1_commit","branch_relations","branch1_trace"),ess({"intent":"commit-event","name":"branch2_commit","world":"w2","result":"branch2_state","root":"r2","attempt":"child2","actor":"A","commitment":"commit"},"branch2_commit","branch_relations","branch2_trace"),ess({"intent":"bind","name":"branch1_context","kind":"context-state","key":"w1","value":{"root_ref":{"$ref":"r1"},"result_ref":{"$ref":"branch1_state.value"},"occurrence_ref":{"$ref":"branch1_state"},"attempt_ref":{"$ref":"child1"}}},"branch1_context"),ess({"intent":"bind","name":"branch2_context","kind":"context-state","key":"w2","value":{"root_ref":{"$ref":"r2"},"result_ref":{"$ref":"branch2_state.value"},"occurrence_ref":{"$ref":"branch2_state"},"attempt_ref":{"$ref":"child2"}}},"branch2_context"),q("w0_ref",_lit({"$ref":"w0"})),q("w1_ref",_lit({"$ref":"w1"})),q("w2_ref",_lit({"$ref":"w2"})),q("r0_ref",_lit({"$ref":"r0"})),q("r1_ref",_lit({"$ref":"r1"})),q("r2_ref",_lit({"$ref":"r2"})),q("r2_derived",{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":{"fixture":"equal-result-y"}}),"rule_override":None}),q("r1_derivation",{"$commit_root_query":"branch1_commit"}),q("r2_derivation",{"$commit_root_query":"branch2_commit"}),rec("r1_record","RootValue","r1","/fields/id"),rec("child1","Attempt","child1","/fields"),rec("child2","Attempt","child2","/fields"),rec("branch1_commit","CommitEvent","branch1_commit","/fields"),rec("branch2_commit","CommitEvent","branch2_commit","/fields"),rec("branch1_record",{"$state_record":True},"branch1_state","/fields"),rec("branch2_record",{"$state_record":True},"branch2_state","/fields"),q("branch1_ref",_lit({"$ref":"branch1_state"})),q("branch2_ref",_lit({"$ref":"branch2_state"})),q("branch1_value_ref",_lit({"$state_value_ref":"branch1_state"})),q("branch2_value_ref",_lit({"$state_value_ref":"branch2_state"})),q("w0_before",{"op":"trace","select":{"step_id":{"$action_step":"w0_bind"},"op":"index.set","status":"COMMITTED"},"project":"output","cardinality":"one"}),q("w0_after",{"op":"binding","kind":"fixture-root-policy","key":_lit({"$ref":"w0"})}),q("w0_write_confinement",{"op":"trace-write-excludes","after_seq":_lit({"$w0_setup_seq":True}),"path":{"$w0_binding_path":True}}),q("branch1_context",{"op":"binding","kind":"context-state","key":_lit({"$ref":"w1"})}),q("branch2_context",{"op":"binding","kind":"context-state","key":_lit({"$ref":"w2"})}),q("branch1_trace",{"op":"trace","select":{"step_id":{"$action_step":"branch1_commit"},"op":"record.put","status":None},"project":"event","cardinality":"many"}),q("branch2_trace",{"op":"trace","select":{"step_id":{"$action_step":"branch2_commit"},"op":"record.put","status":None},"project":"event","cardinality":"many"}),q("branch_relations",{"op":"relation-set","kinds":{"$branch_relations":True}})] add("E06",e06,checkpoint=18) # E07: one namespace/label has immutable create, retarget, tombstone, and recreate versions. alias_ref=lambda name,mode,version=None: q(name,{"op":"resolve","request":{"mode":mode,"reference":{"namespace_ref":{"$ref":"ns"},"label":"a",**({"version_ref":{"$ref":version}} if version else {})},"context":None,"clock":0,"expected_types":["AliasRecordId"]}}) add("E07",b+[setup({"intent":"namespace","name":"ns","label":"main"}),ess({"intent":"alias","name":"av1","namespace":"ns","label":"a","target":"A"},"av1_record","av1_exact","asof_av1"),ess({"intent":"alias","name":"av2","namespace":"ns","label":"a","target":"S","predecessor":"av1"},"av2_record","asof_av2"),ess({"intent":"alias","name":"at","namespace":"ns","label":"a","predecessor":"av2","tombstone":True},"at_record","asof_at"),ess({"intent":"alias","name":"av4","namespace":"ns","label":"a","target":"A","predecessor":"at"},"av4_record","alias_current","asof_av4"),rec("av1_record","AliasVersion","av1","/fields"),rec("av2_record","AliasVersion","av2","/fields"),rec("at_record","AliasVersion","at","/fields"),rec("av4_record","AliasVersion","av4","/fields"),q("subject_ref",_lit({"$ref":"S"})),_resolve("av1_exact","av1","exact",expected=["AliasRecordId"]),alias_ref("alias_current","alias-current"),alias_ref("asof_av1","alias-as-of","av1"),alias_ref("asof_av2","alias-as-of","av2"),alias_ref("asof_at","alias-as-of","at"),alias_ref("asof_av4","alias-as-of","av4")]) # E08: endpoint text S1 is occupied first by A and later by distinct B; A moves to S2. add("E08",b+[setup({"intent":"actor","name":"B","descriptor":"B","genesis_key":"KB"}),ess({"intent":"locator","name":"l1","target":"A","endpoint":"S1"},"l1_record","s1_current"),ess({"intent":"locator","name":"l2","target":"A","endpoint":"S2","predecessor":"l1"},"l2_record","a_current"),ess({"intent":"bind","name":"a_endpoint","kind":"endpoint-occupant","key":"A","value":"l2"},"a_current"),ess({"intent":"locator","name":"l3","target":"B","endpoint":"S1"},"l3_record","s1_current"),ess({"intent":"bind","name":"b_endpoint","kind":"endpoint-occupant","key":"B","value":"l3"},"b_current"),rec("l1_record","LocatorVersion","l1","/fields"),rec("l2_record","LocatorVersion","l2","/fields"),rec("l3_record","LocatorVersion","l3","/fields"),q("a_ref",_lit({"$ref":"A"})),q("b_ref",_lit({"$ref":"B"})),q("l1_ref",_lit({"$ref":"l1"})),q("l2_ref",_lit({"$ref":"l2"})),q("l3_ref",_lit({"$ref":"l3"})),q("a_current",{"op":"binding","kind":"endpoint-occupant","key":_lit({"$ref":"A"})}),q("b_current",{"op":"binding","kind":"endpoint-occupant","key":_lit({"$ref":"B"})}),_resolve("l1_historical","l1","exact",expected=["LocatorRecordId"]),_resolve("l2_historical","l2","exact",expected=["LocatorRecordId"]),_resolve("a_current_resolved","A","locator-current",expected=[],context={"binding_kind":"endpoint-occupant","key":{"$ref":"A"},"expected_value":{"$ref":"l2"}}),_resolve("b_current_resolved","B","locator-current",expected=[],context={"binding_kind":"endpoint-occupant","key":{"$ref":"B"},"expected_value":{"$ref":"l3"}}),q("s1_fixture_current",{"op":"version-select","record_type":"LocatorVersion","match":_lit({"endpoint":"S1"}),"as_of":None})]) # E09: forward, rollback, forward are three persisted generation/selection contexts over an equal root. add("E09",b+[setup({"intent":"world","name":"w"}),ess({"intent":"root","name":"r","bindings":{"x":1}},"root_ref"),setup({"intent":"parent","name":"p2"}),setup({"intent":"parent","name":"p3"}),setup({"intent":"policy","name":"q2"}),setup({"intent":"policy","name":"q3"}),ess({"intent":"generation","name":"g1","world":"w","root":"r","parent":"parent","transition_order":1},"g1"),ess({"intent":"selection","name":"sel1","world":"w","root":"r","generation":"g1","parent":"parent","policy":"policy","nonce":"n1","kind":"forward","transition_order":1},"s1"),ess({"intent":"generation","name":"g2","world":"w","root":"r","parent":"p2","predecessor":"g1","transition_order":2},"g2"),ess({"intent":"selection","name":"sel2","world":"w","root":"r","generation":"g2","parent":"p2","policy":"q2","predecessor":"sel1","nonce":"n2","kind":"rollback","transition_order":2},"s2"),ess({"intent":"generation","name":"g3","world":"w","root":"r","parent":"p3","predecessor":"g2","transition_order":3},"g3"),ess({"intent":"selection","name":"sel3","world":"w","root":"r","generation":"g3","parent":"p3","policy":"q3","predecessor":"sel2","nonce":"n3","kind":"forward","transition_order":3},"s3"),q("world_ref",_lit({"$ref":"w"})),q("root_ref",_lit({"$ref":"r"})),q("p1_ref",_lit({"$ref":"parent"})),q("p2_ref",_lit({"$ref":"p2"})),q("p3_ref",_lit({"$ref":"p3"})),q("policy1_ref",_lit({"$ref":"policy"})),q("policy2_ref",_lit({"$ref":"q2"})),q("policy3_ref",_lit({"$ref":"q3"})),rec("g1","Generation","g1","/fields"),rec("g2","Generation","g2","/fields"),rec("g3","Generation","g3","/fields"),rec("s1","Selection","sel1","/fields"),rec("s2","Selection","sel2","/fields"),rec("s3","Selection","sel3","/fields")]) # E10: each stale vector differs from the fresh Attempt in exactly one directly compared component. components=[{"name":x,"left_path":"/"+x,"right_path":"/"+x} for x in ("nonce","parent_ref","policy_ref","evidence_ref")] cmp=lambda name,left: q(name,{"op":"compare-components","left":{"op":"field","input":{"op":"record","type":"Attempt","key":_lit({"$ref":left})},"path":"/fields"},"right":{"op":"field","input":{"op":"record","type":"Attempt","key":_lit({"$ref":"fresh"})},"path":"/fields"},"components":components}) add("E10",b+[setup({"intent":"parent","name":"fresh_parent"}),setup({"intent":"policy","name":"fresh_policy"}),setup({"intent":"evidence-record","name":"fresh_evidence"}),ess({"intent":"attempt","name":"fresh","actor":"A","commitment":"commit","parent":"fresh_parent","policy":"fresh_policy","evidence_record":"fresh_evidence","nonce":"fresh"},"fresh_attempt"),ess({"intent":"attempt","name":"stale_nonce","actor":"A","commitment":"commit","parent":"fresh_parent","policy":"fresh_policy","evidence_record":"fresh_evidence","nonce":"old"},"stale_nonce_cmp"),ess({"intent":"attempt","name":"stale_parent","actor":"A","commitment":"commit","parent":"parent","policy":"fresh_policy","evidence_record":"fresh_evidence","nonce":"fresh"},"stale_parent_cmp"),ess({"intent":"attempt","name":"stale_policy","actor":"A","commitment":"commit","parent":"fresh_parent","policy":"policy","evidence_record":"fresh_evidence","nonce":"fresh"},"stale_policy_cmp"),ess({"intent":"attempt","name":"stale_evidence","actor":"A","commitment":"commit","parent":"fresh_parent","policy":"fresh_policy","evidence_record":"er","nonce":"fresh"},"stale_evidence_cmp"),rec("fresh_attempt","Attempt","fresh","/fields"),q("fresh_ref_observed",_lit({"$ref":"fresh"})),cmp("stale_nonce_cmp","stale_nonce"),cmp("stale_parent_cmp","stale_parent"),cmp("stale_policy_cmp","stale_policy"),cmp("stale_evidence_cmp","stale_evidence")]) # E11: binding snapshots exclude authoritative allocation/lifecycle ledgers. add("E11",b+[ess({"intent":"state","name":"live","subject":"S","payload":"x","actor":"A","commitment":"commit","attempt":"attempt1"},"live_ref","restored_state","duplicate_trace"),ess({"intent":"snapshot","name":"old","binding_kinds":["state-head"]},"snapshot_record","restored_state"),ess({"intent":"lifecycle","name":"life","target":"live","state":"TOMBSTONED","tombstone":True},"lifecycle_tombstone"),setup({"intent":"state","name":"changed","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1"},"post-snapshot binding mutation required to exercise restore"),ess({"intent":"restore","name":"old"},"restored_state"),ess({"intent":"duplicate","name":"duplicate_old","source":"live"},"duplicate_trace"),q("live_ref",_lit({"$ref":"live"})),q("live_identity",_lit({"$record_ref":"live"})),q("restored_state",{"op":"binding","kind":"state-head","key":_lit({"$ref":"S"})}),rec("snapshot_record","Snapshot","old","/fields"),rec("lifecycle_tombstone","Lifecycle","life","/fields"),q("duplicate_trace",{"op":"trace","select":{"step_id":{"$action_step":"duplicate_old"},"op":"record.put","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),q("allocation_ledger",{"op":"store-section","section":"allocations"}),q("lifecycle_ledger",{"op":"store-section","section":"lifecycle"}),q("snapshot_ledger",{"op":"store-section","section":"snapshots"}),q("snapshot_has_allocations",{"op":"object-has-key","input":{"op":"store-section","section":"snapshots"},"object_key":"old","key":"allocations"}),q("snapshot_has_lifecycle",{"op":"object-has-key","input":{"op":"store-section","section":"snapshots"},"object_key":"old","key":"lifecycle"})],checkpoint="old") # E12: genuine protected reference versus copied structured fields attached to a dangling same-typed claim. copied={"claimed_occurrence_ref":{"$unit24_dangling_protected":True},"actor_ref":{"$ref":"A"},"commitment_ref":{"$ref":"commit"},"authorization_evidence_ref":{"$ref":"auth"},"causal_inputs":[]} add("E12",b+[ess({"intent":"state","name":"real","subject":"S","payload":"x","actor":"A","commitment":"commit","attempt":"attempt1","bind":False},"protected_record","protected_provenance","copied_provenance"),q("protected_ref",_lit({"$protected_ref":True})),q("actor_ref",_lit({"$ref":"A"})),q("commitment_ref",_lit({"$ref":"commit"})),q("auth_ref",_lit({"$ref":"auth"})),q("protected_record",{"$unit24_protected_record":True}),q("protected_actor",{"op":"field","input":{"$unit24_protected_record_input":True},"path":"/fields/actor_ref"}),q("protected_provenance",{"op":"verify-provenance","claim":_lit({"$protected_ref":True})}),q("copied_provenance",{"op":"verify-provenance","claim":_lit(copied)})],fresh=False) # E13: the first override creates a safe same-raw cross-domain record; the # second creates a same-typed unequal-preimage collision and must be fatal. add("E13",b+[ess({"intent":"payload","name":"cross_digest","id_type":"PayloadDigest","body":"cross-domain","fault":{"kind":"HASH_RESULT_OVERRIDE","phase":"after-preimage-before-typed-lookup","raw_digest_hex":{"$digest_of":"x"}}},"cross_digest_record","cross_resolved","cross_type_lookup"),ess({"intent":"payload","name":"collision","body":"unequal","fault":{"kind":"HASH_RESULT_OVERRIDE","phase":"after-preimage-before-typed-lookup","raw_digest_hex":{"$digest_of":"x"}}},"fatal_trace","original_after"),ess({"intent":"availability","name":"post_fatal","payload":"x","state":"AVAILABLE","body":"x"},"post_fatal_trace"),q("original_before",{"op":"record","type":"PayloadEnvelope","key":_lit({"$ref":"x"})}),q("cross_digest_record",{"op":"record","type":"PayloadDigestRecord","key":_lit({"$ref":"cross_digest"})}),_resolve("cross_resolved","cross_digest","exact",expected=["PayloadDigest"]),q("cross_type_lookup",{"op":"resolve","request":{"mode":"exact","reference":{"$ref":"cross_digest"},"context":None,"clock":0,"expected_types":["PayloadId"]}}),q("fatal_trace",{"op":"trace","select":{"step_id":{"$action_step":"collision"},"op":"record.put","status":"FATAL"},"project":"event","cardinality":"one"}),q("post_fatal_trace",{"op":"trace","select":{"step_id":{"$action_step":"post_fatal"},"op":"availability.set","status":"COMMITTED"},"project":"event","cardinality":"one"}),q("original_after",{"op":"record","type":"PayloadEnvelope","key":_lit({"$ref":"x"})}),q("records_after",{"op":"records","types":["PayloadEnvelope","PayloadDigestRecord"]})]) add("E14",b+[setup({"intent":"world","name":"discarded_world"}),setup({"intent":"subject","name":"DiscardedSubject","owner":"A","descriptor":"DiscardedSubject"}),setup({"intent":"state","name":"discarded_state","subject":"DiscardedSubject","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1","bind":False}),ess({"intent":"payload","name":"shared","body":"shared","edges":[{"kind":"payload-body","to":"x"}]},"mark_result","retention_relations"),ess({"intent":"state","name":"retained_state","subject":"S","payload":"shared","actor":"A","commitment":"commit","attempt":"attempt1","bind":False,"accountable_identity":True,"edges":[{"kind":"state-payload","to":"shared"},{"kind":"accountable-actor","to":"A"},{"kind":"protected-state-attempt","to":"attempt1"}]},"mark_result","retention_relations"),ess({"intent":"world","name":"retained_world"},"mark_result","retention_relations"),ess({"intent":"root","name":"retained_root","world":"retained_world","state_targets":["retained_state"],"bindings":{"canonical":"retained"}},"mark_result","retention_relations"),ess({"intent":"lifecycle","name":"actor_dormant","target":"A","state":"DORMANT"},"actor_lifecycle"),ess({"intent":"pin","name":"audit_pin","target":"retained_state","expires_at":10},"frozen_epoch","mark_result"),ess({"intent":"world","name":"deferred"},"deferred_root"),ess({"intent":"freeze","name":"freeze_n","epoch":0,"roots":["retained_world"],"pins":["audit_pin"],"clock":5},"frozen_epoch","mark_result"),ess({"intent":"mark","name":"mark_n","epoch":0,"classes":["identity-strong","audit-summary","body-retaining"],"defer":"deferred","out":"mark"},"mark_result","deferred_root"),ess({"intent":"freeze","name":"freeze_n1","epoch":1,"roots":[],"pins":[],"clock":11},"later_epoch"),ess({"intent":"mark","name":"mark_n1","epoch":1,"classes":["identity-strong","audit-summary","body-retaining"],"out":"mark_later"},"later_epoch"),q("retained_ref",_lit({"$ref":"retained_state"})),q("discarded_key",{"op":"typed-key","value":_lit({"$ref":"discarded_state"})}),q("discarded_world_key",{"op":"typed-key","value":_lit({"$ref":"discarded_world"})}),q("retained_world_ref",_lit({"$ref":"retained_world"})),q("retained_root_ref",_lit({"$ref":"retained_root"})),q("shared_ref",_lit({"$ref":"shared"})),q("payload_x_ref",_lit({"$ref":"x"})),q("actor_ref",_lit({"$ref":"A"})),q("attempt_ref",_lit({"$ref":"attempt1"})),q("pin_ref",_lit({"$ref":"audit_pin"})),q("deferred_ref",_lit({"$ref":"deferred"})),q("mark_result",{"op":"reg","name":"mark"}),q("root_reason",{"op":"list-select","input":{"op":"field","input":{"op":"reg","name":"mark"},"path":"/reasons"},"match":_lit({"edge_kind":"frozen-root"})}),q("audit_reason",{"op":"list-select","input":{"op":"field","input":{"op":"reg","name":"mark"},"path":"/reasons"},"match":_lit({"edge_kind":"active-audit-pin"})}),q("later_epoch",{"op":"reg","name":"mark_later"}),q("deferred_key",{"op":"typed-key","value":_lit({"$ref":"deferred"})}),q("expected_reachable",{"op":"typed-keys","values":{"$e14_reachable":True}}),q("frozen_epoch",{"op":"field","input":{"op":"store-section","section":"roots"},"path":"/frozen/0"}),q("roots_state",{"op":"store-section","section":"roots"}),q("actor_lifecycle",{"op":"map-get","input":{"op":"store-section","section":"lifecycle"},"key":{"op":"typed-key","value":_lit({"$ref":"A"})}}),q("retention_relations",{"op":"relation-set","kinds":["world-root","root-state","state-payload","accountable-actor","protected-state-attempt","payload-body"]}),q("discarded_membership",{"op":"contains","input":{"op":"field","input":{"op":"reg","name":"mark"},"path":"/reachable"},"value":{"op":"typed-key","value":_lit({"$ref":"discarded_state"})}}),q("discarded_world_membership",{"op":"contains","input":{"op":"field","input":{"op":"reg","name":"mark"},"path":"/reachable"},"value":{"op":"typed-key","value":_lit({"$ref":"discarded_world"})}})]) add("E15",b+[ess({"intent":"availability","name":"body_initial","payload":"y","state":"AVAILABLE","body":"y"},"available_trace"),ess({"intent":"payload","name":"body_root","body":"body-root","edges":[{"kind":"payload-body","to":"y"}]},"mark_n"),ess({"intent":"pin","name":"body_pin","target":"y","expires_at":0},"mark_n"),ess({"intent":"freeze","name":"freeze_n","epoch":0,"roots":["body_root"],"pins":["body_pin"],"clock":0},"mark_n"),ess({"intent":"mark","name":"mark_n_action","epoch":0,"classes":["body-retaining"],"out":"mark_n"},"mark_n"),ess({"intent":"payload","name":"next_only","body":"next-only"},"next_only_ref"),ess({"intent":"pin","name":"expired_pin","target":"y","expires_at":0,"active":False},"expired_pin_record"),ess({"intent":"freeze","name":"freeze_n1","epoch":1,"roots":["x"],"pins":["expired_pin"],"clock":1},"mark_n1"),ess({"intent":"mark","name":"mark_n1_action","epoch":1,"classes":["body-retaining"],"out":"mark_n1"},"mark_n1"),setup({"intent":"availability","name":"x_available","payload":"x","state":"AVAILABLE","body":"x"}),setup({"intent":"collect","name":"collect_stale","payload":"y","epoch":0,"expected_reachable":False},"stale epoch adversary must not commit"),setup({"intent":"collect","name":"collect_reachable","payload":"x","epoch":1,"expected_reachable":False},"reachable adversary must not commit"),setup({"intent":"collect","name":"collect_membership","payload":"y","epoch":1,"expected_reachable":True},"membership adversary must not commit"),ess({"intent":"collect","name":"collect_ok","payload":"y","epoch":1,"expected_reachable":False},"collect_trace","collected_body","intermediate_payload_records"),setup({"intent":"collect","name":"collect_replay","payload":"y","epoch":1,"expected_reachable":False},"replay adversary must not commit"),setup({"intent":"availability","name":"body_restore_mismatch","payload":"y","state":"AVAILABLE","body":"wrong"},"mismatch restore adversary must not commit"),ess({"intent":"availability","name":"body_restore","payload":"y","state":"AVAILABLE","body":"y"},"restore_trace","restored_body"),q("mark_n",{"op":"reg","name":"mark_n"}),q("mark_n1",{"op":"reg","name":"mark_n1"}),q("n_y_membership",{"op":"contains","input":{"op":"field","input":{"op":"reg","name":"mark_n"},"path":"/reachable"},"value":{"op":"typed-key","value":_lit({"$ref":"y"})}}),q("available_trace",{"op":"trace","select":{"step_id":{"$action_step":"body_initial"},"op":"availability.set","status":"COMMITTED"},"project":"event","cardinality":"one"}),q("collect_trace",{"op":"trace","select":{"step_id":{"$action_step":"collect_ok"},"op":"availability.collect-if-unreachable","status":"COMMITTED"},"project":"event","cardinality":"one"}),q("replay_trace",{"op":"trace","select":{"step_id":{"$action_step":"collect_replay"},"op":"availability.collect-if-unreachable","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),q("stale_trace",{"op":"trace","select":{"step_id":{"$action_step":"collect_stale"},"op":"availability.collect-if-unreachable","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),q("reachable_trace",{"op":"trace","select":{"step_id":{"$action_step":"collect_reachable"},"op":"availability.collect-if-unreachable","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),q("membership_trace",{"op":"trace","select":{"step_id":{"$action_step":"collect_membership"},"op":"availability.collect-if-unreachable","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),q("mismatch_restore_trace",{"op":"trace","select":{"step_id":{"$action_step":"body_restore_mismatch"},"op":"availability.set","status":"NO_COMMIT"},"project":"event","cardinality":"one"}),_resolve("envelope_resolved","y","exact",expected=["PayloadId"]),_resolve("collected_body","y","payload-body",expected=["PayloadId"]),q("intermediate_payload_records",{"op":"records","types":["PayloadEnvelope","PayloadBody"]}),q("intermediate_y_body_count",{"op":"record-count","record_type":"PayloadBody","key":_lit({"$ref":"y"})}),q("payload_x_ref",_lit({"$ref":"x"}),"intermediate body-count query supersedes this diagnostic literal"),q("matching_verify",{"op":"verify-body","envelope_ref":_lit({"$ref":"y"}),"body":_lit(rt.bytes_value(b"y"))}),q("mismatch_verify",{"op":"verify-body","envelope_ref":_lit({"$ref":"y"}),"body":_lit(rt.bytes_value(b"wrong"))}),q("restore_trace",{"op":"trace","select":{"step_id":{"$action_step":"body_restore"},"op":"availability.set","status":"COMMITTED"},"project":"event","cardinality":"one"}),_resolve("restored_body","y","payload-body",expected=["PayloadId"]),q("availability_section",{"op":"store-section","section":"availability"}),q("y_availability",{"op":"map-get","input":{"op":"store-section","section":"availability"},"key":{"op":"typed-key","value":_lit({"$ref":"y"})}}),q("payload_records",{"op":"records","types":["PayloadEnvelope","PayloadBody"]}),q("x_availability",{"op":"map-get","input":{"op":"store-section","section":"availability"},"key":{"op":"typed-key","value":_lit({"$ref":"x"})}}),q("next_only_ref",_lit({"$ref":"next_only"})),rec("expired_pin_record","Pin","expired_pin","/fields")],checkpoint="freeze_n1",observations_at={"collect_ok":["collected_body","intermediate_payload_records","intermediate_y_body_count"]}) locator_ctx=lambda actor,ref:{"binding_kind":"endpoint-occupant","key":{"$ref":actor},"expected_value":{"$ref":ref}} add("E16",b+[setup({"intent":"actor","name":"TombActor","descriptor":"TombActor","genesis_key":"KT"}),setup({"intent":"actor","name":"ExpireActor","descriptor":"ExpireActor","genesis_key":"KE"}),ess({"intent":"locator","name":"tomb_locator","target":"TombActor","endpoint":"T","available":False,"tombstone":True,"expires_at":0},"tombstoned"),ess({"intent":"locator","name":"expired_locator","target":"ExpireActor","endpoint":"E","available":False,"expires_at":0},"expired"),ess({"intent":"locator","name":"unavail_locator","target":"A","endpoint":"U","available":False},"unavailable"),ess({"intent":"bind","name":"tomb_current","kind":"endpoint-occupant","key":"TombActor","value":"tomb_locator"},"tombstoned"),ess({"intent":"bind","name":"expired_current","kind":"endpoint-occupant","key":"ExpireActor","value":"expired_locator"},"expired"),ess({"intent":"bind","name":"locator_current","kind":"endpoint-occupant","key":"A","value":"unavail_locator"},"unavailable"),ess({"intent":"availability","name":"collected_set","payload":"y","state":"COLLECTED"},"collected")]+[q("malformed",{"op":"resolve","request":{"bad":1}}),q("type_mismatch",{"op":"resolve","request":{"mode":"exact","reference":{"$ref":"A"},"context":None,"clock":0,"expected_types":["PayloadId"]}}),q("context_mismatch",{"op":"resolve","request":{"mode":"exact","reference":{"$ref":"A"},"context":{"binding_kind":"current-actor","key":{"$ref":"A"},"expected_value":{"$ref":"A"}},"clock":0,"expected_types":[{"$types_of":"A"}]}}),q("unknown",{"op":"resolve","request":{"mode":"exact","reference":{"$kind":"ref","type":"PayloadId","hex":"22"*32},"context":None,"clock":0,"expected_types":["PayloadId"]}}),q("tombstoned",{"op":"resolve","request":{"mode":"locator-current","reference":{"$ref":"TombActor"},"context":locator_ctx("TombActor","tomb_locator"),"clock":5,"expected_types":[{"$types_of":"A"}]}}),q("expired",{"op":"resolve","request":{"mode":"locator-current","reference":{"$ref":"ExpireActor"},"context":locator_ctx("ExpireActor","expired_locator"),"clock":5,"expected_types":[{"$types_of":"A"}]}}),_resolve("collected","y","payload-body",expected=["PayloadId"]),q("unavailable",{"op":"resolve","request":{"mode":"locator-current","reference":{"$ref":"A"},"context":locator_ctx("A","unavail_locator"),"clock":0,"expected_types":[{"$types_of":"A"}]}}),_resolve("resolved","x","exact",expected=["PayloadId"]),q("malformed_beats_type",{"op":"resolve","request":{"mode":"exact","reference":{"$kind":"ref","type":"PayloadId","hex":"zz"},"context":None,"clock":0,"expected_types":["AttemptId"]}}),q("type_beats_context",{"op":"resolve","request":{"mode":"exact","reference":{"$ref":"A"},"context":{"binding_kind":"current-actor","key":{"$ref":"A"},"expected_value":{"$ref":"A"}},"clock":0,"expected_types":["PayloadId"]}}),q("context_beats_unknown",{"op":"resolve","request":{"mode":"exact","reference":{"$kind":"ref","type":"PayloadId","hex":"22"*32},"context":{"binding_kind":"current-actor","key":{"$ref":"A"},"expected_value":{"$ref":"A"}},"clock":0,"expected_types":["PayloadId"]}}),q("tombstone_beats_expiry",{"op":"resolve","request":{"mode":"locator-current","reference":{"$ref":"TombActor"},"context":locator_ctx("TombActor","tomb_locator"),"clock":5,"expected_types":[{"$types_of":"A"}]}})]) # Canonical request/result observations are independent query evaluations checked against frozen source goldens. e16_doc=docs[-1] base_queries=[x for x in e16_doc["commands"] if x.get("intent")=="query" and x.get("name") in E16_VECTOR_IDS] for item in base_queries: request=copy.deepcopy(item["expr"]["request"]) def normalize_symbolic(v): if type(v) is dict and v.get("$kind")=="ref" and set(v)=={"$kind","type","hex"}: return {"$kind":"ref","type":v["type"],"hex":"<ref>"} if type(v) is dict: return {k:normalize_symbolic(x) for k,x in v.items()} if type(v) is list: return [normalize_symbolic(x) for x in v] return v e16_doc["commands"].append(q(item["name"]+"_request_canonical",{"op":"canonical-json-raw","value":normalize_symbolic(request)})) e16_doc["commands"].append(q(item["name"]+"_result_canonical",{"op":"canonical-json-normalized","value":copy.deepcopy(item["expr"])})) # E17 has no store actions: schema-directed canonical queries are the experiment. canonical={"$kind":"map","entries":[["z",{"$kind":"set","items":["a","b"]}],["é",{"$kind":"set","items":["c"]}]]} reordered={"$kind":"map","entries":[["é",{"$kind":"set","items":["c"]}],["z",{"$kind":"set","items":["b","a"]}]]} cv=lambda name,value,schema:q(name,{"op":"canonical-value","value":value,"schema":schema}) add("E17",[q("map1",{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":canonical}),"rule_override":None}),q("map2",{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":reordered}),"rule_override":None}),q("schema_diff",{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":canonical}),"rule_override":{"schema":"changed","codec":"CVE1"}}),q("codec_diff",{"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":canonical}),"rule_override":{"schema":"aos.d001.root-value.v1.schema","codec":"changed"}}),cv("absent",{"$kind":"absent"},{"optional":{"type":"text"}}),cv("null",None,{"type":"null"}),cv("empty","",{"type":"text"}),cv("bool_true",True,{"type":"bool"}),cv("uint_one",1,{"type":"uint64"}),cv("bytes_one",{"$kind":"bytes","hex":"01"},{"type":"bytes"}),cv("digest",{"$kind":"digest32","hex":"11"*32},{"type":"digest32"}),cv("ref_payload",{"$kind":"ref","type":"PayloadId","hex":"11"*32},{"type":"PayloadId"}),cv("ref_digest",{"$kind":"ref","type":"PayloadDigest","hex":"11"*32},{"type":"PayloadDigest"}),cv("array_ab",["a","b"],{"array":{"type":"text"}}),cv("array_ba",["b","a"],{"array":{"type":"text"}}),cv("set_ab",{"$kind":"set","items":["a","b"]},{"set":{"type":"text"}}),cv("set_ba",{"$kind":"set","items":["b","a"]},{"set":{"type":"text"}}),cv("map_ordered",{"$kind":"map","entries":[["a",1],["b",2]]},{"map":{"key":{"type":"text"},"value":{"type":"uint64"}}}),cv("map_reordered",{"$kind":"map","entries":[["b",2],["a",1]]},{"map":{"key":{"type":"text"},"value":{"type":"uint64"}}}),cv("nfc_text","é",{"type":"text"}),cv("slot",{"$kind":"slot","owner_actor_ref":{"$unit25_actor_ref":True},"slot_type":"state","slot_name":"main"},{"type":"slot"}),cv("duplicate_set",{"$kind":"set","items":["a","a"]},{"set":{"type":"text"}}),cv("duplicate_map",{"$kind":"map","entries":[["a",1],["a",2]]},{"map":{"key":{"type":"text"},"value":{"type":"uint64"}}}),cv("non_nfc","e\u0301",{"type":"text"}),cv("wrong_width",{"$kind":"ref","type":"PayloadId","hex":"11"},{"type":"PayloadId"}),cv("unknown_wrapper",{"$kind":"text","value":"x"},{"type":"text"}),cv("absent_required",{"$kind":"absent"},{"type":"text"})]) add("E18",b+[ess({"intent":"world","name":"reconstruction_world"},"relations","serialized"),ess({"intent":"root","name":"reconstruction_root","world":"reconstruction_world","bindings":{"reconstruction":"generic"}},"relations","serialized"),ess({"intent":"state","name":"s1","subject":"S","payload":"x","actor":"A","commitment":"commit","attempt":"attempt1","bind":False},"relations","serialized"),ess({"intent":"state","name":"s2","subject":"S","payload":"y","actor":"A","commitment":"commit","attempt":"attempt1","predecessor":"s1"},"relations","serialized"),ess({"intent":"bind","name":"actor_binding","kind":"current-actor","key":"A","value":"A"},"bindings"),ess({"intent":"lifecycle","name":"actor_life","target":"A","state":"DORMANT","expires_at":99},"lifecycle"),ess({"intent":"availability","name":"body_available","payload":"x","state":"AVAILABLE","body":"x"},"availability"),ess({"intent":"pin","name":"body_pin","target":"x","expires_at":50},"roots"),ess({"intent":"freeze","name":"fresh_freeze","epoch":0,"roots":["A"],"pins":["body_pin"],"clock":1},"roots"),ess({"intent":"mark","name":"fresh_mark","epoch":0,"classes":["identity-strong","audit-summary","body-retaining","operational"],"out":"fresh_mark"},"roots"),ess({"intent":"snapshot","name":"fresh_snapshot","binding_kinds":["current-actor"]},"snapshots"),q("serialized",{"op":"serialize-store"}),q("reconstructed",{"op":"reconstruct","bytes":{"op":"field","input":{"op":"serialize-store"},"path":"/bytes"},"mode":"fresh-store","rebind":{"record_type":"ActorGenesis","match_fields":_lit({"descriptor":"A"})}}),q("derived_mapping",{"op":"identity-mapping","kind":"derived"}),q("opaque_mapping",{"op":"identity-mapping","kind":"opaque"}),q("actor_ref",_lit({"$ref":"A"})),q("relations",{"op":"relation-set","kinds":{"$reconstruction_relations":True}}),q("relation_count",{"op":"list-count","input":{"op":"relation-set","kinds":{"$reconstruction_relations":True}}}),q("bindings",{"op":"store-section","section":"bindings"}),q("allocations",{"op":"store-section","section":"allocations"}),q("lifecycle",{"op":"store-section","section":"lifecycle"}),q("availability",{"op":"store-section","section":"availability"}),q("roots",{"op":"store-section","section":"roots"}),q("snapshots",{"op":"store-section","section":"snapshots"})],checkpoint="fresh_freeze",fresh=True) return docs
NEUTRAL_PROGRAMS = _documents()
def _patch_symbols(value, refs): if type(value) is dict: if set(value)=={"$digest_of"}: return refs[value["$digest_of"]]["hex"] if set(value)=={"$hex_of"}: return refs[value["$hex_of"]]["hex"] if set(value)=={"$action_step"}: return refs[value["$action_step"]+".$step"] if set(value)=={"$types_of"}: return refs[value["$types_of"]]["type"] if set(value)=={"$override_hex"}: return _patch_symbols(value["$override_hex"],refs) return {k:_patch_symbols(v,refs) for k,v in value.items()} if type(value) is list: return [_patch_symbols(v,refs) for v in value] return value
def compile_program(document: dict[str,Any], profile: rt.ProfileSemantics) -> dict[str,Any]: compiler=Compiler(profile) # Patches refer only to concrete operand symbols already declared in prior data. result=compiler.compile(document) result["actions"]=_patch_symbols(result["actions"],compiler.refs) result["queries"]=_patch_symbols(result["queries"],compiler.refs) result["observations_at"]=_patch_symbols(result["observations_at"],compiler.refs) family=profile.state_recipe["family"] state_records={"C":["ContentState"],"K":["ContentState"],"L":["MutableState"],"H":["OpaqueRevision"],"V":["RevisionValue","Occurrence"],"O":["RevisionOccurrence"]}[family] subject_records=["SlotDefinition"] if profile.state_recipe["slot"] else (["ContentState"] if family in ("C","K") else ["Subject"]) def profile_patch(v): if type(v) is dict: if set(v)=={"$commit_root_query"}: return {"op":"field","input":{"op":"record","type":"CommitEvent","key":_lit(compiler.refs[v["$commit_root_query"]])},"path":"/fields/root_ref"} if set(v)=={"$w0_setup_seq"}: return next(i for i,a in enumerate(result["actions"]) if a["op"]=="index.set" and a["args"].get("binding_kind")=="fixture-root-policy") if set(v)=={"$w0_binding_path"}: return "bindings/fixture-root-policy|"+rt.typed_key(compiler.refs["w0"]) if set(v)=={"$unit25_actor_ref"}: actor_type=profile.state_recipe["actor_type"]; rule=profile.id_rules[actor_type] return _ref(profile,actor_type,"A") if rule.kind=="opaque" else _derived(profile,actor_type,({"genesis_public_key":rt.bytes_value(b"K1")} if actor_type=="ActorKeyId" else {"type_tag":"actor","canonical_bytes":rt.bytes_value(b"A")})) if set(v)=={"$typed_content_query"}: spec=v["$typed_content_query"] if family in ("C","K"): return {"op":"typed-content-id","subject_ref":_lit(spec["subject"]),"payload_ref":_lit(spec["payload"])} return {"op":"canonical-id","id_type":"RootValueId","fields":_lit({"canonical_bindings":{"typed_content_not_applicable":family}}),"rule_override":None} if set(v)=={"$lineage_record"}: return "ContentCreation" if family=="K" else state_records[-1] if set(v)=={"$lineage_key_x"}: return copy.deepcopy(compiler.refs["sx.creation" if family=="K" else "sx.$record"]) if set(v)=={"$lineage_key_y"}: return copy.deepcopy(compiler.refs["sy.creation" if family=="K" else "sy.$record"]) if set(v)=={"$old_lineage_key"}: return copy.deepcopy(compiler.refs["old_state.creation" if family=="K" else "old_state.$record"]) if set(v)=={"$lineage_relations"}: kinds=["predecessor-revision"] if family=="V": kinds.append("occurrence-value") if family=="K": kinds.append("creation-predecessor") return kinds if set(v)=={"$state_records"}: return list(state_records) if set(v)=={"$subject_records"}: return list(subject_records) if set(v)=={"$state_record"}: return state_records[-1] if set(v)=={"$value_record"}: return "RevisionValue" if family=="V" else state_records[-1] if set(v)=={"$branch_relations"}: kinds=["commit-world","commit-attempt","commit-result","commit-root"] if family=="V": kinds.append("occurrence-value") if family=="K": kinds.extend(["creation-content","creation-attempt"]) return kinds if set(v)=={"$e14_reachable"}: names=["retained_world","retained_root","retained_state","shared","x","A","attempt1"] if family=="V": names.append("retained_state.value") return _lit([copy.deepcopy(compiler.refs[x]) for x in names]) if set(v)=={"$reconstruction_relations"}: kinds=["world-root","predecessor-revision","occurrence-value","subject-state","protected-state-attempt","selection-generation","selection-world","selection-root","selection-parent","selection-policy","selection-predecessor","generation-world","generation-root","generation-parent","generation-predecessor"] if family=="K": kinds.extend(["creation-content","creation-attempt","creation-predecessor"]) return kinds if set(v)=={"$provenance_record"}: return "ContentCreation" if family=="K" else state_records[-1] if set(v)=={"$provenance_key_b"}: return copy.deepcopy(compiler.refs["yb.creation" if family=="K" else "yb.$record"]) if set(v)=={"$provenance_key_a"}: return copy.deepcopy(compiler.refs["ya.creation" if family=="K" else "ya.$record"]) if set(v)=={"$accountability_relations"}: return (["creation-content","creation-attempt"] if family=="K" else (["occurrence-value"] if family=="V" else [])) if set(v)=={"$historical_relations"}: return ["attempt-key-epoch","epoch-key",("creation-attempt" if family=="K" else "protected-state-attempt")] if set(v)=={"$protected_ref"}: symbol="real.creation" if family=="K" else "real" return copy.deepcopy(compiler.refs[symbol]) if set(v)=={"$unit24_dangling_protected"}: symbol="real.creation" if family=="K" else "real" ref=copy.deepcopy(compiler.refs[symbol]); ref["hex"]=("ff" if ref["hex"][:2]!="ff" else "ee")+ref["hex"][2:] return ref if set(v) in ({"$unit24_protected_record"},{"$unit24_protected_record_input"}): symbol="attempt1" if family=="K" else "real" record="Attempt" if family=="K" else state_records[-1] base={"op":"record","type":record,"key":_lit(compiler.refs.get(symbol+".$record",compiler.refs[symbol]))} return {"op":"field","input":base,"path":"/fields"} if "$unit24_protected_record" in v else base return {k:profile_patch(x) for k,x in v.items()} if type(v) is list: return [profile_patch(x) for x in v] return v result["queries"]=profile_patch(result["queries"]) for query in result["queries"]: if query["query_id"].endswith("_request_canonical") and query["expr"].get("op")=="canonical-json-raw": def normalize_refs(v): if type(v) is dict and v.get("$kind")=="ref" and set(v)=={"$kind","type","hex"}: return {"$kind":"ref","type":v["type"],"hex":"<ref>"} if type(v) is dict: return {k:normalize_refs(x) for k,x in v.items()} if type(v) is list: return [normalize_refs(x) for x in v] return v query["expr"]["value"]=normalize_refs(query["expr"]["value"]) result["observations_at"]=profile_patch(result["observations_at"]) for action in result["actions"]: if action["action_meta"].get("essential_for")==["protected_provenance"]: out=action["args"].get("out_ref") if action["op"]=="record.put" else None produced=compiler.refs.get(out) record_type=action["args"].get("record_type") fields=profile.record_rules[record_type].fields if record_type in profile.record_rules else {} if type(produced) is dict and (produced.get("type") not in profile.provenance_types or "authorization_evidence_ref" not in fields): action["action_meta"]={"setup_only":"profile has no independently attributable protected occurrence"} return result
def compile_all() -> dict[str,list[dict[str,Any]]]: return {pid:[compile_program(doc,PROFILES[pid]) for doc in NEUTRAL_PROGRAMS] for pid in PROFILE_IDS}
def rebind_persisted_ref(store: dict[str,Any], profile: rt.ProfileSemantics, record_type: str, match_fields: dict[str,Any]) -> dict[str,Any]: """Reconstruct one compiled symbol from persisted record content, never registers/trace.""" rt.validate_store(store,profile) if type(record_type) is not str or record_type not in profile.record_rules or type(match_fields) is not dict or not match_fields: raise rt.D001Error("MALFORMED","persisted ref query") rr=profile.record_rules[record_type] if rr.id_type is None: raise rt.D001Error("TYPE_MISMATCH","record has no semantic ref") if any(k not in rr.fields for k in match_fields): raise rt.D001Error("MALFORMED","persisted ref field") matches=[rec["key"] for rec in store["records"].values() if rec["record_type"]==record_type and all(rec["fields"][k]==v for k,v in match_fields.items())] if not matches: raise rt.D001Error("UNKNOWN","persisted ref") if len(matches)!=1: raise rt.D001Error("CONTEXT_MISMATCH","persisted ref ambiguity") return copy.deepcopy(matches[0])
def execute_program(program: dict[str,Any], profile: rt.ProfileSemantics, *, reload_path=False) -> dict[str,Any]: runtime=rt.Runtime(profile,program["initial_store"]) checkpoint=program.get("checkpoint_after") observations={} scheduled=program.get("observations_at",{}) if type(scheduled) is not dict: raise ValueError("observations_at schema") for index,action in enumerate(program["actions"]): runtime.apply(copy.deepcopy(action)) for query in scheduled.get(action["step_id"],[]): if query["query_id"] in observations: raise ValueError("duplicate scheduled observation") observations[query["query_id"]]=runtime.query(copy.deepcopy(query["expr"])) if reload_path and checkpoint is not None and index+1==checkpoint: trace=copy.deepcopy(runtime.store["trace"]); registers=copy.deepcopy(runtime.store["registers"]) runtime=rt.Runtime(profile,rt.reconstruct_store(rt.serialize_store(runtime.store),profile)) runtime.store["trace"]=trace; runtime.store["registers"]=registers for query in program["queries"]: if query["query_id"] in observations: raise ValueError("duplicate final observation") observations[query["query_id"]]=runtime.query(copy.deepcopy(query["expr"])) fresh=None if program["fresh_reconstruction"]: raw=rt.serialize_store(runtime.store); rebuilt=rt.reconstruct_store(raw,profile,fresh=True) fresh={"digest":rt.store_digest(rebuilt),"relations":sorted(rebuilt["edges"].values(),key=lambda x:(x["kind"],rt.typed_key(x["from"]),rt.typed_key(x["to"]))) } return {"profile_id":profile.name,"case_id":program["case_id"],"store_bytes":rt.serialize_store(runtime.store).hex(),"trace":copy.deepcopy(runtime.store["trace"]),"observations":observations,"fresh_reconstruction":fresh}
# Provisional external oracle templates. The compiler/runtime never consume these.# Unit 23-25 will replace the scenarios and preregistered matrix, not this DSL.ASSERTION_TEMPLATES = { "E07":[("exact-target","EQ","/alias_exact/value/target_ref",{"path":"/alias_current/value/fields/target_ref"}),("asof-second","EQ","/alias_asof/value/fields/instance_order",2),("tombstone-third","EQ","/alias_tombstone/value/fields/tombstone",True),("recreated-fourth","EQ","/alias_current/value/fields/instance_order",4)], "E08":[("two-locators","EQ","/locator_chain/value/1/record_type","LocatorVersion"),("current-bound","EQ","/current_endpoint/value/version",1),("stale-endpoint","EQ","/stale_tuple/value/endpoint","S1")], "E09":[("one-root","EQ","/roots/value/0/record_type","RootValue"),("two-generations","EQ","/generations/value/1/record_type","Generation"),("selection-nonces-distinct","NE","/selections/value/0/fields/nonce",{"path":"/selections/value/1/fields/nonce"}),("selection-parents-distinct","NE","/selections/value/0/fields/parent_ref",{"path":"/selections/value/1/fields/parent_ref"}),("selection-policies-distinct","NE","/selections/value/0/fields/policy_ref",{"path":"/selections/value/1/fields/policy_ref"})], "E10":[("five-attempts","EQ","/attempt_components/value/4/record_type","Attempt")], "E11":[("restored-version","EQ","/restored_state/value/version",1),("lifecycle-retained","EQ","/lifecycle_tombstone/status","OK"),("duplicate-no-commit","EQ","/duplicate_trace/value/error/code","ALREADY_EXISTS"),("duplicate-digest-stable","EQ","/duplicate_trace/value/before_digest",{"path":"/duplicate_trace/value/after_digest"})], "E12":[("protected-provenance","EQ","/protected_provenance/value/verified",True),("forged-rejected","EQ","/forged_metadata/status","TYPE_MISMATCH")], "E13":[("cross-type","EQ","/cross_type/status","TYPE_MISMATCH"),("fatal-code","EQ","/fatal_trace/value/error/code","FATAL_INTEGRITY_FAILURE"),("fatal-no-change","EQ","/fatal_trace/value/before_digest",{"path":"/fatal_trace/value/after_digest"})], "E14":[("classes","EQ","/mark_result/value/classes",["audit-summary","identity-strong"]),("reachable-nonempty","EQ","/mark_result/value/reachable/0",{"path":"/mark_result/value/reasons/0/target"}),("reason-class","EQ","/mark_result/value/reasons/0/retention_class","identity-strong"),("deferred-epoch","EQ","/mark_result/value/deferred_to_epoch",1),("pending-root","EQ","/roots_state/value/pending/1/0",{"path":"/mark_result/value/deferred_root"})], "E15":[("available-before","EQ","/available_trace/value/status","AVAILABLE"),("collected-before","EQ","/collected_trace/value/status","COLLECTED"),("verified-restore","EQ","/restore_verify/value/verified",True),("retained-available","EQ","/retained/status","OK")], "E16":[(x,"EQ","/"+x+"/status",status) for x,status in (("malformed","MALFORMED"),("wrong_type","TYPE_MISMATCH"),("unknown","UNKNOWN"),("tombstoned","TOMBSTONED"),("collected","CONTENT_COLLECTED"),("unavailable","UNAVAILABLE"),("resolved","RESOLVED"))], "E17":[("canonical-map-set","EQ","/map1/value/ref",{"path":"/map2/value/ref"}),("schema-diff","NE","/map1/value/ref",{"path":"/schema_diff/value/ref"}),("codec-diff","NE","/map1/value/ref",{"path":"/codec_diff/value/ref"})], "E18":[("digest-reproduced","EQ","/serialized/value/sha256",{"path":"/reconstructed/value/store_digest"}),("relations-reproduced","EQ","/relations/value",{"path":"/reconstructed/value/relations"}),("derived-nonempty","NE","/reconstructed/value/derived",{}),("opaque-nonempty","NE","/reconstructed/value/opaque",{})],}ASSERTION_DSL_VERSION = "D001-ASSERT-2"ASSERTION_CONTRACT_STAGE = "unit25-packet-faithful-E01-E18"ASSERTION_KEYS = frozenset({"assertion_id","profile_id","case_id","requirement_id","operator","operands","expected","expected_outcome","failure_rationale","purpose"})ASSERTION_OPERATORS = frozenset({"EQ","NE","STATUS_EQ","EDGE_EXISTS","FATAL"})REQUIREMENT_IDS = frozenset({"R01","R02","R03","R04","R05","R06","R07","R08"})CASE_REQUIREMENTS = {"E01":"R02","E02":"R03","E03":"R04","E04":"R04","E05":"R04","E06":"R05","E07":"R02","E08":"R04","E09":"R05","E10":"R06","E11":"R06","E12":"R03","E13":"R08","E14":"R07","E15":"R07","E16":"R01","E17":"R08","E18":"R08"}ASSERTION_STATUSES = frozenset({"OK","MALFORMED","TYPE_MISMATCH","CONTEXT_MISMATCH","UNKNOWN","TOMBSTONED","EXPIRED","CONTENT_COLLECTED","UNAVAILABLE","RESOLVED","INTERNAL_ERROR"})EXPECTED_FAILURES = {"C":{"E01","E02","E04","E05","E12"},"K":{"E04","E05"},"L":{"E01","E02","E04","E12"}}EXPECTED_VECTORS = {p:{c:("FAIL" if c in EXPECTED_FAILURES.get(p,set()) else "PASS") for c in CASE_IDS} for p in PROFILE_IDS}
def _assertion_error(where: str) -> None: raise ValueError("malformed D001-ASSERT-2: "+where)def _assertion_text(value: Any, where: str, *, neutral: bool=False) -> str: if type(value) is not str or not value.strip() or value.strip()!=value or unicodedata.normalize("NFC",value)!=value or (neutral and (len(value)>240 or any(x in value.casefold() for x in ("better","worse","winner","loser","preferred","inferior","superior")))): _assertion_error(where) return value
def _validate_pointer(path: Any, where: str) -> str: _assertion_text(path,where) if not path.startswith("/"): _assertion_error(where) for token in path[1:].split("/"): i=0 while i<len(token): if token[i]=="~": if i+1>=len(token) or token[i+1] not in "01": _assertion_error(where) i+=2 else: i+=1 return path
def _validate_descriptor(value: Any, where: str) -> None: if type(value) is not dict or set(value) not in ({"path"},{"value"}): _assertion_error(where) if "path" in value: _validate_pointer(value["path"],where+".path") else: try: rt._validate_json(value["value"]) except rt.D001Error: _assertion_error(where+".value")
def validate_assertions(assertions: Any, *, profile_id: str|None=None, case_id: str|None=None) -> list[dict[str,Any]]: if type(assertions) is not list or not assertions: _assertion_error("assertion array") seen=set() for index,a in enumerate(assertions): where="assertions["+str(index)+"]" if type(a) is not dict or set(a)!=ASSERTION_KEYS: _assertion_error(where+" keys") aid=_assertion_text(a["assertion_id"],where+".assertion_id") if aid in seen: _assertion_error("duplicate assertion_id") seen.add(aid) if type(a["profile_id"]) is not str or a["profile_id"] not in PROFILE_IDS: _assertion_error(where+".profile_id") if type(a["case_id"]) is not str or a["case_id"] not in CASE_IDS: _assertion_error(where+".case_id") if type(a["requirement_id"]) is not str or a["requirement_id"] not in REQUIREMENT_IDS or a["requirement_id"]!=CASE_REQUIREMENTS[a["case_id"]]: _assertion_error(where+".requirement_id") if profile_id is not None and a["profile_id"]!=profile_id: _assertion_error(where+" result profile") if case_id is not None and a["case_id"]!=case_id: _assertion_error(where+" result case") op=a["operator"] if type(op) is not str or op not in ASSERTION_OPERATORS or type(a["operands"]) is not dict: _assertion_error(where+".operator/operands") if op in ("EQ","NE"): if set(a["operands"])!={"left","right"}: _assertion_error(where+".operands") _validate_descriptor(a["operands"]["left"],where+".operands.left"); _validate_descriptor(a["operands"]["right"],where+".operands.right") if a["expected"] is not True: _assertion_error(where+".expected") elif op=="STATUS_EQ": if set(a["operands"])!={"actual"}: _assertion_error(where+".operands") _validate_descriptor(a["operands"]["actual"],where+".operands.actual") if type(a["expected"]) is not str or a["expected"] not in ASSERTION_STATUSES: _assertion_error(where+".expected") elif op=="EDGE_EXISTS": if set(a["operands"])!={"relation_set","edge"}: _assertion_error(where+".operands") _validate_descriptor(a["operands"]["relation_set"],where+".operands.relation_set"); edge=a["operands"]["edge"] if type(edge) is not dict or set(edge)!={"kind","from","to"}: _assertion_error(where+".operands.edge") _assertion_text(edge["kind"],where+".operands.edge.kind"); _validate_descriptor(edge["from"],where+".operands.edge.from"); _validate_descriptor(edge["to"],where+".operands.edge.to") if a["expected"] is not True: _assertion_error(where+".expected") else: if set(a["operands"])!={"event"}: _assertion_error(where+".operands") _validate_descriptor(a["operands"]["event"],where+".operands.event"); _assertion_text(a["expected"],where+".expected") if a["expected_outcome"] not in ("PASS","FAIL"): _assertion_error(where+".expected_outcome") if a["expected_outcome"]=="FAIL": _assertion_text(a["failure_rationale"],where+".failure_rationale",neutral=True) elif a["failure_rationale"] is not None: _assertion_error(where+".failure_rationale") _assertion_text(a["purpose"],where+".purpose",neutral=True) return assertions
def _unit23_direct_rows(profile: str, case: str) -> list[tuple]: family=PROFILES[profile].state_recipe["family"] P=lambda path:{"path":"/observations"+path}; V=lambda value:{"value":value} eq=lambda name,left,right:(name,"EQ",{"left":P(left),"right":P(right) if type(right) is str and right.startswith("/") else V(right)}) ne=lambda name,left,right:(name,"NE",{"left":P(left),"right":P(right) if type(right) is str and right.startswith("/") else V(right)}) edge=lambda name,kind,fr,to:(name,"EDGE_EXISTS",{"relation_set":P(("/lineage" if case=="E01" else "/state_relations")+"/value"),"edge":{"kind":kind,"from":P(fr),"to":P(to)}}) if case=="E01": rows=[ne("payload-x-y","/payload_x/value","/payload_y/value"),(eq("mutable-subject-stable","/sx_ref/value","/sy_ref/value") if family=="L" else ne("exact-successor-ref","/sx_ref/value","/sy_ref/value")),eq("binding-exact-successor","/successor_binding/value/value","/sy_ref/value")] if family=="V": rows += [eq("value-x-payload","/sx_value_record/value/payload_ref","/payload_x/value"),eq("value-y-payload","/sy_value_record/value/payload_ref","/payload_y/value"),eq("occurrence-x-value","/sx_record/value/revision_value_ref","/sx_value_record/value/id"),eq("occurrence-y-value","/sy_record/value/revision_value_ref","/sy_value_record/value/id"),eq("exact-predecessor","/sy_record/value/predecessor_occurrence_refs/0","/sx_ref/value"),edge("lineage-edge","predecessor-revision","/sy_ref/value","/sx_ref/value"),edge("successor-value-edge","occurrence-value","/sy_ref/value","/sy_value_record/value/id")] elif family in ("O","H"): rows += [eq("state-x-payload","/sx_record/value/payload_ref","/payload_x/value"),eq("state-y-payload","/sy_record/value/payload_ref","/payload_y/value"),eq("exact-predecessor","/sy_record/value/"+("predecessor_revision_refs" if family=="O" else "predecessor_refs")+"/0","/sx_ref/value"),edge("lineage-edge","predecessor-revision","/sy_ref/value","/sx_ref/value")] elif family=="L": rows += [eq("state-x-payload","/sx_record/value/payload_ref","/payload_x/value"),eq("state-y-payload","/sy_record/value/payload_ref","/payload_y/value"),edge("exact-predecessor","predecessor-revision","/sy_ref/value","/sx_ref/value")] else: rows += [eq("typed-content-x","/sx_record/value/id","/typed_x/value/ref"),eq("typed-content-y","/sy_record/value/id","/typed_y/value/ref"),eq("typed-preimage-x","/sx_record/value/canonical_bytes","/typed_x/value/canonical_bytes"),eq("typed-preimage-y","/sy_record/value/canonical_bytes","/typed_y/value/canonical_bytes")] return rows if case=="E02": rows=[ne("actors-distinct","/attempt_b/value/actor_ref","/attempt_a/value/actor_ref"),ne("commitments-distinct","/attempt_b/value/commitment_ref","/attempt_a/value/commitment_ref"),ne("attempts-distinct","/attempt_b/value/id","/attempt_a/value/id")] if family=="V": rows += [eq("equal-revision-value","/yb_value_ref/value","/ya_value_ref/value"),ne("occurrences-distinct","/yb_ref/value","/ya_ref/value"),eq("b-attribution","/yb_record/value/actor_ref","/attempt_b/value/actor_ref"),eq("a-attribution","/ya_record/value/commitment_ref","/attempt_a/value/commitment_ref"),edge("b-occurrence-value-edge","occurrence-value","/yb_ref/value","/yb_value_ref/value"),edge("a-occurrence-value-edge","occurrence-value","/ya_ref/value","/ya_value_ref/value")] elif family in ("O","H"): rows += [eq("equal-content","/yb_record/value/payload_ref","/ya_record/value/payload_ref"),ne("accountable-states-distinct","/yb_ref/value","/ya_ref/value"),eq("b-attribution","/yb_record/value/actor_ref","/attempt_b/value/actor_ref"),eq("a-attribution","/ya_record/value/commitment_ref","/attempt_a/value/commitment_ref")] elif family=="K": rows += [eq("equal-content","/yb_ref/value","/ya_ref/value"),eq("b-attribution","/attempt_b/value/actor_ref","/actor_b_ref/value"),eq("b-commitment","/attempt_b/value/commitment_ref","/commitment_c2_ref/value"),eq("a-attribution","/attempt_a/value/actor_ref","/actor_a_ref/value"),eq("a-commitment","/attempt_a/value/commitment_ref","/commitment_c3_ref/value")] elif family=="L": rows += [eq("equal-content","/yb_record/value/payload_ref","/ya_record/value/payload_ref"),ne("accountable-occurrences-distinct","/yb_ref/value","/ya_ref/value")] else: rows += [eq("equal-content","/yb_ref/value","/ya_ref/value"),ne("accountable-occurrences-distinct","/yb_ref/value","/ya_ref/value")] return rows if case=="E03": return [eq("actor-continuity","/actor_original/value","/actor_restored/value"),ne("execution-changed","/e1_record/value/id","/e2_record/value/id"),eq("execution-actor-restored","/e2_record/value/actor_ref","/actor_restored/value"),eq("destroyed-target","/destroyed/value/target_ref","/e1_record/value/id"),eq("destroyed-state","/destroyed/value/state","DESTROYED"),eq("restored-exact-state","/restored_binding/value/value","/state_ref/value")] if case=="E04": rows=[eq("actor-continuity","/epoch_1/value/actor_ref","/epoch_2/value/actor_ref"),ne("key-materials-distinct","/material_1/value/id","/material_2/value/id"),ne("keys-distinct","/epoch_1/value/key_ref","/epoch_2/value/key_ref"),ne("epochs-distinct","/epoch_1/value/epoch","/epoch_2/value/epoch"),eq("historical-evidence","/epoch_1/value/authorization_evidence_ref","/old_attempt/value/authorization_evidence_ref")] if family in ("H","V","O"): rows += [eq("historical-actor","/old_state/value/actor_ref","/epoch_1/value/actor_ref"),eq("historical-evidence-state","/old_state/value/authorization_evidence_ref","/epoch_1/value/authorization_evidence_ref")] else: rows += [eq("historical-actor","/old_attempt/value/actor_ref","/epoch_1/value/actor_ref")] return rows if case=="E05": rows=[ne("clone-actor-distinct","/actor_ref/value","/clone_ref/value"),eq("bind-only-reuses-exact","/bind_only/value/value","/source_ref/value"),eq("bind-only-action-kind","/bind_only_trace/value/op","index.set")] if family=="V": rows += [eq("repeat-same-value","/source_value_ref/value","/repeat_value_ref/value"),ne("repeat-new-occurrence","/source_ref/value","/repeat_ref/value"),ne("new-subject-value","/source_value_ref/value","/new_value_ref/value"),ne("new-subject-occurrence","/source_ref/value","/new_ref/value")] elif family in ("O","H"): rows += [ne("repeat-new-revision","/source_ref/value","/repeat_ref/value"),eq("repeat-equal-content","/source_record/value/payload_ref","/repeat_record/value/payload_ref"),ne("new-subject-revision","/source_ref/value","/new_ref/value")] else: rows += [eq("repeat-content-identity","/source_ref/value","/repeat_ref/value"),ne("new-subject-state-identity","/source_ref/value","/new_ref/value")] return rows if case=="E06": return [eq("equal-root-record","/r1_record/value","/r1_ref/value"),ne("world-w0-w1","/w0_ref/value","/w1_ref/value"),ne("world-w1-w2","/w1_ref/value","/w2_ref/value"),eq("equal-result-roots","/r1_ref/value","/r2_ref/value"),ne("w0-root-unchanged","/r0_ref/value","/r1_ref/value"),eq("w0-binding-exact","/w0_root_binding/value/value","/r0_ref/value"),ne("branch-attempts-distinct","/child1/value/id","/child2/value/id"),eq("branch1-attribution","/branch1_binding/value/value","/child1/value/id"),eq("branch2-attribution","/branch2_binding/value/value","/child2/value/id"),eq("child1-actor","/child1/value/actor_ref","/child2/value/actor_ref")] raise AssertionError(case)
def _unit23_rows(profile: str, case: str) -> list[tuple[str,str,str,dict[str,Any]]]: """Map concrete direct predicates to the fixed semantic roles without consulting role metadata.""" family=PROFILES[profile].state_recipe["family"] rows=_unit23_direct_rows(profile,case) # Ref literals remain admissible only when dependency closure rejoins each value to an exact producer action. role_by_name={ "E01": {"typed-payload-grounding":{"payload-x-y","state-x-payload","state-y-payload","value-x-payload","value-y-payload","typed-content-x","typed-content-y","typed-preimage-x","typed-preimage-y","occurrence-x-value","occurrence-y-value","successor-value-edge"},"exact-successor":{"mutable-subject-stable","exact-successor-ref","binding-exact-successor"},"exact-predecessor":{"exact-predecessor","lineage-edge","immutable-no-predecessor-edge"}}, "E02": {"equal-content":{"equal-content","equal-revision-value","b-occurrence-value-edge","a-occurrence-value-edge"},"distinct-attempts":{"actors-distinct","commitments-distinct","attempts-distinct"},"protected-accountable-occurrence":{"accountable-occurrences-distinct","accountable-states-distinct","occurrences-distinct","b-attribution","a-attribution","b-commitment","a-commitment","protected-b-attempt","protected-a-attempt","protected-b-actor","protected-a-actor","protected-b-commitment","protected-a-commitment","protected-b-evidence","protected-a-evidence","protected-b-attempt-edge","protected-a-attempt-edge","protected-b-content","protected-a-content","protected-b-content-edge","protected-a-content-edge"}}, "E03": {"actor-continuity":{"actor-continuity","execution-actor-restored","restored-exact-actor"},"all-old-executions-destroyed":{"execution-changed","destroyed-target","destroyed-state","destroyed-target-2","destroyed-state-2","new-execution-active"},"persisted-restore":{"restored-exact-state","restore-trace-write"}}, "E04": {"rotation-actor-continuity":{"actor-continuity"},"historical-epoch-attribution":{"key-materials-distinct","keys-distinct","epochs-distinct","historical-evidence","historical-actor","historical-evidence-state","epoch1-evidence-exact","epoch2-evidence-exact","epoch-evidence-unique","old-lineage-attempt","old-protected-attempt-edge","old-creation-content","attempt-epoch-edge","epoch-key1-edge","epoch-key2-edge"}}, "E05": {"clone-separation":{"clone-actor-distinct"},"bind-only-no-occurrence":{"bind-only-reuses-exact","bind-only-action-kind","bind-only-one-binding-write","bind-only-no-record-write","bind-only-no-edge-write","bind-only-no-allocation-write"},"repeat-and-new-subject-semantics":{"repeat-same-value","repeat-new-occurrence","new-subject-value","new-subject-occurrence","repeat-new-revision","repeat-equal-content","new-subject-revision","repeat-content-identity","new-subject-state-identity","new-subject-exact"}}, "E06": {"world-and-root-confinement":{"equal-root-record","world-w0-w1","world-w1-w2","equal-result-roots","w0-root-unchanged","w0-binding-exact","w0-root-subvalue-stable","w0-write-key-excluded"},"branch-commit-operations":{"branch-attempts-distinct","branch1-trace-committed","branch2-trace-committed","branch-results-equal","first-root-derivation","second-root-derivation","first-root-canonical","second-root-canonical"},"branch-attributable-occurrences":{"branch1-attribution","branch2-attribution","child1-actor","branch-occurrences-distinct","commit1-world","commit2-world","commit1-result","commit2-result","commit1-root","commit2-root","commit1-attempt","commit2-attempt","commit1-world-edge","commit2-world-edge","commit1-result-edge","commit2-result-edge","commit1-attempt-edge","commit2-attempt-edge","commit1-root-edge","commit2-root-edge"}}, } P=lambda path:{"path":"/observations"+path}; V=lambda value:{"value":value} eq=lambda name,left,right:(name,"EQ",{"left":P(left),"right":P(right) if type(right) is str and right.startswith("/") else V(right)}) ne=lambda name,left,right:(name,"NE",{"left":P(left),"right":P(right) if type(right) is str and right.startswith("/") else V(right)}) edge=lambda name,kind,fr,to,root:(name,"EDGE_EXISTS",{"relation_set":P(root+"/value"),"edge":{"kind":kind,"from":P(fr),"to":P(to)}}) if case=="E01" and family=="C": rows += [edge("exact-predecessor","predecessor-revision","/sy_ref/value","/sx_ref/value","/lineage")] if case=="E01" and family=="K": rows += [eq("exact-predecessor","/sy_lineage_record/value/predecessor_creation_ref","/sx_lineage_record/value/id"),edge("lineage-edge","creation-predecessor","/sy_lineage_record/value/id","/sx_lineage_record/value/id","/lineage")] if case=="E02" and family=="K": rows += [eq("protected-b-attempt","/protected_b/value/attempt_ref","/attempt_b/value/id"),eq("protected-a-attempt","/protected_a/value/attempt_ref","/attempt_a/value/id"),eq("protected-b-actor","/protected_b/value/actor_ref","/attempt_b/value/actor_ref"),eq("protected-a-actor","/protected_a/value/actor_ref","/attempt_a/value/actor_ref"),eq("protected-b-commitment","/protected_b/value/commitment_ref","/attempt_b/value/commitment_ref"),eq("protected-a-commitment","/protected_a/value/commitment_ref","/attempt_a/value/commitment_ref"),eq("protected-b-evidence","/protected_b/value/authorization_evidence_ref","/attempt_b/value/authorization_evidence_ref"),eq("protected-a-evidence","/protected_a/value/authorization_evidence_ref","/attempt_a/value/authorization_evidence_ref"),edge("protected-b-attempt-edge","creation-attempt","/protected_b/value/id","/attempt_b/value/id","/state_relations"),edge("protected-a-attempt-edge","creation-attempt","/protected_a/value/id","/attempt_a/value/id","/state_relations"),eq("protected-b-content","/protected_b/value/content_ref","/yb_ref/value"),eq("protected-a-content","/protected_a/value/content_ref","/ya_ref/value"),edge("protected-b-content-edge","creation-content","/protected_b/value/id","/yb_ref/value","/state_relations"),edge("protected-a-content-edge","creation-content","/protected_a/value/id","/ya_ref/value","/state_relations")] elif case=="E02" and family in ("H","V","O"): rows += [eq("protected-b-attempt","/protected_b/value/attempt_ref","/attempt_b/value/id"),eq("protected-a-attempt","/protected_a/value/attempt_ref","/attempt_a/value/id"),eq("protected-b-actor","/protected_b/value/actor_ref","/attempt_b/value/actor_ref"),eq("protected-a-actor","/protected_a/value/actor_ref","/attempt_a/value/actor_ref"),eq("protected-b-commitment","/protected_b/value/commitment_ref","/attempt_b/value/commitment_ref"),eq("protected-a-commitment","/protected_a/value/commitment_ref","/attempt_a/value/commitment_ref"),eq("protected-b-evidence","/protected_b/value/authorization_evidence_ref","/attempt_b/value/authorization_evidence_ref"),eq("protected-a-evidence","/protected_a/value/authorization_evidence_ref","/attempt_a/value/authorization_evidence_ref")] if case=="E03": rows=[eq("actor-continuity","/actor_original/value","/restored_actor/value/value"),eq("execution-actor-restored","/e3_record/value/actor_ref","/restored_actor/value/value"),ne("execution-changed","/e1_record/value/id","/e3_record/value/id"),eq("destroyed-target","/destroyed_1/value/target_ref","/e1_record/value/id"),eq("destroyed-state","/destroyed_1/value/state","DESTROYED"),eq("destroyed-target-2","/destroyed_2/value/target_ref","/e2_record/value/id"),eq("destroyed-state-2","/destroyed_2/value/state","DESTROYED"),eq("new-execution-active","/restored_active/value/value/0","/e3_record/value/id"),eq("restored-exact-state","/restored_state/value/value","/state_ref/value"),eq("restored-exact-actor","/restored_actor/value/value","/actor_original/value"),eq("restore-trace-write","/restore_trace/value/op","snapshot.restore")] elif case=="E04": rows += [eq("epoch1-evidence-exact","/epoch_1/value/authorization_evidence_ref","/epoch_auth1/value"),eq("epoch2-evidence-exact","/epoch_2/value/authorization_evidence_ref","/epoch_auth2/value"),ne("epoch-evidence-unique","/epoch_auth1/value","/epoch_auth2/value"),edge("attempt-epoch-edge","attempt-key-epoch","/old_attempt/value/id","/epoch_1/value/id","/historical_relations"),edge("epoch-key1-edge","epoch-key","/epoch_1/value/id","/epoch_1/value/key_ref","/historical_relations"),edge("epoch-key2-edge","epoch-key","/epoch_2/value/id","/epoch_2/value/key_ref","/historical_relations")] if family in ("K","H","V","O"): rows += [eq("old-lineage-attempt","/old_lineage/value/attempt_ref","/old_attempt/value/id")] rows += [edge("old-protected-attempt-edge",("creation-attempt" if family=="K" else "protected-state-attempt"),("/old_lineage/value/id" if family=="K" else "/old_state_ref/value"),"/old_attempt/value/id","/historical_relations")] if family=="K": rows += [eq("old-creation-content","/old_lineage/value/content_ref","/old_state_ref/value")] elif case=="E05": rows += [eq("bind-only-one-binding-write","/bind_only_effects/value/binding_writes",1),eq("bind-only-no-record-write","/bind_only_effects/value/record_writes",0),eq("bind-only-no-edge-write","/bind_only_effects/value/edge_writes",0),eq("bind-only-no-allocation-write","/bind_only_effects/value/allocation_writes",0)] if family in ("H","O"): rows += [eq("new-subject-exact","/new_record/value/subject_or_slot_ref","/new_subject_ref/value")] elif case=="E06": rows=[eq("equal-root-record","/r1_record/value","/r1_ref/value"),ne("world-w0-w1","/w0_ref/value","/w1_ref/value"),ne("world-w1-w2","/w1_ref/value","/w2_ref/value"),eq("equal-result-roots","/r1_ref/value","/r2_ref/value"),ne("w0-root-unchanged","/r0_ref/value","/r1_ref/value"),eq("w0-binding-exact","/w0_after/value/value","/r0_ref/value"),eq("w0-root-subvalue-stable","/w0_before/value/value","/w0_after/value/value"),eq("w0-write-key-excluded","/w0_write_confinement/value/excluded",True),ne("branch-attempts-distinct","/child1/value/id","/child2/value/id"),eq("branch1-trace-committed","/branch1_trace/value/0/status","COMMITTED"),eq("branch2-trace-committed","/branch2_trace/value/0/status","COMMITTED"),eq("branch-results-equal",("/branch1_record/value/payload_ref" if family in ("H","O") else "/branch1_value_ref/value"),("/branch2_record/value/payload_ref" if family in ("H","O") else "/branch2_value_ref/value")),eq("first-root-derivation","/r1_derivation/value","/r1_ref/value"),eq("second-root-derivation","/r2_derivation/value","/r2_ref/value"),eq("first-root-canonical","/r1_canonical/value/ref","/r1_ref/value"),eq("second-root-canonical","/r2_canonical/value/ref","/r2_ref/value"),eq("branch1-attribution","/branch1_context/value/value/attempt_ref","/child1/value/id"),eq("branch2-attribution","/branch2_context/value/value/attempt_ref","/child2/value/id"),eq("child1-actor","/child1/value/actor_ref","/child2/value/actor_ref"),ne("branch-occurrences-distinct","/branch1_commit/value/id","/branch2_commit/value/id"),eq("commit1-world","/branch1_commit/value/world_ref","/w1_ref/value"),eq("commit2-world","/branch2_commit/value/world_ref","/w2_ref/value"),eq("commit1-result","/branch1_commit/value/result_ref","/branch1_ref/value"),eq("commit2-result","/branch2_commit/value/result_ref","/branch2_ref/value"),eq("commit1-root","/branch1_commit/value/root_ref","/r1_ref/value"),eq("commit2-root","/branch2_commit/value/root_ref","/r2_ref/value"),eq("commit1-attempt","/branch1_commit/value/attempt_ref","/child1/value/id"),eq("commit2-attempt","/branch2_commit/value/attempt_ref","/child2/value/id"),edge("commit1-world-edge","commit-world","/branch1_commit/value/id","/w1_ref/value","/branch_relations"),edge("commit2-world-edge","commit-world","/branch2_commit/value/id","/w2_ref/value","/branch_relations"),edge("commit1-result-edge","commit-result","/branch1_commit/value/id","/branch1_ref/value","/branch_relations"),edge("commit2-result-edge","commit-result","/branch2_commit/value/id","/branch2_ref/value","/branch_relations"),edge("commit1-attempt-edge","commit-attempt","/branch1_commit/value/id","/child1/value/id","/branch_relations"),edge("commit2-attempt-edge","commit-attempt","/branch2_commit/value/id","/child2/value/id","/branch_relations"),edge("commit1-root-edge","commit-root","/branch1_commit/value/id","/r1_ref/value","/branch_relations"),edge("commit2-root-edge","commit-root","/branch2_commit/value/id","/r2_ref/value","/branch_relations")] result=[] for name,op,operands in rows: found=[role for role,names in role_by_name[case].items() if name in names] if len(found)!=1: raise AssertionError("unassigned unit23 predicate "+case+"/"+name) result.append((found[0],name,op,operands)) return result
def _unit24_rows(profile: str, case: str) -> list[tuple[str,str,str,dict[str,Any],Any]]: P=lambda x:{"path":"/observations"+x}; V=lambda x:{"value":x} eq=lambda n,a,b:(n,"EQ",{"left":P(a),"right":P(b) if type(b) is str and b.startswith("/") else V(b)},True) ne=lambda n,a,b:(n,"NE",{"left":P(a),"right":P(b) if type(b) is str and b.startswith("/") else V(b)},True) st=lambda n,a,b:(n,"STATUS_EQ",{"actual":P(a)},b) role_names={ "E07":{"immutable-alias-version":{"av1-target-stable","av1-order","av1-exact"},"alias-version-chain":{"av2-pred","at-pred","av4-pred","av2-order","at-order","av4-order","versions-distinct"},"exact-alias-resolution":{"current-status","current-version","current-target","asof1-version","asof1-target","asof2-version","asof2-target","asof2-subject","asof3-status","asof3-version","asof4-version","asof4-target"}}, "E08":{"stable-semantic-target":{"targets-stable","locator-ids-distinct","occupants-distinct"},"locator-version-chain":{"l1-endpoint","l1-target","l2-endpoint","l2-target","l2-pred","l1-order","l2-order","a-current-binding","l1-history-status","l1-history-version","l1-history-target","l2-history-status","l2-history-version","l2-history-target","a-resolver-status","a-resolver-version","a-resolver-target"},"endpoint-reuse-occupancy":{"l3-reuses-s1","l3-target","s1-fixture-current","b-current-binding","b-resolver-status","b-resolver-version","b-resolver-target"}}, "E09":{"equal-root-context":{"g1-root","g2-root","g3-root","s1-root","s2-root","s3-root","g1-g2-distinct","g1-g3-distinct","g2-g3-distinct","s1-s2-distinct","s1-s3-distinct","s2-s3-distinct"},"generation-selection-relations":{"g1-world","g2-world","g3-world","s1-world","s2-world","s3-world","s1-generation","s2-generation","s3-generation","g1-parent","g2-parent","g3-parent","s1-parent","s2-parent","s3-parent","p1-p2-distinct","p1-p3-distinct","p2-p3-distinct"},"transition-order-context":{"s1-kind","s2-kind","s3-kind","g1-order","g2-order","g3-order","s1-order","s2-order","s3-order","s1-nonce","s2-nonce","s3-nonce","n1-n2-distinct","n1-n3-distinct","n2-n3-distinct","p1-policy","p2-policy","p3-policy","policy1-policy2-distinct","policy1-policy3-distinct","policy2-policy3-distinct"}}, "E10":{"fresh-attempt-identity":{"fresh-id-observed","fresh-nonce"},"stale-dimension-isolation":set()}, "E11":{"restored-protected-state":{"restored-live","restored-version","snapshot-label"},"later-lifecycle-summary":{"life-target","life-state","life-tombstone","life-order","snapshot-excludes-lifecycle"},"allocation-nonreuse":{"duplicate-status","duplicate-code","duplicate-digest","duplicate-ref-exact","live-identity-target","snapshot-excludes-allocation"}}, "E12":{"protected-occurrence-grounding":{"protected-ref","protected-actor","genuine-verified","genuine-match","genuine-actor","genuine-commitment","genuine-evidence","genuine-causal"},"copied-claim-nonmatch":{"copy-not-match"}}, } if case=="E07": rows=[eq("av1-target-stable","/av1_record/value/target_ref","/asof_av1/denotation_ref"),eq("av1-order","/av1_record/value/instance_order",1),eq("av1-exact","/av1_exact/denotation_ref","/av1_record/value/id"),eq("av2-pred","/av2_record/value/predecessor_ref","/av1_record/value/id"),eq("at-pred","/at_record/value/predecessor_ref","/av2_record/value/id"),eq("av4-pred","/av4_record/value/predecessor_ref","/at_record/value/id"),eq("av2-order","/av2_record/value/instance_order",2),eq("at-order","/at_record/value/instance_order",3),eq("av4-order","/av4_record/value/instance_order",4),ne("versions-distinct","/av1_record/value/id","/av4_record/value/id"),st("current-status","/alias_current/status","RESOLVED"),eq("current-version","/alias_current/matched_version_ref","/av4_record/value/id"),eq("current-target","/alias_current/denotation_ref","/av4_record/value/target_ref"),eq("asof1-version","/asof_av1/matched_version_ref","/av1_record/value/id"),eq("asof1-target","/asof_av1/denotation_ref","/av1_record/value/target_ref"),eq("asof2-version","/asof_av2/matched_version_ref","/av2_record/value/id"),eq("asof2-target","/asof_av2/denotation_ref","/av2_record/value/target_ref"),eq("asof2-subject","/asof_av2/denotation_ref","/subject_ref/value"),st("asof3-status","/asof_at/status","TOMBSTONED"),eq("asof3-version","/asof_at/matched_version_ref","/at_record/value/id"),eq("asof4-version","/asof_av4/matched_version_ref","/av4_record/value/id"),eq("asof4-target","/asof_av4/denotation_ref","/av4_record/value/target_ref")] elif case=="E08": rows=[eq("targets-stable","/l1_record/value/target_ref","/l2_record/value/target_ref"),ne("locator-ids-distinct","/l1_ref/value","/l2_ref/value"),ne("occupants-distinct","/a_ref/value","/b_ref/value"),eq("l1-endpoint","/l1_record/value/endpoint","S1"),eq("l1-target","/l1_record/value/target_ref","/a_ref/value"),eq("l2-endpoint","/l2_record/value/endpoint","S2"),eq("l2-target","/l2_record/value/target_ref","/a_ref/value"),eq("l2-pred","/l2_record/value/predecessor_ref","/l1_ref/value"),eq("l1-order","/l1_record/value/instance_order",1),eq("l2-order","/l2_record/value/instance_order",2),eq("a-current-binding","/a_current/value/value","/l2_ref/value"),st("l1-history-status","/l1_historical/status","RESOLVED"),eq("l1-history-version","/l1_historical/matched_version_ref",None),eq("l1-history-target","/l1_historical/denotation_ref","/l1_ref/value"),st("l2-history-status","/l2_historical/status","RESOLVED"),eq("l2-history-version","/l2_historical/matched_version_ref",None),eq("l2-history-target","/l2_historical/denotation_ref","/l2_ref/value"),st("a-resolver-status","/a_current_resolved/status","RESOLVED"),eq("a-resolver-version","/a_current_resolved/matched_version_ref","/l2_ref/value"),eq("a-resolver-target","/a_current_resolved/denotation_ref","/a_ref/value"),eq("l3-reuses-s1","/l3_record/value/endpoint","/l1_record/value/endpoint"),eq("l3-target","/l3_record/value/target_ref","/b_ref/value"),eq("s1-fixture-current","/s1_fixture_current/value/key","/l3_ref/value"),eq("b-current-binding","/b_current/value/value","/l3_ref/value"),st("b-resolver-status","/b_current_resolved/status","RESOLVED"),eq("b-resolver-version","/b_current_resolved/matched_version_ref","/l3_ref/value"),eq("b-resolver-target","/b_current_resolved/denotation_ref","/b_ref/value")] elif case=="E09": rows=[eq(f"g{i}-root",f"/g{i}/value/root_ref","/root_ref/value") for i in (1,2,3)]+[eq(f"s{i}-root",f"/s{i}/value/root_ref","/root_ref/value") for i in (1,2,3)] for prefix in ("g","s"): for a,b in ((1,2),(1,3),(2,3)): rows.append(ne(f"{prefix}{a}-{prefix}{b}-distinct",f"/{prefix}{a}/value/id",f"/{prefix}{b}/value/id")) rows += [eq(f"g{i}-world",f"/g{i}/value/world_ref","/world_ref/value") for i in (1,2,3)]+[eq(f"s{i}-world",f"/s{i}/value/world_ref","/world_ref/value") for i in (1,2,3)]+[eq(f"s{i}-generation",f"/s{i}/value/generation_ref",f"/g{i}/value/id") for i in (1,2,3)] for i,k in ((1,"forward"),(2,"rollback"),(3,"forward")): rows += [eq(f"g{i}-parent",f"/g{i}/value/parent_ref",f"/p{i}_ref/value"),eq(f"s{i}-parent",f"/s{i}/value/parent_ref",f"/p{i}_ref/value"),eq(f"s{i}-kind",f"/s{i}/value/kind",k),eq(f"g{i}-order",f"/g{i}/value/transition_order",i),eq(f"s{i}-order",f"/s{i}/value/transition_order",i),eq(f"s{i}-nonce",f"/s{i}/value/nonce",f"n{i}"),eq(f"p{i}-policy",f"/s{i}/value/policy_ref",f"/policy{i}_ref/value")] for a,b in ((1,2),(1,3),(2,3)): rows += [ne(f"p{a}-p{b}-distinct",f"/g{a}/value/parent_ref",f"/g{b}/value/parent_ref"),ne(f"n{a}-n{b}-distinct",f"/s{a}/value/nonce",f"/s{b}/value/nonce"),ne(f"policy{a}-policy{b}-distinct",f"/s{a}/value/policy_ref",f"/s{b}/value/policy_ref")] elif case=="E10": rows=[eq("fresh-id-observed","/fresh_attempt/value/id","/fresh_ref_observed/value"),eq("fresh-nonce","/fresh_attempt/value/nonce","fresh")] for stale in ("nonce","parent","policy","evidence"): for dim in ("nonce","parent","policy","evidence"): key=dim if dim=="nonce" else dim+"_ref"; n=stale+"-"+dim+("-mismatch" if stale==dim else "-equal"); role_names[case]["stale-dimension-isolation"].add(n); rows.append(eq(n,f"/stale_{stale}_cmp/value/components/{key}/equal",stale!=dim)) elif case=="E11": rows=[eq("restored-live","/restored_state/value/value","/live_ref/value"),eq("restored-version","/restored_state/value/version",1),eq("snapshot-label","/snapshot_record/value/label",DEFERRED_LABELS["snapshot"]),eq("life-target","/lifecycle_tombstone/value/target_ref","/live_ref/value"),eq("life-state","/lifecycle_tombstone/value/state","TOMBSTONED"),eq("life-tombstone","/lifecycle_tombstone/value/tombstone",True),eq("life-order","/lifecycle_tombstone/value/instance_order",1),eq("duplicate-status","/duplicate_trace/value/status","NO_COMMIT"),eq("duplicate-code","/duplicate_trace/value/error/code","ALREADY_EXISTS"),eq("duplicate-digest","/duplicate_trace/value/before_digest","/duplicate_trace/value/after_digest"),eq("duplicate-ref-exact","/duplicate_trace/value/error/detail/ref","/live_identity/value"),eq("live-identity-target",("/live_identity/value/subject" if profile=="L" else "/live_identity/value"),"/live_ref/value"),eq("snapshot-excludes-allocation","/snapshot_has_allocations/value/present",False),eq("snapshot-excludes-lifecycle","/snapshot_has_lifecycle/value/present",False)] elif case=="E12": causal=[] if profile in ("K","V","O","S-V","S-O") else None rows=[eq("protected-ref","/protected_provenance/value/occurrence_ref","/protected_ref/value"),eq("protected-actor","/protected_actor/value","/actor_ref/value"),eq("genuine-verified","/protected_provenance/value/verified",True),eq("genuine-match","/protected_provenance/value/match_status","MATCH"),eq("genuine-actor","/protected_provenance/value/actor_ref","/actor_ref/value"),eq("genuine-commitment","/protected_provenance/value/commitment_ref","/commitment_ref/value"),eq("genuine-evidence","/protected_provenance/value/evidence_ref","/auth_ref/value"),eq("genuine-causal","/protected_provenance/value/causal_inputs",causal),ne("copy-not-match","/copied_provenance/value/match_status","MATCH")] result=[] for row in rows: found=[r for r,names in role_names[case].items() if row[0] in names] if len(found)!=1: raise AssertionError("unassigned unit24 predicate "+case+"/"+row[0]) result.append((found[0],)+row) return result
def _unit25_rows(profile: str, case: str) -> list[tuple[str,str,str,dict[str,Any],Any]]: P=lambda x:{"path":"/observations"+x}; V=lambda x:{"value":x} eq=lambda r,n,a,b:(r,n,"EQ",{"left":P(a),"right":P(b) if type(b) is str and b.startswith("/") else V(b)},True) ne=lambda r,n,a,b:(r,n,"NE",{"left":P(a),"right":P(b) if type(b) is str and b.startswith("/") else V(b)},True) st=lambda r,n,a,b:(r,n,"STATUS_EQ",{"actual":P(a)},b) fatal=lambda r,n,a:(r,n,"FATAL",{"event":P(a)},"FATAL_INTEGRITY_FAILURE") edge=lambda r,n,k,a,b,root="/retention_relations/value":(r,n,"EDGE_EXISTS",{"relation_set":P(root),"edge":{"kind":k,"from":P(a),"to":P(b)}},True) if case=="E13": return [ eq("typed-domain-separation","same-raw-bytes","/original_before/value/key/hex","/cross_digest_record/value/key/hex"),ne("typed-domain-separation","typed-refs-distinct","/original_before/value/key","/cross_digest_record/value/key"),st("typed-domain-separation","cross-resolved","/cross_resolved/status","RESOLVED"),st("typed-domain-separation","cross-type-mismatch","/cross_type_lookup/status","TYPE_MISMATCH"), fatal("fatal-integrity-atomicity","fatal-event","/fatal_trace/value"),eq("fatal-integrity-atomicity","fatal-digest-stable","/fatal_trace/value/before_digest","/fatal_trace/value/after_digest"),eq("fatal-integrity-atomicity","original-survives","/original_before/value","/original_after/value"),eq("fatal-integrity-atomicity","digest-record-present","/records_after/value/0/record_type","PayloadDigestRecord"),eq("fatal-integrity-atomicity","envelope-record-present","/records_after/value/1/record_type","PayloadEnvelope"), eq("post-fatal-policy","later-commits","/post_fatal_trace/value/status","COMMITTED"),eq("post-fatal-policy","later-op","/post_fatal_trace/value/op","availability.set")] if case=="E14": return [ eq("frozen-root-pin-provenance","epoch","/frozen_epoch/value/epoch",0),eq("frozen-root-pin-provenance","mark-reconciled","/frozen_epoch/value/mark","/mark_result/value"),eq("frozen-root-pin-provenance","root-world","/frozen_epoch/value/root_refs/0","/retained_world_ref/value"),eq("frozen-root-pin-provenance","pin-ref","/frozen_epoch/value/pins/0/pin_ref","/pin_ref/value"),eq("frozen-root-pin-provenance","pin-target","/frozen_epoch/value/pins/0/target_ref","/retained_ref/value"),eq("frozen-root-pin-provenance","dormant-target","/actor_lifecycle/value/target_ref","/actor_ref/value"),eq("frozen-root-pin-provenance","dormant-state","/actor_lifecycle/value/state","DORMANT"),eq("frozen-root-pin-provenance","root-reason","/root_reason/value/edge_kind","frozen-root"),eq("frozen-root-pin-provenance","audit-reason","/audit_reason/value/source",rt.typed_key(_ref(PROFILES[profile],"PinId","audit_pin"))), eq("typed-reachability-reasons","classes","/mark_result/value/classes",["audit-summary","body-retaining","identity-strong"]),eq("typed-reachability-reasons","reachable-exact","/mark_result/value/reachable","/expected_reachable/value"),eq("typed-reachability-reasons","discarded-state-unreachable","/discarded_membership/value/contains",False),eq("typed-reachability-reasons","discarded-state-exact","/discarded_membership/value/value","/discarded_key/value"),eq("typed-reachability-reasons","discarded-world-unreachable","/discarded_world_membership/value/contains",False),eq("typed-reachability-reasons","discarded-world-exact","/discarded_world_membership/value/value","/discarded_world_key/value"),edge("typed-reachability-reasons","world-root-edge","world-root","/retained_world_ref/value","/retained_root_ref/value"),edge("typed-reachability-reasons","root-state-edge","root-state","/retained_root_ref/value","/retained_ref/value"),edge("typed-reachability-reasons","state-payload-edge","state-payload","/retained_ref/value","/shared_ref/value"),edge("typed-reachability-reasons","actor-edge","accountable-actor","/retained_ref/value","/actor_ref/value"),edge("typed-reachability-reasons","attempt-edge","protected-state-attempt","/retained_ref/value","/attempt_ref/value"),edge("typed-reachability-reasons","body-edge","payload-body","/shared_ref/value","/payload_x_ref/value"),eq("typed-reachability-reasons","operational-nonretention","/mark_result/value/classes",["audit-summary","body-retaining","identity-strong"]), eq("deferred-root-isolation","deferred-epoch","/mark_result/value/deferred_to_epoch",1),eq("deferred-root-isolation","deferred-ref","/mark_result/value/deferred_root","/deferred_ref/value"),eq("deferred-root-isolation","n-reasons-unchanged","/frozen_epoch/value/mark/reasons","/mark_result/value/reasons"),eq("deferred-root-isolation","later-epoch","/later_epoch/value/epoch",1),eq("deferred-root-isolation","later-root","/later_epoch/value/reachable/0","/deferred_key/value"),eq("deferred-root-isolation","pending-consumed","/roots_state/value/pending",{})] if case=="E15": return [ eq("mark-gated-collection","n-epoch","/mark_n/value/epoch",0),eq("mark-gated-collection","n-reachable","/n_y_membership/value/contains",True),eq("mark-gated-collection","initial-available","/available_trace/value/output/status","AVAILABLE"),eq("mark-gated-collection","n1-reachable-x","/mark_n1/value/reachable/0",rt.typed_key(_derived(PROFILES[profile],"PayloadId",{"schema_ref":"aos.fixture.scalar.v1","codec_ref":"CVE1","body_bytes":rt.bytes_value(b"x")}))),eq("mark-gated-collection","stale-no-commit","/stale_trace/value/status","NO_COMMIT"),eq("mark-gated-collection","stale-code","/stale_trace/value/error/code","CONTEXT_MISMATCH"),eq("mark-gated-collection","reachable-no-commit","/reachable_trace/value/status","NO_COMMIT"),eq("mark-gated-collection","membership-no-commit","/membership_trace/value/status","NO_COMMIT"),eq("mark-gated-collection","collect-committed","/collect_trace/value/status","COMMITTED"),eq("mark-gated-collection","collect-status","/collect_trace/value/output/status","COLLECTED"),eq("mark-gated-collection","replay-no-commit","/replay_trace/value/status","NO_COMMIT"),eq("mark-gated-collection","next-only-record","/next_only_ref/value/type","PayloadId"),eq("mark-gated-collection","pin-deactivated","/expired_pin_record/value/active",False), st("envelope-body-resolution","envelope-resolved","/envelope_resolved/status","RESOLVED"),st("envelope-body-resolution","intermediate-collected","/collected_body/status","CONTENT_COLLECTED"),eq("envelope-body-resolution","intermediate-denotation","/collected_body/denotation_ref","/collect_trace/value/output/envelope_ref"),eq("envelope-body-resolution","collected-recorded","/collect_trace/value/output/reachable",False),eq("envelope-body-resolution","intermediate-no-y-body","/intermediate_y_body_count/value/count",0),eq("envelope-body-resolution","intermediate-record-count","/intermediate_payload_records/value/4/record_type","PayloadEnvelope"),eq("envelope-body-resolution","retained-x-available","/x_availability/value/body_state","AVAILABLE"), eq("verified-body-restoration","matching-body","/matching_verify/value/verified",True),eq("verified-body-restoration","mismatch-body","/mismatch_verify/value/verified",False),eq("verified-body-restoration","mismatch-restore-no-commit","/mismatch_restore_trace/value/status","NO_COMMIT"),eq("verified-body-restoration","mismatch-restore-code","/mismatch_restore_trace/value/error/code","VERIFICATION_FAILED"),eq("verified-body-restoration","restore-committed","/restore_trace/value/status","COMMITTED"),eq("verified-body-restoration","restore-verified","/restore_trace/value/output/verified",True),st("verified-body-restoration","restored-resolved","/restored_body/status","RESOLVED"),eq("verified-body-restoration","final-payload-body","/payload_records/value/0/record_type","PayloadBody"),eq("verified-body-restoration","final-y-available","/y_availability/value/body_state","AVAILABLE"),eq("verified-body-restoration","availability-y-exact","/availability_section/value/"+rt.typed_key(_derived(PROFILES[profile],"PayloadId",{"schema_ref":"aos.fixture.scalar.v1","codec_ref":"CVE1","body_bytes":rt.bytes_value(b"y")})).replace("~","~0").replace("/","~1")+"/body_state","AVAILABLE")] if case=="E16": ordered=(("malformed","MALFORMED"),("type_mismatch","TYPE_MISMATCH"),("context_mismatch","CONTEXT_MISMATCH"),("unknown","UNKNOWN"),("tombstoned","TOMBSTONED"),("expired","EXPIRED"),("collected","CONTENT_COLLECTED"),("unavailable","UNAVAILABLE"),("resolved","RESOLVED")) rows=[st("nine-status-order",n,n and "/"+n+"/status",v) for n,v in ordered] rows += [st("resolver-precedence","malformed-beats-type","/malformed_beats_type/status","MALFORMED"),st("resolver-precedence","type-beats-context","/type_beats_context/status","TYPE_MISMATCH"),st("resolver-precedence","context-beats-unknown","/context_beats_unknown/status","CONTEXT_MISMATCH"),st("resolver-precedence","tombstone-beats-expiry","/tombstone_beats_expiry/status","TOMBSTONED")] rows += [eq("canonical-request-result-vectors","resolved-denotation","/resolved/denotation_ref","/resolved/value/denotation_ref"),eq("canonical-request-result-vectors","resolved-type","/resolved/denotation_ref/type","PayloadId"),eq("canonical-request-result-vectors","tombstone-no-denotation","/tombstoned/denotation_ref",None),eq("canonical-request-result-vectors","collected-denotation-type","/collected/denotation_ref/type","PayloadId"),eq("canonical-request-result-vectors","collected-value-null","/collected/value",None),eq("canonical-request-result-vectors","unknown-no-fallback","/unknown/denotation_ref",None)] for vector in E16_VECTOR_IDS: golden=E16_GOLDENS[PROFILES[profile].state_recipe["actor_type"]][vector] rows += [eq("canonical-request-result-vectors",vector+"-request-bytes","/"+vector+"_request_canonical/value/canonical_json_hex",golden["request_hex"]),eq("canonical-request-result-vectors",vector+"-request-hash","/"+vector+"_request_canonical/value/sha256",golden["request_sha256"]),eq("canonical-request-result-vectors",vector+"-result-bytes","/"+vector+"_result_canonical/value/canonical_json_hex",golden["result_hex"]),eq("canonical-request-result-vectors",vector+"-result-hash","/"+vector+"_result_canonical/value/sha256",golden["result_sha256"])] return rows if case=="E17": return [ eq("canonical-equivalence","map-set-id","/map1/value/ref","/map2/value/ref"),eq("canonical-equivalence","map-set-preimage","/map1/value/preimage_hex","/map2/value/preimage_hex"),eq("canonical-equivalence","set-reorder","/set_ab/value/cve1_hex","/set_ba/value/cve1_hex"),eq("canonical-equivalence","map-reorder","/map_ordered/value/cve1_hex","/map_reordered/value/cve1_hex"), eq("canonical-equivalence","absent","/absent/value/cve1_hex","00"),eq("canonical-equivalence","null","/null/value/cve1_hex","01"),eq("canonical-equivalence","empty","/empty/value/cve1_hex","0600000000"),eq("canonical-equivalence","bool","/bool_true/value/cve1_hex","03"),eq("canonical-equivalence","uint","/uint_one/value/cve1_hex","040000000000000001"),eq("canonical-equivalence","bytes","/bytes_one/value/cve1_hex","050000000101"),eq("canonical-equivalence","digest","/digest/value/cve1_hex","0500000020"+"11"*32),eq("canonical-equivalence","nfc","/nfc_text/value/cve1_hex","0600000002c3a9"),eq("canonical-equivalence","array","/array_ab/value/cve1_hex","070000000205000000060600000001610500000006060000000162"),eq("canonical-equivalence","set","/set_ab/value/cve1_hex","090000000205000000060600000001610500000006060000000162"), ne("canonical-distinction","schema-distinct","/map1/value/ref","/schema_diff/value/ref"),ne("canonical-distinction","codec-distinct","/map1/value/ref","/codec_diff/value/ref"),ne("canonical-distinction","absent-null","/absent/value/cve1_hex","/null/value/cve1_hex"),ne("canonical-distinction","null-empty","/null/value/cve1_hex","/empty/value/cve1_hex"),ne("canonical-distinction","bool-uint","/bool_true/value/cve1_hex","/uint_one/value/cve1_hex"),ne("canonical-distinction","ref-types","/ref_payload/value/cve1_hex","/ref_digest/value/cve1_hex"),ne("canonical-distinction","array-order","/array_ab/value/cve1_hex","/array_ba/value/cve1_hex"),ne("canonical-distinction","set-array","/set_ab/value/cve1_hex","/array_ab/value/cve1_hex"),eq("canonical-distinction","ref-payload-status","/ref_payload/status","OK"),eq("canonical-distinction","ref-digest-status","/ref_digest/status","OK"),eq("canonical-distinction","slot-tag","/slot/value/cve1_hex","0b"+rt.cve1(("ref",_ref(PROFILES[profile],PROFILES[profile].state_recipe["actor_type"],"A") if PROFILES[profile].id_rules[PROFILES[profile].state_recipe["actor_type"]].kind=="opaque" else _derived(PROFILES[profile],PROFILES[profile].state_recipe["actor_type"],({"genesis_public_key":rt.bytes_value(b"K1")} if PROFILES[profile].state_recipe["actor_type"]=="ActorKeyId" else {"type_tag":"actor","canonical_bytes":rt.bytes_value(b"A")})))).hex()+rt.cve1(("text","state")).hex()+rt.cve1(("text","main")).hex()), st("invalid-canonical-rejection","duplicate-set","/duplicate_set/status","MALFORMED"),st("invalid-canonical-rejection","duplicate-map","/duplicate_map/status","MALFORMED"),st("invalid-canonical-rejection","non-nfc","/non_nfc/status","MALFORMED"),st("invalid-canonical-rejection","wrong-width","/wrong_width/status","MALFORMED"),st("invalid-canonical-rejection","unknown-wrapper","/unknown_wrapper/status","MALFORMED"),st("invalid-canonical-rejection","absent-required","/absent_required/status","MALFORMED")] if case=="E18": return [ eq("fresh-store-identity","digest","/serialized/value/sha256","/reconstructed/value/store_digest"),eq("fresh-store-identity","derived-exact","/derived_mapping/value","/reconstructed/value/derived"),eq("fresh-store-identity","opaque-exact","/opaque_mapping/value","/reconstructed/value/opaque"),eq("fresh-store-identity","rebind-ref","/reconstructed/value/rebound/ref","/actor_ref/value"),eq("fresh-store-identity","rebind-record","/reconstructed/value/rebound/record_type","ActorGenesis"),eq("fresh-store-identity","fresh-registers","/reconstructed/value/registers",{}),eq("fresh-store-identity","fresh-trace","/reconstructed/value/trace",[]), eq("persisted-section-equivalence","relations","/relations/value","/reconstructed/value/relations"),ne("persisted-section-equivalence","relations-nonempty","/relation_count/value/count",0),eq("persisted-section-equivalence","bindings","/bindings/value","/reconstructed/value/bindings"),eq("persisted-section-equivalence","allocations","/allocations/value","/reconstructed/value/allocations"),eq("persisted-section-equivalence","lifecycle","/lifecycle/value","/reconstructed/value/lifecycle"),eq("persisted-section-equivalence","availability","/availability/value","/reconstructed/value/availability"),eq("persisted-section-equivalence","roots","/roots/value","/reconstructed/value/roots"),eq("persisted-section-equivalence","snapshots","/snapshots/value","/reconstructed/value/snapshots"), eq("tamper-reconstruction-rejection","snapshot-protected","/snapshots/value/fresh_snapshot/snapshot_ref","/reconstructed/value/snapshots/fresh_snapshot/snapshot_ref"),eq("tamper-reconstruction-rejection","root-mark-protected","/roots/value/frozen/0/mark","/reconstructed/value/roots/frozen/0/mark"),eq("tamper-reconstruction-rejection","body-link-protected","/availability/value/"+rt.typed_key(_derived(PROFILES[profile],"PayloadId",{"schema_ref":"aos.fixture.scalar.v1","codec_ref":"CVE1","body_bytes":rt.bytes_value(b"x")})).replace("~","~0").replace("/","~1")+"/body_record_key","/reconstructed/value/availability/"+rt.typed_key(_derived(PROFILES[profile],"PayloadId",{"schema_ref":"aos.fixture.scalar.v1","codec_ref":"CVE1","body_bytes":rt.bytes_value(b"x")})).replace("~","~0").replace("/","~1")+"/body_record_key")] raise AssertionError(case)
def _observation_roots(operator: str, operands: dict[str,Any]) -> set[str]: descriptors=[] if operator in ("EQ","NE"): descriptors=[operands["left"],operands["right"]] elif operator=="EDGE_EXISTS": descriptors=[operands["relation_set"],operands["edge"]["from"],operands["edge"]["to"]] else: descriptors=list(operands.values()) return {d["path"].split("/")[2] for d in descriptors if type(d) is dict and d.get("path","").startswith("/observations/")}
def _declared_role_contract(profile: rt.ProfileSemantics, case: str) -> dict[str,dict[str,str]]: family=profile.state_recipe["family"] unavailable=set() if family=="L": unavailable|={"E01:exact-predecessor","E02:protected-accountable-occurrence","E04:historical-epoch-attribution"} if family=="C": unavailable|={"E01:exact-predecessor","E02:protected-accountable-occurrence","E04:historical-epoch-attribution","E05:clone-separation"} if family=="K": unavailable|={"E04:rotation-actor-continuity","E05:clone-separation"} if family in ("C","L"): unavailable|={"E12:protected-occurrence-grounding"} machinery={ "exact-predecessor":"predecessor field plus predecessor-revision edge", "protected-accountable-occurrence":{"C":"none","L":"none","K":"ContentCreation plus creation-attempt edge","H":"OpaqueRevision.attempt_ref","V":"Occurrence.attempt_ref","O":"RevisionOccurrence.attempt_ref"}[family], "actor-continuity":"current-actor persisted binding and ActorGenesis identity", "rotation-actor-continuity":"KeyEpoch.actor_ref equality", "historical-epoch-attribution":{"C":"no protected historical state-to-Attempt relation","L":"no protected historical state-to-Attempt relation","K":"ContentCreation.attempt_ref plus creation-attempt edge","H":"OpaqueRevision.attempt_ref plus protected-state-attempt edge","V":"Occurrence.attempt_ref plus protected-state-attempt edge","O":"RevisionOccurrence.attempt_ref plus protected-state-attempt edge"}[family], "clone-separation":"ActorGenesis typed identity inequality", "branch-attributable-occurrences":"CommitEvent direct world/attempt/result refs plus protected occurrence machinery", "protected-occurrence-grounding":{"C":"no declared ProvenanceRole; exact verifier result UNSUPPORTED","L":"no declared ProvenanceRole; exact verifier result UNSUPPORTED","K":"ContentCreation ProvenanceRole with grounded causal_inputs","H":"OpaqueRevision ProvenanceRole without causal array","V":"Occurrence ProvenanceRole with grounded causal_inputs","O":"RevisionOccurrence ProvenanceRole with grounded causal_inputs"}[family], } return {role:{"status":"UNAVAILABLE" if case+":"+role in unavailable else "IMPLEMENTED","machinery":machinery.get(role,"direct persisted record, edge, binding, or trace query")} for role in CASE_ROLES[case]}
def validate_unit23_role_rejoin(compiled: dict[str,list[dict[str,Any]]], assertions: list[dict[str,Any]]) -> None: """Recursively close named observations to the canonical query AST and its exact producer machinery.""" if type(compiled) is not dict or set(compiled)!=set(PROFILE_IDS): raise ValueError("compiled profile coverage") neutral={doc["case_id"]:doc for doc in NEUTRAL_PROGRAMS} def semantic_program(program): clean=copy.deepcopy(program) for action in clean["actions"]: action.pop("action_meta",None) return clean def recursive_equal(actual,expected,path): if type(actual) is not type(expected): raise ValueError("recursive role rejoin disagreement: "+path) if type(expected) is dict: if set(actual)!=set(expected): raise ValueError("recursive role rejoin disagreement: "+path+" keys") for key in expected: recursive_equal(actual[key],expected[key],path+"/"+key) elif type(expected) is list: if len(actual)!=len(expected): raise ValueError("recursive role rejoin disagreement: "+path+" length") for i,(left,right) in enumerate(zip(actual,expected)): recursive_equal(left,right,path+"/"+str(i)) elif actual!=expected: raise ValueError("recursive role rejoin disagreement: "+path) for pid in PROFILE_IDS: profile=PROFILES[pid]; programs={x["case_id"]:x for x in compiled[pid]} if set(programs)!=set(CASE_IDS): raise ValueError("compiled case coverage: "+pid) for case,roles in CASE_ROLES.items(): program=programs[case]; canonical=compile_program(neutral[case],profile) all_queries=lambda p:p["queries"]+[q for batch in p.get("observations_at",{}).values() for q in batch] queries={q["query_id"]:q for q in all_queries(program)}; expected_queries={q["query_id"]:q for q in all_queries(canonical)} if case >= "E13": if len(queries)!=len(all_queries(program)) or set(queries)!=set(expected_queries): raise ValueError("exact unit25 query set: "+pid+"/"+case) for query_id in expected_queries: recursive_equal(queries[query_id],expected_queries[query_id],pid+"/"+case+"/query/"+query_id) recursive_equal(program.get("observations_at",{}),canonical.get("observations_at",{}),pid+"/"+case+"/observations_at") if any(q["expr"].get("op")=="literal" and type(q["expr"].get("value")) is dict and ("status" in q["expr"]["value"] or "machinery" in q["expr"]["value"]) for q in all_queries(program)): raise ValueError("status-literal role query: "+pid+"/"+case) declared=_declared_role_contract(profile,case) if _thaw(profile.state_recipe["role_mappings"][case])!=declared: raise ValueError("changed profile role mapping: "+pid+"/"+case) rows=([(*x,True) for x in _unit23_rows(pid,case)] if case<="E06" else _unit24_rows(pid,case) if case<="E12" else _unit25_rows(pid,case)); expected_ids=set() for role,name,op,operands,expected in rows: aid=pid+"."+case+"."+role+"."+name; expected_ids.add(aid) matches=[a for a in assertions if a["profile_id"]==pid and a["case_id"]==case and a["assertion_id"]==aid] if len(matches)!=1 or matches[0]["operator"]!=op or matches[0]["operands"]!=operands: raise ValueError("role assertion disagreement: "+aid) roots=_observation_roots(op,operands) if not roots or not roots<=set(queries): raise ValueError("missing direct query: "+aid) for root in roots: if root not in expected_queries: raise ValueError("missing direct query: "+aid) recursive_equal(queries[root],expected_queries[root],aid+"/query/"+root) # Exact recursive action closure proves every record field, identity, order, predecessor and edge endpoint. recursive_equal(semantic_program(program)["actions"],semantic_program(canonical)["actions"],pid+"/"+case+"/actions") if {role for role,_,_,_,_ in rows}!=set(roles): raise ValueError("missing required role predicate: "+pid+"/"+case) actual_ids={a["assertion_id"] for a in assertions if a["profile_id"]==pid and a["case_id"]==case} if actual_ids!=expected_ids: raise ValueError("unexpected predicate: "+pid+"/"+case) if case>="E13": asserted=set().union(*(_observation_roots(a["operator"],a["operands"]) for a in assertions if a["profile_id"]==pid and a["case_id"]==case)) for query in all_queries(program): meta=query.get("query_meta") if type(meta) is not dict or set(meta) not in ({"evidence"},{"setup_only"}): raise ValueError("query metadata closure: "+pid+"/"+case+"/"+query["query_id"]) if "evidence" in meta and query["query_id"] not in asserted: raise ValueError("unasserted evidence query: "+pid+"/"+case+"/"+query["query_id"]) if "setup_only" in meta and query["query_id"] in asserted: raise ValueError("setup-only query asserted: "+pid+"/"+case+"/"+query["query_id"])
UNIT23_FAILING_PREDICATES=frozenset({ "C.E01.exact-predecessor.exact-predecessor", "C.E02.protected-accountable-occurrence.accountable-occurrences-distinct", "C.E04.historical-epoch-attribution.old-protected-attempt-edge", "C.E05.clone-separation.clone-actor-distinct", "K.E04.rotation-actor-continuity.actor-continuity", "K.E05.clone-separation.clone-actor-distinct", "L.E01.exact-predecessor.exact-predecessor", "L.E02.protected-accountable-occurrence.accountable-occurrences-distinct", "L.E04.historical-epoch-attribution.old-protected-attempt-edge",})UNIT24_FAILING_PREDICATES=frozenset({ "C.E12.protected-occurrence-grounding.protected-actor", "C.E12.protected-occurrence-grounding.genuine-verified", "C.E12.protected-occurrence-grounding.genuine-match", "C.E12.protected-occurrence-grounding.genuine-actor", "C.E12.protected-occurrence-grounding.genuine-commitment", "C.E12.protected-occurrence-grounding.genuine-evidence", "L.E12.protected-occurrence-grounding.protected-actor", "L.E12.protected-occurrence-grounding.genuine-verified", "L.E12.protected-occurrence-grounding.genuine-match", "L.E12.protected-occurrence-grounding.genuine-actor", "L.E12.protected-occurrence-grounding.genuine-commitment", "L.E12.protected-occurrence-grounding.genuine-evidence",})
def validate_unit24_role_rejoin(compiled: dict[str,list[dict[str,Any]]], assertions: list[dict[str,Any]]) -> None: validate_unit23_role_rejoin(compiled,assertions)
def validate_unit25_role_rejoin(compiled: dict[str,list[dict[str,Any]]], assertions: list[dict[str,Any]]) -> None: validate_unit23_role_rejoin(compiled,assertions)
def assertion_documents() -> list[dict[str,Any]]: docs=[] for profile in PROFILE_IDS: for case in CASE_IDS: if case in CASE_ROLES: rows=([(*x,True) for x in _unit23_rows(profile,case)] if case<="E06" else _unit24_rows(profile,case) if case<="E12" else _unit25_rows(profile,case)) for role,name,operator,operands,expected in rows: aid=profile+"."+case+"."+role+"."+name; failing=aid in (UNIT23_FAILING_PREDICATES|UNIT24_FAILING_PREDICATES) docs.append({"assertion_id":aid,"profile_id":profile,"case_id":case,"requirement_id":CASE_REQUIREMENTS[case],"operator":operator,"operands":operands,"expected":expected,"expected_outcome":"FAIL" if failing else "PASS","failure_rationale":"The direct persisted evidence does not satisfy this required semantic predicate." if failing else None,"purpose":"Require direct "+role+" predicate "+name+"."}) continue rows=list(ASSERTION_TEMPLATES[case]) if case=="E12": rows=[(n,o,path,(profile!="C") if n=="protected-provenance" else expected) for n,o,path,expected in rows] for name,op,path,expected in rows: operator="STATUS_EQ" if path.endswith("/status") and type(expected) is str and expected in ASSERTION_STATUSES else op operands={"actual":{"path":"/observations"+path}} if operator=="STATUS_EQ" else {"left":{"path":"/observations"+path},"right":({"path":"/observations"+expected["path"]} if type(expected) is dict and set(expected)=={"path"} else {"value":copy.deepcopy(expected)})} docs.append({"assertion_id":profile+"."+case+"."+name,"profile_id":profile,"case_id":case,"requirement_id":CASE_REQUIREMENTS[case],"operator":operator,"operands":operands,"expected":expected if operator=="STATUS_EQ" else True,"expected_outcome":"PASS","failure_rationale":None,"purpose":"Check provisional "+name.replace("-"," ")+" predicate."}) for doc in docs: if doc["case_id"]=="E13" and doc["assertion_id"].endswith(".fatal-code"): doc.update(operator="FATAL",operands={"event":{"path":"/observations/fatal_trace/value"}},expected="FATAL_INTEGRITY_FAILURE") docs=validate_assertions(docs) validate_unit25_role_rejoin(compile_all(),docs) return docs
def assertion_set() -> dict[str,Any]: return {"assertion_version":ASSERTION_DSL_VERSION,"contract_stage":ASSERTION_CONTRACT_STAGE,"assertions":assertion_documents()}
def _resolve_operand(root: dict[str,Any], descriptor: dict[str,Any]) -> Any: return rt._pointer(root,descriptor["path"]) if "path" in descriptor else copy.deepcopy(descriptor["value"])def _typed_equal(left: Any, right: Any) -> bool: return type(left) is type(right) and left==right
def evaluate(result:dict[str,Any], assertions:list[dict[str,Any]]) -> dict[str,Any]: if type(result) is not dict or type(result.get("profile_id")) is not str or type(result.get("case_id")) is not str or type(result.get("observations")) is not dict or type(result.get("trace")) is not list: _assertion_error("execution result") validate_assertions(assertions,profile_id=result["profile_id"],case_id=result["case_id"]) root={"observations":result["observations"],"trace":result["trace"],"fresh_reconstruction":result.get("fresh_reconstruction")}; rows=[] for a in assertions: op=a["operator"] if op in ("EQ","NE"): left=_resolve_operand(root,a["operands"]["left"]); right=_resolve_operand(root,a["operands"]["right"]); equal=_typed_equal(left,right); predicate=equal if op=="EQ" else not equal; evidence={"left":left,"right":right,"typed_equal":equal} elif op=="STATUS_EQ": actual=_resolve_operand(root,a["operands"]["actual"]); predicate=type(actual) is str and actual==a["expected"]; evidence={"actual_status":actual,"expected_status":a["expected"]} elif op=="EDGE_EXISTS": relations=_resolve_operand(root,a["operands"]["relation_set"]); selector=a["operands"]["edge"]; edge={"kind":selector["kind"],"from":_resolve_operand(root,selector["from"]),"to":_resolve_operand(root,selector["to"])} matches=[] if type(relations) is not list else [x for x in relations if type(x) is dict and x.get("kind")==edge["kind"] and _typed_equal(x.get("from"),edge["from"]) and _typed_equal(x.get("to"),edge["to"])]; predicate=bool(matches); evidence={"selector":edge,"matching_edges":copy.deepcopy(matches)} else: event=_resolve_operand(root,a["operands"]["event"]); status=event.get("status") if type(event) is dict else None; error=event.get("error") if type(event) is dict else None; code=error.get("code") if type(error) is dict else None; before=event.get("before_digest") if type(event) is dict else None; after=event.get("after_digest") if type(event) is dict else None predicate=status=="FATAL" and code==a["expected"] and type(before) is str and before==after; evidence={"status":status,"error_code":code,"before_digest":before,"after_digest":after} rows.append({"assertion_id":a["assertion_id"],"operator":op,"predicate_result":predicate,"pass":predicate,"expected_outcome":a["expected_outcome"],"prediction_match":predicate==(a["expected_outcome"]=="PASS"),"actual_evidence":evidence}) outcome="PASS" if all(x["pass"] for x in rows) else "FAIL" return {"profile_id":result["profile_id"],"case_id":result["case_id"],"assertion_results":rows,"case_outcome":outcome,"case_prediction_match":all(x["prediction_match"] for x in rows)}
def validate_profile_predictions(evaluations: list[dict[str,Any]], expected_vectors: dict[str,dict[str,str]]) -> dict[str,Any]: evaluation_keys={"profile_id","case_id","assertion_results","case_outcome","case_prediction_match"} result_keys={"assertion_id","operator","predicate_result","pass","expected_outcome","prediction_match","actual_evidence"} if type(evaluations) is not list or type(expected_vectors) is not dict or set(expected_vectors)!=set(PROFILE_IDS): _assertion_error("profile predictions") for pid in PROFILE_IDS: vector=expected_vectors[pid] if type(vector) is not dict or set(vector)!=set(CASE_IDS) or any(type(x) is not str or x not in ("PASS","FAIL") for x in vector.values()): _assertion_error("expected profile vector") seen=set(); seen_assertions=set(); mismatches=[] evidence_keys={"EQ":{"left","right","typed_equal"},"NE":{"left","right","typed_equal"},"STATUS_EQ":{"actual_status","expected_status"},"EDGE_EXISTS":{"selector","matching_edges"},"FATAL":{"status","error_code","before_digest","after_digest"}} for item in evaluations: if type(item) is not dict or set(item)!=evaluation_keys: _assertion_error("profile prediction entry") pid,case=item["profile_id"],item["case_id"] if type(pid) is not str or pid not in PROFILE_IDS or type(case) is not str or case not in CASE_IDS or (pid,case) in seen: _assertion_error("profile prediction entry") seen.add((pid,case)) rows=item["assertion_results"] if type(rows) is not list or not rows or type(item["case_prediction_match"]) is not bool: _assertion_error("profile prediction evaluation") for row in rows: if type(row) is not dict or set(row)!=result_keys or type(row["assertion_id"]) is not str or not row["assertion_id"] or row["assertion_id"] in seen_assertions or type(row["operator"]) is not str or row["operator"] not in ASSERTION_OPERATORS or type(row["predicate_result"]) is not bool or type(row["pass"]) is not bool or row["pass"]!=row["predicate_result"] or type(row["expected_outcome"]) is not str or row["expected_outcome"] not in ("PASS","FAIL") or type(row["prediction_match"]) is not bool or row["prediction_match"]!=(row["pass"]==(row["expected_outcome"]=="PASS")) or type(row["actual_evidence"]) is not dict or set(row["actual_evidence"])!=evidence_keys[row["operator"]]: _assertion_error("profile prediction assertion result") seen_assertions.add(row["assertion_id"]) actual=item["case_outcome"] if type(actual) is not str or actual not in ("PASS","FAIL") or actual != ("PASS" if all(x["pass"] for x in rows) else "FAIL") or item["case_prediction_match"]!=all(x["prediction_match"] for x in rows): _assertion_error("profile prediction aggregate") expected=expected_vectors[pid][case] if actual!=expected: mismatches.append({"profile_id":pid,"case_id":case,"actual":actual,"expected":expected}) if seen!={(pid,case) for pid in PROFILE_IDS for case in CASE_IDS}: _assertion_error("profile prediction coverage") return {"valid":not mismatches,"mismatches":mismatches}
def _thaw(v: Any) -> Any: if hasattr(v,"items"): return {k:_thaw(x) for k,x in v.items()} if type(v) in (tuple,list,frozenset,set): return [_thaw(x) for x in v] return copy.deepcopy(v)
def profile_to_json(p: rt.ProfileSemantics) -> dict[str,Any]: return {"profile_schema_version":"D001-PROFILE-JSON-1","name":p.name,"fixture_id":p.fixture_id, "id_rules":{k:{**asdict(v),"fields":list(v.fields)} for k,v in p.id_rules.items()}, "record_rules":{k:{"fields":_thaw(v.fields),"id_field":v.id_field,"id_type":v.id_type,"instance_order_field":v.instance_order_field,"predecessor_fields":list(v.predecessor_fields),"projection":v.projection} for k,v in p.record_rules.items()}, "edge_rules":{k:{"from_types":sorted(v.from_types),"to_types":sorted(v.to_types),"retention_class":v.retention_class} for k,v in p.edge_rules.items()}, "unions":{k:sorted(v) for k,v in p.unions.items()},"binding_kinds":sorted(p.binding_kinds), "state_recipe":_thaw(p.state_recipe),"projections":_thaw(p.projections),"provenance_types":sorted(p.provenance_types), "availability_role":None if p.availability_role is None else asdict(p.availability_role), "pin_role":None if p.pin_role is None else asdict(p.pin_role), "versioned_reference_roles":[_thaw(asdict(x)) for x in p.versioned_reference_roles], "provenance_roles":[_thaw(asdict(x)) for x in p.provenance_roles], "typed_content_role":None if p.typed_content_role is None else _thaw(asdict(p.typed_content_role))}
def profile_from_json(raw: dict[str,Any]) -> rt.ProfileSemantics: def malformed(where): raise ValueError("malformed profile JSON: "+where) def exact(value,keys,where): if type(value) is not dict or set(value)!=set(keys): malformed(where) return value def string_list(value,where): if type(value) is not list or any(type(x) is not str for x in value): malformed(where) return value top=("profile_schema_version","name","fixture_id","id_rules","record_rules","edge_rules","unions","binding_kinds","state_recipe","projections","provenance_types","availability_role","pin_role","versioned_reference_roles","provenance_roles","typed_content_role") try: exact(raw,top,"top-level keys") if raw["profile_schema_version"]!="D001-PROFILE-JSON-1" or type(raw["name"]) is not str or type(raw["fixture_id"]) is not str: malformed("identity") for name in ("id_rules","record_rules","edge_rules","unions","state_recipe","projections"): if type(raw[name]) is not dict: malformed(name) string_list(raw["binding_kinds"],"binding_kinds"); string_list(raw["provenance_types"],"provenance_types") id_keys=("kind","type_tag","domain","schema","codec","version","fields","width") record_keys=("fields","id_field","id_type","instance_order_field","predecessor_fields","projection") edge_keys=("from_types","to_types","retention_class") for k,v in raw["id_rules"].items(): if type(k) is not str: malformed("id_rules key") exact(v,id_keys,"id_rules."+k); string_list(v["fields"],"id_rules."+k+".fields") for k,v in raw["record_rules"].items(): if type(k) is not str: malformed("record_rules key") exact(v,record_keys,"record_rules."+k) if type(v["fields"]) is not dict: malformed("record_rules."+k+".fields") string_list(v["predecessor_fields"],"record_rules."+k+".predecessor_fields") for k,v in raw["edge_rules"].items(): if type(k) is not str: malformed("edge_rules key") exact(v,edge_keys,"edge_rules."+k); string_list(v["from_types"],"edge_rules."+k+".from_types"); string_list(v["to_types"],"edge_rules."+k+".to_types") for k,v in raw["unions"].items(): if type(k) is not str: malformed("unions key") string_list(v,"unions."+k) role_specs=(("availability_role",("envelope_record_type","envelope_id_type","body_record_type","envelope_ref_field","body_field","digest_field","length_field","envelope_body_field")), ("pin_role",("pin_record_type","pin_id_type","target_field","active_field","expires_field"))) for name,keys in role_specs: if raw[name] is not None: exact(raw[name],keys,name) if type(raw["versioned_reference_roles"]) is not list or type(raw["provenance_roles"]) is not list: malformed("semantic role arrays") version_keys=("record_type","id_type","namespace_field","label_field","target_field","predecessor_field","order_field","tombstone_field","expires_field","namespace_types","target_types") provenance_keys=("record_type","occurrence_id_type","actor_field","commitment_field","authorization_evidence_field","causal_inputs_field","actor_types","commitment_types","evidence_types","actor_record_types","commitment_record_types","evidence_record_types","causal_types","causal_record_types") for i,v in enumerate(raw["versioned_reference_roles"]): exact(v,version_keys,"versioned_reference_roles["+str(i)+"]"); string_list(v["namespace_types"],"versioned namespace types"); string_list(v["target_types"],"versioned target types") for i,v in enumerate(raw["provenance_roles"]): exact(v,provenance_keys,"provenance_roles["+str(i)+"]") if v["causal_inputs_field"] is not None and type(v["causal_inputs_field"]) is not str: malformed("provenance causal_inputs_field") for field in provenance_keys[6:]: string_list(v[field],"provenance "+field) typed_keys=("state_id_type","subject_union","payload_id_type","derivation_kind","width","codec","version","fields","type_tag_descriptor","canonical_bytes_descriptor","constant_type_tag","applicability_domain","applicability_schema","canonical_value_fields","canonical_encoding","result_fields") if raw["typed_content_role"] is not None: exact(raw["typed_content_role"],typed_keys,"typed_content_role") for field in ("fields","canonical_value_fields","result_fields"): string_list(raw["typed_content_role"][field],"typed_content_role."+field) ids={k:rt.IdRule(v["kind"],v["type_tag"],v["domain"],v["schema"],v["codec"],v["version"],tuple(v["fields"]),v["width"]) for k,v in raw["id_rules"].items()} records={k:rt.RecordRule(v["fields"],v["id_field"],v["id_type"],v["instance_order_field"],tuple(v["predecessor_fields"]),v["projection"]) for k,v in raw["record_rules"].items()} edges={k:rt.EdgeRule(frozenset(v["from_types"]),frozenset(v["to_types"]),v["retention_class"]) for k,v in raw["edge_rules"].items()} availability=None if raw["availability_role"] is None else rt.AvailabilityRole(**raw["availability_role"]) pin=None if raw["pin_role"] is None else rt.PinRole(**raw["pin_role"]) versioned=tuple(rt.VersionedReferenceRole(**{**x,"namespace_types":tuple(x["namespace_types"]),"target_types":tuple(x["target_types"])}) for x in raw["versioned_reference_roles"]) provenance=tuple(rt.ProvenanceRole(**{**x,**{field:tuple(x[field]) for field in provenance_keys[6:]}}) for x in raw["provenance_roles"]) typed=None if raw["typed_content_role"] is None else rt.TypedContentRole(**{**raw["typed_content_role"],**{field:tuple(raw["typed_content_role"][field]) for field in ("fields","canonical_value_fields","result_fields")}}) return rt.ProfileSemantics(raw["name"],raw["fixture_id"],ids,records,edges, unions={k:frozenset(v) for k,v in raw["unions"].items()},binding_kinds=frozenset(raw["binding_kinds"]), state_recipe=raw["state_recipe"],projections=raw["projections"],provenance_types=frozenset(raw["provenance_types"]), availability_role=availability,pin_role=pin,versioned_reference_roles=versioned,provenance_roles=provenance,typed_content_role=typed) except ValueError: raise except (KeyError,TypeError,AttributeError,rt.D001Error) as exc: malformed(type(exc).__name__)
def _runtime_spec() -> dict[str,Any]: action_meta={"oneOf":[{"type":"object","additionalProperties":False,"required":["essential_for"],"properties":{"essential_for":{"type":"array","minItems":1,"items":{"type":"string","unicode":"NFC","format":"assertion-id"}}}},{"type":"object","additionalProperties":False,"required":["setup_only"],"properties":{"setup_only":{"type":"string","unicode":"NFC","format":"rationale"}}}]} common_action={"type":"object","additionalProperties":False,"required":["action_version","step_id","op","args","fault"],"properties":{"action_version":{"const":"D001-ACTION-3"},"step_id":{"type":"string","unicode":"NFC"},"op":{"enum":sorted(rt.OPS)},"args":{"type":"object"},"fault":{"oneOf":[{"type":"null"},{"type":"object"}]},"action_meta":action_meta}} return {"spec_version":"D001-RUNTIME-SPEC-1","normative":True, "json_model":{"values":["null","bool","uint64","NFC-string","array","object"],"numbers":"integers 0..2^64-1 only; bool is not integer","objects":"string keys, no duplicates, recursively closed wrappers","wrappers":{"bytes":{"exact_keys":["$kind","hex"],"kind":"bytes","hex":"lowercase even hex"},"digest32":{"exact_keys":["$kind","hex"],"kind":"digest32","bytes":32},"ref":{"exact_keys":["$kind","type","hex"],"kind":"ref","width":"profile IdRule.width"},"slot":{"exact_keys":["$kind","owner_actor_ref","slot_type","slot_name"],"kind":"slot","pseudo_type":"StateSlotRef"},"set":{"exact_keys":["$kind","items"],"ordering":"strict ascending CVE1, unique"},"map":{"exact_keys":["$kind","entries"],"ordering":"strict ascending CVE1 key, unique"}}}, "canonical_json":{"encoding":"UTF-8","unicode":"NFC keys and strings","object_keys":"UTF-8 lexical order","separators":[",",":"],"escaping":"JSON minimal, ensure_ascii=false","store_terminator":"single LF","strict_load":"input must byte-equal canonical encoding and reject duplicate keys/floats/out-of-range integers"}, "cve1":{"version":"CVE1","frames":{"absent":"00","null":"01","false":"02","true":"03","uint64":"04 + 8-byte big-endian","bytes":"05 + u32 length + bytes","text":"06 + u32 UTF-8 length + NFC UTF-8","array":"07 + u32 count + concatenated values","map":"08 + u32 count + key/value pairs sorted by encoded key","set":"09 + u32 count + unique encoded values sorted","ref":"0a + CVE1(type text) + CVE1(raw bytes)","slot":"0b + owner ref + slot_type text + slot_name text"}}, "identity":{"opaque":"sha256(fixture_id+'/'+profile_name+'/'+domain_id+'/'+symbol) truncated to width","derived":"sha2-256(CVE1 map envelope {domain,schema,codec,hash_algorithm,version,fields}); exact IdRule field set/order","structural":"validated StateSlotRef tuple","typed_key":"kind plus concrete type plus bytes; slots use canonical JSON"}, "store_schema":{"version":"D001-STORE-2","exact_sections":["store_version","profile_name","clock","records","allocations","bindings","edges","lifecycle","snapshots","override_provenance","roots","availability","registers","trace"],"serialized_sections":["store_version","profile_name","clock","records","allocations","bindings","edges","lifecycle","snapshots","override_provenance","roots","availability"],"freeze_receipt":"immutable sha256 canonical receipt binds epoch, frozen_at_clock, exact roots, exact active pins, predecessor receipt, latest token; validation recomputes chain","override_provenance":"exact pre-freeze source/forced target/raw digest/natural ref+preimage hash/fault phase/initial token with record and allocation linkage","reconstruction":"strict canonical load; registers/trace reset; full profile validation; derived IDs/preimages, freeze receipts, and override provenance recomputed; fresh mode copies validated persisted sections into new empty store"}, "action_schema":common_action, "operations":{"record.put":{"args_exact":["record_type","fields","id","edges","out_ref"],"id_kinds":["opaque","derived","structural","keyed"]},"index.set":{"args_exact":["binding_kind","key","value","expected_version","out_version"]},"availability.set":{"args_exact":["envelope_ref","state","body","reason"],"states":["AVAILABLE","COLLECTED","UNAVAILABLE"]},"availability.collect-if-unreachable":{"args_exact":["envelope_ref","epoch","expected_reachable"],"requires":"epoch is exact latest frozen epoch and its persisted mark is completed; any newer frozen-unmarked epoch closes collection; expected membership exact; actual unreachable","effect":"remove role-managed body record only; preserve envelope","committed_result":{"exact_keys":["status","epoch","envelope_ref","reachable"],"constants":{"status":"COLLECTED","reachable":False},"types":{"epoch":"uint64","envelope_ref":"availability envelope ref"}},"no_commit":{"incomplete_mark":"CONTEXT_MISMATCH","membership_mismatch":"CONTEXT_MISMATCH","reachable":"CONTEXT_MISMATCH","replay_or_unavailable_body":"CONTEXT_MISMATCH"}},"snapshot.capture":{"args_exact":["name","snapshot_record","binding_kinds","root_context"]},"snapshot.restore":{"args_exact":["name"]},"roots.freeze":{"args_exact":["epoch","root_refs","pin_refs","clock"],"pin_selection":"immutable active pins with expires_at >= clock"},"reachability.mark":{"args_exact":["epoch","classes","out"]},"store.reload":{"args_exact":["source_register","destination"],"destination":"current"}}, "faults":{"compatibility":{op:[{"kind":k,"phase":ph} for k,ph in sorted(pairs)] for op,pairs in rt.FAULT_COMPATIBILITY.items()},"schemas":{"HASH_RESULT_OVERRIDE":{"exact_keys":["kind","phase","raw_digest_hex"]},"CONCURRENT_ROOT_APPEND":{"exact_keys":["kind","phase","epoch","root_ref"]}}}, "trace_result":{"exact_keys":["seq","step_id","op","status","reads","writes","output","error","before_digest","after_digest"],"statuses":["COMMITTED","NO_COMMIT","FATAL"],"policy":"all actions execute; every D001Error is captured; fatal flag selects FATAL; unexpected exception becomes INTERNAL_ERROR NO_COMMIT; non-commit digest unchanged; expect_error is forbidden"}, "query_schema":{"version":"D001-Q-2","ast":"closed exact-key operator schemas","query_meta":{"one_of":[{"evidence":True},{"setup_only":"nonempty rationale"}]},"observations_at":{"shape":"map exact action step_id to nonempty query batches","timing":"immediately after action trace commit/no-commit and before next action","persistence":False,"closure":"scheduled plus final queries form one exact recursive query set"},"operators":{"literal":["op","value"],"reg":["op","name"],"record":["op","type","key"],"field":["op","input","path"],"binding":["op","kind","key"],"trace":["op","select","project","cardinality"],"resolve":["op","request"],"edge":["op","kind","from","to"],"equal":["op","left","right"],"compare-components":["op","left","right","components"],"verify-provenance":["op","claim"],"verify-body":["op","envelope_ref","body"],"canonical-id":["op","id_type","fields","rule_override"],"canonical-value":["op","value","schema"],"typed-content-id":["op","subject_ref","payload_ref"],"trace-effects":["op","event"],"trace-write-excludes":["op","after_seq","path"],"serialize-store":["op"],"reconstruct":["op","bytes","mode"],"relation-set":["op","kinds"],"records":["op","types"],"store-section":["op","section"],"version-select":["op","record_type","match","as_of"],"object-has-key":["op","input","object_key","key"],"contains":["op","input","value"],"typed-key":["op","value"],"map-get":["op","input","key"],"canonical-json":["op","value"],"canonical-json-raw":["op","value"],"canonical-json-normalized":["op","value"],"identity-mapping":["op","kind"],"persisted-rebind":["op","record_type","match_fields"],"typed-keys":["op","values"],"list-select":["op","input","match"],"record-count":["op","record_type","key"],"list-count":["op","input"]},"evaluation":"recursive AST evaluation against current store/registers/trace; no case/profile dispatch"}, "resolver":{"request_exact":["mode","reference","context","clock","expected_types"],"context_union":[None,{"exact_keys":["binding_kind","key","expected_value"]}],"modes":sorted(rt.RESOLVER_MODES),"reference_schemas":{"ordinary":"profile ref","alias-current":{"exact_keys":["namespace_ref","label"],"namespace_ref":"role namespace_types"},"alias-as-of":{"exact_keys":["namespace_ref","label","version_ref"],"namespace_ref":"role namespace_types","version_ref":"role id_type"},"locator-current":{"reference":"semantic target ref in expected_types","context":{"binding_kind":"endpoint-occupant","key":"same semantic target","expected_value":"current LocatorRecordId"},"result":"matched_version_ref is LocatorRecordId and denotation_ref is semantic target"}},"version_head":"records matching declarative namespace+label whose ID is not referenced as predecessor; unique head required","status_precedence":list(rt.RESOLVER_ORDER),"order":"syntax, concrete reference and expected type, binding context, head/exact version existence, tombstone, expiry, target existence, resolved","result":{"exact_keys":["status","value","denotation_ref","matched_version_ref"],"resolved":{"value":{"exact_keys":["denotation_ref","availability"]},"denotation_ref":"authoritative target ref","matched_version_ref":"selected version ref"},"errors":{"MALFORMED":{"value":None,"denotation_ref":None,"matched_version_ref":None},"TYPE_MISMATCH":{"value":None,"denotation_ref":None,"matched_version_ref":None},"CONTEXT_MISMATCH":{"value":None,"denotation_ref":None,"matched_version_ref":None},"UNKNOWN":{"value":None,"denotation_ref":None,"matched_version_ref":"selected version ref only for null/dangling target"},"TOMBSTONED":{"value":None,"denotation_ref":None,"matched_version_ref":"selected version ref"},"EXPIRED":{"value":None,"denotation_ref":None,"matched_version_ref":"selected version ref"}}}}, "typed_content_id":{"applicability":"profile.typed_content_role must be present; shipped only by C and K","role_exact_fields":["state_id_type","subject_union","payload_id_type","derivation_kind","width","codec","version","fields","type_tag_descriptor","canonical_bytes_descriptor","constant_type_tag","applicability_domain","applicability_schema","canonical_value_fields","canonical_encoding","result_fields"],"operands":{"subject_ref":"member of role subject_union","payload_ref":"exact role payload_id_type"},"canonical_value":{"exact_fields":["subject_ref","payload_ref"],"encoding":"canonical JSON UTF-8 bytes"},"derivation":{"kind":"derived","width":32,"codec":"CVE1","fields":["type_tag","canonical_bytes"],"type_tag":"state","domain_schema":"exactly role applicability_domain/applicability_schema"},"result":{"exact_keys":["ref","canonical_bytes","preimage_hex","subject_ref","payload_ref"]}}, "trace_effects":{"event_operand":"exact recursive trace AST selecting project event and cardinality one","native_event_exact_keys":["seq","step_id","op","status","reads","writes","output","error","before_digest","after_digest"],"path_grammar":"nonempty NFC relative path; no leading/trailing/repeated slash and no dot segments","duplicate_policy":"ordered native occurrences are counted; duplicates are not uniqued","result":{"exact_keys":["step_id","status","read_count","write_count","record_writes","edge_writes","binding_writes","allocation_writes","writes"]}}, "trace_write_excludes":{"authentication":"evaluates only native runtime trace","result":{"exact_keys":["after_seq","path","excluded","events"],"event_exact_keys":["seq","step_id","matching_writes"]},"comparison":"exact canonical write path after exclusive sequence"}, "semantic_roles":{"versioned_reference":{"fields":["record_type","id_type","namespace_field","label_field","target_field","predecessor_field","order_field","tombstone_field","expires_field","namespace_types","target_types"],"descriptor_closure":"namespace exact ref; target exact optional ref; predecessor exact optional id_type; distinct fields"},"provenance":{"fields":["record_type","occurrence_id_type","actor_field","commitment_field","authorization_evidence_field","causal_inputs_field","actor_types","commitment_types","evidence_types","actor_record_types","commitment_record_types","evidence_record_types","causal_types","causal_record_types"],"descriptor_closure":"actor/commitment/evidence exact refs; non-null causal_inputs_field is an exact array ref union equal to unique causal_types and exactly covered by unique causal_record_types; null causal role requires both causal tuples empty; authoritative referenced records required"}}, "verify_provenance":{"claim_union":["exact protected ref",{"exact_keys":["claimed_occurrence_ref","actor_ref","commitment_ref","authorization_evidence_ref","causal_inputs"]}],"result":{"exact_keys":["verified","match_status","occurrence_ref","actor_ref","commitment_ref","evidence_ref","causal_inputs"],"branches":{"MATCH":{"verified":True,"occurrence_ref":"authoritative protected ref","fields":"exact role actor/commitment/evidence and declared causal inputs"},"UNKNOWN_MATCH":{"verified":False,"occurrence_ref":"attempted same-typed ref"},"FIELD_MISMATCH":{"verified":False,"occurrence_ref":"attempted authoritative ref"},"UNSUPPORTED":{"verified":False,"occurrence_ref":"attempted roleless provenance ref"}}},"grounding":"MATCH requires an explicit profile ProvenanceRole plus authoritative actor, commitment, evidence, and every declared causal record; a non-null causal field uses exact ordered refs and cannot dangle or cross authoritative record types","null_causal_role":"structured claim must contain causal_inputs=[]; a nonempty list returns FIELD_MISMATCH; a non-list returns MALFORMED; successful result causal_inputs is null"}, "persisted_rebinding":{"helper":"rebind_persisted_ref","source":"validated persisted records only","registers_or_trace":False,"serialization_change":False}, "assertions":{"version":ASSERTION_DSL_VERSION,"contract_stage":ASSERTION_CONTRACT_STAGE,"consumption":"only evaluate() after execute_program; compiler/runtime source and execution do not read assertions or expected outcomes","schema":{"assertion_array":{"type":"array","minItems":1,"assertion_id_uniqueness":"global"},"exact_keys":sorted(ASSERTION_KEYS),"assertion_id":"trimmed nonempty NFC string; globally unique within assertion array","profile_id":list(PROFILE_IDS),"case_id":list(CASE_IDS),"requirement_id":sorted(REQUIREMENT_IDS),"case_requirement_mapping":copy.deepcopy(CASE_REQUIREMENTS),"operators":sorted(ASSERTION_OPERATORS),"expected_outcome":["PASS","FAIL"],"failure_rationale":"null iff expected_outcome PASS; neutral nonempty NFC string iff FAIL","purpose":"neutral concise nonempty NFC string","descriptor_union":[{"exact_keys":["path"],"path":"nonempty RFC 6901 pointer; slash addresses an empty-key member; array indices are 0 or nonzero ASCII decimal without leading zeros"},{"exact_keys":["value"],"value":"closed JSON value"}],"operands":{"EQ_NE":{"exact_keys":["left","right"],"members":"descriptor"},"STATUS_EQ":{"exact_keys":["actual"],"member":"descriptor"},"EDGE_EXISTS":{"exact_keys":["relation_set","edge"],"edge_exact_keys":["kind","from","to"],"from_to":"descriptor"},"FATAL":{"exact_keys":["event"],"member":"descriptor"}}},"operator_semantics":{"EQ":"left/right have identical JSON/Python type and value","NE":"negation of typed EQ","STATUS_EQ":"actual is a string exactly equal to one closed status token","EDGE_EXISTS":"relation-set output contains an edge with exact kind and typed-equal from/to","FATAL":"event status is FATAL, error.code exactly equals expected, before_digest is a string and equals after_digest"},"expected_semantics":"EQ/NE/EDGE_EXISTS require literal true; STATUS_EQ is exact status token; FATAL is exact error code; expected_outcome never affects predicate evaluation","evidence":{"row_exact_keys":["assertion_id","operator","predicate_result","pass","expected_outcome","prediction_match","actual_evidence"],"EQ_NE":["left","right","typed_equal"],"STATUS_EQ":["actual_status","expected_status"],"EDGE_EXISTS":["selector","matching_edges"],"FATAL":["status","error_code","before_digest","after_digest"]},"aggregation":{"assertion_pass":"actual predicate result only","prediction_match":"pass corresponds to expected_outcome","case_outcome":"PASS iff every assertion predicate passes","case_prediction_match":"all assertion predictions match","profile_prediction_validation":"separate validate_profile_predictions over case outcomes and preregistered vector"}}}
def experiment_bundle() -> dict[str,Any]: return {"bundle_version":"D001-EXPERIMENT-BUNDLE-3","decision_id":"D-001","decision_status":"OPEN","contract_stage":ASSERTION_CONTRACT_STAGE,"runtime_spec":_runtime_spec(),"fixture_local_mechanisms":copy.deepcopy(DEFERRED_LABELS),"profiles":[profile_to_json(PROFILES[x]) for x in PROFILE_IDS],"profile_neutral_programs":copy.deepcopy(NEUTRAL_PROGRAMS),"compiled_programs":compile_all(),"external_assertion_set":assertion_set(),"expected_profile_vectors":copy.deepcopy(EXPECTED_VECTORS)}
__all__=["PROFILE_IDS","CASE_IDS","PROFILES","NEUTRAL_PROGRAMS","EXPECTED_VECTORS","ASSERTION_DSL_VERSION","ASSERTION_CONTRACT_STAGE","ASSERTION_KEYS","ASSERTION_OPERATORS","REQUIREMENT_IDS","CASE_REQUIREMENTS","compile_program","compile_all","execute_program","assertion_documents","assertion_set","validate_assertions","evaluate","validate_profile_predictions","profile_to_json","profile_from_json","experiment_bundle"]