A record is the unit of access in Run. The access block of each _schemas/{name}.yml file says who can open, change and delete the records of that table. A relation field links two records, and a link can pass access in one direction.
The same rules apply on every path: the Records screen, record pages, apps, widgets, search, exports and the data.* tools of an agent. A builder or an agent writes the rules in a Draft. A publisher makes them live, and a Draft never changes live access.
The access block
name: claim
label: Claim
label_field: claim_number
fields:
claim_number: { type: text, required: true, unique: true }
status: { type: select, options: [open, review, closed] }
handler: { type: email } # the person who works the claim
region_team: { type: select, options: [claims-east, claims-west] }
amount: { type: currency }
access:
read: [claims-handlers, claims-leads] # who can open claims
write: [claims-handlers, claims-leads] # who can change claims. Write includes read.
delete: [claims-leads] # who can delete claims. Default [admins].
rows: # optional: which claims each person sees
owner: handler # the claims whose handler is this person
team: region_team # the claims whose region_team is one of their teams
all: [claims-leads] # see every claim. Default [admins].
shares: read # none | read | write. Default read.
links: write # none | read | write. Default write.| Key | Type | Default | Rule |
|---|---|---|---|
access.read |
list of entries | [members] |
Who can open the records of the table. |
access.write |
list of entries | [members] |
Who can create and change records. Write includes read. |
access.delete |
list of entries | [admins] |
Who can delete records. Each entry, also the default [admins], must be in write, unless write has members (schema_delete_not_write). |
access.rows.owner |
field name or $creator, or a list of 1 to 3 |
none | email fields. A person sees the records that name them. $creator: a person sees the records that they added. |
access.rows.team |
field name, or a list of 1 to 3 | none | select, multi_select or text fields that hold team slugs. A person sees the records that name one of their teams. |
access.rows.all |
list of entries | [admins] |
Who sees every record of the table. [] keeps admins out of the rows. |
access.shares |
none, read or write |
read |
The highest level that a share of one record can give. |
access.links |
none, read or write |
write |
The highest level that a link can give on this table. Read the level through a link. |
An entry is members, admins or a team slug. An email is not an entry, and lint refuses it with schema_access_email. To add one person, share one record. To add a group of people, use a team.
How Run decides
- Open. A table rule (
readorwrite) must name the person. When the table hasrows, one row rule must also match: the person is inrows.all, an owner field names them, or a team field names one of their teams. A share of the record also opens it. - Change. The same check, with
write. A change can move a record out of the rows of the person. This is a hand-off. - Delete. The person needs
delete, and they must be able to change the record. A share and a link never give delete. - Create. The person needs
write. The new record must fall in their own rows, or the person must be inrows.all. A link gives one more way to create, but such a record cannot give the person direct access: read create through a link. - No block. A table with no
accessblock keeps the defaults. Every member can open and change its records, and admins can delete them. Lint shows the info noteschema_access_missing.
$creator matches the person who added the record. Run keeps that email on the record at create, and no path can change it. A background run or an API token adds records with no creator, so such a record matches $creator for nobody.
Shares
A person who can change a record can share it with a person or a team. “Can open” gives read, and “Can change” gives write. access.shares caps the level: none turns shares off, and read (the default) gives “Can open” only. A share can expire. Agents and API tokens never create shares.
Teams
A team is a WorkOS organization group. _schemas files and agent.yml name a team by its slug, for example claims-east. Admins make teams and pick directory groups in Organization > Teams. A rename in WorkOS does not change the slug.
- An unknown slug is a lint error when a person makes the project live. On a Draft it is a warning.
- A team that is deleted after a deploy matches nobody.
- A person who joins or leaves a team gets the change within 60 seconds. No push is necessary.
Agents and API tokens
- A turn that a person sends acts for that person. The agent opens a record only when its
datagrant covers the table and the person can open the record. - A background run acts as the agent: a schedule, an inbound webhook or an API token run. The
datagrant of the agent decides alone. - When Run cannot identify the person, the agent opens no record. When Run cannot read the teams of the person, no team rule matches.
- A
crk_key with theadminscope has the admin role. Areadorruntoken opens directly only the tables that havemembersinreadand norows. - A link from such a table also passes access to a
readorruntoken, but never into a table withrows. When the linked table does not havemembersinread, the token can only read its records. - For example,
memohasread: [members]and norows.notehasread: [clinicians], norowsand atakesfield tomemo. Aruntoken can read each note that links to a memo.
Lint rules of the access block
| Rule | Level | Check |
|---|---|---|
schema_access_invalid |
error | The access block has an unknown key or a wrong value. The message names the key. |
schema_access_email |
error | An entry is an email. Use a team, or share one record. |
schema_access_reserved |
error | A team of the organization has the slug members or admins. |
schema_access_team_unknown |
error on make live, warning on a Draft | An entry names a team slug that the organization does not have. |
schema_delete_not_write |
error | A delete entry, also the default [admins], is not in write, and write does not have members. |
schema_rows_owner_field |
error | rows.owner names a missing field, or a field that is not email. |
schema_rows_team_field |
error | rows.team names a missing field, or a field that is not select, multi_select or text. |
schema_rows_creator_reserved |
error | A field uses the reserved name $creator or run_creator. |
schema_access_conflict |
error | Two _schemas files of one name have other access blocks or other relation fields. |
schema_rows_team_option |
warning | An option of a team field is not a team slug. |
schema_rows_empty |
warning | rows has no owner and no team. |
schema_rows_creator_existing |
warning, Draft only | The Draft adds $creator to a table that has records. Those records have no creator. |
schema_access_widened |
warning, Draft only | The Draft lets more people open or change a table. The make-live dialog shows it. |
schema_access_missing |
info | The schema has no access block. |
Linked records
A relation field holds the id of a record of another table, or a list of ids. It can pass access to the linked record, in the direction that the field declares.
name: intake
label: Intake
label_field: number
fields:
number: { type: text, required: true, unique: true }
nurse: { type: email }
status: { type: select, options: [new, review, accepted, refused] }
patient: { type: relation, to: patient, access: gives } # the intake opens its patient
access:
read: [nurses, triage]
write: [nurses, triage]
delete: [triage] # each entry must also be in write
rows:
owner: nurse
all: [triage]name: lab_result
label: Lab result
label_field: title
fields:
title: { type: text, required: true }
intake: { type: relation, to: intake, access: takes } # the intake opens this result
patient: { type: relation, to: patient } # no access through this link
access:
read: [clinicians]
write: [clinicians]
delete: [clinicians]
links: write # the default. read keeps linked people at read.name: appointment
label: Appointment
fields:
starts_at: { type: datetime, required: true }
patient: { type: relation, to: patient, access: takes } # people who open the patient open it
intake: { type: relation, to: intake, access: takes } # people who open the intake open it
access:
read: [clinicians]
write: [clinicians]
delete: [clinicians]
links: readRelation fields
| Key | Type | Default | Rule |
|---|---|---|---|
fields.{name}.type |
relation |
A link to records of the table to. |
|
fields.{name}.to |
table name | required | A _schemas table of the same project. |
fields.{name}.many |
boolean | false |
false: the value is one record id. true: a list of at most 50 ids. |
fields.{name}.access |
none, takes or gives |
none |
Which way access passes through the link. |
fields.{name}.filing.auto_at |
number from 0.5 to 1 | 0.9 |
takes fields only. Read filing queues. |
- A relation field cannot be
unique, and it cannot be thelabel_field. - A change of
toormanyfails lint withschema_breaking. Add a new field instead. - A record cannot link to itself.
- A link to a missing or deleted record passes nothing. Run removes the id of a deleted record from the fields that hold it. History keeps the old value.
- A link with
access: nonepasses nothing. To add it, a person needs only to change the record that holds the field.
The direction
The field sits on the record that holds the id. access says which way access passes.
access |
Effect | Example |
|---|---|---|
none (default) |
The link passes nothing. | lab_result.patient |
takes |
People who can open the linked record can also open this record. | A lab result takes from its intake. |
gives |
People who can open this record can also open the linked record. | An intake gives its patient. |
Use takes on a record that reports to a parent: a lab result, an invoice line, a document of a case. Use gives on a case that opens a shared record, for example a patient or a supplier.
One link, never further
Only direct access passes through a link. Direct access comes from table rules, row rules and shares. Access that a person gets through a link stops there. It does not continue through another link.
A nurse owns intake INT-1 (nurse holds her email), and INT-1 links to patient P-1:
| Record | Can she open it? | Why |
|---|---|---|
| Intake INT-1 | yes, and change it | Direct: the owner rule. |
| Patient P-1 | yes, and change it | Through INT-1 (gives). |
Lab result L-1 with intake: INT-1 |
yes, and change it | Through INT-1 (takes). |
Appointment A-1 with intake: INT-1 |
yes, read only | Through INT-1 (takes), capped by links: read. |
Appointment A-2 with patient: P-1 and intake: INT-7 |
no | Her access to P-1 comes through a link. |
| Intake INT-7 of the same patient | no | INT-7 gives P-1. That does not open INT-7. |
So a person on one case never sees the other cases of a shared record.
The level through a link
The level through a link is the level of the person on the source record. access.links of the linked table caps it.
access.links |
A person who can open the source | A person who can change the source |
|---|---|---|
write (default) |
can open the record | can change the record |
read |
can open the record | can only open the record |
none |
cannot open the record | cannot open the record |
Delete never passes through a link.
A write through a link cannot give the person direct access to the record. For example, a person who changes an intake only through a link cannot set its owner field to their own email. Run answers 403 record_forbidden: “You cannot give yourself access to this record.” A create through a link has the same limit: read create through a link.
Add and remove links
- To add a
takesorgiveslink, a person must be able to change both records: the record that holds the field and the linked record. Direct access and access through a link both count. - To remove a link, a person needs only to change the record that holds the field.
- A refused link names the linked record only when the person can open it: “You cannot link this lab result to Intake INT-7. You cannot change that intake.”
- When another person changes one of the records at the same time, Run decides again, at most 3 times. Then it answers
409 record_changed: “This record changed while you saved. Try again.” - The record history and the “Who can open this” part of the record page show who made each link.
Create through a link
A person who can change a record directly can add a record that takes from it. The table of the new record must have access.links: write. The person needs no write rule on that table.
“Directly” means a table rule, a row rule or a share, not another link. For example, the nurse of intake INT-1 adds a lab result with intake: INT-1, with no write rule on lab results. The record page of the intake shows “Add lab result” in its linked records section.
A record that a person adds through a link cannot give them direct access. This limit applies only when a read rule names the person, no write rule names them, and a row rule decides which records they open. Then:
- An owner field of the new record cannot name them, and a team field cannot name one of their teams. Run answers
403 record_forbidden: “You cannot give yourself access to a record that you add through a link.” - A
$creatorrow rule always names them, because Run writes the person as the creator. So they cannot add a record of that table through a link. The record page shows no “Add” button, and Run answers403 record_forbidden, for example “You cannot add lab results.”
When the person adds a record through a link, the “Add” sheet fills in only the link. It fills in no owner field and no team field.
Shares and links
A share is direct access. So a share of a record also opens the records that this record passes access to, one link away. The share sheet says what else opens, for example “Also opens 3 linked records: Patient P-1, 2 lab results.”
A person who can change a record only through a link can also share it, with two limits:
- The share cannot name the sharer, or a team of the sharer.
- No share raises the access of the person who made it. Run ignores the share for its sharer, also when the sharer joins the team of the share later.
Lists and record pages
A record page, a file download and data.get decide on the current links and rules. Lists use a summary of who can open each record through its links: the Records screen, apps, widgets, search, exports and data.query. Run updates the summary after each change, usually within seconds.
So a record that a new link opens can take a few seconds to show in a list. When a list cannot check every linked record, it says: “Some linked records are not listed. Open the linked record to see them.”
What agents see
data.schemasshows each relation field withtoand its access sentence.data.getanddata.queryreturn a relation value as{ id, label }for each linked record that the actor can open, and as{ hidden: N }for the others.data.queryfilters a relation field on ids:{ "patient": "P-1" }, or{ "intake": ["INT-1", "INT-2"] }for any of a list. An empty value finds the records with no link.data.createanddata.updatetake record ids in relation fields. An update that sends back{ hidden: N }keeps the links that the agent cannot see.
Lint rules of links
| Rule | Level | Check |
|---|---|---|
relation_target_unknown |
error | to names no _schemas table of the project. |
relation_access_invalid |
error | access is not none, takes or gives. |
relation_filing_invalid |
error | filing on a field that is not takes, on a required field, with auto_at outside 0.5 to 1, or twice in one table. |
schema_links_invalid |
error | access.links is not none, read or write. |
relation_gives_open_table |
warning | A gives field on a table that every member can open, to a table that not every member can open. |
relation_link_widens |
warning, Draft only | A new link lets more people open a table. The make-live dialog says, for example, “People who can open intakes can now open patients (412 records).” |
relation_links_none |
info | A takes or gives link into a table with access.links: none. The link passes nothing. |
Runs on one record
A run can work on one record, its focus. Ask an agent on a record page starts a conversation on that record. The conversation shows “Working on Intake INT-0042”. An API caller with a crk_ key sends "focus": { "schema": "intake", "id": "INT-0042" } in the body of POST /{base}/{agent}.
- The run reads and changes only the focus and the records that the focus passes access to. The rules of the person and the
datagrant of the agent still apply. - A run on a lab result does not open its intake. Access passes from the intake to the lab result, not back.
- A new record must belong to the focus. When its table has a
takesfield to the focus table, Run fills it. When the focus table has agivesfield to its table, Run adds the new id to the focus. - A call outside the focus answers
focus_scope: “This conversation works on Intake INT-0042. Start a new conversation for Intake INT-7.” Another create answersfocus_create. - A continuation, a mention, a handoff and a child run keep the focus. They cannot clear it.
- A caller who cannot open the focus gets
404 record_not_found, and no run starts. An anonymous or Cloudflare Access caller that sendsfocusgets400 invalid_body.
Filing queues
A filing agent keeps each inbound document, for example an email attachment, as a record of a queue table. Only the queue team can open it. The agent links the document to its case with data.file. A confident call files the document. A less confident call asks the queue team in the Inbox.
name: inbound_document
label: Inbound document
label_field: subject
fields:
subject: { type: text }
sender: { type: email }
file_id: { type: text } # the Run file id of the attachment
status: { type: select, options: [waiting, filed, refused] }
intake:
type: relation
to: intake
access: takes
filing: { auto_at: 0.9 }
access:
read: [reception]
write: [reception]
delete: [reception]A filing field is a takes relation field with filing. A table has at most one filing field, and it cannot be required.
The data.file tool
Run offers data.file when the agent has a data.write grant on a table with a filing field and a data.read grant on the table that the field links to.
| Input | Rule |
|---|---|
schema |
The queue table. |
document |
The id of the document record. |
field |
The filing field of the queue table. |
target |
The id of the record that the document belongs to. |
confidence |
A number from 0 to 1. |
reason |
1 to 500 characters. The queue team sees it. |
- At or above
filing.auto_at(default 0.9), Run writes the link and setsstatus: filed. The tool answers{ "filed": true }. History says “Filed by Mail intake (96%)”. - Below it, Run opens one Inbox item for the queue team, with the suggested target, the confidence and the reason. The document stays
waiting. The tool answers{ "suggested": true, "inbox_item": "..." }. - A document has one filing item. A second call while the item is open replaces the suggestion.
- When a person decided first, the tool answers
already_decided.
When a person sent the turn, that person must be able to change the document and the target, as for any link. Run sets status only when the table has a select field status with that option.
The decision in the Inbox
The filing item asks “Where does this go?”. It shows in Needs you for each person who can change the document. It counts in the badge and ranks with approvals.
| Action | Who | Effect |
|---|---|---|
| File here | A person who can change the document and the target | Writes the link and sets status: filed. |
| Choose another record | The same, with a target that they can change | Writes the link to that target. |
| Refuse | A person who can change the document | Sets status: refused and keeps the note. |
- The first decision wins. A later one answers
409 already_decided, for example “Rita already filed this document.” - The card shows the label of the suggested target only to a person who can open it. Others see “A record you cannot open”, and they can only choose another record or refuse.
- A filing item closes only with a decision. Dismiss answers
409 use_filing. - Unfile on the record page of a document removes the link and sets
status: waiting. The filing item opens again for the queue team, with no suggested target. - The record form shows the filing field read-only. In the console, only the Inbox decision and Unfile set it.
A confident wrong guess files a document into the wrong case, and the people of that case can open it. To check the work of the agent, use Filed automatically on the Records screen of the queue table. It lists the documents that an agent filed in the last 7 days.
Roles
Run has three roles. An admin gives Can build in Organization > People.
| Can | Admin | Builder (Can build) | Member |
|---|---|---|---|
| Use Home, Inbox, Conversations, Apps, Outputs and Records | yes | yes | yes |
| Open the build pages: projects, agent settings, code, runs, schemas and front doors | yes | yes | no |
| Make changes live | yes | only when in access.publishers |
app changes only, when in access.publishers |
| Open Organization > Teams, People and Billing | yes | no | no |
| Switch to developer mode | yes | yes | no |
| Open records | the rules of this page | the rules of this page | the rules of this page |
| Start an agent | in its audience | in its audience | in its audience |
- Admin. An admin can do everything. By default, admins also see every record of a table with
rows, becauserows.alldefaults to[admins]. - Builder. A builder reads every schema of every project and changes projects in Drafts. A builder opens records only through the rules of this page, as a member does.
- Builder without publish. A builder who is not in
access.publishersworks only on Drafts. A change of the live project answers403 draft_required: “Only a publisher can change the live project. Start a Draft.” - Member. A member uses Run in business mode with the work pages: Home, Inbox, Conversations, Apps, Outputs, Records, personal connections and the agents that they can call. An agent is callable when it has
triggers.chatand its audience includes the person. - Other pages show the 404 page to a member, also when the member types the address. The console API answers
404to a member on build routes. The agent and project lists give a member only the agents that they can call and the tables that they can open. - The audience of an agent applies to every role. An admin or a builder outside the audience cannot start the agent from the console.
access.publishers in the root agent.yml lists admins and the emails of the people who can make changes live.
access:
publishers: [admins, ana@example.com]In Organization > People, an admin turns Can build on (role builder) or off (role member). An admin cannot change their own role or the role of another admin. When the identity provider manages a membership, change the role in the directory. A change takes effect at the next sign-in, or within a few minutes.
In WorkOS, builder is an environment role with no permissions. The role priority is admin, builder, member.
Access sentences
Run says each rule in one plain sentence. The schema editor, the make-live dialog, lint and data.schemas use the same words. Team names come from WorkOS.
The claim example of the access block gives:
- “Claims handlers and Claims leads can open claims.”
- “Claims handlers and Claims leads can change claims.”
- “Claims leads can delete claims.”
- “Each person sees the claims assigned to them.”
- “Each person also sees the claims of their teams.”
- “Claims leads see all claims.”
A table with no access block gives “Every member can open and change claims.” A table with shares: none adds “People cannot share one claim with others.”
The links of the intake example give:
takes: “People who can open an intake can also open its lab results.”gives: “People who can open an intake can also open its patient.”access.links: read: “Through a link, people can only read appointments.”- After the link sentences, always: “Access through a link stops there. It does not continue to other links.”