tractatus/scripts/check-card-view-status.js
TheFlow 2af47035ac refactor: remove website code and fix critical startup crashes (Phase 8)
CRITICAL FIX: Server would CRASH ON STARTUP (multiple import errors)

REMOVED (2 scripts):
1. scripts/framework-watchdog.js
   - Monitored .claude/session-state.json (OUR Claude Code setup)
   - Monitored .claude/token-checkpoints.json (OUR file structure)
   - Implementers won't have our .claude/ directory

2. scripts/init-db.js
   - Created website collections: blog_posts, media_inquiries, case_submissions
   - Created website collections: resources, moderation_queue, users, citations
   - Created website collections: translations, koha_donations
   - Next steps referenced deleted scripts (npm run seed:admin)

REWRITTEN (2 files):

src/models/index.js (29 lines → 27 lines)
- REMOVED imports: Document, BlogPost, MediaInquiry, CaseSubmission, Resource
- REMOVED imports: ModerationQueue, User (all deleted in Phase 2)
- KEPT imports: AuditLog, DeliberationSession, GovernanceLog, GovernanceRule
- KEPT imports: Precedent, Project, SessionState, VariableValue, VerificationLog
- Result: Only framework models exported

src/server.js (284 lines → 163 lines, 43% reduction)
- REMOVED: Imports to deleted middleware (csrf-protection, response-sanitization)
- REMOVED: Stripe webhook handling (/api/koha/webhook)
- REMOVED: Static file caching (for deleted public/ directory)
- REMOVED: Static file serving (public/ deleted in Phase 6)
- REMOVED: CSRF token endpoint
- REMOVED: Website homepage with "auth, documents, blog, admin" references
- REMOVED: Instruction sync (scripts/sync-instructions-to-db.js reference)
- REMOVED: Hardcoded log path (${process.env.HOME}/var/log/tractatus/...)
- REMOVED: Website-specific security middleware
- KEPT: Security headers, rate limiting, CORS, body parsers
- KEPT: API routes, governance services, MongoDB connections
- RESULT: Clean framework-only server

RESULT: Repository can now start without crashes, all imports resolve

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 22:17:02 +13:00

118 lines
3.6 KiB
JavaScript

const { MongoClient } = require('mongodb');
// The 34 public documents by slug
const PUBLIC_SLUGS = [
// Getting Started
'introduction',
'architectural-safeguards-against-llm-hierarchical-dominance-prose',
'core-concepts',
'tractatus-ai-safety-framework-core-values-and-principles',
// Technical Reference
'technical-architecture',
'implementation-guide',
'implementation-roadmap-24-month-deployment-plan',
'GLOSSARY',
'comparison-matrix',
'implementation-guide-v1.1',
'api-reference-complete',
'api-javascript-examples',
'api-python-examples',
'openapi-specification',
// Theory & Research
'executive-summary-tractatus-inflection-point',
'architectural-overview-and-research-status',
'organizational-theory-foundations',
'pluralistic-values-research-foundations',
// Advanced Topics
'value-pluralism-faq',
'pluralistic-values-deliberation-plan-v2',
// Case Studies
'the-27027-incident-a-case-study-in-pattern-recognition-bias',
'when-frameworks-fail-and-why-thats-ok',
'our-framework-in-action-detecting-and-correcting-ai-fabrications',
'real-world-ai-governance-a-case-study-in-framework-failure-and-recovery',
'case-studies-real-world-llm-failure-modes',
// Business & Leadership
'business-case-tractatus-framework',
// Archives
'llm-integration-feasibility-research-scope',
'case-studies-real-world-llm-failure-modes-appendix',
'implementation-guide-python-examples',
'tractatus-framework-enforcement-claude-code',
'research-topic-concurrent-session-architecture',
'research-topic-rule-proliferation-transactional-overhead',
'phase-5-poc-session-1-summary',
'phase-5-poc-session-2-summary'
];
async function checkCardViewStatus() {
const client = new MongoClient('mongodb://localhost:27017');
try {
await client.connect();
const db = client.db('tractatus_dev');
const collection = db.collection('documents');
console.log(`\n=== CHECKING CARD VIEW STATUS FOR 34 PUBLIC DOCUMENTS ===\n`);
const documents = await collection.find({
slug: { $in: PUBLIC_SLUGS }
}).toArray();
console.log(`Found ${documents.length} / ${PUBLIC_SLUGS.length} documents in database\n`);
const withCards = [];
const withoutCards = [];
const notFound = [];
PUBLIC_SLUGS.forEach(slug => {
const doc = documents.find(d => d.slug === slug);
if (!doc) {
notFound.push(slug);
} else if (doc.sections && doc.sections.length > 0) {
withCards.push({
slug: doc.slug,
title: doc.title,
sections: doc.sections.length,
category: doc.category || 'none',
order: doc.order || 999
});
} else {
withoutCards.push({
slug: doc.slug,
title: doc.title,
category: doc.category || 'none',
order: doc.order || 999
});
}
});
console.log(`✅ WITH CARD VIEW (${withCards.length} docs):`);
withCards.forEach(doc => {
console.log(` [order:${doc.order}] ${doc.title}`);
console.log(` slug: ${doc.slug} | sections: ${doc.sections} | category: ${doc.category}`);
});
console.log(`\n❌ WITHOUT CARD VIEW (${withoutCards.length} docs):`);
withoutCards.forEach(doc => {
console.log(` [order:${doc.order}] ${doc.title}`);
console.log(` slug: ${doc.slug} | category: ${doc.category}`);
});
if (notFound.length > 0) {
console.log(`\n⚠️ NOT FOUND IN DATABASE (${notFound.length} slugs):`);
notFound.forEach(slug => console.log(` ${slug}`));
}
} finally {
await client.close();
}
}
checkCardViewStatus().catch(console.error);