# kosasih/autonomous-swarm-negotiation-engine architecture

> Architecture diagram of the GitHub repository kosasih/autonomous-swarm-negotiation-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kosasih/autonomous-swarm-negotiation-engine
- Repository: https://github.com/kosasih/autonomous-swarm-negotiation-engine

## Overview

ASNE is an autonomous B2B negotiation engine. Its sampled REST workflow accepts a deal request, creates an ethics engine and deal environment, runs a negotiating swarm, and returns the deal outcome and ethics report. The documented HyperOrchestrator adds causal and counterparty reasoning, privacy proofs, constitutional review, contract generation, blockchain settlement, and post-session improvement. Other README capabilities—market intelligence, natural-language negotiation, quantum optimization, integrations, and digital-twin context—are represented, but their wiring is not established by the sampled excerpts.

Main entry points: [`asne/orchestrator/__init__.py`](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/orchestrator/__init__.py) (HyperOrchestrator), [`asne/api/server.py`](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/api/server.py) (REST API), [`asne/agents/swarm.py`](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/agents/swarm.py) (Negotiator swarm), [`asne/ethics/engine.py`](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/ethics/engine.py) (Ethics engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and orchestration"]
  node_api["REST API<br/>[server.py]"]
  node_orchestrator["HyperOrchestrator<br/>[__init__.py]"]
end

subgraph group_negotiation["Negotiation runtime"]
  node_environment["Deal environment<br/>[deal_env.py]"]
  node_swarm["Negotiator swarm<br/>[swarm.py]"]
  node_agents["Agent strategies"]
end

subgraph group_intelligence["Intelligence and context"]
  node_causal["Causal reasoning<br/>[causal.py]"]
  node_tom["Theory of mind<br/>[theory_of_mind.py]"]
  node_counterfactual["Counterfactual reasoning<br/>[counterfactual.py]"]
  node_selfimprove["Self improvement<br/>[self_improve.py]"]
  node_market["Market intelligence<br/>[__init__.py]"]
  node_llm["LLM negotiation<br/>[__init__.py]"]
  node_quantum["Quantum optimizer<br/>[optimizer.py]"]
  node_twin["Digital twin<br/>[interface.py]"]
  node_connectors["API connectors<br/>[connector.py]"]
end

subgraph group_governance["Safety and privacy"]
  node_ethics["Ethics engine<br/>[engine.py]"]
  node_audit[("Transparency log<br/>[transparency.py]")]
  node_constitution["Constitutional AI<br/>[__init__.py]"]
  node_redteam["Red-team module<br/>[__init__.py]"]
  node_zkp["Privacy proofs<br/>[__init__.py]"]
end

subgraph group_settlement["Deal completion"]
  node_contract["Contract generator<br/>[smart_contract.py]"]
  node_settlement["Blockchain settlement<br/>[settlement.py]"]
end

node_client(("API client"))
node_chain(("Blockchain network"))
node_llmprovider(("LLM provider"))

node_client -->|"submits deal"| node_api
node_api -->|"creates ethics"| node_ethics
node_api -->|"creates deal"| node_environment
node_api -->|"runs negotiation"| node_swarm
node_swarm -->|"negotiates in"| node_environment
node_swarm -->|"uses ethics"| node_ethics
node_ethics -->|"logs proposals"| node_audit
node_api -->|"returns outcome"| node_client
node_orchestrator -->|"runs negotiation"| node_swarm
node_orchestrator -->|"requests intervention"| node_causal
node_orchestrator -->|"updates beliefs"| node_tom
node_orchestrator -->|"uses reasoning"| node_counterfactual
node_orchestrator -->|"proves sufficiency"| node_zkp
node_orchestrator -->|"checks agreement"| node_constitution
node_orchestrator -->|"generates contract"| node_contract
node_orchestrator -->|"settles deal"| node_settlement
node_orchestrator -->|"records outcome"| node_selfimprove
node_contract -->|"returns source"| node_orchestrator
node_settlement -.->|"settles on-chain"| node_chain
node_llm -.->|"requests language"| node_llmprovider

click node_api "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/api/server.py"
click node_orchestrator "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/orchestrator/__init__.py"
click node_environment "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/environment/deal_env.py"
click node_swarm "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/agents/swarm.py"
click node_agents "https://github.com/kosasih/autonomous-swarm-negotiation-engine/tree/main/asne/agents"
click node_ethics "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/ethics/engine.py"
click node_audit "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/ethics/transparency.py"
click node_constitution "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/safety/__init__.py"
click node_redteam "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/safety/__init__.py"
click node_zkp "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/zkp/__init__.py"
click node_causal "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/causal.py"
click node_tom "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/theory_of_mind.py"
click node_counterfactual "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/counterfactual.py"
click node_selfimprove "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/self_improve.py"
click node_market "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/market/__init__.py"
click node_llm "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/llm/__init__.py"
click node_quantum "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/quantum/optimizer.py"
click node_twin "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/twin/interface.py"
click node_connectors "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/api_hub/connector.py"
click node_contract "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/blockchain/smart_contract.py"
click node_settlement "https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/blockchain/settlement.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_api,node_orchestrator,node_client toneBlue
class node_environment,node_swarm,node_agents toneAmber
class node_causal,node_tom,node_counterfactual,node_selfimprove,node_market,node_llm,node_quantum,node_twin,node_connectors toneMint
class node_ethics,node_audit,node_constitution,node_redteam,node_zkp toneRose
class node_contract,node_settlement,node_chain,node_llmprovider toneIndigo
```

## Components

### API and orchestration

- [REST API](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/api/server.py): `asne/api/server.py`
- [HyperOrchestrator](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/orchestrator/__init__.py): `asne/orchestrator/__init__.py`

### Negotiation runtime

- [Deal environment](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/environment/deal_env.py): `asne/environment/deal_env.py`
- [Negotiator swarm](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/agents/swarm.py): `asne/agents/swarm.py`
- [Agent strategies](https://github.com/kosasih/autonomous-swarm-negotiation-engine/tree/main/asne/agents): `asne/agents`

### Intelligence and context

- [Causal reasoning](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/causal.py): `asne/intelligence/causal.py`
- [Theory of mind](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/theory_of_mind.py): `asne/intelligence/theory_of_mind.py`
- [Counterfactual reasoning](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/counterfactual.py): `asne/intelligence/counterfactual.py`
- [Self improvement](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/intelligence/self_improve.py): `asne/intelligence/self_improve.py`
- [Market intelligence](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/market/__init__.py): `asne/market/__init__.py`
- [LLM negotiation](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/llm/__init__.py): `asne/llm/__init__.py`
- [Quantum optimizer](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/quantum/optimizer.py): `asne/quantum/optimizer.py`
- [Digital twin](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/twin/interface.py): `asne/twin/interface.py`
- [API connectors](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/api_hub/connector.py): `asne/api_hub/connector.py`

### Safety and privacy

- [Ethics engine](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/ethics/engine.py): `asne/ethics/engine.py`
- [Transparency log](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/ethics/transparency.py): `asne/ethics/transparency.py`
- [Constitutional AI](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/safety/__init__.py): `asne/safety/__init__.py`
- [Red-team module](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/safety/__init__.py): `asne/safety/__init__.py`
- [Privacy proofs](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/zkp/__init__.py): `asne/zkp/__init__.py`

### Deal completion

- [Contract generator](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/blockchain/smart_contract.py): `asne/blockchain/smart_contract.py`
- [Blockchain settlement](https://github.com/kosasih/autonomous-swarm-negotiation-engine/blob/main/asne/blockchain/settlement.py): `asne/blockchain/settlement.py`

### Other components

- **API client**
- **Blockchain network**
- **LLM provider**

## Connections

- API client → REST API: submits deal
- REST API → Ethics engine: creates ethics
- REST API → Deal environment: creates deal
- REST API → Negotiator swarm: runs negotiation
- Negotiator swarm → Deal environment: negotiates in
- Negotiator swarm → Ethics engine: uses ethics
- Ethics engine → Transparency log: logs proposals
- REST API → API client: returns outcome
- HyperOrchestrator → Negotiator swarm: runs negotiation
- HyperOrchestrator → Causal reasoning: requests intervention
- HyperOrchestrator → Theory of mind: updates beliefs
- HyperOrchestrator → Counterfactual reasoning: uses reasoning
- HyperOrchestrator → Privacy proofs: proves sufficiency
- HyperOrchestrator → Constitutional AI: checks agreement
- HyperOrchestrator → Contract generator: generates contract
- HyperOrchestrator → Blockchain settlement: settles deal
- HyperOrchestrator → Self improvement: records outcome
- Contract generator → HyperOrchestrator: returns source
- Blockchain settlement → Blockchain network: settles on-chain
- LLM negotiation → LLM provider: requests language
