feat(topology): cm-topology crate + architecture doc (Phases 0–1)
ci / gates (push) Has been cancelled
ci / rust (push) Has been cancelled
ci / sandbox-k8s (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / e2e (push) Has been cancelled

Foundation for the dynamic agentic-topologies platform (see
docs/topology-platform.md), porting agentorg's topology modeling into pure Rust:

- TopologyKind: curated 12-kind taxonomy (hierarchical, flat, pipeline, swarm,
  mesh, hub_spoke, ring, star_moe, market, blackboard, debate, holacratic).
- TopologyGraph: role-slot nodes + typed edges, with validation.
- adapter: normalize a loose JSON spec → validated graph (fills edge kinds).
- classifier: structural metrics (density, hub dominance, clustering, diameter,
  hierarchy score) → inferred kind + confidence (tree→hierarchical, line→pipeline,
  cycle→ring, star→hub_spoke, complete→mesh, empty→flat).
- heuristics: per-kind role distributions (ported from topology_manager.py).

Pure, offline, dependency-light (serde/thiserror). 17 unit tests, clippy clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Omar Sobh
2026-06-15 20:05:06 -07:00
co-authored by Claude Opus 4.8
parent 34da54ccaa
commit 817d8c712c
10 changed files with 1048 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
//! Organizational topologies for agentic systems — pure, offline modeling.
//!
//! A [`TopologyGraph`] describes *who talks to whom and who decides* in a
//! system of agents (claws). It is a description only: execution semantics
//! (and the §15 safety gates) live in the orchestrator, never here.
//!
//! This crate is dependency-light (serde + thiserror) and has no I/O, so it
//! doubles as a reusable library for benchmarking/topology research.
//!
//! Modules:
//! - [`kind`] — the curated [`TopologyKind`] taxonomy.
//! - [`graph`] — the [`TopologyGraph`] data model + validation.
//! - [`adapter`] — normalize a loose JSON/YAML spec into a graph.
//! - [`classifier`]— infer a topology kind from a graph's structure.
//! - [`heuristics`]— per-kind role distributions / optimization weights.
mod adapter;
mod classifier;
mod graph;
mod heuristics;
mod kind;
pub use adapter::{from_json, to_json};
pub use classifier::{classify, Classification, GraphMetrics};
pub use graph::{Edge, EdgeKind, Node, TopologyGraph};
pub use heuristics::{heuristics, Heuristics};
pub use kind::TopologyKind;
/// Errors produced while building or validating a topology.
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
pub enum TopologyError {
/// The graph has no nodes.
#[error("topology has no nodes")]
Empty,
/// An edge references a node id that does not exist.
#[error("edge references unknown node: {0}")]
UnknownNode(String),
/// Two nodes share an id.
#[error("duplicate node id: {0}")]
DuplicateNode(String),
/// The input spec could not be parsed.
#[error("invalid spec: {0}")]
Spec(String),
}