Make bot types an extension of the bot's kind

Coordinator and worker come from bots.kind; bot_types now only holds
workspace_admin (was admin), each row naming its workspace, with no scope
field. Rows from v0.2.8 and earlier are fixed at boot by migrateBotTypes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-26 06:05:18 +01:00
co-authored by Claude Opus 5.5
parent 657a76d868
commit 926bad6bea
29 changed files with 168 additions and 175 deletions
+3 -3
View File
@@ -238,7 +238,7 @@ const schema: BUN_SQLITE_DatabaseSchemaType = {
},
{
fieldName: "kind",
fieldDescription: `Legacy: marks the one coordinator, which only the super admin sees and reaches. What a bot can do comes from \`bot_types\``,
fieldDescription: `Worker or the one coordinator (which only the super admin sees and reaches). \`bot_types\` add to it`,
dataType: "TEXT",
options: BotKinds.map((bk) => bk.value),
defaultValue: "worker",
@@ -1621,7 +1621,7 @@ const schema: BUN_SQLITE_DatabaseSchemaType = {
},
{
tableName: "bot_types",
tableDescription: `A bot's types, like \`user_types\` for users: what it can do (\`BotTypePermissionMatrix\`). A row with no workspace holds everywhere (the coordinator); one with a workspace only there (a workspace admin). A bot with no row is a worker. One per bot, type and workspace, enforced in \`setBotType\` since SQLite treats NULL ids as distinct`,
tableDescription: `Types a bot holds on top of its \`kind\`, like \`user_types\` for users (\`BotTypePermissionMatrix\`): each row holds in one workspace (a workspace admin). A bot with no row is just its kind. One per bot, type and workspace, enforced in \`setBotType\``,
fields: [
{
fieldName: "bot_id",
@@ -1641,7 +1641,7 @@ const schema: BUN_SQLITE_DatabaseSchemaType = {
},
{
fieldName: "workspace_id",
fieldDescription: `The workspace the type holds in; null for install-wide`,
fieldDescription: `The workspace the type holds in`,
dataType: "INTEGER",
foreignKey: {
cascadeDelete: true,
+3 -3
View File
@@ -198,7 +198,7 @@ export type BUN_SQLITE_COBBLE_BOTS = {
user_id?: number | "";
name?: string;
/**
* Legacy: marks the one coordinator, which only the super admin sees and reaches. What a bot can do comes from `bot_types`
* Worker or the one coordinator (which only the super admin sees and reaches). `bot_types` add to it
*/
kind?: "worker" | "coordinator" | "";
/**
@@ -1036,9 +1036,9 @@ export type BUN_SQLITE_COBBLE_BOT_TYPES = {
*/
updated_at?: number | "";
bot_id?: number | "";
bot_type?: "coordinator" | "admin" | "worker" | "";
bot_type?: "workspace_admin" | "";
/**
* The workspace the type holds in; null for install-wide
* The workspace the type holds in
*/
workspace_id?: number | "";
/**