Repository navigation
fix(playback): answer a repeat terminate with the converged receipt - #4553
Conversation
A terminate of a session the server already ended for an administrator answered 404, although the receipt schema promises already_revoked. The end claim read the stopped attempt row and discarded it. It now reports the earlier stop, and a terminate that finds an earlier administrator stop answers 200 with already_revoked, delivery none, and dispatches nothing, locally and through the cross-replica relay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 31 minutes. View limit details
|
Codex Review Summary: ✅ CompletedThis 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. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| if receipt.Finalized || !claimStopFinalization(ctx, store, sessionID, receipt.StopID) { | ||
| if stopped { | ||
| return nativeEndClaim{} | ||
| } | ||
| return nativeEndClaim{earlierStopID: receipt.StopID} | ||
| } | ||
| return nativeEndClaim{store: store, record: record, receipt: receipt, owned: true} |
There was a problem hiding this comment.
Finalization takeover returns a first-terminate receipt for a repeat
After an expired lease is reclaimed, endSessionAsAdmin succeeds and terminateLocal sends another dismissal with already_revoked: false. Preserve the earlier stop identity during takeover and return the converged result after finalization.
Prompt for LLM
File internal/api/handlers/playback_end_claim.go, lines 62-68:
Finalization takeover returns a first-terminate receipt for a repeat
If an earlier administrator stop is unfinalized and its lease has expired, this retry acquires the lease and returns a normal owned claim, so `endSessionAsAdmin` returns success and `terminateLocal` dispatches another dismissal with `already_revoked: false`. Preserve the earlier stop identity when taking over finalization and return the converged result after finishing it.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Leaving this as it is. A takeover happens when the earlier terminate stopped the row and then died before finishing. This request is the one that finalizes the end and writes its history, and nothing shows the player was ever told, so it dispatches and reports already_revoked: false. already_revoked: true is reserved for a request that did nothing: the receipt documents it as "nothing was dispatched, delivery is none".
There was a problem hiding this comment.
That distinction makes sense. A finalization takeover is completing work the earlier request may not have finished, so dispatching the dismissal and returning already_revoked: false is consistent with the receipt’s meaning.
I withdraw the suggestion to return the converged receipt in that case.
| err := h.dropLiveSessionByID(ctx, sessionID) | ||
| if errors.Is(err, playback.ErrSessionNotFound) && claim.earlierStopID == adminStopID(sessionID) { | ||
| return ErrSessionEndedByAdmin | ||
| } | ||
| return err |
There was a problem hiding this comment.
A stale replica dispatches another dismissal on a repeated terminate
If dropLiveSessionByID removes a stale session copy, the repeat sends another dismissal with already_revoked: false. Return the converged result after removal when earlierStopID identifies an administrator stop.
Prompt for LLM
File internal/api/handlers/playback_end_claim.go, lines 226-230:
A stale replica dispatches another dismissal on a repeated terminate
When an earlier administrator stop left a live session copy on another replica, `dropLiveSessionByID` succeeds and this branch returns nil, so the repeat dispatches another dismissal and reports `already_revoked: false`. Return the converged result after dropping the stale copy when `earlierStopID` identifies an administrator stop.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Leaving this as it is, for the same reason. If this server still holds a live copy, its player is still connected and has not been dismissed, so ending that copy and telling the player is real work this request did. Answering already_revoked: true with delivery: none there would report a dispatch that happened as one that did not. The relay test for a lane owner that never replied depends on the copy being ended and its player told.
There was a problem hiding this comment.
That makes sense. A prior administrator stop in the attempt row does not necessarily mean this server’s live session copy has been dismissed. If the copy is still present, removing it and notifying its player is work performed by this request, so returning the normal termination receipt is appropriate.
I withdraw the suggestion. The converged receipt should apply when there is no live copy to end and the attempt row records an administrator stop.
Quick104
left a comment
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5)
One finding, in the documentation. The code change holds up: the new repeat tests fail on main with playback session not found and pass on this head, on the local path and through the relay.
…attempt row records A player that confirms an administrator's stop over the control socket can win the attempt row under the administrator stop id, so a later terminate converges instead of answering 404. Describe the answer by which stop the row records, and cover the converged repeat in client_notified. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
🤖 Claude Code (claude-opus-5-5) Review summaryReviewed head: A repeat administrator terminate now converges instead of answering Addressed
Checked and left as is
Validation
User manual: unaffected. The active-playback page doesn't describe terminate receipts. Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) Fit: it makes an operation already tagged naturally idempotent behave that way, within the existing contract field, and adds no setting. Readiness: the behaviour is shown by tests that fail on main, the author's sandbox run, and docs that now match the code. The only unproven path is two API servers, which is covered by the relay test alone. |
Problem
Related issue: N/A
Validation tasks: reaches #1206 C1 and C2 (the administrator terminate path; a first terminate behaves as before)
Other clients: N/A (no client-visible change; only the HTTP answer to a repeated administrator terminate changes, and the web admin already treats both answers as "session gone")
Terminating a playback session that an administrator already terminated answers
404. The receipt schema has analready_revokedfield described as "the call converged", but no request could ever set it, and the admin API doc said the opposite of the schema. A developer integrating a third-party monitor hit this when a retry of a terminate came back as an error.A repeat terminate now answers
200withauthority_revoked: true,already_revoked: true,delivery: "none"andclient_notified: false, and sends nothing to the player.Approach
The first terminate stops the session's playback attempt row under a stop ID reserved for administrator ends. A repeat read that stopped row and then discarded it, fell through to looking for a live session, found none and answered
404. The end claim now reports which earlier stop won the row, and a terminate that finds an administrator stop there converges. This works on the server that holds the session and through the cross-replica relay.What still answers
404, on purpose:200 already_revokedwould let a monitor report a viewer's own stop as a termination;A session copy still live on the answering server is ended and its player told, as before.
docs/admin-api.md, the handler comments and the OpenAPI descriptions now say the same thing.The operation was already tagged naturally idempotent, so this makes the behaviour match the tag. jellycompat has no terminate route. The user manual does not describe terminate receipts.
Validation
admin:monitor:readandadmin:sessions:control: first terminate200withalready_revoked: false; repeat200withalready_revoked: trueanddelivery: "none"; unknown session404; no credential401; read-only key403. That run used the implementer's combined branch, which also carried the two other changes now in separate pull requests.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4553/
Risks
404to200. A consumer that treated404as "already gone" still gets a success.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix repeated admin playback terminate to return converged receipt
ErrSessionEndedByAdminsentinel.playback.ErrSessionNotFound, andendSessionAsAdmindistinguishes an admin stop from other causes using the attempt record's earlier winning stop ID. Player stops, expiration, abandonment, and expired or missing records still return not found.Macroscope summarized 28ec69b.