# maharanasunil1843/signalmesh architecture

> Architecture diagram of the GitHub repository maharanasunil1843/signalmesh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maharanasunil1843/signalmesh
- Repository: https://github.com/maharanasunil1843/signalmesh

## Overview

1. **What this repository is**
   - A small CLI-based multi-agent incident triage system.
   - Its core job is to turn deterministic network telemetry into a structured incident report using two separate LLM agent roles: **Analyst** and **Reporter**.

2. **Top-level execution path**
   - `main.py` is the entrypoint.
   - It selects a scenario or runs the success metric, wires together the provider and graph, and prints the final report to stdout while emitting trace output to stderr.
   - There is no server, UI, or background worker model here; each run is a single synchronous pipeline.

3. **Core runtime boundary: the agent graph**
   - `src/graph.py` is the orchestration layer.
   - It wires the Analyst and Reporter into a small graph with one bounded conditional branch: if the Analyst output is low-confidence or missing, the flow can re-run once, then either continue or fail safe.
   - This is the main control-flow boundary in the repo.

4. **Analyst subsystem**
   - `src/agent_analyst.py` is responsible for tool use, root-cause interpretation, and producing a validated finding.
   - It is the only place that can invoke telemetry data.
   - Its output is constrained to the typed handoff contract, which prevents downstream agents from receiving raw telemetry directly.

5. **Reporter subsystem**
   - `src/agent_reporter.py` consumes only the validated Analyst finding.
   - It produces the final incident report and is structurally isolated from the telemetry tool and raw telemetry payloads.
   - This separation is the repo’s main architectural enforcement mechanism for agent decoupling.

6. **Typed handoff contract**
   - `src/handoff_contract.py` defines the boundary object passed from Analyst to Reporter.
   - The contract is what makes the boundary enforceable: the Reporter’s input is not “whatever the Analyst saw,” but a specific validated finding type.
   - This is the key dependency barrier in the system diagram.

7. **Telemetry source**
   - `src/tool_network_data.py` provides synthetic, deterministic telemetry.
   - The Analyst is the only agent that can call this tool, and the data is intentionally mockable and reproducible.
   - In architecture terms, this is an internal data source, not an external service.

8. **Provider abstraction and model backends**
   - `src/provider.py` defines a `ModelProvider` protocol and implements both a deterministic mock provider and an OpenAI-backed provider.
   - Agents never import vendor SDKs directly; they speak only through this provider interface.
   - Vendor-specific failures are normalized so provider concerns do not leak into agent logic.

9. **Resilience and failure handling**
   - `src/resilience.py` centralizes bounded retry, timeout, and explicit guard logic.
   - The repo deliberately avoids scattered ad hoc exception handling in the agents.
   - This module supports the single retry policy and the “fail-safe” unresolved outcome when the Analyst cannot identify a real router id.

10. **Observability**
   - `src/observability.py` emits structured JSON decision traces.
   - Tracing is a first-class integration point rather than an afterthought, and it is kept separate from the agent logic.
   - The README indicates this module can later be pointed at OpenTelemetry or LangSmith without changing agent code.

11. **Evaluation and task-success metric**
   - `src/success_metric.py` implements a deterministic programmatic score for the triage behavior.
   - The metric validates that good scenarios carry the Analyst’s router id through to the report, while empty or malformed telemetry causes a safe decline instead of fabrication.
   - `docs/EVALUATION_LOG.md` records the evaluation outcome.

12. **Testing strategy**
   - `tests/test_success_metric.py` and `tests/test_resilience.py` cover the offline deterministic behavior.
   - `tests/test_provider_integration.py` covers the OpenAI path and auto-skips unless the environment is configured for the real provider.
   - The test suite mirrors the architecture: contract validation, retry/failure behavior, and provider integration are separated.

13. **Operational profile**
   - The default mode is offline and reproducible, with no API key required.
   - Real model usage is an opt-in switch via environment configuration.
   - This makes the system suitable for local evaluation, CI, and reproducible demos without changing code.

14. **Main architectural takeaway**
   - The repo is built around a narrow, enforceable pipeline: telemetry tool → Analyst → typed contract → Reporter → final report, with one bounded retry and an explicit unresolved fallback.
   - The strongest architectural boundaries are between tool access, agent roles, and provider implementation.

