+
    jHàjVJ ã                  óê  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHt ]P>                  ! ] 4      t!^t"R	t#R
t$Rt%^t&^t'Rt(^t)R�t*Rt+Rt,Rt-Rt.Rt/Rt0Rt1Rt2Rt3Rt4Rt5Rt6Ržt7RRRRRR RR!RR"/t8/ RRbR#RbR$RbR%RbRRbR&RbR'RbR(RbR)RbRRbR*RbR+RbR,RbR-RbRRbR.RbR/RbR0RR1RR2RRRR3RR4RR5R/Ct9] ! R6 R74      4       t:R8 R9 lt;R: R; lt<] ! R< R=4      4       t=R> R? lt>R@R/RA RB llt?] ! RC RD4      4       t@RE RF ltA/ tBRG]CRH&   ]
Pˆ                  ! 4       tE/ tFRI]CRJ&   RKtGRLtHRM RN ltIRO RP ltJRQ RR ltKRS RT ltLRU RV ltMRW RX ltNRY RZ ltOR[ R\ ltPR] R^ ltQR_R`/Ra Rb lltRRc Rd ltSRe Rf ltTRg Rh ltU]P¬                  ! Ri]P®                  4      tXRj Rk ltYRl Rm ltZRn Ro lt[Rp Rq lt\Rr Rs lt]Rt Ru lt^Rv Rw lt_RxRRyRRzRR{RR|^ /R} R~ llt`R R€ ltaR�tbR‚tcRƒtdR„ R… lteR† R‡ ltfRˆ R‰ ltgRŸRŠR/R‹ RŒ lllthRxR/R� RŽ lltiR� R� ltjR‘tk ! R’ R“4      tlR”tmR•tnR$R R3R¡R–R¢R—R£/toR˜]"R™R`RšR/R› Rœ lltp. R¤OtqR# )¥u±  Persistent session goals â€” the Ralph loop for Hermes.

A goal is a free-form objective that stays active across turns; after each turn an auxiliary-model
judge decides whether it is satisfied. The continuation prompt is a normal user message appended via
``run_conversation`` (no system-prompt mutation or toolset swap â€” prompt caching stays intact). Judge
failures are fail-OPEN (``continue``); the turn budget is the backstop.
)ÚannotationsN)Ú	dataclassÚfieldÚasdict)ÚdatetimeÚtimezoneÚUTC)ÚPath)ÚAnyÚDictÚListÚOptionalÚTuple)Únoninteractive_git_env)Úsafe_strftimeg      >@i   é   é,  i¸  a  [Continuing toward your standing goal]
Goal: {goal}

Continue working toward this goal. Take the next concrete step. If you believe the goal is complete, state so explicitly and stop. If you are blocked and need input from the user, say so clearly and stop.aç  [Continuing toward your standing goal]
Goal: {goal}

Completion contract:
{contract_block}

Continue working toward the outcome above. Take the next concrete step. Stay within the stated boundaries and do not violate the constraints. Before claiming the goal is done, satisfy the Verification criterion and show the concrete evidence (command output, file contents, test result). If you hit the stated stop condition or are otherwise blocked and need user input, say so clearly and stop.a{  [Continuing toward your standing goal]
Goal: {goal}

Additional criteria the user added mid-loop:
{subgoals_block}

Continue working toward the goal AND all additional criteria. Take the next concrete step. If you believe the goal and every additional criterion are complete, state so explicitly and stop. If you are blocked and need input from the user, say so clearly and stop.uá  [Continuing toward your standing goal â€” a quality gate failed]
Goal: {goal}

The quality gate command below must pass before this goal can be declared done, and it just failed (attempt {attempt}/{max_retries}):
  $ {command}
Exit code: {exit_code}
Output (tail):
```
{output}
```

Fix the underlying problem so this gate passes, then re-run it to confirm. Do not declare the goal complete while any gate fails. If the gate itself is wrong or cannot pass, say so clearly and stop.un  You are a strict judge evaluating whether an autonomous agent has achieved a user's stated goal. You receive the goal text, the agent's most recent response, and â€” when present â€” a list of background processes the agent has running. Decide one of four verdicts.

DONE â€” the goal is fully satisfied:
- The response explicitly confirms the goal was completed, OR
- The response clearly shows the final deliverable was produced.
DONE requires the deliverable to actually exist. If the response only explains why the goal cannot be reached, the verdict is BLOCKED, not DONE.

BLOCKED â€” the goal cannot be satisfied as stated:
- The response explains the goal is genuinely unachievable (impossible, out of scope, no valid path to the deliverable), or refuses to fabricate a deliverable that cannot exist, OR
- The response explains progress is blocked and the next step needs user input to proceed.
Return BLOCKED with the reason describing what is blocking. BLOCKED is a refusal, not a completion â€” never return BLOCKED for a goal that was achieved.
When the block is an error the agent hit (an HTTP status, an API, sign-in or token failure), quote the error text verbatim in the reason and attribute it only to a provider, service or credential the response itself names. Never infer one the response does not name â€” an unnamed 401 belongs to the model provider the agent was calling, not to some other service's token.

WAIT â€” the goal is NOT done, but the next step is to wait for async work to finish rather than act again. Choose this ONLY when the agent's progress is genuinely gated on something running on its own:
- A background process listed below is still running AND the response shows the agent is waiting on its result (e.g. a CI poller, build, test run, deploy). If the process has a session id, return it in ``wait_on_session`` â€” that releases when the process exits OR its watch_patterns trigger fires (use this for a long-lived watcher that signals mid-run and may never exit). Otherwise return its pid in ``wait_on_pid`` (releases on exit only).
- The agent says it is rate-limited / backing off / must wait a fixed period â€” return seconds in ``wait_for_seconds``.
- The agent has delegated subagents still running (stated below as active delegations) and the response says it is waiting on them with nothing else dispatchable â€” return ``wait_for_seconds`` between 600 and 1800. Their results wake the agent on their own; re-poking it now only produces a status recap.
Picking WAIT parks the loop without burning a turn; it resumes automatically when the pid exits or the time elapses. Do NOT pick WAIT just because work remains â€” only when re-poking now would be pure busy-work because the agent can't progress until the async thing finishes.

CONTINUE â€” not done, and there is a concrete next step the agent can take right now. This is the default when in doubt.

Reply ONLY with a single JSON object on one line. Shapes:
{"verdict": "done", "reason": "<one sentence>"}
{"verdict": "blocked", "reason": "<one sentence>"}
{"verdict": "continue", "reason": "<one sentence>"}
{"verdict": "wait", "wait_on_session": "<id>", "reason": "<one sentence>"}
{"verdict": "wait", "wait_on_pid": <int>, "reason": "<one sentence>"}
{"verdict": "wait", "wait_for_seconds": <int>, "reason": "<one sentence>"}
The legacy shape {"done": <true|false>, "reason": "..."} is still accepted (true=done, false=continue).z™Active delegations: the agent has {count} delegated subagent batch(es) still running; their results are delivered to it automatically when they finish.

znBackground processes the agent currently has running (it may be waiting on one of these):
{background_lines}

u£   Goal:
{goal}

Agent's most recent response:
{response}

{background_block}Current time: {current_time}

Is the goal satisfied â€” done, blocked, continue, or wait?uÖ  Goal:
{goal}

Additional criteria the user added mid-loop (all must also be satisfied for the goal to be DONE):
{subgoals_block}

Agent's most recent response:
{response}

{background_block}Current time: {current_time}

Decision: For each numbered criterion above, find concrete evidence in the agent's response that the criterion is satisfied. Do not accept generic phrases like 'all requirements met' or 'implying it was done' â€” require specific evidence (a file contents excerpt, an output line, a command result). If ANY criterion lacks specific evidence in the response, the goal is NOT done â€” return CONTINUE (or WAIT if blocked on a listed background process).

Is the goal AND every additional criterion satisfied?uX  Goal:
{goal}

Completion contract (the authoritative definition of done):
{contract_block}

Agent's most recent response:
{response}

{background_block}Current time: {current_time}

Decision rules:
- The goal is DONE only when the Verification criterion is satisfied AND the response shows concrete evidence of it (a command result, file contents excerpt, test/benchmark output) â€” not a claim like 'done' or 'all tests pass' without evidence.
- If any stated Constraint was violated, the goal is NOT done â€” CONTINUE.
- If the response shows the agent is waiting on a listed background process to satisfy the Verification criterion (e.g. CI is the verification and it's still running), return WAIT on that process instead of re-poking â€” re-poking now would be pure busy-work.
- If the response explains the work is genuinely unachievable or hits the stated Stop condition and needs user input, the goal is NOT done â€” return BLOCKED with the reason describing the block.
- Otherwise the goal is NOT done â€” CONTINUE.

Is the goal satisfied per its completion contract â€” done, blocked, continue, or wait?a×  You turn a user's plain-language objective into a structured completion contract for an autonomous coding agent. The contract has five fields:
- outcome: the single end state that must be true when done
- verification: the specific test / command / artifact that PROVES the outcome (must be concrete and checkable)
- constraints: what must NOT change or regress
- boundaries: which files, dirs, tools, or systems are in scope
- stop_when: the condition under which the agent should stop and ask for human input instead of pushing on

Infer sensible, specific values from the objective and any project context implied by it. Prefer concrete verification (a named test command, a build, a benchmark) over vague phrases. Keep each field to one or two sentences. If a field genuinely cannot be inferred, use an empty string for it.

Reply ONLY with a single JSON object on one line:
{"outcome": "...", "verification": "...", "constraints": "...", "boundaries": "...", "stop_when": "..."}ÚoutcomeÚverificationÚconstraintsÚ
boundariesÚ	stop_whenÚOutcomeÚVerificationÚConstraintsÚ
BoundarieszStop when blockedÚgoalÚdonez	done whenÚverifyzverified byÚevidenceÚproofÚ
constraintÚpreservezmust notzdo not changeÚboundaryÚscopeÚallowedÚfilesz	stop whenÚblockedzstop if blockedzgive up whenc                  óœ   € ] tR tRt$ RtRtR]R&   RtR]R&   RtR]R&   Rt	R]R&   Rt
R]R	&   R
 R ltR R lt]R R l4       tR R ltRtR# )ÚGoalContracti  zMOptional structured completion contract; empty fields are omitted everywhere.Ú Ústrr   r   r   r   r   c               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚbool© )Úformats   "Ú5/home/ubuntu/.hermes/hermes-agent/hermes_cli/goals.pyÚ__annotate__ÚGoalContract.__annotate__'  s   € ÷ Kñ K˜$ñ Kó    c                	ó¦   a € \         ;QJ d-    V 3R  l\         4       F  '       g   K   R'       * # 	  R'       * # ! V 3R  l\         4       4      '       * # )c              3  óX   <"  € T F  p\        SV4      P                  4       x € K!  	  R # 5i©N)ÚgetattrÚstrip©Ú.0ÚfÚselfs   & €r3   Ú	<genexpr>Ú(GoalContract.is_empty.<locals>.<genexpr>(  s&   øé € ÐJÑ9I°A”w˜t QÓ'×-Ñ-×/Ð/Ó9Iùs   ƒ'*TF)ÚanyÚ_CONTRACT_FIELDS©r?   s   fr3   Úis_emptyÚGoalContract.is_empty'  s7   ø€ ß“3ÔJÕ9IÓJ—3”3ÔJÐJ’3ÔJÐJ�3ÔJÕ9IÓJÓJÔJÐJr6   c               ó   € V ^8„  d   QhRR/# )r.   r/   zdict[str, str]r1   )r2   s   "r3   r4   r5   *  s   € ÷ ?ñ ?˜ñ ?r6   c                	óJ   € \          Uu/ uF  q\        W4      bK  	  up# u upi r9   )rC   r:   )r?   r>   s   & r3   Úto_dictÚGoalContract.to_dict*  s$   € Ý-=Ó>Ñ-=¨”7˜4Ó#Ò#Ñ-=Ñ>Ð>ùÒ>s   ‰ c               ó    € V ^8„  d   QhRRRR/# )r.   ÚdataúOptional[dict[str, Any]]r/   r)   r1   )r2   s   "r3   r4   r5   .  s   € ÷ Tñ TÐ5ð T¸,ñ Tr6   c                	óÞ   € \        V\        4      '       g   V ! 4       # T ! R/ \         Uu/ uF5  q"\        VP	                  V4      ;'       g    R 4      P                  4       bK7  	  upB # u upi )r*   r1   )Ú
isinstanceÚdictrC   r+   Úgetr;   )ÚclsrL   r>   s   && r3   Ú	from_dictÚGoalContract.from_dict-  sZ   € ä˜$¤×%Ò%Ù“5ˆLÙÑSÕAQÓRÑAQ¸Aœ˜TŸX™X a›[×.Ð.¨BÓ/×5Ñ5Ó7Ò7ÑAQÑRÑSÐSùÒRs   ª!A*ÁA*c               ó   € V ^8„  d   QhRR/# ©r.   r/   r+   r1   )r2   s   "r3   r4   r5   3  s   € ÷ Gñ G˜cñ Gr6   c                óB   a € RP                  V 3R l\         4       4      # )uF   Non-empty fields as a labelled block; empty contract â†’ empty string.Ú
c              3  ó¾   <"  € T FR  p\        SV4      P                  4       '       g   K%  R \        V,           R\        SV4      P                  4        2x € KT  	  R# 5i)ú- ú: N)r:   r;   Ú_CONTRACT_LABELSr<   s   & €r3   r@   Ú,GoalContract.render_block.<locals>.<genexpr>5  s`   øé € ð  GÑYiÐTUÔmtÐuyÐ{|Óm}÷  nDñ  nD÷  nFÔO˜2Ô.¨qÕ1Ð2°"´W¸TÀ1Ó5E×5KÑ5KÓ5MÐ4NÕOÓYiùs
   ƒ"Aª3A)ÚjoinrC   rD   s   fr3   Úrender_blockÚGoalContract.render_block3  s%   ø€ à�y‰yô  GÕYió  Gó  Gð  	Gr6   r1   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__annotations__r   r   r   r   rE   rI   ÚclassmethodrS   r_   Ú__static_attributes__r1   r6   r3   r)   r)     sd   ‡ áWØ€GˆSÓØ€L�#ÓØ€K�ÓØ€J�ÓØ€IˆsÓõKõ?ð ôTó ðT÷
Gñ Gr6   r)   c               ó    € V ^8„  d   QhRRRR/# )r.   Útextr+   r/   ztuple[str, GoalContract]r1   )r2   s   "r3   r4   r4   8  s   € ÷ 6ñ 6˜ð 6Ð!9ñ 6r6   c                óä  € V '       g   R\        4       3# . p\         Uu/ uF  q". bK  	  ppV P                  4        F»  pVP                  4       pV'       g   K  RV9   d‡   VP	                  R4      w  rgp\
        P                  VP                  4       P                  4       4      p	V	e>   VP                  4       '       d(   W9,          P                  VP                  4       4       Kª  VP                  V4       K½  	  \        R/ VP                  4        UU
u/ uF%  w  r*VRP                  V
4      P                  4       bK'  	  up
pB pRP                  V4      P                  4       V3# u upi u up
pi )u  Split user-typed goal text into a headline + contract from inline ``field: value`` lines.

A headline without an explicit ``outcome:`` IS the outcome â€” it is not duplicated into the
contract block (the goal text already carries it), so outcome stays empty in that case.
r*   Ú:Ú r1   )r)   rC   Ú
splitlinesr;   Ú	partitionÚ_CONTRACT_ALIASESrQ   ÚlowerÚappendÚitemsr^   )rj   Úheadline_partsr>   ÚfieldsÚraw_lineÚlineÚprefixÚ_ÚvalueÚkeyÚvÚcontracts   &           r3   Úparse_contractr~   8  s(  € ÷ Ø”<“>Ð!Ð!Ø "€NÝ3CÓ#DÑ3C¨a r¢EÑ3C€FÐ#DØ—O‘OÖ%ˆØ�~‰~ÓˆßÙØ�$Œ;Ø#Ÿ~™~¨cÓ2ÑˆF�uÜ#×'Ñ'¨¯©«×(<Ñ(<Ó(>Ó?ˆCØŠ 5§;¡;§=¢=Ø•×"Ñ" 5§;¡;£=Ô1ÙØ×Ñ˜dÖ#ñ &ô ÑRÀ&Ç,Á,Ä.ÔQÁ.¹$¸!˜q #§(¡(¨1£+×"3Ñ"3Ó"5Ò5Á.ÒQÑR€HØ�8‰8�NÓ#×)Ñ)Ó+¨XÐ5Ð5ùò $Eùó Rs   ŸE'Ä+E,c               ó    € V ^8„  d   QhRRRR/# )r.   Úsubgoalsú	list[str]r/   r+   r1   )r2   s   "r3   r4   r4   Q  s   € ÷ cñ c Yð c°3ñ cr6   c                óH   € R P                  R \        V ^R7       4       4      # )rX   c              3  ó6   "  € T F  w  rR V RV 2x € K  	  R# 5i)z- Extra criterion r[   Nr1   ©r=   Úirj   s   &  r3   r@   Ú)_render_extra_criteria.<locals>.<genexpr>R  s"   é € ÐbÑEa¹'¸!Ð)¨!¨¨B¨t¨fÕ5ÓEaùó   ‚©Ústart)r^   Ú	enumerate)r€   s   &r3   Ú_render_extra_criteriar‹   Q  s   € Ø�9‰9ÑbÄYÈxÐ_`ÕEaÓbÓbÐbr6   c                  óŽ   € ] tR tRt$ RtR]R&   ]tR]R&   ]t	R]R&   ^ t
R]R&   R	tR
]R&   RtR]R&   R R lt]R R l4       tRtR	# )ÚGoalGateiW  zØA deterministic shell command that must pass before a goal can be done.

