stateloom 0.1.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 (613) hide show
  1. stateloom-0.1.0/.claude/plans/v0.2-roadmap.md +92 -0
  2. stateloom-0.1.0/.claude/settings.local.json +39 -0
  3. stateloom-0.1.0/.github/dependabot.yml +39 -0
  4. stateloom-0.1.0/.github/workflows/ci.yml +211 -0
  5. stateloom-0.1.0/.github/workflows/dependabot-auto-merge.yml +34 -0
  6. stateloom-0.1.0/.github/workflows/dependency-review.yml +18 -0
  7. stateloom-0.1.0/.github/workflows/release.yml +71 -0
  8. stateloom-0.1.0/.github/workflows/scorecard.yml +42 -0
  9. stateloom-0.1.0/.github/workflows/security.yml +87 -0
  10. stateloom-0.1.0/.gitignore +46 -0
  11. stateloom-0.1.0/.pre-commit-config.yaml +27 -0
  12. stateloom-0.1.0/.pypirc +4 -0
  13. stateloom-0.1.0/.stateloom/secret.key +1 -0
  14. stateloom-0.1.0/.stateloom/server.log +33293 -0
  15. stateloom-0.1.0/.stateloom/server.pid +1 -0
  16. stateloom-0.1.0/:memory: +0 -0
  17. stateloom-0.1.0/AgentGate_Product_Concept.md +177 -0
  18. stateloom-0.1.0/AgentGate_Product_Concept_v2.md +603 -0
  19. stateloom-0.1.0/AgentGate_Product_Concept_v3.md +435 -0
  20. stateloom-0.1.0/AgentGate_Product_Concept_v4.md +485 -0
  21. stateloom-0.1.0/CLAUDE.md +780 -0
  22. stateloom-0.1.0/LICENSE +191 -0
  23. stateloom-0.1.0/PKG-INFO +575 -0
  24. stateloom-0.1.0/PLAN.md +1245 -0
  25. stateloom-0.1.0/README.md +475 -0
  26. stateloom-0.1.0/debate.py +482 -0
  27. stateloom-0.1.0/debate_live_v2.md +798 -0
  28. stateloom-0.1.0/debate_live_v3.md +691 -0
  29. stateloom-0.1.0/debate_live_v4.md +684 -0
  30. stateloom-0.1.0/debate_report_v2.md +804 -0
  31. stateloom-0.1.0/debate_report_v3.md +697 -0
  32. stateloom-0.1.0/debate_report_v4.md +690 -0
  33. stateloom-0.1.0/demo.py +217 -0
  34. stateloom-0.1.0/demos/_helpers.py +185 -0
  35. stateloom-0.1.0/demos/demo_agents.py +148 -0
  36. stateloom-0.1.0/demos/demo_async_jobs.py +151 -0
  37. stateloom-0.1.0/demos/demo_auth.py +176 -0
  38. stateloom-0.1.0/demos/demo_auto_routing.py +113 -0
  39. stateloom-0.1.0/demos/demo_billing.py +111 -0
  40. stateloom-0.1.0/demos/demo_blast_radius.py +93 -0
  41. stateloom-0.1.0/demos/demo_budget.py +87 -0
  42. stateloom-0.1.0/demos/demo_caching.py +84 -0
  43. stateloom-0.1.0/demos/demo_checkpoints.py +82 -0
  44. stateloom-0.1.0/demos/demo_circuit_breaker.py +145 -0
  45. stateloom-0.1.0/demos/demo_cohere.py +140 -0
  46. stateloom-0.1.0/demos/demo_compliance.py +113 -0
  47. stateloom-0.1.0/demos/demo_consensus.py +207 -0
  48. stateloom-0.1.0/demos/demo_durable.py +104 -0
  49. stateloom-0.1.0/demos/demo_durable_streaming.py +208 -0
  50. stateloom-0.1.0/demos/demo_experiments.py +261 -0
  51. stateloom-0.1.0/demos/demo_export_import.py +176 -0
  52. stateloom-0.1.0/demos/demo_full_workflow.py +273 -0
  53. stateloom-0.1.0/demos/demo_guardrails.py +117 -0
  54. stateloom-0.1.0/demos/demo_kill_switch.py +93 -0
  55. stateloom-0.1.0/demos/demo_langchain.py +203 -0
  56. stateloom-0.1.0/demos/demo_langgraph.py +196 -0
  57. stateloom-0.1.0/demos/demo_litellm.py +124 -0
  58. stateloom-0.1.0/demos/demo_loop_detection.py +61 -0
  59. stateloom-0.1.0/demos/demo_mistral.py +134 -0
  60. stateloom-0.1.0/demos/demo_mock.py +92 -0
  61. stateloom-0.1.0/demos/demo_multi_model.py +120 -0
  62. stateloom-0.1.0/demos/demo_observability.py +141 -0
  63. stateloom-0.1.0/demos/demo_org_team_budget.py +189 -0
  64. stateloom-0.1.0/demos/demo_orgs_teams.py +122 -0
  65. stateloom-0.1.0/demos/demo_parent_child.py +107 -0
  66. stateloom-0.1.0/demos/demo_pii.py +94 -0
  67. stateloom-0.1.0/demos/demo_pii_compliance.py +273 -0
  68. stateloom-0.1.0/demos/demo_prompt_files.py +194 -0
  69. stateloom-0.1.0/demos/demo_proxy.py +159 -0
  70. stateloom-0.1.0/demos/demo_rate_limiting.py +129 -0
  71. stateloom-0.1.0/demos/demo_replay.py +140 -0
  72. stateloom-0.1.0/demos/demo_retries.py +136 -0
  73. stateloom-0.1.0/demos/demo_security.py +117 -0
  74. stateloom-0.1.0/demos/demo_semantic_cache.py +148 -0
  75. stateloom-0.1.0/demos/demo_sessions.py +85 -0
  76. stateloom-0.1.0/demos/demo_shadow.py +180 -0
  77. stateloom-0.1.0/demos/demo_suspension.py +113 -0
  78. stateloom-0.1.0/demos/demo_timeouts.py +121 -0
  79. stateloom-0.1.0/demos/demo_tools.py +107 -0
  80. stateloom-0.1.0/demos/demo_ui_admin_locks.py +224 -0
  81. stateloom-0.1.0/demos/demo_ui_agents_prompts.py +302 -0
  82. stateloom-0.1.0/demos/demo_ui_compliance.py +219 -0
  83. stateloom-0.1.0/demos/demo_ui_config_budget_cache.py +174 -0
  84. stateloom-0.1.0/demos/demo_ui_kill_switch.py +217 -0
  85. stateloom-0.1.0/demos/demo_ui_orgs_teams_ratelimits.py +245 -0
  86. stateloom-0.1.0/demos/demo_ui_pii_rules.py +210 -0
  87. stateloom-0.1.0/demos/demo_ui_security_guardrails.py +281 -0
  88. stateloom-0.1.0/demos/demo_ui_session_lifecycle.py +270 -0
  89. stateloom-0.1.0/demos/demo_ui_vkeys_auth.py +397 -0
  90. stateloom-0.1.0/demos/demo_virtual_keys.py +99 -0
  91. stateloom-0.1.0/docs/api-reference.md +1915 -0
  92. stateloom-0.1.0/docs/reference.md +2727 -0
  93. stateloom-0.1.0/examples/basic_anthropic.py +29 -0
  94. stateloom-0.1.0/examples/basic_openai.py +40 -0
  95. stateloom-0.1.0/examples/budget_enforcement.py +44 -0
  96. stateloom-0.1.0/examples/pii_detection.py +45 -0
  97. stateloom-0.1.0/examples/session_tracking.py +42 -0
  98. stateloom-0.1.0/pyproject.toml +100 -0
  99. stateloom-0.1.0/src/stateloom/__init__.py +2148 -0
  100. stateloom-0.1.0/src/stateloom/_version.py +1 -0
  101. stateloom-0.1.0/src/stateloom/agent/__init__.py +22 -0
  102. stateloom-0.1.0/src/stateloom/agent/models.py +99 -0
  103. stateloom-0.1.0/src/stateloom/agent/prompt_file.py +203 -0
  104. stateloom-0.1.0/src/stateloom/agent/prompt_watcher.py +405 -0
  105. stateloom-0.1.0/src/stateloom/agent/resolver.py +124 -0
  106. stateloom-0.1.0/src/stateloom/auth/__init__.py +25 -0
  107. stateloom-0.1.0/src/stateloom/auth/dependencies.py +79 -0
  108. stateloom-0.1.0/src/stateloom/auth/endpoints.py +751 -0
  109. stateloom-0.1.0/src/stateloom/auth/jwt.py +170 -0
  110. stateloom-0.1.0/src/stateloom/auth/models.py +56 -0
  111. stateloom-0.1.0/src/stateloom/auth/oidc.py +239 -0
  112. stateloom-0.1.0/src/stateloom/auth/oidc_models.py +32 -0
  113. stateloom-0.1.0/src/stateloom/auth/password.py +69 -0
  114. stateloom-0.1.0/src/stateloom/auth/permissions.py +166 -0
  115. stateloom-0.1.0/src/stateloom/cache/__init__.py +34 -0
  116. stateloom-0.1.0/src/stateloom/cache/base.py +57 -0
  117. stateloom-0.1.0/src/stateloom/cache/memory_store.py +100 -0
  118. stateloom-0.1.0/src/stateloom/cache/normalizer.py +96 -0
  119. stateloom-0.1.0/src/stateloom/cache/redis_store.py +216 -0
  120. stateloom-0.1.0/src/stateloom/cache/redis_vector_backend.py +158 -0
  121. stateloom-0.1.0/src/stateloom/cache/semantic.py +155 -0
  122. stateloom-0.1.0/src/stateloom/cache/sqlite_store.py +176 -0
  123. stateloom-0.1.0/src/stateloom/cache/vector_backend.py +151 -0
  124. stateloom-0.1.0/src/stateloom/chat.py +921 -0
  125. stateloom-0.1.0/src/stateloom/cli/__init__.py +325 -0
  126. stateloom-0.1.0/src/stateloom/cli/__main__.py +5 -0
  127. stateloom-0.1.0/src/stateloom/cli/doctor_command.py +199 -0
  128. stateloom-0.1.0/src/stateloom/cli/login_command.py +96 -0
  129. stateloom-0.1.0/src/stateloom/cli/main.py +5 -0
  130. stateloom-0.1.0/src/stateloom/cli/ollama_commands.py +212 -0
  131. stateloom-0.1.0/src/stateloom/cli/stats_command.py +130 -0
  132. stateloom-0.1.0/src/stateloom/cli/tail_command.py +172 -0
  133. stateloom-0.1.0/src/stateloom/cli.py +77 -0
  134. stateloom-0.1.0/src/stateloom/compliance/__init__.py +22 -0
  135. stateloom-0.1.0/src/stateloom/compliance/audit.py +28 -0
  136. stateloom-0.1.0/src/stateloom/compliance/legal_rules.py +38 -0
  137. stateloom-0.1.0/src/stateloom/compliance/profiles.py +91 -0
  138. stateloom-0.1.0/src/stateloom/compliance/purge.py +110 -0
  139. stateloom-0.1.0/src/stateloom/concurrency.py +61 -0
  140. stateloom-0.1.0/src/stateloom/consensus/__init__.py +17 -0
  141. stateloom-0.1.0/src/stateloom/consensus/aggregation.py +126 -0
  142. stateloom-0.1.0/src/stateloom/consensus/confidence.py +61 -0
  143. stateloom-0.1.0/src/stateloom/consensus/models.py +83 -0
  144. stateloom-0.1.0/src/stateloom/consensus/orchestrator.py +119 -0
  145. stateloom-0.1.0/src/stateloom/consensus/prompts.py +29 -0
  146. stateloom-0.1.0/src/stateloom/consensus/strategies/__init__.py +38 -0
  147. stateloom-0.1.0/src/stateloom/consensus/strategies/debate.py +255 -0
  148. stateloom-0.1.0/src/stateloom/consensus/strategies/self_consistency.py +136 -0
  149. stateloom-0.1.0/src/stateloom/consensus/strategies/vote.py +144 -0
  150. stateloom-0.1.0/src/stateloom/core/__init__.py +67 -0
  151. stateloom-0.1.0/src/stateloom/core/config.py +942 -0
  152. stateloom-0.1.0/src/stateloom/core/context.py +74 -0
  153. stateloom-0.1.0/src/stateloom/core/errors.py +474 -0
  154. stateloom-0.1.0/src/stateloom/core/event.py +370 -0
  155. stateloom-0.1.0/src/stateloom/core/feature_registry.py +94 -0
  156. stateloom-0.1.0/src/stateloom/core/interfaces.py +47 -0
  157. stateloom-0.1.0/src/stateloom/core/job.py +69 -0
  158. stateloom-0.1.0/src/stateloom/core/observability_protocol.py +73 -0
  159. stateloom-0.1.0/src/stateloom/core/organization.py +101 -0
  160. stateloom-0.1.0/src/stateloom/core/response_helpers.py +40 -0
  161. stateloom-0.1.0/src/stateloom/core/session.py +390 -0
  162. stateloom-0.1.0/src/stateloom/core/signals.py +71 -0
  163. stateloom-0.1.0/src/stateloom/core/types.py +163 -0
  164. stateloom-0.1.0/src/stateloom/dashboard/__init__.py +7 -0
  165. stateloom-0.1.0/src/stateloom/dashboard/api.py +3516 -0
  166. stateloom-0.1.0/src/stateloom/dashboard/log_buffer.py +86 -0
  167. stateloom-0.1.0/src/stateloom/dashboard/observability_api.py +51 -0
  168. stateloom-0.1.0/src/stateloom/dashboard/oidc_api.py +146 -0
  169. stateloom-0.1.0/src/stateloom/dashboard/server.py +453 -0
  170. stateloom-0.1.0/src/stateloom/dashboard/static/app.js +5551 -0
  171. stateloom-0.1.0/src/stateloom/dashboard/static/index.html +1872 -0
  172. stateloom-0.1.0/src/stateloom/dashboard/static/style.css +3073 -0
  173. stateloom-0.1.0/src/stateloom/dashboard/user_api.py +225 -0
  174. stateloom-0.1.0/src/stateloom/dashboard/ws.py +157 -0
  175. stateloom-0.1.0/src/stateloom/ee/LICENSE +99 -0
  176. stateloom-0.1.0/src/stateloom/ee/__init__.py +124 -0
  177. stateloom-0.1.0/src/stateloom/ee/agent/__init__.py +3 -0
  178. stateloom-0.1.0/src/stateloom/ee/agent/models.py +3 -0
  179. stateloom-0.1.0/src/stateloom/ee/agent/prompt_file.py +3 -0
  180. stateloom-0.1.0/src/stateloom/ee/agent/prompt_watcher.py +3 -0
  181. stateloom-0.1.0/src/stateloom/ee/agent/resolver.py +3 -0
  182. stateloom-0.1.0/src/stateloom/ee/auth/__init__.py +3 -0
  183. stateloom-0.1.0/src/stateloom/ee/auth/dependencies.py +3 -0
  184. stateloom-0.1.0/src/stateloom/ee/auth/endpoints.py +3 -0
  185. stateloom-0.1.0/src/stateloom/ee/auth/jwt.py +3 -0
  186. stateloom-0.1.0/src/stateloom/ee/auth/models.py +3 -0
  187. stateloom-0.1.0/src/stateloom/ee/auth/oidc.py +3 -0
  188. stateloom-0.1.0/src/stateloom/ee/auth/oidc_models.py +3 -0
  189. stateloom-0.1.0/src/stateloom/ee/auth/password.py +3 -0
  190. stateloom-0.1.0/src/stateloom/ee/auth/permissions.py +3 -0
  191. stateloom-0.1.0/src/stateloom/ee/compliance/__init__.py +3 -0
  192. stateloom-0.1.0/src/stateloom/ee/compliance/audit.py +3 -0
  193. stateloom-0.1.0/src/stateloom/ee/compliance/legal_rules.py +3 -0
  194. stateloom-0.1.0/src/stateloom/ee/compliance/profiles.py +3 -0
  195. stateloom-0.1.0/src/stateloom/ee/compliance/purge.py +3 -0
  196. stateloom-0.1.0/src/stateloom/ee/dashboard/__init__.py +5 -0
  197. stateloom-0.1.0/src/stateloom/ee/dashboard/api.py +3 -0
  198. stateloom-0.1.0/src/stateloom/ee/dashboard/observability_api.py +3 -0
  199. stateloom-0.1.0/src/stateloom/ee/dashboard/oidc_api.py +3 -0
  200. stateloom-0.1.0/src/stateloom/ee/dashboard/server.py +3 -0
  201. stateloom-0.1.0/src/stateloom/ee/dashboard/user_api.py +3 -0
  202. stateloom-0.1.0/src/stateloom/ee/dashboard/ws.py +3 -0
  203. stateloom-0.1.0/src/stateloom/ee/jobs/__init__.py +3 -0
  204. stateloom-0.1.0/src/stateloom/ee/jobs/processor.py +3 -0
  205. stateloom-0.1.0/src/stateloom/ee/jobs/queue.py +3 -0
  206. stateloom-0.1.0/src/stateloom/ee/jobs/redis_queue.py +3 -0
  207. stateloom-0.1.0/src/stateloom/ee/jobs/webhook.py +3 -0
  208. stateloom-0.1.0/src/stateloom/ee/license.py +178 -0
  209. stateloom-0.1.0/src/stateloom/ee/middleware/__init__.py +1 -0
  210. stateloom-0.1.0/src/stateloom/ee/middleware/blast_radius.py +3 -0
  211. stateloom-0.1.0/src/stateloom/ee/middleware/circuit_breaker.py +3 -0
  212. stateloom-0.1.0/src/stateloom/ee/middleware/compliance.py +3 -0
  213. stateloom-0.1.0/src/stateloom/ee/middleware/kill_switch.py +3 -0
  214. stateloom-0.1.0/src/stateloom/ee/middleware/rate_limiter.py +3 -0
  215. stateloom-0.1.0/src/stateloom/ee/observability/__init__.py +3 -0
  216. stateloom-0.1.0/src/stateloom/ee/observability/aggregator.py +3 -0
  217. stateloom-0.1.0/src/stateloom/ee/observability/alerting.py +3 -0
  218. stateloom-0.1.0/src/stateloom/ee/observability/collector.py +3 -0
  219. stateloom-0.1.0/src/stateloom/ee/observability/tracing.py +3 -0
  220. stateloom-0.1.0/src/stateloom/ee/proxy/__init__.py +3 -0
  221. stateloom-0.1.0/src/stateloom/ee/proxy/anthropic_native.py +3 -0
  222. stateloom-0.1.0/src/stateloom/ee/proxy/auth.py +3 -0
  223. stateloom-0.1.0/src/stateloom/ee/proxy/billing.py +3 -0
  224. stateloom-0.1.0/src/stateloom/ee/proxy/code_assist.py +3 -0
  225. stateloom-0.1.0/src/stateloom/ee/proxy/errors.py +3 -0
  226. stateloom-0.1.0/src/stateloom/ee/proxy/gemini_native.py +3 -0
  227. stateloom-0.1.0/src/stateloom/ee/proxy/passthrough.py +3 -0
  228. stateloom-0.1.0/src/stateloom/ee/proxy/rate_limiter.py +3 -0
  229. stateloom-0.1.0/src/stateloom/ee/proxy/response_format.py +3 -0
  230. stateloom-0.1.0/src/stateloom/ee/proxy/responses.py +3 -0
  231. stateloom-0.1.0/src/stateloom/ee/proxy/router.py +3 -0
  232. stateloom-0.1.0/src/stateloom/ee/proxy/sticky_session.py +3 -0
  233. stateloom-0.1.0/src/stateloom/ee/proxy/virtual_key.py +3 -0
  234. stateloom-0.1.0/src/stateloom/ee/setup.py +511 -0
  235. stateloom-0.1.0/src/stateloom/experiment/__init__.py +15 -0
  236. stateloom-0.1.0/src/stateloom/experiment/assigner.py +150 -0
  237. stateloom-0.1.0/src/stateloom/experiment/backtest.py +233 -0
  238. stateloom-0.1.0/src/stateloom/experiment/manager.py +219 -0
  239. stateloom-0.1.0/src/stateloom/experiment/models.py +132 -0
  240. stateloom-0.1.0/src/stateloom/export/__init__.py +13 -0
  241. stateloom-0.1.0/src/stateloom/export/bundle.py +365 -0
  242. stateloom-0.1.0/src/stateloom/export/console.py +159 -0
  243. stateloom-0.1.0/src/stateloom/ext/__init__.py +3 -0
  244. stateloom-0.1.0/src/stateloom/ext/langchain.py +563 -0
  245. stateloom-0.1.0/src/stateloom/ext/langgraph.py +141 -0
  246. stateloom-0.1.0/src/stateloom/gate.py +2313 -0
  247. stateloom-0.1.0/src/stateloom/guardrails/__init__.py +22 -0
  248. stateloom-0.1.0/src/stateloom/guardrails/local_validator.py +185 -0
  249. stateloom-0.1.0/src/stateloom/guardrails/nli_classifier.py +132 -0
  250. stateloom-0.1.0/src/stateloom/guardrails/output_scanner.py +72 -0
  251. stateloom-0.1.0/src/stateloom/guardrails/patterns.py +324 -0
  252. stateloom-0.1.0/src/stateloom/guardrails/validators.py +30 -0
  253. stateloom-0.1.0/src/stateloom/integrations/__init__.py +0 -0
  254. stateloom-0.1.0/src/stateloom/intercept/__init__.py +9 -0
  255. stateloom-0.1.0/src/stateloom/intercept/adapters/__init__.py +7 -0
  256. stateloom-0.1.0/src/stateloom/intercept/adapters/anthropic_adapter.py +283 -0
  257. stateloom-0.1.0/src/stateloom/intercept/adapters/cohere_adapter.py +174 -0
  258. stateloom-0.1.0/src/stateloom/intercept/adapters/gemini_adapter.py +287 -0
  259. stateloom-0.1.0/src/stateloom/intercept/adapters/litellm_adapter.py +370 -0
  260. stateloom-0.1.0/src/stateloom/intercept/adapters/mistral_adapter.py +155 -0
  261. stateloom-0.1.0/src/stateloom/intercept/adapters/openai_adapter.py +190 -0
  262. stateloom-0.1.0/src/stateloom/intercept/anthropic_patch.py +252 -0
  263. stateloom-0.1.0/src/stateloom/intercept/auto_patch.py +102 -0
  264. stateloom-0.1.0/src/stateloom/intercept/gemini_patch.py +247 -0
  265. stateloom-0.1.0/src/stateloom/intercept/generic_interceptor.py +566 -0
  266. stateloom-0.1.0/src/stateloom/intercept/openai_patch.py +253 -0
  267. stateloom-0.1.0/src/stateloom/intercept/provider_adapter.py +391 -0
  268. stateloom-0.1.0/src/stateloom/intercept/provider_registry.py +67 -0
  269. stateloom-0.1.0/src/stateloom/intercept/unpatch.py +58 -0
  270. stateloom-0.1.0/src/stateloom/jobs/__init__.py +16 -0
  271. stateloom-0.1.0/src/stateloom/jobs/processor.py +358 -0
  272. stateloom-0.1.0/src/stateloom/jobs/queue.py +192 -0
  273. stateloom-0.1.0/src/stateloom/jobs/redis_queue.py +238 -0
  274. stateloom-0.1.0/src/stateloom/jobs/webhook.py +122 -0
  275. stateloom-0.1.0/src/stateloom/local/__init__.py +17 -0
  276. stateloom-0.1.0/src/stateloom/local/adapter.py +94 -0
  277. stateloom-0.1.0/src/stateloom/local/client.py +412 -0
  278. stateloom-0.1.0/src/stateloom/local/hardware.py +133 -0
  279. stateloom-0.1.0/src/stateloom/local/manager.py +404 -0
  280. stateloom-0.1.0/src/stateloom/local/models.py +157 -0
  281. stateloom-0.1.0/src/stateloom/middleware/__init__.py +6 -0
  282. stateloom-0.1.0/src/stateloom/middleware/auto_router.py +985 -0
  283. stateloom-0.1.0/src/stateloom/middleware/base.py +146 -0
  284. stateloom-0.1.0/src/stateloom/middleware/blast_radius.py +440 -0
  285. stateloom-0.1.0/src/stateloom/middleware/budget_enforcer.py +263 -0
  286. stateloom-0.1.0/src/stateloom/middleware/cache.py +234 -0
  287. stateloom-0.1.0/src/stateloom/middleware/circuit_breaker.py +580 -0
  288. stateloom-0.1.0/src/stateloom/middleware/compliance.py +241 -0
  289. stateloom-0.1.0/src/stateloom/middleware/cost_tracker.py +353 -0
  290. stateloom-0.1.0/src/stateloom/middleware/event_recorder.py +399 -0
  291. stateloom-0.1.0/src/stateloom/middleware/experiment.py +150 -0
  292. stateloom-0.1.0/src/stateloom/middleware/guardrails.py +476 -0
  293. stateloom-0.1.0/src/stateloom/middleware/kill_switch.py +275 -0
  294. stateloom-0.1.0/src/stateloom/middleware/latency_tracker.py +32 -0
  295. stateloom-0.1.0/src/stateloom/middleware/loop_detector.py +97 -0
  296. stateloom-0.1.0/src/stateloom/middleware/pii_scanner.py +882 -0
  297. stateloom-0.1.0/src/stateloom/middleware/pipeline.py +440 -0
  298. stateloom-0.1.0/src/stateloom/middleware/precompute.py +65 -0
  299. stateloom-0.1.0/src/stateloom/middleware/rate_limiter.py +395 -0
  300. stateloom-0.1.0/src/stateloom/middleware/response_converter.py +190 -0
  301. stateloom-0.1.0/src/stateloom/middleware/semantic_router.py +119 -0
  302. stateloom-0.1.0/src/stateloom/middleware/shadow.py +1003 -0
  303. stateloom-0.1.0/src/stateloom/middleware/similarity.py +245 -0
  304. stateloom-0.1.0/src/stateloom/middleware/timeout_checker.py +107 -0
  305. stateloom-0.1.0/src/stateloom/mock.py +298 -0
  306. stateloom-0.1.0/src/stateloom/observability/__init__.py +14 -0
  307. stateloom-0.1.0/src/stateloom/observability/aggregator.py +290 -0
  308. stateloom-0.1.0/src/stateloom/observability/alerting.py +70 -0
  309. stateloom-0.1.0/src/stateloom/observability/collector.py +356 -0
  310. stateloom-0.1.0/src/stateloom/observability/tracing.py +113 -0
  311. stateloom-0.1.0/src/stateloom/pii/__init__.py +6 -0
  312. stateloom-0.1.0/src/stateloom/pii/ner_detector.py +100 -0
  313. stateloom-0.1.0/src/stateloom/pii/patterns.py +140 -0
  314. stateloom-0.1.0/src/stateloom/pii/rehydrator.py +44 -0
  315. stateloom-0.1.0/src/stateloom/pii/scanner.py +136 -0
  316. stateloom-0.1.0/src/stateloom/pii/stream_buffer.py +117 -0
  317. stateloom-0.1.0/src/stateloom/pricing/__init__.py +5 -0
  318. stateloom-0.1.0/src/stateloom/pricing/data/prices.json +135 -0
  319. stateloom-0.1.0/src/stateloom/pricing/registry.py +81 -0
  320. stateloom-0.1.0/src/stateloom/proxy/__init__.py +13 -0
  321. stateloom-0.1.0/src/stateloom/proxy/anthropic_native.py +964 -0
  322. stateloom-0.1.0/src/stateloom/proxy/auth.py +436 -0
  323. stateloom-0.1.0/src/stateloom/proxy/billing.py +52 -0
  324. stateloom-0.1.0/src/stateloom/proxy/code_assist.py +851 -0
  325. stateloom-0.1.0/src/stateloom/proxy/errors.py +72 -0
  326. stateloom-0.1.0/src/stateloom/proxy/gemini_native.py +740 -0
  327. stateloom-0.1.0/src/stateloom/proxy/passthrough.py +228 -0
  328. stateloom-0.1.0/src/stateloom/proxy/rate_limiter.py +237 -0
  329. stateloom-0.1.0/src/stateloom/proxy/response_format.py +131 -0
  330. stateloom-0.1.0/src/stateloom/proxy/responses.py +1394 -0
  331. stateloom-0.1.0/src/stateloom/proxy/router.py +1177 -0
  332. stateloom-0.1.0/src/stateloom/proxy/sticky_session.py +139 -0
  333. stateloom-0.1.0/src/stateloom/proxy/stream_helpers.py +111 -0
  334. stateloom-0.1.0/src/stateloom/proxy/virtual_key.py +75 -0
  335. stateloom-0.1.0/src/stateloom/py.typed +0 -0
  336. stateloom-0.1.0/src/stateloom/replay/__init__.py +27 -0
  337. stateloom-0.1.0/src/stateloom/replay/engine.py +260 -0
  338. stateloom-0.1.0/src/stateloom/replay/network_blocker.py +161 -0
  339. stateloom-0.1.0/src/stateloom/replay/safety.py +101 -0
  340. stateloom-0.1.0/src/stateloom/replay/schema.py +243 -0
  341. stateloom-0.1.0/src/stateloom/replay/step.py +22 -0
  342. stateloom-0.1.0/src/stateloom/retry.py +499 -0
  343. stateloom-0.1.0/src/stateloom/security/__init__.py +6 -0
  344. stateloom-0.1.0/src/stateloom/security/audit_hook.py +197 -0
  345. stateloom-0.1.0/src/stateloom/security/vault.py +141 -0
  346. stateloom-0.1.0/src/stateloom/store/__init__.py +14 -0
  347. stateloom-0.1.0/src/stateloom/store/alembic/__init__.py +0 -0
  348. stateloom-0.1.0/src/stateloom/store/alembic/env.py +27 -0
  349. stateloom-0.1.0/src/stateloom/store/alembic/script.py.mako +22 -0
  350. stateloom-0.1.0/src/stateloom/store/alembic/versions/001_initial_schema.py +271 -0
  351. stateloom-0.1.0/src/stateloom/store/alembic/versions/002_add_migration_columns.py +76 -0
  352. stateloom-0.1.0/src/stateloom/store/alembic/versions/003_add_auth_tables.py +111 -0
  353. stateloom-0.1.0/src/stateloom/store/alembic/versions/004_add_cost_by_model.py +37 -0
  354. stateloom-0.1.0/src/stateloom/store/alembic/versions/005_add_guardrail_detections.py +33 -0
  355. stateloom-0.1.0/src/stateloom/store/alembic/versions/006_add_session_typed_fields.py +81 -0
  356. stateloom-0.1.0/src/stateloom/store/alembic/versions/007_rename_shadow_data_json.py +32 -0
  357. stateloom-0.1.0/src/stateloom/store/alembic/versions/008_add_overwrite_count.py +35 -0
  358. stateloom-0.1.0/src/stateloom/store/alembic/versions/__init__.py +0 -0
  359. stateloom-0.1.0/src/stateloom/store/base.py +392 -0
  360. stateloom-0.1.0/src/stateloom/store/memory_store.py +758 -0
  361. stateloom-0.1.0/src/stateloom/store/migrator.py +69 -0
  362. stateloom-0.1.0/src/stateloom/store/postgres_store.py +2336 -0
  363. stateloom-0.1.0/src/stateloom/store/sqlite_store.py +2691 -0
  364. stateloom-0.1.0/test_experiments.py +142 -0
  365. stateloom-0.1.0/test_manual.py +824 -0
  366. stateloom-0.1.0/tests/__init__.py +0 -0
  367. stateloom-0.1.0/tests/conftest.py +44 -0
  368. stateloom-0.1.0/tests/test_admin_locks.py +485 -0
  369. stateloom-0.1.0/tests/test_agent/__init__.py +0 -0
  370. stateloom-0.1.0/tests/test_agent/test_models.py +126 -0
  371. stateloom-0.1.0/tests/test_agent/test_prompt_file.py +189 -0
  372. stateloom-0.1.0/tests/test_agent/test_prompt_watcher.py +437 -0
  373. stateloom-0.1.0/tests/test_agent/test_resolver.py +195 -0
  374. stateloom-0.1.0/tests/test_agent/test_store.py +225 -0
  375. stateloom-0.1.0/tests/test_auth/__init__.py +0 -0
  376. stateloom-0.1.0/tests/test_auth/test_bootstrap.py +182 -0
  377. stateloom-0.1.0/tests/test_auth/test_dependencies.py +92 -0
  378. stateloom-0.1.0/tests/test_auth/test_device_flow.py +229 -0
  379. stateloom-0.1.0/tests/test_auth/test_endpoints.py +268 -0
  380. stateloom-0.1.0/tests/test_auth/test_jwt.py +113 -0
  381. stateloom-0.1.0/tests/test_auth/test_models.py +104 -0
  382. stateloom-0.1.0/tests/test_auth/test_oidc.py +272 -0
  383. stateloom-0.1.0/tests/test_auth/test_oidc_endpoints.py +204 -0
  384. stateloom-0.1.0/tests/test_auth/test_password.py +55 -0
  385. stateloom-0.1.0/tests/test_auth/test_permissions.py +123 -0
  386. stateloom-0.1.0/tests/test_cache/__init__.py +0 -0
  387. stateloom-0.1.0/tests/test_cache/test_cache_middleware.py +258 -0
  388. stateloom-0.1.0/tests/test_cache/test_memory_store.py +150 -0
  389. stateloom-0.1.0/tests/test_cache/test_normalizer.py +184 -0
  390. stateloom-0.1.0/tests/test_cache/test_redis_cache_store.py +181 -0
  391. stateloom-0.1.0/tests/test_cache/test_redis_vector_backend.py +105 -0
  392. stateloom-0.1.0/tests/test_cache/test_semantic.py +171 -0
  393. stateloom-0.1.0/tests/test_cache/test_sqlite_store.py +138 -0
  394. stateloom-0.1.0/tests/test_cache/test_vector_backend.py +109 -0
  395. stateloom-0.1.0/tests/test_chat.py +994 -0
  396. stateloom-0.1.0/tests/test_checkpoint.py +80 -0
  397. stateloom-0.1.0/tests/test_cli/__init__.py +0 -0
  398. stateloom-0.1.0/tests/test_cli/test_doctor.py +278 -0
  399. stateloom-0.1.0/tests/test_cli/test_serve.py +135 -0
  400. stateloom-0.1.0/tests/test_cli/test_stats.py +171 -0
  401. stateloom-0.1.0/tests/test_cli/test_tail.py +393 -0
  402. stateloom-0.1.0/tests/test_compliance/__init__.py +0 -0
  403. stateloom-0.1.0/tests/test_compliance/test_audit.py +61 -0
  404. stateloom-0.1.0/tests/test_compliance/test_data_residency.py +231 -0
  405. stateloom-0.1.0/tests/test_compliance/test_legal_rules.py +31 -0
  406. stateloom-0.1.0/tests/test_compliance/test_profiles.py +128 -0
  407. stateloom-0.1.0/tests/test_compliance/test_purge.py +118 -0
  408. stateloom-0.1.0/tests/test_compliance/test_zero_retention.py +361 -0
  409. stateloom-0.1.0/tests/test_concurrency_reliability.py +365 -0
  410. stateloom-0.1.0/tests/test_consensus/__init__.py +0 -0
  411. stateloom-0.1.0/tests/test_consensus/test_agent_consensus.py +663 -0
  412. stateloom-0.1.0/tests/test_consensus/test_aggregation.py +104 -0
  413. stateloom-0.1.0/tests/test_consensus/test_confidence.py +98 -0
  414. stateloom-0.1.0/tests/test_consensus/test_ee_gating.py +460 -0
  415. stateloom-0.1.0/tests/test_consensus/test_events.py +95 -0
  416. stateloom-0.1.0/tests/test_consensus/test_models.py +160 -0
  417. stateloom-0.1.0/tests/test_consensus/test_orchestrator.py +360 -0
  418. stateloom-0.1.0/tests/test_consensus/test_strategies.py +468 -0
  419. stateloom-0.1.0/tests/test_core/__init__.py +0 -0
  420. stateloom-0.1.0/tests/test_core/test_concurrency.py +101 -0
  421. stateloom-0.1.0/tests/test_core/test_config.py +87 -0
  422. stateloom-0.1.0/tests/test_core/test_config_validation.py +133 -0
  423. stateloom-0.1.0/tests/test_core/test_context.py +27 -0
  424. stateloom-0.1.0/tests/test_core/test_errors.py +244 -0
  425. stateloom-0.1.0/tests/test_core/test_feature_gating.py +344 -0
  426. stateloom-0.1.0/tests/test_core/test_feature_registry.py +91 -0
  427. stateloom-0.1.0/tests/test_core/test_init.py +131 -0
  428. stateloom-0.1.0/tests/test_core/test_interfaces.py +52 -0
  429. stateloom-0.1.0/tests/test_core/test_organization.py +125 -0
  430. stateloom-0.1.0/tests/test_core/test_pricing.py +84 -0
  431. stateloom-0.1.0/tests/test_core/test_session.py +147 -0
  432. stateloom-0.1.0/tests/test_core/test_signals.py +96 -0
  433. stateloom-0.1.0/tests/test_core/test_tool_session.py +476 -0
  434. stateloom-0.1.0/tests/test_dashboard/__init__.py +0 -0
  435. stateloom-0.1.0/tests/test_dashboard/test_agent_api.py +422 -0
  436. stateloom-0.1.0/tests/test_dashboard/test_api_versioning.py +191 -0
  437. stateloom-0.1.0/tests/test_dashboard/test_auth_middleware.py +266 -0
  438. stateloom-0.1.0/tests/test_dashboard/test_consensus_api.py +240 -0
  439. stateloom-0.1.0/tests/test_dashboard/test_debug_endpoints.py +209 -0
  440. stateloom-0.1.0/tests/test_dashboard/test_experiment_crud.py +260 -0
  441. stateloom-0.1.0/tests/test_dashboard/test_guardrails_api.py +86 -0
  442. stateloom-0.1.0/tests/test_dashboard/test_log_buffer.py +146 -0
  443. stateloom-0.1.0/tests/test_e2e/__init__.py +0 -0
  444. stateloom-0.1.0/tests/test_e2e/conftest.py +53 -0
  445. stateloom-0.1.0/tests/test_e2e/helpers.py +101 -0
  446. stateloom-0.1.0/tests/test_e2e/test_cache_hit.py +56 -0
  447. stateloom-0.1.0/tests/test_e2e/test_cloud_with_shadow.py +77 -0
  448. stateloom-0.1.0/tests/test_e2e/test_local_routed_call.py +70 -0
  449. stateloom-0.1.0/tests/test_e2e/test_local_with_shadow.py +67 -0
  450. stateloom-0.1.0/tests/test_e2e/test_pii_block.py +59 -0
  451. stateloom-0.1.0/tests/test_e2e/test_single_cloud_call.py +46 -0
  452. stateloom-0.1.0/tests/test_ee/__init__.py +0 -0
  453. stateloom-0.1.0/tests/test_ee/test_license.py +307 -0
  454. stateloom-0.1.0/tests/test_ee/test_license_gating.py +229 -0
  455. stateloom-0.1.0/tests/test_ee/test_restricted_dev_mode.py +349 -0
  456. stateloom-0.1.0/tests/test_experiment/__init__.py +0 -0
  457. stateloom-0.1.0/tests/test_experiment/test_agent_experiment.py +339 -0
  458. stateloom-0.1.0/tests/test_experiment/test_api.py +214 -0
  459. stateloom-0.1.0/tests/test_experiment/test_assigner.py +225 -0
  460. stateloom-0.1.0/tests/test_experiment/test_backtest.py +312 -0
  461. stateloom-0.1.0/tests/test_experiment/test_manager.py +321 -0
  462. stateloom-0.1.0/tests/test_experiment/test_middleware.py +212 -0
  463. stateloom-0.1.0/tests/test_experiment/test_models.py +229 -0
  464. stateloom-0.1.0/tests/test_export/__init__.py +0 -0
  465. stateloom-0.1.0/tests/test_export/test_bundle.py +903 -0
  466. stateloom-0.1.0/tests/test_ext/__init__.py +0 -0
  467. stateloom-0.1.0/tests/test_ext/test_langchain.py +710 -0
  468. stateloom-0.1.0/tests/test_ext/test_langgraph.py +194 -0
  469. stateloom-0.1.0/tests/test_gate_compliance.py +204 -0
  470. stateloom-0.1.0/tests/test_gate_hierarchy.py +213 -0
  471. stateloom-0.1.0/tests/test_guardrails/__init__.py +0 -0
  472. stateloom-0.1.0/tests/test_guardrails/test_local_validator.py +118 -0
  473. stateloom-0.1.0/tests/test_guardrails/test_new_patterns.py +155 -0
  474. stateloom-0.1.0/tests/test_guardrails/test_nli_classifier.py +116 -0
  475. stateloom-0.1.0/tests/test_guardrails/test_output_scanner.py +104 -0
  476. stateloom-0.1.0/tests/test_guardrails/test_patterns.py +206 -0
  477. stateloom-0.1.0/tests/test_integration/__init__.py +0 -0
  478. stateloom-0.1.0/tests/test_intercept/__init__.py +0 -0
  479. stateloom-0.1.0/tests/test_intercept/test_adapter_response.py +515 -0
  480. stateloom-0.1.0/tests/test_intercept/test_cohere_adapter.py +137 -0
  481. stateloom-0.1.0/tests/test_intercept/test_custom_provider.py +147 -0
  482. stateloom-0.1.0/tests/test_intercept/test_gemini_patch.py +131 -0
  483. stateloom-0.1.0/tests/test_intercept/test_generic_interceptor.py +278 -0
  484. stateloom-0.1.0/tests/test_intercept/test_litellm_adapter.py +158 -0
  485. stateloom-0.1.0/tests/test_intercept/test_mistral_adapter.py +93 -0
  486. stateloom-0.1.0/tests/test_intercept/test_provider_adapter.py +353 -0
  487. stateloom-0.1.0/tests/test_intercept/test_provider_registry.py +139 -0
  488. stateloom-0.1.0/tests/test_jobs/__init__.py +1 -0
  489. stateloom-0.1.0/tests/test_jobs/test_agent_jobs.py +278 -0
  490. stateloom-0.1.0/tests/test_jobs/test_api.py +237 -0
  491. stateloom-0.1.0/tests/test_jobs/test_job_model.py +227 -0
  492. stateloom-0.1.0/tests/test_jobs/test_processor.py +264 -0
  493. stateloom-0.1.0/tests/test_jobs/test_queue.py +161 -0
  494. stateloom-0.1.0/tests/test_jobs/test_redis_queue.py +347 -0
  495. stateloom-0.1.0/tests/test_jobs/test_store_jobs.py +238 -0
  496. stateloom-0.1.0/tests/test_jobs/test_webhook.py +185 -0
  497. stateloom-0.1.0/tests/test_local/__init__.py +0 -0
  498. stateloom-0.1.0/tests/test_local/test_adapter.py +54 -0
  499. stateloom-0.1.0/tests/test_local/test_client.py +199 -0
  500. stateloom-0.1.0/tests/test_local/test_hardware.py +78 -0
  501. stateloom-0.1.0/tests/test_local/test_manager.py +989 -0
  502. stateloom-0.1.0/tests/test_local/test_models.py +24 -0
  503. stateloom-0.1.0/tests/test_manual/__init__.py +0 -0
  504. stateloom-0.1.0/tests/test_manual/test_parent_child.py +326 -0
  505. stateloom-0.1.0/tests/test_middleware/__init__.py +0 -0
  506. stateloom-0.1.0/tests/test_middleware/test_auto_router.py +1229 -0
  507. stateloom-0.1.0/tests/test_middleware/test_blast_radius.py +512 -0
  508. stateloom-0.1.0/tests/test_middleware/test_budget_hierarchy.py +201 -0
  509. stateloom-0.1.0/tests/test_middleware/test_cache_compliance.py +172 -0
  510. stateloom-0.1.0/tests/test_middleware/test_circuit_breaker.py +485 -0
  511. stateloom-0.1.0/tests/test_middleware/test_compliance.py +415 -0
  512. stateloom-0.1.0/tests/test_middleware/test_cost_tracker_model.py +94 -0
  513. stateloom-0.1.0/tests/test_middleware/test_cost_tracker_tool_continuation.py +464 -0
  514. stateloom-0.1.0/tests/test_middleware/test_embedding_cache.py +119 -0
  515. stateloom-0.1.0/tests/test_middleware/test_force_local.py +279 -0
  516. stateloom-0.1.0/tests/test_middleware/test_guardrails.py +558 -0
  517. stateloom-0.1.0/tests/test_middleware/test_kill_switch.py +479 -0
  518. stateloom-0.1.0/tests/test_middleware/test_pii_conversation_dedup.py +1498 -0
  519. stateloom-0.1.0/tests/test_middleware/test_pii_hierarchy.py +118 -0
  520. stateloom-0.1.0/tests/test_middleware/test_pipeline_framework_context.py +221 -0
  521. stateloom-0.1.0/tests/test_middleware/test_precompute.py +330 -0
  522. stateloom-0.1.0/tests/test_middleware/test_rate_limiter.py +482 -0
  523. stateloom-0.1.0/tests/test_middleware/test_routing_compliance.py +193 -0
  524. stateloom-0.1.0/tests/test_middleware/test_semantic_router.py +230 -0
  525. stateloom-0.1.0/tests/test_middleware/test_shadow.py +811 -0
  526. stateloom-0.1.0/tests/test_middleware/test_similarity.py +195 -0
  527. stateloom-0.1.0/tests/test_middleware/test_store_sync.py +347 -0
  528. stateloom-0.1.0/tests/test_middleware/test_streaming_pipeline.py +871 -0
  529. stateloom-0.1.0/tests/test_middleware/test_timeout.py +219 -0
  530. stateloom-0.1.0/tests/test_mock/__init__.py +0 -0
  531. stateloom-0.1.0/tests/test_mock/test_mock.py +499 -0
  532. stateloom-0.1.0/tests/test_observability/__init__.py +0 -0
  533. stateloom-0.1.0/tests/test_observability/test_aggregator.py +196 -0
  534. stateloom-0.1.0/tests/test_observability/test_collector.py +255 -0
  535. stateloom-0.1.0/tests/test_observability/test_observability_api.py +197 -0
  536. stateloom-0.1.0/tests/test_parent_child_sessions.py +82 -0
  537. stateloom-0.1.0/tests/test_pii/__init__.py +0 -0
  538. stateloom-0.1.0/tests/test_pii/test_compliance_patterns.py +117 -0
  539. stateloom-0.1.0/tests/test_pii/test_ner_detector.py +236 -0
  540. stateloom-0.1.0/tests/test_pii/test_rehydrator.py +48 -0
  541. stateloom-0.1.0/tests/test_pii/test_scanner.py +95 -0
  542. stateloom-0.1.0/tests/test_pii/test_stream_buffer.py +193 -0
  543. stateloom-0.1.0/tests/test_production/__init__.py +0 -0
  544. stateloom-0.1.0/tests/test_production/conftest.py +64 -0
  545. stateloom-0.1.0/tests/test_production/helpers.py +110 -0
  546. stateloom-0.1.0/tests/test_production/test_async_jobs.py +101 -0
  547. stateloom-0.1.0/tests/test_production/test_auto_routing.py +220 -0
  548. stateloom-0.1.0/tests/test_production/test_blast_radius.py +266 -0
  549. stateloom-0.1.0/tests/test_production/test_budget_enforcement.py +212 -0
  550. stateloom-0.1.0/tests/test_production/test_caching.py +149 -0
  551. stateloom-0.1.0/tests/test_production/test_checkpoints.py +111 -0
  552. stateloom-0.1.0/tests/test_production/test_circuit_breaker.py +184 -0
  553. stateloom-0.1.0/tests/test_production/test_compliance.py +185 -0
  554. stateloom-0.1.0/tests/test_production/test_durable_resumption.py +171 -0
  555. stateloom-0.1.0/tests/test_production/test_durable_streaming.py +331 -0
  556. stateloom-0.1.0/tests/test_production/test_experiments.py +263 -0
  557. stateloom-0.1.0/tests/test_production/test_kill_switch.py +184 -0
  558. stateloom-0.1.0/tests/test_production/test_loop_detection.py +89 -0
  559. stateloom-0.1.0/tests/test_production/test_managed_agents.py +309 -0
  560. stateloom-0.1.0/tests/test_production/test_multi_feature_workflow.py +320 -0
  561. stateloom-0.1.0/tests/test_production/test_org_team_budget.py +310 -0
  562. stateloom-0.1.0/tests/test_production/test_org_team_hierarchy.py +154 -0
  563. stateloom-0.1.0/tests/test_production/test_parent_child_sessions.py +172 -0
  564. stateloom-0.1.0/tests/test_production/test_pii_detection.py +233 -0
  565. stateloom-0.1.0/tests/test_production/test_proxy_endpoint.py +181 -0
  566. stateloom-0.1.0/tests/test_production/test_rate_limiting.py +162 -0
  567. stateloom-0.1.0/tests/test_production/test_semantic_retries.py +144 -0
  568. stateloom-0.1.0/tests/test_production/test_session_lifecycle.py +158 -0
  569. stateloom-0.1.0/tests/test_production/test_shadow_drafting.py +165 -0
  570. stateloom-0.1.0/tests/test_production/test_timeouts_cancellation.py +146 -0
  571. stateloom-0.1.0/tests/test_production/test_tool_tracking.py +111 -0
  572. stateloom-0.1.0/tests/test_production/test_virtual_keys.py +154 -0
  573. stateloom-0.1.0/tests/test_proxy/__init__.py +0 -0
  574. stateloom-0.1.0/tests/test_proxy/test_agent_proxy.py +291 -0
  575. stateloom-0.1.0/tests/test_proxy/test_anthropic_native.py +660 -0
  576. stateloom-0.1.0/tests/test_proxy/test_auth_helpers.py +30 -0
  577. stateloom-0.1.0/tests/test_proxy/test_auth_shared.py +304 -0
  578. stateloom-0.1.0/tests/test_proxy/test_billing_mode.py +434 -0
  579. stateloom-0.1.0/tests/test_proxy/test_code_assist.py +1097 -0
  580. stateloom-0.1.0/tests/test_proxy/test_end_user.py +207 -0
  581. stateloom-0.1.0/tests/test_proxy/test_gemini_native.py +684 -0
  582. stateloom-0.1.0/tests/test_proxy/test_passthrough.py +309 -0
  583. stateloom-0.1.0/tests/test_proxy/test_proxy_auth.py +151 -0
  584. stateloom-0.1.0/tests/test_proxy/test_proxy_rate_limiter.py +449 -0
  585. stateloom-0.1.0/tests/test_proxy/test_proxy_router.py +448 -0
  586. stateloom-0.1.0/tests/test_proxy/test_response_format.py +219 -0
  587. stateloom-0.1.0/tests/test_proxy/test_responses.py +1126 -0
  588. stateloom-0.1.0/tests/test_proxy/test_sticky_session.py +182 -0
  589. stateloom-0.1.0/tests/test_proxy/test_stream_helpers.py +153 -0
  590. stateloom-0.1.0/tests/test_proxy/test_virtual_key_scopes.py +147 -0
  591. stateloom-0.1.0/tests/test_proxy/test_virtual_keys.py +206 -0
  592. stateloom-0.1.0/tests/test_proxy/test_vk_scopes.py +359 -0
  593. stateloom-0.1.0/tests/test_replay/__init__.py +0 -0
  594. stateloom-0.1.0/tests/test_replay/test_durable_streaming.py +300 -0
  595. stateloom-0.1.0/tests/test_replay/test_network_blocker.py +86 -0
  596. stateloom-0.1.0/tests/test_replay/test_schema.py +111 -0
  597. stateloom-0.1.0/tests/test_retry.py +478 -0
  598. stateloom-0.1.0/tests/test_security/__init__.py +0 -0
  599. stateloom-0.1.0/tests/test_security/test_audit_hook.py +124 -0
  600. stateloom-0.1.0/tests/test_security/test_security_events.py +51 -0
  601. stateloom-0.1.0/tests/test_security/test_vault.py +94 -0
  602. stateloom-0.1.0/tests/test_session_cancellation.py +92 -0
  603. stateloom-0.1.0/tests/test_session_suspension.py +270 -0
  604. stateloom-0.1.0/tests/test_store/__init__.py +0 -0
  605. stateloom-0.1.0/tests/test_store/test_cost_by_model.py +62 -0
  606. stateloom-0.1.0/tests/test_store/test_guardrail_detections.py +54 -0
  607. stateloom-0.1.0/tests/test_store/test_memory_store.py +105 -0
  608. stateloom-0.1.0/tests/test_store/test_memory_store_hierarchy.py +134 -0
  609. stateloom-0.1.0/tests/test_store/test_migrator.py +281 -0
  610. stateloom-0.1.0/tests/test_store/test_postgres_store.py +315 -0
  611. stateloom-0.1.0/tests/test_store/test_sqlite_store.py +236 -0
  612. stateloom-0.1.0/tests/test_store/test_sqlite_store_hierarchy.py +170 -0
  613. stateloom-0.1.0/tests/test_store/test_user_store.py +190 -0
