mirror of
https://github.com/nestriness/nestri.git
synced 2026-09-23 11:08:18 +03:00
feat(api): hold a run to the attempt that claimed it
The agent side sends a claim token on every write; this side rejected the field outright, so every state report and every ticket publish answered 400. Both bodies now take it. Underneath that, nothing compared a holder. A run was reachable by any caller on the right machine, and a box names exactly one machine — so two attempts polling the same job presented identical credentials and were told apart only by which one's select landed first. That is timing, not a rule, and no caller could be told which case it was in. The row now remembers which attempt holds it. Taking a claim requires there to be no holder; every write after it requires the caller to be the holder. The same state reported by a different attempt is a lost race and not a retry, and is refused whatever the state is - which is the only thing that separates the two 200s from the 409s. The ticket is held to the claim too, for a worse reason than a double start: the client re-reads the address rather than keeping the first, so a ticket written by a losing attempt produces a client that connects, successfully, to a machine running nothing. The holder is never cleared, including on a terminal state, so a settled claim cannot be replayed and a finished run still records which attempt ran it. It is not in what goes out - holding one permits writing to a run, and the owner reading their own session is not the holder.
This commit is contained in:
@@ -146,6 +146,9 @@ export namespace Examples {
|
||||
linkedAccountId: Id('linkedAccount'),
|
||||
state: 'live' as const,
|
||||
ticket: 'nodeaaqf…',
|
||||
// Shaped like the real thing so the docs do not teach a shorter one,
|
||||
// and obviously not one.
|
||||
claimToken: '00000000000000000000000000000000',
|
||||
timeStarted: '2026-07-28T12:00:00.000Z',
|
||||
timeStopped: null,
|
||||
errorMessage: null
|
||||
|
||||
Reference in New Issue
Block a user