- audit-inflection-point.js: Identify fictional content in research paper - fix-inflection-point-fiction.js: Remove fabricated statistics - audit-all-card-sequences.js: Check card sequence quality - audit-card-category-sequences.js: Analyze pedagogical flow - resequence-cards-pedagogically.js: Reorder cards for better learning flow - apply-production-fixes.js: Production deployment script - inspect-*: Helper scripts for analysis Quality improvements: - Removed fictional content from Inflection Point document (3 sections) - Resequenced 21 documents pedagogically (22-67% jumpiness reduction) - Implemented proper learning flow: concepts → warnings → technical → reference
184 lines
7 KiB
JavaScript
184 lines
7 KiB
JavaScript
/**
|
|
* Apply all content fixes to production database
|
|
* 1. Remove fictional content from Inflection Point document
|
|
* 2. Resequence cards pedagogically in all documents
|
|
*/
|
|
const { MongoClient } = require('mongodb');
|
|
require('dotenv').config({ path: '/var/www/tractatus/.env' });
|
|
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017';
|
|
const DB_NAME = process.env.MONGODB_DB || 'tractatus_prod';
|
|
|
|
// Pedagogical ordering strategies
|
|
const ORDERING_STRATEGIES = {
|
|
'getting-started': ['conceptual', 'critical', 'practical', 'technical', 'reference'],
|
|
'research-theory': ['critical', 'conceptual', 'technical', 'practical', 'reference'],
|
|
'technical-reference': ['conceptual', 'technical', 'practical', 'critical', 'reference'],
|
|
'advanced-topics': ['critical', 'conceptual', 'technical', 'practical', 'reference'],
|
|
'business-leadership': ['conceptual', 'critical', 'practical', 'technical', 'reference']
|
|
};
|
|
|
|
function resequenceSections(sections, strategy) {
|
|
if (!sections || sections.length === 0) return sections;
|
|
|
|
const order = ORDERING_STRATEGIES[strategy] || ORDERING_STRATEGIES['getting-started'];
|
|
|
|
const priorityMap = {};
|
|
order.forEach((category, idx) => {
|
|
priorityMap[category] = idx;
|
|
});
|
|
|
|
const resequenced = [...sections].sort((a, b) => {
|
|
const priorityA = priorityMap[a.category] ?? 999;
|
|
const priorityB = priorityMap[b.category] ?? 999;
|
|
|
|
if (priorityA !== priorityB) {
|
|
return priorityA - priorityB;
|
|
}
|
|
|
|
return a.number - b.number;
|
|
});
|
|
|
|
resequenced.forEach((section, idx) => {
|
|
section.number = idx + 1;
|
|
});
|
|
|
|
return resequenced;
|
|
}
|
|
|
|
async function run() {
|
|
const client = new MongoClient(MONGODB_URI);
|
|
await client.connect();
|
|
|
|
const db = client.db(DB_NAME);
|
|
const collection = db.collection('documents');
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(' APPLYING PRODUCTION FIXES');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
console.log(`Database: ${DB_NAME}`);
|
|
console.log(`URI: ${MONGODB_URI}\n`);
|
|
|
|
// Fix 1: Remove fictional content from Inflection Point document
|
|
console.log('\n📝 FIX 1: Inflection Point - Remove Fictional Content\n');
|
|
|
|
const inflectionDoc = await collection.findOne({ slug: 'executive-summary-tractatus-inflection-point' });
|
|
|
|
if (inflectionDoc && inflectionDoc.sections) {
|
|
const sectionsToRemove = [];
|
|
|
|
// Fix section 1: Remove "six months of production deployment"
|
|
const section1 = inflectionDoc.sections.find(s => s.title === 'The Key Finding');
|
|
if (section1) {
|
|
section1.excerpt = section1.excerpt
|
|
.replace(/After six months of production deployment,?\s*/i, '')
|
|
.replace(/we've reached/i, 'We\'ve identified')
|
|
.replace(/We've reached/i, 'We\'ve identified');
|
|
|
|
section1.content_html = section1.content_html
|
|
.replace(/After six months of production deployment,?\s*/i, '')
|
|
.replace(/we've reached/i, 'we\'ve identified')
|
|
.replace(/We've reached/i, 'We\'ve identified');
|
|
|
|
console.log(' ✓ Fixed: "The Key Finding" - removed fictional deployment claim');
|
|
}
|
|
|
|
// Remove section 2: "The Numbers That Matter"
|
|
const section2Idx = inflectionDoc.sections.findIndex(s => s.title === 'The Numbers That Matter');
|
|
if (section2Idx >= 0) {
|
|
sectionsToRemove.push(section2Idx);
|
|
console.log(' ✓ Removed: "The Numbers That Matter" - fabricated statistics table');
|
|
}
|
|
|
|
// Remove section 7: "Evidence That Matters: The Test That Changed Everything"
|
|
const section7Idx = inflectionDoc.sections.findIndex(s => s.title === 'Evidence That Matters: The Test That Changed Everything');
|
|
if (section7Idx >= 0) {
|
|
sectionsToRemove.push(section7Idx);
|
|
console.log(' ✓ Removed: "Evidence That Matters" - fabricated test results');
|
|
}
|
|
|
|
// Remove sections in reverse order
|
|
sectionsToRemove.sort((a, b) => b - a).forEach(idx => {
|
|
inflectionDoc.sections.splice(idx, 1);
|
|
});
|
|
|
|
// Renumber
|
|
inflectionDoc.sections.forEach((section, idx) => {
|
|
section.number = idx + 1;
|
|
});
|
|
|
|
await collection.updateOne(
|
|
{ slug: 'executive-summary-tractatus-inflection-point' },
|
|
{
|
|
$set: {
|
|
sections: inflectionDoc.sections,
|
|
updated_at: new Date()
|
|
}
|
|
}
|
|
);
|
|
|
|
console.log(`\n ✅ Inflection Point fixed: ${inflectionDoc.sections.length} sections remaining\n`);
|
|
} else {
|
|
console.log(' ⚠️ Inflection Point document not found\n');
|
|
}
|
|
|
|
// Fix 2: Resequence all documents pedagogically
|
|
console.log('\n📝 FIX 2: Resequence Cards Pedagogically\n');
|
|
|
|
const PUBLIC_SLUGS = [
|
|
'introduction', 'core-concepts', 'executive-summary-tractatus-inflection-point',
|
|
'implementation-guide-v1.1', 'implementation-guide', 'implementation-guide-python-examples',
|
|
'tractatus-framework-research', 'pluralistic-values-research-foundations',
|
|
'the-27027-incident-a-case-study-in-pattern-recognition-bias',
|
|
'real-world-ai-governance-a-case-study-in-framework-failure-and-recovery',
|
|
'llm-integration-feasibility-research-scope',
|
|
'research-topic-concurrent-session-architecture',
|
|
'research-topic-rule-proliferation-transactional-overhead',
|
|
'technical-architecture', 'api-reference-complete', 'api-javascript-examples',
|
|
'api-python-examples', 'openapi-specification',
|
|
'value-pluralism-faq', 'tractatus-ai-safety-framework-core-values-and-principles',
|
|
'organizational-theory-foundations', 'business-case-tractatus-framework'
|
|
];
|
|
|
|
let resequencedCount = 0;
|
|
|
|
for (const slug of PUBLIC_SLUGS) {
|
|
const doc = await collection.findOne({ slug });
|
|
|
|
if (!doc || !doc.sections || doc.sections.length === 0) {
|
|
continue;
|
|
}
|
|
|
|
const strategy = doc.category || 'getting-started';
|
|
const resequencedSections = resequenceSections([...doc.sections], strategy);
|
|
|
|
await collection.updateOne(
|
|
{ slug },
|
|
{
|
|
$set: {
|
|
sections: resequencedSections,
|
|
updated_at: new Date()
|
|
}
|
|
}
|
|
);
|
|
|
|
resequencedCount++;
|
|
console.log(` ✓ Resequenced: ${doc.title}`);
|
|
}
|
|
|
|
console.log(`\n ✅ Resequenced ${resequencedCount} documents\n`);
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(' PRODUCTION FIXES COMPLETE');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
console.log('Summary:');
|
|
console.log(' • Removed fictional content from Inflection Point');
|
|
console.log(` • Resequenced ${resequencedCount} documents pedagogically`);
|
|
console.log('');
|
|
|
|
await client.close();
|
|
}
|
|
|
|
run().catch(console.error);
|