store

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 13 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, and the one init proposal made from it, which a new gather clears. 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 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
}

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 Proposal

type Proposal struct {
	GatherAt, At time.Time
	SessionID    string
	Model        string
	Appetite     int64
	Input        int64
	CachedInput  int64
	Output       int64
	Body         []byte
}

Proposal is the one init proposal the store keeps: the capabilities and promise proposed from one gather, with the session that made it and what it used. GatherAt is the run time of the gather it belongs to. Body is the proposal as JSON.

type Recovered

type Recovered struct {
	Capability  string
	ProposalAt  time.Time
	At          time.Time
	Status      string
	File        string
	Terms       string
	Details     []byte
	SessionID   string
	Model       string
	Attempts    int
	Appetite    int64
	Input       int64
	CachedInput int64
	Output      int64
	// KeepEarlier, when true, keeps an earlier stored row of the capability
	// that holds a recovered file (a non-empty File) and does not store this
	// row: a re-run that ends not yet recovered or failed loses nothing.
	KeepEarlier bool
}

Recovered is one capability's recovery the store keeps: the capability text and glossary terms its session wrote, how it ended (Status is stored as given), the session and what it used. ProposalAt is the time of the proposal it was recovered from. Details is JSON.

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 Spent

type Spent struct {
	Phase string
	spend.Count
}

Spent is what one init phase spent, as the run's meter counted it: its raw tokens, and its weighted tokens with their cost estimate.

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) AddSpent

func (s *Store) AddSpent(p Spent) error

AddSpent adds p to what its phase has spent so far.

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).

func (*Store) Gathered

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

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

func (*Store) Proposed

func (s *Store) Proposed() (Proposal, bool, error)

Proposed returns the stored init proposal, false when there is none.

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 proposal, recoveries and spend, which belong to one gather.

func (*Store) PutProposal

func (s *Store) PutProposal(p Proposal) error

PutProposal replaces the stored init proposal with p. It also deletes the stored recoveries and what proposing and recovering spent, which belong to one proposal.

func (*Store) PutRecovered

func (s *Store) PutRecovered(rs []Recovered) error

PutRecovered stores rs in one transaction: a capability already stored is replaced, every other stored capability is kept. A row with KeepEarlier leaves an earlier row that holds a file as it is.

func (*Store) PutSliceRecord

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

PutSliceRecord stores one slice record.

func (*Store) Recovered

func (s *Store) Recovered() ([]Recovered, error)

Recovered returns the stored recoveries ordered by capability.

func (*Store) SliceRecords

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

SliceRecords returns every slice record, newest first.

func (*Store) Spending

func (s *Store) Spending() ([]Spent, error)

Spending returns what each init phase has spent, in run order: discover, propose, recover.

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