reactifact 0.17.0__tar.gz → 0.17.2__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 (320) hide show
  1. {reactifact-0.17.0/reactifact.egg-info → reactifact-0.17.2}/PKG-INFO +1 -1
  2. {reactifact-0.17.0 → reactifact-0.17.2}/pyproject.toml +1 -1
  3. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/__init__.py +1 -1
  4. reactifact-0.17.2/reactifact/_persistence.py +147 -0
  5. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/chat.py +5 -1
  6. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/postgres.py +2 -2
  7. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/store.py +46 -39
  8. {reactifact-0.17.0 → reactifact-0.17.2/reactifact.egg-info}/PKG-INFO +1 -1
  9. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_chat_web.py +30 -1
  10. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_session_append.py +48 -0
  11. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_trace_limits.py +23 -0
  12. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_tracing.py +41 -4
  13. reactifact-0.17.0/reactifact/_persistence.py +0 -78
  14. {reactifact-0.17.0 → reactifact-0.17.2}/LICENSE +0 -0
  15. {reactifact-0.17.0 → reactifact-0.17.2}/README.md +0 -0
  16. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/__main__.py +0 -0
  17. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/_extras.py +0 -0
  18. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/_httpx.py +0 -0
  19. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/a2a/__init__.py +0 -0
  20. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/a2a/client.py +0 -0
  21. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/a2a/models.py +0 -0
  22. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/a2a/remote.py +0 -0
  23. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/a2a/server.py +0 -0
  24. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/agent_tool.py +0 -0
  25. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/agents.py +0 -0
  26. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/artifacts.py +0 -0
  27. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/audit.py +0 -0
  28. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/authz.py +0 -0
  29. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/branching.py +0 -0
  30. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/budget.py +0 -0
  31. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cache.py +0 -0
  32. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/checkpoints.py +0 -0
  33. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/__init__.py +0 -0
  34. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/branch.py +0 -0
  35. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/common.py +0 -0
  36. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/context.py +0 -0
  37. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/eval.py +0 -0
  38. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/graph.py +0 -0
  39. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/replay.py +0 -0
  40. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/scenario.py +0 -0
  41. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/skills.py +0 -0
  42. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/cli/trace.py +0 -0
  43. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/commit.py +0 -0
  44. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/commit_log.py +0 -0
  45. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/consume.py +0 -0
  46. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/context.py +0 -0
  47. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/context_builder.py +0 -0
  48. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/effects.py +0 -0
  49. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/__init__.py +0 -0
  50. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/dataset.py +0 -0
  51. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/evaluators.py +0 -0
  52. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/judge.py +0 -0
  53. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/online.py +0 -0
  54. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/runner.py +0 -0
  55. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/eval/scoring.py +0 -0
  56. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/events.py +0 -0
  57. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/guardrails.py +0 -0
  58. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/interrupt.py +0 -0
  59. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/llm_agent.py +0 -0
  60. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/logging.py +0 -0
  61. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/mcp/__init__.py +0 -0
  62. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/mcp/client.py +0 -0
  63. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/mcp/oauth.py +0 -0
  64. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/mcp/server.py +0 -0
  65. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/metrics.py +0 -0
  66. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/native_tool_use.py +0 -0
  67. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/operations.py +0 -0
  68. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/patches.py +0 -0
  69. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/pricing.py +0 -0
  70. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/produce.py +0 -0
  71. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/prompts.py +0 -0
  72. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/__init__.py +0 -0
  73. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/_retry.py +0 -0
  74. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/anthropic.py +0 -0
  75. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/azure.py +0 -0
  76. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/cerebras.py +0 -0
  77. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/chat.py +0 -0
  78. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/contracts.py +0 -0
  79. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/deepseek.py +0 -0
  80. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/fake.py +0 -0
  81. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/fireworks.py +0 -0
  82. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/gemini.py +0 -0
  83. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/github_models.py +0 -0
  84. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/groq.py +0 -0
  85. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/image.py +0 -0
  86. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/mistral.py +0 -0
  87. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/nvidia.py +0 -0
  88. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/ollama.py +0 -0
  89. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/openai.py +0 -0
  90. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/openrouter.py +0 -0
  91. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/perplexity.py +0 -0
  92. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/qwen.py +0 -0
  93. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/speech.py +0 -0
  94. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/together.py +0 -0
  95. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/video.py +0 -0
  96. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/xai.py +0 -0
  97. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/providers/zai.py +0 -0
  98. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/py.typed +0 -0
  99. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/__init__.py +0 -0
  100. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/_shared.py +0 -0
  101. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/agent.py +0 -0
  102. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/chat.py +0 -0
  103. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/models.py +0 -0
  104. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/rag.py +0 -0
  105. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quick/tools_agent.py +0 -0
  106. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/quota.py +0 -0
  107. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/__init__.py +0 -0
  108. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/cleanup.py +0 -0
  109. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/conversation.py +0 -0
  110. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/identity.py +0 -0
  111. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/inputs.py +0 -0
  112. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/memory.py +0 -0
  113. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/plan_execute.py +0 -0
  114. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/reflection.py +0 -0
  115. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/resolve.py +0 -0
  116. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/rollback.py +0 -0
  117. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/search.py +0 -0
  118. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/skills.py +0 -0
  119. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/status.py +0 -0
  120. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/supervisor.py +0 -0
  121. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/text.py +0 -0
  122. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/recipes/tool_loop.py +0 -0
  123. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/redaction.py +0 -0
  124. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/relations.py +0 -0
  125. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/replay.py +0 -0
  126. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/request.py +0 -0
  127. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/resources.py +0 -0
  128. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/routing.py +0 -0
  129. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/runtime.py +0 -0
  130. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/scheduler.py +0 -0
  131. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/session.py +0 -0
  132. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact/SKILL.md +0 -0
  133. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact/references/effects-and-state.md +0 -0
  134. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact/references/trust-and-safety.md +0 -0
  135. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-agents/SKILL.md +0 -0
  136. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-agents/references/consume.md +0 -0
  137. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-agents/references/effects.md +0 -0
  138. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-eval/SKILL.md +0 -0
  139. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-eval/references/online.md +0 -0
  140. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-from-langchain/SKILL.md +0 -0
  141. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-llm/SKILL.md +0 -0
  142. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-llm/references/providers.md +0 -0
  143. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-llm/references/tools.md +0 -0
  144. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-observability/SKILL.md +0 -0
  145. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-rag/SKILL.md +0 -0
  146. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-rag/references/sources.md +0 -0
  147. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/skills/reactifact-testing/SKILL.md +0 -0
  148. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/sources.py +0 -0
  149. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/streaming.py +0 -0
  150. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/structured.py +0 -0
  151. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/__init__.py +0 -0
  152. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/assertions.py +0 -0
  153. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/exceptions.py +0 -0
  154. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/fault.py +0 -0
  155. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/golden.py +0 -0
  156. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/lab.py +0 -0
  157. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/mock.py +0 -0
  158. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/pytest_plugin.py +0 -0
  159. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/record.py +0 -0
  160. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/testing/registry.py +0 -0
  161. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tool_use.py +0 -0
  162. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tools.py +0 -0
  163. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/__init__.py +0 -0
  164. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/_otlp.py +0 -0
  165. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/columns.py +0 -0
  166. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/langfuse.py +0 -0
  167. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/models.py +0 -0
  168. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/otlp.py +0 -0
  169. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/templates/app.css +0 -0
  170. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/templates/sessions.html +0 -0
  171. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/templates/ui.html +0 -0
  172. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/templates/ui_run.html +0 -0
  173. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/tracer.py +0 -0
  174. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/tracing/web.py +0 -0
  175. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/triggers.py +0 -0
  176. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/types.py +0 -0
  177. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/verify.py +0 -0
  178. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/viz.py +0 -0
  179. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact/web.py +0 -0
  180. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact.egg-info/SOURCES.txt +0 -0
  181. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact.egg-info/dependency_links.txt +0 -0
  182. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact.egg-info/entry_points.txt +0 -0
  183. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact.egg-info/requires.txt +0 -0
  184. {reactifact-0.17.0 → reactifact-0.17.2}/reactifact.egg-info/top_level.txt +0 -0
  185. {reactifact-0.17.0 → reactifact-0.17.2}/setup.cfg +0 -0
  186. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_a2a.py +0 -0
  187. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_a2a_example.py +0 -0
  188. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_a2a_interop.py +0 -0
  189. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_absent_consume.py +0 -0
  190. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_adaptive.py +0 -0
  191. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_agent_tool.py +0 -0
  192. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_anthropic_provider.py +0 -0
  193. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_artifacts.py +0 -0
  194. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_audit.py +0 -0
  195. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_authz.py +0 -0
  196. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_backbone.py +0 -0
  197. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_branching.py +0 -0
  198. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_budget.py +0 -0
  199. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_cache.py +0 -0
  200. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_canonical_ports.py +0 -0
  201. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_chat_example.py +0 -0
  202. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_chat_memory.py +0 -0
  203. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_chat_outbox.py +0 -0
  204. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_checkpoint.py +0 -0
  205. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_checkpoints_concurrency.py +0 -0
  206. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_cli.py +0 -0
  207. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_cli_scenario.py +0 -0
  208. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_commit_log.py +0 -0
  209. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_compaction.py +0 -0
  210. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_concurrency.py +0 -0
  211. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_consumes_produces.py +0 -0
  212. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_context_builder.py +0 -0
  213. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_correlated_consume.py +0 -0
  214. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_debounce.py +0 -0
  215. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_determinism.py +0 -0
  216. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_devops.py +0 -0
  217. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_devops_online.py +0 -0
  218. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_devops_web.py +0 -0
  219. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_effects.py +0 -0
  220. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_eval.py +0 -0
  221. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_eval_dataset.py +0 -0
  222. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_eval_judge.py +0 -0
  223. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_eval_online.py +0 -0
  224. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_eval_trajectory.py +0 -0
  225. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_fintech_audit.py +0 -0
  226. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_forklab.py +0 -0
  227. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_forklab_web.py +0 -0
  228. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_friendly_api.py +0 -0
  229. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_gemini_provider.py +0 -0
  230. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_golden.py +0 -0
  231. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_guardrails.py +0 -0
  232. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_hitl.py +0 -0
  233. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_image_provider.py +0 -0
  234. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_incident_commander.py +0 -0
  235. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_invalidation.py +0 -0
  236. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_join_consume.py +0 -0
  237. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_knowledge.py +0 -0
  238. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_knowledge_web.py +0 -0
  239. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_llm_ladder.py +0 -0
  240. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_logging.py +0 -0
  241. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_loop_bound_client.py +0 -0
  242. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_mcp.py +0 -0
  243. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_medic_lab.py +0 -0
  244. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_medic_lab_web.py +0 -0
  245. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_metrics.py +0 -0
  246. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_multisource.py +0 -0
  247. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_native_tool_use.py +0 -0
  248. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_openai_provider.py +0 -0
  249. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_outbox.py +0 -0
  250. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_patches.py +0 -0
  251. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_pending_actions.py +0 -0
  252. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_ports.py +0 -0
  253. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_produce_styles.py +0 -0
  254. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_produce_trigger.py +0 -0
  255. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_prompts.py +0 -0
  256. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_provider_auth.py +0 -0
  257. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_provider_retry.py +0 -0
  258. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_providers_integration.py +0 -0
  259. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_public_api.py +0 -0
  260. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_quick.py +0 -0
  261. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_quota.py +0 -0
  262. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_reacts_to.py +0 -0
  263. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipe_conversation.py +0 -0
  264. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipe_plan_execute.py +0 -0
  265. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipe_reflection.py +0 -0
  266. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipe_supervisor.py +0 -0
  267. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipe_tool_loop.py +0 -0
  268. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipes.py +0 -0
  269. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipes_inputs.py +0 -0
  270. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipes_memory.py +0 -0
  271. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_recipes_skills.py +0 -0
  272. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_redaction.py +0 -0
  273. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_relation_graph.py +0 -0
  274. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_relations.py +0 -0
  275. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_repair.py +0 -0
  276. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_repair_web.py +0 -0
  277. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_replay.py +0 -0
  278. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_repo_agent.py +0 -0
  279. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_request.py +0 -0
  280. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_research.py +0 -0
  281. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_resources.py +0 -0
  282. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_retry.py +0 -0
  283. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_routing.py +0 -0
  284. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_runtime.py +0 -0
  285. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_runtime_errors.py +0 -0
  286. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_scheduler_semantics.py +0 -0
  287. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_sessions.py +0 -0
  288. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_shutdown.py +0 -0
  289. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_skills.py +0 -0
  290. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_sources.py +0 -0
  291. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_sources_search.py +0 -0
  292. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_sources_vector.py +0 -0
  293. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_speech_provider.py +0 -0
  294. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_starter_app.py +0 -0
  295. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_streaming.py +0 -0
  296. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_structured.py +0 -0
  297. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_support_copilot.py +0 -0
  298. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_assertions.py +0 -0
  299. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_golden.py +0 -0
  300. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_lab.py +0 -0
  301. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_mock.py +0 -0
  302. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_provenance.py +0 -0
  303. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_pytest_plugin.py +0 -0
  304. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_testing_registry.py +0 -0
  305. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_token_budget.py +0 -0
  306. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_tools.py +0 -0
  307. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_trace_columns.py +0 -0
  308. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_trace_tags.py +0 -0
  309. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_trace_ui.py +0 -0
  310. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_type_registry.py +0 -0
  311. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_vendor_factories.py +0 -0
  312. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_vendor_multimodal_factories.py +0 -0
  313. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_verify.py +0 -0
  314. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_video_provider.py +0 -0
  315. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_view.py +0 -0
  316. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_viz.py +0 -0
  317. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_web_source.py +0 -0
  318. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_workspace.py +0 -0
  319. {reactifact-0.17.0 → reactifact-0.17.2}/tests/test_workspace_with_sources.py +0 -0
  320. {reactifact-0.17.0 → reactifact-0.17.2}/tests/tests_checkpoints_sqlite.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reactifact
