store

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store keeps Physa's local records for the repo in one SQLite database, physa.db in the store directory the version-control interface names (shared by every worktree, never committed). It keeps slice records: which capabilities were read, with what, which entries were taken by slug, when and by which session. It also keeps one gather of the repo's sources (docs, history, PRs), replaced whole in one transaction, which clears init's record beside it. Init's record (the areas, the proposal, the recoveries and init's spend) has its tables here but its code in package initrecord. It also holds the engine's tables (ideas, pursuits, plans, plan revisions, events, intents and timers), which only the engine's state package writes. Schema changes, init's record's included, are numbered migrations applied at open.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenReadOnly

func OpenReadOnly(path string) (*sql.DB, error)

OpenReadOnly opens an existing <path> without creating, migrating or writing it. It is for readers outside the engine that must never write and must work when no engine runs (the commit hook). A missing file gives an error wrapping fs.ErrNotExist.

func WriteRecords

func WriteRecords(w io.Writer, recs []SliceRecord, asJSON bool) error

WriteRecords writes slice records, newest first as given: one line each for people, or one JSON list for tools ([] when there are none).

Types

type Doc

type Doc struct {
	Path   string
	Kind   string
	Body   string
	Reason string
}

Doc is one gathered document. Reason is why gather picked this source, shown to the person; it is empty for a gather stored before it was kept.

type Gather

type Gather struct {
	Run     GatherRun
	Docs    []Doc
	Changes []GatheredChange
	PRs     []GatheredPR
}

Gather is the one gather the store keeps.

type GatherRun

type GatherRun struct {
	At          time.Time
	Since       time.Time
	MaxPRs      int
	PRsLimited  bool
	Forge       string
	ForgeReason string
	Stopped     bool // true when the forge stopped the gather early
	// Reached is the oldest merge date of the PRs kept; zero when none.
	Reached time.Time
	// StopReason is why the forge stopped the gather.
	StopReason string
}

GatherRun describes how the gather was made: when, the bound used, and whether a forge answered. Forge is empty when there was none, and ForgeReason says why PRs are unavailable.

type GatheredChange

type GatheredChange struct {
	ID       string
	Short    string
	Subject  string
	Message  string
	Author   string
	At       time.Time
	Trailers []Trailer
	Reverts  string
	Files    []string
}

GatheredChange is one change from history with the files it altered. Reverts is the reverted change's id, or empty.

type GatheredComment

type GatheredComment struct {
	Author          string
	At              time.Time
	Kind            string
	RequestsChanges bool
	Body            string
}

GatheredComment is one review comment on a PR.

type GatheredPR

type GatheredPR struct {
	Number int
	Title  string
	Body   string
	Author string
	// MergedBy is who merged the PR, when the forge said.
	MergedBy string
	MergedAt time.Time
	Issues   []string
	Comments []GatheredComment
}

GatheredPR is one merged PR with its review comments and linked issues.

type SliceRecord

type SliceRecord struct {
	At           time.Time
	Capabilities []string
	With         string
	Entries      []string
	Session      string
}

SliceRecord is one printed slice. Entries holds the slugs of an --entry read, whose Capabilities are empty. Entries and Session are empty when there are none or the calling session is unknown; Entries encodes as null then, and Session likewise.

func (SliceRecord) MarshalJSON

func (r SliceRecord) MarshalJSON() ([]byte, error)

MarshalJSON encodes the record with entries and session null when absent.

type Store

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

Store is an open database.

func Open

func Open(dir string) (*Store, error)

Open opens <dir>/physa.db, creating the directory and the file, and applies any migrations it has not seen.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) DB

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

DB returns the open database. It is for the engine's state package, which alone writes the engine's tables (codecheck's engine-tables-writer rule), and for package initrecord, which keeps init's record.

func (*Store) Gathered

func (s *Store) Gathered() (Gather, bool, error)

Gathered returns the stored gather, false when nothing was gathered.

func (*Store) PutGather

func (s *Store) PutGather(g Gather) error

PutGather replaces the stored gather with g in one transaction: on any error the earlier gather is left intact. It also deletes the stored init areas, proposal, recoveries and spend, which belong to one gather.

func (*Store) PutSliceRecord

func (s *Store) PutSliceRecord(r SliceRecord) error

PutSliceRecord stores one slice record.

func (*Store) SliceRecords

func (s *Store) SliceRecords() ([]SliceRecord, error)

SliceRecords returns every slice record, newest first.

type Trailer

type Trailer struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Trailer is one key and value from a change's message.

Jump to

Keyboard shortcuts

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