CORTEGE is a companion-model AI security product where each household member is paired with a dedicated AI agent that silently protects them from scams, fraud, and security threats. Protection deepens over time through behavioral learning.
- Node.js 18+ and npm
- Anthropic API key (get one here)
-
Clone the repository
git clone https://github.com/taylorparsons/cortege-hackathon.git cd cortege-hackathon -
Start the application
./run-local.sh
The script will:
- Check Node.js/npm installation
- Install dependencies automatically (if needed)
- Create
.envfrom.env.example(if needed) - Prompt you to add your
ANTHROPIC_API_KEY - Open two terminal windows:
- Backend server (port 3001)
- Frontend dev server (port 5173)
-
Stop the application
./stop-local.sh
- Frontend UI: http://localhost:5173
- Backend API: http://localhost:3001
- API Documentation: http://localhost:3001/api/docs
- WebSocket: ws://localhost:3001
- API Documentation - Complete REST and WebSocket API reference
- Production Deployment - Twilio integration and production setup
- PRD - Product requirements and roadmap
- Traceability - How to follow the audit trail
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β http://localhost:5173 β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β REST + WebSocket
ββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
β Express.js Backend Server β
β http://localhost:3001 β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Orchestrator β β
β β ββββββββββββββ ββββββββββββββββ βββββββββββββββ β β
β β β Event Bus β β Agent Pool β β Scheduler β β β
β β ββββββββββββββ ββββββββββββββββ βββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Agent Instances (per household member) β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β β β ANCHOR β β SENTINEL β β SCOUT β β β
β β β (elderly)β β (adult) β β (teen) β β β
β β ββββββββββββ ββββββββββββ ββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β Claude API
ββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
β Anthropic Claude β
β (Haiku 4.5 for assessments) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Agents evolve through four maturity stages:
- Baseline (0.00-0.10) - Learning normal patterns
- Pattern Recognition (0.10-0.30) - Identifying recurring behaviors
- Predictive (0.30-0.60) - Anticipating threats
- Cortege Mode (0.60-1.00) - Proactive protection
- Event Simulator - Demo scenarios (default)
- Manual API - POST /api/events for testing
- Twilio Webhook - Real phone call integration (see Production Deployment)
- Live Feed event injector - Targets the currently selected household members instead of the legacy hard-coded demo defaults
- Household fraud case panel - Links one recent household call with one manual evidence item and generates an explainable risk case
The strongest current demo is a household-aware fraud case, not generic phone spam blocking:
- A real inbound call hits the household Twilio number
- CORTEGE resolves the household and target member
- The operator adds one manual evidence item in Live Feed
- CORTEGE creates one case with severity, signals, rationale, and recommended action
Supported first-pass evidence inputs are intentionally text-first and conservative:
message_excerptsuspicious_urlscreenshot_note
This flow does not claim definitive AI-image or AI-video detection. It uses explainable risk heuristics so the demo remains believable under hackathon time pressure.
CORTEGE supports multiple households, each with independent members and companion agents.
Click "Switch Household" in the nav bar to open the household selector. From there you can create households, switch between them, delete unused ones, manage saved locations, edit a location name/address, and reassign a household to another saved location. Referenced locations cannot be deleted until every blocking household is reassigned. Your selected household persists across page reloads via localStorage.
# Create a named location
LOCATION_ID=$(curl -s -X POST http://localhost:3001/api/locations \
-H 'Content-Type: application/json' \
-d '{
"name": "Family A Home",
"address": {
"line1": "123 Main St",
"line2": null,
"city": "New York",
"region": "NY",
"postal_code": "10001",
"country": "US"
}
}' | jq -r '.location_id')
# Create a household
curl -X POST http://localhost:3001/api/households \
-H 'Content-Type: application/json' \
-d "{\"name\": \"Family A\", \"location_id\": \"$LOCATION_ID\"}"
# Add a member
curl -X POST http://localhost:3001/api/households/<id>/members \
-H 'Content-Type: application/json' \
-d '{
"name": "Alex",
"phone": "+14155550123",
"date_of_birth": "2012-05-14",
"profile_type": "child",
"companion": "scout"
}'If you have an existing data/household.json, migrate it to the multi-household store:
node scripts/migrate-household.jsThis will:
- Read the legacy
data/household.json - Create a new household in
data/households/ - Migrate all members
- Back up the original as
data/household.json.backup
The legacy GET /api/household endpoint continues to work β it falls back through: household store (by DEFAULT_HOUSEHOLD_ID) β first available household β legacy household.json β empty default.
DEFAULT_HOUSEHOLD_ID=<uuid> # Optional: default household for legacy endpointThe current household data model is privacy-first:
- Household and location records use
location_idreferences instead of embedding a freeform householdlocation - Member full name, phone, and
date_of_birthare encrypted at rest - Saved location name and structured address are encrypted at rest
- Logs and external LLM calls use redacted or aliased values instead of raw PII
For production deployments, set a strong PII_MASTER_KEY. In development, the server falls back to a dev-only key if it is unset.
Companion runtime instances are keyed by the stable member.id, not by the member display name. That matters for demo reliability:
- A newly created
Sam Dodgedoes not inherit anotherSam Dodge's old memory or activity - Live companion activity starts from that member's actual creation time
- The selected-household Live Feed and Household detail surfaces stay aligned to the same member identity
CORTEGE uses SQLite for production storage with tamper-evident audit trail.
Configure via STORAGE_MODE environment variable:
- sqlite (default) - Production mode with tamper-evident hash chain
- json - Legacy mode using JSON files (for development)
- dual-write - Write to both SQLite and JSON (for migration)
# Storage configuration
STORAGE_MODE=sqlite # sqlite | json | dual-write
SQLITE_DB_PATH=data/cortege.db # SQLite database path
ENABLE_JSON_FALLBACK=false # Fall back to JSON on SQLite errorsTo migrate existing JSON files to SQLite:
node scripts/migrate-to-sqlite.jsThe migration script will:
- Backup existing SQLite database (if it exists)
- Import all events from
data/events/*.jsonl - Reconstruct hash chain for tamper evidence
- Import memory snapshots from
data/memories/*.json - Validate hash chain integrity
- Report progress and errors
Validate event log integrity:
node scripts/validate-hash-chain.jsThis verifies:
- Each event's hash is correctly computed
- Each event's prev_hash matches the previous event's hash
- No events have been tampered with or deleted
Run this daily in production (e.g., via cron job) to ensure audit trail integrity.
- Tamper-evident: Append-only event log with SHA-256 hash chain
- Atomic writes: Events and memory snapshots written in transactions
- Query capabilities: Filter by member, threat level, time range, signals
- Crash recovery: WAL (Write-Ahead Logging) mode enabled
- Security: Database file permissions set to 0600 (owner read/write only)
cortege-hackathon/
βββ .kiro/ # Kiro IDE configuration and specs
β βββ specs/ # Implementation specifications
β βββ agent-orchestration-implementation/ # Main implementation spec
β β βββ requirements.md # 48 FR + 15 NFR requirements
β β βββ tasks.md # 10 phases, 100+ granular tasks
β βββ agent-orchestration-mvp/ # MVP specification
β βββ requirements.md # MVP requirements subset
β βββ tasks.md # MVP task breakdown
β
βββ agents/ # Agent templates (markdown) - swappable layer
β βββ _template/ # Template for creating new agents
β β βββ agent.md # Starter template with examples
β βββ anchor/ # Elderly protection agent
β β βββ agent.md # YAML frontmatter + markdown prompt
β βββ sentinel/ # Adult protection agent
β β βββ agent.md # Primary household coordinator
β βββ scout/ # Teen protection agent
β βββ agent.md # Age-appropriate threat detection
β
βββ data/ # Runtime data storage (gitignored)
β βββ cortege.db # SQLite database (primary storage)
β βββ events/ # Event logs (legacy JSON mode only)
β β βββ YYYY-MM-DD.jsonl # One file per day, one event per line
β βββ memories/ # Agent memory stores (legacy JSON mode only)
β β βββ anchor-member-001.json # Per-agent-instance learning
β β βββ sentinel-member-002.json # Trusted contacts, patterns, history
β β βββ scout-member-003.json # Grows over time = learning
β βββ households/ # Multi-household JSON files
β β βββ <uuid>.json # One file per household (members, config)
β βββ locations/ # Saved named locations (JSON mode)
β β βββ <uuid>.json # One file per saved location
β βββ household.json # Legacy single-household file (backward compat)
β
βββ docs/ # Documentation
β βββ API.md # Complete REST + WebSocket API reference
β βββ PRD.md # Product requirements and roadmap
β βββ PRODUCTION_DEPLOYMENT.md # Twilio integration + production setup
β βββ TRACEABILITY.md # Audit trail navigation guide
β βββ requests.md # Customer request log (CR-*)
β βββ decisions.md # Design decision log (D-*)
β βββ progress.txt # Execution log (session notes)
β βββ specs/ # Feature specifications
β β βββ 20260319-add-household-feature/ # Multi-household management
β β β βββ spec.md # 10 FRs, 3 NFRs, acceptance scenarios
β β β βββ tasks.md # 17 tasks (16 done, 1 deferred)
β β βββ 20260319-frontend-api-integration/ # Live API data in frontend
β β β βββ spec.md
β β β βββ tasks.md
β β βββ working-demo-with-twilio/ # Twilio integration spec
β β β βββ spec.md # Requirements + acceptance criteria
β β β βββ tasks.md # Implementation tasks
β β βββ ... # Additional feature specs
β βββ superpowers/ # Design specifications (architecture)
β βββ specs/
β β βββ 2026-03-14-agent-orchestration-design.md # Agent system design
β β βββ 2026-03-14-agent-orchestration-diagrams.md # Agent system diagrams
β β βββ 2026-03-19-household-management-design.md # Household design
β β βββ 2026-03-19-household-management-diagrams.md # Household diagrams
β βββ plans/ # Implementation plans
β βββ 2026-03-19-add-household-feature.md
β βββ 2026-03-19-frontend-api-integration.md
β βββ 2026-03-18-sqlite-auditability.md
β
βββ scenarios/ # Demo scenario definitions (JSON)
β βββ _template.json # Template for creating scenarios
β βββ grandparent-scam.json # Emergency scam targeting elderly
β βββ bank-fraud.json # Fake bank security call
β βββ tech-support.json # Tech support scam
β
βββ scripts/ # Utility scripts
β βββ migrate-household.js # Migrate legacy household.json to multi-household
β βββ migrate-to-sqlite.js # Migrate JSON files to SQLite
β βββ validate-hash-chain.js # Verify audit trail integrity
β
βββ server/ # Backend (Node.js/Express) - the framework
β βββ index.js # Server entry point
β βββ agents/ # Agent runtime
β β βββ agent-factory.js # Scans agents/ dir, parses templates
β β βββ agent-instance.js # Per-member agent instance
β β βββ template-parser.js # YAML frontmatter + markdown parser
β β βββ memory-store.js # JSON memory persistence + depth calc
β β βββ household.js # Household config loader
β βββ api/ # REST + WebSocket
β β βββ routes.js # Express REST endpoints
β β βββ websocket.js # Real-time event push
β βββ privacy/ # PII protection helpers
β β βββ pii.js # Encryption, tokenization, redaction, LLM sanitization
β βββ claude/ # Claude API client
β β βββ claude-client.js # @anthropic-ai/sdk wrapper
β β βββ response-schema.js # submit_assessment tool definition
β βββ escalation/ # Threat escalation
β β βββ escalation-handler.js # L0-L4 routing + household relay
β βββ ingestion/ # Event ingestion
β β βββ twilio-webhook.js # POST /ingest/twilio/voice
β β βββ simulator.js # Scenario playback engine
β β βββ manual.js # POST /api/events
β βββ orchestrator/ # Core orchestration
β β βββ orchestrator.js # Main coordinator
β β βββ event-bus.js # Typed EventEmitter + SQLite persistence
β β βββ scheduler.js # node-cron for timed tasks
β βββ storage/ # Storage layer
β β βββ schema.sql # SQLite schema with triggers
β β βββ db.js # Database connection + queries
β β βββ hash-chain.js # SHA-256 hash chain computation
β β βββ household-store.js # Multi-household JSON file store
β β βββ location-store.js # Saved-location JSON file store
β β βββ storage-adapter.js # Multi-mode storage (sqlite/json/dual)
β βββ tests/ # Node.js test suite
β βββ integration.test.js # End-to-end flows
β βββ demo-validation.test.js # Demo scenario validation
β βββ template-parser.test.js # Agent template parsing
β βββ event-bus.test.js # Event bus + persistence
β βββ memory-store.test.js # Learning + depth calculation
β βββ escalation-handler.test.js # Threat routing
β βββ db.test.js # SQLite database operations
β βββ hash-chain.test.js # Hash chain computation
β βββ sqlite-triggers.test.js # Append-only trigger validation
β βββ privacy.test.js # PII encryption, tokenization, redaction
β βββ location-store.test.js # Saved-location storage coverage
β βββ household-store.test.js # Household store CRUD (8 tests)
β βββ household-api.test.js # Household API endpoints (8 tests)
β βββ household-integration.test.js # Household end-to-end (4 tests)
β
βββ src/ # Frontend (React + Vite)
β βββ main.jsx # React entry point (HouseholdProvider wrapper)
β βββ Cortege.jsx # Main dashboard component
β βββ components/ # UI components
β β βββ EventFeed.jsx # Real-time event stream
β β βββ AgentStatus.jsx # Companion status cards
β β βββ HouseholdSelector.jsx # Household switching modal
β β βββ LocationManager.jsx # Saved-location list/edit/delete UI
β β βββ MemoryViewer.jsx # Agent memory inspector
β β βββ ScenarioRunner.jsx # Demo scenario controls
β β βββ EventInjector.jsx # Manual event submission
β βββ context/ # React contexts
β β βββ HouseholdContext.jsx # Current household state + localStorage
β βββ hooks/ # Custom React hooks
β β βββ useCortegeData.js # REST + WebSocket data (household-scoped)
β β βββ useCompanionDetail.js # Companion detail panel data
β β βββ useHouseholds.js # Household CRUD operations
β βββ lib/ # Shared utilities
β βββ backend-url.js # API/WS URL helper (proxy-aware)
β βββ companion-display.js # Agent type β display properties
β
βββ .env # Environment config (gitignored)
βββ .env.example # Environment template
βββ package.json # Node.js dependencies
βββ vite.config.js # Vite build config
βββ run-local.sh # Start script (opens 2 terminals)
βββ stop-local.sh # Stop script (kills ports 3001 + 5173)
# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests only
npm run test:integrationWith the backend on http://localhost:3001 and the frontend on http://localhost:5173, rerun the current household/member demo review path with:
npx cypress run --spec cypress/e2e/navigation.cy.js,cypress/e2e/household-crud.cy.js,cypress/e2e/member-crud.cy.js,cypress/e2e/companion-cards.cy.js,cypress/e2e/live-feed.cy.js,cypress/e2e/fraud-case-demo.cy.jsThe latest recorded localhost review suite passed with 24 tests across 6 specs and writes reviewer-friendly artifacts to cypress/screenshots/ and cypress/videos/.
Core screenshots from the exact recorded suite:
- Navigation screenshot
- Household routing editor screenshot
- Member CRUD screenshot
- Selected-household companion screenshot
- Live Feed screenshot
- Fraud case demo screenshot
Recorded videos from the same suite:
- Navigation run video
- Household CRUD run video
- Member CRUD run video
- Companion cards run video
- Live Feed run video
- Fraud case demo run video
Agents are defined as markdown files with YAML frontmatter:
- Create
agents/my-agent/agent.md - Define configuration in YAML frontmatter
- Write system prompt in markdown body
- Restart the orchestrator
See existing agents in agents/ for examples.
# Via API
curl -X POST http://localhost:3001/api/scenarios/grandparent-scam/run
# Available scenarios
ls scenarios/*.json# Required
ANTHROPIC_API_KEY=your_api_key_here
# Optional
CLAUDE_MODEL=claude-haiku-4-5-20251001 # Default model
PORT=3001 # Backend port
PII_MASTER_KEY= # Required in production for encrypted household/member/location PII
# Demo/Learning Acceleration
LEARNING_TIME_MULTIPLIER=1440 # 1 min = 1 day (default)
LEARNING_EVENT_WEIGHT=10 # Event depth multiplier
LEARNING_FAST_MODE=true # Lower stage thresholds
# Twilio (for production)
TWILIO_ACCOUNT_SID=your_sid
TWILIO_AUTH_TOKEN=your_token
# Household
DEFAULT_HOUSEHOLD_ID= # Default household for legacy endpoint
# Debug
CLAUDE_DEBUG=1 # Enable API debug loggingPOST /api/households- Create a new householdGET /api/households- List all householdsGET /api/households/:id- Get household by IDPUT /api/households/:id- Update householdDELETE /api/households/:id- Delete householdPOST /api/households/:id/members- Add member to householdPUT /api/households/:id/members/:mid- Update memberDELETE /api/households/:id/members/:mid- Remove memberGET /api/household- Legacy endpoint (backward-compatible fallback)
GET /api/locations- List saved locationsPOST /api/locations- Create a saved location with a name and structured addressGET /api/locations/:id- Get saved location detailsPUT /api/locations/:id- Update saved location name/addressDELETE /api/locations/:id- Delete a saved location if no household still references it (409 Conflictwhen blocked)
GET /api/companions- Get all agent instancesGET /api/companions/:id- Get specific agentGET /api/companions/:id/memory- Get agent memoryGET /api/companions/:id/activity- Get agent activity log
GET /api/events- Get recent eventsPOST /api/events- Submit manual eventGET /api/fraud-cases?household_id=...- List recent fraud cases for a householdPOST /api/fraud-cases- Create a household fraud case from one linked event and one evidence itemPOST /api/scenarios/:name/run- Run demo scenario
GET /api/agents- List loaded agentsPOST /api/agents/reload- Hot-reload agent templates
GET /api/docs- API documentation (HTML)
See API.md for complete reference with examples.
Connect to ws://localhost:3001 to receive real-time updates:
const ws = new WebSocket('ws://localhost:3001');
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
switch (message.type) {
case 'event': // New event ingested
case 'assessment': // Agent assessment completed
case 'memory_update': // Agent memory updated
case 'escalation': // Threat escalated
case 'error': // Error occurred
}
};Pre-built scenarios in scenarios/:
- grandparent-scam.json - Emergency scam targeting elderly
- bank-fraud.json - Fake bank security call
- tech-support.json - Tech support scam
Run via API or add your own JSON scenario files.
Agents assess threats on a 5-level scale:
- L0 - Benign (normal activity)
- L1 - Suspicious (monitor)
- L2 - Likely threat (warn)
- L3 - High confidence threat (block)
- L4 - Critical threat (block + escalate)
Starts both backend and frontend in separate terminal windows for easy log monitoring.
Features:
- Checks Node.js/npm installation
- Installs dependencies if needed
- Validates .env configuration
- Creates data directory
- Opens two terminal windows (backend + frontend)
Usage:
./run-local.shKills processes on ports 3001 (backend) and 5173 (frontend).
Features:
- Finds PIDs using each port
- Gracefully terminates processes
- Confirms successful shutdown
Usage:
./stop-local.shThis is a hackathon project. For production use:
- Add authentication (API keys, JWT)
- Implement rate limiting
- Add CORS configuration
- Set up proper logging
- Configure production database
- Add monitoring/alerting
- Implement backup/recovery
See PRODUCTION_DEPLOYMENT.md for details.
This project is proprietary, not open source, and all rights are reserved. See
LICENSE.
- Built with Anthropic Claude
- Event-driven architecture inspired by actor model patterns
- Agent learning system based on behavioral analysis research
- Issues: GitHub Issues
- Documentation: See
docs/directory - API Reference: http://localhost:3001/api/docs (when running)
Built for hackathon - March 2026