3
- Version: 0.17.0
3
+ Version: 0.17.2
4
4
  Summary: Reactive, artifact-driven agent runtime: agents transform versioned, typed, provenance-aware artifacts inside an evolving context
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/bzdvdn/reactifact
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "reactifact"
7
- version = "0.17.0"
7
+ version = "0.17.2"
8
8
  description = "Reactive, artifact-driven agent runtime: agents transform versioned, typed, provenance-aware artifacts inside an evolving context"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -51,7 +51,7 @@ from .tools import FunctionTool, Tool, ToolError, ToolOutput, tool
51
51
  from .triggers import Trigger
52
52
  from .types import register as register_type
53
53
 
54
- __version__ = "0.17.0"
54
+ __version__ = "0.17.1"
55
55
 
56
56
  __all__ = [
57
57
  "Agent",
@@ -0,0 +1,147 @@
1
+ """Internal: append-only persistence helpers shared by session/branch stores.
2
+
3
+ Not public API — `SessionStore`/`BranchStore` use these when the backend
4
+ implements `AppendBackend` (SQLite/Postgres). A save writes a full snapshot on
5
+ the first save, after a compaction, or after a rollback; otherwise it appends
6
+ only the new commits plus the current pending-event queue.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any, cast
12
+
13
+ from .artifacts import Artifact
14
+ from .checkpoints import AppendBackend
15
+ from .commit import Commit
16
+ from .context import Context
17
+ from .events import Event
18
+ from .patches import Relation
19
+ from .relations import RelationGraph
20
+
21
+ #: Default number of appended saves before a snapshot rewrite. Bounds load
22
+ #: replay (and log size) for long-lived sessions without an explicit
23
+ #: `context.compact()`.
24
+ DEFAULT_COMPACT_EVERY = 100
25
+
26
+
27
+ async def save_append(
28
+ backend: AppendBackend,
29
+ key: str,
30
+ context: Context,
31
+ *,
32
+ compact_every: int | None = DEFAULT_COMPACT_EVERY,
33
+ ) -> None:
34
+ persisted, persisted_compacted = context.persisted_state(key)
35
+ needs_snapshot = (
36
+ persisted < 0
37
+ or persisted > context.version
38
+ or context.compacted_at > persisted_compacted
39
+ or await backend.get(key) is None
40
+ )
41
+ if (
42
+ not needs_snapshot
43
+ and compact_every is not None
44
+ and await backend.entry_count(key) + 1 >= compact_every
45
+ ):
46
+ needs_snapshot = True
47
+ if needs_snapshot:
48
+ await backend.set(key, cast(dict[str, Any], context.to_dict()))
49
+ await backend.clear_entries(key)
50
+ context.mark_persisted(key=key)
51
+ return
52
+ new_commits = [
53
+ commit.to_dict()
54
+ for commit in context.commit_log()
55
+ if (commit.context_version or 0) > persisted
56
+ ]
57
+ working_tree = _working_tree(context)
58
+ await backend.append(
59
+ key,
60
+ {
61
+ "commits": new_commits,
62
+ "events": [event.to_dict() for event in context.pending_events()],
63
+ # `Context.create()` adds the turn's user artifact to the working
64
+ # tree, not to a commit. Without this snapshot append-only stores
65
+ # lose every user message after the first save (only assistant
66
+ # FinalResponse commits survive a reload). Each entry carries the
67
+ # complete current working tree; the last entry wins on load.
68
+ "working_tree": working_tree,
69
+ },
70
+ )
71
+ context.mark_persisted(key=key)
72
+
73
+
74
+ def _working_tree(context: Context) -> dict[str, Any]:
75
+ """Artifacts/relations that live outside the commit log (the working tree)."""
76
+ committed = context._log.replay_state(context.version)
77
+ artifacts = {
78
+ aid: artifact.to_dict()
79
+ for aid, artifact in context._artifacts.items()
80
+ if aid not in committed or committed[aid] != artifact.data
81
+ }
82
+ committed_relations = context._log.replay_relations(context.version)
83
+ relations = [
84
+ relation.to_dict()
85
+ for key, relation in context._relations.items()
86
+ if key not in committed_relations or committed_relations[key] != relation
87
+ ]
88
+ return {
89
+ "artifacts": artifacts,
90
+ "relations": relations,
91
+ # Working-tree artifacts are merged after commit replay; their IDs in
92
+ # the live insertion order let load restore the exact conversation
93
+ # order instead of appending every user message after assistant turns.
94
+ "order": [artifact.id for artifact in context.list_artifacts()],
95
+ }
96
+
97
+
98
+ def _apply_working_tree(context: Context, payload: dict[str, Any]) -> None:
99
+ """Make the latest appended working tree authoritative over the snapshot."""
100
+ committed = context._log.replay_state(context.version)
101
+ artifacts = payload.get("artifacts") or {}
102
+ for artifact_id in list(context._artifacts):
103
+ if artifact_id not in committed and artifact_id not in artifacts:
104
+ context._artifacts.pop(artifact_id, None)
105
+ for artifact_id, artifact_dict in artifacts.items():
106
+ context._artifacts[artifact_id] = Artifact.from_dict(artifact_dict)
107
+
108
+ committed_relations = context._log.replay_relations(context.version)
109
+ wanted: dict[Any, Relation] = {}
110
+ for item in payload.get("relations") or []:
111
+ relation = Relation.from_dict(item)
112
+ wanted[(relation.source_id, relation.relation, relation.target_id)] = relation
113
+ context._relations = RelationGraph.from_mapping(
114
+ {**committed_relations, **wanted}
115
+ )
116
+ order = payload.get("order")
117
+ if order:
118
+ rank = {artifact_id: index for index, artifact_id in enumerate(order)}
119
+ context._artifacts = dict(
120
+ sorted(
121
+ context._artifacts.items(),
122
+ key=lambda item: rank.get(item[0], len(rank)),
123
+ )
124
+ )
125
+ context.rebuild_indices()
126
+
127
+
128
+ async def load_append(backend: AppendBackend, key: str) -> Context | None:
129
+ snapshot = await backend.get(key)
130
+ if snapshot is None:
131
+ return None
132
+ context = Context.from_dict(snapshot)
133
+ last_working_tree: dict[str, Any] | None = None
134
+ for entry in await backend.entries(key):
135
+ for commit_dict in entry.get("commits", []):
136
+ context.apply_commit(Commit.from_dict(commit_dict), reindex=False)
137
+ if "events" in entry:
138
+ context.replace_events(
139
+ [Event.from_dict(event) for event in entry["events"]]
140
+ )
141
+ if "working_tree" in entry:
142
+ last_working_tree = entry["working_tree"]
143
+ if last_working_tree is not None:
144
+ _apply_working_tree(context, last_working_tree)
145
+ context.rebuild_indices()
146
+ context.mark_persisted(key=key)
147
+ return context
@@ -180,7 +180,11 @@ def default_session_state(
180
180
  `assistant`. Apps with richer reply payloads pass their own hook.
181
181
  """
182
182
  messages: list[dict[str, Any]] = []
183
- for artifact in sorted(ctx.list_artifacts(), key=lambda a: a.created_at):
183
+ # Insertion order is the true creation order. Do not sort by `created_at`:
184
+ # append-only session replay reconstructs committed artifacts at load time,
185
+ # so their timestamps are newer than the working-tree user messages and a
186
+ # timestamp sort would push all user turns to the front.
187
+ for artifact in ctx.list_artifacts():
184
188
  data = artifact.data
185
189
  text = getattr(data, "text", None)
186
190
  if not isinstance(text, str):
@@ -239,8 +239,8 @@ class PostgresStore:
239
239
  ),
