Skip to content

feat: add pkg/plugin-sdk as the stable plugin API surface#14

Merged
directedbits merged 2 commits into
mainfrom
feat/plugin-sdk
Jul 12, 2026
Merged

feat: add pkg/plugin-sdk as the stable plugin API surface#14
directedbits merged 2 commits into
mainfrom
feat/plugin-sdk

Conversation

@directedbits

Copy link
Copy Markdown
Owner

Summary

First step toward extracting first-party plugins into their own repositories: give plugins a stable, supported API to build against instead of reaching into core internals under src/infra/grpc/....

Today every plugin imports the generated gRPC contract and client scaffolding directly. Once plugins live in separate repos, those src/infra/... paths become a de-facto public API pinned from outside — brittle and unversioned. This PR introduces pkg/plugin-sdk as the curated boundary, migrates the in-repo plugins onto it, and brings ./pkg/... under CI.

Also un-breaks the Lint check: golangci-lint was already red on main due to a pre-existing nil-deref pattern in devicemonitor tests (fixed as its own commit).

  • Are new tests required?
  • Does documentation need to be updated? (see Checklist below for what this covers)
  • Contains breaking changes?
  • Touches plugin contract, manifest format, or recurfile YAML schema?
  • Changes daemon config keys or plugin options?
  • Affects daemon startup/shutdown behavior?
  • Changes CLI flags or command signatures?

Changes

fix(devicemonitor)dbus_test.go guarded parsed events with if event == nil { t.Fatal(...) } then dereferenced them. staticcheck (SA5011) doesn't model t.Fatal as terminating, so it flagged the field access as a possible nil dereference (6 findings, 3 test cases), failing lint on main. Add an explicit return after each t.Fatal.

feat: pkg/plugin-sdk

  • New pkg/plugin-sdk package: a thin re-export of Connect/ConnectOrNil, the Client and RecurClient types, and the ReportTriggerEvent request/response messages — the entire surface plugins consume from core (verified: just clientgrpc.Connect + recurv1.ReportTriggerEventRequest).
  • Migrate all 7 in-repo plugins to import pkg/plugin-sdk instead of src/infra/....
  • Build/test ./pkg/... in CI and lint it in the Taskfile (neither pkg/config nor the SDK was covered before); drop a dead strPtr helper that lint then surfaced.
  • Add an SDK test covering the forwarding funcs and pinning the re-exported message contract.

Test plan

  • go build core + SDK + all 7 plugins (workspace)
  • GOWORK=off go test ./pkg/plugin-sdk/ (consumer path, no workspace)
  • go test ./src/... ./pkg/... and all plugin tests pass
  • golangci-lint run over full CI scope + ./pkg/... → 0 issues

Checklist

  • Small, buildable commits — each compiles and passes tests, one logical change per commit
  • No breaking changes — SDK is additive; plugins still build identically

Breaking changes

None. pkg/plugin-sdk is additive and the plugin runtime contract is unchanged.

directedbits and others added 2 commits July 12, 2026 12:35
dbus_test.go guarded parsed events with 'if event == nil { t.Fatal(...) }'
then dereferenced them. staticcheck (SA5011) does not model t.Fatal as
terminating, so it flagged the subsequent field access as a possible nil
dereference — failing 'golangci-lint run' on main (6 findings across three
test cases). Add an explicit return after each t.Fatal so the non-nil
guarantee is visible to flow analysis.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Plugins previously imported core internals under src/infra/grpc/... directly
(the generated contract and client scaffolding). Introduce pkg/plugin-sdk as
the stable, supported API surface for building trigger plugins: a thin
re-export of Connect/ConnectOrNil, the Client and RecurClient types, and the
ReportTriggerEvent request/response messages. Out-of-tree plugin repos depend
on this path so the contract can evolve behind a curated boundary.

- Migrate all 7 in-repo plugins to import pkg/plugin-sdk instead of src/infra.
- Build, test, and lint ./pkg/... in CI (neither pkg/config nor the SDK was
  covered before); drop a dead strPtr test helper that lint then flagged.

Prepares plugins for extraction into their own repositories.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Binary Size Report

Binary Base PR Delta
recur 20MiB 20MiB -16B
recurd 17MiB 17MiB +24B
calendar 17MiB 17MiB -132B
devicemonitor 16MiB 16MiB -44B
mqtt 17MiB 17MiB +1.9KiB
timer 15MiB 15MiB +204B
webhook 17MiB 17MiB -1.5KiB

@directedbits
directedbits merged commit 678a431 into main Jul 12, 2026
6 checks passed
@directedbits
directedbits deleted the feat/plugin-sdk branch July 12, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant