Ë
    ÛJêjê«  ã            	      ó¨  — U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlZdd	lmZ dd
lmZ ddlmZ ddlmZmZmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z* ddl+m,Z, dZ-de.d<   dZ/de.d<   dZ0de.d<   dZ1de.d<   dZ2de.d<   dZ3de.d<   d Z4de.d!<   d"Z5de.d#<   e G d$„ d%«      «       Z6e G d&„ d'«      «       Z7 G d(„ d)e«      Z8dUd*„Z9dVd+„Z:dWd,„Z;dWd-„Z<dWd.„Z=dXd/„Z>dYd0„Z?dZd1„Z@d[d2„ZAdWd3„ZBdWd4„ZCd\d5„ZDdXd6„ZEdWd7„ZFdWd8„ZGd]d9„ZHd^d:„ZId_d;„ZJdWd<„ZKddd=œ	 	 	 	 	 d`d>„ZLddd=œ	 	 	 	 	 dad?„ZMd@dAœdbdB„ZN ejž                  dCdDdE¬F«      ZPePj£                  dG«       ej¤                  ddHdI¬J«       ej¤                  ddKdL¬J«       ej¤                  d@dMdN¬J«       ej¤                  d@dOdP¬J«      f	 	 	 	 	 	 	 	 	 dcdQ„«       ZSePj£                  dR«       ej¤                  ddHdI¬J«       ej¤                  ddKdL¬J«       ej¤                  d@dMdN¬J«       ej¤                  d@dOdP¬J«      f	 	 	 	 	 	 	 	 	 dcdS„«       ZTg dT¢ZUy)dat  Read-only diagnostics for the local CyberBrain26 installation.

``cyberbrain doctor`` reports the effective configuration and the Bubblewrap
prerequisites of the supported local prototype. This module is strictly
read-only:

- it creates no directory and no database;
- it never migrates, prunes, or otherwise modifies existing local state;
- it never changes the policy mode and never offers to change it;
- it performs, requests, or approves no action of any kind;
- it does not evaluate or execute any agent request, and it does not start a
  sandbox in order to test it.

SECRETS RULE: values of environment variables are never printed, logged, or
serialized. Only *presence* flags (``True``/``False``) for a short list of
conventional credential variable names are reported, and those flags are
advisory only. No provider key and no endpoint value leaves this module.

Honesty rule: the quality gates executed here are *configuration self-reports*
produced by the installation itself, not verified security evidence. Several
gate checks (notably ``no_hardcoded_secrets`` in the security gate and
``default_deny_policy`` in the architecture gate) always report ``pass``
without inspecting anything, and the agent-related security checks are skipped
when no agents are supplied. The rendered output states this explicitly.

One unavoidable SQLite side effect is documented rather than hidden: opening an
existing WAL-mode store read-only can create or touch the ``-wal`` and ``-shm``
sidecar files. No schema, row, journal mode, or file permission is changed, and
a store that does not exist is never created.

The policy mode is only ever REPORTED here. SAFE remains the default and the
supported mode for a local installation; any other mode is reported as a hard
failure. No environment variable, configuration file, or CLI flag can switch
the mode, and this module deliberately offers no such switch.
é    )ÚannotationsN)ÚIterator)Úcontextmanager)Ú	dataclassÚfield)ÚPath)ÚAny)Ú__version__)ÚSQLiteDatabase)ÚBubblewrapExecutionProvider)ÚDEFAULT_RETENTION_DAYSÚENV_WORKSPACES_ROOTÚresolve_data_dirÚresolve_db_pathÚretention_days_from_envÚworkspaces_root)ÚApprovalManager)ÚAgentIdentityÚ
TrustLevel)ÚPolicyEngineÚ
PolicyMode)ÚQualityGateRunner)	ÚOPENAI_API_KEYÚANTHROPIC_API_KEYÚGEMINI_API_KEYÚMISTRAL_API_KEYÚCOHERE_API_KEYÚGROQ_API_KEYÚOPENROUTER_API_KEYÚLITELLM_API_KEYÚLITELLM_MASTER_KEYztuple[str, ...]Ú_CREDENTIAL_ENV_NAMES)é   é   ztuple[int, int]ÚMIN_PYTHON_VERSIONÚbwrapÚstrÚBUBBLEWRAP_BINARYi€  ÚintÚEXPECTED_DB_FILE_MODEiÀ  ÚEXPECTED_DATA_DIR_MODEÚEXPECTED_WORKSPACES_ROOT_MODEz Environment variable values are never printed: this report contains only presence flags (true/false) for a short list of conventional credential variable names.ÚSECRETS_NOTE)
zeCyberBrain26 is a tested local Python prototype, not a production-ready or security-certified system.a  Quality gate results are configuration self-reports by the installation, not verified security evidence: the security gate check 'no_hardcoded_secrets' always passes without inspecting any file and the architecture gate check 'default_deny_policy' always passes.z‰RLIMIT_AS, RLIMIT_CPU and RLIMIT_FSIZE are cooperative resource limits of the child process and are NOT enforcement against hostile code.z•The sandbox applies no cgroup or process-count limit and no disk or inode quota, so process forking inside the sandbox is not bounded by the sandbox.ai  A writable workspace handed to the sandbox is confined to the sanctioned root <data dir>/workspaces (overridable with CYBERBRAIN_WORKSPACES_ROOT): a path that does not resolve inside that root is refused before any process is launched. Content written to a confined workspace does persist outside the disposable filesystem, and the sandbox does not clean it up.z„Bubblewrap execution is Linux-only; other platforms are reported as a warning and the supported execution path is unavailable there.z|Doctor never verifies a running end-to-end agent task, an LLM response, a network egress control, or a backup/restore cycle.zíThe ``--scopes`` CLI option grants scopes only to the 'coder' role; it is not applied to security, evaluator, research, browser, or planner steps. This is a known limitation of the current identity_scopes schema, not a scope-gate bypass.z˜Presence of a credential environment variable says nothing about whether a provider is configured, reachable, or permitted; doctor contacts no provider.zºReading an existing WAL-mode store can create or touch its -wal and -shm sidecar files; no schema, row, journal mode, or file permission is changed, and a missing store is never created.ÚPROTOTYPE_NOTESc                  óT   — e Zd ZU dZded<   ded<   ded<    ee¬«      Zded<   dd	„Zy
)ÚCheckResultz=A single diagnostic check row produced by :func:`run_checks`.r'   ÚnameÚstatusÚdetail©Údefault_factoryúdict[str, Any]Úmetadatac                ór   — | j                   | j                  | j                  t        | j                  «      dœS )z6Return a JSON-serializable representation of this row.©r1   r2   r3   r7   )r1   r2   r3   Údictr7   ©Úselfs    úA/home/oem/CyberBrain26-unified/src/cyberbrain26/product/doctor.pyÚto_dictzCheckResult.to_dict�   s/   € ð —I‘IØ—k‘kØ—k‘kÜ˜TŸ]™]Ó+ñ	
ð 	
ó    N)Úreturnr6   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r:   r7   r>   © r?   r=   r0   r0   ”   s(   … áGà
ƒIØƒKØƒKÙ$°TÔ:€HˆnÓ:ô
r?   r0   c                  óŒ   — e Zd ZU dZ ee¬«      Zded<    ed„ ¬«      Zded<   e	dd„«       Z
e	dd	„«       Zd
dœdd„Zd
dœdd„Zy)ÚDoctorReportz<Aggregated diagnostic report returned by :func:`run_checks`.r4   úlist[CheckResult]Úchecksc                 ó    — t        t        «      S ©N)Úlistr.   rF   r?   r=   ú<lambda>zDoctorReport.<lambda>¬   s   € ´T¼/Ó5J€ r?   z	list[str]Únotesc                ó:   — t        d„ | j                  D «       «      S )z&Number of checks reported as ``fail``.c              3  ó@   K  — | ]  }|j                   d k(  sŒd–— Œ y­w)Úfailé   N©r2   ©Ú.0Úchecks     r=   ú	<genexpr>z&DoctorReport.failed.<locals>.<genexpr>±   ó   è ø€ ÒH˜°·±ÀÓ1G”1ÑHùó   ‚—©ÚsumrJ   r;   s    r=   ÚfailedzDoctorReport.failed®   ó   € ô ÑH $§+¡+ÔHÓHÐHr?   c                ó:   — t        d„ | j                  D «       «      S )z&Number of checks reported as ``warn``.c              3  ó@   K  — | ]  }|j                   d k(  sŒd–— Œ y­w)ÚwarnrS   NrT   rU   s     r=   rX   z(DoctorReport.warnings.<locals>.<genexpr>¶   rY   rZ   r[   r;   s    r=   ÚwarningszDoctorReport.warnings³   r^   r?   F©Ústrictc               óH   — | j                   dkD  ry|r| j                  dkD  ryy)a  Return the overall status of the report.

        Args:
            strict: When ``True``, a ``warn`` row counts as a failure.

        Returns:
            ``"fail"`` when any check failed (or, in strict mode, warned),
            otherwise ``"ok"``.
        r   rR   Úok)r]   rb   )r<   rd   s     r=   Úoverall_statuszDoctorReport.overall_status¸   s&   € ð �;‰;˜Š?ØÙ�d—m‘m aÒ'ØØr?   c               ó(  — dddddt         || j                  |¬«      t        | j                  «      | j                  | j
                  dœ| j                  D �cg c]  }|j                  «       ‘Œ c}t        | j                  «      t         gz   dœS c c}w )z>Return a JSON-serializable representation of the whole report.zcyberbrain doctorTFrc   )rJ   r]   rb   )ÚcommandÚ	read_onlyÚchanges_nothingÚperforms_or_approves_actionsÚpolicy_mode_report_onlyÚsecrets_policyrd   rg   ÚcountsrJ   rO   )	r-   rg   ÚlenrJ   r]   rb   r>   rM   rO   )r<   rd   rW   s      r=   r>   zDoctorReport.to_dictÈ   s†   € ð +ØØ#Ø,1Ø'+Ü*ØØ"×1Ñ1¸Ð1Ó@ä˜dŸk™kÓ*ØŸ+™+Ø ŸM™Mñð
 59·K±KÖ@¨5�u—}‘}•Ò@Ü˜$Ÿ*™*Ó%¬¨Ñ6ñ
