T7.2 — חוזה Approval וסמכות לפי מצב עבודה
v1.0 Implementation Report · 11 באוגוסט 2026 · BAROUCH SHALIT
מטרה: איחוד בדיקות הסמכות כך שכל נתיבי manual, semi_auto ו-full_auto מתכנסים לאכיפה משותפת. פתרון 3 פערי P1 מ-T7.1.
3/3 פערי P1 מ-T7.1 נפתרו ✅
GAP-001 (סף 9.5 configurable) + GAP-004 (actor_type/logical_role/session_id) + GAP-005 (re-auth חלופי) — כולם מומשו. חוזה ה-Approval המאוחד מופעל בכל שלושת מצבי העבודה.
סף 9.5 מוקשה בקוד → הפך ל-configurable
נפתר ✅לפני: decisionObject.ts line 128: confidence >= 9.5 hardcoded constant
אחרי: SystemSettings.semi_auto_high_confidence_threshold (default 9.5) + decisionObject.ts uses data.semi_auto_high_confidence_threshold ?? 9.5
חסרים actor_type / logical_role / session_id → נוספו
נפתר ✅לפני: AuditEvent.actor (string) בלבד; קוד משתמש ב-user.email
אחרי: AuditEvent: actor_type (enum: user/agent/system/scheduler) + logical_role (string) נוספו. session_id כבר היה קיים. auditEventLogger.ts מאכלס את השדות החדשות.
אין מנגנון Re-auth → נוצר חלופי
נפתר ✅ (חלופה — לאישור Security Admin)לפני: §7.7/§7.12 דורש re-auth ל-3 פעולות קריטיות; Base44 auth לא תומך ב-step-up auth
אחרי: reauthGuard.ts: חלופת confirmation + reason + audit. requireReauth() בודק שיש reason + confirmed, ולוג ל-AuditEvent עם actor_type + logical_role.
כלל מאוחד מחליף את הסתירה בין §7.7 ו-§7.12. מומש ב-reauthGuard.ts.
| פעולה | דרישה | סיבה | מימוש בקוד |
|---|---|---|---|
| מעבר ל-full_auto | אימות מחדש (re-auth) | סיכון קריטי — ביצוע אוטומטי ללא אישור פרטני | reauthGuard.ts: TRANSITION_TO_FULL_AUTO |
| ביטול Global Freeze | אימות מחדש (re-auth) | סיכון קריטי — שחרור עמדות לקנייה | reauthGuard.ts: CANCEL_GLOBAL_FREEZE |
| שינוי הרשאות מהותי (Break-Glass, PermissionMatrix) | אימות מחדש (re-auth) | סיכון אבטחה — שינוי מפת סמכויות | reauthGuard.ts: PERMISSION_CHANGE |
| הפעלת Global Freeze | מיידי, ללא אימות | פעולת הגנה P0 אינה ממתינה | tradeExecution.ts checkFreeze (immediate) |
| מעבר manual ↔ semi_auto | Audit בלבד | שינוי תפעולי שגרתי, שערי הגנה זהים | Settings page (mode change + AuditEvent) |
| מעבר מ-full_auto למצב אחר | Audit בלבד | הקטנת סיכון — אינה מעלה סיכון | Settings page (mode change + AuditEvent) |
אישור נדרש: תמיד — כל עסקה דורשת אישור מפורש
ביצוע אוטומטי: אף פעולה
שערים: Freeze → Explain → Decision Active → Risk Gate → Approval → Validity → market_open
מיקום בקוד: executeTrade entry.ts: manual approve path
אישור נדרש: confidence < 9.5 (configurable) → דרוש אישור; ≥ 9.5 → auto-approve
ביצוע אוטומטי: SELL/Reduction/Exit (P0 protection) + confidence ≥ 9.5 (auto-approve)
שערים: Freeze → Explain → Decision Active → Risk Gate → Approval (if < 9.5) → Validity → market_open
מיקום בקוד: decisionObject.ts: determineApprovalRequired + refreshPortfolioPrices EXECUTION
אישור נדרש: confidence < 8.5 → דרוש אישור; ≥ 8.5 → auto-execute
ביצוע אוטומטי: BUY/SELL עם confidence ≥ 8.5 (בכפוף לכל השערים)
שערים: Freeze → Explain → Decision Active → Risk Gate → Approval (if < 8.5) → Validity → market_open
מיקום בקוד: decisionObject.ts: determineApprovalRequired + refreshPortfolioPrices EXECUTION
כל השערים מאוחדים — אין מצב שבו מצב עבודה כלשהו מדלג על שער. אפס עקיפות (למעט legacy:true ל-Decision Gate בלבד).
| שער | אכיפה | מיקום בקוד | מאוחד |
|---|---|---|---|
| Global Freeze | checkFreeze() — blocks BUY only; SELL/Reduction/Exit pass | tradeExecution.ts line 82 | |
| Explain Before Execute | assertExplainBeforeExecute() — reasoning + authority ref mandatory | tradeExecution.ts line 89 | |
| Emergency Liquidation | isEmergencyLiquidation + verifyEmergencyAuthorized — BreakGlassEvent required | tradeExecution.ts line 92-98 | |
| Decision Active | assertDecisionActive() — ACTIVE + not expired + snapshot frozen | tradeExecution.ts line 102 + executeTrade entry.ts line 326 | |
| Risk Gate | checkRiskGatePassed() — RiskVerdict=PASS required | tradeExecution.ts line 106 + refreshPortfolioPrices line 474 | |
| Approval Gate | checkApprovalValid() when approval_required=true | tradeExecution.ts line 110 + refreshPortfolioPrices line 481 | |
| Proposal TTL | proposal_expires_at checked at executeTrade entry | executeTrade entry.ts line 114 | |
| Approval TTL | approval_expires_at checked in refreshPortfolioPrices | refreshPortfolioPrices line 440 | |
| Price Drift Validity | driftPct > threshold (auto=3%, semi=5%) → expired | executeTrade entry.ts line 212 + refreshPortfolioPrices line 191 | |
| market_open | isMarketOpen() — BUY parked if closed; sells skip if closed | executeTrade entry.ts line 154 + refreshPortfolioPrices line 438 | |
| Order Fill Guard | shouldFillBuy() — limit/stop conditions | executeTrade entry.ts line 265 + refreshPortfolioPrices line 458 |
המלצת מעבר ל-T7.3
T7.2 השלים את חוזה ה-Approval המאוחד ופתר את כל 3 פערי ה-P1 מ-T7.1. ניתן לעבור ל-T7.3 (Override, Freeze ופעולות חירום) — מיפוי ואימות מטריצת Override/Freeze/Emergency.