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

@@ -45,7 +45,7 @@ async function createHarness(): Promise<Harness> {
const db = new AppDatabase(profileDir);
db.init();
db.updateConnectorHealth({
db.connectorsCrud.updateConnectorHealth({
id: "openai-codex",
status: "ready",
authState: "authenticated",
@@ -58,7 +58,7 @@ async function createHarness(): Promise<Harness> {
description: "Tests archived visibility, bulk retirement, deliverable signal",
status: "active",
});
const workspaceId = db.saveWorkspace({
const workspaceId = db.workspacesMod.saveWorkspace({
companyId,
name: "Primary",
localPath: workspacePath,
@@ -107,7 +107,7 @@ async function createHarness(): Promise<Harness> {
}
function registerArtifact(harness: Harness, relativePath: string): string {
return harness.db.createWorkProduct({
return harness.db.documentsMod.createWorkProduct({
companyId: harness.companyId,
taskId: harness.taskId,
workspaceId: harness.workspaceId,
@@ -126,12 +126,12 @@ describe("work_products archived visibility", () => {
try {
const activeId = registerArtifact(harness, "docs/active.md");
const archivedId = registerArtifact(harness, "docs/retired.md");
harness.db.updateWorkProduct(archivedId, harness.companyId, {
harness.db.documentsMod.updateWorkProduct(archivedId, harness.companyId, {
status: "archived",
lastTouchedByRunId: harness.runId,
});
const snapshot = harness.db.listSnapshot();
const snapshot = harness.db.snap.listSnapshot();
const visibleIds = snapshot.workProducts.map((wp) => wp.id);
expect(visibleIds).toContain(activeId);
expect(visibleIds).not.toContain(archivedId);
@@ -145,12 +145,12 @@ describe("work_products archived visibility", () => {
try {
const activeId = registerArtifact(harness, "src/feature.ts");
const archivedId = registerArtifact(harness, "src/removed.ts");
harness.db.updateWorkProduct(archivedId, harness.companyId, {
harness.db.documentsMod.updateWorkProduct(archivedId, harness.companyId, {
status: "archived",
lastTouchedByRunId: harness.runId,
});
const rows = harness.db.listWorkProductsForTask(harness.taskId, harness.companyId);
const rows = harness.db.documentsMod.listWorkProductsForTask(harness.taskId, harness.companyId);
const ids = rows.map((r) => r.id);
expect(ids).toContain(activeId);
expect(ids).not.toContain(archivedId);
@@ -164,16 +164,16 @@ describe("work_products archived visibility", () => {
try {
const id = registerArtifact(harness, "notes/ghost.md");
expect(
harness.db.resolveWorkProductTarget(id, harness.companyId),
harness.db.documentsMod.resolveWorkProductTarget(id, harness.companyId),
).not.toBeNull();
harness.db.updateWorkProduct(id, harness.companyId, {
harness.db.documentsMod.updateWorkProduct(id, harness.companyId, {
status: "archived",
lastTouchedByRunId: harness.runId,
});
expect(
harness.db.resolveWorkProductTarget(id, harness.companyId),
harness.db.documentsMod.resolveWorkProductTarget(id, harness.companyId),
).toBeNull();
} finally {
harness.db.close();
@@ -193,7 +193,7 @@ describe("work_products bulk retirement", () => {
ids.push(registerArtifact(harness, rel));
}
const archived = harness.db.archiveWorkProductsByExternalPaths({
const archived = harness.db.documentsMod.archiveWorkProductsByExternalPaths({
companyId: harness.companyId,
workspaceId: harness.workspaceId,
provider: "filesystem",
@@ -206,7 +206,7 @@ describe("work_products bulk retirement", () => {
for (const id of ids) {
expect(archivedIdSet.has(id)).toBe(true);
}
const visible = harness.db.listSnapshot().workProducts;
const visible = harness.db.snap.listSnapshot().workProducts;
expect(visible.length).toBe(0);
} finally {
harness.db.close();
@@ -217,7 +217,7 @@ describe("work_products bulk retirement", () => {
const harness = await createHarness();
try {
const id = registerArtifact(harness, "tmp/scratch.log");
harness.db.archiveWorkProductsByExternalPaths({
harness.db.documentsMod.archiveWorkProductsByExternalPaths({
companyId: harness.companyId,
workspaceId: harness.workspaceId,
provider: "filesystem",
@@ -225,7 +225,7 @@ describe("work_products bulk retirement", () => {
lastTouchedByRunId: harness.runId,
});
const second = harness.db.archiveWorkProductsByExternalPaths({
const second = harness.db.documentsMod.archiveWorkProductsByExternalPaths({
companyId: harness.companyId,
workspaceId: harness.workspaceId,
provider: "filesystem",
@@ -235,7 +235,7 @@ describe("work_products bulk retirement", () => {
expect(second).toHaveLength(0);
expect(
harness.db.resolveWorkProductTarget(id, harness.companyId),
harness.db.documentsMod.resolveWorkProductTarget(id, harness.companyId),
).toBeNull();
} finally {
harness.db.close();
@@ -252,7 +252,7 @@ describe("work_products bulk retirement", () => {
const workProductId = registerArtifact(harness, relPath);
expect(
harness.db.resolveWorkProductTarget(workProductId, harness.companyId),
harness.db.documentsMod.resolveWorkProductTarget(workProductId, harness.companyId),
).not.toBeNull();
const baseline = {
@@ -277,7 +277,7 @@ describe("work_products bulk retirement", () => {
expect(retired.map((o) => (o as { relativePath: string }).relativePath)).toContain(relPath);
expect(
harness.db.resolveWorkProductTarget(workProductId, harness.companyId),
harness.db.documentsMod.resolveWorkProductTarget(workProductId, harness.companyId),
).toBeNull();
} finally {
harness.db.close();
@@ -290,19 +290,19 @@ describe("work_products deliverable signal", () => {
const harness = await createHarness();
try {
const id = registerArtifact(harness, "deliverables/final.md");
const beforeArchive = harness.db.collectRunDeliverableSignals(
const beforeArchive = harness.db.knowledgeMod.collectRunDeliverableSignals(
harness.runId,
harness.companyId,
harness.taskId,
);
expect(beforeArchive.hasWorkProduct).toBe(true);
harness.db.updateWorkProduct(id, harness.companyId, {
harness.db.documentsMod.updateWorkProduct(id, harness.companyId, {
status: "archived",
lastTouchedByRunId: harness.runId,
});
const afterArchive = harness.db.collectRunDeliverableSignals(
const afterArchive = harness.db.knowledgeMod.collectRunDeliverableSignals(
harness.runId,
harness.companyId,
harness.taskId,