# Conceptual Health™ — Action ↔ Axis Wiring Map
#
# Every patient action — anywhere in the Guardian Orb app, the web portal, the
# clinic console, the watch, the wearable, a partner API — maps here.  Each
# action declares which sub-signal(s) it updates (from sub-signals.yaml),
# how the update is computed, and which mining lane(s) it credits.
#
# This file is the single contract between "the user did a thing" and
# "the Master Equation moved."  Adding a new product surface means adding
# rows here — never wiring updates ad-hoc in feature code.
#
# Source-of-truth chain:
#   master-equation/sub-signals.yaml       ← signal definitions
#   master-equation/action-axis-map.yaml   ← this file (action → signal)
#   backend/app/health/axis_aggregator.py  ← consumes signal events
#
# Schema:
#   actions:
#     - id: <action_id>                       stable snake_case
#       name: <human label>
#       surface: <ios | web | watch | widget | clinic | api | partner>
#       trigger: <self_report_form | timer | hk_sync | partner_sync | …>
#       updates:                              one or more signal effects
#         - signal: <signal_id from sub-signals.yaml>
#           mode: <set | add | delta | bool>  how the value is applied
#           value: <number, "user_input", or formula reference>
#           cap_per_day: <number, optional>
#       hcr_lanes: [<lane id>, …]             which HCR lanes earn HCR
#       hcc_payout: <ratio of earned HCR convertible to HCC>
#       fraud_controls: [<rule id>, …]        anti-gaming rules applied
#       evidence_required: <none | photo | gps | wearable_signature | clinician>
#       notes: <optional>
#
# Patent: U.S. Provisional 63/921,717.

version: 1
schema_revision: "2026-05-14"

# ────────────────────────────────────────────────────────────────────
# Fraud-control rules referenced below
# ────────────────────────────────────────────────────────────────────
fraud_controls:
  rule_wearable_signature:
    desc: Action must carry a signed payload from a paired wearable.
  rule_gps_required:
    desc: Action must carry a GPS coordinate within plausible bounds.
  rule_daily_cap:
    desc: Per-day max applies; excess is logged but not rewarded.
  rule_clinician_witnessed:
    desc: A clinician account must co-sign the event.
  rule_unique_per_window:
    desc: Same action may not repeat inside its dedupe window.
  rule_consent_active:
    desc: User's data-share consent must be active.

