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 ¶
- func OpenReadOnly(path string) (*sql.DB, error)
- func WriteRecords(w io.Writer, recs []SliceRecord, asJSON bool) error
- type Areas
- type Doc
- type Gather
- type GatherRun
- type GatheredChange
- type GatheredComment
- type GatheredPR
- type Proposal
- type Recovered
- type SliceRecord
- type Spent
- type Store
- func (s *Store) AddSpent(p Spent) error
- func (s *Store) Areas() (Areas, bool, error)
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) Gathered() (Gather, bool, error)
- func (s *Store) Proposed() (Proposal, bool, error)
- func (s *Store) PutAreas(a Areas) error
- func (s *Store) PutGather(g Gather) error
- func (s *Store) PutProposal(p Proposal) error
- func (s *Store) PutRecovered(rs []Recovered) error
- func (s *Store) PutSliceRecord(r SliceRecord) error
- func (s *Store) Recovered() ([]Recovered, error)
- func (s *Store) SliceRecords() ([]SliceRecord, error)
- func (s *Store) Spending() ([]Spent, error)
- type Trailer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenReadOnly ¶
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 Areas ¶ added in v0.0.23
type Areas struct {
GatherAt, At time.Time
Model string
Input, CachedInput, Output int64
Body []byte
}
Areas is the one division of a repo into areas the store keeps, with the session that made it and what it used. GatherAt is the run time of the gather it belongs to. Body is the areas and the source split as JSON.
type Doc ¶
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 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 ¶
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 ¶
Open opens <dir>/physa.db, creating the directory and the file, and applies any migrations it has not seen.
func (*Store) 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) PutGather ¶
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) PutProposal ¶
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 ¶
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) SliceRecords ¶
func (s *Store) SliceRecords() ([]SliceRecord, error)
SliceRecords returns every slice record, newest first.