Files
plugin-legal-ai/src/comment-routing.ts
Chaim Marcus cfbeb582fa
All checks were successful
INV-INT9 issue.status write-ownership / int9-guard (pull_request) Successful in 4s
fix(routing): מסלול-יקיצה יחיד להערת-יו"ר — דילוג על invoke כשהנייטיבי מכסה (#16)
Paperclip מעיר בעצמו את הסוכן המשויך על כל הערת-משתמש ב-issue פתוח
(routes/issues.js: reason "issue_commented", mutation "comment"). הפלאגין דילג
על הניתוב רק כש-`reopened === true`, ולכן כל הוראת-יו"ר על issue פתוח
משויך-CEO הפעילה שתי ריצות-CEO במקביל (legal-ai #772; 2026-11-01 על CMPA-232:
3 ריצות כפולות, ~9$, רשומות chair_feedback כפולות).

הכלל עכשיו הוא מראה של `needs_ceo_run()` ב-legal-ai (comment-routing.ts):
issue פתוח + assignee-סוכן → הנייטיבי מכסה → אין invoke, יש marker.
סגור / משויך-אדם / לא-משויך → הנייטיבי מת → ניתוב כמו היום (#164/#454).

Closes #16

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-01 17:53:55 +02:00

44 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* מסלול-יקיצה יחיד להערת-יו"ר (plugin-legal-ai #16, legal-ai #772).
*
* Paperclip מעיר **בעצמו** את הסוכן המשויך ל-issue על כל הערת-משתמש
* (`@paperclipai/server` routes/issues.js — `addWakeup(assigneeId, {reason:
* "issue_commented", payload.mutation: "comment"})`), ובלבד ש-(א) יש assignee-סוכן,
* (ב) ה-issue אינו סגור (`done`/`cancelled`), (ג) ההערה אינה של אותו סוכן עצמו.
* ‏`ctx.agents.invoke` של הפלאגין על אותה הערה = ריצת-CEO שנייה במקביל: עבודה
* כפולה, שתי רשומות `chair_feedback`, שני issues לכותב (legal-ai #772; שוב
* 2026-11-01 על CMPA-232 — 3 ריצות כפולות, ~9$).
*
* ⚠️ מקור-האמת לכלל הוא **`needs_ceo_run()` ב-legal-ai `web/paperclip_client.py`**
* (נמדד על 120 יום ב-DB החי: agent-owned + open → 70/70 הערות קיבלו wakeup נייטיבי;
* human-owned/unassigned → ה-wakeup מכוון לאדם ומבוטל; closed → אין wakeup כלל).
* הפונקציה כאן היא **מראה** של אותו כלל בצד הפלאגין — אין דרך לקרוא ל-legal-ai
* מתוך event-handler בלי להוסיף תלות-רשת לנתיב-המסירה. **כל שינוי שם מחייב
* שינוי כאן**, ולהיפך (G2 — מסלול-החלטה אחד, שני מימושים שחייבים להישאר זהים).
*/
/** סטטוסים סופיים — Paperclip מדלג על ה-wakeup הנייטיבי בהם (`isClosed`). */
export const CLOSED_ISSUE_STATUSES: ReadonlySet<string> = new Set([
"done",
"cancelled",
]);
export interface RoutableIssue {
status: string;
assigneeAgentId?: string | null;
}
/**
* האם המסירה הנייטיבית של Paperclip כבר מעירה סוכן על הערה ב-issue הזה?
*
* `true` → **אין** להפעיל `ctx.agents.invoke` (זה יהיה המסלול הכפול).
* `false` → המסלול הנייטיבי מת (issue סגור, או משויך לאדם / לא משויך) — זו
* בדיוק הסיבה שמסלול-הפלאגין קיים (#164/#454), ויש לנתב ל-CEO.
*
* זהה ל-`not needs_ceo_run(issue)` ב-legal-ai.
*/
export function nativeWakeCoversComment(issue: RoutableIssue): boolean {
if (CLOSED_ISSUE_STATUSES.has(issue.status)) return false;
return Boolean(issue.assigneeAgentId);
}