schema

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package schema provides the plan schema for proactive architecture validation.

Package schema provides centralized JSON schema versioning and validation for AILANG's AI-first features.

Index

Constants

View Source
const (
	ErrorV1     = "ailang.error/v1"
	TestV1      = "ailang.test/v1"
	DecisionsV1 = "ailang.decisions/v1"
	PlanV1      = "ailang.plan/v1"
	EffectsV1   = "ailang.effects/v1"
)

Schema version constants

Variables

View Source
var CompactMode = false

Compact option for JSON output

Functions

func Accepts

func Accepts(got, wantPrefix string) bool

Accepts checks if a schema version is compatible with the expected version. Supports forward compatibility within major versions (e.g., v1.x accepts v1.0).

func FormatJSON

func FormatJSON(data []byte) ([]byte, error)

FormatJSON formats JSON according to compact mode setting

func MarshalDeterministic

func MarshalDeterministic(v any) ([]byte, error)

MarshalDeterministic marshals a value to JSON with sorted keys for deterministic output.

func MustValidate

func MustValidate(schemaName string, v any) error

MustValidate validates a value against a schema. Currently a no-op placeholder for future schema validation.

func SetCompactMode

func SetCompactMode(enabled bool)

SetCompactMode enables or disables compact JSON output

Types

type FuncPlan

type FuncPlan struct {
	Name    string   `json:"name"`              // Function name
	Type    string   `json:"type"`              // Type signature (e.g., "int -> int")
	Effects []string `json:"effects,omitempty"` // Effects (e.g., ["IO", "FS"])
	Module  string   `json:"module"`            // Module path where function is defined
}

FuncPlan describes a function signature

type ModulePlan

type ModulePlan struct {
	Path    string   `json:"path"`    // e.g., "myapp/core"
	Exports []string `json:"exports"` // Names of exported items
	Imports []string `json:"imports"` // Import paths (e.g., "std/io")
}

ModulePlan describes a module's structure

type Plan

type Plan struct {
	Schema       string       `json:"schema"`                 // "ailang.plan.v1"
	Goal         string       `json:"goal"`                   // Human-readable goal
	Modules      []ModulePlan `json:"modules"`                // Module structure
	Types        []TypePlan   `json:"types"`                  // Type definitions
	Functions    []FuncPlan   `json:"functions"`              // Function signatures
	Effects      []string     `json:"effects,omitempty"`      // Effects used across modules
	Dependencies []string     `json:"dependencies,omitempty"` // External dependencies
}

Plan represents a structured architecture plan for validation and scaffolding

func NewPlan

func NewPlan(goal string) *Plan

NewPlan creates a new plan with the correct schema version

func PlanFromJSON

func PlanFromJSON(data []byte) (*Plan, error)

FromJSON loads a plan from JSON bytes

func (*Plan) AddEffect

func (p *Plan) AddEffect(effect string)

AddEffect adds an effect to the plan's effect list

func (*Plan) AddFunction

func (p *Plan) AddFunction(name, typeSignature, module string, effects []string)

AddFunction adds a function signature to the plan

func (*Plan) AddModule

func (p *Plan) AddModule(path string, exports, imports []string)

AddModule adds a module to the plan

func (*Plan) AddType

func (p *Plan) AddType(name, kind, definition, module string)

AddType adds a type definition to the plan

func (*Plan) ToJSON

func (p *Plan) ToJSON() ([]byte, error)

ToJSON converts the plan to deterministic JSON

type TypePlan

type TypePlan struct {
	Name       string `json:"name"`       // Type name (e.g., "Option")
	Kind       string `json:"kind"`       // "adt", "record", "alias"
	Definition string `json:"definition"` // AILANG type syntax
	Module     string `json:"module"`     // Module path where type is defined
}

TypePlan describes a type to be defined

Jump to

Keyboard shortcuts

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