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
Markdown
# 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.