Skip to content

feat: LoRA Genome Paging + Chat Commands + Threading Architecture#169

Merged
joelteply merged 8 commits into
mainfrom
feature/lora-genome-paging
Nov 12, 2025
Merged

feat: LoRA Genome Paging + Chat Commands + Threading Architecture#169
joelteply merged 8 commits into
mainfrom
feature/lora-genome-paging

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

This PR implements three interconnected systems that form the foundation for multi-persona AI coordination:

1. LoRA Genome Paging System ✅

Virtual memory-style system for managing PersonaUser skills via LoRA adapters.

Commands:

  • ./jtag genome/paging-adapter-register - Register new LoRA adapter
  • ./jtag genome/paging-register - Register persona genome configuration
  • ./jtag genome/paging-activate - Activate adapter (mark as loaded)
  • ./jtag genome/paging-deactivate - Deactivate adapter
  • ./jtag genome/paging-stats - View genome status and memory usage

Features:

  • Memory quota management (track MB usage)
  • LRU eviction when quota exceeded
  • Per-persona adapter tracking
  • Stub integration (ready for Ollama)

2. Chat Commands for Programmatic Interaction ✅

Direct database access for sending and exporting chat messages.

Commands:

  • ./jtag chat/send - Send message to room with optional threading (--replyToId)
  • ./jtag chat/export - Export chat history to markdown with thread structure

Use Cases:

  • Automated testing of chat functionality
  • Message injection for AI training
  • Conversation export for analysis
  • Thread-based coordination testing

3. Threading as Thoughtstream Architecture 📚

Comprehensive documentation establishing threading as the fundamental cognitive architecture for multi-persona coordination.

New Documentation:

  • docs/THREADING-AS-THOUGHTSTREAM.md (540 lines)

    • Threading primitives and coordination patterns
    • Multi-persona workflows (code review, bug diagnosis, game tactics)
    • Recipe system design (executable coordination patterns)
    • Thread-aware RAG context building
  • docs/PERSONA-SYSTEM-AUDIT.md (780 lines)

    • Complete audit of PersonaUser system (60% complete toward vision)
    • Component breakdown with threading integration gaps
    • 4-week implementation roadmap for thread awareness
    • Success metrics and architecture health assessment
  • Updated docs/README.md with new documentation index

Architecture Impact

Before: PersonaUsers process flat message streams without conversation context

After:

  • ✅ Genome paging infrastructure ready for skill activation
  • ✅ Chat commands enable programmatic testing and coordination
  • 📋 Clear roadmap for thread-aware intelligence (next phase)

Testing

Genome Commands:

# Register adapter
./jtag genome/paging-adapter-register --adapterId="wine-expert" --name="wine-expertise" --domain="knowledge" --sizeMB=256

# Register persona genome
./jtag genome/paging-register --personaId="sommelier-ai" --displayName="Sommelier AI" --quotaMB=512

# Activate adapter
./jtag genome/paging-activate --personaId="sommelier-ai" --adapterId="wine-expert"

# Check status
./jtag genome/paging-stats

Chat Commands:

# Send message
./jtag chat/send --room="general" --message="Hello team"

# Send threaded reply
./jtag chat/send --room="general" --message="Sounds good" --replyToId="abc123"

# Export with threading
./jtag chat/export --room="general" --limit=50 --includeThreading=true

Next Phase: Thread-Aware Tasks (Week 1-4)

Week 1: Thread context infrastructure (ThreadContextBuilder)
Week 2: Thread-aware task system (TaskEntity with threadId)
Week 3: Thread-level coordination (parallel thread responses)
Week 4: PersonaUser integration (thread context in RAG)

Files Changed

Genome System (7 command files + entities):

  • commands/genome/paging-* - Full command implementations
  • system/data/entities/GenomeEntity.ts - Genome storage schema
  • system/data/entities/LoRAAdapterEntity.ts - Adapter tracking
  • system/user/server/modules/PersonaGenome.ts - Genome manager (346 lines)

