The Microship Protocol
MSP 0.1.1-beta.1 · Public beta
Copyright © 2026 Lucas Nicolás Masiero. Specification text, diagrams, and illustrative examples are licensed under CC BY 4.0.
What is MSP?
The Microship Protocol (MSP) defines how to design and implement software components called mships.
An mship’s I/O consists of input and output interfaces, also called ports. IN holds the interfaces the mship provides to callers. OUT holds the interfaces it requires from its environment.
The pinout shows what to connect. Its arrows point from adapters to the interfaces they bind. Schematic traces show runtime interactions.
How does MSP work?
1. Mship Architecture
Define what the mship provides and requires, then draw its components and the traces between them.
Grid space · proposed
| Area | Responsibility |
|---|---|
| IN | Provided ports, transport dispatch, and handlers |
| CORE | Flows and domain logic |
| OUT | Required interfaces, their implementations, and adapters |
An area is a grid with an architectural role, and each child occupies a rectangle in its parent grid. Here starts at and spans cells.
Component toolkit
- Adapters. Like an outlet adapter, presents the interface the caller expects and translates calls and results between it and an existing interface or concrete implementation .
- Flow. A solid trace is a synchronous call, including its result. A dotted trace hands off work that can finish later, even if the sender waits for an acknowledgement. An arrowhead points to the receiver. A headless trace means either endpoint can initiate the interaction.
- Wrappers. places the timeout outside the rate limiter around .
A direction adds one to the out-degree of and the in-degree of . A headless trace contributes both directed edges.
Layout multiplicities · proposed
Read each endpoint from the opposite entity. In crow’s-foot notation, a circle means zero, a bar means one, and a fork means many.
The root grid has zero parents. Every other grid and every node has exactly one parent.
Example · mship
| Area | Components |
|---|---|
| IN | h HTTP handler, records interface |
| CORE | timeout, fl flow, cr domain rules |
| OUT | Persistence interface, SQL adapter, SQL client interface, event interface, RabbitMQ adapter |
For a read, fl calls Find through , and translates that call into a query on . Find returns matching records, an empty collection when nothing matches, or a storage error. The flow applies cr to the returned records and propagates storage errors. A write can also hand off an event through .
Geometry and validation · proposed
For a parent with rows and columns, a child starts at and spans cells.
- Keep sibling allocations disjoint. Every component outline and label fits its allocation.
- Use a node bounding box in SVG units before stroke. Labels use one or two characters.
- Route traces between node outlines and around unrelated nodes. A crossing alone carries no connection.
- Keep controller nesting explicit and acyclic.
For child with parent , local position adds to the parent’s absolute position. Drawing properties inherit through SVG groups unless overridden.
MSP defines the schematic model. MSN is planned as a declarative way to author it. Its status as a normative interchange format is open.
2. Mship Assembly
In this proposed assembly, startup supplies the OUT interfaces, wires the CORE flows and IN handlers, then starts accepting traffic.
IN · Provided interfaces
Each IN interface declares one fixed transport, HTTP or gRPC. Multiplexer m dispatches by method and path for HTTP or by service method for gRPC. Each route entry r is paired one-to-one with an entry flow fl. Handler h translates the request into the flow’s input and maps its result back to the transport.
CORE · Flows and domain rules
Each entry flow fl runs a use case. It calls cr for domain rules and uses OUT interfaces i for infrastructure. Flows can share domain rules and OUT implementations. The read flow, for example, obtains records through Persistence and passes them to cr.
OUT · Required interfaces
At startup, factory f reads the selection and parameters for its key in the active profile. It selects one registered concrete implementation c, delegates construction to builder b, and returns the result as i for the flow. The f–c crow’s feet count the available choices.
For Persistence, the in-memory choice implements i directly. The SQLite choice builds an adapter that presents i and calls the SQL client interface.
Example profile and startup
The loader uses .config/init.toml to select a profile and rejects duplicate factory entries. Each factory looks up its settings by fKey.
.config/init.toml
profile = "local"
.config/profiles/local.toml
[out.store]
cKey = "sqlite"
[out.store.cParams]
file = "records.db"
[out.events]
cKey = "rabbit"
[out.events.cParams]
exchange = "mship.events"
urlEnv = "MSHIP_AMQP_URL"
In the Go-style pseudocode, try propagates an error. f switches on cKey and passes the decoded cParams to the selected builder b.
func (fl ReadFlow) Run(q Query) (Result, error) {
records := try fl.store.Find(q.Filter)
return fl.cr.Evaluate(q, records), nil
}
type fValue struct {
cKey string
cParams Raw
}
type Config map[string]fValue
func f(cfg Config, fKey string) (Persistence, Close, error) {
choice := try cfg.Require(fKey)
switch choice.cKey {
case "sqlite":
p := try Decode[SQLiteParams](choice.cParams)
return bSQLite(p)
case "memory":
p := try Decode[MemoryParams](choice.cParams)
return bMemory(p)
default:
return nil, nil, UnknownImplementation(fKey, choice.cKey)
}
}
func Run() error {
cfg := try sdk.LoadConfig(".config")
store, closeStore := try f(cfg, "out.store")
defer closeStore()
events, closeEvents := try BindEvents(cfg, "out.events")
defer closeEvents()
cr := NewRules()
read := NewReadFlow(cr, store)
write := NewWriteFlow(cr, store, events)
m := NewMux()
m.GET("/records", ReadHandler(read))
m.POST("/records", WriteHandler(write))
return ServeUntilShutdown(m)
}
Each builder cleans up its own partial resources on failure. If a later binding fails, Run closes the bindings it already constructed.
Assembly notation and Go scaffold
| Symbol | Meaning |
|---|---|
i |
Interface (port) |
c |
Concrete implementation |
f |
Factory that selects and builds one c to supply i |
a |
Adapter that exposes an interface by translating calls to another interface or concrete implementation |
b |
Builder for a concrete implementation |
m |
Multiplexer |
r |
Route entry |
h |
Handler |
fl |
Entry flow |
cr |
Core domain rules |
ct |
Controller |
| Role | Path | Owns |
|---|---|---|
| — | design/ |
Schematic and port contracts |
| — | bin/entry |
Profile loading, construction, and startup |
in |
in/ |
Transport dispatch and handlers for HTTP or gRPC |
fl · flow |
internal/flow/ |
Use-case orchestration across core and OUT |
cr · core |
internal/core/ |
Domain rules |
out |
out/<capability>/ |
Required interfaces, concrete implementations, and adapters |
| — | .config/ |
Profile selection and binding parameters |
Beta conformance
An mship claiming conformance with this edition must meet four requirements.
- Publish the contracts. Identify the mship release and MSP edition. Name the provided and required interfaces. Document their operations or messages, inputs, outputs, and failures. Specify synchronous or asynchronous interactions, any delivery, ordering, or timing guarantees, and the transport mappings callers use.
- Show the architecture. Map schematic interfaces to their contracts. Show interactions through IN, CORE, and OUT. CORE uses interfaces defined by the mship to access infrastructure.
- Bind before serving. Supply a compatible implementation for every required interface before IN accepts traffic.
- Clean up failed startup. If assembly fails, stop before IN accepts traffic and release resources acquired during that attempt, including resources from partial construction.
Checks for the first implementation · proposed
| Exercise | Expected behavior |
|---|---|
| Run the same reads through the SQLite and in-memory implementations with matching data, no matches, and a storage failure. | Equivalent cases give the same result or documented failure through the provided interface. |
| Start with missing factory settings, a duplicate factory entry, an unknown choice, or invalid parameters. | Startup fails before IN accepts traffic. |
| Fail event adapter construction after opening storage. | Startup fails before IN accepts traffic and cleans up storage and any partially acquired event resources. |
Open decisions
- Composition across mships, controller guarantees, cross-area grouping, and mapper symbols.
- Portable profile schema and MSN interchange.
Glossary and schematic labels
| Term | Meaning |
|---|---|
| MSP | Microship Protocol |
| mship | Microship, a software component with explicit provided and required ports |
| MSN | Microship Schematic Notation |
| SVG | Scalable Vector Graphics, the schematic output format |
| IN / CORE / OUT | Provided interfaces and transport / flows and domain / required interfaces and infrastructure |
| Interface / port | Contract an mship provides or requires |
| Adapter | Component that exposes one interface by translating calls to another interface or concrete implementation |
| Controller / wrapper | Operational policy applied around a component, such as a timeout |
| Binding / profile | Supplying a required interface with an implementation / a named collection of implementation selections and settings |
| Multiplicity | The number of instances allowed at one end of a relationship for one instance at the other end |
| TOML | Tom’s Obvious, Minimal Language, the example profile format |
| HTTP / RPC / gRPC | Hypertext Transfer Protocol / remote procedure call / the gRPC framework for RPC |
| AMQP | Advanced Message Queuing Protocol |
| SQL / SQLite / RabbitMQ | Structured Query Language / an embedded SQL database / a message broker |
| CLI / SDK | Command-line interface / software development kit |
| Symbol | Meaning |
|---|---|
| Provided interface, storage interface, SQL client interface, event interface, RabbitMQ adapter, timeout wrapper | |
| Grid, origin, row and column spans | |
cfg, fKey |
Loaded configuration map, key for a factory entry |
fValue |
Profile settings for one factory entry |
cKey, cParams |
Concrete implementation key and its parameters |
Close, Raw |
Cleanup function, undecoded adapter settings |