Introducing a new way to review your PRs.

Read the announcement

jdx / fnox

encrypted/remote secret manager

View on GitHub

27 documents · Updated Nov 23, 2026

docs / plugin-provider-extensions

Plugin provider extensions

Lua plugin providers let fnox connect its common secret interface to a custom backend without adding that backend to the built-in provider set. A plugin supplies Lua hooks for reading, storing, or encrypting values, while fnox manages provider selection, plugin loading, capability checks, and errors.

This page extends Secret provider integrations with the custom-provider path. See Cloud and vault providers and Local and hardware providers for the built-in provider families that plugins can complement.

Plugin provider model

The Lua provider is a provider adapter whose behavior comes from a plugin entry file. A plugin is a provider.lua file that returns a table of hooks. The required get hook reads one reference; optional hooks add batch reads, remote storage, encryption, and connection checks.

The provider receives a context table for each hook. It contains the configured provider name, the plugin directory, and resolved string options. This keeps backend-specific settings and local plugin resources separate from fnox's shared provider contract.

HookRoleProvider effect
getRead one secret referenceRequired for every plugin
get_batchRead unique references in one callSpeeds up multi-secret reads when supported
putStore a value and return its referenceMakes the provider a remote store
encryptReturn protected textMakes the provider an encryption provider
testCheck backend accessSupports provider connection tests

The provider uses a clear capability rule. encrypt takes priority over put; if neither exists, the provider is read-only. This rule tells fnox whether set should write ciphertext, save to the backend, or reject the store operation rather than placing the secret in project configuration.

References: crates/…/mod.rs• L1-18 crates/…/mod.rs• L409-501 docs/…/lua.md• L91-111

Plugin discovery and registration

Plugin discovery starts with the plugin value in a Lua provider definition. fnox treats a value that looks like a file or directory path as a local plugin. Any other value is an installed plugin name. Local paths resolve from the configuration file that defines the provider, so the same provider works when invoked from a child directory.

Installed plugin names are resolved through the shared [plugins] declarations. A declaration supplies the source that fnox can use for first-use installation. The provider registry passes the declaration into the Lua provider, which then checks or installs the named plugin before it loads the entry file.

This diagram shows how provider configuration becomes a loaded plugin source.

flowchart TD
    A[Lua provider configuration] --> B{plugin value is a path?}
    B -->|Yes| C[Resolve path from defining config file]
    B -->|No| D[Use installed plugin name]
    D --> E{Plugin exists in shared plugin store?}
    E -->|No| F[Install from matching plugins declaration]
    E -->|Yes| G[Check installed source against declaration]
    F --> H[Find provider.lua]
    G --> H
    C --> H
    H --> I[Load Lua provider runtime]

The installed store is shared by projects on the machine. fnox records the source used for an installed plugin and refuses to use it when the current project declares a different source or ref. A linked plugin is the deliberate local override and takes precedence over the declaration.

References: crates/…/mod.rs• L38-77 crates/…/mod.rs• L140-171 crates/…/mod.rs• L497-511 crates/…/plugins.rs• L283-309 crates/…/plugins.rs• L508-544

Host API boundary

The host API is the controlled bridge between Lua code and fnox services. fnox registers the host modules before it runs the plugin, while the plugin can load its own Lua modules from the plugin directory and its lib directory.

ModulePurpose
fnoxReport an authentication failure and read the fnox version
fnox.httpSend HTTP requests and receive status, headers, and body data
fnox.jsonEncode and decode JSON values
fnox.cmdRun a command and either inspect or require a successful result
fnox.logWrite messages to fnox's log at standard log levels
fnox.base64Encode and decode base64 data

The boundary also gives plugins a standard error path. fnox.auth_error marks a backend login problem as an authentication failure, so fnox can present the provider's authentication help. Other Lua errors become provider or plugin errors with the hook name and message.

References: crates/…/host.rs• L1-8 crates/…/host.rs• L17-39 crates/…/host.rs• L77-147 crates/…/host.rs• L266-302 crates/…/host.rs• L397-430 crates/…/mod.rs• L267-284 docs/…/lua.md• L135-148

Loading and execution boundaries

fnox loads a plugin into a Lua runtime only when the provider needs it. The entry file must return a hook table with a function-valued get hook. fnox validates optional hook types during load, creates the shared context, and keeps the runtime with the hook table for later calls.

Each provider operation crosses a defined boundary:

  • Secret reads call get, or use get_batch when the plugin provides it.
  • Writes use encrypt first, then put, and fail for a read-only plugin.
  • Connection tests call test when it exists and otherwise succeed after load.
  • A missing value is represented by nil and becomes fnox's provider-not-found result.

This diagram shows the execution path from a fnox operation to a plugin result.

sequenceDiagram
    participant F as fnox provider flow
    participant L as Lua runtime
    participant P as plugin hook
    participant B as backend or CLI
    F->>L: Load provider.lua and create ctx
    L->>P: Validate and retain hook table
    F->>P: Call get, get_batch, put, encrypt, or test
    P->>B: Use fnox host API or plugin code
    B-->>P: Backend result
    P-->>F: Value, reference, ciphertext, or error

