Navegador

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

Keyboard Shortcuts

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