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

+4 -4
View File
@@ -30,7 +30,7 @@ const SUBJECT_PREVIEW_LEN = 80;
export function resolveInitialUserTurn(
params: {
trigger: string | null;
task: ReturnType<AppDatabase["getTask"]> | null;
task: ReturnType<AppDatabase["entityCrud"]["getTask"]> | null;
companyId: string;
agentId: string;
},
@@ -61,9 +61,9 @@ export function resolveInitialUserTurn(
// mode prompt.
if (trigger === "timer" || trigger === "bootstrap" || trigger === "app_restart_resume") {
try {
const agent = deps.db.getAgent(agentId);
const agent = deps.db.entityCrud.getAgent(agentId);
if (!agent.reportsTo) {
const activeReports = deps.db
const activeReports = deps.db.agents
.getDirectReports(agentId, companyId)
.filter((r) => r.status !== "pending_approval" && r.status !== "terminated");
if (activeReports.length === 0) {
@@ -145,7 +145,7 @@ function buildGenericWakeTurn(trigger: string | null): string {
function resolveAgentLabel(db: AppDatabase, agentId: string): string {
try {
const name = db.findAgentName(agentId);
const name = db.agents.findAgentName(agentId);
if (name && name.length > 0) return name;
} catch {
// fall through