Gates run at turn boundary BEFORE the LLM judge; a failing gate short-circuits judging and its
bounded output becomes the continuation prompt.
r+   ÚcommandÚintÚtimeout_secondsÚmax_retriesÚattemptsNúOptional[int]Úlast_exit_coder*   Úlast_output_tailc               ó   € V ^8„  d   QhRR/# )r.   r/   údict[str, Any]r1   )r2   s   "r3   r4   ÚGoalGate.__annotate__e  s   € ÷ ñ ˜ñ r6   c                	ó   € \        V 4      # r9   )r   rD   s   &r3   rI   ÚGoalGate.to_dicte  s   € Ü�d‹|Ðr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rL   rM   r/   r�   r1   )r2   s   "r3   r4   r˜   i  s   € ÷ 

ñ 

Ð5ð 

¸(ñ 

r6   c                	ó
  € \        V\        4      '       g
   V ! R R7      # T ! \        VP                  R4      ;'       g    R 4      \	        VP                  R4      ;'       g    \
        4      \	        VP                  R4      ;'       g    \        4      \	        VP                  R4      ;'       g    ^ 4      VP                  R4      e   \	        VR,          4      MR\        VP                  R4      ;'       g    R 4      R	7      # )
r*   )rŽ   rŽ   r�   r‘   r’   r”   Nr•   )rŽ   r�   r‘   r’   r”   r•   )rO   rP   r+   rQ   r�   ÚDEFAULT_GATE_TIMEOUT_SECONDSÚDEFAULT_GATE_MAX_RETRIES)rR   rL   s   &&r3   rS   ÚGoalGate.from_dicth  sÇ   € ä˜$¤×%Ò%Ù˜r”?Ð"ÙÜ˜Ÿ™ Ó+×1Ð1¨rÓ2Ü §¡Ð):Ó ;× [Ð [Ô?[Ó\Ü˜DŸH™H ]Ó3×OÐOÔ7OÓPÜ˜Ÿ™ *Ó-×2Ð2°Ó3Ø;?¿8¹8ÐDTÓ;UÒ;aœC Ð%5Õ 6Ô7ÐgkÜ  §¡Ð*<Ó!=×!CÐ!CÀÓDô
ð 	
r6   r1   )ra   rb   rc   rd   re   rf   r�   r�   rž   r‘   r’   r”   r•   rI   rg   rS   rh   r1   r6   r3   r�   r�   W  sZ   ‡ ñð
 ƒLØ7€O�SÓ7Ø/€K�Ó/Ø€HˆcÓØ$(€N�MÓ(ØÐ�cÓõð ô

ó ô

r6   r�   c               ó   € V ^8„  d   QhRR/# )r.   r/   z#tuple[Optional[str], Optional[str]]r1   )r2   s   "r3   r4   r4   v  s   € ÷ ñ Ð<ñ r6   c                 ó  € ^ RI Hp Hp V! 4       pV'       dE   \        V4      P	                  4       pVP                  4       '       d   \        V4      R3# RRV R23#  \        V ! 4       4      R3#   \         d    Ru # i ; i)a  ``(cwd, refusal)`` for this check's gates. A multi-session backend's process directory is not
the session's project, so gates run in the scoped session workspace (#125369). A declared
workspace that is not a directory on this host (deleted, remote, container) is a refusal: a
relative gate run anywhere else would check a different project and could pass a failing goal,
and no agent turn can fix it, so the caller pauses instead of retrying.
No declared workspace keeps the classic resolution (TERMINAL_CWD, else the launch directory).)Úresolve_agent_cwdÚscoped_session_cwdNzthe session workspace za is not a directory on this host, and running gates anywhere else would check a different project)NN)Úagent.runtime_cwdr¢   r£   r	   Ú
expanduserÚis_dirr+   ÚOSError)r¢   r£   ÚdeclaredÚpaths       r3   Ú_gate_workspacerª   v  sŽ   € ÷ Há!Ó#€HßÜ�H‹~×(Ñ(Ó*ˆØ�;‰;�=Š=Ü�t“9˜d�?Ð"ØÐ.¨x¨jð 9Xð Xð Yð 	YðÜÑ$Ó&Ó'¨Ð-Ð-øÜô ØÒðús   ÁA/ Á/A?Á>A?Úcwdc               ó$   € V ^8„  d   QhRRRRRR/# )r.   Úgater�   r«   úOptional[str]r/   ztuple[bool, int, str]r1   )r2   s   "r3   r4   r4   Œ  s'   € ÷ Oñ O�8ð O ]ð OÐ>Sñ Or6   c               ó¸  €  \         P                  ! V P                  RRRRR\        ^\	        V P
                  4      4      T;'       g    RRR7	      pVP                  ;'       g    RVP                  '       d   RVP                  ,           MR,           pVP                  ^ 8H  VP                  V\        ) R 3#   \         P                   d[   pRP                  R	 TP                  TP                  3 4       4      pRRTR
T P
                   R2,           \        ) R 3u Rp?# Rp?i\         d*   pRRR\        T4      P                   RT R23u Rp?# Rp?ii ; i)z…Run one gate through the shell. Returns ``(passed, exit_code, output_tail)``; a timeout kills
the process and counts as exit code -1.Túutf-8ÚreplaceNF)ÚshellÚcapture_outputrj   ÚencodingÚerrorsÚtimeoutr«   Úcheckr*   rX   c              3  óˆ   "  € T F8  q'       g   K  \        V\        4      '       d   TMVP                  R R4      x € K:  	  R# 5i)r°   r±   N)rO   r+   Údecode)r=   Úcs   & r3   r@   Úrun_gate.<locals>.<genexpr>›  s5   é € ÐwÑYqÐTUÓuvÔOœ: a¬×-Ò-‘a°1·8±8¸GÀYÓ3OÔOÓYqùs
   ‚	A�2Az
[gate timed out after zs]z[gate could not run: r[   Ú]éÿÿÿÿ)Ú
subprocessÚrunrŽ   Úmaxr�   r�   ÚstdoutÚstderrÚ
returncodeÚ_GATE_OUTPUT_TAIL_CHARSÚTimeoutExpiredr^   Ú	ExceptionÚtypera   )r­   r«   ÚprocÚcombinedÚexcÚouts   &$    r3   Úrun_gaterÌ   Œ  s=  € ðOô �~Š~Ø�L‰L °TÀÈwÐ_hÜ˜œ3˜t×3Ñ3Ó4Ó5¸3¿;¸;À$Øô
ˆð
 —K‘K×%Ð% 2À$Ç+Ç+À+¨4°$·+±+Ö+=ÐSUÕVˆØ�‰ !Ñ# T§_¡_°hÔ@WÐ?WÐ?XÐ6YÐYÐYøÜ×$Ñ$ô qØ�g‰gÑwÐZ]×ZdÑZdÐfi×fpÑfpÑYqÓwÓwˆØ�b˜3Ð#;¸D×<PÑ<PÐ;QÐQSÐ!TÕTÔWnÐVnÐVoÐpÐpÕpûÜô OØ�bÐ1´$°s³)×2DÑ2DÐ1EÀRÈÀuÈAÐNÐNÕNûðOúsI   ‚AB8 Á	B8 Á%B8 Á9>B8 Â8EÃAD"ÄEÄ"EÄ/EÄ0EÅEÅEc                  ó   € ] tR tRt$ RtR]R&   RtR]R&   ^ tR]R&   ]t	R]R	&   R
t
R]R&   R
tR]R&   RtR]R&   RtR]R&   RtR]R&   ^ tR]R&   ^ tR]R&   ]! ]R7      tR]R&   RtR]R&   RtR]R&   R
tR]R&   ^ tR]R&   RtR]R&   R
tR]R&   ]! ]R7      tR]R &   ]! ]R7      tR!]R"&   R# R$ lt]R% R& l4       tR' R( lt R) R* lt!R+ R, lt"R-t#R# ).Ú	GoalStatei£  z+Serializable goal state stored per session.r+   r   ÚactiveÚstatusr�   Ú
turns_usedÚ	max_turnsç        ÚfloatÚ
created_atÚlast_turn_atNr®   Úlast_verdictÚlast_reasonÚpaused_reasonÚconsecutive_parse_failuresÚconsecutive_transport_failures)Údefault_factoryr�   r€   r“   Úwaiting_on_pidÚwaiting_on_sessionÚwaiting_untilÚwaiting_on_delegationsÚwaiting_reasonÚwaiting_sincer)   r}   zlist[GoalGate]Úgatesc               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   ÚGoalState.__annotate__Ç  s   € ÷ <ñ <˜ñ <r6   c                	óD   € \         P                  ! \        V 4      R R7      # )F)Úensure_ascii)ÚjsonÚdumpsr   rD   s   &r3   Úto_jsonÚGoalState.to_jsonÇ  s   € Ü�zŠzœ& ›,°UÔ;Ð;r6   c               ó    € V ^8„  d   QhRRRR/# )r.   Úrawr+   r/   rÎ   r1   )r2   s   "r3   r4   rå   Ë  s   € ÷ 
ñ 
˜Cð 
 Iñ 
r6   c           "     	ód  € \         P                  ! V4      pVP                  R 4      ;'       g    . pR Uu/ uF'  qD\        VP                  V4      ;'       g    ^ 4      bK)  	  ppR Uu/ uF'  qD\	        VP                  V4      ;'       g    R4      bK)  	  ppT ! RRVP                  RR4      RVP                  RR4      R\        VP                  R4      ;'       g    \
        4      RVP                  R4      RVP                  R4      R	VP                  R	4      R \        V\        4      '       dK   V Uu. uF=  p\        V4      P                  4       '       g   K$  \        V4      P                  4       NK?  	  upM. R
