recovery

package
v0.0.23 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: 24 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 recovery is init's recover and check phases: one prompt-only session per capability, or one per share, one after another, when its sources are more than one session holds, at most Concurrency capabilities at once, reading what it cites and what coverage places with it by files; each capability's text, split into its folder, goes through the map check and back to the same session with the problems, up to MaxRetries times, before failing entries are dropped. Sessions read their sources whole, with no appetite and no circuit breaker: init is never bounded (design 10 Q6). It writes the store, never the repo.

Index

Constants

View Source
const (
	// Concurrency is the most sessions running at once.
	Concurrency = 3
	// MaxRetries is how many times a capability's text with problems goes back
	// to its session before the failing entries are dropped.
	MaxRetries = 2
)

Each number below is a first guess, to be tuned from real runs (measure-before-budget).

View Source
const (
	StatusRecovered = "recovered"
	StatusNotYet    = "not yet recovered"
	StatusFailed    = "failed"
)

The values of Outcome.Status, as the store keeps them.

Variables

View Source
var ErrNoProposal = errors.New("nothing proposed yet; run physa init --propose first")

ErrNoProposal is returned by Run when the store holds no proposal.

Functions

This section is empty.

Types

type Outcome

type Outcome struct {
	Name      string               `json:"name"`
	Status    string               `json:"status"`
	File      string               `json:"file"`
	Terms     string               `json:"terms"`
	Counts    recovering.Counts    `json:"counts"`
	Dropped   []recovering.Dropped `json:"dropped"`
	Problems  []string             `json:"problems"`
	Attempts  int                  `json:"attempts"`
	Shares    int                  `json:"shares,omitempty"`
	SessionID string               `json:"session_id"`
	Model     string               `json:"model"`
	Tokens    adapter.Tokens       `json:"tokens"`
	Error     string               `json:"error,omitempty"`
}

Outcome is how one capability's recovery ended. File is the capability's single text, front matter included, which mapfolder.Split makes its folder of, and Terms its glossary terms, both empty unless Status is StatusRecovered; Counts says what they hold. Dropped lists the entries, terms and overview taken out, each with its reasons. Problems is what failed the capability: what the check found outside any entry, or why the answer could not be read. Error is any other reason it failed: the agent's error, or the check's. Attempts counts the session's turns, the first and each retry, and Tokens is what they used together. Shares is how many shares its sources were read in, one session each, when they were more than one session holds; 0 is one session. SessionID is the id assigned to the session, empty when none started. Without its File and Terms, it is the JSON form of store.Recovered's Details.

type Report

type Report struct {
	Used         adapter.Tokens `json:"used"`
	Capabilities []Outcome      `json:"capabilities"`
}

Report is how one run ended: what its sessions used together, and one outcome per capability, in run order.

func Run

func Run(ctx context.Context, st Store, s Session) (Report, error)

Run is init's recover and check phases end to end. For each capability (those of s.Only, or all the proposal holds) it runs one prompt-only session with the recovering skill on its linked sources, whole, checks the text it writes, sends problems back up to MaxRetries times, then drops what is still at fault; its row replaces the capability's earlier one.

No proposal (ErrNoProposal) and a name in s.Only the proposal lacks are errors that resolve no agent and store nothing. A capability that fails, or that a cancelled run never reaches, is not an error: the Report says so.

func (Report) Whole added in v0.0.6

func (r Report) Whole() bool

Whole reports whether every capability r holds got its session: none is left not yet recovered by a run cut short.

type Session

type Session struct {
	// Agent resolves the agent to recover with, once, and only when nothing
	// refuses the run first.
	Agent func() (adapter.Adapter, error)
	// Only names the capabilities to recover, in the order to run them;
	// empty means every proposed capability, in the proposal's order.
	Only []string
	// Root is the repo's root, where `from <path>` anchors resolve. Nothing
	// is written under it.
	Root string
	// PRExists tells whether a PR exists, asked only for numbers the gather
	// does not hold. Nil checks #N anchors for form only.
	PRExists func(int) (bool, error)
	// OpenRepo opens Root's version control to resolve commit anchors. Nil
	// leaves each unresolved, a problem.
	OpenRepo func(string) (vcs.Repo, error)
	// Progress receives one line before the sessions start and one as each
	// capability ends; nil drops them.
	Progress io.Writer
	// Now dates questions and stored rows; nil means time.Now.
	Now func() time.Time
}

Session says how Run runs its sessions.

type Store

type Store interface {
	Gathered() (store.Gather, bool, error)
	Proposed() (store.Proposal, bool, error)
	PutRecovered([]store.Recovered) error
}

Store is what Run needs of the store: the gather and the proposal to read, and a place for what was recovered.

Jump to

Keyboard shortcuts

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