Skip to content

The brain: collections, records and pages

Last updated November 5, 2026

On this page

The brain is where your company's structured data lives: leads, tickets, roadmap items, incidents, and the pages that show them. People and agents read and write the same records under the same rules. Every write is kept: who made it, for whom, from which run, and every earlier version, so a bad write can be rolled back.

This guide describes the brain as it works today on the master branch. To follow along, start the demo company (see Quickstart) and sign in as the person each step names. What is not possible yet is listed at the end.

Collections#

A collection is one kind of record with a schema: its fields, their types, which are required, and how sensitive the data is. Apps bring their collections with them (the CRM app brings leads and contacts, Support brings tickets). OrchKernel has two of its own: App settings (stored as modules), which holds each enabled app's settings (see Apps), and Views (views), the pages (see Pages are records too).

Open Brain in the sidebar (under Company). The left column lists every collection. Under each name is a line such as "Kept here · Customer PII", and on the right a number or a lock:

What you see Meaning
Kept here A native collection: its records are stored in OrchKernel.
Kept in hubspot (or another system) A federated collection: its records stay in the other system and are read and written there. See Collections kept in another system.
Scratch A loosely typed collection the Schema Steward may later propose to type or archive.
Customer PII, Internal, Confidential, Financial, Captured content, Candidate PII The collection's data class: how sensitive it is. Policy and model rules use it (see Policy).
A number How many records the collection holds, deleted ones not counted. You may be able to read only some of them.
A lock You may not read this collection.

Type in Search collections to narrow the list. It matches names, descriptions and synonyms: as Alice, pipeline leaves Candidates, Forecasts and Leads.

Click a collection to open it. The head shows its name, the same two facts as badges (Kept here, Customer PII), its description and synonyms ("aka prospects, pipeline, customers, deals"), and on the right one of Add record (you may write), Read only or No access. On a phone the list and the collection are separate screens; ‹ All collections goes back.

The Schema & policy tab shows how the collection is built. For Leads:

Row Leads shows Meaning
extends organization The core type the collection builds on
version 1 (2 after a field is added) The schema version
owned by pack crm The app that brought it; org for a collection your company made
read teams, write teams team:sales Only members of these teams may read or write it at all
row rules {"owner_field":"owner","roles":["sales_lead","admin"],"rule":"owner_or_role"} / {"owner_field":"owner","roles":["sales_lead","admin"],"rule":"owner_or_role"} Which rows, as JSON: read rule, then write rule. For leads: you read and change a lead if you own it or are a sales lead or admin, and the same people give it to someone else (see Who owns a record).

Below it is one line per field: name, type (enum values listed), required, data class, synonyms and description. Under the table, after "e.g.", are example questions agents use to find the collection.

Who sees which records#

Every read runs as you. A collection's read teams decide whether you see it at all, and its row rules decide which rows. Being an admin does not bypass this.

In the demo, on Brain › Leads:

Person Sees Why
Alice (sales rep) 4 rows: "4 of 7 rows you can read · as Alice Chen" Her own leads only
Sam (sales lead) All 7: "7 rows you can read · as Sam Ortiz" A sales lead reads every lead
Fiona (founder) All 7 The leads' read rule names the founder: her Chief of Staff reports on the pipeline
Ada (admin) A lock in the list; opening Leads shows No access and "You cannot read this collection. Reads are governed by team policy." Not in the Sales team
Maya (support lead) The same as Ada Not in the Sales team

Off a collection's read teams, a person still reads the records they own, and only those: once Ada has had the Sales Assistant add Initech (the lead is hers), Leads opens for her with that one row, and Leads pages show it, while every other lead stays the team's. Under an owner rule only, never for an agent, and someone who owns none is refused as before.

Writes follow the write rules. Alice can edit her own leads but not Sam's; Sam, the sales lead, can edit any lead. Alice cannot create a lead owned by someone else ("You can't make a lead owned by Sam Ortiz: only its owner, the sales lead or an admin can give a lead to someone else."). A new record with no owner is owned by whoever wrote it, or, when an agent wrote it, by a person: see the next section.

Who owns a record#

A collection whose write rule names an owner field (owner_only or owner_or_role, as Leads) keeps one person as the owner of each record.

A new record is a person's whenever a person is behind the write. When the write leaves the owner empty (or an agent names itself), the owner is filled in with:

