Help us shape the future of Go! Take the 2026 Go Developer Survey

propose

package
v0.10.18 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package propose turns a finding into a reviewable draft, and accepts that draft.

The agent supplies the question and the finding. VaultMind chooses the note, the id, and the formatting. A person promotes the draft with note accept.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept

func Accept(ctx context.Context, v Vault, req Request) error

Accept promotes a draft. A new note flips status in the same file. A patch is appended to its target and the proposal file is removed, so one copy remains.

func Run

func Run(ctx context.Context, v Vault, req Request, retriever Retriever) error

Run writes a draft proposal, or reports the draft that already asks this question.

Types

type Hit

type Hit struct {
	ID, Path, Type, Title, Band string
}

Hit is the closest note ask would have ranked first, plus the relevance band ask already computed for it. Band is empty when that judgement is withheld or there is no band.

type QuestionRank

type QuestionRank struct {
	Hits   []RankedHit
	Mode   string
	Window int
}

QuestionRank is one pass of the question through the ranking ask uses. Mode is "hybrid" or "keyword". Window is the hit limit of that pass. Zero means the caller asked for no cut.

type QuestionRanker

type QuestionRanker interface {
	RankQuestion(ctx context.Context, question string, includeDrafts bool) (QuestionRank, error)
}

QuestionRanker ranks a question. includeDrafts is the only difference between the two passes: false is what an agent gets today, true is the draft counted as if it had been accepted.

type RankCheck

type RankCheck struct {
	Mode        string    `json:"mode,omitempty"`
	Window      int       `json:"window"`
	Before      RankPlace `json:"before"`
	After       RankPlace `json:"after"`
	MeasuredOn  string    `json:"measured_on,omitempty"`
	OutrankedBy []string  `json:"outranked_by,omitempty"`
	// Decision is the hit that chose patch or new: the closest note on the
	// question and the finding. Rank is 1 when that note was found. The zero
	// value means the retrieval named nothing. Before stays the question-only
	// rank stored as rank_before.
	Decision RankPlace `json:"decision,omitempty"`
	// DecisionOn is the text that comparison used.
	DecisionOn string `json:"decision_on,omitempty"`
	// CloseBand is the weakest band the decision treated as close enough.
	CloseBand string `json:"close_band,omitempty"`
}

RankCheck is the before/after measurement stored on the draft and reported to the caller. MeasuredOn is "proposal" when the finding lives on the proposal note rather than on the note it patches.

type RankPlace

type RankPlace struct {
	ID   string `json:"id,omitempty"`
	Rank int    `json:"rank"`
	Band string `json:"band,omitempty"`
}

RankPlace is one side of the retrieval check. Rank 0 means the note was not inside the window.

type RankedHit

type RankedHit struct {
	ID, Band string
}

RankedHit is one note in a ranking window, rank 1 first. Band is empty when ask would not show one for that hit.

type Request

type Request struct {
	Question, Finding, CloseBand string
	// GapID, when set, stores closes_gap on the draft. An empty question
	// uses the gap's stored question.
	GapID string
	// DraftsDir is where a draft goes when it must not sit in an import
	// folder. Empty means notes. "." is the vault root.
	DraftsDir      string
	Sources        []string
	JSON           bool
	Now            time.Time // zero means time.Now().UTC()
	ID             string    // accept: the draft id
	Stdout, Stderr io.Writer
	// Embed runs after a note is re-indexed. rel is the note this command
	// just wrote, so the caller can avoid warning about other notes.
	Embed   func(vaultPath, rel string)
	WorkDir string
	// Ranker re-runs the original question after the draft is on disk.
	// Nil skips the check. The command sets it; tests that only place a
	// draft leave it nil so their output stays the placement report.
	Ranker QuestionRanker
	// contains filtered or unexported fields
}

Request is one propose or accept call.

type Retriever

type Retriever interface {
	Closest(ctx context.Context, vaultPath string, db *index.DB, text string) (Hit, bool, error)
}

Retriever finds the closest note. Drafts are already excluded by the retrieval the caller shares with ask.

type Vault

type Vault struct {
	Path      string
	DB        *index.DB
	Config    *vault.Config
	Reg       *schema.Registry
	IndexHash func() string
}

Vault is an opened vault. Propose does not open one: the command layer does, so a guessed path cannot create an index here.

Jump to

Keyboard shortcuts

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