Skip to content

feat(plugin): add persistent local data and offline backups - #2009

Open
kiroo92 wants to merge 2 commits into
TokenFlux:mainfrom
kiroo92:feat/plugin-persistent-data
Open

kiroo92 wants to merge 2 commits into
TokenFlux:mainfrom
kiroo92:feat/plugin-persistent-data

Conversation

@kiroo92

@kiroo92 kiroo92 commented Nov 14, 2026 •

Copy link
Copy Markdown

Related to #2008.

Plugins currently receive disposable process state but no managed location for a local database or business files. This adds sdk.Env.DataDir, backed by plugins.dir/data/<plugin-id>/. Files survive restart, disable, upgrades, and ordinary uninstall; reinstalling the same ID reuses them. Explicit purge removes local files and KV after draining plugin work, with retryable filesystem cleanup.

plugintest.New(t) also supplies separate writable StateDir and DataDir directories, with testing-owned cleanup. The regression test checks directory isolation, local record reads after disposable cache removal, and cleanup after the owning test finishes. These fixtures support local storage initialization without simulating the real host's uninstall or archive lifecycle.

The admin Local data tab lists retained directories, including uninstalled owners, and provides export, restore, and confirmed purge. Export and restore require a disabled or uninstalled owner and serialize with installation changes. ZIP archives bind the plugin ID, paths, sizes, and SHA-256 hashes; restore validates the complete archive before publishing an absent or empty destination. Path traversal, links, special files, duplicates, corrupt content, and oversized archives are rejected.

SQLite drivers remain plugin dependencies; the host supplies the directory. External databases and S3 remain plugin-configured services with their own backup lifecycle. Documentation covers these boundaries and data-format compatibility on rollback. Ticket workflows, image transport, order queries, and notifications remain outside this PR.

Validation:

  • make fmt and make fmt-check: passed for the SDK follow-up, including Go declaration order, Go formatting, frontend formatting, and Web SDK formatting.
  • cd plugin-sdk/go && go test ./...: all packages passed, including local directory isolation and cleanup and the real-process DataDir protocol round trip.
  • SDK golangci-lint: passed with zero issues.
  • The pre-push checks passed, including go test ./internal/plugin/... ./internal/app in the backend module.
  • Latest fork CI: all eight jobs passed at 10b019de5, including SDK/protocol checks, full Go and frontend tests, Docker integration tests, production build/embed tests, lint, scripts, and installer checks.
  • Latest Security Scan: backend and frontend checks passed at 10b019de5.
  • Full Docker integration execution has not been run locally. Browser appearance has not been manually verified.

AI-assisted implementation.

Provide an SDK data directory retained across ordinary uninstall and package updates. Add administrator inventory, explicit purge, and validated offline ZIP backup and restore with matching documentation and regression coverage.
Provide isolated writable DataDir and StateDir fixtures, verify local data survives cache removal, and document testing cleanup ownership.
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