Implements architectural enforcement of governance rules (inst_016/017/018/079) for all external communications. Publication blocked at API level if violations detected. New Features: - Framework content checker script with pattern matching for prohibited terms - Admin UI displays framework violations with severity indicators - Manual "Check Framework" button for pre-publication validation - API endpoint /api/blog/check-framework for real-time content analysis Governance Rules Added: - inst_078: "ff" trigger for manual framework invocation in conversations - inst_079: Dark patterns prohibition (sovereignty principle) - inst_080: Open source commitment enforcement (community principle) - inst_081: Pluralism principle with indigenous framework recognition Session Management: - Fix session-init.js infinite loop (removed early return after tests) - Add session-closedown.js for comprehensive session handoff - Refactor check-csp-violations.js to prevent parent process exit Framework Services: - Enhanced PluralisticDeliberationOrchestrator with audit logging - Updated all 6 services with consistent initialization patterns - Added framework invocation scripts for blog content validation Files: blog.controller.js:1211-1305, blog.routes.js:77-82, blog-curation.html:61-72, blog-curation.js:320-446 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
119 lines
4.1 KiB
JavaScript
Executable file
119 lines
4.1 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test Framework Invocations
|
|
* Directly invokes all 6 framework services to generate audit logs
|
|
*/
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
async function testFrameworkServices() {
|
|
console.log('Connecting to MongoDB...');
|
|
await mongoose.connect('mongodb://localhost:27017/tractatus_dev');
|
|
|
|
const BoundaryEnforcer = require('../src/services/BoundaryEnforcer.service');
|
|
const ContextPressureMonitor = require('../src/services/ContextPressureMonitor.service');
|
|
const CrossReferenceValidator = require('../src/services/CrossReferenceValidator.service');
|
|
const InstructionPersistenceClassifier = require('../src/services/InstructionPersistenceClassifier.service');
|
|
const MetacognitiveVerifier = require('../src/services/MetacognitiveVerifier.service');
|
|
const PluralisticDeliberationOrchestrator = require('../src/services/PluralisticDeliberationOrchestrator.service');
|
|
|
|
console.log('\n=== Testing Framework Services ===\n');
|
|
|
|
// 1. BoundaryEnforcer - Test cross-project boundary
|
|
console.log('1. Testing BoundaryEnforcer (cross-project boundary)...');
|
|
try {
|
|
await BoundaryEnforcer.checkBoundaries({
|
|
action: 'file_modification',
|
|
target: '/home/theflow/projects/family-history/README.md',
|
|
description: 'Modify family-history README'
|
|
});
|
|
} catch (err) {
|
|
console.log(' ✓ Boundary violation caught (expected)');
|
|
}
|
|
|
|
// 2. BoundaryEnforcer - Test architectural change
|
|
console.log('2. Testing BoundaryEnforcer (architectural change)...');
|
|
try {
|
|
await BoundaryEnforcer.checkBoundaries({
|
|
action: 'schema_modification',
|
|
target: 'src/models/User.model.js',
|
|
description: 'Add new field to User schema'
|
|
});
|
|
} catch (err) {
|
|
console.log(' ✓ Architectural boundary detected');
|
|
}
|
|
|
|
// 3. ContextPressureMonitor - Analyze pressure
|
|
console.log('3. Testing ContextPressureMonitor...');
|
|
await ContextPressureMonitor.analyzeContextPressure({
|
|
tokens: 75000,
|
|
budget: 200000,
|
|
messages: 45,
|
|
tasks: 3
|
|
});
|
|
console.log(' ✓ Pressure analysis logged');
|
|
|
|
// 4. CrossReferenceValidator - Validate against instructions
|
|
console.log('4. Testing CrossReferenceValidator...');
|
|
await CrossReferenceValidator.validateAgainstInstructions({
|
|
action: 'deploy_to_production',
|
|
description: 'Deploy without running tests',
|
|
context: { skipTests: true }
|
|
});
|
|
console.log(' ✓ Validation logged');
|
|
|
|
// 5. InstructionPersistenceClassifier - Classify new instruction
|
|
console.log('5. Testing InstructionPersistenceClassifier...');
|
|
await InstructionPersistenceClassifier.classifyInstruction({
|
|
id: 'test_inst_999',
|
|
text: 'All API endpoints must have rate limiting',
|
|
source: 'test'
|
|
});
|
|
console.log(' ✓ Classification logged');
|
|
|
|
// 6. MetacognitiveVerifier - Verify decision
|
|
console.log('6. Testing MetacognitiveVerifier...');
|
|
await MetacognitiveVerifier.verifyDecision({
|
|
action: 'modify_authentication',
|
|
reasoning: 'Need to add JWT support',
|
|
context: {
|
|
file: 'src/middleware/auth.js',
|
|
security_impact: true
|
|
}
|
|
});
|
|
console.log(' ✓ Verification logged');
|
|
|
|
// 7. PluralisticDeliberationOrchestrator - Value conflict
|
|
console.log('7. Testing PluralisticDeliberationOrchestrator...');
|
|
await PluralisticDeliberationOrchestrator.analyzeConflict({
|
|
proposed_action: 'Remove accessibility features for performance',
|
|
value_conflict: {
|
|
performance: 'faster page load',
|
|
accessibility: 'screen reader support'
|
|
},
|
|
urgency: 'MODERATE'
|
|
});
|
|
console.log(' ✓ Deliberation logged');
|
|
|
|
console.log('\n=== All Services Tested ===\n');
|
|
|
|
// Check results
|
|
const AuditLog = mongoose.model('AuditLog');
|
|
const count = await AuditLog.countDocuments();
|
|
const services = await AuditLog.distinct('service');
|
|
|
|
console.log(`Total audit logs: ${count}`);
|
|
console.log(`Services active: ${services.length}/6`);
|
|
console.log('Services:', services.join(', '));
|
|
|
|
console.log('\nRefresh http://localhost:9000/admin/audit-analytics.html to see results!');
|
|
|
|
await mongoose.disconnect();
|
|
process.exit(0);
|
|
}
|
|
|
|
testFrameworkServices().catch(err => {
|
|
console.error('Error:', err.message);
|
|
process.exit(1);
|
|
});
|