KeiSeiKit-1.0/_primitives/_rust
Denis Parfionovich d1467b8611 feat(kei-pet): Day 1 — persona manifest parse + validate + overlay + Ed25519 identity
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>
2026-04-23 21:29:13 +08:00
..
firewall-diff feat(primitives): 2 Rust verification cubes 2026-04-21 21:00:01 +08:00
kei-agent-runtime refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
kei-artifact Merge feat/v0.16.1-polish — dynamic schema + mode matrix Phase 3.6 2026-04-22 15:13:05 +08:00
kei-atom-discovery feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
kei-auth sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-brain-view feat(wave16): 5 parallel agents — ledger v6 + prune dedupe + brain-view clusters + fork-watch hook + three-role pipeline 2026-04-23 18:53:58 +08:00
kei-cache feat(r2): new kei-cache crate — deterministic result cache 2026-04-23 05:55:13 +08:00
kei-capability feat(e2): kei-capability fork subcommand + lineage stamping 2026-04-23 10:21:45 +08:00
kei-changelog feat(primitives): kei-docs-scaffold shell + kei-changelog Rust 2026-04-21 21:01:28 +08:00
kei-chat-store feat(a): Store::open multi-schema — kei-chat-store sessions fully engine-owned 2026-04-23 14:27:15 +08:00
kei-conflict-scan feat(primitives): 4 Rust crates for deep-sleep — conflict-scan, refactor-engine, graph-check, store 2026-04-22 08:28:22 +08:00
kei-content-store feat(w12a): sister re-migration — content-store campaigns promoted to engine 2026-04-23 14:44:31 +08:00
kei-crossdomain feat(a): Store::open multi-schema — kei-chat-store sessions fully engine-owned 2026-04-23 14:27:15 +08:00
kei-curator chore(rust): misc schema/main refactor in 8 crates (assorted CP splits) 2026-04-22 13:36:17 +08:00
kei-diff feat(wave13): kei-diff + kei-scheduler + kei-watch primitives 2026-04-23 15:51:42 +08:00
kei-discover feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
kei-dna-index refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
kei-entity-store refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
kei-forge feat(stream-f): kei-forge pure-Rust templating — eliminate shell-out 2026-04-23 01:21:00 +08:00
kei-fork fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
kei-graph-check feat(primitives): 4 Rust crates for deep-sleep — conflict-scan, refactor-engine, graph-check, store 2026-04-22 08:28:22 +08:00
kei-hibernate feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
kei-ledger fix(ledger): DNA UNIQUE constraint + v5 migration (HIGH audit) 2026-04-23 15:45:43 +08:00
kei-ledger-sign fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
kei-memory sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-migrate feat(primitives): kei-migrate Rust universal migration runner 2026-04-21 20:35:29 +08:00
kei-pet feat(kei-pet): Day 1 — persona manifest parse + validate + overlay + Ed25519 identity 2026-04-23 21:29:13 +08:00
kei-pipe feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
kei-provision sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-prune feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
kei-refactor-engine fix(kei-refactor-engine): retract 'git apply-ready' claim (F1 RELEASE BLOCKER) 2026-04-22 13:36:17 +08:00
kei-replay feat(w9e): NEW kei-replay crate — reconstruct spawn from DNA 2026-04-23 13:34:16 +08:00
kei-router chore(rust): misc schema/main refactor in 8 crates (assorted CP splits) 2026-04-22 13:36:17 +08:00
kei-runtime fix(p1-integration): validate.rs allows _schemas/fragments $ref + drop additionalProperties on fragment-composed atom schemas 2026-04-23 04:53:26 +08:00
kei-sage feat(a): Store::open multi-schema — kei-chat-store sessions fully engine-owned 2026-04-23 14:27:15 +08:00
kei-scheduler feat(wave13): kei-diff + kei-scheduler + kei-watch primitives 2026-04-23 15:51:42 +08:00
kei-search-core chore(rust): misc schema/main refactor in 8 crates (assorted CP splits) 2026-04-22 13:36:17 +08:00
kei-shared refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
kei-social-store feat(w12a): sister re-migration — content-store campaigns promoted to engine 2026-04-23 14:44:31 +08:00
kei-spawn fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
kei-store refactor(v0.22): kei-store AsyncBackend trait + shared tokio runtime (Track B) 2026-04-22 21:06:50 +08:00
kei-task feat(a): Store::open multi-schema — kei-chat-store sessions fully engine-owned 2026-04-23 14:27:15 +08:00
kei-watch feat(wave13): kei-diff + kei-scheduler + kei-watch primitives 2026-04-23 15:51:42 +08:00
keisei fix(tests): repair 2 missing closing braces from v0.22 Track-A↔Track-C merge 2026-04-22 21:16:22 +08:00
mock-render refactor(mock-render): split main.rs 227 LOC into 4 cubes (F5a Constructor Pattern) 2026-04-22 13:36:17 +08:00
ssh-check feat(primitives): 2 Rust verification cubes 2026-04-21 21:00:01 +08:00
tokens-sync feat(primitives): 3 Rust cubes — mock-render, visual-diff, tokens-sync 2026-04-21 21:07:45 +08:00
visual-diff feat(primitives): 3 Rust cubes — mock-render, visual-diff, tokens-sync 2026-04-21 21:07:45 +08:00
.gitignore feat(primitives): 2 Rust verification cubes 2026-04-21 21:00:01 +08:00
Cargo.lock feat(kei-pet): Day 1 — persona manifest parse + validate + overlay + Ed25519 identity 2026-04-23 21:29:13 +08:00
Cargo.toml feat(kei-pet): Day 1 — persona manifest parse + validate + overlay + Ed25519 identity 2026-04-23 21:29:13 +08:00