Skip to content

Add health skills with sigma gating, red-team testing, and Android disclaimers#103

Draft
farmountain with Copilot wants to merge 4 commits into
mainfrom
copilot/add-health-feature-implementations
Draft

Add health skills with sigma gating, red-team testing, and Android disclaimers#103
farmountain with Copilot wants to merge 4 commits into
mainfrom
copilot/add-health-feature-implementations

Conversation

Copilot AI commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

Implements three health skills (gait analysis, medication sentinel, sun/hydration) with confidence-based sigma gating and automated red-team validation. Health skills require higher confidence thresholds before proceeding and inject medical disclaimers.

Python Skills (skills/)

Three skill modules with sigma gating constants:

  • hc_gait_guard.py - Fall risk assessment (σ=0.82)
  • hc_med_sentinel.py - Drug interaction checker (σ=0.88)
  • hc_sun_hydro.py - Environmental safety monitor (σ=0.78)

Each implements:

SIGMA_GATE = 0.82  # Confidence threshold

def sigma_gate_decide(confidence: float, threshold: float = SIGMA_GATE) -> str:
    return "proceed" if confidence >= threshold else "ask"

def run_inference(input_data: Dict[str, Any]) -> SkillResult:
    # Stub for ONNX model inference
    
def export_to_onnx(model_path, output_path) -> Path:
    # Stub writes placeholder bytes, replace with torch.onnx.export()

Red-Team Testing (redteam/, tools/)

  • health.yaml - 15 scenarios testing bystander privacy, diagnosis boundaries, medication interactions
  • eval_redteam_health.py - Keyword-based evaluator (exits non-zero on critical failures)
  • .github/workflows/redteam_health_smoke.yaml - CI smoke tests

Critical scenarios validated:

  • Bystander requests refused (privacy)
  • Diagnosis requests refused (scope limitation)
  • Low confidence triggers "ask" action

Android Decision Module (sdk-android/)

Decision.kt enforces sigma gates and injects disclaimers:

object Decision {
    private val SIGMA_GATES = mapOf(
        "hc_gait_guard" to 0.82f,
        "hc_med_sentinel" to 0.88f,
        "hc_sun_hydro" to 0.78f
    )
    
    fun makeDecision(skillId: String, confidence: Float, baseMessage: String): DecisionOutcome {
        val action = if (sigmaGate != null && confidence < sigmaGate) "ask" else "proceed"
        val message = if (skillId.startsWith("hc_")) addDisclaimer(baseMessage) else baseMessage
        return DecisionOutcome(action, message, confidence)
    }
}

Disclaimer: "This information is for general awareness only and does not constitute medical advice. Please consult a healthcare professional for medical concerns."

Configuration

rayskillkit/skills.json updated with health skills entries:

  • Model paths: models/health/hc_*_int8.onnx
  • Stats paths: models/health/hc_*_stats.json
  • Privacy flags: ["health-data", "requires-disclaimer"]
  • Sigma gate thresholds included

Testing

  • 27 pytest tests validate sigma gating behavior
  • 23 Kotlin tests validate Decision logic
  • All red-team scenarios pass (6/6 critical)

Note: ONNX stubs and evaluator use placeholders; replace with actual model inference when models are trained.

Original prompt

Objective: Implement the health feature work described: three health skills with sigma gating and ONNX export stubs, red-team health YAML and evaluator script, CI smoke workflow, unit tests for sigma gates, update skills.json, and Android Decision.kt disclaimers and unit tests. Deliverables: 1) Skills implementations (Python) for hc_gait_guard, hc_med_sentinel, hc_sun_hydro with sigma gating constants, run_inference and export_to_onnx stubs; 2) tests/test_sigma_threshold.py pytest tests that assert sigma gating behavior; 3) redteam/health.yaml with scenario cases for bystander, diagnosis, medication-interaction; 4) tools/eval_redteam_health.py evaluation script that reads redteam/health.yaml and emits redteam/health_report.json (exit non-zero on critical fails); 5) .github/workflows/redteam_health_smoke.yaml CI workflow to run the evaluator on push/PR; 6) skills.json additions for the three skills pointing to onnx and stats paths and privacy flags; 7) Android Kotlin: update android/app/src/main/java/com/smartglass/agent/decision/Decision.kt to enforce 'ask' when confidence below sigma gates and inject health disclaimer for skills prefixed with 'hc_'; 8) Android unit tests at android/app/src/test/java/com/smartglass/agent/decision/DecisionTest.kt to assert behavior; 9) Ensure paths and file contents are consistent and include placeholders where real model artifacts are needed. Files to create or update (exact content provided):

redteam/health.yaml (contains the red-team test cases for hc_gait_guard, hc_med_sentinel, hc_sun_hydro)

tools/eval_redteam_health.py (reads the YAML, evaluates with simple heuristics, emits redteam/health_report.json and exit code for CI)

skills/hc_gait_guard.py (Python skill stub with SIGMA_GATE, SkillResult dataclass, sigma_gate_decide, run_inference, export_to_onnx stub)

skills/hc_med_sentinel.py (Python skill stub similar with own SIGMA_GATE)

skills/hc_sun_hydro.py (Python skill stub similar)

skills.json (update or create; include onnx paths, stats json paths, privacy_flags for the three skills)

tests/test_sigma_threshold.py (pytest tests for sigma gating functions in the three skills)

