From f5b15be3a009131965c99874c0501f10e8379621 Mon Sep 17 00:00:00 2001 From: MrBT-nano Date: Fri, 8 May 2026 23:43:31 +0700 Subject: [PATCH 1/2] refactor: implement canonical protobuf standard with namespacing and buf --- .gitignore | 29 +++++++++++++++-- STRUCTURE.tree | 45 ++++++++------------------ buf.yaml | 9 ++++++ crates/brain-grpc/src/bin/server.rs | 2 +- crates/brain-grpc/src/server.rs | 4 +-- crates/brain-proto/build.rs | 8 ++++- crates/brain-proto/proto/brain.proto | 35 -------------------- crates/brain-proto/src/lib.rs | 10 +++++- proto/echo/vtuber/brain/v1/brain.proto | 20 ++++++++++++ proto/echo/vtuber/voice/v1/voice.proto | 18 +++++++++++ 10 files changed, 107 insertions(+), 73 deletions(-) create mode 100644 buf.yaml delete mode 100644 crates/brain-proto/proto/brain.proto create mode 100644 proto/echo/vtuber/brain/v1/brain.proto create mode 100644 proto/echo/vtuber/voice/v1/voice.proto diff --git a/.gitignore b/.gitignore index de3ddcc..d0d7820 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,30 @@ -/target +# Rust /target/ -node_modules/ +Cargo.lock + +# Python +__pycache__/ +*.py[cod] +*$py.class +venv/ +.env + +# Mojo +build/ +.mojo_cache/ + +# IDEs +.vscode/ +.idea/ + +# System .DS_Store +Thumbs.db + +# Logs *.log + +# Project specific +.superpowers/ +docs/ +STRUCTURE.tree diff --git a/STRUCTURE.tree b/STRUCTURE.tree index 8efee47..73ad5cb 100644 --- a/STRUCTURE.tree +++ b/STRUCTURE.tree @@ -1,5 +1,6 @@ . ├── ARCHITECTURE.md +├── buf.yaml ├── Cargo.lock ├── Cargo.toml ├── CLAUDE.md @@ -20,21 +21,14 @@ │   └── brain-proto │   ├── build.rs │   ├── Cargo.toml -│   ├── proto -│   │   └── brain.proto │   └── src │   └── lib.rs ├── DEPLOYMENT_GUIDE.md ├── DESIGN_DECISIONS.md ├── docs -│   ├── specs -│   │   └── ecosystem -│   │   └── .gitkeep -│   └── superpowers -│   ├── plans -│   │   └── 2026-04-30-foundation-core-loop.md -│   └── specs -│   └── 2026-04-30-foundation-core-loop-design.md +│   └── specs +│   └── ecosystem +│   └── 2026-05-01-canonical-proto-standard.md ├── FAQ.md ├── GEMINI.md ├── .github @@ -59,33 +53,22 @@ ├── PHILOSOPHY.md ├── .pre-commit-config.yaml ├── PRINCIPLES.md +├── proto +│   └── echo +│   └── vtuber +│   ├── brain +│   │   └── v1 +│   │   └── brain.proto +│   └── voice +│   └── v1 +│   └── voice.proto ├── README.md ├── ROADMAP.md ├── SECURITY.md ├── STRATEGY.md ├── STRUCTURE.tree -├── .superpowers -│   └── brainstorm -│   ├── 1516087-1777552623 -│   │   ├── content -│   │   │   ├── architecture-overview.html -│   │   │   ├── boundaries.html -│   │   │   └── phase1-design.html -│   │   └── state -│   │   ├── server.pid -│   │   └── server-stopped -│   └── 2118992-1777559437 -│   ├── content -│   │   ├── architecture-overview.html -│   │   ├── boundaries-fixed.html -│   │   ├── boundaries.html -│   │   ├── final-boundaries.html -│   │   └── phase1-design.html -│   └── state -│   ├── server.pid -│   └── server-stopped ├── SUPPORT.md ├── TROUBLESHOOTING.md └── VISION.md -28 directories, 61 files +23 directories, 49 files diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..5af787a --- /dev/null +++ b/buf.yaml @@ -0,0 +1,9 @@ +version: v2 +modules: + - path: proto +lint: + use: + - DEFAULT +breaking: + use: + - DEFAULT diff --git a/crates/brain-grpc/src/bin/server.rs b/crates/brain-grpc/src/bin/server.rs index 6a6ec57..faa4c49 100644 --- a/crates/brain-grpc/src/bin/server.rs +++ b/crates/brain-grpc/src/bin/server.rs @@ -1,5 +1,5 @@ use brain_grpc::server::MyBrainService; -use brain_proto::brain::brain_service_server::BrainServiceServer; +use brain_proto::brain::v1::brain_service_server::BrainServiceServer; use tonic::transport::Server; #[tokio::main] diff --git a/crates/brain-grpc/src/server.rs b/crates/brain-grpc/src/server.rs index 42875c0..153578d 100644 --- a/crates/brain-grpc/src/server.rs +++ b/crates/brain-grpc/src/server.rs @@ -1,5 +1,5 @@ -use brain_proto::brain::brain_service_server::BrainService; -use brain_proto::brain::{ContextRequest, ContextResponse}; +use brain_proto::brain::v1::brain_service_server::BrainService; +use brain_proto::brain::v1::{ContextRequest, ContextResponse}; use tonic::{Request, Response, Status}; #[derive(Default)] diff --git a/crates/brain-proto/build.rs b/crates/brain-proto/build.rs index a421642..25fd8c5 100644 --- a/crates/brain-proto/build.rs +++ b/crates/brain-proto/build.rs @@ -2,6 +2,12 @@ fn main() -> Result<(), Box> { tonic_build::configure() .build_server(true) .build_client(true) - .compile_protos(&["proto/brain.proto"], &["proto"])?; + .compile_protos( + &[ + "../../proto/echo/vtuber/brain/v1/brain.proto", + "../../proto/echo/vtuber/voice/v1/voice.proto", + ], + &["../../proto"], + )?; Ok(()) } diff --git a/crates/brain-proto/proto/brain.proto b/crates/brain-proto/proto/brain.proto deleted file mode 100644 index 5b9b679..0000000 --- a/crates/brain-proto/proto/brain.proto +++ /dev/null @@ -1,35 +0,0 @@ -syntax = "proto3"; - -package brain; - -// vtuber-api -> vtuber-brain -service BrainService { - rpc PushContext (ContextRequest) returns (ContextResponse); -} - -// vtuber-brain -> vtuber-voice -service VoiceService { - rpc EmitDirective (DirectiveRequest) returns (DirectiveResponse); -} - -message ContextRequest { - string session_id = 1; - string user_id = 2; - string message = 3; - map metadata = 4; -} - -message ContextResponse { - bool accepted = 1; - string request_id = 2; -} - -message DirectiveRequest { - string text_prompt = 1; - string voice_prompt = 2; - map commands = 3; -} - -message DirectiveResponse { - bool success = 1; -} diff --git a/crates/brain-proto/src/lib.rs b/crates/brain-proto/src/lib.rs index bc03fc7..4745e37 100644 --- a/crates/brain-proto/src/lib.rs +++ b/crates/brain-proto/src/lib.rs @@ -1,3 +1,11 @@ pub mod brain { - tonic::include_proto!("brain"); + pub mod v1 { + tonic::include_proto!("echo.vtuber.brain.v1"); + } +} + +pub mod voice { + pub mod v1 { + tonic::include_proto!("echo.vtuber.voice.v1"); + } } diff --git a/proto/echo/vtuber/brain/v1/brain.proto b/proto/echo/vtuber/brain/v1/brain.proto new file mode 100644 index 0000000..83570ea --- /dev/null +++ b/proto/echo/vtuber/brain/v1/brain.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package echo.vtuber.brain.v1; + +// BrainService defines the interface for vtuber-api to feed context into the reasoning core. +service BrainService { + rpc PushContext (ContextRequest) returns (ContextResponse); +} + +message ContextRequest { + string session_id = 1; + string user_id = 2; + string message = 3; + map metadata = 4; +} + +message ContextResponse { + bool accepted = 1; + string request_id = 2; +} diff --git a/proto/echo/vtuber/voice/v1/voice.proto b/proto/echo/vtuber/voice/v1/voice.proto new file mode 100644 index 0000000..c718e99 --- /dev/null +++ b/proto/echo/vtuber/voice/v1/voice.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package echo.vtuber.voice.v1; + +// VoiceService defines the interface for the Performer (vtuber-voice) to receive directives. +service VoiceService { + rpc EmitDirective (DirectiveRequest) returns (DirectiveResponse); +} + +message DirectiveRequest { + string text_prompt = 1; + string voice_prompt = 2; + map commands = 3; +} + +message DirectiveResponse { + bool success = 1; +} From 68be18b395d6b82f7cfde69f569f164d256216d5 Mon Sep 17 00:00:00 2001 From: MrBT-nano Date: Sat, 9 May 2026 03:24:06 +0700 Subject: [PATCH 2/2] refactor: follow standard gRPC naming conventions and update buf config --- buf.yaml | 4 ++-- crates/brain-grpc/src/server.rs | 8 ++++---- proto/echo/vtuber/brain/v1/brain.proto | 6 +++--- proto/echo/vtuber/voice/v1/voice.proto | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/buf.yaml b/buf.yaml index 5af787a..26965c6 100644 --- a/buf.yaml +++ b/buf.yaml @@ -3,7 +3,7 @@ modules: - path: proto lint: use: - - DEFAULT + - STANDARD breaking: use: - - DEFAULT + - STANDARD diff --git a/crates/brain-grpc/src/server.rs b/crates/brain-grpc/src/server.rs index 153578d..b32ed48 100644 --- a/crates/brain-grpc/src/server.rs +++ b/crates/brain-grpc/src/server.rs @@ -1,5 +1,5 @@ use brain_proto::brain::v1::brain_service_server::BrainService; -use brain_proto::brain::v1::{ContextRequest, ContextResponse}; +use brain_proto::brain::v1::{PushContextRequest, PushContextResponse}; use tonic::{Request, Response, Status}; #[derive(Default)] @@ -9,12 +9,12 @@ pub struct MyBrainService {} impl BrainService for MyBrainService { async fn push_context( &self, - request: Request, - ) -> Result, Status> { + request: Request, + ) -> Result, Status> { let r = request.into_inner(); tracing::info!("Received context from {}: {}", r.user_id, r.message); - Ok(Response::new(ContextResponse { + Ok(Response::new(PushContextResponse { accepted: true, request_id: "mock-uuid".to_string(), })) diff --git a/proto/echo/vtuber/brain/v1/brain.proto b/proto/echo/vtuber/brain/v1/brain.proto index 83570ea..1470376 100644 --- a/proto/echo/vtuber/brain/v1/brain.proto +++ b/proto/echo/vtuber/brain/v1/brain.proto @@ -4,17 +4,17 @@ package echo.vtuber.brain.v1; // BrainService defines the interface for vtuber-api to feed context into the reasoning core. service BrainService { - rpc PushContext (ContextRequest) returns (ContextResponse); + rpc PushContext (PushContextRequest) returns (PushContextResponse); } -message ContextRequest { +message PushContextRequest { string session_id = 1; string user_id = 2; string message = 3; map metadata = 4; } -message ContextResponse { +message PushContextResponse { bool accepted = 1; string request_id = 2; } diff --git a/proto/echo/vtuber/voice/v1/voice.proto b/proto/echo/vtuber/voice/v1/voice.proto index c718e99..b0254fb 100644 --- a/proto/echo/vtuber/voice/v1/voice.proto +++ b/proto/echo/vtuber/voice/v1/voice.proto @@ -4,15 +4,15 @@ package echo.vtuber.voice.v1; // VoiceService defines the interface for the Performer (vtuber-voice) to receive directives. service VoiceService { - rpc EmitDirective (DirectiveRequest) returns (DirectiveResponse); + rpc EmitDirective (EmitDirectiveRequest) returns (EmitDirectiveResponse); } -message DirectiveRequest { +message EmitDirectiveRequest { string text_prompt = 1; string voice_prompt = 2; map commands = 3; } -message DirectiveResponse { +message EmitDirectiveResponse { bool success = 1; }