statestore

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package statestore owns the shared SQLite database that jungi keeps under <repo>/.jungi/state/state.db. It is intentionally thin: it resolves the database path, ensures the state directory exists, opens the connection with the pragmas every consumer relies on (busy_timeout for cross-session contention, foreign_keys for cascade integrity), and hands back a handle.

State-owning packages (planengine, tasklist, ...) do not open their own database; they accept a *statestore.DB and bootstrap their own tables into the shared connection via CREATE TABLE IF NOT EXISTS. This keeps a single connection pool per repo and lets a future standalone task-list path share the same file without a second open.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBPath

func DBPath(repoRoot string) string

DBPath returns the absolute path of the shared SQLite database for the given repo root. The caller is expected to have verified that repoRoot is an actual git repo root via worktree.RepoRoot before calling.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a handle to the shared state database. It carries the repo root it was opened against so consumers (renderers, tool dispatchers) can resolve sibling artifact paths without threading the root separately.

func Open

func Open(repoRoot string) (*DB, error)

Open returns a DB bound to repoRoot, creating .jungi/state/ on demand and opening state.db with the busy_timeout and foreign_keys pragmas. A fresh repo gets an empty database; consumers create their own tables via their Bootstrap methods.

repoRoot must be an absolute path. The caller (session.Manager) has already validated it via worktree.RepoRoot.

func (*DB) Close

func (d *DB) Close() error

Close releases the underlying connection pool. Safe to call on a nil receiver so Session.Close need not branch on whether a store was successfully opened.

func (*DB) RepoRoot

func (d *DB) RepoRoot() string

RepoRoot returns the repo root the handle was opened against. Renderers and tool dispatchers use it to resolve artifact paths (e.g. plan.md).

func (*DB) SQL

func (d *DB) SQL() *sql.DB

SQL returns the underlying *sql.DB so state-owning packages can run their own queries and bootstrap their tables against the shared connection.

Source Files

  • paths.go
  • statestore.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL