Help us shape the future of Go! Take the 2026 Go Developer Survey

spec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package spec implements `hadron spec ...` — an opinionated layer over the generic node/edge commands for maintaining product-spec nodes that follow the loc-as-citation convention: a spec's loc IS its citation number, <module>:<feature>:<rule>:<flow> (e.g. msg:010:02:03), and each colon level is a real parent/child node. The scheme, the frozen module codes, and the append-only number ledger are governed by a `register` node in the target memory. This package is general — it works on any memory following the convention, addressed by -m/--memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmdSpec

func NewCmdSpec(f *cmdutil.Factory) *cobra.Command

NewCmdSpec returns the `hadron spec` command group.

Types

type Citation

type Citation struct {
	Product string // 3 lowercase letters, "" in a flat corpus
	Module  string // 3 lowercase letters, "" for a bare product root
	Feature string // 3 digits, "" if absent
	Rule    string // 2 digits, "" if absent
	Flow    string // 2 digits, "" if absent
}

Citation is a parsed loc grammar. Flat (legacy): <module>[:<feature>[:<rule>[:<flow>]]] (e.g. msg:010:02). Product-rooted: <product>:<module>[:<feature>[:<rule>[:<flow>]]] (e.g. cli:cha:010:01).

func ParseCitation

func ParseCitation(s string) (Citation, error)

ParseCitation parses and validates a citation, returning a Usage error for any malformed segment. The rooting is inferred from segment 2's character class: a second alpha code ⇒ product-rooted (<product>:<module>:…); a 3-digit feature ⇒ flat (<module>:…). A lone alpha code parses as a flat module — callers that need a bare product root build the Citation directly.

func (Citation) Format

func (c Citation) Format() string

Format re-emits the colon form, including the product when present.

func (Citation) InheritedContractLoc

func (c Citation) InheritedContractLoc() (Citation, bool)

InheritedContractLoc returns the general-provisions contract this citation inherits — the reserved "zero" sibling at its own tier: a rule inherits its feature's :00, a feature inherits its module's :000, and a product-rooted module inherits its product's :gen. ok is false for a flow, a flat module root, a bare product root, or a contract itself (contracts are inheritance sources, not sinks).

func (Citation) IsContract

func (c Citation) IsContract() bool

IsContract reports whether this citation is a reserved general-provisions contract — a feature's rule `00`, a module's feature `000`, or a product's module `gen`. Its siblings at the same tier inherit it.

func (Citation) Level

func (c Citation) Level() int

Level is 0 (bare product root) .. 4 (flow); module is 1, feature 2, rule 3. The product field does not shift levels — a product's module root is still level 1 — so existing level-keyed logic is unchanged.

func (Citation) Parent

func (c Citation) Parent() (Citation, bool)

Parent returns the citation one level up: flow→rule→feature→module, and a product-rooted module→its product root. A flat module root and a bare product root have no parent.

func (Citation) String

func (c Citation) String() string

Jump to

Keyboard shortcuts

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