feat(plugins): plugin drift detector + queue + admin apply endpoint (#123) #204
No reviewers
Labels
No Label
release-blocker
security
tier:high
tier:low
tier:medium
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: molecule-ai/molecule-core#204
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/plugin-drift-queue-123"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds the version-subscription drift detection and operator-apply workflow for per-workspace plugin tracking (core#113).
Components
Migration (
20260510000000_plugin_drift_queue):installed_shacolumn toworkspace_plugins— records the commit SHA installed so the drift sweeper can compare against upstream.plugin_update_queuetable with status:pending | applied | dismissed.(workspace_id, plugin_name).GithubResolver (
github.go):LastFetchSHAfield +LastSHA()getter — populated byFetchafter a successful shallow clone (captured before.gitis stripped). Used by the install pipeline to seedinstalled_sha.ResolveRef(ctx, spec)method — resolves a plugin spec to its full commit SHA usinggit fetch --depth=1 + git rev-parse. Used by the drift sweeper to get the current upstream SHA for a tracked ref.Drift sweeper (
plugins/drift_sweeper.go):tracked_ref != none AND installed_sha IS NOT NULL, resolves upstream SHA, queues drift if different.ListPendingUpdates()— reads pending queue rows for the admin endpoint.ApplyDriftUpdate()— marks entry applied (idempotent).ctx.Err()guard on ticker arm to avoid post-shutdown work.Install pipeline:
stageResult.InstalledSHAfield carries SHA from Fetch to the DB.recordWorkspacePluginInstallnow accepts and storesinstalled_sha.deleteWorkspacePluginRow— removes tracking row on uninstall so a stale SHA doesnt prevent the next install from creating a fresh row.Admin endpoints (
handlers/admin_plugin_drift.go):GET /admin/plugin-updates-pending— list all pending drift entries.POST /admin/plugin-updates/:id/apply— re-installs plugin from source_raw, records new SHA, marks entry applied, triggers workspace restart. Idempotent.Router wiring (
router.go,cmd/server/main.go):PluginsHandler.Sources()export for the sweeper wiring pattern.Test plan
go test -race ./workspace-server/internal/plugins/...go test -race ./workspace-server/internal/handlers/...go build ./workspace-server/...🤖 Generated with Claude Code
[core-lead-agent] LGTM. Closes #123 (plugin drift detector + queue + admin apply). 13 files, ~800 lines new code with 374 lines of tests (drift_sweeper_test.go + admin_plugin_drift_test.go). Migration adds installed_sha column + plugin_update_queue table with partial unique index. tier:medium → core-lead (managers) approval suffices.
[core-lead-agent] Re-approving.
[core-lead-agent] Re-approving.
[core-lead-agent] Re-approving.
core-lead referenced this pull request2026-05-10 01:17:28 +00:00