VP                  R
4      '       d   \        VR
,          4      MRRVP                  R4      '       d   \        VR,          4      MRRVP                  R4      R\        P                  VP                  R4      4      RVP                  R4      ;'       g    .  Uu. uFj  p\        V\        4      '       g   K  \        VP                  R4      ;'       g    R4      P                  4       '       g   KU  \        P                  V4      NKl  	  up/VBVB # u upi u upi u upi u upi )r€   rÓ   r   r*   rÐ   rÏ   rÒ   r×   rØ   rÙ   rÝ   NrÞ   rá   r}   rã   rŽ   )rÑ   rÚ   rÛ   rà   )rÕ   rÖ   rß   râ   r1   )rè   ÚloadsrQ   r�   rÔ   ÚDEFAULT_MAX_TURNSrO   Úlistr+   r;   r)   rS   rP   r�   )	rR   rí   rL   Úraw_subgoalsÚkÚintsÚfloatsÚsÚgs	   &&       r3   Ú	from_jsonÚGoalState.from_jsonÊ  s€  € ä�zŠz˜#‹ˆØ—x‘x 
Ó+×1Ð1¨rˆñ 3[ó  \ñ  3[¨Q”3�t—x‘x “{×'Ð' aÓ(Ò(ñ  3[ˆð  \Ù8xÓyÑ8x°1”U˜4Ÿ8™8 A›;×-Ð-¨#Ó.Ò.Ñ8xˆÐyÙñ 
Ø—‘˜& "Ó%ð
à—8‘8˜H hÓ/ð
ô ˜$Ÿ(™( ;Ó/×DÐDÔ3DÓEð
ð Ÿ™ .Ó1ð	
ð
 Ÿ™ Ó/ð
ð Ÿ(™( ?Ó3ð
ô R\Ð\hÔjn×QoÒQo©lÓM©l¨¼cÀ!»f¿l¹l¿n”n”c˜!“f—l‘l–n©lÒMÐuwð
ð <@¿8¹8ÐDT×;UÒ;UœC Ð%5Õ 6Ô7Ð[_ð
ð DHÇ8Á8ÐL`×CaÒCa¤ DÐ)=Õ$>Ô ?Ðgkð
ð  Ÿ8™8Ð$4Ó5ð
ô "×+Ñ+¨D¯H©H°ZÓ,@ÓAð
ð 15·±¸Ó0A×0GÐ0GÀRÐ0GóÙ0G¨!Ü˜a¤×&ô &Ü+.¨q¯u©u°YÓ/?×/EÐ/EÀ2Ó+F×+LÑ+L×+Nô &”×"Ñ" 1Ö%Ñ0Gñð
ð  ð!
ð  ñ!
ð 	
ùò \ùÚyùò Nùò
s;   ¶!JÁJÁ)!J#ÂJ#Ä5!J($ÅJ($È%J-8ÉJ-8ÉJ-8É<J-8c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   rå   ã  s   € ÷ Jñ J˜dñ Jr6   c                	ól   € V P                   R J;'       d     V P                   P                  4       '       * # r9   )r}   rE   rD   s   &r3   Úhas_contractÚGoalState.has_contractã  s)   € Ø�}‰} DÐ(×IÐI°·±×1GÑ1GÓ1IÔ-IÐIr6   c               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   rå   æ  s   € ÷ \ñ \ sñ \r6   c                ó\   € RP                  R \        V P                  ^R7       4       4      # )z?Numbered ``- N. text`` block; empty when there are no subgoals.rX   c              3  ó6   "  € T F  w  rR V RV 2x € K  	  R# 5i©rZ   z. Nr1   r„   s   &  r3   r@   Ú2GoalState.render_subgoals_block.<locals>.<genexpr>è  s!   é € Ð[Ñ9Z©g¨a˜2˜a˜S  4 &Õ)Ó9Zùr‡   rˆ   )r^   rŠ   r€   rD   s   &r3   Úrender_subgoals_blockÚGoalState.render_subgoals_blockæ  s#   € à�y‰yÑ[¼À4Ç=Á=ÐXYÕ9ZÓ[Ó[Ð[r6   c               ó   € V ^8„  d   QhRR/# ©r.   r/   ÚNoner1   )r2   s   "r3   r4   rå   ê  s   € ÷ !ñ !˜Dñ !r6   c                	óZ   € R V n         R V n        RV n        ^ V n        R V n        RV n        R # )NrÓ   )rÝ   rÞ   rß   rà   rá   râ   rD   s   &r3   Ú
clear_waitÚGoalState.clear_waitê  s2   € Ø"ˆÔØ"&ˆÔØ ˆÔØ&'ˆÔ#Ø"ˆÔØ ˆÖr6   )rà   rÝ   rÞ   rá   râ   rß   )$ra   rb   rc   rd   re   rf   rÐ   rÑ   rð   rÒ   rÕ   rÖ   r×   rØ   rÙ   rÚ   rÛ   r   rñ   r€   rÝ   rÞ   rß   rà   rá   râ   r)   r}   rã   rê   rg   rø   rü   r  r	  rh   r1   r6   r3   rÎ   rÎ   £  s  ‡ á5Ø
ƒIØ€FˆCÓØ€J�ÓØ&€IˆsÓ&Ø€J�ÓØ€L�%ÓØ"&€L�-Ó&Ø!%€K�Ó%Ø#'€M�=Ó'Ø&'Ð Ó'ð +,Ð" CÓ+á°Ô5€HˆiÓ5ð %)€N�MÓ(Ø(,Ð˜Ó,Ø€M�5Óð #$Ð˜CÓ#Ø$(€N�MÓ(Ø€M�5ÓÙ"°<Ô@€HˆlÓ@á!°$Ô7€Eˆ>Ó7õ<ð ô
ó ð
õ0Jõ\÷!ñ !r6   rÎ   c               ó    € V ^8„  d   QhRRRR/# )r.   Ú
session_idr+   r/   r1   )r2   s   "r3   r4   r4   õ  s   € ÷  ñ  ˜#ð   #ñ  r6   c                ó   € R V  2# )zgoal:r1   )r  s   &r3   Ú	_meta_keyr  õ  s   € Ø�:�,ÐÐr6   r—   Ú	_DB_CACHEzdict[str, threading.Event]Ú_DB_BOOTSTRAP_INFLIGHTg      Ð?g      ø?c               ó$   € V ^8„  d   QhRRRRRR/# )r.   Úhomer+   r   zthreading.Eventr/   r  r1   )r2   s   "r3   r4   r4   
  s!   € ÷ ñ  ð ¨?ð ¸tñ r6   c                óp  €  \        V 4      p\        ;_uu_ 4        Ve   V \
        9  d   V\
        V &   Rp\        P                  V R4       RRR4       Ve   \        V4       VP                  4        R#   \         d#   p\        P                  RT4       Rp Rp?L�Rp?ii ; i  + '       g   i     La; i)zDConstruct SessionDB off-loop and populate the cache (worker thread).z/GoalManager: background SessionDB() raised (%s)N)
Ú_acquire_session_dbrÆ   ÚloggerÚdebugÚ_DB_BOOTSTRAP_LOCKr  r  ÚpopÚ_release_session_dbÚset)r  r   ÚdbrÊ   s   &&  r3   Ú_bootstrap_session_dbr  
  s�   € ðÜ  Ó&ˆ÷ 
Ö	ØŠ>˜d¬)Ô3Ø ŒI�d‰OØˆBÜ×"Ñ" 4¨Ô.÷	 
ð
 
‚~Ü˜BÔØ‡H�H†Jøô ô Ü�‰ÐFÈÔLØ�ûðú÷ 
×	ús"   ‚A5 ›1B%Á5B"Â BÂB"Â%B5	c               ó   € V ^8„  d   QhRR/# )r.   r/   zOptional[Any]r1   )r2   s   "r3   r4   r4     s   € ÷ =ñ =˜ñ =r6   c            	     óü  €  ^ RI Hp  \        V ! 4       4      p\        P                  T4      pTeK   \        T4      '       d:   \        ;_uu_ 4        \        P                  T4      TJ d   \        T RRR4       RpTe   T#  \        P                  ! 4        RpT'       dÓ   \        ;_uu_ 4        \        P                  T4      pTe   TuuRRR4       # \        P                  T4      p\        pTfR   \        P                   ! 4       ;p\        T&   \        P"                  ! \$        Y3RRR7      P'                  4        \(        pRRR4       XP+                  X4       \        P                  T4      #  \-        T4      p\        ;_uu_ 4        \        P                  T4      pTe   \/        T4       TuuRRR4       # T\        T&   RRR4       T#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i  + '       g   i     EL˜; i  \         d    Rp EL‹i ; i  + '       g   i     Lë; i  \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i  + '       g   i     T# ; i)	ac  Cached SessionDB per HERMES_HOME (profile switches pick the right DB); None on any failure.

Never constructs SessionDB on an event-loop thread: a cache miss there kicks a one-shot background
bootstrap and waits a bounded grace window (the kick call waits ``_DB_BOOTSTRAP_INIT_WAIT_S`` so a
healthy cold init completes and the first write isn't dropped).
)Úget_hermes_homez,GoalManager: SessionDB bootstrap failed (%s)NTFzgoals-sessiondb-bootstrap)ÚtargetÚargsÚnameÚdaemonz$GoalManager: SessionDB() raised (%s))Úhermes_constantsr  r+   rÆ   r  r  r  rQ   Ú_registry_tore_downr  ÚasyncioÚget_running_loopÚRuntimeErrorr  Ú_DB_BOOTSTRAP_LOOP_WAIT_SÚ	threadingÚEventÚThreadr  r‰   Ú_DB_BOOTSTRAP_INIT_WAIT_SÚwaitr  r  )	r  r  rÊ   ÚcachedÚon_loop_threadr   r.  r  Úexistings	            r3   Ú_get_session_dbr2    s  € ðÝ4ä‘?Ó$Ó%ˆô
 �]‰]˜4Ó €FØÒÔ1°&×9Ò9÷  ÖÜ�}‰}˜TÓ" fÓ,Ü˜d�O÷  ð ˆØÒØˆðÜ× Ò Ô"ð ˆçßÖä—]‘] 4Ó(ˆFØÒ!Ø÷	  Òô
 *×-Ñ-¨dÓ3ˆDÜ,ˆDØŠ|Ü6?·o²oÓ6GÐG�Ô-¨dÑ3Ü× Ò Ô(=ÀTÀLÐWrÐ{ô  A÷  Gñ  Gô  IÜ0�÷  ð 	�	‰	�$ŒÜ�}‰}˜TÓ"Ð"ðÜ  Ó&ˆ÷ 
Ö	Ü—=‘= Ó&ˆØÒä Ô#Ø÷ 
Ò	ð Œ	�$‰÷ 
ð €Iøôe ô Ü�‰ÐCÀSÔIÝûðú÷  ×Ðûô ô Ø‹ðú÷  ×ûô  ô Ü�‰Ð;¸SÔAÝûðú÷ 
Ö	ð €Iúsr   ‚G Á!H ÂH Â/H(ÃA0H(Å4H; Æ&I*Æ>	I*ÇG=ÇG8Ç8G=È H	ÈH%È$H%È(H8	È;I'ÉI"É"I'É*I;	c               ó   € V ^8„  d   QhRR/# )r.   r  r+   r1   )r2   s   "r3   r4   r4   [  s   € ÷ ,ñ ,˜cñ ,r6   c                ó>   € ^ RI Hp V! \        V 4      R,          4      # )u	  The registry's shared handle for ``home/state.db``. A bare ``SessionDB()`` here was a SECOND
writer per profile beside the gateway's registry handle â€” its own token-writer thread and
close-time checkpoint (the #90837 corruption shape), doubled under multiplexing.)Úacquirezstate.db)Úhermes_state_registryr5  r	   )r  r5  s   & r3   r  r  [  s   € õ .Ù”4˜“: 
Õ*Ó+Ð+r6   c               ó   € V ^8„  d   QhRR/# r  r1   )r2   s   "r3   r4   r4   c  s   € ÷ ñ ˜tñ r6   c                óH   € ^ RI Hp  V! V 4       R#   \         d     R# i ; i)é    )Úrelease_or_closeN)r6  r:  rÆ   )r  r:  s   & r3   r  r  c  s$   € Ý6ðÙ˜ÖøÜô Úðús   ˆ ’! !c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r4   k  s   € ÷ @ñ @˜tñ @r6   c                ó    € \        V RR4      RJ # )a   True once the registry force-closed *db* (``close_all`` / ``close_all_under`` clear the
shared-owned flag at teardown); every handle cached here was acquired through the registry, so a
cleared flag means the connection is gone and the cache entry is stale.Ú_shared_registry_ownedTF)r:   )r  s   &r3   r%  r%  k  s   € ô �2Ð/°Ó6¸%Ð?Ð?r6   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r.   Úmanagerr+   Úkindr  r/   r  r1   )r2   s   "r3   r4   r4   r  s(   € ÷ ñ  ð ¨Cð ¸Sð ÀTñ r6   c                ó4   € \         P                  RWV4       R# )u§   WARN on a dropped state write â€” the reply already told the user the state was set. One shared
message keeps goal, loop and heartbeat logs greppable as one bug class.up   %s: %s for %s not persisted â€” session DB unavailable (bootstrap window exceeded, in-memory state still active)N)r  Úwarning)r?  r@  r  s   &&&r3   Ú_warn_dropped_writerC  r  s   € ô ‡N�Nð	Dà�zör6   c               ó    € V ^8„  d   QhRRRR/# )r.   r  r+   r/   úOptional[GoalState]r1   )r2   s   "r3   r4   r4   |  s   € ÷ ñ ˜#ð Ð"5ñ r6   c                óh  € V '       g   R# \        4       pVf   R#  VP                  \        V 4      4      pT'       g   R#  \        P                  T4      #   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i  \         d"   p\        P                  RY4        Rp?R# Rp?ii ; i)z4Load the goal for a session, or None if none exists.Nz GoalManager: get_meta failed: %sz3GoalManager: could not parse stored goal for %s: %s)	r2  Úget_metar  rÆ   r  r  rÎ   rø   rB  )r  r  rí   rÊ   s   &   r3   Ú	load_goalrH  |  s•   € çÙÜ	Ó	€BØ	‚zÙðØ�k‰kœ) JÓ/Ó0ˆ÷ ÙðÜ×"Ñ" 3Ó'Ð'øô ô Ü�‰Ð7¸Ô=Ýûðûô ô Ü�‰ÐLÈjÔ^Ýûðús/   œA ÁB ÁBÁ!A=Á=BÂB1ÂB,Â,B1c               ó$   € V ^8„  d   QhRRRRRR/# )r.   r  r+   ÚstaterÎ   r/   r  r1   )r2   s   "r3   r4   r4   ‘  s!   € ÷ >ñ >˜#ð > ið >°Dñ >r6   c                ó  € V '       g   R# \        4       pVf   \        RRV 4       R#  VP                  \        V 4      VP	                  4       4       R#   \
         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)z5Persist a goal to SessionDB. No-op if DB unavailable.NÚGoalManagerr   z GoalManager: set_meta failed: %s)r2  rC  Úset_metar  rê   rÆ   r  r  )r  rJ  r  rÊ   s   &&  r3   Ú	save_goalrN  ‘  sd   € çÙÜ	Ó	€BØ	‚zÜ˜M¨6°:Ô>Ùð>Ø
�‰”I˜jÓ)¨5¯=©=«?Ö;øÜô >Ü�‰Ð7¸×=Ò=ûð>ús   ©)A ÁB ÁA;Á;B c               ó    € V ^8„  d   QhRRRR/# )r.   r  r+   r/   r  r1   )r2   s   "r3   r4   r4   Ÿ  s   € ÷ !ñ !˜3ð ! 4ñ !r6   c                óL   € \        V 4      pVf   R# RVn        \        W4       R# )zDMark a goal cleared in the DB (preserved for audit, status=cleared).NÚcleared)rH  rÐ   rN  )r  rJ  s   & r3   Ú
clear_goalrR  Ÿ  s#   € ä�jÓ!€EØ‚}ÙØ€E„LÜˆjÖ r6   Úreasonr*   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r.   Úold_session_idr+   Únew_session_idrS  r/   r0   r1   )r2   s   "r3   r4   r4   ¨  s*   € ÷ ñ ¨Cð Àð ÐQTð Ð^bñ r6   c               óf  € V '       d   V'       d   W8X  d   R#  \        V 4      pVe   VP                  R8X  d   R# \        V4      e   R# \        W4       \        V 4       \        P                  RYT;'       g    R4       R#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)uX  Carry a persistent /goal from a parent session to its continuation. Best-effort, never raises
(a failure here must not block compression). Returns True when a goal was migrated.

Context compression rotates ``session_id`` to a fresh child session, but ``load_goal`` does a flat
``goal:<session_id>`` lookup with no parent-lineage walk â€” so an active goal silently dies at the
compaction boundary (#33618). Copy the goal onto the new session and archive the old row as ``cleared``
so exactly one active goal row exists per logical conversation (avoids the "two active goals" hazard of
a pure copy).
FNrQ  z(GoalManager: migrated goal %s -> %s (%s)ÚrotationTz&GoalManager: goal migration failed: %s)rH  rÐ   rN  rR  r  r  rÆ   )rU  rV  rS  rJ  rÊ   s   &&$  r3   Úmigrate_goal_to_sessionrY  ¨  s‘   € ÷ §°>Ô3SÙðÜ˜.Ó)ˆØŠ=˜EŸL™L¨IÔ5Ùä�^Ó$Ò0ÙÜ�.Ô(ä�>Ô"Ü�‰Ð?ÀÐag×auÐauÐkuÔvÙøÜô Ü�‰Ð=¸sÔCÝûðús"   š B ¼B Á7B ÂB0ÂB+Â+B0c               ó$   € V ^8„  d   QhRRRRRR/# )r.   rj   r+   Úlimitr�   r/   r1   )r2   s   "r3   r4   r4   Ç  s&   € ÷ Lñ L�Cð L ð L¨ñ Lr6   c                óR   € V '       g   R # \        V 4      V8:  d   V # V RV R,           # )r*   Nu   â€¦ [truncated])Úlen)rj   r[  s   &&r3   Ú	_truncater^  Ç  s*   € ßÙÜ�t“9 Ô%ˆ4ÐK¨4°°¨<Ð:KÕ+KÐKr6   c               ó    € V ^8„  d   QhRRRR/# )r.   Úpidr�   r/   r0   r1   )r2   s   "r3   r4   r4   Í  s   € ÷ ñ �Cð ˜Dñ r6   c                óü   € V '       d   V ^ 8:  d   R#  ^ RI Hp \        V! \        V 4      4      4      #   \         d     Mi ; i ^ RIp\        TP                  \        T 4      4      4      #   \         d     R# i ; i)zËLiveness via ``gateway.status._pid_exists`` (psutil + ctypes/POSIX fallback). Never uses
``os.kill(pid, 0)``: on Windows that routes to CTRL_C_EVENT and hard-kills the target's console
group (bpo-14484).F)Ú_pid_existsN)Úgateway.statusrb  r0   r�   rÆ   ÚpsutilÚ
pid_exists)r`  rb  rd  s   &  r3   Ú
_pid_aliverf  Í  sr   € ÷ �#˜”(ÙðÝ.ä‘K¤ C£Ó)Ó*Ð*øÜô ÙðúðÛä�F×%Ñ%¤c¨#£hÓ/Ó0Ð0øÜô Úðús!   “3 ³AÁ AÁ&A, Á,A;Á:A;c               ó    € V ^8„  d   QhRRRR/# )r.   r  r+   r/   r0   r1   )r2   s   "r3   r4   r4   á  s   € ÷ 
ñ 
 ð 
¨ñ 
r6   c                ó|   € V '       g   R#  ^ RI Hp \        VP                  V 4      4      #   \         d     R# i ; i)z¯True while the process_registry session is running and its trigger hasn't fired. Fail-safe:
any import/registry error yields False so a stale barrier can never wedge the loop.F©Úprocess_registry)Útools.process_registryrj  r0   Úis_session_waitingrÆ   )r  rj  s   & r3   Ú_session_waitingrm  á  s;   € ÷ ÙðÝ;äÐ$×7Ñ7¸
ÓCÓDÐDøÜô Úðús   Œ, ¬;º;z\{.*?\}c               ó   € V ^8„  d   QhRR/# )r.   r{   r+   r1   )r2   s   "r3   r4   r4   ñ  s   € ÷ ñ ˜Sñ r6   c                óÖ   €  ^ RI Hp T! V! 4       P                  R4      ;'       g    / P                  R/ 4      P                  W4      4      pV^ 8”  d   V#  V#   \         d     T# i ; i)z´Resolve ``auxiliary.goal_judge.<key>``; non-positive/garbage falls back to ``default``
rather than crashing the loop. ``load_config()`` is cached on (mtime, size) so this is cheap.)Úload_configÚ	auxiliaryÚ
goal_judge)Úhermes_cli.configrp  rQ   rÆ   )r{   ÚdefaultÚcastrp  rz   s   &&&  r3   Ú_goal_judge_settingrv  ñ  ss   € ðÝ1á‘k“m×'Ñ'¨Ó4×:Ð:¸×?Ñ?ÀÈbÓQ×UÑUÐVYÓcÓdˆØ�1Œ9ØˆLð ð €Nøô ô ØØ€Nðús   ‚$A §.A ÁA(Á'A(c               ó   € V ^8„  d   QhRR/# ©r.   r/   r�   r1   )r2   s   "r3   r4   r4   ÿ  s   € ÷ Lñ L ñ Lr6   c                 ó,   € \        R \        \        4      # )Ú
max_tokens)rv  ÚDEFAULT_JUDGE_MAX_TOKENSr�   r1   r6   r3   Ú_goal_judge_max_tokensr|  ÿ  s   € Ü˜|Ô-EÄsÓKÐKr6   c               ó   € V ^8„  d   QhRR/# )r.   r/   rÔ   r1   )r2   s   "r3   r4   r4     s   € ÷ Hñ H˜Uñ Hr6   c                 ó,   € \        R \        \        4      # )r¶   )rv  ÚDEFAULT_JUDGE_TIMEOUTrÔ   r1   r6   r3   Ú_goal_judge_timeoutr€    s   € Ü˜yÔ*?ÄÓGÐGr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rí   r+   r/   rM   r1   )r2   s   "r3   r4   r4     s   € ÷ 4ñ 4˜cð 4Ð&>ñ 4r6   c                ó  € V '       g   R# V P                  4       pVP                  R4      '       d5   VP                  R4      pVP                  R4      pVR8w  d   W^,           R p \        P                  ! V4      p\        T\        4      '       d   T# R#   \
         d]    \        P                  T4      pT'       g    R#  \        P                  ! TP                  ^ 4      4      p Lm  \
         d      R# i ; ii ; i)zRBest-effort: strip code fences, parse the blob, else pull the first ``{...}`` out.Nz```Ú`rX   r½   )r;   Ú
startswithÚfindrè   rï   rÆ   Ú_JSON_OBJECT_REÚsearchÚgrouprO   rP   )rí   rj   ÚnlrL   Úmatchs   &    r3   Ú_extract_json_objectr‹    sÐ   € çÙØ�9‰9‹;€DØ‡��u×ÒØ�z‰z˜#‹ˆØ�Y‰Y�t‹_ˆØ�Œ8Ø˜Q�˜�=ˆDð	Ü�zŠz˜$Óˆô ˜d¤D×)Ò)ˆ4Ð3¨tÐ3øô ô Ü×&Ñ& tÓ,ˆßÚð	Ü—:’:˜eŸk™k¨!›nÓ-ŠDøÜô 	Ûð	úðús*   Á'B Â'C>Ã%C*Ã*C:Ã5C>Ã9C:Ã:C>c               ó    € V ^8„  d   QhRRRR/# )r.   rí   r+   r/   z/tuple[str, str, bool, Optional[dict[str, Any]]]r1   )r2   s   "r3   r4   r4     s   € ÷ /\ñ /\˜sð /\Ð'Vñ /\r6   c                óÐ  a
€ V '       g   R# \        V 4      o
S
f   RR\        V ^È4      : 2RR3# \        S
P                  R4      ;'       g    R4      P	                  4       ;'       g    RpS
P                  R4      p\        V\        4      '       d    VP	                  4       P                  4       pM_S
P                  R	4      p\        V\        4      '       d"   VP	                  4       P                  4       R9   M
\        V4      pV'       d   R	MRpVR9  d   RpVR
8w  d   W1RR3# R V
3R llpS
P                  R4      ;'       g+    S
P                  R4      ;'       g    S
P                  R4      p\        V\        4      '       d-   VP	                  4       '       d   R
VRRVP	                  4       /3# V! RRR4      pVe	   R
VRRV/3# V! RRR4      p	V	e	   R
VRRV	/3# RV R2RR3# )a“  Parse the judge's reply, fail-open. Returns ``(verdict, reason, parse_failed, wait_directive)``.

``parse_failed`` flags non-JSON output so callers can auto-pause after N in a row.
``wait_directive`` is ``{"session_id"}`` / ``{"pid"}`` / ``{"seconds"}`` for a ``wait``
verdict; a wait with no target is downgraded to ``continue``. Accepts ``{"verdict": ...}`` and
the legacy ``{"done": <bool>}`` shape.
ÚcontinueTNzjudge reply was not JSON: rS  r*   zno reason providedÚverdictr   r.  Fc               ó    € V ^8„  d   QhRRRR/# )r.   Úkeysr+   r/   r“   r1   )r2   s   "r3   r4   Ú+_parse_judge_response.<locals>.__annotate__9  s   € ÷ ñ ˜#ð  -ñ r6   c                 ó°   <€ V  F6  p SP                  V4      e   \        SV,          4      M^ pT^ 8”  g   K4  Tu # 	  R #   \        \        3 d     KP  i ; ir9   )rQ   r�   Ú	TypeErrorÚ
ValueError)r‘  ró   ÚivrL   s   *  €r3   Ú
_first_intÚ)_parse_judge_response.<locals>._first_int9  sZ   ø€ ÛˆAðØ%)§X¡X¨a£[Ò%<”S˜˜a�”\À!�ð �AŽvØ’	ñ ñ øô	 œzÐ*ô Úðús   ˆ'A Á AÁAÚwait_on_sessionr  Úwait_sessionÚwait_on_pidr`  Úwait_pidÚwait_for_secondsÚsecondsÚwait_secondsu,    (wait verdict had no target â€” continuing))rŽ  zjudge returned empty responseTN>   Ú1Úyesr   Útrue>   r   r.  r'   rŽ  )r‹  r^  r+   rQ   r;   rO   rq   r0   )rí   rS  Úverdict_rawr�  Údone_valr   r—  Úsessr`  rž  rL   s   &         @r3   Ú_parse_judge_responser¦    sß  ø€ ÷ ØFÐFÜ Ó$€DØ‚|ØÐ7¼	À#ÀsÓ8KÑ7NÐOÐQUÐW[Ð[Ð[ä�—‘˜(Ó#×)Ð) rÓ*×0Ñ0Ó2×JÐJÐ6J€FØ—(‘(˜9Ó%€KÜ�+œs×#Ò#Ø×#Ñ#Ó%×+Ñ+Ó-‰à—8‘8˜FÓ#ˆÜKUÐV^Ô`c×KdÒKdˆx�~‰~Ó×%Ñ%Ó'Ð+GÒGÔjnÐowÓjxˆß ‘& jˆØÐ=Ô=ØˆØ�&ÔØ  tÐ+Ð+÷ð ð �8‰8Ð%Ó&×\Ð\¨$¯(©(°<Ó*@×\Ð\ÀDÇHÁHÈ^ÓD\€DÜ�$œ×Ò §¡§¢Ø�v˜u |°T·Z±Z³\Ð&BÐBÐBÙ
�] E¨:Ó
6€CØ
‚Ø�v˜u u¨c lÐ2Ð2ÙÐ+¨Y¸ÓG€GØÒØ�v˜u y°'Ð&:Ð:Ð:Ø˜&˜Ð!MÐNÐPUÐW[Ð[Ð[r6   c               ó    € V ^8„  d   QhRRRR/# )r.   Úbackground_processesúOptional[list[dict[str, Any]]]r/   r+   r1   )r2   s   "r3   r4   r4   P  s    € ÷ Uñ UÐ3Qð UÐVYñ Ur6   c                ó*  € . pT ;'       g    .  EFÒ  p\        V\        4      '       d.   VP                  R4      R8X  g   VP                  R4      '       g   KI  \        \	        VP                  R4      ;'       g    R4      P                  RR4      P                  4       ^x4      p\        \	        VP                  R4      ;'       g    R4      P                  RR4      P                  4       ^x4      pR	VR,           2pVP                  R
4      '       d   VRVR
,           2,          pVRV 2,          pVP                  R4      e   VRVR,           R2,          pVP                  R4      pV'       d+   VP                  R4      '       d   RMRpVRV V 2,          pM VP                  R4      '       d
   VR,          pV'       d   VRV 2,          pVP                  V4       EKÕ  	  V'       g   R# \        P                  RP                  V4      R7      # )zµRender RUNNING ``process_registry.list_sessions()`` entries for the judge prompt. Empty string
