fix: Resolve ESLint errors breaking CI
- audit.controller.js: Remove unused fs/path imports, add AuditLog import, fix indentation, use const for userCostFactors, use property shorthand - crm.controller.js: Remove unused Contact, MediaInquiry, CaseSubmission imports - cases.controller.js: Remove unused GovernanceLog, BoundaryEnforcer imports - DiskMetrics.model.js: Use template literals instead of string concatenation - framework-content-analysis.controller.js: Use template literals, prefix unused destructured vars with underscore - feedback.controller.js: Use template literal for string concat - DeliberationSession.model.js: Fix line length by moving comments to own lines Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f9ffd44ac8
commit
42a7d95c0f
7 changed files with 34 additions and 32 deletions
|
|
@ -19,9 +19,8 @@
|
||||||
* Serves audit logs from MemoryProxy for analytics dashboard
|
* Serves audit logs from MemoryProxy for analytics dashboard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs').promises;
|
|
||||||
const path = require('path');
|
|
||||||
const logger = require('../utils/logger.util');
|
const logger = require('../utils/logger.util');
|
||||||
|
const AuditLog = require('../models/AuditLog.model');
|
||||||
|
|
||||||
// Default cost factors (user-configurable)
|
// Default cost factors (user-configurable)
|
||||||
const DEFAULT_COST_FACTORS = {
|
const DEFAULT_COST_FACTORS = {
|
||||||
|
|
@ -31,7 +30,7 @@ const DEFAULT_COST_FACTORS = {
|
||||||
LOW: { amount: 500, currency: 'USD', rationale: 'Average developer time cost to fix low-impact issue' }
|
LOW: { amount: 500, currency: 'USD', rationale: 'Average developer time cost to fix low-impact issue' }
|
||||||
};
|
};
|
||||||
|
|
||||||
let userCostFactors = { ...DEFAULT_COST_FACTORS };
|
const userCostFactors = { ...DEFAULT_COST_FACTORS };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get audit logs for analytics
|
* Get audit logs for analytics
|
||||||
|
|
@ -193,7 +192,7 @@ async function getAuditAnalytics(req, res) {
|
||||||
timestamp: d.timestamp,
|
timestamp: d.timestamp,
|
||||||
reason: d.violations[0].ruleText || d.violations[0].details,
|
reason: d.violations[0].ruleText || d.violations[0].details,
|
||||||
ruleId: d.violations[0].ruleId,
|
ruleId: d.violations[0].ruleId,
|
||||||
severity: severity,
|
severity,
|
||||||
file: d.metadata?.filePath || d.metadata?.file || 'N/A',
|
file: d.metadata?.filePath || d.metadata?.file || 'N/A',
|
||||||
service: d.service
|
service: d.service
|
||||||
});
|
});
|
||||||
|
|
@ -416,9 +415,11 @@ async function getAuditAnalytics(req, res) {
|
||||||
severityScore: Math.round(severityScore)
|
severityScore: Math.round(severityScore)
|
||||||
},
|
},
|
||||||
trend: recentBlockRate < avgBlockRate ? 'improving' : 'stable',
|
trend: recentBlockRate < avgBlockRate ? 'improving' : 'stable',
|
||||||
message: recentBlockRate < 0.05 ? 'Excellent - Framework teaching good practices' :
|
message: recentBlockRate < 0.05
|
||||||
recentBlockRate < 0.10 ? 'Good - Team adapting well to governance' :
|
? 'Excellent - Framework teaching good practices'
|
||||||
'Learning - Framework actively preventing violations'
|
: recentBlockRate < 0.10
|
||||||
|
? 'Good - Team adapting well to governance'
|
||||||
|
: 'Learning - Framework actively preventing violations'
|
||||||
};
|
};
|
||||||
|
|
||||||
// ROI Projections
|
// ROI Projections
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
const CaseSubmission = require('../models/CaseSubmission.model');
|
const CaseSubmission = require('../models/CaseSubmission.model');
|
||||||
const ModerationQueue = require('../models/ModerationQueue.model');
|
const ModerationQueue = require('../models/ModerationQueue.model');
|
||||||
const GovernanceLog = require('../models/GovernanceLog.model');
|
|
||||||
const BoundaryEnforcer = require('../services/BoundaryEnforcer.service');
|
|
||||||
const logger = require('../utils/logger.util');
|
const logger = require('../utils/logger.util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@ const Organization = require('../models/Organization.model');
|
||||||
const ActivityTimeline = require('../models/ActivityTimeline.model');
|
const ActivityTimeline = require('../models/ActivityTimeline.model');
|
||||||
const ResponseTemplate = require('../models/ResponseTemplate.model');
|
const ResponseTemplate = require('../models/ResponseTemplate.model');
|
||||||
const SLATracking = require('../models/SLATracking.model');
|
const SLATracking = require('../models/SLATracking.model');
|
||||||
const Contact = require('../models/Contact.model');
|
|
||||||
const MediaInquiry = require('../models/MediaInquiry.model');
|
|
||||||
const CaseSubmission = require('../models/CaseSubmission.model');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get CRM dashboard statistics
|
* Get CRM dashboard statistics
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ async function getStatus(req, res) {
|
||||||
submittedAt: feedback.created_at,
|
submittedAt: feedback.created_at,
|
||||||
hasResponse: !!feedback.response.content,
|
hasResponse: !!feedback.response.content,
|
||||||
responsePreview: feedback.response.content
|
responsePreview: feedback.response.content
|
||||||
? feedback.response.content.substring(0, 200) + '...'
|
? `${feedback.response.content.substring(0, 200)}...`
|
||||||
: null
|
: null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ exports.analyzeBlogPost = async (req, res) => {
|
||||||
* Body: { title, content, category, tags, status: 'draft' }
|
* Body: { title, content, category, tags, status: 'draft' }
|
||||||
*/
|
*/
|
||||||
exports.saveBlogDraft = async (req, res) => {
|
exports.saveBlogDraft = async (req, res) => {
|
||||||
const { title, content, category, tags } = req.body;
|
const { title, content: _content, category: _category, tags: _tags } = req.body;
|
||||||
|
|
||||||
logger.info('[Framework Content Analysis] Saving blog draft', {
|
logger.info('[Framework Content Analysis] Saving blog draft', {
|
||||||
userId: req.user.id,
|
userId: req.user.id,
|
||||||
|
|
@ -159,7 +159,7 @@ exports.saveBlogDraft = async (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Draft saved successfully',
|
message: 'Draft saved successfully',
|
||||||
draftId: 'draft_' + Date.now()
|
draftId: `draft_${Date.now()}`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ exports.saveBlogDraft = async (req, res) => {
|
||||||
* Body: { title, content, category, tags, status: 'published' }
|
* Body: { title, content, category, tags, status: 'published' }
|
||||||
*/
|
*/
|
||||||
exports.publishBlogPost = async (req, res) => {
|
exports.publishBlogPost = async (req, res) => {
|
||||||
const { title, content, category, tags } = req.body;
|
const { title, content: _content, category: _category, tags: _tags } = req.body;
|
||||||
|
|
||||||
logger.info('[Framework Content Analysis] Publishing blog post', {
|
logger.info('[Framework Content Analysis] Publishing blog post', {
|
||||||
userId: req.user.id,
|
userId: req.user.id,
|
||||||
|
|
@ -182,7 +182,7 @@ exports.publishBlogPost = async (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Post published successfully',
|
message: 'Post published successfully',
|
||||||
postId: 'post_' + Date.now()
|
postId: `post_${Date.now()}`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ exports.analyzeFeedback = async (req, res) => {
|
||||||
* Body: { source, relatedPost, content, notes }
|
* Body: { source, relatedPost, content, notes }
|
||||||
*/
|
*/
|
||||||
exports.saveFeedbackAnalysis = async (req, res) => {
|
exports.saveFeedbackAnalysis = async (req, res) => {
|
||||||
const { source, relatedPost, content, notes } = req.body;
|
const { source, relatedPost: _relatedPost, content: _content, notes: _notes } = req.body;
|
||||||
|
|
||||||
logger.info('[Framework Content Analysis] Saving feedback analysis', {
|
logger.info('[Framework Content Analysis] Saving feedback analysis', {
|
||||||
userId: req.user.id,
|
userId: req.user.id,
|
||||||
|
|
@ -290,7 +290,7 @@ exports.saveFeedbackAnalysis = async (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Feedback analysis saved successfully',
|
message: 'Feedback analysis saved successfully',
|
||||||
analysisId: 'feedback_' + Date.now()
|
analysisId: `feedback_${Date.now()}`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ exports.saveFeedbackAnalysis = async (req, res) => {
|
||||||
* Body: { source, relatedPost, content }
|
* Body: { source, relatedPost, content }
|
||||||
*/
|
*/
|
||||||
exports.exportFeedbackReport = async (req, res) => {
|
exports.exportFeedbackReport = async (req, res) => {
|
||||||
const { source, relatedPost, content } = req.body;
|
const { source, relatedPost: _relatedPost, content: _content } = req.body;
|
||||||
|
|
||||||
logger.info('[Framework Content Analysis] Exporting feedback report', {
|
logger.info('[Framework Content Analysis] Exporting feedback report', {
|
||||||
userId: req.user.id,
|
userId: req.user.id,
|
||||||
|
|
@ -337,7 +337,7 @@ function analyzeSentiment(content) {
|
||||||
|
|
||||||
// Question indicators
|
// Question indicators
|
||||||
const questionWords = ['how', 'what', 'why', 'when', 'where', '?'];
|
const questionWords = ['how', 'what', 'why', 'when', 'where', '?'];
|
||||||
const questionCount = questionWords.filter(word => lowerContent.includes(word)).length;
|
const _questionCount = questionWords.filter(word => lowerContent.includes(word)).length;
|
||||||
|
|
||||||
// Determine overall sentiment
|
// Determine overall sentiment
|
||||||
let overall = 'neutral';
|
let overall = 'neutral';
|
||||||
|
|
|
||||||
|
|
@ -190,14 +190,18 @@ class DeliberationSession {
|
||||||
|
|
||||||
const interventionRecord = {
|
const interventionRecord = {
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
intervener: intervention.intervener, // Name/ID of human who intervened
|
intervener: intervention.intervener,
|
||||||
trigger: intervention.trigger, // "safety_concern" | "ai_error" | "stakeholder_request" | "quality_issue" | "manual"
|
// "safety_concern" | "ai_error" | "stakeholder_request" | "quality_issue" | "manual"
|
||||||
|
trigger: intervention.trigger,
|
||||||
round_number: intervention.round_number || null,
|
round_number: intervention.round_number || null,
|
||||||
description: intervention.description,
|
description: intervention.description,
|
||||||
ai_action_overridden: intervention.ai_action_overridden || null, // What AI was doing when intervention occurred
|
// What AI was doing when intervention occurred
|
||||||
corrective_action: intervention.corrective_action, // What human did instead
|
ai_action_overridden: intervention.ai_action_overridden || null,
|
||||||
stakeholder_informed: intervention.stakeholder_informed || false, // Were stakeholders told about the intervention?
|
corrective_action: intervention.corrective_action,
|
||||||
resolution: intervention.resolution || null // How was the situation resolved?
|
// Were stakeholders told about the intervention?
|
||||||
|
stakeholder_informed: intervention.stakeholder_informed || false,
|
||||||
|
// How was the situation resolved?
|
||||||
|
resolution: intervention.resolution || null
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = await collection.updateOne(
|
const result = await collection.updateOne(
|
||||||
|
|
@ -229,7 +233,8 @@ class DeliberationSession {
|
||||||
const escalationRecord = {
|
const escalationRecord = {
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
detected_by: escalation.detected_by, // "ai" | "human" | "stakeholder"
|
detected_by: escalation.detected_by, // "ai" | "human" | "stakeholder"
|
||||||
escalation_type: escalation.escalation_type, // "pattern_bias" | "stakeholder_distress" | "disengagement" | "hostile_exchange" | "ai_malfunction"
|
// "pattern_bias" | "stakeholder_distress" | "disengagement" | "hostile_exchange" | "ai_malfunction"
|
||||||
|
escalation_type: escalation.escalation_type,
|
||||||
severity: escalation.severity, // "low" | "moderate" | "high" | "critical"
|
severity: escalation.severity, // "low" | "moderate" | "high" | "critical"
|
||||||
round_number: escalation.round_number || null,
|
round_number: escalation.round_number || null,
|
||||||
description: escalation.description,
|
description: escalation.description,
|
||||||
|
|
@ -280,7 +285,8 @@ class DeliberationSession {
|
||||||
values_prioritized: outcome.values_prioritized || [],
|
values_prioritized: outcome.values_prioritized || [],
|
||||||
values_deprioritized: outcome.values_deprioritized || [],
|
values_deprioritized: outcome.values_deprioritized || [],
|
||||||
deliberation_summary: outcome.deliberation_summary,
|
deliberation_summary: outcome.deliberation_summary,
|
||||||
consensus_level: outcome.consensus_level, // "full_consensus" | "strong_accommodation" | "moderate_accommodation" | "documented_dissent" | "no_resolution"
|
// "full_consensus" | "strong_accommodation" | "moderate_accommodation" | "documented_dissent" | "no_resolution"
|
||||||
|
consensus_level: outcome.consensus_level,
|
||||||
dissenting_perspectives: outcome.dissenting_perspectives || [],
|
dissenting_perspectives: outcome.dissenting_perspectives || [],
|
||||||
justification: outcome.justification,
|
justification: outcome.justification,
|
||||||
moral_remainder: outcome.moral_remainder || null, // What was sacrificed/lost?
|
moral_remainder: outcome.moral_remainder || null, // What was sacrificed/lost?
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ class DiskMetrics {
|
||||||
const totalMem = os.totalmem();
|
const totalMem = os.totalmem();
|
||||||
const freeMem = os.freemem();
|
const freeMem = os.freemem();
|
||||||
metrics.memory = {
|
metrics.memory = {
|
||||||
total: (totalMem / (1024 ** 3)).toFixed(2) + 'GB',
|
total: `${(totalMem / (1024 ** 3)).toFixed(2)}GB`,
|
||||||
used: ((totalMem - freeMem) / (1024 ** 3)).toFixed(2) + 'GB',
|
used: `${((totalMem - freeMem) / (1024 ** 3)).toFixed(2)}GB`,
|
||||||
free: (freeMem / (1024 ** 3)).toFixed(2) + 'GB',
|
free: `${(freeMem / (1024 ** 3)).toFixed(2)}GB`,
|
||||||
usedPercent: Math.round(((totalMem - freeMem) / totalMem) * 100)
|
usedPercent: Math.round(((totalMem - freeMem) / totalMem) * 100)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue