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

gap

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: 24 Imported by: 0

Documentation

Overview

Package gap records a question the vault did not answer.

A gap is a note. The index is a regenerable cache, so a committed note is the only durable home (Principle 7 — one source of truth). Recall never returns it. A weak ask is only a hint, written to local state, and is not a gap.

Index

Constants

View Source
const (
	// DefaultLogLimit is how many hint records a compaction keeps. The file
	// may hold twice that many before it is rewritten. app.ask.gap_log_limit
	// defaults to this number. A non-positive limit uses it too, so a missing
	// config value cannot wipe the log.
	DefaultLogLimit = 1000
)

Variables

This section is empty.

Functions

func Open

func Open(ctx context.Context, v Vault, req Request, hits Hits) error

Open records an open gap, or reports the open gap that already asks this question. A closed gap with the same question does not count.

func RecordPossible

func RecordPossible(vaultPath, query, band string, storeQuery bool, limit int, now time.Time) error

RecordPossible appends a weak or no-match ask to the per-user hint log. Strong, moderate, and empty bands are not hints. The raw query is stored only when storeQuery is set; otherwise the line keeps a salted hash and a length.

The log is not vault content. It lives under xdg.StateDir, the same resolver episode cursors and the signer socket use: one 0600 file per vault, named by the sha256 of vault.CanonicalKey. The directory is 0700. An old .vaultmind/possible-gaps.jsonl is not read. It never shipped.

limit is the retained window. When the file grows past twice that, it is rewritten to the newest limit records. The scan keeps at most twice the window in memory, so one write stays bounded even if a previous file is large.

Types

type Hits

type Hits interface {
	IDs(ctx context.Context, question string) ([]string, error)
}

Hits lists the note ids ask would return for a question right now. Drafts and gaps are already excluded by that ranking.

type OpenNote

type OpenNote struct {
	ID       string
	Question string
	AgeDays  int
}

OpenNote is one open gap for doctor and the meter.

type Report

type Report struct {
	Notes          []OpenNote
	Opened, Closed int
	Median         *float64
	Possible       int
	PossibleSince  string
}

Report is the gap meter. Opened counts open and closed gaps. Median is nil when nothing has been closed. Possible is the hint log, not a note.

func Measure

func Measure(db *index.DB, vaultPath string, now time.Time) (Report, error)

Measure lists open gaps and the meter. A missing possible-gap log counts as zero. A log that cannot be read is logged and counted as zero, so a hint-log problem does not hide the notes.

type Request

type Request struct {
	Question       string
	Session        string
	JSON           bool
	Now            time.Time // zero means time.Now().UTC()
	Stdout, Stderr io.Writer
}

Request is one note gap call.

type Vault

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

Vault is an opened vault. The command opens it; gap does not.

Jump to

Keyboard shortcuts

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