gts-agency-python-sdk 0.0.2rc3__tar.gz → 0.0.2rc4__tar.gz

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 (101) hide show
  1. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/PKG-INFO +1 -1
  2. gts_agency_python_sdk-0.0.2rc4/agency_sdk/__init__.py +8 -0
  3. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/client.py +6 -0
  4. gts_agency_python_sdk-0.0.2rc4/agency_sdk/delegates/graphs_client.py +18 -0
  5. gts_agency_python_sdk-0.0.2rc4/agency_sdk/delegates/graphs_dto.py +34 -0
  6. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/adk_fakes.py +24 -0
  7. gts_agency_python_sdk-0.0.2rc4/agency_sdk/test/test_adk_fakes_graphs.py +44 -0
  8. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_client_facade.py +19 -0
  9. gts_agency_python_sdk-0.0.2rc4/agency_sdk/test/test_contract_graphs.py +54 -0
  10. gts_agency_python_sdk-0.0.2rc4/agency_sdk/test/test_graphs_client.py +179 -0
  11. gts_agency_python_sdk-0.0.2rc4/agency_sdk/test/test_graphs_docs.py +49 -0
  12. gts_agency_python_sdk-0.0.2rc4/agency_sdk/test/test_graphs_dto.py +58 -0
  13. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/gts_agency_python_sdk.egg-info/PKG-INFO +1 -1
  14. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/gts_agency_python_sdk.egg-info/SOURCES.txt +7 -0
  15. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/pyproject.toml +2 -2
  16. gts_agency_python_sdk-0.0.2rc3/agency_sdk/test/__init__.py +0 -0
  17. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/LICENSE +0 -0
  18. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/README.md +0 -0
  19. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/__init__.py +0 -0
  20. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/_records.py +0 -0
  21. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/_store.py +0 -0
  22. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/durable.py +0 -0
  23. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/errors.py +0 -0
  24. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/adk/session_service.py +0 -0
  25. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/auth_hooks.py +0 -0
  26. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/credentials.py +0 -0
  27. {gts_agency_python_sdk-0.0.2rc3/agency_sdk → gts_agency_python_sdk-0.0.2rc4/agency_sdk/delegates}/__init__.py +0 -0
  28. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/annotations_client.py +0 -0
  29. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/annotations_dto.py +0 -0
  30. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/base_client.py +0 -0
  31. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/datasets_client.py +0 -0
  32. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/datasets_dto.py +0 -0
  33. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/datasource_client.py +0 -0
  34. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/datasource_dto.py +0 -0
  35. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/files_client.py +0 -0
  36. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/files_dto.py +0 -0
  37. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/gateway_client.py +0 -0
  38. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/gateway_dto.py +0 -0
  39. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/ontology_client.py +0 -0
  40. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/ontology_dto.py +0 -0
  41. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/prompts_client.py +0 -0
  42. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/rules_client.py +0 -0
  43. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/rules_dto.py +0 -0
  44. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_client.py +0 -0
  45. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_dto.py +0 -0
  46. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_hitl_client.py +0 -0
  47. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_hitl_dto.py +0 -0
  48. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_templates_client.py +0 -0
  49. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_templates_dto.py +0 -0
  50. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_vault_client.py +0 -0
  51. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/session_vault_dto.py +0 -0
  52. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/work_queue_client.py +0 -0
  53. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/delegates/work_queue_dto.py +0 -0
  54. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/domain.py +0 -0
  55. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/observability/__init__.py +0 -0
  56. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/observability/auth.py +0 -0
  57. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/observability/bootstrap.py +0 -0
  58. {gts_agency_python_sdk-0.0.2rc3/agency_sdk/delegates → gts_agency_python_sdk-0.0.2rc4/agency_sdk/test}/__init__.py +0 -0
  59. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/adk_llm_fakes.py +0 -0
  60. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/adk_proc.py +0 -0
  61. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/conftest.py +0 -0
  62. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_docs.py +0 -0
  63. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_durable.py +0 -0
  64. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_hitl.py +0 -0
  65. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_integration.py +0 -0
  66. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_phi_sentinel.py +0 -0
  67. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_session_service.py +0 -0
  68. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_adk_store.py +0 -0
  69. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_annotations_client.py +0 -0
  70. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_annotations_dto.py +0 -0
  71. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_base_client.py +0 -0
  72. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_credentials.py +0 -0
  73. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_datasets_client.py +0 -0
  74. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_files_client.py +0 -0
  75. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_files_dto.py +0 -0
  76. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_gateway_dto.py +0 -0
  77. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_gateway_facade.py +0 -0
  78. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_gateway_openai.py +0 -0
  79. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_observability_auth.py +0 -0
  80. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_observability_facade_threadsafety.py +0 -0
  81. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_observability_langfuse.py +0 -0
  82. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_observability_packaging.py +0 -0
  83. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_observability_pipeline.py +0 -0
  84. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_ontology_client.py +0 -0
  85. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_ontology_dto.py +0 -0
  86. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_client.py +0 -0
  87. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_dto.py +0 -0
  88. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_hitl_client.py +0 -0
  89. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_lookup_and_register.py +0 -0
  90. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_templates_client.py +0 -0
  91. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_templates_dto.py +0 -0
  92. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_vault_client.py +0 -0
  93. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_vault_dto.py +0 -0
  94. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_session_vault_versioned.py +0 -0
  95. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_stub_requests.py +0 -0
  96. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_work_queue_client.py +0 -0
  97. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/agency_sdk/test/test_work_queue_dto.py +0 -0
  98. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/gts_agency_python_sdk.egg-info/dependency_links.txt +0 -0
  99. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/gts_agency_python_sdk.egg-info/requires.txt +0 -0
  100. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/gts_agency_python_sdk.egg-info/top_level.txt +0 -0
  101. {gts_agency_python_sdk-0.0.2rc3 → gts_agency_python_sdk-0.0.2rc4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gts-agency_python-sdk
3
- Version: 0.0.2rc3
3
+ Version: 0.0.2rc4
4
4
  Author-email: Ground Control Systems <engineering@groundcontrolsystems.com>
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,8 @@
1
+ """GTS Agency Python SDK. Build an ``agency_sdk.client.AgencyClient`` to call the platform.
2
+
3
+ The names below are re-exported for convenience; importing the package stays light (DTOs only).
4
+ """
5
+
6
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphEntry, KnowledgeGraphList
7
+
8
+ __all__ = ["KnowledgeGraphEntry", "KnowledgeGraphList"]
@@ -8,6 +8,7 @@ from agency_sdk.delegates.annotations_client import AgencyAnnotationsClient
8
8
  from agency_sdk.delegates.datasets_client import AgencyDatasetsClient
9
9
  from agency_sdk.delegates.datasource_client import AgencyDatasourceClient
10
10
  from agency_sdk.delegates.files_client import AgencyFilesClient
11
+ from agency_sdk.delegates.graphs_client import AgencyGraphsClient
11
12
  from agency_sdk.delegates.ontology_client import AgencyOntologyClient
12
13
  from agency_sdk.delegates.prompts_client import AgencyPromptsClient
13
14
  from agency_sdk.delegates.rules_client import AgencyRulesClient
@@ -44,6 +45,7 @@ class AgencyClient:
44
45
  )
