UNPKG

oneie

Version:

Build apps, websites, and AI agents in English. Zero-interaction setup for AI agents (Claude Code, Cursor, Windsurf). Download to your computer, run in the cloud, deploy to the edge. Open source and free forever.

244 lines (183 loc) • 8.35 kB
# Ontology Structure Validation Hook - Update Summary **Date:** 2025-11-03 **Status:** āœ… Complete and Tested **Hook:** `.claude/hooks/validate-ontology-structure.py` ## Changes Made ### 1. Enhanced Documentation Header Added comprehensive documentation explaining: - The 6-dimension ontology (groups, people, things, connections, events, knowledge) - Database implementation (5 tables mapping to 6 dimensions) - Expected directory structure for `/one/` - Clarification that people are stored as things with `type: 'creator'` ### 2. Updated Dimension Definitions Each dimension now includes: - **Simplified aliases** (removed variants like "organisations/organizations") - **Clear descriptions** aligned with ontology.md - **Example files** showing what belongs in each dimension - **Type counts** (66 thing types, 25 connection types, 67 event types) - **Special notes** (e.g., people stored as things with role metadata) #### Dimension Structure: ``` šŸ“ /one/groups/ Hierarchical containers - friend circles → DAOs → governments Examples: groups.md, revenue.md, vision.md šŸ“ /one/people/ Authorization & governance - roles, permissions, organization Examples: people.md, roles.md, governance.md Note: People are stored as things (type: 'creator') with role metadata šŸ“ /one/things/ All entities - users, agents, content, tokens, courses (66 types) Examples: agents/, plans/, specifications/ šŸ“ /one/connections/ All relationships - owns, purchased, enrolled_in (25 types) Examples: protocols.md, workflow.md, integrations/ šŸ“ /one/events/ All actions - created, updated, purchased, completed (67 types) Examples: deployment/, releases/, test-results/ šŸ“ /one/knowledge/ AI understanding - embeddings, search, RAG (labels, chunks, vectors) Examples: ontology.md, architecture.md, patterns/ ``` ### 3. Added EXPECTED_STRUCTURE Constant New constant defining what should go in each dimension directory: - **groups:** Group definitions, hierarchies, vision, strategy, revenue - **people:** Roles, governance, team structure, organization - **things:** Entity specifications, agent definitions, plans, components - **connections:** Protocols, workflows, integrations, relationships, patterns - **events:** Deployment plans, release notes, test results, agent execution summaries - **knowledge:** Architecture docs, implementation guides, patterns, rules, tutorials ### 4. Improved Error Messages Enhanced error output to include: - Visual separators (======= lines) - Emoji indicators for each dimension (šŸ“) - Example files for each dimension - Notes about special cases (e.g., people as things) - Clear database implementation mapping (5 tables → 6 dimensions) - Current file location and detected dimension ### 5. Created Comprehensive Test Suite New file: `.claude/hooks/test-validate-ontology.sh` Tests 14 scenarios: - āœ… Valid files in all 6 dimensions - āœ… Invalid dimension detection - āœ… Invalid filename detection (uppercase, spaces, CamelCase) - āœ… Files outside `/one/` are ignored - āœ… All tests passing ## Ontology Alignment Verification ### āœ… Aligned with ontology.md 1. **6 Dimensions Confirmed:** - groups - Hierarchical containers (friend circles → governments) - people - Authorization & governance (who can do what) - things - All entities (66 types) - connections - All relationships (25 types) - events - All actions (67 types) - knowledge - AI understanding (embeddings, search, RAG) 2. **Database Implementation (5 tables):** - groups table → groups dimension āœ… - things table → things + people dimensions āœ… - connections table → connections dimension āœ… - events table → events dimension āœ… - knowledge table → knowledge dimension āœ… 3. **Key Insight: People as Things** - People are stored in the `things` table with `type: 'creator'` - The `/one/people/` directory contains role/governance docs - Hook correctly notes this relationship ### āœ… Directory Structure Validation The hook validates that all files in `/one/` follow the ontology: ``` /one/ ā”œā”€ā”€ groups/ āœ… Group definitions, vision, strategy ā”œā”€ā”€ people/ āœ… Roles, governance, organization ā”œā”€ā”€ things/ āœ… Entity specs, agents, plans ā”œā”€ā”€ connections/ āœ… Protocols, workflows, integrations ā”œā”€ā”€ events/ āœ… Deployment, releases, test results └── knowledge/ āœ… Architecture, patterns, guides ``` ### āœ… Validation Rules 1. **File location:** Must be in one of the 6 dimension directories 2. **File naming:** kebab-case only (lowercase-with-hyphens.md) 3. **File extensions:** .md, .yaml, .yml, .json only 4. **Thing types:** Validates against 66 defined types 5. **Connection types:** Validates against 25 relationship types 6. **Event types:** Validates against 67 action types 7. **Protocol metadata:** Ensures protocols stored in metadata.protocol field ## Test Results ```bash $ ./.claude/hooks/test-validate-ontology.sh ======================================================================= Testing Ontology Structure Validation Hook ======================================================================= Testing valid files in each dimension... āœ… Valid file in /one/groups/ āœ… Valid file in /one/people/ āœ… Valid file in /one/things/ āœ… Valid file in /one/connections/ āœ… Valid file in /one/events/ āœ… Valid file in /one/knowledge/ Testing invalid dimensions... āœ… Invalid dimension /one/invalid/ (correctly failed) āœ… File directly in /one/ (correctly failed) Testing invalid filenames... āœ… Uppercase filename (correctly failed) āœ… Spaces in filename (correctly failed) āœ… CamelCase filename (correctly failed) Testing files outside /one (should be ignored)... āœ… File in /web (correctly ignored) āœ… File in /backend (correctly ignored) āœ… File in root (correctly ignored) ======================================================================= Test Summary ======================================================================= Total tests: 14 Passed: 14 Failed: 0 āœ… All tests passed! ``` ## Usage ### Manual Testing ```bash # Test the hook manually python3 .claude/hooks/validate-ontology-structure.py <<EOF { "hook_event_name": "PostToolUse", "tool_name": "Write", "tool_input": { "file_path": "/path/to/file.md", "content": "# Test content" } } EOF ``` ### Run Test Suite ```bash # Run all tests ./.claude/hooks/test-validate-ontology.sh ``` ### Integration with Claude Code The hook automatically runs when: - Using the `Write` tool on files in `/one/` - Using the `Edit` tool on files in `/one/` - Using the `MultiEdit` tool on files in `/one/` Files outside `/one/` are ignored and not validated. ## Benefits 1. **Enforces ontology structure** - Prevents misplaced documentation 2. **Maintains consistency** - All files follow kebab-case naming 3. **Educates developers** - Clear error messages explain the ontology 4. **Automated validation** - Catches errors before they're committed 5. **Comprehensive testing** - 14 test cases ensure reliability 6. **Non-intrusive** - Only validates `/one/` directory, ignores others ## Future Enhancements Potential improvements for future iterations: 1. **Auto-fix mode** - Automatically move misplaced files to correct dimensions 2. **Content validation** - Deeper validation of file contents against schemas 3. **Integration with git hooks** - Pre-commit validation 4. **VS Code extension** - Real-time validation in editor 5. **Documentation links** - Suggest relevant ontology docs based on errors ## Files Modified - `.claude/hooks/validate-ontology-structure.py` - Updated validation logic and error messages ## Files Created - `.claude/hooks/test-validate-ontology.sh` - Comprehensive test suite - `.claude/hooks/validate-ontology-structure-summary.md` - This summary document ## Conclusion The ontology validation hook is now fully aligned with the 6-dimension ontology specification in `/one/knowledge/ontology.md`. It enforces proper directory structure, validates file naming conventions, and provides clear, educational error messages that help developers understand the ontology structure. **Status: āœ… Production Ready** All tests passing. Hook is active and validating files in `/one/` directory.