diff --git a/openspec/changes/add-jellyfin-12-support/tasks.md b/openspec/changes/add-jellyfin-12-support/tasks.md index c4b701fd..a236feb3 100644 --- a/openspec/changes/add-jellyfin-12-support/tasks.md +++ b/openspec/changes/add-jellyfin-12-support/tasks.md @@ -18,6 +18,7 @@ - [x] 2.2 Floor decision on the dependabot SDK-12 PR: default is close-without-merge and stay on the 10.11.9 floor (merging = net10.0 = dropping every 10.11 user; see design). Settled 2026-10-13: no such PR can arrive (see 1.5), and the floor stays at 10.11.9; adopting the 12 SDK is Phase C, started deliberately, never from a Dependabot PR - [x] 2.3 README declares 12.x support explicitly, backed by the 1.6 result, and documents the plugin-directory move. Site release notes carry the same. Original wording: declare 12.0 support explicitly ("runs on 10.11.x and 12.x from one release"), with migration guidance covering Jellyfin's remove-plugins-before-migrating advice (RC3 notes escalated this to "disable all external plugins") and that config + sync history survive a remove/reinstall - [x] 2.4 Covered by 1.6 above: the smoke test was run directly against 12.0.0 stable +- [x] 2.5 Re-verified 2026-12-02 with the released v2.15.2 artifact on **12.4.0** stable (throwaway local container, removed after). `Loaded plugin: Jellyscribe 2.15.2.0`, status Active; every dashboard endpoint, both config pages, the three static assets and the injected `sidebar.js` tag answered 200, and an unauthenticated call answered 401; all seven Letterboxd and Serializd scheduled tasks ran to `Completed` with no accounts linked; no error or warning line named the plugin. Read from the server's own assemblies: `IPlaylistManager.AddItemToPlaylistAsync` on 12.4 is still `(Guid, IReadOnlyCollection, int?, Guid)`, the shape `PlaylistManagerCompat` binds, and all 56 server types and 107 server members the plugin references exist there (matched by name and parameter count, not full signature). Still not covered: a sync with real Letterboxd or Serializd credentials on 12, a playlist actually written on 12, and a catalog install on 12 ## 3. Phase C: SDK adoption / stream split (only when a 12-only API is needed or ABI breaks) diff --git a/openspec/changes/add-serializd-show-status/.openspec.yaml b/openspec/changes/add-serializd-show-status/.openspec.yaml new file mode 100644 index 00000000..eb2b21e7 --- /dev/null +++ b/openspec/changes/add-serializd-show-status/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-12-02 diff --git a/openspec/changes/add-serializd-show-status/design.md b/openspec/changes/add-serializd-show-status/design.md new file mode 100644 index 00000000..d6c1fabb --- /dev/null +++ b/openspec/changes/add-serializd-show-status/design.md @@ -0,0 +1,130 @@ +## Context + +Two entry points log TV to Serializd: `PlaybackHandler.HandleEpisodeAsync` (real time, on a finished play) and `SerializdSyncRunner.SyncOneAsync` (scheduled catch-up and "Sync TV now"). Both call `ISerializdService.LogEpisodesAsync` and `CreateEpisodeLogAsync`, record what they sent in `SerializdSyncHistory` (kinds `watched`, `log`, `showmeta`), and the runner then mirrors the series rating and favourite with `SetShowMetaAsync`. Nothing sets a show's status. + +`SerializdApiClient` already reads `GET /show/{tmdbId}` to resolve season ids and episode counts, and keeps the answer in a season cache. `SerializdSeasonFallback` handles shows Serializd lists as a single season while Jellyfin has several. + +Constraints: + +- A Serializd failure must never affect the Letterboxd path, and a status failure must never affect the episode log. +- A cancelled token cancels waits and reads, never a write already sent. +- Every export path applies `LibraryExclusion.IsExcluded` before calling the service. +- Serializd has no documented public API. The plugin uses the endpoints the Serializd web client uses, so every new request shape has to be captured from the web client and confirmed against a live account before it is relied on. + +## Goals / Non-Goals + +**Goals:** + +- A show appears on "Currently watching" once Jellyscribe has logged an episode of it. +- A show moves to "Watched" only when that is certain: the show has ended and the user has played every episode Serializd lists. +- Each status is sent once per user, account and show, and survives restarts. +- Shows finished before this release are picked up by the scheduled run. + +**Non-Goals:** + +- See the proposal's Non-goals. In addition: no change to how episodes, ratings, likes or reviews are sent. + +## Decisions + +### 1. A pure rule and a separate updater, called after the episode log from both entry points + +Two types, so the name of each says what it does: + +- `SerializdShowStatus`: static and pure. `IsFinished(...)` and the early-out `CannotBeFinished(...)` (decision 6). No I/O. +- `SerializdShowStatusUpdater`: `UpdateAsync(service, user, account, series, showTmdbId, cancellationToken)`. Reads state, calls Serializd, writes state, logs. + +The updater is called after the episode log succeeded and its history rows are written. A failure inside it is logged (account named with `LogRedaction.AccountTag`) and swallowed, with one exception: an `OperationCanceledException` raised because the caller's token was cancelled is rethrown, so a server shutdown stops the work instead of running on through the remaining shows. + +The updater holds a keyed lock per user, account and show (the `FilmSyncLock` pattern) around read, decide, call and write. Two playback-stopped events arriving together for one show therefore make one decision, not two. + +Alternative considered: fold the status calls into `LogEpisodesAsync`. Rejected, because a status failure would then surface as a failed episode log and be retried as one. + +### 2. "Currently watching" is set on the first logged episode, not on playback start + +The plugin subscribes to `PlaybackStopped` and acts only on `PlayedToCompletion`. Using the same moment keeps one trigger, covers the scheduled path (which has no playback event at all), and avoids listing a show the user sampled and dropped. + +Alternative considered: subscribe to `PlaybackStart`. Rejected for the reasons above and because it adds a second event path with its own duplicate handling. + +### 3. "Watched" needs three things to be true + +1. Jellyfin reports the series as ended (`Series.Status` is `Ended`). +2. Serializd lists at least one regular season (season number 1 or higher) for the show, and gives an episode count for every regular season. +3. For every regular season Serializd lists, the number of distinct episodes of that season the user has played in Jellyfin is at least Serializd's count. + +"Played" is Jellyfin's own played flag for that user, so episodes watched before the plugin was installed count. A multi-episode file counts every episode number it covers. Specials (season 0) are ignored on both sides. + +For a show Serializd lists as a single season while Jellyfin has several, condition 3 compares the total of played regular episodes with that one season's count, the same mapping `SerializdSeasonFallback` uses for logging. + +A missing count, an unreadable show, or a missing series status means "not finished". The check fails closed. + +Alternative considered: "every episode in the Jellyfin library is played". Rejected, because a library that holds only the first two seasons would mark a five-season show as watched. + +Alternative considered: trust Jellyfin's status alone and mark any fully played show. Rejected, because a show still airing would be marked watched every time the user catches up. + +### 4. Order of writes when a show is finished + +Mark Watched, then remove from Currently watching. Marking first means a failure between the two leaves the show on both lists, which is harmless and is repaired on a later run; the other order could leave it on neither. + +The removal is always sent for a finished show, including one the plugin never added to Currently watching. The user may have listed it by hand, and the plugin never reads status, so sending the removal is the only way to leave a finished show on one list. Task 1.2 confirms that removing a show that is not listed is harmless. + +### 5. State is one value per user, account and show, in its own small store + +`SerializdSyncHistory` is an append-only set of keys with no values and no timestamps, so it cannot hold a state that changes or a "last checked" time. A new `SerializdShowStatusStore` holds, per user, account and show: + +- `State`: `Watching`, `WatchedPendingRemoval` or `Watched`. Absent means nothing was sent. +- `LastCheckedUtc`: when the scheduled pass last read this show from Serializd and found it not finished (decision 6). + +It is a JSON dictionary persisted the way `SerializdCollectionStore` persists its own (temp file, then move), keyed by Jellyfin user id, the SHA-256 of the lower-cased email, and the show's TMDb id, so the file holds no address. One value per show makes contradictory combinations unrepresentable, and the decision is a switch: + +| State | Finished? | Action | New state | +|---|---|---|---| +| none | no | add to Currently watching | `Watching` | +| none or `Watching` | yes | mark Watched | `WatchedPendingRemoval`, then continue as that row | +| `Watching` | no | nothing | `Watching` | +| `WatchedPendingRemoval` | not rechecked | remove from Currently watching | `Watched` | +| `Watched` | not rechecked | nothing, no network | `Watched` | + +A state is written only after Serializd accepted the request it records. A failed request leaves the state where it was, which is what makes the next run retry exactly the step that failed. + +Alternative considered: three new row kinds in `SerializdSyncHistory`. Rejected: three independent flags for one lifecycle allow combinations the table does not cover, and the rotation in decision 6 needs a timestamp the history file cannot hold. + +### 6. The scheduled run also works through shows with earlier history + +After its normal pass, `SerializdSyncRunner` builds a work list for the account from every show with a `watched` history row whose state is not `Watched`: + +1. **Pending removals** (`WatchedPendingRemoval`): the removal is retried. No read, no recheck. This is what retries a failed removal for a show the user never plays again. +2. **Candidates** (no state, or `Watching`): checked for being finished. + +For candidates, `SerializdShowStatus.CannotBeFinished` is an early-out on Jellyfin data alone: the series is not ended, or an episode of it in the library is unplayed. It can only skip work. It never declares a show finished; only `IsFinished`, the one rule in decision 3, does that, and both entry points and this pass call the same function. A test pins that every show `CannotBeFinished` skips is one `IsFinished` would reject. + +Candidates that survive the early-out are read from Serializd, oldest `LastCheckedUtc` first and never-checked before any checked. A show that is read and found not finished gets `LastCheckedUtc` set to now and is not read again for 7 days. Without that, shows that can never finish (the library holds fewer episodes than Serializd lists) would be read on every run and would use up the cap ahead of shows that can. + +The pass makes at most 25 Serializd show reads per account per run, stops when the token is cancelled, and stops starting new shows once it has run for 5 minutes, so a rate-limited Serializd cannot hold the scheduled task open. The first run after an upgrade therefore spreads a large library over several days. + +Candidates that are not finished are left alone by this pass: it never adds a show to Currently watching, because history that may be years old says nothing about what the user is watching now. For a show it finds finished, it does both writes of decision 4. + +### 7. No new setting + +The account's existing enabled switch governs status as it governs episode logs. The recent direction is fewer per-account settings, and a status that follows from watch history the account already sends does not need its own consent. + +Alternative considered: a per-account "Update show status" switch, on by default. Kept as an open question below. + +## Risks / Trade-offs + +- [The request shapes for the three writes are not yet confirmed] → Task group 1 captures them from the Serializd web client with the test account and records them here before any production code depends on them. If Serializd has no call for one of them, that part is dropped and the proposal is updated. +- [Marking a show Watched might have side effects: overwriting episode logs or ratings, or posting to followers' feeds] → Task 1.3 checks the account's diary, ratings and activity before and after on the test account. A side effect that changes user data stops the change for a decision. +- [Jellyfin's series status is wrong or stale for some shows] → A wrong "Continuing" only delays Watched. A wrong "Ended" still needs every Serializd episode played, so the worst case is a show marked Watched one season early when Serializd's listing is also behind. +- [A user set a status by hand on serializd.com] → The plugin never reads status, so it cannot tell. Adding to Currently watching a show the user already listed is expected to be a no-op (confirmed in task 1.2). The plugin never removes a show from Watched. +- [First run after upgrade marks many shows Watched at once] → Capped at 25 reads per account per run and 5 minutes (decision 6). Release notes say it will happen. +- [A show that passes the early-out but can never pass the full check uses up the cap] → Such a show is read once and then left for 7 days, and the list is ordered oldest-checked first (decision 6). +- [Two finishes of one show arrive together] → Keyed lock per user, account and show (decision 1). +- [The series rating and favourite write (`SetShowMetaAsync`) and a status write affect each other] → Task 1.3 checks both orders on the test account. + +## Migration Plan + +No data migration. The new store is a new file; an older build ignores it. Rolling back the release leaves the file on disk and the statuses on Serializd, both harmless. + +## Open Questions + +- Should accounts get an opt-out switch (decision 7)? Default answer: no. +- Should a status change appear in the dashboard's Activity list? Default answer: no, logged only. diff --git a/openspec/changes/add-serializd-show-status/proposal.md b/openspec/changes/add-serializd-show-status/proposal.md new file mode 100644 index 00000000..a956f007 --- /dev/null +++ b/openspec/changes/add-serializd-show-status/proposal.md @@ -0,0 +1,43 @@ +# Proposal: add-serializd-show-status + +## Why + +Jellyscribe marks episodes watched on Serializd and writes diary logs, but it never touches a show's status. A Serializd profile has two show lists that people use to see where they are: "Currently watching" and "Watched". Today both stay empty for shows watched through Jellyfin unless the user sets them by hand on serializd.com, so the profile says less than the watch history the plugin already sent. No GitHub issue exists. + +## What Changes + +- When Jellyscribe logs an episode of a show for a Serializd account and that show has no status from the plugin yet, it adds the show to the account's "Currently watching" list. +- When a show has ended and the user has played every episode Serializd lists for it, Jellyscribe marks the show "Watched" on Serializd and takes it off "Currently watching". +- The scheduled Serializd sync also checks shows the account already has history for, so shows finished before this release move to "Watched" without another play. +- A status update that fails is retried on a later run. It never fails, delays, or undoes the episode log it followed. +- Status updates follow the same account rules as episode logs: only enabled accounts, and never for a show in a library the account excludes. + +## Capabilities + +### New Capabilities + +None. + +### Modified Capabilities + +- `serializd-sync`: gains requirements for the "Currently watching" and "Watched" show status. + +## Impact + +- `LetterboxdSync/Serializd/ISerializdService.cs` and `SerializdApiClient.cs`: three new operations (add to Currently watching, remove from it, mark a show Watched) and one read (the seasons Serializd lists for a show, with their episode counts). +- New `LetterboxdSync/Serializd/SerializdShowStatus.cs` (the pure rule), `SerializdShowStatusUpdater.cs` (the calls and state changes both entry points use) and `SerializdShowStatusStore.cs` (one state per user, account and show). +- `LetterboxdSync/PlaybackHandler.cs` (`HandleEpisodeAsync`) and `LetterboxdSync/Serializd/SerializdSyncRunner.cs`: call the updater after a successful episode log; the runner also runs the check for shows with earlier history. +- `LetterboxdSync/Serializd/SerializdSyncHistory.cs`: one new read, the shows an account has episode history for. +- More Serializd traffic: at most one show read per status decision, shared with the read the episode log already makes in the same run. +- Tests in `SerializdSyncRunnerTests`, `SerializdSyncRunnerCatchUpTests`, `SerializdPlaybackTests`, `SerializdApiClientTests`, and new `SerializdShowStatusTests`, `SerializdShowStatusUpdaterTests` and `SerializdShowStatusStoreTests`. A live check against the Serializd test account before the write shapes are relied on. +- Ships a minor release: version bump, `## Release notes`, `release-notes.ts` entry, README feature list. + +## Non-goals + +- Reading show status back from Serializd into Jellyfin. +- Setting "Currently watching" when playback starts. The plugin acts on finished plays only, so a show sampled for two minutes is not listed. +- Putting a show back on "Currently watching" after it was marked "Watched" (a rewatch leaves the status alone). +- Any other Serializd list or status (paused, dropped, custom lists). +- A new account setting. Status follows the account's existing sync switch. +- Activity rows for status changes. They are logged, not listed on the dashboard. +- Films and Letterboxd. diff --git a/openspec/changes/add-serializd-show-status/specs/serializd-sync/spec.md b/openspec/changes/add-serializd-show-status/specs/serializd-sync/spec.md new file mode 100644 index 00000000..09227c81 --- /dev/null +++ b/openspec/changes/add-serializd-show-status/specs/serializd-sync/spec.md @@ -0,0 +1,109 @@ +## ADDED Requirements + +### Requirement: Shows being watched are listed as Currently watching +After the plugin logs an episode of a show to a Serializd account, and the plugin has not yet sent any show status for that user, account and show, and the show is not finished (see "Finished shows are marked Watched"), the plugin SHALL add the show to that account's "Currently watching" list. It SHALL do so once per user, account and show, from both the real-time path and the scheduled sync, and SHALL remember that it did across restarts. + +#### Scenario: First episode of a show +- **WHEN** a user finishes S1E1 of a show the plugin has sent no status for, and the episode log succeeds +- **THEN** the show is added to the account's Currently watching list, and the plugin records that it was + +#### Scenario: Later episodes send nothing more +- **WHEN** the same user then finishes S1E2 of that show +- **THEN** the episode is logged and no Currently watching request is made + +#### Scenario: Two accounts of one user +- **WHEN** a user with two enabled Serializd accounts finishes the first episode of a show +- **THEN** each account's Currently watching list gains the show, and each is recorded separately + +#### Scenario: Old history alone does not list a show +- **WHEN** the scheduled sync runs and an account has history for an unfinished show, but no episode of it is logged in this run +- **THEN** the show is not added to Currently watching + +### Requirement: Finished shows are marked Watched +The plugin SHALL treat a show as finished for a user only when all of these hold: Jellyfin reports the series as ended; Serializd lists at least one regular season for the show and an episode count for each; and for every regular season Serializd lists, the user has played at least that many distinct episodes of the season in Jellyfin. Specials (season 0) SHALL be ignored. For a show Serializd lists as a single season while Jellyfin has several, the comparison SHALL use the total of played regular episodes against that one season's count. When any input is missing or cannot be read, the show is not finished. + +When a show is finished and the plugin has not marked it Watched for that user and account, the plugin SHALL mark the show Watched on Serializd and then remove it from Currently watching, once, and SHALL remember that it did across restarts. The removal SHALL be sent whether or not the plugin added the show to Currently watching. + +#### Scenario: Last episode of an ended show +- **WHEN** a user finishes the final episode of an ended show whose every regular episode Serializd lists is now played +- **THEN** the show is marked Watched on Serializd and removed from Currently watching + +#### Scenario: Caught up on a show still airing +- **WHEN** a user has played every released episode of a show Jellyfin reports as continuing +- **THEN** the show is not marked Watched and stays on Currently watching + +#### Scenario: Library holds fewer episodes than Serializd lists +- **WHEN** an ended show has five seasons on Serializd, the Jellyfin library holds two, and the user has played both in full +- **THEN** the show is not marked Watched + +#### Scenario: Episode count unavailable +- **WHEN** Serializd gives no episode count for one regular season of an ended show +- **THEN** the show is not marked Watched + +#### Scenario: Single-season listing +- **WHEN** Serializd lists an ended show as one season of 24 episodes, Jellyfin has it as two seasons of 12, and the user has played all 24 +- **THEN** the show is marked Watched + +#### Scenario: Specials are ignored +- **WHEN** every regular episode of an ended show is played and its specials are not +- **THEN** the show is marked Watched + +#### Scenario: Finished show the user listed by hand +- **WHEN** a show the plugin never added to Currently watching is found finished +- **THEN** it is marked Watched and a removal from Currently watching is still sent + +#### Scenario: Rewatch after Watched +- **WHEN** a user plays an episode of a show the plugin already marked Watched +- **THEN** the episode is logged and no status request is made + +### Requirement: Shows finished earlier are marked Watched by the scheduled sync +The scheduled Serializd sync SHALL check each show the account has episode history for and that the plugin has not finished marking Watched, and SHALL mark the finished ones Watched and remove them from Currently watching without requiring a new play. It SHALL never add a show to Currently watching from this check. It SHALL decide from Jellyfin data alone which shows cannot be finished, and SHALL make no Serializd request for those; that shortcut SHALL only ever skip a show and SHALL never mark one. + +For this check the sync SHALL make at most 25 Serializd show reads per account per run, taking never-checked shows first and then the least recently checked, SHALL NOT read again within 7 days a show it read and found unfinished, SHALL stop when the run is cancelled, and SHALL start no further show after 5 minutes. + +#### Scenario: Show finished before the feature existed +- **WHEN** the scheduled sync runs for an account whose history holds an ended, fully played show with no status sent +- **THEN** the show is marked Watched on Serializd and a removal from Currently watching is sent + +#### Scenario: Unfinished show costs no request +- **WHEN** the scheduled sync checks a show Jellyfin reports as continuing, or one with an unplayed episode in the library +- **THEN** no Serializd request is made for that show + +#### Scenario: Large backlog is spread out +- **WHEN** an account has 60 shows that pass the Jellyfin-only check +- **THEN** the run reads at most 25 of them from Serializd, and the next run reads 25 others + +#### Scenario: Shows that can never finish do not block the rest +- **WHEN** an account has 30 ended shows whose library copies are fully played but shorter than Serializd's listing, and 10 shows that are finished +- **THEN** within two runs every finished show has been marked Watched, and none of the 30 is read a second time inside 7 days + +#### Scenario: Unfinished history is not listed +- **WHEN** the scheduled sync checks a show with old history that is not finished +- **THEN** it is not added to Currently watching + +#### Scenario: Run is cancelled +- **WHEN** the server shuts down while the check is part way through its list +- **THEN** the check stops without starting another show + +### Requirement: Show status follows the account's sync rules and never affects the episode log +Show status SHALL be sent only for enabled Serializd accounts, and never for a show in a library the account excludes. A status request that fails SHALL NOT fail, delay or undo the episode log, SHALL NOT write a failed row to the activity list, and SHALL be attempted again on a later run. The plugin SHALL record a status as sent only after Serializd accepted the request. + +#### Scenario: Excluded library +- **WHEN** an episode is in a library the account excludes +- **THEN** no status request is made for its show, as no episode log is made + +#### Scenario: Status request fails +- **WHEN** the episode log succeeds and the Currently watching request then fails +- **THEN** the episode stays logged with a success row, the failure is logged, nothing is recorded as sent, and the next logged episode of that show tries again + +#### Scenario: Removal fails after Watched succeeded +- **WHEN** the Watched request succeeds and the removal from Currently watching fails +- **THEN** the show is recorded as Watched with its removal outstanding, and the next scheduled sync retries only the removal, even if no further episode of the show is played + +#### Scenario: Two finishes of one show at the same moment +- **WHEN** two playback-finished events for the first two episodes of a show are handled at the same time +- **THEN** both episodes are logged and exactly one Currently watching request is made + +#### Scenario: Letterboxd is unaffected +- **WHEN** every Serializd status request fails +- **THEN** film syncing to Letterboxd behaves as if none had been made diff --git a/openspec/changes/add-serializd-show-status/tasks.md b/openspec/changes/add-serializd-show-status/tasks.md new file mode 100644 index 00000000..66fad35b --- /dev/null +++ b/openspec/changes/add-serializd-show-status/tasks.md @@ -0,0 +1,35 @@ +## 1. Confirm the Serializd requests (before any production code) + +- [ ] 1.1 With the Serializd test account in a browser, capture the requests the web client sends for "add to Currently watching", "remove from Currently watching" and "mark show Watched" (method, path, body, response). Record the exact shapes in design.md under a new "Confirmed requests" heading +- [ ] 1.2 Replay each request against the test account and record: the response to a repeat of the same request, and the response for a show the account already has that status for +- [ ] 1.3 Compare the test account's diary, episode logs, ratings and activity feed before and after marking a show Watched. Also set a series rating and favourite before and after each status write and confirm neither overwrites the other. Record any side effect in design.md. Stop and raise it if user data changes +- [ ] 1.4 Confirm in the Jellyfin 10.11.9 SDK how a series reports that it has ended (`Series.Status`), and what a series with no status returns + +## 2. Service operations and state + +- [ ] 2.1 Add to `ISerializdService` and `SerializdApiClient`: add to Currently watching, remove from Currently watching, mark show Watched, and list a show's regular seasons with ids and episode counts (reusing the cached show read). Cancellation cancels waits and reads only +- [ ] 2.2 Add `SerializdShowStatusStore`: one state (`Watching`, `WatchedPendingRemoval`, `Watched`) and a last-checked time per user, account and show, keyed without the email, persisted with a temp file and move. Add to `SerializdSyncHistory` a read of the shows an account has `watched` rows for +- [ ] 2.3 Tests in `SerializdApiClientTests`: each new request matches the shape recorded in 1.1, uses snake_case, retries a cold start, and the season list comes from the cached read +- [ ] 2.4 Tests in a new `SerializdShowStatusStoreTests`: states round-trip and survive a reload, are scoped by user and account, the file holds no email, a missing or unreadable file reads as empty; and in `SerializdSyncHistoryTests`, the new read returns only shows with watched rows for that user and account + +## 3. The rule and the updater + +- [ ] 3.1 Add `SerializdShowStatus` (static, no I/O): `IsFinished` (ended flag, played episodes per season, Serializd seasons with counts, single-season mapping), failing closed on missing input, and the early-out `CannotBeFinished` (Jellyfin data only) +- [ ] 3.2 Add `SerializdShowStatusUpdater.UpdateAsync` implementing the decision table in design.md under a keyed lock per user, account and show; a state is written only after the request it records was accepted; failures are logged with `LogRedaction.AccountTag` and swallowed, except cancellation of the caller's token, which is rethrown +- [ ] 3.3 Tests in a new `SerializdShowStatusTests`: every scenario under "Finished shows are marked Watched", plus multi-episode files and a show with no regular season; and a property-style test that every input `CannotBeFinished` skips is one `IsFinished` rejects +- [ ] 3.4 Tests in a new `SerializdShowStatusUpdaterTests`: every row of the decision table, the order of the two writes, the removal sent for a show the plugin never listed, a failed Currently watching request, a failed removal left as `WatchedPendingRemoval`, two concurrent calls for one show making one request, and a cancelled token propagating + +## 4. Entry points + +- [ ] 4.1 Call the updater from `PlaybackHandler.HandleEpisodeAsync` after the episode log and its history rows, inside the existing per-account loop and library-exclusion check +- [ ] 4.2 Call the updater from `SerializdSyncRunner.SyncOneAsync` for each show it logged an episode of in the run +- [ ] 4.3 Add the earlier-history pass to `SerializdSyncRunner`: pending removals first, then candidates through `CannotBeFinished`, ordered never-checked then oldest-checked, at most 25 Serializd reads per account per run, a 7-day wait after an unfinished read, a stop on cancellation and after 5 minutes, and never an add to Currently watching +- [ ] 4.4 Tests in `SerializdPlaybackTests`: first episode adds to Currently watching; second sends nothing; a status failure leaves a success row and no failed row; an excluded library sends nothing; a repeated playback-stopped event sends no second status +- [ ] 4.5 Tests in `SerializdSyncRunnerTests` and `SerializdSyncRunnerCatchUpTests`: a show logged in the run gets its status; an old finished show is marked Watched; a continuing show and a show with an unplayed episode cost no request; the cap holds at 25 and a second run reads 25 different shows; shows that can never finish are not read again inside 7 days and do not keep finished shows from being reached; a pending removal is retried with no read; an unfinished show with old history is not added to Currently watching; the pass stops on cancellation and after 5 minutes; a disabled account sends nothing + +## 5. Verify and document + +- [ ] 5.1 Run the full unit suite and `openspec validate add-serializd-show-status --strict` +- [ ] 5.2 On the throwaway Jellyfin server with the Serializd test account: finish a first episode and see the show on Currently watching; finish an ended show and see it move to Watched; run the scheduled sync and see an earlier finished show move. Record the evidence +- [ ] 5.3 Update the README's TV feature list, and in `CLAUDE.md`: the `SerializdSyncTask` / `SerializdSyncRunner` and `PlaybackHandler` bullets under "Sync entry points" (status after an episode log, the finished rule, the capped and rotated earlier-history pass), and a sentence that a status failure never affects the episode log or the Letterboxd path +- [ ] 5.4 Release plumbing: minor version bump in `Directory.Build.props` and `LetterboxdSync/LetterboxdSync.csproj`, the PR's `## Release notes` paragraph (saying earlier finished shows will move to Watched over the next few runs), and the `site/src/data/release-notes.ts` entry