Skip to content

docs(ahand): pin hub-keying invariant in compensation comment - #79

Open
winrey wants to merge 1 commit into
devfrom
docs/ahand-hub-keying-invariant
Open

docs(ahand): pin hub-keying invariant in compensation comment#79
winrey wants to merge 1 commit into
devfrom
docs/ahand-hub-keying-invariant

Conversation

@winrey

@winrey winrey commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #78.

Follow-up on the concurrent-register race question raised in #78. I cloned team9ai/aHand (SHA 62c2f9cabde1a953ea3f13917998f5cc6efff564) and confirmed:

Race conclusion (Case A — moot): In the feared race where two users try to register the same hubDeviceId, the loser's hub.registerDevice() at step 1 already returns HTTP 409. AhandHubClient re-throws it as ConflictException before 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 bare hub.deleteDevice(deviceId) compensation is safe because deviceId is the hub's global PK.

Change

Adds a 9-line comment to the 23505 catch in ahand.service.ts documenting this invariant so future readers don't re-investigate the same question.

Test plan

  • No logic changed; existing unit + e2e tests cover the path
  • Comment wording reviewed for accuracy against hub source

https://claude.ai/code/session_01LWu6p2kzp1f4JTA1Jzyb4D


Generated by Claude Code

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
@railway-app

railway-app Bot commented Apr 26, 2026

Copy link
Copy Markdown

🚅 Deployed to the team9-pr-79 environment in Team9

Service Status Web Updated (UTC)
Im-worker ◻️ Removed (View Logs) Jun 8, 2026 at 9:02 am
API-Gateway ◻️ Removed (View Logs) Web Jun 8, 2026 at 9:02 am
Task-worker ◻️ Removed (View Logs) Jun 8, 2026 at 9:02 am
team9-app-web ◻️ Removed (View Logs) Web Jun 8, 2026 at 9:02 am

@railway-app
railway-app Bot temporarily deployed to Team9 / team9-pr-79 April 26, 2026 09:29 Destroyed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants