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>
147 lines
4.8 KiB
JavaScript
147 lines
4.8 KiB
JavaScript
/**
|
|
* Archive Outdated Documents
|
|
* Sets visibility: 'archived' for 10 documents identified in audit
|
|
*/
|
|
|
|
const { MongoClient } = require('mongodb');
|
|
|
|
// MongoDB connection
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/tractatus_dev';
|
|
const DB_NAME = process.env.MONGODB_DB || 'tractatus_dev';
|
|
|
|
// Documents to archive with reasons
|
|
const DOCUMENTS_TO_ARCHIVE = [
|
|
{
|
|
slug: 'introduction-to-the-tractatus-framework',
|
|
category: 'archived',
|
|
archiveNote: 'Superseded by Architectural Overview & Research Status. References outdated filesystem-only architecture.',
|
|
reason: 'Outdated architecture (pre-MongoDB)'
|
|
},
|
|
{
|
|
slug: 'tractatus-based-llm-architecture-for-ai-safety',
|
|
category: 'archived',
|
|
archiveNote: 'Historical architecture proposal. See Architectural Overview for implemented architecture.',
|
|
reason: 'Pre-Phase 5 architecture proposal'
|
|
},
|
|
{
|
|
slug: 'executive-brief-tractatus-based-llm-architecture-for-ai-safety',
|
|
category: 'archived',
|
|
archiveNote: 'Historical brief based on pre-Phase 5 architecture. See Architectural Overview for current status.',
|
|
reason: 'Pre-Phase 5 executive brief'
|
|
},
|
|
{
|
|
slug: 'tractatus-framework-enforcement-for-claude-code',
|
|
category: 'archived',
|
|
archiveNote: 'Development tool documentation. See Implementation Guide for production deployment.',
|
|
reason: 'Internal development tool'
|
|
},
|
|
{
|
|
slug: 'organizational-theory-foundations-of-the-tractatus-framework',
|
|
category: 'archived',
|
|
archiveNote: 'Academic foundations. See Core Concepts for practical overview.',
|
|
reason: 'Academic content, not practical'
|
|
},
|
|
{
|
|
slug: 'phase-5-poc-session-1-summary',
|
|
category: 'project-tracking',
|
|
archiveNote: 'Project tracking - Phase 5 Session 1. See Architectural Overview for complete project history.',
|
|
reason: 'Project tracking'
|
|
},
|
|
{
|
|
slug: 'phase-5-poc-session-2-summary',
|
|
category: 'project-tracking',
|
|
archiveNote: 'Project tracking - Phase 5 Session 2. See Architectural Overview for complete project history.',
|
|
reason: 'Project tracking'
|
|
},
|
|
{
|
|
slug: 'research-scope-feasibility-of-llm-integrated-tractatus-framework',
|
|
category: 'research-proposal',
|
|
archiveNote: 'Research proposal (not completed work). See Architectural Overview for actual implementation status.',
|
|
reason: 'Research proposal'
|
|
},
|
|
{
|
|
slug: 'research-topic-concurrent-session-architecture-limitations-in-claude-code-governance',
|
|
category: 'research-topic',
|
|
archiveNote: 'Open research question. See Architectural Overview for current architecture limitations.',
|
|
reason: 'Open research question'
|
|
},
|
|
{
|
|
slug: 'research-topic-rule-proliferation-and-transactional-overhead-in-ai-governance',
|
|
category: 'research-topic',
|
|
archiveNote: 'Open research question. See Architectural Overview for current governance approach.',
|
|
reason: 'Open research question'
|
|
}
|
|
];
|
|
|
|
async function main() {
|
|
console.log('=== Archiving Outdated Documents ===\n');
|
|
|
|
let client;
|
|
|
|
try {
|
|
// Connect to MongoDB
|
|
console.log('Connecting to MongoDB...');
|
|
client = await MongoClient.connect(MONGODB_URI);
|
|
const db = client.db(DB_NAME);
|
|
const collection = db.collection('documents');
|
|
console.log('✓ Connected\n');
|
|
|
|
let archived = 0;
|
|
let notFound = 0;
|
|
|
|
// Archive each document
|
|
for (const doc of DOCUMENTS_TO_ARCHIVE) {
|
|
console.log(`Archiving: ${doc.slug}`);
|
|
console.log(` Reason: ${doc.reason}`);
|
|
|
|
const result = await collection.updateOne(
|
|
{ slug: doc.slug },
|
|
{
|
|
$set: {
|
|
visibility: 'archived',
|
|
category: doc.category,
|
|
archiveNote: doc.archiveNote,
|
|
order: 999
|
|
}
|
|
}
|
|
);
|
|
|
|
if (result.matchedCount > 0) {
|
|
console.log(` ✓ Archived\n`);
|
|
archived++;
|
|
} else {
|
|
console.log(` ⚠ Not found in database\n`);
|
|
notFound++;
|
|
}
|
|
}
|
|
|
|
// Summary
|
|
console.log('=== Summary ===\n');
|
|
console.log(`✓ Archived: ${archived} documents`);
|
|
if (notFound > 0) {
|
|
console.log(`⚠ Not found: ${notFound} documents`);
|
|
}
|
|
console.log(`\nTotal processed: ${DOCUMENTS_TO_ARCHIVE.length}`);
|
|
|
|
// Verify archives
|
|
console.log('\n=== Verification ===\n');
|
|
const archivedCount = await collection.countDocuments({ visibility: 'archived' });
|
|
const publicCount = await collection.countDocuments({ visibility: 'public' });
|
|
console.log(`Archived documents: ${archivedCount}`);
|
|
console.log(`Public documents: ${publicCount}`);
|
|
|
|
} catch (error) {
|
|
console.error('\n✗ Error:', error.message);
|
|
console.error(error.stack);
|
|
process.exit(1);
|
|
} finally {
|
|
if (client) await client.close();
|
|
}
|
|
}
|
|
|
|
// Run if called directly
|
|
if (require.main === module) {
|
|
main();
|
|
}
|
|
|
|
module.exports = { main };
|