ð 	
ùò As   ÁBN)r@   r)   )rd   Úboolr@   r'   )rd   rq   r@   r6   )rA   rB   rC   rD   r   rM   rJ   rE   rO   Úpropertyr]   rb   rg   r>   rF   r?   r=   rH   rH   §   sc   … áFá %°dÔ ;€FÐÓ;ÙÑ-JÔK€Eˆ9ÓKàòIó ðIð òIó ðIð 05õ ð  ).ö 
r?   rH   c                  ó8   — e Zd ZdZddœdd„Zd	d„Zed
d„«       Zy)Ú_ReadOnlyDatabasea[  A :class:`SQLiteDatabase` that can only read an existing store.

    Constructing the real database creates the parent directory, applies
    migrations, switches the journal to WAL and chmods the file. ``doctor``
    must not write, so this subclass skips initialization and opens every
    connection in SQLite read-only (``mode=ro``) mode.
    éZ   ©Úretention_daysc               ój   — t        |«      j                  «       j                  «       | _        || _        y)z:Record the location without creating or touching any file.N)r   Ú
expanduserÚresolveÚpathrw   )r<   r{   rw   s      r=   Ú__init__z_ReadOnlyDatabase.__init__æ   s'   € ä˜“J×)Ñ)Ó+×3Ñ3Ó5ˆŒ	Ø,ˆÕr?   c                 ó   — y)z>Do nothing: no migration, no WAL switch, no permission change.NrF   r;   s    r=   Ú_initializez_ReadOnlyDatabase._initializeë   s   � r?   c              #  óÜ   K  — d| j                   › d�}t        j                  |ddd¬«      }t        j                  |_        	 |–— |j                  «        y# |j                  «        w xY w­w)zBYield a read-only SQLite connection and always close it afterward.úfile:ú?mode=roTç      @N)ÚuriÚtimeoutÚisolation_level)r{   Úsqlite3ÚconnectÚRowÚrow_factoryÚclose)r<   rƒ   Ú
connections      r=   r‹   z_ReadOnlyDatabase.connectionî   s^   è ø€ ð �d—i‘i�[ Ð)ˆÜ—_‘_ S¨d¸CÐQUÔVˆ
Ü!(§¡ˆ
Ôð	ØÒà×ÑÕøˆJ×ÑÕüs   ‚?A,ÁA ÁA,ÁA)Á)A,N)r{   z
str | Pathrw   r)   r@   ÚNone)r@   rŒ   )r@   zIterator[sqlite3.Connection])rA   rB   rC   rD   r|   r~   r   r‹   rF   r?   r=   rt   rt   Ý   s-   „ ñð CEõ -ó
Mð òó ñr?   rt   c                ón   — 	 t        | j                  «       j                  dz  «      S # t        $ r Y yw xY w)z@Return the POSIX permission bits of ``path`` as an octal string.iÿ  Úunavailable)ÚoctÚstatÚst_modeÚOSError)r{   s    r=   Ú_mode_stringr“   ú   s5   € ðÜ�4—9‘9“;×&Ñ&¨Ñ.Ó/Ð/øÜò Ùðús   ‚%( ¨	4³4c                ór   — 	 | j                  «       j                  }t        |dz  «      S # t        $ r Y yw xY w)zDReturn whether the POSIX mode grants group or other read/write bits.Fé?   )r�   r‘   r’   rq   )r{   Úmodes     r=   Ú_is_world_or_group_readabler—     s=   € ðØ�y‰y‹{×"Ñ"ˆô ��u‘ÓÐøô ò Ùðús   ‚* ª	6µ6c            	     óX  — t         j                  } | j                  › d| j                  › d| j                  › �}t
        d   › dt
        d   › �}||dœ}| j                  | j                  ft
        k  rt        ddd|› d|› d	�|¬
«      S t        ddd|› dt         j                  › d�|¬
«      S )zFReport the running interpreter against the declared ``>=3.11`` target.ú.r   rS   )ÚcurrentÚrequired_minimumÚpython_versionrR   zPython z is older than the required z:+ declared in pyproject.toml (requires-python = ">=3.11").r9   Úpassz (executable: ú).)ÚsysÚversion_infoÚmajorÚminorÚmicror%   r0   Ú
executable)Úinforš   Úrequiredr7   s       r=   Ú_check_python_versionr§     sÌ   € ä×Ñ€DØ—‘�˜A˜dŸj™j˜\¨¨4¯:©:¨,Ð7€GÜ$ QÑ'Ð(¨Ô*<¸QÑ*?Ð)@ÐA€HØ+2ÈÑQ€HØ�
‰
�D—J‘JÐÔ"4Ò4ÜØ!Øà˜'˜Ð">¸x¸jð I?ð ?ð ô
ð 	
ô ØØØ˜˜	 ´·±Ð/?¸rÐBØô	ð r?   c            
     óŒ   — t        dddt        › dt        t        «      j	                  «       j
                  › d�dt        i¬«      S )z6Report the installed ``cyberbrain26`` package version.Úpackage_versionr�   zcyberbrain26 z imported from r™   Úversionr9   )r0   r
   r   Ú__file__rz   ÚparentrF   r?   r=   Ú_check_package_versionr­   #  sD   € äØØØœ{˜m¨?¼4Ä»>×;QÑ;QÓ;S×;ZÑ;ZÐ:[Ð[\Ð]Øœ[Ð)ô	ð r?   c                 óî   — t        j                  «       } t        j                  «       }t        j                  «       }| ||dœ}| dk7  rt	        ddd| › d|› d|› d�|¬	«      S t	        dd
d|› d|› d�|¬	«      S )zCReport whether the platform supports the Bubblewrap execution path.)ÚsystemÚreleaseÚmachineÚLinuxÚplatform_supportedra   zPlatform is ú ú (z©). The supported prototype target is Linux, so the Bubblewrap execution path is Linux-only and unavailable here; identity, policy, audit and the local store still apply.r9   r�   zLinux z.): the Bubblewrap execution path is supported.)Úplatformr¯   r°   r±   r0   )r¯   r°   r±   r7   s       r=   Ú_check_platform_supportedr·   -  sŸ   € ä�_‰_Ó€FÜ×ÑÓ €GÜ×ÑÓ €GØ*0¸WÐQXÑY€HØ�ÒÜØ%Øà˜v˜h a¨ y°°7°)ð <ð ð
 ô

ð 
	
ô Ø!ØØ˜�y  7 )Ð+YÐZØô	ð r?   c                ó<  — t        | «      | j                  «       dœ}t        t        «      dd }| j                  «       st	        ddd| › d|› d�|¬	«      S | j                  «       st	        dd
d| › d�|¬	«      S t        j                  | t        j                  t        j                  z  «      }t        | «      }|j                  ||dœ«       |st	        dd
d| › d|› d�|¬	«      S t        | «      rt	        ddd| › d|› d|› d�|¬	«      S t	        ddd| › d|› d�|¬	«      S )z7Report the resolved data directory without creating it.)r{   Úexistsé   NÚdata_dirra   zData directory zo does not exist yet. Doctor does not create it; the first command that writes local state creates it with mode r™   r9   rR   zData directory path ú exists but is not a directory.)Úwritabler–   ú exists (mode z) but is not writable.z is writable (mode zG) but readable by group or others; local state should stay owner-only (rž   r�   z exists, is writable, mode )r'   r¹   r�   r+   r0   Úis_dirÚosÚaccessÚW_OKÚX_OKr“   Úupdater—   )r»   r7   Úexpected_moder½   r–   s        r=   Ú_check_data_dirrÆ   G  si  € ä(+¨H«ÀÇÁÓARÑS€HÜÔ.Ó/°°Ð3€MØ�?‰?ÔÜØØà! ( ð ,Và �/ ð$ð ô	
ð 		
ð �?‰?ÔÜØØØ)¨(¨Ð3RÐSØô	
ð 	
ô �y‰y˜¤2§7¡7¬R¯W©WÑ#4Ó5€HÜ˜Ó!€DØ‡O�O °4Ñ8Ô9ÙÜØØØ$ X J¨n¸T¸FÐBXÐYØô	
ð 	
ô # 8Ô,ÜØØà! ( Ð+>¸t¸fð EHØHUÀÐVXðZð ô
ð 	
ô ØØØ   
Ð*EÀdÀVÈ1ÐMØô	ð r?   c                ó¨  — 	 d| › d�}t        j                  |dd¬«      }	 |j                  d«      j	                  «       }	 |j                  «        |�|d   €y	 t        |d   «      S # t         j                  $ r Y yw xY w# t         j                  $ r Y |j                  «        yw xY w# |j                  «        w xY w# t        t        f$ r Y yw xY w)	zŸRead ``PRAGMA user_version`` from an existing database in read-only mode.

    Returns ``None`` when the file cannot be opened as a readable SQLite store.
    r€   r�   Tr‚   )rƒ   r„   NzPRAGMA user_versionr   )	r†   r‡   ÚErrorÚexecuteÚfetchonerŠ   r)   Ú	TypeErrorÚ
ValueError)Údb_pathrƒ   r‹   Úrows       r=   Ú_read_user_versionrÏ   y  sÙ   € ð
Ø�g�Y˜hÐ'ˆÜ—_‘_ S¨d¸CÔ@ˆ
ðØ× Ñ Ð!6Ó7×@Ñ@ÓB‰ð 	×ÑÔØ
€{�c˜!‘f�nØðÜ�3�q‘6‹{Ðøô �=‰=ò Ùðûô �=‰=ò Øà×ÑÕðûð 	×ÑÕûô
 ”zÐ"ò ÙðúsF   ‚A( ¡B ÁB? Á(A>Á=A>ÂB'ÂB* Â&B'Â'B* Â*B<Â?CÃCc                ó  — t         j                  }t        t        «      dd }t	        | «      | j                  «       |dœ}| j                  «       st        ddd| › d|› d|› d	�|¬
«      S t        | «      }t        | «      }|j                  ||dœ«       |€t        ddd| › d|› d�|¬
«      S ||k7  rt        ddd| › d|› d|› d�|¬
«      S t        | «      rt        ddd| › d|› d|› d|› d|› d	�|¬
«      S t        ddd| › d|› d|› d|› d	�	|¬
«      S )zFReport the expected local store file without creating or migrating it.rº   N)r{   r¹   Úexpected_schema_versionÚdatabasera   z	Database zd does not exist yet. Doctor never creates it; the store is created on first use with schema version z and file mode r™   r9   )r–   Úuser_versionrR   r¾   zN) but could not be read as a SQLite store; PRAGMA user_version is unavailable.z has schema version z but this code expects z%; a migration is required before use.z is at schema version z (expected z) but its file mode z6 is readable by group or others; the expected mode is r�   z exists, schema version z), file mode )r   ÚCURRENT_SCHEMA_VERSIONr�   r*   r'   r¹   r0   r“   rÏ   rÄ   r—   )rÍ   ÚexpectedrÅ   r7   r–   rÓ   s         r=   Ú_check_databaserÖ   ‘  s¯  € ä×4Ñ4€HÜÔ-Ó.¨q¨rÐ2€Mä�G“Ø—.‘.Ó"Ø#+ñ €Hð
 �>‰>ÔÜØØà˜G˜9ð %EØEMÀJð OØ%� að)ð ô	
