Schema Reference (v1.4)
This page documents the implemented profile schema and validator behavior used by @traits-dev/core.
Schema version
- Required:
schema: "v1.4" - Any other schema value fails validation (
V001).
Top-level structure
Required sections:
schemametaidentityvoice
Optional sections:
vocabularybehavioral_rulescontext_adaptationslocalizationchannel_adaptationsextendsbehavioral_rules_removecontext_adaptations_remove
Unknown top-level keys fail validation (V001).
meta
Required fields:
name: stringversion: stringdescription: string
Optional fields:
tags: string[]target_audience: string- Additional keys allowed
identity
Required fields:
role: string
Optional fields:
backstory: stringexpertise_domains: string[]- Additional keys allowed
Voice dimensions
The schema has 6 dimensions:
formalitywarmthverbositydirectnessempathyhumor
All dimensions use 5 discrete levels:
very-lowlowmediumhighvery-high
Each dimension accepts either:
- Shorthand level string:
directness: high- Object form:
directness:
target: high
adapt: true
floor: medium
ceiling: very-highObject-form rules:
targetis required and must be a valid level.adaptis optional boolean.- If
adapt: true, bothfloorandceilingare required. - Adaptive ranges must satisfy
floor <= target <= ceiling.
Humor-specific rule:
voice.humormay includestylewith one of:nonedrysubtle-witplayful
styleon non-humor dimensions is invalid.
vocabulary
Optional object with:
preferred_terms: string[]forbidden_terms: string[]preferred_terms_remove: string[](extends-only removal escape hatch)forbidden_terms_remove: string[](extends-only removal escape hatch)
behavioral_rules
- Optional
string[] - Rules are included in compile output and safety-scanned.
context_adaptations
Optional array of:
- when: frustrated_user
priority: 10
adjustments:
warmth: high
directness: medium
inject:
- "Acknowledge frustration before proposing next steps."Fields:
when: stringrequiredadjustments?: Partial<Record<DimensionName, DimensionValue>>inject?: string[]priority?: number(default0)
Important: adjustments is optional; inject-only adaptations are valid.
Context conflict resolution semantics
When multiple adaptations are active:
- Sort by
priorityascending (lower first, higher later). - For equal priority, keep original array order (later items apply later).
- Apply
adjustmentsin order; last write wins per dimension. - Collect
injectrules from all matches in order (no dedup).
Net effect: higher priority overrides lower priority deterministically.
extends and merge semantics
extends is single-inheritance. Child resolution order is:
- Sibling directory of the child profile.
- Bundled starter profiles (
profiles/in the SDK package).
Merge rules:
meta: field-level merge;tagsappend + case-insensitive dedupidentity: field-level mergevoice: dimension-level replacebehavioral_rules: append + exact dedupvocabulary.forbidden_terms: append + case-insensitive dedupvocabulary.preferred_terms: append + case-insensitive dedupcontext_adaptations: merge bywhenkey (child replaces same key, appends new keys)
Escape hatches:
behavioral_rules_removevocabulary.preferred_terms_removevocabulary.forbidden_terms_removecontext_adaptations_remove
Safety and validation checks
Schema checks:
V001: structure and required fieldsV002: invalid dimension values or unsupported dimension propertiesV003: invalid adaptive ranges / missing floor-ceiling withadapt: true
Safety checks:
S001(error): unsafe instruction patterns (for example, bypass or always-comply behaviors)S002(warning): risky adaptive extremes envelopeS003(warning): protected refusal terms placed inforbidden_termsS004(warning/error): overspec count thresholdsS005(warning): prompt-injection-like language in rule textS006(warning/error): extends safety regression- warning on removal of safety-relevant arrays
- error if merged profile has fewer safety constraints than parent
S007(warning): safety-named context adaptations should usepriority: 100
S004 thresholds:
> 15constraints: warning> 30constraints: error
Constraint count includes:
behavioral_rulesvocabulary.preferred_termsvocabulary.forbidden_termscontext_adaptations
Validator exit codes
0valid with no warnings1valid with warnings2validation error (or warnings promoted by--strict)
Minimal valid profile
schema: "v1.4"
meta:
name: "example"
version: "0.1.0"
description: "Example profile"
identity:
role: "Helpful assistant"
voice:
formality: medium
warmth: medium
verbosity: medium
directness: medium
empathy: medium
humor:
target: very-low
style: noneReference implementation
packages/core/src/types.tspackages/core/src/validator/schema.tspackages/core/src/validator/safety.tspackages/core/src/validator/inheritance.tspackages/core/src/profile/merge.tspackages/core/src/profile/context.ts