45
46
  self.annotations_client = AgencyAnnotationsClient(token_supplier=token_supplier, base_url=self.base_url)
46
47
  self.session_hitl_client = AgencySessionHitlClient(token_supplier=token_supplier, base_url=self.base_url)
48
+ self.graphs_client = AgencyGraphsClient(token_supplier=token_supplier, base_url=self.base_url)
47
49
  self._observability: "Observability | None" = None
48
50
  self._observability_lock = threading.Lock()
49
51
  self._gateway_clients: "dict[tuple[str, str | None, str | None], AgencyGatewayClient]" = {}
@@ -86,6 +88,10 @@ class AgencyClient:
86
88
  def annotations(self) -> AgencyAnnotationsClient:
87
89
  return self.annotations_client
88
90
 
91
+ def graphs(self) -> AgencyGraphsClient:
92
+ """Knowledge-graph reads: the org's catalogue and a condition's known subgraph."""
93
+ return self.graphs_client
94
+
89
95
  def gateway(
90
96
  self,
91
97
  *,
@@ -0,0 +1,18 @@
1
+ """Knowledge-graph reads through comand: the org's knowledge-graph catalogue."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from agency_sdk.delegates.base_client import BaseDelegateClient
6
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphList
7
+
8
+ __all__ = ["AgencyGraphsClient"]
9
+
10
+
11
+ class AgencyGraphsClient(BaseDelegateClient):
12
+ api_path = "/api/knowledge-graphs"
13
+
14
+ def list(self, organisation_id: int) -> KnowledgeGraphList:
15
+ """Return the org's knowledge-graph catalogue (``GET /api/knowledge-graphs?o=``). Not paged."""
16
+ body = self._make_request("GET", "", params={"o": str(organisation_id)})
17
+ catalogue: KnowledgeGraphList = KnowledgeGraphList.model_validate(body)
18
+ return catalogue
@@ -0,0 +1,34 @@
1
+ """DTOs for the knowledge-graphs delegate (snake_case, matching the API).
2
+
3
+ :class:`KnowledgeGraphList` / :class:`KnowledgeGraphEntry` mirror comand's ``ListKnowledgeGraphsResponse``
4
+ (``service/knowledge_graphs/knowledge_graph_service.rs``): the built-in catalogue with the org's ``enabled``
5
+ flag. ``credential_variable_id`` and ``config`` are omitted by the server when unset, and both are hidden
6
+ from ``repr`` because ``config`` is operator configuration that should never reach a log line.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from pydantic import BaseModel, ConfigDict, Field
14
+
15
+
16
+ class KnowledgeGraphEntry(BaseModel):
17
+ """One knowledge graph in the org's catalogue."""
18
+
19
+ model_config = ConfigDict(extra="allow")
20
+
21
+ code: str
22
+ name: str
23
+ description: str
24
+ enabled: bool
25
+ credential_variable_id: str | None = Field(default=None, repr=False)
26
+ config: Any = Field(default=None, repr=False)
27
+
28
+
29
+ class KnowledgeGraphList(BaseModel):
30
+ """``GET /api/knowledge-graphs?o=`` response. Not paged."""
31
+
32
+ model_config = ConfigDict(extra="allow")
33
+
34
+ items: list[KnowledgeGraphEntry]
@@ -14,6 +14,9 @@ way comand does: ``user`` to the session's bound owner (403 when none is bound
14
14
  Pass ``path=`` to persist everything to a JSON file under an exclusive ``flock``, so separate
15
15
  processes (the cross-process read-back and SIGKILL scenarios) share one fake backend.
16
16
 
17
+ ``FakeGraphs`` (``cp.graphs``) is a duck-typed ``AgencyGraphsClient``: seed it with ``add_graph``. Set
18
+ ``error`` to make every call raise it (e.g. ``http_error(500)``).
19
+
17
20
  Hooks for failure injection: ``FakeVault.on_set(key, apply)`` runs instead of a plain write (call
18
21
  ``apply()`` to commit); ``FakeVault.get_delay`` makes every ``get`` sleep.
19
22
  """
@@ -34,6 +37,7 @@ from typing import Any, Callable, Iterator
34
37
  import requests
35
38
 
36
39
  from agency_sdk.delegates.datasets_dto import Page
40
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphEntry, KnowledgeGraphList
37
41
  from agency_sdk.delegates.session_dto import SessionCommandResponse, SessionRef, SessionSearchResult
38
42
  from agency_sdk.delegates.session_hitl_client import HitlAlreadyAnswered, HitlNotAuthorised, HitlRequestExpired
39
43
  from agency_sdk.delegates.session_hitl_dto import HitlRequest
@@ -323,6 +327,7 @@ class FakeControlPlane:
323
327
  self.sessions = _FakeSessions(self)
324
328
  self.templates = _FakeTemplates(self)
325
329
  self.hitl = _FakeHitl(self)
330
+ self.graphs = FakeGraphs()
326
331
  self.log: list[tuple[str, dict[str, Any]]] = []
327
332
 
328
333
  def _scope_space(self, session_id: str, scope: str) -> str | None:
@@ -515,3 +520,22 @@ class _FakeHitl:
515
520
  answered_at="2026-10-12T01:00:00Z",
516
521
  )
517
522
  return HitlRequest(**record)
523
+
524
+
525
+ class FakeGraphs:
526
+ """In-memory ``AgencyGraphsClient``: the knowledge-graph catalogue."""
527
+
528
+ def __init__(self) -> None:
529
+ self._graphs: list[KnowledgeGraphEntry] = []
530
+ #: Raised by every call while set (failure injection).
531
+ self.error: Exception | None = None
532
+ self.calls: list[tuple[str, dict[str, Any]]] = []
533
+
534
+ def add_graph(self, code: str, *, name: str = "", description: str = "", enabled: bool = True) -> None:
535
+ self._graphs.append(KnowledgeGraphEntry(code=code, name=name or code, description=description, enabled=enabled))
536
+
537
+ def list(self, organisation_id: int) -> KnowledgeGraphList:
538
+ self.calls.append(("list", {"organisation_id": organisation_id}))
539
+ if self.error is not None:
540
+ raise self.error
541
+ return KnowledgeGraphList(items=list(self._graphs))
@@ -0,0 +1,44 @@
1
+ """Parity tests: ``FakeGraphs`` must match the real graphs delegate's signature."""
2
+
3
+ import inspect
4
+
5
+ import pytest
6
+ import requests
7
+
8
+ from agency_sdk.delegates.graphs_client import AgencyGraphsClient
9
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphList
10
+ from agency_sdk.test.adk_fakes import FakeControlPlane, FakeGraphs, http_error
11
+
12
+
13
+ def test_fake_signature_matches_real():
14
+ """TS-22."""
15
+ assert inspect.signature(FakeGraphs.list) == inspect.signature(AgencyGraphsClient.list)
16
+
17
+
18
+ def test_fake_hangs_off_control_plane():
19
+ assert isinstance(FakeControlPlane().graphs, FakeGraphs)
20
+
21
+
22
+ def test_fake_list():
23
+ graphs = FakeGraphs()
24
+ assert graphs.list(2).items == []
25
+
26
+ graphs.add_graph("medical-ontology", name="Medical Ontology", enabled=True)
27
+ result = graphs.list(2)
28
+
29
+ assert isinstance(result, KnowledgeGraphList)
30
+ assert [(e.code, e.enabled) for e in result.items] == [("medical-ontology", True)]
31
+ assert graphs.calls[-1] == ("list", {"organisation_id": 2})
32
+
33
+
34
+ def test_fake_error_injection():
35
+ """TS-24."""
36
+ graphs = FakeGraphs()
37
+ graphs.error = http_error(500)
38
+
39
+ with pytest.raises(requests.HTTPError) as info:
40
+ graphs.list(2)
41
+ assert info.value.response.status_code == 500
42
+
43
+ graphs.error = None
44
+ assert graphs.list(2).items == []
@@ -103,3 +103,22 @@ def test_facade_returns_same_annotations_instance(fake_credentials):
103
103
  client = AgencyClient(token_supplier=fake_credentials, base_url="http://cp.test")
104
104
 
105
105
  assert client.annotations() is client.annotations()
106
+
107
+
108
+ def test_graphs_accessor_and_root_exports(fake_credentials):
109
+ """TS-21: AgencyClient.graphs() shares the supplier; DTOs are exported from the package root."""
110
+ import agency_sdk
111
+ from agency_sdk.delegates import graphs_dto
112
+ from agency_sdk.delegates.graphs_client import AgencyGraphsClient
113
+
114
+ client = AgencyClient(token_supplier=fake_credentials, base_url="http://cp.test/")
115
+
116
+ graphs = client.graphs()
117
+
118
+ assert isinstance(graphs, AgencyGraphsClient)
119
+ assert graphs.token_supplier is fake_credentials
120
+ assert graphs.base_url == "http://cp.test"
121
+ assert client.graphs() is graphs
122
+ for name in ("KnowledgeGraphEntry", "KnowledgeGraphList"):
123
+ assert getattr(agency_sdk, name) is getattr(graphs_dto, name)
124
+ assert name in agency_sdk.__all__
@@ -0,0 +1,54 @@
1
+ """Contract smoke for the graphs delegate against a NON-PRODUCTION comand (opt-in: ``pytest -m integration``).
2
+
3
+ Scenario: TS-27 list.
4
+
5
+ Environment:
6
+ - ``AGENCY_AUTH_URL``, ``AGENCY_API_URL``, ``AGENCY_CLIENT_ID``, ``AGENCY_CLIENT_SECRET`` for a dedicated
7
+ non-production **service account** (never a personal or pasted browser token); ``AGENCY_ORG_ID`` (default 2).
8
+
9
+ The probe skips the module when comand is not configured or unreachable. A skip never satisfies the
10
+ release gate. Nothing here prints credentials or ``config``.
11
+ """
12
+
13
+ import os
14
+
15
+ import pytest
16
+ import requests
17
+
18
+ pytestmark = pytest.mark.integration
19
+
20
+ REQUIRED_ENV = ("AGENCY_AUTH_URL", "AGENCY_API_URL", "AGENCY_CLIENT_ID", "AGENCY_CLIENT_SECRET")
21
+
22
+
23
+ def _org() -> int:
24
+ return int(os.environ.get("AGENCY_ORG_ID", "2"))
25
+
26
+
27
+ @pytest.fixture(scope="module")
28
+ def client():
29
+ """Probe: configured env, a token, and comand answering the knowledge-graph list."""
30
+ missing = [n for n in REQUIRED_ENV if not os.environ.get(n)]
31
+ if missing:
32
+ pytest.skip(f"non-prod comand not configured: {', '.join(missing)}")
33
+ from agency_sdk.client import AgencyClient, CredentialsSupplier
34
+
35
+ credentials = CredentialsSupplier(
36
+ auth_base_url=os.environ["AGENCY_AUTH_URL"],
37
+ client_id=os.environ["AGENCY_CLIENT_ID"],
38
+ client_secret=os.environ["AGENCY_CLIENT_SECRET"],
39
+ )
40
+ agency = AgencyClient(token_supplier=credentials, base_url=os.environ["AGENCY_API_URL"])
41
+ try:
42
+ agency.graphs().list(_org())
43
+ except requests.RequestException as exc:
44
+ pytest.skip(f"graphs contract probe failed: {type(exc).__name__}")
45
+ return agency
46
+
47
+
48
+ def test_list_contract(client):
49
+ """TS-27."""
50
+ catalogue = client.graphs().list(_org())
51
+
52
+ entry = next((e for e in catalogue.items if e.code == "medical-ontology"), None)
53
+ assert entry is not None, "medical-ontology missing from the catalogue"
54
+ assert entry.enabled, "medical-ontology is not enabled for this org"
@@ -0,0 +1,179 @@
1
+ """Graphs delegate tests: the knowledge-graph list.
2
+
3
+ Synthetic data only. The canary token is not a real credential.
4
+ """
5
+
6
+ import pytest
7
+ import requests
8
+ from pydantic import ValidationError
9
+
10
+ from agency_sdk.delegates import base_client
11
+ from agency_sdk.delegates.graphs_client import AgencyGraphsClient
12
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphList
13
+
14
+ BASE = "http://cp.test"
15
+ ORG = 2
16
+ CANARY = "CANARY-TOKEN-NOT-REAL"
17
+
18
+ KG_BODY = {
19
+ "items": [
20
+ {
21
+ "code": "medical-ontology",
22
+ "name": "Medical Ontology",
23
+ "description": "Built-in",
24
+ "enabled": True,
25
+ "credential_variable_id": "var-1",
26
+ "config": {"base_url": "https://example.invalid"},
27
+ },
28
+ {"code": "other", "name": "Other", "description": "", "enabled": False},
29
+ ]
30
+ }
31
+
32
+
33
+ @pytest.fixture
34
+ def client(fake_credentials):
35
+ return AgencyGraphsClient(token_supplier=fake_credentials, base_url=BASE)
36
+
37
+
38
+ @pytest.fixture
39
+ def no_sleep(monkeypatch):
40
+ monkeypatch.setattr(base_client.time, "sleep", lambda _s: None)
41
+
42
+
43
+ # --------------------------------------------------------------------------- list (UC-01)
44
+
45
+
46
+ def test_list_returns_items(stub_requests, client):
47
+ """TS-01."""
48
+ stub_requests.queue(KG_BODY)
49
+
50
+ result = client.list(ORG)
51
+
52
+ assert isinstance(result, KnowledgeGraphList)
53
+ assert [e.code for e in result.items] == ["medical-ontology", "other"]
54
+ assert result.items[1].config is None and result.items[1].credential_variable_id is None
55
+
56
+
57
+ def test_list_wire(stub_requests, client):
58
+ """TS-02."""
59
+ stub_requests.queue(KG_BODY)
60
+
61
+ client.list(ORG)
62
+
63
+ (call,) = stub_requests.calls
64
+ assert call.method == "GET"
65
+ assert call.url == f"{BASE}/api/knowledge-graphs"
66
+ assert call.kwargs["params"] == {"o": str(ORG)}
67
+ assert call.kwargs["headers"]["Authorization"] == "Bearer test-token"
68
+
69
+
70
+ @pytest.mark.parametrize("status", [401, 403, 500])
71
+ def test_list_errors_raise(stub_requests, client, status):
72
+ """TS-03 (HTTP statuses)."""
73
+ stub_requests.queue({"error": "x"}, status_code=status)
74
+
75
+ with pytest.raises(requests.HTTPError) as info:
76
+ client.list(ORG)
77
+ assert info.value.response.status_code == status
78
+ assert len(stub_requests.calls) == 1
79
+
80
+
81
+ @pytest.mark.parametrize("error, expected_calls", [(requests.ConnectionError, 3), (requests.ReadTimeout, 1)])
82
+ def test_list_transport_errors_raise(monkeypatch, no_sleep, client, error, expected_calls):
83
+ """TS-03 (transport): connection errors retry to 3 attempts, read timeouts never retry."""
84
+ calls = []
85
+
86
+ def boom(method, url, **kwargs):
87
+ calls.append(url)
88
+ raise error("down")
89
+
90
+ monkeypatch.setattr(requests, "request", boom)
91
+ with pytest.raises(error):
92
+ client.list(ORG)
93
+ assert len(calls) == expected_calls
94
+
95
+
96
+ @pytest.mark.parametrize(
97
+ "queue_kwargs",
98
+ [
99
+ {"json_data": []},
100
+ {"json_data": None, "content_bytes": b"null"},
101
+ {"json_data": {}},
102
+ {"json_data": {"items": {}}},
103
+ {"json_data": {"items": [{"name": "x", "description": "", "enabled": True}]}},
104
+ ],
105
+ )
106
+ def test_list_malformed_raises(stub_requests, client, queue_kwargs):
107
+ """TS-04."""
108
+ stub_requests.queue(**queue_kwargs)
109
+
110
+ with pytest.raises(ValidationError):
111
+ client.list(ORG)
112
+
113
+
114
+ # --------------------------------------------------------------------------- token secrecy (NFR-01, TM-1)
115
+
116
+
117
+ class CanaryCredentials:
118
+ def bearer_token(self) -> str:
119
+ return CANARY
120
+
121
+
122
+ def _real_response_factory(plan):
123
+ """Build real requests.Response objects (with a PreparedRequest) from a list of (status, body bytes)."""
124
+ sent = []
125
+
126
+ def fake_request(method, url, **kwargs):
127
+ sent.append(kwargs)
128
+ status, body = plan.pop(0)
129
+ prepared = requests.Request(method, url, headers=kwargs["headers"], params=kwargs["params"]).prepare()
130
+ response = requests.Response()
131
+ response.status_code = status
132
+ response._content = body # noqa: SLF001
133
+ response.url = prepared.url
134
+ response.request = prepared
135
+ response.reason = "X"
136
+ return response
137
+
138
+ return fake_request, sent
139
+
140
+
141
+ FAILING_PLANS = [
142
+ [(401, b'{"error": "unauthorised"}')],
143
+ [(500, b"{}")],
144
+ [(200, b"[]")],
145
+ ]
146
+
147
+
148
+ @pytest.mark.parametrize("plan", FAILING_PLANS)
149
+ def test_canary_token_absent(monkeypatch, plan):
150
+ """TS-18: the bearer never appears in an exception's str/repr/args on any failing path."""
151
+ fake_request, _sent = _real_response_factory(list(plan))
152
+ monkeypatch.setattr(requests, "request", fake_request)
153
+ graphs = AgencyGraphsClient(token_supplier=CanaryCredentials(), base_url=BASE)
154
+
155
+ with pytest.raises(Exception) as info:
156
+ graphs.list(ORG)
157
+
158
+ exc = info.value
159
+ for text in (str(exc), repr(exc), repr(exc.args)):
160
+ assert CANARY not in text
161
+
162
+
163
+ def test_token_only_in_header(monkeypatch):
164
+ """TS-19: on success the token travels only in the Authorization header and never reaches a DTO."""
165
+ plan = [
166
+ (200, b'{"items": [{"code": "medical-ontology", "name": "MO", "description": "", "enabled": true}]}'),
167
+ ]
168
+ fake_request, sent = _real_response_factory(plan)
169
+ monkeypatch.setattr(requests, "request", fake_request)
170
+ graphs = AgencyGraphsClient(token_supplier=CanaryCredentials(), base_url=BASE)
171
+
172
+ kg = graphs.list(ORG)
173
+
174
+ for kwargs in sent:
175
+ assert kwargs["headers"]["Authorization"] == f"Bearer {CANARY}"
176
+ assert CANARY not in repr(kwargs["params"])
177
+ assert kwargs.get("json") is None
178
+ assert CANARY not in repr(kg)
179
+ assert CANARY not in repr(kg.model_dump())
@@ -0,0 +1,49 @@
1
+ """TS-30: the graphs doc carries its security warnings, and its example runs on the fakes."""
2
+
3
+ import pathlib
4
+ import re
5
+
6
+ from agency_sdk.test.adk_fakes import FakeGraphs
7
+
8
+ ROOT = pathlib.Path(__file__).resolve().parents[2]
9
+ DOC = ROOT / "docs" / "graphs.md"
10
+
11
+
12
+ def _doc() -> str:
13
+ return DOC.read_text()
14
+
15
+
16
+ def test_doc_warns_against_logging_headers_and_config():
17
+ text = _doc()
18
+ assert "exc.response.request.headers" in text
19
+ assert re.search(r"never log[^\n]*`config`", text, re.I)
20
+
21
+
22
+ def test_doc_warns_against_http_base_url():
23
+ assert re.search(r"`http://`[^\n]*base URL", _doc(), re.I)
24
+
25
+
26
+ def test_doc_warns_never_to_send_the_token_to_config_base_url():
27
+ assert re.search(r"never send[^\n]*token[^\n]*`config\.base_url`", _doc(), re.I)
28
+
29
+
30
+ def test_claude_md_lists_graphs_delegate():
31
+ text = (ROOT / "CLAUDE.md").read_text()
32
+ assert "graphs_client.py" in text
33
+ assert "thirteen delegate clients" in text
34
+
35
+
36
+ def test_doc_example_runs_against_fakes():
37
+ match = re.search(r"<!-- graphs-example -->\n```python\n(.*?)```", _doc(), re.S)
38
+ assert match, "graphs example block not found"
39
+ graphs = FakeGraphs()
40
+ graphs.add_graph("medical-ontology", name="Medical Ontology")
41
+ graphs.add_graph("other", enabled=False)
42
+
43
+ class _Client:
44
+ def graphs(self):
45
+ return graphs
46
+
47
+ namespace = {"client": _Client(), "org_id": 2}
48
+ exec(match.group(1), namespace) # nosec B102 - our own doc
49
+ assert namespace["enabled"] == ["medical-ontology"]
@@ -0,0 +1,58 @@
1
+ """DTO tests for the graphs delegate.
2
+
3
+ Shapes mirror comand's ``ListKnowledgeGraphsResponse`` (knowledge_graph_service.rs). Synthetic data only.
4
+ """
5
+
6
+ import pytest
7
+ from pydantic import ValidationError
8
+
9
+ from agency_sdk.delegates.graphs_dto import KnowledgeGraphEntry, KnowledgeGraphList
10
+
11
+ CANARY = "CANARY-TOKEN-NOT-REAL"
12
+
13
+
14
+ def test_knowledge_graph_list_parses_full_and_minimal_entries():
15
+ body = {
16
+ "items": [
17
+ {
18
+ "code": "medical-ontology",
19
+ "name": "Medical Ontology",
20
+ "description": "Built-in clinical knowledge graph",
21
+ "enabled": True,
22
+ "credential_variable_id": "var-1",
23
+ "config": {"base_url": "https://example.invalid"},
24
+ },
25
+ {"code": "other", "name": "Other", "description": "", "enabled": False},
26
+ ]
27
+ }
28
+ kg = KnowledgeGraphList.model_validate(body)
29
+
30
+ assert [e.code for e in kg.items] == ["medical-ontology", "other"]
31
+ assert kg.items[0].enabled is True
32
+ assert kg.items[0].config == {"base_url": "https://example.invalid"}
33
+ assert kg.items[1].credential_variable_id is None
34
+ assert kg.items[1].config is None
35
+
36
+
37
+ @pytest.mark.parametrize("body", [{}, {"items": {}}, {"items": [{"name": "x", "description": "", "enabled": True}]}])
38
+ def test_knowledge_graph_list_rejects_malformed(body):
39
+ with pytest.raises(ValidationError):
40
+ KnowledgeGraphList.model_validate(body)
41
+
42
+
43
+ def test_repr_hides_config():
44
+ """TS-20: config and credential_variable_id never appear in repr, but stay readable."""
45
+ entry = KnowledgeGraphEntry(
46
+ code="medical-ontology",
47
+ name="Medical Ontology",
48
+ description="",
49
+ enabled=True,
50
+ credential_variable_id=f"var-{CANARY}",
51
+ config={"base_url": f"https://{CANARY}.example.invalid"},
52
+ )
53
+
54
+ assert CANARY not in repr(entry)
55
+ assert CANARY not in str(entry)
56
+ assert CANARY not in repr(KnowledgeGraphList(items=[entry]))
57
+ assert entry.credential_variable_id == f"var-{CANARY}"
58
+ assert entry.config == {"base_url": f"https://{CANARY}.example.invalid"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gts-agency_python-sdk
3
- Version: 0.0.2rc3
3
+ Version: 0.0.2rc4
4
4
  Author-email: Ground Control Systems <engineering@groundcontrolsystems.com>
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -24,6 +24,8 @@ agency_sdk/delegates/files_client.py
24
24
  agency_sdk/delegates/files_dto.py
25
25
  agency_sdk/delegates/gateway_client.py
26
26
  agency_sdk/delegates/gateway_dto.py
27
+ agency_sdk/delegates/graphs_client.py
28
+ agency_sdk/delegates/graphs_dto.py
27
29
  agency_sdk/delegates/ontology_client.py
28
30
  agency_sdk/delegates/ontology_dto.py
29
31
  agency_sdk/delegates/prompts_client.py
@@ -49,6 +51,7 @@ agency_sdk/test/adk_proc.py
49
51
  agency_sdk/test/conftest.py
50
52
  agency_sdk/test/test_adk_docs.py
51
53
  agency_sdk/test/test_adk_durable.py
54
+ agency_sdk/test/test_adk_fakes_graphs.py
52
55
  agency_sdk/test/test_adk_hitl.py
53
56
  agency_sdk/test/test_adk_integration.py
54
57
  agency_sdk/test/test_adk_phi_sentinel.py
@@ -58,6 +61,7 @@ agency_sdk/test/test_annotations_client.py
58
61
  agency_sdk/test/test_annotations_dto.py
59
62
  agency_sdk/test/test_base_client.py
60
63
  agency_sdk/test/test_client_facade.py
64
+ agency_sdk/test/test_contract_graphs.py
61
65
  agency_sdk/test/test_credentials.py
62
66
  agency_sdk/test/test_datasets_client.py
63
67
  agency_sdk/test/test_files_client.py
@@ -65,6 +69,9 @@ agency_sdk/test/test_files_dto.py
65
69
  agency_sdk/test/test_gateway_dto.py
66
70
  agency_sdk/test/test_gateway_facade.py
67
71
  agency_sdk/test/test_gateway_openai.py
72
+ agency_sdk/test/test_graphs_client.py
73
+ agency_sdk/test/test_graphs_docs.py
74
+ agency_sdk/test/test_graphs_dto.py
68
75
  agency_sdk/test/test_observability_auth.py
69
76
  agency_sdk/test/test_observability_facade_threadsafety.py
70
77
  agency_sdk/test/test_observability_langfuse.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gts-agency_python-sdk"
7
- version = "0.0.2rc3"
7
+ version = "0.0.2rc4"
8
8
  description = ""
9
9
  requires-python = ">=3.12"
10
10
  authors = [{name="Ground Control Systems", email="engineering@groundcontrolsystems.com"}]
@@ -46,7 +46,7 @@ testpaths = ["agency_sdk/test"]
46
46
  # The integration suite talks to a local comand (docs/local_e2e.md); opt in with `pytest -m integration`.
47
47
  addopts = "-m 'not integration'"
48
48
  markers = [
49
- "integration: runs against a local comand with the Agent Vault endpoints (opt-in; skips when the contract probe fails)",
49
+ "integration: runs against a local or non-production comand (Agent Vault endpoints, graphs contract smoke; opt-in; skips when the contract probe fails)",
50
50
  ]
51
51
 
52
52
  [tool.coverage.run]