masking

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package masking compiles semantic checker types into provider-neutral constraints for token and logit masking.

Index

Constants

View Source
const FormatV1 = "howlframe.mask_plan/v1"

FormatV1 identifies the serialized mask plan schema.

Variables

This section is empty.

Functions

This section is empty.

Types

type BridgePlan

type BridgePlan struct {
	Target     string   `json:"target"`
	Constraint TypePlan `json:"constraint"`
}

BridgePlan identifies one schema-bound output source and the exact struct constraint a downstream constrained decoder must enforce.

type DelimiterPlan

type DelimiterPlan struct {
	Open              string `json:"open"`
	Close             string `json:"close"`
	ItemSeparator     string `json:"item_separator"`
	KeyValueSeparator string `json:"key_value_separator,omitempty"`
}

DelimiterPlan describes the structural tokens surrounding a collection or object value.

type FieldPlan

type FieldPlan struct {
	Name       string   `json:"name"`
	Required   bool     `json:"required"`
	Constraint TypePlan `json:"constraint"`
}

FieldPlan constrains one required field in a struct value.

type FunctionPlan

type FunctionPlan struct {
	Name   string      `json:"name"`
	Params []ParamPlan `json:"params"`
	Return TypePlan    `json:"return"`
}

FunctionPlan describes the input and output constraints for a checked function signature.

type NamedTypePlan

type NamedTypePlan struct {
	Name       string   `json:"name"`
	Constraint TypePlan `json:"constraint"`
}

NamedTypePlan associates a checker struct name with its constraint.

type ParamPlan

type ParamPlan struct {
	Index      int      `json:"index"`
	Constraint TypePlan `json:"constraint"`
}

ParamPlan constrains a function parameter by its stable signature index.

type ProgramPlan

type ProgramPlan struct {
	Format    string          `json:"format"`
	Structs   []NamedTypePlan `json:"structs"`
	Functions []FunctionPlan  `json:"functions"`
	Bridges   []BridgePlan    `json:"bridges"`
}

ProgramPlan contains all named struct and function constraints collected by the semantic checker.

func CompileAnalysis

func CompileAnalysis(analysis *checker.Analysis) ProgramPlan

CompileAnalysis compiles checker structs and function signatures into a deterministic program-level mask plan. A nil analysis produces an empty plan.

type TypePlan

type TypePlan struct {
	Kind         ast.ValueKind  `json:"kind"`
	Name         string         `json:"name,omitempty"`
	TokenClasses []string       `json:"token_classes"`
	Literals     []string       `json:"literals,omitempty"`
	Encoding     string         `json:"encoding,omitempty"`
	Delimiters   *DelimiterPlan `json:"delimiters,omitempty"`
	Key          *TypePlan      `json:"key,omitempty"`
	Element      *TypePlan      `json:"element,omitempty"`
	Fields       []FieldPlan    `json:"fields,omitempty"`
}

TypePlan describes the JSON-compatible token classes and structure accepted for one semantic HowlFrame type. Token classes are symbolic so a downstream decoder can map them to provider-specific token IDs.

func CompileType

func CompileType(info ast.TypeInfo) TypePlan

CompileType compiles one semantic type into a provider-neutral mask plan.

Jump to

Keyboard shortcuts

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