ð 		
ô ˜Ó €DÜ% gÓ.€LØ‡O�O˜T°<Ñ@ÔAØÐÜØØà˜G˜9 N°4°&ð 9Dð Dð ô
ð 	
ð �xÒÜØØà˜G˜9Ð$8¸¸ð GØ#˜*Ð$IðKð ô
ð 	
ô # 7Ô+ÜØØà˜G˜9Ð$:¸<¸.ÈØ�*Ð0°°ð 7(Ø(5 °að9ð ô	
ð 		
ô ØØà˜�yÐ 8¸¸ÀkØˆj˜ d V¨1ð.ð ôð r?   c           	     óà   — | dt         dœ}t        | t        «      st        | t        «      st	        ddd| ›d�|¬«      S | dk  rt	        ddd| › d	�|¬«      S t	        dd
d| › dt         › d�|¬«      S )zEReport the resolved retention window and reject a non-positive value.ÚCYBERBRAIN_RETENTION_DAYS©rw   Úenv_varÚdefaultÚ	retentionrR   zResolved retention window zK is not an integer; the store requires an explicit positive number of days.r9   r   zI is not positive; the store requires an explicit positive number of days.r�   zRetention window is z3 days (CYBERBRAIN_RETENTION_DAYS, else the default zX). Retention is applied only when a caller explicitly runs pruning; doctor never prunes.)r   Ú
isinstancerq   r)   r0   )rw   r7   s     r=   Ú_check_retentionrÞ   Ò  sÄ   € ð )Ø.Ü)ñ €Hô
 �.¤$Ô'¬z¸.Ì#Ô/NÜØØà,¨^Ð,>ð ?Fð Fð ô
ð 	
ð ˜ÒÜØØà,¨^Ð,<ð =@ð @ð ô
ð 	
ô ØØà" >Ð"2ð 3Ü1Ð2ð 3CðCð ô	ð 	r?   c            
     ó$  — t        j                  t        «      } t        | dœ}| €t        ddd|¬«      S 	 t	        j
                  | dgddd	d
¬«      }|j                  xs |j                  xs dj                  «       }||d<   |j                  |d<   |j                  dk7  r t        ddd| › d|j                  › d�|¬«      S t        ddd| › d|› d�|¬«      S # t        t        j                  f$ r }t        ddd| › d|› d�|¬«      cY d}~S d}~ww xY w)zÃReport Bubblewrap availability using only ``--version``.

    Bubblewrap is never asked to execute code; the sandbox is probed only by
    locating the binary and reading its version string.
    )ÚbinaryÚresolved_pathNÚ
bubblewraprR   a  bwrap was not found on PATH. The supported execution path fails closed without it (RuntimeError: Bubblewrap executable ... is unavailable; refusing to run code without a sandbox), so code execution is disabled on this machine. There is deliberately no unsandboxed fallback.r9   z	--versionTg      $@F)Úcapture_outputÚtextr„   rW   zbwrap found at z but 'bwrap --version' failed: r™   Ú Úversion_outputÚ
returncoder   z# but 'bwrap --version' exited with r�   z; 'bwrap --version' reports: )ÚshutilÚwhichr(   r0   Ú
subprocessÚrunr’   ÚSubprocessErrorÚstdoutÚstderrÚstriprç   )Úresolvedr7   Ú	completedÚexcÚversion_texts        r=   Ú_check_bubblewraprô   ù  s_  € ô �|‰|Ô-Ó.€HÜ*;ÈhÑW€HØÐÜØØðRð
 ô

ð 
	
ð
Ü—N‘NØ�{Ð#ØØØØô
ˆ	ð ×$Ñ$Ò>¨	×(8Ñ(8Ò>¸B×EÑEÓG€LØ!-€HÐÑØ&×1Ñ1€Hˆ\ÑØ×Ñ˜qÒ ÜØØà! ( Ð+NØ×'Ñ'Ð(¨ð+ð ô
ð 	
ô ØØØ   
Ð*GÈÀ~ÐUVÐWØô	ð øô) ”Z×/Ñ/Ð0ò 
ÜØØØ$ X JÐ.MÈcÈUÐRSÐTØô	
õ 	
ûð
ús   µC ÃDÃ/D
ÄDÄ
Dc                 ó   — t        «       } | j                  | j                  | j                  | j                  | j
                  dœ}d| j                  › d|d   › d|d   › d|d   › d	|d
   › d|d   › d�}t        dd|d| j                  i|¥¬«      S )zHReport the configured sandbox limits together with their honest caveats.)Úmax_timeout_secondsÚmax_memory_mbÚmax_cpu_secondsÚmax_file_size_mbÚmax_output_bytesz
Provider 'z*' is configured with: max_timeout_seconds=rö   z, max_memory_mb=r÷   z, max_cpu_seconds=rø   z, max_file_size_mb=rù   z, max_output_bytes=rú   a—  . These are the DEFAULT values from the provider constructor; doctor does not verify them at runtime. Caveats: RLIMIT_AS, RLIMIT_CPU and RLIMIT_FSIZE are cooperative resource limits of the child process and are NOT enforcement against hostile code, because a program that ignores or resets them is not stopped by them. There is no cgroup or process-count limit, so forking inside the sandbox is not bounded by the sandbox, and there is no disk or inode quota on the sandbox filesystem. A writable workspace passed to the sandbox is confined to the sanctioned root <data dir>/workspaces (overridable with CYBERBRAIN_WORKSPACES_ROOT): a path that does not resolve inside that root is refused before any process is launched, so the read-write bind mount cannot expose an arbitrary host directory. Content written to a confined workspace does persist outside the disposable filesystem, and the sandbox does not clean it up.Úsandbox_limitsra   Úproviderr9   )r   rö   r÷   rø   rù   rú   Úprovider_namer0   )rü   Úlimitsr3   s      r=   Ú_check_sandbox_limitsrÿ   1  sÜ   € ä*Ó,€Hà'×;Ñ;Ø!×/Ñ/Ø#×3Ñ3Ø$×5Ñ5Ø$×5Ñ5ñ€Fð �X×+Ñ+Ð,ð -Ø%Ð&;Ñ<Ð=ð >Ø Ñ0Ð1ð 2Ø!Ð"3Ñ4Ð5ð 6Ø"Ð#5Ñ6Ð7ð 8Ø"Ð#5Ñ6Ð7ð 80ð	0ð ô( ØØØØ˜h×4Ñ4Ð?¸Ð?ô	ð r?   c                óü   — t         j                  j                  t        «      }|�K|j	                  «       r;t        |j	                  «       «      j                  «       j                  «       t        fS t        | «      dfS )a
  Return the sanctioned workspaces root and a label naming its source.

    This mirrors the precedence of
    :attr:`BubblewrapExecutionProvider.allowed_workspaces_root` but creates nothing:
    the provider's ``ensure_workspaces_root()`` is replaced by the non-creating
    :func:`workspaces_root`, because ``doctor`` must never make a directory.

    Args:
        data_dir: Resolved data directory used to derive the default root.

    Returns:
        The resolved root and a short label naming where it came from.
    zdefault (<data dir>/workspaces))	rÀ   ÚenvironÚgetr   rï   r   ry   rz   r   )r»   Ú	env_values     r=   Ú_configured_workspaces_rootr  W  sa   € ô —
