Remove final AppDatabase pass-through methods with ESLint guard (C1 part 3/3)
Migrate all remaining pass-through call sites (social, skills, budget,
entityCrud, documents, knowledge, automation, wakeup, backup, threads,
settings, snapshot, connectors, workspaces, activity) to their owning
domain modules. `AppDatabase` now carries only three methods:
- createHireRequest (multi-module composite: agents + approvalsMod)
- rollbackConfigRevision (multi-module composite: documents + entityCrud)
- queryAll (raw-SQL escape hatch, @internal)
The vault/env-binding infrastructure previously passed argument-by-
argument into `entityCrud.saveSecret`/`resolveSecretEnv` now binds at
module construction, letting callers invoke `db.entityCrud.saveSecret({...})`
without carrying vault plumbing.
Structural types that narrowed AppDatabase to a bag of flat methods
(`ConnectorModelPolicyDeps` callers, `CapabilityMatchDb`, test mocks in
budget-enforcement / budget-incidents / task-quality-gates /
failure-escalation / task-quality-gates-sweep) are reshaped to the new
namespace. `connectorPolicyDepsFromDb` replaces the old pattern of
handing the whole AppDatabase to `validateConnectorModelSelection`.
A new ESLint rule in eslint.config.mjs blocks new top-level methods on
AppDatabase so the pass-through layer cannot silently grow back.
`AppDatabase.ts` dropped from 193 lines to 58; `AppDatabaseBase` lost
the 270-line trailing pass-through block.
This commit is contained in:
1 parent
a69fbb053b
commit
118e3d8795
120 files changed
+838
-933
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { AppDatabase } from "./database";
|
||||
import { getConnectorExecutionReadinessIssue, isConnectorExecutionReady } from "@shared/connector-policy";
|
||||
import type { ConnectorId, ConnectorRecord } from "@shared/types";
|
||||
import { validateConnectorModelSelection } from "./connector-model-policy";
|
||||
import { validateConnectorModelSelection, connectorPolicyDepsFromDb } from "./connector-model-policy";
|
||||
|
||||
interface OnboardingBootstrapSummary {
|
||||
companyId: string;
|
||||
@@ -113,7 +113,7 @@ export function createOnboardingService({
|
||||
const trimmedPath = workspacePath.trim();
|
||||
if (!trimmedPath) return null;
|
||||
const wsLocale = getLocale();
|
||||
return db.saveWorkspace({
|
||||
return db.workspacesMod.saveWorkspace({
|
||||
companyId,
|
||||
name: wsLocale === "zh" ? "默认工作区" : "Default Workspace",
|
||||
localPath: trimmedPath,
|
||||
@@ -158,7 +158,7 @@ export function createOnboardingService({
|
||||
? `Turn the founding goal "${activeGoal.title}" into an execution plan, delegation map, and the first wave of real work.`
|
||||
: "Establish the first operating plan, assign work, and start the company execution loop.";
|
||||
|
||||
const projectId = db.saveProject({
|
||||
const projectId = db.entityCrud.saveProject({
|
||||
companyId,
|
||||
goalId: activeGoal?.id ?? null,
|
||||
name: kickoffProjectName,
|
||||
@@ -217,7 +217,7 @@ export function createOnboardingService({
|
||||
}
|
||||
|
||||
function bootstrapOnboarding(input: BootstrapInput): OnboardingBootstrapSummary {
|
||||
const connectors = db.listSnapshot({ companyId: null }).connectors;
|
||||
const connectors = db.snap.listSnapshot({ companyId: null }).connectors;
|
||||
const selectedConnectorId = resolveOnboardingConnector(connectors, input.connectorId);
|
||||
|
||||
const companyId = db.company.saveCompany({
|
||||
@@ -234,13 +234,13 @@ export function createOnboardingService({
|
||||
// pre-commit; the pool settings arrive in the input payload and
|
||||
// land in the DB only once a company exists to scope them.
|
||||
for (const pool of input.connectorPoolSelections ?? []) {
|
||||
db.setDisabledModels(companyId, pool.connectorId, pool.disabledModels);
|
||||
db.settings.setDisabledModels(companyId, pool.connectorId, pool.disabledModels);
|
||||
}
|
||||
|
||||
// Validate the CEO model selection against the now-persisted pool
|
||||
// scoped to this new company. Must run AFTER the pool is stored,
|
||||
// otherwise the validator sees an empty pool and accepts anything.
|
||||
const modelSelection = validateConnectorModelSelection(db, companyId, selectedConnectorId, input.connectorModel ?? null);
|
||||
const modelSelection = validateConnectorModelSelection(connectorPolicyDepsFromDb(db), companyId, selectedConnectorId, input.connectorModel ?? null);
|
||||
if (!modelSelection.ok) {
|
||||
throw new Error(modelSelection.error);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ export function createOnboardingService({
|
||||
|
||||
const goalTitle = input.goalTitle.trim();
|
||||
if (goalTitle) {
|
||||
db.saveGoal({
|
||||
db.entityCrud.saveGoal({
|
||||
companyId,
|
||||
title: goalTitle,
|
||||
description: input.goalDescription.trim() || `Achieve: ${goalTitle}`,
|
||||
@@ -280,7 +280,7 @@ export function createOnboardingService({
|
||||
roleLevel: "c_suite",
|
||||
});
|
||||
db.agents.setHeartbeat(ceoId, true, 120);
|
||||
db.setCurrentCompany(companyId);
|
||||
db.settings.setCurrentCompany(companyId);
|
||||
seedDefaultAutomationRules(companyId);
|
||||
|
||||
if (scanAndAssignSkills) {
|
||||
@@ -292,7 +292,7 @@ export function createOnboardingService({
|
||||
|
||||
const kickoff = createInitialExecutionLoop(companyId, workspaceId);
|
||||
|
||||
db.addActivity({
|
||||
db.activityMod.addActivity({
|
||||
companyId,
|
||||
actor: "board",
|
||||
action: "company.bootstrapped",
|
||||
|
||||
Reference in new issue
Block a user