Skip to content

Clear deviceIdentityToken when we fail to load id or deviceSecret#474

Open
lawrence-forooghian wants to merge 4 commits into
mainfrom
tighten-up-RSH8j
Open

Clear deviceIdentityToken when we fail to load id or deviceSecret#474
lawrence-forooghian wants to merge 4 commits into
mainfrom
tighten-up-RSH8j

Conversation

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

@lawrence-forooghian lawrence-forooghian commented May 13, 2026

A couple of minor bits and then a replacement of RSH8j (which is not implemented in most of our SDKs AFAIK — the important one in which it's not implemented is ably-cocoa since that's the one in which load failure is likely to happen, tracked in ably/ably-cocoa#1257). Intention is to make sure that you don't end up with a deviceIdentityToken that belongs to a previous id and to make it clearer how to implement "become NotActivated".

See commit messages for more details.

lawrence-forooghian and others added 2 commits May 13, 2026 16:01
The note in RSH8k2 mentioned RSH3a2b three times but only linked
the first reference. Link the other two for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The note previously said "our implementations" all generate eagerly,
but this isn't accurate. ably-java follows RSH3a2b (lazy generation
on CalledActivate); ably-cocoa and ably-js generate eagerly at device
fetch time.

Checked against:
- ably-cocoa 745e7b7
- ably-java da4c60f
- ably-js 17be43e

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maratal
Copy link
Copy Markdown
Collaborator

maratal commented May 17, 2026

There is a lot of back and forth between RSH8a, RSH8b, RSH3h, RSH8k2, RSH3a2b which makes it very hard to follow. Can we keep such a thing as "load details or generate if it doesn't exist or loading failed" in at least two places?

Earlier this year I've tried to fit specs with current cocoa behavior and reducing amount of jumping between spec points, wdyt @lawrence-forooghian? - #181

Regarding loading failure - it's not like unrecoverable failure, right? Why generate new details if you can try to load a bit later when user unlocks device?

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator Author

lawrence-forooghian commented May 20, 2026

Will answer your other points @maratal, but re

Regarding loading failure - it's not like unrecoverable failure, right? Why generate new details if you can try to load a bit later when user unlocks device?

It's an option that I'd considered but when I discussed with Paddy he said he didn't think we should do this and instead should just make sure it's stored in a way that's always available. Bear in mind also that in ably-cocoa ARTRealtime.device() loads the device synchronously and is expected to return a fully populated LocalDevice.

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator Author

lawrence-forooghian commented May 20, 2026

BTW I've added 5ccc1d1 to remove a statement I didn't realise existed which seems quite redundant

lawrence-forooghian and others added 2 commits May 19, 2026 21:54
I didn't even know that this statement existed. Paul added it to RSH3a2b
in a6e9e18 but then added RSH8j in 17d4a2a a couple of weeks later, both
in the same PR [1]; the former seems to be a vaguer version of the
latter.

[1] ably/docs#1062
Otherwise, the old token will survive and we'll end up trying to
validate it with an absent or non-matching device ID in RSH3a2a.

Given that most of our SDKs have not yet implemented RSH8j, it seemed
like a good moment to also tighten up the language before we start
trying to implement it. The spec provides no mechanism for the state
machine to perform a state transition outside of the context of
receiving an event. So instead of talking about a transition, we make it
clear that LocalDevice load failure should always be handled before the
state machine is hydrated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lawrence-forooghian
Copy link
Copy Markdown
Collaborator Author

There is a lot of back and forth between RSH8a, RSH8b, RSH3h, RSH8k2, RSH3a2b which makes it very hard to follow. Can we keep such a thing as "load details or generate if it doesn't exist or loading failed" in at least two places?

What are some examples of jumping-around that you think we could remove?

  • RSH3h is the authoritative spec point for when to load the push activation state machine data
  • RSH8a is the authoritative spec point for when to load the LocalDevice data, and its child RSH8a1 is the authoritative spec point for what to do if this loading fails

Earlier this year I've tried to fit specs with current cocoa behavior and reducing amount of jumping between spec points, wdyt @lawrence-forooghian? - #181

It seems like that PR is largely orthogonal to the current one; that's about when the device ID and secret should be regenerated. But if you think that merging that one would allow us to simplify this one, I'm happy to hear how. My worry about merging that one is, as described in 9871e20, we'd be replacing a spec point that describes how it's currently implemented in ably-java with one that describes how it's currently implemented in ably-cocoa and ably-js; I'd prefer that if we're going to do that then we also align the implementations.

@maratal
Copy link
Copy Markdown
Collaborator

maratal commented May 20, 2026

BTW I've added 5ccc1d1 to remove a statement I didn't realise existed which seems quite redundant

I bet you mean 64fdb7f

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator Author

lawrence-forooghian commented May 20, 2026

I bet you mean 64fdb7f

yes, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants