Navegador

navegador / navegador / graph / schema.py
Blame History Raw 132 lines
1
"""
2
Graph schema — node labels and edge types for the navegador property graph.
3
4
Navegador maintains two complementary layers in one graph:
5
6
CODE layer — AST-derived structure (files, functions, classes, calls, imports)
7
KNOWLEDGE layer — business context (concepts, rules, decisions, wiki, people)
8
9
The two layers are connected by IMPLEMENTS, DOCUMENTS, GOVERNS, and ANNOTATES
10
edges, so agents can traverse from a function straight to the business rule it
11
enforces, or from a wiki page down to the exact code that implements it.
12
"""
13
14
from enum import StrEnum
15
16
17
class NodeLabel(StrEnum):
18
# ── Code layer ────────────────────────────────────────────────────────────
19
Repository = "Repository"
20
File = "File"
21
Module = "Module"
22
Class = "Class"
23
Function = "Function"
24
Method = "Method"
25
Variable = "Variable"
26
Import = "Import"
27
Decorator = "Decorator"
28
29
# ── Knowledge layer ───────────────────────────────────────────────────────
30
Domain = "Domain" # logical grouping (auth, billing, notifications…)
31
Concept = "Concept" # a named business entity or idea
32
Rule = "Rule" # a constraint, invariant, or business rule
33
Decision = "Decision" # an architectural or product decision + rationale
34
WikiPage = "WikiPage" # a page from the project wiki (GitHub, Confluence…)
35
Person = "Person" # a contributor, owner, or stakeholder
36
37
38
class EdgeType(StrEnum):
39
# ── Code structural ───────────────────────────────────────────────────────
40
CONTAINS = "CONTAINS" # File/Class -CONTAINS-> Function/Class/Variable
41
DEFINES = "DEFINES" # Module -DEFINES-> Class/Function
42
IMPORTS = "IMPORTS" # File -IMPORTS-> Module/File
43
DEPENDS_ON = "DEPENDS_ON" # module/package-level dependency
44
CALLS = "CALLS" # Function -CALLS-> Function
45
REFERENCES = "REFERENCES" # Function/Class -REFERENCES-> Variable/Class
46
INHERITS = "INHERITS" # Class -INHERITS-> Class
47
IMPLEMENTS = "IMPLEMENTS" # Class/Function -IMPLEMENTS-> Concept/Rule
48
DECORATES = "DECORATES" # Decorator -DECORATES-> Function/Class
49
50
# ── Knowledge structural ──────────────────────────────────────────────────
51
BELONGS_TO = "BELONGS_TO" # any node -BELONGS_TO-> Domain
52
RELATED_TO = "RELATED_TO" # Concept -RELATED_TO-> Concept (bidirectional intent)
53
GOVERNS = "GOVERNS" # Rule -GOVERNS-> Concept/Function/Class
54
DOCUMENTS = "DOCUMENTS" # WikiPage/Decision -DOCUMENTS-> any node
55
ANNOTATES = "ANNOTATES" # Concept/Rule -ANNOTATES-> code node (lightweight link)
56
ASSIGNED_TO = "ASSIGNED_TO" # any node -ASSIGNED_TO-> Person (ownership)
57
DECIDED_BY = "DECIDED_BY" # Decision -DECIDED_BY-> Person
58
59
60
# ── Property keys per node label ──────────────────────────────────────────────
61
62
NODE_PROPS = {
63
# Code layer
64
NodeLabel.Repository: ["name", "path", "language", "description"],
65
NodeLabel.File: ["name", "path", "language", "size", "line_count", "content_hash"],
66
NodeLabel.Module: ["name", "file_path", "docstring"],
67
NodeLabel.Class: ["name", "file_path", "line_start", "line_end", "docstring", "source"],
68
NodeLabel.Function: [
69
"name",
70
"file_path",
71
"line_start",
72
"line_end",
73
"docstring",
74
"source",
75
"signature",
76
],
77
NodeLabel.Method: [
78
"name",
79
"file_path",
80
"line_start",
81
"line_end",
82
"docstring",
83
"source",
84
"signature",
85
"class_name",
86
],
87
NodeLabel.Variable: ["name", "file_path", "line_start", "type_annotation"],
88
NodeLabel.Import: ["name", "file_path", "line_start", "module", "alias"],
89
NodeLabel.Decorator: ["name", "file_path", "line_start"],
90
# Knowledge layer
91
NodeLabel.Domain: ["name", "description"],
92
NodeLabel.Concept: [
93
"name",
94
"description",
95
"domain",
96
"status",
97
"rules",
98
"examples",
99
"wiki_refs",
100
],
101
NodeLabel.Rule: [
102
"name",
103
"description",
104
"domain",
105
"severity", # info|warning|critical
106
"rationale",
107
"examples",
108
],
109
NodeLabel.Decision: [
110
"name",
111
"description",
112
"domain",
113
"status", # proposed|accepted|deprecated
114
"rationale",
115
"alternatives",
116
"date",
117
],
118
NodeLabel.WikiPage: [
119
"name",
120
"url",
121
"source", # github|confluence|notion|local
122
"content",
123
"updated_at",
124
],
125
NodeLabel.Person: [
126
"name",
127
"email",
128
"role",
129
"team",
130
],
131
}
132

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button