when nothing is running, so the prompt stays byte-identical to the no-background case.rÐ   Úexitedr`  rŽ   r*   rX   rm   Úoutput_previewz- pid r  z / session r[   Úuptime_secondsz
 (running zs)Úwatch_patternsÚ	watch_hitz [already matched]z | watch_patterns=Únotify_on_completez | notify_on_completez | recent output: )Úbackground_lines)rO   rP   rQ   r^  r+   r±   r;   rr   ÚJUDGE_BACKGROUND_BLOCK_TEMPLATEr2   r^   )r¨  ÚlinesÚpÚcmdÚtailrw   ÚwpsÚhits   &       r3   Ú_render_background_blockr¹  P  sÊ  € ð €EØ!×'Ð' RÓ'ˆÜ˜!œT×"Ò" a§e¡e¨H£o¸Ô&AÈÏÉÈuÏÊÙÜœ˜AŸE™E )Ó,×2Ð2°Ó3×;Ñ;¸DÀ#ÓF×LÑLÓNÐPSÓTˆÜœ˜QŸU™UÐ#3Ó4×:Ð:¸Ó;×CÑCÀDÈ#ÓN×TÑTÓVÐX[Ó\ˆØ˜˜%��zÐ"ˆØ�5‰5�×ÒØ�k ! L¥/Ð!2Ð3Õ3ˆDØ�"�S�E�
ÕˆØ�5‰5Ð!Ó"Ò.Ø�j Ð#3Õ!4Ð 5°RÐ8Õ8ˆDà�e‰eÐ$Ó%ˆßØ*+¯%©%°×*<Ò*<Ñ&À"ˆCØÐ(¨¨¨c¨UÐ3Õ3‰DØ�U‰UÐ'×(Ò(ØÐ+Õ+ˆDßØÐ(¨¨Ð/Õ/ˆDØ�‰�T×ñ) (÷* ÙÜ*×1Ñ1À4Ç9Á9ÈUÓCSÐ1ÓTÐTr6   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r.   Úsystem_promptr+   Úuser_promptr¶   úOptional[float]r/   r1   )r2   s   "r3   r4   r4   n  s*   € ÷ ñ °#ð ÀCð ÐRað Ðfiñ r6   c                óÈ   € V ! RRRRV/RRRV/.^ \        4       VR7      p VP                  ^ ,          P                  P                  ;'       g    R#   \         d     R# i ; i)z–Route through call_llm so auxiliary.goal_judge.* config (provider/model, extra_body,
reasoning_effort, retries) all apply. Returns the raw reply text.rr  ÚroleÚsystemÚcontentÚuser)ÚtaskÚmessagesÚtemperaturerz  r¶   r*   )r|  ÚchoicesÚmessagerÁ  rÆ   )Úcall_llmr»  r¼  r¶   Úresps   &&&& r3   Ú_call_goal_judge_llmrÊ  n  sq   € ñ
 ØØ˜8 Y°Ð>ÀÈÐQZÐ\gÐ@hÐiØÔ"8Ó":ÀGô€Dð
Ø�|‰|˜A�×&Ñ&×.Ñ.×4Ð4°"Ð4øÜô Úðús   ¡-A ÁA ÁA!Á A!r¶   r€   r¨  r}   Úactive_delegationsc               ó8   € V ^8„  d   QhRRRRRRRRRR	R
RRRRR/# )r.   r   r+   Úlast_responser¶   r½  r€   zOptional[list[str]]r¨  r©  r}   úOptional[GoalContract]rË  r�   r/   z5tuple[str, str, bool, Optional[dict[str, Any]], bool]r1   )r2   s   "r3   r4   r4   ~  sl   € ÷ A@ñ A@Ø
ðA@àðA@ð ð	A@ð
 "ðA@ð 9ðA@ð %ðA@ð ðA@ð ;ñA@r6   c               óÖ  € V P                  4       '       g   R# VP                  4       '       g   R# Vf   \        4       p ^ RIHp ^ RIHp T;'       g    .  U
u. uF4  qª'       g   K  T
P                  4       '       g   K$  T
P                  4       NK6  	  pp
\        \        T R4      \        T\        4      \        T4      T^ 8”  d   \        P                  TR7      MR	,           \        \         P"                  ! \$        R
7      P'                  4       R4      R7      pTeb   TP)                  4       '       gL   TP+                  4       pT'       d   T R\-        T4       2p\.        P                  ! RR\        TR4      /TB pMdT'       dG   RP1                  R \3        T^R7       4       4      p\4        P                  ! RR\        TR4      /TB pM\6        P                  ! R/ TB p \9        T\:        Yâ4      p\C        T4      w  pppp\        P=                  RT\        T^x4      T'       d   RT 2MR	4       TTTTR3#   \         d#   p	\        P                  RT	4       Ru Rp	?	# Rp	?	ii ; iu up
i   T d+   p	\        P=                  RT	4       RRT	 2RRR3u Rp	?	# Rp	?	i\         d>   p	\        P=                  RT	4       RR\?        T	4      P@                   2RRR3u Rp	?	# Rp	?	ii ; i)a7  Ask the auxiliary model whether the goal is satisfied.

Returns ``(verdict, reason, parse_failed, wait_directive, transport_failed)``; verdict is done /
blocked / continue / wait / skipped. ``parse_failed`` means unusable output; transport errors
set ``transport_failed`` instead and fail-open to ``continue``.
FNrŽ  ©rÈ  )ÚAuxiliaryClientUnavailablez.goal judge: auxiliary client import failed: %siÐ  )Úcountr*   )Útzz%Y-%m-%d %H:%M:%S %Z)r   ÚresponseÚbackground_blockÚcurrent_timerX   Úcontract_blockiÄ	  c              3  ó6   "  € T F  w  rR V RV 2x € K  	  R# 5ir  r1   r„   s   &  r3   r@   Újudge_goal.<locals>.<genexpr>¬  s!   é € Ð"fÑCe¹¸ R¨ s¨"¨T¨FÕ#3ÓCeùr‡   rˆ   Úsubgoals_blockuM   goal judge: auxiliary client unavailable (%s) â€” falling through to continuez)goal_judge auxiliary client unavailable: Tu@   goal judge: API call failed (%s) â€” falling through to continuezjudge error: z"goal judge: verdict=%s reason=%s%sz wait=)Úskippedz
empty goalFNF)rŽ  z$empty response (nothing to evaluate)FNF)rŽ  zauxiliary client unavailableFNFr1   )"r;   r€  Úagent.auxiliary_clientrÈ  Úagent.auxiliary_unavailablerÑ  rÆ   r  r  rP   r^  Ú_JUDGE_RESPONSE_SNIPPET_CHARSr¹  Ú JUDGE_DELEGATIONS_BLOCK_TEMPLATEr2   r   r   Únowr   Ú
astimezonerE   r_   r‹   Ú(JUDGE_USER_PROMPT_WITH_CONTRACT_TEMPLATEr^   rŠ   Ú(JUDGE_USER_PROMPT_WITH_SUBGOALS_TEMPLATEÚJUDGE_USER_PROMPT_TEMPLATErÊ  ÚJUDGE_SYSTEM_PROMPTÚinforÇ   ra   r¦  )r   rÍ  r¶   r€   r¨  r}   rË  rÈ  rÑ  rÊ   rö   Úclean_subgoalsÚcommonr×  ÚpromptrÚ  rí   r�  rS  Úparse_failedÚwait_directives   &&$$$$$              r3   Ú
judge_goalrì  ~  s©  € ð  �:‰:�<Š<Ø:Ð:Ø×Ñ× Ò ØUÐUØ‚Ü%Ó'ˆðNÝ3ÝJð +3¯.¨.°b¨.ÓM©. A»Q”iÀ1Ç7Á7Ç9”i�a—g‘g–i©.€NÐMÜÜ�t˜TÓ"Ü˜=Ô*GÓHÜ1Ð2FÓGØPbÐefÔPfÔ+×2Ñ2Ð9KÐ2ÔLÐlnõpä"¤8§<¢<´3Ô#7×#BÑ#BÓ#DÐF\Ó]ô€Fð Ò H×$5Ñ$5×$7Ò$7Ø!×.Ñ.Ó0ˆßØ .Ð/¨rÔ2HÈÓ2XÐ1YÐZˆNÜ9×@Ò@ÑzÔPYÐZhÐjnÓPoÐzÐsyÑz‰ß	ØŸ™Ñ"fÄ9È^ÐcdÕCeÓ"fÓfˆÜ9×@Ò@ÑzÔPYÐZhÐjnÓPoÐzÐsyÑz‰ä+×2Ò2Ñ<°VÑ<ˆð	SÜ" 8Ô-@À&ÓRˆô 5JÈ#Ó4NÑ1€GˆV�\ >Ü
‡K�KÐ4°g¼yÈÐQTÓ?Uß-;�&˜Ð(Ñ)ÀôEà�F˜L¨.¸%Ð?Ð?øôO ô NÜ�‰ÐEÀsÔKØMÕMûðNüò Nøð* &ô `ô 	�‰ÐcÐehÔiØÐFÀsÀeÐLÈeÐUYÐ[_Ð_Õ_ûÜô SÜ�‰ÐVÐX[Ô\Ø˜]¬4°«9×+=Ñ+=Ð*>Ð?ÀÈÈdÐRÕRûðSúsf   Á H< Á	I,Á(I,Â I,Ç%I1 È<I)ÉI$ÉI)É$I)É1K(É8JÊK(ÊK(Ê*K(Ê+2K#ËK(Ë#K(c               ó    € V ^8„  d   QhRRRR/# )r.   r  r®   r/   r�   r1   )r2   s   "r3   r4   r4   Â  s   € ÷ ñ ¨ð ¸3ñ r6   c           
     ó†   € V '       g   ^ #  ^ RI HpHp \        V! VRR\	        V 4      4      4      #   \
         d     ^ # i ; i)zDLive async delegation batches spawned by this session (fail-safe 0).)Ú_LIVE_STATESÚ_session_recordsr*   )Útools.async_delegationrï  rð  r]  r+   rÆ   )r  rï  rð  s   &  r3   Úcount_active_delegationsrò  Â  s=   € çÙðßIÜÑ# L°"°b¼#¸j»/ÓJÓKÐKøÜô Úðús   Œ$1 ±A ¿A zV[Goal set] Continue with the goal you were just given; there is no need to re-read it.é�  gš™™™™™é?c               ó$   € V ^8„  d   QhRRRRRR/# )r.   r   r+   Úlast_user_messager
   r/   r1   )r2   s   "r3   r4   r4   Ø  s!   € ÷ ñ ˜3ð °3ð ¸3ñ r6   c                ó´  € Tp\        V\        4      '       d   RP                  R V 4       4      pRP                  \        T ;'       g    R4      P	                  4       4      RP                  \        T;'       g    R4      P	                  4       4      rC\        V4      \        8¼  d1   W49   d+   \        V4      \        \        V4      ,          8¼  d   \        # V # )zaThe goal text, or ``GOAL_ALREADY_SEEN_KICK`` when ``last_user_message`` is essentially that text.rm   c              3  óˆ   "  € T F8  p\        V\        4      '       g   K  \        VP                  R R4      4      x € K:  	  R# 5i)rj   r*   N)rO   rP   r+   rQ   )r=   Úbs   & r3   r@   Ú#goal_kick_prompt.<locals>.<genexpr>Ü  s1   é € ÐZ¹7°aÄjÐQRÔTX×FYÔ1œ3˜qŸu™u V¨RÓ0×1Ð1»7ùs
   ‚AŸ#Ar*   )	rO   rñ   r^   r+   Úsplitr]  Ú_GOAL_REPASTE_MIN_CHARSÚ_GOAL_REPASTE_MIN_SHAREÚGOAL_ALREADY_SEEN_KICK)r   rõ  rÁ  Ú	goal_normÚ	last_norms   &&   r3   Úgoal_kick_promptr   Ø  s�   € à€GÜ�'œ4× Ò Ø—(‘(ÑZ¹7ÓZÓZˆØŸ8™8¤C¨¯
¨
°£O×$9Ñ$9Ó$;Ó<¸c¿h¹hÄsÈ7Ï=È=ÐVXÓGY×G_ÑG_ÓGaÓ>bˆyäˆI‹Ô1Ô1ØÔ"Ü�	‹NÔ5¼¸I»ÕFÔFä%Ð%Ø€Kr6   c               ó    € V ^8„  d   QhRRRR/# )r.   Úhistoryr
   r/   r1   )r2   s   "r3   r4   r4   ç  s   € ÷ ñ  sð ¨sñ r6   c                óÀ   € \        T ;'       g    . 4       FD  p\        V\        4      '       g   K  VP                  R4      R8X  g   K3  VP                  R4      u # 	  R# )zZContent of the newest ``role == "user"`` message in an OpenAI-shaped history, else ``""``.r¿  rÂ  rÁ  r*   )ÚreversedrO   rP   rQ   )r  Úmsgs   & r3   Úlast_user_message_contentr  ç  sG   € ä˜Ÿ˜ 2Ö&ˆÜ�cœ4× Ô  S§W¡W¨V£_¸Ö%>Ø—7‘7˜9Ó%Ò%ñ 'ñ r6   c               ó    € V ^8„  d   QhRRRR/# )r.   r  r®   r/   r
   r1   )r2   s   "r3   r4   r4   ï  s   € ÷ ñ ¨-ð ¸Cñ r6   c                ó¬   € V '       g   R#  \        4       pVf   R# VP                  \        V 4      ^RR7      p\        V4      #   \         d     R# i ; i)z—Newest user message of ``session_id`` from the SessionDB (gateway/TUI surfaces have no live
history object at slash-command time); ``""`` on any error.r*   T)r[  Úlatest)r2  Úget_messagesr+   r  rÆ   )r  r  Úrowss   &  r3   Úlast_user_message_from_dbr  ï  sT   € ÷ ÙðÜÓˆØŠ:ÙØ�‰œs :›°bÀˆÓFˆÜ(¨Ó.Ð.øÜô Úðús   ŒA œ'A ÁAÁAÚowner_task_idc               ó$   € V ^8„  d   QhRRRRRR/# )r.   Útask_idr®   r  r/   zlist[dict[str, Any]]r1   )r2   s   "r3   r4   r4   þ  s#   € ÷ ñ ¨ð ÐQ^ð Ðj~ñ r6   c               ó  €  ^ RI Hp VP                  V R7      ;'       g    . pT Uu. uF5  p\        T\        4      '       g   K  TP                  R4      R8w  g   K3  TNK7  	  ppT'       d_   T Uu. uFR  p\        TP                  R4      ;'       g    TP                  R4      ;'       g    R	4      \        T4      8X  g   KP  TNKT  	  ppT#   \         d#   p\        P                  RT4       . u Rp?# Rp?ii ; iu upi u upi )
ag  Fail-safe snapshot of RUNNING ``process_registry`` sessions for the judge; ``[]`` on any error
so the loop degrades to its pre-wait-barrier behavior.

``owner_task_id`` restricts the snapshot to processes the goal's OWN session spawned. The registry's
``task_id`` is the container key, which collapses to one value for every agent in the process, so
without this filter a fan-out parent's judge saw every subagent's pollers and parked the goal on a
grandchild's ``proc_*`` session (one run: 7 of 7 root verdicts were WAIT on child-owned processes;
parked 3 h 22 min at the end while nothing of its own was running).ri  )r  z&gather_background_processes failed: %sNrÐ   r«  r  r  r*   )
rk  rj  Úlist_sessionsrÆ   r  r  rO   rP   rQ   r+   )r  r  rj  ÚsessionsrÊ   rö   Úrunnings   &$     r3   Úgather_background_processesr  þ  sÚ   € ðÝ;à#×1Ñ1¸'Ð1ÓB×HÐHÀbˆñ #ÓZ™(�Q¤j°´D×&9Œq¸a¿e¹eÀH»oÐQYÑ>Y�qˆq™(€GÐZßÙ%Óu™g˜¬¨Q¯U©U°?Ó-C×-]Ð-]ÀqÇuÁuÈYÓGW×-]Ð-]Ð[]Ó)^ÔbeÐfsÓbtÑ)t—1�1™gˆÐuØ€Nøô ô Ü�‰Ð=¸sÔCØ�	ûðüò [ùâusK   ‚C ¡C ¨C=ÁC=ÁC=Á1!DÂDÂ,DÃDÃC:ÃC5Ã/C:Ã5C:c               ó$   € V ^8„  d   QhRRRRRR/# )r.   Ú	objectiver+   r¶   r½  r/   rÎ  r1   )r2   s   "r3   r4   r4     s"   € ÷ 5ñ 5˜cð 5¨ð 5ÐJ`ñ 5r6   c          	     óT  € T ;'       g    RP                  4       p V '       g   R# Vf   \        4       p ^ RIHp  \        T\        R\        T R4       2T4      p\        T4      p\        T\        4      '       g#   \
        P                  R\        T^È4      4       R# \        P                  T4      pTP!                  4       '       d   R# T#   \         d"   p\
        P                  RT4        Rp?R# Rp?ii ; i  \         d"   p\
        P                  RT4        Rp?R# Rp?ii ; i)	z´Expand a plain-language objective into a completion contract via the ``goal_judge`` auxiliary
