# 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" }