.github/workflows/redteam_health_smoke.yaml (CI to run the evaluator script; install pyyaml; run eval script)

android/app/src/main/java/com/smartglass/agent/decision/Decision.kt (Kotlin Decision object with SIGMA_GATES map for the three skills and addDisclaimer injects disclaimer for hc_ skills; returns DecisionOutcome(action, message, confidence))

android/app/src/test/java/com/smartglass/agent/decision/DecisionTest.kt (JUnit tests asserting ask/proceed and disclaimer injection; non-health skill unchanged)

Notes for implementer: - The ONNX export stubs write placeholder bytes; replace with torch.onnx.export or TF export if models available. - Update skills.json paths to target models/ directory; generate stats JSON after training. - The evaluator script uses keyword heuristics; integrate real model calls later. - CI will fail if CRITICAL severity tests marked failed; intended as smoke to catch critical regressions.

Please create a branch to contain these changes and open a pull request against the repository default branch. Branch name suggestion: pr/health-skills-and-redteam

Do not assign reviewers or assignees. Include all files above exactly as described.

This pull request was created as a result of the following prompt from Copilot chat.

Objective: Implement the health feature work described: three health skills with sigma gating and ONNX export stubs, red-team health YAML and evaluator script, CI smoke workflow, unit tests for sigma gates, update skills.json, and Android Decision.kt disclaimers and unit tests. Deliverables: 1) Skills implementations (Python) for hc_gait_guard, hc_med_sentinel, hc_sun_hydro with sigma gating constants, run_inference and export_to_onnx stubs; 2) tests/test_sigma_threshold.py pytest tests that assert sigma gating behavior; 3) redteam/health.yaml with scenario cases for bystander, diagnosis, medication-interaction; 4) tools/eval_redteam_health.py evaluation script that reads redteam/health.yaml and emits redteam/health_report.json (exit non-zero on critical fails); 5) .github/workflows/redteam_health_smoke.yaml CI workflow to run the evaluator on push/PR; 6) skills.json additions for the three skills pointing to onnx and stats paths and privacy flags; 7) Android Kotlin: update android/app/src/main/java/com/smartglass/agent/decision/Decision.kt to enforce 'ask' when confidence below sigma gates and inject health disclaimer for skills prefixed with 'hc_'; 8) Android unit tests at android/app/src/test/java/com/smartglass/agent/decision/DecisionTest.kt to assert behavior; 9) Ensure paths and file contents are consistent and include placeholders where real model artifacts are needed. Files to create or update (exact content provided):

redteam/health.yaml (contains the red-team test cases for hc_gait_guard, hc_med_sentinel, hc_sun_hydro)

tools/eval_redteam_health.py (reads the YAML, evaluates with simple heuristics, emits redteam/health_report.json and exit code for CI)

skills/hc_gait_guard.py (Python skill stub with SIGMA_GATE, SkillResult dataclass, sigma_gate_decide, run_inference, export_to_onnx stub)

skills/hc_med_sentinel.py (Python skill stub similar with own SIGMA_GATE)

skills/hc_sun_hydro.py (Python skill stub similar)

skills.json (update or create; include onnx paths, stats json paths, privacy_flags for the three skills)

tests/test_sigma_threshold.py (pytest tests for sigma gating functions in the three skills)

.github/workflows/redteam_health_smoke.yaml (CI to run the evaluator script; install pyyaml; run eval script)

android/app/src/main/java/com/smartglass/agent/decision/Decision.kt (Kotlin Decision object with SIGMA_GATES map for the three skills and addDisclaimer injects disclaimer for hc_ skills; returns DecisionOutcome(action, message, confidence))

android/app/src/test/java/com/smartglass/agent/decision/DecisionTest.kt (JUnit tests asserting ask/proceed and disclaimer injection; non-health skill unchanged)

Notes for implementer: - The ONNX export stubs write placeholder bytes; replace with torch.onnx.export or TF export if models available. - Update skills.json paths to target models/ directory; generate stats JSON after training. - The evaluator script uses keyword heuristics; integrate real model calls later. - CI will fail if CRITICAL severity tests marked failed; intended as smoke to catch critical regressions.

Please create a branch to contain these changes and open a pull request against the repository default branch. Branch name suggestion: pr/health-skills-and-redteam

Do not assign reviewers or assignees. Include all files above exactly as described.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 14, 2025 12:42
- Created Python skills: hc_gait_guard, hc_med_sentinel, hc_sun_hydro
- Added sigma gating with confidence thresholds (0.82, 0.88, 0.78)
- Implemented unit tests for sigma threshold behavior
- Created redteam/health.yaml with 16 test scenarios
- Added tools/eval_redteam_health.py evaluator script
- Added CI workflow for health red-team smoke tests
- Updated rayskillkit/skills.json with health skills
- Updated Android Decision.kt with sigma gates and disclaimers
- Added Android DecisionTest.kt with comprehensive tests

Co-authored-by: farmountain <478847+farmountain@users.noreply.github.com>
Co-authored-by: farmountain <478847+farmountain@users.noreply.github.com>
- Remove Gradle build artifacts (.gradle/, *.class, META-INF/)
- Update .gitignore to exclude Gradle and Kotlin build artifacts

Co-authored-by: farmountain <478847+farmountain@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement health feature with sigma gating and ONNX export Add health skills with sigma gating, red-team testing, and Android disclaimers Nov 14, 2025
Copilot AI requested a review from farmountain November 14, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants