Skip to content

fix(kanban): call recompute_ready after unlink_tasks removes a dependency#22646

Closed
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:fix/ag04-unlink-recompute
Closed

fix(kanban): call recompute_ready after unlink_tasks removes a dependency#22646
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:fix/ag04-unlink-recompute

Conversation

@wesleysimplicio

Copy link
Copy Markdown
Contributor

Problem

unlink_tasks() removes a parent→child dependency edge but does not call recompute_ready(). A child whose last blocking parent is unlinked stays stuck in todo indefinitely — it only promotes to ready on the next dispatcher tick or a manual hermes kanban recompute. For CLI-only users without a dispatcher, the task is permanently stuck.

Root cause

complete_task() and unblock_task() both call recompute_ready(conn) after their write transaction so downstream children are evaluated immediately. unlink_tasks() was missing this call — removing a dependency edge is semantically equivalent to completing one, so the same recompute is required.

Fix

Capture the rowcount result before the write_txn context manager exits, then call recompute_ready(conn) outside the transaction when a row was actually deleted (so the child sees the updated task_links state):

# Before:
return cur.rowcount > 0

# After:
removed = cur.rowcount > 0
# (write_txn exits here)
if removed:
    recompute_ready(conn)
return removed

Tests

Added test_unlink_tasks_triggers_recompute_ready in tests/hermes_cli/test_kanban_db.py:

  • Creates parent A (done) + parent C (running), child B depending on both → todo
  • unlink_tasks(C, B) → asserts B is ready immediately

Stash-verified: FAILS without fix (child stays todo), PASSES with fix.
62/62 tests green in tests/hermes_cli/test_kanban_db.py.

Closes #22459.

…ency

Problem:
unlink_tasks() removes a parent→child dependency edge but does not trigger
recompute_ready().  A child whose last blocking parent is unlinked stays
stuck in 'todo' indefinitely — it only promotes to 'ready' on the next
dispatcher tick or a manual 'hermes kanban recompute'.  For CLI-only users
without a dispatcher, the child is permanently stuck.

Root cause:
complete_task() and unblock_task() both call recompute_ready() after their
write transaction so downstream children are evaluated immediately.
unlink_tasks() was missing this call — removing a dependency is
semantically equivalent to completing one, so the same recompute is needed.

Fix:
Capture the rowcount result before the write_txn exits, then call
recompute_ready(conn) outside the transaction when a row was actually
deleted (so the child sees the updated task_links state).

Tests:
Added test_unlink_tasks_triggers_recompute_ready in
tests/hermes_cli/test_kanban_db.py: creates parent A (done) + parent C
(running), child B with both parents (todo), unlinks C→B, asserts B is
ready immediately.  Stash-verified: FAILS without fix (child stays todo),
PASSES with fix.
62/62 tests green in tests/hermes_cli/test_kanban_db.py.

Closes NousResearch#22459.
Copilot AI review requested due to automatic review settings May 9, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Kanban dependency-resolution bug where unlink_tasks() removed a parent→child edge but did not immediately re-evaluate todo → ready promotions, leaving tasks stuck for CLI-only users (no dispatcher).

Changes:

  • Update unlink_tasks() to call recompute_ready(conn) after the write transaction when a link row was actually deleted.
  • Add a regression test covering the “unlink last blocking dependency promotes child to ready immediately” behavior (issue #22459).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
hermes_cli/kanban_db.py Triggers recompute_ready() after successfully unlinking a dependency edge so readiness updates immediately.
tests/hermes_cli/test_kanban_db.py Adds a regression test ensuring unlink_tasks() promotes a child to ready when its remaining parents are all done.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@teknium1

teknium1 commented May 9, 2026

Copy link
Copy Markdown
Contributor

Merged via salvage PR #22669. Your commit was cherry-picked onto current main with your authorship preserved in git log (rebase-merge). Thanks for the contribution!

@teknium1 teknium1 closed this May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: unlink_tasks does not trigger recompute_ready — tasks stuck in todo without dispatcher

3 participants