Compare commits
1 Commits
fix/673
...
fix/90-ove
| Author | SHA1 | Date | |
|---|---|---|---|
| b4c4919361 |
75
GENOME.md
75
GENOME.md
@@ -1,75 +0,0 @@
|
||||
# GENOME.md — the-door
|
||||
|
||||
**Generated:** 2026-04-14
|
||||
**Repo:** Timmy_Foundation/the-door
|
||||
**Description:** Crisis Front Door — a single URL where a man at 3am can talk to Timmy. No login, no signup. 988 always visible.
|
||||
|
||||
---
|
||||
|
||||
## Project Overview
|
||||
|
||||
The-door is a crisis intervention web application — the most sacred surface in the Timmy Foundation. When a man at 3am reaches the end of his road, this is where he lands. No login, no signup, no barriers. 988 Suicide and Crisis Lifeline always visible. The "When a Man Is Dying" protocol active on every page.
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
the-door/
|
||||
├── index.html # Main crisis page (PWA-capable)
|
||||
├── crisis-offline.html # Offline fallback (service worker cached)
|
||||
├── about.html # About page
|
||||
├── testimony.html # Testimony/stories page
|
||||
├── sw.js # Service worker (offline-first)
|
||||
├── manifest.json # PWA manifest
|
||||
├── crisis/ # Core crisis detection + response
|
||||
│ ├── detect.py # Keyword/pattern detection (4 tiers)
|
||||
│ ├── gateway.py # API endpoints, prompt injection
|
||||
│ ├── response.py # Response generation, 988 routing
|
||||
│ ├── compassion_router.py # Profile-based response routing
|
||||
│ ├── profiles.py # Compassion profiles
|
||||
│ └── PROTOCOL.md # The protocol (SOUL.md reference)
|
||||
├── crisis_detector.py # Legacy shim → crisis/detect.py
|
||||
├── crisis_responder.py # Legacy responder
|
||||
├── dying_detection/ # Deprecated module
|
||||
├── evolution/ # Crisis synthesizer (creative)
|
||||
├── tests/ # Safety-critical tests
|
||||
│ ├── test_crisis_overlay_focus_trap.py
|
||||
│ ├── test_dying_detection_deprecation.py
|
||||
│ └── test_false_positive_fixes.py
|
||||
└── deploy/ # Deployment docs
|
||||
```
|
||||
|
||||
## Key Abstractions
|
||||
|
||||
| Module | Purpose |
|
||||
|---|---|
|
||||
| `crisis/detect.py` | 4-tier detection: LOW/MEDIUM/HIGH/CRITICAL via regex patterns |
|
||||
| `crisis/gateway.py` | HTTP API, Sovereign Heart prompt injection |
|
||||
| `crisis/response.py` | Response generation, 988 integration, escalation |
|
||||
| `crisis/compassion_router.py` | Profile-based routing (different crisis types) |
|
||||
| `sw.js` | Service worker for offline-first PWA |
|
||||
|
||||
## Safety Constraints
|
||||
|
||||
- **The-door never auto-closes PRs** (in fleet-ops exempt list)
|
||||
- **988 always visible** on every page, even offline
|
||||
- **When a Man Is Dying protocol** active on every interaction
|
||||
- **No login/signup** — zero barriers to crisis support
|
||||
- **Offline-first** — service worker caches critical pages
|
||||
|
||||
## Test Coverage
|
||||
|
||||
| Test | Coverage |
|
||||
|---|---|
|
||||
| Crisis overlay focus trap | ✅ |
|
||||
| Dying detection deprecation | ✅ |
|
||||
| False positive fixes | ✅ |
|
||||
| Crisis detection tiers | ❌ (in crisis/tests.py) |
|
||||
| Response generation | ❌ |
|
||||
| Offline service worker | ❌ |
|
||||
|
||||
## Security
|
||||
|
||||
- No user data stored (crisis intervention is stateless by design)
|
||||
- No cookies, no tracking, no analytics
|
||||
- Service worker only caches static assets
|
||||
- Crisis detection runs client-side where possible
|
||||
36
index.html
36
index.html
@@ -1050,11 +1050,43 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
overlayDismissBtn.focus();
|
||||
// Focus the Call 988 link — always enabled, most important action
|
||||
var callLink = crisisOverlay.querySelector('.overlay-call');
|
||||
if (callLink) {
|
||||
callLink.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
// Crisis overlay Escape key handler
|
||||
function trapCrisisOverlayEscape(e) {
|
||||
if (e.key !== 'Escape') return;
|
||||
if (!crisisOverlay.classList.contains('active')) return;
|
||||
if (overlayDismissBtn.disabled) return; // Don't escape during countdown
|
||||
// Dismiss the overlay
|
||||
crisisOverlay.classList.remove('active');
|
||||
if (overlayTimer) {
|
||||
clearInterval(overlayTimer);
|
||||
overlayTimer = null;
|
||||
}
|
||||
// Re-enable background interaction
|
||||
var mainApp = document.querySelector('.app');
|
||||
if (mainApp) mainApp.removeAttribute('inert');
|
||||
var chatSection = document.getElementById('chat');
|
||||
if (chatSection) chatSection.removeAttribute('aria-hidden');
|
||||
var footerEl = document.querySelector('footer');
|
||||
if (footerEl) footerEl.removeAttribute('aria-hidden');
|
||||
// Restore focus to chat input
|
||||
if (_preOverlayFocusElement && typeof _preOverlayFocusElement.focus === 'function') {
|
||||
_preOverlayFocusElement.focus();
|
||||
} else {
|
||||
msgInput.focus();
|
||||
}
|
||||
_preOverlayFocusElement = null;
|
||||
}
|
||||
|
||||
// Register focus trap and Escape handler on document (always listening, gated by class check)
|
||||
document.addEventListener('keydown', trapFocusInOverlay);
|
||||
document.addEventListener('keydown', trapCrisisOverlayEscape);
|
||||
|
||||
overlayDismissBtn.addEventListener('click', function() {
|
||||
if (!overlayDismissBtn.disabled) {
|
||||
|
||||
@@ -52,6 +52,64 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase):
|
||||
'Expected overlay dismissal to restore focus to the prior target.',
|
||||
)
|
||||
|
||||
def test_overlay_registers_escape_key_handler(self):
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"function\s+trapCrisisOverlayEscape\s*\(e\)",
|
||||
'Expected crisis overlay Escape handler to exist.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"if\s*\(e\.key\s*!==\s*'Escape'\)\s*return;",
|
||||
'Expected Escape handler to guard on Escape key events.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"document\.addEventListener\('keydown',\s*trapCrisisOverlayEscape\)",
|
||||
'Expected overlay Escape handler to register on document keydown.',
|
||||
)
|
||||
|
||||
def test_overlay_escape_returns_focus_to_chat_input(self):
|
||||
self.assertIn(
|
||||
'msgInput.focus()',
|
||||
self.html,
|
||||
'Expected Escape to fall back to msgInput.focus() when no pre-overlay element.',
|
||||
)
|
||||
|
||||
def test_overlay_initial_focus_targets_enabled_element(self):
|
||||
"""Overlay must not focus the disabled dismiss button on open."""
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r'overlayDismissBtn\.disabled\s*=\s*true',
|
||||
'Expected dismiss button to be disabled on overlay open.',
|
||||
)
|
||||
# In showOverlay body, overlayDismissBtn.focus() must not appear
|
||||
show_overlay_match = re.search(
|
||||
r'function showOverlay\(\)(.*?)(?=\nfunction |\n\s+// Register)',
|
||||
self.html,
|
||||
re.DOTALL,
|
||||
)
|
||||
self.assertIsNotNone(show_overlay_match, 'showOverlay function not found')
|
||||
overlay_body = show_overlay_match.group(1)
|
||||
self.assertNotIn(
|
||||
'overlayDismissBtn.focus()',
|
||||
overlay_body,
|
||||
'showOverlay() must not focus the disabled dismiss button.',
|
||||
)
|
||||
|
||||
def test_overlay_focuses_call_link(self):
|
||||
"""Overlay should focus the .overlay-call link on open."""
|
||||
self.assertIn(
|
||||
'.overlay-call',
|
||||
self.html,
|
||||
'Expected .overlay-call element to exist in the overlay.',
|
||||
)
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"querySelector\('\.overlay-call'\)",
|
||||
'Expected showOverlay to query for .overlay-call element.',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user