Wiremap format
Introduction
Wiremap describes the architecture of one repository's system: what runs and what stores (nodes), how each acts on the others (edges), the sets of nodes the repository states (groups), and constraints on edges (rules). Every edge, every group and every node the repository defines is backed by anchors: lines of the repository's own files that make it exist, or, when that proof lives outside the repository, a note that says where. A node or edge that is not built yet is marked planned and has no anchors.
A model is two files at the root of the repository:
wiremap/model.txt, the model file, holds the nodes, edges, groups and rules.wiremap/evidence.txt, the evidence file, holds the anchors.
Other files MAY live in wiremap/ beside them, such as the skill's conventions.md: wiremap ignores them.
The repository root is the directory that contains wiremap/. It may be a subdirectory of a git repository, such as one service of a monorepo. The git root is the nearest directory at or above the repository root that holds .git, a directory or, in a worktree or a submodule, a file.
The format is designed to be read as a diff. Each edge is one line inside the block of the node it starts from, so a pull request changes one line per changed edge, and git's hunk header names the node. Each file has a single canonical form, which fixes spacing and sort order, so a diff shows only what changed.
The key words MUST, MUST NOT and MAY are to be interpreted as described in RFC 2119.
Example
wiremap/model.txt:
service billing on go {
read orders-db
write invoices-db
consume order-placed
}
service checkout on go {
call api.pay.example.com
call billing
call fraud-check planned
write orders-db
publish order-placed
}
service fraud-check planned
service storefront on typescript {
call checkout
}
store invoices-db on postgres
store orders-db on postgres
channel order-placed on pubsub
external api.pay.example.com outside
actor user {
call storefront via ingress-nginx
}
group orders {
member checkout
member orders-db
member storefront
}
group payments {
member billing
member invoices-db
}
group shop {
group orders
group payments
}
rule no call to any external except from checkout
rule no edge from storefront to any store
rule no publish to order-placed except from checkout
rule no read from group orders to invoices-db
rule no read to any store on postgres except from any service on go
rule no write to invoices-db except from group paymentswiremap/evidence.txt:
service billing {
at deploy/compose.yaml | billing:
on go at services/billing/go.mod | go 1.22
read orders-db at services/billing/main.go | orders := store.Open(cfg.OrdersDSN)
read orders-db at deploy/billing.env | ORDERS_DSN=postgres://db:5432/orders-db
write invoices-db at services/billing/main.go | invoices := store.Open(cfg.InvoicesDSN)
write invoices-db at deploy/billing.env | INVOICES_DSN=postgres://db:5432/invoices-db
consume order-placed at services/billing/main.go | bus.Subscribe(cfg.Subscription, onOrderPlaced)
consume order-placed known | subscription billing-orders on order-placed is created by the platform team in the cloud console
}
service checkout {
at deploy/compose.yaml | checkout:
on go at services/checkout/go.mod | go 1.22
call api.pay.example.com at services/checkout/pay.go | pay.NewClient(cfg.PayURL)
call api.pay.example.com at deploy/checkout.env | PAY_URL=https://api.pay.example.com/v2
call billing at services/checkout/main.go | billingpb.NewBillingClient(conn)
call billing at deploy/checkout.env | BILLING_ADDR=billing:9000
write orders-db at services/checkout/main.go | orders := store.Open(cfg.OrdersDSN)
write orders-db at deploy/checkout.env | ORDERS_DSN=postgres://db:5432/orders-db
publish order-placed at services/checkout/main.go | bus.Publisher("order-placed")
}
service storefront {
at deploy/compose.yaml | storefront:
on typescript at services/storefront/package.json | "typescript": "^5.4.0"
call checkout at services/storefront/server.ts | new CheckoutClient(process.env.CHECKOUT_URL)
call checkout at deploy/storefront.env | CHECKOUT_URL=http://checkout:8080
}
store invoices-db {
at deploy/billing.env | INVOICES_DSN=postgres://db:5432/invoices-db
on postgres at deploy/billing.env | INVOICES_DSN=postgres://db:5432/invoices-db
}
store orders-db {
at deploy/billing.env | ORDERS_DSN=postgres://db:5432/orders-db
on postgres at deploy/billing.env | ORDERS_DSN=postgres://db:5432/orders-db
}
channel order-placed {
at deploy/topics.tf | name = "order-placed"
on pubsub at deploy/topics.tf | resource "google_pubsub_topic" "order_placed" {
}
actor user {
call storefront at deploy/ingress.yaml | service: storefront
}
group orders {
member checkout at docs/teams.md | - checkout: run by the orders team
member orders-db at docs/teams.md | - orders-db: run by the orders team
member storefront at docs/teams.md | - storefront: run by the orders team
}
group payments {
at docs/teams.md | The payments team runs billing and invoices-db.
}
group shop {
at docs/teams.md | The shop department has two teams: orders and payments.
}Lexical structure
This section and the grammar say what a reader accepts. The canonical form is stricter.
Notation. The grammar here and in the next section uses ::= for definitions, | for alternatives, ? for optional, * for zero or more and + for one or more. Quoted strings are literal. [...] is one character from the characters and ranges it lists, so [a-z0-9] is one ASCII lowercase letter or ASCII digit.
Encoding. Both files MUST exist and be UTF-8 without a byte order mark. wiremap/, wiremap/model.txt and wiremap/evidence.txt MUST NOT be symbolic links, since a link would let an anchor reach the model through another path, where its own text would hold any snippet. A line ends with LF (U+000A) or CRLF, and the last line MAY have no line ending. A file MUST NOT contain TAB (U+0009), or CR (U+000D) other than before LF. A space is U+0020 only. Spaces at the end of a line are ignored.
Blank lines contain nothing but spaces. Comment lines are any spaces, then #, then any text. Before parsing, a reader sets both aside. A comment belongs to the next line that is neither blank nor a comment, which may be a block's closing }, or to the end of the file if there is none.
Identifiers. In the rules below, a letter is any Unicode letter and a digit is any Unicode decimal digit.
node-id ::= ( letter | digit | "_" ) ( letter | digit | "." | "-" | "_" | "/" | "@" | "+" | "~" | "%" )*
group-id ::= node-id
via-id ::= node-idIdentifiers are case-sensitive. Via ids are names, not references.
Other tokens.
nameis one or more characters other than space,,,:and{. Names gives the shape it MUST have.techis one or more characters other than space,,,:and{. Engines and languages gives the shape it MUST have.pathandsnippetare the two parts of an anchor's text afteratand its spaces. They are split at the first|in that text with a space on each side, and the spaces around that|belong to neither part. Neither part may be empty.textis the rest of aknownline after its|and spaces. It may be any text, and it MUST NOT be empty.
Reserved words. Keywords are recognized only by their position, so any word may be an id except these: no node id or group id is any or group.
Grammar
model ::= ( node | group | rule )*
node ::= node-kind SP node-id ( SP "as" SP name )? ( SP "on" SP tech )? ( SP ( "outside" | "planned" ) )?
( EOL | OPEN edge* CLOSE )
edge ::= SP edge-kind SP node-id ( SP "planned" )? ( SP "via" SP via-id )? EOL
group ::= "group" SP group-id ( EOL | OPEN group-item* CLOSE )
group-item ::= SP ( "member" SP node-id | "group" SP group-id ) EOL
rule ::= "rule" SP "no" SP kinds ( SP "from" SP selectors )? ( SP "to" SP selectors )?
( SP "except" SP exception )* EOL
exception ::= "from" SP selectors ( SP "to" SP selectors )? | "to" SP selectors
kinds ::= "edge" | edge-kind ( COMMA edge-kind )*
selectors ::= selector ( COMMA selector )*
selector ::= "any" SP node-kind ( SP "on" SP tech )? | "group" SP group-id | node-id
evidence ::= ( node-anchors | group-anchors )*
node-anchors ::= node-kind SP node-id OPEN ( SP ( "on" SP tech SP | edge-kind SP node-id SP )? anchor EOL )* CLOSE
group-anchors ::= "group" SP group-id OPEN ( SP ( "member" SP node-id SP )? anchor EOL )* CLOSE
anchor ::= "at" SP path SP "|" SP snippet | "known" SP "|" SP text
node-kind ::= "service" | "job" | "store" | "channel" | "external" | "actor"
edge-kind ::= "call" | "read" | "write" | "publish" | "consume"
OPEN ::= " "* "{" EOL
CLOSE ::= " "* "}" EOL
COMMA ::= " "* "," " "*
SP ::= " "+
EOL ::= LF | CR LF | end of fileSemantics
Node ids and group ids are two separate namespaces. A node or group production declares the id that follows its keyword. In each namespace, an id MUST NOT be declared twice, and every other node id or group id, in either file, MUST be declared. A kinds or selectors list MUST NOT repeat an item.
Nodes
A node is something deployed or used on its own, with no parts the model describes. It has one kind:
| Kind | What it is |
|---|---|
service | a workload that runs code |
job | work a platform runs on a schedule or a trigger |
store | a database, cache or shared volume, as code connects to it |
channel | a topic, queue or exchange that code publishes to or consumes from |
external | a system the product uses but does not build |
actor | someone who uses the system, such as user or operator |
A job has no long-running workload of its own: a scheduled query, a Dataflow or Cloud Scheduler job, a Kubernetes CronJob. Work that a service schedules in its own code or deployment is part of that service.
Names
as <Name> gives a node the name the viewer shows in place of its id, for an id that runs words together, such as service workshopmanagementeventhandler as WorkshopManagementEventHandler. The id stays the one the repository uses, so that it can still be found in the code.
- A name MUST be UpperCamelCase: an uppercase letter, then letters and digits only.
- A name MUST spell its id: with case ignored, it MUST equal the id with the id's
-,_and.removed, each of its letters being the id's letter at that place or that letter's uppercase or lowercase. A name can only add capitals, never change the words.
A name is how the node is shown, not a claim about the architecture, so it needs no anchor.
Engines and languages
on <tech> says what a node is built on: the engine of a store or a channel, such as store orders-db on postgres or channel orders on kafka, or the language of a service or a job, such as service cartservice as CartService on csharp or job nightly-report on sql. A service's or a job's language is the language of its entry point, or of its query. A framework is never a tech.
- Only a service, a job, a store or a channel MAY have a tech. An external or an actor MUST NOT.
- A tech MUST be one lowercase word: an ASCII lowercase letter, then ASCII lowercase letters and digits. It names the engine or the language without a version, so a store whose image moves from
postgres:16topostgres:17stayson postgres.
A tech is free text of that shape: check doesn't know which words name real engines and languages, so postgres and postgresql are two different techs. Unlike a name, a tech is a claim about the architecture, so it is anchored, by a tech anchor.
Outside nodes
A node marked outside is not defined under the repository root. Examples are another repository's service, a service in another directory of the same monorepo, a SaaS API and a topic another team owns. An actor MUST NOT be marked outside. An outside node MAY start edges, such as the webhooks the repository receives.
Planned nodes and edges
A node or an edge marked planned is not built yet: it describes a change the code will make. A node MUST NOT be both outside and planned. An edge whose source or target is a planned node MUST itself be planned, since an edge can't exist before both its ends do. An edge between two built nodes MAY be planned on its own. Apart from evidence, a planned node or edge meets every other constraint in this specification, rules included, so a planned edge that breaks a rule is a violation.
Edges and their kinds
An edge is one node acting on another. It is written in the block of the node it starts from, its source. The target of an edge MUST be a node whose kind fits the edge's kind:
| Edge kind | Target kinds | Meaning |
|---|---|---|
call | service, external | sends a request and gets an answer |
read | store | reads the store without changing it |
write | store | changes the store, and may also read it |
publish | channel | sends messages to the channel |
consume | channel | receives messages from the channel |
- A channel MUST NOT start edges, and no edge targets a job: a job acts, and nothing acts on it.
- An edge's target MUST NOT be its source, except a
call's from a service: a service MAY call itself when replicas of it call each other, such as pods that forward a message to the pod that owns it. An external or an actor MUST NOT call itself, since the model does not describe its insides, and a job can't, since nothing calls a job. - A node MUST NOT have two edges with the same kind and target.
- A node MUST NOT have both a
readand awriteto the same store.
A consume is written on the consumer, since the consumer's code makes it, even though its messages flow from the channel to the consumer.
Via
via <id> names the forwarding infrastructure an edge goes through, such as an ingress, an API gateway or a load balancer, by its workload id. That infrastructure is not a node, so a via id MUST NOT be the id of a node.
Groups
A group is a named set of nodes that the repository states, such as a team, a deployment namespace or a bounded context. A member line names a node of the group. A group line names a group inside it. The nodes of a group are its members plus the nodes of every group inside it, at any depth. A node or a group MAY be in several groups.
- A group MUST NOT list the same member or inner group twice.
- A group MUST NOT be inside itself, directly or through other groups.
- A group MUST have at least one node.
- A node that is a member of a group MUST NOT also be a node of a group inside it.
Rules
An edge breaks a rule when all of these hold:
- Its kind is matched by the rule's kinds.
edgematches every kind, and each other kind matches itself, except thatreadalso matcheswrite, since a write may also read. - Its source is selected by the
fromselectors, if the rule has them. - Its target is selected by the
toselectors, if the rule has them. - No
exceptclause matches it. Anexceptclause matches an edge when itsfrompart, if any, selects the edge's source and itstopart, if any, selects the edge's target.
A list of selectors selects what any one of them selects. A node selector selects that node (checkout), every node of a kind (any store), every node of a kind with a tech (any store on postgres), or the nodes of a group (group payments). A node with no tech is selected by no selector with a tech.
- A rule MUST NOT list both
readandwrite. A list that matches every kind (call, read, publish, consume) MUST be writtenedge. - A rule MUST NOT have two
exceptclauses with the samefromandtoselectors. - A selector with a tech MUST name the kind
service,job,storeorchannel, and its tech MUST have the shape of a tech. - An edge MUST NOT break a rule.
Evidence and anchors
An anchor is an at line, which points to a line of a file in the repository, or a known line, which states in words that the proof exists outside the repository. In an evidence block, a line with only an anchor anchors the node or group itself (its own anchors). A line that starts with on <tech> anchors the node's tech (a tech anchor), a line that starts with an edge kind and target anchors that edge of the node (an edge anchor), and a line that starts with member <node> anchors that node's membership (a member anchor).
An at anchor holds when the working tree has a regular file at exactly its path, matched case-sensitively, where no segment of the path is a symbolic link, and the file contains the snippet byte for byte. Every at anchor MUST hold. The text of a known anchor is not checked.
- A path is relative to the repository root, or, when it starts with
/, to the git root, so that a model of a subdirectory can anchor shared code and files at the top of the git repository (/proto/order.proto,/CODEOWNERS). A path that starts with/MUST have a git root. - A path MUST use
/as its separator and have no empty,.or..segment after its leading/, if any. It MUST NOT be inside the repository root'swiremap/, whose files would hold any snippet, whichever way it is written. - A node block's kind MUST be that of its node. A node or group MUST NOT have more than one block.
- A tech anchor MUST repeat its node's tech, so a node with no tech has none. An edge anchor MUST name an edge of that node, by its kind and target. A member anchor MUST name a member of that group.
- A node that is not outside, not planned and not an actor MUST have one or two anchors of its own. An outside node, a planned node or an actor MUST NOT have any.
- A node with a tech that is not outside and not planned MUST have one or two tech anchors. An outside or planned node MUST NOT have any.
- Every edge that is not planned MUST have one or two anchors. A planned edge MUST NOT have any.
- Every group MUST have at least one anchor. If it has none of its own, every member that is not planned MUST have at least one member anchor. A planned member MUST NOT have a member anchor.
atandknownanchors MAY be mixed for the same node, tech, edge, group or member, and both count towards the numbers above.- The same anchor MUST NOT appear twice for the same node, tech, edge, group or member.
check does not judge which lines are anchored. A node's first anchor should be the line that defines it. A tech's should be the line that names the engine or the language: an image (image: postgres:16), the scheme of a connection string (postgres://), the client library the code connects with, or for a service or a job the build file that builds it (build.sbt, go.mod, a .csproj, package.json). An edge's first anchor should be the line whose removal would remove the edge, such as a client's creation, a listener annotation or an infrastructure resource. Its second, when the target's address or name is written elsewhere (a connection string, a topic name in configuration), should be the line that writes it. A group stated as a whole, by a namespace or an ownership entry, should be anchored by its own at lines, and a group whose members a document states one by one, per member. A known anchor should be used only when the proof is outside the repository, such as a subscription made in a cloud console, and its text should say where that proof is.
Canonical form
wiremap fmt rewrites both files into their canonical form, and only when both parse. On a file that parses but is not in canonical form, check names the first line that differs from it.
- Lines end with LF, the last one included. No line ends in a space. Tokens are separated by one space, list items by
,, a block opens with{, and|separates an anchor's path from its snippet and aknownfrom its text. A node'sasand its name come right after its id, then itsonand its tech, then itsoutsideorplanned, and an edge'splannedright after its target, beforevia. Block lines are indented by two spaces, and}is not indented. Paths and snippets are written exactly as read. - The model file has up to three sections, in this order: nodes, groups, rules. The evidence file has up to two: nodes, then groups. One blank line separates two sections, a section with nothing in it is left out, and there are no other blank lines.
- A comment line comes just before the line it belongs to, after any blank line that separates sections, and keeps the text after its
#. It is indented by two spaces inside a block, including one that belongs to the}, and is not indented elsewhere. - Kinds sort in the order the grammar lists them. Ids and other text sort by Unicode code point, so
Invoicingcomes beforebilling. - Every comma-separated list is sorted: kinds by kind, other items by their printed text (
any store,checkout,group payments). - Nodes sort by kind, then by id. A node with no edges is a bare line, and so is a group with nothing in it, unless its block holds a comment: a model block that holds a comment keeps its braces, so the comment keeps its place. An evidence block is always a block, even with nothing in it.
- A node's edges sort by kind, then by target.
- Groups sort by id. In a group block, the
memberlines come first, sorted, then thegrouplines, sorted. - A rule's
exceptclauses sort by their printed text, and rules sort by their whole line. - Evidence node blocks sort like nodes, and group blocks by id. In a node block, the node's own anchors come first, then its tech anchors sorted by tech, then edge anchors sorted like edges. In a group block, the group's own anchors come first, then member anchors by member id. A
knownanchor sorts with theatanchors of the same node, tech, edge, group or member, in written order. - Sorting is stable: items with equal keys keep their written order.
Conformance
A model is valid when both files parse under the grammar, meet every MUST and MUST NOT in this specification, and are in canonical form. wiremap check reads both files and the repository they describe, reports every violation with its file and, where there is one, its line, and succeeds only for a valid model. When an edge breaks a rule, it reports the rule, the edge and the edge's anchors, and when an anchor doesn't hold, the anchor's text. wiremap fmt changes only layout and order, so it fixes no other violation: rule no call, read, publish, consume stays as it is, and check reports it.