
    jj                      U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZ ddlmZmZ dd	lmZmZ dd
l m!Z!m"Z"m#Z# ddl$m%Z% dg dg dddg ddddZ&de'd<   dg g dZ(de'd<   ddie(d ejR                   ejT                  e(dd      jW                               jY                         iZ-de'd<    ej\                  d       Z/d!Z0d"Z1d#Z2d$d%d&d'd(d)e0gZ3 ej\                  d*      Z4 G d+ d,e5      Z6	 	 	 	 dsd-Z7dtd.Z8dud/Z9dd0dvd1Z:dwd2Z;dxd3Z<dyd4Z=	 	 	 	 dzd5Z>	 	 	 	 d{d6Z?	 	 	 	 	 	 d|d7Z@	 	 	 	 	 	 	 	 d}d8ZA	 	 	 	 	 	 d~d9ZBdd:ZCdd;ZD	 	 	 	 	 	 	 	 	 	 dd<ZE	 	 	 	 	 	 	 	 	 	 	 	 dd=ZF	 	 	 	 dd>ZG	 	 	 	 	 	 dd?ZH	 	 	 	 	 	 dd@ZI	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddAZJ	 	 	 	 	 	 	 	 ddBZK edC      ZLdDZM edE      ZN edF      ZO edG      ZP edH      ZQdIZRdJZS ejR                  eS      jY                         ZTdKdLeQj                         ePj                         gg dMdNdOZVdPg ddQdRdRdSdTdUdUdUdSdUdQdQdVdWZWh dXZXh dYZYddZZZdd[Z[dd\Z\dd]Z]d^d_	 	 	 	 	 	 	 	 	 	 	 dd`Z^ddaZ_	 	 	 	 	 	 	 	 	 	 ddbZ`	 	 	 	 	 	 	 	 	 	 ddcZadddZb	 	 	 	 	 	 	 	 ddeZc	 	 	 	 	 	 	 	 	 	 ddfZdddg	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddhZeddi	 	 	 	 	 	 	 	 	 ddjZfddkZgddlZh	 	 	 	 	 	 	 	 ddmZi	 	 	 	 	 	 	 	 ddnZjdddo	 	 	 	 	 	 	 	 	 	 	 	 	 ddpZkddqZlemdrk(  r en el             y)zHOffline rehydration and sealed expected-state checks for Task26 bundles.    )annotationsN)BytesParser)compat32)Path)AnyCallableMappingSequencecast)InvalidRequirementRequirement)InvalidVersionVersion)qualification_tool_hashestrust_boundary_digestvalidate_product_binding)validate_snapshotz!task26-evidence-trust-boundary-v1)trusted_operator_accounthost_kernelselected_python_pip_toolchainsealed_wheel_bytes)content_identitydeterministic_tamper_detectionreproducibility*revocation_and_current_authority_selectionfail_closed_workflowzThese guarantees apply only while the trusted operator account, host kernel, selected Python/pip toolchain, and sealed wheel bytes remain trustworthy.zCoherent compromise of the trusted operator account or host administrator, including coherent modification of the repository, ledger, or verifier, is outside the Task26 threat model.)external_authenticitynon_repudiationowner_tamper_proof_or_worm+resistance_to_compromised_operator_or_adminFnone)schematrust_anchorsguarantees_within_boundaryscope_statementoutside_scopenot_claimedexternal_authenticity_claimedsignature_claimdict[str, object]TRUST_BOUNDARY	root_modedirectoriesentries_EMPTY_WHEELHOUSE_PAYLOADr"   %task26-sealed-wheelhouse-inventory-v1inventory_sha256T,:	sort_keys
separators_EMPTY_WHEELHOUSEz[-_.]+z3.12@d01195a6c0de359b77948625d1e97c35cffbc7dcd145daaa4eed1a5c252ce063@ba03fe2e484683a8bdba0121f014caf614891c84da06a674a25314da1fce658az	sealed-tycheck'gateway/platforms/nutrition_coaching.pyz--output-formatgitlab--python-versionz^[0-9a-f]{64}$c                        e Zd Zd fdZ xZS )InvariantMismatchc                T    t         |   d|        || _        || _        || _        y )Nzinvariant differs: )super__init__keyexpectedactual)selfrE   rF   rG   	__class__s       /home/cube/projects/richard/traning coach/.omo/evidence/task26/task26-combined-prefreeze-st_01a0198f-v38/gateway/platforms/task26_final_state.pyrD   zInvariantMismatch.__init__a   s-    .se45     )rE   strrF   objectrG   rM   returnNone)__name__
__module____qualname__rD   __classcell__)rI   s   @rJ   rA   rA   `   s     rK   rA   c                >    | D ]  \  }}}||k7  st        |||       y N)rA   )checksrE   rF   rG   s       rJ   _require_invariantsrW   h   s,     "(XvX#C6:: "(rK   c                R    t        j                  | dddd      j                         S )NFTr3   )ensure_asciir7   r8   	allow_nan)jsondumpsencodevalues    rJ   	canonicalr`   p   s+    :: fhrK   c                   t        j                         }| j                  d      5 t        fdd      D ]  }|j	                  |        	 d d d        |j                         S # 1 sw Y   |j                         S xY w)Nrbc                 &     j                  d      S )Ni   )read)streams   rJ   <lambda>zsha256_file.<locals>.<lambda>}   s    &++k":rK   rK   )hashlibsha256openiterupdate	hexdigest)pathdigestchunkre   s      @rJ   sha256_filerp   z   sh    ^^F	4F:C@EMM%  A 
  
 s   &A&&A>	directoryc                  | j                         }|rt        j                  nt        j                  }|rddhnddh}t        j                  |j
                        se ||j
                        rS|j                  t        j                         k7  s2|s|j                  dk7  s!t        j                  |j
                        |vrt        d|        y )N  i@          z sealed private path is invalid: )lstatstatS_ISDIRS_ISREGS_ISLNKst_modest_uidosgeteuidst_nlinkS_IMODE
ValueError)rm   rr   inforF   modess        rJ   _privater      s    ::<D(t||dllH'UENeU^ET\\"%;;"**,&dmmq0<<%U2;D6BCC 3rK   c                    t        | t              rt        d | D              rt        | d      t	        t        t
        t        f   |       S )Nc              3  >   K   | ]  }t        |t                 y wrU   
isinstancerL   ).0rE   s     rJ   	<genexpr>z_object.<locals>.<genexpr>   s     )Tesjc.B*Be   z is invalid)r   dictanyr   r   rL   r   )r_   labels     rJ   _objectr      s@    eT"c)Te)T&TE7+.//S#X&&rK   c                J    t         j                  d|       j                         S )N-)_NORMALIZE_PROJECTsublowerr^   s    rJ   _normal_projectr      s    !!#u-3355rK   c           	     d   t        |        	 t        j                  |       5 }|j                         }t	        |      t	        t        |            k7  st        d |D              rt        d      |D cg c]  }|j                  d      s| }}t	        |      dk7  rt        d      t        t              j                  |j                  |d               }d d d        t        j                  d	d
            j!                         }t        |j                  dd
            j!                         }|r|st        d      	 t        t#        |            }	t'        d |j)                  d      xs g D              }
t+        |      |	|
t-        |       | j/                         j0                  t/        j2                  | j/                         j4                        dS c c}w # 1 sw Y   xY w# t        j                  $ r}t        d      |d }~ww xY w# t$        $ r}t        d      |d }~ww xY w)Nc              3  p   K   | ].  }|j                  d       xs dt        |      j                  v  0 yw)/..N)
startswithr   parts)r   names     rJ   r   z"_wheel_identity.<locals>.<genexpr>   s3     ZTYDts+GttDz7G7G/GGTYs   46zwheel members are invalidz.dist-info/METADATArw   z%wheel METADATA cardinality is invalid)policyr   zdependency wheel is invalidName r   z$wheel project/version is unavailablezwheel version is invalidc              3  2   K   | ]  }t        |        y wrU   rL   )r   r_   s     rJ   r   z"_wheel_identity.<locals>.<genexpr>   s     [3Y#e*3Y   zRequires-Dist)projectversionrequires_distrh   sizemode)r   zipfileZipFilenamelistlensetr   r   endswithr   r   
parsebytesrd   
BadZipFilerL   getstripr   r   sortedget_allr   rp   ry   st_sizer   r}   )rm   archivenamesr   metadata_namesmessageexcr   version_textr   requirementss              rJ   _wheel_identityr      s   TNA__T"g$$&EE
c#e*o-ZTYZZ !<==!&!&$--8M*N   >"a' !HII!2==^A./G #" '++fb)*002Gw{{9b1288:L,?@@>gl+, [7???3S3YWY3Y[[L"7+%d#		##TYY[001 ' #"  A67S@A  >34#=>s`   G. AG!4GGAG!G. H G!!G+&G. .HHH	H/H**H/c                `    t         d       g }g } g}|ry|j                         }t        |d       t        t        j                  |      d       D ]3  }t        |j                        }|j                         }t        j                  |j                        rt        d      t        j                  |j                        rmt        |d       |j                  |j                         j                         t        j                   |j                        d       |j                  |       t        j"                  |j                        r-|j$                  dk(  rt        |       |j                  |       +t        d       |ryt        | fd	      t        |d
       fS )NTrq   c                    | j                   S rU   )r   )items    rJ   rf   z#_wheelhouse_files.<locals>.<lambda>   s    DIIrK   )rE   zwheelhouse symlink is forbidden)relative_pathr   z.whlz.wheelhouse contains an unbound non-wheel entryc                B    | j                        j                         S rU   )relative_toas_posix)rm   roots    rJ   rf   z#_wheelhouse_files.<locals>.<lambda>   s    (8(8(>(G(G(IrK   c                    t        | d         S )Nr   r   )rows    rJ   rf   z#_wheelhouse_files.<locals>.<lambda>   s    CO0D,ErK   )r   popr   r   scandirr   rm   rx   ry   r|   r}   r   rz   appendr   r   r   r{   suffix)r   wheelsr.   pendingrr   entryrm   r   s   `       rJ   _wheelhouse_filesr      sO    TT"F+-KfG
KKM	d+BJJy17MNNE

