Contracts
What an order, a customer or an invoice has to look like to be accepted. A contract is the shape of one kind of data plus rules in plain language.
In short
How to go about it
- Start with the library: it holds 18 contracts, from order to stock count. Add the ones your business has.
- Open a contract to see its fields. Add a field, mark one as required, or write in words what applies.
- For a kind of data the library does not have, build your own.
An example
You make “customer number” required on orders. From then on an order without one is refused, with the reason, whoever tries to save it.
When a contract, when the original is enough
What arrives is always kept as it came. It becomes an object of a contract when you want a rule to hold for it, want to find or link it by a key, when it changes over time, when it is counted, or when several sources deliver the same thing differently. What is read once and then done with stays the original.
The story of an object in the journal starts with the delivery it was made from. The original itself is one click away, and your co-founder fetches it only when the object lacks something or something contradicts.
Good to know
A contract's name never changes; it is its identity. A stricter contract does not touch what is already stored.
In detailFor those who want to know exactly how the co-founder behaves.
What your co-founder gets, and when
The agent reads a contract before it saves an object of that kind: the fields, which are required, and your rules in words. It may create a contract for a new kind of data at once.
Enforced, or only instructed
- The shape is enforced on every save, for agent, source and translation alike.
- The rules in words are instruction: the agent reads them, the platform does not check them. What must hold without exception belongs in a hard rule.
- Only you change an existing contract. An agent's change becomes a proposal that says in words what changes and how many stored objects would no longer fit.
What is in the journal
Every contract in full when it is set, every change with the version before, every proposal with what became of it.
Limits
- Changing a contract does not recheck objects saved earlier.
- A contract cannot be renamed.
The co-founder's tools here
contract_listreadsAll contracts with schema and rules.contract_getreadsRead one contract: JSON schema and plain-language rules.contract_savechangesCreate a contract, or propose a change to one that exists: a new contract is set at once; a change is put to the human with what it alters and how many existing objects would no longer fit, and takes effect with their yes (give reason). schema is a JSON schema, rules describe in plain language when a record is valid. refs declares which fields are business keys, e.g. {"sku":["lines[].sku"],"customer":["customer.email"]}: they are indexed automatically whenever a record is saved, so always declare them.