workflow vastopolis-outbreak-origin-and-transmission
  template: define-unit -> loop(build-model -> characterise -> visualise ->
            abstract -> assess -> build-model) -> define-unit ->
            characterise -> contextualise -> visualise -> assess ->
            define-unit -> characterise -> contextualise -> visualise ->
            abstract -> generate-knowledge -> generate-knowledge ->
            characterise -> build-model ->
            loop(characterise -> contextualise -> visualise -> abstract ->
                 assess -> build-model) ->
            visualise -> generate-knowledge -> characterise -> visualise ->
            generate-knowledge
  description: "Visual analytics workflow for identifying likely outbreak-origin
    areas, comparing possible transmission mechanisms, and prioritising public
    health deployment using geolocated microblog reports, geographic context,
    population statistics, and weather observations."

# ============================================================================
# INPUT DATA AND INITIAL SPECIFICATIONS
# ============================================================================

artifact D_posts : entities
  origin: given
  internal structure: elementary
  embedment: {space, time}
  features:
    - id: timestamp
      value structure: atomic
      value type: temporal
      description: "Posting time"
    - id: gps_location
      value structure: atomic
      value type: spatial
      description: "GPS coordinate recorded by the mobile device"
    - id: text
      value structure: atomic
      value type: text
      description: "Microblog message text"
    - id: account_id
      value structure: atomic
      value type: reference
      description: "Pseudonymous account identifier, used only for duplicate
        and probable-bot detection"
  description: "Geolocated microblog messages collected during several days
    of the suspected outbreak"

artifact D_city_features : entities
  origin: given
  internal structure: elementary
  embedment: space
  features:
    - id: feature_type
      value structure: atomic
      value type: categorical
      description: "Highway, hospital, landmark, water body, or other map feature"
    - id: geometry
      value structure: atomic
      value type: spatial
      description: "Geographic geometry"
    - id: name
      value structure: atomic
      value type: text
      description: "Map feature name, where available"
  description: "Metropolitan geographic context including highways, hospitals,
    landmarks, and water bodies"

artifact D_zones : entities
  origin: given
  internal structure: region
  embedment: space
  features:
    - id: population
      value structure: atomic
      value type: numeric
      description: "Resident population of the city zone"
    - id: zone_name
      value structure: atomic
      value type: text
      description: "Zone identifier or name"
  description: "Thirteen city zones with population statistics"

artifact D_weather : entities
  origin: given
  internal structure: elementary
  embedment: time
  features:
    - id: wind_speed
      value structure: atomic
      value type: numeric
      description: "Observed wind speed"
    - id: wind_direction
      value structure: atomic
      value type: numeric
      description: "Observed wind direction"
  description: "Daily weather observations for Vastopolis"

artifact K_epidemiology : knowledge(D_posts, D_city_features, D_weather)
  origin: given
  representation form: "domain assumptions and interpretation guidance"
  description: "Public-health knowledge concerning flu-like symptoms,
    plausible reporting biases, plausible transmission mechanisms, expected
    temporal lags, and limitations of social-media data as a proxy for cases"

artifact S_cleaning : specification
  origin: given
  representation form: "filtering rules and uncertainty criteria"
  description: "Rules for duplicate removal, bot detection, timestamp and
    coordinate validation, and retention of uncertainty flags"

artifact S_content_initial : specification
  origin: given
  representation form: "initial text-classification configuration"
  description: "Initial symptom vocabulary, topic-model settings, content
    categories, confidence thresholds, and rules for identifying probable
    self-reported illness"

artifact S_spatiotemporal_units : specification
  origin: given
  representation form: "spatiotemporal aggregation settings"
  description: "Zone, fine-grid, and adaptive-cell resolutions; one-, three-,
    and six-hour temporal bins; population normalization; and low-volume
    uncertainty rules"

artifact S_origin_detection : specification
  origin: given
  representation form: "cluster and origin-ranking criteria"
  description: "Space-time clustering settings, persistence requirement,
    independent-account requirement where possible, onset definition, and
    sensitivity-analysis settings"

artifact S_model_initial : specification
  origin: given
  representation form: "candidate-model configuration"
  description: "Initial lag ranges, candidate source locations, covariates,
    comparison criteria, and transparent count/rate regression forms for
    contact-propagation, airborne, water-exposure, point-source, and mixed
    hypotheses"

