Fixes CI pipeline failures caused by missing Prisma Client generation and TypeScript type safety issues. Added Prisma generation step to CI pipeline, installed missing type dependencies, and resolved 40+ exactOptionalPropertyTypes violations across service layer.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comprehensive architecture document for M4 quality enforcement pattern.
Problem (L-015 Evidence):
- AI agents claim done prematurely (60-70% complete)
- Defer work as "incremental" or "follow-up PRs"
- Identical language across sessions ("good enough for now")
- Happens even in YOLO mode with full permissions
- Cannot be fixed with instructions or prompting
Evidence:
- uConnect agent: 853 warnings deferred
- Mosaic Stack agent: 509 lint errors + 73 test failures deferred
- Both required manual override to continue
- Pattern observed across multiple agents and sessions
Solution: Non-AI Coordinator Pattern
- AI agents do the work
- Non-AI orchestrator enforces quality gates
- Gates are programmatic (build, lint, test, coverage)
- Agents cannot negotiate or bypass
- Forced continuation when gates fail
- Rejection with specific failure messages
Documentation Includes:
- Problem statement with evidence
- Why non-AI enforcement is necessary
- Complete architecture design
- Component specifications
- Quality gate types and configuration
- State machine and workflow
- Forced continuation prompt templates
- Integration points
- Monitoring and metrics
- Troubleshooting guide
- Implementation examples
Related Issues: #134-141 (M4-MoltBot)
Agents working on M4 issues now have complete context
and rationale without needing jarvis-brain access.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Issues resolved:
- #68: pgvector Setup
* Added pgvector vector index migration for knowledge_embeddings
* Vector index uses HNSW algorithm with cosine distance
* Optimized for 1536-dimension OpenAI embeddings
- #69: Embedding Generation Pipeline
* Created EmbeddingService with OpenAI integration
* Automatic embedding generation on entry create/update
* Batch processing endpoint for existing entries
* Async generation to avoid blocking API responses
* Content preparation with title weighting
- #70: Semantic Search API
* POST /api/knowledge/search/semantic - pure vector search
* POST /api/knowledge/search/hybrid - RRF combined search
* POST /api/knowledge/embeddings/batch - batch generation
* Comprehensive test coverage
* Full documentation in docs/SEMANTIC_SEARCH.md
Technical details:
- Uses OpenAI text-embedding-3-small model (1536 dims)
- HNSW index for O(log n) similarity search
- Reciprocal Rank Fusion for hybrid search
- Graceful degradation when OpenAI not configured
- Async embedding generation for performance
Configuration:
- Added OPENAI_API_KEY to .env.example
- Optional feature - disabled if API key not set
- Falls back to keyword search in hybrid mode
- Created KNOWLEDGE_USER_GUIDE.md with comprehensive user documentation
- Getting started, creating entries, wiki-links
- Tags and organization, search capabilities
- Import/export, version history, graph visualization
- Tips, best practices, and permissions
- Created KNOWLEDGE_API.md with complete REST API reference
- All endpoints with request/response formats
- Authentication and permissions
- Detailed examples with curl and JavaScript
- Error responses and validation
- Created KNOWLEDGE_DEV.md with developer documentation
- Architecture overview and module structure
- Database schema with all models
- Service layer implementation details
- Caching strategy and performance
- Wiki-link parsing and resolution system
- Testing guide and contribution guidelines
- Updated README.md with Knowledge Module section
- Feature overview and quick examples
- Links to detailed documentation
- Performance metrics
- Added knowledge management to overview
All documentation includes:
- Real examples from codebase
- Code snippets and API calls
- Best practices and workflows
- Cross-references between docs
Strict enforcement is now ACTIVE and blocking commits.
Updated documentation to reflect:
- Pre-commit hooks are actively blocking violations
- Package-level enforcement strategy
- How developers should handle blocked commits
- Next steps for incremental cleanup
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: Strict lint enforcement is now ACTIVE
Pre-commit hooks now block commits if:
- Affected package has ANY lint errors or warnings
- Affected package has ANY type errors
Impact: If you touch a file in a package with existing violations,
you MUST fix ALL violations in that package before committing.
This forces incremental cleanup:
- Work in @mosaic/shared → Fix all @mosaic/shared violations
- Work in @mosaic/api → Fix all @mosaic/api violations
- Work in clean packages → No extra work required
Fixed regex to handle absolute paths from lint-staged.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Strict enforcement now active:
- Format all changed files (auto-fix)
- Lint entire packages that have changed files
- Type-check affected packages
- Block commit if ANY warnings or errors
Impact: If you touch a file in a package with existing violations,
you must clean up the entire package before committing.
This forces incremental cleanup while preventing new violations.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements two key knowledge module features:
**#62 - Backlinks Display:**
- Added BacklinksList component to show entries that link to current entry
- Fetches backlinks from /api/knowledge/entries/:slug/backlinks
- Displays entry title, summary, and link context
- Clickable links to navigate to linking entries
- Loading, error, and empty states
**#64 - Wiki-Link Rendering:**
- Added WikiLinkRenderer component to parse and render wiki-links
- Supports [[slug]] and [[slug|display text]] syntax
- Converts wiki-links to clickable navigation links
- Distinct styling (blue color, dotted underline)
- XSS protection via HTML escaping
- Memoized HTML processing for performance
**Components:**
- BacklinksList.tsx - Backlinks display with empty/loading/error states
- WikiLinkRenderer.tsx - Wiki-link parser and renderer
- Updated EntryViewer.tsx to use WikiLinkRenderer
- Integrated BacklinksList into entry detail page
**API:**
- Added fetchBacklinks() function in knowledge.ts
- Added KnowledgeBacklink type to shared types
**Tests:**
- Comprehensive tests for BacklinksList (8 tests)
- Comprehensive tests for WikiLinkRenderer (14 tests)
- All tests passing with Vitest
**Type Safety:**
- Strict TypeScript compliance
- No 'any' types
- Proper error handling
- Add POST /api/knowledge/import endpoint for .md and .zip files
- Add GET /api/knowledge/export endpoint with markdown/json formats
- Import parses frontmatter (title, tags, status, visibility)
- Export includes frontmatter in markdown format
- Add ImportExportActions component with drag-and-drop UI
- Add import progress dialog with success/error summary
- Add export dropdown with format selection
- Include comprehensive test suite
- Support bulk import with detailed error reporting
- Fixed TypeScript error: object possibly undefined in useGraphData.ts
- Removed console.error and console.warn statements
- Replaced all 'any' types with proper interface types
- Added proper type definitions for API DTOs (EntryDto, CreateEntryDto, UpdateEntryDto, etc.)
- Improved type safety across mindmap integration components
- Fixed TypeScript exactOptionalPropertyTypes errors in chat components
- Removed console.error statements (errors are handled via state)
- Fixed type compatibility issues with undefined vs null values
- All chat-related files now pass strict TypeScript checks
- Added EntryVersion model with author relation
- Implemented automatic versioning on entry create/update
- Added API endpoints for version history:
- GET /api/knowledge/entries/:slug/versions - list versions
- GET /api/knowledge/entries/:slug/versions/:version - get specific
- POST /api/knowledge/entries/:slug/restore/:version - restore version
- Created VersionHistory.tsx component with timeline view
- Added History tab to entry detail page
- Supports version viewing and restoring
- Includes comprehensive tests for version operations
- All TypeScript types are explicit and type-safe
- Created API clients for LLM chat (/api/llm/chat) and Ideas (/api/ideas)
- Implemented useChat hook for conversation state management
- Connected Chat component to backend with full CRUD operations
- Integrated ConversationSidebar with conversation fetching
- Added automatic conversation persistence after each message
- Integrated WebSocket for connection status
- Used existing better-auth for authentication
- All TypeScript strict mode compliant (no any types)
Deliverables:
✅ Working chat interface at /chat route
✅ Conversations save to database via Ideas API
✅ Real-time WebSocket connection
✅ Clean TypeScript (no errors)
✅ Full conversation loading and persistence
See CHAT_INTEGRATION_SUMMARY.md for detailed documentation.