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.
- tortoise/__init__.py +45 -0
- tortoise/__main__.py +1865 -0
- tortoise/analyze.py +473 -0
- tortoise/api.py +303 -0
- tortoise/archived/search_legacy.py +31 -0
- tortoise/audit.py +236 -0
- tortoise/audit_events.py +284 -0
- tortoise/auth.py +107 -0
- tortoise/backup.py +155 -0
- tortoise/config.py +99 -0
- tortoise/connector_loader.py +74 -0
- tortoise/connectors/__init__.py +5 -0
- tortoise/connectors/github.py +432 -0
- tortoise/connectors/github_docs.py +146 -0
- tortoise/connectors/linear.py +199 -0
- tortoise/connectors/slack.py +222 -0
- tortoise/consistency.py +132 -0
- tortoise/crypto.py +52 -0
- tortoise/deployment.py +62 -0
- tortoise/domain_loader.py +142 -0
- tortoise/dream.py +153 -0
- tortoise/embedded_reaper.py +744 -0
- tortoise/embeddings.py +227 -0
- tortoise/ep.py +534 -0
- tortoise/exceptions.py +16 -0
- tortoise/extractor.py +945 -0
- tortoise/hosted_api.py +1982 -0
- tortoise/hosted_middleware.py +22 -0
- tortoise/idempotency.py +39 -0
- tortoise/ids.py +23 -0
- tortoise/indexer/github_indexer.py +129 -0
- tortoise/ingest.py +614 -0
- tortoise/log.py +29 -0
- tortoise/m0.py +50 -0
- tortoise/mcp_auth.py +337 -0
- tortoise/mcp_client.py +108 -0
- tortoise/mcp_server.py +1356 -0
- tortoise/memory_orchestrator.py +492 -0
- tortoise/memory_scope.py +15 -0
- tortoise/migrate_db.py +244 -0
- tortoise/migrate_kinds.py +141 -0
- tortoise/mining.py +338 -0
- tortoise/models.py +109 -0
- tortoise/monitoring.py +133 -0
- tortoise/navigation.py +216 -0
- tortoise/pack_registry.py +767 -0
- tortoise/pipeline_cli.py +197 -0
- tortoise/projection/__init__.py +913 -0
- tortoise/projection/edges.py +311 -0
- tortoise/projection/entities.py +521 -0
- tortoise/projection/grounding.py +95 -0
- tortoise/projection/propagation.py +114 -0
- tortoise/projection.py +37 -0
- tortoise/quadrature.py +90 -0
- tortoise/query_suggestions.py +194 -0
- tortoise/quota.py +163 -0
- tortoise/ranking.py +280 -0
- tortoise/render.py +108 -0
- tortoise/scripts/manifest.py +67 -0
- tortoise/sdk.py +4713 -0
- tortoise/search_engine.py +887 -0
- tortoise/security.py +268 -0
- tortoise/selfhost.py +157 -0
- tortoise/selfhost_api.py +201 -0
- tortoise/session_continuity.py +82 -0
- tortoise/session_indexer.py +569 -0
- tortoise/shared_state/__init__.py +20 -0
- tortoise/shared_state/concurrency.py +113 -0
- tortoise/shared_state/event_log.py +192 -0
- tortoise/shared_state/events.py +150 -0
- tortoise/shared_state/monitoring.py +87 -0
- tortoise/shared_state/recovery.py +126 -0
- tortoise/shared_state/tests/__init__.py +15 -0
- tortoise/shared_state/tests/test_concurrency.py +123 -0
- tortoise/shared_state/tests/test_events.py +145 -0
- tortoise/shared_state/tests/test_monitoring.py +54 -0
- tortoise/shared_state/tests/test_recovery.py +181 -0
- tortoise/source_credibility.py +306 -0
- tortoise/svbp.py +446 -0
- tortoise/taxonomy.py +71 -0
- tortoise/test_cross_ontology.py +180 -0
- tortoise/test_tortoise_client.py +206 -0
- tortoise/tool_registry.py +805 -0
- tortoise/tortoise_client.py +262 -0
- tortoise/verify_ontology.py +154 -0
- tortoise/version_vector.py +97 -0
- tortoise/weights.py +61 -0
- tortoise_graph-0.2.0.dist-info/METADATA +152 -0
- tortoise_graph-0.2.0.dist-info/RECORD +93 -0
- tortoise_graph-0.2.0.dist-info/WHEEL +5 -0
- tortoise_graph-0.2.0.dist-info/entry_points.txt +4 -0
- tortoise_graph-0.2.0.dist-info/licenses/LICENSE +95 -0
- tortoise_graph-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
"""Canonical tool registry — single source of truth for all Tortoise operations.
|
|
2
|
+
|
|
3
|
+
One ToolDefinition per SDK operation. Both MCP and REST surfaces derive their
|
|
4
|
+
registrations from this registry. HTTP_ALLOWED is derived — zero manual sync.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass, replace, field
|
|
9
|
+
from typing import Any, Callable, Optional
|
|
10
|
+
|
|
11
|
+
from mcp.types import ToolAnnotations
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class RestSpec:
|
|
16
|
+
"""REST route metadata for SDK-backed operations."""
|
|
17
|
+
method: str # "GET" | "POST" | "DELETE"
|
|
18
|
+
path: str # "/v1/points" etc.
|
|
19
|
+
request_model: type | None = None # Pydantic request model
|
|
20
|
+
response_model: type | None = None # Pydantic response model
|
|
21
|
+
status_code: int = 200
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class ToolDefinition:
|
|
26
|
+
"""One entry per SDK-exposed operation."""
|
|
27
|
+
name: str # e.g. "tortoise_create_point"
|
|
28
|
+
description: str # Docstring for MCP + OpenAPI
|
|
29
|
+
annotations: ToolAnnotations # readOnlyHint, destructiveHint, idempotentHint
|
|
30
|
+
http_policy: bool # True = exposed on HTTP surfaces
|
|
31
|
+
sdk_method: str # Attribute name on TortoiseSDK, e.g. "create_point"
|
|
32
|
+
handler_override: Optional[Callable] = None # For raw-Cypher REST ops
|
|
33
|
+
rest_spec: Optional[RestSpec] = None # For SDK-backed REST ops
|
|
34
|
+
group: str = "memory" # Curation group (#523): memory|reasoning|graph|sessions|sources|journal|admin|onboarding
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# ── Shorthand constructors ────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
def _ro() -> ToolAnnotations:
|
|
40
|
+
return ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=False)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _rw() -> ToolAnnotations:
|
|
44
|
+
return ToolAnnotations(readOnlyHint=False, destructiveHint=True, idempotentHint=False)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _idem() -> ToolAnnotations:
|
|
48
|
+
return ToolAnnotations(readOnlyHint=False, destructiveHint=False, idempotentHint=True)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# ── Registry Entries ────────────────────────────────────────────
|
|
52
|
+
# Maintained in the same order as mcp_server.py for diffability.
|
|
53
|
+
# New tools: add one entry here → both surfaces pick it up.
|
|
54
|
+
|
|
55
|
+
TOOL_REGISTRY: list[ToolDefinition] = [
|
|
56
|
+
# ── Core CRUD ─────────────────────────────────────────────────
|
|
57
|
+
ToolDefinition(
|
|
58
|
+
name="tortoise_create_point",
|
|
59
|
+
description="Create a Point node (statement, decision, vision, hypothesis, etc.). "
|
|
60
|
+
"dedup=True (default): idempotent — returns existing Point if content matches.",
|
|
61
|
+
annotations=_idem(),
|
|
62
|
+
http_policy=True,
|
|
63
|
+
sdk_method="create_point",
|
|
64
|
+
rest_spec=RestSpec(method="POST", path="/v1/points",
|
|
65
|
+
request_model="CreatePointRequest",
|
|
66
|
+
response_model="PointResponse"),
|
|
67
|
+
),
|
|
68
|
+
ToolDefinition(
|
|
69
|
+
name="tortoise_query",
|
|
70
|
+
description="Query points by pointKind and/or property filters. "
|
|
71
|
+
"When text is provided, routes through tortoise_fts_query() for hybrid search.",
|
|
72
|
+
annotations=_ro(),
|
|
73
|
+
http_policy=True,
|
|
74
|
+
sdk_method="query",
|
|
75
|
+
),
|
|
76
|
+
ToolDefinition(
|
|
77
|
+
name="tortoise_paginated_query",
|
|
78
|
+
description="Query points with SKIP/LIMIT pagination. Returns {results, total, hasMore}.",
|
|
79
|
+
annotations=_ro(),
|
|
80
|
+
http_policy=True,
|
|
81
|
+
sdk_method="paginated_query",
|
|
82
|
+
),
|
|
83
|
+
ToolDefinition(
|
|
84
|
+
name="tortoise_check_structure",
|
|
85
|
+
description="Check Gate 0→4 chain integrity (orphans, dangling refs).",
|
|
86
|
+
annotations=_ro(),
|
|
87
|
+
http_policy=True,
|
|
88
|
+
sdk_method="check_structure",
|
|
89
|
+
),
|
|
90
|
+
ToolDefinition(
|
|
91
|
+
name="tortoise_summarize_structure",
|
|
92
|
+
description="Count points per Gate (by pointKind). Returns {gateN_*, total}.",
|
|
93
|
+
annotations=_ro(),
|
|
94
|
+
http_policy=True,
|
|
95
|
+
sdk_method="summarize_structure",
|
|
96
|
+
),
|
|
97
|
+
ToolDefinition(
|
|
98
|
+
name="tortoise_list_pointkinds",
|
|
99
|
+
description="List all pointKinds present in the graph with counts. What EXISTS.",
|
|
100
|
+
annotations=_ro(),
|
|
101
|
+
http_policy=True,
|
|
102
|
+
sdk_method="list_pointkinds",
|
|
103
|
+
),
|
|
104
|
+
ToolDefinition(
|
|
105
|
+
name="tortoise_list_sources",
|
|
106
|
+
description="List all Sources with point counts. Where data came FROM.",
|
|
107
|
+
annotations=_ro(),
|
|
108
|
+
http_policy=True,
|
|
109
|
+
sdk_method="list_sources",
|
|
110
|
+
),
|
|
111
|
+
ToolDefinition(
|
|
112
|
+
name="tortoise_list_namespaces",
|
|
113
|
+
description="List installed pack namespaces.",
|
|
114
|
+
annotations=_ro(),
|
|
115
|
+
http_policy=True,
|
|
116
|
+
sdk_method="list_namespaces",
|
|
117
|
+
),
|
|
118
|
+
# ── Tags (#215) ───────────────────────────────────────────────
|
|
119
|
+
ToolDefinition(
|
|
120
|
+
name="tortoise_list_tags",
|
|
121
|
+
description="List all Tag names with count of tagged Points. Where tags are USED.",
|
|
122
|
+
annotations=_ro(),
|
|
123
|
+
http_policy=True,
|
|
124
|
+
sdk_method="list_tags",
|
|
125
|
+
),
|
|
126
|
+
ToolDefinition(
|
|
127
|
+
name="tortoise_query_points_by_tag",
|
|
128
|
+
description="Return Points connected to a Tag via TAGGED edge.",
|
|
129
|
+
annotations=_ro(),
|
|
130
|
+
http_policy=True,
|
|
131
|
+
sdk_method="query_points_by_tag",
|
|
132
|
+
),
|
|
133
|
+
# ── Point accessors ───────────────────────────────────────────
|
|
134
|
+
ToolDefinition(
|
|
135
|
+
name="tortoise_get_point",
|
|
136
|
+
description="Get a single Point by ID. Returns all properties, or empty dict.",
|
|
137
|
+
annotations=_ro(),
|
|
138
|
+
http_policy=True,
|
|
139
|
+
sdk_method="get_point",
|
|
140
|
+
),
|
|
141
|
+
ToolDefinition(
|
|
142
|
+
name="tortoise_suggest_entry_points",
|
|
143
|
+
description="Entity resolution — NL query → matching entities from the graph.",
|
|
144
|
+
annotations=_ro(),
|
|
145
|
+
http_policy=True,
|
|
146
|
+
sdk_method="suggest_entry_points",
|
|
147
|
+
),
|
|
148
|
+
# ── Semantic Search (#6990) ───────────────────────────────────
|
|
149
|
+
ToolDefinition(
|
|
150
|
+
name="tortoise_search",
|
|
151
|
+
description="Hybrid search with RRF fusion + EP annotation. "
|
|
152
|
+
"Full-scan mode: omit query, set kind → all Points of kind.",
|
|
153
|
+
annotations=_ro(),
|
|
154
|
+
http_policy=True,
|
|
155
|
+
sdk_method="tortoise_fts_query",
|
|
156
|
+
rest_spec=RestSpec(method="GET", path="/v1/search"),
|
|
157
|
+
),
|
|
158
|
+
# ── EP Belief Propagation (#6908) ─────────────────────────────
|
|
159
|
+
ToolDefinition(
|
|
160
|
+
name="tortoise_compute_confidence",
|
|
161
|
+
description="Compute confidence via EP belief propagation. "
|
|
162
|
+
"Returns {iterations, converged, confidences}.",
|
|
163
|
+
annotations=_ro(),
|
|
164
|
+
http_policy=True,
|
|
165
|
+
sdk_method="compute_confidence",
|
|
166
|
+
),
|
|
167
|
+
ToolDefinition(
|
|
168
|
+
name="tortoise_set_point_baseline",
|
|
169
|
+
description="Set Beta prior evidence for a claim.",
|
|
170
|
+
annotations=_rw(),
|
|
171
|
+
http_policy=True,
|
|
172
|
+
sdk_method="set_point_baseline",
|
|
173
|
+
),
|
|
174
|
+
ToolDefinition(
|
|
175
|
+
name="tortoise_get_confidence",
|
|
176
|
+
description="Get EP confidence for a claim: {mean, variance, alpha, beta}.",
|
|
177
|
+
annotations=_ro(),
|
|
178
|
+
http_policy=True,
|
|
179
|
+
sdk_method="get_confidence",
|
|
180
|
+
),
|
|
181
|
+
ToolDefinition(
|
|
182
|
+
name="tortoise_calibrate_summary",
|
|
183
|
+
description="Audit graph calibration state. Returns per-point guidance.",
|
|
184
|
+
annotations=_ro(),
|
|
185
|
+
http_policy=True,
|
|
186
|
+
sdk_method="calibrate_summary",
|
|
187
|
+
),
|
|
188
|
+
ToolDefinition(
|
|
189
|
+
name="tortoise_dream",
|
|
190
|
+
description="Run EP stabilization (dreaming, #85). "
|
|
191
|
+
"Default: incremental dirty subgraph. Set full=True for whole-graph.",
|
|
192
|
+
annotations=_rw(),
|
|
193
|
+
# #329: whole-graph EP is CPU-heavy — tenant MCP surface excluded
|
|
194
|
+
# (stdio/operator only). REST /v1/dream remains tenant-reachable but is
|
|
195
|
+
# separately budgeted at MAX_DREAM_FULL_PER_HOUR (hosted_api).
|
|
196
|
+
http_policy=False,
|
|
197
|
+
sdk_method="dream",
|
|
198
|
+
rest_spec=RestSpec(method="POST", path="/v1/dream"),
|
|
199
|
+
),
|
|
200
|
+
# ── Updates ───────────────────────────────────────────────────
|
|
201
|
+
ToolDefinition(
|
|
202
|
+
name="tortoise_update_point",
|
|
203
|
+
description="Update properties on a Point. Safe — modifies one Point only.",
|
|
204
|
+
annotations=_rw(),
|
|
205
|
+
http_policy=True,
|
|
206
|
+
sdk_method="update_point",
|
|
207
|
+
),
|
|
208
|
+
# ── Operators ─────────────────────────────────────────────────
|
|
209
|
+
ToolDefinition(
|
|
210
|
+
name="tortoise_create_operator",
|
|
211
|
+
description="Create an operator connecting Points. "
|
|
212
|
+
"op_type: IMPL, NAND, composedOf, decomposesInto, contains, wraps.",
|
|
213
|
+
annotations=_idem(),
|
|
214
|
+
http_policy=True,
|
|
215
|
+
sdk_method="create_operator",
|
|
216
|
+
),
|
|
217
|
+
ToolDefinition(
|
|
218
|
+
name="tortoise_annotate_operator",
|
|
219
|
+
description="Annotate an operator Point with structured epistemic dimensions "
|
|
220
|
+
"(bias, precision, consistency, directness).",
|
|
221
|
+
annotations=_rw(),
|
|
222
|
+
http_policy=True,
|
|
223
|
+
sdk_method="annotate_operator",
|
|
224
|
+
),
|
|
225
|
+
ToolDefinition(
|
|
226
|
+
name="tortoise_get_operator",
|
|
227
|
+
description="Get an operator Point by ID. Returns all properties including "
|
|
228
|
+
"annotation dimensions.",
|
|
229
|
+
annotations=_ro(),
|
|
230
|
+
http_policy=True,
|
|
231
|
+
sdk_method="get_point", # get_operator uses get_point + is_operator check
|
|
232
|
+
),
|
|
233
|
+
ToolDefinition(
|
|
234
|
+
name="tortoise_mitigate_operator",
|
|
235
|
+
description="Create a mitigation Point that modulates an operator's edge strength. "
|
|
236
|
+
"Idempotent — second call updates existing mitigation.",
|
|
237
|
+
annotations=_idem(),
|
|
238
|
+
http_policy=True,
|
|
239
|
+
sdk_method="mitigate_operator",
|
|
240
|
+
),
|
|
241
|
+
# ── Decisions ─────────────────────────────────────────────────
|
|
242
|
+
ToolDefinition(
|
|
243
|
+
name="tortoise_file_decision",
|
|
244
|
+
description="File a simple decision directly to the graph. "
|
|
245
|
+
"Creates decision + options + evidence + IMPL edges atomically.",
|
|
246
|
+
annotations=_rw(),
|
|
247
|
+
http_policy=True,
|
|
248
|
+
sdk_method="file_decision",
|
|
249
|
+
),
|
|
250
|
+
ToolDefinition(
|
|
251
|
+
name="tortoise_file_human_approval",
|
|
252
|
+
description="File a human approval of a planning artifact to the graph. "
|
|
253
|
+
"Creates Event (eventKind: humanApproval) + decision Point "
|
|
254
|
+
"(pointKind: humanApproval) + unidirectional IMPL fan-out "
|
|
255
|
+
"(label approvedBy) so dependent claims strengthen.",
|
|
256
|
+
annotations=_rw(),
|
|
257
|
+
http_policy=True,
|
|
258
|
+
sdk_method="file_human_approval",
|
|
259
|
+
),
|
|
260
|
+
# ── Deletion / Invalidation ───────────────────────────────────
|
|
261
|
+
ToolDefinition(
|
|
262
|
+
name="tortoise_delete_point",
|
|
263
|
+
description="Delete a Point. DESTRUCTIVE — requires human confirmation. Cannot be undone.",
|
|
264
|
+
annotations=_rw(),
|
|
265
|
+
http_policy=True,
|
|
266
|
+
sdk_method="delete_point_wrapped",
|
|
267
|
+
),
|
|
268
|
+
ToolDefinition(
|
|
269
|
+
name="tortoise_invalidate",
|
|
270
|
+
description="Mark a Point outdated with a CORRECTS edge from the correcting Point.",
|
|
271
|
+
annotations=_rw(),
|
|
272
|
+
http_policy=True,
|
|
273
|
+
sdk_method="invalidate_point",
|
|
274
|
+
),
|
|
275
|
+
ToolDefinition(
|
|
276
|
+
name="tortoise_supersede",
|
|
277
|
+
description="Atomically replace old Point with new — CORRECTS edge + outdated flag. "
|
|
278
|
+
"Equivalent to invalidate(old_id, new_id).",
|
|
279
|
+
annotations=_rw(),
|
|
280
|
+
http_policy=True,
|
|
281
|
+
sdk_method="supersede_point",
|
|
282
|
+
),
|
|
283
|
+
# ── Navigation (#6962, #6963, #6964) ──────────────────────────
|
|
284
|
+
ToolDefinition(
|
|
285
|
+
name="tortoise_entity_profile",
|
|
286
|
+
description="Entity-centric traversal — BFS from entity node, categorize connected nodes. "
|
|
287
|
+
"Returns {entity, connected: {points, documents, events, subjects, objects}}.",
|
|
288
|
+
annotations=_ro(),
|
|
289
|
+
http_policy=True,
|
|
290
|
+
sdk_method="entity_profile", # navigation.entityProfile — not a direct SDK method
|
|
291
|
+
),
|
|
292
|
+
ToolDefinition(
|
|
293
|
+
name="tortoise_traverse",
|
|
294
|
+
description="Multi-hop graph traversal from entity following ALL relationship types. "
|
|
295
|
+
"Returns {entity, nodes: [{node, relationship, depth}]}.",
|
|
296
|
+
annotations=_ro(),
|
|
297
|
+
http_policy=True,
|
|
298
|
+
sdk_method="traverse", # navigation.tortoise_traverse — not a direct SDK method
|
|
299
|
+
),
|
|
300
|
+
# ── P0 Group 3: Checkpoint, Diary, Status, Ingest ─────────────
|
|
301
|
+
ToolDefinition(
|
|
302
|
+
name="tortoise_checkpoint",
|
|
303
|
+
description="Session batch save — two-tier dedup (content hash + embedding similarity). "
|
|
304
|
+
"Returns {filed: N, duplicates: M}.",
|
|
305
|
+
annotations=_idem(),
|
|
306
|
+
http_policy=True,
|
|
307
|
+
sdk_method="checkpoint",
|
|
308
|
+
),
|
|
309
|
+
ToolDefinition(
|
|
310
|
+
name="tortoise_diary_write",
|
|
311
|
+
description="Write an agent diary entry (AAAK format suggested). "
|
|
312
|
+
"Creates a Point with pointKind=diary, authoredBy=agent.",
|
|
313
|
+
annotations=_rw(),
|
|
314
|
+
http_policy=True,
|
|
315
|
+
sdk_method="diary_write",
|
|
316
|
+
),
|
|
317
|
+
ToolDefinition(
|
|
318
|
+
name="tortoise_diary_read",
|
|
319
|
+
description="Read recent diary entries for an agent, newest first.",
|
|
320
|
+
annotations=_ro(),
|
|
321
|
+
http_policy=True,
|
|
322
|
+
sdk_method="diary_read",
|
|
323
|
+
),
|
|
324
|
+
ToolDefinition(
|
|
325
|
+
name="tortoise_list_graphs",
|
|
326
|
+
description="List all graph names in the database. Useful for namespace discovery.",
|
|
327
|
+
annotations=_ro(),
|
|
328
|
+
http_policy=True,
|
|
329
|
+
sdk_method="list_graphs",
|
|
330
|
+
),
|
|
331
|
+
ToolDefinition(
|
|
332
|
+
name="tortoise_status",
|
|
333
|
+
description="Graph health + entity counts + FalkorDB connectivity. "
|
|
334
|
+
"Returns {connected, counts, total_entities}.",
|
|
335
|
+
annotations=_ro(),
|
|
336
|
+
http_policy=True,
|
|
337
|
+
sdk_method="status",
|
|
338
|
+
),
|
|
339
|
+
ToolDefinition(
|
|
340
|
+
name="tortoise_health",
|
|
341
|
+
description="Health check + basic metrics: graph_size, last_ingest, error_count, uptime.",
|
|
342
|
+
annotations=_ro(),
|
|
343
|
+
http_policy=True,
|
|
344
|
+
sdk_method="health", # monitoring.metrics — not a direct SDK method
|
|
345
|
+
),
|
|
346
|
+
ToolDefinition(
|
|
347
|
+
name="tortoise_session_context",
|
|
348
|
+
description="Return 'what happened last session' — diary entries, recent Points, "
|
|
349
|
+
"Events, confidence changes.",
|
|
350
|
+
annotations=_ro(),
|
|
351
|
+
http_policy=True,
|
|
352
|
+
sdk_method="session_context",
|
|
353
|
+
rest_spec=RestSpec(method="GET", path="/v1/context"),
|
|
354
|
+
),
|
|
355
|
+
# ── Excluded from HTTP ────────────────────────────────────────
|
|
356
|
+
ToolDefinition(
|
|
357
|
+
name="tortoise_ingest_corpus",
|
|
358
|
+
description="Batch document ingestion — walk directory, parse YAML frontmatter "
|
|
359
|
+
"from .md files, create/update Document nodes. "
|
|
360
|
+
"EXCLUDED from tenant HTTP — walks server filesystem with user-supplied path.",
|
|
361
|
+
annotations=_rw(),
|
|
362
|
+
http_policy=False,
|
|
363
|
+
sdk_method="ingest_corpus",
|
|
364
|
+
),
|
|
365
|
+
# ── Taxonomy ──────────────────────────────────────────────────
|
|
366
|
+
ToolDefinition(
|
|
367
|
+
name="tortoise_taxonomy",
|
|
368
|
+
description="Count entities by node label. "
|
|
369
|
+
"Returns {Point: N, Event: N, Subject: N, Object: N, Document: N}.",
|
|
370
|
+
annotations=_ro(),
|
|
371
|
+
http_policy=True,
|
|
372
|
+
sdk_method="taxonomy",
|
|
373
|
+
),
|
|
374
|
+
ToolDefinition(
|
|
375
|
+
name="tortoise_list_topics",
|
|
376
|
+
description="entityProfile lite for an entity. "
|
|
377
|
+
"Returns {id, pointKind, neighbors, neighborCounts}.",
|
|
378
|
+
annotations=_ro(),
|
|
379
|
+
http_policy=True,
|
|
380
|
+
sdk_method="list_topics",
|
|
381
|
+
),
|
|
382
|
+
# ── Graph Analysis ────────────────────────────────────────────
|
|
383
|
+
ToolDefinition(
|
|
384
|
+
name="tortoise_analyze",
|
|
385
|
+
description="Answer natural language questions about the Tortoise epistemic graph. "
|
|
386
|
+
"Ask things like: 'where is the disagreement?' 'what supports claim X?'",
|
|
387
|
+
annotations=_ro(),
|
|
388
|
+
http_policy=True,
|
|
389
|
+
sdk_method="analyze", # analyze.analyze — not a direct SDK method
|
|
390
|
+
),
|
|
391
|
+
# ── P1-3: Staleness Detection ─────────────────────────────────
|
|
392
|
+
ToolDefinition(
|
|
393
|
+
name="tortoise_stale",
|
|
394
|
+
description="Find Points not updated in N days. Returns {stale, count, cutoff, limit}.",
|
|
395
|
+
annotations=_ro(),
|
|
396
|
+
http_policy=True,
|
|
397
|
+
sdk_method="stale_points",
|
|
398
|
+
),
|
|
399
|
+
ToolDefinition(
|
|
400
|
+
name="tortoise_provenance",
|
|
401
|
+
description="Provenance chain — 'Who decided this?' "
|
|
402
|
+
"Follows authoredBy → Subject → delegation.",
|
|
403
|
+
annotations=_ro(),
|
|
404
|
+
http_policy=True,
|
|
405
|
+
sdk_method="provenance",
|
|
406
|
+
),
|
|
407
|
+
# ── Multi-tenancy (#7001) ─────────────────────────────────────
|
|
408
|
+
ToolDefinition(
|
|
409
|
+
name="tortoise_team_create",
|
|
410
|
+
description="Create isolated team graph via FalkorDB select_graph. "
|
|
411
|
+
"EXCLUDED from tenant HTTP — provisioning belongs to "
|
|
412
|
+
"/internal/provision behind FASTAPI_INTERNAL_KEY.",
|
|
413
|
+
annotations=_rw(),
|
|
414
|
+
http_policy=False,
|
|
415
|
+
sdk_method="team_create",
|
|
416
|
+
),
|
|
417
|
+
# ── Entity CRUD (ONTOLOGY v2.5) ───────────────────────────────
|
|
418
|
+
ToolDefinition(
|
|
419
|
+
name="tortoise_create_subject",
|
|
420
|
+
description="Create a Subject node (team, role, organization, person).",
|
|
421
|
+
annotations=_rw(),
|
|
422
|
+
http_policy=True,
|
|
423
|
+
sdk_method="create_subject",
|
|
424
|
+
),
|
|
425
|
+
ToolDefinition(
|
|
426
|
+
name="tortoise_create_object",
|
|
427
|
+
description="Create an Object node (product, customer, skill, etc.).",
|
|
428
|
+
annotations=_rw(),
|
|
429
|
+
http_policy=True,
|
|
430
|
+
sdk_method="create_object",
|
|
431
|
+
),
|
|
432
|
+
ToolDefinition(
|
|
433
|
+
name="tortoise_create_event",
|
|
434
|
+
description="Create an Event node (meeting, decision, deployment, etc.).",
|
|
435
|
+
annotations=_rw(),
|
|
436
|
+
http_policy=True,
|
|
437
|
+
sdk_method="create_event",
|
|
438
|
+
),
|
|
439
|
+
ToolDefinition(
|
|
440
|
+
name="tortoise_get_events",
|
|
441
|
+
description="Get recent Events, optionally filtered by eventKind (e.g. 'AgentSession').",
|
|
442
|
+
annotations=_ro(),
|
|
443
|
+
http_policy=True,
|
|
444
|
+
sdk_method="get_events",
|
|
445
|
+
),
|
|
446
|
+
ToolDefinition(
|
|
447
|
+
name="tortoise_get_session",
|
|
448
|
+
description="Get a single agent session Event by session_id.",
|
|
449
|
+
annotations=_ro(),
|
|
450
|
+
http_policy=True,
|
|
451
|
+
sdk_method="get_session",
|
|
452
|
+
),
|
|
453
|
+
ToolDefinition(
|
|
454
|
+
name="tortoise_index_sessions",
|
|
455
|
+
description="Index session .md files as AgentSession Events. "
|
|
456
|
+
"EXCLUDED from tenant HTTP — walks server filesystem with user-supplied path.",
|
|
457
|
+
annotations=_rw(),
|
|
458
|
+
http_policy=False,
|
|
459
|
+
sdk_method="index_sessions",
|
|
460
|
+
),
|
|
461
|
+
ToolDefinition(
|
|
462
|
+
name="tortoise_search_sessions",
|
|
463
|
+
description="Search indexed agent sessions. Returns Events with narrative_arc snippets.",
|
|
464
|
+
annotations=_ro(),
|
|
465
|
+
http_policy=True,
|
|
466
|
+
sdk_method="search_sessions",
|
|
467
|
+
),
|
|
468
|
+
ToolDefinition(
|
|
469
|
+
name="tortoise_create_document",
|
|
470
|
+
description="Create a Document node (research, planDoc, meetingNotes, etc.).",
|
|
471
|
+
annotations=_idem(),
|
|
472
|
+
http_policy=True,
|
|
473
|
+
sdk_method="create_document",
|
|
474
|
+
),
|
|
475
|
+
ToolDefinition(
|
|
476
|
+
name="tortoise_create_source",
|
|
477
|
+
description="Create a Source node for provenance (document, web, db, etc.). "
|
|
478
|
+
"Sources track content origin — url is the permalink key. "
|
|
479
|
+
"tier (T0-T4 / legacy alias) stores the credibility tier; "
|
|
480
|
+
"sourceDate is the evidence-age clock.",
|
|
481
|
+
annotations=_idem(),
|
|
482
|
+
http_policy=True,
|
|
483
|
+
sdk_method="create_source",
|
|
484
|
+
),
|
|
485
|
+
ToolDefinition(
|
|
486
|
+
name="tortoise_get_source_reliability",
|
|
487
|
+
description="Derive a Source's reliability (0-1) — query-time, "
|
|
488
|
+
"cache-consistency-checked. NOTE: refreshes the reliability "
|
|
489
|
+
"cache on the Source node (write-through projection), so not read-only.",
|
|
490
|
+
annotations=_rw(),
|
|
491
|
+
http_policy=True,
|
|
492
|
+
sdk_method="get_source_reliability",
|
|
493
|
+
),
|
|
494
|
+
ToolDefinition(
|
|
495
|
+
name="tortoise_assess_source",
|
|
496
|
+
description="Record an agent's assessment of a Source (0-1 score + rationale). "
|
|
497
|
+
"Creates a pointKind='assessment' Statement Point; latest per "
|
|
498
|
+
"(url, assessor) wins; weighted by assessor reputation.",
|
|
499
|
+
annotations=_rw(),
|
|
500
|
+
http_policy=True,
|
|
501
|
+
sdk_method="assess_source",
|
|
502
|
+
),
|
|
503
|
+
ToolDefinition(
|
|
504
|
+
name="tortoise_set_source_tier",
|
|
505
|
+
description="Set (or change) a Source's credibility tier (T0-T4). "
|
|
506
|
+
"Non-destructive — never overwrites sourceKind type strings.",
|
|
507
|
+
annotations=_rw(),
|
|
508
|
+
http_policy=True,
|
|
509
|
+
sdk_method="set_source_tier",
|
|
510
|
+
),
|
|
511
|
+
ToolDefinition(
|
|
512
|
+
name="tortoise_get_entity",
|
|
513
|
+
description="Get any entity by ID, eventId, or url.",
|
|
514
|
+
annotations=_ro(),
|
|
515
|
+
http_policy=True,
|
|
516
|
+
sdk_method="get_entity",
|
|
517
|
+
),
|
|
518
|
+
ToolDefinition(
|
|
519
|
+
name="tortoise_update_entity",
|
|
520
|
+
description="Update any entity's properties.",
|
|
521
|
+
annotations=_rw(),
|
|
522
|
+
http_policy=True,
|
|
523
|
+
sdk_method="update_entity",
|
|
524
|
+
),
|
|
525
|
+
ToolDefinition(
|
|
526
|
+
name="tortoise_delete_entity",
|
|
527
|
+
description="Delete any entity by ID.",
|
|
528
|
+
annotations=_rw(),
|
|
529
|
+
http_policy=True,
|
|
530
|
+
sdk_method="delete_entity",
|
|
531
|
+
),
|
|
532
|
+
ToolDefinition(
|
|
533
|
+
name="tortoise_create_edge",
|
|
534
|
+
description="Create an edge between two entities. "
|
|
535
|
+
"Predicate: performs, produces, ownedBy, managedBy, etc.",
|
|
536
|
+
annotations=_rw(),
|
|
537
|
+
http_policy=True,
|
|
538
|
+
sdk_method="create_edge", # proj.create_edge — not a direct SDK method
|
|
539
|
+
),
|
|
540
|
+
ToolDefinition(
|
|
541
|
+
name="tortoise_get_governance",
|
|
542
|
+
description="Get all entities owned by a Subject.",
|
|
543
|
+
annotations=_ro(),
|
|
544
|
+
http_policy=True,
|
|
545
|
+
sdk_method="get_owned_entities",
|
|
546
|
+
),
|
|
547
|
+
ToolDefinition(
|
|
548
|
+
name="tortoise_backfill_v25",
|
|
549
|
+
description="Backfill database to ONTOLOGY v2.5 schema. "
|
|
550
|
+
"EXCLUDED from tenant HTTP — schema-level migration (operator-only).",
|
|
551
|
+
annotations=_rw(),
|
|
552
|
+
http_policy=False,
|
|
553
|
+
sdk_method="backfill_v25",
|
|
554
|
+
),
|
|
555
|
+
# ── Onboarding tools (#498/#499/#500) ─────────────────────────
|
|
556
|
+
ToolDefinition(
|
|
557
|
+
name="tortoise_onboarding_demo_create",
|
|
558
|
+
description="Create the demo epistemic graph (4 layers) for this team. Idempotent (Q4).",
|
|
559
|
+
annotations=_idem(),
|
|
560
|
+
http_policy=True,
|
|
561
|
+
sdk_method="", # custom handler in mcp_server.py
|
|
562
|
+
rest_spec=RestSpec(method="POST", path="/v1/demo"),
|
|
563
|
+
),
|
|
564
|
+
ToolDefinition(
|
|
565
|
+
name="tortoise_onboarding_state",
|
|
566
|
+
description="Return this team's onboarding progress (Q6 verification).",
|
|
567
|
+
annotations=_ro(),
|
|
568
|
+
http_policy=True,
|
|
569
|
+
sdk_method="",
|
|
570
|
+
rest_spec=RestSpec(method="GET", path="/v1/onboarding/state"),
|
|
571
|
+
),
|
|
572
|
+
ToolDefinition(
|
|
573
|
+
name="tortoise_onboarding_session_recording",
|
|
574
|
+
description="Toggle automatic session recording for this team (Q3).",
|
|
575
|
+
annotations=_rw(),
|
|
576
|
+
http_policy=True,
|
|
577
|
+
sdk_method="",
|
|
578
|
+
rest_spec=RestSpec(method="POST", path="/v1/onboarding/session-recording"),
|
|
579
|
+
),
|
|
580
|
+
ToolDefinition(
|
|
581
|
+
name="tortoise_onboarding_github_connect",
|
|
582
|
+
description="Initiate GitHub OAuth — returns authorize URL + CSRF state (Q1).",
|
|
583
|
+
annotations=_rw(),
|
|
584
|
+
http_policy=True,
|
|
585
|
+
sdk_method="",
|
|
586
|
+
rest_spec=RestSpec(method="POST", path="/v1/onboarding/github/connect"),
|
|
587
|
+
),
|
|
588
|
+
ToolDefinition(
|
|
589
|
+
name="tortoise_onboarding_github_index",
|
|
590
|
+
description="Start background GitHub indexing of an org's issues/PRs (Q2).",
|
|
591
|
+
annotations=_rw(),
|
|
592
|
+
http_policy=True,
|
|
593
|
+
sdk_method="",
|
|
594
|
+
rest_spec=RestSpec(method="POST", path="/v1/index/github"),
|
|
595
|
+
),
|
|
596
|
+
ToolDefinition(
|
|
597
|
+
name="tortoise_onboarding_github_status",
|
|
598
|
+
description="Return GitHub connection status for this team (Q1 verify).",
|
|
599
|
+
annotations=_ro(),
|
|
600
|
+
http_policy=True,
|
|
601
|
+
sdk_method="",
|
|
602
|
+
rest_spec=RestSpec(method="GET", path="/v1/onboarding/github/status"),
|
|
603
|
+
),
|
|
604
|
+
|
|
605
|
+
]
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
# ── Derived sets ─────────────────────────────────────────────────
|
|
609
|
+
|
|
610
|
+
def get_http_allowed() -> frozenset[str]:
|
|
611
|
+
"""Derive HTTP_ALLOWED from registry — zero manual sync."""
|
|
612
|
+
return frozenset(t.name for t in TOOL_REGISTRY if t.http_policy)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
# ── Adapters ────────────────────────────────────────────────────
|
|
616
|
+
|
|
617
|
+
class FastMCPAdapter:
|
|
618
|
+
"""Register all TOOL_REGISTRY entries on a FastMCP instance via add_tool().
|
|
619
|
+
|
|
620
|
+
Replaces the 58 @mcp.tool() decorators with a single adapter call.
|
|
621
|
+
Tool function bodies remain in mcp_server.py as module-level callables;
|
|
622
|
+
this adapter wraps each via FunctionTool.from_function() and registers
|
|
623
|
+
them through mcp.add_tool().
|
|
624
|
+
|
|
625
|
+
Usage (in mcp_server.py):
|
|
626
|
+
adapter = FastMCPAdapter(mcp)
|
|
627
|
+
adapter.register_all(TOOL_REGISTRY, _handler_map)
|
|
628
|
+
"""
|
|
629
|
+
|
|
630
|
+
def __init__(self, mcp: Any) -> None:
|
|
631
|
+
self._mcp = mcp
|
|
632
|
+
|
|
633
|
+
def register_all(self, registry: list[ToolDefinition], handlers: dict[str, Callable]) -> None:
|
|
634
|
+
"""Register every registry entry as an MCP tool.
|
|
635
|
+
|
|
636
|
+
Args:
|
|
637
|
+
registry: TOOL_REGISTRY list of ToolDefinition entries.
|
|
638
|
+
handlers: dict mapping tool_name → callable function body.
|
|
639
|
+
"""
|
|
640
|
+
from fastmcp.tools import FunctionTool
|
|
641
|
+
|
|
642
|
+
missing = [e.name for e in registry if e.name not in handlers]
|
|
643
|
+
if missing:
|
|
644
|
+
import logging
|
|
645
|
+
logging.getLogger(__name__).warning(
|
|
646
|
+
"FastMCPAdapter: %d registry entries have no handler — skipped: %s",
|
|
647
|
+
len(missing), ", ".join(sorted(missing)),
|
|
648
|
+
)
|
|
649
|
+
for entry in registry:
|
|
650
|
+
handler = handlers.get(entry.name)
|
|
651
|
+
if handler is None:
|
|
652
|
+
continue
|
|
653
|
+
tool = FunctionTool.from_function(
|
|
654
|
+
handler,
|
|
655
|
+
name=entry.name,
|
|
656
|
+
description=entry.description,
|
|
657
|
+
annotations=entry.annotations,
|
|
658
|
+
)
|
|
659
|
+
self._mcp.add_tool(tool)
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
# ── REST endpoint classification (Gate 3 pre-step, #454) ─────────
|
|
663
|
+
# 8 REST tool-ops classified for the FastAPIRouterAdapter:
|
|
664
|
+
#
|
|
665
|
+
# | REST endpoint | SDK-backed? | Registry entry | RestSpec |
|
|
666
|
+
# |--------------------------|-------------|---------------------|---------------------|
|
|
667
|
+
# | POST /v1/points | YES | tortoise_create_point | populated above |
|
|
668
|
+
# | GET /v1/points | RAW CYPHER | (no SDK method) | — extract list_points |
|
|
669
|
+
# | GET /v1/points/{id} | RAW CYPHER | (differs from sdk.get_point) | — extract |
|
|
670
|
+
# | POST /v1/dream | YES | tortoise_dream | populated above |
|
|
671
|
+
# | GET /v1/search | YES | tortoise_search | populated above |
|
|
672
|
+
# | POST /v1/sessions | RAW CYPHER | (content_hash dedup bug — filed as tortoise#490) | — extract capture_session |
|
|
673
|
+
# | GET /v1/sessions | RAW CYPHER | (no SDK method) | — extract list_sessions |
|
|
674
|
+
# | GET /v1/context | YES | tortoise_session_context | populated above |
|
|
675
|
+
#
|
|
676
|
+
# Raw-Cypher ops are NOT added to the registry (no SDK method to register).
|
|
677
|
+
# Gate 3 pre-step: extract SDK methods for list_points/get_point_by_id/
|
|
678
|
+
# capture_session/list_sessions OR keep them hand-written in hosted_api.py
|
|
679
|
+
# and document the drift (control-plane-style). capture_session dedup bug
|
|
680
|
+
# tracked as tortoise#490.
|
|
681
|
+
#
|
|
682
|
+
# Control-plane endpoints (/internal/*, /v1/team*, /v1/team/keys) stay
|
|
683
|
+
# hand-written — out of registry scope per the epic scope guard.
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
class FastAPIRouterAdapter:
|
|
687
|
+
"""Register REST tool-ops from the registry onto a FastAPI APIRouter.
|
|
688
|
+
|
|
689
|
+
Reads entries with rest_spec populated and registers routes. Surface
|
|
690
|
+
policies (audit logging, team limits, dream enqueue) stay in the route
|
|
691
|
+
handlers — the adapter only wires registration.
|
|
692
|
+
|
|
693
|
+
Raw-Cypher ops (list_points, get_point, capture_session, list_sessions)
|
|
694
|
+
have NO sdk_method — they are registered via handler_override with their
|
|
695
|
+
existing hosted_api handler functions, OR kept hand-written in
|
|
696
|
+
hosted_api.py with drift documented (Gate 3 pre-step decision).
|
|
697
|
+
"""
|
|
698
|
+
|
|
699
|
+
def __init__(self, router: Any) -> None:
|
|
700
|
+
self._router = router
|
|
701
|
+
|
|
702
|
+
def register_all(self, registry: list[ToolDefinition],
|
|
703
|
+
handlers: dict[str, Callable]) -> None:
|
|
704
|
+
"""Register every rest_spec entry as a route.
|
|
705
|
+
|
|
706
|
+
Args:
|
|
707
|
+
registry: TOOL_REGISTRY entries.
|
|
708
|
+
handlers: dict mapping tool_name → FastAPI route handler callable.
|
|
709
|
+
"""
|
|
710
|
+
for entry in registry:
|
|
711
|
+
if entry.rest_spec is None:
|
|
712
|
+
continue
|
|
713
|
+
handler = handlers.get(entry.name)
|
|
714
|
+
if handler is None:
|
|
715
|
+
continue
|
|
716
|
+
self._router.add_api_route(
|
|
717
|
+
entry.rest_spec.path,
|
|
718
|
+
handler,
|
|
719
|
+
methods=[entry.rest_spec.method],
|
|
720
|
+
response_model=entry.rest_spec.response_model,
|
|
721
|
+
name=entry.name,
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
# ── Tool curation groups (#523) ──────────────────────────────────
|
|
726
|
+
# Role-scoped grouping so agents can be served a curated subset (tool-selection
|
|
727
|
+
# accuracy degrades past ~20 tools). Groups:
|
|
728
|
+
# memory — point CRUD, queries, confidence, search
|
|
729
|
+
# reasoning — structure checks, EP, analysis, taxonomy, provenance
|
|
730
|
+
# graph — operators, entities, events, edges
|
|
731
|
+
# sessions — session context, indexing, search
|
|
732
|
+
# sources — sources, documents, corpus ingestion
|
|
733
|
+
# journal — checkpoints, diary, decisions, approvals
|
|
734
|
+
# admin — status, health, teams, governance, migrations
|
|
735
|
+
# onboarding — hosted onboarding flows
|
|
736
|
+
|
|
737
|
+
GROUP_BY_NAME: dict[str, str] = {
|
|
738
|
+
# memory
|
|
739
|
+
"tortoise_create_point": "memory", "tortoise_update_point": "memory",
|
|
740
|
+
"tortoise_get_point": "memory", "tortoise_query": "memory",
|
|
741
|
+
"tortoise_paginated_query": "memory", "tortoise_query_points_by_tag": "memory",
|
|
742
|
+
"tortoise_delete_point": "memory", "tortoise_supersede": "memory",
|
|
743
|
+
"tortoise_invalidate": "memory", "tortoise_list_tags": "memory",
|
|
744
|
+
"tortoise_list_pointkinds": "memory", "tortoise_search": "memory",
|
|
745
|
+
"tortoise_compute_confidence": "memory", "tortoise_get_confidence": "memory",
|
|
746
|
+
"tortoise_set_point_baseline": "memory", "tortoise_calibrate_summary": "memory",
|
|
747
|
+
"tortoise_suggest_entry_points": "memory",
|
|
748
|
+
# reasoning
|
|
749
|
+
"tortoise_check_structure": "reasoning", "tortoise_summarize_structure": "reasoning",
|
|
750
|
+
"tortoise_traverse": "reasoning", "tortoise_entity_profile": "reasoning",
|
|
751
|
+
"tortoise_analyze": "reasoning", "tortoise_taxonomy": "reasoning",
|
|
752
|
+
"tortoise_list_topics": "reasoning", "tortoise_provenance": "reasoning",
|
|
753
|
+
"tortoise_stale": "reasoning", "tortoise_dream": "reasoning",
|
|
754
|
+
# graph
|
|
755
|
+
"tortoise_create_operator": "graph", "tortoise_annotate_operator": "graph",
|
|
756
|
+
"tortoise_get_operator": "graph", "tortoise_mitigate_operator": "graph",
|
|
757
|
+
"tortoise_create_subject": "graph", "tortoise_create_object": "graph",
|
|
758
|
+
"tortoise_create_event": "graph", "tortoise_get_events": "graph",
|
|
759
|
+
"tortoise_create_edge": "graph", "tortoise_get_entity": "graph",
|
|
760
|
+
"tortoise_update_entity": "graph", "tortoise_delete_entity": "graph",
|
|
761
|
+
"tortoise_list_sources": "sources", "tortoise_create_source": "sources",
|
|
762
|
+
"tortoise_create_document": "sources", "tortoise_ingest_corpus": "sources",
|
|
763
|
+
# sessions
|
|
764
|
+
"tortoise_session_context": "sessions", "tortoise_get_session": "sessions",
|
|
765
|
+
"tortoise_index_sessions": "sessions", "tortoise_search_sessions": "sessions",
|
|
766
|
+
"tortoise_list_graphs": "sessions", "tortoise_list_namespaces": "sessions",
|
|
767
|
+
# journal
|
|
768
|
+
"tortoise_checkpoint": "journal", "tortoise_diary_write": "journal",
|
|
769
|
+
"tortoise_diary_read": "journal", "tortoise_file_decision": "journal",
|
|
770
|
+
"tortoise_file_human_approval": "journal",
|
|
771
|
+
# admin
|
|
772
|
+
"tortoise_status": "admin", "tortoise_health": "admin",
|
|
773
|
+
"tortoise_team_create": "admin", "tortoise_get_governance": "admin",
|
|
774
|
+
"tortoise_backfill_v25": "admin",
|
|
775
|
+
# onboarding
|
|
776
|
+
"tortoise_onboarding_demo_create": "onboarding", "tortoise_onboarding_state": "onboarding",
|
|
777
|
+
"tortoise_onboarding_session_recording": "onboarding",
|
|
778
|
+
"tortoise_onboarding_github_connect": "onboarding",
|
|
779
|
+
"tortoise_onboarding_github_index": "onboarding",
|
|
780
|
+
"tortoise_onboarding_github_status": "onboarding",
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def _apply_groups() -> list[ToolDefinition]:
|
|
785
|
+
"""Return the registry with curation groups assigned (frozen dataclass)."""
|
|
786
|
+
out = []
|
|
787
|
+
for t in TOOL_REGISTRY:
|
|
788
|
+
out.append(replace(t, group=GROUP_BY_NAME.get(t.name, "memory")))
|
|
789
|
+
return out
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
TOOL_REGISTRY = _apply_groups()
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
def tools_by_group(group: str) -> list[ToolDefinition]:
|
|
796
|
+
"""Tools in a curation group (e.g. "memory" — role-scoped server surface)."""
|
|
797
|
+
return [t for t in TOOL_REGISTRY if t.group == group]
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
def tool_groups() -> dict[str, list[str]]:
|
|
801
|
+
"""Group name → tool names (for docs / surface introspection)."""
|
|
802
|
+
out: dict[str, list[str]] = {}
|
|
803
|
+
for t in TOOL_REGISTRY:
|
|
804
|
+
out.setdefault(t.group, []).append(t.name)
|
|
805
|
+
return out
|