metacore Start a pilot

Showcase · Support desk

A support desk, as one domain.

Tickets, their replies and the response targets of each team. A reply that an AI agent drafts always waits for a person, and a reply never changes once it is sent.

The domain, as its schema declares it

4 entities and 8 layers, 3 roles and 5 atoms, in one file.

Model

Each entity, split by who changes it.

A layer is a group of fields that change together: it is the unit of a permission, of an approval and of a release. Its scope is the lowest level at which a value may differ.

EntityLayerScopeKindFields
ticketopenedglobalStated oncerequester, email, subject, body, channel, opened_at
triageglobalReleasedpriority, category, assignee
statusglobalReleasedstate, solved_at
clockglobalOverlayfirst_reply_due, breached
replysentglobalStated onceauthor, public, body, sent_at
categorymainglobalReleasedlabel, default_priority
routingteamReleasedowner
targettimesteamReleasedfirst_reply_minutes, resolution_minutes

The entities and their layers

A released layer publishes and rolls back. A dated one holds values by period, one stated once never changes, balances add up, and an overlay is written live by another system.

Roles

A role holds what a job needs, and no more.

A role names operations on layers. Where a person works is in the grant: one role serves every scope value, and a grant gives it on one.

RoleReadsChangesDecides, starts and calls
agentticket, reply, category, targetticket.opened, ticket.triage, ticket.status, reply.sentStarts escalation.
leadticket, reply, category, targetcategory.main, category.routing, target.timesApproves reply.sent. Rolls back ticket.triage. Decides the stage review of escalation.
timerNothingticket.clockNothing

Who does what

The engine checks each operation for every caller: a person, a system or an AI agent.

Flow

People decide, and your code acts.

The schema holds no formula and no condition. Whatever computes is an atom: your code, which the engine calls outside itself or in a sandbox.

AtomKindWhat it does
intakeHandlerChanges ticket.opened, ticket.status and reply.sent. Emits ticket_opened.
routeHandlerChanges ticket.triage.
reply_guardGate ruleJudges each change of reply.sent before it is live: pass, reject, or hold for a person.
deliverHandlerAsks mail through the engine.
escalateHandlerChanges ticket.triage.

What computes

An atom returns its effects as data, and the engine checks each one.

  1. OpenedThe mail provider tells through a webhook
  2. RoutedA handler sets its priority and its category
  3. AnsweredA reply is judged, and one from an AI agent waits for a person
  4. SentA handler sends the reply through the mail provider

A ticket, step by step

Each step is a run with its own audit entry.

Connections

What comes in, and what goes out.

A third party reaches the domain through a webhook, and a handler reaches a third party through the engine. A schema holds no address and no secret: an admin binds each one in each environment.

NameKindHow
inboxWebhookThe third party signs each notification. It starts intake.
after_openTriggerAfter the event ticket_opened: it starts route.
after_replyTriggerAfter a change to a reply: it starts deliver.
ticket_openedEventA handler emits it for a ticket. Other domains and the event stream follow it.
mailThird partyA handler asks it through the engine, with a secret that your org keeps.

The connections of the domain

Every system meets the engine at one public API.

Boundaries

What the engine gives, and what you build.

metacore is not a product of this kind. It is the engine under one that you build: the guarantees come with it, and the rest is yours.

From the engineWhat you get
A public APITyped from the schema, for every entity. There is no private interface.
A back officeEvery record at every level, from the schema, with no code.
Access controlA role holds an operation, on a layer, at a scope value.
Approvals and releasesA change waits where a person must approve it, publishes in one step, and rolls back in one step.
An audit trailAn entry is written in the same step as the operation it records.
Search, events and MCPBuilt in, from the same schema.

With no code

The same for every domain.

Yours to buildHow it meets the engine
The schemaThis file. It is the whole model, and it changes only by deployment.
The atoms5 in this domain, in your repository and in your language.
The inboxYour mail provider. A webhook opens a ticket, and a handler sends each reply.
The portal of your customersAn app of yours on the public API.
The AI agentIt connects through MCP, with the grants that you give it.

In your code

A product of this kind brings its own screens. Here they are yours.

Schema

The whole domain, in one file.

Every table of this page is read from this file. The check of the CLI finds no problem in it.

ticketing.txtpb
# proto-file: metacore/api/v1/schema.proto
# proto-message: metacore.api.v1.Schema

