metacore Start a pilot

Showcase · Contract lifecycle management

Contract lifecycle, as one domain.

Contracts with their terms, their clauses and their signature, and standard clauses worded for each jurisdiction. Terms outside the playbook wait for a lawyer, and a signature is stated once and never changes.

The domain, as its schema declares it

4 entities and 9 layers, 4 roles and 4 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
contractmainglobalReleasedtitle, kind, counterparty, owner
termsglobalReleasedvalue, currency, payment_days, liability_cap, governing_law
documentsglobalReleaseddraft, signed_copy
signedglobalStated oncesigned_on, signatories
validityglobalDatedstate, notice_days
clausemainglobalReleasedtemplate, text, deviates
clause templatemainglobalReleasedtitle, topic
textsjurisdictionReleasedtext, fallback
counterpartymainglobalReleasedname, vat_number, country

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
requestercontract, clause, clause template, counterpartycontract.mainStarts approval.
legalcontract, clause, clause template, counterpartycontract.terms, contract.documents, clause.main, clause_template.main, clause_template.texts, counterparty.mainApproves contract.terms. Rolls back contract.terms. Decides the stage review of approval.
financecontract, counterpartyNothingDecides the stage review of approval.
keepercontractcontract.validityRolls back contract.validity.

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
playbookGate ruleJudges each change of contract.terms before it is live: pass, reject, or hold for a person.
send_for_signatureHandlerAsks signature_provider through the engine.
record_signatureHandlerChanges contract.signed, contract.documents and contract.validity. Emits contract_signed.
renewal_noticeHandlerAsks mail through the engine.

What computes

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

  1. NegotiatedLegal states the terms and the clauses
  2. JudgedA gate rule holds what the playbook does not allow
  3. ApprovedLegal and finance decide together
  4. SentA handler sends the draft to the signature provider
  5. SignedA webhook brings the signature back, stated once

A contract, 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
signaturesWebhookThe third party signs each notification. It starts record_signature.
daily_renewalsTriggerOn a schedule, 0 7 * * 1-5 in Europe/Rome: it starts renewal_notice.
contract_signedEventA handler emits it for a contract. Other domains and the event stream follow it.
signature_providerThird partyA handler asks it through the engine, with a secret that your org keeps.
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 atoms4 in this domain, in your repository and in your language.
The editor of a draftYour word processor. A draft enters the domain as a PDF.
The signatureYour signature provider. A handler sends the draft, and a webhook brings the signature back.
RemindersYour mail server. A handler tells each owner of a contract that ends soon.

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.

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

# The contracts of a company, from a request to a signature and to their end.
# A message of metacore.api.v1.Schema, in the text format of Protocol Buffers.
#
#   contract         main       global        what it is, and with whom
#                    terms      global        what was negotiated
#                    documents  global        the draft that travels
#                    signed     global        the signature: stated once
#                    validity   global        when it is in force, by period
#   clause           main       global        a clause of a contract, by position
#   clause_template  main       global        a standard clause
#                    texts      jurisdiction  its wording in each jurisdiction
#   counterparty     main       global        the other side
#
# A gate rule judges the terms against the playbook of the legal team: it
# passes what the playbook allows, and holds the rest for a lawyer. A contract
# goes to its signature through a workflow, where legal and finance both
# approve it. The signature provider tells through a webhook when everyone
# signed: the handler states the signature, once, and the period of validity.
# Every morning a handler tells the owners of the contracts that end soon.
#
# The org declares the scope jurisdiction under global before the first
# deployment.

