Add shared wearable payload contracts and mark Phase 1 progress#1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ee9d6281e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| showMoon: boolean; | ||
| moon?: LiveMoonGeometryV1; |
There was a problem hiding this comment.
Require moon geometry when showMoon is true
LiveRenderPayloadV1 currently permits { showMoon: true } without a moon object, because showMoon is a plain boolean and moon is optional. That weakens the shared contract this commit is introducing: producers can pass type-checking while emitting an internally inconsistent live payload, and downstream sanitization will then drop it as invalid (or renderers may assume moon data exists and fail). Model this as a discriminated union (showMoon: false without moon vs showMoon: true with required moon) so the invariant is enforced at compile time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Addressed the review feedback by changing
LiveRenderPayloadV1to a discriminated union soshowMoon: truenow requiresmoon, whileshowMoon: falsedisallows it (moon?: never). This enforces the invariant at compile time in the shared contract. packages/shared/src/wearable.tsL9-L25 - Added a regression assertion that
sanitizeWearRenderPayloadV1rejects a live payload whereshowMoonis true butmoonis missing, keeping runtime validation aligned with the stricter type contract. packages/shared/tests/wearable.payload.test.tsL103-L112 - Committed the change on branch
work(71be26c) and created a follow-up PR message viamake_prsummarizing what changed, why, and how to test.
Testing
- ✅
pnpm --filter @eclipse-timer/shared test - ✅
pnpm --filter @eclipse-timer/shared typecheck - ✅
pnpm --filter @eclipse-timer/shared lint ⚠️ python - <<'PY'\nimport urllib.request\nurl='https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions'\nwith urllib.request.urlopen(url, timeout=10) as r:\n print('fetched', r.status, 'bytes', len(r.read(2000)))\nPY(network proxy returned403 Forbiddenin this environment)
There was a problem hiding this comment.
Summary
- Updated
LiveRenderPayloadV1to a discriminated union soshowMoon: truenow requires amoongeometry object at the type level, whileshowMoon: falseremains the sun-only shape. This enforces the invariant at compile time as requested in review feedback. packages/shared/src/wearable.tsL9-L24 - Added a regression test case to ensure runtime sanitization rejects a
livepayload that setsshowMoon: truebut omitsmoon, protecting against inconsistent external input. packages/shared/tests/wearable.payload.test.tsL79-L115
Testing
- ✅
pnpm --filter @eclipse-timer/shared test - ✅
pnpm --filter @eclipse-timer/shared typecheck
Committed on the current branch with message: Tighten live wearable moon payload contract (commit 57b809a), and I also created the follow-up PR via the make_pr tool.
Motivation
liveandpreviewrender state.Description
packages/shared/src/wearable.tswithLiveRenderPayloadV1,PreviewRenderPayloadV1, the discriminated unionWearRenderPayloadV1, runtime sanitizers (sanitizeLiveRenderPayloadV1,sanitizePreviewRenderPayloadV1,sanitizeWearRenderPayloadV1), numeric clamps for normalized fields, and acreateSunOnlyLivePayloadhelper.packages/shared/src/index.tstoexport * from "./wearable".packages/shared/tests/wearable.payload.test.tsthat cover mode discrimination, normalized value clamping, and invalid-payload rejection.documents/wearable-companion-implementation-plan.mdto mark Phase 1 checklist items complete, add Phase 1 implementation notes, and capture the current integration gap that phone/watch runtime adoption remains pending.Testing
pnpm --filter @eclipse-timer/shared typecheckand it succeeded.pnpm --filter @eclipse-timer/shared lintand it reported no issues.pnpm --filter @eclipse-timer/shared testand all tests passed (1 test file, 3 tests).Codex Task