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.
Files changed (33) hide show
  1. orchid_storage_postgres-1.3.0/.gitignore +11 -0
  2. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/PKG-INFO +2 -2
  3. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/__init__.py +1 -1
  4. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/chat_storage.py +1 -0
  5. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/event_storage.py +11 -0
  6. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/pyproject.toml +1 -1
  7. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_event_storage.py +111 -4
  8. orchid_storage_postgres-1.2.0/.gitignore +0 -8
  9. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/.github/workflows/ci.yml +0 -0
  10. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/.pre-commit-config.yaml +0 -0
  11. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/AGENTS.md +0 -0
  12. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/CHANGELOG.md +0 -0
  13. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/LICENSE +0 -0
  14. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/README.md +0 -0
  15. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/config_storage.py +0 -0
  16. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/event_queue.py +0 -0
  17. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/ingestion_manifest.py +0 -0
  18. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_client_registration_store.py +0 -0
  19. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_gateway_state_store.py +0 -0
  20. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/mcp_token_store.py +0 -0
  21. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/__init__.py +0 -0
  22. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/_schema_ddl.py +0 -0
  23. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/v001_initial_schema.py +0 -0
  24. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/migrations/v002_ingestion_manifest.py +0 -0
  25. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/orchid_storage_postgres/visibility.py +0 -0
  26. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_chat_storage.py +0 -0
  27. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_checkpointer.py +0 -0
  28. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_config_storage.py +0 -0
  29. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_ingestion_manifest.py +0 -0
  30. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_mcp_stores.py +0 -0
  31. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_migration.py +0 -0
  32. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_postgres_queue.py +0 -0
  33. {orchid_storage_postgres-1.2.0 → orchid_storage_postgres-1.3.0}/tests/test_visibility.py +0 -0
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ .env
5
+ .venv/
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+
10
+ # orchid-sdd workspace override (root config is authoritative)
11
+ /orchid-sdd.yml
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: orchid-storage-postgres
3
- Version: 1.2.0
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.11.0
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'
@@ -32,7 +32,7 @@ from __future__ import annotations
32
32
 
33
33
  import logging
34
34
 
35
- __version__ = "1.2.0"
35
+ __version__ = "1.3.0"
36
36
 
37
37
  from .chat_storage import OrchidPostgresChatStorage
38
38
  from .config_storage import OrchidPostgresConfigStorage
@@ -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
  }
@@ -19,7 +19,7 @@ classifiers = [
19
19
  ]
20
20
  keywords = ["ai", "agents", "storage", "postgresql", "asyncpg"]
21
21
  dependencies = [
22
- "orchid-ai>=1.11.0",
22
+ "orchid-ai>=1.13.0",
23
23
  "asyncpg>=0.29.0",
24
24
  "langgraph-checkpoint-postgres>=2.0.0",
25
25
  ]
@@ -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
- with pytest.raises(ImportError):
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()
@@ -1,8 +0,0 @@
1
- __pycache__/
2
- *.pyc
3
- *.pyo
4
- .env
5
- .venv/
6
- *.egg-info/
7
- dist/
8
- build/