
    yj#                        d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZ  G d d	ee          Z G d
 de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )zInternal schemas used by the deriver, dreamer, and other background systems.

These are not part of the public API contract and may change without notice.
    )Enum)	AnnotatedLiteralSelf)	BaseModelFieldfield_validatormodel_validator)MessageCreate)SessionPeerConfig)DocumentLevelc                       e Zd ZdZdZdZdS )ReconcilerTypez0Types of reconciler tasks that can be performed.sync_vectorscleanup_queueN)__name__
__module____qualname____doc__SYNC_VECTORSCLEANUP_QUEUE     </DATA/AppData/hermes/projects/honcho/src/schemas/internal.pyr   r      s        ::!L#MMMr   r   c                       e Zd ZdS )DocumentBaseN)r   r   r   r   r   r   r   r      s        Dr   r   c                   V   e Zd ZU  ed          Zee         ed<    ed          Ze	ed<    edd          Z
ee	         dz  ed	<    edd
          Zee	         dz  ed<    edd          Zee	         dz  ed<    edd          Ze	dz  ed<    edd          Ze	dz  ed<   dS )DocumentMetadataa  The ID range(s) of the messages that this document was derived from. Acts as a link to the primary source of the document. Note that as a document gets deduplicated, additional ranges will be added, because the same document could be derived from completely separate message ranges.)descriptionmessage_idszThe timestamp of the message that this document was derived from. Note that this is not the same as the created_at timestamp of the document. This timestamp is usually only saved with second-level precision.message_created_atNzeDocument IDs of source documents for tree traversal -- required for deductive and inductive documentsdefaultr   
source_idszRHuman-readable premise text for display -- only applicable for deductive documentspremiseszQHuman-readable source text for display -- only applicable for inductive documentssourceszType of pattern identified (preference, behavior, personality, tendency, correlation) -- only applicable for inductive documentspattern_typezOConfidence level (high, medium, low) -- only applicable for inductive documents
confidence)r   r   r   r   r    listint__annotations__r!   strr$   r%   r&   r'   r(   r   r   r   r   r       s        "U q  Kc    $e f      $)5{$ $ $JS	D     "'h" " "Hd3i$    !&g! ! !GT#Y     %u W     L#*    #Ue  Jd
     r   r   c                   2   e Zd ZU ee edd          f         ed<    edd          Zedz  ed<    ed	d
          Ze	ed<    eddd          Z
eed<    e            Zeed<    e            Zee         ed<    edd          Zee         dz  ed<   dS )DocumentCreate   i )
min_length
max_lengthcontentNzNThe session from which the document was derived (NULL for global observations)r"   session_nameexplicitzLThe level of the document (explicit, deductive, inductive, or contradiction)levelzSThe number of times that a semantic duplicate document to this one has been derived)r#   ger   times_derivedmetadata	embeddingzQDocument IDs of source/premise documents -- for deductive and inductive documentsr$   )r   r   r   r   r,   r   r+   r3   r5   r   r7   r*   r8   r   r9   r)   floatr$   r   r   r   r.   r.   =   s6        sEEQ6BBBBCCCC$ud     L#*    !5b  E=    i  M3   
 "'H((("UWWItE{$$$#(5g$ $ $JS	D      r   r.   c                   f   e Zd ZU dZee ed          f         ed<   dZe	ed<   dZ
ee         dz  ed<   dZee         dz  ed	<   dZee         dz  ed
<   dZed         dz  ed<   dZed         dz  ed<    edd          ededefd                        Z ed          defd            ZdS )ObservationInputz0Validated observation input from LLM tool calls.r/   )r0   r2   r4   r5   Nr$   r%   r&   )
preferencebehaviorpersonalitytendencycorrelationr'   )highmediumlowr(   after)modevreturnc                 .    |                     dd          S )N  )replace)clsrG   s     r   sanitize_contentz!ObservationInput.sanitize_contentc   s     yy$$$r   c                     | j         dk    r| j        st          d          | j         dk    r| j        st          d          | j         dk    r.| j        rt          | j                  dk     rt          d          | S )z>Validate that level-specific fields are present when required.	deductivezOdeductive observations require 'source_ids' field with document IDs of premises	inductivezNinductive observations require 'source_ids' field with document IDs of sourcescontradiction   zgcontradiction observations require 'source_ids' field with at least 2 IDs of contradicting observations)r5   r$   
ValueErrorlen)selfs    r   validate_level_fieldsz&ObservationInput.validate_level_fieldsh   s     :$$T_$a   :$$T_$`   :(( )#&t#7#7!#;#;y   r   )r   r   r   r   r   r,   r   r+   r5   r   r$   r)   r%   r&   r'   r   r(   r	   classmethodrN   r
   r   rW   r   r   r   r<   r<   U   s\        ::sEEQ////0000%E=%%%#'JS	D '''!%Hd3i$%%% $GT#Y$$$ 	 RS
	   ;?J/047>>>_YW---% % % % % [ .-% _'"""t    #"  r   r<   c                   2    e Zd ZU dZeed<   eed<   eed<   dS )SessionCountsz2Counts for a specific session in queue processing.	completedin_progresspendingN)r   r   r   r   r*   r+   r   r   r   rZ   rZ      s4         <<NNNLLLLLr   rZ   c                   V    e Zd ZU dZeed<   eed<   eed<   eed<   eeef         ed<   dS )QueueCountsz.Aggregated counts for queue processing status.totalr[   r\   r]   sessionsN)	r   r   r   r   r*   r+   dictr,   rZ   r   r   r   r_   r_      sU         88JJJNNNLLL3%&&&&&&r   r_   c                   t    e Zd ZU dZedz  ed<   eed<   eed<   eed<   eed<   eed<   eed	<   eed
<   eed<   dS )QueueStatusRowz8Represents a row from the queue status SQL query result.N
session_idr`   r[   r\   r]   session_totalsession_completedsession_in_progresssession_pending)r   r   r   r   r,   r+   r*   r   r   r   rd   rd      s         BBd
JJJNNNLLLr   rd   c                   .    e Zd ZU dZeeef         ed<   dS )SessionPeerDataz-Data for managing session peer relationships.
peer_namesN)r   r   r   r   rb   r,   r   r+   r   r   r   rk   rk      s/         77S++,,,,,,r   rk   c                   >    e Zd ZU dZee         ed<   eed<   eed<   dS )MessageBulkDataz!Data for bulk message operations.messagesr3   workspace_nameN)r   r   r   r   r)   r   r+   r,   r   r   r   rn   rn      sA         ++=!!!!r   rn   N)r   enumr   typingr   r   r   pydanticr   r   r	   r
   src.schemas.apir   src.schemas.configurationr   src.utils.typesr   r,   r   r   r   r.   r<   rZ   r_   rd   rk   rn   r   r   r   <module>rw      sL   
       + + + + + + + + + + G G G G G G G G G G G G ) ) ) ) ) ) 7 7 7 7 7 7 ) ) ) ) ) )$ $ $ $ $S$ $ $ $	 	 	 	 	9 	 	 	    y   :    \   0$ $ $ $ $y $ $ $X    I   ' ' ' ' ') ' ' '    Y   &- - - - -i - - -    i     r   