bss

Meta-Pet Starter 🧬

Working Demo: Identity Core + Genome System + Live Vitals (v5)


What’s Running Now

βœ… PrimeTail ID System

Naming rationale: We standardize on PrimeTail ID to emphasize the cryptographic identifier (vault/rotation/tail + hashes) rather than the visual crest. Formerly known as Prime-Tail Crest / PrimeTailId.

βœ… Genome Core (Red60/Blue60/Black60)

βœ… Interactive Conscious Jewble Hub (7 Items)

βœ… Visual Pet Sprite

βœ… HeptaCode v1 (Base-7 Identity)

βœ… Live Vitals System

βœ… Evolution Guidance

βœ… Offline-First

βœ… Archive Manager


Identity Glossary

Relationship: DNA β†’ hashes β†’ PrimeTailId crest β†’ HeptaCode visual/audio. The crest and HeptaCode always reference hashes, never raw DNA.

For a longer reference, see docs/identity-glossary.md.


File Structure

meta-pet/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ identity/
β”‚   β”‚   β”‚   β”œβ”€β”€ types.ts          # Core types
β”‚   β”‚   β”‚   β”œβ”€β”€ crest.ts          # PrimeTail ID minting
β”‚   β”‚   β”‚   └── hepta/
β”‚   β”‚   β”‚       β”œβ”€β”€ codec.ts      # Payload β†’ base-7
β”‚   β”‚   β”‚       β”œβ”€β”€ ecc.ts        # 6Γ—7 error correction
β”‚   β”‚   β”‚       β”œβ”€β”€ audio.ts      # HeptaCode β†’ crest chime playback
β”‚   β”‚   β”‚       └── index.ts      # heptaEncode42/Decode42
β”‚   β”‚   β”œβ”€β”€ genome/
β”‚   β”‚   β”‚   β”œβ”€β”€ types.ts          # Genome + trait types
β”‚   β”‚   β”‚   β”œβ”€β”€ encoder.ts        # Red60/Blue60/Black60 encoding
β”‚   β”‚   β”‚   β”œβ”€β”€ decoder.ts        # Trait derivation logic
β”‚   β”‚   β”‚   └── index.ts          # Public API
β”‚   β”‚   β”œβ”€β”€ addons/               # Crypto-secured addon system
β”‚   β”‚   β”‚   β”œβ”€β”€ types.ts          # Addon interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ crypto.ts         # ECDSA P-256 signing/verification
β”‚   β”‚   β”‚   β”œβ”€β”€ catalog.tsx       # 12 addon templates (6 standard + 6 premium)
β”‚   β”‚   β”‚   β”œβ”€β”€ mint.ts           # Addon minting with dual signatures
β”‚   β”‚   β”‚   β”œβ”€β”€ store.ts          # Zustand inventory management
β”‚   β”‚   β”‚   β”œβ”€β”€ starter.ts        # Demo starter addon setup
β”‚   β”‚   β”‚   └── index.ts          # Public API
β”‚   β”‚   β”œβ”€β”€ lineage/              # Heraldic lineage system
β”‚   β”‚   β”‚   β”œβ”€β”€ types.ts          # Coat of arms types
β”‚   β”‚   β”‚   β”œβ”€β”€ generator.ts      # CoA generation, breeding, analysis
β”‚   β”‚   β”‚   └── index.ts          # Public API
β”‚   β”‚   └── store/
β”‚   β”‚       └── index.ts          # Zustand (vitals + genome + tick)
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ HUD.tsx               # Vitals + actions
β”‚   β”‚   β”œβ”€β”€ TraitPanel.tsx        # Genome trait display
β”‚   β”‚   β”œβ”€β”€ AuraliaMetaPet.tsx    # Main pet component (3000+ lines)
β”‚   β”‚   β”œβ”€β”€ AuraliaSprite.tsx     # Visual pet (SVG + genome-driven)
β”‚   β”‚   β”œβ”€β”€ HeptaTag.tsx          # 7-sided visual
β”‚   β”‚   β”œβ”€β”€ SeedOfLifeGlyph.tsx   # Sacred geometry
β”‚   β”‚   β”œβ”€β”€ addons/               # Addon UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ AddonRenderer.tsx       # SVG addon rendering + drag
β”‚   β”‚   β”‚   β”œβ”€β”€ AddonInventoryPanel.tsx # Inventory management UI
β”‚   β”‚   β”‚   β”œβ”€β”€ PetProfilePanel.tsx     # Profile with CoA + addons
β”‚   β”‚   β”‚   └── CryptoKeyDisplay.tsx    # Key pair display
β”‚   β”‚   └── lineage/              # Lineage UI components
β”‚   β”‚       └── CoatOfArmsRenderer.tsx  # SVG coat of arms rendering
β”‚   └── app/
β”‚       β”œβ”€β”€ page.tsx              # Main demo
β”‚       β”œβ”€β”€ pet/page.tsx          # Pet viewer with addons
β”‚       └── addons-demo/page.tsx  # Addon system demo

Run It

npm ci

# Optional: copy .env.example to .env.local and adjust NEXT_PUBLIC_SITE_URL
npm run dev

# Run checks
npm run lint
npm test
npm run build

Visit http://localhost:3000


Planning Docs

School Packaging Docs

MOSS60 Network Docs


What Works

1. Identity (Crest)

import { mintPrimeTailId, getDeviceHmacKey } from '@/lib/identity/crest';

const hmacKey = await getDeviceHmacKey();
const crest = await mintPrimeTailId({
  dna: 'ATGCCG...', // Your genome
  vault: 'blue',
  rotation: 'CW',
  tail: [12, 37, 5, 59],
  hmacKey
});

// crest.dnaHash = SHA-256 of DNA (visible)
// crest.mirrorHash = SHA-256 of reverse DNA
// crest.signature = HMAC(hashes + tail + vault + rotation)
// DNA itself NEVER leaves device!

2. HeptaCode (Base-7 Encoding)

import { heptaEncode42, playHepta } from '@/lib/identity/hepta';

const payload = {
  version: 1,
  preset: 'standard',
  vault: 'blue',
  rotation: 'CW',
  tail: [12, 37, 5, 59],
  epoch13: Math.floor(Date.now() / 60000) % 8192,
  nonce14: Math.floor(Math.random() * 16384)
};

const digits42 = await heptaEncode42(payload, hmacKey);
// Returns: readonly number[] (42 digits, base-7)

// Play the crest chime in the browser
await playHepta(digits42);

3. Genome System

import { encodeGenome, decodeGenome, hashGenome } from '@/lib/genome';

// Generate genome from DNA hashes
const genome = await encodeGenome(primeDNA, tailDNA);
// Returns: { red60, blue60, black60 } - 3 Γ— 60-digit base-7 arrays

// Derive all traits deterministically
const traits = decodeGenome(genome);
// Returns: { physical, personality, latent }

// Physical traits: body type, colors, pattern, texture, size, features
console.log(traits.physical.bodyType); // 'Spherical'
console.log(traits.physical.primaryColor); // '#4ECDC4'
console.log(traits.physical.features); // ['Horns', 'Tail Flame']

// Personality traits: temperament, energy, social, curiosity, etc.
console.log(traits.personality.temperament); // 'Gentle'
console.log(traits.personality.energy); // 70 (0-100)

// Latent traits: evolution path, rare abilities, potential
console.log(traits.latent.evolutionPath); // 'Chaos Trickster'
console.log(traits.latent.rareAbilities); // ['Telepathy', ...]

// For privacy: only store genome hashes
const hashes = await hashGenome(genome);
// Returns: { redHash, blueHash, blackHash } - SHA-256 hashes

4. Live Vitals

import { useStore } from '@/lib/store';

const vitals = useStore(s => s.vitals);
const feed = useStore(s => s.feed);
const startTick = useStore(s => s.startTick);

useEffect(() => {
  startTick(); // Begins real-time decay
}, []);

<button onClick={feed}>Feed</button>

5. Offline Archives & Sealed Exports

import { exportPetToJSON, importPetFromJSON, savePet } from '@/lib/persistence/indexeddb';
import { createSealedExport, importSealedExport, verifySealedExport } from '@/lib/persistence/sealed';
import { getDeviceHmacKey } from '@/lib/identity/crest';

// Regular JSON export (for debugging)
const petJSON = exportPetToJSON(snapshot);

// Sealed export (cryptographically signed for tamper-evidence)
const hmacKey = await getDeviceHmacKey();
const sealedExport = await createSealedExport(snapshot, hmacKey);

// Verify sealed export before importing
const verification = await verifySealedExport(sealedExport, hmacKey);
if (verification.valid) {
  const imported = await importSealedExport(sealedExport, hmacKey);
  await savePet(imported); // Restores to IndexedDB
}

6. Breeding System

import { breedPets, canBreed, predictOffspring, calculateSimilarity } from '@/lib/breeding';

// Check if two pets can breed (both must be at SPECIATION stage)
if (canBreed(pet1Evolution.state, pet2Evolution.state)) {
  // Preview possible offspring
  const preview = predictOffspring(pet1Genome, pet2Genome);
  console.log('Possible traits:', preview.possibleTraits);
  console.log('Prediction confidence:', preview.confidence);

  // Breed with different modes
  const balanced = breedPets(pet1Genome, pet2Genome, 'BALANCED'); // 50/50 mix
  const dominant = breedPets(pet1Genome, pet2Genome, 'DOMINANT'); // 70/30 split
  const mutation = breedPets(pet1Genome, pet2Genome, 'MUTATION'); // Random mutations

  // Check genetic similarity
  const similarity = calculateSimilarity(pet1Genome, pet2Genome);
  console.log('Parents are', similarity.toFixed(1), '% similar');

  // Access offspring data
  console.log('Offspring genome:', balanced.offspring);
  console.log('Inherited traits:', balanced.traits);
  console.log('Inheritance map:', balanced.inheritanceMap);
  console.log('Lineage key:', balanced.lineageKey);
}

7. Crypto-Secured Addon System

import { useAddonStore, mintAddon, WIZARD_HAT, generateAddonKeypair } from '@/lib/addons';

// Generate cryptographic keypairs
const userKeys = await generateAddonKeypair();
const issuerKeys = await generateAddonKeypair();

// Mint a new addon with dual signatures
const addon = await mintAddon(
  { addonTypeId: WIZARD_HAT.id, recipientPublicKey: userKeys.publicKey, edition: 1 },
  issuerKeys.privateKey, issuerKeys.publicKey, userKeys.privateKey
);

// Add to inventory and equip
const { addAddon, equipAddon } = useAddonStore();
await addAddon(addon);
equipAddon(addon.id);

// Drag-position customization
const { setAddonPosition, lockAddonPosition } = useAddonStore();
setAddonPosition(addon.id, 220, 150); // Custom position
lockAddonPosition(addon.id, true);     // Lock in place

Available Addons (12 templates): | Addon | Category | Rarity | Bonuses | Max Editions | |β€”β€”-|β€”β€”β€”-|——–|β€”β€”β€”|————–| | Wizard Hat | Headwear | Epic | +15 Curiosity, +10 Bond | 100 | | Wizard Staff | Weapon | Legendary | +20 Energy/Curiosity, +15 Bond, +10 Luck | 50 | | Celestial Crown | Headwear | Mythic | +25 All Stats, +20 Luck | 10 | | Shadow Cloak | Accessory | Rare | +5 Energy, +10 Bond | 200 | | Prismatic Aura | Aura | Epic | +10 Energy/Curiosity/Bond | 150 | | Floating Familiar | Companion | Legendary | +20 Bond, +15 Luck | 75 | | Holographic Vault | Effect | Mythic | +25 Bond, +20 Luck | 25 | | Ethereal Background | Effect | Mythic | +30 Energy, +25 Curiosity | 25 | | Quantum Data Flow | Effect | Mythic | +25 Energy, +30 Curiosity, +15 Luck | 25 | | Phoenix Wings | Accessory | Legendary | +30 Energy, +15 Curiosity, +20 Luck | 30 | | Crystal Heart | Companion | Epic | +35 Bond, +10 Energy | 50 | | Void Mask | Headwear | Mythic | +40 Curiosity, +15 Bond, +25 Luck | 15 |

8. Heraldic Lineage System

import { generateFounderCoatOfArms, breedCoatsOfArms, analyzeLineage, getBlason } from '@/lib/lineage';

// Generate founder coat of arms
const coa = generateFounderCoatOfArms(petId, seed);
console.log(getBlason(coa)); // "Azure, bearing a star Or, a lion Gules"

// Breed two coats of arms
const { offspring, inheritance } = breedCoatsOfArms(parent1Coa, parent2Coa, offspringId, seed);
console.log(`Generation ${offspring.generation} coat with ${offspring.charges.length} charges`);

// Analyze lineage
const analysis = analyzeLineage(offspring);
console.log(`Dominant colors: ${analysis.dominantTinctures.join(', ')}`);
console.log(`Inbreeding coefficient: ${analysis.inbreedingCoefficient}`);
console.log(`Lineage purity: ${(analysis.purity * 100).toFixed(1)}%`);

Heraldic Components:

9. Privacy Presets

The dashboard ships with three share-level presets that re-encode the 42-digit HeptaCode on demand:

Preset Share Level Best For
Stealth Tail digits only; crest metadata stays local. Solo play, hidden alt vaults.
Standard Vault + rotation broadcast; hashes remain private. Trusted circles, family swaps.
Radiant Full crest metadata + aura for discovery. Public pairing, community drops.

Changing the preset regenerates the digits with a fresh nonce and stores the choice in IndexedDB so autosave snapshots, exports, and re-imports maintain the same privacy stance.


Next Steps (From Master Build Prompt)

Phase 1: Complete Identity Layer

Phase 2: Game Loop βœ… COMPLETE

Phase 3: Vimana Integration βœ… COMPLETE

Phase 4: Endgame Features βœ… COMPLETE


Design Principles (B$S)

  1. DNA stays private – Only hashes + tail are ever shared
  2. One source, multi-modal – 42 digits render as color + geometry + tone
  3. Offline-first – Full gameplay without network
  4. Deterministic – Same genome always produces same traits
  5. Kid-safe – Parental mode, no ads, calm UX

Tech Stack


Current Status

Version 8 - Addon & Lineage Systems Complete βœ…

Phases 1-4 All Complete:

Known Issues:

Recent Additions (v8):


Master Build Prompt

Full spec: docs/master-build-prompt.pdf (attached by user)

TL;DR:


License

This project is licensed under the MIT License. See LICENSE.

Asset licensing

No separate asset license overrides are currently defined in this repository. Unless explicitly noted otherwise, assets checked into this repo are covered by the MIT License in /LICENSE.


Built with Same.new Docs Support