fix(sweep): route-pending-comments לוקח חברות מ-CEO_AGENT_IDS ולא מ-companies.list (legal-ai#1280)
All checks were successful
INV-INT9 issue.status write-ownership / int9-guard (pull_request) Successful in 5s

ctx.companies.list() דורש scope של instance והמארח דוחה אותו באקראי בג'וב מתוזמן
(invalidInvocationScope, ~21% מהריצות מאז 10.11). הלולאה ממילא מדלגת על חברה בלי CEO
ממופה, ולכן הרשימה זהה. אותו דפוס כמו knownCompanyIds ב-resolveApiBase.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVyJoEa3s1vA9XeNE6WyDu
This commit is contained in:
2026-11-12 12:53:43 +02:00
parent f0925982c9
commit c934a6be44

View File

@@ -1243,27 +1243,17 @@ const plugin = definePlugin({
// double-routed. Runs every 2 minutes (manifest schedule).
ctx.jobs.register("route-pending-comments", async (_job) => {
await runJobHandler("route-pending-comments", ctx.logger, async () => {
// כשל-מהיר: דחיית-scope (legal-ai issue #637) אינה "שגיאה
// פר-issue" שאפשר להתעלם ממנה — היא אומרת שה-run **כולו** לא
// יכול לעבוד. לזרוק מיד במקום לבלוע ולהמשיך ללולאה על 2
// חברות × 200 issues שכולן ייכשלו זהה. שגיאה אחרת (ולא scope)
// נשארת warn+continue — זו העמידות האמיתית פר-issue.
let companies: Awaited<ReturnType<typeof ctx.companies.list>>;
try {
companies = await ctx.companies.list();
} catch (err) {
if (isCompanyScopeDenied(err)) {
throw new CompanyScopeUnavailableError(
"route-pending-comments",
"companies.list",
{ cause: err },
);
}
ctx.logger.warn("route-pending-comments: companies.list failed", {
error: String(err),
});
return;
}
// רשימת החברות נלקחת ממפת ה-CEO ולא מ-`ctx.companies.list()` (legal-ai
// #1280): הקריאה הזו דורשת scope של instance, וה-host דוחה אותה
// באקראי בג'וב מתוזמן (invalidInvocationScope, ~21% מהריצות מ-10.11).
// הלולאה ממילא מדלגת על חברה בלי CEO ממופה, ולכן הרשימה זהה
// (אותו דפוס כמו `knownCompanyIds` ב-`resolveApiBase`).
//
// כשל-מהיר נשאר ב-`issues.list`: דחיית-scope (legal-ai issue #637)
// אינה "שגיאה פר-issue" שאפשר להתעלם ממנה — היא אומרת שה-run
// **כולו** לא יכול לעבוד. שגיאה אחרת (ולא scope) נשארת
// warn+continue — זו העמידות האמיתית פר-issue.
const companies = Object.keys(CEO_AGENT_IDS).map((id) => ({ id }));
for (const company of companies) {
const ceoAgentId = CEO_AGENT_IDS[company.id];