Skip to content

fix(playback): record an admin stop as terminated when the player's stop lands first - #4625

Open
Quick104 wants to merge 4 commits into
fix/4618-detached-stop-seekfrom
fix/4616-admin-stop-end-reason
Open

Quick104 wants to merge 4 commits into
fix/4618-detached-stop-seekfrom
fix/4616-admin-stop-end-reason

Conversation

@Quick104

@Quick104 Quick104 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #4616
Related issue: N/A
Validation tasks: none

Other clients: Apple N/A (no client change needed); Android N/A (no client change needed); Roku N/A (no client change needed)

An administrator's stop could be recorded in history as end_reason: "stopped", as if the viewer had stopped. The stop command recorded nothing durable when it was sent. When the player confirmed, the server removed the live session at once and stopped the attempt under the administrator's stop id afterwards. A player that sends its own stop as it leaves, as the web player and Android do, could reach the attempt first, and its stop was recorded as the viewer's. On a Silo dev deployment with a transcode node, the web player showed "An administrator ended this playback session" while history recorded stopped.

This is stacked on #4622 and targets its branch, because both change the attempt's stop statement; review that one first. It does not depend on #4623.

Approach

The attempt now records each pending stop, by command id and when it was sent, written before the stop goes out and only when this server holds the player's control socket. The stop that wins the attempt copies whether one was pending into its stop receipt, in the same update that wins, so retries, takeovers and the lifecycle sweep all read the same answer. A client stop that won while one was pending records terminated.

Each stop withdraws only its own entry, when it can't be sent or the player refuses it, so overlapping stops, sent from any server, don't clear each other. An entry older than 30 seconds no longer counts, so one whose command was lost (a restart, a failed fallback, a refusal that reached another server) can't turn a much later viewer stop into the administrator's. A stop to a player with no control socket records nothing: its fallback ends the session under the administrator's stop id. Neither write touches updated_at, which the idle expiry reads as activity.