‘
—‘Ô2Ó3€IØÐ §¡Ô!2Ü�I—O‘OÓ%Ó&×1Ñ1Ó3×;Ñ;Ó=Ô?RÐRÐRÜ˜8Ó$Ð&GÐGÐGr?   c                óÐ  — t        | «      \  }}t        t        «      dd }t        |«      |t        |j                  «       |dddœ}d|› d�}|j                  «       st        dd	d
|› d|› d�|z   |¬«      S |j                  «       st        ddd|› d�|¬«      S t        |«      }||d<   t        |«      rt        dd	d
|› d|› d|› d�|z   |¬«      S t        ddd
|› d|› d�|z   |¬«      S )a  Report the sanctioned workspaces root without creating or modifying it.

    Only ``stat``-level inspection is performed: existence, directory-ness, and
    permission bits. No directory is created, no migration is run, and the root
    itself is left exactly as found.
    rº   NzAlocal_store.resolve_workspace(), called before any process launchT)r{   ÚsourcerÚ   r¹   rÅ   Úenforced_byÚinspections_are_read_onlyzjThis root is the only tree a writable sandbox mount may live in: a workspace that does not resolve inside z+ is refused before any process is launched.r   ra   zWorkspaces root zl does not exist yet. Doctor never creates it; the first command that needs a workspace creates it with mode z. r9   rR   zWorkspaces root path r¼   r–   r¾   zŒ) but is readable by group or others; sandboxed code writes there and the content survives the sandbox, so the root should stay owner-only (z). r�   z exists, is a directory, mode )
r  r�   r,   r'   r   r¹   r0   r¿   r“   r—   )r»   Úrootr  rÅ   r7   Úconfinementr–   s          r=   Ú_check_workspaces_rootr  k  sb  € ô /¨xÓ8�L€Dˆ&ÜÔ5Ó6°q°rÐ:€Mä�D“	ØÜ&Ø—+‘+“-Ø&ØZØ%)ñ €Hð(Ø(, vÐ-Xð	Zð ð �;‰;Œ=ÜØ"Øà" 4 &ð )Mà �/ ð%à'2ñ3ð ô	
ð 		
ð �;‰;Œ=ÜØ"ØØ*¨4¨&Ð0OÐPØô	
ð 	
ô ˜Ó€DØ€HˆVÑÜ" 4Ô(ÜØ"Øà" 4 &¨°t°fð =7à7D°oÀSðJàLWñXð ô	
ð 		
ô ØØà˜t˜fÐ$BÀ4À&ÈÐKÈkÑYàôð r?   c                 ó  — t        «       } | j                  }dj                  d„ | j                  «       D «       «      }t	        t         j
                  «      }|j                  |d|dœ}dt        |«      › ddj                  |«      › d�}|t        j                  urQd|j                  ›d	�|d
<   t        ddd|j                  ›dt        j                  j                  ›d|› d�|z   |¬«      S t        ddd|j                  ›d|› d�|z   |¬«      S )zÖReport the effective policy mode; anything but SAFE is a hard failure.

    The mode is only reported. ``doctor`` never changes it, and no environment
    variable, configuration file, or CLI flag switches it.
    ú, c              3  ó4   K  — | ]  }|j                   –— Œ y ­wrL   )r1   )rV   Úrules     r=   rX   z%_check_policy_mode.<locals>.<genexpr>²  s   è ø€ ÒE¨˜4Ÿ9�9ÑEùs   ‚T)Úconfigured_modeÚrules_loaded_at_constructionÚrules_are_fixed_at_constructionÚsensitive_actionszISAFE mode requires human approval for every action in SENSITIVE_ACTIONS (z): zŠ. No environment variable, configuration file, or CLI flag can switch the mode, and doctor reports the mode without offering to change it.zPolicyEngine.mode is a public attribute and can be reassigned without reloading rules; the rules reported here were loaded for z at construction time.ÚmismatchÚpolicy_moderR   zEffective PolicyEngine mode is z, not zc. A mode other than SAFE is not supported for a local installation. Rules loaded at construction: [z‰]. PolicyEngine.mode can be reassigned without reloading rules, so the configured value and the loaded rule set are reported separately. r9   r�   z4 (the SAFE default). Rules loaded at construction: [z¢]. PolicyEngine.mode is a public attribute that can be reassigned without reloading rules, so both the configured mode and the loaded rule set are reported here. )r   r–   ÚjoinÚ
list_rulesÚsortedÚSENSITIVE_ACTIONSÚvaluerp   r   ÚSAFEr0   )ÚengineÚ
configuredÚ
rule_namesÚ	sensitiver7   Úshareds         r=   Ú_check_policy_moder!  ª  sb  € ô ‹^€FØ—‘€JØ—‘ÑE°×1BÑ1BÓ1DÔEÓE€JÜ”|×5Ñ5Ó6€Ià%×+Ñ+Ø(2Ø+/Ø&ñ	 €HðÜ�	‹NÐ˜3˜tŸy™y¨Ó3Ð4ð 5.ð	.ð ð œŸ™Ñ(ðHà×ÑÐ"Ð"8ð:ð 	�Ñô
 ØØà1°*×2BÑ2BÐ1EÀVÜ—?‘?×(Ñ(Ð+ð ,FØFPÀ\ð RUðUð
 ñð ô
ð 	
ô ØØà-¨j×.>Ñ.>Ð-Að B.Ø.8¨\ð :JðJð MSñSð
 ô
ð 
r?   c            
     ór  — t        ddt        j                  ¬«      } t        d„ | j                  D «       «      }| j
                  | j                  | j                  j                  |dœ}|rt        dddt        |«      › d	�|¬
«      S t        ddd| j                  j                  › dt        |«      › d�|¬
«      S )zÉReport how built-in agents receive scopes, using a scopeless probe identity.

    The probe identity below carries NO scopes: doctor grants itself no
    permission and reports no invented scopes.
    zcyberbrain-doctorÚ
supervisor)Úagent_idÚroleÚtrust_levelc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wrL   )r'   )rV   Úscopes     r=   rX   z&_check_agent_scopes.<locals>.<genexpr>ë  s   è ø€ Ò?¨œ#˜eŸ*Ñ?ùs   ‚)Úprobe_agent_idÚ
probe_roleÚprobe_trust_levelÚprobe_scopesÚagent_scopesrR   z/The doctor probe identity unexpectedly carries z3 scope(s); doctor must never hold execution scopes.r9   r�   a*  Built-in Ptah agents receive their permission scopes through AgentIdentity.scopes; this check infers no scope on their behalf. SAFE-mode identities have no execution scopes by default - a scope must be granted explicitly. The doctor probe identity 'cyberbrain-doctor' (role=supervisor, trust_level=z') was created with an empty scope set (z! scopes) and holds no permission.)r   r   ÚVERIFIEDr  Úscopesr$  r%  r&  r  r0   rp   )Úprober,  r7   s      r=   Ú_check_agent_scopesr1  à  sÝ   € ô Ø$ØÜ×'Ñ'ô€Eô
 Ñ?°%·,±,Ô?Ó?€LàŸ.™.Ø—j‘jØ"×.Ñ.×4Ñ4Ø$ñ	 €Hñ ÜØØàAÄ#ÀlÓBSÐATð UEð Eð ô
ð 	
ô ØØðð !×,Ñ,×2Ñ2Ð3ð 4Ü�LÓ!Ð"Ð"CðEð ôð r?   c                ód  — t        | «      | j                  «       ddœ}| j                  «       st        ddd| › d�|¬«      S 	 t        | |¬«      }t	        |¬	«      j                  «       }t        |«      |d<   t        j                  |d<   t        ddt        |«      › d| › dt        j                  d›d�|¬«      S # t        j                  t        t        t        f$ rR}t        |«      j                  › d
|› �|d<   t        ddd| › dt        |«      j                  › d
|› �|¬«      cY d}~S d}~ww xY w)a&  Count pending human approval requests when an existing store is readable.

    The store is opened through a read-only connection, so no database is
    created, migrated, or modified. ``check_expired`` is deliberately not
    called because it marks requests as expired, which is a write.
    T)r{   r¹   rj   Úpending_approvalsra   zNo local store at zK, so there is nothing to count. Doctor never creates the store to find out.r9   rv   )rÒ   ú: ÚerrorrR   zThe local store at z* could not be read for pending approvals: NÚpending_countÚapproval_timeout_secondsr�   z& pending human approval request(s) in zG, read through a read-only SQLite connection (default approval timeout z.0fz±s). Doctor neither lists nor expires individual requests, and opening a WAL store read-only may create or touch its -wal and -shm sidecar files without changing any stored data.)r'   r¹   r0   rt   r   Úlist_pendingr†   rÈ   r’   rÌ   ÚRuntimeErrorÚtyperA   rp   ÚDEFAULT_TIMEOUT_SECONDS)rÍ   rw   r7   rÒ   Úpendingrò   s         r=   Ú_check_pending_approvalsr=    sY  € ô ),¨G«ÀÇÁÓ@PÐ_cÑd€HØ�>‰>ÔÜØ$Øà$ W Ið .1ð 1ð ô
ð 	
ð
Ü$ W¸^ÔLˆÜ!¨8Ô4×AÑAÓCˆô !$ G£€Hˆ_ÑÜ+:×+RÑ+R€HÐ'Ñ(ÜØ Øä�7‹|ˆnÐBÀ7À)ð LGä×6Ñ6°sÐ;ð <VðVð ôð øô �M‰Mœ7¤J´Ð=ò 

Ü# C›y×1Ñ1Ð2°"°S°EÐ:ˆ�ÑÜØ$Øà% g YÐ.XÜ˜“9×%Ñ%Ð& b¨¨ð/ð ô
õ 	
ûð

ús   Á'B: Â:#D/ÃAD*Ä$D/Ä*D/c                ó@   — 	 ddl m}  || ¬«      S # t        $ r Y yw xY w)zÙReturn a :class:`PermissionGateway` for gate wiring, or ``None``.

    The gateway exists only so the security gate can report that a permission
    gateway is configured. It grants nothing and evaluates nothing.
    r   )ÚPermissionGatewayN)Úpolicy_engine)Ú&cyberbrain26.security_plane.permissionr?  ÚImportError)r@  r?  s     r=   Ú_build_permission_gatewayrC  ;  s+   € ðÝLñ ¨=Ô9Ð9øô ò Ùðús   ‚ ‘	œc                ó  — t        | «      }t        «       }	 |j                  d|| dd|¬«      }g }g }g }|D �]  }	|j                  |	j                  |	j                  |	j                  j                  |	j                  |	j                  |	j                  |	j                  |	j                   D �
cg c]%  }
|
j"                  |
j                  j                  dœ‘Œ' c}
d	œ«       |	j$                  s,|j                  |	j                  › d
|	j                  › d�«       Œß|	j                  dkD  sŒï|j                  |	j                  › d
|	j                  › d�«       �Œ dj'                  d„ |D «       «      }d|› d�}|ddœ}d}|r||d<   |ddj'                  |«      › d�z  }|r||d<   |ddj'                  |«      › d�z  }t	        dd||z   |¬«      S # t        $ r2}t	        dddt        |«      j                  › d|› �i ¬«      cY d}~S d}~ww xY wc c}
w )zJRun the quality gates and label the result as a configuration self-report.N)ÚagentsÚpermission_gatewayr@  Ú	audit_logÚfirewallrw   Úquality_gatesrR   zThe quality gate runner raised r4  r9   )r1   r2   )Ú	gate_nameÚgate_idr2   Úpassedr]   Úskippedrb   rJ   rµ   ú)r   z; c              3  ót   K  — | ]0  }|d    › d|d   › d|d   › d|d   › d|d   › d	|d
   › d|d   › d�–— Œ2 y­w)rJ  z [rK  z] r2   rµ   rL  z	 passed, r]   ú	 failed, rM  z
 skipped, rb   z
 warnings)NrF   )rV   Úitems     r=   rX   z'_check_quality_gates.<locals>.<genexpr>r  sp   è ø€ ò ð ð �ÑÐ
˜R  Y¡Ð0°°4¸±>Ð2BÀ"ÀTÈ(Á^ÐDTÐT]Ø�‰>Ð
˜) D¨¡OÐ#4°J¸tÀJÑ?OÐ>PÐPZô	\ñùs   ‚68zrCONFIGURATION SELF-REPORT, NOT VERIFIED SECURITY EVIDENCE: these results are produced by the installation itself. a+  . Limits of these gates: the security gate check 'no_hardcoded_secrets' always passes without inspecting any file, the architecture gate check 'default_deny_policy' always passes, and the agent checks of the security gate are skipped because doctor supplies no agent list. The permission gateway is wired only to show that an object is present, and no audit log or AI firewall instance is configured here, so these gates do not prove that audit logging or filtering works. A gate reported as passing is not evidence that the control it names is effective.T)ÚgatesÚself_reporta[   A gate failure here reflects the configuration doctor wired, not a verified installation defect: doctor deliberately supplies no agent list, no audit log and no AI firewall instance, because opening an audit log would write to local state. A failing gate row is therefore reported as a warning, never as evidence that the named control is broken.Úfailed_gatesz Gates reported as failing: r  r™   Úwarned_gatesz Gates reported with warnings: ra   )rC  r   Úrun_allÚ	Exceptionr0   r:  rA   ÚappendrJ  rK  r2   r  rL  r]   rM  rb   rJ   r1   Úoverall_passedr  )r@  rw   ÚgatewayÚrunnerÚresultsrò   ÚsummaryrT  rU  ÚresultrW   Úrenderedr3   r7   Útails                  r=   Ú_check_quality_gatesra  H  sF  € ä'¨Ó6€GÜÓ €Fð
Ø—.‘.ØØ&Ø'ØØØ)ð !ó 
ˆð %'€GØ €LØ €LØó JˆØ�‰à#×-Ñ-Ø!Ÿ>™>Ø Ÿ-™-×-Ñ-Ø Ÿ-™-Ø Ÿ-™-Ø!Ÿ>™>Ø"ŸO™OàTZ×TaÑTaöØKP˜UŸZ™Z°5·<±<×3EÑ3EÓFòñô	
ð ×$Ò$Ø×Ñ 6×#3Ñ#3Ð"4°B°v·~±~Ð6FÀaÐ HÕIØ�_‰_˜qÓ Ø×Ñ 6×#3Ñ#3Ð"4°B°v·~±~Ð6FÀaÐ HÖIð%Jð& �y‰yñ ð ôó €Hð	0Ø08¨zð :?ð	?ð ð *1ÀÑF€Hð	,ð 	ñ Ø#/ˆ�Ñ ØÐ.¨t¯y©y¸Ó/FÐ.GÀqÐIÑIˆÙØ#/ˆ�Ñ ØÐ1°$·)±)¸LÓ2IÐ1JÈ!ÐLÑLˆÜØØØ˜‰}Øô	ð øôw ò 
ÜØ ØØ4´T¸#³Y×5GÑ5GÐ4HÈÈ3È%ÐPØô	
õ 	
ûð
üò(s#   —G Â**HÇ	HÇ'G>Ç8HÇ>Hc            	     ó‚  — g } dD ]"  \  }}	 t        |«       | j                  |«       Œ$ t        D �ci c]+  }|t	        t
        j                  j                  |«      «      “Œ- }}| |dddœ}d| rdj                  | «      nd› ddj                  t        «      › d	�}t        d
| rdnd||¬«      S # t        $ r Y Œ³w xY wc c}w )zFReport available provider adapters and credential presence flags only.))z'cyberbrain26.model_layer.litellm_clientÚLiteLLM)z&cyberbrain26.model_layer.ollama_clientÚOllama)z)cyberbrain26.model_layer.llama_cpp_clientz	llama.cppFT)ÚadaptersÚcredential_env_presenceÚvalues_printedÚpresence_is_advisory_onlyz8Model provider adapters available in this installation: r  znone importablea+  . These are adapters only; doctor contacts no provider and cannot determine whether a provider is reachable, authorised, or correctly configured. The project defines no canonical provider-credential environment variable, so only presence (true/false) is reported for the conventional variable names zŽ, and no value is ever printed. A true presence flag means only that the variable is set and non-empty, not that a key is valid or authorised.Úmodel_providersr�   ra   r9   )
Ú
__import__rB  rX  r"   rq   rÀ   r  r  r  r0   )re  Úmodule_nameÚlabelr1   Úpresencer7   r3   s          r=   Ú_check_model_providersrn  ˜  sò   € à€Hðò 	Ñˆ�Uð
	Ü�{Ô#ð 	�‰˜Õð	ô >SÖS°T�”dœ2Ÿ:™:Ÿ>™>¨$Ó/Ó0Ñ0ÐS€HÐSàØ#+ØØ%)ñ	 €Hð 	CÙ"*ˆ4�9‰9�XÔÐ0AÐ
Bð CHð
 �9‰9Ô*Ó+Ð
,ð -"ð	"ð ô ØÙ!‰v vØØô	ð øô+ ò 	Ùð	üò Ts   ŒB-²0B<Â-	B9Â8B9©r»   Údbc                ó.  — t        | «      }t        ||¬«      }	 t        t        «      }t	        |«      }t        |t        «      rt        |«      nt        }t        «       }t        «       t        «       t        «       t        |«      t        |«      |t        «       t!        «       t#        |«      t%        «       t'        «       t)        ||«      t+        ||«      t-        «       g}	|	S # t        $ r+}t        ddd|› d�ddt        dœ¬	«      }t        }Y d}~Œºd}~ww xY w)
a  Run every diagnostic check and return the list of results.

    This is the plain, importable entry point: it does no CLI work and can be
    called directly from tests. It creates no directory or database, never
    changes the policy mode, and never performs or approves any action.

    Args:
        data_dir: Optional explicit data directory, overriding resolution.
        db: Optional explicit database file path, overriding resolution.

    Returns:
        One :class:`CheckResult` per check, in reporting order.
    )r»   rÜ   rR   zECYBERBRAIN_RETENTION_DAYS is malformed and was rejected fail-closed: z8 The store requires an explicit positive number of days.NrØ   rÙ   r9   )r   r   r   r   rÞ   rÝ   r)   rÌ   r0   r   r§   r­   r·   rÆ   rÖ   rô   rÿ   r  r!  r1  r=  ra  rn  )
r»   rp  Úresolved_data_dirÚresolved_db_pathrw   Úretention_checkÚeffective_retentionrò   r@  rJ   s
             r=   Ú
run_checksrv  ¿  s  € ô$ )¨Ó2ÐÜ& rÐ4EÔFÐð
Ü5Ô6LÓMˆô" +¨>Ó:ˆä#-¨n¼cÔ#BŒC�ÔÔH^ð 	ô !“N€MäÓÜÓ Ü!Ó#ÜÐ)Ó*ÜÐ(Ó)ØÜÓÜÓÜÐ0Ó1ÜÓÜÓÜ Ð!1Ð3FÓGÜ˜]Ð,?Ó@ÜÓ ð!€Fð  €MøôK ò 5Ü%ØØàWØ�%ÐOðQð #'Ø6Ü1ñô
ˆô 5Õûð5ús   šC  Ã 	DÃ)!DÄDc                ó0   — t        t        | |¬«      ¬«      S )a9  Run every diagnostic check and return the aggregated report.

    Args:
        data_dir: Optional explicit data directory, overriding resolution.
        db: Optional explicit database file path, overriding resolution.

    Returns:
        A :class:`DoctorReport` wrapping the rows from :func:`run_checks`.
    ro  )rJ   )rH   rv  ro  s     r=   Úbuild_reportrx  ý  s   € ô œz°8ÀÔCÔDÐDr?   Frc   c               óÆ  — g d¢}t        d„ | j                  D «       d¬«      }| j                  D ]M  }|j                  |j                  j	                  «       d›d|j
                  d|› d�›d	|j                  › �«       ŒO |j                  d«       |j                  d