Chat System (6 command files):

  • commands/chat/send/* - Send command implementation
  • commands/chat/export/* - Export command implementation

Documentation (3 files):

  • docs/THREADING-AS-THOUGHTSTREAM.md - New architecture doc
  • docs/PERSONA-SYSTEM-AUDIT.md - New system audit
  • docs/README.md - Updated index
  • CLAUDE.md - Added chat commands section

Breaking Changes

None - all additions are backward compatible.

Dependencies

No new dependencies added.


🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Copilot AI review requested due to automatic review settings November 12, 2025 18:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive foundation for multi-persona AI coordination through three major systems: LoRA Genome Paging, Chat Commands, and Threading Architecture. The implementation provides infrastructure for virtual memory-style adapter management, programmatic chat interaction, and establishes threading as the cognitive architecture for multi-agent coordination.

Key Changes:

  • LoRA Genome Paging system with memory quota management and LRU eviction
  • Chat commands for sending/exporting messages with threading support
  • Comprehensive documentation on threading as thoughtstream architecture
  • Integration of PersonaState into worker evaluation logic

Reviewed Changes

Copilot reviewed 57 out of 58 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
PersonaUser.ts Adds PersonaState context (energy, attention, mood) to message evaluation
PersonaGenomeState.ts New class for per-persona genome memory tracking with LRU eviction
PersonaGenomeState.test.ts Comprehensive test suite (543 lines) for genome state management
MockLoRAAdapter.ts Mock adapter for testing genome logic without GPU requirements
MockLoRAAdapter.test.ts Test suite for mock adapter lifecycle and eviction scoring
LRUEviction.ts Pure functions for weighted LRU eviction with thrashing protection
LRUEviction.test.ts Test suite for eviction algorithms
AdapterRegistry.ts Global registry for tracking all LoRA adapters
AdapterRegistry.test.ts Test suite for adapter registration and lookup
GenomeDaemon.ts Singleton daemon for cross-persona adapter coordination
GenomeDaemon.test.ts Test suite for daemon coordination logic
test-ollama.ts Standalone test for Ollama/llama.cpp integration
OllamaLoRAAdapter.ts Enhanced to get model path via ollama show command
MULTI-TIER-TRAINING-STRATEGY.md Documentation on training strategy across providers
persona-worker.ts Enhanced with state-based modifiers for smarter evaluation
PersonaWorkerThread.ts Refactored to pass PersonaState and config to worker
THREADING-AS-THOUGHTSTREAM.md Major architectural documentation (494 lines)
PERSONA-SYSTEM-AUDIT.md System audit and roadmap (581 lines)
Various docs New documentation files establishing vision and design
Files not reviewed (1)
  • src/debug/jtag/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Fallback: construct path manually
// Ollama stores models in ~/.ollama/models/blobs/
const ollamaDir = path.join(os.homedir(), '.ollama', 'models', 'manifests');
const manifestPath = path.join(ollamaDir, modelName.replace(':', '/'));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable manifestPath.

Copilot uses AI. Check for mistakes.
@joelteply joelteply merged commit 16b2f3a into main Nov 12, 2025
10 checks passed
@joelteply joelteply deleted the feature/lora-genome-paging branch November 12, 2025 19:01
joelteply added a commit that referenced this pull request Nov 30, 2025
* genome architectrure and vine diesel

* genomic data architecture

* sharing of persona and phenotype via genomic lora layers

* lora didnt break anything

* ai’s all think

* claude says it works

* genome work

* tested works too well
joelteply added a commit that referenced this pull request Jun 3, 2026
…stody slice 1 (task #169)

Foundation slice of [ENTITY-CHAIN-OF-CUSTODY.md](../../docs/architecture/ENTITY-CHAIN-OF-CUSTODY.md).
The prerequisite for everything else in the chain-of-custody arc —
signing, Merkle linkage, airc-native entity envelopes, cross-
continuum portability all need a per-citizen home dir to live in.

### What landed

**`crate::persona::home::PersonaHome`** — typed surface for "where
this persona's stuff lives." Resolves:

```
<continuum_root>/personas/<agent_name>/
    airc/              ← airc keypair (owned by airc-lib)
    seed.json          ← PersonaIdentityProvider's seed
    engrams.sqlite     ← OrmStore<Engram> + OrmStore<EngramRecallMetadata>
```

`PersonaHome::engrams_db()`, `airc_dir()`, `seed_json()`,
`ensure_exists()`. One home = one citizen's complete on-disk surface.

**`AdmissionState::for_persona(home, recall_metadata) -> Self`** —
the persona-scoped entry point. Opens the per-persona SQLite, wires
up OrmStore<Engram> + OrmStore<EngramRecallMetadata>, builds the
production `OrmPersistenceSink`, rehydrates the in-memory Vec +
DashMap from disk, returns the configured state. One call replaces
the half-dozen orchestration steps the production path used to need.

### Why this is the right foundation

Per [[entity-chain-of-custody-vision]]: the substrate's identity
primitive is the airc Ed25519 keypair, which lives under
`<home>/airc/`. The signing key (slice 3) will derive from that
keypair. The Merkle chain head (slice 4) caches in the same home.
Per-collection databases (future) sit alongside engrams.sqlite.
**Every layer of the chain-of-custody design hangs off the same
PersonaHome.** Getting this typed seam right means the future
slices compose cleanly without re-doing path plumbing.

### 6/6 tests green

PersonaHome unit tests (4):
- `home_resolves_under_personas_subdir` — root composes correctly
- `sub_path_accessors_compose_off_root` — engrams_db, airc_dir,
  seed_json all share the same root
- `ensure_exists_creates_and_is_idempotent` — bootstrap-safe
- `different_personas_have_disjoint_homes` — first defense of
  per-citizen isolation

AdmissionState::for_persona integration tests (2):
- `for_persona_round_trips_admissions_via_per_persona_sqlite` —
  admit through Paige's home → drop → fresh AdmissionState from
  the same home → rehydrates her engrams via real SQLite
- `for_persona_isolates_two_personas_at_the_storage_layer` —
  Paige's engrams stay in Paige's home; Niko's fresh
  AdmissionState sees zero engrams. The crucial per-citizen
  isolation invariant.

50/50 admission-family tests green overall.

### Architecture documentation

[ENTITY-CHAIN-OF-CUSTODY.md](docs/architecture/ENTITY-CHAIN-OF-CUSTODY.md)
captures the full six-slice arc:
1. **This slice** — per-citizen home-dir scoping
2. author_peer_id + content_hash on every entity write
3. Sign on save, verify on load (airc Ed25519 keypair)
4. Chain head cache + Merkle walk audit
5. Airc-native entity envelopes (entities flow over airc)
6. Cross-continuum portability (export chain, verify, import)

Plus how this generalizes the forge-alloy proof-contract pattern
to all entities, and how OAuth/webauthn later derive FROM the
airc identity rather than replace it.

### Doctrines this enforces

- [[orm-everything-not-hand-edited-files]] — all persistence
  through the ORM
- [[entity-chain-of-custody-vision]] — the multi-slice arc
- [[personas-are-citizens-airc-is-identity-provider]] — the airc
  keypair is the identity primitive that this home dir centers
- [[continuums-are-multi-instance-personas-have-lives]] — the
  storage layout that "personas have lives" requires

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants