Founder-CEO direct conversation is a structural invariant

Every org now keeps one direct chat between the primary employee and the
active c_suite agent: created at onboarding bootstrap (hard failure if
missing), repaired for existing orgs at startup. The existing
wakeDirectCounterparts path already wakes the CEO on every founder
message, so this space is the pinned "talk to your AI CEO" entry the
Messages page will surface next.
This commit is contained in:
ZacharyZhang-NY committed 2026-07-14 00:07:30 -04:00
1 parent 74195c6cdd
commit 62ce1570cd
4 files changed
+172

No files matched your search

+18
View File
@@ -6,6 +6,7 @@ import { DatabaseConnection } from "./database/connection";
import { createMainWindow } from "./app/create-window";
import { registerIpcHandlers } from "./app/ipc-handlers";
import { builtinSkillsSourceOverride, importStagedSkills, stageBuiltinSkillsLibrary } from "./services/builtin-skills";
import { ensureCeoDirectSpace } from "./services/ceo-direct-space";
import { SkillService } from "./services/skill-service";
import { startProviderBackgroundWorker } from "./app/provider-background-worker";
import { recoverInterruptedWork } from "./app/startup-recovery";
@@ -45,6 +46,7 @@ if (!app.requestSingleInstanceLock()) {
builtinSkillsLibrary,
});
syncAllOrganizationSkills(connection, join(profileDir, "artifacts"), builtinSkillsSource, builtinSkillsLibrary);
ensureAllCeoConversations(connection);
const stopProviderBackgroundWorker = startProviderBackgroundWorker({
db: connection.db,
mainWindow: win,
@@ -109,3 +111,19 @@ function syncAllOrganizationSkills(connection: DatabaseConnection, artifactRoot:
console.error(`[skills] built-in skill sync failed: ${error instanceof Error ? error.message : String(error)}`);
}
}
/**
* Repairs the founder⇄CEO conversation invariant for every organization at
* startup — orgs created before the pinned CEO chat existed get theirs here.
* A broken org is loud in the log but must not stop the app.
*/
function ensureAllCeoConversations(connection: DatabaseConnection): void {
const orgs = connection.db.prepare("select id from organizations").all() as Array<{ id: string }>;
for (const org of orgs) {
try {
connection.transaction(() => ensureCeoDirectSpace(connection.db, org.id));
} catch (error) {
console.error(`[chat] ensuring the CEO conversation for org ${org.id} failed: ${error instanceof Error ? error.message : String(error)}`);
}
}
}