Repository navigation
Conversation
Silo delivers a Jellyfin-compat client's Stopped report as a confirmed stop under a 5-second deadline and spends part of it before calling the plugin. The plugin kept a fixed 5-second margin, so its time box was negative and it deferred the stop as TEMPORARY without sending a request, on every retry, until Silo dropped the stop at session expiry. Keep syncDeadlineMargin when at least 20 seconds remain, otherwise keep a quarter of the remaining time. Longer deadlines are unchanged, and a call whose deadline has passed still starts nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| limit := defaultRequestTimeout | ||
| if deadline, ok := ctx.Deadline(); ok { | ||
| limit = min(limit, max(time.Until(deadline)-syncDeadlineMargin, 0)) | ||
| limit = min(limit, max(untilMargin(deadline), 0)) |
There was a problem hiding this comment.
Short deadlines leave less than the required response reserve
For deadlines under 20 seconds, untilMargin reserves only a quarter of the remaining time, allowing ApplyEvents requests to exceed the required five-second reserve. Use syncDeadlineMargin to calculate the cutoff.
Also found in:
provider/provider_test.go:483-483provider/provider.go:143-143provider/provider_test.go:487-487provider/ratings_test.go:907-907
Kody rule violation: Reserve response time before the ApplyEvents host deadline
Prompt for LLM
File provider/provider.go, line 133:
Short deadlines leave less than the required response reserve
Use the fixed five-second margin when calculating the ApplyEvents request cutoff. For deadlines less than 20 seconds away, untilMargin reserves only a quarter of the remaining time, allowing upstream requests to run past the required host-deadline-minus-five-seconds cutoff.
**Also found in:**
- `provider/provider_test.go:483-483`
- `provider/provider.go:143-143`
- `provider/provider_test.go:487-487`
- `provider/ratings_test.go:907-907`
Kody rule violation: [Reserve response time before the ApplyEvents host deadline](https://kodus.siloserver.org/settings/code-review/1324553393/kody-rules/1ab2c6d6-2601-4df9-bf6f-9e7e6ef0110d?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)
Suggested code:
limit = min(limit, max(time.Until(deadline)-syncDeadlineMargin, 0))
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
|
Closing this. The change goes against the reserve rule Kody flagged, and the right fix is in the host. Kody is right that the plugin must keep its fixed 5-second reserve before the host deadline. My proportional margin only worked around the real cause: Silo delivers a confirmed stop under a 5-second timeout ( I filed the host-side bug with the analysis, the raw logs and a reference fix on a branch: Silo-Server/silo-server#3506. I am closing this pull request and #11 with it; no plugin change is needed. Thanks for the review. |
Problem
When a Jellyfin-compat client sends a clean Stopped report, Silo delivers the stop as a confirmed stop with a 5-second deadline. It spends part of that deadline before calling the plugin. The plugin always kept a fixed 5-second margin before the deadline, so its time box came out negative. It deferred the stop as TEMPORARY ("Floppy sync time limit reached; the event will be retried") without sending any request. Every retry carries the same deadline, so the stop never reaches Floppy. Silo retries about every 15 seconds until the play session expires (24 hours by default), then drops the stop. A completed play still reaches Floppy later through history-export reconciliation, but the progress of an incomplete stop is lost.
Observed on a real deployment with plugin v0.3.1: one clean stop retried about 3,000 times over 13 hours. Floppy logged nothing for the session. A stop for the same episode that ended by expiry, which Silo sends without a deadline, was delivered normally.
Related issue: #11
Fix
syncTimeBoxandsyncRequestLimitnow shareuntilMargin. It keepssyncDeadlineMargin(5 s) when at least 20 s remain, and otherwise keeps a quarter of the remaining time. A 4.5-second deadline now leaves about 3.4 s for the request and about 1.1 s to return the result.listRatingsuses the same helpers, so a short-deadline rating page now reads titles instead of returning nothing.Risk
Tests
TestApplyEventsSendsAStopUnderAShortHostDeadline: an end-to-end call toApplyEventsagainst anhttptestFloppy, with 4.5 s and 2 s deadlines. It asserts that the stop is APPLIED and Floppy receives exactly one incomplete stop.TestApplyEventsDefersEventsPastTheTimeBox: "call deadline already too close" (3 s, no events) became "short call deadline" (4 s, three events start) plus a new "call deadline already passed" case, which keeps the guarantee that nothing starts after the deadline.TestSyncRequestLimitEndsBeforeTheHostDeadline: the 1 s case expected 0. It is now a 4 s case expecting just under 3 s, plus an already-passed case expecting 0.TestSyncTimeBox: adds a 4 s case.TestListRatingsKeepsResolvedTitlesWhenTheDeadlineCutsARead: uses a 2 s deadline, so the cut read still ends 0.5 s before the deadline and the test stays fast.Before the fix (new and updated tests against the old
provider.go):After the fix:
Validation
Go 1.26.5 (linux/amd64), the version in
go.mod:go test -count=10 ./provideralso passed.go test -race ./...also passed. The fixed plugin has not yet been run against a live Silo.AI Disclosure
Note
Fix scrobble stop delivery under short host deadlines in
providerStops were dropped when the host deadline was shorter than the fixed five-second margin, leaving no time to send anything. Adds
provider.untilMargin, which subtracts the smaller of the fixed margin and one quarter of the remaining time, and uses it inprovider.syncTimeBoxandprovider.syncRequestLimit.TestApplyEventsSendsAStopUnderAShortHostDeadlinein provider_test.go, covering 4.5-second and two-second deadlines with one incomplete stop request each.Macroscope summarized 067550e.