mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-11 14:27:32 +01:00
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KwUCPESvE5CjCtmUFz8xQ
2.0 KiB
2.0 KiB
Migration: GitHub Gist → shared crdt_sync
phone_app's alarm sync was moved off a bespoke GitHub Gist onto the shared
crdt_sync library
(pinned tag crdt_sync_dart-v0.3.0), matching how the other companion apps
sync.
What changed
- phone_app (Dart):
gist_service.dartis gone.AlarmSyncServicestores the alarm locally in acrdt_syncLogStore(one HLC-stampedRecord) and pushes it towake-alarm-sync/devices/phone/alarm.jsoninkuhyx/syncsviacrdt_sync'sGitHubClient. The device-flow OAuth scope movedgist→repo(the Contents API needs private-repo access). - shutdown-wrapper.sh (PC, Bash): now reads that alarm from the Contents
API (
Accept: application/vnd.github.raw, so no base64) and parses thecrdt_syncRecordlog withjq(.alarm.fields.alarm_hour[0]). Config moved from~/.config/wake_alarm/gist_sync.json{token, gist_id}to~/.config/wake_alarm/sync.json{token}(repo-scoped).
Setup after pulling this
- On the phone: Settings → Connect GitHub (now requests
reposcope; the old gist-scoped token won't reach the Contents API). - On the PC:
~/.config/wake_alarm/sync.json→{ "token": "<repo-scoped>" }, then re-runinstall.shso/usr/local/bin/shutdownpicks up the new reader.
Surprises / non-obvious decisions
- The consumer is a Python-less Bash reader (
shutdown-wrapper.shruns at shutdown, when a Python runtime may not be available), so it can't use thecrdt_synclibrary — it parses the log withjq. What makes that tractable:Hlc.toStr()is lexicographically sortable == chronological, so "latest wins" across device dirs is a plain string max, no date math. - The phone is push-only (sole writer); there is no pull/merge. Its local
LogStoreis always the source of truth. - Any parse miss still falls back to
WAKE_AFTER_HOURS, so a bad read can never brick the morning wake.