Documentation
¶
Overview ¶
Package model holds the shared data types of the seamark graph.
The graph captures three layers (RFC-001 §5.1):
- structure: Symbol and Edge rows, parsed from source with tree-sitter
- history: CoChange pairs and Decision rows, mined from git
- effects: Effect tags propagated along call edges (later milestone)
Every value here traces to a parse, a commit, or a policy file — never to generated prose.
Index ¶
Constants ¶
const ( // OriginSamePackage: bare-identifier call resolved within the package. OriginSamePackage = "same-package" // OriginSameClass: self/cls/this method call resolved to a method of // the caller's own class. OriginSameClass = "same-class" // OriginQualified: qualified call resolved through the file's imports. OriginQualified = "qualified" // OriginUniqueName: method call resolved because exactly one symbol in // the repo carries that name. Lowest confidence. OriginUniqueName = "unique-name" // OriginParse: edge read directly off the syntax tree (imports). OriginParse = "parse" )
Edge origins record how an edge was derived, so downstream consumers can filter by confidence.
const ( SourceReview = "review" SourceRevert = "revert" SourceFixConventional = "fix:conventional" SourceFixIssueLink = "fix:issue-link" SourceFixSubject = "fix:subject" // SourceFixBranch marks a fix whose only declaration is its branch // name: a merge from fix/… whose commits carried no fix-shaped // message of their own. The finding is the merge's whole diff. SourceFixBranch = "fix:branch" )
Finding sources.
const ( ProposalProposed = "proposed" ProposalApplied = "applied" ProposalDismissed = "dismissed" ProposalSuperseded = "superseded" )
Proposal lifecycle states. Dismissed and superseded are both "not in the pin file", but they mean opposite things about the pattern: dismissed rejects the guidance, superseded keeps it and drops a redundant wording of it. Conflating them would let pruning a duplicate silently suppress a theme the user still wants.
const MaxTriggerPaths = 3
MaxTriggerPaths is the durable upper bound on one proposal's trigger answer and precise delivery union. Importers enforce the same contract as live distillation.
Variables ¶
This section is empty.
Functions ¶
func CountEvents ¶ added in v0.2.0
CountEvents collapses findings into distinct events: findings sharing a pull request are one event (the review comment and the fix commit that answered it), while findings without a pr number are independent. The distiller's recurrence bar, region inference, and confidence all count evidence this way — one definition, or two surfaces disagree about what recurred.
func FixMinedSources ¶
func FixMinedSources() []string
FixMinedSources returns the sources replaced together with fix mining.
func IsDocPath ¶ added in v0.2.0
IsDocPath reports whether a file is documentation — never the semantic home of a code change. Shared by fix mining (a doc file must not be elected a fix's primary file) and region inference (doc paths don't vote; a README citation must not drag a region to repo-wide).
func IsTestPath ¶
IsTestPath reports whether a file is test code, by each language's naming convention. Shared by resolution (test doubles must not win unique-name matches) and reporting (orientation shows the production surface, not test helpers).
Types ¶
type CoChange ¶
type CoChange struct {
FileA string // canonical order: FileA < FileB
FileB string
Together int // commits touching both
Total int // commits in the mined window
Lift float64
}
CoChange records that two files changed together in history. Lift = P(a,b) / (P(a)·P(b)) over the mined commit window: >1 means the pair co-occurs more than chance, and the further above 1 the stronger the empirical coupling.
type Decision ¶
type Decision struct {
ID int64
Kind DecisionKind
Ref string // commit SHA, PR number, ADR path
TS int64 // unix seconds
Author string
Title string
Body string
Files []string // repo-relative files this decision touched
}
Decision is one unit of "why": a commit, PR, revert, or ADR.
type DecisionKind ¶
type DecisionKind string
DecisionKind classifies where a Decision row came from.
const ( DecisionCommit DecisionKind = "commit" DecisionRevert DecisionKind = "revert" DecisionPR DecisionKind = "pr" DecisionADR DecisionKind = "adr" )
The decision sources the history miner records.
type Finding ¶
type Finding struct {
ID int64 // stable across mines: GitHub comment id, or sha-derived for fixes
LessonKey string // ClusterKey of the lesson this comment fed; "" for fix findings
// Path is the finding's semantic home: the commented file for a
// review finding, the most-changed non-test code file for a fix.
Path string
// Paths is a fix commit's full code footprint (primary first, by
// churn, capped) — what region inference votes with, so a fix whose
// test out-churned it still points at the code it corrected. Nil
// for review findings: their single Path IS the location.
Paths []string
PR int // pull-request number, 0 when unknown
Reviewer string // coderabbit | copilot | bot | person
Body string // boilerplate-stripped text, capped
URL string // provenance link (comment or commit), "" when none
CreatedAt int64 // unix seconds
// Source is the provider and its derivation: review, revert, or
// fix:conventional / fix:issue-link / fix:subject — every finding
// declares how it was mined, like every edge declares how it was
// resolved.
Source string
}
Finding is one raw review comment behind a lesson — the full material the 80-char fingerprint was distilled from. Lessons answer "what keeps happening"; findings keep the evidence, so deeper passes (distillation, provenance display) work from what reviewers actually wrote rather than from lossy summaries.
type Lesson ¶
type Lesson struct {
ID int64
ClusterKey string // stable identity of (region, symptom); the upsert key
Region string // file or directory the feedback lands in
Reviewer string // coderabbit | copilot | bot | person | mixed
Symptom string // a rule code (RUF001) or a normalized message
Fix string // extracted suggestion, when the comment carried one
Occurrences int // how many comments fall in this cluster
LastTS int64 // most recent occurrence, unix seconds
ExampleURL string // a representative comment, for provenance
// Annotation is surface-time display text (a confidence tag like
// "weak evidence: 1 event"), never part of the lesson's identity:
// the firing log records Symptom, and an annotation that changes
// with age must not split one lesson into many statistical rows.
Annotation string
}
Lesson is a cluster of recurring review feedback (M6): the same kind of comment landing on the same region across pull requests. It is the anti-repeat signal — "reviewers keep flagging X here" — surfaced to an agent before it makes the mistake a fourth time.
type Proposal ¶
type Proposal struct {
ID int64
Signature string // the evidence group that produced it
Rule string // short kebab-case pin label
// Region is the first current delivery region of Regions, kept as
// a single value for display and for readers that predate region
// sets ("" = repo-wide).
Region string
// Regions is the current bounded delivery set. It starts as evidence
// coverage and may become a set of verified trigger files or
// directories. Empty means "derive from Region" — pre-set rows and
// repo-wide proposals both land there.
Regions []string
// TriggerPaths are validated repo paths where the mistake is MADE,
// named by the distiller and verified by the harness.
// Region recomputation reads them, so precise trigger scopes survive
// a retarget. Nil for rows distilled before extraction existed.
TriggerPaths []string
// TriggerChecked is when the trigger question was last answered
// for this row (unix seconds; 0 = never). "Examined, none found"
// must stay distinct from "never examined", or every extraction
// run re-pays for the same negative answers.
TriggerChecked int64
// TriggerPromptVersion identifies the extraction question that produced
// the answer. A newer semantic question may re-examine an old negative
// answer once without disturbing already validated positive triggers.
TriggerPromptVersion int
Note string // the guidance, pin-ready
Members []int64 // finding ids the agent cited — verified to exist in the group
Agent string // provenance: adapter name + prompt version
Status string // proposed | applied | dismissed
CreatedAt int64
}
Proposal is one distilled pattern awaiting review. It is a pin-shaped lesson synthesized by the configured agent from the findings it cited. Proposals follow the plan/apply contract: the distiller may only propose. A pin reaches .seamark/lessons.yaml only through an explicit apply.
func (Proposal) RegionSet ¶ added in v0.2.0
RegionSet returns the effective region set: Regions when present, else the single Region, else nil — which means repo-wide. A "*" (or empty) entry anywhere means the whole set is repo-wide: matching code compares literal paths, and an unnormalized wildcard would match nothing instead of everything.
type Symbol ¶
type Symbol struct {
ID int64
FQN string // e.g. "internal/store.Store.UpsertSymbols"
Name string // last FQN segment, e.g. "UpsertSymbols"
Kind SymbolKind
File string // repo-relative path; empty for external packages
Span Span
Sig string // declaration signature text, single line
DocHash string // sha256 hex of the doc comment, "" if none
}
Symbol is one node of the structure graph.
type SymbolKind ¶
type SymbolKind string
SymbolKind classifies a Symbol row.
const ( KindFunction SymbolKind = "function" KindMethod SymbolKind = "method" KindType SymbolKind = "type" KindConst SymbolKind = "const" KindVar SymbolKind = "var" // KindPackage represents a package/module grouping node. Internal // packages use their repo-relative directory as FQN; external ones use // the import path as written. KindPackage SymbolKind = "package" )
The symbol kinds extractors produce.