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.

Version: 1.0.0
Created: 2026-01-23
Status: πŸ“‹ Specification

Overview

This document defines the integration contract between CE-05 (Pipeline & Reporting) and PF-12 (Reports System). CE-05 creates report definitions in PF-12 for scheduled report generation and export functionality.

Integration Pattern

Pattern: Platform Integration Layer (Pattern 1)
Direction: CE-05 β†’ PF-12 (CE-05 is the consumer)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     CE-05       │────▢│     PF-12       β”‚
β”‚ Pipeline Report β”‚     β”‚ Reports System  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                       β”‚
        β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Report Defns    β”‚     β”‚ execute-report  β”‚
β”‚ (pf_reports)    β”‚     β”‚ Edge Function   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Report Definitions

Lead Pipeline Report

FieldValue
report_keyce_lead_pipeline
nameLead Pipeline Report
descriptionLead counts by stage, conversion rates, and average time to convert
modulece
sql_querySELECT * FROM ce_lead_pipeline_metrics WHERE organization_id = :organization_id
parameters{ "date_from": "date", "date_to": "date", "assigned_to": "uuid?" }
formats["csv", "pdf"]
permission_keyce.pipeline.export

Partner Scorecard Report

FieldValue
report_keyce_partner_scorecard
namePartner Scorecard Report
descriptionPartner performance metrics with success rates and trends
modulece
sql_querySELECT * FROM ce_partner_scorecard WHERE organization_id = :organization_id
parameters{ "date_from": "date", "date_to": "date", "partner_type": "string?" }
formats["csv", "pdf"]
permission_keyce.scorecard.export

Call Analytics Report

FieldValue
report_keyce_call_analytics
nameCall Analytics Report
descriptionCall volume, disposition breakdown, and recording coverage
modulece
sql_querySELECT * FROM ce_call_analytics WHERE organization_id = :organization_id
parameters{ "date_from": "date", "date_to": "date", "user_id": "uuid?", "direction": "string?" }
formats["csv", "pdf"]
permission_keyce.analytics.export

Activity Analytics Report

FieldValue
report_keyce_activity_analytics
nameActivity Analytics Report
descriptionActivity counts by type and subject, follow-up rates
modulece
sql_querySELECT * FROM ce_activity_analytics WHERE organization_id = :organization_id
parameters{ "date_from": "date", "date_to": "date", "activity_type": "string?", "subject_type": "string?" }
formats["csv", "pdf"]
permission_keyce.analytics.export

Scheduled Reports

Default Schedules

ReportFrequencyRecipientsTime
Lead PipelineDailyProgram Directors06:00 UTC
Partner ScorecardWeeklyBusiness Dev DirectorsMonday 08:00 UTC
Call AnalyticsWeeklySupervisorsMonday 08:00 UTC
Activity AnalyticsWeeklyProgram DirectorsMonday 08:00 UTC

PHI/PII Protection

  1. Secure Storage: Reports generated to access-controlled storage referenced by pf_report_schedules
  2. Notification Only: Email via PF-10 contains secure portal link only, no PHI/PII
  3. Auto-Expiry: Generated reports auto-expire after 30 days
  4. Audit Logging: All report access logged to pf_audit_logs

Role-Based Recipients

Recipients pulled from user roles, not hardcoded:
  • Program Director β†’ Lead Pipeline, Activity Analytics
  • Business Development Director β†’ Partner Scorecard
  • Supervisor β†’ Call Analytics

API Contract

Export Report (Synchronous)

import { ReportService } from '@/platform/reports';

// CE-05 components call PF-12 for export
const exportReport = async (params: {
  reportKey: 'ce_lead_pipeline' | 'ce_partner_scorecard' | 'ce_call_analytics' | 'ce_activity_analytics';
  organizationId: string;
  format: 'csv' | 'pdf';
  parameters: Record<string, unknown>;
}) => {
  return ReportService.generateReport(params);
};

Schedule Report (Admin Only)

import { ReportService } from '@/platform/reports';

// Org admin schedules recurring report
const scheduleReport = async (params: {
  reportKey: string;
  organizationId: string;
  frequency: 'daily' | 'weekly' | 'monthly';
  recipients: { roleId: string }[];
  parameters: Record<string, unknown>;
}) => {
  return ReportService.createSchedule(params);
};

Error Handling

Error CodeDescriptionUser Message
REPORT_NOT_FOUNDReport definition not in pf_reports”Report configuration not found. Contact support.”
PERMISSION_DENIEDUser lacks export permission”You don’t have permission to export this report.”
GENERATION_FAILEDReport generation error”Failed to generate report. Please try again.”
SCHEDULE_FAILEDSchedule creation error”Failed to schedule report. Please try again.”

Dependencies

Required PF-12 Tables

  • pf_reports - Report definitions
  • pf_report_schedules - Scheduled report configurations
  • pf_report_executions - Execution history
  • pf_report_permissions - Permission mappings

Required Views (CE-05)

  • ce_lead_pipeline_metrics
  • ce_partner_scorecard
  • ce_call_analytics
  • ce_activity_analytics

Testing Requirements

Integration Tests

  1. Report definition exists in pf_reports
  2. Report generates successfully with sample data
  3. Scheduled report executes on schedule
  4. Export respects permission keys
  5. PHI/PII protection in email notifications

Security Tests

  1. Cross-organization access blocked
  2. Permission keys enforced
  3. Audit logging verified
  4. Auto-expiry working

References

  • PF-12 Spec: specs/pf/specs/PF-12-reports-system.md
  • CE-05 Spec: specs/ce/specs/CE-05-pipeline-reporting.md
  • Integration Patterns: docs/architecture/integrations/index.md