← Back to brief

reference pwa staleness

memory · reference_pwa_staleness.md

The problem this solves

The PWA used to rebuild once at 11pm nightly. If anything changed during the day — new draft, deal stage moved, new transcript, action item captured — the PWA stayed stale until midnight. User opens PWA on their phone → sees yesterday's state → makes a decision on stale data. Dangerous.

Three layers of freshness

Layer 1 — Instant rebuild on state change (best case)

launchd agent: com.skyrun.pwa-autorebuild (plist at ~/Library/LaunchAgents/).

Uses native macOS WatchPaths — fires the rebuild script within seconds of any watched file being modified.

Watches:

Script: ~/Library/Application Support/SkyRun/pwa_auto_rebuild.sh

⚠️ Requires Full Disk Access for /bin/bash + /usr/bin/python3:
Without FDA, launchd-spawned bash can't read Desktop/SkyRun. Add both binaries via:
System Settings → Privacy & Security → Full Disk Access → + → select /bin/bash and /usr/bin/python3.

If FDA isn't granted, Layer 1 silently logs "Operation not permitted" and Layer 2 catches the staleness within 20 min.

Layer 2 — Live-ea 20-min ceiling (always-on safety net)

live-ea scheduled task already runs every 20 min during business hours (weekdays 9am–7pm MDT). Added Step 7b (Apr 24): if this run processed any drafts / captures / drive-sort files, rebuild + deploy PWA.

Gives a 20-min maximum staleness guarantee during business hours, regardless of FDA. Automatic, no config needed.

Layer 3 — Nightly baseline (catches the overnight window)

nightly-consolidation at 11pm already rebuilds + deploys. Keeps the PWA current through the morning even if live-ea and the fswatch agent both miss something.

Per-section freshness badges

Every PWA section header shows a color-coded freshness badge:

ColorMeaningThresholds (by section)
🟢 freshCurrentbrief <6h, graph <24h, approvals <1h, health <2h
🟡 agingGetting oldbrief <24h, graph <72h, approvals <6h, health <6h
🔴 staleNeeds a rebuildabove the aging threshold
Badges appear in:

Top sync banner

New at the top of every PWA view:


🔄 Last synced 10:15 AM · brief 🟢 12m ago · graph 🟢 2h ago · approvals 🟢 45m ago · health 🟢 10m ago [↻ Reload]

What this guarantees

Manual refresh options

Files

PurposePath
fswatch script~/Library/Application Support/SkyRun/pwa_auto_rebuild.sh
launchd agent~/Library/LaunchAgents/com.skyrun.pwa-autorebuild.plist
Log~/Library/Logs/skyrun-pwa-autorebuild.log
PWA build script/Users/josephbowens/Library/Application Support/SkyRun/build_pwa.py
PWA deploy script~/Library/Application Support/SkyRun/deploy_pwa.sh
Deploy log~/Library/Logs/skyrun-pwa-deploy.log

Related