+
    „WÝjg  ã                  óö   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
 RRRRR	R
RR
R]P                  RRR^RR/R R llt]P                  RR
/R R ll4       tR R lt]P                  R R l4       tR# )uÍ  Shared SQLite primitives for the small per-profile / board stores.

``open_db`` is the one connect + PRAGMA stack; ``transaction`` is the one commit-and-ALWAYS-close
shape. Every hand-rolled ``_connect``/``_transaction`` pair used to re-carry the #69567 fix (a
``with conn:`` only commits â€” it never closes, so each call leaked a connection and its WAL/SHM fds
until GC, exhausting ``RLIMIT_NOFILE`` on long-running gateways) and at least one copy missed it.
)ÚannotationsN)ÚPath)ÚCallableÚIteratorÚbusy_timeout_msiˆ  ÚwalTÚforeign_keysFÚsynchronous_fullÚrow_factoryÚcheck_same_threadÚwal_lock_retriesÚ
initializec               ó@   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRR/
# )é   Úpathz
Path | strÚdb_labelÚstrr   Úintr   Úboolr   r	   r   r   r   z+Callable[[sqlite3.Connection], None] | NoneÚreturnúsqlite3.Connection© )Úformats   "ÚJC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\sqlite_util.pyÚ__annotate__r      sn   € ÷ 1ñ 1Ø
ð1ð ð1ð ð	1ð
 
ð1ð ð1ð ð1ð ð1ð ð1ð <ð1ð ñ1ó    c       	        óÔ  € ^ RI Hp
 \        V 4      p V P                  P	                  RRR7       \
        P                  ! WR,          VR7      p Wkn        VP                  R\        V4       24       V'       d   \        V4       F  p V
! W±R7        M	  V'       d   VP                  R4       V'       d   VP                  R4       V	e	   V	! V4       V#   \
        P                   d]   p\        T4      P                  4       R8w  g   T^,           T8X  d   h \        P                  ! R	^T,          ,          4        R
p?K½  R
p?ii ; i  \          d    TP#                  4        h i ; i)u­  Open ``path`` (parent created), apply the PRAGMA set, run ``initialize``; closed if anything raises.

``busy_timeout_ms`` is the single busy knob: it is passed as ``connect(timeout=)`` AND set as the
explicit PRAGMA so it is observable. ``wal=True`` goes through ``apply_wal_with_fallback`` â€” the
only journal-mode setter that carries the WAL-reset-bug gate, the network-FS silent-refusal
fallback and the never-live-downgrade invariant; a raw ``PRAGMA journal_mode=WAL`` bypasses all
three. Only the transient ``database is locked`` from that pragma is retried (``wal_lock_retries``):
a first opener initializing a shared DB can make it ignore the busy timeout, notably on Windows.
)Úapply_wal_with_fallbackT)ÚparentsÚexist_okiè  )Útimeoutr   zPRAGMA busy_timeout=)r   zdatabase is lockedg{®Gáz„?NzPRAGMA foreign_keys=ONzPRAGMA synchronous=FULL)Úhermes_state_walr   r   ÚparentÚmkdirÚsqlite3Úconnectr
   Úexecuter   ÚrangeÚOperationalErrorr   ÚlowerÚtimeÚsleepÚBaseExceptionÚclose)r   r   r   r   r   r	   r
   r   r   r   r   ÚconnÚattemptÚexcs   &$$$$$$$$$    r   Úopen_dbr1      s+  € õ, 9ä�‹:€DØ‡K�K×Ñ˜d¨TÐÔ2ä�?Š?˜4¸4Õ)?ÐSdÔe€DðØ&ÔØ�‰Ð+¬C°Ó,@Ð+AÐBÔCßÜ Ð!1Ö2�ð4Ù+¨DÕDÙñ 3÷ Ø�L‰LÐ1Ô2ßØ�L‰LÐ2Ô3ØÒ!Ù�tÔð €Køô ×/Ñ/ô 4Ü˜3“x—~‘~Ó'Ð+?Ô?À7ÈQÅ;ÐRbÔCbØÜ—J’J˜t q¨'¥zÕ2×3Ò3ûð4ûô ô Ø�
‰
ŒØðúsC   Á9E
 Â		CÂE
 ÂE
 Â7E
 ÃEÃ+AEÄ<E
 ÅEÅE
 Å
E'Ú	immediatec               ó$   € V ^8„  d   QhRRRRRR/# )r   r.   r   r2   r   r   zIterator[sqlite3.Connection]r   )r   s   "r   r   r   G   s#   € ÷ ñ Ð(ð ¸ð ÐIeñ r   c             #  óà   "  €  V'       d   V P                  R4       V ;_uu_ 4        V x € RRR4       V P                  4        R#   + '       g   i     L"; i  T P                  4        i ; i5i)z\Commit on success, roll back on error, and ALWAYS close ``conn`` (see the module docstring).úBEGIN IMMEDIATEN)r&   r-   )r.   r2   s   &$r   Útransactionr6   F   sG   é € ðßØ�L‰LÐ*Ô+ßŠTØŠJ÷ ð 	�
‰
Ž÷ �Tûð 	�
‰
�üs1   ‚A.„#A §A¬A ´A.ÁA	ÁA ÁA+Á+A.c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r.   r   Útabler   ÚcolumnÚddlr   r   r   )r   s   "r   r   r   R   s2   € ÷ ñ Ð 2ð ¸3ð Èð ÐRUð ÐZ^ñ r   c                óº   €  V P                  RV RV 24       R#   \        P                   d+   pR\        T4      P	                  4       9   d    Rp?R# h Rp?ii ; i)a  ``ALTER TABLE <table> ADD COLUMN <ddl>``, idempotent across races: True when this call added
it, False on the ``duplicate column name`` a concurrent migrator caused.

``column`` is the human-readable name for the call site; ``ddl`` carries the actual definition. See
#21708.
zALTER TABLE z ADD COLUMN Tzduplicate column nameNF)r&   r$   r(   r   r)   )r.   r8   r9   r:   r0   s   &&&& r   Úadd_column_if_missingr<   R   sR   € ðØ�‰�| E 7¨,°s°eÐ<Ô=ÙøÜ×#Ñ#ô Ø"¤c¨#£h§n¡nÓ&6Ô6ÝØûðús   ‚ ›A°AÁAÁAc               ó   € V ^8„  d   QhRR/# )r   r.   r   r   )r   s   "r   r   r   c   s   € ÷ ñ Ð&ñ r   c              #  óÖ   "  € V P                  R4        V x € V P                  R4       R#   \         d0     T P                  R4       h   \        P                   d     h i ; ii ; i5i)zÞAn IMMEDIATE write transaction on a long-lived connection (stays open). The explicit ROLLBACK is
guarded so a SQLite auto-rollback (no transaction left under EIO / contention / corruption) cannot
shadow the original error.r5   ÚCOMMITÚROLLBACKN)r&   Ú	Exceptionr$   r(   )r.   s   &r   Ú	write_txnrB   b   so   é € ð
 	‡L�LÐ"Ô#ð	ØŠ
ð 	�‰�XÖøô ô ð	Ø�L‰L˜Ô$ð 	øô ×'Ñ'ô 	ØØð	úðüs<   ‚A)•, ™A)¬A&¸A
Á	A&Á
A"ÁA&Á!A"Á"A&Á&A))Ú__doc__Ú
__future__r   Ú
contextlibr$   r*   Úpathlibr   Útypingr   r   ÚRowr1   Úcontextmanagerr6   r<   rB   r   r   r   Ú<module>rJ      s¹   ðñõ #ã Û Û Ý ß %ð1ð  ð	1ð
 ð1ð ð1ð #ð1ð —‘ð1ð #ð1ð ð1ð ?C÷1ðh ×Ñð¸uö ó ðõð  ×Ñôó òr   