
    ^iB                    r   d Z ddlmZ ddlZddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZmZ  G d d	ee      Z G d
 dee      Z G d dee      Z G d dee      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y) u  
Pydantic schemas for the AI Transformation Audit Report pipeline.

These models represent structured data gathered from voice conversations,
intake forms, or direct input, and drive all report generation logic.

6 Readiness Dimensions (from ENTERPRISE_AI_TRANSFORMATION_STRATEGY.md):
  1. Operations    — manual workflows, process automation opportunities
  2. Customer Experience — call handling, lead capture, CX touch-points
  3. Data           — data quality, governance, integration health
  4. Technology     — tech stack maturity, integration ecosystem
  5. People         — AI literacy, change readiness, upskilling
  6. Strategy       — AI vision, leadership buy-in, competitive awareness

VERIFICATION_STAMP
Module: core/audit/schemas.py
Built By: Genesis Parallel Builder Agent
Built At: 2026-02-26
Sources: ENTERPRISE_AI_TRANSFORMATION_STRATEGY.md, BRAND_BIBLE.md
Tests: 30/30 passing (see tests/audit/test_report_generator.py)
    )annotationsN)datedatetime)Enum)AnyOptional)	BaseModelFieldfield_validatormodel_validatorc                  8    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZy)Industrytradesprofessional_services
healthcareretailhospitalityconstruction	logistics
technologyfinance	educationotherN)__name__
__module____qualname__TRADESPROFESSIONAL_SERVICES
HEALTHCARERETAILHOSPITALITYCONSTRUCTION	LOGISTICS
TECHNOLOGYFINANCE	EDUCATIONOTHER     +/mnt/e/genesis-system/core/audit/schemas.pyr   r   &   s:    F3JFK!LIJGIEr)   r   c                       e Zd ZdZdZdZdZdZy)CompanySizesolomicrosmallmediumlargeN)r   r   r   SOLOMICROSMALLMEDIUMLARGEr(   r)   r*   r,   r,   4   s    DEEFEr)   r,   c                       e Zd ZdZdZdZdZdZy)
ScoreGradeABCDFN)r   r   r   EXCEPTIONALSTRONG
DEVELOPINGEARLY_STAGECRITICALr(   r)   r*   r8   r8   <   s    KFJKHr)   r8   c                      e Zd ZdZdZdZdZy)PriorityLevelrB   HIGHr5   LOWN)r   r   r   rB   rE   r5   rF   r(   r)   r*   rD   rD   D   s    HDF
Cr)   rD   c                       e Zd ZdZdZdZdZdZy)ImplementationComplexity	quick_win
short_termmedium_term	long_term	strategicN)r   r   r   	QUICK_WIN
SHORT_TERMMEDIUM_TERM	LONG_TERM	STRATEGICr(   r)   r*   rH   rH   K   s    IJKIIr)   rH   c                     e Zd ZU dZ eddd      Zded<    edd	
      Zded<    edd
      Zded<    edd
      Z	ded<    eddd      Z
ded<    edd      Zded<    edd      Zded<    eed       Zd!ed"<   dZded#<   dZded$<   dZded%<    edd&
      Zded'<    edd(
      Zded)<    eed*       Zd!ed+<    eddd,      Zded-<    eddd.      Zded/<    eddd0      Zded1<    eddd2      Zd3ed4<    eddd5      Zd3ed6<    ed7d8      Zd9ed:<    eed;       Zd!ed<<    ed=dd>d?@      ZdAedB<    ed=dd>dC@      ZdAedD<    edEdd>dF@      ZdAedG<    eedH       Zd!edI<    eddJ
      Z dedK<    ee!jD                  L      Z#dMedN<    edOdP      Z$dedQ<    e%d      e&dVdR              Z' e%d      e&dWdS              Z(e)dXdT       Z*e)dYdU       Z+y)ZCompanyProfileu   
    Structured data about the company being audited.

    Populated from voice conversation transcript, intake form, or direct input.
    No hardcoded secrets — all values come from caller/form.
    .   zLegal or trading name)