entities {
  name: "contract"
  key { name: "number" type: FIELD_TYPE_TEXT }
  layers {
    name: "main"
    scope: "global"
    fields { name: "title" type: FIELD_TYPE_TEXT required: true max_length: 200 }
    fields { name: "kind" type: FIELD_TYPE_TEXT required: true allowed_values: "nda" allowed_values: "supply" allowed_values: "service" allowed_values: "license" }
    fields { name: "counterparty" type: FIELD_TYPE_REFERENCE required: true reference { entity: "counterparty" carries: "name" } }
    fields { name: "owner" type: FIELD_TYPE_TEXT }
  }
  layers {
    name: "terms"
    scope: "global"
    fields { name: "value" type: FIELD_TYPE_DECIMAL decimal_places: 2 least { decimal: "0" } }
    fields { name: "currency" type: FIELD_TYPE_TEXT allowed_values: "EUR" allowed_values: "USD" allowed_values: "GBP" }
    fields { name: "payment_days" type: FIELD_TYPE_INTEGER least { integer: 0 } greatest { integer: 365 } }
    fields { name: "liability_cap" type: FIELD_TYPE_DECIMAL decimal_places: 2 least { decimal: "0" } }
    fields { name: "governing_law" type: FIELD_TYPE_TEXT max_length: 60 }
  }
  layers {
    name: "documents"
    scope: "global"
    fields {
      name: "draft"
      type: FIELD_TYPE_FILE
      file { media_types: FILE_MEDIA_TYPE_PDF max_bytes: 20971520 }
    }
    fields {
      name: "signed_copy"
      type: FIELD_TYPE_FILE
      file { media_types: FILE_MEDIA_TYPE_PDF max_bytes: 20971520 }
    }
  }
  # A signature is a document: it is stated once, and never changes.
  layers {
    name: "signed"
    scope: "global"
    once: true
    fields { name: "signed_on" type: FIELD_TYPE_DATE required: true }
    fields { name: "signatories" type: FIELD_TYPE_TEXT list: true max_length: 120 }
  }
  # A contract is in force over a period: a renewal states the next one.
  layers {
    name: "validity"
    scope: "global"
    dated: true
    fields { name: "state" type: FIELD_TYPE_TEXT allowed_values: "in_force" allowed_values: "suspended" exposed: true }
    fields { name: "notice_days" type: FIELD_TYPE_INTEGER least { integer: 0 } }
  }
}

entities {
  name: "clause"
  key { name: "contract" type: FIELD_TYPE_TEXT }
  key { name: "position" type: FIELD_TYPE_INTEGER }
  layers {
    name: "main"
    scope: "global"
    fields { name: "template" type: FIELD_TYPE_REFERENCE reference { entity: "clause_template" carries: "title" } }
    fields { name: "text" type: FIELD_TYPE_TEXT }
    fields { name: "deviates" type: FIELD_TYPE_BOOLEAN }
  }
}

entities {
  name: "clause_template"
  key { name: "code" type: FIELD_TYPE_TEXT }
  layers {
    name: "main"
    scope: "global"
    fields { name: "title" type: FIELD_TYPE_TEXT required: true max_length: 120 }
    fields { name: "topic" type: FIELD_TYPE_TEXT allowed_values: "liability" allowed_values: "payment" allowed_values: "term" allowed_values: "confidentiality" allowed_values: "other" }
  }
  # The wording stated at the global root holds in every jurisdiction, until
  # one states its own.
  layers {
    name: "texts"
    scope: "jurisdiction"
    fields { name: "text" type: FIELD_TYPE_TEXT }
    fields { name: "fallback" type: FIELD_TYPE_TEXT }
  }
}

entities {
  name: "counterparty"
  key { name: "code" type: FIELD_TYPE_TEXT }
  layers {
    name: "main"
    scope: "global"
    fields { name: "name" type: FIELD_TYPE_TEXT required: true max_length: 160 }
    fields { name: "vat_number" type: FIELD_TYPE_TEXT max_length: 20 }
    fields { name: "country" type: FIELD_TYPE_TEXT pattern: "[A-Z]{2}" }
    uniques { name: "vat_number" fields: "vat_number" scope: "global" ignore_case: true }
  }
}

roles {
  name: "requester"
  permissions { operation: OPERATION_READ entity: "contract" }
  permissions { operation: OPERATION_READ entity: "clause" }
  permissions { operation: OPERATION_READ entity: "clause_template" }
  permissions { operation: OPERATION_READ entity: "counterparty" }
  permissions { operation: OPERATION_CHANGE entity: "contract" layer: "main" }
  permissions { operation: OPERATION_START workflow: "approval" }
}

roles {
  name: "legal"
  permissions { operation: OPERATION_READ entity: "contract" }
  permissions { operation: OPERATION_READ entity: "clause" }
  permissions { operation: OPERATION_READ entity: "clause_template" }
  permissions { operation: OPERATION_READ entity: "counterparty" }
  permissions { operation: OPERATION_CHANGE entity: "contract" layer: "terms" }
  permissions { operation: OPERATION_CHANGE entity: "contract" layer: "documents" }
  permissions { operation: OPERATION_CHANGE entity: "clause" layer: "main" }
  permissions { operation: OPERATION_CHANGE entity: "clause_template" layer: "main" }
  permissions { operation: OPERATION_CHANGE entity: "clause_template" layer: "texts" }
  permissions { operation: OPERATION_CHANGE entity: "counterparty" layer: "main" }
  permissions { operation: OPERATION_DECIDE entity: "contract" layer: "terms" }
  permissions { operation: OPERATION_GO_BACK entity: "contract" layer: "terms" }
}

roles {
  name: "finance"
  permissions { operation: OPERATION_READ entity: "contract" }
  permissions { operation: OPERATION_READ entity: "counterparty" }
}

roles {
  name: "keeper"
  permissions { operation: OPERATION_READ entity: "contract" }
  permissions { operation: OPERATION_CHANGE entity: "contract" layer: "validity" }
  permissions { operation: OPERATION_GO_BACK entity: "contract" layer: "validity" }
}

atoms {
  name: "playbook"
  connection: "legal_rules"
  timeout { seconds: 10 }
  gate_rule { layer { entity: "contract" layer: "terms" } }
}

# The handler sends the draft to the signature provider: it asks it through
# the engine, with a secret that the org keeps.
atoms {
  name: "send_for_signature"
  connection: "legal_rules"
  timeout { seconds: 30 }
  handler {
    inputs { name: "number" type: FIELD_TYPE_TEXT required: true }
    outcomes: "sent"
    outcomes: "refused"
    asks: "signature_provider"
  }
}

atoms {
  name: "record_signature"
  connection: "legal_rules"
  timeout { seconds: 30 }
  handler {
    outcomes: "recorded"
    outcomes: "ignored"
    changes { entity: "contract" layer: "signed" }
    changes { entity: "contract" layer: "documents" }
    changes { entity: "contract" layer: "validity" }
    events: "contract_signed"
  }
}

atoms {
  name: "renewal_notice"
  connection: "legal_rules"
  timeout { seconds: 60 }
  handler {
    outcomes: "done"
    asks: "mail"
  }
}

events {
  name: "contract_signed"
  entity: "contract"
  exposed: true
}

triggers {
  name: "daily_renewals"
  schedule { cron: "0 7 * * 1-5" time_zone: "Europe/Rome" }
  atom: "renewal_notice"
}

# Legal and finance approve a contract together: one of them can send it
# back, and only both move it on to its signature.
workflows {
  name: "approval"
  inputs { name: "number" type: FIELD_TYPE_TEXT required: true }
  first_stage: "review"
  stages {
    name: "review"
    person {
      roles { role: "legal" }
      roles { role: "finance" }
      timeout { seconds: 864000 }
      outcomes: "approved"
      outcomes: "sent_back"
      agreed_outcome: "approved"
      second_person: true
    }
    transitions { outcome: "approved" next_stage: "signature" }
    transitions { outcome: "sent_back" }
  }
  stages {
    name: "signature"
    handler: "send_for_signature"
    transitions { outcome: "sent" }
    transitions { outcome: "refused" next_stage: "review" }
  }
}

# The signature provider signs the body, and writes the signature in hex
# after a prefix.
webhooks {
  name: "signatures"
  handler: "record_signature"
  proof: WEBHOOK_PROOF_SIGNATURE
  proof_header: "X-Signature"
  proof_prefix: "sha256="
  signature_encoding: SIGNATURE_ENCODING_HEX
  id_header: "X-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