sanka-cli 0.2.9__tar.gz → 0.2.10__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 (201) hide show
  1. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/PKG-INFO +1 -1
  2. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/pyproject.toml +1 -1
  3. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/discovery.py +113 -2
  4. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/model.py +55 -1
  5. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/store.py +46 -11
  6. sanka_cli-0.2.10/src/sanka/runtime/flow/extension.py +263 -0
  7. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/__init__.py +1 -1
  8. sanka_cli-0.2.10/src/sanka_extensions/flow/__init__.py +101 -0
  9. sanka_cli-0.2.10/src/sanka_extensions/flow/_wire.py +134 -0
  10. sanka_cli-0.2.10/src/sanka_extensions/flow/blueprint.py +483 -0
  11. sanka_cli-0.2.10/src/sanka_extensions/flow/graph.py +474 -0
  12. sanka_cli-0.2.10/src/sanka_extensions/flow/identity.py +177 -0
  13. sanka_cli-0.2.10/src/sanka_extensions/flow/protocol.py +524 -0
  14. sanka_cli-0.2.10/src/sanka_extensions/flow/scenario.py +169 -0
  15. sanka_cli-0.2.10/src/sanka_extensions/flow/source.py +188 -0
  16. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/conftest.py +4 -0
  17. sanka_cli-0.2.10/tests/fixtures/flow/synthetic_sales_created_estimate_blueprint.json +306 -0
  18. sanka_cli-0.2.10/tests/fixtures/flow/synthetic_sales_quote_blueprint.json +325 -0
  19. sanka_cli-0.2.10/tests/flow_wheel_acceptance.py +135 -0
  20. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_cli.py +1 -1
  21. sanka_cli-0.2.10/tests/test_flow_extension.py +275 -0
  22. sanka_cli-0.2.10/tests/test_flow_extension_wheel_acceptance.py +65 -0
  23. sanka_cli-0.2.10/tests/test_flow_sdk_codec.py +112 -0
  24. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_mcp_retirement.py +1 -1
  25. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_sanka_facade.py +1 -1
  26. sanka_cli-0.2.9/src/sanka_extensions/flow/__init__.py +0 -18
  27. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/.gitignore +0 -0
  28. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/LICENSES/AGPL-3.0-only.txt +0 -0
  29. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/LICENSES/Apache-2.0.txt +0 -0
  30. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/NOTICE +0 -0
  31. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/README.md +0 -0
  32. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/__init__.py +0 -0
  33. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/_client.py +0 -0
  34. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/cli/__init__.py +0 -0
  35. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/cli/_compact.py +0 -0
  36. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/cli/_output.py +0 -0
  37. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/cli/_research.py +0 -0
  38. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/cli/py.typed +0 -0
  39. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/connector/__init__.py +0 -0
  40. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/connector/py.typed +0 -0
  41. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/__about__.py +0 -0
  42. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/__init__.py +0 -0
  43. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/concurrency.py +0 -0
  44. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/connector_client.py +0 -0
  45. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/connector_host.py +0 -0
  46. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/engine.py +0 -0
  47. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/__init__.py +0 -0
  48. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/continuous.py +0 -0
  49. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/errors.py +0 -0
  50. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/local.py +0 -0
  51. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/model.py +0 -0
  52. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/report_codec.py +0 -0
  53. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/routes.py +0 -0
  54. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/scope.py +0 -0
  55. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/state.py +0 -0
  56. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/execution/validate.py +0 -0
  57. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/__init__.py +0 -0
  58. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/artifacts.py +0 -0
  59. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/code_lifecycle.py +0 -0
  60. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/code_repair.py +0 -0
  61. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/lifecycle.py +0 -0
  62. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/runner.py +0 -0
  63. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/extensions/stage.py +0 -0
  64. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/__init__.py +0 -0
  65. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/host.py +0 -0
  66. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/lifecycle.py +0 -0
  67. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/merge.py +0 -0
  68. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/model.py +0 -0
  69. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/planner.py +0 -0
  70. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/sqlite.py +0 -0
  71. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/state.py +0 -0
  72. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/flow/verification.py +0 -0
  73. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/hashing.py +0 -0
  74. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/__init__.py +0 -0
  75. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/errors.py +0 -0
  76. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/mapping_candidates.py +0 -0
  77. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/model.py +0 -0
  78. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/owner_mapping.py +0 -0
  79. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/pending_relationships.py +0 -0
  80. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/mapping/record_mapping.py +0 -0
  81. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/planner.py +0 -0
  82. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/private_sqlite.py +0 -0
  83. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/py.typed +0 -0
  84. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/registry.py +0 -0
  85. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/safe_local_io.py +0 -0
  86. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/spec.py +0 -0
  87. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka/runtime/state.py +0 -0
  88. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/__main__.py +0 -0
  89. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/bundle.py +0 -0
  90. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/certificates.py +0 -0
  91. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/client.py +0 -0
  92. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/__init__.py +0 -0
  93. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/ai.py +0 -0
  94. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/auth.py +0 -0
  95. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/cloud.py +0 -0
  96. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/cloud_fleet.py +0 -0
  97. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/cloud_migrate.py +0 -0
  98. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/code.py +0 -0
  99. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/functions.py +0 -0
  100. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/migrate.py +0 -0
  101. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/profiles.py +0 -0
  102. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/resources.py +0 -0
  103. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/skill.py +0 -0
  104. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/commands/workflows.py +0 -0
  105. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/config.py +0 -0
  106. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/main.py +0 -0
  107. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/output.py +0 -0
  108. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/runtime.py +0 -0
  109. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/skills/sanka-cli/SKILL.md +0 -0
  110. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_cli/state.py +0 -0
  111. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/__about__.py +0 -0
  112. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/__init__.py +0 -0
  113. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/credentials.py +0 -0
  114. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/errors.py +0 -0
  115. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/protocols.py +0 -0
  116. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/provisioning.py +0 -0
  117. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/py.typed +0 -0
  118. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/records.py +0 -0
  119. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/registration.py +0 -0
  120. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_connector/schema.py +0 -0
  121. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extension_sdk/__init__.py +0 -0
  122. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extension_sdk/contract.py +0 -0
  123. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extension_sdk/py.typed +0 -0
  124. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/__init__.py +0 -0
  125. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/code/__init__.py +0 -0
  126. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/code/contract.py +0 -0
  127. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/__about__.py +0 -0
  128. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/__init__.py +0 -0
  129. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/credentials.py +0 -0
  130. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/errors.py +0 -0
  131. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/protocols.py +0 -0
  132. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/provisioning.py +0 -0
  133. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/py.typed +0 -0
  134. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/records.py +0 -0
  135. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/registration.py +0 -0
  136. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/data/schema.py +0 -0
  137. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/flow/definition.py +0 -0
  138. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/py.typed +0 -0
  139. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/__about__.py +0 -0
  140. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/__init__.py +0 -0
  141. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/credentials.py +0 -0
  142. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/errors.py +0 -0
  143. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/protocols.py +0 -0
  144. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/provisioning.py +0 -0
  145. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/py.typed +0 -0
  146. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/records.py +0 -0
  147. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/registration.py +0 -0
  148. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/src/sanka_extensions/systems/schema.py +0 -0
  149. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/api/__init__.py +0 -0
  150. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/api/serializers.py +0 -0
  151. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/api/views.py +0 -0
  152. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/config/__init__.py +0 -0
  153. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/config/settings.py +0 -0
  154. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/config/urls.py +0 -0
  155. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_drf_project/manage.py +0 -0
  156. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_marketplace/drf-to-fastapi.json +0 -0
  157. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/fixtures/extension_marketplace/marketplace.json +0 -0
  158. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_cli_developer_experience.py +0 -0
  159. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_code_bundle.py +0 -0
  160. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_code_commands.py +0 -0
  161. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_code_lifecycle.py +0 -0
  162. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_code_repair.py +0 -0
  163. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_concurrency.py +0 -0
  164. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_connector_client.py +0 -0
  165. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_connector_host.py +0 -0
  166. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_credential_provider.py +0 -0
  167. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_engine_e2e.py +0 -0
  168. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_engine_execution_adoption.py +0 -0
  169. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_engine_pg_to_clickhouse_e2e.py +0 -0
  170. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_engine_postgres_e2e.py +0 -0
  171. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_continuous.py +0 -0
  172. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_exact_scope.py +0 -0
  173. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_local_store.py +0 -0
  174. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_report_codec.py +0 -0
  175. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_routes.py +0 -0
  176. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_scope.py +0 -0
  177. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_seam.py +0 -0
  178. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_execution_validate.py +0 -0
  179. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_discovery.py +0 -0
  180. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_lifecycle.py +0 -0
  181. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_runner.py +0 -0
  182. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_stage.py +0 -0
  183. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_store.py +0 -0
  184. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_extension_wheel_acceptance.py +0 -0
  185. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_flow_lifecycle.py +0 -0
  186. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_flow_merge.py +0 -0
  187. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_flow_planner.py +0 -0
  188. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_flow_sqlite.py +0 -0
  189. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_flow_verification.py +0 -0
  190. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_hashing.py +0 -0
  191. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_hosted_cli.py +0 -0
  192. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_mapping_candidates.py +0 -0
  193. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_mapping_owner_mapping.py +0 -0
  194. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_mapping_pending_relationships.py +0 -0
  195. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_mapping_record_mapping.py +0 -0
  196. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_planner.py +0 -0
  197. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_registry.py +0 -0
  198. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_safe_local_io.py +0 -0
  199. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_skill_commands.py +0 -0
  200. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_spec.py +0 -0
  201. {sanka_cli-0.2.9 → sanka_cli-0.2.10}/tests/test_state_store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sanka-cli
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: Sanka command-line interface and migration runtime
5
5
  Project-URL: Repository, https://github.com/sankaHQ/sanka
