schema

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckQuality

func CheckQuality(section, value string) []string

CheckQuality returns the messages for failed quality rules for section.

Types

type Command

type Command struct {
	Command     string `yaml:"command"`
	Description string `yaml:"description"`
}

Command is a runnable shell command with a description.

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 Links map[string]string

Links is an open map of name → URL.

type Maintainer

type Maintainer struct {
	Name string `yaml:"name"`
	Role string `yaml:"role,omitempty"`
}

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

type StructureEntry struct {
	Path        string `yaml:"path"`
	Description string `yaml:"description"`
}

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.

Jump to

Keyboard shortcuts

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