K12 Safety Documentation
K12 Safety Platform Overview
The K12 Safety platform provides AI-powered tools and workflows for managing Emergency Operation Plans (EOPs) and Quick Reference Guides (QRGs) for K12 educational institutions. The system helps schools and districts create, edit, and maintain critical safety documentation through intelligent automation and structured workflows.
What Is Currently Implemented
1. Emergency Operation Plan (EOP) Editing
Purpose: AI-assisted editing of EOP functional annexes (emergency response procedures).
What It Does:
- Accepts edit requests for specific EOP annex sections
- Uses AI agents to generate or modify safety procedure content
- Maintains contextual awareness through EOP snapshot integration with MOEOP (Missouri EOP) system
- Provides version tracking and audit logging of all changes
- Ensures role-based access for authorized personnel
Use Cases:
- Safety coordinators editing emergency response procedures
- Principals updating facility-specific safety protocols
- District administrators standardizing safety documentation
Output: Edited EOP content ready for review and incorporation into official plans
Current Status: Production-ready. Processes edit requests with full database logging and status tracking.
2. Quick Reference Guide (QRG) Generation
Purpose: Automated creation of action-oriented safety guides from EOP annexes.
What It Does:
- Generates QRGs from existing EOP functional annexes
- Classifies annex categories (functionality-based vs. emergency-type)
- Extracts target audiences from annexes
- Maps audiences to specific K12 role IDs (teachers, administrators, staff)
- Creates structured content blocks organized by phases (BEFORE, DURING, AFTER)
- Supports batch processing for multiple QRG creation
Use Cases:
- Generating role-specific quick reference cards from comprehensive EOPs
- Creating emergency response checklists for different scenarios
- Producing actionable guides for specific audiences
Output: Role-specific QRG documents with phase-structured action items
Current Status: Production-ready. Generates multiple QRGs per EOP with customizable roles and formats.
3. QRG Editing Workflow
Purpose: AI-assisted modification of existing Quick Reference Guides.
What It Does:
- Accepts edit requests for existing QRG content
- Uses specialized QRG editor agent to modify specific sections
- Maintains structural integrity (BEFORE/DURING/AFTER phases)
- Preserves role-specific targeting
- Logs all modifications for audit trail
Current Status: Production-ready. Edits existing QRGs with full version control.
Architecture Components
Agents
K12 Safety uses specialized AI agents for different tasks:
- K12 Safety Agent (Eddy) - Main agent for EOP editing and content generation
- Category Classification Agent - Classifies annex categories
- Group Extraction Agent - Identifies target audiences from annexes
- Role Mapping Agent - Maps audiences to K12 role IDs
- Content Generation Agent - Generates QRG content blocks
- QRG Editor Agent - Edits existing QRG content
See K12 Agents for detailed agent documentation.
Workflows
Production workflows and evaluation workflows orchestrate the K12 domain:
-
EOP Workflow (
packages/domain-k12/src/k12-annex.workflow.ts)- Handles EOP editing requests
- Manages task logging and status tracking
- Integrates with MOEOP (Missouri EOP) system for snapshots
-
QRG Workflows
- Generation (
packages/domain-k12/src/qrg-generation.workflow.ts) - Creates new QRGs from EOPs - Editing (
packages/domain-k12/src/qrg-editing.workflow.ts) - Modifies existing QRGs
- Generation (
-
Turn-based evaluation workflows (
packages/domain-k12/src/k12-turn-based/)- Replays annex and QRG conversations
- Runs checked-in scenarios and batch scenario suites
- Mines draft scenarios from historical interactions
See K12 Workflows for workflow details.
Tools
28 registered K12 tools handle specific operations:
- Task Management: Insert, update, lookup task requests and status
- Workflow Orchestration: EOP kickoff, scenario-specific kickoff, status polling, result retrieval
- Data Collection: EOP snapshots and role universe lookups
- QRG Operations: Generation, editing, status tracking, cancellation
See K12 Tools (Detailed) for complete tool catalog.
Database
K12 Safety uses the K12SAFETY schema in Azure SQL for operational data:
EOP Tables:
log_EOP_TaskRequests- Full request payloads and responseslog_EOP_TaskStatus- Status timeline for monitoringlog_Jobs- General job tracking
QRG Tables:
qrg_requests- QRG generation/editing requestsqrg_generations- Generation metadata and resultsqrg_generated_items- Individual generated QRGsqrg_generation_annexes- Per-annex processing trackingqrg_ai_calls- Individual AI call logs (tokens, duration, status)qrg_execution_errors- Workflow-level error trackingqrg_edits- Edit requests and resultsqrg_edit_context- Edit context snapshotsqrg_request_prompts- Custom prompts per requestqrg_request_roles- Role associations
See K12 Database for schema details and ER diagrams.
How It Works
EOP Editing Flow
- Request Submission: User submits edit request via API or UI
- Task Logging: Request logged to
log_EOP_TaskRequests - Workflow Kickoff:
k12-annex-editing-kickoffstarts Mastra workflow - EOP Snapshot: Fetches current plan state from MOEOP
- AI Processing: K12 Safety Agent generates/edits content
- Result Storage: Response saved to database
- Status Updates: Client polls status via
k12-annex-editing-status - Result Retrieval: Final payload fetched via
k12-annex-editing-result
QRG Generation Flow
- Request Submission: Submit EOP ID and generation parameters
- Request Creation: Record created in
qrg_requests(type: GENERATION) - Workflow Kickoff:
k12-qrg-generation-kickoffstarts workflow - Category Classification: Classifies each annex
- Group Extraction: Identifies target audiences
- Role Mapping: Maps audiences to K12 roles
- Content Generation: Generates BEFORE/DURING/AFTER content blocks
- Result Storage: QRGs saved to
qrg_generated_items - Status Polling: Client checks status via
k12-qrg-generation-status - Result Retrieval: Fetch complete results via
k12-qrg-generation-result
Key Features
Profile-Based Agent Management
Agents use database-managed prompts from Core.AgentProfiles:
- Prompts editable via Admin UI
- Version tracking with
ProfileHash - Per-profile LLM model overrides
- Automatic agent rebuilding on profile changes
Idempotent Workflow Execution
Workflows support safe retries and status checking:
- Duplicate request detection via
requestId - Status tracking for in-flight operations
- Cancellation support via
k12-qrg-cancel
Audit Trail
Complete audit logging for compliance:
- Full request/response payloads in
RawRequestJson/RawResponseJson - Status timeline in
log_EOP_TaskStatus - Timestamp tracking (
CreatedAt,ModifiedAt) - User and role tracking
Integration Points
- MOEOP Integration: EOP snapshot tool for contextual data
- Mastra Workflows: Native Mastra workflow orchestration
- Azure SQL: Durable state and audit logging
- Azure OpenAI: LLM-powered content generation
Development & Testing
Local Development
# Run dev server
npm run dev
# Run all K12 tests
npm run test:k12
Testing
- Tool unit tests:
packages/domain-k12/tests/tools/(annex editing, EOP snapshot, QRG tools, task management) - Agent tests:
packages/domain-k12/tests/agents/k12-agents.test.ts - E2E tests:
tests/e2e/k12/annex-editing.e2e.test.ts - Bruno collections:
npm run bruno:test:k12
See K12 Testing for full details.
Environment Variables
Key environment variables:
AZURE_SQL_CONNECTION_STRING- Database connectionAZURE_INFERENCE_ENDPOINT- Azure AI Inference endpointK12_MOEOP_API_ENDPOINT- MOEOP integration endpointK12_DEBUG_AGENT_OVERRIDES- Enable agent debugging
Code Locations
- Agents: packages/domain-k12/src/agents/
- Workflows: packages/domain-k12/src/ (
k12-annex.workflow.ts,qrg-*.workflow.ts) and packages/domain-k12/src/k12-turn-based/ - Tools: packages/domain-k12/src/
- Database: db/sqlproj/Mastra.Platform.K12SafetyDb/
- Tests: packages/domain-k12/tests/, tests/integration/k12/, tests/e2e/k12/, tests/shared/integration/workflows/k12-annex-schemas.test.ts