plugin-sdk

module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0

README

plugin-sdk

The SDK for creating plugins in Omniview, the Integrated DevOps Environment

Plugin author documentation

Start with the plugin author guides, or run the read-only plugin quickstart. Use the resource API reference for signatures and contracts, and the migration guide when moving from resource v1.

Internal Logging

Use log for plugin runtime/internal logging. This is separate from the log capability API in pkg/v1/logs.

See docs/internal-logging.md.

Settings validation

Register settings.Setting.Validator with a func(interface{}) settings.ValidationResult to return contextual validation feedback. Set Valid for accepted values and provide a stable Code plus a user-safe Message. Validators may read provider state, but must not mutate provider values, definitions, or handlers. Bound any external work.

This is a breaking source migration: replace error-returning Validator callbacks with callbacks returning settings.ValidationResult, then rebuild plugins. There is only one callback; no legacy callback adapter is provided.

Setting.Validation and Provider.ValidateSetting check drafts without saving. Writes validate again and reject invalid values; bulk writes validate all values before changing any. Sensitive settings always return generic feedback. Invalid structured results with an empty message receive generic user-safe feedback; nonempty contextual messages remain unchanged. Setting.Validate enforces writes by calling the same Setting.Validation evaluation and returning rejection messages as errors.

Provider.CommitSettings(ctx, values, persist) normalizes and validates each proposed value exactly once, then passes only the normalized changed values to persist. The callback receives scoped setting IDs and detached values. Persistence runs before publication; returning an error leaves all values unchanged and sends no notifications. After persistence succeeds, the provider publishes the prepared values without validating again. A nil callback performs an in-memory commit. Root SetSetting and SetSettings use this same transaction path.

Validators and persistence callbacks may read the previously published provider state. They must not call provider mutation methods or wait for another mutation: transactions serialize value and definition writes. Change notifications run after publication, outside transaction serialization, and may read or mutate the provider, including starting another commit.

Waiting transactions honor context cancellation before validation or persistence. Once persistence succeeds, the provider publishes even if cancellation follows: durable success must not become a rejected commit. Root setters use context.Background(). The v1 client caps commits at 30 seconds while honoring earlier caller deadlines.

settings.CommitResult reports Committed, Applied, and Uncertain. The plugin RPC uses a bidirectional commit stream: the plugin prepares values, the host persists and acknowledges them, and the plugin publishes. If host persistence succeeds but the final RPC response is lost, the client returns durable success with Committed: true, Applied: false, and Uncertain: true; do not retry as though persistence failed. Rebuild both host and plugins for this breaking RPC cutover; the old RPC write endpoints are removed.

Setting.RequiresRestart is definition metadata. Setting.PendingRestart is a host snapshot projection, not provider-owned restart state. settings.CloneValue detaches supported JSON values and typed setting slices; it is not an arbitrary Go object copier. Provider.GetCategoryValues returns detached category values for trusted internal consumers, including sensitive values; do not expose that accessor as an authorized public snapshot.

Draft validation and commits share schema-driven normalization before the custom validator runs. JSON arrays become native []string, []int, or []float64 according to the definition. Booleans accept only booleans. Integers reject fractional and out-of-range numbers; floats reject NaN and infinity. Validators receive canonical values for both drafts and writes.

The settings capability exposes draft validation through gRPC using a dedicated ValidateSettingRequest, executing callbacks inside the plugin rather than on serialized host copies. Rebuild plugins and the host against the updated SDK to use this RPC. Older plugin processes report an unsupported RPC instead of approving unvalidated drafts.

Application state and workspace isolation

The SDK resolves all owned plugin configuration and capability stores through pkg/state.ResolveRoot. The host must pass its resolved absolute root as OMNIVIEW_STATE_DIR, including when the host selected that root programmatically. A non-workspace process without this variable retains the production default ~/.omniview; nightly hosts must explicitly pass their nightly root. The SDK never changes HOME.

When OMNIVIEW_WORKSPACE_FILE is nonempty, it must be an absolute readable v1 workspace manifest with a canonical nonzero workspaceID UUID and profile.kind: development. The SDK reads identity/path-boundary metadata, leaving full manifest validation and mutation to the host. OMNIVIEW_STATE_DIR is mandatory and must agree with the selected profile. Without a machine-local binding, the default remains the exact literal <canonical-shared-profiles>/<workspaceID>/state; UUID-specific profile/state symlink remaps are rejected, while HOME/shared profiles-container aliases are canonicalized.

