evidence

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

@index Turns ranked search candidates into a list a reader can judge.

Index

Constants

View Source
const PageHitBudget = 50

PageHitBudget is the point past which one answer stops taking on more files.

It bounds a page without ever trimming a file: a file is added whole or left for the next page, and the first file of a page is always added. So a file holding sixty hits is still answered with sixty hits — it just travels alone. Half a file is worse evidence than a long one, because the reader cannot tell which half they got.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// Namespace is empty outside federated search. Two repositories can each
	// hold an internal/app/main.go, and those are two files, not one.
	Namespace string
	FilePath  string
	Hits      []Result
}

File is every hit one file answered the query with.

The file is the unit of a search answer because it is the unit of reading: a reader picks a file first and a declaration inside it second. Grouping also removes the old reason to hide hits — ten hits in one file cost one decision, not ten — so a shown file arrives whole.

@intent make the file, not the declaration, the thing a caller chooses between.

func (File) HitCount

func (f File) HitCount() int

HitCount is how many hits this file answered with. @intent let a caller weigh a file before reading any of its hits.

type List

type List struct {
	Files        []File
	WeakFiltered int
	// OverflowFiles is how many further files this page did not reach, whether
	// the Limit or the page budget stopped it. It separates "this is
	// everything" from "this is the first ten files of thirty".
	OverflowFiles int
	// Note is set only when Files is empty, and says which kind of empty it is:
	// nothing retrieved, nothing explainable, or a page past the end.
	Note string
}

List is a whole search answer, including what it decided not to show. @intent make "nothing to show" a readable answer rather than an empty array.

func Build

func Build(query string, nodes []graph.Node, opts Options) List

Build turns the reranked candidate pool into a list whose every entry can be justified, and reports what it left out.

The order it is handed is the order it keeps. Ranking was measured against the golden set and its job turned out to be membership, not sequence: a reader who reads all ten lines is unaffected by which is third. So this changes who is in the list, never who is first — except that weak results kept by IncludeWeak go last, since they are there to be scrolled past.

@requires nodes arrive in the order rank.Rerank left them, and carry their loaded Annotation. @ensures the returned Files never exceed Options.Limit, and every returned file carries all of its justified hits. @ensures Note is non-empty exactly when Files is empty. @intent give a reader or an agent a file list where every line states why it is there.

func (List) Hits

func (l List) Hits() []Result

Hits flattens the answer back into one ranked sequence, a file at a time. @ensures hits of one file stay contiguous and keep the order Build was handed. @intent give renderers and measurements one sequence without losing the grouping.

type Match

type Match string

Match names one reason a candidate is in the list. @intent let a reader see which part of a result the query actually touched.

const (
	MatchName   Match = "name"
	MatchPath   Match = "path"
	MatchIntent Match = "intent"
)

type Options

type Options struct {
	Limit  int
	Offset int
	// IncludeWeak keeps candidates no signal explains, after the explainable
	// ones. Off by default, because a list padded with unexplainable results
	// reads as "here are ten answers" when there were two.
	IncludeWeak bool
}

Options are the caller's choices about how wide the list may be. @domainRule Limit and Offset are both counted in files, never in hits, so paging never splits a file. @intent keep the bounds a caller controls — page size, page position, strictness — in one argument.

type Result

type Result struct {
	Node   graph.Node
	Intent string
	// Matched lists every signal the query touched, in a fixed order: name,
	// path, intent. It is empty only for a weak result kept by IncludeWeak.
	Matched []Match
}

Result is one candidate and the case for it. @intent carry a search hit together with the evidence that justifies showing it.

Jump to

Keyboard shortcuts

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