assign:
  S_content_current := S_content_initial
  S_model_current := S_model_initial

# ============================================================================
# STEP 1: CLEAN POSTS AND ITERATIVELY REFINE CONTENT CLASSIFICATION
# ============================================================================

transform T_clean_posts :
  intent: define-unit
  manner: "filter and quality-control"
  input: D_posts, S_cleaning
  output: D_clean_posts
  actor: machine
  description: "Remove duplicate posts, obvious automated activity, and posts
    with invalid timestamps or coordinates while retaining quality and
    uncertainty indicators"

artifact D_clean_posts : entities
  internal structure: elementary
  embedment: {space, time}
  features:
    - id: text
      value structure: atomic
      value type: text
      description: "Post text"
    - id: location
      value structure: atomic
      value type: spatial
      description: "Validated GPS coordinate"
    - id: timestamp
      value structure: atomic
      value type: temporal
      description: "Validated posting time"
    - id: data_quality_flag
      value structure: atomic
      value type: categorical
      description: "Reliability and uncertainty flag"
  description: "Quality-controlled microblog posts"

transform T_train_initial_content_model :
  intent: build-model
  manner: "train text classifier and topic model"
  input: D_clean_posts, S_content_current, K_epidemiology
  output: M_content_model_initial
  actor: hybrid
  description: "Construct an initial content model using rules, topic
    modelling, and public-health terminology to distinguish symptom reports
    from news, concern, misinformation, and unrelated posts"

artifact M_content_model_initial : model(D_clean_posts, K_epidemiology)
  model type: "text classifier and topic model"
  representation form: "keyword rules plus topic-model parameters"
  description: "Initial model for classifying illness-related microblog posts"

assign:
  M_content_model := M_content_model_initial

loop L_content_refinement:
  purpose: "Refine illness-report classification until categories and
    confidence judgements are adequate for outbreak analysis"
  until: "Public-health analysts judge that sampled classifications, topic
    interpretations, and uncertainty flags are sufficiently credible"
  body:

    transform T_classify_posts :
      intent: characterise
      manner: "classify text content"
      input: D_clean_posts, M_content_model, S_content_current
      output: F_content_class
      actor: machine
      description: "Assign content categories and confidence values, including
        self-reported symptoms, reports about others, severe illness or death,
        healthcare seeking, news or concern, and unrelated content"

    artifact F_content_class : feature(D_clean_posts)
      value structure: vector
      value type: {categorical, numeric}
      representation form: "content category and confidence per post"
      description: "Probabilistic content labels for cleaned posts"

    transform T_visualise_content_review :
      intent: visualise
      manner: "linked text-map-time review"
      input: D_clean_posts, F_content_class
      output: V_content_review
      actor: machine
      description: "Display sampled original posts, topic/category summaries,
        message locations, and posting times for analyst inspection"

    artifact V_content_review : visualisation(D_clean_posts, F_content_class)
      layout: "linked document list, topic summary, map, and timeline"
      form: "text excerpts, coloured points, bars, and time series"
      encoding: "colour represents content category; map position represents
        GPS location; timeline position represents posting time; text panel
        exposes original messages"
      description: "Evidence view for reviewing text-classification results"

    transform T_interpret_content :
      intent: abstract
      manner: "perception-and-interpretation"
      input: V_content_review, F_content_class, K_epidemiology
      output: P_content_interpretation
      actor: human
      description: "Identify misleading terms, sarcasm, news reposting,
        non-flu conditions, category ambiguities, and meaningful illness-
        related themes"

    artifact P_content_interpretation : pattern(D_clean_posts, F_content_class)
      representation form: "annotated topic and classification issues"
      description: "Observed semantic patterns and classification problems in
        microblog content"

    transform T_assess_content :
      intent: assess
      manner: "assess text-classification adequacy"
      input: V_content_review, P_content_interpretation, F_content_class
      output: K_content_quality, S_content_refined
      actor: human
      description: "Judge whether content categories and confidence thresholds
        are adequate for use as illness indicators; formulate revised settings
        when they are not"

    artifact K_content_quality : knowledge(F_content_class, V_content_review)
      representation form: "quality judgment"
      description: "Analyst judgment about credibility, ambiguity, and
        suitability of classified posts for outbreak analysis"

    artifact S_content_refined : specification
      representation form: "revised text-classification configuration"
      description: "Updated symptom terms, topic interpretation, category
        definitions, thresholds, and exclusion rules"

    if K_content_quality indicates classification refinement needed:
      then:
        transform T_refine_content_model :
          intent: build-model
          manner: "retrain with analyst-guided vocabulary and topic changes"
          input: D_clean_posts, M_content_model, S_content_refined,
                 P_content_interpretation
          output: M_content_model_refined
          actor: hybrid
          description: "Retrain or adjust the content model using analyst-
            identified semantic issues and revised classification settings"

        artifact M_content_model_refined : model(D_clean_posts,
            P_content_interpretation)
          model type: "refined text classifier and topic model"
          representation form: "updated keyword rules and topic-model parameters"
          description: "Revised model for identifying credible illness reports"

        assign:
          M_content_model := M_content_model_refined
          S_content_current := S_content_refined
      else:
        exit loop L_content_refinement