A host-bound custom root is accepted only when all three v1 machine-local records match: <workspace>/.local/profile.json, <custom-parent>/.omniview-profile.json, and a claim in <HOME>/.omniview-dev/custom-profiles.json. Identity records contain schemaVersion, workspaceID, and canonical absolute stateRoot; the claims registry contains schemaVersion and claims. State must be the literal state child of its dedicated canonical parent. Missing/foreign/malformed or redirected records, duplicate/nested claims, environment disagreement, and overlap with production/nightly/default profiles or workspace/registered source storage fail closed. Absent binding permits only the default, never an unclaimed custom override. The SDK reads these records but never creates claims, binds/rebinds a profile, or initializes state during resolution. The host keeps runtime storage in the default private UUID namespace independently of custom application state.

A moved workspace may retain a durable interrupted sibling-rename journal before the host rewrites its root. The SDK accepts only the exact recorded rename phase and current target, clean absolute sibling old root, matching v1 UUID/development identity, and valid target slug. The old root remains a protected source boundary. Unrelated root mismatches remain errors; the host still performs full manifest validation and owns rename recovery. The native-independent pkg/profilecontract package owns these v1 binding, claim, and ownership-journal schemas and shared read-only identity validation. Both host and SDK consume that contract directly; only the host validates the complete portable manifest and publishes or repairs ownership metadata. Metadata decode failures use fixed diagnostics without including private JSON values.

Plugin IDs and capability filenames must be single nonempty ASCII letter/digit/dot/underscore/hyphen components, not ./.., trailing-dot names, or Windows reserved device names. SDK file operations use os.Root handles and reject symlink aliases in owned plugin/store paths. Returned path strings such as GetPluginStorePath are advisory: external consumers must not replace handle-based SDK operations with unchecked path-based access.

Development plugins use the same go-plugin handshake/lifecycle RPC transport as other plugins. The host owns process supervision, readiness, rebuilds, and shutdown through its managed lifecycle/control client. The SDK does not inspect OMNIVIEW_DEV, intercept stdout, write .devinfo, or clean up old discovery records. The removed standalone runner/discovery APIs have no compatibility shim. Legacy .devinfo* files remain excluded from baseline exports and are not proof of attachment/readiness or permission to start an imported executable.

Pre-launch artifact compatibility

config.PluginMeta.StateIsolation is optional, additive YAML/JSON metadata under state_isolation. Missing metadata means isolation support is unverified. Its v1 fields are schema_version: 1, capability: state-root-v1, sdk_module: github.com/omniviewdev/plugin-sdk, a fully resolved lowercase sdk_revision known-fixed capability-base commit hash, binary_sha256, and optional sdk_source_sha256 identifying the exact selected SDK source snapshot.

A trusted host-owned builder calls config.BuildStateIsolationProvenance(binaryPath, sdkRevision, sdkSourceSHA256) after validating the selected SDK module/path, known-fixed reviewed baseline, and actual build inputs. For live editable SDK worktrees, it computes a stable lowercase SHA-256 source snapshot before/after the build and rejects a changing snapshot. Dirty feature edits are supported without requiring a commit per edit; the reviewed commit establishes the capability base and the source digest identifies the exact editable build. The SDK does not define a second source-tree hashing algorithm: the trusted host builder owns that snapshot contract.

The host stores the attestation and independent expected source digest in its owned artifact/install record, or accepts independently authenticated registry provenance. Before launch, it calls provenance.VerifyArtifact(binaryPath, expectedSDKRevision, expectedSDKSourceSHA256) to check capability, schema, module, trusted capability base, source snapshot, and exact artifact bytes without executing the plugin. A supplied snapshot must be lowercase 64-hex and match the trusted expectation exactly. Empty source digests are permitted only when both expectation and attestation are empty for a trusted immutable clean-commit build; a source-bound record cannot downgrade to commit-only verification. Trusted expectations never come from arbitrary artifact self-assertions. Protect verified artifact bytes from replacement before execution.

These helpers hash and compare attestations; they do not prove source inclusion or authenticate metadata. Arbitrary plugin.yaml claims are not sufficient authorization. No lifecycle RPC, protobuf, or protocol-version change is needed: starting an unknown binary to query isolation support is already unsafe. Existing marketplace executables are not retroactively fixed. Baseline-imported binaries remain inactive until rebuilt with the fixed SDK or verified through an appropriate trusted artifact pipeline.

Application-state isolation is not a process, credential, or remote-resource sandbox. Plugin-authored filesystem operations, user-selected exports, external tool caches, and cluster/account mutations require their own policies.

Plugin settings sensitivity transport

