/ scripts / verify-slo-tracker.js
verify-slo-tracker.js
 1  /**
 2   * Verification Script for SLO Tracker Implementation
 3   *
 4   * Quick verification that SLO tracker is properly integrated
 5   */
 6  
 7  import { SLO_DEFINITIONS, getSLOSummary } from '../src/agents/utils/slo-tracker.js';
 8  import { createDatabaseConnection } from '../src/utils/db.js';
 9  
10  console.log('=== SLO Tracker Verification ===\n');
11  
12  // 1. Verify SLO definitions
13  console.log('1. SLO Definitions:');
14  console.log(`   Total SLOs defined: ${SLO_DEFINITIONS.length}`);
15  for (const slo of SLO_DEFINITIONS) {
16    console.log(`   - ${slo.stage_name}:`);
17    console.log(`     Description: ${slo.description}`);
18    console.log(
19      `     Target: ${slo.target_percentile}% within ${slo.target_duration_minutes} minutes`
20    );
21  }
22  
23  // 2. Verify database schema has required tables
24  console.log('\n2. Database Schema:');
25  const db = createDatabaseConnection();
26  
27  const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
28  const hasRequiredTables =
29    tables.some(t => t.name === 'site_status') && tables.some(t => t.name === 'sites');
30  
31  if (hasRequiredTables) {
32    console.log('   ✓ Required tables (sites, site_status) exist');
33  } else {
34    console.log('   ✗ Missing required tables');
35  }
36  
37  // 3. Test getSLOSummary function
38  console.log('\n3. SLO Summary Function:');
39  const summary = getSLOSummary();
40  console.log(`   Total SLOs: ${summary.total_slos}`);
41  console.log(`   Violations: ${summary.violations}`);
42  console.log(`   Compliance Rate: ${summary.compliance_rate.toFixed(1)}%`);
43  
44  // 4. Check Monitor agent integration
45  console.log('\n4. Monitor Agent Integration:');
46  import('./monitor.js')
47    .then(({ MonitorAgent }) => {
48      const monitor = new MonitorAgent();
49      const hasMethod = typeof monitor.checkSLOCompliance === 'function';
50      console.log(`   ${hasMethod ? '✓' : '✗'} Monitor.checkSLOCompliance method exists`);
51    })
52    .catch(() => {
53      console.log('   (Skipping - Monitor agent not available in test context)');
54    });
55  
56  // 5. Verify agent_tasks table supports check_slo_compliance
57  const agentTasksExists = tables.some(t => t.name === 'agent_tasks');
58  console.log(
59    `\n5. Agent System:${agentTasksExists ? '\n   ✓ agent_tasks table exists' : '\n   ✗ agent_tasks table missing'}`
60  );
61  
62  db.close();
63  
64  console.log('\n=== Verification Complete ===');