orchid-storage-postgres 1.2.0__tar.gz → 1.3.0__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.
- orchid_storage_postgres-1.3.0/.gitignore +11 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/PKG-INFO +2 -2
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/__init__.py +1 -1
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/chat_storage.py +1 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/event_storage.py +11 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/pyproject.toml +1 -1
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_event_storage.py +111 -4
- orchid_storage_postgres-1.2.0/.gitignore +0 -8
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/.github/workflows/ci.yml +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/.pre-commit-config.yaml +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/AGENTS.md +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/CHANGELOG.md +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/LICENSE +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/README.md +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/config_storage.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/event_queue.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/ingestion_manifest.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_client_registration_store.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_gateway_state_store.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_token_store.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/__init__.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/_schema_ddl.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/v001_initial_schema.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/v002_ingestion_manifest.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/visibility.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_chat_storage.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_checkpointer.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_config_storage.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_ingestion_manifest.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_mcp_stores.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_migration.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_postgres_queue.py +0 -0
- {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_visibility.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: orchid-storage-postgres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: PostgreSQL storage backend plugin for the Orchid AI framework
|
|
5
5
|
Project-URL: Homepage, https://github.com/gadz82/orchid-storage-postgres
|
|
6
6
|
Project-URL: Issues, https://github.com/gadz82/orchid-storage-postgres/issues
|
|
@@ -17,7 +17,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
17
17
|
Requires-Python: >=3.11
|
|
18
18
|
Requires-Dist: asyncpg>=0.29.0
|
|
19
19
|
Requires-Dist: langgraph-checkpoint-postgres>=2.0.0
|
|
20
|
-
Requires-Dist: orchid-ai>=1.
|
|
20
|
+
Requires-Dist: orchid-ai>=1.13.0
|
|
21
21
|
Provides-Extra: dev
|
|
22
22
|
Requires-Dist: pytest-asyncio>=0.25.0; extra == 'dev'
|
|
23
23
|
Requires-Dist: pytest-cov>=6.0; extra == 'dev'
|
|
@@ -21,6 +21,7 @@ from .migrations import PostgresMigrationRunner
|
|
|
21
21
|
logger = logging.getLogger(__name__)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
# ORCHID-MEM: 01a1a0c1-dc9c-7bcd-bd96-1cfe8dd8f581 — PostgreSQL chat storage and migrations
|
|
24
25
|
class OrchidPostgresChatStorage(OrchidChatStorage):
|
|
25
26
|
"""Async PostgreSQL storage for chat sessions and messages.
|
|
26
27
|
|
|
@@ -558,6 +558,11 @@ def _row_to_run(row: Any) -> JobRun:
|
|
|
558
558
|
visibility=spec_dict.get("visibility", row["visibility"]),
|
|
559
559
|
visibility_user_id=spec_dict.get("visibility_user_id", row["visibility_user_id"]),
|
|
560
560
|
chat_binding=spec_dict.get("chat_binding"),
|
|
561
|
+
proactive_chat=bool(spec_dict.get("proactive_chat", False)),
|
|
562
|
+
target=spec_dict.get("target", "agent"),
|
|
563
|
+
pipeline_name=spec_dict.get("pipeline_name"),
|
|
564
|
+
pipeline_input=spec_dict.get("pipeline_input"),
|
|
565
|
+
persist_graph=bool(spec_dict.get("persist_graph", False)),
|
|
561
566
|
)
|
|
562
567
|
return JobRun(
|
|
563
568
|
run_id=row["run_id"],
|
|
@@ -597,6 +602,7 @@ def _row_to_trigger(row: Any) -> OrchidTriggerRecord:
|
|
|
597
602
|
)
|
|
598
603
|
|
|
599
604
|
|
|
605
|
+
# ORCHID-MEM: 01a1f342-9e1e-727a-9738-8798af747ef6 — Job spec persistence; every field is serialized and old rows default to the agent target.
|
|
600
606
|
def _jobspec_to_dict(spec: JobSpec) -> dict[str, Any]:
|
|
601
607
|
return {
|
|
602
608
|
"trigger_id": spec.trigger_id,
|
|
@@ -609,4 +615,9 @@ def _jobspec_to_dict(spec: JobSpec) -> dict[str, Any]:
|
|
|
609
615
|
"visibility": spec.visibility,
|
|
610
616
|
"visibility_user_id": spec.visibility_user_id,
|
|
611
617
|
"chat_binding": spec.chat_binding,
|
|
618
|
+
"proactive_chat": spec.proactive_chat,
|
|
619
|
+
"target": spec.target,
|
|
620
|
+
"pipeline_name": spec.pipeline_name,
|
|
621
|
+
"pipeline_input": spec.pipeline_input,
|
|
622
|
+
"persist_graph": spec.persist_graph,
|
|
612
623
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import datetime as _dt
|
|
6
|
+
import json
|
|
6
7
|
import uuid
|
|
7
8
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
8
9
|
|
|
9
10
|
import pytest
|
|
10
|
-
|
|
11
11
|
from orchid_ai.core.events.job import JobRun, JobSpec, JobStatus
|
|
12
12
|
from orchid_ai.core.events.signal import Signal
|
|
13
13
|
from orchid_ai.core.events.store import OrchidScheduleRecord, OrchidTriggerRecord
|
|
@@ -18,6 +18,7 @@ from orchid_storage_postgres.event_storage import (
|
|
|
18
18
|
PostgresScheduleStore,
|
|
19
19
|
PostgresSignalStore,
|
|
20
20
|
PostgresTriggerStore,
|
|
21
|
+
_jobspec_to_dict,
|
|
21
22
|
_maybe_load_jsonb,
|
|
22
23
|
_row_to_run,
|
|
23
24
|
_row_to_schedule,
|
|
@@ -57,9 +58,8 @@ class TestFacade:
|
|
|
57
58
|
@pytest.mark.asyncio
|
|
58
59
|
async def test_init_db_missing_asyncpg_raises_import_error(self):
|
|
59
60
|
store = PostgresEventStorage(dsn="postgresql://x")
|
|
60
|
-
with patch.dict("sys.modules", {"asyncpg": None}):
|
|
61
|
-
|
|
62
|
-
await store.init_db()
|
|
61
|
+
with patch.dict("sys.modules", {"asyncpg": None}), pytest.raises(ImportError):
|
|
62
|
+
await store.init_db()
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
# ── Signal store ────────────────────────────────────────────
|
|
@@ -276,6 +276,113 @@ class TestRowMappers:
|
|
|
276
276
|
assert result.trigger_id == "t1"
|
|
277
277
|
assert result.version == 2
|
|
278
278
|
|
|
279
|
+
def test_jobspec_to_dict_includes_pipeline_fields(self):
|
|
280
|
+
spec = JobSpec(
|
|
281
|
+
trigger_id="t-pipe",
|
|
282
|
+
signal_id=uuid.uuid4(),
|
|
283
|
+
agent_name="",
|
|
284
|
+
prompt="",
|
|
285
|
+
identity_claim={"mode": "service_account", "name": "digest-bot"},
|
|
286
|
+
correlation_id=None,
|
|
287
|
+
parallelism_key="sa:t:bot",
|
|
288
|
+
chat_binding={"chat_id": "C-1"},
|
|
289
|
+
proactive_chat=True,
|
|
290
|
+
target="pipeline",
|
|
291
|
+
pipeline_name="weekly_digest",
|
|
292
|
+
pipeline_input={"topic": "release notes"},
|
|
293
|
+
persist_graph=True,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
payload = _jobspec_to_dict(spec)
|
|
297
|
+
|
|
298
|
+
assert payload["target"] == "pipeline"
|
|
299
|
+
assert payload["pipeline_name"] == "weekly_digest"
|
|
300
|
+
assert payload["pipeline_input"] == {"topic": "release notes"}
|
|
301
|
+
assert payload["persist_graph"] is True
|
|
302
|
+
assert payload["proactive_chat"] is True
|
|
303
|
+
|
|
304
|
+
def test_jobspec_round_trip_keeps_every_field(self):
|
|
305
|
+
now = _dt.datetime.now(tz=_dt.UTC)
|
|
306
|
+
spec = JobSpec(
|
|
307
|
+
trigger_id="t-pipe",
|
|
308
|
+
signal_id=uuid.uuid4(),
|
|
309
|
+
agent_name="",
|
|
310
|
+
prompt="",
|
|
311
|
+
identity_claim={"mode": "service_account", "name": "digest-bot"},
|
|
312
|
+
correlation_id="corr",
|
|
313
|
+
parallelism_key="sa:t:bot",
|
|
314
|
+
visibility="admin",
|
|
315
|
+
visibility_user_id=None,
|
|
316
|
+
chat_binding={"chat_id": "C-1", "on_failure": "silent"},
|
|
317
|
+
proactive_chat=True,
|
|
318
|
+
target="pipeline",
|
|
319
|
+
pipeline_name="weekly_digest",
|
|
320
|
+
pipeline_input={"topic": "release notes", "limit": 3},
|
|
321
|
+
persist_graph=True,
|
|
322
|
+
)
|
|
323
|
+
row = {
|
|
324
|
+
"run_id": uuid.uuid4(),
|
|
325
|
+
# Cross the same JSON boundary the JSONB column uses.
|
|
326
|
+
"spec": json.loads(json.dumps(_jobspec_to_dict(spec))),
|
|
327
|
+
"attempt_number": 1,
|
|
328
|
+
"status": JobStatus.PENDING.value,
|
|
329
|
+
"queued_at": now,
|
|
330
|
+
"started_at": None,
|
|
331
|
+
"finished_at": None,
|
|
332
|
+
"result": None,
|
|
333
|
+
"error": None,
|
|
334
|
+
"next_retry_at": None,
|
|
335
|
+
"metadata": {},
|
|
336
|
+
"visibility": "admin",
|
|
337
|
+
"visibility_user_id": None,
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
run = _row_to_run(row)
|
|
341
|
+
|
|
342
|
+
assert run.spec.target == "pipeline"
|
|
343
|
+
assert run.spec.pipeline_name == "weekly_digest"
|
|
344
|
+
assert run.spec.pipeline_input == {"topic": "release notes", "limit": 3}
|
|
345
|
+
assert run.spec.persist_graph is True
|
|
346
|
+
assert run.spec.proactive_chat is True
|
|
347
|
+
assert run.spec.chat_binding == {"chat_id": "C-1", "on_failure": "silent"}
|
|
348
|
+
|
|
349
|
+
def test_row_to_run_defaults_new_fields_for_old_rows(self):
|
|
350
|
+
now = _dt.datetime.now(tz=_dt.UTC)
|
|
351
|
+
row = {
|
|
352
|
+
"run_id": uuid.uuid4(),
|
|
353
|
+
"spec": {
|
|
354
|
+
"trigger_id": "t1",
|
|
355
|
+
"signal_id": str(uuid.uuid4()),
|
|
356
|
+
"agent_name": "agent-a",
|
|
357
|
+
"prompt": "hello",
|
|
358
|
+
"identity_claim": {"tenant_key": "t"},
|
|
359
|
+
"correlation_id": None,
|
|
360
|
+
"parallelism_key": "tenant:t",
|
|
361
|
+
"visibility": "tenant",
|
|
362
|
+
"visibility_user_id": None,
|
|
363
|
+
"chat_binding": None,
|
|
364
|
+
},
|
|
365
|
+
"attempt_number": 1,
|
|
366
|
+
"status": JobStatus.PENDING.value,
|
|
367
|
+
"queued_at": now,
|
|
368
|
+
"started_at": None,
|
|
369
|
+
"finished_at": None,
|
|
370
|
+
"result": None,
|
|
371
|
+
"error": None,
|
|
372
|
+
"next_retry_at": None,
|
|
373
|
+
"metadata": {},
|
|
374
|
+
"visibility": "tenant",
|
|
375
|
+
"visibility_user_id": None,
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
run = _row_to_run(row)
|
|
379
|
+
|
|
380
|
+
assert run.spec.target == "agent"
|
|
381
|
+
assert run.spec.pipeline_name is None
|
|
382
|
+
assert run.spec.pipeline_input is None
|
|
383
|
+
assert run.spec.persist_graph is False
|
|
384
|
+
assert run.spec.proactive_chat is False
|
|
385
|
+
|
|
279
386
|
def test_row_to_run(self):
|
|
280
387
|
now = _dt.datetime.now(tz=_dt.UTC)
|
|
281
388
|
sid = uuid.uuid4()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_config_storage.py
RENAMED
|
File without changes
|
{orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_ingestion_manifest.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_postgres_queue.py
RENAMED
|
File without changes
|
|
File without changes
|