SQLite key-value store wrapper
Find a file
Virgil e1341ff2d5
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
refactor(store): align internal lifecycle naming with AX
Use more descriptive private lifecycle, watcher, and orphan cache field names so the implementation reads more directly for agent consumers while preserving the exported API and behaviour.\n\nCo-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 21:09:20 +00:00
.core chore: add .core/ build and release configs 2026-03-06 18:52:37 +00:00
.forgejo/workflows ci: add Forgejo Actions test and security scan workflows 2026-02-23 03:28:08 +00:00
.github/workflows ci: add Core ecosystem CI workflow with CodeRabbit auto-fix 2026-03-17 14:05:30 +00:00
docs refactor(scope): prefer scoped-store config literals 2026-04-04 19:53:53 +00:00
.editorconfig chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig) 2026-02-23 06:45:49 +00:00
.gitignore chore: add .core/ and .idea/ to .gitignore 2026-03-15 10:17:50 +00:00
.golangci.yml chore(repo): enforce AX review conventions 2026-03-26 11:17:06 +00:00
bench_test.go refactor(store): tighten AX naming and examples 2026-03-30 18:17:07 +00:00
CLAUDE.md docs(ax): prefer declarative store configuration 2026-04-04 11:13:36 +00:00
CODEX.md docs(ax): prefer declarative store configuration 2026-04-04 11:13:36 +00:00
compact.go refactor(store): clarify compaction lifecycle names 2026-04-04 20:29:21 +00:00
compact_test.go fix(compact): normalise whitespace archive formats 2026-04-04 19:41:58 +00:00
CONTRIBUTING.md chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig) 2026-02-23 06:45:49 +00:00
conventions_test.go test(ax): enforce exported field usage examples 2026-04-04 09:48:02 +00:00
coverage_test.go docs(store): tighten AX-facing package docs 2026-04-04 20:24:21 +00:00
doc.go docs(store): clarify declarative constructors 2026-04-04 20:46:40 +00:00
events.go refactor(store): align internal lifecycle naming with AX 2026-04-04 21:09:20 +00:00
events_test.go feat(store): add scoped store config constructor 2026-04-04 16:06:43 +00:00
go.mod feat(store): add zstd archive support 2026-03-30 20:53:12 +00:00
go.sum feat(scope): expose scoped config snapshot 2026-04-04 20:54:45 +00:00
journal.go fix: support scalar Flux journal filters 2026-04-04 17:39:45 +00:00
journal_test.go fix: support scalar Flux journal filters 2026-04-04 17:39:45 +00:00
path_test.go fix(store): normalise default directory paths 2026-04-04 09:01:23 +00:00
README.md docs(ax): prefer declarative config literals in examples 2026-04-04 19:45:52 +00:00
scope.go refactor(store): align internal lifecycle naming with AX 2026-04-04 21:09:20 +00:00
scope_test.go feat(scope): expose scoped config snapshot 2026-04-04 20:54:45 +00:00
store.go refactor(store): align internal lifecycle naming with AX 2026-04-04 21:09:20 +00:00
store_test.go feat: normalise declarative store config defaults 2026-04-04 19:07:18 +00:00
test_helpers_test.go feat(scope): restore scoped quota constructor 2026-04-04 19:38:06 +00:00
transaction.go feat(store): add transaction purge helpers 2026-04-04 18:20:52 +00:00
transaction_test.go refactor(scope): prefer scoped-store config literals 2026-04-04 19:53:53 +00:00
workspace.go refactor(store): align internal lifecycle naming with AX 2026-04-04 21:09:20 +00:00
workspace_test.go fix(workspace): close partial workspaces without filesystem 2026-04-04 19:02:35 +00:00

Go Reference License: EUPL-1.2 Go Version

go-store

Group-namespaced SQLite key-value store with TTL expiry, namespace isolation, quota enforcement, and a reactive event system. Backed by a pure-Go SQLite driver (no CGO), uses WAL mode for concurrent reads, and enforces a single connection to keep pragma settings consistent. Supports scoped stores for multi-tenant use, Watch/Unwatch subscriptions, and OnChange callbacks for downstream event consumers.

Module: dappco.re/go/core/store Licence: EUPL-1.2 Language: Go 1.26

Quick Start

package main

import (
	"fmt"
	"time"

	"dappco.re/go/core/store"
)

func main() {
	// Configure a persistent store with "/tmp/go-store.db", or use ":memory:" for ephemeral data.
	storeInstance, err := store.NewConfigured(store.StoreConfig{
		DatabasePath: "/tmp/go-store.db",
		Journal: store.JournalConfiguration{
			EndpointURL:  "http://127.0.0.1:8086",
			Organisation: "core",
			BucketName:   "events",
		},
		PurgeInterval: 30 * time.Second,
		WorkspaceStateDirectory: "/tmp/core-state",
	})
	if err != nil {
		return
	}
	defer storeInstance.Close()

	if err := storeInstance.Set("config", "colour", "blue"); err != nil {
		return
	}
	if err := storeInstance.SetWithTTL("session", "token", "abc123", 24*time.Hour); err != nil {
		return
	}
	colourValue, err := storeInstance.Get("config", "colour")
	if err != nil {
		return
	}
	fmt.Println(colourValue)

	// Watch "config" mutations and print each event as it arrives.
	events := storeInstance.Watch("config")
	defer storeInstance.Unwatch("config", events)
	go func() {
		for event := range events {
			fmt.Println(event.Type, event.Group, event.Key, event.Value)
		}
	}()

	// Store tenant-42 preferences under the "tenant-42:" prefix.
	scopedStore, err := store.NewScopedConfigured(storeInstance, store.ScopedStoreConfig{
		Namespace: "tenant-42",
		Quota:     store.QuotaConfig{MaxKeys: 100, MaxGroups: 10},
	})
	if err != nil {
		return
	}
	if err := scopedStore.SetIn("preferences", "locale", "en-GB"); err != nil {
		return
	}
}

Documentation

  • Agent Conventions - Codex-facing repo rules and AX notes
  • AX RFC - naming, comment, and path conventions for agent consumers
  • Architecture — storage layer, group/key model, TTL expiry, event system, namespace isolation
  • Development Guide — prerequisites, test patterns, benchmarks, adding methods
  • Project History — completed phases, known limitations, future considerations

Build & Test

go test ./...
go test -race ./...
go test -bench=. ./...
go build ./...

Licence

European Union Public Licence 1.2 — see LICENCE for details.