Stress Particle algorithm structure — from biometric input through personalization engine to efficacy learning loop

01 · INPUT FUSION — what feeds the algorithm
Biometric stream
Smart ring + smartwatch, 30s interval tick
HRV
ms · 0–100
SpO₂
% saturation
HR
bpm
Sleep
score 0–100
Context signals
Calendar, location, screen time, IoT state
home / office / commute meeting in progress screen time ÷ min time of day
User profile
Set once in onboarding, persists across all calls
stress archetype recovery style audio preference scent profile chronotype
Composite stress score =
f(HRV, HR, sleep, screen_time, calendar_density)
→ 0–100 scalar · drives particle state
02 · PARTICLE STATE ENGINE — stress made visible
Stress score maps to one of 4 visual states — transitions animate 8–20s, spring physics
Acute 70–100
dense amber vortex
Elevated 45–69
oscillating clusters
Balanced 20–44
cool teal drift
Recovered 0–19
violet galaxy
Transition triggers
Breathing guide starts → density −20%
Session complete → drop one state level
HRV +10% post-action → particles grow + slow
Full recipe executed → galaxy lock-in
Animation principles
Anticipation: contract 15% inward 0.3s before change
Ease-out-expo for recovery (fast drop → long tail)
Spring physics: overshoot + settle = biological feel
Stagger: wave propagates center → outward
03 · AGENT DECISION LOGIC — when and how to intervene
State machine
Watching score below threshold
↓ threshold crossed
Pending waiting for right moment
↓ not in meeting
Intervening card surfaced + Apify fires
↓ HRV +10%
Recovering efficacy written → loop
Autonomy levels
Suggest only
Notification sent · no device changes · Apify fires on user tap
Ask then act
Card shown with results · waits 30s · executes on accept
Full auto
Recipe runs immediately · Apify background · undo available
Context holdback rules
Meeting in progress → hold, re-check at block_end + 5 min

Location = home → skip Maps Actor, trigger Amazon instead

Location = office → Maps filters to 0.5mi radius, open now

Particle already Recovered → no intervention surfaced
04 · PERSONALIZATION ENGINE — the core differentiator
Design principle — the same Actor called for two users produces entirely different results
Without profile fusion
"wellness near me"
With profile fusion (Alex)
"yoga studio OR float tank near SF open now"
buildQuery() — profile fields → Actor input object
Actor 1 · Google Maps
base = recoveryStyle + stressArchetype
urgency = acute ? "open now" : ""
→ "yoga studio near SF open now"
Actor 2 · YouTube
audio[0] + chronotype + particle_state
→ "rain white noise ASMR sleep 1 hour"
Actor 3 · Healthline
stressor + archetype keyword blend
→ "work burnout HRV recovery tension"
Actor 4 · Reddit
archetype term + recovery term
→ r/burnout r/Wellbeing "solo recharge"
Actor 5 · Amazon
scent_profile + archetype need + urgency → "lavender muscle relaxation magnesium fast acting supplement"
synthesize() — raw results → agent-voiced cards (never raw lists)
1 · Filter — remove closed venues (if acute), videos under 20 min
2 · Score — rating × 0.4 + proximity × 0.3 + open_now × 0.2 + archetype_match × 0.1
3 · Rank — take top 2 venues, top 3 tracks, top 2 snippets
4 · Voice — add one-line rationale per result
Example output
"Inner Sunset Yoga 0.4mi away — 6pm class in 38 min. Good for solo decompression after tension stress."
05 · EFFICACY LEARNING LOOP — the algorithm improves over time
Measure
HRV delta measured 20 min post-recipe
hrv_delta = hrv_t20 − hrv_start
Written to efficacy_history[]
Score
efficacy_score = avg(hrv_delta history) ÷ 100
High-delta audio types flagged
Low-use venue types flagged
Reweight
"rain" appeared 3× in high-efficacy entries → boosted in next YouTube query
Float tank never used → removed from Maps base
Next call
buildQuery() uses updated weights
sortBy switches from "relevance" to weighted sort
Loop runs every recipe completion
No backend required · all state in Zustand store · improves within the session
5
Apify Actors, each personalized
4
Agent states in the decision machine
12
Profile fields shaping every query
0
Backend servers required