identity

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package identity owns the stable identity policy for D&D non-player characters.

Index

Constants

View Source
const (
	// Policy identifies the complete identity comparison and ID derivation
	// policy. A future semantic change must use a new value.
	Policy = "dnd.npc_registry.identity.v1"
	// IdentityPolicy is an explicit alias for callers recording policy
	// fingerprints.
	IdentityPolicy = Policy
)

Variables

This section is empty.

Functions

func ComparisonKey

func ComparisonKey(value string) string

ComparisonKey returns the stable key used for NPC identity comparisons.

func DeriveID

func DeriveID(name string) string

DeriveID returns the deterministic ID for a canonical NPC name. Empty identity keys intentionally produce an empty ID so shape validation can report the missing identity instead of manufacturing one.

func IDFor

func IDFor(name string) string

IDFor is a concise alias for DeriveID for callers that work with IDs as values rather than derivation operations.

func IsValidID

func IsValidID(value string) bool

IsValidID reports whether value has the exact durable NPC ID syntax.

func NormalizeDisplay

func NormalizeDisplay(value string) string

NormalizeDisplay trims and collapses Unicode whitespace while retaining all other observed spelling and punctuation.

func ValidID

func ValidID(value string) bool

ValidID is an alias for IsValidID.

Types

type Issue

type Issue struct {
	Code        IssueCode
	RecordIndex int
	Value       string
}

Issue is an inspectable identity validation problem.

func ValidateList

func ValidateList(list dnd.NPCRegistry) []Issue

ValidateList validates the identity members of list.

func ValidateRegistry

func ValidateRegistry(npcs []dnd.NPC) []Issue

ValidateRegistry checks all identity invariants without changing the input. It accepts the NPC slice used by typed pipeline artifacts. Use ValidateList when the enclosing NPCRegistry is more convenient at the call site.

func (Issue) Error

func (i Issue) Error() string

Error makes an issue useful in simple callers while preserving its structured fields for aggregate diagnostics.

type IssueCode

type IssueCode string

IssueCode identifies one deterministic registry identity problem.

const (
	IssueEmptyCanonicalName IssueCode = "empty_canonical_name"
	IssueInvalidID          IssueCode = "invalid_id"
	IssueIDMismatch         IssueCode = "id_mismatch"
	IssueDuplicateCanonical IssueCode = "duplicate_canonical_identity"
	IssueDuplicateID        IssueCode = "duplicate_id"
)

Jump to

Keyboard shortcuts

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