{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Episteme Knowledge Graph Schema",
"description": "Metadata schema for knowledge graph entities and relations",
"version": "0.1.0",
"definitions": {
"entity": {
"type": "object",
"required": ["id", "type", "title"],
"properties": {
"id": {
"type": "string",
"pattern": "^(DP|RF|LAW|SMELL|TK)-[0-9]{2,3}(?:-[A-Z])?$",
"description": "Unique identifier: DP=Design Pattern, RF=Refactoring, LAW=Software Law/Principle, SMELL=Code Smell, TK=Tacit Knowledge/Insight"
},
"type": {
"type": "string",
"enum": ["pattern", "refactoring", "law", "smell", "insight"]
},
"file_path": {
"type": "string",
"description": "Relative path from raw/ directory"
},
"title": {
"type": "string"
},
"name": {
"type": "string",
"description": "Alternative display name (used by smell entities)"
},
"description": {
"type": "string"
},
"category": {
"type": "string",
"description": "Subcategory: creational/structural/behavioral, bloater/dispensable/coupler, etc."
},
"tags": {
"type": "array",
"items": { "type": "string" }
},
"source": {
"oneOf": [
{ "type": "string" },
{ "type": "object" },
{ "type": "null" }
],
"description": "Source metadata"
}
}
},
"relation": {
"type": "object",
"properties": {
"solves": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of problems/smells this entity solves"
},
"solved_by": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of patterns/refactorings that solve this entity"
},
"enforces": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of laws/principles this entity enforces"
},
"enforced_by": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of entities that enforce this law/principle"
},
"violates": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of laws/principles this entity violates"
},
"violated_by": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of entities that violate this law/principle"
},
"related_to": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of similar/alternative entities"
},
"derives_from": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of canonical entities this insight derives from (user insights only)"
},
"applies_to": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of entities this insight applies to (user insights only)"
},
"supersedes": {
"type": "array",
"items": { "type": "string" },
"description": "IDs of entities superseded by this one"
},
"requires": {
"type": "array",
"items": { "type": "string" },
"description": "Reserved for future use (currently empty in data)"
},
"enables": {
"type": "array",
"items": { "type": "string" },
"description": "Reserved for future use (currently empty in data)"
}
}
},
"context": {
"type": "object",
"properties": {
"when_to_use": {
"type": "array",
"items": { "type": "string" },
"description": "Scenarios where this should be applied"
},
"when_not_to_use": {
"type": "array",
"items": { "type": "string" },
"description": "Anti-scenarios where this should be avoided"
},
"symptoms": {
"type": "array",
"items": { "type": "string" },
"description": "Code smells or indicators (for smells/refactorings)"
},
"benefits": {
"type": "array",
"items": { "type": "string" }
},
"drawbacks": {
"type": "array",
"items": { "type": "string" }
}
}
}
},
"type": "object",
"patternProperties": {
"^(DP|RF|LAW|SMELL|TK)-[0-9]{2,3}(?:-[A-Z])?$": {
"allOf": [
{ "$ref": "#/definitions/entity" },
{
"properties": {
"relations": { "$ref": "#/definitions/relation" },
"context": { "$ref": "#/definitions/context" }
}
}
]
}
}
}