task (a side LLM call, not a conversation turn). None when unavailable or unparseable.r*   NrÐ  z.goal draft: auxiliary client import failed: %szObjective:
r   z goal draft: API call failed (%s)z"goal draft: reply was not JSON: %r)r;   r€  rÜ  rÈ  rÆ   r  r  rÊ  ÚDRAFT_CONTRACT_SYSTEM_PROMPTr^  ræ  r‹  rO   rP   r)   rS   rE   )r  r¶   rÈ  rÊ   rí   rL   r}   s   &$     r3   Údraft_contractr    s  € ð —�˜b×'Ñ'Ó)€IßÙØ‚ô &Ó'ˆðÝ3ð
Ü" 8Ô-IÈ\ÔZcÐdmÐosÓZtÐYuÐKvÐxó  Aˆô
   Ó$€DÜ�dœD×!Ò!Ü�‰Ð9¼9ÀSÈ#Ó;NÔOÙÜ×%Ñ% dÓ+€HØ×$Ñ$×&Ò&ˆ4Ð4¨HÐ4øô ô Ü�‰ÐEÀsÔKÝûðûô ô Ü�‰Ð6¸Ô<Ýûðús.   ´C »C; ÃC8ÃC3Ã3C8Ã;D'ÄD"Ä"D'c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r.   Úshould_continuer0   ré  r®   r�  r+   rS  rÇ  r/   r—   r1   )r2   s   "r3   r4   r4   6  sA   € ÷ Fñ F tð F°]ð FÈSð FÐZ]ð FÐhkð FÐp~ñ Fr6   c                ó   € R V RVRVRVRVRV/# )rÐ   r  Úcontinuation_promptr�  rS  rÇ  r1   )rÐ   r  ré  r�  rS  rÇ  s   &&&&&&r3   Ú	_decisionr  6  s+   € Ø�fÐ/°ÐBWÐY_Ø�w ¨&°)¸WðFð Fr6   z‚~/.hermes/config.yaml:
  auxiliary:
    goal_judge:
      provider: {provider}
      model: {model}
Then /goal resume to continue.c                  ól  € ] tR tRtRtR]/R R lltR R lt]R R	 l4       t	R
 R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltRRRR/R R  lltR! R" ltRbR# R$ lltR%R&/R' R( lltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 ltR7 R8 ltR9RR:R/R; R< lltR= R> lt R? R@ lt!RA RB lt"RC RD lt#RE RF lt$RcRG RH llt%RcRI RJ llt&RcRK^ /RL RM lllt'RN RO lt(RP RQ lt)RR RS lt*RT^ /RU RV llt+RcRW RX llt,RYR&RZRRT^ /R[ R\ llt-R] R^ lt.R_ R` lt/Rat0R# )drL  iA  a/  Per-session goal state + continuation decisions.

The CLI and gateway each hold one per live session. ``evaluate_after_turn`` calls the judge and
returns the decision dict that drives the next turn; ``next_continuation_prompt`` is the
canonical user-role message to feed back into ``run_conversation``.
Údefault_max_turnsc               ó    € V ^8„  d   QhRRRR/# )r.   r  r+   r   r�   r1   )r2   s   "r3   r4   ÚGoalManager.__annotate__I  s   € ÷ Añ A 3ð A¸cñ Ar6   c               	ón   € Wn         \        T;'       g    \        4      V n        \	        V4      V n        R # r9   )r  r�   rð   r   rH  Ú_state)r?   r  r   s   &&$r3   Ú__init__ÚGoalManager.__init__I  s*   € Ø$ŒÜ!$Ð%6×%KÐ%KÔ:KÓ!LˆÔÜ+4°ZÓ+@ˆŽr6   c               ó   € V ^8„  d   QhRR/# r  r1   )r2   s   "r3   r4   r"  N  s   € ÷ 1ñ 1˜ñ 1r6   c                ó:   € \        V P                  4      V n        R# )zBRe-read state from the DB (another writer, e.g. a tool, moved it).N)rH  r  r$  rD   s   &r3   ÚrefreshÚGoalManager.refreshN  s   € ä §¡Ó0ˆŽr6   c               ó   € V ^8„  d   QhRR/# ©r.   r/   rE  r1   )r2   s   "r3   r4   r"  U  s   € ÷ ñ Ð*ñ r6   c                	ó   € V P                   # r9   )r$  rD   s   &r3   rJ  ÚGoalManager.stateT  s   € à�{‰{Ðr6   c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r"  X  s   € ÷ Jñ J˜4ñ Jr6   c                	ó`   € V P                   R J;'       d    V P                   P                  R8H  # ©NrÏ   ©r$  rÐ   rD   s   &r3   Ú	is_activeÚGoalManager.is_activeX  s(   € Ø�{‰{ $Ð&×IÐI¨4¯;©;×+=Ñ+=ÀÑ+IÐIr6   c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r"  [  s   € ÷ Vñ V˜$ñ Vr6   c                	ó`   € V P                   R J;'       d    V P                   P                  R9   # )N>   rÏ   Úpausedr2  rD   s   &r3   Úhas_goalÚGoalManager.has_goal[  s)   € Ø�{‰{ $Ð&×UÐU¨4¯;©;×+=Ñ+=ÐAUÑ+UÐUr6   c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r"  ^  s   € ÷ Fñ F˜dñ Fr6   c                	ób   € V P                   R J;'       d    V P                   P                  4       # r9   )r$  rü   rD   s   &r3   rü   ÚGoalManager.has_contract^  s&   € Ø�{‰{ $Ð&×EÐE¨4¯;©;×+CÑ+CÓ+EÐEr6   c               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   r"  a  s   € ÷ 6ñ 6˜Sñ 6r6   c                	ó  € V P                   pVe   VP                  R8X  d   R# VP                   RVP                   R2pVP                  '       d8   R\        VP                  4       R\        VP                  4      ^8w  d   RMR 2MRpV P                  4       '       d   R	MRpVP                  '       d8   R\        VP                  4       R
\        VP                  4      ^8w  d   RMR 2MRpV V V V 2pVP                  R8X  Edo   VP                  '       dR   \        VP                  4      '       d7   RVP                  ;'       g    RVP                   2 RV RVP                   2# VP                  '       dR   \        VP                  4      '       d7   RVP                  ;'       g    RVP                   2 RV RVP                   2# VP                  '       d…   \        P                  ! 4       VP                  8  da   \!        VP                  \        P                  ! 4       ,
          4      pVP                  ;'       g    V R2pRV RV RV RVP                   2# RV RVP                   2# VP                  R8X  d8   VP"                  '       d   RVP"                   2MRp	RV V	 RVP                   2# VP                  R8X  d   RV RVP                   2# RVP                   RV RVP                   2# )NrQ  z*No active goal. Set one with /goal <text>.Ú/z turnsz, z subgoalrö   r*   z
