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:
ZacharyZhang-NY committed 2026-04-20 13:31:39 -04:00
1 parent a69fbb053b
commit 118e3d8795
120 files changed
+838 -933

No files matched your search

+11 -11
View File
@@ -60,7 +60,7 @@ export function registerCoreAdminHandlers({
nextReviewDeliverables: parsed.reviewDeliverables,
handleApprovalResolved,
});
db.addActivity({
db.activityMod.addActivity({
companyId: id,
actor: "board",
action: parsed.id ? "company.updated" : "company.created",
@@ -76,10 +76,10 @@ export function registerCoreAdminHandlers({
if (typeof companyId !== "string" || !companyId) {
return fail("INVALID_COMPANY_ID", "A valid company id is required.");
}
if (!db.hasCompany(companyId)) {
if (!db.settings.hasCompany(companyId)) {
return fail("COMPANY_NOT_FOUND", "The selected company does not exist.");
}
db.setCurrentCompany(companyId);
db.settings.setCurrentCompany(companyId);
publishDomainChanged();
return ok(true);
});
@@ -93,12 +93,12 @@ export function registerCoreAdminHandlers({
// The per-company disabled-models pool is not consulted here —
// connector config is a global hint, and pool enforcement
// happens at run dispatch time where the company is known.
db.saveConnector({
db.connectorsCrud.saveConnector({
...parsed,
model: parsed.model ?? null,
});
db.addActivity({
companyId: db.getCurrentCompanyId() ?? "00000000-0000-0000-0000-000000000000",
db.activityMod.addActivity({
companyId: db.settings.getCurrentCompanyId() ?? "00000000-0000-0000-0000-000000000000",
actor: "board",
action: "connector.updated",
entityType: "connector",
@@ -127,7 +127,7 @@ export function registerCoreAdminHandlers({
registerHandle(IPC_CHANNELS.setConnectorDisabledModels, async (_event, payload) => {
const parsed = connectorDisabledModelsSchema.parse(payload);
db.setDisabledModels(parsed.companyId, parsed.connectorId, parsed.disabledModels);
db.settings.setDisabledModels(parsed.companyId, parsed.connectorId, parsed.disabledModels);
publishDomainChanged();
return ok(true);
});
@@ -136,11 +136,11 @@ export function registerCoreAdminHandlers({
const parsed = deleteEntitySchema.parse(payload);
const companyError = ensureCompanyExists(parsed.companyId);
if (companyError) return companyError;
if (!db.belongsToCompany("secrets", parsed.id, parsed.companyId)) {
if (!db.settings.belongsToCompany("secrets", parsed.id, parsed.companyId)) {
return fail("SECRET_NOT_FOUND", "Secret not found in the current company.");
}
db.deleteSecret(parsed.id, parsed.companyId);
db.addActivity({
db.entityCrud.deleteSecret(parsed.id, parsed.companyId);
db.activityMod.addActivity({
companyId: parsed.companyId,
actor: "board",
action: "secret.deleted",
@@ -156,7 +156,7 @@ export function registerCoreAdminHandlers({
if (typeof companyId !== "string" || companyId.length === 0) {
return fail("INVALID_INPUT", "Company ID is required.");
}
if (!db.hasCompany(companyId)) {
if (!db.settings.hasCompany(companyId)) {
return fail("COMPANY_NOT_FOUND", "Company not found.");
}
db.company.deleteCompany(companyId);