end loop L_content_refinement

transform T_extract_place_mentions :
  intent: characterise
  manner: "named-entity and place-reference extraction"
  input: D_clean_posts, F_content_class, D_city_features
  output: F_place_mentions
  actor: hybrid
  description: "Extract and contextually validate references to landmarks,
    hospitals, events, workplaces, water locations, and travel locations"

artifact F_place_mentions : feature(D_clean_posts)
  value structure: list
  value type: reference
  representation form: "linked map-feature references and unresolved place names"
  description: "Place and facility references found in microblog text"

# ============================================================================
# STEP 2: CONSTRUCT AND VALIDATE SPATIOTEMPORAL OUTBREAK SIGNALS
# ============================================================================

transform T_select_health_reports :
  intent: define-unit
  manner: "filter by classified health-report category"
  input: D_clean_posts, F_content_class, K_content_quality
  output: D_symptom_reports, D_severe_reports
  actor: machine
  description: "Select high-confidence symptom reports and separately retain
    severe-illness or death-associated reports"

artifact D_symptom_reports : entities
  internal structure: elementary
  embedment: {space, time}
  features:
    - id: symptom_confidence
      value structure: atomic
      value type: numeric
      description: "Confidence that the post reports flu-like illness"
    - id: report_type
      value structure: atomic
      value type: categorical
      description: "Self-report or report about another person"
  description: "High-confidence flu-like symptom-report posts"

artifact D_severe_reports : entities
  internal structure: elementary
  embedment: {space, time}
  features:
    - id: severity_type
      value structure: atomic
      value type: categorical
      description: "Severe illness, death, or hospital-related report category"
  description: "Posts associated with severe illness, deaths, or healthcare seeking"

transform T_construct_signal_units :
  intent: define-unit
  manner: "spatiotemporal aggregation"
  input: D_symptom_reports, D_severe_reports, D_zones, S_spatiotemporal_units
  output: D_analysis_areas, D_signal_units
  actor: machine
  description: "Create city-zone, fine-grid, or adaptive spatial units and
    time-binned units for comparing outbreak signals across resolutions"

artifact D_analysis_areas : entities
  internal structure: region
  embedment: space
  features:
    - id: area_type
      value structure: atomic
      value type: categorical
      description: "Zone, grid cell, or adaptive area"
    - id: population
      value structure: atomic
      value type: numeric
      description: "Population estimate for the analysis area"
  description: "Spatial analysis areas at multiple resolutions"

artifact D_signal_units : entities
  internal structure: group/cluster
  embedment: {space, time}
  features:
    - id: temporal_bin
      value structure: atomic
      value type: temporal
      description: "Time interval represented by the unit"
    - id: spatial_area
      value structure: atomic
      value type: reference
      description: "Associated analysis area"
  description: "Aggregated symptom and severe-report observations by area and time"

transform T_compute_outbreak_indicators :
  intent: characterise
  manner: "aggregate and normalise"
  input: D_signal_units, D_clean_posts, D_analysis_areas
  output: F_outbreak_indicators
  actor: machine
  description: "Compute symptom counts, population-normalised rates, symptom
    share of local posting volume, severe-report counts, growth measures, and
    uncertainty indicators"

artifact F_outbreak_indicators : feature(D_signal_units)
  value structure: vector
  value type: numeric
  representation form: "time-binned outbreak indicator vector"
  description: "Counts, rates, posting-volume-adjusted measures, severe-report
    signals, growth estimates, and uncertainty values"

transform T_arrange_signals_on_map :
  intent: contextualise
  manner: "map-based"
  input: D_signal_units, D_analysis_areas
  output: A_signal_map
  actor: machine
  description: "Arrange aggregated signal units in their corresponding
    geographic analysis areas"

artifact A_signal_map : arrangement(D_signal_units)
  context: D_analysis_areas
  principle: "spatial-area membership"
  description: "Map arrangement of outbreak signal units"

transform T_visualise_outbreak_signals :
  intent: visualise
  manner: "coordinated map and temporal views"
  input: A_signal_map, F_outbreak_indicators, D_city_features, D_severe_reports
  output: V_signal_overview
  actor: machine
  description: "Show animated maps, area time series, temporal heatmaps,
    severe-report signals, and uncertainty indicators"

artifact V_signal_overview : visualisation(A_signal_map, F_outbreak_indicators,
    D_city_features, D_severe_reports)
  layout: "linked map, space-time heatmap, and zone time-series views"
  form: "coloured areas, points, lines, and uncertainty bands"
  encoding: "map position from arrangement; colour and height from symptom
    rate; point overlays from severe reports; bands represent uncertainty"
  description: "Visual overview for checking whether apparent peaks are
    credible illness signals rather than posting or media artifacts"

transform T_assess_signal_validity :
  intent: assess
  manner: "judge social-media signal credibility"
  input: V_signal_overview, D_symptom_reports, D_severe_reports,
         K_content_quality, K_epidemiology
  output: K_signal_validity
  actor: human
  description: "Inspect supporting posts and assess whether observed peaks
    plausibly reflect illness reporting rather than news amplification,
    hospital-reporting effects, or a viral-post cascade"

artifact K_signal_validity : knowledge(V_signal_overview, D_symptom_reports)
  representation form: "quality judgment and caveats"
  description: "Analyst assessment of credible, uncertain, and likely
    artifact-driven outbreak signals"

# ============================================================================
# STEP 3: DETECT PERSISTENT EARLY CLUSTERS AND RANK ORIGIN CANDIDATES
# ============================================================================

transform T_cluster_outbreak_events :
  intent: define-unit
  manner: "space-time density clustering"
  input: D_symptom_reports, F_outbreak_indicators, S_origin_detection
  output: D_outbreak_clusters, F_cluster_membership
  actor: machine
  description: "Identify persistent space-time concentrations of independent
    symptom reports and distinguish them from isolated bursts"

artifact D_outbreak_clusters : entities
  internal structure: group/cluster
  embedment: {space, time}
  features:
    - id: cluster_extent
      value structure: vector
      value type: {spatial, temporal}
      description: "Spatial and temporal extent of the cluster"
  description: "Persistent candidate outbreak clusters"

artifact F_cluster_membership : feature(D_symptom_reports)
  value structure: atomic
  value type: reference
  description: "Outbreak-cluster identifier for each symptom report"

transform T_characterise_clusters :
  intent: characterise
  manner: "compute onset, persistence, and robustness descriptors"
  input: D_outbreak_clusters, D_signal_units, F_outbreak_indicators,
         D_analysis_areas, S_origin_detection
  output: F_cluster_descriptors
  actor: machine
  description: "Compute sustained onset time, intensity, persistence,
    population-normalised severity, subsequent expansion, and sensitivity to
    classification thresholds and spatial-temporal resolutions"

artifact F_cluster_descriptors : feature(D_outbreak_clusters)
  value structure: vector
  value type: {numeric, temporal}
  representation form: "origin-evidence descriptor vector"
  description: "Features used to compare candidate origin areas"

transform T_arrange_clusters_on_map :
  intent: contextualise
  manner: "map-based"
  input: D_outbreak_clusters, D_analysis_areas
  output: A_cluster_map
  actor: machine
  description: "Place outbreak clusters on the geographic analysis map"

artifact A_cluster_map : arrangement(D_outbreak_clusters)
  context: D_analysis_areas
  principle: "cluster centroid and spatial extent"
  description: "Geographic arrangement of outbreak clusters"

transform T_visualise_onset_and_expansion :
  intent: visualise
  manner: "animated onset and expansion map"
  input: A_cluster_map, F_cluster_descriptors, D_city_features,
         F_outbreak_indicators
  output: V_origin_evidence
  actor: machine
  description: "Show onset times, expansion contours, candidate clusters,
    nearby hospitals, landmarks, highways, and water bodies"

artifact V_origin_evidence : visualisation(A_cluster_map, F_cluster_descriptors,
    D_city_features, F_outbreak_indicators)
  layout: "time-enabled geographic map with linked cluster ranking"
  form: "coloured cluster regions, contours, points, and ranked bars"
  encoding: "colour represents onset time; size represents intensity;
    contours represent later expansion; map overlays show city features"
  description: "Evidence view for identifying early sustained outbreak areas"

transform T_interpret_origin_patterns :
  intent: abstract
  manner: "rank persistent early clusters"
  input: V_origin_evidence, F_cluster_descriptors, K_signal_validity
  output: P_origin_candidates
  actor: hybrid
  description: "Rank candidate origin areas by early sustained onset,
    persistence, intensity, downstream temporal ordering, and robustness,
    while retaining the distinction between reporting origin and infection origin"

artifact P_origin_candidates : pattern(D_outbreak_clusters,
    F_cluster_descriptors)
  representation form: "ranked candidate-origin patterns"
  description: "Persistent early outbreak clusters and their observed
    expansion relationships"

transform T_formulate_origin_assessment :
  intent: generate-knowledge
  manner: "formulate-statements"
  input: P_origin_candidates, V_origin_evidence, K_signal_validity,
         K_epidemiology
  output: K_origin_assessment
  actor: human
  description: "Formulate a ranked, uncertainty-aware assessment of candidate
    source areas, including supporting evidence, contradictory evidence, and
    reporting-bias caveats"

artifact K_origin_assessment : knowledge(P_origin_candidates,
    V_origin_evidence)
  representation form: "ranked evidence statements"
  description: "Candidate outbreak-origin areas with confidence, supporting
    observations, contradictions, and caveats"

# ============================================================================
# STEP 4: FORMULATE COMPETING TRANSMISSION HYPOTHESES AND PREDICTORS
# ============================================================================

transform T_formulate_hypotheses :
  intent: generate-knowledge
  manner: "formulate-statements and modelling strategy"
  input: K_origin_assessment, K_epidemiology, D_city_features, D_weather
  output: K_transmission_hypotheses, S_hypothesis_models
  actor: human
  description: "Define testable person-to-person, airborne, waterborne,
    common-point-source, reporting-artifact, and mixed-mechanism hypotheses,
    with expected observable patterns and comparison requirements"

artifact K_transmission_hypotheses : knowledge(K_origin_assessment,
    D_city_features, D_weather)
  representation form: "competing explanatory hypotheses"
  description: "Explicit statements of expected spatial and temporal patterns
    for alternative transmission mechanisms"

artifact S_hypothesis_models : specification
  representation form: "model structure and comparison constraints"
  description: "Hypothesis-specific predictors, lags, candidate-source
    handling, validation periods, matched-area comparisons, and complexity
    constraints"

transform T_compute_exposure_predictors :
  intent: characterise
  manner: "derive spatiotemporal explanatory features"
  input: D_signal_units, F_outbreak_indicators, D_analysis_areas,
         D_city_features, D_weather, K_origin_assessment,
         S_hypothesis_models
  output: F_exposure_predictors
  actor: machine
  description: "Compute prior local rates, adjacent-zone and highway-connected
    rates, source distance, downwind alignment, wind speed, water proximity,
    reporting volume, hospital proximity, and population-related predictors"

artifact F_exposure_predictors : feature(D_signal_units)
  value structure: vector
  value type: numeric
  representation form: "lagged spatial-exposure predictor vector"
  description: "Predictors for contrasting transmission mechanisms"

transform T_build_initial_models :
  intent: build-model
  manner: "fit alternative transparent spatiotemporal regressions"
  input: D_signal_units, F_outbreak_indicators, F_exposure_predictors,
         K_transmission_hypotheses, S_model_current
  output: M_contact_initial, M_airborne_initial, M_water_initial,
          M_point_source_initial, M_mixed_initial
  actor: machine
  description: "Fit initial explanatory models for contact propagation,
    airborne spread, water exposure, common point source, and mixed mechanisms"

