Skip to content

Evolve a Kovlet schema and approve schema proposals

Change the tables of a Kovlet Data Space without breaking the other apps that use it. Safe changes apply at once, and risky ones wait for an owner to approve them.

8 min readUpdated December 2026Markdown
On this page

At a glance

  • Apps declare their tables in code (t.string(), t.number(), …). On connect, Kovlet compares the declaration with the Data Space.
  • Applied at once, for any app with editor access: a new table, a new optional column (.optional()), .indexed(), and a column order for a table that has none.
  • Anything that could break another app waits for an owner as a schema proposal. The app gets a SchemaApprovalRequiredError and keeps syncing.
  • A column the app leaves out of its declaration is never dropped.
  • An owner approves in the console under Safety (https://kovlet.com/safety/<space id>). Approving checks every row first.

A table's schemaThe column definitions of every table in a Data Space. Additive changes apply at once; destructive ones become schema proposals. is its list of columns and their types. Kovlet sorts each change you make to it into one of two kinds:

  • Additive changes apply on their own. They can't break another app.
  • Destructive changes become a schema proposalA destructive schema change (drop, rename, change type, make required) that waits for a space owner to approve or reject it in the Kovlet console.. An owner of the Data Space approves it in the Kovlet console.

These changes become proposals: a new required column, making a column required, a type change, .unique(), and renames and drops. You send renames and drops with POST /v1/spaces/{space}/schema/changes or the MCP tool propose_schema_addition.

This guide adds a column that applies at once. Then it makes a change that waits for an owner, and walks the owner through approving it.

Tip To add a required column to a table that has rows, add it as optional, give every row a value, then make it required. Step 4 shows how. If a row has no value, approving fails with 409 rows_violate_schema, which names the rows to fix.

Before you start

  • A Kovlet server. This guide uses a local kovletd --dev started with --dev-auto-approve, so the scripts connect without a browser. See Run Kovlet locally. Use the Docker image: it includes the console you need in step 4.
  • Against the hosted service, leave out url and consoleUrl, and approve each run in the browser.
  • Node.js 22 or newer, and npm i @kovlet/client tsx in an empty folder with "type": "module" in its package.json.
  • To approve proposals, the owner role on the Data Space. The person who created the space is its owner. Locally that is dev@example.com, the user --dev-auto-approve acts as.

Step 1: Start with a table

Declare one table with one column:

kovlet.ts
import { createKovletClient, t } from "@kovlet/client";

export const kovlet = createKovletClient({
  appName: "Expenses",
  url: "http://127.0.0.1:8080", // kovletd --dev; leave out for https://api.kovlet.com
  consoleUrl: "http://localhost:5173", // leave out for https://kovlet.com
  spaces: {
    main: {
      tables: {
        expenses: { amount: t.number() },
      },
    },
  },
});

Write one row, so the later steps have data to check against:

seed.ts
import { kovlet } from "./kovlet";

await kovlet.connect();
const expenses = kovlet.space("main").table("expenses");
await expenses.insert({ amount: 12.5 });
await kovlet.whenSynced();
console.log("space:", kovlet.space("main").spaceId);
console.log("rows:", expenses.all().length);
kovlet.disconnect();
terminal
npx tsx seed.ts

You should see this (the IDs differ):

output
[kovlet] To connect Expenses, open http://localhost:5173/activate?user_code=V6Q3-RVGT and confirm code V6Q3-RVGT
space: 01a23730-72e9-74d4-9a74-024789ad000b
rows: 1

With --dev-auto-approve, the code is approved at once. The app gets the Data Space named after it, "Expenses".

Note Keep the space ID. Step 4 opens it in the console.

Now add a script that prints the table's current columns and reports a pending approval. You run it after each change:

main.ts
import { SchemaApprovalRequiredError } from "@kovlet/client";
import { kovlet } from "./kovlet";

kovlet.onError((err) => {
  if (err instanceof SchemaApprovalRequiredError) {
    console.log("waiting for an owner:", err.tables, err.proposalIds);
  }
});

await kovlet.connect();
await kovlet.whenSynced();
const { expenses } = kovlet.space("main").schemas();
console.log("expenses:", JSON.stringify(expenses?.columns));
kovlet.disconnect();

space.schemas() is the schema the server holds, not the one you declared.

Step 2: Add an optional column

Add note to the declaration as an optional column:

kovlet.ts
 import { createKovletClient, t } from "@kovlet/client";
  
 export const kovlet = createKovletClient({
   appName: "Expenses",
   url: "http://127.0.0.1:8080", // kovletd --dev; leave out for https://api.kovlet.com
   consoleUrl: "http://localhost:5173", // leave out for https://kovlet.com
   spaces: {
     main: {
       tables: {
−        expenses: { amount: t.number() },
+        expenses: { amount: t.number(), note: t.string().optional() },
       },
     },
   },
 });
terminal
npx tsx main.ts

You should see

  • note in the printed columns, with "optional":true.
output
expenses: {"amount":{"type":"number"},"note":{"type":"string","optional":true}}

The column was added when the app connected, before the first sync, with no approval. Every other app on the Data Space receives the new schema live. Existing rows have no value in note, which is fine for an optional column.

These changes apply at once in the same way:

In the declaration and Change
In the declarationChange
A table the Data Space doesn't havecreate_table
A column the table doesn't have, with .optional()add_column (optional)
.indexed() on an existing columnadd_index
The declared column order, on a table that has noneset_order

Step 3: Make a change that needs approval

Make note required by removing .optional():

kovlet.ts
 import { createKovletClient, t } from "@kovlet/client";
  
 export const kovlet = createKovletClient({
   appName: "Expenses",
   url: "http://127.0.0.1:8080", // kovletd --dev; leave out for https://api.kovlet.com
   consoleUrl: "http://localhost:5173", // leave out for https://kovlet.com
   spaces: {
     main: {
       tables: {
−        expenses: { amount: t.number(), note: t.string().optional() },
+        expenses: { amount: t.number(), note: t.string() },
       },
     },
   },
 });
terminal
npx tsx main.ts

You should see

  • waiting for an owner:, with the table and the proposal's ID.
  • The columns unchanged: note is still optional.
output
waiting for an owner: [ 'expenses' ] [ '01a23731-0e31-776d-8ec3-a986f2bc2dae' ]
expenses: {"amount":{"type":"number"},"note":{"type":"string","optional":true}}

Kovlet did not apply the change. Instead:

  • It recorded a schema proposal for an owner.
  • It sent the app a schema_proposal_required error. The client raises it as SchemaApprovalRequiredError, with the tables and proposalIds.

The error is not fatal. The app stays connected and syncs. Only writes that need the new schema are rejected until an owner approves it. Connecting again with the same declaration reuses the pending proposal instead of making a new one.

What a declaration turns into a proposal:

In the declaration and Proposal
In the declarationProposal
A new column without .optional() on an existing tableadd_column (required)
An optional column declared without .optional()make_required
A different type, or a t.ref() to another tablechange_type
.unique() on an existing columnadd_unique

Some differences are ignored:

  • A column the declaration leaves out. Deleting a line from your code never drops data.
  • A column the app declares optional that the Data Space stores as required.

Renames and drops have no declaration form. Request them as in step 5.

In a React app, read the same error from useSyncStatus().error. Tell the user that an owner needs to approve the change.

Step 4: Approve the proposal in the console

An owner of the Data Space approves or rejects proposals in the Kovlet console:

  1. Open Safety for the Data Space: http://localhost:5173/safety/<space id> locally, or https://kovlet.com/safety/<space id>. You can also pick Safety in the console's navigation and choose the space.
  2. Find the card marked Waiting for approval: "Expenses wants to change expenses". It lists each change, the number of rows affected, and the other apps that use the table (May break).
  3. Click Approve change, then Approve change again in the dialog. Or click Reject, and the schema stays as it is.

Here the approval fails, because the row from step 1 has no note. The card shows the error, and the proposal stays pending. Over the API, the same refusal is HTTP 409:

JSON
{"error": {"code": "rows_violate_schema", "message": "make_required on expenses.note: 1 rows have no value in note",
           "table": "expenses", "column": "note", "op": "make_required", "reason": "required_missing",
           "type": "string", "count": 1, "examples": ["01a23730-86fc-7497-ac8e-70360827db02"],
           "hint": "Give these rows (trashed ones included) a value in note, then approve again; the proposal is still pending."}}

Kovlet never rewrites rows to fit a stricter schema. It has no default values or backfill. So give every row a value first. An update reaches rows in the TrashWhere deleted rows and files go. Deletes are soft: a trashed row or file keeps its data and can be restored. too:

backfill.ts
import { kovlet } from "./kovlet";

await kovlet.connect();
await kovlet.whenSynced();
const expenses = kovlet.space("main").table("expenses");
for (const row of expenses.all()) {
  if (row.note == null) await expenses.update(row.id, { note: "" });
}
await kovlet.whenSynced();
console.log("rows without a note:", expenses.all().filter((row) => row.note == null).length);
kovlet.disconnect();
terminal
npx tsx backfill.ts
output
rows without a note: 0

Caution table.all() lists live rows only. If the table has rows in the Trash, restore them or update them by ID too. Otherwise the approval names them in examples.

Click Approve change again. The change applies, and every app that uses expenses gets the new schema right away. main.ts now connects with no error:

terminal
npx tsx main.ts
output
expenses: {"amount":{"type":"number"},"note":{"type":"string"}}

This is the safe way to add a required column to a table that has rows: add it as optional, give every row a value, then make it required. A required column added in one step can only be approved while the table has no rows, live or trashed.

Step 5: Rename or drop a column

Renames and drops are explicit changes. An app, a script or a coding agent with editor access sends them. They become proposals, just like in step 3.

With the local server, kovletd dev seed gives you an app token for the "Expenses" space. With Docker, prefix it with docker exec kovletd.

terminal
eval "$(kovletd dev seed --env --space Expenses)"
curl -s -X POST "$KOVLET_URL/v1/spaces/$KOVLET_SPACE_ID/schema/changes" \
  -H "Authorization: Bearer $KOVLET_TOKEN" -H "Content-Type: application/json" \
  -d '{"changes": [{"op": "rename_column", "table": "expenses", "column": "note", "new_name": "memo"}]}'

The answer is HTTP 202 with the proposal (shortened):

JSON
{"tables": {"expenses": {"version": 3, "columns": {"amount": {"type": "number"}, "note": {"type": "string"}}, "order": ["amount", "note"]}},
 "ops": [],
 "proposals": [{"id": "01a23731-ae8c-7efe-b02f-05eeb0ec7d53", "table": "expenses", "base_version": 3,
                "changes": [{"op": "rename_column", "table": "expenses", "column": "note", "new_name": "memo"}],
                "status": "pending", "proposed_by": {"user_id": "…", "machine_id": "…", "app_id": "…"}}],
 "head_seq": 5}

How the server handles changes:

  • It is a list, applied in order.
  • The whole list must fit the current schema. Otherwise the call fails with 422 invalid_change and nothing changes.
  • Additive changes in the list apply at once. The answer is HTTP 200 when every change is additive.
  • Destructive changes become one proposal per table (HTTP 202).

The ops:

Op and Fields and Applies
OpFieldsApplies
create_tabletable, columns, order (optional)at once
add_columntable, column, def ({"type": "string", "optional": true})at once if optional, else a proposal
set_order, add_indextable, order / columnat once
rename_columntable, column, new_nameproposal
drop_columntable, columnproposal
change_typetable, column, def (the new type, and ref_table for a ref)proposal
make_requiredtable, columnproposal
rename_tabletable, new_nameproposal
drop_tabletableproposal
add_unique, drop_unique, drop_indextable, columnproposal

A coding agent sends the same changes with the MCP tool propose_schema_addition ({space, changes}). It can also add tables and optional columns with {space, tables}. See Connect a coding agent (MCP).

The owner approves the rename in Safety, as in step 4. Then update every app's declaration to the new name (memo: t.string()) right away.

Caution An app that still declares the old name asks for it again on its next connect. An optional column comes back at once as a new, empty column. A required one becomes a new proposal.

What approving a destructive change does to the data:

  • Drop a column: the values are removed from every row. Their earlier values stay in the Data Space's activity history.
  • Drop a table: its rows go to the Trash. A new table with that name later is accepted only if those rows fit its columns (409 trashed_rows_conflict otherwise).
  • Rename: every row is rewritten to the new name.
  • make_required, change_type, required add_column: existing rows are checked, not changed (409 rows_violate_schema).
  • add_unique: refused with 409 unique_violation while live rows share a value. The error lists them in duplicates.

Step 6: List and decide proposals over the APIOptional

Any session with at least viewer access can list proposals:

terminal
curl -s "$KOVLET_URL/v1/spaces/$KOVLET_SPACE_ID/schema/proposals?status=pending" -H "Authorization: Bearer $KOVLET_TOKEN"
JSON
{"proposals": [{"id": "01a23731-ae8c-7efe-b02f-05eeb0ec7d53", "space_id": "01a23730-72e9-74d4-9a74-024789ad000b", "table": "expenses",
                "base_version": 3, "changes": [{"op": "rename_column", "table": "expenses", "column": "note", "new_name": "memo"}],
                "status": "pending", "proposed_by": {"user_id": "…", "machine_id": "…", "app_id": "…"},
                "created_at": "2026-12-02T14:38:52.556985Z"}]}

status is pending, approved, rejected or superseded.

Deciding is for owners in the console. POST /v1/spaces/{space}/schema/proposals/{id}/approve and …/reject need the owner role and a console session. An app, a script or an agent gets 403 scope_required.

That is on purpose. An app can ask for a breaking change, but only a person who owns the data can accept it.

Troubleshooting

What you see and Why and What to do
What you seeWhyWhat to do
SchemaApprovalRequiredError / schema_proposal_required on connectThe declaration has a destructive change (step 3).Ask an owner to approve it in Safety, or change the declaration back.
409 rows_violate_schema when approvingRows (trashed ones included) have no value, or a value of another type, for the new definition. examples lists up to 5 IDs.Fix those rows, then approve again. The proposal stays pending.
409 proposal_stale when approvingThe table changed after the proposal was made. The proposal is now superseded.Connect the app again, or send the change again, to make a new proposal.
409 unique_violation when approving add_uniqueLive rows share a value; duplicates lists them.Make the values unique, then approve again.
409 rules_invalid when approvingThe change drops or renames a column the space's end-user rules read.Update the rules first.
409 trashed_rows_conflictA new or renamed table takes the name of a dropped table whose rows in the Trash don't fit it.Declare columns those rows fit, or restore and fix them.
409 proposal_decidedSomeone already approved or rejected it.Nothing to do.
403 scope_required on approve or rejectApps and agents can't decide proposals.Approve as an owner in the console.
422 invalid_changeA change is malformed or doesn't fit the current schema (for example a column that doesn't exist). Nothing changed.Read the schema (GET /v1/spaces/{space}/tables) and fix the change.
A new empty column appears after a renameAn app still declares the old name as optional.Update that app's declaration.
KovletAuthError: the user denied the request right after the code appears, on kovletd --dev --dev-auto-approveEvery run of a Node script without a persistent storage signs in as a new personal device, and the free plan allows 10. The kovletd log says quota exceeded: devices limit is 10.Start from an empty server (Run Kovlet locally).

Every error code is in the errors and limits reference.

Next

Ready to try it? Start free. No credit card, no API keys.

For coding agents: this page is also Markdown. Add .md to the URL or send Accept: text/markdown. The full reference is at /llms-full.txt.