The v1 settings protobuf carries optional bool sensitive with field presence. Current SDK schema conversion explicitly transmits either public (false) or sensitive (true) classification; Password settings are always classified sensitive, even if a sender supplies false. Settings received without this field are legacy/unclassified and decode conservatively as Sensitive: true. Re-encoding such a setting cannot upgrade it to public. Rebuild legacy plugins with the corrected SDK before expecting nonsecret settings to remain visible in secret-safe inspection; absent metadata is not evidence that a value is public.

Conversion preserves setting values/defaults, options, and file-selection metadata for trusted runtime consumers. The inspecting host must use sensitivity classification to redact every value-bearing field, including defaults, options, and file-selection defaults, rather than exposing the raw RPC schema. Malformed value/default/option payloads fail closed as sensitive metadata. This transport fix does not change the provider's runtime accessors or itself authorize access to secret settings.

Resource v2 boundary

Resource v2 is an implementation candidate awaiting public API review, not an approved contract. Providers use handwritten pkg/resource/v2 values and sdk.RegisterResourcePlugin(plugin, provider). Only catalog discovery is required; finite operations, lifecycle, ancillary traits and advisory updates are optional. Catalog declarations qualify each operation independently, including create, mutation update and delete. Advisory OperationUpdate never authorizes writes.

Start with the plugin author guides for a runnable quickstart, resource recipes, connection management, and capability registration. Use the API reference for lookup and the advanced contracts for host integration details. The Go package overview links those concepts to the compiling public examples: catalog-only, get-only, controller lifecycle and custom-provider generation issuance.

Read the code review and specification comparison before freezing or claiming approval. Connection routes and catalog pins are not permission grants; the host owns authority and public error policy. Generated messages and binary framing are transport details, not provider construction APIs.

Providers must rebuild for the resource v2 contract. Existing nonresource utility engines remain; resource-bearing operations use canonical values and strict versioned admission without legacy-method fallback. Resource wire version is 2; the shared go-plugin transport remains 1. Local replacements alone are not a consumable release receipt.

buf.gen.yaml pins protoc-gen-go v1.36.11 and protoc-gen-go-grpc v1.3.0. Use make proto for regeneration; remote Buf generators require no ambient native protoc binary.

Settings value reads

The v1 RPC client's GetSettingValue returns the decoded setting value, not a protobuf Any envelope. It uses the existing JSON-backed settings codec: numbers decode as float64, objects as map[string]any, arrays as []any, and JSON null as nil. Malformed or unsupported wire payloads return decoding errors; RPC status errors propagate unchanged.

Releasing the Go module

The module is github.com/omniviewdev/plugin-sdk at the repository root. Publish a new, previously unused root tag of the form v0.MINOR.PATCH on the reviewed commit after it has merged into main. The module has no source-code release-version constant, nested module, or publishing workflow; a pushed Git tag is the Go module release. A GitHub release can accompany that tag but is not required for Go module resolution. Never move or reuse an existing release tag: Go proxies and the checksum database treat published versions as immutable.

Before tagging, run the SDK tests with GOWORK=off GOFLAGS= go test ./... -count=1 and finish the coordinated host/plugin compatibility checks. After pushing the tag, confirm the version's .info and .mod endpoints at https://proxy.golang.org/github.com/omniviewdev/plugin-sdk/@v/, then resolve it with GOWORK=off GOFLAGS= GOPROXY=https://proxy.golang.org GOSUMDB=sum.golang.org go mod download -json github.com/omniviewdev/plugin-sdk@<release-tag>. Consumers must pin the new version, update go.sum, and pass their own checks without a local SDK replacement before their releases are published.

The workspace-isolation release is v0.6.0: it removes the standalone .devinfo APIs and requires rebuilding plugins against this SDK. It must not reuse the already published v0.5.0, v0.5.1, or v0.5.2 tags. The added exec sequence and optional settings-sensitivity fields preserve their protobuf field numbers and wire compatibility. Their generated Go files are committed alongside the schemas; regenerate them with make proto only when changing those schemas. The module's release tag is independent of sdk.CurrentProtocolVersion, which remains 1; these additive fields and the host-owned isolation metadata do not require a handshake/lifecycle protocol bump.

Directories

