SQLite key-value store wrapper
Find a file
Snider 4aeddacb3f
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4
Round 4 follow-up to fc77445.

Code:
- import.go: benchmark directory/subdirectory creation now checked
  with contextual errors (was silently failing on EnsureDir)
- import.go: terse loop variables expanded in reviewed loops
- scope.go: nil Namespace() guarded
- scope.go: scoped readiness uses 'store.ScopedStore.*' operation
  names across wrappers (matching test updated)

Tests:
- publish_test.go: HOME fallback test clears DIR_HOME (was flaky
  due to env leakage)
- store_test.go: purge event wait now uses bounded select with
  timeout (was hanging on missing event)
- store_test.go: Exists/GroupExists tests no longer swallow fixture
  setup errors

Verification: gofmt clean, golangci-lint v2 0 issues, GOWORK=off
go vet + go test -count=1 ./... pass with explicit cache paths.

Closes residual r4 findings on https://github.com/dAppCore/go-store/pull/4

Co-authored-by: Codex <noreply@openai.com>
2026-04-27 18:55:55 +01: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 fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
docs fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
tests/cli/store fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01: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 fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
bench_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
CLAUDE.md Align module path docs 2026-04-15 11:22:20 +01:00
CODEX.md docs(ax): prefer declarative store configuration 2026-04-04 11:13:36 +00:00
compact.go fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
compact_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
CONTRIBUTING.md chore: add Go repo norms (badges, contributing, lint, taskfile, editorconfig) 2026-02-23 06:45:49 +00:00
conventions_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
coverage_test.go fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4 2026-04-27 18:55:55 +01:00
DEPENDENCIES.md fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
doc.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
duckdb.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
events.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
events_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
go.mod fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
go.sum fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
import.go fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4 2026-04-27 18:55:55 +01:00
import_export_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
import_test.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
inventory.go refactor(store): replace banned stdlib imports with core/go primitives 2026-04-08 16:43:49 +01:00
journal.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
journal_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
json.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
LICENCE.md fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
medium.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
medium_test.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
parquet.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
path_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
publish.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
publish_test.go fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4 2026-04-27 18:55:55 +01:00
README.md fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
recover_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
scope.go fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4 2026-04-27 18:55:55 +01:00
scope_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
store.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
store_test.go fix(store): r4 — EnsureDir errors + scoped readiness names + purge event timeout on PR #4 2026-04-27 18:55:55 +01:00
test_asserts_test.go fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
test_helpers_test.go fix(go-store): replace testify with stdlib testing patterns (AX-6) 2026-04-24 18:51:17 +01:00
transaction.go fix(store): r3 — transactional import + DELETE RETURNING + token home order on PR #4 2026-04-27 18:29:59 +01:00
transaction_test.go fix(store): address all CodeRabbit findings on PR #4 2026-04-27 14:51:06 +01:00
workspace.go fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00
workspace_test.go fix(store): r2 — address residual CodeRabbit findings on PR #4 2026-04-27 17:00:07 +01:00

Go Reference Licence: 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/store Licence: EUPL-1.2 Language: Go 1.26

Quick Start

package main

import (
	"fmt"
	"time"

	"dappco.re/go/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
  • Dependency Exceptions — documented runtime dependency exceptions

Build & Test

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

Licence

European Union Public Licence 1.2 — see LICENCE.md for details.