artifact M_contact_initial : model(F_outbreak_indicators,
    F_exposure_predictors)
  model type: "spatiotemporal count or rate regression model"
  representation form: "lagged local, adjacent-zone, and highway-connectivity terms"
  description: "Model of person-to-person or mobility-mediated propagation"

artifact M_airborne_initial : model(F_outbreak_indicators,
    F_exposure_predictors)
  model type: "spatiotemporal count or rate regression model"
  representation form: "source-distance, downwind-alignment, wind-speed, and lag terms"
  description: "Model of airborne or aerosol-mediated spread"

artifact M_water_initial : model(F_outbreak_indicators,
    F_exposure_predictors)
  model type: "spatiotemporal count or rate regression model"
  representation form: "water-proximity or service-area exposure terms"
  description: "Model of water-related exposure"

artifact M_point_source_initial : model(F_outbreak_indicators,
    F_exposure_predictors)
  model type: "spatiotemporal count or rate regression model"
  representation form: "candidate-event or candidate-location exposure terms"
  description: "Model of common-event or local point-source exposure"

artifact M_mixed_initial : model(F_outbreak_indicators,
    F_exposure_predictors)
  model type: "spatiotemporal count or rate regression model"
  representation form: "penalised combination of mechanism-specific predictors"
  description: "Model allowing more than one transmission mechanism"

assign:
  M_contact := M_contact_initial
  M_airborne := M_airborne_initial
  M_water := M_water_initial
  M_point_source := M_point_source_initial
  M_mixed := M_mixed_initial

# ============================================================================
# STEP 5: RESIDUAL-DRIVEN HYPOTHESIS COMPARISON AND MODEL REFINEMENT
# ============================================================================

loop L_hypothesis_refinement:
  purpose: "Compare competing transmission explanations and refine models only
    when visual residual evidence identifies a meaningful missing factor"
  until: "Model performance, residual patterns, validation results, and
    epidemiological interpretability are adequate for operational comparison"
  body:

    transform T_apply_hypothesis_models :
      intent: characterise
      manner: "predict and compute residuals"
      input: D_signal_units, F_outbreak_indicators, F_exposure_predictors,
             M_contact, M_airborne, M_water, M_point_source, M_mixed
      output: F_model_outputs
      actor: machine
      description: "Generate model-specific predicted rates, residuals,
        uncertainty estimates, fit statistics, and held-out location/time
        validation measures"

    artifact F_model_outputs : feature(D_signal_units)
      value structure: vector
      value type: numeric
      representation form: "observed, predicted, residual, and validation values per model"
      description: "Comparative outputs of the candidate transmission models"

    transform T_arrange_model_outputs :
      intent: contextualise
      manner: "map-based"
      input: D_signal_units, D_analysis_areas
      output: A_model_map
      actor: machine
      description: "Arrange model predictions and residuals by analysis area"

    artifact A_model_map : arrangement(D_signal_units)
      context: D_analysis_areas
      principle: "spatial-area membership"
      description: "Geographic arrangement for model diagnostics"

    transform T_visualise_model_diagnostics :
      intent: visualise
      manner: "comparative residual and validation display"
      input: A_model_map, F_model_outputs, D_weather, D_city_features,
             K_transmission_hypotheses
      output: V_model_diagnostics
      actor: machine
      description: "Display observed-versus-predicted rates, residual maps,
        uncertainty intervals, model comparisons, lag plots, wind vectors,
        and downwind/upwind contrasts"

    artifact V_model_diagnostics : visualisation(A_model_map, F_model_outputs,
        D_weather, D_city_features)
      layout: "linked maps, time series, observed-predicted plots, residual
        panels, and model-comparison charts"
      form: "coloured areas, lines, arrows, scatterplots, and uncertainty bands"
      encoding: "map colour represents residual or predicted rate; wind arrows
        represent direction and speed; line plots show lagged changes;
        panels compare alternative models"
      description: "Visual diagnostic environment for evaluating competing
        transmission explanations"

    transform T_interpret_residual_patterns :
      intent: abstract
      manner: "perception-and-interpretation"
      input: V_model_diagnostics, F_model_outputs, K_transmission_hypotheses
      output: P_model_residual_patterns
      actor: human
      description: "Identify coherent unexplained residual hotspots, stable
        lagged wind effects, spatial propagation waves, water-aligned
        concentrations, or model-specific failure patterns"

    artifact P_model_residual_patterns : pattern(F_model_outputs,
        V_model_diagnostics)
      representation form: "annotated residual and cross-impact patterns"
      description: "Observed explanatory successes, failures, and possible
        missing factors in the transmission models"

    transform T_assess_hypothesis_models :
      intent: assess
      manner: "assess model adequacy and comparative support"
      input: V_model_diagnostics, P_model_residual_patterns,
             K_transmission_hypotheses, S_model_current
      output: K_model_assessment, S_model_refined
      actor: human
      description: "Assess predictive performance, residual structure,
        robustness across wind changes and resolutions, plausibility, and
        whether model refinement is justified"

    artifact K_model_assessment : knowledge(F_model_outputs,
        P_model_residual_patterns)
      representation form: "comparative quality judgment"
      description: "Assessment of each transmission model's adequacy,
        limitations, residual anomalies, and relative operational support"

    artifact S_model_refined : specification
      representation form: "revised model configuration"
      description: "Revised predictors, lag choices, interaction terms,
        thresholds, validation settings, or feature exclusions justified by
        residual analysis"

    if K_model_assessment indicates refinement needed:
      then:
        transform T_refine_hypothesis_models :
          intent: build-model
          manner: "residual-driven regression refinement"
          input: D_signal_units, F_outbreak_indicators, F_exposure_predictors,
                 P_model_residual_patterns, S_model_refined,
                 M_contact, M_airborne, M_water, M_point_source, M_mixed
          output: M_contact_refined, M_airborne_refined, M_water_refined,
                  M_point_source_refined, M_mixed_refined
          actor: hybrid
          description: "Refit candidate models after adding, removing, or
            reconfiguring factors only where diagnostic evidence supports it"

        artifact M_contact_refined : model(F_outbreak_indicators,
            F_exposure_predictors)
          model type: "refined spatiotemporal regression model"
          description: "Refined contact-propagation explanation"

        artifact M_airborne_refined : model(F_outbreak_indicators,
            F_exposure_predictors)
          model type: "refined spatiotemporal regression model"
          description: "Refined airborne-spread explanation"

        artifact M_water_refined : model(F_outbreak_indicators,
            F_exposure_predictors)
          model type: "refined spatiotemporal regression model"
          description: "Refined water-exposure explanation"

        artifact M_point_source_refined : model(F_outbreak_indicators,
            F_exposure_predictors)
          model type: "refined spatiotemporal regression model"
          description: "Refined common-point-source explanation"

        artifact M_mixed_refined : model(F_outbreak_indicators,
            F_exposure_predictors)
          model type: "refined spatiotemporal regression model"
          description: "Refined mixed-mechanism explanation"

        assign:
          M_contact := M_contact_refined
          M_airborne := M_airborne_refined
          M_water := M_water_refined
          M_point_source := M_point_source_refined
          M_mixed := M_mixed_refined
          S_model_current := S_model_refined
      else:
        exit loop L_hypothesis_refinement

end loop L_hypothesis_refinement

# ============================================================================
# STEP 6: INVESTIGATE CANDIDATE SOURCES AND SYNTHESISE EVIDENCE
# ============================================================================

transform T_visualise_source_evidence :
  intent: visualise
  manner: "linked evidence investigation"
  input: D_symptom_reports, D_severe_reports, F_place_mentions,
         P_origin_candidates, F_model_outputs, D_city_features,
         V_model_diagnostics
  output: V_source_investigation
  actor: machine
  description: "Support inspection of candidate-source messages in temporal
    order, linked landmarks and facilities, backward tracing from later
    hotspots, matched comparison areas, and conflicting evidence"

artifact V_source_investigation : visualisation(D_symptom_reports,
    D_severe_reports, F_place_mentions, P_origin_candidates,
    F_model_outputs, D_city_features)
  layout: "linked map, message timeline, candidate-source panel, and
    comparison-area views"
  form: "points, trajectories, text excerpts, ranked lists, and maps"
  encoding: "message positions derive from GPS coordinates; temporal order
    derives from timestamps; overlays show candidate origins, facilities,
    water bodies, highways, and model-supported exposure relationships"
  description: "Detailed evidence view for field investigation of possible
    source locations and exposure mechanisms"

transform T_investigate_candidate_sources :
  intent: generate-knowledge
  manner: "formulate evidence statements"
  input: V_source_investigation, K_origin_assessment, K_model_assessment,
         K_transmission_hypotheses, K_epidemiology
  output: K_source_investigation
  actor: human
  description: "Record source-specific supporting and contradictory evidence,
    compare matched non-outbreak areas, distinguish infection-source evidence
    from care-seeking/reporting effects, and identify field-investigation needs"

artifact K_source_investigation : knowledge(V_source_investigation,
    K_origin_assessment, K_model_assessment)
  representation form: "candidate-source evidence log"
  description: "Documented interpretation of likely sources, possible
    mechanisms, uncertainties, contradictions, and recommended validation
    actions"

transform T_synthesise_transmission_assessment :
  intent: generate-knowledge
  manner: "formulate-statements"
  input: K_origin_assessment, K_model_assessment, K_source_investigation,
         K_transmission_hypotheses, K_signal_validity
  output: K_transmission_assessment
  actor: human
  description: "Synthesize the relative support for person-to-person,
    airborne, waterborne, point-source, reporting-artifact, and mixed
    explanations without claiming definitive causation from microblog data"

artifact K_transmission_assessment : knowledge(K_origin_assessment,
    K_model_assessment, K_source_investigation)
  representation form: "uncertainty-aware explanatory assessment"
  description: "Ranked transmission hypotheses, supporting and contradictory
    evidence, uncertainty, and requirements for clinical or environmental
    confirmation"

# ============================================================================
# STEP 7: PRIORITISE DEPLOYMENT AND COMMUNICATE RESULTS
# ============================================================================

transform T_compute_resource_priority :
  intent: characterise
  manner: "risk and deployment prioritisation"
  input: D_signal_units, F_outbreak_indicators, F_model_outputs,
         D_analysis_areas, K_transmission_assessment
  output: F_resource_priority
  actor: machine
  description: "Compute area priority from current intensity, growth rate,
    severe-report signal, population exposure, hospital context, model support,
    and uncertainty"

artifact F_resource_priority : feature(D_analysis_areas)
  value structure: vector
  value type: {numeric, ordinal}
  representation form: "priority score with explanatory components"
  description: "Emergency-management priority and contributing risk factors
    for each analysis area"

transform T_visualise_operational_dashboard :
  intent: visualise
  manner: "linked emergency-management dashboard"
  input: A_signal_map, F_outbreak_indicators, P_origin_candidates,
         K_transmission_assessment, F_resource_priority, D_city_features
  output: V_operational_dashboard
  actor: machine
  description: "Provide current risk, origin candidates, transmission evidence,
    uncertainty, and resource-priority views in one linked dashboard"

artifact V_operational_dashboard : visualisation(A_signal_map,
    F_outbreak_indicators, P_origin_candidates, K_transmission_assessment,
    F_resource_priority, D_city_features)
  layout: "linked current-risk map, origin-ranking panel, transmission-evidence
    panel, and resource-priority map"
  form: "coloured areas, ranked lists, time series, symbols, and uncertainty bands"
  encoding: "area colour and size encode current risk and priority; panels
    show ranked origin candidates and relative hypothesis support; symbols
    identify hospitals, highways, landmarks, and water bodies"
  description: "Operational dashboard for public-health and emergency managers"

transform T_formulate_deployment_recommendations :
  intent: generate-knowledge
  manner: "derive-rules and write-summary"
  input: V_operational_dashboard, K_transmission_assessment,
         K_source_investigation, K_epidemiology
  output: K_deployment_recommendations, K_update_protocol
  actor: human
  description: "Recommend immediate resource deployment, targeted field
    investigations, clinical and environmental validation, public communication,
    and documented re-analysis as new posts and weather observations arrive"

artifact K_deployment_recommendations : knowledge(V_operational_dashboard,
    K_transmission_assessment)
  representation form: "prioritised recommendations"
  description: "Recommended deployment of testing, clinical outreach,
    communications, environmental inspection, and emergency resources, with
    uncertainty-aware rationale"

artifact K_update_protocol : knowledge(V_operational_dashboard,
    K_deployment_recommendations)
  representation form: "operational update protocol"
  description: "Instructions to preserve the analysis log and rerun the
    workflow when new microblogs, weather data, clinical surveillance, or
    environmental evidence become available"