Compare commits
2 Commits
fix/673
...
burn/69-17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84569659b0 | ||
|
|
2697b8ef75 |
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
|
||||
@@ -1045,12 +1045,18 @@ Sovereignty and service always.`;
|
||||
overlayTimer = null;
|
||||
overlayDismissBtn.disabled = false;
|
||||
overlayDismissBtn.textContent = 'Continue to chat';
|
||||
overlayDismissBtn.focus();
|
||||
} else {
|
||||
overlayDismissBtn.textContent = 'Continue to chat (' + countdown + 's)';
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
overlayDismissBtn.focus();
|
||||
// Focus the Call 988 link — the dismiss button is disabled during countdown
|
||||
// and disabled elements cannot receive focus. #69
|
||||
var overlayCallBtn = crisisOverlay.querySelector('.overlay-call');
|
||||
if (overlayCallBtn) {
|
||||
overlayCallBtn.focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Register focus trap on document (always listening, gated by class check)
|
||||
|
||||
83
tests/test_safety_plan_save_feedback.py
Normal file
83
tests/test_safety_plan_save_feedback.py
Normal file
@@ -0,0 +1,83 @@
|
||||
import pathlib
|
||||
import re
|
||||
import unittest
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
INDEX_HTML = ROOT / 'index.html'
|
||||
|
||||
|
||||
class TestSafetyPlanSaveFeedback(unittest.TestCase):
|
||||
"""Verify safety plan save feedback uses inline UI instead of blocking alerts."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.html = INDEX_HTML.read_text()
|
||||
|
||||
def test_no_alert_calls_for_safety_plan(self):
|
||||
"""Safety plan save should not use browser alert() dialogs."""
|
||||
# Find the save handler
|
||||
save_handler_match = re.search(
|
||||
r'saveSafetyPlan\.addEventListener.*?\}\);',
|
||||
self.html,
|
||||
re.DOTALL
|
||||
)
|
||||
self.assertIsNotNone(save_handler_match, 'Expected saveSafetyPlan handler to exist.')
|
||||
handler = save_handler_match.group(0)
|
||||
self.assertNotIn('alert(', handler, 'Safety plan save handler should not contain alert() calls.')
|
||||
|
||||
def test_inline_status_element_exists(self):
|
||||
"""Safety plan modal should have an inline status element."""
|
||||
self.assertIn('id="sp-status"', self.html, 'Expected sp-status element in the modal.')
|
||||
self.assertIn('aria-live="polite"', self.html, 'Expected sp-status to have aria-live="polite".')
|
||||
|
||||
def test_inline_status_shows_on_save(self):
|
||||
"""Save handler should show the status element on success."""
|
||||
save_handler_match = re.search(
|
||||
r'saveSafetyPlan\.addEventListener.*?\}\);',
|
||||
self.html,
|
||||
re.DOTALL
|
||||
)
|
||||
handler = save_handler_match.group(0)
|
||||
self.assertIn("statusEl.textContent = 'Safety plan saved locally.'", handler,
|
||||
'Expected success message in status element.')
|
||||
self.assertIn("statusEl.className = 'success'", handler,
|
||||
'Expected success class on status element.')
|
||||
self.assertIn("statusEl.style.display = 'block'", handler,
|
||||
'Expected status element to be displayed.')
|
||||
|
||||
def test_inline_status_shows_on_error(self):
|
||||
"""Save handler should show the status element on error."""
|
||||
save_handler_match = re.search(
|
||||
r'saveSafetyPlan\.addEventListener.*?\}\);',
|
||||
self.html,
|
||||
re.DOTALL
|
||||
)
|
||||
handler = save_handler_match.group(0)
|
||||
self.assertIn("statusEl.className = 'error'", handler,
|
||||
'Expected error class on status element.')
|
||||
# Error message should mention local storage blocking
|
||||
self.assertIn('blocking local storage', handler,
|
||||
'Expected error message about local storage blocking.')
|
||||
|
||||
def test_status_auto_hides_after_success(self):
|
||||
"""Success status should auto-hide after a timeout."""
|
||||
save_handler_match = re.search(
|
||||
r'saveSafetyPlan\.addEventListener.*?\}\);',
|
||||
self.html,
|
||||
re.DOTALL
|
||||
)
|
||||
handler = save_handler_match.group(0)
|
||||
self.assertIn('setTimeout', handler, 'Expected setTimeout for auto-hiding status.')
|
||||
self.assertIn("statusEl.style.display = 'none'", handler,
|
||||
'Expected status to be hidden after timeout.')
|
||||
|
||||
def test_status_css_exists(self):
|
||||
"""CSS for sp-status success and error states should exist."""
|
||||
self.assertIn('#sp-status.success', self.html,
|
||||
'Expected CSS for sp-status.success class.')
|
||||
self.assertIn('#sp-status.error', self.html,
|
||||
'Expected CSS for sp-status.error class.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user