ops

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ops is each operation once, for every surface. The CLI, the MCP server and the hooks used to each call the memory package and compose their own report of what happened, and the reports drifted: #241 was the review queue's hand-edit announcement fixed for one surface while another said nothing, and a remember whose vault write failed lost its memory id on both. An operation here returns what it found plus an Outcome — what it did on the way, with counts, and what failed — and a surface only renders it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoAcceptedSinceReview

func AutoAcceptedSinceReview(db *sql.DB) (int, error)

AutoAcceptedSinceReview is how many memories the review switch accepted since a person last accepted or rejected one: the number every mention of the queue carries, so what was accepted for the user is never out of their sight.

func AutoLead

func AutoLead(vault, project string) string

AutoLead is what resume does about auto, as the lines that open it, the same on the CLI and over MCP, or "" when there is nothing to say: AutoReport, then the day's dream if it is due. The report comes first so it covers the last dream, not the one just launched.

func AutoReview

func AutoReview(db *sql.DB, vault string, now time.Time) (int, error)

AutoReview runs the review switch over the queue and returns how many it accepted. Off, it does nothing at all. A memory it could not accept is reported, and the rest are still tried: one failure is not a reason to leave the others for a person who turned the switch on to be spared them.

func Backticked

func Backticked(c string) string

Backticked is how an agent's markdown shows a command; Plain is a terminal.

func NotDurable

func NotDurable(stranded bool) string

NotDurable is worded as a fact about where a memory is rather than a warning, because the memory itself is fine — an agent should still use it, and should know not to rely on it being there tomorrow.

func Plain

func Plain(c string) string

func ProjectExists

func ProjectExists(db *sql.DB, vault, name string) bool

ProjectExists reports whether the vault has ever heard this exact name — either a memory filed under it or a session directory carrying it. Both are consulted because a project can have checkpoints and no memory, or memory and no checkpoint, and either one makes the name real.

func QueueAdoption

func QueueAdoption(restored, rejected int) string

QueueAdoption says what a hand edit to the review queue file did to the queue, in the words `logos review` prints for the same adoption. Empty when nothing changed, which is nearly always.

func QueueLine

func QueueLine(waiting, autoAccepted int, shell string, cmd func(string) string) string

QueueLine is the review queue in one line: what waits for the user, and what the review switch accepted for them since they last looked. Empty when there is neither. cmd wraps a command as the reader shows it: backticks for an agent's markdown, nothing for a terminal.

func RunAutoReview

func RunAutoReview(db *sql.DB, vault, project string) string

RunAutoReview is the sweep as resume runs it: logged, so the auto line resume opens with says what it accepted, and a failure returned as a line to print, since resume has nobody to return an error to but the reader.

func TurnRef

func TurnRef(harness, path string, turns int) string

TurnRef is how a proposal cites the transcript turn it was made in: the harness, how many turns the transcript held, and its path. The path is last because it is the one part that can hold a colon.

Types

type Note

type Note struct {
	Text   string `json:"text"`
	Failed bool   `json:"failed,omitempty"`
}

Note is one thing an operation has to say beyond its result. Ordered, not keyed, because the order is part of the report: the adoption of a hand edit reads before the count it changed.

type Outcome

type Outcome struct {
	Notes []Note `json:"notes,omitempty"`
}

Outcome is what an operation did besides answering, and what went wrong. A failure that does not void the result — the review queue could not be counted, the vault refused a write the cache took — is a failed note rather than an error, so the half that succeeded is still reported (invariant 4).

func AutoReport

func AutoReport(vault, project string) Outcome

AutoReport is what resume says about auto: what it did out of sight since the project's last checkpoint an agent wrote, and anything wrong with auto.md. Since that checkpoint and not since the last one of any kind, because the latest is often the one auto wrote at session end, and the report is there to say it was auto that wrote it.

func ReviewQueue

func ReviewQueue(db *sql.DB, shell string) Outcome

ReviewQueue is what every read reports while the review queue is not empty. Quarantine keeps an agent's memories out of recall until the user says yes, and a user who is never told there is anything to say yes to leaves them there for good — while the agent reads the empty recall as the fact never having been stored. A failed count is said, not swallowed, but does not fail the read it is attached to. shell is the command the user types, which the MCP server learns from its install.

func (Outcome) Err

func (o Outcome) Err() error

Err is the failed notes as one error, or nil, for a surface whose exit status has to carry the failure.

func (Outcome) Failed

func (o Outcome) Failed() bool

Failed reports whether any part of the operation failed.

func (Outcome) Text

func (o Outcome) Text() string

Text renders the notes as paragraphs to follow a result, a failure in parentheses so it reads as a remark on the result rather than a replacement for it.

func (Outcome) TextWithoutFailures

func (o Outcome) TextWithoutFailures() string

TextWithoutFailures is Text less the failed notes, for a surface that reports those separately through Err.

type RecallQuery

type RecallQuery struct {
	Query   string
	Limit   int
	Project string
	Embed   *provider.Provider // nil ranks by keyword alone
	Model   string
	Shell   string
}

RecallQuery is a recall as any surface asks it. Project "" searches every project; otherwise the project's memories plus the global ones.

type RecallResult

type RecallResult struct {
	Memories []Recalled `json:"memories"`
	Project  string     `json:"project,omitempty"`
	Outcome  Outcome    `json:"outcome"`
}

func Recall

func Recall(db *sql.DB, q RecallQuery) (RecallResult, error)

Recall answers a query from memory and reports the review queue alongside, which it adopts the user's hand edits to on the way.

func (RecallResult) Text

func (r RecallResult) Text(ifEmpty string) string

Text renders the result, with ifEmpty standing in for the list when nothing matched — the one sentence a surface words for itself, since only it knows what its caller can do about it (a flag, a tool parameter).

type Recalled

type Recalled struct {
	memory.Memory
	// NotDurable marks a memory the cache holds and the vault does not. It is
	// still usable and still true — it is just one `rm -rf .logos` from gone,
	// and the README tells people that command is safe. The write reported the
	// failure once, to a caller that has since exited; every reader after
	// that saw a row indistinguishable from a durable one. See
	// memory.UnflushedIDs.
	NotDurable bool `json:"not_durable,omitempty"`
}

Recalled is a memory as recall returns it, with where it is kept.

type RememberRequest

type RememberRequest struct {
	Memory memory.Memory
	Embed  *provider.Provider // nil dedups by exact text
	Model  string
}

type RememberResult

type RememberResult struct {
	Receipt memory.Receipt `json:"receipt"`
	Outcome Outcome        `json:"outcome"`
}

func Remember

func Remember(db *sql.DB, req RememberRequest) (RememberResult, error)

Remember stores a memory. The error is for a write refused before anything was stored. A write the cache took and the vault did not is a result, not an error: the memory exists, recall returns it, and its id is the one handle anyone has to re-save or forget it — so the receipt comes back with the failure in its Outcome instead of being dropped for it.

Jump to

Keyboard shortcuts

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