01Beginner
Foundations

Building a Neuron

The smallest possible Cosmonapse program - one Neuron, one Axon, one Dendrite, one TASK, one reply. Single process, in-memory Synapse, no broker. The example to read first.

NeuronAxonDendriteSynapsePathway
Open
02Intermediate
Web integration

Building an Orchestrator API

Wire a Dendrite into Flask, FastAPI, Express, or raw WSGI. Your HTTP framework stays at the edge and dispatches TASKs from its route handlers - the Neuron never sees HTTP, the framework never sees the Synapse.

DendriteSynapsePathway
Open
03Beginner
Orchestration

Orchestrator + Round Robin

A Cortex (orchestrator Dendrite) load-balances prompts across two workers in a plain rotation. Slide across five stacks - Python and TypeScript over devsynapse, NATS, and Kafka.

NeuronAxonDendriteSynapse
Open
04Beginner
Consume

Pathway - three consumption shapes

One primitive, three faces: await pw.wait() for sequential request/reply, @pw.on(SignalType.X) for reactive trace-scoped callbacks, and async for sig in pw: for streaming. Plus scope="terminal" for decentralised orchestration and observe_pathway() for non-originating watchers.

PathwayDendriteSynapse
Open
05Intermediate
Shared memory

Integrating an Engram

Bind shared memory to a Neuron with EngramBinding. The Neuron calls recall() and imprint() to read and write the bound Engram without ever touching the protocol. Backed by InMemoryEngram; swap for SqliteEngram / PostgresEngram without editing Neuron code.

EngramEngramBindingAxonDendrite
Open
06Intermediate
Decentralised

No Orchestrator

Drop the Cortex. Every worker hears every task and runs the same pure owner_of(trace_id), so exactly one claims each - no coordination, no queue. Same five stacks via the slider.

AxonDendriteSynapse
Open
07Intermediate
Neuron sources

Real-world Neurons (MCP + web edge)

A Neuron is anything that interacts with the real world - here, a wrapped stdio MCP server. An HTTP API is not a Neuron: your web framework (Flask / Express) stays at the edge and dispatches TASKs from its route handlers via an orchestrator Dendrite. Same five stacks via the slider.

NeuronAxonDendriteSynapse
Open
08Advanced
Discovery

Capability-based Routing

A router Dendrite holds a RegistryStore and discovers workers from their REGISTER signals. Each task names a capability; the router finds a live worker that advertises it - no hard-coded ids. Same five stacks via the slider.

AxonDendriteRegistryStoreSynapse
Open
09Advanced
Atomic claim

Bidding - TASK_OFFER / BID / TASK_AWARDED

Competitive bidding for capability-routed dispatch. Workers register on_task_offer + call bid(); the producer picks a winner by first_bid, lowest_cost, or highest_confidence and emits TASK_AWARDED. Atomic claim for heterogeneous deployments where queue-group routing falls short.

DendritePathwaySynapse
Open
10Advanced
Retrieval

Full RAG System

Retrieval-augmented generation built entirely on Cosmonapse primitives - four Neurons across two workers, three Engrams across two hosts, run as a staged retrieve → rerank → generate pipeline on one trace. Hybrid semantic + lexical retrieval fused by reciprocal rank, plus an answer cache shared through one Engram binding.

NeuronAxonEngramPathway
Open
11Advanced
Coding agent

RAG + MCP Coding Agent

RAG-grounded code generation that lands on disk and runs. A coder Neuron recalls the team style guide from a VectorEngram, an MCP filesystem Neuron writes the file, and a runner Neuron executes it - retrieve → write → run, one trace. The model follows rules it was never trained on, supplied entirely by retrieval.

NeuronEngramMCPPathway
Open
12Advanced
Resilience

Retry, STOP & Rollback

Resilience patterns over the RAG primitives, fully offline. run_with_retry re-dispatches a stuck stage on a fresh trace after STOPping the abandoned one; stop_trace cooperatively cancels a whole workflow by trace_id; and stop_trace(rollback=True) replays each Engram's saga journal to undo a half-finished write.

DendriteRetryStrategyEngramPathway
Open