First crate of the Pet UI v1 line (feat/pet-ui-v1 branch). Ships: ## Schema (src/schema.rs — 213 LOC) Strongly-typed `PetManifest` covering: - identity (pet_name, user_name, addressing, languages) - voice (tone primary/secondary, humor style + frequency) - edge (profanity, directness, initiative) - appearance (base_shape, size, colours, eyes, expression, accessories) - room (theme, lighting, decor, time_sync) - privacy (public_profile, publish_allowed, share_dreams, share_garden) - interests[] (topic, depth, freshness, vault_path, last_refresh) - routines[] (kind, schedule, template, enabled) - forbidden (topics, tone_patterns) - meta (schema version, timestamps, tune_count) All enums serde-renamed to kebab-case for TOML-native feel. ## Validation (src/validate.rs — 180 LOC) 19-rule validator (R1–R19 per earlier spec). Errors **accumulate** — single validate() call surfaces every issue, not just the first. Covers: - schema version (R1) - name bounds (R2, R2) - languages ISO-639-1 (R4) - tone_secondary cardinality + no-primary-dup (R6) - profanity/language consistency (R10) - interest topic slug-safety (R12) - interest/forbidden contradiction (R14) - schedule grammar: HH:MM, dow-HH:MM, every-Nh, no-commit-for-Nh, N-errors-in-N-calls (R16) - empty-string guards (R18) - ISO-8601 timestamps (R19) - hex-colour sanity on appearance ## Overlay rendering (src/overlay.rs — 128 LOC) Pure function `system_prompt(&PetManifest) -> String`. Deterministic — same manifest → same bytes. Used as prompt-prefix by the runtime at spawn time. ## Identity (src/identity.rs — 117 LOC incl. 5 unit tests) Standard Ed25519 (RFC 8032) via ed25519-dalek. `user_id` = first 16 hex chars of blake3(public_key) — deterministic, 64-bit, URL-safe. Hex-string API for cross-boundary verify. No proprietary crypto, no matrix math. ## CLI (src/bin/kei-pet.rs — 110 LOC) - `kei-pet validate <path>` — parse + run R1–R19 - `kei-pet show <path>` — print rendered overlay - `kei-pet identity new` — generate + store ~/.keisei/identity.key (0600) - `kei-pet identity show` — print public key + user_id - `kei-pet tune` stub (Day 2 — /pet-tune skill lands full implementation) ## Tests - 23/23 integration (tests/validation_tests.rs) — one rejector per rule + accept cases for examples/minimal.toml and examples/full.toml + overlay smoke + multi-error accumulation guard - 5/5 unit (identity module) — keypair roundtrip, user_id determinism, sign/verify, hex API boundary - cargo test -p kei-pet --release: all green ## Examples - examples/minimal.toml — smallest valid manifest - examples/full.toml — every optional section populated ## Scope boundary (enforced by in-file doc comment in lib.rs) NO imports, references, or conceptual mentions of sibling research-grade IP. Identity is standard Ed25519. Cache/projection is standard CQRS. This crate ships as a clean MIT-licensable unit of the KeiSeiKit public surface. Day 2: /pet-setup 7-phase wizard skill that drives this crate via the CLI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
837 B
TOML
34 lines
837 B
TOML
# Minimal pet.toml — smallest valid manifest.
|
|
# Required: schema, identity (all 4 fields), voice (4 fields), edge (3 fields),
|
|
# forbidden (both arrays can be empty), meta (3 fields).
|
|
# Optional: appearance, room, privacy, interests, routines.
|
|
|
|
schema = 1
|
|
|
|
[identity]
|
|
pet_name = "Kei"
|
|
user_name = "Alex"
|
|
addressing = "by-name"
|
|
languages = ["en"]
|
|
|
|
[voice]
|
|
tone_primary = "neutral"
|
|
tone_secondary = []
|
|
humor_style = "none"
|
|
humor_frequency = "rare"
|
|
|
|
[edge]
|
|
profanity = "never"
|
|
profanity_languages = []
|
|
directness = "balanced"
|
|
initiative = "wait"
|
|
|
|
[forbidden]
|
|
topics = []
|
|
tone_patterns = []
|
|
|
|
[meta]
|
|
schema_version_written_by = "kei-pet 0.1.0"
|
|
created_at = "2026-04-23T12:30:00Z"
|
|
last_tuned = "2026-04-23T12:30:00Z"
|
|
tune_count = 0
|