Wake the CEO when the team stalls, not only when tasks are zero

The bootstrap gate fired on goalCount > 0 && taskCount === 0, which
missed the common failure mode: every task stuck in_review or blocked
so the counter stays positive while no progress happens. The CEO
then waited for the normal timer interval to spot the stall.

Add countAdvancingTasksForCompany (todo + in_progress only) and gate
bootstrap on that. Also pull messages to the top of the timer wake
step list so an agent waking on the normal cadence doesn't skip over
unanswered peer DMs in favour of its own task work.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-19 19:27:26 -04:00
1 parent 2e60ecc0e0
commit 2b2a6446cb
4 files changed
+32 -5

No files matched your search

+18
View File
@@ -112,6 +112,24 @@ export function buildTaskQueryMethods(
return row.cnt;
},
/**
* Count tasks that are actively producing progress this cycle —
* todo (waiting to be checked out) and in_progress (currently being
* worked). Excludes in_review (waiting on a human or manager) and
* blocked (waiting on a resolution). Used by the bootstrap
* scheduler to decide whether the CEO needs to be pinged: a company
* where every task is stuck in review or blocked is functionally
* idle even though countActiveTasksForCompany reports > 0.
*/
countAdvancingTasksForCompany(companyId: string): number {
const row = getDb()
.prepare(
"select count(*) as cnt from tasks where company_id = ? and status in ('todo','in_progress')",
)
.get(companyId) as { cnt: number };
return row.cnt;
},
listChildTasks(
parentId: string,
companyId: string,