Compare commits
1 Commits
door/issue
...
fix/673
| Author | SHA1 | Date | |
|---|---|---|---|
| 36ce6faec7 |
75
GENOME.md
Normal file
75
GENOME.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# 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
|
||||
23
index.html
23
index.html
@@ -993,16 +993,6 @@ Sovereignty and service always.`;
|
||||
|
||||
function trapFocusInOverlay(e) {
|
||||
if (!crisisOverlay.classList.contains('active')) return;
|
||||
|
||||
// Escape: dismiss overlay (only when dismiss button is enabled after countdown)
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
if (!overlayDismissBtn.disabled) {
|
||||
overlayDismissBtn.click();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key !== 'Tab') return;
|
||||
|
||||
var focusable = getOverlayFocusableElements();
|
||||
@@ -1011,13 +1001,6 @@ Sovereignty and service always.`;
|
||||
var first = focusable[0];
|
||||
var last = focusable[focusable.length - 1];
|
||||
|
||||
// If focus escaped outside the overlay, bring it back
|
||||
if (!crisisOverlay.contains(document.activeElement)) {
|
||||
e.preventDefault();
|
||||
first.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) {
|
||||
// Shift+Tab: if on first, wrap to last
|
||||
if (document.activeElement === first) {
|
||||
@@ -1067,11 +1050,7 @@ Sovereignty and service always.`;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Focus the Call 988 link (always enabled) — not the disabled dismiss button
|
||||
var callLink = crisisOverlay.querySelector('a.overlay-call');
|
||||
if (callLink) {
|
||||
callLink.focus();
|
||||
}
|
||||
overlayDismissBtn.focus();
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
|
||||
@@ -52,38 +52,6 @@ class TestCrisisOverlayFocusTrap(unittest.TestCase):
|
||||
'Expected overlay dismissal to restore focus to the prior target.',
|
||||
)
|
||||
|
||||
def test_overlay_initial_focus_targets_enabled_element(self):
|
||||
"""Issue #69: overlay must not focus the disabled dismiss button on open."""
|
||||
# The showOverlay function should NOT call overlayDismissBtn.focus()
|
||||
# while the button is disabled. Instead it should focus an enabled element.
|
||||
self.assertNotRegex(
|
||||
self.html,
|
||||
r"overlayDismissBtn\.disabled\s*=\s*true;.*overlayDismissBtn\.focus\(\)",
|
||||
'showOverlay must not focus the dismiss button while it is disabled (issue #69).',
|
||||
)
|
||||
# Verify focus goes to the Call 988 link (always enabled)
|
||||
self.assertIn(
|
||||
"querySelector('a.overlay-call')",
|
||||
self.html,
|
||||
'Expected showOverlay to focus the Call 988 link on open.',
|
||||
)
|
||||
|
||||
def test_overlay_escape_key_dismisses(self):
|
||||
"""Issue #69/95: Escape key should dismiss the overlay when countdown completes."""
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"e\.key\s*===\s*['\"]Escape['\"]",
|
||||
'Expected Escape key handler in overlay focus trap.',
|
||||
)
|
||||
|
||||
def test_overlay_focus_recovery_when_focus_escapes(self):
|
||||
"""Focus trap should recover focus if it escapes the overlay."""
|
||||
self.assertRegex(
|
||||
self.html,
|
||||
r"crisisOverlay\.contains\(document\.activeElement\)",
|
||||
'Focus trap should check if focus is still within the overlay.',
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user