textmachine/backend/internal/seed/seed.go

96 lines
4.5 KiB
Go

// Package seed is the SCHEMA of a book's glossary seed file — the YAML artifact that
// carries curated terms into the memory bank.
//
// It is deliberately a schema and its READERS, and nothing else: no loading policy, no validation, no
// store types. The strict decoders in decode.go belong here because the KEY SET is the format — a key
// the schema does not have is a typo, and dropping it silently is the defect backlog row 212 records —
// and because two readers share each document, so the strictness has to sit where the format does.
// Two subsystems meet on this file and must not depend on each other —
// the miner WRITES it (the mined delta is emitted as a seed the operator reviews) and
// the memory bank READS it (loadGlossarySeed validates and materializes store rows).
// Sharing the struct is the mechanism that keeps the emitted delta loadable by the very
// loader `translate` runs: a field added on one side cannot silently drift from the
// other, and SeedLint dry-runs the real loader over an emitted delta.
//
// The yaml tags ARE the file format (operator-authored seeds live in the book's data
// directory, outside git); renaming a Go field is safe, changing a tag is a data-format
// break.
package seed
// File is a whole seed YAML document.
type File struct {
Terms []Term `yaml:"terms"`
// Voices and Addresses are the two D21 record types added by pack-19. They are OWNER-CURATED only —
// no miner emits them — so they have no counterpart on the mined-delta side of this schema.
Voices []Voice `yaml:"voices"`
Addresses []Address `yaml:"addresses"`
}
// Voice is one character's voice profile for a chapter window (research/15 §1.5). Src/Sense name the
// glossary term this profile belongs to — the same stable key the bank uses everywhere else.
type Voice struct {
Src string `yaml:"src"`
Sense string `yaml:"sense"`
// Register is one line of register+tone; SelfRef is the character's own self-designation (the field
// D7 reserved as first_person); AddressDefault is the T/V default outside the pair registry.
Register string `yaml:"register"`
SelfRef string `yaml:"self_ref"`
AddressDefault string `yaml:"address_default"` // informal|formal
LexiconMarkers []string `yaml:"lexicon_markers"`
NGLexicon []string `yaml:"ng_lexicon"`
Exemplars []string `yaml:"exemplars"`
Brightness string `yaml:"brightness"`
SinceCh int `yaml:"since_ch"`
UntilCh int `yaml:"until_ch"`
}
// Address is one entry of the ты/вы transition journal: the register the SPEAKER uses toward the
// ADDRESSEE over a chapter window. A register change is a new row with a non-overlapping window, never
// an edit of this one — the switch is a story event.
type Address struct {
Speaker string `yaml:"speaker"`
SpeakerSense string `yaml:"speaker_sense"`
Addressee string `yaml:"addressee"`
AddresseeSense string `yaml:"addressee_sense"`
// Register is ABSTRACT (informal|formal): which target surfaces realise it is target data, so a
// target language without a T/V distinction activates nothing.
Register string `yaml:"register"`
Form string `yaml:"form"`
Closeness string `yaml:"closeness"`
SinceCh int `yaml:"since_ch"`
UntilCh int `yaml:"until_ch"`
}
// Term is one seeded term: the source surface, its rendering and the metadata the bank
// needs to inject it (gender/speech/declension, spoiler window, trust status, aliases).
type Term struct {
Src string `yaml:"src"`
Dst string `yaml:"dst"`
Type string `yaml:"type"`
Sense string `yaml:"sense"`
Gender string `yaml:"gender"`
Speech string `yaml:"speech"`
Decl *Decl `yaml:"decl"`
TranslitPolicy string `yaml:"translit_policy"`
FirstPerson string `yaml:"first_person"`
NicknameTranslation string `yaml:"nickname_translation"`
SinceCh int `yaml:"since_ch"`
UntilCh int `yaml:"until_ch"`
Status string `yaml:"status"`
AllowShort bool `yaml:"allow_short"`
Note string `yaml:"note"`
Aliases []Alias `yaml:"aliases"`
}
// Decl carries the target-side declension forms used by the post-check (an invariant
// term has none by design).
type Decl struct {
Invariant bool `yaml:"invariant"`
Forms []string `yaml:"forms"`
}
// Alias is an additional source surface that fires for the same term.
type Alias struct {
Alias string `yaml:"alias"`
Type string `yaml:"type"`
}