The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): require durable re-review provenance
Jakub Wolniewicz224592875707
diff --git a/hermes_cli/kanban_db.py b/hermes_cli/kanban_db.pyindex 2ab0b8a1c40..7e6630029e5 100644--- a/hermes_cli/kanban_db.py+++ b/hermes_cli/kanban_db.py@@ -6134,12 +6134,21 @@ def request_review(return Falseimplementer = trow["assignee"]if reviewer is None:- changes_event = conn.execute(- "SELECT payload FROM task_events "- "WHERE task_id = ? AND kind = 'changes_requested' "+ changes_run = conn.execute(+ "SELECT id FROM task_runs "+ "WHERE task_id = ? AND outcome = 'changes_requested' ""ORDER BY id DESC LIMIT 1",(task_id,),).fetchone()+ changes_event = None+ if changes_run is not None:+ changes_event = conn.execute(+ "SELECT payload FROM task_events "+ "WHERE task_id = ? AND run_id = ? "+ "AND kind = 'changes_requested' "+ "ORDER BY id DESC LIMIT 1",+ (task_id, int(changes_run["id"])),+ ).fetchone()try:changes_payload = (json.loads(changes_event["payload"])@@ -6153,7 +6162,7 @@ def request_review(if isinstance(changes_payload, dict)else None)- if changes_event is not None:+ if changes_run is not None:if not isinstance(prior_reviewer, str) or not prior_reviewer.strip():return Falsereviewer = prior_reviewerdiff --git a/tests/hermes_cli/test_kanban_review_lifecycle_complete.py b/tests/hermes_cli/test_kanban_review_lifecycle_complete.pyindex 949da113100..72684c04520 100644--- a/tests/hermes_cli/test_kanban_review_lifecycle_complete.py+++ b/tests/hermes_cli/test_kanban_review_lifecycle_complete.py@@ -149,10 +149,10 @@ def test_same_card_review_supports_changes_and_approval_without_block_loop(conn)assert completed.block_recurrences == 0[email protected]("bad_payload", ["{not-json", "{}"])[email protected]("bad_payload", [None, "{not-json", "{}"])def test_rereview_requires_explicit_reviewer_when_provenance_is_invalid(conn,- bad_payload: str,+ bad_payload: str | None,) -> None:task_id, review = _claimed_review(conn, "Malformed reviewer provenance")assert kb.request_changes(@@ -162,13 +162,20 @@ def test_rereview_requires_explicit_reviewer_when_provenance_is_invalid(expected_run_id=review.current_run_id,) == (True, "builder")with kb.write_txn(conn):- conn.execute(- "UPDATE task_events SET payload = ? "- "WHERE id = (SELECT id FROM task_events "- "WHERE task_id = ? AND kind = 'changes_requested' "- "ORDER BY id DESC LIMIT 1)",- (bad_payload, task_id),- )+ if bad_payload is None:+ conn.execute(+ "DELETE FROM task_events "+ "WHERE task_id = ? AND kind = 'changes_requested'",+ (task_id,),+ )+ else:+ conn.execute(+ "UPDATE task_events SET payload = ? "+ "WHERE id = (SELECT id FROM task_events "+ "WHERE task_id = ? AND kind = 'changes_requested' "+ "ORDER BY id DESC LIMIT 1)",+ (bad_payload, task_id),+ )implementation = kb.claim_task(conn, task_id, claimer="builder:retry")assert implementation is not None