#D::<D||DLL) !BCC||DLL)."")-)9)9$)?)H)H)J $T\\ : t$dll+v0Ed# !QRR% O . 	vIJ{ EF rK   c                   i }t               }| D ]j  \  }}t        |j                  dd            }t        |j                  dd            }||f}||v s||v rt        d      |j	                  |       ||f||<   l | D ]*  \  }}|j                  d      }	t        |	t              st        d      |	D ]  }
	 t        t        |
            }|j                  t        d      |j                  |j                  j                         sV|j                  t        |j                              }|t        d	|j                         t        |d
   j                  dd            }|j                  s|j                  j                  |d      rt        d|j                          - y # t        $ r}t        d      |d }~ww xY w)Nr   r   r   z/duplicate project/version in explicit wheel setr   z)wheel dependency declarations are invalidz'wheel dependency declaration is invalidz%direct URL dependencies are forbiddenzmissing dependency: rw   T)prereleaseszdependency version mismatch: )r   rL   r   r   addr   listr   r   urlmarkerevaluater   r   	specifiercontains)r   projects
identitiesrm   identityr   r   rE   _pathr   rawrequirementr   
dependencyselected_versions                  rJ   _validate_dependency_closurer      s    >@H'*uJ hhll9b12hll9b12 *8 3NOOs!8, ! "x||O4,-HIICU)#c(3 * !HII!!-k6H6H6Q6Q6S!ok6F6F&GHJ! #78H8H7I!JKK":a=#4#4Y#CD$$[-B-B-K-K d .L . !#@AQAQ@R!STT!  	 " & U !JKQTTUs   7F--	G6GGc                  |D cg c]  }|t        |      f }}| g }g }n]t        |       \  }}|D cg c]  }|t        |      f }}|D cg c](  \  }}d|j                  |       j                         i|* }}}| d}	g }n-t	        j
                  | j	                         j                        }	t        g ||       |	|d}
ddi|
dt        j                  t        |
            j                         iS c c}w c c}w c c}}w )zMBuild an exact recursive inventory and prove the explicit dependency closure.Nr   r,   r"   r1   r2   )r   r   r   r   ry   r   r}   r   rg   rh   r`   rl   )
wheelhouserequired_wheelsrm   root_wheelsdependency_wheelsr/   pathsr.   r   r-   payloads              rJ   build_wheelhouse_inventoryr     sN    >MM_TD/$/0_KMEG+-.z:{GLMutdOD$9:uM #4

 #4h  !1!1*!=!F!F!H #4 	 
  $	LL!2!:!:;	 !C;!C1B!CD"G 	9
 	GNN9W+=>HHJ 3 N N
s   C<D-Dc                  t        |d      }t        |      h dk7  s|j                  d      dk7  rt        d      |j                  d      }|j                  d      }|j                  d      ||d	}t	        |t
              rNt	        |t
              r>|j                  d
      t        j                  t        |            j                         k7  rt        d      t        | |      }||k7  rt        d      |S )Nsealed wheelhouse inventory>   r"   r/   r-   r.   r2   r"   r1   -sealed wheelhouse inventory schema is invalidr/   r.   r-   r,   r2   z-sealed wheelhouse inventory digest is invalidr   z4wheelhouse inventory differs from sealed expectation)r   r   r   r   r   r   rg   rh   r`   rl   r   )r   rF   r   documentr/   r.   r   rG   s           rJ   verify_wheelhouse_inventoryr   .  s     x!>?H
8}   

	0
1 HIIll9%G,,}-K\\+."G w%+t,<<*+>>)G,-779: HII'OF OPPMrK   c                   |j                  d      }t        |t              st        d      | |rt        d      g S g }|D ]~  }t	        |d      }|j                  d      }t        |t
              r0t        |      j                         sdt        |      j                  v rt        d      |j                  | |z          |S )Nr/   %sealed wheelhouse entries are invalidz sealed wheelhouse is unavailablezsealed wheelhouse rowr   r   z!sealed wheelhouse path is invalid)
r   r   r   r   r   rL   r   is_absoluter   r   )r   	inventoryr/   r   r   r   relatives          rJ   _bound_wheel_pathsr   U  s     mmI&Ggt$@AA?@@	Ec2377?+8S)H~))+tH~+++@AAZ(*+  LrK   c                    t        | t              r t        d | j                         D              S t        | t              rt        d | D              S y)Nc              3  D   K   | ]  \  }}|d v xs t        |        yw)>   record_pathraw_direct_urlraw_direct_url_sha256raw_installed_record_sha256raw_installed_record_portable raw_direct_url_record_row_sha256!raw_installed_records_nonportableN%_contains_nonportable_record_material)r   rE   r   s      rJ   r   z8_contains_nonportable_record_material.<locals>.<genexpr>o  s>      
 +	T 	 
; 5T:
; +s    c              3  2   K   | ]  }t        |        y wrU   r   r   r   s     rJ   r   z8_contains_nonportable_record_material.<locals>.<genexpr>~  s     Q548>5r   F)r   r   r   itemsr   r^   s    rJ   r  r  m  sN    % 
 #[[]
 
 	
 %Q5QQQrK   c           	     |   t        | d      }t        |j                  d      d      }t        |j                  d      d      }t        |j                  d      d      }|j                  d      }|j                  d	      }|j                  d
      dk7  s`t        |t              rP|d d ddgk7  sFt	        |      s;|j                  d
      dk7  s'|ddddk7  st        |t              rt        |      dk7  rt        d      t        |j                  d      d      }t        |      ddhk7  rt        d      dD ]  }t        |j                  |      d| d      }	|	j                  d      }
t        |
t              st        d      |
D cg c]2  }t        |t              r |j                  d      d k(  rt        |d!      4 }}t        |      d"k7  rt        d#      |d$   }t        |j                  d%      d&      }|	j                  d'      }|j                  d(      }t        |      h d)k7  s|j                  d*      |k7  st        |t              r|j                  d+      rt        |      h d,k7  s|j                  d
      d-k7  s|j                  d.      |	j                  d/      k7  so|j                  d0      |	j                  d1      k7  sL|j                  d2      |k7  s8|j                  d3      |k7  s$t        j                  t        |xs d4            t        d5       d6d7g}t        ||d8      D ]  \  }\  }}	t        |d9      }|j                  d:      }t        |      h d;k7  s|j                  d<      |k7  s|j                  d.      |	k7  st        |t              rt        |      j                         snd=t        |      j                   v sWt        j                  t        |j                  d>d4                  )t#        |j                  d?            t$        us	|d?   d"k  st        d@       y c c}w )ANportable installed runtimeorigin_proofzportable origin proof	executionzportable origin executioninterpreterzportable interpreterr   modulesr"   $installed-golden-runtime-portable-v2          task26-installed-origin-proof-v1private_empty_controlledTFcwd_authoritypython_isolatedpythonpath_inheritedz*portable installed origin proof is invaliddistributionsportable runtime distributionsprofilehermesz,portable installed distributions are invalidr  r  z	portable  distributioninstalled_inventoryz'portable installed inventory is invalidkind'canonical_direct_url_archive_provenancez!portable direct URL inventory rowrw   z2portable direct URL provenance cardinality differsr   
provenancezportable direct URL provenancewheel_sha256dist_info_member_path>   r  rm   r  rm   z.dist-info/direct_url.json>   r"   distributionarchive_sha256sealed_wheel_sha256r   sealed_wheel_basenamez(task26-portable-direct-url-provenance-v1r!  distribution_namer$  wheel_filenamer#  r"  r   z)portable direct URL provenance is invalidgatewayr  checkin_clir  strictzportable origin moduleinstalled_relative_path>   r   modulerh   r!  r-  r.  r   rh   r   z1portable installed origin module proof is invalid)r   r   r   r   r  r   r   r   r   rL   r   _HEX_DIGEST	fullmatchzipr   r   r   typeint)runtime_portableruntimeproofr  r	  interpreter_versionr
  r  roler!  r   r   direct_rows
direct_rowr  r  member_pathexpected_pairsr   r.  r   s                        rJ   "_validate_portable_origin_contractr=    s   &(DEGGKK/1HIE		+.0KLI'++m46LMK%//)4ii	"GH!GG-t4r"q"g-0999X"DD7#$)

 '4(w<1EFFO$&FM =i22GHH%d#ym%D
 !$$%:;	)T*FGG !
 #t$89 C<=  	 
 {q QRR ^
NN<(*J

 $''7 nn%<=
O==~~f%4k3/''(DE: ~~h'9:~~n- 345~~56 012~~34D~~./<?$$S);%<=EHII] &^ ,-GHN'*7N4'P##flc347745H wwx F*ww~&,6h,H~))+tH~+++$$S2)>%?@HCGGFO$C/6{QPQQ+ (QS
s   
7P9c          	        t        | d      }t        |      h dk7  rt        d      |j                         D ci c]  \  }}|dk7  s|| }}}t        |j	                  d      d      }t        |j	                  d      d      }	|j	                  d      d	k7  s|j	                  d
      |k7  su|j	                  d      |k7  sa|j	                  d      dusN|j	                  d      t        j                  t        |            j                         k7  st        |      ddhk7  rt        d      dD ]  }