min_lengthdescriptionstrcompany_nameNzPrimary website URLrW   Optional[str]website_urlzPrimary industry classificationr   industryzHeadcount bandr,   company_sizer   z-Annual revenue in AUD. None if not disclosed.gerW   Optional[int]annual_revenue_audBrisbanezPrimary city of operationdefaultrW   cityQLDzAustralian state/territorystatez9Geographic areas served (e.g. ['Brisbane', 'Gold Coast'])default_factoryrW   	list[str]regions_servedprimary_contact_nameprimary_contact_roleprimary_contact_emailz$e.g. 'HubSpot', 'Salesforce', 'none'current_crmz#e.g. 'Telnyx', 'Vonage', 'landline'current_phone_systemzMarketing platforms in usecurrent_marketing_toolsz!Estimated inbound calls per monthmonthly_inbound_callsz0Estimated inbound leads per month (all channels)monthly_leadsz-Average revenue per completed job/sale in AUDaverage_job_value_audz5Estimated calls missed per day (unanswered/voicemail)Optional[float]missed_calls_per_dayz5Owner/team hours spent on manual admin tasks per weekhours_on_admin_per_weekFz0True if any AI tools are currently in active useboolhas_ai_tools_deployedz?Names of AI tools currently in use, e.g. ['ChatGPT', 'Copilot']ai_tools_in_use      z61=unaware, 3=aware/curious, 5=champion. Self-reported.re   r`   lerW   intleadership_ai_awarenessz%1=poor/fragmented, 5=clean/integrateddata_quality_self_rating   z(1=resistant, 3=open, 5=eager to automateautomation_appetiteu.   Top 3–5 pain points as stated by the contacttop_pain_pointsz<Single biggest time/revenue drain identified in conversationbiggest_operational_bottleneckrj   r   
audit_datevoice_conversationzFHow data was gathered: voice_conversation / intake_form / direct_inputaudit_sourcec                ^    ||S |j                         }|r|j                  d      sd| }|S )N)zhttp://https://r   )strip
startswithclsvs     r*   normalise_urlzCompanyProfile.normalise_url   s8     9HGGIQ\\"9:1#Ar)   c                >    |j                         j                         S N)upperr   r   s     r*   upper_statezCompanyProfile.upper_state   s     wwy  r)   c                    | j                   r7| j                  r+| j                   dz  }t        |dz  | j                  z  d      S y)z&Danny Harris Math from Sales Playbook.   g333333?r|   N)rw   ru   round)selfcalls_per_months     r*    estimated_monthly_missed_revenuez/CompanyProfile.estimated_monthly_missed_revenue   sE     $$)C)C"77"<O4/$2L2LLaPPr)   c                R    | j                    d| j                   d| j                   S )Nz,  )rY   rf   rh   r   s    r*   full_name_locationz!CompanyProfile.full_name_location   s(    ##$Btyyk4::,??r)   )r   r[   returnr[   )r   rX   r   rX   )r   rv   )r   rX   ),r   r   r   __doc__r
   rY   __annotations__r\   r]   r^   rb   rf   rh   listrl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rw   rx   rz   r{   r   r   r   r   r   r   todayr   r   r   classmethodr   r   propertyr   r   r(   r)   r*   rT   rT   X   s    ca=TUL#U!&t9N!OKOs0QRHhR %c7G HL+H(-C)  j6QRD#Ru2NOE3O %O!NI  +/-.*.-.+/=/ "'t9_!`K`*/Bg*h-h).0*Y  ,17,= 
 $)F$M= 
 ,1C,= 
 -2K-/ 
 05K0_  #(F#4  "'U"OY  $)L	$S  %*;	%c   %>	   "'D"OY  5:R5"M  TZZ8J8$\L# 
 ]#  $ W!  !   @ @r)   rT   c                      e Zd ZU dZ edd      Zded<    eddd	      Zd
