Documentation
¶
Overview ¶
Package match is the canonical term-overlap primitive: it scores how much of a new text another record already holds, by the words the two share, and classifies a likely double as `duplicates` (near-identical) or `refines` (narrower). It is a lexical HEURISTIC and says so on every result it returns (Heuristic): no model is consulted, nothing semantic is claimed, and a match is a proposal a person confirms or removes (itd-2609212137116617).
It is the one home of the overlap score (the one-canonical-primitive rule): the filing-time match of `capture` and of the quoted-text `intent` create call it, and any later ranking by shared terms (the embark ranking the reflect spec names) calls it rather than growing a copy. It sits below the record dispatcher rather than inside it because the dispatcher reads the capture and intent stores, and both of those call this package; a leaf package is what lets every caller reach it without an import cycle.
The scorer reads nothing, writes nothing and never prints; the one read in the package is LoadConfig, through the layered configuration reader. Its callers gather the candidate texts under their own locks and write the links.
Index ¶
Constants ¶
const ( // FieldIssueBody is an open or resolved issue's markdown body. FieldIssueBody = "issue.body" // FieldIntentTitle is an intent's H1. FieldIntentTitle = "intent.title" // FieldIntentPressRelease is an intent's `## Press Release` section. FieldIntentPressRelease = "intent.press_release" )
The compared fields: which text of each candidate family the match reads. The set is closed; a name outside it is refused, never ignored.
const ( // DefaultThreshold is the weighted share of the new text's terms a // candidate must hold for a link to be written. It was read off this // repository's own ledger on 2026-09-26: each of the 449 open issues was // matched against the other 1,660 issues and intents, and 14 cleared 0.6. // Most of those were the same finding filed twice or a narrower follow-up // of an earlier one; the false ones shared a relocation footer rather than // a finding. Below 0.6 the best pairs stop being the same finding. DefaultThreshold = 0.6 // MinTerms is the fewest distinct terms a new text needs before it is // compared at all. Below it the overlap of a line or two is chance, so the // record is filed without matching and the outcome says so (the intent's // scope condition). MinTerms = 8 // MaxLinks caps the links one filing writes. A text that clears the // threshold against more candidates than this links the highest scorers; // the rest are still listed, so nothing is hidden. MaxLinks = 3 // NearMissLimit caps how many below-threshold candidates an outcome lists. NearMissLimit = 5 )
Bundled defaults. The threshold is configuration (the layered resolver's match.threshold); the rest are declared constants of the heuristic.
const Heuristic = "lexical term overlap, weighted by how rare each term is across the candidates; a heuristic, not a judgement"
Heuristic names the method on every outcome, so a surface never renders a score as more than it is.
Variables ¶
var DefaultFields = []string{FieldIssueBody, FieldIntentTitle, FieldIntentPressRelease}
DefaultFields is the bundled match.fields: every field in the set.
Functions ¶
func Overlap ¶
Overlap is THE overlap score: the weighted share of a's terms that b holds (forward), the weighted share of b's terms that a holds (reverse), and the shared terms, rarest first. Both inputs are sorted term sets (Terms).
Types ¶
type Config ¶
type Config struct {
Threshold float64 `json:"threshold"`
ThresholdOrigin string `json:"threshold_origin"`
Fields []string `json:"fields"`
FieldsOrigin string `json:"fields_origin"`
}
Config is the resolved match configuration, with the origin of each value (the layered resolver's: "bundled", a file, or a flag), so a surface can say where a threshold came from.
func LoadConfig ¶
LoadConfig resolves match.threshold and match.fields through the one layered configuration reader (.abcd/config.json, then ~/.abcd/config.json, then the bundled defaults). It claims the `match` namespace, so a misspelt key is refused rather than letting a default apply unannounced, and a value outside its range or set is refused naming its file, never replaced by the default.
type Outcome ¶
type Outcome struct {
Heuristic string `json:"heuristic"`
Threshold float64 `json:"threshold"`
// Terms is the number of distinct terms the new text carries.
Terms int `json:"terms"`
MinTerms int `json:"min_terms"`
// Compared is the number of candidates scored.
Compared int `json:"compared"`
// Skipped says why no candidate was compared; empty when matching ran.
Skipped string `json:"skipped,omitempty"`
// Matches are the candidates at or above the threshold, best first.
Matches []Score `json:"matches"`
// NearMisses are the best candidates below it, with their scores.
NearMisses []Score `json:"near_misses"`
}
Outcome is one text matched against a candidate set.
func Rank ¶
Rank matches text against every candidate. A threshold outside (0, 1] is the caller's fault and reads as the bundled default, so a matcher can never be configured into linking everything or nothing by accident; the layered reader refuses such a value before it gets here.
func Skip ¶
Skip is the outcome of a match that compared nothing, for the reason given: the filing goes ahead, and the reason is what a surface says.
type Relation ¶
type Relation string
Relation is the typed link a match writes. The vocabulary is the itd-84 discipline's (supersedes / reverses / duplicates / refines); a lexical score can only ever propose the two below. A reversal or a supersession is a judgement about meaning, which the discipline keeps advisory and human, so this package never proposes either.
type Score ¶
type Score struct {
ID string `json:"id"`
// Score is the weighted share of the NEW text's terms this candidate holds,
// in [0, 1] and rounded to three places. It is what the threshold compares.
Score float64 `json:"score"`
// Reverse is the weighted share of the CANDIDATE's terms the new text
// holds: high both ways is a duplicate, high one way a refinement.
Reverse float64 `json:"reverse"`
// Relation is set on a match above the threshold, and empty on a near miss.
Relation Relation `json:"relation,omitempty"`
// Linked is true when the writer wrote this match onto the record: every
// match up to MaxLinks.
Linked bool `json:"linked"`
// reads before confirming or removing the link.
Shared []string `json:"shared_terms"`
}
Score is one candidate's result.
type Weights ¶
type Weights struct {
// contains filtered or unexported fields
}
Weights is the rarity weight of every term across a candidate set: a term few candidates carry says more about a text than one most of them carry. A term no candidate carries takes the highest weight.
func NewWeights ¶
NewWeights counts, per term, how many of the term sets carry it.