docs(ahand): pin hub-keying invariant in compensation comment - #79
Open
winrey wants to merge 1 commit into
Open
Conversation
Documents that ahand-hub keys devices by `id TEXT PRIMARY KEY` (globally unique, no per-user partitioning), which makes the 23505 catch unreachable in a concurrent-register race — the loser's hub.registerDevice() already fails at step 1. Clarifies the only reachable path (crash-retry) and why the bare-deviceId hub.deleteDevice compensation is safe in that case. Closes #78 — see PR for hub code references. https://claude.ai/code/session_01LWu6p2kzp1f4JTA1Jzyb4D
3 tasks
|
🚅 Deployed to the team9-pr-79 environment in Team9
|
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.
Summary
Closes #78.
Follow-up on the concurrent-register race question raised in #78. I cloned
team9ai/aHand(SHA62c2f9cabde1a953ea3f13917998f5cc6efff564) and confirmed:crates/ahand-hub-store/migrations/0001_initial.sql:id TEXT PRIMARY KEY. NoexternalUserIdcolumn. The devices table is keyed globally bydeviceIdalone.crates/ahand-hub/src/http/devices.rs,create_device, lines 60–101: callsdevices.insert(NewDevice { id, ... })which maps a unique violation toHubError::DeviceAlreadyExists.crates/ahand-hub/src/http/api_error.rs, lines 112–116:DeviceAlreadyExists→ HTTP 409.AhandHubClient.registerDevicemaps HTTP 409 →ConflictException, thrown before the DB-inserttryblock.Race conclusion (Case A — moot): In the feared race where two users try to register the same
hubDeviceId, the loser'shub.registerDevice()at step 1 already returns HTTP 409.AhandHubClientre-throws it asConflictExceptionbefore entering the try block around the DB insert — so the 23505 catch is unreachable. The only legitimate path into that catch is a crash-retry scenario (hub succeeded, DB never got the row), and in that case the barehub.deleteDevice(deviceId)compensation is safe becausedeviceIdis the hub's global PK.Change
Adds a 9-line comment to the 23505 catch in
ahand.service.tsdocumenting this invariant so future readers don't re-investigate the same question.Test plan
https://claude.ai/code/session_01LWu6p2kzp1f4JTA1Jzyb4D
Generated by Claude Code