MirrorDimensions

Docs / Your world

Systems built from a description

Give the world an OpenAPI file for a system it has no software for, and it runs a simulated stand-in that keeps records.

Mostly read byOperations and support leaders

Where this sits01 Agents02 Boundary03 Company04 ModelSee the map

An animation in three parts. A command summarising a simulated system: its operations and groups of records. The portal's page for it, showing what keeps records and what answers by shape only. Then one operation: what a request must carry and what the agent gets back.
Seeing inside a simulated system. Made from the mirror's own commands and portal screens, shortened. Select it to see it full size.

A world runs real software for code hosting and chat. For everything else your agents touch, a ticketing tool, a CRM, one of your own internal services, you can give the world a description of the system and it will run a working stand-in built from it.

The description is an OpenAPI 3 file (YAML or JSON), the kind most teams already keep for their APIs. A Swagger 2.0 file, the older form of the same thing, is read too: it is treated as the OpenAPI 3 description it corresponds to.

This is a simulation, not the product. It keeps records and answers in the shapes your file declares. It does not have the real system's behaviour beyond that. Every result lists the systems that were simulated, so a pass here is not mistaken for a pass on the real thing.

Add one

In the world's folder:

Terminal
mirror world add --spec ~/apis/helpdesk.yaml
Output
ok    Added helpdesk (Northfield Helpdesk) at helpdesk.northfield-logistics.com
  Description kept as specs/helpdesk.yaml: 11 operation(s)
  Keeps records of: comments, customers, tickets
  Answers by shape only (nothing is kept): GET /status

The file is copied into the world's folder, under specs/, and the system is written into mirror.yaml:

YAML
apps:
  - id: helpdesk
    kind: described-service
    hostname: helpdesk.northfield-logistics.com
    visibility: granted
    described:
      spec: specs/helpdesk.yaml

Then build it: mirror world create.

  • --id sets the system's id. Left out, it comes from the description's title.
  • --hostname sets its hostname. Left out, it is the one the description's servers entry names, so the agent's own configuration still points at it; failing that, <id>.<your domain>.