6
6
  Project-URL: Issues, https://github.com/sankaHQ/sanka/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sanka-cli"
3
- version = "0.2.9"
3
+ version = "0.2.10"
4
4
  description = "Sanka command-line interface and migration runtime"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -20,6 +20,10 @@ from sanka.runtime.extensions.model import (
20
20
  EndpointSupport,
21
21
  ExtensionError,
22
22
  Fingerprint,
23
+ FlowCapability,
24
+ FlowReferenceRole,
25
+ FlowTemplateIdentity,
26
+ FlowValueRole,
23
27
  Manifest,
24
28
  MatchedEvidence,
25
29
  Matcher,
@@ -425,6 +429,100 @@ def _load_json(path: Path, code: str, *, data: bytes | None = None) -> dict[str,
425
429
  return payload
426
430
 
427
431
 
432
+ def _flow_capabilities(value: Any, code: str, path: Path) -> tuple[FlowCapability, ...]:
433
+ """Validate static Flow declarations without importing an extension SDK or provider."""
434
+ logical_id = re.compile(r"[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}")
435
+
436
+ def identifier(item: Any) -> bool:
437
+ return isinstance(item, str) and logical_id.fullmatch(item) is not None
438
+
439
+ if not isinstance(value, list) or not value:
440
+ _invalid(code, path, "Flow capabilities must be a nonempty array")
441
+ capabilities: list[FlowCapability] = []
442
+ for raw in value:
443
+ item = _object(
444
+ raw,
445
+ {"type", "references", "values", "template", "output_schema"},
446
+ code,
447
+ path,
448
+ "capability",
449
+ )
450
+ flow_type = item["type"]
451
+ if (
452
+ not isinstance(flow_type, str)
453
+ or len(flow_type) > 127
454
+ or re.fullmatch(
455
+ r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:/[a-z][a-z0-9]*(?:-[a-z0-9]+)*)?", flow_type
456
+ )
457
+ is None
458
+ or item["output_schema"] not in ("sanka-flow-blueprint/v1", "sanka-flow-blueprint/v2")
459
+ or not isinstance(item["references"], list)
460
+ or not isinstance(item["values"], list)
461
+ ):
462
+ _invalid(code, path, "Flow capability type, output schema or inputs are invalid")
463
+ template = _object(item["template"], {"id", "revision", "digest"}, code, path, "template")
464
+ if (
465
+ template["id"] != flow_type
466
+ or not isinstance(template["revision"], str)
467
+ or not template["revision"].strip()
468
+ or template["revision"] != template["revision"].strip()
469
+ or len(template["revision"]) > 1024
470
+ or not isinstance(template["digest"], str)
471
+ or re.fullmatch(r"sha256:[0-9a-f]{64}", template["digest"]) is None
472
+ ):
473
+ _invalid(code, path, "Flow capability requires an exact template artifact identity")
474
+ references: list[FlowReferenceRole] = []
475
+ for raw_role in item["references"]:
476
+ role = _object(
477
+ raw_role,
478
+ {"id", "kind", "parent_id", "related_object_id"},
479
+ code,
480
+ path,
481
+ "reference role",
482
+ )
483
+ kind, parent, related = role["kind"], role["parent_id"], role["related_object_id"]
484
+ if (
485
+ not identifier(role["id"])
486
+ or kind not in ("object", "property", "relationship", "record")
487
+ or (kind == "object" and (parent is not None or related is not None))
488
+ or (kind != "object" and not identifier(parent))
489
+ or (kind == "relationship" and not identifier(related))
490
+ or (kind != "relationship" and related is not None)
491
+ ):
492
+ _invalid(code, path, "Flow reference role is invalid")
493
+ references.append(FlowReferenceRole(**role))
494
+ index = {reference.id: reference for reference in references}
495
+ if len(index) != len(references):
496
+ _invalid(code, path, "Flow reference roles must be unique")
497
+ for reference in references:
498
+ for parent in (reference.parent_id, reference.related_object_id):
499
+ if parent is not None and (parent not in index or index[parent].kind != "object"):
500
+ _invalid(code, path, "Flow reference role must name a declared object parent")
501
+ values: list[FlowValueRole] = []
502
+ for raw_role in item["values"]:
503
+ role = _object(raw_role, {"id", "types"}, code, path, "value role")
504
+ types = _string_list(role["types"], code=code, path=path, label="Flow scalar types")
505
+ if not identifier(role["id"]) or not set(types).issubset(
506
+ {"string", "number", "boolean", "null"}
507
+ ):
508
+ _invalid(code, path, "Flow value role is invalid")
509
+ values.append(FlowValueRole(role["id"], tuple(sorted(types))))
510
+ if len({role.id for role in values}) != len(values):
511
+ _invalid(code, path, "Flow value roles must be unique")
512
+ capabilities.append(
513
+ FlowCapability(
514
+ flow_type,
515
+ tuple(sorted(references, key=lambda role: role.id)),
516
+ tuple(sorted(values, key=lambda role: role.id)),
517
+ FlowTemplateIdentity(**template),
518
+ item["output_schema"],
519
+ )
520
+ )
521
+ if len({capability.type for capability in capabilities}) != len(capabilities):
522
+ _invalid(code, path, "Flow capability types must be unique")
523
+ return tuple(sorted(capabilities, key=lambda capability: capability.type))
524
+
525
+
428
526
  def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -> Manifest:
429
527
  code = "SANKA_EXTENSION_MANIFEST_INVALID"
430
528
  raw = _load_json(path, code, data=data)
@@ -445,6 +543,8 @@ def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -
445
543
  keys = common | {"commands", "match", "targets"}
446
544
  elif kind == "connector":
447
545
  keys = common | {"providers"}
546
+ elif kind == "flow":
547
+ keys = common | {"commands", "capabilities"}
448
548
  else:
449
549
  _invalid(code, path, "manifest kind is unsupported")
450
550
  payload = _object(
@@ -459,11 +559,15 @@ def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -
459
559
  version = payload["version"]
460
560
  if not isinstance(version, str) or VERSION.fullmatch(version) is None:
461
561
  _invalid(code, path, "extension version must be exact")
462
- protocol = "sanka-extension/v1" if kind == "migration" else "sanka-connector/v1"
562
+ protocol = {
563
+ "migration": "sanka-extension/v1",
564
+ "connector": "sanka-connector/v1",
565
+ "flow": "sanka-flow-extension/v1",
566
+ }[kind]
463
567
  if payload["protocol_version"] != protocol:
464
568
  _invalid(code, path, "manifest kind and protocol version differ")
465
569
 
466
- distribution_key = "executable" if kind == "migration" else "entry_point"
570
+ distribution_key = "entry_point" if kind == "connector" else "executable"
467
571
  distribution = _object(
468
572
  payload["distribution"],
469
573
  {distribution_key, "name", "version"},
@@ -485,6 +589,7 @@ def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -
485
589
  match_all: tuple[Matcher, ...] = ()
486
590
  match_any: tuple[Matcher, ...] = ()
487
591
  providers: tuple[EndpointSupport, ...] = ()
592
+ capabilities: tuple[FlowCapability, ...] = ()
488
593
  if kind == "migration":
489
594
  commands = _string_list(payload["commands"], code=code, path=path, label="commands")
490
595
  if not set(commands).issubset(LIFECYCLE_COMMANDS):
@@ -503,6 +608,11 @@ def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -
503
608
  _invalid(code, path, "manifest must declare at least one matcher")
504
609
  if len(set(match_all)) != len(match_all) or len(set(match_any)) != len(match_any):
505
610
  _invalid(code, path, "manifest matchers must be unique")
611
+ elif kind == "flow":
612
+ if payload["commands"] != ["blueprint"]:
613
+ _invalid(code, path, "Flow extensions expose only the blueprint command")
614
+ commands = ("blueprint",)
615
+ capabilities = _flow_capabilities(payload["capabilities"], code, path)
506
616
  else:
507
617
  raw_providers = payload["providers"]
508
618
  if not isinstance(raw_providers, list) or not raw_providers:
@@ -589,6 +699,7 @@ def _load_manifest(path: Path, marketplace: str, *, data: bytes | None = None) -
589
699
  runtime_sanka_cli=runtime_specifier,
590
700
  wheels=tuple(sorted(wheels, key=lambda item: item.name)),
591
701
  digest=content_hash(payload),
702
+ capabilities=capabilities,
592
703
  )
593
704
 
594
705
 
@@ -50,6 +50,59 @@ class EndpointSupport:
50
50
  roles: tuple[Literal["source", "destination"], ...]
51
51
 
52
52
 
53
+ @dataclass(frozen=True)
54
+ class FlowReferenceRole:
55
+ id: str
56
+ kind: str
57
+ parent_id: str | None
58
+ related_object_id: str | None
59
+
60
+ def to_dict(self) -> dict[str, Any]:
61
+ return {
62
+ "id": self.id,
63
+ "kind": self.kind,
64
+ "parent_id": self.parent_id,
65
+ "related_object_id": self.related_object_id,
66
+ }
67
+
68
+
69
+ @dataclass(frozen=True)
70
+ class FlowValueRole:
71
+ id: str
72
+ types: tuple[str, ...]
73
+
74
+ def to_dict(self) -> dict[str, Any]:
75
+ return {"id": self.id, "types": list(self.types)}
76
+
77
+
78
+ @dataclass(frozen=True)
79
+ class FlowTemplateIdentity:
80
+ id: str
81
+ revision: str
82
+ digest: str
83
+
84
+ def to_dict(self) -> dict[str, str]:
85
+ return {"id": self.id, "revision": self.revision, "digest": self.digest}
86
+
87
+
88
+ @dataclass(frozen=True)
89
+ class FlowCapability:
90
+ type: str
91
+ references: tuple[FlowReferenceRole, ...]
92
+ values: tuple[FlowValueRole, ...]
93
+ template: FlowTemplateIdentity
94
+ output_schema: str
95
+
96
+ def to_dict(self) -> dict[str, Any]:
97
+ return {
98
+ "type": self.type,
99
+ "references": [item.to_dict() for item in self.references],
100
+ "values": [item.to_dict() for item in self.values],
101
+ "template": self.template.to_dict(),
102
+ "output_schema": self.output_schema,
103
+ }
104
+
105
+
53
106
  @dataclass(frozen=True)
54
107
  class Fingerprint:
55
108
  languages: tuple[str, ...]
@@ -64,7 +117,7 @@ class Manifest:
64
117
  id: str
65
118
  version: str
66
119
  marketplace: str
67
- kind: Literal["migration", "connector"]
120
+ kind: Literal["migration", "connector", "flow"]
68
121
  protocol_version: str
69
122
  distribution: str
70
123
  distribution_version: str
@@ -78,6 +131,7 @@ class Manifest:
78
131
  runtime_sanka_cli: str
79
132
  wheels: tuple[Wheel, ...]
80
133
  digest: str
134
+ capabilities: tuple[FlowCapability, ...] = ()
81
135
 
82
136
 
83
137
  @dataclass(frozen=True)
@@ -46,6 +46,7 @@ from sanka.runtime.extensions.model import (
46
46
  EndpointSupport,
47
47
  ExtensionError,
48
48
  Fingerprint,
49
+ FlowCapability,
49
50
  Manifest,
50
51
  Recommendation,
51
52
  Wheel,
@@ -56,9 +57,9 @@ from sanka_extensions.data import ENTRY_POINT_GROUP, ExtensionRegistration
56
57
 
57
58
  OFFICIAL_IDENTITY = "github.com/sankaHQ/extensions"
58
59
  OFFICIAL_SOURCE = "https://github.com/sankaHQ/extensions.git"
59
- # Published extensions-v0.1.0a18. Advance only after verifying its release wheels.
60
+ # Published extensions-v0.1.0a20. Advance only after verifying its release wheels.
60
61
  # The development catalog can refer to artifacts that have not been published yet.
61
- OFFICIAL_REVISION = "1a8c9450243b1cc25096396244dac5ed3cf7abfd"
62
+ OFFICIAL_REVISION = "b52bf22f60b2a3704bf0414d609c3e3f767bcd41"
62
63
  DEFAULT_EXTENSION_ID = "sanka/drf-to-fastapi"
63
64
  MAX_WHEEL_BYTES = 128 * 1024 * 1024
64
65
  MAX_WHEEL_UNCOMPRESSED_BYTES = 512 * 1024 * 1024
@@ -374,9 +375,10 @@ class ExtensionRecord:
374
375
  targets: tuple[str, ...]
375
376
  status: tuple[str, ...]
376
377
  wheels: tuple[Wheel, ...]
378
+ capabilities: tuple[FlowCapability, ...] = ()
377
379
 
378
380
  def to_dict(self) -> dict[str, Any]:
379
- return {
381
+ payload = {
380
382
  **asdict(self),
381
383
  "providers": [
382
384
  asdict(provider) | {"roles": list(provider.roles)} for provider in self.providers
@@ -385,6 +387,12 @@ class ExtensionRecord:
385
387
  "status": list(self.status),
386
388
  "wheels": [asdict(wheel) for wheel in self.wheels],
387
389
  }
390
+ # Keep published Data/Code listing keys unchanged.
391
+ if self.kind == "flow":
392
+ payload["capabilities"] = [item.to_dict() for item in self.capabilities]
393
+ else:
394
+ payload.pop("capabilities")
395
+ return payload
388
396
 
389
397
 
390
398
  @dataclass(frozen=True)
@@ -947,10 +955,10 @@ class ExtensionStore:
947
955
  @contextmanager
948
956
  def execution_lease(self, entry: LockEntry) -> Iterator[int]:
949
957
  """Bind the verified console script inode until its subprocess completes."""
950
- if entry.kind != "migration" or entry.executable is None:
958
+ if entry.kind not in {"migration", "flow"} or entry.executable is None:
951
959
  _error(
952
960
  "SANKA_EXTENSION_PROTOCOL",
953
- "Only migration extensions expose lifecycle executables",
961
+ "Only Code and Flow extensions expose protocol executables",
954
962
  extension_id=entry.id,
955
963
  )
956
964
  if self.resolve_locked(entry.id) != entry:
@@ -1883,7 +1891,8 @@ class ExtensionStore:
1883
1891
  )
1884
1892
  or not isinstance(value["commands"], list)
1885
1893
  or any(
1886
- not isinstance(command, str) or command not in LIFECYCLE_COMMANDS
1894
+ not isinstance(command, str)
1895
+ or command not in LIFECYCLE_COMMANDS | {"blueprint"}
1887
1896
  for command in value["commands"]
1888
1897
  )
1889
1898
  or len(value["commands"]) != len(set(value["commands"]))
@@ -1930,7 +1939,7 @@ class ExtensionStore:
1930
1939
  re.fullmatch(r"[0-9a-f]{40}(?:[0-9a-f]{24})?", entry.snapshot_digest)
1931
1940
  or re.fullmatch(r"sha256:[0-9a-f]{64}", entry.snapshot_digest)
1932
1941
  )
1933
- or entry.kind not in {"migration", "connector"}
1942
+ or entry.kind not in {"migration", "connector", "flow"}
1934
1943
  or (
1935
1944
  entry.kind == "migration"
1936
1945
  and (
@@ -1941,6 +1950,19 @@ class ExtensionStore:
1941
1950
  or entry.entry_point is not None
1942
1951
  or entry.providers
1943
1952
  or not entry.commands
1953
+ or not set(entry.commands).issubset(LIFECYCLE_COMMANDS)
1954
+ )
1955
+ )
1956
+ or (
1957
+ entry.kind == "flow"
1958
+ and (
1959
+ entry.protocol_version != "sanka-flow-extension/v1"
1960
+ or not isinstance(entry.executable, str)
1961
+ or not entry.executable
1962
+ or "/" in entry.executable
1963
+ or entry.entry_point is not None
1964
+ or entry.providers
1965
+ or entry.commands != ("blueprint",)
1944
1966
  )
1945
1967
  )
1946
1968
  or (
@@ -2048,6 +2070,7 @@ class ExtensionStore:
2048
2070
  targets=manifest.targets,
2049
2071
  status=tuple(item for item in STATUS_ORDER if item in statuses),
2050
2072
  wheels=manifest.wheels,
2073
+ capabilities=manifest.capabilities,
2051
2074
  )
2052
2075
  )
2053
2076
  return tuple(sorted(records, key=lambda item: (item.id, item.version, item.marketplace)))
@@ -2496,7 +2519,7 @@ class ExtensionStore:
2496
2519
  assert identity_name is not None
2497
2520
  try:
2498
2521
  parser.read_string(entry_points)
2499
- if manifest.kind == "migration":
2522
+ if manifest.kind in {"migration", "flow"}:
2500
2523
  assert manifest.executable is not None
2501
2524
  target = parser["console_scripts"][manifest.executable]
2502
2525
  else:
@@ -3105,7 +3128,7 @@ class ExtensionStore:
3105
3128
  (path, wheel.sha256) for path, wheel in zip(cached, selected_wheels, strict=True)
3106
3129
  )
3107
3130
  self._wheel_import_records(verified_wheels)
3108
- if manifest.kind == "migration":
3131
+ if manifest.kind in {"migration", "flow"}:
3109
3132
  assert manifest.executable is not None
3110
3133
  self._wheel_entry_point(verified_wheels, manifest.executable)
3111
3134
  else:
@@ -3125,7 +3148,7 @@ class ExtensionStore:
3125
3148
  None,
3126
3149
  )
3127
3150
  expected_digest = prior.get("environment_digest") if isinstance(prior, dict) else None
3128
- if manifest.kind == "migration":
3151
+ if manifest.kind in {"migration", "flow"}:
3129
3152
  environment = self._materialize_environment(
3130
3153
  artifact_digest,
3131
3154
  manifest.executable,
@@ -3326,6 +3349,18 @@ class ExtensionStore:
3326
3349
  )
3327
3350
  return manifest
3328
3351
 
3352
+ @_store_operation
3353
+ def flow_manifest(self, extension_id: str) -> tuple[LockEntry, Manifest]:
3354
+ """Resolve an explicitly selected Flow installation and its verified capabilities."""
3355
+ entry = self.resolve_locked(extension_id)
3356
+ if entry.kind != "flow":
3357
+ _error(
3358
+ "SANKA_FLOW_EXTENSION_REQUIRED",
3359
+ "Selected extension does not declare Flow generation",
3360
+ extension_id=extension_id,
3361
+ )
3362
+ return entry, self._manifest_for_lock(entry)
3363
+
3329
3364
  @staticmethod
3330
3365
  def _manifest_artifact_digest(manifest: Manifest) -> str:
3331
3366
  return content_hash(
@@ -3428,7 +3463,7 @@ class ExtensionStore:
3428
3463
  must_exist=True,
3429
3464
  expected=expected_root,
3430
3465
  )