t        |j	                  |
      |
 d      }t        |	j	                  |
      |
 d      }|j	                  d      }t        |      h dk7  sa|j	                  d      |j	                  d      k7  s=|j	                  d      |j	                  d      k7  s|j	                  d      |j	                  d      k7  st        j                  t        |j	                  dd                  	 |j	                  d      dust        j                  t        |j	                  dd                  	 |j	                  d      |j	                  d      k7  sb|j	                  d       dusO|j	                  d!      d"k7  s;t        |t              r+|t        t        |            k7  st        d# |D              st        d$       |S c c}}w )%Nz"nonportable installed RECORD audit>   r"   audit_sha256install_roler  candidate_digest0raw_direct_url_hash_equality_required_or_claimedz4nonportable installed RECORD audit schema is invalidr?  r  znonportable audit distributionsr  r"   z,task26-nonportable-installed-record-audit-v1r@  rA  rB  Fr  r  z5nonportable installed RECORD audit binding is invalidr  z raw RECORD auditz portable distributionpath_dependent_classifications>
   reasonr!  r  r   portable_projection_sha256r   r   rC  r   +raw_direct_url_equality_required_or_claimedr!  r%  r  rE  !portable_record_projection_sha256r   r   r   r   r   rF  rD  Avalidated_path_dependent_installer_material_may_change_raw_recordc              3  $   K   | ]  }|d v 
 yw)>   path_dependent_launcherdirect_url_raw_record_hashconsole_entry_point_launcherdirect_url_absolute_file_urlN r  s     rJ   r   z5_validate_nonportable_record_audit.<locals>.<genexpr>0  s&      	 ,D  ,   z1nonportable installed RECORD audit row is invalid)r   r   r   r  r   rg   rh   r`   rl   r/  r0  rL   r   r   r   r   )r_   r@  rA  r4  auditrE   r   unsignedaudit_distributionsportable_distributionsr8  r   portableclassificationss                 rJ   "_validate_nonportable_record_auditrV    s    E?@E
5z   OPP+0;;=R=ic4C><QT	=HR!		/"$E %_-/O 			(MM99^$499'(,<<99GHPUU99^$>>)H-.88:;"#	8'<<PQQ%)--d3v=N5OP"&&t,6L.M
 ''"BCH ww~&(,,7J*KKww~&(,,~*FFww34||?@A$$CGG92>?  ww67uD$$CGG3R89  ww9:ww./0wwDEURwwx RSot4&_)=">> 	 ,	 	 PQQg &h LK Ss   L	Lc                  t        | d||      }t        |d||      }t        |j                  d      d      }t        |j                  d      d      }i }	dD ]  }
t        |j                  |
      d|
 d	      }t        |j                  |
      d
|
 d	      }|j                  d      }||j                  d      k7  s#|j                  d      |j                  d      k7  rt        d      ||	|
<    d||dd|	dS )zDValidate both raw audits without comparing their nonportable hashes.originalr@  rA  r4  
rehydratedr  zoriginal portable distributionsz!rehydrated portable distributionsr  z	original r  zrehydrated rG  r  z3original and rehydrated portable projection differsz.task26-frozen-installed-record-verification-v2F)r"   !original_nonportable_record_audit#rehydrated_nonportable_record_audit,raw_record_hash_equality_required_or_claimedrB  rE  )rV  r   r   r   )rX  rZ  rA  original_runtime_portablerehydrated_runtime_portableoriginal_auditrehydrated_auditoriginal_distributionsrehydrated_distributionsprojection_digestsr8  original_distributionrehydrated_distribution
projections                 rJ   $verify_nonportable_record_audit_pairrh  ?  sS    8)2	N :!)4	 %!%%o6)  '#''8+  -/% '"&&t,	$}.M!
 #*$((.+dV=0Q#
 +../

 &**+NOP$((8&**>:; RSS#-4 # && C-;/?8=<A&8 rK   c                    t        t        |             }d|d   |d}t        j                  t	        |            j                         |d<   |S )zIBind the complete canonical product derivation, never a digest tautology."task26-outer-candidate-manifest-v2rA  )r"   rA  product_bindingmanifest_sha256)r   r   rg   rh   r`   rl   )rk  	validatedr   s      rJ   build_outer_candidate_manifestrn  y  sR     )o)>?I6%&89$#H
 #*..81D"E"O"O"QHOrK   c                   t        |      }|j                         sd|j                  v rt        d      | |z  }t	        |       t        t        j                  |j                  d            d      }t        |      h dk7  rt        d      |j                         D ci c]  \  }}|dk7  s|| }}}t        |j                  d	            }t        |j                  d
d            }	|j                  d      dk7  sF|	|d
   k7  s>|j                  d      t        j                  t!        |            j#                         k7  rt        d      |	t%        |      |fS c c}}w )Nr   (outer candidate manifest path is invalidutf-8encodingzouter candidate manifest>   r"   rl  rk  rA  z*outer candidate manifest schema is invalidrl  rk  rA  r   r"   rj  z+outer candidate manifest binding is invalid)r   r   r   r   r   r   r[   loads	read_textr   r  r   r   rL   rg   rh   r`   rl   rp   )
bundler   r   rm   r   rE   r_   rQ  rk  	candidates
             rJ    _verify_outer_candidate_manifestrx    sX    M"H!7CDDHDTN

4>>7>346PH 8}   EFF%-^^%5%5zsE@Q9QU
%5   /x||<M/NOOHLL!3R89IX"FF(:;;<<)*>>)H-.88:; FGGk$'88s   "E 0E c                  t        | j                  d      | d      }t        | j                  d      | d      }t        |j                  d      | d      }t        | j                  d      | d      }| j                  d	      }| j                  d
      }t        | j                  d      | d      }t        | j                  d            }	|j                         D 
ci c]  \  }
}|
dk7  r|
| }}
}| j                  d      |k7  st        j                  t        |            t        j                  t        |            |j                  d      |k7  st        j                  t        |j                  dd                  	 lt        j                  t        |j                  dd                  	 <t        j                  t        |j                  dd                  |j                  d      dk7  s|j                  d      |k7  s|j                  d      d| dk7  st        j                  t        |j                  dd                  	 |j                  d      dk7  s|j                  d	      |k7  spt        j                  t        |j                  dd                  	 @t        j                  t        |j                  dd                  	 t        j                  t        |j                  dd                  	 |j                  d      |j                  d      k(  s||j                  d      |j                  d      hv s|d||j                  d      |j                  d      |j                  d      |j                  d      d k7  sR|j                  d      t        j                  t        |            j                         k7  s|	j                  d	      |k7  rt        | d!      |||d   |d   |j                  d      |j                  d      |||	|d"
S c c}}
w )#Ncandidate_authorityz
 authoritytask26_contractz Task26 contractlocal_socket_transcriptz local socket transcriptdeployment_wheelsz deployment wheelsrA  source_tree_digestcapability_identity_receiptz capability identity receiptruntime_authority_snapshotreceipt_sha256runtime_modecurrent_qualified_candidateregistry_head_sha256r   ledger_head_sha256
