# Health Bridge + VPT handoff — current state

Last updated: 2026-05-24 UTC.

## User intent

Chicho wants Health Bridge to:

1. Sync automatically every 12 hours.
2. Backfill/read only the last 12 hours during the scheduled recent sync.
3. Trigger the VPT cron 5 minutes after the phone sync.
4. The VPT output should hype him up and tell him exactly what to do next.
5. Use DeepSeek for Hermes delegate/worker/subagent tasks when delegating.

## Model/delegation config

Current `/home/ubuntu/.hermes/config.yaml` shows:

```yaml
model:
  default: gpt-5.5
  provider: openai-codex

delegation:
  model: deepseek-v4-pro
  provider: deepseek
  max_iterations: 50
  max_concurrent_children: 3
  default_toolsets:
    - terminal
    - file
    - web
```

So the main gateway agent is OpenAI Codex/gpt-5.5 right now, but `delegate_task` workers are configured as DeepSeek (`deepseek-v4-pro`). If spawning full Hermes subprocesses instead of `delegate_task`, pass `--provider deepseek -m deepseek-v4-pro` explicitly unless the profile defaults already do that.

## Android app changes made

Files changed:

- `/home/ubuntu/health-bridge/android-app/app/src/main/java/com/healthbridge/app/MainActivity.kt`
- `/home/ubuntu/health-bridge/android-app/app/src/main/java/com/healthbridge/app/HealthConnectSync.kt`

### WorkManager schedule

`MainActivity.kt` now schedules unique work named:

```kotlin
"health_12h_sync"
```

It cancels old work:

```kotlin
workManager.cancelUniqueWork("health_daily_sync")
```

It uses:

```kotlin
PeriodicWorkRequestBuilder<SyncWorker>(12, TimeUnit.HOURS)
```

The initial delay anchors first run to local 10:00 or 22:00, then repeats every 12 hours.

### Recent sync/backfill window

`HealthConnectSync.kt` now has:

```kotlin
suspend fun syncRecent(): String = syncWindow(Instant.now().minus(12, ChronoUnit.HOURS), Instant.now(), "recent-12h")
```

The implementation adds `syncWindow(requestedStart: Instant, requestedEnd: Instant, label: String)` so interval reads use the exact last-12h instant window. Daily aggregates still read the local dates touched by the 12h window, because Health Connect aggregate APIs are day-oriented and the backend daily summary expects local-day rows.

## Build/install status

Build succeeded:

```bash
cd /home/ubuntu/health-bridge/android-app
./gradlew assembleDebug --no-daemon
cp app/build/outputs/apk/debug/app-debug.apk /home/ubuntu/health-bridge/static/health-bridge.apk
```

APK path:

```text
/home/ubuntu/health-bridge/static/health-bridge.apk
```

Install did NOT complete after the last 12h-window build because ADB went offline/dead:

```text
adb: device offline
```

Then after `adb kill-server; adb start-server`, no devices were connected. Need Chicho to reopen Wireless debugging and provide a fresh connection port. Use:

```bash
adb disconnect 100.111.239.9:<old_port> || true
adb connect 100.111.239.9:<fresh_connection_port>
adb devices -l
adb -s 100.111.239.9:<fresh_connection_port> install -r /home/ubuntu/health-bridge/static/health-bridge.apk
adb -s 100.111.239.9:<fresh_connection_port> shell am start -n com.healthbridge.app/.MainActivity
adb -s 100.111.239.9:<fresh_connection_port> shell "dumpsys jobscheduler | grep -i -A16 -B4 'JOB #.*com.healthbridge.app/androidx.work.impl.background.systemjob.SystemJobService'"
```

Expected next JobScheduler minimum latency should point to next 10:00/22:00 ART window.

## Cron status

Two Hermes cron jobs exist:

1. `908162529405` — `Health Bridge phone sync trigger 10am/10pm ART`
   - Schedule: `0 13,1 * * *`
   - Script-only/no-agent: `health_bridge_morning_sync.sh`
   - Runs at 10:00 and 22:00 ART.

2. `0d7dc9f4ca42` — `MVP VPT health/readiness check 10:05am/10:05pm ART`
   - Schedule: `5 13,1 * * *`
   - Runs 5 minutes after phone sync.
   - Prompt updated to be a direct motivating coach, include readiness and exact next steps.

## Skills updated

`health-bridge` skill was patched to say scheduled/recent sync window is last 12h and runs every 12h around 10:00/22:00 ART.

## Next iteration instructions

1. If user provides fresh ADB port, immediately install `/home/ubuntu/health-bridge/static/health-bridge.apk`.
2. Open Health Bridge once via ADB to force WorkManager scheduling.
3. Verify JobScheduler has only the relevant Health Bridge WorkManager job and next run aligns with 10:00/22:00 ART.
4. If multiple stale jobs remain, inspect WorkManager DB or uninstall/reinstall only if necessary; prefer non-destructive cancellation first.
5. Optionally force-run the job once using discovered JobScheduler ID, then query `/home/ubuntu/health-bridge/health.db` for latest `health_connect` raw rows and daily_summary.
6. For subagents/delegation, use `delegate_task` normally; config routes delegates to DeepSeek. For full Hermes subprocess agents, explicitly pass DeepSeek provider/model.
