+
    *jF  c            	          R t ^ RIHt ^ RIt^ RIHu Ht ^ RI	t	^ RI
Ht ^ RIHt ]! RR^d^RRR	7      t]	P                  R
 4       tR tR tR tR tR tR tR tR tR tR tR# )u   TDD tests for runtime/conversation/prompt.py.

Key invariant: the pre-breakpoint prefix is byte-stable across turns
(same persona, different retrieved chunks → same stable prefix).
)annotationsN)assemble)PersonaManifestztest-personaTest Persona	generatedz"Speaks in short, direct aphorisms.)slugdisplay_nameborndiedvoice_policystyle_summaryc                    V # )N )test_persona_dirs   &B/Users/jameslopez/projects/MentorCore/tests/runtime/test_prompt.pypkg_dirr      s        c                   \        \        V 4      w  r\        V\        4      q3'       Eg9   RRR\        P
                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRRR\        P
                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p\        \        P                  ! V4      4      hR	p\        V\        4      q3'       Eg9   RRR\        P
                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR
\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
RR\        P
                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRR\        P                  ! V4      /,          p\        \        P                  ! V4      4      hR	p^ qRV8  qf'       g   \        P                  ! RV3RW%34      RR
\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR	;reR	# ) z5assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}py0
isinstancepy1systempy2strpy4Nbpintpy3assert %(py5)spy5)>)z%(py0)s > %(py3)s)r   PERSONAr   r   @py_builtinslocals
@pytest_ar_should_repr_global_name	_safereprAssertionError_format_explanationr   _call_reprcompare)	r   r   r   @py_assert3@py_format5@py_assert2@py_assert1@py_format4@py_format6s	   &        r   +test_assemble_returns_system_and_breakpointr0      s   '7+JFfc""""""""":"""":"""""""f""""f"""""""c""""c""""""""""b#::bb##M6MMMM2MMMMMM2MMMM2MMMMMMMMMMMr   c                   \        \        V 4      w  rR q3V9   qD'       g   \        P                  ! RV3RW134      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                  ! V4      4      hR;r4R# )	r   r   r   r   r   r   Ninz%(py1)s in %(py3)s
r   r!   r$   r)   r&   r"   r#   r%   r'   r(   r   r   _@py_assert0r,   r.   r/   s   &      r   test_assemble_contains_identityr9   &   sn    '*IF#V#####>###>######V####V########r   c                   \        \        V 4      w  rR q3V9   qD'       g   \        P                  ! RV3RW134      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                  ! V4      4      hR;r4R# )	180r   r   r   r   r   Nr2   r4   r5   r6   s   &      r    test_assemble_contains_era_guardr<   +   sm    '*IFF?55FFr   c                   \        \        V 4      w  rR q3V9   qD'       g   \        P                  ! RV3RW134      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                  ! V4      4      hR;r4R# )	zNEVER invent a quoter   r   r   r   r   Nr2   r4   r5   r6   s   &      r   +test_assemble_contains_misattribution_guardr>   0   sp    '*IF!+V+++++!+++!++++++V++++V++++++++r   c                   \        \        V 4      w  rR q3V9   qD'       g   \        P                  ! RV3RW134      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                  ! V4      4      hR;r4R# )	authentic voicer   r   r   r   r   Nr2   r4   r5   r6   s   &      r    test_assemble_contains_exemplarsrA   5   sp    '*IF&&&&&&&&&&&&&&&&&&&&&&&&&&&r   c                :   R RRR/.p\        \        WR7      w  r#RqDV9   qU'       g   \        P                  ! RV3RWB34      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRR	V/,          p\        \        P                  ! V4      4      hR
;rERqDV9   qU'       g   \        P                  ! RV3RWB34      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRR	V/,          p\        \        P                  ! V4      4      hR
;rER
# )	source_idsrctextzVirtue is the only good.retrieved_chunksr   r   r   r   r   NzRelevant passagesr2   r4   r5   )r   chunksr   r7   r8   r,   r.   r/   s   &       r   'test_assemble_contains_retrieved_chunksrI   ;   s    E6+EFGF'CIF%//////%///%//////////////////(&((((((((((((((&((((&((((((((r   c                   RRRR/.pRRRR/.p\        \        WR7      w  r4\        \        WR7      w  rVWF8H  qw'       Eg   \        P                  ! RV3RWF34      RR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR	R
\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
/,          p\        P                  ! R4      R,           RV/,          p	\        \        P                  ! V	4      4      hRpVP                  R4      RV p
VP                  R4      RV pW8H  qw'       Eg   \        P                  ! RV3RW34      RR\        P
                  ! 4       9   g   \        P                  ! V