chain_headr"   z4task26-local-http-telegram-api-transcript-binding-v1r   z'data/task26-local-http-telegram-api-qa-.jsontranscript_sha256z"task26-deployment-wheel-binding-v1 candidate_product_binding_sha256hermes_wheel_sha256profile_wheel_sha256z.task26-delivery-capability-identity-receipt-v1)r"   rA  r  r  r  wheel_digestz- candidate or authority projection is invalid)
rA  r~  task26_chain_headauthority_current_candidateauthority_registry_headauthority_ledger_headr}  r  r  r|  )r   r   r   r  r/  r0  rL   rg   rh   r`   rl   r   )resultr   	authoritycontract
transcript
deploymentrw  source_treecapability_identityr  rE   r_   capability_unsigneds                rJ   _candidate_result_projectionr    s>    

#89dV:;NOIvzz"34>N6OPH./&()J $78TFBT:UVJ

-.I**12K!

01&,- "3

/0"
 .3355JC"" 	U
5   	

>"d*  Y08  [!12:==679D  	4b9:
    	2B78
    X\\,%C!DEM>>(#AB>>.)T1>>/*4TF%@A  
2B78
  >>(#'KK>>,-:  
A2FG
    
4b9:
    
5r:;
  >>/0>>012NN01NN12


 F )0:21 $.>>2G#H$.NN3I$J&NN+@A	


 ""#34>>)$789CCEF%))*<=JD6!NOPP%)%l3'01N'O#,==1G#H!*/C!D'':&@#- Cs   &P>c               L   t        |d      }t        |d      }t        | |      \  }	}
}t        |j                  d      d      }|d   |d   k7  rt	        d      t        |d   d	      }t        |d   d
      }|j                  d      dk7  sZ|j                  d      dk7  sF|j                  d      |j                  d      k(  s#|j                  d      |j                  d      k(  rt	        d      |d   |d   k7  slt        |d   d      j                  d      |d   k7  sHt        |d   d      j                  d      |d   k7  s$t        |d   d      j                  d      |d   k7  rt	        d      t        fd|d   |d   |d   |d   |	fD              rt	        d      ||fD ]6  }t        |      }|j                         sd|j                  v s-t	        d       d||||||
|	|d   dd}t        j                  t        |            j                         |d<   |S ) Nsourcer   	installedderivation_inputsouter product derivation inputsr~  z3source and installed tree provenance digests differr|  zsource local socket transcriptz!installed local socket transcriptr  r   r  z8source and installed socket transcripts were substitutedr}  source deployment wheelsr  binding_sha256r  r  z5source and installed deployment wheel receipts differc              3  (   K   | ]	  }|k7    y wrU   rN  )r   r_   rA  s     rJ   r   z)build_candidate_parity.<locals>.<genexpr>=  s#      	
E 	!!
   rA  r  9source, installed, authority, and outer candidates differr   z'candidate parity bundle path is invalid%task26-cross-mode-candidate-parity-v1)r   rh   rA  product_binding_sha256)r"   rA  source_bundle_relative_pathinstalled_bundle_relative_pathr  r  outer_manifestparity_sha256)r  rx  r   r   r   r   r   r   r   rg   rh   r`   rl   )rv  rA  source_resultinstalled_resultr  r  outer_manifest_relative_pathr  r  outer_candidate	outer_shark  product_inputssource_transcriptinstalled_transcriptr   rm   r   s    `                rJ   build_candidate_parityr  
  s    *-hGF,-=KPI2R,3/OY /02SN "#y1E'FFNOO()+K #+,.Q 	n-9##N3{B  1##O45  !45##$789 STT"#y1D'EE6-.0JKOO.
 +,- 6-.0JKOO!
 /01 6-.0JKOO"
 012
 PQQ
 	 %&01()34
	 	 TUU02PQH~!3FGG R
 :,'B*H9 /&56F&G	
#H !(y/B C M M OH_OrK   c          
        t        |d      }t        |      h dk7  rt        d      |j                         D ci c]  \  }}|dk7  s|| }}}t        |j	                  d      d      }|j	                  d      }|j	                  d      d	k7  sb|j	                  d
      k7  sN|j	                  d      t        j                  t        |            j                         k7  st        |t              st        d      t        | |      \  }	}
}t        |j	                  d      d      }t        |j	                  d      d      }t        |j	                  d      d      }t        |j	                  d      d      }|j	                  d      |j	                  d      k7  s-|j	                  d      |j	                  d      k7  s	|j	                  d      |j	                  d      k7  s|j	                  d      |j	                  d      k7  s|j	                  d      |j	                  d      k7  s|j	                  d      |
k7  s|j	                  d
      |	k7  sx|j	                  d      |j	                  d      k7  sUt        fd|	|j	                  d
      |j	                  d      |j	                  d
      |j	                  d      fD              rt        d      t        t        t        t        f   |      S c c}}w )Ncandidate parity>   r"   r  r  r  r  rA  r  r  z"candidate parity schema is invalidr  r  outer manifest parityr   r"   r  rA  z"candidate parity digest is invalidr  zsource candidate parityr  zinstalled candidate parityr  r  r}  r  r~  r  r  r  r  rh   r  c              3  (   K   | ]	  }|k7    y wrU   rN  )r   r_   expected_candidates     rJ   r   z*verify_candidate_parity.<locals>.<genexpr>  s#      	
 ''r  r  r  )r   r   r   r  r   rg   rh   r`   rl   r   rL   rx  r   r   r   rM   )rv  parityr  r   rE   r_   rQ  outerr   r  r  rk  r  r  r  source_deployments     `             rJ   verify_candidate_parityr  ^  s    v12H
8} 	 	 =>>%-^^%5%5zsE9OU
%5   HLL!124KLEyy)HX"II<<*+/AA<<(>>)H-.88:;(C(=>>2R3/OY X\\(+-FGF[13OPI/02SN  

&')C 	

'(IMM:N,OO::)*imm<O.PP  !CD/01  !67345  !7845699X)+99'(O;99-./01 	
  

-.

8901;<	
 	
 TUUS&[!8,,cs   K4
K4z0qualification/profile-qualification-receipt.json&supplied_successor_profile_source_treez#qualification/profile-pytest.stdoutz#qualification/profile-pytest.stderrz.qualification/profile-collection-manifest.jsonz&qualification/profile-pytest-runner.pyi  s  import hashlib,json,sys
import pytest

def canonical(value):
 return json.dumps(value,sort_keys=True,separators=(",",":"),allow_nan=False).encode()
class Plugin:
 def __init__(self,path): self.path=path; self.ids=[]; self.outcomes={}
 def pytest_collection_finish(self,session): self.ids=[item.nodeid for item in session.items]
 def pytest_runtest_logreport(self,report):
  if report.when=="call": self.outcomes[report.nodeid]=report.outcome
 def pytest_sessionfinish(self,session,exitstatus):
  passed=sorted(key for key,value in self.outcomes.items() if value=="passed")
  doc={"schema":"task26-profile-pytest-manifest-v1","pytest_version":pytest.__version__,"interpreter_version":list(sys.version_info[:3]),"interpreter_executable_sha256":hashlib.sha256(open(sys.executable,"rb").read()).hexdigest(),"collected_count":len(self.ids),"executed_count":len(self.outcomes),"passed_count":len(passed),"test_ids":self.ids,"passed_test_ids":passed,"exit_code":int(exitstatus)}
  doc["manifest_sha256"]=hashlib.sha256(canonical(doc)).hexdigest()
  open(self.path,"wb").write(canonical(doc)+b"\n")
if len(sys.argv)!=2 or not sys.flags.isolated: raise SystemExit(4)
plugin=Plugin(sys.argv[1])
raise SystemExit(pytest.main(["-q","-p","no:cacheprovider","."],plugins=[plugin]))
selected_qualification_python-I)z-qz-pzno:cacheprovider.profile_source_root)executable_roleargvpytest_argvworking_directory_rolez$task26-profile-pytest-environment-v1private_cache_rootC.UTF-8r   z
os.devnull1HOMELANGLC_ALLPATHPIP_CONFIG_FILEPIP_NO_INDEXPYTHONDONTWRITEBYTECODEPYTHONNOUSERSITEPYTEST_ADDOPTSPYTEST_DISABLE_PLUGIN_AUTOLOADTMPDIRXDG_CACHE_HOME)r"   inherited_variablesprivate_cache	variables>   r"   statusstderrstdout	exit_code
test_countr	  runner_toolpytest_versionr  timeout_secondscommand_identitysource_root_rolecollection_manifestenvironment_contractr  source_tree_sha256_aftersource_tree_sha256_beforeprofile_source_tree_digest>   r"   test_idsr  passed_countexecuted_countr  collected_countrl  passed_test_idsr7  interpreter_executable_sha256c                   g }t        | j                  d            D ]  }|j                         s,|j                         rt	        d |j
                  D              r@|j                  |j                  |       j                         t        |      |j                         j                  d        |st        d      t        j                  t        |            j!                         S )Nz*.pyc              3  $   K   | ]  }|d v  
 yw)>   .venv__pycache__NrN  )r   parts     rJ   r   z)_profile_source_digest.<locals>.<genexpr>  s      :
9CD,,rO  )rm   rh   r   z,profile source tree contains no Python files)r   rglob
is_symlinkis_filer   r   r   r   r   rp   ry   r   r   rg   rh   r`   rl   )r   rowsrm   s      rJ   _profile_source_digestr    s    $&Dtzz&)*??DLLNc :
9=:
 7
 $$T*335!$'IIK''
 	 + GHH>>)D/*4466rK   c                H    | j                  |       | j                  d       y )Nru   )write_byteschmod)rm   datas     rJ   _write_private_bytesr    s    TJJurK   c                l    |j                         t        |       | j                         j                  dS )N)r   rh   r   )r   rp   ry   r   )rm   r   s     rJ   _profile_artifactr    s/    !**,d#		## rK   c                J    	 	 	 	 	 	 	 	 dd}t        j                  | |       y )Nc                    t        |      }|j                  j                  d       |j                         r3|j	                         s#|j                  |j                         rdnd        | |       y )Nrt   ru   )r   parentr  existsr  is_dir)functionrm   _errortargets       rJ   make_removablez-_remove_profile_cache.<locals>.make_removable   sP     dE"==?6#4#4#6LL&--/u=rK   )onexc)r  zCallable[[str], object]rm   rL   r  BaseExceptionrN   rO   )shutilrmtree)cacher  s     rJ   _remove_profile_cacher    s7    )14>K	 MM%~.rK   i,  )r  c                  |j                  d      }|j                  d      }|j                         r|j                         rt        d      t        |      t        usd|cxk  rdk  st        d       t        d      t        |       t        |      }t        |      }| t        j                  z  }	|	j                  d       | t        z  }
| t        z  }| t        z  }| t        z  }t        |
t               t!        |      }t#        t%        j&                  d	
            }|j)                  d       t+        |      dddt,        j.                  dddddt+        |      t+        |      d}	 	 t1        j2                  t+        |      dt+        |
      t+        |      g||dd|      }t        ||j6                         t        ||j8                         t;        |       t!        |      }||k7  rt        d      |j=                         st        d      |j)                  d       t?        tA        jB                  |jE                  d            d      jG                         D ci c]  \  }}|dk7  s|| }}}jI                  d      }jI                  d      }jI                  d      }t        |      |k7  sCt        |      |k7  s4|
jK                         t        k7  stM              tN        k7  s	jI                  d      d k7  sjI                  d      tQ        jR                  tU        |            jW                         k7  stY        |tZ              rt]        d! |D              st_        |      t_        tM        |            k7  sutY        |tZ              reta        |      |k7  sWt]        fd"d#D              sCjI                  d$      d%k7  s/|jb                  d%k7  s te        jf                  d&|j6                        t        d'      tY        |tZ              r=|dd( d)d*gk7  s3jI                  d+      |k7  stY        jI                  d,      t*              st        d-      i dd.d/|d0|d1|d2|d3th        d4tj        d5tl        d6|d7tn        d8d9d$|jb                  d:d;||d<d,d,   d=t        jq                         tr        d>d?tu        |t              d@tu        |t              dAtu        |t              i}tQ        jR                  tU        |            jW                         |dB<   | t        z  }t        |tU        |      dCz          |
||||fD ]  }|j)                  dD        |S # t0        j4                  $ rE}t        ||j6                  xs d       t        ||j8                  xs d       t        d      |d}~ww xY w# t;        |       w xY wc c}}w )Ez;Execute and persist the exact profile pytest qualification.Tr+  z6profile qualification source or interpreter is invalidrw     z(profile qualification timeout is invalidrt   r  ztask26-profile-pytest-)prefixr  r   r  r  r  F)cwdenvr<   capture_outputtimeoutrK   z&profile pytest qualification timed outNz0profile source tree changed during qualificationz8profile pytest run did not produce a collection manifestru   rq  rr  profile pytest manifestrl  r  r  r7  r"   !task26-profile-pytest-manifest-v1c              3  H   K   | ]  }t        |t               xs |   y wrU   r   r  s     rJ   r   z6write_profile_qualification_receipt.<locals>.<genexpr>T  s%     E:dC((4H4s    "c              3  N   K   | ]  }j                  |      t        k7    y wrU   r   _PROFILE_TEST_COUNTr   rE   manifests     rJ   r   z6write_profile_qualification_receipt.<locals>.<genexpr>X  #     yCxCx||C $77Cx   "%r  r  r  r  r      (?m)749 passed in [0-9]zDprofile pytest qualification must execute and pass exactly 749 testsr  r  r  r  r  z6profile qualification interpreter or pytest is invalid'task26-profile-qualification-receipt-v2r  r  r  r  r  r  r  r  r  r  PASSr	  r  )r  executable_sha256r   r  r   rh   r  r  r  r     
rv   );resolver  r   r2  r3  r   rp   #_PROFILE_QUALIFICATION_RECEIPT_PATHr  mkdir_PROFILE_RUNNER_PATH_PROFILE_MANIFEST_PATH_PROFILE_STDOUT_PATH_PROFILE_STDERR_PATHr  _PROFILE_RUNNERr  r   tempfilemkdtempr  rL   r   devnull
subprocessrunTimeoutExpiredr  r  r  r  r   r[   rt  ru  r  r   
read_bytesr   _PROFILE_MANIFEST_KEYSrg   rh   r`   rl   r   r   r   r   r   
returncoderesearch_PROFILE_COMMAND_V2_PROFILE_ENV_V2_PROFILE_SOURCE_ROOT_ROLEr  r   _PROFILE_RUNNER_SHA256r  )rv  r  profile_wheelqualification_pythonr  r  python
wheel_hashpython_hashqualificationrunnermanifest_pathstdout_pathstderr_pathbeforer  r  	completedr   afterrE   r_   manifest_unsignedidspassedr   receiptreceipt_pathrm   r  s                                @rJ   #write_profile_qualification_receiptrO    s    !(((5F!)))6F==?fmmoQRROC'qO/Js/JCDD 0KCDD]]+Jf%K@GGGMU#**F33M//K//K1#F+F!!)ABCE	KKE
IB::s#&Ce*E
C%	P"VdCK]1CD#'I 	[)*:*:;[)*:*:;e$"6*EKLL  "STTtzz-"9"97"9"KLNghH6>nn6Fc6F
U#QbJbe6Fc
,,z
"C\\+,Fll01GM"j0v+-/1x=22<<!%HH<<)*gnnYGX=Y.Z.d.d.ff#t$EEEs8s3s8}$&$'#;& yCxyy<<$)1$990)2B2BCK_``w%2A;1b'!<<78KG(,,'78#>QRR";"$f" 	$V" 	#E	"
 	
" 	/" 	" 	5" 	?" 	)" 	&" 	Y))" 	>!,
"$ 	(#34%"& 	)=)F)F)HTjk'"( 	#K1EF)"* 	#K1EF+", 	0@VW-"G0 !(y/A B L L NG??Ly'9E'AB[,O

5 PNS (( 	P cjj.?C@ cjj.?C@EFCO	P 	e$ ds7   3:U7 -,W -W";W"7W
A W

WW Wc                `   t        |d      }| |z  }t        |      h dk7  s"|j                  d      |j                         k7  rt	        d      t        |       |j                  d      t        |      k7  s,|j                  d      |j                         j                  k7  rt	        d      |S )Nzprofile qualification artifact>   r   rh   r   r   z1profile qualification artifact binding is invalidrh   r   z&profile qualification artifact differs)	r   r   r   r   r   r   rp   ry   r   )rv  r_   r   bindingrm   s        rJ   _verify_profile_artifactrR    s    e=>GHD
7|::gkk/>Z^f^o^o^q>qLMMTN{{8D 11W[[5HDIIKL_L_5_ABBKrK   c                  t        |d      }| t        z  }t        |       t        t        j                  |j                  d            d      }t        | |j                  d      t              }t        | |j                  d      t               t        | |j                  d      t              }| t        z  }	t        |	       t        t        j                  |j                  d            d      t        |j                  d	      d
      }
t        |j                  d      d      }|j                         D ci c]  \  }}|dk7  s|| }}}j                         D ci c]  \  }}|dk7  s|| }}}j                  d      }j                  d      }|j                  d      }|j                  d      }t        |      t        k7  xs |j                  d      dk7  xs |j                  d      |k7  xs |j                  d      |k7  xs |j                  d      |k7  xs t        j!                  t#        |xs d            d u xsr |j                  d      |k7  xs[ |j                  d      t$        k7  xs@ |j                  d      t&        k7  xs% |j                  d      t(        k7  xs
 t+        |      t,        uxs d|cxk  xr dk  nc  xs |j                  d      t.        k7  xs t+        |j                  d            t,        uxs |j                  d       d!k7  xs |j                  d"      d#k7  xsv |
t        j1                         t2        d$k7  xsU |	j5                         t6        k7  xs; |j                  d%      d&k7  xs$ t        j!                  t#        |j                  d'd                  d u xs t9        |t:               xs |d d( d)d*gk7  xs |j                  d+      j                  d+      k7  xs j                  d,      |k7  xs j                  d-      |j                  d'      k7  xsm t              t<        k7  xsX j                  d      d.k7  xsA j                  d      t?        j@                  tC        |            jE                         k7  xs  t9        |t:               xs tG        |      t.        k7  xs tG        t        |            t.        k7  xs t9        |t:               xs tI        |      |k7  xs tK        fd/d0D              xs j                  d"      d#k7  xsm tM        jN                  d1|j5                               d u xsE |j                  d      t?        j@                  tC        |            jE                         k7  xs ||k7  }|rtQ        d2      |S c c}}w c c}}w )3Nzprofile qualification receiptrq  rr  zpersisted profile receiptr  r  r  r  r  zprofile runnerr	  zprofile interpreterr  rl  r  r  r   r  r"   r!  r  r  r  r   r  r  r  r  rw   r  r  r  r"  r  r   r$  r  r  r#  r  r  r  r  r7  r  r  c              3  N   K   | ]  }j                  |      t        k7    y wrU   r  r  s     rJ   r   z0_verify_profile_qualification.<locals>.<genexpr>  r  r  r  r   z%profile qualification receipt differs))r   r'  r   r[   rt  ru  rR  r   r+  r,  r*  r)  r  r   _PROFILE_KEYS_V2r/  r0  rL   r9  r:  r;  r2  r3  r  r   r<  r4  r-  r   r   r5  rg   rh   r`   rl   r   r   r   r7  r8  r   )rv  r_   r  r  rM  rN  	persistedr  rD  runner_pathrC  r	  rE   rQ  rJ  rK  rL  r   r  invalidr  s                       @rJ   _verify_profile_qualificationrY    s    e<=G??L\

<#9#97#9#KLNijI%fgkk(.CEYZFVW[[%:<PQ,VW[[AV5WYopM//K[tzz-"9"97"9"KLNghHW[[/1ABF'++m46KLK-4]]_X_zsEGW@WU
_HX6>nn6Fc6F
U#QbJbe6Fc
,,z
"C\\+,Fooi(Gkk+,GG(( 	 ;;x $MM	 ;;348RR	  ;;237QQ	  ;;126PP		 
   %?%E2!FG4O	  ;;-.2FF	  ;;)*.AA	  ;;-./A	  ;;)*.GG	  =#	  ,-+>3+>'>	  ;;|$(;;	  L)*#5	  ;;x F*	  /6kk+.F!.K	  ';'D'D'FRhii	  !!#6	   ??,-1PP!	 "   [__5H"%M!NOSWW#	 $ '4((%	 $ -4BQKAr7,B%	 & ;;'(HLL9I,JJ'	 ( <<-.'9)	 * <<78KOOL_<``+	 , x=22-	 . <<!%HH/	 0 <<)*gnnYGX=Y.Z.d.d.ff1	 2 #t$$3	 2 ),C4G(G3	 2 LOsSVx=\oKo3	 4 &$''5	 4 ,2#;&+@5	 6 yCxyy7	 8 <<$)9	 : 990&2C2C2EF$N;	 < ;;'(GNN9X;N,O,Y,Y,[[=	 > A D @AANU Ycs   =WW&W4Wc          
     z   t        | d       t        |       t        |       t        |       t        t        j                  |j	                  d            d      }t        |      h dk7  s|j                  d      dk7  rt        d	      |j                  d
      }|j                         D ci c]  \  }}|d
k7  s|| }}}|t        j                  t        |            j                         k7  rt        d      |j                  d      t        k7  rt        d      t        |j                  d             t        |j                  d      dt!        |j                  dd            t        |j                  d      d             t#        | |j                  d      t!        |j                  dd                  }	t        |j                  d      d      }
t        |	j                  d      d      }t        |	j                  d      d      }t        |j                  d      d      }t%        | |j                  d      |j                  d       t'        |      !       |j                  d"      t'        |      k7  rt        d#      |
|j                  d$      |j                  d$      d%k7  rt        d&      d'|fd|ffD ]J  \  }}t        |j                  |      |      }||j(                  t'        |      d(k7  s=t        d)| d*       t        |j                  d+      d,      }t        |      h d-k7  rt        d.      |j                  d/      }t+        |t,              st        d0      t        |j                  d      d1      }t        |j                  d2      d3      }|j                  d4      }t+        |t               st        d5      t/        | |      \  }}}t1        |t3        | d6z  t5        t6              j9                         j:                  d7   8      t=        t              t!        |d9         t?        |      ||:       tA        |j                  d;      t!        |j                  dd            |<       d=D ]  }t        |j                  |      |      }|j                  d4      }t+        |t               r0t5        |      jC                         sd>t5        |      jD                  v rt        d)| d?      | |z  }t        |       |j                  d"      t'        |      k7  st        d)| d*       t        |j                  d@      dA      }dBD ]O  }| dCz  |z  }t        |       |j                  |jG                  dD      dEz         t'        |      k7  sFt        dF       |S c c}}w )GzGValidate the hash-bound portable expectation before creating a runtime.Trq   rq  rr  zsealed expected state>   r"   verifierr  r   hermes_wheelr=  trust_boundarydocument_sha256expected_statusrA  candidate_parityfrozen_bootstrapr4  provenance_helperprofile_qualificationexpected_result_sha256hermetic_ty_attestationlocal_socket_transcriptsindependent_candidate_verifierr[  r"   task26-sealed-final-state-v7z'sealed expected-state schema is invalidr^  z'sealed expected-state digest is invalidr]  z)sealed evidence trust boundary is invalidr4  r[  rX  rA  r   r  rY  r`  r  rf  zsealed local socket transcriptsr  source candidate projectionr  installed candidate projectionr=  zprofile wheelrc  r~  r  r  rh   z+profile qualification wheel binding differsr|  r  r  z.sealed local socket transcript bindings differr\  filenamerh   sealed  digest differsr   r   >   r"   r/   r-   r.   r2   r   r/   r   r  r  r  r   rp  verification-toolsr  scripts_dirpackage_rootr2   expected_tool_hashesexpected_trust_boundary_sha256$expected_wheelhouse_inventory_sha256expected_wheelhouse_entry_countactual_hermes_wheelactual_profile_wheelre  rA  rk  )r[  rb  ra  rg  r   z path is invalidr  zsealed authority)zregistry.jsonzqualification-ledger.jsonzcandidate-authorityr  _sha256zsealed authority digest differs)$r   r   r[   rt  ru  r   r   r   r  rg   rh   r`   rl   r+   r=  rV  rL   r  rY  rp   r   r   r   rx  r   r   r   __file__r&  parentsr   r   !_validate_hermetic_ty_attestationr   r   removesuffix)rv  expected_pathr\  r=  rF   claimedrE   r_   rQ  verified_paritytranscript_bindingssource_projectioninstalled_projectionprofile_bindingr   rm   rQ  r   r/   r  r  r   _rk  r  r  r   s                              rJ   verify_expected_stater    sd    Vt$]\]

=**G*<=H 8}  * 
h	#A	ABCCll,-G-5^^-=Z-=zsEHYAYU
-=HZ'..8!45??AABCC||$%7DEE&x||4F'GH&89X\\*<bAB LL+,.J
	 .'(x||,>CDO
 "/0)  H%'D #K(*J hll?;_MO!,-#4#8#89M#N(7	 8$M(BBFGG#''(AB)--.GH  IJJ	&	-(t (,,u-u5499D8IJJwug_=>> l35RSJ
:   HIInnY'Ggt$@AAX\\"457IJFFJJ/02IJEyy)Hh$CDD<VXNAq/6!55h//199!<
 (=^'L-0<N1O-P(+G(* &./X\\*<bAB'
 (,,u-u5;;/8S)H~))+tH~+++wug-=>??(";;x K$77wug_=>>#$ [13EFI>//$6==**73i?@KE
 
 >?? ? O_ [s   1V7?V7c                ^    | j                         D ci c]  \  }}|dvr|| c}}S c c}}w )N>   package_authorityrehydration_origin_proof)r  )r  rE   r_   s      rJ   _portable_verifier_resultr  j  s@     !,,.(JCGG 	U
(  s   )c               h   t        | d      t              h dk7  rt        d      t        |j                  d      d      }t        |j                  d      d      }j	                         D ci c]  \  }}|dk7  s|| }}}j                  d	      d
k7  sj                  d      |k7  soj                  d      |j                  d      k7  sKj                  d      |j                  d      k7  s'j                  d      t
        k7  sj                  d      |j                  d      k7  sj                  d      |j                  d      k7  st        j                  d      t              rt        t        t           d         d d ddgk7  sj                  d      t        k7  sjj                  d      |j                  d      k7  sFj                  d      t        |j                  d      d      j                  d      k7  s	j                  d      t        |j                  d      d      j                  d      k7  s͉j                  d      t        k7  sj                  d      t        k7  sj                  d      |j                  d      k7  szt        fddD              sft        j                  d             t        usFd    d!k  s>j                  d      t!        j"                  t%        |            j'                         k7  rt        d"      S c c}}w )#Nzsealed hermetic Ty attestation>   r"   
ty_versionr  ty_command_argvrA  gate_tool_sha256attestation_sha256runner_tool_sha256binary_member_sha256raw_diagnostics_counttarget_python_versionraw_diagnostics_sha256corrected_ty_wheel_sha256execution_provenance_sha256qualification_interpreter_role!qualification_interpreter_version'diagnostics_semantic_fingerprint_sha256z0sealed hermetic Ty attestation schema is invalidr  zproduct inputshermetic_tyzhermetic Ty bindingr  r"   z(task26-sealed-hermetic-ty-attestation-v2rA  r  r  r  r  r  r  r  r  r  r  qualification_tool_sha256zqualification toolsty_hermetic_runnerr  ty_surface_gater  r  r  c           	   3  ~   K   | ]4  }t         j                  t        j                  |d                   du  6 yw)r   N)r/  r0  rL   r   )r   fieldattestations     rJ   r   z4_validate_hermetic_ty_attestation.<locals>.<genexpr>  s=      

 !!#kooeR&@"ABdJs   :=)r  r  r  r  r  r  r  rw   z1sealed hermetic Ty attestation binding is invalid)r   r   r   r   r   _TASK26_TY_TARGET_PYTHON_VERSIONr   r   r   rM   _TASK26_TY_COMMAND_ARGV!_TASK26_TY_RAW_DIAGNOSTICS_SHA256)_TASK26_TY_DIAGNOSTICS_FINGERPRINT_SHA256r   r2  r3  rg   rh   r`   rl   )	r_   rA  rk  inputsr  rE   r   rQ  r  s	           @rJ   r  r  r  s    %!ABK
;  & KLL_(()<=?OPF&**]35JKK#.#4#4#6#6ic4#AU:UT	#6   	!%OO??-.2BB??67??678??<(KOOL,II??23+,??23??234??;<??;<=+//*MNPTUVk*MNOPRQRSr7??,-1HH??,-AR1SS??/06::9:<QRVV 

 ??-.6::9:<QRVV

 ??34,-??DE45??12??123 



 

  789D./!3??/0>>)H-.88:; LMMgs   2L. L.c                (   t        d| j                  d      |j                  d      fd| j                  d      |j                  d      fd| j                  d      t        |j                  d      d      j                  d	      fd
d|j                  d      fdt        |j                  d      fdt        |j                  d      fdd|j                  d      fdt        |j                  d      fdt        |j                  d      fd| j                  d      |j                  d      fd| j                  d      |j                  d      fd| j                  d      |j                  d      fd| j                  d      |j                  d      fd| j                  d      |j                  d      fd| j                  d      |j                  d      fd | j                  d      |j                  d      fd!| j                  d      |j                  d      fd"d#|j                  d$      fd%d&|j                  d'      ff       |j                  d      }t        |t              st        d(      t        t        t           |      }|t        k7  s|j                  d)      d*k7  rt        d(      t        |j                  d      d      }|j                  d	      }|j                  d+      d,k7  st        |t              r
|d-d. d/d0gk7  rt        d1      y-)2zKCompare portable Ty behavior, never path-dependent installed RECORD hashes.z-hermetic_ty_attestation.target_python_versionr  z'hermetic_ty_attestation.ty_command_argvr  z9hermetic_ty_attestation.qualification_interpreter_versionr  qualification_interpreterz'rehydrated Ty qualification interpreterr   z)hermetic_ty_attestation.provenance.schemaztask26-hermetic-ty-execution-v2r"   z8hermetic_ty_attestation.provenance.target_python_versionz2hermetic_ty_attestation.provenance.ty_command_argvz&hermetic_ty_attestation.receipt.schemaz'task26-ty-capability-surface-receipt-v3z5hermetic_ty_attestation.receipt.target_python_versionz/hermetic_ty_attestation.receipt.ty_command_argvz1hermetic_ty_attestation.corrected_ty_wheel_sha256r  ty_wheel_sha256z,hermetic_ty_attestation.binary_member_sha256r  installed_executable_sha256z.hermetic_ty_attestation.raw_diagnostics_sha256r  z-hermetic_ty_attestation.raw_diagnostics_countr  z?hermetic_ty_attestation.diagnostics_semantic_fingerprint_sha256r  zGhermetic_ty_attestation.receipt.diagnostics_semantic_fingerprint_sha256z6hermetic_ty_attestation.receipt.raw_diagnostics_sha256z5hermetic_ty_attestation.receipt.raw_diagnostics_countz;hermetic_ty_attestation.receipt.capability_diagnostic_countr   capability_diagnostic_countz&hermetic_ty_attestation.receipt.status?PASS_CHANGED_SURFACE_WITH_PREEXISTING_OUTSIDE_SCOPE_DIAGNOSTICSr  z0rehydrated Ty semantic target command is invalidr?   rw   r  r  Nr  r  r  z2rehydrated Ty qualification interpreter is invalid)rW   r   r   r  r  r   r   r   r   rM   count)	sealed_ty	ty_resultty_provenance
ty_receiptcommand_valuecommandr	  r   s           rJ   _verify_rehydrated_ty_resultr    sf     @5656 :/0/0 LABMM"=>= #i. <1!!(+ K0!!"9: E'!!"34 99x( H067 B'01 D9:/0 ?45;< A6767 @56!!"9: RGHGH ZGHHI I6778 H5667 N<= 9Qx(}c	
eL "%%&78MmT*KLL4</G**==+,1KLL561K ooi(G)*.MM'4(2A;1b'!MNN "rK   )r   c          	     T   t        |	j                  d      d      }t        |       |t        t              nt        |||f      }t        | |      \  }}}|j                  d      }t        |t              st        d      t        |t        | dz  t        t              j                         j                  d         t!        t"              t%        |d	         t'        |      ||
       t        |      }t)        t        |      d||      }t+        t        |      ||      }t-        | ||
|	|||      }t        |j                  d      d      }t        |j                  d      d      }| t.        z  }t1        |       t3        | t5        j6                  |j9                  d            |j                  d      t;        |            }i ddd|d|d|d|d|j<                  t;        |      dd|j<                  t;        |      dd |d!|t;        | |z        d"d#|t;        | |z        d"d$d%t;        | d%z        d"d&d't;        | d'z        d"d(|	j                  d)      d*t?        j@                  tC        tE        |	                  jG                         d+t;        | d,z        t;        | d-z        |j                  d.      |j                  d/      d0d1|d2|d3   |d3   d4|t"        d5}t?        j@                  tC        |            jG                         |d6<   |S )7zIBuild, but do not write or freeze, one successor expected-state document.rz  zcandidate authority resultr   r/   zwheelhouse entries are invalidrr  r  rs  r2   rv  rX  rY  r}  )rA  r  r  r  r  r  r  rj  r  rk  rq  rr  r~  rl  r"   rh  rA  r4  r[  re  r\  rn  r=  r   r[  r$  rb  ra  z-verification-tools/task26_frozen_bootstrap.pyrg  z2verification-tools/independent_verify_candidate.pyr_  r  rd  r  z!candidate-authority/registry.jsonz-candidate-authority/qualification-ledger.jsonr  r  )registry_sha256zqualification-ledger_sha256r  r  r`  rf  r|  rm  )rc  r]  r^  )$r   r   r=  r   r9   r   rx  r   r   r   r   r   r   r  r&  r  r   r+   rL   r   rV  r  r  r'  r   rY  r[   rt  ru  rp   r   rg   rh   r`   r  rl   )rv  rA  r4  r[  re  r\  r=  verifier_relative_pathprovenance_relative_pathverifier_resultsource_verifier_resultr  r  r  r   authority_resultwheelhouse_inventoryr  outer_product_bindingwheelhouse_entriesruntime_expectationr`  sealed_ty_attestationr`  r  r  profile_qualification_pathrc  r   s                                rJ   build_expected_stater  H  s   & 124P ''78  	'(E
  #C,#Aq
 .11)<($/9::6!55h//199!<
 (=^'L-0 !34.
 ),,>(?(* /07./),	N >$%)-
 .),($?'E%A  X&(E #[)+K "(*M!M'(9

-777IJ#4#8#89M#N(7	:#0:#,:# 	/:# 	,^	:#
 	"#8:# 	$))!,/
:# 	%**!-0
:# 	*:# 	3!&+A"AB
:#& 	5!&+C"CD
':#. 	L!HH
/:#: 	)D!MM	+
;:#J 	?..x8K:#L 	!'../@A#

)+Q:#R 	*<<  ,7HH, %5$8$89O$P"2"6"67K"L	
S:#f 	,g:#h 	#'(AB-.GH%
i:#p "7(s:#Hv #*..81D"E"O"O"QHOrK   controlled_cwdc          	        t        |d      }t        |j                  d      d      }|j                  d      dk7  s|j                  d      dk7  s~|j                  d      d	uskt        |      d
dhk7  s[t        |j                  d      t              r<|Et        t	        |d               j                  d      |j                  d      k7  rt        d      t        | j                  d      d      }g }dD ]  \  }}	|j                  |      }
t        |
t              st        d      t        |
      }	 |j                  d      }|j                  |j                  d            j                         }|j                         }|j                         s.t        j                  |j                        r|j                  dk7  rt        d      t        |j                  |	      |	 d      }|j                  d      }t        |t               st        d      |D cg c]2  }t        |t"              r |j                  d      |k(  rt        |d      4 }}t%        |      }t'        |      dk7  s8|d   j                  d      |k7  s!|d   j                  d      |j(                  k7  rt        d      |j+                  |	||||j(                  d         d!d"dd	d#|d$S # t        t        f$ r}t        d      |d}~ww xY wc c}w )%z@Bind imported package origins to exact installed inventory rows.zrehydrated origin prober
  zrehydrated module originsr"   z!task26-rehydrated-origin-probe-v1isolatedrw   pythonpath_presentFr(  r*  r  NTr+  z,rehydrated Python isolation proof is invalidr  runtime distributions)r'  r)  z#rehydrated module origin is invalidz1module origin is outside rehydrated site-packagesz.rehydrated module origin is not a regular filer  r  zinstalled inventory is invalidrm   zinstalled inventory rowr   rh   r   z5module origin differs from installed RECORD inventory)r!  r.  r-  rh   r   r  r  r  )r"   r  r
  )r   r   r   r   rL   r   r&  r   r   r   OSErrorry   r  r{   r}   r   r   r   rp   r   r   r   )r5  site_packagesprober  evidencer
  r  
proof_rowsr.  r8  raw_pathrm   resolvedr   r   metadatar!  r   r   matchesrn   s                        rJ   verify_runtime_origin_proofr    s    u78Hhll9-/JKGX"EE<<
#q(<<,-U:w<I}55(,,u-s3&S%)*22$2?%%T%23 GHHGKK8:QRM*,JK;;v&(C(BCCH~	||4|0H++M,A,A,A,NOXXZH
 ==?!<< 0 01  A%MNN}0064&8NO $$%:;	)T*=>> !
 #t$H)D C23  	 

 X&LAqz~~h'61qz~~f%)9)99TUU $ +3  ((	
G LZ 57#$)

  I $ 	C	
s   7AK"7L"L1K==Lc                   t        | j                  d      d      }i }dD ]U  }t        |j                  |      | d      }|j                  d      }t        |t              rt	        d |D              rt        | d      |D cg c]^  }dt        t        |j                  d	d
                  j                  vr,t        |j                  d	d
            j                  d      s|` }}dD ci c]  }||j                  |       }	}t        |j                  d      | d      }
|
j                  d      |	d<   ||	d<   t        j                  t        |            j                         |	d<   |	||<   X t        | j                  d      d      }d|j                  d      |j                  d      d|| j                  d      dS c c}w c c}w )Nr  r  r  r  r  c              3  >   K   | ]  }t        |t                 y wrU   )r   r   )r   r   s     rJ   r   z$_portable_runtime.<locals>.<genexpr>2  s      6
1>#
3%%r   z installed inventory is invalidr   rm   r   z.dist-info/RECORD)r%  distribution_versionmetadata_sha256r&  r  wheel_record_sha256portable_record_projectionz portable RECORD projectionprojection_sha256rG  installed_inventory_sha256r	  zruntime interpreterr  rh   r   )rh   r   r  )r"   r	  r  r  )r   r   r   r   r   r   r   rL   r   r   rg   rh   r`   rl   )r5  r  rS  r8  r!  raw_inventoryr   r   rE   portable_distributionrg  r	  s               rJ   _portable_runtimer  ,  s   GKK8:QRM02%}0064&8NO$(()>?-.# 6
1>6
 3
 v%DEFF %
$4CGGFB$7 89???+,556IJ $ 	 

4
 !!#&& 	 
4
 9:f/0

 FP^^F
AB 8A34>Enni ?

)+ 	:; (=t$G &H '++m46KLK8!ooh/"y1
 0N3 =

4
s   A#G0Gc                     t         j                  j                         D  ci c]*  \  } }| j                  d      s| j                  d      s| |, }} }|j	                  dt         j
                  ddd       |S c c}} w )NPYTHONPIPr  )r  r  r  PIP_DISABLE_PIP_VERSION_CHECK)r   environr  r   rk   r0  )rE   r_   environments      rJ   _clean_environmentr  _  s     ****,,JC~~h'u0E 	U
,  
  #!zz-0		
 s   /A:c               
   t        |d       t        |j                               rt        d      t	        j
                  t        |       d|t        |      dd      }t        |j                               rt        d      |S )NTrq   z"controlled Python cwd is not empty)r<   r  r  r  textz)Python subprocess wrote to controlled cwd)r   r   iterdirr   r1  r2  r   r   )r  r  r  rH  s       rJ   _run_pythonr  p  sy     ^t,
>!!#$=>>WI >!!#$DEErK   c                    d|fd|ffD ]J  \  }}t        | j                  |      |      }||j                  t        |      dk7  s=t	        d| d       y )Nr\  r=  rn  rp  rq  )r   r   r   rp   r   )rF   r\  r=  r   rm   rQ  s         rJ   _verify_bound_wheel_hashesr    se     
&	-(t (,,u-u5499D8IJJwug_=>>rK   )r   temp_parentc                  '()*+, t         |||      }t        ||j                  d      ||f      }t        t	        j
                  d|            }|j                  d       |dz  ''j                  d       t               (	 |d	z  }	t        t        j                  d
dd	t        |	      g'(       |	j                  d       |	t        j                  dk(  rdndz  *t        ||||f      }t        |||       t!        ||      }
t        *      d
ddddddgd |
D        t        |      t        |      }t        |'(       t        t        *      d
ddg'(      j"                  j%                         }t        |      }|dz  + t        t'        |d   d      d         z  }d}t        t        *      d
d|t        |      t        |	      t        |      t        |      t        |      t        |j                  dd            g
'(      j"                  }t'        t)        j*                  |      d      }t'        |j                  d       d!      }t-        |||j                  d"      '#      }||d$<   t/        |      }|j                  d%      }||j                  d&      k7  rt1        d'      t3        |j                  d(      t        |j                  dd            t'        t5         t        t'        t'        |j                  d)      d*      j                  d+      d,      j                  dd                  d-   d.      /      }|t1        d0      t7        t8        t:           |j                  d1g             D cg c]V  }t'        |d2      j                  d3      |j                  d4      k(  r'|t        t'        |d2      j                  d            z  X }}t=        |      d5k7  rt1        d6      |d7z  } d8z  } d9z  }t        t        *      d
t        |      d:t        |d;z        d<t        |d=         d>t        |d4         d?t        |d@         dAt        |      dBt        |      g'(      }t'        t)        j*                  |j"                        dC      }t'        |j                  dD      dE      }t'        |j                  dF      dG      }t?        ||||       +jA                  tC        |      dHz          +j                  dI        t        t'        |dJ   dJ      d         z  ,tE         |j                  d)      t        |j                  dd            K      )dk '()*+,fdL}  | dMdN      }! | dOdP      }"tG        |!dQ      )j                  dQ      k7  stG        |"dR      )j                  dR      k7  rt1        dS      tI         |j                  dT      |!j                  dU      tK        |      V      }#|"j                  dU      |#j                  dW      k7  rt1        dX      t'        |"j                  dY      dZ      }$t'        |j                  d[      d\      }%|"j                  d]      |j                  d^      k7  s|"j                  d      |j                  d      k7  s|$j                  d_      |%j                  d_      k7  sj|$j                  d`      |%j                  d`      k7  sGtM        jN                  tC        tQ        |"                  jS                         |j                  da      k7  rt1        db      tU        |j                  dc      |t        |j                  dd            t'        |j                  d&      dd      |e      |"df<   ||"d(<   |#|"dT<   ||"dg<   |"	 t        ||||f       t        |||       |jW                         rc|jY                  dh      D ]7  }&	 |&j[                         r|&j                  |&j]                         rdndI       9 ta        jb                  |dij       S S c c}w # t^        $ r Y cw xY w# |jW                         rr|jY                  dh      D ]F  }&	 |&j[                         r|&j                  |&j]                         rdndI       9# t^        $ r Y Dw xY w ta        jb                  |dij       w w xY w# 	 t        ||||f       t        |||       |jW                         rr|jY                  dh      D ]F  }&	 |&j[                         r|&j                  |&j]                         rdndI       9# t^        $ r Y Dw xY w ta        jb                  |dij       w w # |jW                         rr|jY                  dh      D ]F  }&	 |&j[                         r|&j                  |&j]                         rdndI       9# t^        $ r Y Dw xY w ta        jb                  |dij       w w xY wxY w)lzECreate an isolated offline runtime, rerun verification, and scrub it.)r\  r=  r   r   ztask26-rehydrate-)r  dirrt   zcontrolled-cwdr  venvr  z-mr  r  ntzScripts/python.exez
bin/pythonpipinstallz
--no-indexz	--no-depsz--no-compilec              3  2   K   | ]  }t        |        y wrU   r   )r   rm   s     rJ   r   z'rehydrate_and_verify.<locals>.<genexpr>  s     5$4Dc$i$4r   z-cz9import sysconfig; print(sysconfig.get_paths()['purelib'])zruntime.jsonrb  zprovenance helperr   a=  import hashlib,importlib.util,json,os,pathlib,sys;p=pathlib.Path(sys.argv[1]);s=importlib.util.spec_from_file_location('sealed_provenance',p);m=importlib.util.module_from_spec(s);s.loader.exec_module(m);r=m.collect_installed_runtime(venv=pathlib.Path(sys.argv[2]),site_packages=pathlib.Path(sys.argv[3]),profile_wheel=pathlib.Path(sys.argv[4]),hermes_wheel=pathlib.Path(sys.argv[5]));a=m.nonportable_installed_record_audit(r,install_role='rehydrated',candidate_digest=sys.argv[6]);import checkin_cli,gateway;o={'schema':'task26-rehydrated-origin-probe-v1','isolated':sys.flags.isolated,'pythonpath_present':'PYTHONPATH' in os.environ,'cwd':os.getcwd(),'modules':{'gateway':gateway.__file__,'checkin_cli':checkin_cli.__file__}};print(json.dumps({'runtime':r,'record_audit':a,'origin_probe':o},sort_keys=True,separators=(',',':')))rA  r   zrehydrated probe documentr5  zrehydrated runtimeorigin_prober  r  record_auditr4  z5rehydrated runtime differs from sealed portable bytesre  r`  r  r  r  r  zouter product bindingr}  z-sealed corrected Ty wheelhouse is unavailabler/   zwheelhouse rowrh   r  rw   z(sealed corrected Ty wheel is unavailablezty-attestationz/verification-tools/task26_hermetic_ty_runner.pyz,verification-tools/task26_ty_surface_gate.pyz--sourcer=   z
--ty-wheelr   z--expected-wheel-sha256z--expected-executable-sha256r  z--gate-toolz--output-directoryzrehydrated hermetic Ty resultexecution_provenancez"rehydrated Ty execution provenancesurface_receiptzrehydrated Ty surface receiptr%  ru   r[  ri  c           
        t        t        j                  | d                  }|z  }t        t        	      dt              t        |      dt        
      g      }t	        t        j                  |j                        |      S )Nr   r  z--rehydrated-runtimer  )r   rL   r   r  r   r[   rt  r  )relative_keyr   r   target_bundlerH  rv  r  r  r  r?  runtime_pathr[  s        rJ   run_verifierz*rehydrate_and_verify.<locals>.run_verifierb  s    C

< <=>H"X-M#KM&*%  .'I 4::i&6&67??rK   r  z!rehydrated source verifier resultr  z$rehydrated installed verifier resultr  r  z4rehydrated source/installed candidate parity differsrc  r~  rl  r  z/rehydrated profile qualification source differsrz  zrehydrated authorityr  zexpected authorityr  r_  r  r  rd  z=rehydrated verifier result differs from sealed expected stater[  zoriginal portable runtime)rA  r^  r_  installed_record_provenancer  *F)ignore_errors)r  rL   r   rL   rN   dict[str, Any])2r  r   r   r   r.  r/  r  r(  r  r  sys
executablerL   r   r   r  r   r  r   r   r[   rt  r  r  r   r  rx  r   r   rM   r   r  r  r`   r  r  rY  rp   rg   rh   r  rl   rh  r  r  r  r  r  r
  r  )-rv  r  r\  r=  r   r  rF   r   	temporaryr  dependency_pathsr  site_packages_textr  helperr  probe_outputprobe_documentruntime_documentr  rehydrated_portablera  r  r   ty_wheel_matches	ty_output	ty_runnerty_gatety_completedr  r  r  r   r  r  rc  r  expected_authorityrm   r  r  r  r?  r  r[  s-   `                                      @@@@@@rJ   rehydrate_and_verifyr    s>
    %!#	H ,\"&5I
 X%%-@kRSIOOE!11Ne$$&KU>6!^^T4T;)#	

 	

5D-lS/*L9
	
 	#8\=I-j)DK
 6$45
 
 
 	N	
 )FK	 *#	
 & 	 /0 >1#H013FG
 
4 	& #FFD	M"M"L!HLL!3R89 *#
 & 	  !JJ|$&A
 #y)+?
 3~.)	
 ,8(/0@A)--n=(,,/A"BBTUU5LL23 .@"!EF#0# (-? @ 2 "c"233 #or2  (
	& LMM DL)--	2*FG
Gs,-11(;}}89: WS*:;??PQQG 	 
  A%GHH 00	NN	II"FIM$MMN$Q'()I9:;.I456G$I" *#'
* JJ|**+-L
	  MM010
 MM+,.M

 	%		
 	  +;!<u!DE5!CHZ(*5oF
 
 )LL+,"8<<0BB#GH
	@ 	@" %)+N
 ,.T
 )XFzz(#$+FEzz+&' STT =LL01'4'8'89M'N!,]!;	!
 ::*+/D/H/H(0
 
 NOOJJ,-/E
	 %LL%';
 JJx HLL1B$CCzz,->P1QQ}}34!%%&<=>}}12!%%&:;<~~3F;<ik||456
 O  1@A !$X\\2Db%I!J*1LL!34/+ -@	 	,- -6()*?&'-9)*	>'!. =
 'x}M!%OOC0D??,$

DKKM5uE	 1 iu= "e
p #  !%OOC0D??,$

DKKM5uE"  1 iu= "	>'!. =
 'x}M!%OOC0D??,$

DKKM5uE"  1 iu= "y!%OOC0D??,$

DKKM5uE"  1 iu= "s   	K=c Aa !Oc /a1a#a c 	aa%c:b/
c#b/.c/	b;8c:b;;che=:$he/h0#eh	e 	he 	 h=%h#g
3h4#g
h	g$!h#g$$hhc                    t        j                         } | j                  dt               | j                  dt               | j                  dt        d       | j                  dt        d       | j                  dt               | j                  d	t               | j	                         }	 t        |j                  |j                  |j                  |j                  |j                  |j                  
      }t3        t!        j4                  |dd             y# t        t        t        j                  t         j"                  f$ r}dt%        |      d}t'        |t(              r>|j+                  |j,                  |j,                  |j.                  |j0                  d       t3        t!        j4                  |d      t6        j8                         Y d }~yd }~ww xY w)Nrv  )r2  expected_statez--hermes-wheelT)r2  requiredz--profile-wheelz--wheelhousez--temp-parent)r\  r=  r   r  TASK26_REHYDRATION_FAIL)r  rD  )first_invariant_keyrm   rF   rG   )r7   )filerw   r3   r6   r   )argparseArgumentParseradd_argumentr   
parse_argsr  rv  r  r\  r=  r   r  r  r   r1  SubprocessErrorr[   JSONDecodeErrorrL   r   rA   rk   rE   rF   rG   printr\   r  r  )parserargsr  r   failures        rJ   mainr&    s   $$&F
t,
(t4
(tdC
)tD
T2
d3D#%KK**,,((
F 
$**Vt

CD7 	""	  0#h&
 c,-NN+.77GG #!jj	 	JJ 	
 5s   2AD! !-G$BGG$__main__)rV   z$Sequence[tuple[str, object, object]]rN   rO   )r_   rM   rN   bytes)rm   r   rN   rL   )rm   r   rr   boolrN   rO   )r_   rM   r   rL   rN   r  )r_   rL   rN   rL   )rm   r   rN   r*   )r   r   rN   z*tuple[list[Path], list[dict[str, object]]])r   z+Sequence[tuple[Path, Mapping[str, object]]]rN   rO   )r   Path | Noner   Sequence[Path]rN   r*   )r   r*  rF   rM   r   r+  rN   r*   )r   r*  r   Mapping[str, object]rN   z
list[Path])r_   rM   rN   r)  )r4  rM   rN   rO   )
r_   rM   r@  rL   rA  rL   r4  r,  rN   r*   )rX  rM   rZ  rM   rA  rL   r^  r,  r_  r,  rN   r*   )rk  r,  rN   r*   )rv  r   r   rL   rN   z"tuple[str, str, dict[str, object]])r  r,  r   rL   rN   r*   )rv  r   rA  rL   r  r,  r  r,  r  rL   r  rL   r  rL   rN   r*   )rv  r   r  rM   r  rL   rN   r*   )r   r   rN   rL   )rm   r   r  r(  rN   rO   )rm   r   r   r   rN   r*   )r  r   rN   rO   )rv  r   r  r   r=  r   r>  r   r  r3  rN   r*   )rv  r   r_   rM   r   r   rN   r   )
rv  r   r_   rM   r  rM   r  rL   rN   r*   )
rv  r   r  r   r\  r   r=  r   rN   r  )r  r,  rN   r*   )r_   rM   rA  rL   rk  r,  rN   r*   )
r  r,  r  r,  r  r,  r  r,  rN   rO   ) rv  r   rA  rL   r4  r,  r[  r,  re  r,  r\  r   r=  r   r  rL   r  rL   r  r,  r  r,  r  rL   r  rL   r  rL   r   r*  rN   r*   )
r5  r,  r  r   r  rM   r  r*  rN   r*   )r5  r,  rN   r*   )rN   zdict[str, str])r  zSequence[str]r  r   r  zMapping[str, str]rN   z subprocess.CompletedProcess[str])rF   r,  r\  r   r=  r   rN   rO   )rv  r   r  r   r\  r   r=  r   r   r*  r  r*  rN   r*   )rN   r3  )o__doc__
__future__r   r  rg   r[   r   r7  r
  ry   r1  r  r.  r   email.parserr   email.policyr   pathlibr   typingr   r   r	   r
   r   packaging.requirementsr   r   packaging.versionr   r   -gateway.platforms.task26_candidate_derivationr   r   r   *gateway.platforms.task26_runtime_authorityr   r+   __annotations__r0   rh   r\   r]   rl   r9   compiler   r  r  r  r  r/  r   rA   rW   r`   rp   r   r   r   r   r   r   r   r   r   r  r=  rV  rh  rn  rx  r  r  r  r'  r;  r+  r,  r*  r)  r  r-  r<  r   r9  r:  rU  r5  r  r  r  r  rO  rR  rY  r  r  r  r  r  r  r  r  r  r  r  r&  rP   
SystemExitrN  rK   rJ   <module>r:     s   N "    	 	    
   $ !  9 9 B 5 
 I 2#	
	+ &+A!%! !F 0 ,  5
(
( 

%!	
 &( ik
( $ 
  RZZ	* #)  $f !,n )-$  bjj*+
 ;0;	; /4 D'6$N 
 / F!U7!U	!UH## $# 	#L$$$ $	$
 $N(<0*aRHVV V 	V
 +V Vr777 	7
  47 "67 7t)99!$9'9B_ _+.__DQQ Q (	Q
 +Q "%Q %(Q #&Q Qh@-@- @-9<@-@-F '+6' # E  AB AB NO DE  & (8BBD 6'0024J4S4S4UV83	  5$i9|S#&C&:N	  7"

/& vv v 	v
 v v vr=== !'	=
 = =@WWW 	W
 W WtPP P *	P
 Pf@O#@O#@O (@O %	@O
 
@Of #!QQ Q +	Q
 (<Q 2Q Q Q  Q "Q *Q 1Q "%Q %(Q #&Q  !Q" #Qr #'M!MM M
  M M`0f"  #	
 &,	?"	?26	?GK	?		?$ ##o>o>o> 	o>
 o> o> o> o>d	.b z
TV
 rK   