Path Synopsis
examples
resource-plugin command
Command resource-plugin serves an immutable embedded notes provider.
Command resource-plugin serves an immutable embedded notes provider.
internal
catalogadmission
Package catalogadmission owns SDK-only catalog observation storage and framing.
Package catalogadmission owns SDK-only catalog observation storage and framing.
resourceconformance
Package resourceconformance is verification-only data and finite oracles.
Package resourceconformance is verification-only data and finite oracles.
testutil
Package testutil contains shared SDK test fixtures, never runtime behavior.
Package testutil contains shared SDK test fixtures, never runtime behavior.
log
Package log provides structured runtime logging with context enrichment, configurable severity thresholds, and pluggable output backends.
Package log provides structured runtime logging with context enrichment, configurable severity thresholds, and pluggable output backends.
logtest
Package logtest provides an in-memory log sink for assertions.
Package logtest provides an in-memory log sink for assertions.
pkg
config
Package config defines plugin manifests, host configuration, and artifact provenance.
Package config defines plugin manifests, host configuration, and artifact provenance.
interceptors
Package interceptors supplies RPC recovery, logging, and diagnostic plugin-context extraction.
Package interceptors supplies RPC recovery, logging, and diagnostic plugin-context extraction.
profilecontract
Package profilecontract owns the v1 read-only machine-local profile protocol.
Package profilecontract owns the v1 read-only machine-local profile protocol.
resource/v2
Package resourcev2 defines the handwritten, provider-neutral resource API.
Package resourcev2 defines the handwritten, provider-neutral resource API.
resource/v2/plugin
Package plugin transports resource v2 providers over bounded, validated gRPC messages.
Package plugin transports resource v2 providers over bounded, validated gRPC messages.
sdk
Package sdk composes plugin capabilities, connection-context transport, and process serving.
Package sdk composes plugin capabilities, connection-context transport, and process serving.
state
Package state resolves SDK-owned application state.
Package state resolves SDK-owned application state.
telemetry
Package telemetry configures process-wide tracing and optional profiling from host environment settings.
Package telemetry configures process-wide tracing and optional profiling from host environment settings.
types
Package types defines shared plugin metadata, connection state, and request context values.
Package types defines shared plugin metadata, connection state, and request context values.
utils
Package utils provides SDK state-store access, RPC middleware composition, and legacy encoding helpers.
Package utils provides SDK state-store access, RPC middleware composition, and legacy encoding helpers.
utils/timeutil
Package timeutil provides shared time abstractions for deterministic testing.
Package timeutil provides shared time abstractions for deterministic testing.
v1/command
Package command dispatches plugin-specific opaque command payloads through optional RPC transport.
Package command dispatches plugin-specific opaque command payloads through optional RPC transport.
v1/exec
Package exec manages plugin terminal sessions, multiplexed input and output, and bounded output history for reconnecting clients.
Package exec manages plugin terminal sessions, multiplexed input and output, and bounded output history for reconnecting clients.
v1/exec/exectest
Package exectest exercises exec managers with pipe-backed terminals and synchronized output recording.
Package exectest exercises exec managers with pipe-backed terminals and synchronized output recording.
v1/lifecycle
Package lifecycle exposes plugin identity, declared capabilities, and process readiness over gRPC.
Package lifecycle exposes plugin identity, declared capabilities, and process readiness over gRPC.
v1/logs
Package logs manages asynchronous log sessions, source discovery, and streaming.
Package logs manages asynchronous log sessions, source discovery, and streaming.
v1/logs/logtest
Package logtest provides programmable log sources, output recorders, and a harness that exercises the real log manager with context-aware test streams.
Package logtest provides programmable log sources, output recorders, and a harness that exercises the real log manager with context-aware test streams.
v1/metric
Package metric provides metric queries and subscription streams.
Package metric provides metric queries and subscription streams.
v1/networker
Package networker manages resource and static port-forward sessions.
Package networker manages resource and static port-forward sessions.
v1/networker/networktest
Package networktest provides forwarding fakes, session harnesses, and state observers for tests that exercise the real networker session manager.
Package networktest provides forwarding fakes, session harnesses, and state observers for tests that exercise the real networker session manager.
v1/settings
Package settings adapts plugin preferences and validation to the v1 gRPC transport.
Package settings adapts plugin preferences and validation to the v1 gRPC transport.
v1/tools
Package tools defines plugin tools, validates their descriptors, and exposes tool discovery and calls over the plugin gRPC transport.
Package tools defines plugin tools, validates their descriptors, and exposes tool discovery and calls over the plugin gRPC transport.
Package settings provides synchronized in-memory preferences and user-safe validation.
Package settings provides synchronized in-memory preferences and user-safe validation.
settingstest
Package settingstest provides test doubles for the settings.Provider interface.
Package settingstest provides test doubles for the settings.Provider interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL