surfacearrangement

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version            = 1
	ResolverVersion    = 1
	MaximumItemCount   = 12
	MaximumStackHeight = 3
)

Variables

This section is empty.

Functions

func ContentHash

func ContentHash(spec Spec) string

ContentHash is the SHA-256 of normalized compact JSON with spec_hash blank, matching the established Spatial Contract hashing convention.

func Marshal

func Marshal(spec Spec) ([]byte, error)

Marshal returns stable, normalized, indented JSON terminated by a newline.

func Normalize

func Normalize(spec *Spec)

Normalize canonicalizes all hash-relevant values without inventing required identifiers, versions, member counts, or preset choices.

func Validate

func Validate(spec Spec) error

Types

type Member

type Member struct {
	DescriptorID    string  `json:"descriptor_id"`
	MinimumCount    int     `json:"minimum_count"`
	MaximumCount    int     `json:"maximum_count"`
	SelectionWeight float64 `json:"selection_weight"`
	AffinityGroup   string  `json:"affinity_group"`
}

Member describes one eligible descriptor and its count range in an arrangement. SelectionWeight is a normalized, relative preference; it does not relax any geometry or support validation.

type Preset

type Preset string
const (
	PresetNeat      Preset = "Neat"
	PresetInUse     Preset = "InUse"
	PresetScattered Preset = "Scattered"
)

type Spec

type Spec struct {
	SurfaceArrangementVersion int      `json:"surface_arrangement_version"`
	ArrangementID             string   `json:"arrangement_id"`
	TargetElementID           string   `json:"target_element_id"`
	TargetFrameID             string   `json:"target_frame_id"`
	Members                   []Member `json:"members"`
	Preset                    Preset   `json:"preset"`
	Amount                    float64  `json:"amount"`
	Orderliness               float64  `json:"orderliness"`
	Grouping                  float64  `json:"grouping"`
	Stacking                  float64  `json:"stacking"`
	EdgeMargin                float64  `json:"edge_margin"`
	MaxStackHeight            int      `json:"max_stack_height"`
	SeedOffset                int64    `json:"seed_offset"`
	ResolverVersion           int      `json:"resolver_version"`
	SpecHash                  string   `json:"spec_hash"`
}

Spec is independent from Spatial Contract v1. It describes how already approved support interactions may be composed on a target surface.

func Decode

func Decode(data []byte) (Spec, error)

Decode rejects unknown fields and trailing JSON, normalizes stable fields, and strictly verifies the required spec_hash. Draft authoring and repair tools must use DecodeForHash so the validate path cannot bless an unhashed document by inventing its integrity value.

func DecodeForHash

func DecodeForHash(data []byte) (Spec, error)

DecodeForHash is the schema-strict parsing path for recomputing a spec hash. It validates raw values but replaces (rather than verifies) a missing or stale embedded spec_hash.

func Load

func Load(path string) (Spec, error)

func LoadForHash

func LoadForHash(path string) (Spec, error)

LoadForHash loads and validates a spec while intentionally ignoring an embedded spec_hash. It is used by the read-only hash command so callers can calculate the replacement for a stale hash without weakening validation.

Jump to

Keyboard shortcuts

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