Documentation
¶
Overview ¶
Package schema defines the CONTEXT.yaml v1 data model, parser, and validator.
The canonical source of truth for the schema is context-yaml.schema.json. The Go types here mirror it; if you change one, change the other.
Index ¶
- func CheckQuality(section, value string) []string
- type Command
- type Constraint
- type Context
- type Convention
- type Decision
- type Dependency
- type Identity
- type Links
- type Maintainer
- type Ownership
- type ParseResult
- type Risk
- type ScoreResult
- type SectionResult
- type StructureEntry
- type ValidationError
- type Working
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckQuality ¶
CheckQuality returns the messages for failed quality rules for section.
Types ¶
type Constraint ¶
type Constraint struct {
Content string `yaml:"content"`
Scope string `yaml:"scope,omitempty"`
Why string `yaml:"why,omitempty"`
}
Constraint is a rule engineers or AI must not violate.
type Context ¶
type Context struct {
Ktext string `yaml:"ktext" json:"ktext"`
Identity Identity `yaml:"identity" json:"identity"`
Constraints []Constraint `yaml:"constraints,omitempty" json:"constraints,omitempty"`
Decisions []Decision `yaml:"decisions,omitempty" json:"decisions,omitempty"`
Conventions []Convention `yaml:"conventions,omitempty" json:"conventions,omitempty"`
Risks []Risk `yaml:"risks,omitempty" json:"risks,omitempty"`
Dependencies []Dependency `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
Working *Working `yaml:"working,omitempty" json:"working,omitempty"`
Links Links `yaml:"links,omitempty" json:"links,omitempty"`
Ownership *Ownership `yaml:"ownership,omitempty" json:"ownership,omitempty"`
X map[string]any `yaml:"x,omitempty" json:"x,omitempty"`
}
Context is the top-level CONTEXT.yaml document.
type Convention ¶
type Convention struct {
Rule string `yaml:"rule"`
Scope string `yaml:"scope,omitempty"`
Why string `yaml:"why,omitempty"`
Reference string `yaml:"reference,omitempty"`
}
Convention is a coding or process rule for the project.
type Decision ¶
type Decision struct {
Title string `yaml:"title"`
Rationale string `yaml:"rationale"`
Date string `yaml:"date,omitempty"`
Status string `yaml:"status,omitempty"`
Reference string `yaml:"reference,omitempty"`
}
Decision records an architectural choice and its rationale.
type Dependency ¶
type Dependency struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Why string `yaml:"why,omitempty"`
}
Dependency is an outgoing connection from this project to another system.
type Identity ¶
type Identity struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Type string `yaml:"type,omitempty"`
Purpose string `yaml:"purpose,omitempty"`
Status string `yaml:"status,omitempty"`
}
Identity describes what the project is.
type Maintainer ¶
Maintainer is a named person responsible for the project.
type Ownership ¶
type Ownership struct {
Team string `yaml:"team,omitempty"`
Escalation string `yaml:"escalation,omitempty"`
Maintainers []Maintainer `yaml:"maintainers,omitempty"`
}
Ownership records who maintains the project.
type ParseResult ¶
type ParseResult struct {
Doc *Context
Errors []ValidationError
}
ParseResult is the outcome of parsing and validating a CONTEXT.yaml document.
func Parse ¶
func Parse(src []byte) ParseResult
Parse reads a CONTEXT.yaml document from src, validates it against the embedded JSON Schema, and returns the result.
func (ParseResult) OK ¶
func (r ParseResult) OK() bool
OK reports whether parsing and validation succeeded.
type Risk ¶
type Risk struct {
Content string `yaml:"content"`
Severity string `yaml:"severity"` // "high" | "medium" | "low"
Mitigation string `yaml:"mitigation,omitempty"`
}
Risk is a known vulnerability, tech-debt item, or operational risk.
type ScoreResult ¶
type ScoreResult struct {
Score int
Sections []SectionResult
Fixes []string
}
ScoreResult is the output of ScoreDocument.
func ScoreDocument ¶
func ScoreDocument(doc *Context) ScoreResult
ScoreDocument scores a parsed Context document. Total max is 100.
type SectionResult ¶
type SectionResult struct {
Name string `json:"name"`
Score int `json:"score"`
Max int `json:"max"`
Status string `json:"status"` // "pass" | "warn" | "fail"
Details []string `json:"details,omitempty"`
Fixes []string `json:"fixes,omitempty"`
}
SectionResult holds the score for one top-level section of a CONTEXT.yaml.
type StructureEntry ¶
StructureEntry describes a path within the project.
type ValidationError ¶
type ValidationError struct {
Path []string // JSON Pointer segments, e.g. ["identity", "url"]
Message string
}
ValidationError is a single schema violation with a location and message.
type Working ¶
type Working struct {
Commands []Command `yaml:"commands,omitempty"`
Structure []StructureEntry `yaml:"structure,omitempty"`
Notes []string `yaml:"notes,omitempty"`
}
Working holds information a developer or LLM needs to operate in the codebase.