An import does the same. mirror world import helpdesk.yaml (or the portal's Import a description) reads the file, and a system with no real software to run is proposed as "Build it from its specification (simulated)". An import keeps the description's shapes only: descriptions, examples and contacts are left out, like every secret and person an import meets. The examples can be kept afterwards, once you have looked at them: see Keep its examples. A description published on the web can be given by its https:// address in place of a file: it is fetched once and kept in the world's imports/ folder. Where a description names no host (its server address is a placeholder such as https://{your-domain}), the review suggests a hostname under the company's domain and takes your own: mirror world import decide <subject>.hostname <hostname>.

Start from a vendor's published description

For some products in the catalog, the vendor publishes an OpenAPI description of its API. The catalog lists where, and the mirror can fetch the file for you:

Output
mirror catalog list --published
mirror world add github --published

The file is fetched once, from this computer, from the vendor's own address, and kept under the world's specs/ folder. The command says where it came from and the licence the vendor states for it. Nothing is fetched unless you pass --published, and nothing inside the sandbox reaches the vendor.

What you get is a simulation of that description, with every limit on this page. It is not the product. A well-known product is also where a stand-in is easiest for an agent to tell apart, because the agent knows how the real one answers. What is known about each listed product is shown when you add it: read those lines before relying on it. Each was sent sample requests offline, by a trial that guesses every request, and says how many of its operations answered, whether a record made was read back, and what it refuses. That is a first look, not a comparison with the real product: none has been run in a sandbox or put before an agent. Some entries point at one part of a product, such as its orders or accounting API, where the vendor publishes each part as a file of its own.

Forty-five products are listed. A product is left off when its vendor's terms say the description is not for outside use, when the description is made per customer or sits behind a sign-in, when the mirror cannot read its file (a description split across several files, or one older than Swagger 2.0), or when its licence is missing or unclear. Whether a vendor's terms allow your use of its description is for you to check. See decision 0043.

What it does with your description

In the description What the service does
A path that lists or creates, with a path for one record beside it: /tickets and /tickets/{id} Keeps a collection of records. GET lists, POST creates, GET, PUT, PATCH and DELETE on one record read, replace, change and delete it
A path under one record: /tickets/{id}/comments Keeps that record's own list. Deleting the record removes it
A request body's schema Checks each request against it: required fields, types, allowed values, lengths, unknown fields where the schema forbids them. What does not fit is refused
A response's schema Answers in that shape. A list wrapped in an object ({items: [...], total: 12}) is wrapped the same way
Query parameters limit, offset, page, and ones named after a record's fields Pages the list, and filters it by those fields
Fields marked readOnly Sets them itself: the id, when it was created and changed, who created it
An error response's schema Words its own errors in that shape
security and securitySchemes Asks for a bearer token, or a key in the header you name. An operation with security: [] is open
Any other operation Answers with a value of the declared shape, or with an empty body where no shape is declared. Nothing is kept for it
An example on a response, on its schema or on a field Answers with it, where the world's copy of the description holds it

mirror system show <id> --surfaces lists every operation as the world understands it.

See inside it

A description with hundreds of operations is hard to judge from a list. The portal shows one from the inside: on the Environment map, choose the system and then See inside.

  • Keeps records. Each group of records, with its path, how many operations act on it and how many records it starts with. A group that belongs to each record of another (/tickets/{id}/comments) is drawn inside it. Where a field's name matches another group (customer_id beside a group called customers), the page says so. That is read from the names only: the service does not check that the record exists.
  • Answers by shape only. Every other operation, grouped by the start of its path, with how many check the request and how many answer with an empty body.
  • One operation. The fields a request must carry and the rule for each, what the agent gets back with a sample, and a dry run of a request. An operation whose description asks for a file upload or a stream is marked: the service does neither.

A search and filters narrow it, and choosing a run shows only the operations that run reached, with how many requests each took.

From the command line:

Terminal
mirror system inside helpdesk
mirror system inside helpdesk --operation createTicket

Keep its examples

Many descriptions give examples: a sample answer, or a sample value for a field. With them, an operation that answers by shape answers with its example, in place of values made up from field types.

A description added with mirror world add --spec is kept as you gave it, examples included. One that came through an import was kept without them. To keep them:

Terminal
mirror system examples helpdesk            # what would be kept, and what would be left out
mirror system examples helpdesk --keep

The first command changes nothing. It reads the description the system was imported from again (or --from <file>) and lists what it found. An example is left out when any part of it looks like a secret or like a person's details; the rest are kept as they are. Read the list before keeping them. The check is a filter, and it will miss things. What is kept reaches the agent you test and its model provider.

Keeping them writes specs/<id>-with-examples.yaml beside the world's copy and points the system at it, so going back is a one-line change in mirror.yaml. It takes effect at the next rebuild. The portal has the same under Bring it closer to the real system.

Its records

The service starts with records generated from the world: tickets are assigned to people who work at the company, their subjects read like the company's other work, and a ticket's customer is one of the customers. The same world gives the same records every time. Each collection gets 12 unless you say otherwise:

YAML
described:
  spec: specs/helpdesk.yaml
  records: { tickets: 60, customers: 25 }

To use records of your own for a collection, give a file with a list of them. Use test data: what is in it reaches the agent you test and its model provider.

YAML
data: { customers: specs/customers.json }

For a collection that sits under another record (/tickets/{id}/comments), each row must say which record it belongs to: give the parent's id in the field the description uses for it, or in _parent. A row without one is refused when the world is built, since no request could ever list it.

Every run starts from the same records: restoring the base snapshot restarts the service.

What a description cannot say

A description gives shapes, not behaviour. Three things you can add under behavior, naming an operation by its operationId or as METHOD /path:

YAML
behavior:
  - on: closeTicket # POST /tickets/{id}/close
    set: { status: closed }
  - on: updateTicket
    transitions:
      status: { open: [pending, closed], pending: [open, closed], closed: [] }
  - on: serviceStatus # GET /status
    answer: { open: false, queue: night }
    status: 503
  • set: fields the operation sets on the record. Without it, an action such as close returns the record unchanged.
  • transitions: for a field, the values each value may change to. Any other change is refused with a conflict.
  • answer: for an operation that keeps nothing, the body it answers with, and with status the status. It is the same answer every time, whatever the request; the request is still checked against its declared shape first. Use it for the operations your agent depends on that would otherwise answer with an empty body or made-up values. An operation on a record answers with the record, so answer is refused there.

The portal's page for the system sets all three from the operation's panel. Each is a change to mirror.yaml and takes effect at the next rebuild.

Rules work on it as on any system: slow it down, make it fail, plant text in an answer (mirror set rule).

Give an agent access

Access is by collection, read or write:

Terminal
mirror set grant support-agent helpdesk/tickets write
mirror set grant support-agent helpdesk/customers read

The agent is deployed with the system's address and a token in the form <ID>_URL and <ID>_TOKEN (HELPDESK_URL, HELPDESK_TOKEN). The service refuses what is not granted.

Use it in a scenario

YAML
delivery:
  channel: described.record
  system: helpdesk
  collection: tickets
  record:
    subject: Label printer at dock 2 prints blank labels
    status: open
    created_at: { $ago: 45 }
checks:
  success:
    - described.record_exists:
        system: helpdesk
        collection: tickets
        where: { subject: Label printer at dock 2 prints blank labels, status: closed }
  forbidden:
    - described.request_made: { system: helpdesk, path: /customers }
  side_effects:
    allow:
      - helpdesk: { collection: tickets }
      - helpdesk: { collection: comments }

See writing a scenario for every operation.

Limits

  • It does only what the description and your behavior say. Business rules, approval chains and side effects on other systems are not there unless you add them.
  • It does not have a vendor's quirks: query languages, exact error wording, rate limits, webhooks. An agent tied to one vendor's exact API fits worst. Your own internal service, whose description you own, fits best.
  • It answers as itself. An agent that knows the real product well could tell the difference (tell 41).
  • One file. A reference to another file or a URL is refused; nothing is fetched. A description published as many files has to be bundled into one first, if its publisher offers that.
  • A reference to something the file does not hold is not followed. Published descriptions sometimes carry such a slip. The shape it names is read as one that says nothing, so a field of that shape is not checked or filled, and adding the system says how many there were.
  • A fixed answer is fixed. An operation given an answer gives it to every request. Nothing is computed from the request, and no model runs behind an operation that would call one in the real system.
  • JSON over HTTPS only. No file uploads, streams or webhooks.
  • Bring your own description. This project ships no vendor's API description.
  • Not yet run on Windows or Linux engines, nor with a description from a real company: see platforms.

This page is docs/described-systems.md in the repository; improve it there.