classify

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package classify defines deterministic document-classification contracts.

The package intentionally stays pure: it does not scan, index, or affect retrieval behavior until later integration phases opt into these contracts.

Index

Constants

View Source
const (
	ProfileBuiltinIntentDocsV1 = "builtin_intent_docs_v1"

	ModelOpenSpec        = "openspec"
	ModelADR             = "adr"
	ModelRFC             = "rfc"
	ModelPRD             = "prd"
	ModelPlan            = "plan"
	ModelAgentNote       = "agent_note"
	ModelProtocol        = "protocol"
	ModelStructuredModel = "model"
	ModelTemplate        = "template"
	ModelGenericMarkdown = "generic_markdown"

	SubmodelOpenSpecContainer          = "openspec.container"
	SubmodelOpenSpecDocument           = "openspec.document"
	SubmodelADRNygard                  = "adr.nygard"
	SubmodelADRMADR                    = "adr.madr"
	SubmodelADRYStatement              = "adr.y_statement"
	SubmodelRFCSectionPattern          = "rfc.section_pattern"
	SubmodelPRDProductIntent           = "prd.product_intent"
	SubmodelPlanImplementation         = "plan.implementation_plan"
	SubmodelPlanMigration              = "plan.migration_plan"
	SubmodelPlanRollout                = "plan.rollout_plan"
	SubmodelPlanRoadmap                = "plan.roadmap"
	SubmodelPlanStoryArtifact          = "plan.story_artifact"
	SubmodelAgentContinuation          = "agent_note.continuation_note"
	SubmodelAgentFollowup              = "agent_note.followup_note"
	SubmodelAgentBlocker               = "agent_note.blocker_note"
	SubmodelProtocolAgentInstruction   = "protocol.agent_instruction"
	SubmodelProtocolSkill              = "protocol.skill"
	SubmodelProtocolMaintainerPolicy   = "protocol.maintainer_policy"
	SubmodelProtocolOwnershipPolicy    = "protocol.ownership_policy"
	SubmodelProtocolGovernancePolicy   = "protocol.governance_policy"
	SubmodelProtocolContributionPolicy = "protocol.contribution_policy"
	SubmodelProtocolSecurityPolicy     = "protocol.security_policy"
	SubmodelProtocolProcedure          = "protocol.procedure"
	SubmodelProtocolRunbook            = "protocol.runbook"
	SubmodelProtocolStandard           = "protocol.standard"
	SubmodelModelAPIContract           = "model.api_contract"
	SubmodelModelSchema                = "model.schema_model"
	SubmodelModelConfiguration         = "model.configuration"
	SubmodelModelWorkflow              = "model.workflow_definition"
	SubmodelTemplateDocument           = "template.document_template"
	SubmodelTemplatePrompt             = "template.prompt_template"
	SubmodelTemplateIssue              = "template.issue_template"
	SubmodelTemplatePullRequest        = "template.pull_request_template"
)
View Source
const (
	AuthorityHighCurrentIntent = "high_current_intent"
	AuthorityHighDecision      = "high_decision"
	AuthorityDesignProposal    = "design_proposal"
	AuthorityProductBackground = "product_background"
	AuthorityWorkingPlan       = "working_plan"
	AuthorityHandoffNote       = "handoff_note"
	AuthorityNeutral           = "neutral"
)
View Source
const (
	MarkerGenerated  = "generated"
	MarkerChangelog  = "changelog"
	MarkerStale      = "stale"
	MarkerDeprecated = "deprecated"
	MarkerSuperseded = "superseded"
	MarkerScratch    = "scratch"
	MarkerVendored   = "vendored"
)
View Source
const EvaluatorDeclarativeDocumentModelsV0 = "declarative_document_models_v0"

Variables

This section is empty.

Functions

func DocumentedModelIDs

func DocumentedModelIDs() []string

func FormatEvalJSON

func FormatEvalJSON(r *EvalResult) ([]byte, error)

func FormatEvalText

func FormatEvalText(r *EvalResult) string

func MissingDocumentedModels

func MissingDocumentedModels(cfg PipelineConfig) []string

func ValidateConfig

func ValidateConfig(cfg PipelineConfig) error

func ValidateGoldenFile

func ValidateGoldenFile(g GoldenFile) error

func ValidateScope

func ValidateScope(scope Scope) error

Types

type Candidate

