The Kernel Merge & MJN Emissions
Nine services became one process. 40,000 lines deleted. Then we built a token economy in one evening.
⚙️ Kernel Merge (#615, PR #631)
The biggest architectural change since launch. Nine standalone services — auth, pay, profile, registry, connections, chat, media, notify, www — consolidated into a single Next.js application: apps/kernel/.
- Phase 1–4: Scaffold → move www → move auth → move remaining 7 services. ~600 files moved, all imports rewritten
- Phase 5: 519 old service directories deleted.
-40,732 lines - Phase 6: ~45 cross-service HTTP calls replaced with direct function calls.
getSessionFromCookies(),checkAccess(),lookupIdentity()— no morefetch("http://localhost:3001/api/session") - Phase 7: 12 duplicate utility files consolidated into
src/lib/kernel/. SharedgenerateId, CORS, rate-limit, graph membership auth - 664 files changed, +2,362 / -40,732 lines in a single PR
The kernel runs on one domain: dev-jin.imajin.ai. Caddy routes /auth/api/*, /pay/api/*, etc. to the same process. Userspace apps (events, coffee, learn, links, market, dykil) remain separate — federated apps that can be hosted anywhere.
🔧 Routing Fixes (17+ in one session)
Single-domain routing surfaced three classes of bugs:
- Client fetch paths — bare
/api/...needed service prefix:/chat/api/... - Userspace basePath —
apiFetch()+NEXT_PUBLIC_BASE_PATHin@imajin/config - Navigation paths —
router.push(),href,window.locationall needed explicit service prefix
Also fixed: nested <html>/<body> in chat and media layouts (double NavBar), missing pages lost in Phase 5 cleanup, global unread count in NavBar, Caddy file_server for /api/media/*, auth subdomain URLs in userspace apps.
人 MJN Emissions — The Token Economy (#433, #641, #642)
Built in one evening. The economic loop: gas burns MJN, attestations emit MJN, .fair defines the rates, chains record everything.
- Emission schedule (
src/lib/kernel/emissions.ts) — attestation type → MJN credits. Fixed amounts for lifecycle events, percentage-of-settlement for commerce - Attestation-driven handler — after every attestation is stored, the emission schedule fires. Upserts
pay.balances, logspay.transactions. Fire-and-forget, non-fatal - Tiered identity emissions: soft DID → 10 MJN ($0.10), preliminary → +100 MJN ($1.00), hard → +100 MJN ($1.00). Fully verified = 210 MJN ($2.10)
- Valuation: 1 MJN = 0.01 CHF (≈1¢). 100 MJN = 1 MJNx. Grounded as "one unit of compute"
- Currency symbol: 人 — the "jin" in MJN. Person as currency.
人210in the NavBar
Wallet display: amber MJN badge in NavBar (alongside green cash badge), BalanceCard with separate MJN/cash cards, transaction history with 人 formatting and ✨ emission icons, currency filter (All/Fiat/MJN).
Retroactive backfill ran on dev: 19 identities, 1,490 MJN credited across 32 emissions.
Emissions model draft at docs/rfcs/drafts/emissions-model.md — the .fair cascade applies: root .fair (protocol defaults) → identity .fair (scope overrides) → record .fair (frozen proof at attestation time = mint proof).
📖 Launcher & API Docs
- Kernel services in launcher — broke single "Kernel" tile into 9 individual services (Home 🏠, Identity 🔑, Profile 👤, Connections 🤝, Chat 💬, Wallet 💰, Media 📁, Registry 📡, Notify 🔔). New "kernel" category at top, "Userspace" label for Events/Learn/Market
- Centered grid — launcher tiles center instead of left-aligning
- OpenAPI specs restored — 8 per-service YAML specs updated for single-domain routing,
{node}.imajin.ai/{service}server variables, new notify spec created from scratch - Registry docs page — filters meta services, reads kernel specs from file instead of HTTP
📝 Essays
- Essay 37: "How to Fix the Commons" — Hardin wrong, Ostrom right, Imajin = implementation. Bridge piece for Humane Tech
- Essay 38: "The Inherited Pathology" — LLMs inherit "do it later" from training data. Context design as governance. SOUL.md as Ostrom's principles for an attention commons
📊 By the Numbers
- 72 commits on feat/kernel-merge
- 9 services → 1 kernel process
- ~45 HTTP calls → direct function calls
- 40,732 lines deleted
- 1,490 MJN emitted retroactively
- 8 OpenAPI specs updated
- 2 essays drafted