240
240
  ),
241
241
  )
242
- if self.max_runs is not None:
243
- await self._prune_cur(cur, self.max_runs)
242
+ if self.max_runs is not None:
243
+ await self._prune_cur(cur, self.max_runs)
244
244
  await conn.commit()
245
245
  finally:
246
246
  await conn.close()
@@ -372,48 +372,54 @@ class TraceStore:
372
372
  started = trace.started_at.timestamp() if trace.started_at else time.time()
373
373
  prompt_tokens = sum(c.prompt_tokens for c in trace.llm_calls)
374
374
  completion_tokens = sum(c.completion_tokens for c in trace.llm_calls)
375
- self._conn.execute(
376
- "INSERT INTO runs (id, session_id, started_at, duration_ms, outcome, "
377
- "prompt_tokens, completion_tokens, truncated) "
378
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
379
- (
380
- trace.id,
381
- trace.session_id,
382
- started,
383
- trace.duration_ms,
384
- trace.outcome,
385
- prompt_tokens,
386
- completion_tokens,
387
- 1 if trace.trace_truncated else 0,
388
- ),
389
- )
390
- for span in trace.spans:
375
+ try:
391
376
  self._conn.execute(
392
- "INSERT INTO spans (run_id, agent, event_type, event_artifact_type, "
393
- "latency_ms, error, started_at, reads, writes, relations, llm_calls, "
394
- "produces, tools, event_artifact_id, contract) "
395
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
377
+ "INSERT INTO runs (id, session_id, started_at, duration_ms, outcome, "
378
+ "prompt_tokens, completion_tokens, truncated) "
379
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
396
380
  (
397
381
  trace.id,
398
- span.agent,
399
- span.event_type,
400
- span.event_artifact_type,
401
- span.latency_ms,
402
- span.error,
403
- span.started_at.timestamp() if span.started_at else None,
404
- json.dumps([r.model_dump(mode="json") for r in span.reads]),
405
- json.dumps([w.model_dump(mode="json") for w in span.writes]),
406
- json.dumps([r.model_dump(mode="json") for r in span.relations]),
407
- json.dumps([c.model_dump(mode="json") for c in span.llm_calls]),
408
- json.dumps([p.model_dump(mode="json") for p in span.produces]),
409
- json.dumps([t.model_dump(mode="json") for t in span.tools]),
410
- span.event_artifact_id,
411
- json.dumps(span.contract.model_dump(mode="json")),
382
+ trace.session_id,
383
+ started,
384
+ trace.duration_ms,
385
+ trace.outcome,
386
+ prompt_tokens,
387
+ completion_tokens,
388
+ 1 if trace.trace_truncated else 0,
412
389
  ),
413
390
  )