, contractz gaterÏ   u   â�³ Goal (parked on úsession ú): úpid u   â�³ Goal (parked u   s â€” u   âŠ™ Goal (active, r7  u    â€” u   â�¸ Goal (paused, r   u   âœ“ Goal done (zGoal ()r$  rÐ   rÑ   rÒ   r€   r]  rü   rã   rÞ   rm  rá   r   rÝ   rf  rß   Útimer�   rÙ   )
r?   rö   ÚturnsÚsubÚconÚgatÚmetaÚ	remainingÚwrÚextras
   &         r3   Ústatus_lineÚGoalManager.status_linea  sª  € Ø�K‰KˆØŠ9˜Ÿ™ IÔ-Ù?Ø—<‘<�.  !§+¡+ ¨fÐ5ˆØUV×U_×U_ÐU_�”3�q—z‘z“?Ð# 8´3°q·z±z³?ÀaÔ3G©CÈRÐ+PÑQÐegˆØ"×/Ñ/×1Ò1‰l°rˆØLMÏGÏGÈG�”3�q—w‘w“<�. ¬S°·±«\¸QÔ->¡cÀBÐ%GÑHÐY[ˆØ�˜˜˜c˜U 3 %Ð(ˆØ�8‰8�xÕØ×#×#Ð#Ô(8¸×9MÑ9M×(NÒ(NØ-¨a×.>Ñ.>×.cÐ.cÀHÈQ×MaÑMaÐLbÐBcÐ-dÐdfÐgkÐflÐloÐpq×pvÑpvÐowÐxÐxØ××Ð¤J¨q×/?Ñ/?×$@Ò$@Ø-¨a×.>Ñ.>×.[Ð.[ÀDÈ×IYÑIYÐHZÐB[Ð-\Ð\^Ð_cÐ^dÐdgÐhi×hnÑhnÐgoÐpÐpØ��ˆ¤4§9¢9£;°·±Ô#@Ü §¡´$·)²)³+Õ =Ó>�	Ø×%Ñ%×8Ð8¨I¨;°a¨�Ø*¨9¨+°V¸B¸4¸rÀ$ÀÀsÈ1Ï6É6È(ÐSÐSØ'¨ v¨S°·±°Ð9Ð9Ø�8‰8�xÔØ12··°�e˜AŸO™OÐ,Ñ-ÀbˆEØ'¨ v¨e¨W°C¸¿¹°xÐ@Ð@Ø�8‰8�vÔØ$ T F¨#¨a¯f©f¨XÐ6Ð6Ø˜Ÿ™�z  D 6¨¨Q¯V©V¨HÐ5Ð5r6   c               ó   € V ^8„  d   QhRR/# r,  r1   )r2   s   "r3   r4   r"  }  s   € ÷ ñ Ð*ñ r6   c                	óZ   € \        V P                  V P                  4       V P                  # r9   )rN  r  r$  rD   s   &r3   Ú_saveÚGoalManager._save}  s   € Ü�$—/‘/ 4§;¡;Ô/Ø�{‰{Ðr6   c               ó   € V ^8„  d   QhRR/# ©r.   r/   rÎ   r1   )r2   s   "r3   r4   r"  �  s   € ÷ ñ ˜yñ r6   c                	óx   € V P                   e   V P                  4       '       g   \        R4      hV P                   # )Núno active goal)r$  r8  r(  rD   s   &r3   Ú_require_goalÚGoalManager._require_goal�  s,   € Ø�;‰;Ò d§m¡m§o¢oÜÐ/Ó0Ð0Ø�{‰{Ðr6   c               ó   € V ^8„  d   QhRR/# rS  r1   )r2   s   "r3   r4   r"  †  s   € ÷ ñ  ñ r6   c                	ó‚   € V P                   e   V P                   P                  R8w  d   \        R4      hV P                   # )NrÏ   zno active goal to park)r$  rÐ   r(  rD   s   &r3   Ú_require_activeÚGoalManager._require_active†  s3   € Ø�;‰;Ò $§+¡+×"4Ñ"4¸Ô"@ÜÐ7Ó8Ð8Ø�{‰{Ðr6   c               ó    € V ^8„  d   QhRRRR/# ©r.   rS  r+   r/   r  r1   )r2   s   "r3   r4   r"  ‹  s   € ÷ ñ  3ð ¨4ñ r6   c                	óh   € R V P                   n        WP                   n        V P                  4        R# )r7  N)r$  rÐ   rÙ   rP  ©r?   rS  s   &&r3   Ú_pause_stateÚGoalManager._pause_state‹  s!   € Ø%ˆ�‰ÔØ$*�‰Ô!Ø�
‰
Žr6   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r.   rÙ   r+   r�  rS  rÇ  r/   r—   r1   )r2   s   "r3   r4   r"  �  s8   € ÷ Jñ J¨Sð J¸3ð JÈð JÐVYð JÐ^lñ Jr6   c                	óB   € V P                  V4       \        R RRW#V4      # )r7  FN)r`  r  )r?   rÙ   r�  rS  rÇ  s   &&&&&r3   Ú_pause_decisionÚGoalManager._pause_decision�  s#   € Ø×Ñ˜-Ô(Ü˜ 5¨$°ÀÓIÐIr6   rÒ   Nr}   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r.   r   r+   rÒ   r“   r}   rÎ  r/   rÎ   r1   )r2   s   "r3   r4   r"  ”  s*   € ÷ 	ñ 	˜ð 	¨=ð 	ÐKað 	Ðmvñ 	r6   c          
     	ó&  € T;'       g    R P                  4       pV'       g   \        R4      h\        TR^ \        P                  ! 4       RV'       d   \	        V4      MV P
                  Ve   TM	\        4       R7      V n        V P                  4       # )r*   zgoal text is emptyrÏ   rÓ   )r   rÐ   rÑ   rÕ   rÖ   rÒ   r}   )	r;   r•  rÎ   rC  r�   r   r)   r$  rP  )r?   r   rÒ   r}   s   &&$$r3   r  ÚGoalManager.set”  sn   € Ø—
�
˜×!Ñ!Ó#ˆßÜÐ1Ó2Ð2ÜØ˜h°1ÄÇÂÃÐ[^ß(1”c˜)”n°t×7MÑ7MØ!)Ò!5‘X¼<»>ô
ˆŒð
 �z‰z‹|Ðr6   c               ó    € V ^8„  d   QhRRRR/# )r.   r}   r)   r/   rE  r1   )r2   s   "r3   r4   r"  Ÿ  s   € ÷ ñ  \ð Ð6Iñ r6   c                óˆ   € V P                   f   R# T;'       g    \        4       V P                   n        V P                  4       # )z=Attach or replace the completion contract on the active goal.N)r$  r)   r}   rP  )r?   r}   s   &&r3   Úset_contractÚGoalManager.set_contractŸ  s1   € à�;‰;ÒÙØ'×9Ð9¬<«>ˆ�‰ÔØ�z‰z‹|Ðr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rS  r+   r/   rE  r1   )r2   s   "r3   r4   r"  ¦  s   € ÷ ñ ˜Cð Ð4Gñ r6   c                	óÀ   € V P                   '       g   R # RV P                   n        WP                   n        V P                   P                  4        V P	                  4       # )Nr7  )r$  rÐ   rÙ   r	  rP  r_  s   &&r3   ÚpauseÚGoalManager.pause¦  s@   € Ø�{�{ˆ{ÙØ%ˆ�‰ÔØ$*�‰Ô!Ø�‰×ÑÔ Ø�z‰z‹|Ðr6   Úreset_budgetTc               ó    € V ^8„  d   QhRRRR/# )r.   rq  r0   r/   rE  r1   )r2   s   "r3   r4   r"  ®  s   € ÷ ñ  dð Ð6Iñ r6   c               	óô   € V P                   '       g   R # RV P                   n        R V P                   n        V P                   P                  4        V'       d   ^ V P                   n        V P                  4       # r1  )r$  rÐ   rÙ   r	  rÑ   rP  )r?   rq  s   &$r3   ÚresumeÚGoalManager.resume®  sQ   € Ø�{�{ˆ{ÙØ%ˆ�‰ÔØ$(ˆ�‰Ô!Ø�‰×ÑÔ ßØ%&ˆD�K‰KÔ"Ø�z‰z‹|Ðr6   c               ó   € V ^8„  d   QhRR/# r  r1   )r2   s   "r3   r4   r"  ¸  s   € ÷ ñ �tñ r6   c                	óv   € V P                   f   R # RV P                   n        V P                  4        R V n         R # )NrQ  )r$  rÐ   rP  rD   s   &r3   ÚclearÚGoalManager.clear¸  s+   € Ø�;‰;ÒÙØ&ˆ�‰ÔØ�
‰
ŒØˆŽr6   c               ó    € V ^8„  d   QhRRRR/# r]  r1   )r2   s   "r3   r4   r"  ¿  s   € ÷ ñ  ð ¨ñ r6   c                	ó²   € V P                   '       g   R # RV P                   n        RV P                   n        WP                   n        V P	                  4        R # )Nr   )r$  rÐ   r×   rØ   rP  r_  s   &&r3   Ú	mark_doneÚGoalManager.mark_done¿  s9   € Ø�{�{ˆ{ÙØ#ˆ�‰ÔØ#)ˆ�‰Ô Ø"(�‰ÔØ�
‰
Žr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rj   r+   r/   r1   )r2   s   "r3   r4   r"  É  s   € ÷ ñ  ð ¨ñ r6   c                óÖ   € V P                  4       pT;'       g    RP                  4       pV'       g   \        R4      hVP                  P	                  V4       V P                  4        V# )zNAppend a user-added criterion; raises ``RuntimeError`` without ``has_goal()``.r*   zsubgoal text is empty)rV  r;   r•  r€   rr   rP  )r?   rj   rJ  s   && r3   Úadd_subgoalÚGoalManager.add_subgoalÉ  sS   € à×"Ñ"Ó$ˆØ—
�
˜×!Ñ!Ó#ˆßÜÐ4Ó5Ð5Ø�‰×Ñ˜dÔ#Ø�
‰
ŒØˆr6   c               ó    € V ^8„  d   QhRRRR/# )r.   Úattrr+   Úindex_1basedr�   r1   )r2   s   "r3   r4   r"  Ó  s   € ÷ ñ ˜cð °ñ r6   c                	óþ   € \        V P                  4       V4      p\        V4      ^,
          pV^ 8  g   V\        V4      8¼  d   \	        R\        V4       R24      hVP                  V4      pV P                  4        V# )é   zindex out of range (1..Ú))r:   rV  r�   r]  Ú
IndexErrorr  rP  )r?   rƒ  r„  rs   ÚidxÚremoveds   &&&   r3   Ú	_pop_itemÚGoalManager._pop_itemÓ  sl   € Ü˜×*Ñ*Ó,¨dÓ3ˆÜ�,Ó !Õ#ˆØ�Œ7�cœS ›ZÔ'ÜÐ6´s¸5³z°lÀ!ÐDÓEÐEØ—)‘)˜C“.ˆØ�
‰
ŒØˆr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rƒ  r+   r/   r�   r1   )r2   s   "r3   r4   r"  Ü  s   € ÷ ñ  ð ¨ñ r6   c                	ó†   € V P                  4       p\        \        W!4      4      p\        W!. 4       V P	                  4        V# r9   )rV  r]  r:   ÚsetattrrP  )r?   rƒ  rJ  Úprevs   &&  r3   Ú_clear_itemsÚGoalManager._clear_itemsÜ  s7   € Ø×"Ñ"Ó$ˆÜ”7˜5Ó'Ó(ˆÜ�˜RÔ Ø�
‰
ŒØˆr6   c               ó    € V ^8„  d   QhRRRR/# ©r.   r„  r�   r/   r+   r1   )r2   s   "r3   r4   r"  ã  s   € ÷ 8ñ 8¨3ð 8°3ñ 8r6   c                ó&   € V P                  RV4      # )z<Remove a subgoal by 1-based index. Returns the removed text.r€   )r‹  ©r?   r„  s   &&r3   Úremove_subgoalÚGoalManager.remove_subgoalã  s   € à�~‰~˜j¨,Ó7Ð7r6   c               ó   € V ^8„  d   QhRR/# rx  r1   )r2   s   "r3   r4   r"  ç  s   € ÷ -ñ - ñ -r6   c                ó$   € V P                  R4      # )z.Wipe all subgoals. Returns the previous count.r€   ©r‘  rD   s   &r3   Úclear_subgoalsÚGoalManager.clear_subgoalsç  s   € à× Ñ  Ó,Ð,r6   c               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   r"  ë  s   € ÷ nñ n ñ nr6   c                ój   € V P                   f   R# V P                   P                  4       ;'       g    R# )z-Public helper for the /subgoal slash command.ú(no active goal)u5   (no subgoals â€” use /subgoal <text> to add criteria))r$  r  rD   s   &r3   Úrender_subgoalsÚGoalManager.render_subgoalsë  s+   € à�;‰;ÒÙ%Ø�{‰{×0Ñ0Ó2×mÐmÐ6mÐmr6   r�   r‘   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r.   rŽ   r+   r�   r“   r‘   r/   r�   r1   )r2   s   "r3   r4   r"  ó  s*   € ÷ ñ  ð ¸ð Ð\ið Ðu}ñ r6   c               óN  € V P                  4       pT;'       g    RP                  4       pV'       g   \        R4      h\        TV'       d   \	        V4      M\
        V'       d   \	        V4      M\        R7      pVP                  P                  V4       V P                  4        V# )zNAppend a quality-gate command; raises ``RuntimeError`` without ``has_goal()``.r*   zgate command is empty)rŽ   r�   r‘   )
rV  r;   r•  r�   r�   r�   rž   rã   rr   rP  )r?   rŽ   r�   r‘   rJ  r­   s   &&$$  r3   Úadd_gateÚGoalManager.add_gateó  s|   € à×"Ñ"Ó$ˆØ—=�=˜b×'Ñ'Ó)ˆßÜÐ4Ó5Ð5ÜØß4CœC Ô0ÔIeß,7œ˜KÔ(Ô=Uô
ˆð
 	�‰×Ñ˜4Ô Ø�
‰
ŒØˆr6   c               ó    € V ^8„  d   QhRRRR/# r”  r1   )r2   s   "r3   r4   r"    s   € ÷ =ñ =¨ð =°ñ =r6   c                ó:   € V P                  RV4      P                  # )z<Remove a gate by 1-based index. Returns the removed command.rã   )r‹  rŽ   r–  s   &&r3   Úremove_gateÚGoalManager.remove_gate  s   € à�~‰~˜g |Ó4×<Ñ<Ð<r6   c               ó   € V ^8„  d   QhRR/# rx  r1   )r2   s   "r3   r4   r"    s   € ÷ *ñ *˜Sñ *r6   c                ó$   € V P                  R4      # )z-Remove all gates. Returns the previous count.rã   r›  rD   s   &r3   Úclear_gatesÚGoalManager.clear_gates  s   € à× Ñ  Ó)Ð)r6   c               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   r"  
  s   € ÷  ñ  ˜cñ  r6   c                óº  € V P                   f   R# V P                   P                  '       g   R# . p\        V P                   P                  ^R7       Fv  w  r#RpVP                  ^ 8X  d   RpM8VP                  e+   RVP                   RVP                   RVP
                   R	2pVP                  R
V RVP                   V 24       Kx  	  RP                  V4      # )z/Public helper for the /goal gate slash command.r   uB   (no quality gates â€” use /goal gate add <command> to require one)rˆ   r*   u    âœ“ passingu    âœ— failing (exit z
, attempt r?  r‡  rZ   z. $ rX   )	r$  rã   rŠ   r”   r’   r‘   rr   rŽ   r^   )r?   r³  r…   r÷   rÐ   s   &    r3   Úrender_gatesÚGoalManager.render_gates
  sÉ   € à�;‰;ÒÙ%Ø�{‰{× × Ð ÙWØˆÜ˜dŸk™k×/Ñ/°q×9‰DˆAØˆFØ×Ñ 1Ô$Ø'‘Ø×!Ñ!Ò-Ø.¨q×/?Ñ/?Ð.@À
È1Ï:É:È,ÐVWÐXY×XeÑXeÐWfÐfgÐh�Ø�L‰L˜2˜a˜S  Q§Y¡Y K°¨xÐ8Ö9ñ :ð �y‰y˜ÓÐr6   c               ó   € V ^8„  d   QhRR/# )r.   r/   rM   r1   )r2   s   "r3   r4   r"    s   € ÷ 5ñ 5Ð6ñ 5r6   c                óø  € V P                   pVe   VP                  '       g   R# \        4       w  r#V'       d   V P                  RV 2RRV 2RV R24      # VP                   EF‚  p\	        WBR7      w  rVpWdn        Wtn        V'       d
   ^ Vn        K0  V;P                  ^,          un        VP                  VP                  8”  dc   V P                  RVP                  ^,
           R	VP                   2RR
VP                   2RVP                   R	VP                   RV R24      u # V P                  4        \        P                  VP                  VP                  YdP                  VP                  T;'       g    RR7      p\        RRVRRV RVP                   2RVP                   RVP                    RVP                   RVP                   RVP                   2
4      u # 	  V P                  4        R# )aà  Run quality gates in order; return a decision dict on failure.

Every eligible boundary re-executes a failed gate. A git HEAD+porcelain fingerprint used to
replay the recorded failure when "nothing changed", but porcelain sees neither the contents
of an untracked or already-modified file nor inputs outside the repo, so a repaired input
was replayed as still-failing until retry exhaustion paused the goal (#110649). The
retry cap below still bounds a genuinely stuck red suite.
Nzquality gates not run: Úgate_failedzgates not run: u+   â�¸ Goal paused â€” quality gates not run: zF. Fix the workspace or /goal gate remove the gates, then /goal resume.)r«   zquality gate exhausted z retries: $ zgate exhausted retries: $ u5   â�¸ Goal paused â€” quality gate still failing after z (exit z>). Fix it manually or /goal gate remove it, then /goal resume.z(no output))r   rŽ   Ú	exit_codeÚattemptr‘   ÚoutputrÏ   Tzgate failed (exit z): $ u   âœ— Quality gate failed (r?  z turns, attempt )r$  rã   rª   rd  rÌ   r”   r•   r’   r‘   rŽ   rP  Ú(CONTINUATION_PROMPT_GATE_FAILED_TEMPLATEr2   r   r  rÑ   rÒ   )	r?   rJ  Úgate_cwdÚrefusalr­   Úpassedr¶  r¶  ré  s	   &        r3   Ú_check_gatesÚGoalManager._check_gates  sú  € ð —‘ˆØŠ= §§ Ùä+Ó-ÑˆßØ×'Ñ'Ø)¨'¨Ð3°]ÀoÐV]ÐU^ÐD_Ø=¸g¸Yð GBð Cóð ð
 —K•KˆDÜ&.¨tÔ&BÑ#ˆF˜tØ"+ÔØ$(Ô!ßØ !�”Ùà�MŠM˜QÕ�Mà�}‰}˜t×/Ñ/Ô/Ø×+Ñ+Ø-¨d¯m©m¸aÕ.?Ð-@ÀÈTÏ\É\ÈNÐ[Ø!Ð%?ÀÇÁ¸~Ð#NØKØ×'Ñ'Ð(¨°T·\±\°Nð CØ&˜Kð ()ð*óò ð �J‰JŒLÜ=×DÑDØ—Z‘Z¨¯©À×TaÑTaØ ×,Ñ,°T×5JÐ5J¸]ð Eó ˆFô Ø˜$ ¨Ø$ Y K¨u°T·\±\°NÐCØ+¨E×,<Ñ,<Ð+=¸Q¸u¿¹Ð>Oð PØŸ=™=˜/¨¨4×+;Ñ+;Ð*<¸EÀ$Ç,Á,ÀðQóò ñ3  ð@ 	�
