Commit graph

2 commits

Author SHA1 Message Date
TheFlow
da7eee39fb fix: resolve CrossReferenceValidator conflict detection and enhance parameter extraction
CrossReferenceValidator improvements (31% → 96.4% pass rate):

1. Context Format Handling
   - Support both context.messages (production) and context.recent_instructions (testing)
   - Fix relevance calculation to handle actions without descriptions
   - Add null safety to _semanticSimilarity()

2. Multiple Conflicts Detection
   - Change _checkConflict() to return array of ALL conflicts
   - Detect all parameter mismatches in single instruction (port, host, database)

InstructionPersistenceClassifier parameter extraction enhancements:

3. Smart Protocol Extraction
   - Context-aware scoring: positive keywords (always, prefer) vs negative (never, not)
   - "never use HTTP, always use HTTPS" → protocol: "https" (correct)

4. Confirmation Flag Handling
   - Double-negative support: "never X without confirmation" → confirmed: true
   - Handles: with/without confirmation, require/skip confirmation

5. Additional Parameters
   - Frameworks: React, Vue, Angular, Svelte, Ember, Backbone
   - Module types: ESM, CommonJS
   - Patterns: callback, promise, async/await
   - Host/collection/package names

6. Regex Fixes
   - Add word boundaries to port, database, collection patterns
   - Prevent false matches like "MongoDB on" → database: "on"

Test Results:
- CrossReferenceValidator: 27/28 passing (96.4%)
- Overall: 87/192 (45.3%, +8 tests from 79/192)
- Core 27027 failure prevention now working

Remaining: 1 test expects REJECTED for MEDIUM persistence instruction, gets WARNING (correct behavior)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 01:46:04 +13:00
TheFlow
47818bade1 feat: add governance document and core utilities
Core Values (TRA-VAL-0001):
- Adapt STR-VAL-0001 for Tractatus AI Safety Framework
- Define 6 core values: Sovereignty, Transparency, Harmlessness,
  Human Judgment Primacy, Community, Biodiversity
- Establish AI governance principles and decision framework
- Document Te Tiriti commitment as strategic baseline
- Create values alignment metrics and review process

Database Utilities:
- MongoDB connection with retry logic and health checks
- Singleton pattern for connection management
- Comprehensive error handling and reconnection

Logger Utility:
- Winston-based logging (console + file)
- Request logging middleware
- Error log separation
- Configurable log levels

JWT Utility:
- Token generation and verification
- Secure admin authentication
- Header extraction methods

Markdown Utility:
- Markdown to HTML conversion with syntax highlighting
- XSS protection via sanitization
- Table of contents extraction
- Front matter parsing
- Slug generation

Status: Core infrastructure utilities complete
2025-10-06 23:34:40 +13:00