Repository navigation
feat(cloudwire): a watch reads FTW Cloud in one request - #1627
Merged
Merged
Conversation
ADR 0009 milestone 6, decisions 7, 8 and 9.
cloudwire gains the one-shot read: POST /v1/app/once?home=<id> with
Noise IK message 1 as the body and prologue ftw.cloud.once.v1: plus the
home id, so it never stands in for an app session handshake. Message 1
carries read {have, hz}, token.get, push.register or push.unregister.
Have.Covers says which box envelopes the watch already holds. The answer
is message 2 and the envelopes that did not fit, each message after its
length as u16 big endian; message 2 is framed too, since a Noise message
cannot be opened without its end.
push.register gains app, iphone or watch, so the service picks the APNs
topic. docs/protocol-cloud.md specifies the read, its limits, app and
role watch in the roster. Golden vectors for one read are in
testdata/cloud-once-vectors.json; the other vector files are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
Milestone 6 of ADR 0009, decisions 7, 8 and 9: FTW Cloud's wire for a watch, in
go/protocol/cloudwireanddocs/protocol-cloud.md. A watch on its own reads its home from FTW Cloud in one HTTPS request; this PR specifies that request and its bytes. FTW Cloud serves it in step 7 (srcfl/ftw-cloud); nothing on the box changes.POST https://cloud.ftw.energy/v1/app/once?home=<id>,content-type: application/octet-stream. The body is Noise IK message 1 to a service key, with prologueftw.cloud.once.v1:and the home id, so it can never stand in for an app session handshake. Message 1 carries one unsigned envelope:read,token.get,push.registerorpush.unregister; anything else, an owner'ssuspendamong them, gets 400. Admission is the app session's; a refusal is 403 with an empty body. The answer is message 2 and then the envelopes that did not fit, each message after its length as u16 big endian. The service keeps no session and no Noise state.read {have, hz}.haveis{boot, seq}: the boot the watch's envelopes come from and the highest seq it holds per class. The service leaves out every box envelopehavecovers (Have.Covers).hz: 1keeps the box'swatchin force for 60 s.token.getgetstoken {token, expiresInS}in message 2; push registration gets an empty payload once stored.push.registergainsapp,iphone(the default when absent) orwatch, so the service picks the APNs topic. A watch and its phone get byte-identical alert payloads.watch, with the scopes the box derives: the watch role's, cut to what its phone's role carries now. The box already sends them (feat(applink): an owner phone adds a watch as a device of its own #1625).One finding against the ADR
The ADR says message 2 is followed by transport messages "each after its length as u16 big-endian", which leaves message 2 itself unframed. Its length varies with the snapshot, and a Noise message cannot be opened without knowing where it ends, so this PR puts the same u16 length in front of message 2 too. Every message in the body is framed alike.
Scope and safety
cloud-vectors.json,cloud-app-vectors.jsonandpush-vectors.jsonare byte for byte as before.appis additive and omitted when empty, so an existing phone's registration encodes as before.Verification
TestOnceReadVectorswrites and checkscloudwire/testdata/cloud-once-vectors.json: fixed keys on both ends, areadwhosehavecovers the fullliveand thelpfromcloud-vectors.json, message 2 with thelivedelta andprices, thehbafter it as a transport message, and the whole answer body. It also plays the watch: splits the body, reads message 2, and opens thehbas the box's exact bytes.TestOnceAndAppHandshakesStayApart: an app session responder cannot read a one-shot message 1.TestHaveCoversOnlyWhatTheWatchHolds: older and equal seq covered; newer seq, another class, another boot and junk not.TestOnceAnswerFramingandTestPushRegisterNamesTheApp.make verifygreen.Checklist
Independent of #1626. srcfl/ftw-cloud (step 7) and the watch app (steps 8 and 10) replay the vectors.
🤖 Generated with Claude Code