The progress and replan answers (410 after an administrator's end) and a repeat terminate are unchanged.

Validation

  • Reproduced live before and after on a dev sandbox (on this branch's first version, afb0d87; the review since changed how the pending stops are stored, not the path shown) with a transcode node, with the web player in headless Chromium playing an episode the node transcodes. Main recorded stopped in both runs while the player showed the administrator's notice; this branch records terminated in all three runs.
  • A scripted native player that sends its own stop before confirming: stopped on main, terminated here. Controls on this branch: a viewer's stop with no command records stopped, and a viewer's stop after the player refused the admin stop records stopped.
  • A new handler test fails on main (the admin-stopped plays record stopped) and passes here; its viewer-stop cases pass on both. New Postgres and memory-store tests pin the receipt flag, per-command withdrawal, the 30 s window and that updated_at doesn't move; the Postgres ones are listed in scripts/ci/db-contracts.txt.
  • Review fixes: the handler cases "a later stop's refusal leaves the earlier one" and "viewer stop before a stop's fallback" fail on 01b493d and pass here. TestAdminStopMarksPerCommandDB pins that withdrawing one stop leaves another.
  • go test ./internal/api/handlers/ ./internal/playback/... ./internal/apiv2/ with a freshly migrated Postgres, golangci-lint on the changes, make verify-migrations.
  • v1.0 validation board: no task links this change, and the passed transcode-node failover cases, which end sessions through the same stop paths, see no change (no pending administrator stop, so the receipt flag stays unset).

Evidence: https://evidence.siloserver.org/r/silo-server/4616-admin-stop-end-reason/

Risks

One nullable JSONB column, added without a default. During a rolling deploy, a stop that an older replica sends doesn't set the mark, so that play can still record stopped, as before.

The admin stop command now makes one bounded write (up to 1 s) before it reaches the player, under the command ledger's lock, and a refused stop makes one on the socket reader.

A viewer who stops on their own within moments of an administrator's stop reaching their player is recorded as terminated. A control socket that connects in the instant between the lane check and the send gets an unmarked stop, which records as before this change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

Council review

Plan round on 4eb4d4a86 (before implementing): Sol, Opus and Gemini, no scores. Adopted then: decide the reason in the stop's own update and keep it in the receipt (Opus, Sol); scope the mark to its command (Sol); include the lifecycle sweep's caller (Gemini). Keeping the mark on the no-socket path (Opus, Gemini) was reversed in review.

The background review this PR opened with: Sol posted findings on afb0d87 (no score recorded); no Opus or Gemini review appears on the PR.

Review rounds: 3, last reviewed 703adb1

Member Round 1 (01b493d) Round 2 (b1dc724) Round 3 (703adb1)
Sol (gpt-6.2-sol, xhigh) 5/10 6/10 7/10
Opus (claude-opus-5-5, high) 7.5/10 8/10 8.5/10
Gemini (gemini-4-neon, xhigh) 6/10 7/10 9/10

Fixed: a second stop's refusal or failed send erased the first stop's mark (now one entry per command); a stop with no control socket left a mark for the viewer's own stop; the replan test couldn't fail. Answered: the refusal clear stays on the socket reader (the pause confirmation already spends the same budget there) and the mark write stays under the ledger lock (moving it lets a stale command take a mark it never withdraws). Left open for the maintainers: progress, replan and a repeat terminate still judge an administrator's end by the stop id alone, and a socket that connects between the lane check and the send gets an unmarked stop.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, GitHub CLI, T3 Code delegated reviews (Codex, Claude, Antigravity), Playwright (web player capture)
  • Model(s): claude-opus-5-5 (implementation and review fixes), gpt-6.2-sol, gemini-4-neon (review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: a plan round before implementing, a code review at high effort, a background review, and three council rounds in a maintainer review; see Council review.

Note

Record player stops as terminated when an admin stop is pending

  • When an admin issues a stop, the server marks the attempt (MarkAdminStop) before dispatching. If the player's own stop reaches the server first within the 30-second AdminStopPendingFor window, the stop receipt records AdminStopRequested and the end reason becomes terminated.
  • ClearAdminStop withdraws a mark when a stop is refused or fails to dispatch, and can transfer it to another pending stop command for the same session.
  • Implemented in both the in-memory store (protocol_store_v3.go) and PostgreSQL (postgres.go); PostgreSQL persists marks in new admin_stop_command_id/admin_stop_requested_at columns.
  • Risk: Behavioral Change — stops that previously recorded stopped now record terminated when an admin stop was pending within 30 seconds; see endReasonForStop in playback_service.go and the new migration.

Macroscope summarized b1dc724.

…top lands first

An administrator's stop command recorded nothing durable when it was sent.
When the player confirmed, the server removed the live session at once and
stopped the attempt under the administrator's stop id afterwards. A player
that sends its own stop as it leaves, as the web player and Android do, could
reach the attempt first, and history recorded the play as stopped by the
viewer.

The attempt now carries the pending stop's command id and when it was sent,
set before the stop goes out. The stop that wins the attempt copies whether
one was pending into its receipt, in the same update, and a client stop that
won while it was pending records terminated. Only that command clears the
mark, when it can't be sent or the player refuses it, and a mark older than
30 seconds no longer counts, so one whose command was lost can't relabel a
later viewer stop. The mark doesn't touch updated_at, which the idle expiry
reads as activity.

Closes #4616

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T01:57:56.124176Z 703adb1 New commits
🔒 Security Review ✅ Completed 2026-11-22T02:00:14.049117Z 703adb1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The change tracks pending administrator stop requests and includes their status in stop receipts. When a client stop wins while an administrator stop is pending, handler paths use that status to select the playback end reason.

Changes: Administrator stop attribution

Layer / File(s) Summary
Record pending administrator stops
internal/playback/protocol_store_v3.go, internal/playback/protocol_store_progress_v3_test.go, internal/playback/planstore/postgres.go, internal/playback/planstore/progress_lifecycle_db_test.go, migrations/sql/20261120011304_add_playback_attempt_admin_stop_command.sql, scripts/ci/db-contracts.txt
Stop receipts record whether an administrator stop was pending. The memory and PostgreSQL stores mark and clear pending stops, with a 30-second attribution window. The migration adds the PostgreSQL marker columns. Tests cover marker behavior and expiration.
Dispatch stops and resolve end reasons
internal/api/handlers/admin_playback_commands.go, internal/api/handlers/admin_playback_commands_test.go, internal/api/handlers/playback_realtime.go, internal/api/handlers/session_ws.go, internal/api/handlers/playback_service.go, internal/api/handlers/playback_end_claim.go, internal/api/handlers/playback_lifecycle_sweep.go, docs/admin-api.md, docs/playback-api.md
The handler marks an administrator stop before dispatch and clears the mark on specified failures. Stop receipt state is passed to end-reason selection and lifecycle finalization. Tests cover stop orderings, and the API documentation describes the resulting terminated reason.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant AdminCommandHandler
  participant PlanStoreV3
  participant Player
  participant StopFinalizer
  AdminCommandHandler->>PlanStoreV3: MarkAdminStop(sessionID, commandID)
  AdminCommandHandler->>Player: Dispatch administrator stop
  Player->>PlanStoreV3: StopAttempt
  PlanStoreV3-->>StopFinalizer: StopReceiptV3 with AdminStopRequested
  StopFinalizer->>StopFinalizer: Select playback end reason
Loading

Possibly related PRs

Suggested reviewers: rhainland, blurbery

Merge Risk: Low · up to b1dc7

This change records a player stop that follows an administrator stop as terminated. The attribution is time-window based, so the documentation should say it is an attribution rule, not proof that the player carried out the command. There is no established functional defect, so merge risk is low.

Security architecture risk: Minimal · up to b1dc7

The change makes administrator-stop attribution durable without expanding playback-control authority. No introduced design-level issue materially affecting security, session revocation, or failure containment was identified in the reviewed paths.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected change affects attribution for the identified playback attempt and its history/lifecycle finalization. Marker mutations are session-scoped, and withdrawal additionally requires the matching command ID; no broader data-store or environment authority is introduced by these operations.

Trust Boundaries and Controls

  • observed — Viewer stop requests validate stop identity, reject reserved server stop IDs, and check user/profile ownership before mutating an attempt. Socket results must match the socket session and known command ownership before withdrawing a pending stop; the store then enforces command-scoped withdrawal.

Resilience and Maintainability Implications

  • observed — Pending-command handoff selects another stop from replica-local memory, while the PostgreSQL marker and winning receipt are durable. The expiry window bounds how long a stranded marker can affect attribution after interruption; it is not a durable inventory of every outstanding command.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title describes the main change: an administrator stop is recorded as terminated when the player's stop reaches the attempt first. The changeset adds pending admin-stop marks, a receipt flag, and …
Linked Issues check Passed Objective [#4616]: when an administrator stop wins or races a client stop, playback history must record terminated, whichever stop reaches the attempt first. Stack scope: the stacked parent #4622 is…
Out of Scope Changes check Passed All changes since the previous review relate to the #4616 fix. The heir hand-off (ClearAdminStop with heir, pendingRealtimeStop) covers overlapping admin stops. The no-socket withdrawal follows th…
Description check Passed The description is specific and closely tied to the changeset. It names the bug (an administrator stop recorded as end_reason "stopped"), explains the approach (pending admin-stop marks written before…
Full details: Title check

Explanation

The title describes the main change: an administrator stop is recorded as terminated when the player's stop reaches the attempt first. The changeset adds pending admin-stop marks, a receipt flag, and end-reason resolution that returns terminated for this case, which matches the title.

Full details: Linked Issues check

Explanation

Objective [#4616]: when an administrator stop wins or races a client stop, playback history must record terminated, whichever stop reaches the attempt first. Stack scope: the stacked parent #4622 is contained in the merge base, and no other stack member is required. Stack review evidence is unavailable, and this PR states it does not depend on #4623. Evidence from the whole-PR summary and the incremental diff (afb0d87..b1dc724, internal/api/handlers/playback_realtime.go): (1) the admin stop mark is set before dispatch (markAdminStop, dispatchSequenced), as the issue requests; (2) the winning StopAttempt copies the pending flag into the stop receipt in the same update (planstore/postgres.go, protocol_store_v3.go); (3) endReasonForStop returns terminated for a client stop when that flag is set; (4) the mark is cleared when dispatch fails or the player refuses the stop, which the issue also requests. The later commit changes the no-control-socket path to withdraw the mark, and hands the mark to another unanswered stop on the same replica (pendingRealtimeStop). This is consistent with the issue's clear-on-rejection rule. A viewer stop that wins before the no-socket fallback is recorded as stopped. The issue does not require terminated in that case, because the player never received or acknowledged the admin command. The PR description still says a no-socket stop keeps its mark, which is stale. Uncertainty: the assessment relies on the summary and one focused diff read, not a full test run. The 30-second window and the rolling-deploy gap are documented limits. The HTTP finalizer measurement side effect has no stated acceptance criterion.

Full details: Out of Scope Changes check

Explanation

All changes since the previous review relate to the #4616 fix. The heir hand-off (ClearAdminStop with heir, pendingRealtimeStop) covers overlapping admin stops. The no-socket withdrawal follows the clear-on-undelivered rule. The change in stopPlaybackSessionWithResult uses the accepted progress sample's position for the stopped attempt. It ties to the measurement handoff side effect named in the issue, but the PR description does not state it. Earlier changes (handler, planstore, protocol store, migration, tests, CI contract, docs) remain connected to the same fix. No unrelated change is found in the reviewed evidence. Reviewer follow-up, not a scope failure: the PR description's no-socket text is stale and conflicts with the later commit, and the accepted-sample position change should be described in the PR description.

Full details: Description check

Explanation

The description is specific and closely tied to the changeset. It names the bug (an administrator stop recorded as end_reason "stopped"), explains the approach (pending admin-stop marks written before dispatch, copied into the stop receipt, cleared on refusal or failed dispatch, 30-second window, no updated_at change), and lists the affected stores, migration, and tests. It also records validation and risks. The description is detailed and on-topic, so it meets the lenient check.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Nov 20, 2026

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review (gpt-6.2-sol, reviewed afb0d87)

AI disclosure. This review was written by gpt-6.2-sol in the T3 Code Codex harness.

Comment thread internal/playback/planstore/postgres.go Resolved
if record.Name == playback.CommandStop {
// The player refused the administrator's stop and plays on,
// so a stop it makes later is its own again.
h.markAdminStop(sessionID, result.CommandID, false)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — A slow refusal clear can make an answered pause terminate playback. The socket loop at internal/api/handlers/playback_control_socket_v2.go:445 processes frames serially. Hold the attempt row while this clear runs, then send a pause with a 250 ms deadline. Its immediate completion can sit unread for up to one second, and internal/api/handlers/admin_playback_commands.go:279 runs the fallback that ends the session. Keep reading frames and cancel their timers as results arrive, while processing the database updates in order outside the reader.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this one. The mechanism is real, but it's the same exposure the pause confirmation already accepts on this reader (realtimeProgressAttempt with the same 1 s realtimeReceiptReadBudget, kept "well inside the default command deadline"), and here only a refused stop pays it. Moving the clear off the reader isn't free: the HTTP stop doesn't wait on the per-session result queue, so a viewer stop right after a refusal could win before an asynchronous clear lands and record terminated. I've left it to the maintainers whether sub-second custom deadlines are worth a tighter budget on reader-side store calls generally.

🤖 Claude Code (claude-opus-5-5)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1

internal/playback/planstore/progress_lifecycle_db_test.go: 1

213-213: Trivial · Maintainability & Code Quality · Quick win

Check replan survival before replacing the mark.

MarkAdminStop(commandB) restores a pending mark after CompleteReplan. The test therefore passes even if the replan deletes command A's mark.

Use a separate attempt for the replan-survival case. Stop that attempt immediately after CompleteReplan and assert AdminStopRequested. Keep command replacement and command-scoped clearing in a separate case.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fb58ac99-b21f-482c-8270-1eb7e38ceff8
Commits

Reviewing files that changed from the base of the PR and between bc86d9e and afb0d87.

Files selected for processing: 15

  • docs/admin-api.md
  • docs/playback-api.md
  • internal/api/handlers/admin_playback_commands.go
  • internal/api/handlers/admin_playback_commands_test.go
  • internal/api/handlers/playback_end_claim.go
  • internal/api/handlers/playback_lifecycle_sweep.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/session_ws.go
  • internal/playback/planstore/postgres.go
  • internal/playback/planstore/progress_lifecycle_db_test.go
  • internal/playback/protocol_store_progress_v3_test.go
  • internal/playback/protocol_store_v3.go
  • migrations/sql/20261120011304_add_playback_attempt_admin_stop_command.sql
  • scripts/ci/db-contracts.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 01b493d (this PR's change on top of #4622's current head, which I merged in first; the only conflicts were the finishStop call sites #4622 reshaped, and finishStop now reads the receipt's flag).

The approach holds: the player's own stop can reach any replica, so the mark has to be durable, and copying it into the receipt in the update that wins the attempt is the one place every finalizer already reads. The PR's handler test fails on the base for the administrator-stop cases and passes for the viewer-stop cases, as described.

Verified defects, each already raised in an earlier thread on this PR. I'm fixing both in a commit on this branch, so there's no need to change them yourself:

  • Medium: a second stop's refusal or failed send erases the first stop's mark. Stop A is delivered and the player starts leaving, then stop B (a second click mints a new command id) takes the mark over. If the player refuses B, or B's socket write fails, clearing B leaves no mark, and A's HTTP stop records stopped. A new handler case reproduces it. Fix: when a stop's mark is withdrawn and another stop of the same session is still unanswered on this replica, the mark passes to that stop.
  • Low: a stop with no control socket keeps its mark. Nothing was sent, so no player is carrying it out, but a viewer stop before the fallback records terminated. If the replica restarts before its in-memory fallback timer runs, that lasts for the whole 30 s while playback continues. The fallback's own stop id already records terminated when it wins, so the mark adds nothing there. It also contradicts the new playback-api.md text ("being sent to the player"). Fix: withdraw the mark on a missing lane too, before scheduling the fallback.

Also fixed: TestAdminStopMarkDB re-marked before it checked that the mark survives a replan, so that check couldn't fail. It now reads A's mark straight after CompleteReplan.

Not changed, with reasons, in the earlier threads and the summary: the refusal clear on the socket reader (the same 1 s budget the pause confirmation already spends on that reader), and the write under the ledger lock (inline below).

Maintainer decision: history now says terminated for a play whose client stop won with the mark, but attemptEndedByAdmin (410 vs 404 on a late progress or replan) and a repeat terminate's already_revoked still look only at the stop id. The PR keeps them unchanged on purpose. The player in that case has already left, so I'd leave them and note the split in the docs, rather than widen this PR.

🤖 Claude Code (claude-opus-5-5)

A second administrator stop took the attempt's pending mark over from the
first. When the player refused the second one, or its send failed, clearing
it left no mark, and the first stop's player recorded `stopped`. Withdrawing
a stop's mark now hands it to another stop of the session still unanswered
on this replica.

A stop that could not reach the player because it has no control socket
also withdraws its mark now. Nothing is carrying it out, so a viewer stop
before the fallback is the viewer's own, and the fallback records the
administrator's end under its own stop id.

TestAdminStopMarkDB now checks the mark right after the replan, before a
second stop replaces it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 697a75b1-05e6-4618-ba0d-26f8f1e28139
Commits

Reviewing files that changed from the base of the PR and between afb0d87 and b1dc724.

Files selected for processing: 10

  • docs/admin-api.md
  • docs/playback-api.md
  • internal/api/handlers/admin_playback_commands.go
  • internal/api/handlers/admin_playback_commands_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/playback/planstore/postgres.go
  • internal/playback/planstore/progress_lifecycle_db_test.go
  • internal/playback/protocol_store_v3.go
  • scripts/ci/db-contracts.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment thread docs/playback-api.md
Comment on lines +341 to +342
pending, records the administrator's end (`terminated`): the player is
carrying it out. A stop the player refused, or one that could not be sent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Describe the attribution as a heuristic.

If the viewer independently stops while an administrator command is pending, the stop also records terminated. The pending mark does not prove that the player carried out the command. Describe the time window as an attribution rule rather than proof of cause.

The attempt held a single pending-stop slot, so overlapping stops had to
hand it back and forth through each replica's in-memory command records.
That handover could race a refusal on the socket reader and restore a stop
the player had already refused, and it couldn't see a stop sent from
another replica before the player's control socket moved.

admin_stop_commands now holds each pending stop as {command_id: sent_at}.
A stop withdraws only its own entry, and the stop that wins the attempt
records the administrator's end when any entry is inside the window. A
stop marks only when this replica holds the player's lane, so a stop to a
player with no control socket writes nothing.

The migration hasn't merged anywhere, so it is rewritten in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104

Quick104 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed head: 703adb1 (this PR's change on top of #4622 at 7d22771, which I merged in first). Rechecked on the same head: the validation board, CI, and overlap with main.

Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green)

Fit: this makes the administrator's playback history say who ended a play, which is what the admin log is for. It does that on the server, for every native client, with one nullable column, no setting and no API change. Admin commands are rare, so the extra write per stop costs a low-end box nothing noticeable.

Readiness: the approach is sound and each behavior change is covered by a test that failed before it. The administrator-stop cases of the PR's handler test fail on the base. The two cases I added fail on 01b493d. The validation board check has now run and found no affected case. One open decision remains (below), and the final head wasn't shown live again after the review changed how pending stops are stored. The path the author reproduced live is unchanged.

Addressed

  • A second stop's refusal or failed send erased the first stop's mark (raised in the earlier review and by all three council members). Each pending stop now has its own entry (admin_stop_commands, {command_id: sent_at}), and a stop withdraws only its own. A round-2 handover between stops was replaced in 703adb1, because it could race a refusal and couldn't see a stop sent from another server. The migration hasn't merged anywhere, so it was rewritten in place.
  • A stop to a player with no control socket kept its mark, which turned the viewer's own stop into terminated for up to 30 s if the server restarted before its fallback ran. Such a stop now records nothing, and its fallback records the administrator's end under its own stop id.
  • The replan test couldn't fail. It now checks the mark straight after the replan.
  • The commandLocal lock comment and the playback-api.md wording now match the code.

Answered, not changed

  • The refusal clear is a store write of up to 1 s on the socket reader, the same budget the pause confirmation already spends there. Making it asynchronous would let a viewer stop sent right after a refusal win before the clear lands.
  • The mark write runs under the handler-wide command lock (disclosed in the PR). Moving it before the lock would let a stale or duplicate command take a mark it never withdraws.
  • A failed mark or withdrawal falls back to the old behavior or lapses after 30 s. The rolling-upgrade gap is in the PR's risks.

Left for the maintainers

  • Maintainer decision: history now records terminated when the player's own stop won with a stop pending, but progress and replan (410 vs 404) and a repeat terminate's already_revoked still judge an administrator's end by the stop id alone. The player has already left in that case, so I'd keep this PR as it is and document the split. Unifying them would change what clients get back.
  • Low: a control socket that connects in the instant between the lane check and the send gets an unmarked stop, which records as before this change. Skipping the send when no lane is open would close it. A retry under the same command id on another server after the socket moved, and expired entries left on the row by a failed withdrawal, are smaller still.

Checks

Council

Member Round 1 (01b493d) Round 2 (b1dc724) Round 3 (703adb1)
Sol (gpt-6.2-sol, xhigh) 5/10 6/10 7/10
Opus (claude-opus-5-5, high) 7.5/10 8/10 8.5/10
Gemini (gemini-4-neon, xhigh) 6/10 7/10 9/10

🤖 Claude Code (claude-opus-5-5)

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

Labels

bug Something isn't working priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant