tortoise-graph 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. tortoise/__init__.py +45 -0
  2. tortoise/__main__.py +1865 -0
  3. tortoise/analyze.py +473 -0
  4. tortoise/api.py +303 -0
  5. tortoise/archived/search_legacy.py +31 -0
  6. tortoise/audit.py +236 -0
  7. tortoise/audit_events.py +284 -0
  8. tortoise/auth.py +107 -0
  9. tortoise/backup.py +155 -0
  10. tortoise/config.py +99 -0
  11. tortoise/connector_loader.py +74 -0
  12. tortoise/connectors/__init__.py +5 -0
  13. tortoise/connectors/github.py +432 -0
  14. tortoise/connectors/github_docs.py +146 -0
  15. tortoise/connectors/linear.py +199 -0
  16. tortoise/connectors/slack.py +222 -0
  17. tortoise/consistency.py +132 -0
  18. tortoise/crypto.py +52 -0
  19. tortoise/deployment.py +62 -0
  20. tortoise/domain_loader.py +142 -0
  21. tortoise/dream.py +153 -0
  22. tortoise/embedded_reaper.py +744 -0
  23. tortoise/embeddings.py +227 -0
  24. tortoise/ep.py +534 -0
  25. tortoise/exceptions.py +16 -0
  26. tortoise/extractor.py +945 -0
  27. tortoise/hosted_api.py +1982 -0
  28. tortoise/hosted_middleware.py +22 -0
  29. tortoise/idempotency.py +39 -0
  30. tortoise/ids.py +23 -0
  31. tortoise/indexer/github_indexer.py +129 -0
  32. tortoise/ingest.py +614 -0
  33. tortoise/log.py +29 -0
  34. tortoise/m0.py +50 -0
  35. tortoise/mcp_auth.py +337 -0
  36. tortoise/mcp_client.py +108 -0
  37. tortoise/mcp_server.py +1356 -0
  38. tortoise/memory_orchestrator.py +492 -0
  39. tortoise/memory_scope.py +15 -0
  40. tortoise/migrate_db.py +244 -0
  41. tortoise/migrate_kinds.py +141 -0
  42. tortoise/mining.py +338 -0
  43. tortoise/models.py +109 -0
  44. tortoise/monitoring.py +133 -0
  45. tortoise/navigation.py +216 -0
  46. tortoise/pack_registry.py +767 -0
  47. tortoise/pipeline_cli.py +197 -0
  48. tortoise/projection/__init__.py +913 -0
  49. tortoise/projection/edges.py +311 -0
  50. tortoise/projection/entities.py +521 -0
  51. tortoise/projection/grounding.py +95 -0
  52. tortoise/projection/propagation.py +114 -0
  53. tortoise/projection.py +37 -0
  54. tortoise/quadrature.py +90 -0
  55. tortoise/query_suggestions.py +194 -0
  56. tortoise/quota.py +163 -0
  57. tortoise/ranking.py +280 -0
  58. tortoise/render.py +108 -0
  59. tortoise/scripts/manifest.py +67 -0
  60. tortoise/sdk.py +4713 -0
  61. tortoise/search_engine.py +887 -0
  62. tortoise/security.py +268 -0
  63. tortoise/selfhost.py +157 -0
  64. tortoise/selfhost_api.py +201 -0
  65. tortoise/session_continuity.py +82 -0
  66. tortoise/session_indexer.py +569 -0
  67. tortoise/shared_state/__init__.py +20 -0
  68. tortoise/shared_state/concurrency.py +113 -0
  69. tortoise/shared_state/event_log.py +192 -0
  70. tortoise/shared_state/events.py +150 -0
  71. tortoise/shared_state/monitoring.py +87 -0
  72. tortoise/shared_state/recovery.py +126 -0
  73. tortoise/shared_state/tests/__init__.py +15 -0
  74. tortoise/shared_state/tests/test_concurrency.py +123 -0
  75. tortoise/shared_state/tests/test_events.py +145 -0
  76. tortoise/shared_state/tests/test_monitoring.py +54 -0
  77. tortoise/shared_state/tests/test_recovery.py +181 -0
  78. tortoise/source_credibility.py +306 -0
  79. tortoise/svbp.py +446 -0
  80. tortoise/taxonomy.py +71 -0
  81. tortoise/test_cross_ontology.py +180 -0
  82. tortoise/test_tortoise_client.py +206 -0
  83. tortoise/tool_registry.py +805 -0
  84. tortoise/tortoise_client.py +262 -0
  85. tortoise/verify_ontology.py +154 -0
  86. tortoise/version_vector.py +97 -0
  87. tortoise/weights.py +61 -0
  88. tortoise_graph-0.2.0.dist-info/METADATA +152 -0
  89. tortoise_graph-0.2.0.dist-info/RECORD +93 -0
  90. tortoise_graph-0.2.0.dist-info/WHEEL +5 -0
  91. tortoise_graph-0.2.0.dist-info/entry_points.txt +4 -0
  92. tortoise_graph-0.2.0.dist-info/licenses/LICENSE +95 -0
  93. tortoise_graph-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,197 @@