The runtime boundary protects fnox's provider flow from malformed plugin output. fnox rejects a missing get hook, invalid hook values, and return values of the wrong type. A load failure also prevents a write from silently falling back to plaintext configuration.

References: crates/…/mod.rs• L174-265 crates/…/mod.rs• L295-383 crates/…/mod.rs• L386-406 crates/…/mod.rs• L409-501 test/lua_plugin.bats• L276-291

Plugin lifecycle commands

The fnox plugin command manages the machine-wide plugin store and the local development override. It can use a Git source with an optional tag, branch, or commit ref. A two-part owner/repo source is shorthand for a GitHub repository.

CommandLifecycle role
fnox plugin installInstall all declared plugins that are missing, or install one name from a declared or explicit source
fnox plugin linkPoint a plugin name at a local directory that contains provider.lua
fnox plugin lsShow installed and linked plugins, their source or target, and declared-but-missing plugins
fnox plugin updateMove installed Git plugins to their declared source and ref, or to the current remote default when no declaration exists
fnox plugin uninstallRemove an installed or linked plugin from the shared store

The lifecycle keeps incomplete changes out of the active store. Installation prepares a checkout before moving it into place, and failed replacement or update work restores the prior usable plugin. Updates skip linked plugins because a linked checkout is an active development source rather than a managed Git install.

This diagram shows the normal lifecycle from declaration to removal.

flowchart LR
    A[[plugins] declaration] --> B[install]
    B --> C[shared installed plugin]
    C --> D[ls and provider use]
    D --> E[update to declared source or ref]
    D --> F[link local checkout]
    F --> G[provider uses linked checkout]
    C --> H[uninstall]
    G --> H

Plugin commands can run without a project configuration. In that case, commands that need a declaration use an explicit source, while listing and removal still operate on the shared store.

References: src/…/plugin.rs• L7-29 src/…/plugin.rs• L31-78 src/…/plugin.rs• L93-111 src/…/plugin.rs• L113-239 crates/…/plugins.rs• L312-370 crates/…/plugins.rs• L373-427 crates/…/plugins.rs• L435-505

Trust and source boundaries

Plugins run with the user's permissions and can use network access or local commands through the host API. The plugin source is therefore part of the provider's trust boundary, not only a package download detail.

Project declarations should pin a trusted tag or commit when repeatable behavior matters. The source check prevents one project from using a plugin installed from a different source, while linking remains an explicit local development choice.

References: docs/…/lua.md• L57-89 crates/…/plugins.rs• L508-544 test/lua_plugin.bats• L245-274

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the plugin path-versus-name rule aligned with provider source resolution. A change can make a local file resolve as a shared plugin name or the reverse.
  • Keep [plugins] source tracking aligned with install, first-use loading, and update behavior. A mismatch must not run a different plugin with project options.
  • Keep hook capability precedence aligned across capability reporting and put execution. encrypt must remain stronger than put.
  • Keep host module names and error mapping aligned with the Lua contract. In particular, preserve the distinction between authentication errors and ordinary hook failures.
  • Keep linked plugins outside update replacement. Developers must be able to edit a linked checkout without an update resetting it.
  • Keep plugin validation before activation. A missing provider.lua, malformed hook table, or failed load must not permit a write to fall back to plaintext.

Important failure modes

TriggerConsequenceGuard
A plugin name has no installed copy and no [plugins] sourceProvider use fails before Lua code runsInstall it explicitly or declare its Git source
The installed source or ref differs from the project's declarationfnox refuses to load the pluginRun fnox plugin update <name>
provider.lua is missing or returns no valid get hookPlugin loading failsKeep provider.lua at the plugin root and return the required hook table
A read-only plugin receives setfnox rejects the write instead of storing through the backendAdd put or encrypt, or pass a reference intended for project storage
The plugin raises a normal Lua errorThe provider operation fails with the hook errorReturn valid values and handle backend errors in the plugin
The plugin raises fnox.auth_errorfnox reports an authentication failure and may offer auth_commandRe-authenticate with the backend or configure the provider login command
fnox plugin update targets a linked pluginThe update is skippedEdit the linked checkout or unlink it before using managed updates
A plugin source is unavailable or Git cannot access itInstall or update fails and the current install remains in placeCheck the source, ref, Git access, and network path

Key files

FileWhy to read it
crates/…/mod.rsDefines the Lua provider contract, runtime loading, hook calls, capability mapping, and provider errors.
crates/…/host.rsDefines the host modules available to plugin code and the authentication error boundary.
crates/…/plugins.rsDefines plugin sources, shared installation, linking, source checks, updates, and removal.
src/…/plugin.rsMaps the CLI lifecycle commands to plugin management actions.
crates/…/mod.rsConnects Lua provider configuration to path resolution, declarations, and provider creation.
docs/…/lua.mdGives the plugin author contract, configuration model, and host API examples.
test/lua_plugin.batsShows end-to-end guarantees for discovery, first-use installation, updates, links, errors, and safe failed writes.