From 931dde7af4e4cd478536514f9d3a9b49267c6da3 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Wed, 24 Jun 2026 15:46:58 +0500 Subject: [PATCH 1/2] remove client connection manager --- aether/CMakeLists.txt | 1 - aether/client.cpp | 16 ++---- aether/client.h | 3 -- aether/client_messages/p2p_message_stream.cpp | 21 +++----- aether/client_messages/p2p_message_stream.h | 9 ++-- .../p2p_message_stream_manager.cpp | 1 - .../p2p_message_stream_manager.h | 1 - .../cloud_connections_tele.h | 6 --- .../cloud_server_connections.cpp | 21 +++++--- .../cloud_server_connections.h | 18 +++++-- .../client_connection_manager.cpp | 44 ----------------- .../client_connection_manager.h | 49 ------------------- 12 files changed, 42 insertions(+), 148 deletions(-) delete mode 100644 aether/connection_manager/client_connection_manager.cpp delete mode 100644 aether/connection_manager/client_connection_manager.h diff --git a/aether/CMakeLists.txt b/aether/CMakeLists.txt index be442990..9d579e17 100644 --- a/aether/CMakeLists.txt +++ b/aether/CMakeLists.txt @@ -206,7 +206,6 @@ list(APPEND aether_srcs "server_connections/server_connection.cpp") list(APPEND aether_srcs - "connection_manager/client_connection_manager.cpp" "connection_manager/get_cloud_aether.cpp" "connection_manager/client_cloud_manager.cpp" "connection_manager/server_connection_manager.cpp") diff --git a/aether/client.cpp b/aether/client.cpp index 64bf3487..acae8640 100644 --- a/aether/client.cpp +++ b/aether/client.cpp @@ -40,7 +40,8 @@ Uid const& Client::ephemeral_uid() const { return ephemeral_uid_; } ServerKeys* Client::server_state(ServerId server_id) { auto ss_it = server_keys_.find(server_id); if (ss_it == server_keys_.end()) { - auto [it, _] = server_keys_.emplace(server_id, ServerKeys{server_id, master_key_}); + auto [it, _] = + server_keys_.emplace(server_id, ServerKeys{server_id, master_key_}); ss_it = it; } return &ss_it->second; @@ -62,20 +63,11 @@ ServerConnectionManager& Client::server_connection_manager() { return *server_connection_manager_; } -ClientConnectionManager& Client::connection_manager() { - if (!client_connection_manager_) { - auto aether = Aether::ptr{aether_}; - client_connection_manager_ = std::make_unique( - cloud_.Load(), - server_connection_manager().GetServerConnectionFactory()); - } - return *client_connection_manager_; -} - CloudServerConnections& Client::cloud_connection() { if (!cloud_connection_) { cloud_connection_ = std::make_unique( - *aether_.Load().as(), connection_manager(), + *aether_.Load().as(), cloud_.Load(), + server_connection_manager().GetServerConnectionFactory(), AE_CLOUD_MAX_SERVER_CONNECTIONS); #if AE_TELE_ENABLED diff --git a/aether/client.h b/aether/client.h index 836dc1d7..12f9f113 100644 --- a/aether/client.h +++ b/aether/client.h @@ -31,7 +31,6 @@ #include "aether/connection_manager/client_cloud_manager.h" #include "aether/client_messages/p2p_message_stream_manager.h" #include "aether/connection_manager/server_connection_manager.h" -#include "aether/connection_manager/client_connection_manager.h" namespace ae { class Aether; @@ -58,7 +57,6 @@ class Client : public Obj { Cloud::ptr const& cloud() const; ClientCloudManager::ptr const& cloud_manager() const; ServerConnectionManager& server_connection_manager(); - ClientConnectionManager& connection_manager(); CloudServerConnections& cloud_connection(); P2pMessageStreamManager& message_stream_manager(); @@ -86,7 +84,6 @@ class Client : public Obj { ClientCloudManager::ptr client_cloud_manager_; std::unique_ptr server_connection_manager_; - std::unique_ptr client_connection_manager_; std::unique_ptr cloud_connection_; std::unique_ptr message_stream_manager_; diff --git a/aether/client_messages/p2p_message_stream.cpp b/aether/client_messages/p2p_message_stream.cpp index 74b2755c..076353ee 100644 --- a/aether/client_messages/p2p_message_stream.cpp +++ b/aether/client_messages/p2p_message_stream.cpp @@ -254,11 +254,12 @@ void P2pStream::ConnectSend() { auto& get_client_cloud = client_ptr->cloud_manager()->GetCloud(destination_); get_client_cloud_sub_ = get_client_cloud.result_event().Subscribe( - [this](Result&& result) { + [this, client_ptr](Result&& result) { if (result) { auto cloud = std::move(result).value(); - dest_conn_manager_ = MakeConnectionManager(cloud.Load()); - dest_cloud_conn_ = MakeDestinationCloudConn(*dest_conn_manager_); + dest_cloud_conn_ = MakeDestinationCloudConn( + cloud.Load(), client_ptr->server_connection_manager() + .GetServerConnectionFactory()); // TODO: add config for request policy message_send_stream_ = std::make_unique( @@ -276,19 +277,11 @@ void P2pStream::ConnectSend() { }); } -std::unique_ptr P2pStream::MakeConnectionManager( - Ptr const& cloud) { - auto client_ptr = client_.Lock(); - assert(client_ptr); - return std::make_unique( - cloud, - client_ptr->server_connection_manager().GetServerConnectionFactory()); -} - std::unique_ptr P2pStream::MakeDestinationCloudConn( - ClientConnectionManager& connection_manager) { + Ptr const& cloud, + std::unique_ptr factory) { return std::make_unique( - ae_context_, connection_manager, AE_CLOUD_MAX_SERVER_CONNECTIONS); + ae_context_, cloud, std::move(factory), AE_CLOUD_MAX_SERVER_CONNECTIONS); } WriteAction* P2pStream::OnWrite(AeMessage&& message) { diff --git a/aether/client_messages/p2p_message_stream.h b/aether/client_messages/p2p_message_stream.h index 7d856bf1..449ec815 100644 --- a/aether/client_messages/p2p_message_stream.h +++ b/aether/client_messages/p2p_message_stream.h @@ -27,7 +27,6 @@ #include "aether/cloud_connections/cloud_server_connections.h" #include "aether/connection_manager/client_cloud_manager.h" -#include "aether/connection_manager/client_connection_manager.h" namespace ae { class Client; @@ -64,18 +63,16 @@ class P2pStream final : public ByteIStream { void ConnectReceive(); void ConnectSend(); - std::unique_ptr MakeConnectionManager( - Ptr const& cloud); std::unique_ptr MakeDestinationCloudConn( - ClientConnectionManager& connection_manager); + Ptr const& cloud, + std::unique_ptr factory); WriteAction* OnWrite(AeMessage&& message); AeContext ae_context_; PtrView client_; Uid destination_{}; - // connection manager to destination cloud - std::unique_ptr dest_conn_manager_; + // connection to destination cloud std::unique_ptr dest_cloud_conn_; BufferWrite buffer_write_; std::unique_ptr message_send_stream_; diff --git a/aether/client_messages/p2p_message_stream_manager.cpp b/aether/client_messages/p2p_message_stream_manager.cpp index a996dcb2..1ef78528 100644 --- a/aether/client_messages/p2p_message_stream_manager.cpp +++ b/aether/client_messages/p2p_message_stream_manager.cpp @@ -26,7 +26,6 @@ P2pMessageStreamManager::P2pMessageStreamManager(AeContext const& ae_context, Ptr const& client) : ae_context_{ae_context}, client_{client}, - connection_manager_{&client->connection_manager()}, cloud_connection_{&client->cloud_connection()}, on_message_received_sub_{CloudSubscription{ ClientListener{[this](ClientApiSafe& client_api, auto*) { diff --git a/aether/client_messages/p2p_message_stream_manager.h b/aether/client_messages/p2p_message_stream_manager.h index 64c623d8..d5204b50 100644 --- a/aether/client_messages/p2p_message_stream_manager.h +++ b/aether/client_messages/p2p_message_stream_manager.h @@ -50,7 +50,6 @@ class P2pMessageStreamManager { AeContext ae_context_; PtrView client_; - ClientConnectionManager* connection_manager_; CloudServerConnections* cloud_connection_; std::map> streams_; NewStreamEvent new_stream_event_; diff --git a/aether/cloud_connections/cloud_connections_tele.h b/aether/cloud_connections/cloud_connections_tele.h index 4ffc3c78..4bdf67f4 100644 --- a/aether/cloud_connections/cloud_connections_tele.h +++ b/aether/cloud_connections/cloud_connections_tele.h @@ -28,10 +28,4 @@ AE_TAG(CloudClientNewStream, kCloudClientConnection) AE_TELE_MODULE(kClientServerStream, 61, 113, 113); AE_TAG(ClientServerStreamCreate, kClientServerStream) -AE_TELE_MODULE(kClientConnectionManager, 62, 114, 116); -AE_TAG(ClientConnectionManagerSelfCloudConnection, kClientConnectionManager) -AE_TAG(ClientConnectionManagerUidCloudConnection, kClientConnectionManager) -AE_TAG(ClientConnectionManagerUnableCreateClientServerConnection, - kClientConnectionManager) - #endif // AETHER_CLOUD_CONNECTIONS_CLOUD_CONNECTIONS_TELE_H_ diff --git a/aether/cloud_connections/cloud_server_connections.cpp b/aether/cloud_connections/cloud_server_connections.cpp index 7734a2c5..6e702673 100644 --- a/aether/cloud_connections/cloud_server_connections.cpp +++ b/aether/cloud_connections/cloud_server_connections.cpp @@ -24,11 +24,14 @@ namespace ae { CloudServerConnections::CloudServerConnections( - AeContext const& ae_context, ClientConnectionManager& connection_manager, + AeContext const& ae_context, Ptr const& cloud, + std::unique_ptr connection_factory, std::size_t max_connections) : ae_context_{ae_context}, - connection_manager_{&connection_manager}, + cloud_{cloud}, + connection_factory_{std::move(connection_factory)}, max_connections_{max_connections} { + InitServerConnections(); InitServers(); } @@ -57,6 +60,13 @@ void CloudServerConnections::Restream() { } } +void CloudServerConnections::InitServerConnections() { + server_connections_.clear(); + for (auto& server : cloud_->servers()) { + server_connections_.emplace_back(server.Load(), *connection_factory_); + } +} + void CloudServerConnections::InitServers() { AE_TELED_DEBUG("Init servers"); auto server_candidates = ServerCandidates(); @@ -112,8 +122,7 @@ void CloudServerConnections::SubscribeToServerState( auto bad_server = [this, sc{&server_connection}]() { // TODO: add the policy how to change the server priority on failure // put server in quarantine and make it the least prioritized - auto new_priority = - sc->priority() + connection_manager_->server_connections().size(); + auto new_priority = sc->priority() + server_connections_.size(); sc->EndConnection(new_priority); QuarantineTimer(*sc); UnselectServer(*sc); @@ -183,8 +192,8 @@ void CloudServerConnections::QuarantineTimer( std::vector CloudServerConnections::ServerCandidates() { std::vector servers; - servers.reserve(connection_manager_->server_connections().size()); - for (auto& s : connection_manager_->server_connections()) { + servers.reserve(server_connections_.size()); + for (auto& s : server_connections_) { if (s.quarantine()) { continue; } diff --git a/aether/cloud_connections/cloud_server_connections.h b/aether/cloud_connections/cloud_server_connections.h index 13fb873c..2ea28c53 100644 --- a/aether/cloud_connections/cloud_server_connections.h +++ b/aether/cloud_connections/cloud_server_connections.h @@ -17,10 +17,14 @@ #define AETHER_CLOUD_CONNECTIONS_CLOUD_SERVER_CONNECTIONS_H_ #include +#include +#include "aether/cloud.h" +#include "aether/ptr/ptr.h" #include "aether/ae_context.h" #include "aether/events/events.h" -#include "aether/connection_manager/client_connection_manager.h" +#include "aether/cloud_connections/cloud_server_connection.h" +#include "aether/server_connections/iserver_connection_factory.h" namespace ae { @@ -30,9 +34,10 @@ class CloudServerConnections { public: using ServersUpdate = Event; - CloudServerConnections(AeContext const& ae_context, - ClientConnectionManager& connection_manager, - std::size_t max_connections); + CloudServerConnections( + AeContext const& ae_context, Ptr const& cloud, + std::unique_ptr connection_factory, + std::size_t max_connections); /** * \brief The event then top list of the servers were updated. @@ -52,6 +57,7 @@ class CloudServerConnections { void Restream(); private: + void InitServerConnections(); void InitServers(); void SelectServers(std::vector const& servers); void SubscribeToServerState(CloudServerConnection& server_connection); @@ -63,8 +69,10 @@ class CloudServerConnections { std::vector ServerCandidates(); AeContext ae_context_; - ClientConnectionManager* connection_manager_; + Ptr cloud_; + std::unique_ptr connection_factory_; std::size_t max_connections_; + std::vector server_connections_; // selected list of servers sorted by the priority std::vector selected_servers_; diff --git a/aether/connection_manager/client_connection_manager.cpp b/aether/connection_manager/client_connection_manager.cpp deleted file mode 100644 index 7876aab4..00000000 --- a/aether/connection_manager/client_connection_manager.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2025 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "aether/connection_manager/client_connection_manager.h" - -#include "aether/cloud.h" - -namespace ae { -ClientConnectionManager::ClientConnectionManager( - Ptr const& cloud, - std::unique_ptr&& connection_factory) - : cloud_{cloud}, connection_factory_{std::move(connection_factory)} { - InitServerConnections(); -} - -std::vector& -ClientConnectionManager::server_connections() { - return server_connections_; -} - -void ClientConnectionManager::InitServerConnections() { - auto cloud = cloud_.Lock(); - assert(cloud); - server_connections_.reserve(cloud->servers().size()); - for (auto& server : cloud->servers()) { - assert(server.is_valid()); - server_connections_.emplace_back(server.Load(), *connection_factory_); - } -} - -} // namespace ae diff --git a/aether/connection_manager/client_connection_manager.h b/aether/connection_manager/client_connection_manager.h deleted file mode 100644 index eaae7bd1..00000000 --- a/aether/connection_manager/client_connection_manager.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2025 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AETHER_CONNECTION_MANAGER_CLIENT_CONNECTION_MANAGER_H_ -#define AETHER_CONNECTION_MANAGER_CLIENT_CONNECTION_MANAGER_H_ - -#include "aether/ptr/ptr.h" -#include "aether/ptr/ptr_view.h" - -#include "aether/cloud_connections/cloud_server_connection.h" -#include "aether/server_connections/iserver_connection_factory.h" - -namespace ae { -class Cloud; - -/** - * \brief Manager of all connections to the client's cloud - */ -class ClientConnectionManager { - public: - ClientConnectionManager( - Ptr const& cloud, - std::unique_ptr&& connection_factory); - - std::vector& server_connections(); - - private: - void InitServerConnections(); - - PtrView cloud_; - std::unique_ptr connection_factory_; - std::vector server_connections_; -}; -} // namespace ae - -#endif // AETHER_CONNECTION_MANAGER_CLIENT_CONNECTION_MANAGER_H_ From 3d3bddad6e84988c2f98b5d085e88c43e1b940a1 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Wed, 24 Jun 2026 15:47:04 +0500 Subject: [PATCH 2/2] add new agents --- opencode.json | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/opencode.json b/opencode.json index 819eeeef..0c1a0a60 100644 --- a/opencode.json +++ b/opencode.json @@ -34,10 +34,13 @@ "coder": { "mode": "subagent", "description": "Write c++ code", - "prompt": "You are a highly qualified c++ developer. Your task is to write c++ code that solves the given problem. You get instruction from the team lead/architect. You only implement the ideas in code.", + "prompt": "You are a highly qualified c++ developer. Your task is to write c++ code that solves the given problem. You get instruction from the team lead/architect. You only implement the ideas in code. To verify builds ask @builder_cpp.", "permission": { "edit": "allow", - "bash": "ask", + "bash": { + "cmake*": "deny", + "*": "ask" + }, "external_directory": "deny", "repo_clone": "deny" } @@ -50,15 +53,28 @@ "edit": "deny", "bash": { "git log*": "allow", - "git diff*": "allow" + "git diff*": "allow", + "*": "deny" } }, "temperature": 0.1 }, - "team-lead-architect": { + "architect": { + "mode": "all", + "description": "Review code and reasone architecture", + "prompt": "You a c++ architect. You don't write code, you don't build, you don't test. Your task to analaize and create architecture. You analyze existing code and search for architecture flaws and points of improvements. You analyze requirements and crete best architecture to implement them.", + "permission": { + "edit": "deny", + "bash": { + "git log*": "allow", + "git diff*": "allow" + } + } + }, + "team-lead": { "mode": "primary", "description": "The main agent to rule the others on the way to work on code.", - "prompt": "You are team-lead architect. You don't write code, you don't build, you don't test. You manage agent team and architect solutions. You have @coder - to write actual code by your detailed instructions; @builder_cpp to validate builds, analyze compiler errors; @tester to run tests and analyze test logs; @code-reviewer to work in pair with @coder and check if everything made as it's intended.", + "prompt": "You are team-lead. You don't write code, you don't build, you don't test. You manage agent team and architect solutions. You have @architect - to create a solution based on requirements and existent code; @coder - to write actual code by your detailed instructions; @builder_cpp to validate builds, analyze compiler errors; @tester to run tests and analyze test logs; @code-reviewer to work in pair with @coder and check if everything made as it's intended.", "permission": { "edit": "deny", "bash": "deny"