414
- self._conn.commit()
415
- if self.max_runs is not None:
416
- self._prune_sync(self.max_runs)
391
+ for span in trace.spans:
392
+ self._conn.execute(
393
+ "INSERT INTO spans (run_id, agent, event_type, event_artifact_type, "
394
+ "latency_ms, error, started_at, reads, writes, relations, llm_calls, "
395
+ "produces, tools, event_artifact_id, contract) "
396
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
397
+ (
398
+ trace.id,
399
+ span.agent,
400
+ span.event_type,
401
+ span.event_artifact_type,
402
+ span.latency_ms,
403
+ span.error,
404
+ span.started_at.timestamp() if span.started_at else None,
405
+ json.dumps([r.model_dump(mode="json") for r in span.reads]),
406
+ json.dumps([w.model_dump(mode="json") for w in span.writes]),
407
+ json.dumps([r.model_dump(mode="json") for r in span.relations]),
408
+ json.dumps([c.model_dump(mode="json") for c in span.llm_calls]),
409
+ json.dumps([p.model_dump(mode="json") for p in span.produces]),
410
+ json.dumps([t.model_dump(mode="json") for t in span.tools]),
411
+ span.event_artifact_id,
412
+ json.dumps(span.contract.model_dump(mode="json")),
413
+ ),
414
+ )
415
+ # Insert and retention commit together: a prune failure rolls the
416
+ # run back instead of leaving it stored with retention unapplied.
417
+ if self.max_runs is not None:
418
+ self._prune_sync(self.max_runs, commit=False)
419
+ self._conn.commit()
420
+ except Exception:
421
+ self._conn.rollback()
422
+ raise
417
423
 
