fix(ceo): סריקת הערות-יו"ר תלויות company-wide עם שיוך-לתיק חובה (#164) #362

Merged
chaim merged 1 commits from worktree-ceo-pending-comment-scan into main 2026-06-30 12:19:43 +00:00
Owner

שורש-הבעיה (מוכח)

ה-sweep מעיר את ה-CEO דרך ctx.agents.invoke, שאינו מאכלס $PAPERCLIP_WAKE_REASON/payload.issueId. התעתיק הראה "generic heartbeat with no scoped wake" — הסתעפות ה-user_commented של ה-CEO לא נדלקה, הוא רץ heartbeat גנרי שסורק רק issues משויכים-ל-CEO, והערות-יו"ר על issues של חיים/סוכני-מִשנה (CMPA-116) היו בלתי-נראות → no-op. שתי בקשות-יו"ר אמיתיות (6 ימים) נשארו לא-מסופקות.

התיקון

על כל wake ללא reason מכוּון, ה-CEO מגלה הערות-יו"ר תלויות בעצמו. סעיף חדש "סריקת הערות-יו"ר תלויות (company-wide)":

  • מונה את כל issues החברה הפעילים (/api/companies/{id}/issues)
  • תלוי = הערת-user אחרונה חדשה מהערת-agent אחרונה (התעלם מ-system); order-independent sort_by(createdAt) כי ה-API newest-first
  • שיוך-לתיק חובה מ-project.name המובנה ("ערר <תיק> — …"), לעולם לא מהכותרת (ל-CMPA-116 אין) ולא מתוכן-ההערה (שעלול לנקוב בתיק אחר, "ניסיתי ב-CMPA-89"). אין תיק ודאי → לא לפעול, להסלים ליו"ר.
  • כל הערה מטופלת ב-scope של ה-$ISSUE_ID/$CASE_NUMBER שלה

אימות (מול נתונים חיים)

13 issues פעילים → בדיוק 2 תלויים (CMPA-116, CMPA-89), שניהם נפתרו לתיק 8125-09-24 דרך project.name, אפס false-positives. שלב 0 + שלב A חוברו להריץ את הסריקה על wakes עיוורים.

Invariants

  • G2 — מרחיב את "טיפול בתגובות" הקיים, ללא resolver מקביל · G12 — הוראות-סוכן, לא קוד-פלטפורמה

Refs TaskMaster #164. משלים את ה-sweep (מסירה) — זה גילוי+פעולה.

🤖 Generated with Claude Code

## שורש-הבעיה (מוכח) ה-sweep מעיר את ה-CEO דרך `ctx.agents.invoke`, ש**אינו** מאכלס `$PAPERCLIP_WAKE_REASON`/`payload.issueId`. התעתיק הראה *"generic heartbeat with no scoped wake"* — הסתעפות ה-`user_commented` של ה-CEO לא נדלקה, הוא רץ heartbeat גנרי שסורק **רק issues משויכים-ל-CEO**, והערות-יו"ר על issues של חיים/סוכני-מִשנה (CMPA-116) היו **בלתי-נראות** → no-op. שתי בקשות-יו"ר אמיתיות (6 ימים) נשארו לא-מסופקות. ## התיקון על כל wake ללא reason מכוּון, ה-CEO **מגלה** הערות-יו"ר תלויות בעצמו. סעיף חדש "סריקת הערות-יו"ר תלויות (company-wide)": - מונה את כל issues החברה הפעילים (`/api/companies/{id}/issues`) - תלוי = הערת-`user` אחרונה חדשה מהערת-`agent` אחרונה (התעלם מ-`system`); order-independent `sort_by(createdAt)` כי ה-API newest-first - **שיוך-לתיק חובה מ-`project.name` המובנה** (`"ערר <תיק> — …"`), **לעולם לא** מהכותרת (ל-CMPA-116 אין) ולא מתוכן-ההערה (שעלול לנקוב בתיק אחר, "ניסיתי ב-CMPA-89"). אין תיק ודאי → **לא לפעול**, להסלים ליו"ר. - כל הערה מטופלת ב-scope של ה-`$ISSUE_ID`/`$CASE_NUMBER` שלה ## אימות (מול נתונים חיים) 13 issues פעילים → **בדיוק 2 תלויים** (CMPA-116, CMPA-89), שניהם נפתרו לתיק 8125-09-24 דרך project.name, **אפס false-positives**. שלב 0 + שלב A חוברו להריץ את הסריקה על wakes עיוורים. ## Invariants - **G2** — מרחיב את "טיפול בתגובות" הקיים, ללא resolver מקביל · **G12** — הוראות-סוכן, לא קוד-פלטפורמה Refs TaskMaster #164. משלים את ה-sweep (מסירה) — זה גילוי+פעולה. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-30 12:19:36 +00:00
fix(ceo): company-wide pending-comment scan with mandatory case binding
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s
Lint — undefined names / undefined-names (pull_request) Successful in 10s
26451f7c9d
Root cause (proven 2026-06-30, legal-ai #164): the comment-sweep wakes the CEO
via ctx.agents.invoke, which does NOT populate $PAPERCLIP_WAKE_REASON or
payload.issueId. The run transcript showed "generic heartbeat with no scoped
wake" — the CEO's `user_commented` branch never fired, it ran a generic
heartbeat that scans only CEO-assigned issues, and chair comments on
chaim/sub-agent-owned issues (e.g. CMPA-116) were invisible → no-op. Two real
6-day-stale chair requests sat undelivered.

Fix: on any wake without a scoped reason, the CEO must DISCOVER pending chair
comments itself. Adds "סריקת הערות-יו"ר תלויות (company-wide)":
- enumerate all active company issues (/api/companies/{id}/issues)
- pending = newest user comment newer than newest agent comment (ignore
  system); order-independent sort_by(createdAt) since the API is newest-first
- MANDATORY case binding from the STRUCTURED project.name ("ערר <case> — …"),
  never from the title (CMPA-116 has none) nor the comment content (which may
  name a different case, e.g. "ניסיתי ב-CMPA-89"). No confident case → do NOT
  act; escalate to chair.
- handle each pending comment scoped to its own $ISSUE_ID/$CASE_NUMBER

Verified end-to-end against live data: 13 active issues → exactly 2 pending
(CMPA-116, CMPA-89), both resolved to case 8125-09-24 via project.name, zero
false positives. Step 0 + Step A wired to run the scan on blind wakes.

Refs #164. Pairs with the plugin sweep (delivery) — this is discovery+action.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 7655acddc3 into main 2026-06-30 12:19:43 +00:00
chaim deleted branch worktree-ceo-pending-comment-scan 2026-06-30 12:19:43 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#362