fix(webhook): remove comment-based approve, keep status-only verdict
Status-only verdict model: comments NEVER drive the pipeline. Removed the whole comment-based control mechanism from handle_comment (:approved: / :rejected: / answer-to-questions) which caused bug 3 (echo self-hit): the analyst posts its own "waiting for approval" comment, handle_comment catches its own comment and reverts In Review -> In Progress. handle_comment is now a pure logger with no side effects. handle_status_start: a return to In Progress on an EXISTING task (Slava answered the analyst questions in Needs Input) now RELAUNCHES the stage agent instead of being a no-op. Distinguished from a duplicate In Progress webhook via has_active_job_for_task() (new db helper): no active job => agent idle => relaunch; active job => busy => skip (no double launch).
This commit is contained in:
17
src/db.py
17
src/db.py
@@ -351,6 +351,23 @@ def mark_job(
|
||||
conn.close()
|
||||
|
||||
|
||||
def has_active_job_for_task(task_id: int) -> bool:
|
||||
"""True if the task already has a queued or running job.
|
||||
|
||||
Used by the status-only verdict model (handle_status_start) to guard against
|
||||
double-launching an agent when a duplicate In Progress webhook arrives or a
|
||||
job is still in flight. The events de-dup absorbs identical webhook bodies;
|
||||
this guards against distinct webhooks while a job is pending/running.
|
||||
"""
|
||||
conn = get_db()
|
||||
row = conn.execute(
|
||||
"SELECT 1 FROM jobs WHERE task_id = ? AND status IN ('queued','running') LIMIT 1",
|
||||
(task_id,),
|
||||
).fetchone()
|
||||
conn.close()
|
||||
return row is not None
|
||||
|
||||
|
||||
def count_running_jobs() -> int:
|
||||
"""Number of jobs currently in 'running' status (for max_concurrency)."""
|
||||
conn = get_db()
|
||||
|
||||
Reference in New Issue
Block a user