@@ -0,0 +1,92 @@
1
+ # StateLoom v0.2 Roadmap: Enterprise Scale & Distributed Governance
2
+
3
+ ## The Vision: "The Standard Library for Agent State"
4
+
5
+ While v0.1 focused on the **individual developer's productivity** (Replay, Local Dashboard, Cost Tracking), v0.2 transforms StateLoom into **enterprise-grade infrastructure**. The goal is to provide a unified governance and observability layer that works across distributed microservices, multi-cloud environments, and complex agent orchestration frameworks.
6
+
7
+ ---
8
+
9
+ ## Pillar 1: OpenTelemetry (OTel) & Distributed Tracing
10
+
11
+ StateLoom will adopt OpenTelemetry as its underlying observability standard. This allows it to "speak the same language" as the rest of the enterprise stack (Datadog, Honeycomb, New Relic).
12
+
13
+ ### 1.1 Trace Context Propagation
14
+ - **Session-to-Trace Mapping:** Automatically link an StateLoom `session_id` to an OTel `TraceID`.
15
+ - **Header Injection:** Automatically inject `x-stateloom-session-id` and `traceparent` headers into outbound `httpx` and `requests` calls.
16
+ - **Microservice Continuity:** If Service A starts a session and calls Service B (a researcher agent), Service B will automatically detect and resume the same StateLoom session from the OTel context.
17
+
18
+ ### 1.2 OTLP Exporter
19
+ - **Export to Any Backend:** Provide a native OTLP exporter to pipe StateLoom metrics (cost, PII detections, loop flags) into standard enterprise dashboards.
20
+ - **Custom Attributes:** Attach `stateloom.model`, `stateloom.cost`, and `stateloom.session_status` as attributes to every OTel span.
21
+
22
+ ### 1.3 Auto-Instrumentation
23
+ - **Web Framework Middleware:** Provide one-line `StateLoomMiddleware` for **FastAPI**, **Flask**, and **Django**.
24
+ - **Zero-Touch Sessions:** A new session is automatically created at the start of an HTTP request and closed when the response is sent.
25
+
26
+ ---
27
+
28
+ ## Pillar 2: Distributed State & Governance
29
+
30
+ Moving beyond single-process agents to horizontally scaled production environments.
31
+
32
+ ### 2.1 Pluggable State Backends
33
+ - **Redis & Postgres:** Support Redis (for high-speed budget locking) and Postgres (for long-term session storage) as alternatives to local SQLite.
34
+ - **Distributed Locking:** Implement distributed locks for **Budget Enforcement**. If five workers are executing steps for one session, they must all share a single atomic budget counter.
35
+
36
+ ### 2.2 Centralized Policy Management (The Control Plane)
37
+ - **Dynamic Policy Sync:** The SDK should be able to fetch `stateloom.yaml` from a remote URL at startup.
38
+ - **Policy Hot-Reload:** Update PII rules or budget limits across an entire fleet of agents in real-time without redeploying code.
39
+
40
+ ### 2.3 Advanced PII with Microsoft Presidio
41
+ - **Presidio Integration:** Formalize the `stateloom[presidio]` extra to use NLP-based PII detection (better than regex for addresses, names, and entities).
42
+ - **Custom Scrubbing:** Allow enterprises to define custom scrubbing logic for proprietary data types (e.g., internal part numbers).
43
+
44
+ ### 2.4 Zero-Trust Data Architecture (BYOD Audit Trails)
45
+ - **Data Routing:** StateLoom acts as a secure router. Metadata (cost, tokens, latency) is synced to the StateLoom Control Plane for analytics, but **raw payloads** (prompts/responses) are routed directly to the customer's own VPC storage (AWS S3, Azure Blob, GCS, or Snowflake).
46
+ - **End-to-End Encryption:** Payloads are encrypted at the SDK level using customer-managed keys (AWS KMS / Azure Key Vault) before being persisted.
47
+ - **Compliance-Grade Logging:** Generate immutable, cryptographically signed audit logs of every LLM interaction, stored entirely within the customer's security boundary.
48
+ - **Why it wins:** This architecture bypasses the most difficult stage of enterprise procurement—the Security Review—by ensuring StateLoom never has "custody" of sensitive customer data.
49
+
50
+ ---
51
+
52
+ ## Pillar 3: The "Developer Wedge" V2 (CLI & Replay)
53
+
54
+ Hardening the local-to-production debugging loop.
55
+
56
+ ### 3.1 Production Incident Triage (`stateloom pull`)
57
+ - **Remote Session Pull:** Fetch a failed production session from the control plane/database to a local machine.
58
+ - **Automatic Masking:** The control plane applies PII masking *before* the session is downloaded to a developer's machine to maintain GDPR/SOC2 compliance.
59
+
60
+ ### 3.2 Regression Testing (`stateloom test`)
61
+ - **Golden Run Pinning:** "Pin" a successful session as a "Golden Run."
62
+ - **CI/CD Integration:** A new `stateloom test` command that replays the Golden Runs against the current code. If the agent fails to reach the same conclusion or exceeds the "Golden Cost," the CI pipeline fails.
63
+
64
+ ### 3.3 Replay "Fuzzing"
65
+ - **Non-Deterministic Analysis:** Automatically run a replay 10 times with different temperatures to find "flaky" agent steps that lead to divergent outcomes.
66
+
67
+ ---
68
+
69
+ ## Pillar 4: AI Economics (Local Offloading)
70
+
71
+ Maximizing ROI through model cascading.
72
+
73
+ ### 4.1 Intelligent Auto-Router V2
74
+ - **Semantic Complexity Scoring:** Use a local embedding model to grade the "difficulty" of a prompt before routing.
75
+ - **Fallback Logic:** If a local model (Ollama) returns a low-confidence score, automatically re-route the request to GPT-4o and log the failure to improve the router's training data.
76
+
77
+ ### 4.2 Local Cache Proxy
78
+ - **Session-Independent Caching:** Allow exact-match caching across *different* sessions for identical requests (e.g., "What are our return policies?").
79
+
80
+ ---
81
+
82
+ ## Technical Milestones
83
+
84
+ 1. **v0.2.1 (The OTel Bridge):** Implement `ContextVar` synchronization with OTel and basic OTLP exporter.
85
+ 2. **v0.2.2 (The Scale Layer):** Implement Redis storage backend and distributed budget locking.
86
+ 3. **v0.2.3 (The Policy Plane):** Add remote config fetching and Presidio PII support.
87
+ 4. **v0.2.4 (The CLI Suite):** Finalize `stateloom pull` and `stateloom test` workflows.
88
+
89
+ ---
90
+
91
+ ## Success Metric for v0.2
92
+ "A developer can deploy a LangGraph agent to a Kubernetes cluster with 10 replicas, and StateLoom will correctly enforce a single $5 budget across the entire fleet while piping the results into the company's existing Datadog dashboard."
@@ -0,0 +1,39 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebSearch",
5
+ "Bash(python -m pytest:*)",
6
+ "WebFetch(domain:github.com)",
7
+ "WebFetch(domain:developers.openai.com)",
8
+ "Bash(curl:*)",
9
+ "Bash(tar:*)",
10
+ "Bash(python3:*)",
11
+ "Bash(ruff format:*)",
12
+ "Bash(ruff check:*)",
13
+ "Bash(python -m ruff check:*)",
14
+ "Bash(python -m ruff format:*)",
15
+ "Bash(ls:*)",
16
+ "Bash(find:*)",
17
+ "Bash(__NEW_LINE_f878715c604ee769__ echo \"\")",
18
+ "Bash(__NEW_LINE_155e46961a51060b__ echo \"\")",
19
+ "Bash(python:*)",
20
+ "Bash(xargs:*)",
21
+ "Bash(grep:*)",
22
+ "Bash(done)",
23
+ "Bash(__NEW_LINE_48e957917c204c8a__ echo \"=== CLI COMMAND NAME ===\")",
24
+ "Bash(__NEW_LINE_9f1f5c11b909831e__ echo \"\")",
25
+ "Bash(__NEW_LINE_2b0e96ce7f84692b__ echo \"\")",
26
+ "Bash(__NEW_LINE_94f4a257f596dc85__ echo \"\")",
27
+ "Bash(__NEW_LINE_973c1a54780550e2__ echo \"\")",
28
+ "Bash(echo:*)",
29
+ "Bash(__NEW_LINE_5749ae0392ae1f60__ echo \"\")",
30
+ "Bash(__NEW_LINE_9ed2b214ac25caa6__ echo \"\")",
31
+ "Bash(EOF)",
32
+ "Bash(bash /tmp/grep_queries.sh)",
33
+ "Bash(wc:*)",
34
+ "Bash(pytest:*)",
35
+ "WebFetch(domain:arxiv.org)",
36
+ "Bash(/tmp/shadow_code_summary.md:*)"
37
+ ]
38
+ }
39
+ }
@@ -0,0 +1,39 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: pip
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ day: monday
8
+ open-pull-requests-limit: 10
9
+ groups:
10
+ dev-deps:
11
+ patterns:
12
+ - "pytest*"
13
+ - "ruff"
14
+ - "mypy"
15
+ - "respx"
16
+ update-types:
17
+ - "minor"
18
+ - "patch"
19
+ core-deps:
20
+ patterns:
21
+ - "pydantic*"
22
+ - "fastapi"
23
+ - "uvicorn*"
24
+ - "httpx"
25
+ - "rich"
26
+ - "wrapt"
27
+ - "tiktoken"
28
+ - "websockets"
29
+ - "pyyaml"
30
+ - "click"
31
+ update-types:
32
+ - "patch"
33
+
34
+ - package-ecosystem: github-actions
35
+ directory: "/"
36
+ schedule:
37
+ interval: weekly
38
+ labels:
39
+ - ci
@@ -0,0 +1,211 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ concurrency:
11
+ group: ci-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ lint:
16
+ name: Lint
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Harden Runner
20
+ uses: step-security/harden-runner@v2
21
+ with:
22
+ egress-policy: audit
23
+
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.10"
29
+
30
+ - name: Install ruff
31
+ run: pip install ruff>=0.1
32
+
33
+ - name: Ruff check
34
+ run: ruff check src/ tests/
35
+
36
+ - name: Ruff format check
37
+ run: ruff format --check src/ tests/
38
+
39
+ typecheck:
40
+ name: Type Check
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - name: Harden Runner
44
+ uses: step-security/harden-runner@v2
45
+ with:
46
+ egress-policy: audit
47
+
48
+ - uses: actions/checkout@v4
49
+
50
+ - uses: actions/setup-python@v5
51
+ with:
52
+ python-version: "3.10"
53
+
54
+ - name: Install dependencies
55
+ run: pip install -e ".[dev,metrics,prompts,encryption,migrations]"
56
+
57
+ - name: mypy
58
+ run: mypy src/stateloom/
59
+
60
+ test:
61
+ name: Test (Python ${{ matrix.python-version }})
62
+ runs-on: ubuntu-latest
63
+ needs: lint
64
+ strategy:
65
+ fail-fast: false
66
+ matrix:
67
+ python-version: ["3.10", "3.13"]
68
+ steps:
69
+ - name: Harden Runner
70
+ uses: step-security/harden-runner@v2
71
+ with:
72
+ egress-policy: audit
73
+
74
+ - uses: actions/checkout@v4
75
+
76
+ - uses: actions/setup-python@v5
77
+ with:
78
+ python-version: ${{ matrix.python-version }}
79
+
80
+ - name: Install dependencies
81
+ run: pip install -e ".[dev,metrics,prompts,encryption,migrations]"
82
+
83
+ - name: Run tests
84
+ run: |
85
+ pytest tests/ \
86
+ --ignore=tests/test_production \
87
+ --ignore=tests/test_e2e \
88
+ --ignore=tests/test_store/test_postgres_store.py \
89
+ --ignore=tests/test_cache/test_redis_cache_store.py \
90
+ --ignore=tests/test_integration \
91
+ -v --tb=short \
92
+ --cov=stateloom --cov-report=xml --cov-report=term-missing --cov-fail-under=80
93
+
94
+ - name: Upload coverage
95
+ if: matrix.python-version == '3.13'
96
+ uses: actions/upload-artifact@v4
97
+ with:
98
+ name: coverage-report
99
+ path: coverage.xml
100
+
101
+ test-production:
102
+ name: Production Tests
103
+ runs-on: ubuntu-latest
104
+ needs: lint
105
+ steps:
106
+ - name: Harden Runner
107
+ uses: step-security/harden-runner@v2
108
+ with:
109
+ egress-policy: audit
110
+
111
+ - uses: actions/checkout@v4
112
+
113
+ - uses: actions/setup-python@v5
114
+ with:
115
+ python-version: "3.13"
116
+
117
+ - name: Install dependencies
118
+ run: pip install -e ".[dev,metrics,prompts,encryption,migrations]"
119
+
120
+ - name: Run production tests
121
+ run: |
122
+ pytest tests/test_production/ tests/test_e2e/ \
123
+ -v --tb=short \
124
+ --ignore-glob="**/test_postgres*" \
125
+ --ignore-glob="**/test_redis*" \
126
+ || true
127
+
128
+ test-integration:
129
+ name: Integration Tests
130
+ runs-on: ubuntu-latest
131
+ needs: lint
132
+ services:
133
+ postgres:
134
+ image: postgres:16
135
+ env:
136
+ POSTGRES_USER: stateloom_test
137
+ POSTGRES_PASSWORD: stateloom_test
138
+ POSTGRES_DB: stateloom_test
139
+ ports:
140
+ - 5432:5432
141
+ options: >-
142
+ --health-cmd="pg_isready -U stateloom_test"
143
+ --health-interval=10s
144
+ --health-timeout=5s
145
+ --health-retries=5
146
+ redis:
147
+ image: redis:7
148
+ ports:
149
+ - 6379:6379
150
+ options: >-
151
+ --health-cmd="redis-cli ping"
152
+ --health-interval=10s
153
+ --health-timeout=5s
154
+ --health-retries=5
155
+ env:
156
+ STATELOOM_TEST_POSTGRES_URL: postgresql://stateloom_test:stateloom_test@localhost:5432/stateloom_test
157
+ STATELOOM_TEST_REDIS_URL: redis://localhost:6379/0
158
+ steps:
159
+ - name: Harden Runner
160
+ uses: step-security/harden-runner@v2
161
+ with:
162
+ egress-policy: audit
163
+
164
+ - uses: actions/checkout@v4
165
+
166
+ - uses: actions/setup-python@v5
167
+ with:
168
+ python-version: "3.13"
169
+
170
+ - name: Install dependencies
171
+ run: pip install -e ".[dev,metrics,prompts,encryption,migrations,postgres,redis]"
172
+
173
+ - name: Run integration tests
174
+ run: |
175
+ pytest \
176
+ tests/test_store/test_postgres_store.py \
177
+ tests/test_cache/test_redis_cache_store.py \
178
+ -v --tb=short
179
+
180
+ build:
181
+ name: Build
182
+ runs-on: ubuntu-latest
183
+ needs: [test, typecheck]
184
+ steps:
185
+ - name: Harden Runner
186
+ uses: step-security/harden-runner@v2
187
+ with:
188
+ egress-policy: audit
189
+
190
+ - uses: actions/checkout@v4
191
+
192
+ - uses: actions/setup-python@v5
193
+ with:
194
+ python-version: "3.13"
195
+
196
+ - name: Install build tools
197
+ run: pip install build
198
+
199
+ - name: Build package
200
+ run: python -m build
201
+
202
+ - name: Verify wheel installs
203
+ run: |
204
+ pip install dist/*.whl
205
+ python -c "import stateloom; print(stateloom.__version__)"
206
+
207
+ - name: Upload build artifacts
208
+ uses: actions/upload-artifact@v4
209
+ with:
210
+ name: dist
211
+ path: dist/
@@ -0,0 +1,34 @@
1
+ name: Dependabot Auto-Merge
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ permissions:
7
+ contents: write
8
+ pull-requests: write
9
+
10
+ jobs:
11
+ auto-merge:
12
+ name: Auto-Merge Dependabot PRs
13
+ runs-on: ubuntu-latest
14
+ if: github.actor == 'dependabot[bot]'
15
+ steps:
16
+ - name: Fetch Dependabot metadata
17
+ id: metadata
18
+ uses: dependabot/fetch-metadata@v2
19
+ with:
20
+ github-token: ${{ secrets.GITHUB_TOKEN }}
21
+
22
+ - name: Auto-approve patch and minor updates
23
+ if: steps.metadata.outputs.update-type != 'version-update:semver-major'
24
+ run: gh pr review --approve "$PR_URL"
25
+ env:
26
+ PR_URL: ${{ github.event.pull_request.html_url }}
27
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28
+
29
+ - name: Auto-merge patch and minor updates
30
+ if: steps.metadata.outputs.update-type != 'version-update:semver-major'
31
+ run: gh pr merge --auto --squash "$PR_URL"
32
+ env:
33
+ PR_URL: ${{ github.event.pull_request.html_url }}
34
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,18 @@
1
+ name: Dependency Review
2
+ on: [pull_request]
3
+
4
+ permissions:
5
+ contents: read
6
+
7
+ jobs:
8
+ dependency-review:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout
12
+ uses: actions/checkout@v4
13
+
14
+ - name: Dependency Review
15
+ uses: actions/dependency-review-action@v4
16
+ with:
17
+ fail-on-severity: moderate
18
+ comment-summary-in-pr: always
@@ -0,0 +1,71 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: write
10
+ id-token: write
11
+
12
+ jobs:
13
+ build:
14
+ name: Build
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.13"
22
+
23
+ - name: Install build tools
24
+ run: pip install build
25
+
26
+ - name: Build package
27
+ run: python -m build
28
+
29
+ - name: Upload build artifacts
30
+ uses: actions/upload-artifact@v4
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+
35
+ publish:
36
+ name: Publish to PyPI
37
+ runs-on: ubuntu-latest
38
+ needs: build
39
+ environment: pypi
40
+ permissions:
41
+ id-token: write
42
+ steps:
43
+ - name: Download build artifacts
44
+ uses: actions/download-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+
49
+ - name: Publish to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
51
+
52
+ github-release:
53
+ name: GitHub Release
54
+ runs-on: ubuntu-latest
55
+ needs: build
56
+ permissions:
57
+ contents: write
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+
61
+ - name: Download build artifacts
62
+ uses: actions/download-artifact@v4
63
+ with:
64
+ name: dist
65
+ path: dist/
66
+
67
+ - name: Create GitHub Release
68
+ uses: softprops/action-gh-release@v2
69
+ with:
70
+ generate_release_notes: true
71
+ files: dist/*
@@ -0,0 +1,42 @@
1
+ name: OpenSSF Scorecard
2
+ on:
3
+ branch_protection_rule:
4
+ schedule:
5
+ - cron: "20 7 * * 2"
6
+ push:
7
+ branches: ["main"]
8
+
9
+ permissions: read-all
10
+
11
+ jobs:
12
+ analysis:
13
+ name: Scorecard analysis
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ security-events: write
17
+ id-token: write
18
+
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v4
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - name: Run analysis
26
+ uses: ossf/scorecard-action@v2.4.0
27
+ with:
28
+ results_file: results.sarif
29
+ results_format: sarif
30
+ publish_results: true
31
+
32
+ - name: Upload artifact
33
+ uses: actions/upload-artifact@v4
34
+ with:
35
+ name: SARIF file
36
+ path: results.sarif
37
+ retention-days: 5
38
+
39
+ - name: Upload to code-scanning
40
+ uses: github/codeql-action/upload-sarif@v3
41
+ with:
42
+ sarif_file: results.sarif
@@ -0,0 +1,87 @@
1
+ name: Security
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ schedule:
9
+ - cron: "0 6 * * 1" # Monday 6am UTC
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ bandit:
14
+ name: Bandit SAST
15
+ runs-on: ubuntu-latest
16
+ continue-on-error: true
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.13"
23
+
24
+ - name: Install bandit
25
+ run: pip install bandit[toml]
26
+
27
+ - name: Run bandit
28
+ run: bandit -c pyproject.toml -r src/ -f json -o bandit-report.json || true
29
+
30
+ - name: Upload bandit report
31
+ uses: actions/upload-artifact@v4
32
+ with:
33
+ name: bandit-report
34
+ path: bandit-report.json
35
+
36
+ pip-audit:
37
+ name: Dependency Audit
38
+ runs-on: ubuntu-latest
39
+ continue-on-error: true
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - uses: actions/setup-python@v5
44
+ with:
45
+ python-version: "3.13"
46
+
47
+ - name: Install dependencies
48
+ run: pip install -e ".[dev]" pip-audit
49
+
50
+ - name: Run pip-audit
51
+ run: pip-audit --desc --format json --output pip-audit-report.json || true
52
+
53
+ - name: Upload pip-audit report
54
+ uses: actions/upload-artifact@v4
55
+ with:
56
+ name: pip-audit-report
57
+ path: pip-audit-report.json
58
+
59
+ codeql:
60
+ name: CodeQL
61
+ runs-on: ubuntu-latest
62
+ permissions:
63
+ security-events: write
64
+ steps:
65
+ - uses: actions/checkout@v4
66
+
67
+ - name: Initialize CodeQL
68
+ uses: github/codeql-action/init@v3
69
+ with:
70
+ languages: python
71
+
72
+ - name: Perform CodeQL analysis
73
+ uses: github/codeql-action/analyze@v3
74
+
75
+ secrets-scan:
76
+ name: Secrets Scan
77
+ runs-on: ubuntu-latest
78
+ continue-on-error: true
79
+ steps:
80
+ - uses: actions/checkout@v4
81
+ with:
82
+ fetch-depth: 0
83
+
84
+ - name: TruffleHog scan
85
+ uses: trufflesecurity/trufflehog@main
86
+ with:
87
+ extra_args: --only-verified
@@ -0,0 +1,46 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+
7
+ # Distribution / packaging
8
+ dist/
9
+ build/
10
+ *.egg-info/
11
+ *.egg
12
+
13
+ # Virtual environments
14
+ .venv/
15
+ venv/
16
+ env/
17
+
18
+ # Testing
19
+ .pytest_cache/
20
+ .coverage
21
+ coverage.xml
22
+ htmlcov/
23
+
24
+ # Type checking / linting
25
+ .mypy_cache/
26
+ .ruff_cache/
27
+
28
+ # IDE
29
+ .vscode/
30
+ .idea/
31
+ *.swp
32
+ *.swo
33
+ *~
34
+
35
+ # Environment
36
+ .env
37
+ .env.*
38
+
39
+ # Database
40
+ *.db
41
+ *.db-wal
42
+ *.db-shm
43
+
44
+ # OS
45
+ .DS_Store
46
+ Thumbs.db