Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kanoliban/caresupport-original/llms.txt
Use this file to discover all available pages before exploring further.
The complete message pipeline
Every message that comes into CareSupport flows through a 13-step pipeline that ensures safety, context-awareness, and proper state management.runtime/scripts/sms_handler.py - lines 914-1228Step-by-step breakdown
Message arrives via Linq API
webhook_receiver.py- Push notifications (preferred)poll_inbound.py- Cron-based polling (fallback)linq_gateway.py- Send/receive API client
Resolve phone → family → member → role
- Which family this person belongs to
- Their role (coordinator, caregiver, family member)
- Their access level (full, limited, schedule-only)
- Their relationship to the care recipient
sms_handler.py:122-168 (resolve_phone, resolve_chat_id)If the phone number is unknown, the message is rejected and logged to the PHI audit trail.Load family context
family.md- Core care context (schedules, team, status)schedule.md- Detailed schedule if split outmedications.md- Medication list if split out
- Last 50 messages with this phone number
- Monthly log files in
conversations/{phone}/
- Personal context from
members/{name}.md - Communication preferences
- Care responsibilities
sms_handler.py:185-231Filter context by access level (ENFORCEMENT)
| Access Level | Can See |
|---|---|
| full | Everything (coordinators only) |
| limited | Care recipient info, schedules, team contacts, medications |
| schedule | Schedules and basic contact info only |
## Medical History, ## Sensitive Notes, and ## Crisis Protocol are stripped before the AI processes them.Code reference: enforcement/role_filter.py - filter_family_context()Log PHI access (ENFORCEMENT)
- Timestamp
- Family ID
- Accessor phone & role
- Access level
- Which sections were loaded
- The trigger message (what prompted the access)
enforcement/phi_audit.py - PHIAuditLoggerBuild system prompt
SOUL.md- Agent identity, voice, and constraintsagent_root.md- Routing logic for loading protocolscapabilities.md- Explicit CAN/CANNOT list
skills/*.md- Conversation patterns (social, onboarding, scheduling)protocols/*.md- 16 care protocols loaded on demand
lessons.md(global) - Corrections from all conversationsfamilies/{id}/lessons.md(family-specific) - Local corrections
- Filtered family.md (scoped to member’s access)
- Recent conversation history
- Member profile
- Current date/time
sms_handler.py:289-397 (build_system_context)Call AI agent (Claude Haiku via OpenRouter)
sms_handler.py:487-535 (generate_response)Check response for leakage (ENFORCEMENT)
- Medical diagnoses
- Sensitive family dynamics
- Financial information
- Crisis protocol details
“I’m sorry, I can’t share that information with your access level. Please contact the care coordinator if you need more details.”The blocked response is logged to the PHI audit trail.Code reference:
enforcement/role_filter.py - check_outbound_message()Apply family_file_updates (PERSISTENCE)
append- Add to the end of a sectionprepend- Add to the beginning of a sectionreplace- Find and replace specific content
- Backup created before every edit
- Only existing sections can be modified
- Find-and-replace requires exact match
- High-risk updates (medications, member changes) require approval
enforcement/family_editor.py - apply_updates()Persist corrections to lessons.md
lessons.md file.Categories:[behavioral]- How to reason/respond[factual]- Care facts about this family[operational]- System behavior patterns
sms_handler.py:664-684 (_persist_lessons)Update member profiles
- Communication preferences
- Availability changes
- Personal context (“prefers calls after 6pm”)
- Interaction history
sms_handler.py:686-713 (_persist_member_updates)Register new members (if requested)
- Add them to
routing.json - Create their member profile in
members/{name}.md - Assign role and access level
sms_handler.py:716-812 (_persist_routing_updates)Log and send response
- Logged to conversation history (
conversations/{phone}/) - Logged to family timeline (
families/{id}/timeline/) - Logged to PHI audit trail
- Sent back via Linq API
Message flow diagram
Key design decisions
Why files instead of a database?
Why files instead of a database?
family.md and understand the current care situation. No SQL queries needed.Version control: Every change can be tracked with git. “What did the schedule look like last Tuesday?” is a git log away.No vendor lock-in: Your care data is markdown files. You can move them anywhere.Atomic edits: The surgical edit model (find-and-replace) prevents race conditions better than traditional DB updates.Why mechanical safety instead of prompt engineering?
Why mechanical safety instead of prompt engineering?
Why surgical edits instead of file rewrites?
Why surgical edits instead of file rewrites?
Why 16 care protocols?
Why 16 care protocols?
- “Can someone take auntie to her appointment?” → appointment-coordination protocol
- “She missed her morning meds” → medication-management protocol
- “Liban is unavailable this weekend” → caregiver-handoff protocol