418
424
  def _delete_run_sync(self, trace_id: str) -> bool:
419
425
  exists = self._conn.execute(
@@ -445,7 +451,7 @@ class TraceStore:
445
451
  self._conn.commit()
446
452
  return len(ids)
447
453
 
448
- def _prune_sync(self, keep: int) -> int:
454
+ def _prune_sync(self, keep: int, *, commit: bool = True) -> int:
449
455
  """Keeps the last `keep` traces, deletes older ones (retention)."""
450
456
  cur = self._conn.execute(
451
457
  "DELETE FROM runs WHERE id NOT IN "
@@ -458,7 +464,8 @@ class TraceStore:
458
464
  self._conn.execute(
459
465
  "DELETE FROM run_tags WHERE run_id NOT IN (SELECT id FROM runs)"
460
466
  )
461
- self._conn.commit()
467
+ if commit:
468
+ self._conn.commit()
462
469
  return cur.rowcount
463
470
 
464
471
  def _where(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reactifact
3
- Version: 0.17.0
3
+ Version: 0.17.2
4
4
  Summary: Reactive, artifact-driven agent runtime: agents transform versioned, typed, provenance-aware artifacts inside an evolving context
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/bzdvdn/reactifact
@@ -7,7 +7,7 @@ from fastapi.testclient import TestClient
7
7
  from pydantic import BaseModel
8
8
  from reactifact import Consume, SessionStore, create_agent, produce
9
9
  from reactifact.chat import ChatAssistant
10
- from reactifact.checkpoints import FileKVBackend
10
+ from reactifact.checkpoints import FileKVBackend, SQLiteKVBackend
11
11
  from reactifact.web import create_chat_router
12
12
 
13
13
 
@@ -67,6 +67,35 @@ def test_history_roundtrip(tmp_path):
67
67
  assert history["messages"][1]["text"] == "answer"
68
68
 
69
69
 
70
+ def test_history_keeps_every_user_message_with_append_backend(tmp_path):
71
+ """Append-only sessions must persist working-tree user messages, not just
72
+ the assistant commits the runtime writes."""
73
+ store = SessionStore(SQLiteKVBackend(str(tmp_path / "sessions.sqlite3")))
74
+
75
+ def reply(ctx, msg_id):
76
+ answer = ctx.latest(A)
77
+ return {"reply": answer.data.text if answer else "fallback", "waiting": False}
78
+
79
+ assistant = ChatAssistant(
80
+ store=store,
81
+ agents=[ANSWER_AGENT],
82
+ user_message=Q,
83
+ reply=reply,
84
+ max_concurrency=1,
85
+ )
86
+ for text in ("first", "second", "third"):
87
+ _drain(assistant.stream(text, session_id="s1"))
88
+
89
+ history = asyncio.run(assistant.history("s1"))
90
+ messages = history["messages"]
91
+ assert [m["role"] for m in messages] == [
92
+ "user", "assistant", "user", "assistant", "user", "assistant"
93
+ ]
94
+ assert [m["text"] for m in messages if m["role"] == "user"] == [
95
+ "first", "second", "third"
96
+ ]
97
+
98
+
70
99
  def test_history_empty_for_unknown_session(tmp_path):
71
100
  assistant = make_assistant(str(tmp_path))
72
101
  assert asyncio.run(assistant.history("nope"))["messages"] == []
@@ -69,6 +69,54 @@ def test_sqlite_session_appends_only_new_commits(tmp_path):
69
69
  asyncio.run(_run())
70
70
 
71
71
 
72
+ def test_append_persists_working_tree_artifacts(tmp_path):
73
+ """User input is a working-tree artifact, not a commit: append saves must
74
+ carry it too, or every message after the first is lost on reload."""
75
+
76
+ async def _run() -> None:
77
+ backend = SQLiteKVBackend(str(tmp_path / "sessions.db"))
78
+ store = SessionStore(backend)
79
+ context = Context()
80
+
81
+ await store.save_session("s", context) # initial snapshot
82
+ first = context.create(Note(text="first user message"))
83
+ _commit(context, "committed", "note:committed")
84
+ await store.save_session("s", context) # append
85
+
86
+ second = context.create(Note(text="second user message"))
87
+ await store.save_session("s", context) # append again
88
+
89
+ loaded = await store.load_session("s")
90
+ assert loaded is not None
91
+ texts = [note.data.text for note in loaded.list_artifacts(Note)]
92
+ assert texts == ["first user message", "committed", "second user message"]
93
+ assert loaded.get(first.id) is not None
94
+ assert loaded.get(second.id) is not None
95
+ await backend.aclose()
96
+
97
+ asyncio.run(_run())
98
+
99
+
100
+ def test_working_tree_artifact_delete_survives_append_reload(tmp_path):
101
+ async def _run() -> None:
102
+ backend = SQLiteKVBackend(str(tmp_path / "sessions.db"))
103
+ store = SessionStore(backend)
104
+ context = Context()
105
+
106
+ await store.save_session("s", context)
107
+ first = context.create(Note(text="temporary"))
108
+ await store.save_session("s", context)
109
+ context.delete(first.id)
110
+ await store.save_session("s", context)
111
+
112
+ loaded = await store.load_session("s")
113
+ assert loaded is not None
114
+ assert loaded.list_artifacts(Note) == []
115
+ await backend.aclose()
116
+
117
+ asyncio.run(_run())
118
+
119
+
72
120
  def test_compaction_rewrites_the_snapshot_and_clears_the_log(tmp_path):
73
121
  async def _run() -> None:
74
122
  backend = SQLiteKVBackend(str(tmp_path / "sessions.db"))
@@ -129,3 +129,26 @@ def test_trace_truncate_is_deprecated():
129
129
  warnings.simplefilter("error")
130
130
  default = RuntimeResources()
131
131
  assert default.trace_truncate == 1500
132
+
133
+
134
+ def test_sqlite_export_rolls_back_when_prune_fails(tmp_path, monkeypatch):
135
+ store = TraceStore(str(tmp_path / "atomic.db"), max_runs=100)
136
+
137
+ def boom(keep: int, *, commit: bool = True) -> int:
138
+ raise RuntimeError("prune failed")
139
+
140
+ monkeypatch.setattr(store, "_prune_sync", boom)
141
+ with pytest.raises(RuntimeError, match="prune failed"):
142
+ run(
143
+ store.export(
144
+ RunTrace(
145
+ id="r1",
146
+ session_id="s1",
147
+ outcome="completed",
148
+ spans=[AgentSpan(agent="a")],
149
+ )
150
+ )
151
+ )
152
+
153
+ # insert + retention share one transaction, so the failed prune leaves no run
154
+ assert run(store.get("r1")) is None
@@ -419,15 +419,27 @@ def test_trace_memoizes_artifact_dump(tmp_path):
419
419
  def test_trace_store_retention_prunes_oldest(tmp_path):
420
420
  store = TraceStore(str(tmp_path / "ret.db"), max_runs=2)
421
421
  for i in range(5):
422
- run(store.export(RunTrace(id=f"r{i}", session_id="s", outcome="completed")))
422
+ run(
423
+ store.export(
424
+ RunTrace(
425
+ id=f"r{i}",
426
+ session_id="s",
427
+ outcome="completed",
428
+ spans=[AgentSpan(agent="a")],
429
+ )
430
+ )
431
+ )
432
+ run(store.tag_runs(["r0", "r1"], "old"))
423
433
 
424
434
  items = run(store.query())["items"]
425
435
  ids = {item["id"] for item in items}
426
436
  assert ids == {"r3", "r4"} # the last 2 remain
427
437
  assert run(store.get("r0")) is None
428
- # spans of old traces are also removed
429
- rows = store._conn.execute("SELECT COUNT(*) FROM spans").fetchone()[0]
430
- assert rows == 0 # r3/r4 have no spans (exported without spans)
438
+ # spans and tags of old traces are also removed
439
+ spans = store._conn.execute("SELECT COUNT(*) FROM spans").fetchone()[0]
440
+ tags = store._conn.execute("SELECT COUNT(*) FROM run_tags").fetchone()[0]
441
+ assert spans == 2 # one per r3/r4
442
+ assert tags == 0
431
443
 
432
444
 
433
445
  class FakeClient:
@@ -871,6 +883,31 @@ def test_postgres_store_roundtrip(tmp_path):
871
883
  assert loaded.spans[0].relations[0].relation == "supported_by"
872
884
 
873
885
 
886
+ def test_postgres_export_with_retention_does_not_raise(tmp_path):
887
+ """Retention must run on the still-open cursor (regression: InterfaceError)."""
888
+ import os
889
+
890
+ import pytest
891
+ from reactifact.tracing import PostgresStore
892
+
893
+ dsn = os.environ.get("TEST_PG_DSN")
894
+ if not dsn:
895
+ pytest.skip("TEST_PG_DSN not set — skipping Postgres trace integration")
896
+
897
+ store = PostgresStore(dsn, max_runs=100_000)
898
+ trace = RunTrace(
899
+ id="pg-retention-1",
900
+ session_id="pg-retention-test",
901
+ outcome="completed",
902
+ spans=[AgentSpan(agent="a")],
903
+ )
904
+ try:
905
+ run(store.export(trace))
906
+ assert run(store.get("pg-retention-1")) is not None
907
+ finally:
908
+ run(store.delete_session("pg-retention-test"))
909
+
910
+
874
911
  def test_span_started_at_roundtrips(tmp_path):
875
912
  from datetime import UTC, datetime, timedelta
876
913
 
@@ -1,78 +0,0 @@
1
- """Internal: append-only persistence helpers shared by session/branch stores.
2
-
3
- Not public API — `SessionStore`/`BranchStore` use these when the backend
4
- implements `AppendBackend` (SQLite/Postgres). A save writes a full snapshot on
5
- the first save, after a compaction, or after a rollback; otherwise it appends
6
- only the new commits plus the current pending-event queue.
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- from typing import Any, cast
12
-
13
- from .checkpoints import AppendBackend
14
- from .commit import Commit
15
- from .context import Context
16
- from .events import Event
17
-
18
- #: Default number of appended saves before a snapshot rewrite. Bounds load
19
- #: replay (and log size) for long-lived sessions without an explicit
20
- #: `context.compact()`.
21
- DEFAULT_COMPACT_EVERY = 100
22
-
23
-
24
- async def save_append(
25
- backend: AppendBackend,
26
- key: str,
27
- context: Context,
28
- *,
29
- compact_every: int | None = DEFAULT_COMPACT_EVERY,
30
- ) -> None:
31
- persisted, persisted_compacted = context.persisted_state(key)
32
- needs_snapshot = (
33
- persisted < 0
34
- or persisted > context.version
35
- or context.compacted_at > persisted_compacted
36
- or await backend.get(key) is None
37
- )
38
- if (
39
- not needs_snapshot
40
- and compact_every is not None
41
- and await backend.entry_count(key) + 1 >= compact_every
42
- ):
43
- needs_snapshot = True
44
- if needs_snapshot:
45
- await backend.set(key, cast(dict[str, Any], context.to_dict()))
46
- await backend.clear_entries(key)
47
- context.mark_persisted(key=key)
48
- return
49
- new_commits = [
50
- commit.to_dict()
51
- for commit in context.commit_log()
52
- if (commit.context_version or 0) > persisted
53
- ]
54
- await backend.append(
55
- key,
56
- {
57
- "commits": new_commits,
58
- "events": [event.to_dict() for event in context.pending_events()],
59
- },
60
- )
61
- context.mark_persisted(key=key)
62
-
63
-
64
- async def load_append(backend: AppendBackend, key: str) -> Context | None:
65
- snapshot = await backend.get(key)
66
- if snapshot is None:
67
- return None
68
- context = Context.from_dict(snapshot)
69
- for entry in await backend.entries(key):
70
- for commit_dict in entry.get("commits", []):
71
- context.apply_commit(Commit.from_dict(commit_dict), reindex=False)
72
- if "events" in entry:
73
- context.replace_events(
74
- [Event.from_dict(event) for event in entry["events"]]
75
- )
76
- context.rebuild_indices()
77
- context.mark_persisted(key=key)
78
- return context
File without changes
File without changes