#!/usr/bin/env node /** * Update Document Ordering - Rational Pedagogical Sequence * * Sets rational order values for all 34 public documents based on: * - Learning progression (beginner → advanced) * - Logical dependencies * - User journey optimization */ require('dotenv').config(); const { connect, close } = require('../src/utils/db.util'); const Document = require('../src/models/Document.model'); // Rational ordering scheme for all 34 documents const ORDERING_SCHEME = { 'getting-started': [ { slug: 'introduction', order: 1, reason: 'Start here - overview of framework' }, { slug: 'core-concepts', order: 2, reason: 'Core concepts after introduction' }, { slug: 'architectural-safeguards-against-llm-hierarchical-dominance-prose', order: 3, reason: 'Deep dive into architecture' }, { slug: 'tractatus-ai-safety-framework-core-values-and-principles', order: 4, reason: 'Values & philosophy last' } ], 'technical-reference': [ { slug: 'technical-architecture', order: 1, reason: 'Technical overview first' }, { slug: 'implementation-guide', order: 2, reason: 'How to implement' }, { slug: 'implementation-guide-v1.1', order: 3, reason: 'Updated implementation guide' }, { slug: 'implementation-roadmap-24-month-deployment-plan', order: 4, reason: 'Long-term deployment plan' }, { slug: 'GLOSSARY', order: 5, reason: 'Reference for terminology' }, { slug: 'comparison-matrix', order: 6, reason: 'Context vs other frameworks' }, { slug: 'api-reference-complete', order: 7, reason: 'API overview' }, { slug: 'api-javascript-examples', order: 8, reason: 'JavaScript code examples' }, { slug: 'api-python-examples', order: 9, reason: 'Python code examples' }, { slug: 'openapi-specification', order: 10, reason: 'OpenAPI spec for integration' } ], 'research-theory': [ { slug: 'executive-summary-tractatus-inflection-point', order: 1, reason: 'Executive summary first (quick read)' }, { slug: 'architectural-overview-and-research-status', order: 2, reason: 'Main research paper' }, { slug: 'organizational-theory-foundations', order: 3, reason: 'Academic grounding' }, { slug: 'pluralistic-values-research-foundations', order: 4, reason: 'Advanced research topic' } ], 'advanced-topics': [ { slug: 'value-pluralism-faq', order: 1, reason: 'FAQ introduction to value pluralism' }, { slug: 'pluralistic-values-deliberation-plan-v2', order: 2, reason: 'Implementation plan' } ], 'case-studies': [ { slug: 'the-27027-incident-a-case-study-in-pattern-recognition-bias', order: 1, reason: 'Famous incident - start here' }, { slug: 'when-frameworks-fail-and-why-thats-ok', order: 2, reason: 'Philosophy of failure' }, { slug: 'our-framework-in-action-detecting-and-correcting-ai-fabrications', order: 3, reason: 'Success story' }, { slug: 'real-world-ai-governance-a-case-study-in-framework-failure-and-recovery', order: 4, reason: 'Comprehensive analysis' }, { slug: 'case-studies-real-world-llm-failure-modes', order: 5, reason: 'Collection of failure modes' } ], 'business-leadership': [ { slug: 'business-case-tractatus-framework', order: 1, reason: 'Business case template' } ], 'archives': [ { slug: 'llm-integration-feasibility-research-scope', order: 1, reason: 'Research scope document' }, { slug: 'case-studies-real-world-llm-failure-modes-appendix', order: 2, reason: 'Appendix B - historical tracking' }, { slug: 'implementation-guide-python-examples', order: 3, reason: 'Historical Python examples' }, { slug: 'tractatus-framework-enforcement-claude-code', order: 4, reason: 'Development tool docs' }, { slug: 'research-topic-concurrent-session-architecture', order: 5, reason: 'Research analysis 1' }, { slug: 'research-topic-rule-proliferation-transactional-overhead', order: 6, reason: 'Research analysis 2' }, { slug: 'phase-5-poc-session-1-summary', order: 7, reason: 'Phase 5 Session 1 tracking' }, { slug: 'phase-5-poc-session-2-summary', order: 8, reason: 'Phase 5 Session 2 tracking' } ] }; async function updateDocumentOrder(slug, order, category, reason) { try { const doc = await Document.findBySlug(slug); if (!doc) { console.log(` ❌ Not found: ${slug}`); return { success: false, reason: 'not_found' }; } // Update order and category const updated = await Document.update(doc._id.toString(), { order, category }); if (!updated) { console.log(` ❌ Failed to update: ${slug}`); return { success: false, reason: 'update_failed' }; } console.log(` ✅ ${category}[${order}] ${doc.title}`); console.log(` Reason: ${reason}`); return { success: true }; } catch (error) { console.error(` ❌ Error: ${error.message}`); return { success: false, error: error.message }; } } async function main() { try { console.log('🚀 Updating Document Ordering - Rational Pedagogical Sequence\n'); console.log('═══════════════════════════════════════════════════\n'); await connect(); let updated = 0; let failed = 0; let total = 0; for (const [category, docs] of Object.entries(ORDERING_SCHEME)) { console.log(`\n📂 Category: ${category} (${docs.length} docs)`); console.log('─'.repeat(60)); for (const { slug, order, reason } of docs) { total++; const result = await updateDocumentOrder(slug, order, category, reason); if (result.success) { updated++; } else { failed++; } } } console.log('\n═══════════════════════════════════════════════════'); console.log('\n📊 Summary:'); console.log(` ✅ Updated: ${updated}`); console.log(` ❌ Failed: ${failed}`); console.log(` 📦 Total: ${total}`); console.log('\n🎯 Ordering Rationale:'); console.log(' • Getting Started: Introduction → Core Concepts → Architecture → Values'); console.log(' • Technical Reference: Overview → Guides → Roadmap → Reference → API → Examples'); console.log(' • Research & Theory: Executive Summary → Main Paper → Foundations → Advanced'); console.log(' • Advanced Topics: FAQ → Implementation Plan'); console.log(' • Case Studies: Famous Case → Philosophy → Success → Analysis → Collection'); console.log(' • Archives: Chronological + topical grouping'); await close(); } catch (error) { console.error('\n❌ Fatal error:', error); process.exit(1); } } main();