Skip to content

Add HaloSim pre-action simulation, deterministic risk scoring, and Trust Preview#8

Open
mlmrx wants to merge 1 commit into
mainfrom
mlmrx/implement-halosim-feature-in-agenthalo
Open

Add HaloSim pre-action simulation, deterministic risk scoring, and Trust Preview#8
mlmrx wants to merge 1 commit into
mainfrom
mlmrx/implement-halosim-feature-in-agenthalo

Conversation

@mlmrx

@mlmrx mlmrx commented May 6, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Introduce a pre-action simulation layer so AgentHalo simulates proposed plans and previews risk and data exposure before any consent or delegation occurs.
  • Provide deterministic, auditable risk scoring and safer-alternative generation so the system can recommend privacy-preserving plans and block high-risk actions by policy.
  • Surface a human-readable TrustPreview to users that summarizes what will/will-not happen and lets the user choose the safest acceptable plan before any external call or delegation.

Description

  • Added a new HaloSim subsystem under src/sim/ including haloSim.js, riskScorer.js, dataExposureAnalyzer.js, alternativePlanner.js, trustPreviewBuilder.js, and simulationStore.js to implement RiskPlan, DataExposureReport, AlternativePlan, RiskScore, and TrustPreview objects.
  • Integrated new HTTP endpoints in src/server.js for simulation and preview operations (POST /api/v1/simulate, GET /api/v1/simulations/:simulation_id, GET /api/v1/simulations/task/:task_id, POST /api/v1/simulations/:simulation_id/choose-plan, POST /api/v1/trust-preview, GET /api/v1/trust-preview/:preview_id, POST /api/v1/risk/score, POST /api/v1/data-exposure/analyze, and POST /api/v1/alternatives/generate).
  • Refactored runtime flow in src/runtime/haloRuntime.js so simulation and TrustPreview are created before consent and delegation, plan selection gates consent/delegation, and enforcement audits/blocking occur for unverified or high-risk plans (including money movement and policy blocks).
  • Added demo UI changes in public/index.html and public/app.js to render a basic Trust Preview panel, created docs/halosim.md to document HaloSim, and implemented in-memory simulation storage and audit events via HaloAudit integration.

Testing

  • Ran the automated test suite with npm test which passed; the test run reported 8 passing tests.
  • Added end-to-end tests in tests/endToEnd.test.js validating that simulation is created before consent, that DataExposureReport returns shared and blocked items, and that exact location scores higher-risk than approximate location, all of which passed.
  • Added tests asserting medical and financial fields increase risk and that the alternativePlanner recommends a lower-data privacy-preserving plan, both passing.
  • Added tests ensuring denied optional data is removed from outbound payloads and delegation scopes, that travel "do not purchase" blocks purchase plans, and that simulation audit events are recorded before action events, all of which passed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant