a
    C�j>  ã                   @   sÔ  d Z ddlZej dd¡ ej dd¡ ddlZg Zd?dd„Zedƒ ej	d	d
�Z
ej	dd
�Zededd„ e
D ƒƒdee
ƒ› �ƒ eddd„ e
D ƒdhkdd„ e
D ƒ› ƒ ededd„ eD ƒƒƒ ededd„ eD ƒƒedd„ eD ƒƒ› d�ƒ edƒ dd„ eD ƒZededd„ eD ƒƒdeeƒ› �ƒ ed eeƒee
ƒkeeƒ› d!ee
ƒ› �ƒ ed"ƒ d#d„ e
D ƒZd$d„ eD ƒZe e e¡¡Ze e e¡¡Zed%ed& ed& ked& › d!ed& › �ƒ ed'eed( ed(  ƒd)k ed( d*›d+ed( d*›d,�ƒ ed-ƒ d.d„ d/d„ eD ƒD ƒZd0d„ eD ƒZed1e eeƒ› d2�ƒ d3d„ eD ƒZed4ed5d„ eD ƒƒeeƒ› d6eeƒ› d7�e�s‚d8nd ƒ ed9d:d„ eD ƒ ƒ ed;e�s®d<nd=e› � ƒ e e�rÊd>nd¡ dS )@a[  The scoring paths must never see a result that was inferred from prices.

This exists because they did. On 2026-08-15 a market-derived fallback was put
straight into `ftr` so the dashboard would stop showing finished matches as
open. Every scoring path in the project defines "settled" as `ftr is not None`,
so the inferences were promoted into the forward test unnoticed and moved the
xlow OOS ROI from -1.22% to -0.01% -- a losing rule rendered break-even, in the
flattering direction, on the tile sitting next to real account cash.

The fix was to stop overloading `ftr`. These tests hold that line.
é    NzE:\soccer\researchzE:\soccer\mainÚ c                 C   s>   t d|rdnd› d| › |r"d| nd› �ƒ |s:t | ¡ d S )Nz  [ÚpassZFAILz] z  r   )ÚprintÚfailsÚappend)ZlabelZcondZextra© r   ú,E:\soccer\research\test_result_provenance.pyÚcheck   s    ,r	   z=== load_fixtures contract ===T)Zrequire_resultFz&every scored fixture has a real resultc                 c   s   | ]}|d  dv V  qdS )Úftr)ÚHÚDÚANr   ©Ú.0Úfr   r   r   Ú	<genexpr>   ó    r   zn=z#scored fixtures are all api-sourcedc                 C   s   h | ]}|  d ¡’qS ©Úftr_src©Úgetr   r   r   r   Ú	<setcomp>!   r   r   Úapic                 C   s   h | ]}|  d ¡’qS r   r   r   r   r   r   r   "   r   z9ftr is NEVER a market inference, even on the display loadc                 c   s(   | ] }|d  du p|  d¡dkV  qdS )r
   Nr   r   r   r   r   r   r   r   $   r   z'market results live only in ftr_displayc                 c   s(   | ] }|  d ¡dkr|d du V  qdS )r   Úmarketr
   Nr   r   r   r   r   r   &   r   c                 c   s    | ]}|  d ¡dkrdV  qdS )r   r   é   Nr   r   r   r   r   r   '   r   z	 inferredz7
=== the invariant the dashboard actually relies on ===c                 C   s   g | ]}|d  dur|‘qS )r
   Nr   )r   Zfxr   r   r   Ú
<listcomp>+   r   r   z<filtering on `ftr is not None` yields ONLY confirmed resultsc                 c   s   | ]}|  d ¡dkV  qdS )r   r   Nr   r   r   r   r   r   -   r   z/and matches the require_result=True set exactlyz vs z5
=== scoring is unchanged by the display fallback ===c                 C   s   g | ]}|d  t jkr|‘qS ©Úgd©ÚFZFREEZE_DATEr   r   r   r   r   2   r   c                 C   s   g | ]}|d  t jkr|‘qS r   r   r   r   r   r   r   3   r   zxlow n identicalÚnzxlow roi identicalZroig•Ö&è.>z+.4fz% vs ú%z>
=== fire_xhigh_detail keeps `won` on the confirmed result ===c                 C   s   g | ]}|r|‘qS r   r   ©r   Údr   r   r   r   ;   r   c                 c   s   | ]}t  |¡V  qd S )N)r   Zfire_xhigh_detailr   r   r   r   r   ;   r   c                 C   s,   g | ]$}|  d ¡du r|  d¡du r|‘qS )r
   NZwonTr   r"   r   r   r   r   <   s   ÿz5no detail row claims a win without a confirmed resultz detail rows checkedc                 C   s$   g | ]}|  d ¡r|  d¡s|‘qS )Zftr_displayr
   r   r"   r   r   r   r   F   r   z/every display-only result is tagged as inferredc                 c   s   | ]}|  d ¡dkV  qdS )r   r   Nr   r"   r   r   r   r   H   r   z inferred of z rowsz& (none right now -- API has caught up)z7no row carries a result in ftr that is flagged inferredc                 C   s(   g | ] }|  d ¡r|  d¡dkr|‘qS )r
   r   r   r   r"   r   r   r   r   L   r   Ú
z
ALL PASSEDz
FAILURES: r   )r   )Ú__doc__ÚsysÚpathÚinsertZforward_test_unique_bookr   r   r	   r   Zload_fixturesZscoredZdispÚallÚlenÚsumZpreppedZ	oos_cleanZoos_dispÚstatZclassify_xlowÚaÚbÚabsZdetZbadZinferredÚexitr   r   r   r   Ú<module>   st   
ÿþÿþÿ"ÿ*ÿÿÿþÿ