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 |
|
TheFlow
|
0dd4a5f6c8
|
refactor: reduce public repo to minimal implementation-only resource
REMOVED: 267 non-implementation files (51% reduction)
Categories removed:
- Research documents & case studies (35 files)
- Planning/internal development docs (28 files)
- Website pages & assets (93 files - this is framework code, not website code)
- Audit reports (6 files)
- Non-essential admin UI (11 files)
- Markdown content duplicates (10 files)
- Internal development scripts (96 files)
- Internal setup docs (2 files)
RETAINED: 253 implementation-focused files
- Core framework services (src/)
- Test suite (tests/)
- API documentation (docs/api/)
- Deployment quickstart guide
- Essential admin UI (rule manager, dashboard, hooks dashboard)
- Architecture decision records
- Configuration files
PURPOSE: Public repo is now focused exclusively on developers
implementing Tractatus, not researchers studying it or users visiting
the website. All background/research content available at
https://agenticgovernance.digital
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-10-21 21:09:34 +13:00 |
|
TheFlow
|
9bc2410420
|
feat(framework): implement 6 high-priority governance enhancements
SUMMARY:
Implemented 6 framework refinements identified from incident analysis
(inst_049 and inst_025 violations). These enhancements provide architectural
enforcement for patterns that previously relied on voluntary compliance.
ENHANCEMENTS IMPLEMENTED:
1. Instruction Analytics Script (Priority 8)
- scripts/analyze-instruction-violations.js
- Analyzes instruction-history.json for usage patterns
- Identifies most violated instructions
- Calculates enforcement effectiveness (hook vs. voluntary)
- Shows 97.2% voluntary compliance, 75% hook enforcement
- Recommendations for converting voluntary → architectural
2. Framework Incidents Database (Priority 7)
- .claude/framework-incidents.json
- Structured tracking of framework violations
- INC-001: Ignored user hypothesis (70k tokens wasted)
- INC-002: Deployment directory flattening (inst_025 violation)
- Statistics: 2 incidents, 75k tokens wasted, 4.5 hours lost
3. Loop Detector Module (Priorities 3 & 4)
- scripts/framework-components/LoopDetector.js
- Detects "stuck in loop" patterns
- Triggers: 3+ edits to same file, repeated action types
- Feeds into MetacognitiveVerifier and ContextPressureMonitor
- Calculates pressure contribution (5-40 points by severity)
4. Action Pattern Tracker (Priority 3 & 4)
- scripts/track-action-patterns.js
- Tracks edit/write actions to detect repetition
- Alerts after 3 consecutive edits to same file
- Maintains action history (last 100 actions)
- Recommendations for metacognitive verification
5. Pre-Deployment Validation (Priority 5)
- scripts/validate-deployment.js
- Validates rsync/scp commands against inst_025
- Detects directory structure flattening
- Suggests separate commands for different directories
- Prevents 4th documented occurrence of deployment errors
6. User Suggestion Tracker (Priority 6)
- scripts/track-user-suggestions.js
- Implements inst_049: "Test user hypothesis first"
- Tracks user technical hypotheses
- Flags untested hypotheses as HIGH priority
- Integrates with MetacognitiveVerifier for compliance
USAGE:
Instruction Analytics:
node scripts/analyze-instruction-violations.js
Loop Detection:
node scripts/track-action-patterns.js --check
node scripts/track-action-patterns.js --summary
Deployment Validation:
node scripts/validate-deployment.js --command "rsync ..."
User Suggestions:
node scripts/track-user-suggestions.js --add "hypothesis text"
node scripts/track-user-suggestions.js --check-untested
IMPACT:
- Converts 6 voluntary compliance patterns to architectural enforcement
- Prevents repeat of documented 75k token waste
- Provides visibility into framework effectiveness
- Establishes foundation for future hook integration
METRICS FROM ANALYTICS:
- Active Instructions: 40
- Voluntary Compliance: 97.2%
- Hook Enforcement: 75.0%
- Recorded Violations: 2
- Tokens Wasted: 75,000
NEXT STEPS:
- Integrate LoopDetector into MetacognitiveVerifier.service.js
- Add Pre-Deployment Validation to Bash command validator hook
- Wire User Suggestion Tracker into BoundaryEnforcer checks
- Document successful compliance patterns (7 STRATEGIC instructions at 100%)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-10-20 20:41:10 +13:00 |
|