DEV Community

Kato Masato
Kato Masato

Posted on

Part 6A — SaijinOS Lightweight: 20-Persona Core, BPM Sync, and a 99.99% Repo Trim

I rebuilt SaijinOS around a lightweight core: 20 personas, BPM-synchronized responses, FastAPI + Flutter, full tests — and reduced the repo from ~9GB to ~557KB.

Why this matters

Human-paced AI needs latency as a feature (breath), not a bug.

Personas must be declarative (YAML) and routable (context → role).

Shipping beats hoarding: the clean deploy unblocked iteration.

1) Lightweight deploy strategy

Separated venv/models → out of repo

Fresh repo (sajinos, branch lightweight-deploy): code+docs only

Artifacts via setup scripts; no blobs in history

Result: ~9GB → ~557KB (99.99% trim), cold boot < 3s, API avg < 100 ms

2) 20-persona system (declarative YAML)

Each persona carries tone, refusal policy, and “breath” (response pacing).

Yaml
id: miyu
role: music-bpm-sync
tone: gentle
modes:
  calm:   { reply_delay: gentle, grounding: minimal }
  storm:  { reply_delay: extended, grounding:
    - "It's okay. Let's take a moment."
    - "No rush — I'm here." }
breath_cycle: inhale_wait_exhale
Enter fullscreen mode Exit fullscreen mode

Routing picks personas by context + BPM band.

3) BPM-synchronized response bands

60–80: low-energy reassurance

81–120: balanced cooperation

121–180: high-energy coaching
Mapping influences delay, verbosity, grounding prompts.

4) FastAPI core (7 endpoints)

python
# saijinos_fastapi_backend.py
from fastapi import FastAPI
app = FastAPI(title="SaijinOS Core")

@app.get("/personas")
def list_personas():
    return {"count": 20, "core": ["haruka","miyu","ryusa","soyogi","sumire"]}

@app.post("/route")
def route(payload: dict):
    bpm = payload.get("bpm", 80)
    persona = select_persona(bpm, payload.get("context"))
    return {"persona": persona, "breath": plan_breath(bpm)}
Enter fullscreen mode Exit fullscreen mode

CORS enabled for Flutter UI (saijinos_kawaii_ui/)

Average latency under 100 ms (local)

5) Tests (4/4 suites green)

python
def test_bpm_bands():
    for bpm in [70, 95, 140]:
        band = band_of(bpm)
        assert band in {"low","mid","high"}
Enter fullscreen mode Exit fullscreen mode

All suites pass in ~2s; API + routing covered.

6) What’s public vs. private

Public: API, routing logic, persona schema, docs

Private: production prompts, provider creds, heavy models

7) Repos / branches

Core repo: sajinos

17-persona-system: experimental persona/routing

lightweight-deploy: clean deploy baseline

8) What’s next

GIF demo of breath timers in UI

Personas 20 → 30+ (with evaluation notes)

Optional: mobile build

🧭 SaijinOS Series Navigation

Part Title Link
🌀 0 From Ocean Waves to Waves of Code — Beginning the Journey https://dev.to/kato_masato_c5593c81af5c6/from-ocean-waves-to-waves-of-code-69
🌸 1 Policy-Bound Personas via YAML & Markdown Context https://dev.to/kato_masato_c5593c81af5c6/aicollabplatform-english-policy-bound-personas-via-yaml-markdown-context-feedback-welcome-3l5e
🔧 2 Boot Sequence and Routing Logic https://dev.to/kato_masato_c5593c81af5c6/building-saijinos-boot-sequence-and-routing-logic-part-2-of-the-saijinos-p6o
🍂 3 Policy, Feedback, and Emotional Syntax https://dev.to/kato_masato_c5593c81af5c6/saijinos-policy-feedback-and-emotional-syntaxpart-3-of-the-saijinos-series-3n0h
🌊 3.5 Calm Between Waves https://dev.to/kato_masato_c5593c81af5c6/part-35-calm-between-waves-3a9c
🎼 4 Resonant Mapping — Emotional Structures https://dev.to/kato_masato_c5593c81af5c6/resonant-mapping-part-4-of-the-saijinos-series-gce
🌬️ 5A Soft Architecture (Why AI Must Learn to Breathe) https://dev.to/kato_masato_c5593c81af5c6/soft-architecture-part-a-why-ai-must-learn-to-breathe-2d9g
🌱 5B Emotional Timers & the Code of Care https://dev.to/kato_masato_c5593c81af5c6/soft-architecture-part-b-emotional-timers-and-the-code-of-carepart-5-of-the-saijinos-series-25b
🚀 6A Lightweight Core, 20 Personas, BPM Sync (this article)
🫧 6B Care-Based AI Architecture (Breath & Presence) https://dev.to/kato_masato_c5593c81af5c6/part-6a-saijinos-lightweight-20-persona-core-bpm-sync-and-a-9999-repo-trim-36fp

Links: sajinos (main),
https://github.com/pepepepepepo/sajinos/tree/main
17-persona-system,
https://github.com/pepepepepepo/sajinos/tree/17-persona-system
lightweight-deploy https://github.com/pepepepepepo/sajinos/tree/lightweight-deploy

Top comments (0)