Skip to content

feat(plugins): apply plugin task bindings and lifecycle changes live - #3611

Merged
Quick104 merged 8 commits into
mainfrom
feat/plugin-task-live-apply
Nov 19, 2026
Merged

Quick104 merged 8 commits into
mainfrom
feat/plugin-task-live-apply

Conversation

@Quick104

@Quick104 Quick104 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A (follows #3551)
Validation tasks: changes #1224 C1; changes #1225 C1

Other clients: N/A (web admin only; the Apple, Android and Roku apps have no plugin administration)

Plugin tasks register only when an API server starts. Turning a plugin task on or off, changing
its binding trigger, and installing, enabling, disabling, updating or removing a plugin all wait
for every API server to restart, and each binding write answers restart_required: true. An
administrator who installs a plugin with a scheduled task doesn't see the task until a restart.

This change applies those changes on every API server within seconds, without a restart.

Approach

  • plugins.TaskRegistry.Sync compares the database with the task manager: it registers new
    tasks, unregisters disabled or removed ones, updates names and default schedules in place, and
    reloads schedules. It never writes a schedule; the "saved schedule, else binding trigger, else
    manifest default, else startup" rule from feat(plugins): run plugin tasks on their manifest default schedule #3551 is unchanged.
  • Each API server attempts a sync before a lifecycle change or binding write it handles returns, on every
    plugins_changed or new plugin_tasks_changed event, and every minute as a backstop (10 seconds
    after a failed sync). Binding writes publish only plugin_tasks_changed, so proxy nodes and
    event dispatchers don't rebuild on them.
  • The task manager can register after Start and unregister. Unregistering retires the worker:
    its triggers stop, a run in progress is canceled, and a firing or manual run that found the
    worker before it was retired is refused. ReloadSchedule installs a task's schedule when it
    differs from the one it runs.
  • Reload compares triggers by the fields each type reads. task_schedules keeps day_of_week
    only on weekly triggers, so before this a daily trigger carrying a weekday looked changed on
    every reload and restarted its timer.
  • The v2 binding PUT answers restart_required: false; it is true only on a server with no task
    manager. Disabling a binding cancels a run in progress. The plugin page's Tasks panel now says
    on/off applies without a restart (catalog change fix(catalog): say plugin task switches apply without a restart silo-translations#101).
  • The task manager checks the schedule and reserves the worker as part of claiming a firing. A
    database claim has a timeout of 5 seconds. Retirement hides the task and cancels a reserved
    execution. The same key can register again once the local execution exits.
  • Live registration loads the schedule before the worker can accept runs. A replacement schedule
    installed during an execution starts its timers when that execution finishes. Task observers
    also get an update when only a task's name or description changes.
  • Task reconciliation skips installations without scheduled capabilities. Scheduled runs resolve
    the plugin against current installation state so a peer can run a task it just learned about.

Validation

  • Touched Go packages (internal/plugins, internal/taskmanager/..., internal/apiv2 plugin and task routes, internal/api/handlers plugin and task routes), with the race detector on the registry and task manager: pass.
  • make lint-changed, the OpenAPI, contract, web types, route inventory, migration ledger and local-path checks: pass.
  • Web: prettier and the plugin helper and plugin admin component tests: pass.
  • Rebased onto main after feat(plugins): run plugin tasks on their manifest default schedule #3551 and fix(plugins): run each plugin task firing on one API server #3612 merged. The trigger loop conflict was resolved so the claim step gets the fired trigger and runs after the preflight.
  • Shared dev, before the rebase, on a build that combines this branch with the single-run change and the other plugin
    notification changes, using a QA plugin with two 1-minute default tasks: both appeared on the
    Tasks page right after install, with no restart, and ran every minute. Changing one to every 2
    minutes on the task page applied at once. The plugin page's switch stopped and restarted a task
    live, and its binding kept an empty trigger. Upgrading the plugin to a 3-minute default moved
    the task still on the default and left the other on its 2-minute admin schedule.
  • Review fixes: focused task and plugin suites passed with the race detector. The new startup and
    retirement regressions fail on f87ac9f6f and pass with the fixes. The OpenAPI, web types,
    fixtures, route inventory, and contract comparison checks pass. Four web test files passed
    (38 tests). The event delivery model also passed.
  • Isolated sandbox: main faa406d92 showed no tasks after upload. On 3463f2f0a, two API servers
    registered both tasks after upload, applied the binding off and on, and kept the saved 2-minute
    schedule while upgrading the other task's default to 3 minutes. Both binding writes returned
    restart_required: false.

Evidence

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

The captures show the plugin's Tasks panel and the Scheduled Tasks page before and after the
change. The API results show the same installation on two servers through a binding change and
an upgrade.

Risks

  • Task registration changes at runtime on every API server; a bug here could leave a task
    unscheduled until the next one-minute sync.
  • A task installed or enabled at runtime whose schedule is "at startup" runs once a few seconds
    after it registers, as at a server start. With the single-run pull request, that run happens
    on one server.
  • Core tasks still pick up a schedule edited on another server only after a restart; plugin tasks
    pick it up within a minute.
  • Re-check Plugin management / marketplace — Server #1224 C1 and Plugin management / marketplace — Web admin #1225 C1 after merge. Install and update now attempt a task sync,
    and the web admin can show scheduled plugin tasks as soon as the upload completes.
  • The web catalog is pinned to published release 2026.11.19-6d986e8.
  • A startup firing is skipped within 10 minutes of any claim for the task. Each API server
    reads the schedule for each registered plugin task once per minute.
  • A server still using the previous default can accept its revision-zero schedule ETag after a
    binding write on another server. That first save becomes an explicit override. The registry's
    separate installation, capability and binding reads can also briefly combine different commits.
    Both cases need a database boundary if the admin writes must take effect together.

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, run from T3 Code

  • Tool(s): Claude Code (implementation); Codex CLI (independent review of the earlier combined revision in feat(plugins): run plugin tasks on their manifest default schedule #3551)

  • Model(s): claude-opus-5-5 (implementation); gpt-6.1-sol (review)

  • Involvement: Fully AI-generated, human verified

  • Adversarial review: Codex (gpt-6.2-sol) reviewed db0091f after the rebase and found six issues. The two trigger-loop races, the startup rearm and the stale schedule-PUT summary are fixed; three narrower windows are listed under Risks. Earlier, Codex (gpt-6.1-sol) reviewed the multi-server sync, restart durability and
    run cancellation when this code was part of feat(plugins): run plugin tasks on their manifest default schedule #3551; a retired worker that could still run a
    firing it had taken and tasks registering on the wrong schedule were fixed then. A later
    four-agent Claude review found the day_of_week reload mismatch, fixed here.

  • Review fixes and sandbox verification: Codex in T3 Code (gpt-6.2-sol), with an independent review by Claude Code (claude-opus-5-5) in T3 Code.

🤖 Generated with Claude Code

Note

Apply plugin task bindings and lifecycle changes live via task registry sync

  • Replaces one-time plugin task registration at startup with a live TaskRegistry that periodically reconciles plugin tasks against installations, capabilities, and bindings. It registers new tasks, updates defaults and presentation, reloads changed schedules, and unregisters tasks whose bindings are disabled or installations are removed. See task_registry.go and main.go.
  • Adds live task lifecycle support to the task manager: RegisterLive, Unregister, and ReloadSchedule on a started manager. Workers track trigger generations and retirement so firings from replaced schedules are discarded and retired workers stop claiming new runs while in-flight executions still record results. See manager.go.
  • Task-binding writes now trigger an immediate local sync plus a cross-server sync event, and the API's restart_required response reports the value returned by the service instead of always returning true. Only servers without a task scheduler report restart required.
  • CancelTask now returns a TaskInfo snapshot alongside the error, and the cancel handler uses it instead of a separate lookup.
  • Behavioral Change: retired workers return ErrTaskNotFound from getWorker, UpdateTriggers, and UpdateSchedule; a firing claim that exceeds 5 seconds is canceled and the firing is skipped. Constructors NewTaskRegistry and NewTaskRegistryWithTypedResolver now require a taskScheduler argument.

Macroscope summarized f3467cf.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Nov 6, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-19T21:11:19.840185Z f3467cf New commits
🔒 Security Review ✅ Completed 2026-11-19T21:13:34.715975Z f3467cf 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 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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

Plugin task synchronization now applies installation and binding changes while API servers run. The task manager supports live registration, schedule reloads, and worker retirement. Task-binding responses report whether a restart is required.

Changes: Live Plugin Task Synchronization

Layer / File(s) Summary
Dynamic task worker lifecycle
internal/taskmanager/manager.go, internal/taskmanager/worker.go, internal/taskmanager/triggers/startup.go, internal/taskmanager/*_test.go
The task manager can register, replace, unregister, and reload tasks after startup. Retired workers stop triggers and cancel active runs. Startup triggers can be restarted if stopped before firing. Tests cover live registration, schedule reloads, unregistering, and trigger behavior.
Registry reconciliation and sync wiring
internal/plugins/task_registry.go, internal/plugins/task_registry_test.go, cmd/silo/main.go, internal/cache/redis.go, docs/architecture/plugin-scheduled-tasks.md, docs/admin-tasks-api.md, .silo-translations
The registry reconciles eligible plugin tasks and schedules with installations and bindings. Startup, local changes, cache events, and periodic runs trigger syncs; failed syncs are retried. Tests cover binding changes, saved schedules, read failures, and retry timing.
Task-binding API and response behavior
internal/api/handlers/plugins.go, internal/api/router.go, internal/apiv2/admin_plugin_configuration.go, contracts/api/v2/openapi.json, internal/apiv2/admin_tasks.go, docs/admin-api.md, web/src/api/v2/schema.ts
Task-binding writes invoke the configured synchronization callback. The API returns whether a restart is required. API descriptions document live application, cross-server sync, and conditional restart behavior.
Localized interface strings
web/src/locales/*
Locale files add Next Up settings, collection and detail labels, manual-add status messages, and recommendation-card similarity text. Task-setting descriptions now describe applying changes without restart and possible propagation delay across servers.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AdminClient
  participant PluginHandler
  participant BindingStore
  participant TaskRegistry
  participant TaskManager
  participant ChannelAdmin
  participant ReplicaTaskRegistry
  participant ReplicaTaskManager
  AdminClient->>PluginHandler: submit task-binding change
  PluginHandler->>BindingStore: store binding
  PluginHandler->>TaskRegistry: invoke sync callback
  TaskRegistry->>TaskManager: apply task and schedule changes
  PluginHandler->>ChannelAdmin: publish plugin_tasks_changed
  ChannelAdmin->>ReplicaTaskRegistry: deliver plugin_tasks_changed
  ReplicaTaskRegistry->>ReplicaTaskManager: apply task and schedule changes
Loading
Merge Risk: Moderate · previous review 8681d

Live plugin task sync is mostly sound, but startup-scheduled tasks can silently miss their one run under some timings. A stale firing can also run after an administrator changes the schedule. Fix these in the task manager before merging, and re-pin the translations to a published release.

Architecture risk: Low · up to 8681d

The change affects 5 systems.

Changed systems: web, internal, docs, cmd, contracts

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — web (service) was modified; 43 changed files map to changed impact.
  • observed — internal (service) was modified; 14 changed files map to changed impact.
  • observed — docs (service) was modified; 3 changed files map to changed impact.
  • observed — cmd (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in internal/api/handlers/plugins.go: PluginHandler gains a callback field for synchronizing task bindings, documented as nil when no task manager is wired; in that case the binding takes effect at the next restart.
  • observed — Modified behavior in internal/api/handlers/plugins.go: Adds a nil-safe callback registration method and applyTaskBinding. The helper marks plugin_task_binding as restart-required and returns true when no callback is configured; otherwise it invokes the callback and returns false.
  • observed — Modified behavior in internal/api/handlers/plugins.go: SetAdminPluginTaskBinding now documents applying bindings through every API server’s task manager or reporting a restart requirement. Its return changes from error to (restartRequired bool, err error). Missing stores, target-validation failures, and upsert failures return false with the error; successful upserts return the result of applyTaskBinding and nil error instead of unconditionally marking a restart required.
  • observed — Modified behavior in internal/cache/redis.go: Added EventPluginTasksChanged for plugin task-binding updates, documented as published on ChannelAdmin so API replicas re-sync scheduled tasks.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(plugins): apply plugin task bindings and lifecycle changes live" matches the main change. The changeset adds a live TaskRegistry sync, task manager register/unregister/reload support, …
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 description is detailed and directly related to the changeset. It explains that plugin task bindings, lifecycle changes, and schedule reloads now apply live on every API server without a restart. …
Full details: Title check

Explanation

The title "feat(plugins): apply plugin task bindings and lifecycle changes live" matches the main change. The changeset adds a live TaskRegistry sync, task manager register/unregister/reload support, and binding writes that return restart_required: false when a task manager is present. The title is specific and concise, and it uses the conventional commit form.

Full details: Description check

Explanation

The description is detailed and directly related to the changeset. It explains that plugin task bindings, lifecycle changes, and schedule reloads now apply live on every API server without a restart. It names the affected components (TaskRegistry.Sync, the task manager, the v2 binding PUT, and the plugin page Tasks panel), and it describes validation and risks. This matches the changes in the raw summary, such as the TaskRegistry, the task manager, the restart_required flag, and the locale text updates.

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 enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Nov 6, 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: 5

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: 3e807b59-a7b1-4e3c-a450-3aac7be34857
Commits

Reviewing files that changed from the base of the PR and between 8e19480 and f759db7.

Files selected for processing: 18

  • cmd/silo/main.go
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • docs/admin-tasks-api.md
  • docs/architecture/plugin-scheduled-tasks.md
  • internal/api/handlers/plugins.go
  • internal/api/router.go
  • internal/apiv2/admin_plugin_configuration.go
  • internal/apiv2/admin_plugin_configuration_test.go
  • internal/cache/redis.go
  • internal/plugins/task_registry.go
  • internal/plugins/task_registry_test.go
  • internal/taskmanager/manager.go
  • internal/taskmanager/manager_test.go
  • internal/taskmanager/worker.go
  • internal/taskmanager/worker_test.go
  • web/src/api/v2/schema.ts
  • web/src/components/admin/plugins/PluginDetailSections.tsx

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 contracts/api/v2/openapi.json Resolved
Comment thread contracts/api/v2/openapi.json Resolved
Comment thread docs/admin-api.md Resolved
Comment thread docs/admin-tasks-api.md 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: 101e626a1f

ℹ️ 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/taskmanager/manager.go Outdated
Comment on lines +194 to +195
if !w.runsSchedule(configs) {
w.setTriggers(configs, m.triggerFactory, nil, true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear the change flag when reloading an unscheduled task

When a plugin task has an explicitly empty schedule on this replica and another server saves a nonempty schedule, this reload calls setTriggers with notify=true. The waiting triggerLoop consumes triggerUpdate in its zero-trigger branch without clearing triggerChanged; consequently, the first real firing only clears that flag and skips execution. The production triggers are one-shot until rearmed, so the task then remains unscheduled indefinitely, and subsequent registry syncs cannot recover it because runsSchedule already reports a match. Clear the change flag when consuming the update in the zero-trigger branch so remotely re-enabled schedules actually run.

Useful? React with 👍 / 👎.

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.

Fixed in 54d188c, with a synctest regression test (TestReloadScheduleRunsTaskThatHadNoTriggers) that fails without the fix. While testing I found the reverse case: two quick updates made the loop treat the second update signal as a firing and run the task unscheduled. 3b38461 replaces the change flag with a trigger generation count. An update now only wakes the loop, and a firing runs the task only if it came from the triggers the loop is waiting on.

@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: 3fdf944f-9b47-45e6-a2df-78ae3ade2d78
Commits

Reviewing files that changed from the base of the PR and between f759db7 and 101e626.

Files selected for processing: 7

  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • docs/admin-tasks-api.md
  • docs/architecture/plugin-scheduled-tasks.md
  • internal/apiv2/admin_plugin_configuration.go
  • web/src/api/v2/schema.ts
  • web/src/components/admin/plugins/PluginDetailSections.tsx
Files skipped from review as they are similar to previous changes: 1

  • web/src/components/admin/plugins/PluginDetailSections.tsx

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

@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Nov 6, 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: 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: 3a1f3fa3-91a0-491b-8833-e59f3d9fd260
Commits

Reviewing files that changed from the base of the PR and between 101e626 and f2c7731.

Files selected for processing: 7

  • docs/architecture/plugin-scheduled-tasks.md
  • internal/plugins/task_registry.go
  • internal/plugins/task_registry_test.go
  • internal/taskmanager/manager.go
  • internal/taskmanager/manager_test.go
  • internal/taskmanager/worker.go
  • internal/taskmanager/worker_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.

Comment thread internal/plugins/task_registry.go Resolved
@Quick104
Quick104 force-pushed the feat/plugin-task-default-schedule branch from cebebb3 to 68e9e30 Compare November 18, 2026 16:38
@Quick104
Quick104 force-pushed the feat/plugin-task-live-apply branch from 40c0624 to 2ece1fe Compare November 18, 2026 16:38
@Quick104 Quick104 closed this Nov 18, 2026
@Quick104
Quick104 force-pushed the feat/plugin-task-live-apply branch from 2ece1fe to 7269acb Compare November 18, 2026 16:49
@Quick104 Quick104 reopened this Nov 18, 2026
@Quick104
Quick104 force-pushed the feat/plugin-task-live-apply branch from 22efdd2 to 89edbb1 Compare November 18, 2026 17:15
Base automatically changed from feat/plugin-task-default-schedule to main November 18, 2026 19:27
@Quick104
Quick104 force-pushed the feat/plugin-task-live-apply branch from 89edbb1 to db0091f Compare November 19, 2026 16:04
@silo-kody

silo-kody Bot commented Nov 19, 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 ❌

Comment thread internal/plugins/task_registry.go Outdated
Comment on lines +131 to +132
if err := r.scheduler.ReloadSchedule(ctx, spec.key); err != nil {
errs = append(errs, fmt.Errorf("reload plugin task %s schedule: %w", spec.key, err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Performance medium

Periodic task reconciliation issues one schedule query per plugin task

Each periodic sync makes a database read per registered plugin task on every API server, even when nothing changes. Load schedules in a batch and reconcile ReloadSchedule calls from that snapshot.

Prompt for LLM
File internal/plugins/task_registry.go, lines 131-132:

Periodic task reconciliation issues one schedule query per plugin task

Every periodic sync calls `ReloadSchedule` once per registered plugin task, and each call queries the schedule repository, producing N database reads per API server per minute even when nothing changes. Load plugin schedules in a batch and reconcile them from that snapshot.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Comment thread internal/taskmanager/manager.go Outdated
continue
}
if !m.claimFiring(ctx, w, fired) {
if !m.claimFiring(ctx, w, firedTrigger) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

A schedule change during preflight can leave an old firing eligible to run

Revalidate the trigger generation after preflight and coordinate validation, claiming, and run reservation with schedule replacement.

Kody rule violation: Distinguish schedule changes from actual task firings

Prompt for LLM
File internal/taskmanager/manager.go, line 317:

A schedule change during preflight can leave an old firing eligible to run

The generation check occurs before the potentially blocking scheduled-task preflight. If the schedule changes during that preflight, this call can claim and run a firing from the old schedule. Revalidate the trigger generation after preflight and coordinate validation, claiming, and run reservation with schedule replacement so a superseded trigger cannot be claimed or executed.

Kody rule violation: [Distinguish schedule changes from actual task firings](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/0868609e-1ebf-419e-a377-6f5c104799f6?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Comment thread internal/taskmanager/manager.go Outdated
Comment on lines +283 to +287
case <-w.triggerUpdate:
// Wait on the new triggers. An update never runs the task.
close(done)
continue
case firedTrigger = <-fired:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Schedule update notifications can discard a new trigger's only firing

A pending triggerUpdate can discard a firing already consumed from the new trigger, preventing one-shot startup and interval triggers from running or rearming. Synchronize notifications with trigger generations or process firings from the current generation.

Prompt for LLM
File internal/taskmanager/manager.go, lines 283-287:

Schedule update notifications can discard a new trigger's only firing

A pending `triggerUpdate` can win the select after a goroutine has already consumed a firing from the newly installed trigger, discarding that firing; one-shot startup and interval triggers then never run or rearm. Synchronize update notification with trigger generation or preserve and process a firing when it belongs to the current generation.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@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.

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

Review of db0091f, which is this branch rebased onto main (#3551 and #3612 have merged since it was opened). The review covered the diff, its callers, the task manager's trigger loop after the merge with #3612's firing claims, and an independent pass by Codex (gpt-6.2-sol). Five findings are inline. Three more sit outside the diff:

  1. The plugin page still says a task switch needs a restart. Medium severity. web.admin.plugins.settings.tasksDescription reads "Tasks are registered when the server starts, so turning one on or off takes effect after a restart." After this PR, an admin who reads it restarts for nothing or doubts the switch worked. The catalog change is Silo-Server/silo-translations#101. I'm fixing this in a commit on this branch, so there's no need to change it yourself.

  2. A startup trigger that is stopped before it fires never fires. Medium severity. StartupTrigger.Start sets fired when it arms the timer, and Stop cancels that timer. The rearm after a run (Stop, then Start) therefore leaves a startup trigger installed during the run with no timer and no next firing. Trigger: a binding or sync switches a task to the startup schedule while a run is going, and the run ends within five seconds. Main had the same gap for a task-page edit during a run. This PR adds live binding changes and syncs as new ways to reach it. The repair is to mark the trigger fired only when its timer delivers. I'm fixing this in a commit on this branch, so there's no need to change it yourself.

  3. The schedule PUT summary still says other processes reload on restart. Low severity. That is now wrong for plugin tasks (internal/apiv2/admin_tasks.go, updateAdminTaskSchedule). I'm fixing this in a commit on this branch, so there's no need to change it yourself.

Left for the maintainers, not changed here:

  • The retired-worker check before claiming (inline) covers a worker retired before its claim. A worker retired while its claim waits on Postgres can still commit the claim and skip the run. Closing that window means a winner can abandon a slot to a peer, which is a change to #3612's claim design.
  • A startup firing is skipped within 10 minutes of any claim of the task, including claims from an interval trigger. Switching a task to the startup schedule right after a run therefore runs nothing on any server. The architecture doc now says so. Changing it would mean scoping startup claims to the schedule's activation.
  • RegisterLive puts the worker in the task map before reading its schedule. A manual run that arrives during that read can start, and then the failed read removes the task until the 10-second retry. Rare, low impact.
  • Each API server reads every plugin task's schedule once a minute. The server that makes a change also syncs twice, once inline and once on its own event's echo. Both costs are small at today's plugin counts.

Comment thread internal/taskmanager/manager.go Resolved
Comment thread internal/taskmanager/manager.go Resolved
Comment thread internal/taskmanager/worker.go Resolved
Comment thread docs/admin-tasks-api.md Resolved
…aced

- The trigger loop ignores an update signal whose generation it has already
  read, so a signal left from an edit during a run no longer discards the new
  trigger's firing.
- A worker retired after its trigger fired returns before claiming the
  firing, so other servers don't skip a firing that runs nowhere.
- A startup trigger stopped before it fires arms again on the next Start, so
  the rearm after a run keeps a startup schedule installed during that run.
- Unregistering a task publishes task.updated, so task lists drop it.
- API and architecture text now says how plugin task edits reach other
  servers and that disabling a binding cancels a run in progress.

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

silo-kody Bot commented Nov 19, 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 ❌

Comment thread internal/taskmanager/manager.go Outdated
Comment on lines +300 to +305
if w.isRetired() {
// Unregistered since the firing: claiming it would make every
// other server skip a firing this one won't run.
return
}
if !m.claimFiring(ctx, w, firedTrigger) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Retirement can still race with the firing claim

A worker can retire between isRetired and claimFiring, causing reserve to reject the run while the persisted claim makes other servers skip it. Coordinate retirement with claiming and reservation so an unexecuted firing cannot be claimed.

Prompt for LLM
File internal/taskmanager/manager.go, lines 300-305:

Retirement can still race with the firing claim

A worker can be retired after `isRetired` returns but while `claimFiring` is committing, so `reserve` rejects the run while the persisted claim makes other servers skip that firing. Coordinate retirement with claiming and run reservation so an unexecuted firing cannot be claimed.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

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.

Fixed in 3463f2f. The firing claim and local reservation share the worker gate with retirement. A retirement after reservation cancels the run, which records a result. TestRetirementRecordsRunForClaimAlreadyInFlight fails on f87ac9f and passes with this fix.

AI-assisted review by Codex in T3 Code (gpt-6.2-sol).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the update. Sharing the worker gate between claiming, reservation, and retirement addresses the reported race. The regression test provides coverage for a claim already in flight when retirement occurs.

I haven’t independently verified the fix or run the test.

Generated from silo-translations main at 8b0ffaa (#101). Re-pin to the
published release before merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. and removed size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. labels Nov 19, 2026
@silo-kody

silo-kody Bot commented Nov 19, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@Quick104

Quick104 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

AI-assisted review by Codex in T3 Code (gpt-6.2-sol), with an independent Claude Code review (claude-opus-5-5).

Fit 8/10 · Readiness 5/10 · Not ready to merge (assuming CI is green)

Reviewed f87ac9f6f and pushed fixes through 44f5f0333. Plugin task changes belong in live admin. The work still adds a schedule read per registered plugin task on each server's periodic sync.

  • The scheduler now checks the active schedule before claiming a firing and reserves the worker before retirement can cancel it. A startup schedule installed during a run arms when that run finishes.
  • A task is visible after its schedule loads. Cancellation returns the worker's own snapshot, and a task rename refreshes open task views. Scheduled runs refresh installation state before resolving the plugin client.
  • The translation pin points to published release 2026.11.19-6d986e8. The contract check passes after removing the consumed approval from fix(playback): measure watch time on every stop and name the history end position #4552.

Remaining decision. A server with the previous default can accept a revision-zero schedule ETag after the binding changes on another server. That save can permanently override the new default. The registry can also combine installation and binding data from different commits. I recommend checking the authoritative default as part of the first schedule write, and reading the task definitions from a single snapshot.

Verification. On the baseline, a successful upload left both tasks absent. On the sandbox runtime build 3463f2f0a, both API servers added both tasks after upload, applied the binding off and on, and preserved the 2 minute saved schedule while applying the new 3 minute default to the other task. The final commit only removes contract approval metadata. The startup and retirement regression tests fail on the reviewed head and pass with the fixes. Go race, focused API, web, lint, contract and event delivery model checks passed locally. The previous hosted Go failure also reproduces on main and is tracked in #4583. Hosted checks have restarted on the new head.

Validated features. #1224 C1 and #1225 C1 need a recheck after this ships. Direct Project 5 access was unavailable, so I checked the recorded case results through the validation issues. The plugin guide should cover live Tasks switches, cancellation and schedule precedence. Native clients and Jellyfin have no equivalent admin path.

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

Comment thread .silo-translations Outdated
Comment on lines +2 to +3
version=local-8b0ffaa32b55
sha256=-

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Local translation pin breaks the standard reinstall command

scripts/sync-translations exits without a separate translations checkout, preventing contributors from reproducing the installation. Pin a published release and its checksum.

Prompt for LLM
File .silo-translations, lines 2-3:

Local translation pin breaks the standard reinstall command

The documented `scripts/sync-translations` reinstall now exits immediately because the script rejects a pinned `local-*` version without a separate translations checkout. Pin a published release and its checksum so contributors can reproduce the installed translations with the standard command.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@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: 8681d97be6

ℹ️ 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 .silo-translations Outdated
Comment on lines +2 to +3
version=local-8b0ffaa32b55
sha256=-

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pin the translations to a published release before merging

The translation pin now names a local catalog build and has no archive checksum. This leaves the change short of the repository's explicit merge requirement, and a subsequent normal translation sync rejects this pin (scripts/sync-translations:67) instead of reproducing the checked-in output. Publish or merge the catalog changes, then re-sync with --version <release> and commit the resulting metadata and generated files before merging.

AGENTS.md reference: AGENTS.md:L222-L225

Useful? React with 👍 / 👎.

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.

Confirmed that the local pin blocks a clean reinstall. Published release 2026.11.19-6d986e8 includes the plugin task wording from Silo-Server/silo-translations#101. I’m pinning that release as part of the merge from main, which now conflicts in the generated catalog.

AI-assisted review by Codex in T3 Code (gpt-6.2-sol).

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.

Fixed in f87ac9f. The branch now pins published catalog release 2026.11.19-6d986e8 and its archive checksum.

AI-assisted review by Codex in T3 Code (gpt-6.2-sol).

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Major · Preserve a startup firing that the worker has not received yet. · startup.go:40-46

internal/taskmanager/triggers/startup.go:40-46
Major · Functional Correctness · Quick win

Preserve a startup firing that the worker has not received yet.

If an administrator switches a task to startup during a scheduled run and the run lasts more than five more seconds, the new timer can queue its signal while the worker is still executing. When that run ends, the manager calls Stop and Start. Start drains the queued signal, then returns because fired is already true. The startup run never happens.

Do not drain a committed startup signal when rearming the same trigger. Keep the existing behavior for a timer stopped before firing, and ensure an already consumed signal does not cause a second run.

Minor · Retry a startup firing when claim storage fails. · firing.go:137

internal/taskmanager/firing.go:137
Minor · Stability & Availability · Heavy lift

Retry a startup firing when claim storage fails.

If the claim write fails when a newly enabled startup task fires, claimFiring returns the same result as when a peer wins. The loop rearms, but the startup trigger has already fired and will not arm again. Periodic sync leaves the unchanged schedule in place. On a single API server, the task can therefore miss its only startup run after a brief database outage.

Distinguish a claim error from a peer win. Retry the same firing with bounded backoff while its worker and schedule are current. Do not retry a definitive peer win.

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: b77ef27a-2771-41c1-9a56-7906ece0f91a
Commits

Reviewing files that changed from the base of the PR and between 22efdd2 and 8681d97.

Files selected for processing: 59

  • .silo-translations
  • cmd/silo/main.go
  • contracts/api/v2/openapi.json
  • docs/admin-api.md
  • docs/admin-tasks-api.md
  • docs/architecture/plugin-scheduled-tasks.md
  • internal/api/router.go
  • internal/apiv2/admin_plugin_configuration.go
  • internal/apiv2/admin_tasks.go
  • internal/taskmanager/firing.go
  • internal/taskmanager/firing_test.go
  • internal/taskmanager/manager.go
  • internal/taskmanager/manager_test.go
  • internal/taskmanager/triggers/startup.go
  • internal/taskmanager/triggers/startup_test.go
  • internal/taskmanager/worker.go
  • web/src/api/v2/schema.ts
  • web/src/locales/ar-XB.json
  • web/src/locales/ar.json
  • web/src/locales/bg.json
  • web/src/locales/ca.json
  • web/src/locales/cs.json
  • web/src/locales/da.json
  • web/src/locales/de.json
  • web/src/locales/el.json
  • web/src/locales/en-XA.json
  • web/src/locales/en.json
  • web/src/locales/es.json
  • web/src/locales/et.json
  • web/src/locales/fi.json
  • web/src/locales/fr.json
  • web/src/locales/he.json
  • web/src/locales/hi.json
  • web/src/locales/hr.json
  • web/src/locales/hu.json
  • web/src/locales/id.json
  • web/src/locales/it.json
  • web/src/locales/ja.json
  • web/src/locales/keys.ts
  • web/src/locales/ko.json
  • web/src/locales/lt.json
  • web/src/locales/lv.json
  • web/src/locales/ms.json
  • web/src/locales/nb.json
  • web/src/locales/nl.json
  • web/src/locales/pl.json
  • web/src/locales/pt-BR.json
  • web/src/locales/pt-PT.json
  • web/src/locales/ro.json
  • web/src/locales/ru.json
  • web/src/locales/sk.json
  • web/src/locales/sl.json
  • web/src/locales/sv.json
  • web/src/locales/th.json
  • web/src/locales/tr.json
  • web/src/locales/uk.json
  • web/src/locales/vi.json
  • web/src/locales/zh-Hans.json
  • web/src/locales/zh-Hant.json
Files skipped from review as they are similar to previous changes: 2

  • docs/admin-tasks-api.md
  • docs/architecture/plugin-scheduled-tasks.md

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/taskmanager/manager_test.go Resolved
Comment thread internal/taskmanager/manager.go Resolved
Comment thread internal/taskmanager/manager.go Resolved
Comment thread web/src/locales/ca.json Resolved
@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 Nov 19, 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.

Reviewed f87ac9f6f after merging main and pinning published translations. The sandbox reproduced the baseline: installing a plugin on main succeeds and its tasks are absent until restart. I also checked the independent Claude review and reproduced the startup and stale installation failures in focused tests.

I’m fixing the in-flight claim and schedule replacement races from the existing threads. I’ll also make schedule writes reject retired workers and have cancellation return the snapshot of the worker that accepted it. A second lookup can already point to a different worker or yield a response with empty enum values.

Maintainer decision. A node that has yet to sync a binding change can still accept the old schedule ETag at revision zero. That write becomes an explicit override. Fully closing this requires the database to validate the binding or manifest default in the same transaction that creates the first saved schedule. I recommend that guard before merge.

AI-assisted review by Codex in T3 Code (gpt-6.2-sol), with a read-only Claude Opus 5.5 review.

Comment thread cmd/silo/main.go Resolved
Comment thread internal/plugins/task_registry.go Resolved
Comment thread internal/plugins/task_registry.go Resolved
@silo-kody

silo-kody Bot commented Nov 19, 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 35b0ed7 into main Nov 19, 2026
8 checks passed
@Quick104
Quick104 deleted the feat/plugin-task-live-apply branch November 19, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 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