Codemod db pass-through calls to domain modules: tasks + agents (C1 part 1/3)

Rewrite ~525 call sites from `db.<method>()` to `db.<module>.<method>()`
for tasks and agents domains (including `getAgent`/`findAgent`/`getTask`
which live on the `entityCrud` field). Delete the corresponding
pass-through methods on AppDatabaseBase. Structural types that narrowed
`db` to a bag of flat methods (CapabilityMatchDb, EscalationDeps,
SweepStaleReviewsDeps) are reshaped to match the new namespace. Internal
callback references inside database.ts/database-base.ts now invoke the
owning module directly (e.g. `this.agents.saveAgent`) rather than the
deleted pass-through.

The codemod lives at scripts/codemod/remove-appdatabase-passthrough.mjs
and filters by owning module + optional explicit method list. It is
idempotent and does not re-rewrite already-namespaced calls.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-20 13:17:01 -04:00
1 parent 411294afa6
commit 5e9b7acbc6
95 files changed
+1123 -793

No files matched your search

+6 -6
View File
@@ -56,7 +56,7 @@ describe("company mode switching", () => {
repoRef: "",
isPrimary: true,
});
const ceoId = db.saveAgent({
const ceoId = db.agents.saveAgent({
companyId,
name: "CEO",
role: "CEO",
@@ -69,7 +69,7 @@ describe("company mode switching", () => {
capabilities: "Lead the company",
budgetMonthlyUsd: 250,
});
const engineerId = db.saveAgent({
const engineerId = db.agents.saveAgent({
companyId,
name: "Engineer",
role: "Engineer",
@@ -83,7 +83,7 @@ describe("company mode switching", () => {
budgetMonthlyUsd: 180,
department: "engineering",
});
const taskId = db.saveTask({
const taskId = db.tasks.saveTask({
companyId,
title: "Ship feature",
description: "Waits for cofounder review.",
@@ -100,7 +100,7 @@ describe("company mode switching", () => {
threadIntegration.onTaskCreated(taskId, companyId);
threadIntegration.onRunFinished("run-1", taskId, engineerId, companyId, "succeeded", null);
db.setTaskRequiresUserReview(taskId, true);
db.tasks.setTaskRequiresUserReview(taskId, true);
const approvalId = db.requestApproval({
companyId,
relatedTaskId: taskId,
@@ -113,7 +113,7 @@ describe("company mode switching", () => {
threadIntegration.onApprovalCreated(approvalId, companyId, taskId, "deliverable_review", "Review deliverable");
expect(db.listThreadWaitStates(companyId).length).toBeGreaterThan(0);
expect(db.getTask(taskId).requiresUserReview).toBe(true);
expect(db.entityCrud.getTask(taskId).requiresUserReview).toBe(true);
expect(db.getApprovalRecord(approvalId).state).toBe("pending");
const handlers = new Map<string, IpcHandler>();
@@ -149,7 +149,7 @@ describe("company mode switching", () => {
expect(result.ok).toBe(true);
expect(db.getCompanyExecutionMode(companyId)).toBe("ai_ceo");
expect(db.listThreadWaitStates(companyId)).toHaveLength(0);
expect(db.getTask(taskId).requiresUserReview).toBe(false);
expect(db.entityCrud.getTask(taskId).requiresUserReview).toBe(false);
expect(db.getApprovalRecord(approvalId).state).toBe("approved");
db.close();