3431
- if manifest.kind == "migration":
3466
+ if manifest.kind in {"migration", "flow"}:
3432
3467
  assert manifest.executable is not None
3433
3468
  binary = root / ("Scripts" if os.name == "nt" else "bin") / manifest.executable
3434
3469
  self._confined(self.user_root, binary, must_exist=True, expected=binary)
@@ -0,0 +1,263 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-only
2
+ """Verified Flow generation through its own protocol and an isolated environment.
3
+
4
+ The SDK owns wire validation. This host owns trust, artifact identity, process
5
+ limits and target/input correlation. A venv and temporary working directory are
6
+ process isolation, not an operating-system filesystem or network sandbox.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import importlib
12
+ import json
13
+ import os
14
+ import stat
15
+ import tempfile
16
+ from pathlib import Path
17
+ from typing import Any, Protocol, cast
18
+
19
+ from sanka.runtime.extensions.model import ExtensionError, FlowCapability
20
+ from sanka.runtime.extensions.runner import ExtensionRunner
21
+ from sanka.runtime.extensions.store import ExtensionStore, LockEntry
22
+ from sanka.runtime.flow.model import BlueprintInput, Document, FlowError
23
+
24
+ PROTOCOL_VERSION = "sanka-flow-extension/v1"
25
+ MAX_MESSAGE_BYTES = 4 * 1024 * 1024
26
+
27
+
28
+ class FlowCodec(Protocol):
29
+ """Host-supplied, released SDK contract; never supplied by the selected extension."""
30
+
31
+ def prepare(self, request: Document, capability: FlowCapability) -> Document: ...
32
+
33
+ def decode(self, response: Document, request: Document) -> BlueprintInput | None: ...
34
+
35
+
36
+ class SDKFlowCodec:
37
+ """Load the canonical SDK lazily; older embedded SDKs fail before execution."""
38
+
39
+ @staticmethod
40
+ def _protocol() -> Any:
41
+ try:
42
+ return importlib.import_module("sanka_extensions.flow.protocol")
43
+ except ImportError as error:
44
+ raise ExtensionError(
45
+ "SANKA_FLOW_SDK_REQUIRED",
46
+ "Flow generation requires a runtime with the released Flow protocol SDK",
47
+ ) from error
48
+
49
+ def prepare(self, request: Document, capability: FlowCapability) -> Document:
50
+ protocol = self._protocol()
51
+ parsed = protocol.BlueprintRequest.from_dict(request.to_dict())
52
+ protocol.FlowCapability.from_dict(capability.to_dict()).validate_request(parsed)
53
+ return Document(parsed.to_dict())
54
+
55
+ def decode(self, response: Document, request: Document) -> BlueprintInput | None:
56
+ protocol = self._protocol()
57
+ parsed = protocol.BlueprintResponse.from_dict(response.to_dict())
58
+ parsed.validate_for(protocol.BlueprintRequest.from_dict(request.to_dict()))
59
+ return cast(BlueprintInput | None, parsed.blueprint)
60
+
61
+
62
+ def _response_document(stdout: bytes) -> Document:
63
+ def unique_fields(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
64
+ result: dict[str, Any] = {}
65
+ for key, value in pairs:
66
+ if key in result:
67
+ raise ValueError("Duplicate Flow response field")
68
+ result[key] = value
69
+ return result
70
+
71
+ if len(stdout) > MAX_MESSAGE_BYTES:
72
+ raise ValueError("Flow response exceeds its byte limit")
73
+ return Document(json.loads(stdout.decode("utf-8"), object_pairs_hook=unique_fields))
74
+
75
+
76
+ class FlowExtensionRunner(ExtensionRunner):
77
+ """Generate one Blueprint from an explicit installed Flow extension identity."""
78
+
79
+ def __init__(
80
+ self,
81
+ store: ExtensionStore,
82
+ *,
83
+ codec: FlowCodec | None = None,
84
+ timeout_seconds: float = 30.0,
85
+ ) -> None:
86
+ super().__init__(user_root=store.user_root, timeout_seconds=timeout_seconds)
87
+ self.store = store
88
+ self.codec = codec or SDKFlowCodec()
89
+
90
+ def _generate_process(
91
+ self, lock: LockEntry, request: Document, executable_fd: int
92
+ ) -> tuple[int, bytes, bytes]:
93
+ executable = self._executable(lock)
94
+ opened, linked = os.fstat(executable_fd), executable.lstat()
95
+ if (
96
+ not stat.S_ISREG(opened.st_mode)
97
+ or opened.st_nlink != 1
98
+ or not stat.S_ISREG(linked.st_mode)
99
+ or (opened.st_dev, opened.st_ino) != (linked.st_dev, linked.st_ino)
100
+ ):
101
+ raise ExtensionError(
102
+ "SANKA_EXTENSION_PATH", "Flow executable changed after verification"
103
+ )
104
+ command = [str(executable.parent / "python"), "-I", "-B", f"/dev/fd/{executable_fd}"]
105
+ content = (request.text + "\n").encode("utf-8")
106
+ if len(content) > MAX_MESSAGE_BYTES:
107
+ raise ValueError("Flow request exceeds its byte limit")
108
+ with tempfile.TemporaryDirectory(prefix="sanka-flow-") as temporary:
109
+ temporary = str(Path(temporary).resolve())
110
+ return self._execute(
111
+ command,
112
+ content,
113
+ cwd=temporary,
114
+ environment={
115
+ "LANG": "C.UTF-8",
116
+ "PYTHONUTF8": "1",
117
+ "PYTHONDONTWRITEBYTECODE": "1",
118
+ "PATH": os.defpath,
119
+ "HOME": temporary,
120
+ "TMPDIR": temporary,
121
+ },
122
+ pass_fds=(executable_fd,),
123
+ )
124
+
125
+ def generate(
126
+ self,
127
+ extension_id: str,
128
+ *,
129
+ request_id: str,
130
+ definition: dict[str, Any],
131
+ target: dict[str, Any],
132
+ references: list[dict[str, Any]],
133
+ values: dict[str, Any],
134
+ ) -> BlueprintInput:
135
+ """Resolve no implicit type/name match and perform no native construction."""
136
+ try:
137
+ with self.store.execution_guard():
138
+ lock, manifest = self.store.flow_manifest(extension_id)
139
+ capability = next(
140
+ (item for item in manifest.capabilities if item.type == definition.get("type")),
141
+ None,
142
+ )
143
+ if capability is None:
144
+ raise ExtensionError(
145
+ "SANKA_FLOW_CAPABILITY_UNSUPPORTED",
146
+ "Selected Flow extension does not declare this definition type",
147
+ )
148
+ extension = {
149
+ "id": lock.id,
150
+ "revision": lock.version,
151
+ "digest": lock.manifest_digest,
152
+ }
153
+ request = self.codec.prepare(
154
+ Document(
155
+ {
156
+ "schema_version": PROTOCOL_VERSION,
157
+ "request_id": request_id,
158
+ "operation": "blueprint",
159
+ "extension": extension,
160
+ "definition": definition,
161
+ "target": target,
162
+ "references": references,
163
+ "values": values,
164
+ "template": capability.template.to_dict(),
165
+ "output_schema": capability.output_schema,
166
+ }
167
+ ),
168
+ capability,
169
+ )
170
+ prepared = request.to_dict()
171
+ # The SDK canonicalizes this set; its ordering is not a target change.
172
+ expected_target = dict(target)
173
+ if "capabilities" in expected_target:
174
+ expected_target["capabilities"] = sorted(expected_target["capabilities"])
175
+ for field, expected in (
176
+ ("extension", extension),
177
+ ("target", expected_target),
178
+ ("definition", definition),
179
+ ("values", values),
180
+ ("template", capability.template.to_dict()),
181
+ ("output_schema", capability.output_schema),
182
+ ):
183
+ if Document({"value": prepared[field]}) != Document({"value": expected}):
184
+ raise ValueError("Flow SDK changed requested generation input")
185
+ with self.store.execution_lease(lock) as executable_fd:
186
+ exit_code, stdout, _stderr = self._generate_process(
187
+ lock, request, executable_fd
188
+ )
189
+ if self.store.resolve_locked(lock.id) != lock:
190
+ raise ValueError("Flow installation changed during generation")
191
+ response = _response_document(stdout)
192
+ payload = response.to_dict()
193
+ if set(payload) != {
194
+ "schema_version",
195
+ "request_id",
196
+ "request_digest",
197
+ "operation",
198
+ "extension",
199
+ "outcome",
200
+ "blueprint",
201
+ "error",
202
+ } or any(
203
+ payload.get(field) != expected
204
+ for field, expected in (
205
+ ("schema_version", PROTOCOL_VERSION),
206
+ ("operation", "blueprint"),
207
+ ("request_id", request_id),
208
+ ("request_digest", request.digest),
209
+ ("extension", extension),
210
+ )
211
+ ):
212
+ raise ValueError("Flow response does not match the exact request")
213
+ if (payload["outcome"], exit_code) not in (("success", 0), ("error", 1)):
214
+ raise ValueError("Flow process status and protocol outcome differ")
215
+ blueprint = self.codec.decode(response, request)
216
+ if blueprint is None:
217
+ raise ExtensionError(
218
+ "SANKA_FLOW_GENERATION_FAILED",
219
+ "Flow extension could not resolve the requested Blueprint",
220
+ details={"extension_id": lock.id, "error": payload["error"]},
221
+ )
222
+ output = blueprint.to_dict()
223
+ origin = output.get("origin", {})
224
+ if (
225
+ output.get("schema_version") != capability.output_schema
226
+ or output.get("extension") != extension
227
+ or origin.get("kind") != "template"
228
+ or origin.get("identity") != capability.template.to_dict()
229
+ or output.get("references") != prepared["references"]
230
+ or output.get("mappings") != []
231
+ or Document(output.get("parameters", {}))
232
+ != Document(
233
+ {
234
+ "target": prepared["target"],
235
+ "values": values,
236
+ "definition_parameters": definition.get("parameters"),
237
+ }
238
+ )
239
+ ):
240
+ raise ValueError(
241
+ "Flow Blueprint changed requested provenance or target bindings"
242
+ )
243
+ return blueprint
244
+ except ExtensionError:
245
+ raise
246
+ except OSError as error:
247
+ raise ExtensionError(
248
+ "SANKA_FLOW_EXTENSION_IO", "Flow extension process could not complete"
249
+ ) from error
250
+ except (
251
+ ValueError,
252
+ TypeError,
253
+ KeyError,
254
+ AttributeError,
255
+ RecursionError,
256
+ FlowError,
257
+ ) as error:
258
+ raise ExtensionError(
259
+ "SANKA_FLOW_EXTENSION_PROTOCOL", "Flow extension request or response is invalid"
260
+ ) from error
261
+
262
+
263
+ __all__ = ["FlowCodec", "FlowExtensionRunner", "SDKFlowCodec"]