# The support desk of a company: tickets, their replies, and the rules that
# route them. A message of metacore.api.v1.Schema, in the text format of
# Protocol Buffers.
#
#   ticket    opened   global  the request as it came: stated once
#             triage   global  its priority, its category and who has it
#             status   global  where the ticket stands
#             clock    global  when a first reply is due: an overlay
#   reply     sent     global  a reply or a note, by position: stated once
#   category  main     global  a kind of request
#             routing  team    who owns it, in each team
#   target    times    team    how fast each priority is answered, in each team
#
# The mail provider tells through a webhook when a customer writes: the
# handler opens a ticket, or adds a reply to one. A second handler routes
# each new ticket, and a third sends each reply out. A gate rule judges a
# reply before it is live: it passes a plain one, and holds for a person one
# that promises a refund. A reply that an AI agent writes always waits for a
# person: that rule is in the engine, not in this schema.
#
# The org declares the scope team under global before the first deployment.

entities {
  name: "ticket"
  key { name: "number" type: FIELD_TYPE_TEXT }
  layers {
    name: "opened"
    scope: "global"
    once: true
    fields { name: "requester" type: FIELD_TYPE_TEXT required: true max_length: 160 }
    fields { name: "email" type: FIELD_TYPE_TEXT restricted { read_roles: "agent" read_roles: "lead" write_roles: "agent" } }
    fields { name: "subject" type: FIELD_TYPE_TEXT required: true max_length: 200 }
    fields { name: "body" type: FIELD_TYPE_TEXT }
    fields { name: "channel" type: FIELD_TYPE_TEXT allowed_values: "email" allowed_values: "portal" allowed_values: "phone" }
    fields { name: "opened_at" type: FIELD_TYPE_TIME required: true }
  }
  layers {
    name: "triage"
    scope: "global"
    fields { name: "priority" type: FIELD_TYPE_TEXT allowed_values: "low" allowed_values: "normal" allowed_values: "high" allowed_values: "urgent" }
    fields { name: "category" type: FIELD_TYPE_REFERENCE reference { entity: "category" carries: "label" } }
    fields { name: "assignee" type: FIELD_TYPE_TEXT }
  }
  layers {
    name: "status"
    scope: "global"
    fields { name: "state" type: FIELD_TYPE_TEXT allowed_values: "open" allowed_values: "pending" allowed_values: "solved" allowed_values: "closed" }
    fields { name: "solved_at" type: FIELD_TYPE_TIME }
  }
  layers {
    name: "clock"
    scope: "global"
    overlay: true
    fields { name: "first_reply_due" type: FIELD_TYPE_TIME }
    fields { name: "breached" type: FIELD_TYPE_BOOLEAN }
  }
}

# A reply is a document: once it is sent it never changes, and a correction
# is a reply of its own.
entities {
  name: "reply"
  key { name: "ticket" type: FIELD_TYPE_TEXT }
  key { name: "position" type: FIELD_TYPE_INTEGER }
  layers {
    name: "sent"
    scope: "global"
    once: true
    fields { name: "author" type: FIELD_TYPE_TEXT required: true }
    fields { name: "public" type: FIELD_TYPE_BOOLEAN }
    fields { name: "body" type: FIELD_TYPE_TEXT required: true }
    fields { name: "sent_at" type: FIELD_TYPE_TIME }
  }
}

entities {
  name: "category"
  key { name: "code" type: FIELD_TYPE_TEXT }
  layers {
    name: "main"
    scope: "global"
    fields { name: "label" type: FIELD_TYPE_TEXT required: true max_length: 80 }
    fields { name: "default_priority" type: FIELD_TYPE_TEXT allowed_values: "low" allowed_values: "normal" allowed_values: "high" allowed_values: "urgent" }
  }
  layers {
    name: "routing"
    scope: "team"
    fields { name: "owner" type: FIELD_TYPE_TEXT }
  }
}

# The targets stated at the global root hold for every team, until a team
# states its own.
entities {
  name: "target"
  key { name: "priority" type: FIELD_TYPE_TEXT }
  layers {
    name: "times"
    scope: "team"
    fields { name: "first_reply_minutes" type: FIELD_TYPE_INTEGER least { integer: 1 } }
    fields { name: "resolution_minutes" type: FIELD_TYPE_INTEGER least { integer: 1 } }
  }
}

roles {
  name: "agent"
  permissions { operation: OPERATION_READ entity: "ticket" }
  permissions { operation: OPERATION_READ entity: "reply" }
  permissions { operation: OPERATION_READ entity: "category" }
  permissions { operation: OPERATION_READ entity: "target" }
  permissions { operation: OPERATION_CHANGE entity: "ticket" layer: "opened" }
  permissions { operation: OPERATION_CHANGE entity: "ticket" layer: "triage" }
  permissions { operation: OPERATION_CHANGE entity: "ticket" layer: "status" }
  permissions { operation: OPERATION_CHANGE entity: "reply" layer: "sent" }
  permissions { operation: OPERATION_START workflow: "escalation" }
}

roles {
  name: "lead"
  permissions { operation: OPERATION_READ entity: "ticket" }
  permissions { operation: OPERATION_READ entity: "reply" }
  permissions { operation: OPERATION_READ entity: "category" }
  permissions { operation: OPERATION_READ entity: "target" }
  permissions { operation: OPERATION_CHANGE entity: "category" layer: "main" }
  permissions { operation: OPERATION_CHANGE entity: "category" layer: "routing" }
  permissions { operation: OPERATION_CHANGE entity: "target" layer: "times" }
  permissions { operation: OPERATION_DECIDE entity: "reply" layer: "sent" }
  permissions { operation: OPERATION_GO_BACK entity: "ticket" layer: "triage" }
}

roles {
  name: "timer"
  permissions { operation: OPERATION_CHANGE entity: "ticket" layer: "clock" }
}

atoms {
  name: "intake"
  connection: "desk"
  timeout { seconds: 15 }
  handler {
    outcomes: "opened"
    outcomes: "added"
    outcomes: "ignored"
    changes { entity: "ticket" layer: "opened" }
    changes { entity: "ticket" layer: "status" }
    changes { entity: "reply" layer: "sent" }
    events: "ticket_opened"
  }
}

atoms {
  name: "route"
  connection: "desk"
  timeout { seconds: 10 }
  handler {
    outcomes: "routed"
    changes { entity: "ticket" layer: "triage" }
  }
}

atoms {
  name: "reply_guard"
  connection: "desk"
  timeout { seconds: 10 }
  gate_rule { layer { entity: "reply" layer: "sent" } }
}

# The handler sends a reply out through the mail provider: it asks it through
# the engine, with a secret that the org keeps.
atoms {
  name: "deliver"
  connection: "desk"
  timeout { seconds: 30 }
  handler {
    outcomes: "sent"
    outcomes: "kept_inside"
    outcomes: "failed"
    asks: "mail"
  }
}

atoms {
  name: "escalate"
  connection: "desk"
  timeout { seconds: 10 }
  handler {
    inputs { name: "number" type: FIELD_TYPE_TEXT required: true }
    outcomes: "escalated"
    changes { entity: "ticket" layer: "triage" }
  }
}

events {
  name: "ticket_opened"
  entity: "ticket"
  exposed: true
}

triggers {
  name: "after_open"
  event { event: "ticket_opened" }
  atom: "route"
}

triggers {
  name: "after_reply"
  event { changed_entity: "reply" }
  atom: "deliver"
}

# An agent asks for an escalation, and a lead who did not ask decides it.
workflows {
  name: "escalation"
  inputs { name: "number" type: FIELD_TYPE_TEXT required: true }
  first_stage: "review"
  stages {
    name: "review"
    person {
      roles { role: "lead" }
      timeout { seconds: 86400 }
      outcomes: "approved"
      outcomes: "declined"
      second_person: true
    }
    transitions { outcome: "approved" next_stage: "act" }
    transitions { outcome: "declined" }
  }
  stages {
    name: "act"
    handler: "escalate"
    transitions { outcome: "escalated" }
  }
}

# The mail provider signs the body, and writes the signature in base64.
webhooks {
  name: "inbox"
  handler: "intake"
  proof: WEBHOOK_PROOF_SIGNATURE
  proof_header: "X-Mail-Signature"
  signature_encoding: SIGNATURE_ENCODING_BASE64
  id_header: "X-Mail-Event-Id"
}

The schema of the domain

A message of the public contract, in the text format of Protocol Buffers.

See also

Build your domain.

Declare its schema, and take it to production, self-hosted or in a managed region.

Briefing