# yogeshwars-cys/autonomous-neighbourhood-watch-anw- architecture

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

- Interactive diagram: https://gitdiagram.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-
- Repository: https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-

## Overview

ANW is a research system for decentralized neighbourhood awareness, not a conventional centralized IDS. An operator starts an agent; each agent observes a local sensor, updates its local reasoning, exchanges information with peers, adjusts confidence, and decides whether action is warranted. The richer `anw/src` tree adds semantic event detection, bounded memory, world-model inference, planning, and reflection. The README documents the broad agent cycle; the sampled source confirms selected runtime entry points and capabilities, but does not expose enough calls to assert most internal subsystem wiring.

Main entry points: [`anw/src/internal/agent/agent.go`](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/agent.go) (Agent loop), [`anw/src/internal/agent/reflection_agent.go`](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection_agent.go) (Reflection agent), [`anw/src/internal/agent/communicator.go`](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/communicator.go) (UDP communicator), [`anw/src/cmd/agent/main.go`](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/cmd/agent/main.go) (Agent command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Agent runtime"]
  node_cli["Agent command<br/>[main.go]"]
  node_agent["Agent loop<br/>[agent.go]"]
  node_sensor["Local sensor<br/>[sensor.go]"]
  node_state["Agent state<br/>[state.go]"]
end

subgraph group_reasoning["Local reasoning"]
  node_event["Event detection<br/>[event.go]"]
  node_detector["Anomaly detector<br/>[detector.go]"]
  node_feature["Event features<br/>[feature.go]"]
  node_episodic[("Episodic memory<br/>[episodic_memory.go]")]
  node_longterm[("Long-term memory")]
  node_world[("Local world model<br/>[world.go]")]
  node_inference["Bounded inference<br/>[inference.go]"]
end

subgraph group_network["Peer collaboration"]
  node_communicator["UDP communicator<br/>[communicator.go]"]
  node_neighbors["Neighbor tracking<br/>[neighbor.go]"]
  node_addressbook["Peer discovery<br/>[addressbook.go]"]
  node_cooperation["Cooperative scoring<br/>[cooperation.go]"]
  node_trust["Peer reputation<br/>[reputation.go]"]
  node_corroboration["Corroboration<br/>[corroboration.go]"]
end

subgraph group_autonomy["Adaptive autonomy"]
  node_advisory["Advisories<br/>[advisory.go]"]
  node_planner["Commitment planner<br/>[planner.go]"]
  node_plan["Plans and actions<br/>[plan_action.go]"]
  node_reflection["Reflection<br/>[reflection.go]"]
  node_reflection_agent["Reflection agent"]
  node_metrics["Reflection metrics"]
end

node_operator(("Operator"))
node_peers(("Peer agents"))

node_operator -->|"starts"| node_cli
node_cli -->|"runs"| node_agent
node_agent -->|"observes"| node_sensor
node_agent -->|"updates"| node_state
node_agent -->|"exchanges updates"| node_communicator
node_communicator -->|"sends heartbeats"| node_peers
node_peers -->|"sends heartbeats"| node_communicator
node_agent -.->|"assesses"| node_detector
node_detector -.->|"classifies"| node_event
node_event -.->|"uses features"| node_feature
node_agent -.->|"records events"| node_episodic
node_agent -.->|"updates summaries"| node_longterm
node_agent -.->|"tracks peers"| node_neighbors
node_agent -.->|"discovers peers"| node_addressbook
node_agent -.->|"cooperates"| node_cooperation
node_cooperation -->|"reinforces trust"| node_trust
node_agent -.->|"maintains local model"| node_world
node_world -.->|"supports inference"| node_inference
node_agent -.->|"corroborates"| node_corroboration
node_agent -.->|"forms advisories"| node_advisory
node_agent -.->|"plans commitments"| node_planner
node_planner -.->|"selects actions"| node_plan
node_agent -.->|"reflects"| node_reflection_agent
node_reflection_agent -.->|"evaluates commitments"| node_reflection
node_reflection_agent -.->|"reports measures"| node_metrics

click node_cli "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/cmd/agent/main.go"
click node_agent "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/agent.go"
click node_sensor "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/sensor.go"
click node_state "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/state.go"
click node_event "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/event.go"
click node_detector "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/detector.go"
click node_feature "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/feature.go"
click node_episodic "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/episodic_memory.go"
click node_longterm "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/long_term_memory.go"
click node_communicator "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/communicator.go"
click node_neighbors "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/neighbor.go"
click node_addressbook "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/addressbook.go"
click node_cooperation "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/cooperation.go"
click node_trust "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reputation.go"
click node_world "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/world.go"
click node_inference "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/inference.go"
click node_corroboration "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/corroboration.go"
click node_advisory "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/advisory.go"
click node_planner "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/planner.go"
click node_plan "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/plan_action.go"
click node_reflection "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection.go"
click node_reflection_agent "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection_agent.go"
click node_metrics "https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection_metrics.go"

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_cli,node_agent,node_sensor,node_state toneBlue
class node_event,node_detector,node_feature,node_episodic,node_longterm,node_world,node_inference toneAmber
class node_communicator,node_neighbors,node_addressbook,node_cooperation,node_trust,node_corroboration toneMint
class node_advisory,node_planner,node_plan,node_reflection,node_reflection_agent,node_metrics toneRose
class node_operator,node_peers toneIndigo
```

## Components

### Agent runtime

- [Agent command](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/cmd/agent/main.go): `anw/src/cmd/agent/main.go`
- [Agent loop](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/agent.go): `anw/src/internal/agent/agent.go`
- [Local sensor](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/sensor.go): `anw/src/internal/agent/sensor.go`
- [Agent state](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/state.go): `anw/src/internal/agent/state.go`

### Local reasoning

- [Event detection](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/event.go): `anw/src/internal/agent/event.go`
- [Anomaly detector](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/detector.go): `anw/src/internal/agent/detector.go`
- [Event features](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/feature.go): `anw/src/internal/agent/feature.go`
- [Episodic memory](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/episodic_memory.go): `anw/src/internal/agent/episodic_memory.go`
- [Long-term memory](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/long_term_memory.go): `anw/src/internal/agent/long_term_memory.go`
- [Local world model](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/world.go): `anw/src/internal/agent/world.go`
- [Bounded inference](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/inference.go): `anw/src/internal/agent/inference.go`

### Peer collaboration

- [UDP communicator](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/communicator.go): `anw/src/internal/agent/communicator.go`
- [Neighbor tracking](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/neighbor.go): `anw/src/internal/agent/neighbor.go`
- [Peer discovery](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/addressbook.go): `anw/src/internal/agent/addressbook.go`
- [Cooperative scoring](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/cooperation.go): `anw/src/internal/agent/cooperation.go`
- [Peer reputation](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reputation.go): `anw/src/internal/agent/reputation.go`
- [Corroboration](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/corroboration.go): `anw/src/internal/agent/corroboration.go`

### Adaptive autonomy

- [Advisories](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/advisory.go): `anw/src/internal/agent/advisory.go`
- [Commitment planner](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/planner.go): `anw/src/internal/agent/planner.go`
- [Plans and actions](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/plan_action.go): `anw/src/internal/agent/plan_action.go`
- [Reflection](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection.go): `anw/src/internal/agent/reflection.go`
- [Reflection agent](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection_agent.go): `anw/src/internal/agent/reflection_agent.go`
- [Reflection metrics](https://github.com/yogeshwars-cys/autonomous-neighbourhood-watch-anw-/blob/main/anw/src/internal/agent/reflection_metrics.go): `anw/src/internal/agent/reflection_metrics.go`

### Other components

- **Operator**
- **Peer agents**

## Connections

- Operator → Agent command: starts (evidence: `anw/src/cmd/agent/main.go`)
- Agent command → Agent loop: runs (evidence: `anw/src/cmd/agent/main.go`)
- Agent loop → Local sensor: observes
- Agent loop → Agent state: updates
- Agent loop → UDP communicator: exchanges updates
- UDP communicator → Peer agents: sends heartbeats (evidence: `anw/src/internal/agent/communicator.go`)
- Peer agents → UDP communicator: sends heartbeats (evidence: `anw/src/internal/agent/communicator.go`)
- Agent loop → Anomaly detector: assesses
- Anomaly detector → Event detection: classifies
- Event detection → Event features: uses features
- Agent loop → Episodic memory: records events
- Agent loop → Long-term memory: updates summaries
- Agent loop → Neighbor tracking: tracks peers
- Agent loop → Peer discovery: discovers peers
- Agent loop → Cooperative scoring: cooperates
- Cooperative scoring → Peer reputation: reinforces trust (evidence: `anw/src/internal/agent/cooperation.go`)
- Agent loop → Local world model: maintains local model
- Local world model → Bounded inference: supports inference
- Agent loop → Corroboration: corroborates
- Agent loop → Advisories: forms advisories
- Agent loop → Commitment planner: plans commitments
- Commitment planner → Plans and actions: selects actions
- Agent loop → Reflection agent: reflects
- Reflection agent → Reflection: evaluates commitments
- Reflection agent → Reflection metrics: reports measures