# ────────────────────────────────────────────────────────────────────
# Actions
# ────────────────────────────────────────────────────────────────────
actions:

  # ─── Movement ─────────────────────────────────────────────────────
  - id: log_steps_hk_sync
    name: Apple Health / Google Fit steps sync
    surface: ios
    trigger: hk_sync
    updates:
      - { signal: po_steps_daily,     mode: set, value: user_input }
      - { signal: po_active_minutes,  mode: set, value: user_input }
    hcr_lanes: [hcr_movement]
    hcc_payout: 0.5
    fraud_controls: [rule_wearable_signature]
    evidence_required: wearable_signature

  - id: log_workout_session
    name: Log a workout session
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: po_active_minutes,    mode: add, value: user_input, cap_per_day: 240 }
      - { signal: po_strength_sessions, mode: add, value: 1, cap_per_day: 3 }
    hcr_lanes: [hcr_movement, hcr_cardio]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap, rule_wearable_signature]
    evidence_required: wearable_signature

  - id: outdoor_session_gps
    name: Outdoor session with GPS
    surface: watch
    trigger: timer
    updates:
      - { signal: po_outdoor_minutes,    mode: add, value: user_input, cap_per_day: 360 }
      - { signal: po_sun_exposure_safe,  mode: add, value: user_input, cap_per_day: 60 }
      - { signal: es_green_space_minutes, mode: add, value: user_input, cap_per_day: 240 }
    hcr_lanes: [hcr_nature, hcr_stewardship]
    hcc_payout: 0.5
    fraud_controls: [rule_gps_required, rule_wearable_signature]
    evidence_required: gps

  - id: sleep_record
    name: Record sleep window
    surface: ios
    trigger: hk_sync
    updates:
      - { signal: po_sleep_minutes, mode: set, value: user_input }
      - { signal: po_sleep_quality, mode: set, value: user_input }
    hcr_lanes: [hcr_recovery]
    hcc_payout: 0.3
    fraud_controls: [rule_wearable_signature]
    evidence_required: wearable_signature

  # ─── Nutrition ────────────────────────────────────────────────────
  - id: log_meal
    name: Log a meal
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: nm_whole_food_ratio, mode: delta, value: user_input }
      - { signal: nm_protein_grams,    mode: add,   value: user_input, cap_per_day: 300 }
      - { signal: nm_added_sugar,      mode: add,   value: user_input, cap_per_day: 300 }
    hcr_lanes: [hcr_nutrition]
    hcc_payout: 0.3
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: log_water
    name: Log water intake
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: nm_water_intake, mode: add, value: user_input, cap_per_day: 6 }
    hcr_lanes: [hcr_nutrition]
    hcc_payout: 0.2
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: lab_result_import
    name: Import lab result
    surface: clinic
    trigger: partner_sync
    updates:
      - { signal: nm_fasting_glucose, mode: set, value: user_input }
      - { signal: nm_hba1c,           mode: set, value: user_input }
      - { signal: nm_lipid_ldl,       mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_clinician_witnessed]
    evidence_required: clinician

  - id: supplement_check
    name: Daily supplement adherence check
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: nm_supplement_adherence, mode: set, value: user_input }
    hcr_lanes: [hcr_nutrition]
    hcc_payout: 0.2
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  # ─── Emotional / Mind ─────────────────────────────────────────────
  - id: daily_mood_checkin
    name: Daily mood check-in
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: er_mood_self_rating, mode: set, value: user_input }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.3
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: phq9_assessment
    name: PHQ-9 assessment
    surface: clinic
    trigger: self_report_form
    updates:
      - { signal: er_phq9, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_clinician_witnessed]
    evidence_required: clinician

  - id: gad7_assessment
    name: GAD-7 assessment
    surface: clinic
    trigger: self_report_form
    updates:
      - { signal: er_gad7, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_clinician_witnessed]
    evidence_required: clinician

  - id: journal_entry
    name: Write a journal / dream entry
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: er_journal_entries, mode: add, value: 1, cap_per_day: 3 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: therapy_visit
    name: Therapy / counseling session
    surface: clinic
    trigger: partner_sync
    updates:
      - { signal: er_therapy_attendance, mode: bool, value: 1 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.5
    fraud_controls: [rule_clinician_witnessed]
    evidence_required: clinician

  # ─── Social / Communal ────────────────────────────────────────────
  - id: log_in_person_contact
    name: Log meaningful in-person contact
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: sc_in_person_contacts, mode: add, value: 1, cap_per_day: 10 }
    hcr_lanes: [hcr_community]
    hcc_payout: 0.3
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: volunteer_session
    name: Log volunteer / service session
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: sc_volunteer_minutes, mode: add, value: user_input, cap_per_day: 480 }
    hcr_lanes: [hcr_community]
    hcc_payout: 0.6
    fraud_controls: [rule_daily_cap, rule_gps_required]
    evidence_required: gps

  - id: family_meal
    name: Shared family meal
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: sc_family_meals, mode: add, value: 1, cap_per_day: 3 }
    hcr_lanes: [hcr_community]
    hcc_payout: 0.2
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: loneliness_assessment
    name: UCLA loneliness short
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: sc_loneliness_scale, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: civic_action_log
    name: Civic / voting / town-hall action
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: sc_civic_participation, mode: bool, value: 1 }
    hcr_lanes: [hcr_community]
    hcc_payout: 0.3
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  # ─── Spiritual / Reflective ───────────────────────────────────────
  - id: meditation_session
    name: Meditation / contemplation session
    surface: ios
    trigger: timer
    updates:
      - { signal: rs_meditation_minutes, mode: add, value: user_input, cap_per_day: 120 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: prayer_session
    name: Prayer / devotion session
    surface: ios
    trigger: timer
    updates:
      - { signal: rs_prayer_minutes, mode: add, value: user_input, cap_per_day: 120 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: gratitude_entry
    name: Gratitude entry
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: rs_gratitude_practice, mode: add, value: 1, cap_per_day: 5 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.3
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: scripture_session
    name: Scripture / wisdom study
    surface: ios
    trigger: timer
    updates:
      - { signal: rs_scripture_study, mode: add, value: user_input, cap_per_day: 120 }
    hcr_lanes: [hcr_mind]
    hcc_payout: 0.3
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: service_attendance
    name: Service / gathering attendance
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: rs_service_attendance, mode: add, value: 1, cap_per_day: 1 }
    hcr_lanes: [hcr_community]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap, rule_gps_required]
    evidence_required: gps

  - id: purpose_rating
    name: Purpose-in-life rating
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: rs_purpose_in_life, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  # ─── Environmental / Stewardship ──────────────────────────────────
  - id: aqi_partner_sync
    name: AQI partner sync
    surface: api
    trigger: partner_sync
    updates:
      - { signal: es_air_quality_exposure, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_consent_active]
    evidence_required: none

  - id: recycle_action
    name: Recycle / compost action
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: es_recycle_compost, mode: bool, value: 1 }
    hcr_lanes: [hcr_stewardship]
    hcc_payout: 0.2
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: active_commute_log
    name: Active / low-emission commute
    surface: watch
    trigger: hk_sync
    updates:
      - { signal: es_active_commute, mode: set, value: user_input }
    hcr_lanes: [hcr_stewardship]
    hcc_payout: 0.5
    fraud_controls: [rule_wearable_signature, rule_gps_required]
    evidence_required: gps

  - id: local_food_log
    name: Local / seasonal food log
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: es_local_food_ratio, mode: set, value: user_input }
    hcr_lanes: [hcr_stewardship]
    hcc_payout: 0.3
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: home_air_filter_check
    name: Home air-filter maintenance
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: es_home_air_filter, mode: bool, value: 1 }
    hcr_lanes: [hcr_stewardship]
    hcc_payout: 0.2
    fraud_controls: [rule_unique_per_window]
    evidence_required: photo

  # ─── Technological / Adaptive ─────────────────────────────────────
  - id: focus_block_complete
    name: Complete a deep-focus block
    surface: ios
    trigger: timer
    updates:
      - { signal: ta_focus_blocks, mode: add, value: 1, cap_per_day: 8 }
    hcr_lanes: [hcr_learning]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: skill_minutes_log
    name: Skill-building minutes
    surface: ios
    trigger: timer
    updates:
      - { signal: ta_skill_minutes, mode: add, value: user_input, cap_per_day: 180 }
    hcr_lanes: [hcr_learning]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: telehealth_visit
    name: Telehealth visit
    surface: clinic
    trigger: partner_sync
    updates:
      - { signal: ta_telehealth_engagement, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_clinician_witnessed]
    evidence_required: clinician

  - id: security_hygiene_check
    name: Security-hygiene self-audit
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: ta_security_hygiene, mode: set, value: user_input }
    hcr_lanes: [hcr_learning]
    hcc_payout: 0.2
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: research_consent_grant
    name: Grant new research-data consent
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: ta_data_consent_active, mode: add, value: 1, cap_per_day: 2 }
    hcr_lanes: [hcr_research]
    hcc_payout: 0.6
    fraud_controls: [rule_consent_active]
    evidence_required: none

  - id: doomscroll_alert_ack
    name: Doomscroll alert acknowledged
    surface: ios
    trigger: hk_sync
    updates:
      - { signal: ta_doomscroll_minutes, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_wearable_signature]
    evidence_required: wearable_signature

  # ─── Provisional / Vocational ─────────────────────────────────────
  - id: vocation_session
    name: Purposeful-work session
    surface: ios
    trigger: timer
    updates:
      - { signal: pv_purposeful_work_minutes, mode: add, value: user_input, cap_per_day: 480 }
    hcr_lanes: [hcr_vocation]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: career_growth_action
    name: Career-growth action (course, certification, mentor meeting)
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: pv_career_growth_action, mode: add, value: 1, cap_per_day: 3 }
    hcr_lanes: [hcr_vocation]
    hcc_payout: 0.5
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: financial_checkin
    name: Financial check-in
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: pv_income_stability,        mode: set, value: user_input }
      - { signal: pv_emergency_fund_months,   mode: set, value: user_input }
      - { signal: pv_debt_to_income,          mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: mentor_session
    name: Mentor / mentee session
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: pv_mentor_relationships, mode: add, value: 1, cap_per_day: 2 }
    hcr_lanes: [hcr_vocation]
    hcc_payout: 0.4
    fraud_controls: [rule_daily_cap]
    evidence_required: none

  - id: burnout_assessment
    name: Burnout self-assessment
    surface: ios
    trigger: self_report_form
    updates:
      - { signal: pv_burnout_index, mode: set, value: user_input }
    hcr_lanes: []
    hcc_payout: 0.0
    fraud_controls: [rule_unique_per_window]
    evidence_required: none

  - id: vocational_service_log
    name: Vocational service / pro-bono hours
    surface: ios
    trigger: timer
    updates:
      - { signal: pv_volunteer_vocation, mode: add, value: user_input, cap_per_day: 480 }
    hcr_lanes: [hcr_vocation, hcr_community]
    hcc_payout: 0.5
    fraud_controls: [rule_daily_cap, rule_gps_required]
    evidence_required: gps
