fix(sweep): בחירת הערת-יו"ר אחרונה לפי זמן, לא לפי מיקום-מערך #4
Reference in New Issue
Block a user
Delete Branch "fix/sweep-comment-ordering"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
הבאג (נתפס חי)
ה-sweep הניח ש-
listCommentsמחזיר oldest-first ולקחcomments[length-1]כ"הערה האחרונה". בפועלlistCommentsמחזיר newest-first → ה-sweep ניתב את הערת-היו"ר הישנה ביותר, וללא בדיקה אם סוכן כבר ענה.נתפס על CMPA-116: ה-sweep ניתב גְּריפה בת-6-ימים ("הסוכן לא הופעל ב-CMPA-89", שכבר נענתה דקות אחרי) במקום את הבקשה האמיתית התלויה של היו"ר ("צרפתי פסקי דין — תחזור להליך חוקר-תקדימים ותבדוק"). לכן ה-CEO עשה no-op בצדק, והבקשה האמיתית נשארה תקועה.
התיקון — order-independent
מחשב את הערת-היו"ר האחרונה ואת הערת-הסוכן האחרונה לפי
createdAt, ומנתב רק כשהיו"ר דיבר אחרון בין המשתתפים האמיתיים (newest-user > newest-agent, או אין הערת-סוכן). כך תגובת-סוכן נחשבת "טופל", אבל שורת-system אוטומטית ("טיוטה מוכנה") לא. תוקן גם אותו latent array-order ב-fallback של ה-event handler (reduce-by-createdAt).Self-heal: הסמן התקוע על CMPA-116 (שהוצמד בטעות להערה הישנה) ייפתר לבד — id הערת-היו"ר-האחרונה שונה.
בדיקות
tscנקי ·biomeנקי · נמדד true-backlog = 2 issues (CMPA-116 + CMPA-89, שתי בקשות-יו"ר תקועות אמיתיות).Refs legal-ai #164.
🤖 Generated with Claude Code
The sweep assumed listComments returns oldest-first and took comments[length-1] as "the last comment". listComments actually returns newest-first, so the sweep routed the OLDEST user comment instead of the newest — and routed it whether or not an agent had already answered. Caught live on CMPA-116: the sweep routed a stale 6-day-old "agent didn't activate" gripe (already answered minutes later) instead of the chair's real pending request ("I attached case law — go back to the precedent-researcher and check the docs"), so the CEO correctly no-op'd and the real request stayed dropped. Fix: order-independent. Compute the newest USER comment and newest AGENT comment by createdAt; route only when the chair spoke last among real participants (newest user > newest agent, or no agent comment), so an agent reply — but NOT an automated system "draft ready" line — counts as handled. Also fix the same latent array-order assumption in the event-handler body fallback (reduce-by-createdAt instead of comments[length-1]). Self-heals the stuck marker on CMPA-116 (newest-user id differs from the wrongly-stamped one). Refs legal-ai #164. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>