ed<    edd      Zd
ed<   ded<    edd      Z	ded<    ee
d      Zded<    ee
d      Zded<   edd       Zedd       Zy)DimensionScorez
    Score for one of the 6 AI readiness dimensions.

    Max 100 per dimension. Weighted aggregate = overall AI Readiness Index.
    .z!Dimension name, e.g. 'Operations'rZ   rX   	dimensionr   d   r`   r   floatscore      ?zPRelative weight when computing aggregate. Must sum to 6.0 across all dimensions.rd   weightr8   gradez*One-sentence assessment for this dimensionheadlineu-   2–4 specific findings with evidence or datari   rk   key_findingsz)Immediate actions achievable in < 30 days
quick_winsc                H    t        | j                  | j                  z  d      S )Nr|   )r   r   r   r   s    r*   weighted_scorezDimensionScore.weighted_score   s    TZZ$++-q11r)   c                    |dk\  rt         j                  S |dk\  rt         j                  S |dk\  rt         j                  S |dk\  rt         j                  S t         j
                  S )NP   A   2      )r8   r>   r?   r@   rA   rB   )r   r   s     r*   grade_from_scorezDimensionScore.grade_from_score   sZ    B;)))b[$$$b[(((b[)))&&&r)   N)r   r   )r   r   r   r8   )r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r(   r)   r*   r   r      s     3,OPIsPs+E5+fFE  #+WXHcX#CL)  "?J	 
 2 2 
' 
'r)   r   c                  l   e Zd ZU dZ edd      Zded<    edd      Zd	ed
<    edd      Zd	ed<    edddd      Z	d	ed<    eddd      Z
d	ed<    eddd      Zd	ed<    ed      Zd	ed<    ed      Zd	ed<    ed      Zd	ed<   dZded<    ed       Zded!<    ed"#      d%d$       Zy)&ROIProjectionu   
    ROI model based on ENTERPRISE_AI_TRANSFORMATION_STRATEGY.md formula.

    ROI (%) = ((Annual Hard Benefits × Utilisation Factor) - Annual Costs)
              / Initial Total Investment × 100
    .z.e.g. 'Conservative', 'Base Case', 'Optimistic'rZ   rX   scenarior   )r`   r   hours_saved_per_weekg     R@)re   r`   blended_hourly_rate_audgffffff?        r   uJ   Fraction of team actually using AI tools. Typically 0.60–0.85 in year 1.r~   utilisation_factorzAnnual API fees + licencesr_   annual_ai_costs_audz!Implementation + onboarding costsinitial_investment_audre   annual_hard_benefits_audnet_annual_benefit_audroi_percentageNrv   payback_months break_even_noteaftermodec                   | j                   dz  }t        || j                  z  | j                  z  d      | _        t        | j                  | j
                  z
  d      | _        | j                  dkD  r+t        | j                  | j                  z  dz  d      | _        | j                  dkD  rG| j                  dz  }|dkD  r3t        | j                  |z  d      | _	        d| j                   d| _
        | S )	Ng      J@r|   r   r   rU   g      (@z&Investment recovered in approximately z months.)r   r   r   r   r   r   r   r   r   r   r   )r   annual_hours_savedmonthly_benefits      r*   compute_roizROIProjection.compute_roi*  s    !66=(-!=!==@W@WWYZ)
% ',))D,D,DDa'
# &&*"',,t/J/JJcQST#D &&*"99D@O"&+D,G,G/,Y[\&]#<T=P=P<QQYZ $ r)   )r   z'ROIProjection')r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r(   r)   r*   r   r     s     #+[\Hc\ #("2%2%*4A%>U> %`	!  "'sq>Z![[$)#!Ad$eEe ',C&8e8$)#$6E6!#.NE.&*NO* ,OS,'" #r)   r   c                      e Zd ZU dZded<   ded<    edd      Zded<   d	ed
<   ded<   dZded<   dZded<    edd      Z	ded<    edd      Z
ded<   y)RecommendedActionzD
    A single recommended action in the implementation roadmap.
    rX   titlerW   .z(Which of the 6 dimensions this addressesrZ   r   rD   priorityrH   
complexityNrv   estimated_weekly_hours_savedestimated_monthly_roi_audzHAgileAdapt product that delivers this (e.g. 'ReceptionistAI Enterprise')r[   agileadapt_productTz8True if AgileAdapt can deliver this as a managed servicerd   ry   done_for_you)r   r   r   r   r   r
   r   r   r   r   r   r(   r)   r*   r   r   A  sy     J3,VWIsW((48 /8155(-^)  NL$ r)   r   c                      e Zd ZU dZ eddd      Zded<   ded	<    edd
      Zded<    edd      Zded<   ded<   ded<   ded<   y)ImplementationPhasezF
    One phase of the implementation roadmap (30/60/90/180 days).
    .rU      r   r   phase_numberrX   r   u   e.g. 'Days 1–30'rZ   durationz!One-sentence theme for this phasefocuszlist[RecommendedAction]actionsrk   expected_outcomessuccess_metricN)	r   r   r   r   r
   r   r   r   r   r(   r)   r*   r   r   W  sW     caA.L#.J#+?@Hc@s(KLE3L$$  r)   r   c                  T   e Zd ZU dZ edd      Zded<    eej                        Z	ded	<   d