Who writes Owner
A person That person
An agent acting for someone (they delegated to it) The person it acts for
An agent acting for nobody, at someone's ask or mention The person who asked, an admin too
An agent's own work with nobody to act for (a schedule, a webhook) The agent, so it can read and change what it wrote, in that run and the next. Its other readers are the rule's role holders (for Leads the sales lead) and admins; an admin or the lead of a team that writes the collection claims or reassigns it.

So when Ada, the admin, asks the Sales Assistant "@Sales Assistant lets add a new lead. Rachna 9764092911" without having delegated to it, the lead is Ada's. An owner that names an agent or a team is refused: "Sales Assistant can't own a lead: leads belong to people, not to agents." So is a person who may not read the collection, who could not open what they were given: "maya can't own a lead: they may not read leads".

Reassigning. Under owner_or_role, the owner of a record, or anyone holding one of the rule's roles, may give it to someone else, including through an agent. For Leads that is the lead's owner, the sales lead and admins:

Who Gives a lead to someone else
Alice (rep) Her own leads only. Taking Sam's is refused, without naming a lead she cannot read: "You can't give this lead to Alice Chen: only its owner, the sales lead or an admin can reassign it."
Sam (sales lead) Any lead
Ada (admin, on no team) Any lead, from the record's Reassign (she cannot read leads, so not by editing them)
An agent acting for Alice Only what Alice may: her own leads
An agent acting for nobody, at Ada's ask The leads Ada owns. A lead the agent itself owns only when an admin, or the lead of a team that writes leads and that the agent is on, asked; never just because the asker would own it after.

Under owner_only only the owner changes a record and nobody gives it away; an admin or the lead of a team that writes the collection may still claim, on the record, one no person owns.

Each change of owner is the event Record reassigned (record_reassigned, with from, to and by), and the new owner gets an inbox item, "Sam Ortiz gave you the lead Globex" ("Sales Assistant, for Alice Chen, gave you the lead Acme" when an agent did it for someone). Choosing it opens the lead. A new record given to someone other than the person it was written for counts too.

Reassign and Claim on the record. The record panel shows an Owner line with a list of people, Reassign and Claim (give it to yourself), to anyone who may write the collection and to admins. Besides the people the rule names, admins and the lead of a team that writes the collection may reassign or claim a record no person owns this way (an agent's, a team's or one with no owner), and admins any record under owner_or_role, whose rule names them. A record someone else owns stays out of reach of a team lead who holds none of the rule's roles. The new owner must be an active person who may read the collection: "Maya Patel can't own a lead: they may not read leads". A record you may neither read nor reassign answers as missing (or, when you may not read the collection, with the same refusal whether or not it exists). An admin who cannot read the collection opens a record from a link (an answer, an inbox item) and sees "You cannot read this collection", with the same Reassign below it.

A company that enabled the CRM app before this change keeps the old Leads write rule, owner_only, until its server next starts: reconciling the app then moves Leads to owner_or_role (the app's Overview says "leads: write rule now ..."). A write rule your company changed since is left as it is.

Browsing and filtering records#

The Data tab shows the records you may read, in a table built from the schema: money is formatted ($12,000.00), dates read as days (Mon, Oct 5), people as names. The last two columns are the version (v) and who wrote it (By). Click a column head to sort by it; click again to reverse. Numbers sort as text, so Value puts $12,000.00 before $9,000.00 (a bug).

To filter, as Alice on Brain › Leads:

  1. Choose Add condition. A row appears: a field list, an operator list and a value box.
  2. Pick stage, keep eq, and type contacted.
  3. Choose Run. The table shows Litware only, and the count reads "1 of 7 rows you can read · as Alice Chen".

Operators are eq, ne, contains, gt, gte, lt, lte, is_null and not_null. All conditions must match. typed filter shows the filter as JSON, the form agents and the API use. Remove a condition with its ×, then choose Run again.

Click a row to open the record in a panel. Its title is the collection, the first 8 characters of the record's id and its version (Leads 96d4ef85 V1). It holds:

  • Edit, Flag as suspicious and Delete, shown to anyone who may write to the collection, even on rows they may not change (see Flagging a bad write).
  • The fields.
  • Provenance: written by (the person or agent), acting for (the person an agent worked for), run (a link to the agent's run on the Work page), skill, source (direct, or rollback when the version came from a rollback) and at.
  • History: every version, newest first, each with who wrote it, its source and when. Open fields on a version to see its values. Every version but the current one has Roll back to vN.
  • Linked from: records in other collections that point at this one. On Alice's Litware lead it shows a Contacts record for Dana Brooks, CTO, whose lead field names Litware.

Files attached to a record are listed at the end of its detail page (the Lead page), with Attach for anyone who may write the collection; whoever may read the record may open them (see Files).

Adding and editing records#

To add a lead, as Alice on Brain › Leads:

  1. Choose Add record. A sheet opens, titled "New leads record", with one input per field. Each label gives the field name and type (name * · string); * marks a required field. Enums are a list, dates a date picker, yes or no a checkbox, and an owner a list of people and agents ("Alice Chen (alice)").
  2. Type Woodgrove Bank in name and pick new in stage. Leave owner empty.
  3. Choose Create. "Record created" appears and Woodgrove Bank is in the table at version 1, owned by Alice Chen.

To edit:

  1. Click the Tailspin Toys row, then Edit. The fields become a form.
  2. Change value to 950000. Money is typed in cents (the box shows cents when empty): 950000 is $9,500.00.
  3. Choose Save. "Saved new version" appears. A moment later the panel shows V2 with value $9,500.00, and v1 is still in History.

Every save makes a new version; nothing is overwritten. The server refuses a field the schema does not know ("unknown field budget"), a value outside an enum, and a missing required field.

Emptying a field in the form and saving clears it: the new version has no value there (the form sends the field as null, as the API takes it). A required field cannot be emptied.

Rolling back#

Rolling back makes a new version with the fields of an earlier one. The bad version stays in History, so the rollback can itself be undone.

  1. As Alice, open Litware, choose Edit, set stage to qualified, and choose Save. The record is at V2.
  2. In History, on v1, choose Roll back to v1. "Rolled back to v1" appears.
  3. A moment later the record is at V3 with stage Contacted, and Provenance shows source rollback. History lists V3, V2 and V1.

Only someone who may write the record can roll it back. Maya, who may not write leads, never sees Roll back; Sam, the sales lead, may roll back Alice's leads.

Rolling back also clears any flags on the record (next section).

Delete opens a box, "Delete?" with "Soft-delete this record?", and Cancel or Delete. Choosing Delete shows "Deleted" and removes the record from the table. The delete is a new version marked deleted; the earlier versions stay. The Brain page does not show deleted records, so restoring one takes a rollback to an earlier version through the API or CLI (see For developers).

Flagging a bad write#

When a record looks wrong and you cannot or should not fix it yourself, flag it. The owner is told.

  1. Sign in as Sam, open Brain › Leads and click Tailspin Toys (Alice's lead).
  2. Choose Flag as suspicious. The browser asks "Why is this write suspicious?". Type Value looks wrong; they quoted 9,000 and choose OK.
  3. "Flagged; the owner has been notified" appears.
  4. Sign in as Alice and open Inbox. Under Items, a new item reads "Record leads:6ed34b48-... flagged: Value looks wrong; they quoted 9,000" (the id is the full record id).
  5. Alice opens Tailspin Toys on Brain › Leads and rolls it back to the right version. The flag is cleared.

The flag goes to the record's owner; if it has none, to the person the writer acted for, or else to the writer. Only people who may write to the collection see Flag as suspicious. Only a record you may read can be flagged: Eli, an engineer, flagging a lead is refused with "eli may not read leads:...", and nobody is told. A flag passes the same checks as a read of the collection (kill switches, delegations, rules). The Events page lists the flag as Record flagged.

Things to know:

  • The record itself does not show that it is flagged. The open flags are listed on Brain before you pick a collection, under Flagged records (on a phone, above the list of collections): each with its collection, id, the reason and who flagged it, opening the record ("Writes someone marked as suspicious"). You see the flags on records you may read; an admin sees all.
  • The inbox item names the record by its id, not its name, and does not link to it.
  • A rep sees Edit, Delete and Roll back on a teammate's lead too, when the collection lists it for them; saving is refused in plain words ("You can't change the lead Fabrikam Labs: only its owner, the sales lead or an admin can."), with the technical line under details.

The Search box at the top of the sidebar searches the records, knowledge and files you may read, as you type. A file is found by the words of its text or its name for anyone who can see its conversation or its record, and by nobody else. As Alice, litware finds the Litware lead, and clicking it opens its Lead page. fabrikam shows "Nothing you may read matches.", because Fabrikam Labs is Sam's lead. Search also matches by meaning when an embedding model is set up, as in the demo: a small model (all-MiniLM-L6-v2) that runs on the server's own CPU, downloaded once (about 91 MB) when the demo first starts, so nothing you search leaves it. Its vectors are kept in an index on disk, built in the background as records and knowledge are written. Until that model is ready, or without one, search matches your words only and says "Matched on your words only: search by meaning is not set up here." Admins see how far the index has got under Search by meaning on the Brain page, and turn the built-in model on or off on Models. The workspace tour covers the box in full.

Search stays quick as the company grows: one company is comfortable at about a million items on one server, searching by words and by meaning (see How big it can get). Keep a large system of record, such as a CRM's half a million leads, where it is, as below.

Collections kept in another system#

An app can keep a collection in a system your company already runs, such as a CRM, instead of in OrchKernel. The admin chooses this when enabling the app: the enable sheet offers "Keep records in " for each collection the connection maps (see Apps and Connections).

Such a collection is federated:

  • Its line reads Kept in and it shows no record count.
  • Every read and write goes to the vendor through the connection, as you. Nothing is copied into OrchKernel. Each call is an event (Call to another system).
  • A read asks the vendor for what you asked for, where the vendor's adapter can take it: your filter, the rows your access allows (a rep's own leads), the order and the rows the page shows. A rep's "my leads in stage X" over 500,000 leads is one request to the vendor. OrchKernel still checks every row it gets back against your access before showing it.
  • A read stops at 5,000 rows or 60 seconds. The table, and any page that reads the collection, then shows "partial: the first 5,000 from . Rows past them were not read."
  • When the vendor limits requests or does not answer, the read fails at once with "rate_limited: ... try again in N s" or "vendor_unavailable: ... resume in N s" instead of waiting; try again after that time.
  • Deleting or rolling back one of its records is refused; change it in the vendor instead.
  • The Schema & policy tab shows its external mapping.
  • Where a collection is kept can change only while nothing is stored for it in OrchKernel.

The demo keeps every collection in OrchKernel, so none of this shows there, and this section was not checked in the demo.

Changing a schema: the Schema Steward#

No agent changes a schema directly. Changes arrive as proposals, and a person applies or rejects them on Governance › Schema.

The Schema Steward is a built-in agent that looks for structure that is needed or no longer needed and proposes changes. From its code:

It notices It proposes
Three or more records have a line starting key: value in a text field (Budget: 20000 in notes) Add a field budget (a string)
A field whose name looks like personal data (an email, a phone) has no sensitive data class Classify the field
A scratch collection has five or more records of one shape Promote it to a typed collection
A scratch collection idle for 30 days Archive it
A federated collection whose vendor has fields with no mapping Map each field
The same organization name or person email in two collections Synonyms that link them, for a person to review

It never applies anything. An admin starts it with Run steward now on Governance › Schema; only admins see that button.

Getting a new field#

The Steward's way to a new field is to see people already keeping it in a text field. In the demo:

  1. As Alice, edit the notes of three of your leads to add a line each: Budget: 20000 on Contoso Health, Budget: 15000 on Litware, Budget: 9000 on Tailspin Toys. Each value must start its own line.
  2. As Ada, open Governance, then Schema, and choose Run steward now. "Steward proposed 1 change(s)" appears. Under Open a card marked Proposed reads add field on leads, "3 records carry budget: inside notes; a real field would make it queryable", proposed by Schema Steward. details shows the field as JSON. Ada also gets an inbox item, "Steward proposes on leads: add field budget".
  3. Apply it, as below. The Leads schema goes to version 2 and every lead has an empty budget field. The values in the notes are not copied over; fill them in.

A person can also propose a change through the API (POST /schema/proposals, see For developers). There is no form for it on the screen.

Applying or rejecting#

Applying a schema change is a critical action, one that needs an admin:

Who What happens on Apply
An admin (Ada), or a person with the data owner role (no one in the demo) The change is applied at once. "Applied".
Anyone else (Sam) An approval goes to the admins. The proposal stays open until it is approved.
An agent Refused.
  1. As Sam, open Governance › Schema and choose Apply on the budget card. The screen says "Applied", but the card stays under Open: the change is waiting for Ada (a bug: the message should say it was sent for approval).
  2. As Ada, open Inbox. Under Waiting on you, a card Apply a schema change reads "Sam Ortiz asks to apply a schema change.", "Proposal 712b2529" (the start of the proposal id) and "critical actions require an admin". Choose Approve. "Approved" appears.
  3. On Governance › Schema, the card is under Decided, marked Applied.

Reject asks "Why?" and records your answer on the card ("proposed by Eli Novak · Not needed"). If the card still shows under Open, reload the page.

Anyone signed in can propose a change to any collection, even one they cannot read: Eli, an engineer, can propose a field on leads. Proposing changes nothing; applying is what is governed.

Pages are records too#

The pages under Apps in the sidebar (Leads, Pipeline, Marketing, Support operations and so on) are not code. Each one is a record in the views collection, so it has provenance, versions, history and rollback like any other record. One renderer draws every page from its record.

A page record holds:

Field What it does
name The page title and its sidebar label
kind list or dashboard, or detail for a page about one record (the Lead page)
collection The collection a list or detail page is about
section The sidebar heading it sits under. Empty keeps it out of the sidebar (detail pages are opened from a list or from search).
order Its position inside the section
icon A sidebar icon name
owner Who may edit it besides admins. An app's pages are owned by the app: the record shows "CRM app" (stored as module:crm).
spec The blocks the page is built from, as JSON

Under Apps, the sidebar groups pages by section, sections in alphabetical order (Context, Marketing, Product, Sales, Support for Alice), then by order. An admin can hide or move an app's pages from the app's Pages tab without editing the page record (see Apps).

The block kit#

A page is built only from these blocks. A page cannot add its own styles or new kinds of block.

Block Shows
header Title, subtitle, tags and facts from the record, and buttons
fields The record's fields as a list, with who wrote the current version
refs Everything about the record: runs, messages, approvals, tasks, decisions, knowledge, writes and linked records. The Lead page's Activity.
list Rows from a query, each with a title, subtitle and tag, linking to a detail page
table Rows from a query in a table
tiles Numbers: counts, sums, averages (Open pipeline $21,000.00)
chart Bar, stacked bar or line chart of a grouped count or sum
text A paragraph of text
actions Buttons that ask an agent or open another page

A button that asks an agent opens a new conversation with that agent with the text filled in. On Alice's Litware Lead page, Email the contact opens New conversation with Sales Assistant with "Email the contact at Litware" ready to send.

Who sees a page#

A page never grants access. Every block reads as the person viewing it:

  • Alice and Sam open the same Pipeline, and each sees only the leads they may read. Its subtitle says so: "Every number counts only the leads you may read". For Alice, Open pipeline is $21,000.00 (Litware and Tailspin Toys).
  • A page none of whose collections you may read is left out of your sidebar, and opening its address says "This page is paused or no longer exists." Alice opening Engineering (/v/tech.overview) gets this.
  • A block reading a collection you may not read, on a page you can otherwise see, says "You don't have access to ...". Alice on Support operations sees "You don't have access to Qa reviews."

Tiles and charts on large collections#

On a collection with 5,000 records or more, tiles and charts read running totals instead of every record. The first time a tile asks for a number, the brain counts its rows once and keeps the total. After that, every write, delete, rollback and purge updates the total as part of the same change.

  • The same numbers. A tile shows what it would show if it counted the records. Totals are kept separately for each owner, so a rep's tile adds up only that rep's totals, and a sales lead's tile adds up the whole team's. The row rules decide who sees what, exactly as for a query.
  • Speed. At 500,000 leads, a rep's tile takes under a millisecond instead of about a second.
  • When it still counts. A tile is counted from the records, as before, when its collection has fewer than 5,000 records or lives in another system. It is also counted when its numbers split into more than 20,000 groups, such as a filter on a date that changes daily for each lead. Self-hosters can change these limits (the settings are in docs/deployment.md in the repository).
  • Checking them. ok --as <admin> brain totals --verify compares each kept total with a fresh count of the records. --rebuild counts them again.

Who sees which pages in the demo is in the workspace tour.

Editing a page and rolling it back#

An admin edits a page as a record. As Ada:

  1. Open Marketing in the sidebar. At the bottom, choose Edit page (it is followed by the page id, marketing.overview, and only admins see it). It opens Brain › Views, the list of every page record, not the one page.
  2. Click the Marketing row, then Edit. spec is a JSON text box.
  3. Change name to Marketing overview and choose Save. The sidebar entry now reads Marketing overview.
  4. In History, choose Roll back to v1. The sidebar reads Marketing again.

Who may write a page record:

Who May
An admin Edit any page
The page's owner Edit that page
Any other person Create a new page (they become its owner), not edit someone else's. Alice editing Leads is refused ("alice may not modify row crm.leads in views").
An agent Draft a page; the person it works for approves it before it is published

A spec that reads a collection that does not exist is refused when saved ("block 0 (table) reads unknown collection 'nope'").

A new page made by a person is published at once, for everyone who may read its data, with no approval. In the demo, when Sam wrote a Follow-ups list page in the Sales section (through the API), it appeared in Alice's pages straight away, and Alice could not edit it.

Asking the Designer for a page#

The Designer is a built-in agent whose one job is writing pages. As its code describes it: you ask it in words ("Give the support team a queue sorted by age"); it reads the collections and existing pages, drafts a page from the block kit, posts the draft in the conversation ("Drafted the page "...". Approve to publish it."), and writes it to views. That write needs your approval. Approving publishes the page, and it appears in the sidebar under its section. Asking it to change an existing page makes a new version of that page.

In the demo:

  • Only admins work with the Designer; as Ada it is under No team in Talk to an agent on the Threads page. Sam does not see it.
  • The Designer needs a real model; the demo's stub planner cannot draft a page. Without one, an admin edits pages by hand as above.

Not possible yet#

  • Restoring a deleted record from the screen.
  • Proposing a new field, or any schema change, from the screen: only the Steward's own proposals, or the API.
  • Asking the Steward for a particular field: it proposes only from what it notices.
  • Changing who may read or write a collection from the screen: read and write teams and row rules come from the app.
  • Moving a field's values into a new field (the budget values stay in notes).
  • A visual page editor: pages are edited as JSON, or by asking the Designer.
  • Opening a page's own record from Edit page: it opens the whole Views list.

For developers#

API#

All under /api, with Authorization: Bearer <token>: an API token you issue on your profile (see People, tokens and access); the workspace itself uses your sign-in session. Reads and writes run as the caller; 403 denied when the caller may not read or write.

Method and path Body Notes
GET /brain/collections Every collection: def, readable, writable, count (null when federated or not readable)
GET /brain/collections/:name def, describe, history (schema versions)
POST /brain/collections/:name/query { filter?, order?, limit?, offset?, include_deleted? } Rows the caller may read. A federated read cut short answers x-ok-partial: true and x-ok-partial-from: <adapter>.
POST /brain/collections/:name/aggregate { filter?, group_by?: { field, bucket? }, metrics: [{ op, field?, as }] } count, sum, avg, min, max; bucket is day, week or month. Row rules apply before counting. On a large collection the answer comes from running totals (Tiles and charts on large collections), with the same rows.
POST /brain/collections/:name/records { id?, fields } Creates, or with id writes a new version. Fields given are merged into the current ones; null clears one. 422 invalid for an unknown field, a bad enum value or a missing required field.
GET /brain/collections/:name/records/:id { record, links }: links are the records that point at it
DELETE /brain/collections/:name/records/:id Soft delete: a new version with deleted: true
GET /brain/collections/:name/records/:id/history Every version, oldest first
POST /brain/collections/:name/records/:id/rollback { to_version } New version with that version's fields; clears flags; restores a deleted record. 404 for an unknown version, 409 federated_record for a federated one.
POST /brain/collections/:name/records/:id/flag { reason } Notifies the owner. 403 for a record you may not read (or one that does not exist).
POST /brain/collections/:name/records/:id/reassign { to } Gives the record to a person (Reassign; Claim is to yourself): { id, collection, version, owner, name }, never its other fields. Allowed under the write rule (owner, the rule's roles); to admins and the leads of the collection's write teams for a record no person owns; to admins for any record under owner_or_role. 404 for a record you may not read (when you may read the collection), 403 in plain words otherwise, missing or not; then 422 when to is not an active person who may read the collection or the collection has no owner field.
GET /brain/records/:id { collection, id, name } of a record you may read, found by its id alone (for an answer that holds only an id); 404 otherwise
GET /brain/flags Open flags on records you may read (an admin sees all): [collection, id, reason, by].
PUT /brain/collections/:name/semantics partial semantics Human admins; governed as a schema apply. searchable adds or removes the collection from search.
GET /refs/:collection/:id Everything that points at the record, filtered to what the caller may see
GET /search?q= collections, kinds, topics, since, limit { hits, keyword_only, truncated? }; 422 for an empty query
GET /search/index-status Human admins (403 otherwise): { models, budget_limit_cents, budget_spent_cents, index }; per embedding model queued, done, chunks_per_hour, eta_seconds, estimated_cost_cents, budget_days, local and status (ready, preparing with detail, unavailable with reason); per vector index its state, windows, partitions, sealed_segments, memory_bytes, disk_bytes and deleted
GET /schema/proposals Every proposal for an admin; for anyone else, their own and those about a collection they may read (a proposal for a collection that does not exist yet shows to admins and its proposer only)
POST /schema/proposals { collection, change, rationale } change is tagged by change: add_field (field), remove_field (name), set_data_class, set_field_data_class, promote_scratch, add_mapping, add_synonyms, archive, create_collection
POST /schema/proposals/:id/apply, .../reject reject: { note } Governed as schema.apply(<collection>)
POST /schema/steward Human admins only; returns the new proposals
GET /views Pages the caller may see, sidebar order
GET /views/:id?record=<id> The page rendered for the caller: each block with its data, error, denied or partial. A detail page without record is 422.
POST /views/preview { view, record?, params? } Renders a page record that is not stored

To restore a deleted record, find it with include_deleted: true, read its history, and roll back to the last version before the delete:

sh
curl -X POST -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' \
  http://127.0.0.1:8080/api/brain/collections/leads/records/<id>/rollback \
  -d '{"to_version": 1}'

A field to propose, for example:

json
{ "collection": "leads",
  "change": { "change": "add_field",
              "field": { "name": "industry", "type": "enum",
                         "values": ["health", "retail", "software"],
                         "description": "The lead's industry" } },
  "rationale": "We segment the pipeline by industry" }

A page record is written like any record, to views, with the page id as the record id (crm.lead, org.roadmap). A minimal list page:

json
{ "id": "sales.followups",
  "fields": { "name": "Follow-ups", "kind": "list", "collection": "leads",
              "section": "Sales", "order": 60, "icon": "list",
              "spec": { "blocks": [ { "type": "table",
                                      "columns": ["name", "next_follow_up"],
                                      "source": { "collection": "leads",
                                                  "filter": { "op": "not_null", "field": "next_follow_up" } } } ] } } }

The spec grammar is in RFC-0002 and, exactly as the Designer is told it, in crates/ok-kernel/src/designer.rs. Expressions $record.<field>, $record.id, $me.id, $today and $param.<name> may appear in titles and filter values.

CLI#

The CLI works on the state file directly. Commands that only read (brain query, history, collections, describe, flags, search, schema proposals, brain totals without --rebuild) work beside a running server; commands that change something are refused while it runs (exit status 75, "The server is running on ..."). With the demo running, make changes in the workspace or through the API.

sh
ok --state orchkernel-demo/state.db --as alice brain query leads --filter '{"op":"eq","field":"stage","value":"won"}'
ok --state orchkernel-demo/state.db --as alice brain history leads <id>
ok --state orchkernel-demo/state.db --as alice search litware
ok brain collections | describe <c> | upsert <c> --fields '<json>' [--id <id>]
ok brain rollback <c> <id> <version> | flag <c> <id> --reason <text> | flags
ok --as <admin> brain totals [<c>] [--verify] [--rebuild]   # running totals for tiles
ok schema proposals | apply <id> | reject <id> | steward

Events#

Event Events page label
record_written Record written
record_rolled_back Record rolled back
record_flagged Record flagged
collection_registered Collection added
schema_proposed, schema_applied, schema_rejected Schema change proposed, applied, rejected
adapter_request Call to another system