1
+ """Pipeline CLI — manage entity extraction pipelines.
2
+
3
+ Usage:
4
+ tortoise pipeline list — show all pipelines and their status
5
+ tortoise pipeline enable <name> — enable a pipeline
6
+ tortoise pipeline disable <name> — disable a pipeline
7
+ tortoise pipeline status <name> — show detailed status for one pipeline
8
+ tortoise pipeline run <name> — trigger a pipeline manually
9
+
10
+ Config: config/pipelines.yaml (ONTOLOGY_v2.5 §1.1 entity kinds, PM domain extension)
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import os
16
+ import sys
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ import yaml
21
+
22
+ CONFIG_PATH = Path(__file__).resolve().parent.parent / "config" / "pipelines.yaml"
23
+ _PROJECT_ROOT = Path(__file__).resolve().parent.parent
24
+
25
+
26
+ def _load() -> dict:
27
+ if not CONFIG_PATH.exists():
28
+ return {"version": 1, "pipelines": {}}
29
+ return yaml.safe_load(CONFIG_PATH.read_text()) or {"version": 1, "pipelines": {}}
30
+
31
+
32
+ def _save(data: dict) -> None:
33
+ CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
34
+ CONFIG_PATH.write_text(yaml.dump(data, default_flow_style=False, sort_keys=False))
35
+
36
+
37
+ def cmd_list() -> None:
38
+ """List all pipelines with status."""
39
+ data = _load()
40
+ pipelines = data.get("pipelines", {})
41
+ if not pipelines:
42
+ print("No pipelines configured.")
43
+ return
44
+
45
+ print(f"{'PIPELINE':<25} {'ENABLED':<8} {'SOURCE':<15} {'TRIGGER':<12}")
46
+ print("-" * 60)
47
+ for name, cfg in sorted(pipelines.items()):
48
+ enabled = "✓" if cfg.get("enabled") else "—"
49
+ source = cfg.get("source", "?")
50
+ trigger = cfg.get("trigger", "manual")
51
+ print(f"{name:<25} {enabled:<8} {source:<15} {trigger:<12}")
52
+
53
+
54
+ def cmd_enable(name: str) -> None:
55
+ data = _load()
56
+ if name not in data.get("pipelines", {}):
57
+ print(f"Pipeline '{name}' not found in config.")
58
+ sys.exit(1)
59
+ data["pipelines"][name]["enabled"] = True
60
+ _save(data)
61
+ print(f"Enabled: {name}")
62
+
63
+
64
+ def cmd_disable(name: str) -> None:
65
+ data = _load()
66
+ if name not in data.get("pipelines", {}):
67
+ print(f"Pipeline '{name}' not found in config.")
68
+ sys.exit(1)
69
+ data["pipelines"][name]["enabled"] = False
70
+ _save(data)
71
+ print(f"Disabled: {name}")
72
+
73
+
74
+ def cmd_status(name: str) -> None:
75
+ data = _load()
76
+ cfg = data.get("pipelines", {}).get(name)
77
+ if not cfg:
78
+ print(f"Pipeline '{name}' not found.")
79
+ return
80
+
81
+ print(f"Pipeline: {name}")
82
+ print(f" Enabled: {cfg.get('enabled')}")
83
+ print(f" Source: {cfg.get('source')} ({cfg.get('sourceKind', '?')})")
84
+ print(f" Trigger: {cfg.get('trigger', 'manual')}")
85
+ em = cfg.get("entity_mapping", {})
86
+ if em:
87
+ print(f" Entity mappings:")
88
+ if em.get("repo_to_team"):
89
+ for repo, team in em["repo_to_team"].items():
90
+ print(f" repo {repo} → team {team}")
91
+ if em.get("label_to_team"):
92
+ for label, team in em["label_to_team"].items():
93
+ print(f" label {label} → team {team}")
94
+ if em.get("user_to_role"):
95
+ for user, role in em["user_to_role"].items():
96
+ print(f" user {user} → role {role}")
97
+
98
+
99
+ def cmd_run(name: str) -> None:
100
+ data = _load()
101
+ cfg = data.get("pipelines", {}).get(name)
102
+ if not cfg:
103
+ print(f"Pipeline '{name}' not found.")
104
+ sys.exit(1)
105
+ if not cfg.get("enabled"):
106
+ print(f"Pipeline '{name}' is disabled. Enable it first: tortoise pipeline enable {name}")
107
+ sys.exit(1)
108
+
109
+ module_path = cfg.get("connector", {}).get("module", "")
110
+ class_name = cfg.get("connector", {}).get("class", "")
111
+ if not module_path or not class_name:
112
+ print(f"Pipeline '{name}' has no connector configured.")
113
+ sys.exit(1)
114
+
115
+ print(f"Running {name} pipeline...")
116
+ try:
117
+ import importlib
118
+ import sys as _sys
119
+ if str(_PROJECT_ROOT) not in _sys.path:
120
+ _sys.path.insert(0, str(_PROJECT_ROOT))
121
+
122
+ mod = importlib.import_module(module_path)
123
+ conn_cls = getattr(mod, class_name)
124
+ connector = conn_cls(config=cfg.get("connector", {}).get("config"))
125
+ if hasattr(connector, "poll"):
126
+ events = connector.poll()
127
+ print(f" Got {len(events)} events")
128
+ if hasattr(connector, "ingest"):
129
+ # Create projection and ingest
130
+ from tortoise.projection import FalkorProjection
131
+ from tortoise.config import resolve_db_path
132
+ proj = FalkorProjection(resolve_db_path())
133
+ count = connector.ingest(proj)
134
+ print(f" Ingested {count} entities into FalkorDB")
135
+ # Auto-dispatch: create missions + cards from ingested Objects
136
+ try:
137
+ import sys as _s
138
+ _s.path.insert(0, str(Path(__file__).resolve().parent.parent.parent / "operations" / "coordination"))
139
+ from mission_registry import MissionRegistry
140
+ from coordinator import CoordinatorDaemon
141
+ reg = MissionRegistry()
142
+ d = CoordinatorDaemon(reg)
143
+ missions = d.ingest_from_graph()
144
+ if missions:
145
+ print(f" Auto-dispatched {missions} missions into cards")
146
+ except Exception:
147
+ pass # coordinator not available — ingestion-only mode
148
+ else:
149
+ print(" Connector has no ingest method — events logged only")
150
+ else:
151
+ print(" Connector has no poll method")
152
+ except ImportError as e:
153
+ print(f" Error: {e}")
154
+ print(f" Is the connector installed? Module: {module_path}")
155
+ print(f" Check that {_PROJECT_ROOT} is on PYTHONPATH")
156
+ except Exception as e:
157
+ print(f" Error running {name}: {e}")
158
+
159
+
160
+ # ── CLI ───────────────────────────────────────────────────────
161
+
162
+ def main(argv: list[str] | None = None) -> None:
163
+ ap = argparse.ArgumentParser(description="Tortoise pipeline management")
164
+ sub = ap.add_subparsers(dest="command")
165
+
166
+ sub.add_parser("list", help="List all pipelines")
167
+
168
+ ep = sub.add_parser("enable", help="Enable a pipeline")
169
+ ep.add_argument("name", help="Pipeline name")
170
+
171
+ dp = sub.add_parser("disable", help="Disable a pipeline")
172
+ dp.add_argument("name", help="Pipeline name")
173
+
174
+ sp = sub.add_parser("status", help="Show pipeline status")
175
+ sp.add_argument("name", help="Pipeline name")
176
+
177
+ rp = sub.add_parser("run", help="Run a pipeline manually")
178
+ rp.add_argument("name", help="Pipeline name")
179
+
180
+ args = ap.parse_args(argv)
181
+
182
+ if args.command == "list":
183
+ cmd_list()
184
+ elif args.command == "enable":
185
+ cmd_enable(args.name)
186
+ elif args.command == "disable":
187
+ cmd_disable(args.name)
188
+ elif args.command == "status":
189
+ cmd_status(args.name)
190
+ elif args.command == "run":
191
+ cmd_run(args.name)
192
+ else:
193
+ ap.print_help()
194
+
195
+
196
+ if __name__ == "__main__":
197
+ main()