4      '       d   \        P                  ! V
4      MRR	R\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          p\        P                  ! R4      R,           RV/,          p	\        \        P                  ! V	4      4      hRpR# )zKThe prefix before the cache breakpoint must be byte-identical across turns.rC   rD   rE   zFirst retrieved chunk.zEntirely different chunk.rF   r   bp_ar   bp_bz/Cache breakpoint must be identical across turnsz
>assert %(py4)sr   Nutf-8prefix_aprefix_bz1Stable prefix must be byte-identical across turns==)z%(py0)s == %(py2)s)r   r!   r$   r)   r"   r#   r%   r&   _format_assertmsgr'   r(   encode)r   chunks_achunks_bsystem_arK   system_brL   r-   @py_format3r+   rN   rO   s   &           r   1test_cache_invariant_stable_prefix_byte_identicalrY   B   si   eV-EFGHeV-HIJHgwJNHgwJNH<JJJJ4JJJJJJ4JJJJ4JJJJJJJ4JJJJ4JJJJJJJJJJJJw'.Hw'.HTTTT8TTTTTT8TTTT8TTTTTTTxTTTTxTTTT!TTTTTTTTr   c                   \        \        V RR7      w  rVP                  pRqC! V4      p\        V4      qfV8H  qw'       Eg   \        P
                  ! RV3RWb34      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MRRR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R	\        P                  ! V4      R
\        P                  ! V4      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;p;rgR# )z?Without retrieved chunks, the full system is the stable prefix.NrF   rM   r   lenr   r   r   r   py7py9py11r   zassert %(py13)spy13rP   )zk%(py9)s
{%(py9)s = %(py0)s(%(py7)s
{%(py7)s = %(py3)s
{%(py3)s = %(py1)s.encode
}(%(py5)s)
})
} == %(py11)s)r   r!   rS   r[   r$   r)   r"   r#   r%   r&   r'   r(   )
r   r   r   r,   @py_assert4@py_assert6@py_assert8@py_assert10@py_format12@py_format14s
   &         r   -test_cache_invariant_no_chunks_is_pure_stablerf   Q   s    '7TBJF}},W,}W%,3%&,",,,,,&,,,,,,3,,,,3,,,,,,,v,,,,v,,,},,,W,,,%,,,&,,,,,,",,,,",,,,,,,,,r   c                   V R,          pVP                  RR7       \        \        V 4      w  r#RqDV9  qU'       g   \        P                  ! RV3RWB34      R\        P
                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P
                  ! V4      MR/,          pRR	V/,          p\        \        P                  ! V4      4      hR
;rER
# )z7When exemplars.jsonl absent, exemplar block is skipped.styleT)parentsr@   r   r   r   r   r   N)not in)z%(py1)s not in %(py3)s)mkdirr   r!   r$   r)   r&   r"   r#   r%   r'   r(   )tmp_path	style_dirr   r7   r8   r,   r.   r/   s   &       r   %test_assemble_no_exemplars_if_missingrn   W   s    7"IOODO!(+IF*F**************F****F********r   c                   \        R RRR7      p\        W4      w  r#RqDV9   qU'       g   \        P                  ! R
V3RWB34      R\        P                  ! V4      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\        \        P                  ! V4      4      hR	;rER	# )livingzLiving Personr   )r   r   r
   r   r   r   r   r   Nr2   r4   )
r   r   r$   r)   r&   r"   r#   r%   r'   r(   )rl   personar   r7   r8   r,   r.   r/   s   &       r   "test_assemble_persona_without_diedrr   `   s    $ G
 +IF$f$$$$$?$$$?$$$$$$f$$$$f$$$$$$$$r   )__doc__
__future__r   builtinsr"   _pytest.assertion.rewrite	assertionrewriter$   pytestruntime.conversation.promptr   shared.packager   r!   fixturer   r0   r9   r<   r>   rA   rI   rY   rf   rn   rr   r   r   r   <module>r}      s    #    0 *
			6  $

,
')U-+%r   