()
| 638 | // ─── Status reporting (for shield icon via /health) ────────── |
| 639 | |
| 640 | export function getStatus(): StatusDetail { |
| 641 | const state = readSessionState(); |
| 642 | const layers = state?.classifierStatus ?? { |
| 643 | testsavant: 'off', |
| 644 | transcript: 'off', |
| 645 | }; |
| 646 | const canary = state?.canary ? 'ok' : 'off'; |
| 647 | |
| 648 | let status: SecurityStatus; |
| 649 | if (layers.testsavant === 'ok' && layers.transcript === 'ok' && canary === 'ok') { |
| 650 | status = 'protected'; |
| 651 | } else if (layers.testsavant === 'off' && canary === 'off') { |
| 652 | status = 'inactive'; |
| 653 | } else { |
| 654 | status = 'degraded'; |
| 655 | } |
| 656 | |
| 657 | return { |
| 658 | status, |
| 659 | layers: { ...layers, canary: canary as 'ok' | 'off' }, |
| 660 | lastUpdated: state?.lastUpdated ?? new Date().toISOString(), |
| 661 | }; |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Extract url domain for logging. Never logs path or query string. |
no test coverage detected