db

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package db provides database connectivity and migration logic for norma.

Package db provides database connectivity and migration logic for norma.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(ctx context.Context, path string) (*sql.DB, error)

Open opens the SQLite database with required pragmas and migrations.

Types

type Event

type Event struct {
	Type     string
	Message  string
	DataJSON string
}

Event represents a timeline event for a run.

type StepRecord

type StepRecord struct {
	RunID     string
	StepIndex int
	Role      string
	Iteration int
	Status    string
	StepDir   string
	StartedAt string
	EndedAt   string
	Summary   string
}

StepRecord represents a committed step in the database.

type Store

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

Store provides persistence for runs and steps.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore creates a store for run/step persistence.

func (*Store) CommitStep

func (s *Store) CommitStep(ctx context.Context, step StepRecord, events []Event, update Update) error

CommitStep inserts the step record, events, and updates the run in one transaction.

func (*Store) CreateRun

func (s *Store) CreateRun(ctx context.Context, runID, goal, runDir string, iteration int) error

CreateRun inserts the run record and a run_started event.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB returns the underlying database handle.

func (*Store) RunStatus

func (s *Store) RunStatus(ctx context.Context, runID string) (string, error)

RunStatus returns the status for a run id, or empty if missing.

func (*Store) UpdateRun

func (s *Store) UpdateRun(ctx context.Context, runID string, update Update, event *Event) error

UpdateRun applies a run update and optional event without inserting a step.

type Update

type Update struct {
	CurrentStepIndex int
	Iteration        int
	Status           string
	Verdict          *string
}

Update contains updates for a run record.

Jump to

Keyboard shortcuts

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