refactor(db): group database domain modules
This commit is contained in:
1 parent
e43a89096d
commit
6da0a58769
160 files changed
+2124
-1999
No files matched your search
@@ -25,12 +25,14 @@ interface CapabilityMatchResult {
|
||||
}
|
||||
|
||||
interface CapabilityMatchDb {
|
||||
entityCrud: {
|
||||
getAgent(id: string): { name: string; capabilities: string };
|
||||
};
|
||||
skills: {
|
||||
listAgentSkillAssignments(id: string): string[];
|
||||
getCompanySkill(companyId: string, skillId: string): { name: string; description: string | null; slug: string } | null;
|
||||
core: {
|
||||
entity: {
|
||||
getAgent(id: string): { name: string; capabilities: string };
|
||||
};
|
||||
skills: {
|
||||
listAgentSkillAssignments(id: string): string[];
|
||||
getCompanySkill(companyId: string, skillId: string): { name: string; description: string | null; slug: string } | null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -132,14 +134,14 @@ export function checkCapabilityMatch(
|
||||
return { matched: true, warning: "Task description has no distinctive keywords for capability matching." };
|
||||
}
|
||||
|
||||
const agent = db.entityCrud.getAgent(agentId);
|
||||
const agent = db.core.entity.getAgent(agentId);
|
||||
const capWords = tokenize(agent.capabilities);
|
||||
const capabilityOverlap = taskWords.filter((w) => capWords.includes(w)).length;
|
||||
|
||||
let skillOverlap = 0;
|
||||
const skillIds = db.skills.listAgentSkillAssignments(agentId);
|
||||
const skillIds = db.core.skills.listAgentSkillAssignments(agentId);
|
||||
for (const skillId of skillIds) {
|
||||
const skill = db.skills.getCompanySkill(companyId, skillId);
|
||||
const skill = db.core.skills.getCompanySkill(companyId, skillId);
|
||||
if (skill) {
|
||||
const skillWords = tokenize(`${skill.name} ${skill.description ?? ""} ${skill.slug}`);
|
||||
skillOverlap += taskWords.filter((w) => skillWords.includes(w)).length;
|
||||
@@ -201,7 +203,7 @@ export function sweepStaleReviews(
|
||||
const isCofounderMode = deps.getCompanyExecutionMode(companyId) === "ai_cofounder";
|
||||
|
||||
let escalatedCount = 0;
|
||||
const reviewTasks = deps.db.tasks.listReviewTasksForSweep(companyId);
|
||||
const reviewTasks = deps.db.core.tasks.listReviewTasksForSweep(companyId);
|
||||
|
||||
for (const task of reviewTasks) {
|
||||
const reviewAge = now - new Date(task.updatedAt).getTime();
|
||||
@@ -209,14 +211,14 @@ export function sweepStaleReviews(
|
||||
if (!task.assigneeAgentId) continue;
|
||||
|
||||
// The reviewer is the assignee's direct manager
|
||||
const reviewer = deps.db.agents.getManagerForAgent(task.assigneeAgentId);
|
||||
const reviewer = deps.db.core.agents.getManagerForAgent(task.assigneeAgentId);
|
||||
if (!reviewer) continue; // No manager = CEO-assigned task, skip escalation
|
||||
|
||||
// D-09: Escalate to the reviewer's manager (manager's manager)
|
||||
const chain = deps.db.agents.getChainOfCommand(reviewer.id);
|
||||
const chain = deps.db.core.agents.getChainOfCommand(reviewer.id);
|
||||
const escalationTarget = chain.length > 0 ? chain[0] : null;
|
||||
|
||||
const pendingApproval = deps.db.approvalsMod.findPendingApprovalForTask(companyId, task.id);
|
||||
const pendingApproval = deps.db.core.approvals.findPendingApprovalForTask(companyId, task.id);
|
||||
|
||||
// In ai_cofounder mode, ALL approvals require human decision — never auto-advance.
|
||||
if (isCofounderMode && pendingApproval) {
|
||||
@@ -285,7 +287,7 @@ export function sweepStaleReviews(
|
||||
|
||||
// D-10: Advance task status from in_review to done
|
||||
try {
|
||||
deps.db.tasks.advanceTaskStatus(task.id, "done", "Auto-advanced: review timeout exceeded 30 minutes.");
|
||||
deps.db.core.tasks.advanceTaskStatus(task.id, "done", "Auto-advanced: review timeout exceeded 30 minutes.");
|
||||
deps.handleTaskStatusChange(task.id, companyId, "in_review", "done");
|
||||
} catch (err) {
|
||||
log.warn(`[task-quality-gates] advanceTaskStatus failed for task ${task.id}:`, err instanceof Error ? err.message : String(err));
|
||||
|
||||
Reference in new issue
Block a user