evidence

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package evidence computes review evidence the author cannot fake, scoped to an item's declared targets (T-01KYD88KE): the B-0009 class (exported, declared, never consumed) and the B-0003 class (one call site diverging from twenty siblings). The server surfaces, the agent judges — records render one line each, capped, deterministic, never a veto.

Index

Constants

View Source
const DupThreshold = 0.85

DupThreshold marks a pair redundant: at 0.85 shingle-Jaccard the two blocks share their structure with only local renames — the proving gate/rule twin scores well above, unrelated same-idiom code well below (calibrated by the fixture test, T-01KYD9R).

Variables

This section is empty.

Functions

func DivergentCallers

func DivergentCallers(g graph.Graph, targets []string, load func(path string) []byte) []string

DivergentCallers reports call sites whose argument shape is in a small minority against their siblings — the B-0003 class. The graph carries no argument metadata (rejected: grows every edge for one consumer), so the sweep re-parses only the files the inbound call edges name, bounded.

func Duplicates

func Duplicates(changed []IndexedNode, index []IndexedNode) []string

Duplicates reports, for each changed node, its best index match at or above DupThreshold — one match per node (the best; more is noise), test against test and production against production only (fixture boilerplate across tests is a deliberate idiom, not redundancy). Bucketed by shared shingle so the comparison is candidates-only, never all-pairs.

func Similarity

func Similarity(a, b Print) float64

Similarity is shingle-set Jaccard.

func Unconsumed

func Unconsumed(g graph.Graph, targets []string, suppressed map[string]string) []string

Unconsumed reports exported function-kind symbols under the target paths with zero inbound call/use edges from outside their own file — declared and never consumed. Suppressions (unconsumed-ok body directives) render visibly instead of counting; a directive naming an unflagged symbol is itself flagged stale, so suppressions never outlive their reason.

Types

type IndexedNode

type IndexedNode struct {
	ID    graph.NodeID
	File  string
	Test  bool
	Print Print
}

IndexedNode pairs a node with its fingerprint.

func BuildDupIndex

func BuildDupIndex(g graph.Graph, load func(path string) []byte) ([]IndexedNode, bool)

BuildDupIndex fingerprints every function-kind node's span, reading spans only (never whole files repeatedly — spans come from one read per file). load returns nil to skip a file (unreadable or generated).

type Print

type Print struct {
	Shingles map[uint64]struct{}
	Tokens   int
}

Print is a fingerprint: the shingle-hash set plus its significant-token count.

func Fingerprint

func Fingerprint(src []byte, isGo bool) Print

Fingerprint normalizes a span and shingles it. Go spans normalize via go/scanner with identifiers and basic literals replaced by kind placeholders (type-2 clones: renamed copies still match); non-Go spans fall back to whitespace-normalized byte shingles.

Jump to

Keyboard shortcuts

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