Skip to content

fix(playback): let only the end that wins a session's row record it - #3192

Merged
Quick104 merged 13 commits into
mainfrom
feat/playback-finalization-claims
Oct 28, 2026
Merged

Quick104 merged 13 commits into
mainfrom
feat/playback-finalization-claims

Conversation

@Quick104

@Quick104 Quick104 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #1206 C2, #1208 C2, Silo-Server/silo-apple#330 C2, Silo-Server/silo-apple#331 C2, Silo-Server/silo-android#340 C2, Silo-Server/silo-android#341 C2, Silo-Server/silo-apple#339 C5, Silo-Server/silo-android#349 C5, Silo-Server/silo-android#350 C5

When two ends of one native playback session race (an expiry, an abort, an administrator's terminate, a client stop), more than one of them can write the play's watch history and admin history. Native watch history mints a new row per write, so the user can see the same play twice. A losing end can also record its reason over the winner's. Separately, an administrator terminate on an API server without the session's live copy revoked the session but recorded nothing in admin history.

This change makes the end that wins the session's attempt row the only one that writes those records, on every path. It also records the play when a terminate lands on a server without the copy.

Builds on #3191, which has merged.

Approach

  • One claim for every end. Before an expiry, an abort, a terminate or an unconfirmed admin command's fallback writes anything, it stops the attempt row under its own server-minted stop id and claims the finalization lease, the order a v2 stop already used.
    • Only the claim holder runs the non-idempotent writers: watch history, watch-provider events, the admin log.
    • An end that loses removes only its own server's copy and transport.
    • A claim can also take over a winner that died before finishing.
    • If the store can't answer, the end writes as before rather than risk nobody writing it.
  • Terminate without the copy. The winning terminate finalizes from the attempt row, the same way a v2 stop on such a server does. A terminate of a session another stop already ended still answers 404.
  • The winning stop's own end. An end that claims an earlier stop's unfinished receipt finishes it as that stop, with its reason and accepted final sample, and only then tears down its own copy. An expiry or abort writes the final sample its attempt accepted. A terminate whose teardown fails stays reclaimable, and a claim whose reply was lost is resolved by reading the lease back.
  • Providers hear an end recorded from the attempt row, so a terminate on a server without the copy (or a v2 stop there) sends the provider stop the dropped copy never would. An end that finishes an abort whose server died sends the abort's terminal pause.
  • Stale Jellyfin copies. A Jellyfin session has no attempt row. When its copy on one server expires after another server already recorded the play's end (a stop or a method switch), the copy is dropped instead of recording an expiry over that end. This closes the known limit fix(playback): record admin history for every way a session ends #3191 left.
  • Validated paths this reworks. Manual reports on the tasks above exercised two of these ends: an administrator stop the player never confirmed, together with terminate (C2), and expiry after a client outage longer than the idle grace (Audiobooks C5). Both now claim the attempt row before writing, so the order of their steps changes. What a client sees stays the same: 410 after an administrator end, 404 after an expiry, and the session's tokens denied. What changes is that a losing end no longer writes a second history row or provider event, and a terminate without the live copy now records the play. The cases are worth re-running after merge.
  • The player-confirmed admin stop over the control socket already claims the row. It still sends that flow's provider notification, and skips it when a client stop finalized the row first and already sent one.
  • docs/playback-api.md describes the claim. No API contract change. Admin and server internals only: no Apple, Android or web change, and no Jellyfin protocol change.

Validation

  • Ran on an isolated sandbox built from this branch, with real HTTP calls. A hard restart of the single API server stood in for "a server without the live copy":
    • v2 start, progress at 300 s, restart, then admin terminate: 200, history terminated at 300 s with client and device, and progress afterwards 410. Before, no history row.
    • terminate with the live copy: 200, terminated at 240 s; a second terminate 404, history unchanged.
    • expiry after 51 s idle: expired at 120 s, receipt finalized, progress 404, a later client stop replays and leaves history as is.
    • abort (source made unreadable, stream request 404): aborted at 200 s, progress 404.
  • Races between two servers (an expiry or abort losing to a client stop that lands after its checks, a stale Jellyfin copy expiring after a stop elsewhere, a terminate without the copy) have tests; they need two API servers, so they weren't run on the sandbox. The history facts DB contract now also covers reading a session's recorded end.
  • Gate: build, gofmt, vet, make lint-changed (0 issues), make lint-router-recovery, every make verify-* target, TestCommittedArtifactMatchesRouter, web lint, format, build and budget, and make test-web pass.
    • make verify-actionlint didn't run: actionlint 1.7.12 isn't installed on the machine used, and no workflow changed.
    • make test-go passed every package except internal/database's TestLogPartitionsMatchPartmanOnNonUTCServer, which fails on fix(playback): record admin history for every way a session ends #3191 too. It builds its own database from migrations up to 028 and fails for America/New_York while US daylight saving time ends inside its window. It doesn't reach this change.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3192/

No visible change. The evidence page has the sandbox steps and results, the build and the test results.

Risks

  • Expiry, abort and terminate now order their steps differently (row and claim first, writers after). The deny marker and stopped row are written first, as before for terminate and newly for expiry and abort. Existing expiry, abort, terminate, replan-410 and realtime tests pass unchanged, apart from helpers the change removed.
  • The stale-copy check reads admin_playback_history for a Jellyfin copy when it expires: one indexed read per expiry.

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 says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code; Codex (gpt-6.1-sol) for read-only design reviews
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. claude-opus-5-5 wrote the code, tests, docs change and this description from a maintainer-approved plan.
  • Adversarial review: The lifecycle-events design behind this PR had two read-only Codex reviews (gpt-6.1-sol, xhigh then high). Writing before claiming and duplicate native watch history were among their findings, and this PR resolves them. A review of this diff follows in the PR thread.

🤖 Generated with Claude Code

Note

Fix playback session end so only the winning end records history

Adds a shared end-claim flow in playback_end_claim.go. Every session-ending path (client stop, expiry, abort, admin terminate, stream abort) now claims the attempt row and its finalization lease before writing history, so exactly one admin-history row, provider event, and watch-history entry are written for the winning stop.

  • The recorded end reason comes from the stop that won the attempt row, not from the caller that happens to run last.
  • Admin termination and expiry on a replica without a live session copy can finalize from the attempt row via endSessionAsAdmin and FinishOtherEnd takeovers.
  • Adds PGPlaybackAdminStore.HistoryEndReason to read a session's recorded end reason; used to keep a stale Jellyfin copy from overwriting a prior non-expiry end.
  • Removes the standalone expiry and admin stop helpers in playback_service.go; their duties moved to the shared claim flow. The listAdminPlaybackHistory entry was removed from breaking-approvals.json.
  • Extensive race coverage in playback_service_test.go verifies one history row, winning reason, and single provider event across stop races.
  • Behavioral Change: provider pause events for aborted sessions now set SessionEnded; aborted or expiring ends that lose the race no longer write their own history or provider event. Docs in playback-api.md describe the new ordering.

Macroscope summarized 84fb4ce.

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T15:45:14.506189Z 84fb4ce New commits
🔒 Security Review ✅ Completed 2026-10-28T15:46:50.175435Z 84fb4ce 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 Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

Expiry, abort, and administrator termination now use native-end claims to arbitrate session finalization. Only the winning end writes history and provider events. Tests cover competing endings, stale replica expiry, and recorded end reasons.

Changes: Playback end arbitration

Layer / File(s) Summary
Native-end claims and stop finalization
internal/api/handlers/playback_end_claim.go, internal/api/handlers/playback_service.go, internal/api/handlers/playback_admin_store.go
Native-end claims arbitrate attempt finalization. Stop callers can receive errors from failed live-session stops. The admin store reads recorded end reasons.
Expiry, abort, and administrator termination
internal/api/handlers/playback.go, internal/api/handlers/playback_realtime.go, internal/api/handlers/stream.go, internal/api/handlers/admin_playback_control.go, internal/api/handlers/admin_playback_terminate.go, internal/api/router.go, docs/playback-api.md
Expiry, abort, and administrator termination use end claims. Losing local copies can be dropped without writing end records. The router connects the stream handler to the playback handler’s FinishOtherEnd callback. The documentation describes distinct expiry and abort stop IDs and claim-based finalization.
History and competing-end validation
internal/api/handlers/playback_finish_history_test.go, internal/api/handlers/playback_service_test.go, internal/api/handlers/playback_test.go, internal/api/handlers/session_ws_pause_state_test.go, contracts/api/v2/breaking-approvals.json
Tests cover history reason lookups, stale-copy expiry, competing endings, and realtime provider notification. The breaking-approval list is empty.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant EndPath
  participant PlaybackHandler
  participant AttemptRow
  participant History
  participant Providers
  EndPath->>PlaybackHandler: Claim session end
  PlaybackHandler->>AttemptRow: Stop attempt and claim finalization
  alt claim owns the end
    PlaybackHandler->>History: Record winning end
    PlaybackHandler->>Providers: Send eligible end events
  else another end owns the attempt
    PlaybackHandler->>AttemptRow: Read winning stop receipt
  end
Loading

Possibly related issues

  • Silo-Server/silo-server#2845: The issue describes a stale Jellyfin replica stopping a job served by another replica. This change prevents a stale copy that loses end ownership from writing finalization records.

Possibly related PRs

  • Silo-Server/silo-server#3191: Adds detached finishing and history recording for ends without a local session; this change gates finalization on attempt-row ownership.
  • Silo-Server/silo-server#3184: Introduces playback end reasons and reason-aware history, which this change uses during end arbitration.
  • Silo-Server/silo-server#3194: Adds lifecycle end recording; this change defines attempt-row ownership for competing ends.

Suggested labels: api-v2, impact: playback

Merge Risk: Moderate · up to 54eae

Failure races can lose playback history and provider updates or duplicate end effects, while stream aborts can leave providers active. These issues should be resolved before merging.

Security architecture risk: Moderate · up to 54eae

Coordination should reduce duplicate playback records and preserve the winning end reason. However, an unresolved finalization claim can remove the local session without a confirmed owner for completing its end records. Access revocation is still attempted before recording.

Retained concerns

  • Medium · reliability · inferred: After stopping an attempt, an unconfirmed finalization claim is represented like an already-completed end. Native callers can then discard local state without running the winning writers or establishing a durable retry owner. Administrator termination can report success after local teardown, while its playback-history and provider effects remain incomplete. This weakens lifecycle failure containment and end-record accountability; recovery requires another caller unless an external recovery mechanism exists.
Security review details

Security Blast Radius

  • inferred — The demonstrated coordination failure is scoped to affected playback sessions and their end records across replicas. It does not establish cross-user authority, credential access, or continued media access after successful revocation. Store failure could affect multiple concurrent session endings.

Trust Boundaries and Controls

  • observed — The inspected realtime chain remains behind authenticated WebSocket session ownership checks. The public stop path retains caller and attempt ownership validation. Administrator termination remains registered as an acting-administrator operation, and legacy playback-control routes remain inside the acting-administrator middleware group.

Resilience and Maintainability Implications

  • inferred — Lease takeover provides recovery when another end or replay arrives, but lease expiry alone does not execute recovery. Removing the local copy after an unresolved claim therefore leaves completion dependent on future traffic or an unverified external recovery owner.

Hardening Proposals

  • proposed — Represent unresolved finalization separately from completed or actively owned finalization, and give pending work an explicit durable recovery owner. Preserve prompt revocation while making completion recoverable without requiring another client request; do not resolve ambiguity by speculatively repeating non-idempotent writers.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: only the end that wins the session row records playback history.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly explains the native-end claim arbitration changes, affected termination paths, validation, risks, and test results described in the changeset.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Oct 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c8649e402

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/playback.go Resolved
Comment thread internal/api/handlers/playback.go Resolved
@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase impact: playback Can't play, stalls, or wrong media labels Oct 28, 2026

@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: 3


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: 2fedc2d7-9a1a-42c4-a808-e4c1f7cd74c9
Commits

Reviewing files that changed from the base of the PR and between 466f047 and 6c8649e.

Files selected for processing: 12
  • contracts/api/v2/breaking-approvals.json
  • docs/playback-api.md
  • internal/api/handlers/admin_playback_control.go
  • internal/api/handlers/admin_playback_terminate.go
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/playback_test.go
  • internal/api/handlers/stream.go

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 internal/api/handlers/playback.go Resolved
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch from 6c8649e to e98f2ba Compare October 28, 2026 00:51
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Oct 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e98f2ba653

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Major revalidation impact

Unconfirmed admin stops (C2). The reports for #1206 (Server), #1208 (Web), Silo-Server/silo-apple#330 (iPhone/iPad), Silo-Server/silo-apple#331 (tvOS), Silo-Server/silo-android#340 (phone/tablet), and Silo-Server/silo-android#341 (Android TV) exercise stops the player did not confirm and check for orphaned playback state. This PR replaces that fallback/terminate cleanup path with claim-first finalization. The prior reports use the old end state machine, so these cases need re-validation after merge.

Expiry recovery (Audiobooks C5). The reports for Silo-Server/silo-apple#339 (iPhone/iPad) and Silo-Server/silo-android#349 (phone/tablet) and #350 (Android TV) include reconnects after roughly three-minute or at least 70-second outages. Those exceed the 45-second active-session idle grace and reach expireSessionCopy, whose finalization order this PR changes. Expiry still returns 404, but the server lifecycle is reworked; revalidate these C5 cases after merge.

The PR should explain why these previously reported cleanup and recovery paths are being reworked. The task issue Results tables remain Not run; the manual reports are in issue comments on the tasks and the #2280/#2282 fix stack.

Validation tasks line

Validation tasks: changes #1206 C2, #1208 C2, Silo-Server/silo-apple#330 C2, Silo-Server/silo-apple#331 C2, Silo-Server/silo-android#340 C2, Silo-Server/silo-android#341 C2, Silo-Server/silo-apple#339 C5, Silo-Server/silo-android#349 C5, Silo-Server/silo-android#350 C5

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@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: 65421eb9-a484-4084-8443-2db8bced1320
Commits

Reviewing files that changed from the base of the PR and between 6c8649e and 21ba551.

Files selected for processing: 7
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_end_claim.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/stream.go

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

Comment thread internal/api/handlers/stream.go Resolved
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch from 21ba551 to a8580fe Compare October 28, 2026 01:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b428c2ab16

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/stream.go Resolved
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch from b428c2a to 90c980b Compare October 28, 2026 01:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90c980bd1c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/playback.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37a2029a9f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67610da5f1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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: 055141d0-083f-4f18-9ae9-c27044754c51
Commits

Reviewing files that changed from the base of the PR and between 21ba551 and 67610da.

Files selected for processing: 11
  • docs/playback-api.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_admin_store.go
  • internal/api/handlers/playback_end_claim.go
  • internal/api/handlers/playback_finish_history_test.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go
  • internal/api/handlers/session_ws_pause_state_test.go
  • internal/api/handlers/stream.go
  • internal/api/router.go

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f61758d04

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/api/handlers/playback.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d12916bc3a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c65f57fc64

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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: 9f4036cc-bc9b-4e58-9473-9c80b9fbb507
Commits

Reviewing files that changed from the base of the PR and between 67610da and c5e5e8d.

Files selected for processing: 6
  • docs/playback-api.md
  • internal/api/handlers/playback.go
  • internal/api/handlers/playback_end_claim.go
  • internal/api/handlers/playback_realtime.go
  • internal/api/handlers/playback_service.go
  • internal/api/handlers/playback_service_test.go

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

@silo-triage silo-triage Bot removed the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Oct 28, 2026
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch from 54eaeee to 47d655c Compare October 28, 2026 13:30
@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. labels Oct 28, 2026
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch 2 times, most recently from f137d34 to 06a7c78 Compare October 28, 2026 13:50
@Quick104
Quick104 force-pushed the feat/playback-end-history branch from 250f88e to 05c801f Compare October 28, 2026 15:10
Base automatically changed from feat/playback-end-history to main October 28, 2026 15:36
Quick104 and others added 13 commits October 28, 2026 15:37
Expiry, abort and administrator ends now stop the attempt row and claim its
finalization before writing watch history, provider events or the admin log,
the order a v2 stop already used. An end that loses tears down only its own
copy. An administrator end on a replica without the live copy records the
play from the attempt row, aborts get their own server-minted stop id, and a
stale Jellyfin copy whose play another replica ended no longer records an
expiry over that end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An end that takes over an earlier stop's unfinished receipt now finishes it
as that stop, and an expiry or abort writes the final sample its attempt
accepted. A terminate whose teardown fails stays reclaimable instead of
finalized, a finalization claim whose reply was lost is resolved by reading
the lease back, and an end recorded from the attempt row tells watch
providers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…later copy finish an expiry

A player-confirmed administrator stop told providers from both its finalizer
and its caller. An earlier Jellyfin copy's expiry is no longer a definite
end, so a newer copy can still record its further progress.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… realtime notice another stop sent

A realtime confirmed stop no longer tells providers when another stop's
finalizer already recorded the end and told them. An administrator end that
finishes an abort whose replica died sends the abort's terminal pause.

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

A competing finalizer that holds the lease and finishes while the realtime
worker waits told providers itself, so the worker now notifies only when its
own finalization recorded the end and left the event to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a taken-over abort for providers

An expiry that finds the row stopped by an unfinished end now claims it and
finishes it as that end once its lease lapses, instead of dropping its copy.
An end that takes over an abort with the live copy sends a pause that ends
the session, as the abort itself would.

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

An expiry that saw the row stopped but cannot confirm its claim through the
store now drops its copy instead of recording a second end.

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

A finalized administrator receipt without a history row no longer gives the
realtime worker the provider notice: the finalizer already sent it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…inishes another end

The realtime worker no longer writes a terminated admin row over the end its
finalizer recorded, and tells providers with the reason of the stop that won
the attempt row, such as an abort's ending pause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the feat/playback-finalization-claims branch from 06a7c78 to 84fb4ce Compare October 28, 2026 15:42
@silo-kody

silo-kody Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 6de06d1 into main Oct 28, 2026
41 of 51 checks passed
@Quick104
Quick104 deleted the feat/playback-finalization-claims branch October 28, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 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