
    wjl	                    8    d Z ddlmZ ddlmZ h dZh dZddZy)	uY  v3.6 Runtime Harness — JSONL record schema validator.

chair_authorization_id=CHAIR-AUTH-TASK-2703-V36-HARNESS-MVP-260528

Required fields (5 canonical fields per spec verbatim):
  ts, decision, matched_rule, command_or_tool, task_id, timestamp
  (ts + timestamp both required to fulfill "ts (ISO8601 UTC)" and "timestamp (epoch float)" spec)
    )annotations)Any>   tstask_iddecision	timestampmatched_rulecommand_or_tool>   DENYALLOW
AUDIT_ONLYHOLD_FOR_CHAIRDRY_RUN_WOULD_DENYc                L   g }t        | t              sddgfS t        D ]  }|| vs|j                  d|        | j	                  d      }|,|t
        vr$|j                  d|dt        t
                      | j	                  d      }|7t        |t              s'|j                  dt        |      j                          t        |t              r!|j                         s|j                  d	       | j	                  d
      }|=t        |t        t        f      s'|j                  dt        |      j                          |dv rJ| j	                  d      |j                  d|       | j	                  d      |j                  d|       t        |      dk(  }||fS )z|Validate a JSONL decision record against the v36 harness schema.

    Returns:
        (valid: bool, errors: list[str])
    Fzrecord must be a dictzmissing required field: r   zinvalid decision value: z; expected one of r   z+field 'ts' must be a string (ISO8601), got zfield 'ts' must not be emptyr   z5field 'timestamp' must be numeric (epoch float), got )r   r   r	   z3field 'matched_rule' must not be None for decision=reasonz-field 'reason' must not be None for decision=r   )
isinstancedictREQUIRED_FIELDSappendgetVALID_DECISIONSsortedstrtype__name__stripintfloatlen)recorderrorsfieldr   r   r   valids          1/home/jay/workspace/scripts/harness/v36/schema.pyvalidate_recordr%      s    Ffd#./// ! @MM4UI>?@
 zz*%H ?0<NvVeOfNghi 
D	B	~jS1CDHDUDUCVWX"c288:45 

;'IZ	C<%HMdS\oNfNfMghi --::n%-MMOPX|\]::h'MMI(VWK1E&=    N)r    r   returnztuple[bool, list[str]])__doc__
__future__r   typingr   r   r   r%    r&   r$   <module>r,      s$    #  `Y)r&   