Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

Status: ✅ Active (GR-01–GR-08, GR-10, GR-11 implemented; GR-09 pending; GR-12 specified)
Last Updated: 2026-03-06
Constitution Reference: §1 Architecture & Module Boundaries — no direct core-to-core imports; all cross-core via Platform Integration Layer, events, or API contracts.

Overview

The GR (Governance & Compliance) module manages policies, compliance tracking, audits, risk, quality improvement, accreditation, incident reporting, contracts, and procedures. This document is the canonical anchor for all GR integration contracts, cross-core event publisher/consumer mappings, API contracts, and platform layer usage. Related documents:

Events Published by GR

EventChannelPublisher SpecSubscribersStatus
policy_createdgr_eventsGR-01GR-02, GR-03📝 Planned
policy_acknowledgedgr_eventsGR-01GR-02, GR-03📝 Planned
training_completedgr_eventsGR-02GR-03, HR-02📝 Planned
requirement_createdgr_eventsGR-03GR-04, GR-06📝 Planned
compliance_status_changedgr_eventsGR-03GR-04, GR-05, GR-06📝 Planned
audit_createdgr_eventsGR-04GR-06📝 Planned
audit_finding_createdgr_eventsGR-04GR-05, GR-06📝 Planned
risk_createdgr_eventsGR-05GR-06📝 Planned
risk_assessedgr_eventsGR-05GR-06📝 Planned
qi_project_createdgr_eventsGR-07GR-03, GR-04📝 Planned
accreditation_createdgr_eventsGR-08GR-03, GR-04📝 Planned
incident_createdgr_eventsGR-09GR-05, GR-06, CL (chart flag via gr_incident_created)📝 Planned
incident_resolvedgr_eventsGR-09GR-05, GR-06📝 Planned
gr_incident_createdgr_eventsGR-09CL — chart flag📝 Planned
procedure_approvedgr_eventsGR-11GR-02, GR-03, PF-10✅ Complete
procedure_execution_completedgr_eventsGR-11GR-03, PF-10✅ Complete
gr_template_instantiatedgr_eventsGR-12GR-03, PF-10📝 Planned
gr_template_contributedgr_eventsGR-12GR-03📝 Planned
procedure_gap_identifiedgr_eventsGR-13GR-07 (QI project candidate)📝 Planned
Notes:
  • All GR trigger functions that publish to gr_events MUST use SECURITY DEFINER.
  • gr_incident_created is also documented in CL-GR-CLINICAL-INCIDENT-INTEGRATION.md; follow PHI payload restrictions there.

Events Consumed by GR

EventPublisherGR Consumer SpecGR ActionStatus
employee_createdHRGR-01, GR-02Assign onboarding policies and training📝 Planned
incident_reportedHR-14GR-03, GR-04Create compliance check; initiate audit workflow✅ Implemented
grievance_filedHR-14GR-03Create compliance check record✅ Implemented
vendor_certification_expiringFMGR-03Create compliance check for expiring vendor cert✅ Implemented
pm_overdueFMGR-03Flag preventive maintenance compliance gap📝 Planned
inspection_dueFMGR-03Create upcoming compliance check📝 Planned
inspection_failedFMGR-03, GR-05Create compliance finding; link to risk📝 Planned
inspection_compliantFMGR-03Update compliance check to compliant📝 Planned
it_security_incident_createdITGR-09Create or link GR incident report📝 Planned
it_critical_vulnerability_detectedITGR-09Create GR risk and potential incident📝 Planned
it_asset_disposedITGR-03Update compliance tracking for asset disposal📝 Planned
cl_safety_plan_activatedCL (CL-07)GR-09Create draft incident report (type: safety_plan_activation)📝 Planned
cl_restraint_event_documentedCL (CL-13)GR-09Create draft incident report (type: restraint_seclusion)📝 Planned
cl_incident_reportedCL (CL-15)GR-03, GR-04, GR-08Compliance check; audit log; accreditation evidence✅ Implemented
goal_completedLOGRCross-core governance linkage📝 Planned
Security requirements for all GR consumers:
  • Server-side tenant isolation: validate organization_id against JWT claims before writing.
  • Use SECURITY DEFINER stored procedures for event-triggered writes.
  • Log all event consumptions to pf_audit_logs with user_id, organization_id, timestamp, correlation_id.
  • Implement exponential backoff retries; dead-letter queue for max-retry failures.

API Contracts

No GR-owned API contracts are currently defined. The following are candidates for future specification:
Proposed APITypeConsumerPriority
GET /gr/incidents/{id} (or incident lookup via platform layer)RESTCL, IT, HRHigh (needed for chart flag navigation)
GET /gr/compliance-status?org=&site=RESTCL, PM, HRMedium
GET /gr/accreditation-readiness?org=RESTGR-06 AI, executive dashboardMedium

Platform Layer Usage

LayerPF SpecGR UsageStatus
Forms (PF-08)PF-08Policy acknowledgment forms, audit checklists, compliance surveys✅ Used
Notifications (PF-10)PF-10Policy review reminders, compliance due dates, audit finding alerts✅ Used
Documents (PF-11)PF-11Policy documents, audit evidence, compliance certificates, contract docs✅ Used
Reports (PF-12)PF-12Compliance reports, audit reports, accreditation reports✅ Used
AI (PF-27)PF-27GR-06 AI Compliance Advisor; GR-10 contract analysis (Phase 2, planned)Partial
Permissions (PF-30)PF-30Granular permission system for all GR entities✅ Used
Workflow / Swim Lane (PF-73)PF-73Diagram generation from GR-01 policies and GR-11 procedures✅ Used
Picklists (PF-15)PF-15Policy categories, compliance status, audit types❌ Pending
Custom Fields (PF-16)PF-16gr_policies custom_fields❌ Pending
Configurable Forms (PF-17)PF-17Policy acknowledgment form, audit checklist form❌ Pending
PF-15/16/17 adoption is tracked in PF_ADOPTION_STATUS.md.

Cross-Core Data References

GR does not hold foreign keys to other cores (per constitution §1 / ADR-002 restrictions). Cross-core linkage is by UUID reference columns:
GR EntityReferencesMethod
gr_compliance_checksHR employees, FM vendorsUUID column (entity_id, entity_type) — no FK
gr_incidents (GR-09)CL chart_idUUID column — no FK; link surfaced via gr_incident_created event
gr_contractsFM vendors, HR employees, FAUUID columns (counterparty_id) — no FK
gr_accreditation_evidenceAny documentVia PF-11 document UUIDs — no direct FK

Implementation Notes for GR-09 (Pending)

The GR-09 Incident Reporting implementation must:
  1. Create gr_incidents table with RLS, org isolation, and full audit trail.
  2. Subscribe to cl_safety_plan_activated and cl_restraint_event_documented to auto-create draft incidents.
  3. Publish gr_incident_created and incident_created on incident creation.
  4. Subscribe to it_security_incident_created and it_critical_vulnerability_detected for IT-originated incidents.
  5. Implement statutory deadline tracking for ARS 46-454, ARS 13-3620, AHCCCS AMPM 1620-O.
  6. Create gr_incident_regulatory_reports sub-table for state/AHCCCS report tracking.
  7. Add RLS tests for all new tables in tests/rls/.
  8. Add E2E tests in tests/e2e/gr-incident-workflow.test.ts.
See GR-09-incident-reporting.md for full spec.
See CL-GR-CLINICAL-INCIDENT-INTEGRATION.md for bridge implementation requirements.

Testing Requirements

Test TypeFileCoverage
RLS — policiestests/rls/gr-policies.rls.test.ts
RLS — procedurestests/rls/gr-procedures.rls.test.ts
RLS — auditstests/rls/gr-audits.rls.test.ts
RLS — compliancetests/rls/gr-compliance*.rls.test.ts
RLS — accreditationtests/rls/gr-accreditation*.rls.test.ts
RLS — contractstests/rls/gr-contracts.test.ts
RLS — riskstests/rls/gr-risks.rls.test.ts
RLS — incidentstests/rls/gr-incidents.rls.test.ts❌ Missing — create when GR-09 implemented
RLS — procedure templatestests/rls/gr-procedure-templates.rls.test.ts❌ Missing — create when GR-12 implemented
E2E — AI compliance advisortests/e2e/gr-ai-compliance-advisor.test.ts⚠️ Uses test.fixme — needs enabling
E2E — incident workflowtests/e2e/gr-incident-workflow.test.ts❌ Missing — create when GR-09 implemented
Integration — procedure workflowssrc/cores/gr/tests/integration/procedure-workflows.test.ts
Integration — contractstests/integration/gr-contracts*.ts