tractatus/scripts/check-boundary-enforcer-logs.js
TheFlow 8602f9e917 feat(framework): add Phase 4 effectiveness measurement and analysis scripts
Framework Measurement Scripts (Phase 4.2-4.3):
- measure-framework-effectiveness.js: Overall participation rate and service metrics
- check-boundary-enforcer-logs.js: Service-specific analysis with recent decision tracking
- measure-recent-participation.js: Recent-only metrics to avoid historical data skew

Purpose:
Discovered that 91.6% of audit logs were created before Phase 3 deployment,
creating artificially low participation metrics. These scripts separate
historical (pre-Phase 3) data from current performance metrics.

Key Findings:
- Overall participation: 4.3% (misleading - includes 91.6% pre-Phase 3 data)
- Recent BoundaryEnforcer decisions: 100% guidance generation (last 5/5)
- CrossReferenceValidator: 56% participation (last 24h)
- MetacognitiveVerifier: 43% participation (last 24h)

Validates Phase 3 is working correctly - 100% of new decisions include guidance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 19:47:39 +13:00

52 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
const mongoose = require('mongoose');
async function main() {
await mongoose.connect('mongodb://localhost:27017/tractatus_dev');
const db = mongoose.connection.db;
const auditLogs = db.collection('auditLogs');
// Get all BoundaryEnforcer decisions
const all = await auditLogs.countDocuments({ service: 'BoundaryEnforcer' });
// Get ones with framework_backed_decision = true
const withGuidance = await auditLogs.countDocuments({
service: 'BoundaryEnforcer',
'metadata.framework_backed_decision': true
});
// Get ones with empty or no framework_backed_decision
const withoutGuidance = await auditLogs.countDocuments({
service: 'BoundaryEnforcer',
$or: [
{ 'metadata.framework_backed_decision': { $exists: false } },
{ 'metadata.framework_backed_decision': false },
{ 'metadata.framework_backed_decision': null }
]
});
console.log('BoundaryEnforcer Analysis:');
console.log('─'.repeat(50));
console.log(`Total decisions: ${all}`);
console.log(`With guidance: ${withGuidance} (${((withGuidance/all)*100).toFixed(1)}%)`);
console.log(`Without guidance: ${withoutGuidance} (${((withoutGuidance/all)*100).toFixed(1)}%)`);
console.log('');
// Get most recent 5 decisions
const recent = await auditLogs.find({ service: 'BoundaryEnforcer' })
.sort({ timestamp: -1 })
.limit(5)
.toArray();
console.log('Most recent 5 decisions:');
recent.forEach((doc, i) => {
const hasGuidance = doc.metadata && doc.metadata.framework_backed_decision === true;
console.log(` ${i+1}. ${doc.timestamp.toISOString()} - Guidance: ${hasGuidance ? 'YES' : 'NO'}`);
});
await mongoose.disconnect();
}
main().catch(console.error);