import type { Profile, ServiceName } from "../profiles/types.js"; import { type TreeActivity } from "../maintenance/progress-file.js"; /** كم فشلًا متتاليًا قبل أن نعدّ الخدمة ميّتة. */ export declare const FAILURES_BEFORE_REVIVAL = 2; /** نافذة الحارس وحدّها: أكثر من ثلاث إحياءات في عشر دقائق يعني عطلًا لا حادثة. */ export declare const REVIVAL_LIMIT = 3; export declare const REVIVAL_WINDOW_MS: number; export interface RevivalDecision { /** نُحيي الآن؟ */ revive: boolean; /** توقّفنا نهائيًا عن إحياء هذه الخدمة؟ يقع مرّة واحدة عند تجاوز الحدّ. */ looping: boolean; /** عدد الإحياءات داخل النافذة، بما فيها هذه. */ attempts: number; } /** * AR: حارس الدورة، **خالص بلا أثر جانبي وبلا ساعة خاصة به**. الزمن يُمرَّر إليه، فيُختبَر عبور * عشر دقائق في سطر بدل انتظارها فعلًا — واختبارٌ لا يُكتَب لأنه بطيء هو اختبارٌ لا يوجد. * EN: The loop guard, **pure, side-effect-free, and holding no clock of its own**. Time is passed * in, so crossing a ten-minute window is tested in a line instead of waited out — and a test * not written because it is slow is a test that does not exist. */ export declare class RevivalGuard { private readonly limit; private readonly windowMs; private readonly revivals; private readonly stopped; constructor(limit?: number, windowMs?: number); /** هل توقّفنا عن إحياء هذه الخدمة؟ */ isStopped(service: string): boolean; /** * يسجّل محاولة إحياء ويقرّر مصيرها. **يُستدعى مرّة لكل محاولة** — استدعاؤه للاستعلام وحده * يفسد العدّ. */ record(service: string, now: number): RevivalDecision; /** يمسح تاريخ خدمة عادت واستقرّت — أو أعاد المالك تشغيلها بيده. */ clear(service: string): void; } export interface MonitorEvent { service: ServiceName; kind: "revived" | "revival-failed" | "loop-stopped" | "recovered"; detail: string; } export interface MonitorOptions { onEvent?: (event: MonitorEvent) => void; guard?: RevivalGuard; /** للاختبار: ما الذي يجري على الشجرة الآن. الافتراضيّ يقرأ ملفّي التقدّم. */ activity?: () => TreeActivity | undefined; } /** * AR: جولة مراقبة واحدة على كل الخدمات. جولةٌ لا حلقة: من ينادينا يملك الإيقاع، فيُختبَر السلوك * بجولات متتابعة بلا مؤقّتات ولا انتظار. * EN: One monitoring round over every service. A round rather than a loop: the caller owns the * cadence, so the behaviour is tested by calling rounds in sequence with no timers and no waits. */ export declare class ServiceMonitor { private readonly profile; private readonly options; private readonly failures; private readonly guard; constructor(profile: Profile, options?: MonitorOptions); /** * AR: **لا إحياء والشجرة في يد تحديثٍ أو صيانة** (2026-10-12). * * التحديث والاستعادة والتصفير يوقفون الخدمات عمدًا ثم يستبدلون ‎core/‎ أو ‎data/‎ — والخدمة * الصامتة هنا ليست معطّلة بل موقوفةٌ بيد من يملك الشجرة الآن. والمراقب كان يراها «لا تجيب» * فيعيدها بعد جولتين: في منتصف الاستعادة (رُصد في نسخةٍ معزولة: النواة أُقلعت 06:08:11 داخل * استعادةٍ امتدّت 06:07:54–06:08:45) وفي منتصف تحديثٍ من اللوحة، حيث أمسكت النواةُ المُعادة * ملفّاتٍ فلم يكتمل الاستبدال ولا التراجع. **وإيقاف الإشراف المؤقّت (‎pauseBootSupervision‎) * للينكس وحده** — فعلى ويندوز لم يكن شيءٌ يمنعه. * * والعدّاد يُصفَّر كي تحتاج الخدمة بعد انتهاء العملية جولتين جديدتين قبل إحيائها: من يملك * الشجرة يشغّل الخدمات بنفسه في آخر عمله، وإحياءٌ يسبقه بثانيةٍ يسابقه. وتحديثٌ يجري داخل * المُشرِف نفسه (نافذة الليل) لا يتقاطع مع هذا: الجولتان في الحلقة نفسها، واحدةً بعد الأخرى. * EN: **No revival while an update or maintenance owns the tree** (2026-10-12). * * Update, restore and reset stop the services on purpose and then swap `core/` or `data/` — a * silent service here is not broken but stopped by whoever owns the tree right now. The monitor * read it as "not answering" and revived it after two rounds: mid-restore (seen on an isolated copy: * the core booted at 06:08:11 inside a restore spanning 06:07:54–06:08:45) and mid-update from the * dashboard, where the revived core held files so neither the swap nor the rollback completed. * **And the supervision pause (`pauseBootSupervision`) is Linux-only** — on Windows nothing stopped * it. * * The counters are reset so a service needs two fresh rounds once the operation ends before it is * revived: the owner of the tree starts the services itself at the end of its work, and a revival a * second earlier races it. An update running inside the supervisor itself (the night window) does * not cross this: both rounds run in the same loop, one after the other. */ round(now?: number): Promise; private check; private emit; } //# sourceMappingURL=monitor.d.ts.map