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

@@ -47,7 +47,7 @@ async function createHarness() {
repoRef: "",
isPrimary: true,
});
const agentId = db.saveAgent({
const agentId = db.agents.saveAgent({
companyId,
name: "Research Lead",
role: "Researcher",
@@ -60,7 +60,7 @@ async function createHarness() {
capabilities: "Research and synthesis",
budgetMonthlyUsd: 180,
});
const taskId = db.saveTask({
const taskId = db.tasks.saveTask({
companyId,
title: "Refresh the market report",
description: "Update the report with new findings and submit it for review.",
@@ -69,7 +69,7 @@ async function createHarness() {
priority: "high",
status: "in_progress",
});
db.setTaskType(taskId, "research");
db.tasks.setTaskType(taskId, "research");
const existingDocumentId = db.saveDocument({
companyId,
@@ -172,7 +172,7 @@ describe("document run provenance", () => {
// ai_ceo + top-level CEO without `reviewDeliverables` advances
// straight to `done` — there is no reviewer in that configuration
// so the prior `in_review` state was a dead letter.
const task = harness.db.getTask(harness.taskId);
const task = harness.db.entityCrud.getTask(harness.taskId);
expect(task.status).toBe("done");
} finally {
harness.server.stop();