How krishnendubose-github/ai-metadata-copilot-salesforce-health-cloud works
Purpose and Runtime
Salesforce-native metadata intelligence application for Health Cloud-style orgs. It indexes selected org metadata, derives usage relationships, and produces grounded search, impact, security, release-readiness, documentation, and optimization outputs. Runtime is Apex on Salesforce with Lightning Web Components, Salesforce custom objects/metadata, Tooling API callouts, and Queueable async jobs. SFDX project entry is sfdx-project.json.
User and API Entry Points
The primary UI is the multi-tab LWC at force-app/main/default/lwc/aiMetadataCopilotWorkspace/aiMetadataCopilotWorkspace.js. It invokes @AuraEnabled endpoints in force-app/main/default/classes/AiMetadataCopilotController.cls, which delegates structured domain requests through force-app/main/default/classes/AiAgentActionService.cls. MetadataNaturalLanguageAction.cls is an invocable entry point for Agentforce/Flow-style natural-language resolution.
Metadata Refresh, Index, and Snapshot Pipeline
MetadataExtractionOrchestrator.cls coordinates refresh: query Tooling API, extract supported Apex/Flow/CustomField components, normalize them, index them, derive relationships, and snapshot results.
• Tooling boundary: force-app/main/default/classes/MetadataToolingApiClient.cls calls the same-org Salesforce Tooling API through the externally configured SalesforceTooling Named Credential.
• Catalog: MetadataIndexerService.cls upserts force-app/main/default/objects/Metadata_Item__c/Metadata_Item__c.object-meta.xml.
• Relationship graph source: MetadataUsageAnalyzerService.cls persists edges in force-app/main/default/objects/Metadata_Usage__c/Metadata_Usage__c.object-meta.xml.
• Historical state: MetadataSnapshotService.cls writes snapshots and component versions under Metadata_Snapshot__c and Metadata_Component_Version__c.
Search, Resolution, and Impact Graph
Search operates on persisted index and usage evidence rather than live metadata queries. MetadataSearchService.cls filters direct relationships; NaturalLanguageResolutionService.cls resolves API names, labels, objects, and fields before service execution. Impact starts from the same evidence but traverses both inbound/outbound edges with depth and cycle protection in DependencyGraphService.cls; MetadataImpactAnalysisService.cls calculates and persists assessments. Coverage is intentionally constrained to indexed metadata types.
Security Governance Pipeline
SecurityAuditOrchestrator.cls parses requested scope, classifies sensitive fields, aggregates exposure checks, and persists an audit run plus findings. Its policy boundary is configurable sensitive-field metadata, represented by force-app/main/default/objects/Sensitive_Field_Rule__mdt/Sensitive_Field_Rule__mdt.object-meta.xml and example records in force-app/main/default/customMetadata/. Specialized services cover field access, permission sets, profiles, and sharing. Results are durable records in Security_Audit_Run__c and Security_Finding__c; SecurityAuditQueueable.cls supports asynchronous execution.
Deployment Intelligence and Advisory Outputs
Deployment functionality is comparison-only, never a Salesforce deployment executor. EnvironmentSnapshotService.cls captures named environment-comparison snapshots; MetadataCompareService.cls computes added/removed/changed components by key and checksum. DeploymentRiskAssessmentService.cls converts deltas to readiness score, severity, findings, rollback checklist, and regression-test guidance, persisted under Deployment_Assessment__c and Deployment_Finding__c. DeploymentCompareQueueable.cls isolates potentially long-running comparisons.
Other Generated Analyses and Operational Controls
Documentation and optimization consume the same indexed metadata rather than bypassing the catalog: MetadataDocumentationService.cls creates documentation requests, while scanner classes feed Optimization_Finding__c. Async refresh and scan paths use MetadataRefreshQueueable.cls and OptimizationScanQueueable.cls. Custom metadata configures enabled agent actions and environment references, notably Agent_Action_Config__mdt and Environment_Connection__mdt; users require force-app/main/default/permissionsets/AI_Metadata_Copilot_User.permissionset-meta.xml.
Main entry points: AiAgentActionService.cls Agent Action Service · Metadata_Item__c.object-meta.xml Metadata Catalog · Metadata_Usage__c.object-meta.xml Usage Graph · AiMetadataCopilotController.cls Copilot Controller
Components 22
Entry Points
- Copilot Workspace · Multi-tab metadata intelligence workspace.
force-app/main/default/lwc/aiMetadataCopilotWorkspace/aiMetadataCopilotWorkspace.js - Copilot Controller
force-app/main/default/classes/AiMetadataCopilotController.cls - Agent Action Service
force-app/main/default/classes/AiAgentActionService.cls - Natural Language Action · Agentforce and Flow entry point.
- Action, Environment & Access Config · Controls enabled actions, environment references, and user access.
force-app/main/default/permissionsets/AI_Metadata_Copilot_User.permissionset-meta.xml
Metadata Index Pipeline
- Extraction Orchestrator · Coordinates extraction, normalization, indexing, relationships, and snapshots.
- Tooling API Client · Calls same-org Tooling API through the SalesforceTooling Named Credential.
force-app/main/default/classes/MetadataToolingApiClient.cls - Metadata Catalog · Persisted normalized component index.
force-app/main/default/objects/Metadata_Item__c/Metadata_Item__c.object-meta.xml - Usage Graph · Persisted metadata usage edges.
force-app/main/default/objects/Metadata_Usage__c/Metadata_Usage__c.object-meta.xml - Metadata History · Snapshots and component versions.
- Refresh Jobs · Asynchronous refresh execution.
Analysis Services
- NL Resolution · Resolves names, labels, objects, and fields before execution.
- Metadata Search · Searches persisted catalog and direct usage evidence.
- Impact Analysis · Traverses inbound and outbound usage with depth and cycle protection.
- Documentation & Optimization · Generates documentation requests and optimization findings from the catalog.
Security Governance
- Security Audit · Evaluates sensitive-field exposure and persists audit findings.
- Sensitive Field Rules · Configurable sensitive-field policy.
force-app/main/default/objects/Sensitive_Field_Rule__mdt/Sensitive_Field_Rule__mdt.object-meta.xml - Security Audit Results · Audit runs and findings.
Deployment Intelligence
- Environment Comparison · Captures environment snapshots and computes component deltas.
- Deployment Risk Assessment · Produces readiness, findings, rollback checklist, and test guidance.
- Deployment Assessment Results · Comparison-only assessment and findings; never deploys.
- Comparison Jobs · Isolates long-running comparisons.
Connections 23
- Copilot Workspace → Copilot Controller: Aura calls
- Copilot Controller → Agent Action Service: delegates requests
- Natural Language Action → Agent Action Service: natural-language requests
- Agent Action Service → NL Resolution: resolve inputs
- Agent Action Service → Metadata Search: search
- Agent Action Service → Impact Analysis: analyze impact
- Agent Action Service → Security Audit: run audit
- Agent Action Service → Environment Comparison: compare environments
- Refresh Jobs → Extraction Orchestrator: runs refresh
- Extraction Orchestrator → Tooling API Client: extract metadata
- Extraction Orchestrator → Metadata Catalog: normalize and index
- Extraction Orchestrator → Usage Graph: derive relationships
- Extraction Orchestrator → Metadata History: write history
- Metadata Search → Metadata Catalog: query indexed items
- Metadata Search → Usage Graph: direct relationships
- Impact Analysis → Usage Graph: traverse graph
- Documentation & Optimization → Metadata Catalog: consume index
- Security Audit → Sensitive Field Rules: apply policy
- Security Audit → Security Audit Results: persist findings
- Comparison Jobs → Environment Comparison: run comparison
- Environment Comparison → Deployment Risk Assessment: component deltas
- Deployment Risk Assessment → Deployment Assessment Results: persist assessment
- Action, Environment & Access Config → Agent Action Service: governs actions and access