| j                  |¬«      j	                  «       › d| j                  › d| j                  › dt        | j                  «      › d|rdnd› d�«       |j                  d«       |j                  d«       t        | j                  «      t        gz   D ]  }|j                  d|› �«       Œ dj                  |«      S )záRender a report as a plain-text table.

    Args:
        report: The report to render.
        strict: Whether a ``warn`` row counts as a failure.

    Returns:
        A newline-separated text block ready for printing.
    )z+CyberBrain26 doctor - read-only diagnosticszI(doctor changes nothing, performs no action, and never approves anything)rå   c              3  óF   K  — | ]  }t        |j                  «      –— Œ y ­wrL   )rp   r1   rU   s     r=   rX   zrender_text.<locals>.<genexpr>  s   è ø€ Ò< U”�U—Z‘Z—Ñ<ùs   ‚!é   )rÛ   z<5r´   ú<rå   z  z	Overall: rc   rµ   rP  z warnings, z checks, strict=ÚonÚoffrN  zNotes:z- ú
)ÚmaxrJ   rX  r2   Úupperr1   r3   rg   r]   rb   rp   rM   rO   r-   r  )Úreportrd   ÚlinesÚwidthrW   Únotes         r=   Úrender_textr†    sH  € ò€Eô
 Ñ<¨f¯m©mÔ<ÀaÔH€EØ—‘ò YˆØ�‰˜Ÿ™×*Ñ*Ó,¨RÐ0°°%·*±*¸Q¸u¸gÀP¸IÐ1FÀbÈÏÉÈÐWÕXðYà	‡L�L�ÔØ	‡L�LØ
�F×)Ñ)°Ð)Ó8×>Ñ>Ó@ÐAð BØ�M‰Mˆ?˜) F§O¡OÐ#4°KÄÀFÇMÁMÓ@RÐ?Sð TÙ ‘$ eÐ,¨Að	/ôð
 
‡L�L�ÔØ	‡L�L�ÔÜ�V—\‘\Ó"¤l ^Ñ3ò "ˆØ�‰�r˜$˜�[Õ!ð"à�9‰9�UÓÐr?   ÚdoctorzDCheck the local installation and report the effective security mode.T)r1   ÚhelpÚno_args_is_helprW   z
--data-dirz#Explicit data directory to inspect.)rˆ  z--dbz)Explicit SQLite database path to inspect.z--strictzTreat WARN as FAIL.z--jsonzEmit the report as JSON.c                ó.  — t        | |¬«      }|r;t        j                  t        j                  |j                  |¬«      d¬«      «       n t        j                  t        ||¬«      «       |j                  |¬«      dk(  rt        j                  d¬«      ‚y)	zðRun the read-only installation checks and report the effective security mode.

    Exits with code 1 when any check fails, or when ``--strict`` is given and any
    check warns. It never creates files and never changes the policy mode.
    ro  rc   rº   )ÚindentrR   rS   )ÚcodeN)	rx  ÚtyperÚechoÚjsonÚdumpsr>   r†  rg   ÚExit)r»   rp  rd   Úas_jsonr‚  s        r=   rW   rW   4  sr   € ô  8°Ô3€FÙÜ�
‰
”4—:‘:˜fŸn™n°F˜nÓ;ÀAÔFÕGä�
‰
”;˜v¨fÔ5Ô6Ø×Ñ FÐÓ+¨vÒ5Ü�j‰j˜aÔ Ð ð 6r?   Úmainc                ó"   — t        | |||¬«       y)zMRun the same read-only checks as ``check``; the alias used by the parent CLI.©r»   rp  rd   r’  N)rW   r•  s       r=   r“  r“  I  s   € ô 
�8 ¨6¸7ÖCr?   )r(   r+   r*   r,   r%   r.   r-   r0   rH   rx  rW   Ú
doctor_appr“  r†  rv  )r{   r   r@   r'   )r{   r   r@   rq   )r@   r0   )r»   r   r@   r0   )rÍ   r   r@   z
int | None)rÍ   r   r@   r0   )rw   r	   r@   r0   )r»   r   r@   ztuple[Path, str])rÍ   r   rw   r)   r@   r0   )r@  r   r@   r	   )r@  r   rw   r)   r@   r0   )r»   ústr | Path | Nonerp  r—  r@   rI   )r»   r—  rp  r—  r@   rH   )r‚  rH   rd   rq   r@   r'   )
r»   r'   rp  r'   rd   rq   r’  rq   r@   rŒ   )VrD   Ú
__future__r   r�  rÀ   r¶   rè   r†   rê   rŸ   Úcollections.abcr   Ú
contextlibr   Údataclassesr   r   Úpathlibr   Útypingr	   r�  Úcyberbrain26r
   Ú$cyberbrain26.data_plane.sqlite_storer   Ú0cyberbrain26.execution_plane.bubblewrap_providerr   Ú cyberbrain26.product.local_storer   r   r   r   r   r   Ú$cyberbrain26.security_plane.approvalr   Ú$cyberbrain26.security_plane.identityr   r   Ú"cyberbrain26.security_plane.policyr   r   Ú)cyberbrain26.security_plane.quality_gatesr   r"   rE   r%   r(   r*   r+   r,   r-   r.   r0   rH   rt   r“   r—   r§   r­   r·   rÆ   rÏ   rÖ   rÞ   rô   rÿ   r  r  r!  r1  r=  rC  ra  rn  rv  rx  r†  ÚTyperr–  ri   ÚOptionrW   r“  Ú__all__rF   r?   r=   ú<module>r©     s)  ðò"õH #ã Û 	Û Û Û Û Û 
Ý $Ý %ß (Ý Ý ã å $Ý ?Ý X÷÷ õ Aß Jß GÝ Gð

*Ð �ó 
ð '.Ð �OÓ -Ø Ð �3Ó  Ø"Ð �sÓ "Ø#Ð ˜Ó #Ø%*Ð ˜sÓ *ðUð ˆcó ð
1$€�ó 1ðh ÷
ð 
ó ð
ð$ ÷2
ð 2
ó ð2
ôj˜ô ó:óóó0óó4/ódó0>óB$óN5óp#óLHó(<ó~3ól(óV-ó`
:óMó`$ðR #'Ø ñ;àð;ð 	ð;ð ó	;ð@ #'Ø ñEàðEð 	ðEð ó	Eð" 9>õ ð> ˆU�[‰[Ø	Ø	OØô€
ð ×Ñ�GÓà �E—L‘L  |Ð:_Ô`Øˆe�l‰l˜4 Ð.YÔZØ�5—<‘<  zÐ8MÔNØ �E—L‘L ¨Ð7QÔRð	!Øð!àð!ð ð!ð ð	!ð
 
ò!ó ð!ð( ×Ñ�FÓà �E—L‘L  |Ð:_Ô`Øˆe�l‰l˜4 Ð.YÔZØ�5—<‘<  zÐ8MÔNØ �E—L‘L ¨Ð7QÔRð	DØðDàðDð ðDð ð	Dð
 
òDó ðDò�r?   