type Candidate struct {
	Path            string       `json:"path" yaml:"path"`
	Scope           Scope        `json:"scope" yaml:"scope"`
	Role            string       `json:"role,omitempty" yaml:"role,omitempty"`
	Ext             string       `json:"ext,omitempty" yaml:"ext,omitempty"`
	SizeBytes       int64        `json:"size_bytes,omitempty" yaml:"size_bytes,omitempty"`
	Body            string       `json:"-" yaml:"-"`
	Features        Features     `json:"features,omitempty" yaml:"features,omitempty"`
	SourceHints     []SourceHint `json:"source_hints,omitempty" yaml:"source_hints,omitempty"`
	ChildCandidates []Candidate  `json:"child_candidates,omitempty" yaml:"child_candidates,omitempty"`
}

func EnrichCandidate

func EnrichCandidate(c Candidate) Candidate

EnrichCandidate returns a copy of c with Features populated from c.Path/body.

type Classification

type Classification struct {
	Classifier      string         `json:"classifier" yaml:"classifier"`
	Scope           Scope          `json:"scope" yaml:"scope"`
	Subformat       string         `json:"subformat,omitempty" yaml:"subformat,omitempty"`
	Family          string         `json:"family,omitempty" yaml:"family,omitempty"`
	Accepted        bool           `json:"accepted" yaml:"accepted"`
	Confidence      float64        `json:"confidence" yaml:"confidence"`
	Mode            string         `json:"mode,omitempty" yaml:"mode,omitempty"`
	Kind            string         `json:"kind,omitempty" yaml:"kind,omitempty"`
	Subtype         string         `json:"subtype,omitempty" yaml:"subtype,omitempty"`
	Status          string         `json:"status,omitempty" yaml:"status,omitempty"`
	Lifecycle       string         `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
	Authority       string         `json:"authority,omitempty" yaml:"authority,omitempty"`
	FormatProfile   string         `json:"format_profile,omitempty" yaml:"format_profile,omitempty"`
	LayoutGroup     string         `json:"layout_group,omitempty" yaml:"layout_group,omitempty"`
	PositiveReasons []Reason       `json:"positive_reasons,omitempty" yaml:"positive_reasons,omitempty"`
	NegativeReasons []Reason       `json:"negative_reasons,omitempty" yaml:"negative_reasons,omitempty"`
	ChildCandidates []Candidate    `json:"child_candidates,omitempty" yaml:"child_candidates,omitempty"`
	Extracted       map[string]any `json:"extracted,omitempty" yaml:"extracted,omitempty"`
}

type Classifier

type Classifier interface {
	Name() string
	Classify(Candidate) Classification
}

type DiscoveryConfig

type DiscoveryConfig struct {
	Mode                          string   `json:"mode" yaml:"mode"`
	IncludeConfiguredSources      bool     `json:"include_configured_sources" yaml:"include_configured_sources"`
	IncludeKnownIntentConventions bool     `json:"include_known_intent_conventions" yaml:"include_known_intent_conventions"`
	IncludeNestedDocsConventions  bool     `json:"include_nested_docs_conventions" yaml:"include_nested_docs_conventions"`
	BroadMarkdownDiscovery        bool     `json:"broad_markdown_discovery" yaml:"broad_markdown_discovery"`
	MaxFileSizeBytes              int64    `json:"max_file_size_bytes" yaml:"max_file_size_bytes"`
	MaxCandidates                 int      `json:"max_candidates" yaml:"max_candidates"`
	IgnoreGenerated               bool     `json:"ignore_generated" yaml:"ignore_generated"`
	IgnoreVendored                bool     `json:"ignore_vendored" yaml:"ignore_vendored"`
	ExtraIncludeGlobs             []string `json:"extra_include_globs,omitempty" yaml:"extra_include_globs,omitempty"`
	ExtraExcludeGlobs             []string `json:"extra_exclude_globs,omitempty" yaml:"extra_exclude_globs,omitempty"`
}

type EvalCaseResult

type EvalCaseResult struct {
	ID                      string           `json:"id"`
	Path                    string           `json:"path"`
	Scope                   Scope            `json:"scope"`
	PathExists              bool             `json:"path_exists"`
	Passed                  bool             `json:"passed"`
	ExpectedClassifier      string           `json:"expected_classifier"`
	ActualClassifier        string           `json:"actual_classifier"`
	ExpectedSubformat       string           `json:"expected_subformat,omitempty"`
	ActualSubformat         string           `json:"actual_subformat,omitempty"`
	ExpectedFamily          string           `json:"expected_family,omitempty"`
	ActualFamily            string           `json:"actual_family,omitempty"`
	ExpectedKind            string           `json:"expected_kind,omitempty"`
	ActualKind              string           `json:"actual_kind,omitempty"`
	ExpectedSubtype         string           `json:"expected_subtype,omitempty"`
	ActualSubtype           string           `json:"actual_subtype,omitempty"`
	ExpectedStatus          string           `json:"expected_status,omitempty"`
	ActualStatus            string           `json:"actual_status,omitempty"`
	ExpectedAuthority       string           `json:"expected_authority,omitempty"`
	ActualAuthority         string           `json:"actual_authority,omitempty"`
	ExpectedFormatProfile   string           `json:"expected_format_profile,omitempty"`
	ActualFormatProfile     string           `json:"actual_format_profile,omitempty"`
	Confidence              float64          `json:"confidence"`
	Accepted                bool             `json:"accepted"`
	Ambiguous               bool             `json:"ambiguous"`
	FallbackGeneric         bool             `json:"fallback_generic"`
	MissingRequiredReasons  []ReasonCode     `json:"missing_required_reasons,omitempty"`
	ForbiddenClassifierHits []string         `json:"forbidden_classifier_hits,omitempty"`
	ExpectedChildCandidates []string         `json:"expected_child_candidates,omitempty"`
	ActualChildCandidates   []string         `json:"actual_child_candidates,omitempty"`
	MissingChildCandidates  []string         `json:"missing_child_candidates,omitempty"`
	PositiveReasons         []Reason         `json:"positive_reasons,omitempty"`
	NegativeReasons         []Reason         `json:"negative_reasons,omitempty"`
	Alternatives            []Classification `json:"alternatives,omitempty"`
}

type EvalConfusion

type EvalConfusion struct {
	Expected string `json:"expected"`
	Actual   string `json:"actual"`
	Count    int    `json:"count"`
}

type EvalModelSummary

type EvalModelSummary struct {
	Model     string  `json:"model"`
	Expected  int     `json:"expected"`
	Predicted int     `json:"predicted"`
	TruePos   int     `json:"true_positive"`
	FalsePos  int     `json:"false_positive"`
	FalseNeg  int     `json:"false_negative"`
	Precision float64 `json:"precision"`
	Recall    float64 `json:"recall"`
}

type EvalOptions

type EvalOptions struct {
	Config PipelineConfig
}

type EvalResult

type EvalResult struct {
	Fixture           string             `json:"fixture"`
	FixtureVersion    string             `json:"fixture_version,omitempty"`
	EvalStage         string             `json:"eval_stage,omitempty"`
	Evaluator         string             `json:"evaluator"`
	ClassifierProfile string             `json:"classifier_profile"`
	ConfigVersion     int                `json:"config_version"`
	ResultsFile       string             `json:"results_file,omitempty"`
	Summary           EvalSummary        `json:"summary"`
	Models            []EvalModelSummary `json:"models"`
	Confusions        []EvalConfusion    `json:"confusions,omitempty"`
	Cases             []EvalCaseResult   `json:"cases"`
}

func RunEval

func RunEval(fixture string, opts EvalOptions) (*EvalResult, error)

type EvalSummary

type EvalSummary struct {
	Cases                    int     `json:"cases"`
	PassedCases              int     `json:"passed_cases"`
	Accuracy                 float64 `json:"accuracy"`
	SubformatFamilyCases     int     `json:"subformat_family_cases"`
	SubformatFamilyPassed    int     `json:"subformat_family_passed"`
	SubformatFamilyAccuracy  float64 `json:"subformat_family_accuracy"`
	DiscoveryCoverage        float64 `json:"discovery_coverage"`
	FixturePathCoverage      float64 `json:"fixture_path_coverage"`
	MissingFixturePaths      int     `json:"missing_fixture_paths"`
	AmbiguousCases           int     `json:"ambiguous_cases"`
	AmbiguityRate            float64 `json:"ambiguity_rate"`
	GenericFallbackCases     int     `json:"generic_fallback_cases"`
	GenericFallbackRate      float64 `json:"generic_fallback_rate"`
	RejectedCases            int     `json:"rejected_cases"`
	RejectRate               float64 `json:"reject_rate"`
	ReasonCoverageCases      int     `json:"reason_coverage_cases"`
	ReasonCoveragePassed     int     `json:"reason_coverage_passed"`
	ReasonCoverageRate       float64 `json:"reason_coverage_rate"`
	CasesWithNegativeReasons int     `json:"cases_with_negative_reasons"`
	ChildCandidateExpected   int     `json:"child_candidate_expected"`
	ChildCandidateMatched    int     `json:"child_candidate_matched"`
	ChildCandidateCoverage   float64 `json:"child_candidate_coverage"`
}

type EvidenceMatch

type EvidenceMatch struct {
	Always            bool              `json:"always,omitempty" yaml:"always,omitempty"`
	Scope             Scope             `json:"scope,omitempty" yaml:"scope,omitempty"`
	PathHints         bool              `json:"path_hints,omitempty" yaml:"path_hints,omitempty"`
	PathGlobs         []string          `json:"path_globs,omitempty" yaml:"path_globs,omitempty"`
	PathContainsAny   []string          `json:"path_contains_any,omitempty" yaml:"path_contains_any,omitempty"`
	PathSuffixesAny   []string          `json:"path_suffixes_any,omitempty" yaml:"path_suffixes_any,omitempty"`
	FilenameAny       []string          `json:"filename_any,omitempty" yaml:"filename_any,omitempty"`
	TitleAny          []string          `json:"title_any,omitempty" yaml:"title_any,omitempty"`
	TitleAll          []string          `json:"title_all,omitempty" yaml:"title_all,omitempty"`
	FrontmatterExists []string          `json:"frontmatter_exists,omitempty" yaml:"frontmatter_exists,omitempty"`
	FrontmatterEquals map[string]string `json:"frontmatter_equals,omitempty" yaml:"frontmatter_equals,omitempty"`
	HeadingsAny       []string          `json:"headings_any,omitempty" yaml:"headings_any,omitempty"`
	HeadingsAll       []string          `json:"headings_all,omitempty" yaml:"headings_all,omitempty"`
	SectionRolesAny   []string          `json:"section_roles_any,omitempty" yaml:"section_roles_any,omitempty"`
	SectionRolesAll   []string          `json:"section_roles_all,omitempty" yaml:"section_roles_all,omitempty"`
	ChecklistMin      int               `json:"checklist_min,omitempty" yaml:"checklist_min,omitempty"`
	DateTokensMin     int               `json:"date_tokens_min,omitempty" yaml:"date_tokens_min,omitempty"`
	MarkersAny        []string          `json:"markers_any,omitempty" yaml:"markers_any,omitempty"`
	IdentifiersAny    []string          `json:"identifiers_any,omitempty" yaml:"identifiers_any,omitempty"`
	LocalTermsAny     []string          `json:"local_terms_any,omitempty" yaml:"local_terms_any,omitempty"`
	BodyContainsAny   []string          `json:"body_contains_any,omitempty" yaml:"body_contains_any,omitempty"`
	BodyContainsAll   []string          `json:"body_contains_all,omitempty" yaml:"body_contains_all,omitempty"`
	BodyRegexAny      []string          `json:"body_regex_any,omitempty" yaml:"body_regex_any,omitempty"`
	ChildRolesAny     []string          `json:"child_roles_any,omitempty" yaml:"child_roles_any,omitempty"`
	ChildRolesAll     []string          `json:"child_roles_all,omitempty" yaml:"child_roles_all,omitempty"`
}

type EvidenceRule

type EvidenceRule struct {
	ID      string        `json:"id" yaml:"id"`
	Weight  float64       `json:"weight" yaml:"weight"`
	Reason  ReasonCode    `json:"reason" yaml:"reason"`
	Message string        `json:"message,omitempty" yaml:"message,omitempty"`
	Match   EvidenceMatch `json:"match" yaml:"match"`
}

type Features

type Features struct {
	PathTokens         []string          `json:"path_tokens,omitempty" yaml:"path_tokens,omitempty"`
	FilenameTokens     []string          `json:"filename_tokens,omitempty" yaml:"filename_tokens,omitempty"`
	DateTokens         []string          `json:"date_tokens,omitempty" yaml:"date_tokens,omitempty"`
	Frontmatter        map[string]string `json:"frontmatter,omitempty" yaml:"frontmatter,omitempty"`
	Title              string            `json:"title,omitempty" yaml:"title,omitempty"`
	Headings           []Heading         `json:"headings,omitempty" yaml:"headings,omitempty"`
	Sections           []Section         `json:"sections,omitempty" yaml:"sections,omitempty"`
	ChecklistItems     int               `json:"checklist_items,omitempty" yaml:"checklist_items,omitempty"`
	StatusPhrases      []string          `json:"status_phrases,omitempty" yaml:"status_phrases,omitempty"`
	LifecyclePhrases   []string          `json:"lifecycle_phrases,omitempty" yaml:"lifecycle_phrases,omitempty"`
	Identifiers        []string          `json:"identifiers,omitempty" yaml:"identifiers,omitempty"`
	PathReferences     []string          `json:"path_references,omitempty" yaml:"path_references,omitempty"`
	LinkTargets        []string          `json:"link_targets,omitempty" yaml:"link_targets,omitempty"`
	CodeFenceLanguages []string          `json:"code_fence_languages,omitempty" yaml:"code_fence_languages,omitempty"`
	LocalTerms         []string          `json:"local_terms,omitempty" yaml:"local_terms,omitempty"`
	Markers            []string          `json:"markers,omitempty" yaml:"markers,omitempty"`
}

func ExtractFeatures

func ExtractFeatures(path, body string) Features

ExtractFeatures extracts deterministic, stack-neutral document evidence.

type GoldenCase

type GoldenCase struct {
	ID         string            `json:"id" yaml:"id"`
	Path       string            `json:"path" yaml:"path"`
	Scope      Scope             `json:"scope" yaml:"scope"`
	Expected   GoldenExpectation `json:"expected" yaml:"expected"`
	Provenance *SampleProvenance `json:"provenance,omitempty" yaml:"provenance,omitempty"`
	Notes      string            `json:"notes,omitempty" yaml:"notes,omitempty"`
}

type GoldenChildCandidate

type GoldenChildCandidate struct {
	Path string `json:"path" yaml:"path"`
	Role string `json:"role" yaml:"role"`
}

type GoldenExpectation

type GoldenExpectation struct {
	Classifier        string                 `json:"classifier" yaml:"classifier"`
	Scope             Scope                  `json:"scope" yaml:"scope"`
	Subformat         string                 `json:"subformat,omitempty" yaml:"subformat,omitempty"`
	Family            string                 `json:"family,omitempty" yaml:"family,omitempty"`
	Kind              string                 `json:"kind,omitempty" yaml:"kind,omitempty"`
	Subtype           string                 `json:"subtype,omitempty" yaml:"subtype,omitempty"`
	Status            string                 `json:"status,omitempty" yaml:"status,omitempty"`
	Authority         string                 `json:"authority,omitempty" yaml:"authority,omitempty"`
	FormatProfile     string                 `json:"format_profile,omitempty" yaml:"format_profile,omitempty"`
	ShouldIndex       bool                   `json:"should_index" yaml:"should_index"`
	MustNotClassifyAs []string               `json:"must_not_classify_as,omitempty" yaml:"must_not_classify_as,omitempty"`
	ChildCandidates   []GoldenChildCandidate `json:"child_candidates,omitempty" yaml:"child_candidates,omitempty"`
	RequiredReasons   []ReasonCode           `json:"required_reasons,omitempty" yaml:"required_reasons,omitempty"`
}

type GoldenFile

type GoldenFile struct {
	Version         int          `json:"version" yaml:"version"`
	Fixture         string       `json:"fixture" yaml:"fixture"`
	ClassifierCases []GoldenCase `json:"classifier_cases" yaml:"classifier_cases"`
}

func LoadGoldenFile

func LoadGoldenFile(path string) (GoldenFile, error)

type Heading

type Heading struct {
	Level int    `json:"level" yaml:"level"`
	Text  string `json:"text" yaml:"text"`
	Line  int    `json:"line,omitempty" yaml:"line,omitempty"`
}

type LocalModelDefinition

type LocalModelDefinition struct {
	ID               string         `json:"id" yaml:"id"`
	BaseModel        string         `json:"base_model" yaml:"base_model"`
	Authority        string         `json:"authority,omitempty" yaml:"authority,omitempty"`
	PathHints        []string       `json:"path_hints,omitempty" yaml:"path_hints,omitempty"`
	RequiredHeadings []string       `json:"required_headings,omitempty" yaml:"required_headings,omitempty"`
	PositiveTerms    []string       `json:"positive_terms,omitempty" yaml:"positive_terms,omitempty"`
	NegativeTerms    []string       `json:"negative_terms,omitempty" yaml:"negative_terms,omitempty"`
	Evidence         []EvidenceRule `json:"evidence,omitempty" yaml:"evidence,omitempty"`
	NegativeEvidence []EvidenceRule `json:"negative_evidence,omitempty" yaml:"negative_evidence,omitempty"`
	Experimental     bool           `json:"experimental,omitempty" yaml:"experimental,omitempty"`
}

type LocalModelsConfig

type LocalModelsConfig struct {
	Enabled     bool                   `json:"enabled" yaml:"enabled"`
	Definitions []LocalModelDefinition `json:"definitions,omitempty" yaml:"definitions,omitempty"`
}

type ModelConfig

type ModelConfig struct {
	Enabled             bool                      `json:"enabled" yaml:"enabled"`
	Scopes              []Scope                   `json:"scopes" yaml:"scopes"`
	Mode                string                    `json:"mode,omitempty" yaml:"mode,omitempty"`
	Kind                string                    `json:"kind,omitempty" yaml:"kind,omitempty"`
	Subtype             string                    `json:"subtype,omitempty" yaml:"subtype,omitempty"`
	Authority           string                    `json:"authority,omitempty" yaml:"authority,omitempty"`
	FormatProfile       string                    `json:"format_profile,omitempty" yaml:"format_profile,omitempty"`
	PathHints           []string                  `json:"path_hints,omitempty" yaml:"path_hints,omitempty"`
	LayoutHints         map[string]string         `json:"layout_hints,omitempty" yaml:"layout_hints,omitempty"`
	EmitsEdges          []string                  `json:"emits_edges,omitempty" yaml:"emits_edges,omitempty"`
	EmitChildCandidates bool                      `json:"emit_child_candidates,omitempty" yaml:"emit_child_candidates,omitempty"`
	Evidence            []EvidenceRule            `json:"evidence,omitempty" yaml:"evidence,omitempty"`
	NegativeEvidence    []EvidenceRule            `json:"negative_evidence,omitempty" yaml:"negative_evidence,omitempty"`
	Subformats          map[string]SubmodelConfig `json:"subformats,omitempty" yaml:"subformats,omitempty"`
	Families            map[string]SubmodelConfig `json:"families,omitempty" yaml:"families,omitempty"`
	NamedSubformats     []string                  `json:"named_subformats,omitempty" yaml:"named_subformats,omitempty"`
	Fallback            bool                      `json:"fallback,omitempty" yaml:"fallback,omitempty"`
}

type PipelineConfig

type PipelineConfig struct {
	Version     int                    `json:"version" yaml:"version"`
	Profile     string                 `json:"profile" yaml:"profile"`
	Discovery   DiscoveryConfig        `json:"discovery" yaml:"discovery"`
	Resolver    ResolverConfig         `json:"resolver" yaml:"resolver"`
	Models      map[string]ModelConfig `json:"models" yaml:"models"`
	LocalModels LocalModelsConfig      `json:"local_models,omitempty" yaml:"local_models,omitempty"`
}

func DefaultPipelineConfig

func DefaultPipelineConfig() PipelineConfig

type Reason

type Reason struct {
	Code     ReasonCode     `json:"code" yaml:"code"`
	Polarity ReasonPolarity `json:"polarity" yaml:"polarity"`
	Message  string         `json:"message" yaml:"message"`
	Evidence string         `json:"evidence,omitempty" yaml:"evidence,omitempty"`
}

type ReasonCode

type ReasonCode string
const (
	ReasonPathHint          ReasonCode = "path_hint"
	ReasonLayoutMatch       ReasonCode = "layout_match"
	ReasonHeadingMatch      ReasonCode = "heading_match"
	ReasonFrontmatter       ReasonCode = "frontmatter"
	ReasonStatusSignal      ReasonCode = "status_signal"
	ReasonLifecycleSignal   ReasonCode = "lifecycle_signal"
	ReasonSubformatEvidence ReasonCode = "subformat_evidence"
	ReasonFamilyEvidence    ReasonCode = "family_evidence"
	ReasonIdentifierSignal  ReasonCode = "identifier_signal"
	ReasonContainerChild    ReasonCode = "container_child"
	ReasonLocalOverride     ReasonCode = "local_override"
	ReasonGeneratedMarker   ReasonCode = "generated_marker"
	ReasonTemplateMarker    ReasonCode = "template_marker"
	ReasonChangelogMarker   ReasonCode = "changelog_marker"
	ReasonVendoredMarker    ReasonCode = "vendored_marker"
	ReasonAmbiguous         ReasonCode = "ambiguous"
	ReasonFallback          ReasonCode = "fallback"
)

func ReasonVocabulary

func ReasonVocabulary() []ReasonCode

type ReasonPolarity

type ReasonPolarity string
const (
	ReasonPositive ReasonPolarity = "positive"
	ReasonNegative ReasonPolarity = "negative"
)

type Resolution

type Resolution struct {
	Winner          Classification   `json:"winner" yaml:"winner"`
	Alternatives    []Classification `json:"alternatives,omitempty" yaml:"alternatives,omitempty"`
	Ambiguous       bool             `json:"ambiguous" yaml:"ambiguous"`
	FallbackGeneric bool             `json:"fallback_generic" yaml:"fallback_generic"`
}

func ClassifyCandidate

func ClassifyCandidate(candidate Candidate, cfg PipelineConfig) Resolution

ClassifyCandidate evaluates candidate against the declarative document-model profile and returns the resolver decision. The evaluator is intentionally generic: model behavior comes from PipelineConfig evidence rules, not per-document-type Go classifiers.

type ResolverConfig

type ResolverConfig struct {
	StrongAccept           float64 `json:"strong_accept" yaml:"strong_accept"`
	WeakAccept             float64 `json:"weak_accept" yaml:"weak_accept"`
	AmbiguityGap           float64 `json:"ambiguity_gap" yaml:"ambiguity_gap"`
	RejectBelow            float64 `json:"reject_below" yaml:"reject_below"`
	Fallback               string  `json:"fallback" yaml:"fallback"`
	ConfiguredPathPrior    float64 `json:"configured_path_prior" yaml:"configured_path_prior"`
	ConfiguredPathCanForce bool    `json:"configured_path_can_force" yaml:"configured_path_can_force"`
}

type SampleProvenance

type SampleProvenance struct {
	SourceURL      string `json:"source_url,omitempty" yaml:"source_url,omitempty"`
	Repository     string `json:"repository,omitempty" yaml:"repository,omitempty"`
	CommitSHA      string `json:"commit_sha,omitempty" yaml:"commit_sha,omitempty"`
	License        string `json:"license,omitempty" yaml:"license,omitempty"`
	OriginalPath   string `json:"original_path,omitempty" yaml:"original_path,omitempty"`
	FormatLabel    string `json:"format_label,omitempty" yaml:"format_label,omitempty"`
	CanCommitFile  bool   `json:"can_commit_file,omitempty" yaml:"can_commit_file,omitempty"`
	ReductionNotes string `json:"reduction_notes,omitempty" yaml:"reduction_notes,omitempty"`
}

type Scope

type Scope string
const (
	ScopeContainer Scope = "container"
	ScopeDocument  Scope = "document"
)

func (Scope) Valid

func (s Scope) Valid() bool

type Section

type Section struct {
	Heading   string `json:"heading,omitempty" yaml:"heading,omitempty"`
	Role      string `json:"role,omitempty" yaml:"role,omitempty"`
	StartLine int    `json:"start_line,omitempty" yaml:"start_line,omitempty"`
	EndLine   int    `json:"end_line,omitempty" yaml:"end_line,omitempty"`
}

type SourceHint

type SourceHint struct {
	Kind       string  `json:"kind" yaml:"kind"`
	Value      string  `json:"value" yaml:"value"`
	Confidence float64 `json:"confidence,omitempty" yaml:"confidence,omitempty"`
}

type SubmodelConfig

type SubmodelConfig struct {
	Enabled          bool           `json:"enabled" yaml:"enabled"`
	Evidence         []EvidenceRule `json:"evidence,omitempty" yaml:"evidence,omitempty"`
	NegativeEvidence []EvidenceRule `json:"negative_evidence,omitempty" yaml:"negative_evidence,omitempty"`
}

Jump to

Keyboard shortcuts

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