Documentation
¶
Index ¶
- type AuditEntry
- type Block
- type Constraint
- type Content
- type Contract
- type DecoError
- type DocRef
- type ErrorCode
- type ErrorCodeRegistry
- type ErrorDocsGenerator
- type ErrorFormatter
- type Graph
- type Issue
- type Location
- type Node
- type Ref
- type RefLink
- type Related
- type Reviewer
- type Scenario
- type Section
- type SortedInterfaceMap
- type SortedStringMap
- type Step
- type StepType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp" yaml:"timestamp"`
NodeID string `json:"node_id" yaml:"node_id"`
Operation string `json:"operation" yaml:"operation"` // create, update, delete, set, append, unset, move, baseline
User string `json:"user" yaml:"user"`
ContentHash string `json:"content_hash,omitempty" yaml:"content_hash,omitempty"`
Before map[string]interface{} `json:"before,omitempty" yaml:"before,omitempty"`
After map[string]interface{} `json:"after,omitempty" yaml:"after,omitempty"`
}
AuditEntry represents a single entry in the audit log. It tracks changes to nodes over time (who, what, when).
func (*AuditEntry) Validate ¶
func (a *AuditEntry) Validate() error
Validate checks that all required fields are present and valid.
type Block ¶
type Block struct {
Type string `json:"type"` // table, rule, param, mechanic, list, etc.
Data map[string]interface{} `json:"data,omitempty"`
}
Block represents a content block within a section. Block fields (except 'type') are stored in Data map and written as inline YAML fields.
func (Block) MarshalYAML ¶
MarshalYAML implements custom YAML marshaling for Block. It writes Data fields as inline block fields (not nested under 'data:'). Keys are sorted for deterministic output (important for content hashing).
type Constraint ¶
type Constraint struct {
Expr string `json:"expr" yaml:"expr"` // CEL expression
Message string `json:"message" yaml:"message"` // Error message if constraint fails
Scope string `json:"scope" yaml:"scope"` // Which nodes this applies to (e.g., "all", "mechanic", "systems/*")
}
Constraint defines a validation rule that must be satisfied. Constraints use CEL (Common Expression Language) for validation.
func (*Constraint) Validate ¶
func (c *Constraint) Validate() error
Validate checks that all required fields are present.
type Content ¶
type Content struct {
Sections []Section `json:"sections" yaml:"sections"`
}
Content holds the structured content sections of a node.
type Contract ¶
type Contract struct {
Name string `json:"name" yaml:"name"`
Scenario string `json:"scenario" yaml:"scenario"`
Given []string `json:"given,omitempty" yaml:"given,omitempty"`
When []string `json:"when,omitempty" yaml:"when,omitempty"`
Then []string `json:"then,omitempty" yaml:"then,omitempty"`
}
Contract represents a Gherkin-style scenario or acceptance criteria.
type DecoError ¶
type DecoError struct {
Code string
Summary string
Detail string
Location *Location
Context []string
Suggestion string
Related []Related
}
DecoError represents a structured error following Rust-like error patterns
type DocRef ¶
type DocRef struct {
Path string `json:"path" yaml:"path"`
Keywords []string `json:"keywords,omitempty" yaml:"keywords,omitempty"`
Context string `json:"context,omitempty" yaml:"context,omitempty"`
}
DocRef represents a reference to an external markdown file.
type ErrorCodeRegistry ¶
type ErrorCodeRegistry struct {
// contains filtered or unexported fields
}
ErrorCodeRegistry maintains a registry of all error codes
func NewErrorCodeRegistry ¶
func NewErrorCodeRegistry() *ErrorCodeRegistry
NewErrorCodeRegistry creates a new error code registry with all defined codes
func (*ErrorCodeRegistry) AllCodes ¶
func (r *ErrorCodeRegistry) AllCodes() []ErrorCode
AllCodes returns all registered error codes
func (*ErrorCodeRegistry) ByCategory ¶
func (r *ErrorCodeRegistry) ByCategory(category string) []ErrorCode
ByCategory returns all error codes in a specific category
func (*ErrorCodeRegistry) Categories ¶
func (r *ErrorCodeRegistry) Categories() []string
Categories returns all unique categories
type ErrorDocsGenerator ¶
type ErrorDocsGenerator struct {
// contains filtered or unexported fields
}
ErrorDocsGenerator generates markdown documentation for error codes
func NewErrorDocsGenerator ¶
func NewErrorDocsGenerator(registry *ErrorCodeRegistry) *ErrorDocsGenerator
NewErrorDocsGenerator creates a new documentation generator
func (*ErrorDocsGenerator) GenerateCodeList ¶
func (g *ErrorDocsGenerator) GenerateCodeList() string
GenerateCodeList generates a simple list of all codes
func (*ErrorDocsGenerator) GenerateDetailedMarkdown ¶
func (g *ErrorDocsGenerator) GenerateDetailedMarkdown() string
GenerateDetailedMarkdown generates detailed markdown with examples
func (*ErrorDocsGenerator) GenerateMarkdown ¶
func (g *ErrorDocsGenerator) GenerateMarkdown() string
GenerateMarkdown generates markdown documentation for all error codes
type ErrorFormatter ¶
type ErrorFormatter struct {
// contains filtered or unexported fields
}
ErrorFormatter formats DecoError objects in a Rust-like style
func NewErrorFormatter ¶
func NewErrorFormatter() *ErrorFormatter
NewErrorFormatter creates a new error formatter with color enabled by default
func (*ErrorFormatter) Format ¶
func (f *ErrorFormatter) Format(err DecoError) string
Format formats a single DecoError into a human-readable string
func (*ErrorFormatter) FormatMultiple ¶
func (f *ErrorFormatter) FormatMultiple(errors []DecoError) string
FormatMultiple formats multiple errors
func (*ErrorFormatter) FormatWithSource ¶
func (f *ErrorFormatter) FormatWithSource(err DecoError, sourceLines []string) string
FormatWithSource formats a DecoError with source code context
func (*ErrorFormatter) SetColor ¶
func (f *ErrorFormatter) SetColor(enabled bool)
SetColor enables or disables color output
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a collection of nodes with efficient lookup. It provides methods for adding, retrieving, and iterating over nodes.
func (*Graph) Add ¶
Add adds a node to the graph. Returns an error if a node with the same ID already exists.
func (*Graph) Get ¶
Get retrieves a node by ID. Returns the node and true if found, or a zero-value node and false if not found.
type Issue ¶
type Issue struct {
ID string `json:"id" yaml:"id"`
Description string `json:"description" yaml:"description"`
Severity string `json:"severity" yaml:"severity"` // low, medium, high, critical
Location string `json:"location" yaml:"location"` // path to field (e.g., "content.sections[0]")
Resolved bool `json:"resolved" yaml:"resolved"`
}
Issue represents a tracked TBD or question within a node. Issues mark areas that need clarification or resolution.
type Node ¶
type Node struct {
// Core metadata
ID string `json:"id" yaml:"id"`
Kind string `json:"kind" yaml:"kind"` // mechanic, system, feature, etc.
Version int `json:"version" yaml:"version"` // Incremented on updates
Status string `json:"status" yaml:"status"` // draft, approved, deprecated, etc.
Title string `json:"title" yaml:"title"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
// Source location (set during load, not serialized)
SourceFile string `json:"-" yaml:"-"`
// Raw YAML content (set during load, not serialized) - used for line number tracking
RawContent []byte `json:"-" yaml:"-"`
// References to other nodes
Refs Ref `json:"refs,omitempty" yaml:"refs,omitempty"`
// Structured content sections
Content *Content `json:"content,omitempty" yaml:"content,omitempty"`
// Tracked TBDs and questions
Issues []Issue `json:"issues,omitempty" yaml:"issues,omitempty"`
// External doc references
Docs []DocRef `json:"docs,omitempty" yaml:"docs,omitempty"`
// Optional fields
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
Glossary map[string]string `json:"glossary,omitempty" yaml:"glossary,omitempty"`
Contracts []Contract `json:"contracts,omitempty" yaml:"contracts,omitempty"`
LLMContext string `json:"llm_context,omitempty" yaml:"llm_context,omitempty"`
Constraints []Constraint `json:"constraints,omitempty" yaml:"constraints,omitempty"`
Reviewers []Reviewer `json:"reviewers,omitempty" yaml:"reviewers,omitempty"`
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
}
Node represents a design node in the game design document. Nodes are the core building blocks of a GDD, containing metadata, references to other nodes, structured content, and tracked issues.
func (Node) MarshalYAML ¶
MarshalYAML implements custom YAML marshaling for Node. It ensures Glossary and Custom maps are serialized with sorted keys.
type Ref ¶
type Ref struct {
Uses []RefLink `json:"uses,omitempty" yaml:"uses,omitempty"`
Related []RefLink `json:"related,omitempty" yaml:"related,omitempty"`
EmitsEvents []string `json:"emits_events,omitempty" yaml:"emits_events,omitempty"`
Vocabulary []string `json:"vocabulary,omitempty" yaml:"vocabulary,omitempty"`
}
Ref holds references from one node to other nodes. It tracks dependencies, relationships, events, and shared vocabulary.
type RefLink ¶
type RefLink struct {
Target string `json:"target" yaml:"target"`
Context string `json:"context,omitempty" yaml:"context,omitempty"`
Resolved bool `json:"resolved,omitempty" yaml:"resolved,omitempty"`
}
RefLink represents a single reference to another node with optional context.
type Reviewer ¶
type Reviewer struct {
Name string `json:"name" yaml:"name"` // reviewer email/username
Timestamp time.Time `json:"timestamp" yaml:"timestamp"` // when approved
Version int `json:"version" yaml:"version"` // version that was approved
Note string `json:"note,omitempty" yaml:"note,omitempty"` // optional comment
}
Reviewer represents an approval record for a node version.
type Scenario ¶
type Scenario struct {
Name string // Scenario name
Description string // Scenario description text
Given []Step // Preconditions
When []Step // Actions
Then []Step // Expected outcomes
}
Scenario represents a parsed contract scenario with structured steps. This is the validation-ready form of the YAML Contract type.
func ParseContract ¶
ParseContract converts a YAML Contract into a validation-ready Scenario.
func ParseContracts ¶
ParseContracts converts multiple YAML Contracts into Scenarios.
func (*Scenario) AllNodeRefs ¶
AllNodeRefs returns all unique node references across all steps.
type Section ¶
type Section struct {
Name string `json:"name" yaml:"name"`
Blocks []Block `json:"blocks" yaml:"blocks"`
}
Section represents a logical section in the node content.
type SortedInterfaceMap ¶
type SortedInterfaceMap map[string]interface{}
SortedInterfaceMap wraps map[string]interface{} for deterministic YAML output. Keys are sorted alphabetically when marshaling to YAML.
func (SortedInterfaceMap) MarshalYAML ¶
func (m SortedInterfaceMap) MarshalYAML() (interface{}, error)
type SortedStringMap ¶
SortedStringMap wraps map[string]string for deterministic YAML output. Keys are sorted alphabetically when marshaling to YAML.
func (SortedStringMap) MarshalYAML ¶
func (m SortedStringMap) MarshalYAML() (interface{}, error)
type Step ¶
type Step struct {
Text string // The raw step text
NodeRefs []string // Node IDs referenced in this step (extracted from @node.id patterns)
StepType StepType // Given, When, or Then
StepNumber int // Position within its type (1-indexed)
}
Step represents a single Given/When/Then step in a contract scenario. Steps can reference nodes using the @node.id syntax.
func (*Step) ValidateStep ¶
ValidateStep checks that a step is well-formed.