‰
ŒÙr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rS  r+   r/   rÎ   r1   )r2   s   "r3   r4   r"  S  s   € ÷ ñ ˜Cð ¨yñ r6   c                	ó2  € V P                  4       pVP                  4        VP                  4        F  w  rE\        W4V4       K  	  T;'       g    R P	                  4       ;'       g    RVn        \        P                  ! 4       Vn        V P                  4       # )r*   N)	rZ  r	  rs   r�  r;   rá   rC  râ   rP  )r?   rS  ÚbarrierrJ  ró   r|   s   &&,   r3   Ú_parkÚGoalManager._parkS  sq   € Ø×$Ñ$Ó&ˆØ×ÑÔØ—M‘M–O‰DˆAÜ�E˜aÖ ñ $à &§ ¨"×3Ñ3Ó5×=Ð=¸ˆÔÜ"Ÿiši›kˆÔØ�z‰z‹|Ðr6   c               ó$   € V ^8„  d   QhRRRRRR/# )r.   r`  r�   rS  r+   r/   rÎ   r1   )r2   s   "r3   r4   r"  \  s!   € ÷ 	6ñ 	6˜3ð 	6¨ð 	6°Yñ 	6r6   c                ó¸   € V P                  4        \        V4      pV^ 8:  d   \        R4      h\        V4      '       g   \        R4      hV P	                  W!R7      # )z¯Park the goal loop until a background PID exits (no turn burned, no judge call). For a
process with a watch/notify trigger prefer ``wait_on_session``. Requires an active goal.zpid must be a positive integerzpid is not alive on this host)rÝ   )rZ  r�   r•  rf  rÂ  )r?   r`  rS  s   &&&r3   Úwait_onÚGoalManager.wait_on\  sR   € ð 	×ÑÔÜ�#‹hˆØ�!Œ8ÜÐ=Ó>Ð>Ü˜#�ŠÜÐ<Ó=Ð=Ø�z‰z˜&ˆzÓ5Ð5r6   c               ó$   € V ^8„  d   QhRRRRRR/# )r.   r  r+   rS  r/   rÎ   r1   )r2   s   "r3   r4   r"  g  s&   € ÷ Añ A¨#ð A°sð AÀIñ Ar6   c                ó²   € V P                  4        \        T;'       g    R4      P                  4       pV'       g   \        R4      hV P	                  W!R7      # )z®Park on a process_registry session's OWN trigger: exit OR ``watch_patterns`` match. The
right barrier for a long-lived watcher/poller that signals mid-run and may never exit.r*   z%session_id must be a non-empty string)rÞ   )rZ  r+   r;   r•  rÂ  )r?   r  rS  s   &&&r3   r™  ÚGoalManager.wait_on_sessiong  sK   € ð 	×ÑÔÜ˜×)Ð) rÓ*×0Ñ0Ó2ˆ
ßÜÐDÓEÐEØ�z‰z˜&ˆzÓ@Ð@r6   Úon_delegationsc               ó(   € V ^8„  d   QhRRRRRRRR/# )r.   rž  r�   rS  r+   rË  r/   rÎ   r1   )r2   s   "r3   r4   r"  p  s0   € ÷ 
{ñ 
{¨ð 
{°Sð 
{ÐRUð 
{Ð^gñ 
{r6   c          
     óÞ   € V P                  4        \        V4      pV^ 8:  d   \        R4      hV P                  V\        P                  ! 4       V,           \        ^ \        V4      4      R7      # )a‘  Park until ``seconds`` from now (backoff/cooldown waits with no process to track). With
``on_delegations`` the wait is FOR those live delegation batches: it also lifts as soon as
fewer are live (a batch result came back), so the loop re-judges with the result in hand
instead of sleeping out a 20-minute timer (independent review: results arrived with 1,199 s
left on the timer and nothing re-judged).z"seconds must be a positive integer)rß   rà   )rZ  r�   r•  rÂ  rC  rÀ   )r?   rž  rS  rË  s   &&&$r3   r�  ÚGoalManager.wait_for_secondsp  s\   € ð 	×ÑÔÜ�g“,ˆØ�aŒ<ÜÐAÓBÐBØ�z‰z˜&´·	²	³¸gÕ0EÔ^aÐbcÔehÐiwÓexÓ^yˆzÓzÐzr6   c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r"  |  s   € ÷ ñ ˜dñ r6   c                óÆ   € V P                   pVe/   VP                  f#   VP                  f   VP                  '       g   R# VP	                  4        V P                  4        R# )zVClear any active wait barrier (pid / session / time). Returns True if one was cleared.FT)r$  rÝ   rÞ   rß   r	  rP  )r?   rö   s   & r3   Ústop_waitingÚGoalManager.stop_waiting|  sJ   € à�K‰KˆØŠ9˜×)Ñ)Ò1°a×6JÑ6JÒ6RÐ[\×[j×[jÐ[jÙØ	�‰ŒØ�
‰
ŒÙr6   c               ó   € V ^8„  d   QhRR/# r-   r1   )r2   s   "r3   r4   r"  …  s   € ÷ ñ ˜Dñ r6   c                ó  € V P                   pVf   R# VP                  e   \        VP                  4      pM›VP                  e   \	        VP                  4      pMwVP
                  '       dd   \        P                  ! 4       VP
                  8  pV'       d9   VP                  ^ 8”  d(   \        V P                  4      pW1P                  8  d   RpMR# V'       d™   VP                  '       d‡   VP
                  R8X  dv   \        P                  ! 4       VP                  ,
          \        8”  dG   \        P                  RV P                  VP                  ;'       g    VP                  \        4       RpV'       g   V P                  4        V# )as  True iff a barrier is set AND not yet satisfied. A satisfied barrier is cleared here
(lazy auto-clear) so the next evaluation resumes normal judging. A pid/session barrier
also expires after ``_MAX_BARRIER_WAIT_S``: a watcher or poller that never exits would
otherwise park the goal indefinitely (one run sat 3 h 22 min on a poller that outlived
the work it was polling).FrÓ   z:goal %s: wait barrier on %s exceeded %ds; resuming judging)r$  rÞ   rm  rÝ   rf  rß   rC  rà   rò  r  râ   Ú_MAX_BARRIER_WAIT_Sr  ræ  rÑ  )r?   rö   ÚstillÚlives   &   r3   Ú
is_waitingÚGoalManager.is_waiting…  s  € ð �K‰KˆØŠ9ÙØ×ÑÒ+Ü$ Q×%9Ñ%9Ó:‰EØ×ÑÒ)Ü˜q×/Ñ/Ó0‰EØ�_�_ˆ_Ü—I’I“K !§/¡/Ñ1ˆEß˜×1Ñ1°AÔ5ä/°·±Ó@�Ø×2Ñ2Ô2Ø!�Eøáß�Q—_—_�_¨¯©¸CÔ)?ÄDÇIÂIÃKÐRS×RaÑRaÕDaÔdwÔDwÜ�K‰KÐTØŸ™¨×)=Ñ)=×)QÐ)QÀ×AQÑAQÔSfôhàˆEßØ×ÑÔØˆr6   c               ó    € V ^8„  d   QhRRRR/# )r.   rJ  rÎ   r/   r—   r1   )r2   s   "r3   r4   r"  ¥  s   € ÷ vñ v yð v°^ñ vr6   c                	óJ  € VP                   e   RVP                    2pMZVP                  e   RVP                   2pM<\        ^ \        VP                  \
        P
                  ! 4       ,
          4      4       R2pVP                  ;'       g    Tp\        RRR RVRV RV 24      # )	Nr@  rB  zs remainingrÏ   FÚwaitingu   â�³ Goal parked â€” waiting on r[   )rÞ   rÝ   rÀ   r�   rß   rC  rá   r  )r?   rJ  ÚtgtrS  s   &&  r3   Ú_waiting_decisionÚGoalManager._waiting_decision¥  s¥   € Ø×#Ñ#Ò/Ø˜U×5Ñ5Ð6Ð7‰CØ×!Ñ!Ò-Ø˜×-Ñ-Ð.Ð/‰Cä˜œC × 3Ñ 3´d·i²i³kÕ AÓBÓCÐDÀKÐPˆCØ×%Ñ%×,Ð,¨ˆÜ˜ 5¨$°	¸6ÐEdÐehÐdiÐikÐlrÐksÐCtÓuÐur6   rË  c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r.   rë  r—   rS  r+   rË  r�   r/   rM   r1   )r2   s   "r3   r4   r"  ¯  s4   € ÷ {ñ {°Nð {ÈCð {Ðhkð {ð  uMñ {r6   c               ó   € VP                  R4      '       d2   RV P                  \        VR,          4      VR7      P                   2pMyVP                  R4      '       d4   \	        VR,          4      p RV P                  WRR7      P                   2pM/V P                  \	        VR,          4      W#R	7       VR,           R
2p\        RRRRVRV RV 24      #   \         d    \        P                  RT4        R# i ; i)zåJudge said WAIT: set the barrier and park. The counted turn stands (the judge ran) but no
continuation fires; the loop resumes once the barrier clears. ``None`` = the barrier is
unobservable here, so the caller continues instead.r  r@  ©rS  r`  rB  z@goal judge: wait_on_pid %s is not alive on this host; continuingNrž  )rS  rË  rö   rÏ   Fr.  u'   â�³ Goal parked (judge) â€” waiting on r[   )rQ   r™  r+   rÞ   r�   rÆ  rÝ   r•  r  ræ  r�  r  )r?   rë  rS  rË  rÝ  r`  s   &&&$  r3   Ú_apply_wait_directiveÚ!GoalManager._apply_wait_directive¯  s  € ð ×Ñ˜l×+Ò+Ø˜T×1Ñ1´#°nÀ\Õ6RÓ2SÐ\bÐ1Óc×vÑvÐwÐx‰CØ×Ñ ×&Ò&Ü�n UÕ+Ó,ˆCðØ˜TŸ\™\¨#˜\Ó=×LÑLÐMÐN‘ð ×!Ñ!¤# n°YÕ&?Ó"@ÈÐ!ÔsØ# IÕ.Ð/¨qÐ1ˆCÜ˜ 5¨$°¸ÐBiÐjmÐinÐnpÐqwÐpxÐ@yÓzÐzøô ô ô
 —‘Ð^Ð`cÔdÚðús   Á3C Ã!C=Ã<C=c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r.   rJ  rÎ   r�  r+   rS  Únoter/   r—   r1   )r2   s   "r3   r4   r"  Å  s0   € ÷ 
ñ 
 9ð 
°sð 
ÀCð 
Èsð 
Ð\jñ 
r6   c                	óš   € V P                  R VP                   RVP                   R2W#RVP                   RVP                   RV R24      # )zturn budget exhausted (r?  r‡  u   â�¸ Goal paused â€” z turns usedz9. Use /goal resume to keep going, or /goal clear to stop.)rd  rÑ   rÒ   )r?   rJ  r�  rS  ræ  s   &&&&&r3   Ú_budget_pauseÚGoalManager._budget_pauseÅ  sc   € Ø×#Ñ#Ø% e×&6Ñ&6Ð%7°q¸¿¹Ð8IÈÐKÈWØ" 5×#3Ñ#3Ð"4°A°e·o±oÐ5FÀkÐRVÐQWð XFð Fó
ð 	
r6   Úuser_initiatedr¨  c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r.   rÍ  r+   rê  r0   r¨  r©  rË  r�   r/   r—   r1   )r2   s   "r3   r4   r"  Ì  s?   € ÷ T
ñ T
Ø ðT
Ø59ðT
à<ðT
ð  ðT
ð 
ñ	T
r6   c               ó„  € V P                   pVe   VP                  R8w  d%   \        V'       d   VP                  MRRRRRR4      # V P                  4       '       d   V P	                  V4      # V;P
                  ^,          un        \        P                  ! 4       Vn        V P                  4       pVeZ   VP                  R4      '       dA   VP
                  VP                  8¼  d&   V P                  VRVP                  R	R4      R
R7      # V# \        VP                  YP                  ;'       g    RTVP                  4       '       d   VP                   MRVR7      w  rxršpWun        W…n        V	'       d   VP&                  ^,           M^ Vn        V'       d   VP(                  ^,           M^ Vn        VR8X  d"   V
'       d   V P+                  W¨VR7      pVe   V# VR8X  d   V P-                  RV 2RVRV R24      # VR8X  d+   RVn        V P/                  4        \        RRRRVRV 24      # VP(                  VP&                  ríV\0        8¼  d9   V P-                  RV R2RVRV R2\2        P5                  RRR7      ,           4      # V\6        8¼  d9   V P-                  RV R2RVRV R 2\2        P5                  R!R"R7      ,           4      # VP
                  VP                  8¼  d   V P                  VRV4      # V P/                  4        \        RR#V P9                  4       RVR$VP
                   R%VP                   R&V 24      # )'u  Run gates + judge and update state. Return a decision dict (``status``, ``should_continue``,
``continuation_prompt``, ``verdict``, ``reason``, ``message``). Both real user prompts and our
own continuations increment ``turns_used`` â€” both consume model budget.NrÏ   FÚinactiverU  r*   r  rµ  rS  z" (a quality gate is still failing))ræ  )r€   r¨  r}   rË  r.  )rË  r'   zjudged unachievable: u*   ðŸš« Goal judged unachievable â€” paused: z8 Re-scope with /goal set, or override with /goal resume.r   u   âœ“ Goal achieved: zjudge API unreachable zH turns in a row (check auxiliary.goal_judge provider/key in config.yaml)rŽ  u/   â�¸ Goal paused â€” judge API returned errors (z. turns). Check the goal_judge provider/key in Údeepseekzdeepseek-flash)ÚproviderÚmodelz(judge model returned unparseable output z turns in a rowu%   â�¸ Goal paused â€” the judge model (zZ turns) isn't returning the required JSON verdict. Route the judge to a stricter model in Ú
openrouterzgoogle/gemini-3-flash-previewTu   â†» Continuing toward goal (r?  rA  )r$  rÐ   r  rØ  rÞ  rÑ   rC  rÖ   r½  rQ   rÒ   rè  rì  r   r€   rü   r}   r×   rØ   rÚ   rÛ   rã  rd  rP  Ú*DEFAULT_MAX_CONSECUTIVE_TRANSPORT_FAILURESÚ_JUDGE_CONFIG_HINTr2   Ú&DEFAULT_MAX_CONSECUTIVE_PARSE_FAILURESÚnext_continuation_prompt)r?   rÍ  rê  r¨  rË  rJ  Úgate_decisionr�  rS  rê  rë  Útransport_failedÚparkedÚn_txÚn_parses   &&$$$          r3   Úevaluate_after_turnÚGoalManager.evaluate_after_turnÌ  sO  € ð —‘ˆØŠ=˜EŸL™L¨HÔ4Ü¯U˜UŸ\š\¸¸eÀTÈ:ÐWgÐikÓlÐlð �?‰?×ÒØ×)Ñ)¨%Ó0Ð0à×Ò˜AÕÕÜ!ŸYšY›[ˆÔð ×)Ñ)Ó+ˆØÒ$Ø× Ñ Ð!2×3Ò3¸×8HÑ8HÈEÏOÉOÔ8[Ø×)Ñ)¨%°À×@QÑ@QÐRZÐ\^Ó@_ð  gKÐ)ó  Lð  LØ Ð äJTØ�J‰J˜·±×0FÐ0FÀ$Ð]qØ',×'9Ñ'9×';Ò';�U—^’^ÀÐZlôK
ÑGˆ˜Ð7Gð %ÔØ"Ô÷ T`¨5×+KÑ+KÈaÖ+OÐefˆÔ(ß[k¨u×/SÑ/SÐVWÖ/WÐqrˆÔ,à�fÔ§Ø×/Ñ/°Ð[mÐ/ÓnˆFØÒ!Ø�ð �iÔØ×'Ñ'Ø'¨ xÐ0°)¸VØ<¸V¸HÐD|Ð}óð ð
 �fÔØ!ˆEŒLØ�J‰JŒLÜ˜V U¨D°&¸&ÐDWÐX^ÐW_ÐB`ÓaÐað ×<Ñ<¸e×>^Ñ>^ˆgØÔ=Ô=Ø×'Ñ'Ø(¨¨Ð.vÐwØ˜FØAÀ$ÀÐGuÐvÜ$×+Ñ+°ZÐGWÐ+ÓXõYóð ð Ô<Ô<Ø×'Ñ'Ø:¸7¸)À?ÐSÐU_ÐagØ7¸°yð A:ð :ä$×+Ñ+°\ÐIhÐ+Óiõjóð ð ×Ñ˜uŸ™Ô.Ø×%Ñ% e¨Z¸Ó@Ð@à�
‰
ŒÜØ�d˜D×9Ñ9Ó;¸ZÈØ*¨5×+;Ñ+;Ð*<¸A¸e¿o¹oÐ=NÈcÐRXÐQYÐZó
ð 	
r6   c               ó   € V ^8„  d   QhRR/# )r.   r/   r®   r1   )r2   s   "r3   r4   r"  "  s   € ÷ @ñ @¨-ñ @r6   c                	ó  € V P                   pV'       d   VP                  R 8w  d   R# VP                  4       '       dh   VP                  P	                  4       pVP
                  '       d   V R\        VP
                  4       2p\        P                  VP                  VR7      # VP
                  '       d0   \        P                  VP                  VP                  4       R7      # \        P                  VP                  R7      # )rÏ   NrX   )r   r×  )r   rÚ  )r   )r$  rÐ   rü   r}   r_   r€   r‹   Ú*CONTINUATION_PROMPT_WITH_CONTRACT_TEMPLATEr2   r   Ú*CONTINUATION_PROMPT_WITH_SUBGOALS_TEMPLATEr  ÚCONTINUATION_PROMPT_TEMPLATE)r?   rö   r×  s   &  r3   rõ  Ú$GoalManager.next_continuation_prompt"  sÀ   € Ø�K‰Kˆß�A—H‘H Ô(Ùà�>‰>×ÒØŸZ™Z×4Ñ4Ó6ˆNØ�z�zˆzØ$2Ð#3°2Ô6LÈQÏZÉZÓ6XÐ5YÐ!Z�Ü=×DÑDÈ!Ï&É&ÐaoÐDÓpÐpØ�:�:ˆ:Ü=×DÑDÈ!Ï&É&Ðab×axÑaxÓazÐDÓ{Ð{Ü+×2Ñ2¸¿¹Ð2Ó?Ð?r6   c               ó   € V ^8„  d   QhRR/# rV   r1   )r2   s   "r3   r4   r"  0  s   € ÷ nñ n ñ nr6   c                ó®   € V P                   f   R# V P                   P                  4       '       d%   V P                   P                  P                  4       # R# )z>Public helper for the /goal show + /goal draft slash commands.r   u^   (no completion contract â€” set one with /goal draft <objective> or inline field: value lines))r$  rü   r}   r_   rD   s   &r3   Úrender_contractÚGoalManager.render_contract0  sF   € à�;‰;ÒÙ%Ø6:·k±k×6NÑ6N×6PÒ6Pˆt�{‰{×#Ñ#×0Ñ0Ó2ð 	nØlð	nr6   )r$  r   r  )zuser-paused)r*   )1ra   rb   rc   rd   re   rð   r%  r)  ÚpropertyrJ  r3  r8  rü   rL  rP  rV  rZ  r`  rd  r  rk  ro  rt  rx  r|  r€  r‹  r‘  r—  rœ  r¡  r¥  r©  r­  r±  r½  rÂ  rÆ  r™  r�  rÑ  rØ  rÞ  rã  rè  rû  rõ  r  rh   r1   r6   r3   rL  rL  A  s\  † ñðAÐDU÷ Aõ
1ð ôó ðõJõVõFõ6õ8õõ
õ
õ
Jð	¸4ð 	Ðdh÷ 	õ÷ð¨T÷ õõõõõõ8õ-õnðÈð Ðlp÷ õ=õ*õ õ 5õr÷	6÷Añ
{ÐXY÷ 
{ð 
{õõõ@vð{Ðno÷ {÷,
ðT
Ø<@ðT
à?CðT
ð #$÷T
õl@÷nñ nr6   rL  uÌ  [Continuing toward this kanban task â€” judge says it is not done yet]
Reason: {reason}

Take the next concrete step toward completing the task. When the work is genuinely finished, call kanban_complete with a summary. If it is a code change that needs same-card review before counting as done, call kanban_request_review with a summary instead. If you are blocked and need human input, call kanban_block with a reason. Do not stop without calling one of them.a^  [The work looks complete, but the task is still open]
Reason: {reason}

If the task is genuinely done, call kanban_complete now with a short summary of what you did. If it is a code change awaiting same-card review, call kanban_request_review with that summary instead. If something still blocks completion, call kanban_block with the reason instead.ÚreviewÚchanges_requestedrÒ   Úfirst_responseÚlogc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r.   r  r+   Ú	goal_textrÒ   r�   r
  r/   r—   r1   )r2   s   "r3   r4   r4   ^  sC   € ÷ {ñ {àð{ð ð{ð ð{ð ð{ð ñ{r6   c                ó¾  aaaa€ R V3R lloR VV3R llpR V3R llp	\        T;'       g    \        4      pV^8  d   \        pT;'       g    Rp
^oRp  V! 4       p\        P	                  T4      pTe0   Tw  pppS! RTP                  T SR7      ,           4       T	! TT4      # TR;9  d   S! RT  RT: R24       T	! RRT 24      # ^ RIHpHpH	p T! 4       '       d   RM
T! RT  24      p \        Y4      w  pppppTe	   T! T4       T'       d   S! RS R24       T	! RR4      # TR8X  d   RpS! RS RT RT R\        T^x4       24       TR8X  d$   S! RT  R 24       T! R!T 24       T	! R"R#T 24      # TR$8X  dM   T'       d"   S! RT  R%24       T! R&T R'24       T	! R(R)4      # \        P                  \        TR*4      R+7      pR	pM \        P                  \        TR*4      R+7      pST8¼  d7   S! RT  R,S RT R-24       T! R.S RT R/\        TR04       24       T	! R(R14      #  T! T4      p\        T\        4      '       dT   TP	                  R2R4      ;'       g    Rp
\!        TP	                  R3R4      4      pTP	                  R44      ;'       g    R5pMT;'       g    Rp
RpRp T'       d   S! R8S R9T R24       T	! RR:T 24      # S^,          oEK†    \         d    pS! R
T R24       T	! RR4      u Rp?# Rp?ii ; i  Te
   T! T4       i i ; i  \         d6   pS! R6T R24       T	! RR7\#        T4      P$                   24      u Rp?# Rp?ii ; i)<a‹  Drive a kanban worker through a Ralph-style goal loop.

Each iteration: stop if the worker already terminated the task (``kanban_complete`` /
``kanban_block`` / review hand-off); otherwise judge the latest response against ``goal_text``
(the card's title + body) and feed a continuation or finalize nudge. A WAIT verdict is treated
as CONTINUE (workers finish via kanban tools, not by parking).
c               ó    € V ^8„  d   QhRRRR/# )r.   r  r+   r/   r  r1   )r2   s   "r3   r4   Ú*run_kanban_goal_loop.<locals>.__annotate__q  s   € ÷ ñ �#ð ˜$ñ r6   c                óJ   <€ Se    S! V 4       R # R #   \          d     R # i ; ir9   ©rÆ   )r  r  s   &€r3   Ú_logÚ"run_kanban_goal_loop.<locals>._logq  s-   ø€ ØŠ?ðÙ�C–ñ øô ô Úðús   ‡ “"¡"c               ó    € V ^8„  d   QhRRRR/# )r.   rÇ  r+   r/   r  r1   )r2   s   "r3   r4   r  x  s   € ÷ ?ñ ?˜ð ? ñ ?r6   c                ód   <€  S! V 4       R#   \          d   pS! R T R24        Rp?R# Rp?ii ; i)z#kanban goal loop: block_fn failed (r‡  Nr  )rÇ  rÊ   r  Úblock_fns   & €€r3   Ú_blockÚ$run_kanban_goal_loop.<locals>._blockx  s5   ø€ ð	?Ù�WÖøÜô 	?ÙÐ6°s°e¸1Ð=×>Ò>ûð	?ús   ƒ �/˜*ª/c               ó$   € V ^8„  d   QhRRRRRR/# )r.   r   r+   rS  r/   r—   r1   )r2   s   "r3   r4   r  ~  s&   € ÷ Pñ P˜ð P cð P¨nñ Pr6   c                ó   <€ R V RSRV/# )r   rÑ   rS  r1   )r   rS  rÑ   s   &&€r3   Ú_resultÚ%run_kanban_goal_loop.<locals>._result~  s   ø€ Ø˜7 L°*¸hÈÐOÐOr6   r*   FTz'kanban goal loop: status check failed (z); stoppingÚstoppedzstatus check failedNzkanban goal loop: )r  rD  zkanban goal loop: task z status=z
; stoppingzstatus=)Úget_affinity_scopeÚreset_affinity_scopeÚset_affinity_scopezkanban:z1kanban goal loop: judge transport failed on turn zjudge transport failurer.  rŽ  zkanban goal loop: turn r?  z	 verdict=z reason=r'   z judged unachievable; blockingz-Goal-mode judge ruled the goal unachievable: Úblocked_unachievablezjudge verdict blocked: r   z0 judged done but worker won't finalize; blockingzfGoal-mode worker's output looked complete but it never called kanban_complete after a finalize nudge (z).Úblocked_budgetzjudged done, never finalizedró  râ  z exhausted z turns; blockingz,Goal-mode worker exhausted its turn budget (z3) without completing the task. Last judge verdict: r   zturn budget exhaustedrÔ  ÚfailedÚfailure_reasonÚunknownz#kanban goal loop: run_turn failed (zrun_turn error: z(kanban goal loop: worker failed on turn z	 (reason=zworker failed: )r  Úready)r�   rð   rÆ   Ú_KANBAN_TERMINAL_STATUSESrQ   r2   Úagent.portal_tagsr  r   r!  rì  r^  ÚKANBAN_GOAL_FINALIZE_TEMPLATEÚ!KANBAN_GOAL_CONTINUATION_TEMPLATErO   rP   r0   rÇ   ra   ) r  r  Úrun_turnÚtask_status_fnr  rÒ   r
  r  r  r  rÍ  Únudged_to_finalizerÐ   rÊ   Úterminalr   rS  Úlog_fmtr  r   r!  Úaffinity_tokenr�  Ú_parse_failedÚ_waitÚ_transport_failedré  Úresultr$  r%  r  rÑ   s    $$$$d$$d                      @@r3   Úrun_kanban_goal_loopr6  ^  s  û€ ÷&ð ÷?ñ ?÷Pð Pô �I×2Ð2Ô!2Ó3€IØ�1„}Ü%ˆ	à"×(Ð( b€MØ€JØÐà
ð	=Ù#Ó%ˆFô
 -×0Ñ0°Ó8ˆØÒØ'/Ñ$ˆG�V˜WÙÐ%¨¯©¸wÈj¨Ó(YÕYÔZÙ˜7 FÓ+Ð+ØÐ-Ô-áÐ*¨7¨)°8¸F¹:ÀZÐPÔQÙ˜9¨°¨xÐ&8Ó9Ð9çbÑbÙ!3×!5Ò!5™Ñ;MÐPWÐX_ÐW`ÐNaÓ;bˆð	5ÜGQÐR[ÓGkÑDˆG�V˜]¨EÐ3DàÒ)Ù$ ^Ô4ßÙÐDÀZÀLÐPZÐ[Ô\Ù˜9Ð&?Ó@Ð@Ø�fÔØ ˆGÙÐ& z l°!°I°;¸iÈÀyÐPXÔYbÐciÐknÓYoÐXpÐqÔrà�iÔñ Ð*¨7¨)Ð3QÐRÔSÙÐBÀ6À(ÐKÔLÙÐ1Ð5LÈVÈHÐ3UÓVÐVà�fÔß!áÐ.¨w¨iÐ7gÐhÔiÙðFØFLÀXÈRðQôñ Ð/Ð1OÓPÐPÜ2×9Ñ9ÄÈ6ÐSVÓAWÐ9ÓXˆFØ!%Ñä6×=Ñ=ÄYÈvÐWZÓE[Ð=Ó\ˆFð ˜Ô"ÙÐ*¨7¨)°;¸z¸lÈ!ÈIÈ;ÐVfÐgÔhÙðØ�<˜q  ð ,'Ü'0°¸Ó'=Ð&>ð@ôñ
 Ð+Ð-DÓEÐEð	OÙ˜fÓ%ˆFÜ˜&¤$×'Ò'Ø &§
¡
¨:°rÓ :× @Ð @¸b�Ü˜fŸj™j¨°5Ó9Ó:�Ø!'§¡Ð,<Ó!=×!JÐ!JÀ‘ð !'§ ¨"�Ø�Ø!%‘÷ ÙÐ;¸J¸<ÀyÐQ_ÐP`Ð`kÐlÔmÙ˜9¨¸Ð7GÐ&HÓIÐIØ�a�‹
øô[ ô 	=ÙÐ:¸3¸%¸{ÐKÔLÙ˜9Ð&;Ó<Õ<ûð	=ûð& Ò)Ù$ ^Õ4ð *ûôh ô 	OÙÐ6°s°e¸;ÐGÔHÙ˜9Ð(8¼¸c»×9KÑ9KÐ8LÐ&MÓNÕNûð	Oús`   ÁK Ã0L
 È,6L É#5L ÊL ÊL Ê&L ËLË(LË<LÌLÌ
LÌMÌ'*MÍMÍMi  )r   r   r   r   r   r9   )Úcompleted_by_workerzworker completed the taskz8task {task_id} completed by worker after {turns} turn(s))Úblocked_by_workerzworker blocked the taskz6task {task_id} blocked by worker after {turns} turn(s))Úreview_requested_by_workerzworker requested reviewzDtask {task_id} handed off for review by worker after {turns} turn(s))Úchanges_requested_by_reviewerzreviewer requested changeszBreviewer returned task {task_id} for changes after {turns} turn(s))r  rÿ  r   rð   r  rä  râ  rã  r+  r*  r)   r�   rL  rÎ   rR  r  rì  rH  rY  r~   rÌ   r6  rN  )rÚ__conditional_annotations__re   Ú
__future__r   r&  rè   ÚloggingÚosÚrer¾   r*  rC  Údataclassesr   r   r   r   r   r   Úpathlibr	   Útypingr
   r   r   r   r   Úhermes_cli._subprocess_compatr   Úhermes_timer   Ú	getLoggerra   r  rð   r  r{  rÞ  rô  rò  r�   rž   rÕ  rÄ   r  rÿ  r   r¹  rå  rß  r²  rä  rã  râ  r  rC   r\   rp   r)   r~   r‹   r�   rª   rÌ   rÎ   r  r  rf   ÚLockr  r  r)  r-  r  r2  r  r  r%  rC  rH  rN  rR  rY  r^  rf  rm  ÚcompileÚDOTALLr†  rv  r|  r€  r‹  r¦  r¹  rÊ  rì  rò  rý  rû  rü  r   r  r  r  r  r  ró  rL  r+  r*  r(  r6  Ú__all__)r;  s   @r3   Ú<module>rJ     st  øðôõ #ã Û Û Û 	Û 	Û Û Û ß 0Ñ 0ß ,Ñ ,Ý ß 3Õ 3å @Ý %à	×	Ò	˜8Ó	$€ð
 Ð ØÐ ð  Ð à $Ð ð *+Ð &ð ./Ð *ð
  #Ð ØÐ ð Ð àÐ ðPð ð	+ð +ðð +ðDð )ð"9,ð ð~Lð !ð0ð  ðBð ð<ð )ð(^ð )ð4/ð ð4 YÐ ð ˆy˜.¨.¸-ÈØ�, Ð-@ðÐ ð
Øˆyð
Ø  )ð
Ø-3°Yð
Ø@KÈYð
à�Nð
à$,¨nð
à>KÈ^ð
ð �ð
ð !(¨ð
ð �=ð	
ð #/°ð	
ð @JÈ=ð	
ð
 �ð
ð
  /°ð
ð �,ð
ð !+¨Lð
ð ;BÀ<ð
ð ˆ|˜W lØ�˜k¨;¸	À;Ø�{ N°Kñ
Ð ð ÷Gð Gó ðGõ26õ2cð ÷
ð 
ó ð
õ<ð,O°T÷ Oð. ÷L!ð L!ó ðL!õb ð €	ˆ>Ó Ø—^’^Ó%Ð Ø57Ð Ð2Ó 7ð !Ð ð  Ð õõ"=õ@,õõ@õõõ*>õ!ðÐWY÷ õ>Lõõ(
ð —*’*˜Z¨¯©Ó3€õõLõHõ4õ./\õdUõ<ð A@ð  $ð	A@ð
 %)ðA@ð <@ðA@ð (,ðA@ð  ÷A@õHð" rÐ ØÐ ØÐ õõõñÐae÷ ð ð,5À÷ 5õDFð%ð ÷tnñ tnðxð "ðDð ð Ð|ØÐyàð  PØð  _ðÐ ð{ð 'ð{ð ð{ð 	÷{ò|‚r6   