ed<    edddd      Z
ded<    edddd      Zded<    eej                        Zded<    edd      Zded<    eed      Zded <    ed!d"      Zd#ed$<    eed%      Zd&ed'<    ed(d)*      Zded+<    ed(d,*      Zded-<    ed!d.      Zd/ed0<    ed1d2*      Zded3<    ed4d5*      Zded6<    ed78      d>d9       Zed?d:       Zed?d;       Zed@d<       ZedAd=       Zy!)BAIReadinessReportz
    The complete AI Transformation Audit Report.

    This is the primary output of AuditReportGenerator.
    All 6 dimension scores, ROI projections, roadmap, and competitive context.
    .z%Unique report ID, e.g. 'AAR-2026-001'rZ   rX   	report_idr   r   generated_atrT   company   zNExactly 6 dimension scores: Operations, CX, Data, Technology, People, Strategy)rV   
max_lengthrW   list[DimensionScore]dimension_scoresr   r   r   z*Weighted average of all 6 dimension scoresr~   r   overall_ai_readiness_indexr   r8   overall_gradeu%   3–5 sentence plain-language summaryexecutive_summaryz1Conservative, Base Case, and Optimistic scenariosri   zlist[ROIProjection]roi_projectionsNz7Total addressable annual savings + revenue gains in AUDrv   total_annual_opportunity_audz84-phase roadmap: Foundation, Quick Wins, Scale, Optimisezlist[ImplementationPhase]implementation_phasesr   z@Plain English statement of competitive risk if AI is not adoptedrd   competitive_risk_summaryz/Industry-specific context on AI adoption trendsindustry_ai_adoption_ratez2Recommended ReceptionistAI tier or engagement typer[   recommended_agileadapt_tierz8Book a 30-minute strategy call with the AgileAdapt team.zClear CTA for the prospect	next_stepz'https://agileadapt.com.au/strategy-callzCalendar booking linkbooking_urlr   r   c                   | j                   rut        d | j                   D              }t        d | j                   D              }|dkD  rt        ||z  d      | _        t        j                  | j                        | _        | S )Nc              3  4   K   | ]  }|j                     y wr   )r   .0ds     r*   	<genexpr>z:AIReadinessReport.compute_overall_index.<locals>.<genexpr>  s     GAqxxGs   c              3  N   K   | ]  }|j                   |j                  z    y wr   )r   r   r   s     r*   r   z:AIReadinessReport.compute_overall_index.<locals>.<genexpr>  s     Qaqww1Qs   #%r   rU   )r   sumr   r   r   r   r   )r   total_weightweighted_sums      r*   compute_overall_indexz'AIReadinessReport.compute_overall_index  sw      G1F1FGGLQ4;P;PQQLa27|8SUV2W/!/!@!@//"D r)   c                2    t        | j                  d       S )Nc                    | j                   S r   r   r   s    r*   <lambda>z<AIReadinessReport.lowest_scoring_dimension.<locals>.<lambda>  
     r)   key)minr   r   s    r*   lowest_scoring_dimensionz*AIReadinessReport.lowest_scoring_dimension      4((.?@@r)   c                2    t        | j                  d       S )Nc                    | j                   S r   r  r  s    r*   r	  z=AIReadinessReport.highest_scoring_dimension.<locals>.<lambda>  r
  r)   r  )maxr   r   s    r*   highest_scoring_dimensionz+AIReadinessReport.highest_scoring_dimension  r  r)   c                |    | j                   D cg c]"  }|j                  t        j                  k(  s!|$ c}S c c}w r   )r   r   r8   rB   )r   r   s     r*   critical_gapszAIReadinessReport.critical_gaps  s-    00SaAGGz?R?R4RSSSs   "99c                b    g }| j                   D ]  }|j                  |j                          |S r   )r   extendr   )r   winsdims      r*   all_quick_winsz AIReadinessReport.all_quick_wins  s1    (( 	(CKK'	(r)   )r   z'AIReadinessReport')r   r   )r   r   )r   rk   ) r   r   r   r   r
   r   r   r   utcnowr   r   r   r8   rB   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r  r  r  r(   r)   r*   r   r   e  s    3,STIsT"8??CL(C .3ad.*  ).@	)  !&j.A.A BM:B"34[\s\ ,1G,O(  5:M5 /  8=N84  %*V%c  &+E&s  27H2  J0Is  9+K 
 '"	 #	 A A A A T T  r)   r   c                     e Zd ZU dZded<   ded<   ded<   dZded	<   d
Zded<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<    ee      Zded<    eddd       Zd!ed"<    eddd       Zd!ed#<    ed$dd       Zd!ed%<    ee      Zded&<   dZded'<   dZded(<   dZded)<   dZded*<   d+Zded,<   d.d-Zy)/
AuditInputu   
    Simplified intake model — what a voice agent or form collects.

    This is the external API surface. The report generator converts
    AuditInput → CompanyProfile → AIReadinessReport.
    rX   rY   r   r]   r,   r^   rc   rf   rg   rh   Nr[   r\   ra   rb   rs   ru   rv   rw   rx   rp   Fry   rz   r   rk   r{   r|   rU   r}   )re   r`   r   r   r   r   r   r   r   r   rm   rn   ro   r   r   c                4    t        di | j                         S )Nr(   )rT   
model_dumpr   s    r*   to_company_profilezAuditInput.to_company_profile  s    2 122r)   )r   rT   )r   r   r   r   r   rf   rh   r\   rb   rs   ru   rw   rx   rp   rz   r
   r   r{   r   r   r   r   r   rm   rn   ro   r   r   r(   r)   r*   r  r    s    D#E3 "&K%(,,+/=/+/=/,0/0/3_3!%K%"'4'!&t!<OY<#(qQ#?S?$)!a$@c@$Q1;;!&t!<OY<48"M8*.-.*.-.+/=/,L#,3r)   r  )r   
__future__r   rer   r   enumr   typingr   r   pydanticr	   r
   r   r   rX   r   r,   r8   rD   rH   rT   r   r   r   r   r   r  r(   r)   r*   <module>r&     s   , # 	 #    G GsD #t d C sD H@Y H@V''Y ''T1I 1h	 ,) `	 `F$3 $3r)   