Documentation
¶
Overview ¶
Package sisyphus is a small, app-agnostic toolkit for the plumbing every CLI or service ends up rewriting: config reconciliation, DuckDB-backed stores, secret escrow, encrypted backups, and daemon primitives.
The root package carries the two application-facing facades:
- ConfigStore reconciles named config documents between files on disk and a versioned DuckDB store (see Open, Plan, Apply, Effective).
- Backup and Restore produce and consume encrypted tar archives whose AES key is escrowed in a secret manager (see BackupSpec, RestoreSpec).
Everything application-specific — home directory, file names, namespaces, key names — is passed in by the caller; nothing is baked in. Each sub-package (config, configdb, kv, journal, secret, sealed, backup, daemon, mode, lifecycle, redact, duckfile, ...) is usable on its own.
Index ¶
- func Backup(ctx context.Context, spec BackupSpec) (sealed []byte, storeName string, err error)
- func Restore(ctx context.Context, spec RestoreSpec) (names []string, storeName string, err error)
- type Action
- type Backend
- type BackupSpec
- type ConfigStore
- func (m *ConfigStore) Apply(ctx context.Context, rec Reconciliation, act Action) (content []byte, format config.Format, err error)
- func (m *ConfigStore) Backend() Backend
- func (m *ConfigStore) Close() error
- func (m *ConfigStore) Current(ctx context.Context, name string) (Snapshot, bool, error)
- func (m *ConfigStore) Effective(ctx context.Context, it Item) (content []byte, format config.Format, err error)
- func (m *ConfigStore) Forget(ctx context.Context, name string) error
- func (m *ConfigStore) Generation() (string, bool)
- func (m *ConfigStore) History(ctx context.Context, name string, limit int) ([]Snapshot, error)
- func (m *ConfigStore) Home() string
- func (m *ConfigStore) Import(ctx context.Context, name string, content []byte, format config.Format) error
- func (m *ConfigStore) Plan(ctx context.Context, items ...Item) ([]Reconciliation, error)
- type Item
- type Options
- type Reconciliation
- type RestoreSpec
- type SecretRef
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶
Backup archives spec.Files into a tar, encrypts it with AES-256-GCM, and returns the sealed bytes plus the name of the secret store that holds the key. The key is created and escrowed on first use (under spec.Secret.Name, "backup-key" when empty) and never travels with the archive. Backup is independent of ConfigStore, so it works without opening the config DB.
func Restore ¶
Restore decrypts spec.Sealed with the escrowed key and swaps the archived files into spec.DestDir, returning the restored basenames plus the name of the secret store that supplied the key. A missing key is an error — restore never generates one. Like Backup it is independent of ConfigStore, so a corrupt config DB does not block restoring it.
Types ¶
type Action ¶
type Action int
Action is the caller's decision for one drifted document, passed to Apply.
type Backend ¶ added in v0.2.0
type Backend int
Backend selects where a ConfigStore keeps config documents.
type BackupSpec ¶
BackupSpec describes one encrypted backup: which Files to archive and which Secret entry escrows the encryption key.
type ConfigStore ¶ added in v0.2.0
type ConfigStore struct {
// contains filtered or unexported fields
}
ConfigStore is the facade over an application's config home: named config documents on disk, versioned snapshots in a DuckDB store, or both, reconciled through Plan/Apply/Effective.
A ConfigStore opened with BackendFiles carries no database: reads report absent with a nil error, Import and Forget return configdb.ErrUnavailable, and Close returns nil (as it does on a nil *ConfigStore).
func Open ¶
Open returns a ConfigStore rooted at home. Unless opts.Backend is BackendFiles it opens (creating if needed) the config database inside home, named by opts.ConfigDBName ("config.duckdb" when empty).
func (*ConfigStore) Apply ¶ added in v0.2.0
func (m *ConfigStore) Apply(ctx context.Context, rec Reconciliation, act Action) (content []byte, format config.Format, err error)
Apply resolves one planned Reconciliation with the caller's decision and returns the effective content and format.
func (*ConfigStore) Backend ¶ added in v0.2.0
func (m *ConfigStore) Backend() Backend
Backend reports which backend this store was opened with.
func (*ConfigStore) Close ¶ added in v0.2.0
func (m *ConfigStore) Close() error
Close releases the underlying config database. It is safe on a nil *ConfigStore and on one opened with BackendFiles; both return nil.
func (*ConfigStore) Current ¶ added in v0.2.0
Current returns the stored current snapshot of the named document. Without a database (BackendFiles) it reports absent with a nil error.
func (*ConfigStore) Effective ¶ added in v0.2.0
func (m *ConfigStore) Effective(ctx context.Context, it Item) (content []byte, format config.Format, err error)
Effective resolves the content for an item that needs no reconciliation: BackendFiles uses the file, BackendDB uses the stored snapshot, and BackendBoth uses the file when present, falling back to the stored snapshot.
func (*ConfigStore) Forget ¶ added in v0.2.0
func (m *ConfigStore) Forget(ctx context.Context, name string) error
Forget drops a document's current snapshot and history from the store.
func (*ConfigStore) Generation ¶ added in v0.2.0
func (m *ConfigStore) Generation() (string, bool)
Generation reports the store's change marker: an opaque value that changes with every committed write, so pollers can detect change without opening the database.
func (*ConfigStore) History ¶ added in v0.2.0
History returns up to limit archived snapshots of the named document, newest first (limit <= 0 means 50). Without a database (BackendFiles) it returns nil with a nil error.
func (*ConfigStore) Home ¶ added in v0.2.0
func (m *ConfigStore) Home() string
Home returns the home directory the store was opened at.
func (*ConfigStore) Import ¶ added in v0.2.0
func (m *ConfigStore) Import(ctx context.Context, name string, content []byte, format config.Format) error
Import stores content as the named document's new current snapshot, archiving the previous one into its history. Without a database (BackendFiles) it returns configdb.ErrUnavailable.
func (*ConfigStore) Plan ¶ added in v0.2.0
func (m *ConfigStore) Plan(ctx context.Context, items ...Item) ([]Reconciliation, error)
Plan returns one Reconciliation per item that has drifted: the file differs from the DB snapshot, or the item exists on only one side. Items in sync (or absent on both sides) are omitted. In BackendFiles and BackendDB it returns nil: there is nothing to reconcile, and Effective resolves content per the backend.
type Item ¶ added in v0.2.0
type Item struct {
Name string
FileContent []byte // empty = no file on disk
FileFormat config.Format
}
Item is one named config document to reconcile against the DB.
type Options ¶
type Options struct {
// Backend selects files, DB, or both (the zero value, BackendBoth).
Backend Backend
// ConfigDBName is the config database filename inside home. Empty means
// "config.duckdb".
ConfigDBName string
}
Options configures Open.
type Reconciliation ¶
Reconciliation is one drifted document reported by Plan: the file-side content next to the stored DB snapshot (zero when only one side exists), awaiting a caller decision via Apply.
func (Reconciliation) HasDB ¶
func (r Reconciliation) HasDB() bool
HasDB reports whether a stored snapshot exists for this item. A zero DB Snapshot expresses absence; stored snapshots always carry a non-empty hash.
func (Reconciliation) HasFile ¶ added in v0.2.0
func (r Reconciliation) HasFile() bool
HasFile reports whether a file version exists for this item.
type RestoreSpec ¶
RestoreSpec describes one restore: the Sealed archive bytes, the Secret entry holding its key, and the DestDir the files are written into.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth implements the credential-acquisition flows an application wires its own OAuth endpoints into: an authorization-code loopback server (LoopbackAuthCode), the device-authorization grant (DeviceToken), and a small helper for shelling out to auth CLIs (RunTool).
|
Package auth implements the credential-acquisition flows an application wires its own OAuth endpoints into: an authorization-code loopback server (LoopbackAuthCode), the device-authorization grant (DeviceToken), and a small helper for shelling out to auth CLIs (RunTool). |
|
Package backup snapshots a set of files into a tar archive and restores such archives atomically.
|
Package backup snapshots a set of files into a tar archive and restores such archives atomically. |
|
Package config resolves an application's home directory, reads its config file, and parses YAML or JSON into the caller's own struct with environment-variable overrides layered on top.
|
Package config resolves an application's home directory, reads its config file, and parses YAML or JSON into the caller's own struct with environment-variable overrides layered on top. |
|
Package configdb is a versioned, name-keyed config-document store in a single DuckDB file: one current snapshot per name (store_current) plus its archived predecessors (store_history).
|
Package configdb is a versioned, name-keyed config-document store in a single DuckDB file: one current snapshot per name (store_current) plus its archived predecessors (store_history). |
|
Package daemon holds what is genuinely daemon-flavored: SignalContext for shutdown-signal handling and Attached, the capability-aware probe for a running service.
|
Package daemon holds what is genuinely daemon-flavored: SignalContext for shutdown-signal handling and Attached, the capability-aware probe for a running service. |
|
service
Package service wraps kardianos/service to install, start, stop and run a program as an OS service (systemd, launchd, Windows SCM, ...), system-wide or per-user.
|
Package service wraps kardianos/service to install, start, stop and run a program as an OS service (systemd, launchd, Windows SCM, ...), system-wide or per-user. |
|
Package desktop sends OS desktop notifications.
|
Package desktop sends OS desktop notifications. |
|
Package duckfile owns plugin-scoped DuckDB files: each plugin opens its own database with its own schema and queries it through string tables.
|
Package duckfile owns plugin-scoped DuckDB files: each plugin opens its own database with its own schema and queries it through string tables. |
|
Package duckopt carries the DuckDB handle tuning shared by every sisyphus store package (kv, configdb, journal, duckfile).
|
Package duckopt carries the DuckDB handle tuning shared by every sisyphus store package (kv, configdb, journal, duckfile). |
|
internal
|
|
|
crypt
Package crypt is the AES-256-GCM sealing shared by the backup archive format and the sealed store.
|
Package crypt is the AES-256-GCM sealing shared by the backup archive format and the sealed store. |
|
duckdb
Package duckdb is the shared DuckDB plumbing under every sisyphus store: opening files owner-only (database and WAL alike), the Handle that coordinates single-writer access across processes via sidecar lock files, and small SQL helpers (NULL adapters, QueryTable).
|
Package duckdb is the shared DuckDB plumbing under every sisyphus store: opening files owner-only (database and WAL alike), the Handle that coordinates single-writer access across processes via sidecar lock files, and small SQL helpers (NULL adapters, QueryTable). |
|
fsutil
Package fsutil holds the generic filesystem helpers behind the config package.
|
Package fsutil holds the generic filesystem helpers behind the config package. |
|
Package ipc carries events between local processes over unix sockets (named pipes on Windows): Listen/Dial establish the transport, Broadcast fans a stream.Subject out to every connected peer, and IsListening probes for a live listener.
|
Package ipc carries events between local processes over unix sockets (named pipes on Windows): Listen/Dial establish the transport, Broadcast fans a stream.Subject out to every connected peer, and IsListening probes for a live listener. |
|
Package journal is a generic activity log in a single DuckDB file: runs (optionally nested one level, parent/child) and per-run records, each carrying a free-form string attribute map.
|
Package journal is a generic activity log in a single DuckDB file: runs (optionally nested one level, parent/child) and per-run records, each carrying a free-form string attribute map. |
|
Package kv is a generic namespaced key/value store in a single DuckDB file, with an optional expiry per entry.
|
Package kv is a generic namespaced key/value store in a single DuckDB file, with an optional expiry per entry. |
|
Package lifecycle holds home-directory install, clean and nuke primitives, plus a small shell-hook runner (Scripts / Select / Run*) for the bash or PowerShell snippets an application lets its users attach to those moments.
|
Package lifecycle holds home-directory install, clean and nuke primitives, plus a small shell-hook runner (Scripts / Select / Run*) for the bash or PowerShell snippets an application lets its users attach to those moments. |
|
Package mode names an application's operating surfaces (CLI, serve, daemon, deck, or app-defined) and runs the application's own authorization policy at the right moment through Gate.
|
Package mode names an application's operating surfaces (CLI, serve, daemon, deck, or app-defined) and runs the application's own authorization policy at the right moment through Gate. |
|
Package redact masks secret-looking values in config content before it is displayed or logged.
|
Package redact masks secret-looking values in config content before it is displayed or logged. |
|
Package schedule drives periodic jobs: Run polls each Job's Next for its Due time on a fixed tick and executes it with per-job failure backoff; RunAt runs a single function at an absolute time.
|
Package schedule drives periodic jobs: Run polls each Job's Next for its Due time on a fixed tick and executes it with per-job failure backoff; RunAt runs a single function at an absolute time. |
|
Package sealed is an encrypted credential store: Entry values are AES-256-GCM sealed and kept in a kv.Store, with the encryption key escrowed in the OS keyring (or supplied by the caller).
|
Package sealed is an encrypted credential store: Entry values are AES-256-GCM sealed and kept in a kv.Store, with the encryption key escrowed in the OS keyring (or supplied by the caller). |
|
Package secret escrows small string secrets (typically encryption keys) in an external secret manager: the Bitwarden CLI (bw), the 1Password CLI (op), or the OS keyring.
|
Package secret escrows small string secrets (typically encryption keys) in an external secret manager: the Bitwarden CLI (bw), the 1Password CLI (op), or the OS keyring. |
|
Package storeerr holds the sentinel error shared by every sisyphus store package.
|
Package storeerr holds the sentinel error shared by every sisyphus store package. |
|
Package stream provides event pipelines with resumable position state: polling sources (Poll, PollAdaptive, Source), fan-in and pub/sub plumbing (FanIn, Subject), duplicate suppression across restarts (Deduper), and the small KV-backed persistence primitives that make resumption work (Cursor, Watermark, ScopedKV over the KV interface).
|
Package stream provides event pipelines with resumable position state: polling sources (Poll, PollAdaptive, Source), fan-in and pub/sub plumbing (FanIn, Subject), duplicate suppression across restarts (Deduper), and the small KV-backed persistence primitives that make resumption work (Cursor, Watermark, ScopedKV over the KV interface). |
|
Package tabular holds the string-table result type shared by the sisyphus query surfaces (journal.Query, duckfile.Query), plus typed accessors for reading cells back out of it.
|
Package tabular holds the string-table result type shared by the sisyphus query surfaces (journal.Query, duckfile.Query), plus typed accessors for reading cells back out of it. |
|
Package tray models the coarse run-state a long-running process surfaces to the user — State and its icon Assets — and, in non-nodaemon builds, shows it as a system tray icon (Tray).
|
Package tray models the coarse run-state a long-running process surfaces to the user — State and its icon Assets — and, in non-nodaemon builds, shows it as a system tray icon (Tray). |