5.9 KiB
5.9 KiB
Project Meatbag: Session Handoff
Date: June 27, 2026
Ecosystem: WhetForge
Goal: Scaffolding and Implementing the MVP for Meatbag, a multiplatform "Human Latency Optimization Tool" for server-driven UI (SDUI).
1. What We Did This Session
We initiated the project from scratch, structured it as a Kotlin Multiplatform Gradle project, and developed a stateful routing backend and a stateless Compose Multiplatform client. The session focused on achieving a successful end-to-end ping-pong loop:
- An agent submits an
ApprovalRequestvia HTTP POST to the backend. - The backend determines the target device and attention tier based on user context rules, then suspends the request.
- The backend notifies the target device via WebSockets.
- The client simulates haptics (or alerts) based on the
AttentionTier, parses the JSON UI primitive, and inflates the UI dynamically. - The human taps "Yes" / interacts, sending a response to the backend.
- The backend resumes the suspended agent request and returns the response.
2. Core Project Architecture
The project directory is structured as a multi-module Kotlin project:
-
:common(Kotlin Multiplatform)- UiPrimitive.kt: Declares the sealed hierarchy representing JSON UI elements (
UiPrimitivewith sub-typesApprovalRequest,ActionList,TextInput), theAttentionTierenum (SILENT_HAPTIC,BACKGROUND_NOTIFICATION,OVERRIDE_SCREEN), and common payload envelopes (WebSocketPayload,ApprovalResponse). Includes polymorphic serialization helpers. - UiPrimitiveTest.kt: Verifies correct serialization and parsing with class discriminators.
- UiPrimitive.kt: Declares the sealed hierarchy representing JSON UI elements (
-
:backend(Ktor/JVM)- Application.kt: Scaffolds Ktor Netty, sets up CORS/WebSockets/ContentNegotiation plugins, exposes client-facing WebSocket (
/ws/connect), response handler (/api/respond), agent request (/api/request), and diagnostic endpoints. Includes context-aware urgency auto-detection. - DeviceRegistry.kt: Registers connected active client devices dynamically.
- RoutingEngine.kt: Implements attention-based routing (e.g. routes urgent/silent haptics to Wear OS if active, otherwise falls back to phone/desktop) and holds coroutine suspend contexts via
CompletableDeferredpending user callbacks. - RoutingEngineTest.kt: Fully verifies WebSocket connections, payload transmission, attention tier routing, and callback resume resolution under Ktor's
testApplicationengine.
- Application.kt: Scaffolds Ktor Netty, sets up CORS/WebSockets/ContentNegotiation plugins, exposes client-facing WebSocket (
-
:client(Compose Multiplatform / Desktop target)- ComponentRegistry.kt: dynamic Compose renderer converting
UiPrimitivepolymorphically into premium, dark cyberpunk UI components using Unidirectional Data Flow (UDF) callbacks. - MeatbagClient.kt: Manages WebSocket connections and POST responses. Decodes payloads and triggers simulated attention effects (vibrations, sound chimes, or display takeover overlays).
- Main.kt: Cyberpunk glassmorphic client simulator. Displays connection logs and simulates haptic profiles (Smartwatch vs. Phone vs. Desktop) and injects local offline mock payloads for isolated UI debugging.
- ComponentRegistry.kt: dynamic Compose renderer converting
3. Configuration & Dependency Fixes Applied
During compilation and verification, several compatibility fixes were successfully applied:
- Plugin Portal Registration: Configured
gradlePluginPortal()insettings.gradle.ktsto allow resolution of the Ktor and Kotlin JVM plugins. - Kotlin Compiler Version Alignment: Managed Kotlin compiler plugin versions centrally in the root
build.gradle.ktsand applied them cleanly inside sub-modules to prevent classloader duplicate classpath conflicts. - Obsolete Property Removal: Removed the obsolete
kotlin.mpp.enableGranularSourceSetsMetadata=truefromgradle.propertiesto fix Kotlin Gradle compiler configuration errors. - Client Test Classpath: Added Ktor Client content negotiation and websocket JVM targets to
:backendtest dependencies so that Ktor's test client works flawlessly during JUnit runs. - Client Simulator Fixes:
- Fixed window size dimensions to use
Dpunits (1280.dp,800.dp). - Resolved Ktor 2.x
Frame.Textread extension function resolution by importingio.ktor.websocket.readText. - Refactored client
loghelpers to be non-suspending (using flowtryEmitinstead ofemit), and introduced a publicinjectMockEventhelper to safely feed mock events from the simulator UI without coroutine thread blocks.
- Fixed window size dimensions to use
4. Current Status
- Compilation Status:
BUILD SUCCESSFULfor all modules and targets. - Testing Status: Common serialization and backend integration routing tests pass successfully.
- Active Subagents: Cleaned up and terminated all background subagent processes.
5. Next Steps
- Develop Android/Wear OS Platform Code: Implement physical haptic motor triggers (
VibratorandVibratorManager) inwearMainand push banner notifications inandroidMain. - Persistence Layer: Implement a database (e.g., SQLite via SQLDelight or PostgreSQL) to persist user rule-sets and past agent requests.
- Authentication: Secure endpoints using API keys for CLI agents and OAuth/Device Tokens for clients.