Main entry points: [`src/agent_analyst.py`](https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_analyst.py) (Analyst), [`src/agent_reporter.py`](https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_reporter.py) (Reporter), [`src/graph.py`](https://github.com/maharanasunil1843/signalmesh/blob/main/src/graph.py) (Agent graph), [`src/success_metric.py`](https://github.com/maharanasunil1843/signalmesh/blob/main/src/success_metric.py) (Success metric)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["main.py<br/>CLI entrypoint<br/>[main.py]"]
  node_graph{{"Agent graph<br/>orchestrator<br/>[graph.py]"}}
end

subgraph group_agents["Agents"]
  node_analyst["Analyst<br/>agent<br/>[agent_analyst.py]"]
  node_reporter["Reporter<br/>agent<br/>[agent_reporter.py]"]
  node_handoff["Handoff<br/>typed contract"]
end

subgraph group_infra["Infrastructure"]
  node_telemetry[("Telemetry<br/>data tool")]
  node_provider["Provider<br/>model abstraction<br/>[provider.py]"]
  node_resilience{{"Resilience<br/>guardrails<br/>[resilience.py]"}}
  node_observability["Tracing<br/>structured logs<br/>[observability.py]"]
end

subgraph group_eval["Evaluation"]
  node_metric["Success metric<br/>evaluation<br/>[success_metric.py]"]
end

subgraph group_tests["Tests"]
  node_provider_tests["Provider tests<br/>integration test"]
  node_resilience_tests["Resilience tests<br/>unit test<br/>[test_resilience.py]"]
  node_metric_tests["Metric tests<br/>unit test"]
end

subgraph group_docs["Docs"]
  node_eval_log["Eval log<br/>run record<br/>[EVALUATION_LOG.md]"]
end

node_main -->|"runs"| node_graph
node_main -.->|"can run"| node_metric
node_graph -->|"invokes"| node_analyst
node_graph -->|"invokes"| node_reporter
node_analyst -->|"reads"| node_telemetry
node_analyst -->|"uses"| node_provider
node_analyst -->|"guards"| node_resilience
node_analyst -.->|"traces"| node_observability
node_analyst -->|"produces"| node_handoff
node_handoff -->|"consumed by"| node_reporter
node_reporter -->|"uses"| node_provider
node_reporter -->|"guards"| node_resilience
node_reporter -.->|"traces"| node_observability
node_graph -->|"applies"| node_resilience
node_graph -.->|"emits"| node_observability
node_metric -->|"validates"| node_handoff
node_metric -->|"scores"| node_reporter
node_metric -.->|"records"| node_eval_log
node_provider_tests -.->|"covers"| node_provider
node_resilience_tests -.->|"covers"| node_resilience
node_metric_tests -.->|"covers"| node_metric

click node_main "https://github.com/maharanasunil1843/signalmesh/blob/main/main.py"
click node_graph "https://github.com/maharanasunil1843/signalmesh/blob/main/src/graph.py"
click node_analyst "https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_analyst.py"
click node_reporter "https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_reporter.py"
click node_handoff "https://github.com/maharanasunil1843/signalmesh/blob/main/src/handoff_contract.py"
click node_telemetry "https://github.com/maharanasunil1843/signalmesh/blob/main/src/tool_network_data.py"
click node_provider "https://github.com/maharanasunil1843/signalmesh/blob/main/src/provider.py"
click node_resilience "https://github.com/maharanasunil1843/signalmesh/blob/main/src/resilience.py"
click node_observability "https://github.com/maharanasunil1843/signalmesh/blob/main/src/observability.py"
click node_metric "https://github.com/maharanasunil1843/signalmesh/blob/main/src/success_metric.py"
click node_eval_log "https://github.com/maharanasunil1843/signalmesh/blob/main/docs/EVALUATION_LOG.md"
click node_provider_tests "https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_provider_integration.py"
click node_resilience_tests "https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_resilience.py"
click node_metric_tests "https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_success_metric.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_graph toneBlue
class node_analyst,node_reporter,node_handoff toneAmber
class node_telemetry,node_provider,node_resilience,node_observability toneMint
class node_metric toneRose
class node_provider_tests,node_resilience_tests,node_metric_tests toneIndigo
class node_eval_log toneTeal
```

## Components

### Runtime

Synchronous CLI execution and graph orchestration

- [main.py](https://github.com/maharanasunil1843/signalmesh/blob/main/main.py): CLI entrypoint · Selects scenario or runs the metric, wires the pipeline, and prints the final report · `main.py`
- [Agent graph](https://github.com/maharanasunil1843/signalmesh/blob/main/src/graph.py): orchestrator · Coordinates Analyst and Reporter with one bounded retry/fail-safe branch · `src/graph.py`

### Agents

Analyst and reporter roles plus their typed boundary

- [Analyst](https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_analyst.py): agent · Interprets telemetry, uses the tool, and produces a validated finding · `src/agent_analyst.py`
- [Reporter](https://github.com/maharanasunil1843/signalmesh/blob/main/src/agent_reporter.py): agent · Consumes only the validated finding and produces the incident report · `src/agent_reporter.py`
- [Handoff](https://github.com/maharanasunil1843/signalmesh/blob/main/src/handoff_contract.py): typed contract · Validated finding passed from Analyst to Reporter · `src/handoff_contract.py`

### Infrastructure

Provider, telemetry, resilience, and observability support

- [Telemetry](https://github.com/maharanasunil1843/signalmesh/blob/main/src/tool_network_data.py): data tool · Synthetic deterministic network telemetry available only to the Analyst · `src/tool_network_data.py`
- [Provider](https://github.com/maharanasunil1843/signalmesh/blob/main/src/provider.py): model abstraction · Protocol plus mock and OpenAI-backed model implementations · `src/provider.py`
- [Resilience](https://github.com/maharanasunil1843/signalmesh/blob/main/src/resilience.py): guardrails · Central retry, timeout, and explicit fail-safe logic · `src/resilience.py`
- [Tracing](https://github.com/maharanasunil1843/signalmesh/blob/main/src/observability.py): structured logs · Emits JSON decision traces separate from agent logic · `src/observability.py`

### Evaluation

Deterministic task success metric and recorded results

- [Success metric](https://github.com/maharanasunil1843/signalmesh/blob/main/src/success_metric.py): evaluation · Deterministic score for triage correctness and safe decline behavior · `src/success_metric.py`

### Tests

Offline and integration test coverage

- [Provider tests](https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_provider_integration.py): integration test · OpenAI-path coverage with environment-gated skip · `tests/test_provider_integration.py`
- [Resilience tests](https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_resilience.py): unit test · Retry and failure-path coverage · `tests/test_resilience.py`
- [Metric tests](https://github.com/maharanasunil1843/signalmesh/blob/main/tests/test_success_metric.py): unit test · Offline deterministic behavior coverage for the success metric · `tests/test_success_metric.py`

### Docs

Evaluation log and project documentation

- [Eval log](https://github.com/maharanasunil1843/signalmesh/blob/main/docs/EVALUATION_LOG.md): run record · Recorded evaluation outcome and notes · `docs/EVALUATION_LOG.md`

## Connections

- main.py → Agent graph: runs · Entry point launches the orchestration layer
- main.py → Success metric: can run · CLI can execute the deterministic success metric path
- Agent graph → Analyst: invokes · Orchestration starts with the Analyst
- Agent graph → Reporter: invokes · Reporter is called after validated analysis
- Analyst → Telemetry: reads · Only the Analyst may access raw telemetry
- Analyst → Provider: uses · Agent speaks to model backends through the provider interface
- Analyst → Resilience: guards · Retry and fail-safe behavior is centralized outside agent logic
- Analyst → Tracing: traces · Analysis decisions are emitted as structured traces
- Analyst → Handoff: produces · Validated finding becomes the typed boundary object
- Handoff → Reporter: consumed by · Reporter accepts only the typed, validated finding
- Reporter → Provider: uses · Reporter can use the provider without vendor SDK coupling
- Reporter → Resilience: guards · Reporter participates in centralized guard and timeout policy
- Reporter → Tracing: traces · Final reporting decisions are traced structurally
- Agent graph → Resilience: applies · Graph enforces one bounded retry and fail-safe unresolved outcome
- Agent graph → Tracing: emits · Pipeline control-flow decisions are traced
- Success metric → Handoff: validates · Metric checks whether the router id survives into the handoff/report path
- Success metric → Reporter: scores · Metric inspects report quality and safe decline behavior
- Success metric → Eval log: records · Evaluation outcome is documented
- Provider tests → Provider: covers · Exercises the real provider path when configured
- Resilience tests → Resilience: covers · Validates retry and failure behavior
- Metric tests → Success metric: covers · Checks deterministic offline scoring behavior
