@atmem/architect 0.0.0-stage → 0.2.0-alpha.4.1

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 (498) hide show
  1. package/CONSTITUTION.md +144 -0
  2. package/README.md +33 -2
  3. package/agent-skills/discovery/SKILL.md +48 -0
  4. package/agent-skills/discovery/topics.json +139 -0
  5. package/agent-skills/generation-capabilities.json +760 -0
  6. package/agent-skills/service-lifecycle.json +21 -0
  7. package/agent-skills/specialists/architecture/SKILL.md +15 -0
  8. package/agent-skills/specialists/aws/SKILL.md +17 -0
  9. package/agent-skills/specialists/azure/SKILL.md +7 -0
  10. package/agent-skills/specialists/composition/SKILL.md +17 -0
  11. package/agent-skills/specialists/devops/SKILL.md +10 -0
  12. package/agent-skills/specialists/finops/SKILL.md +7 -0
  13. package/agent-skills/specialists/gcp/SKILL.md +7 -0
  14. package/agent-skills/specialists/ibm/SKILL.md +7 -0
  15. package/agent-skills/specialists/manifest.json +13 -0
  16. package/agent-skills/specialists/pulumi/SKILL.md +7 -0
  17. package/agent-skills/specialists/security/SKILL.md +7 -0
  18. package/agent-skills/specialists/terraform/SKILL.md +14 -0
  19. package/agent-skills/upstream/aws/LICENSE +175 -0
  20. package/agent-skills/upstream/aws/SKILL.md +125 -0
  21. package/agent-skills/upstream/azure/LICENSE +21 -0
  22. package/agent-skills/upstream/azure/SKILL.md +387 -0
  23. package/agent-skills/upstream/gcp/LICENSE +202 -0
  24. package/agent-skills/upstream/gcp/SKILL.md +159 -0
  25. package/agent-skills/upstream/manifest.json +57 -0
  26. package/agent-skills/upstream/pulumi/LICENSE +201 -0
  27. package/agent-skills/upstream/pulumi/SKILL.md +501 -0
  28. package/agent-skills/upstream/terraform/LICENSE +373 -0
  29. package/agent-skills/upstream/terraform/SKILL.md +316 -0
  30. package/agent-skills/workflows/workflows.json +601 -0
  31. package/cli/architect.mjs +3 -0
  32. package/cli/runtime.mjs +115 -0
  33. package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
  34. package/dist/assets/index-B97MkVMs.css +1 -0
  35. package/dist/assets/index-qtCM2D7O.js +21271 -0
  36. package/dist/assets/index.es-C6C0sneB.js +18 -0
  37. package/dist/assets/purify.es-CAi2OJFm.js +3 -0
  38. package/dist/assets/visual-export-DjbjgQbA.js +173 -0
  39. package/dist/favicon.svg +2 -0
  40. package/dist/fonts/DM-Sans-OFL.txt +93 -0
  41. package/dist/fonts/Manrope-OFL.txt +93 -0
  42. package/dist/fonts/NotoSans-Regular.ttf +0 -0
  43. package/dist/fonts/OFL.txt +94 -0
  44. package/dist/fonts/dm-sans-latin-wght-normal.woff2 +0 -0
  45. package/dist/fonts/manrope-latin-wght-normal.woff2 +0 -0
  46. package/dist/index.html +4 -0
  47. package/dist/licenses/aws-architect-LICENSE.txt +17 -0
  48. package/dist/licenses/aws-mcp-LICENSE.txt +175 -0
  49. package/dist/licenses/aws-mcp-NOTICE.txt +1 -0
  50. package/dist/licenses/cloud-emulation-notices.txt +36619 -0
  51. package/dist/licenses/dependency-notices.txt +6379 -0
  52. package/dist/licenses/emulation-notices.txt +717 -0
  53. package/dist/licenses/github-copilot-sdk-LICENSE.txt +21 -0
  54. package/dist/licenses/memory-dependency-notices.txt +3319 -0
  55. package/dist/licenses/openarchflow-LICENSE.txt +21 -0
  56. package/dist/licenses/python-dependency-notices.txt +11951 -0
  57. package/docs/upstream-lock.json +26 -0
  58. package/knowledge/engineering-practices.json +536 -0
  59. package/package.json +30 -4
  60. package/packaging/uv-release-lock.json +54 -0
  61. package/public/licenses/aws-architect-LICENSE.txt +17 -0
  62. package/public/licenses/aws-mcp-LICENSE.txt +175 -0
  63. package/public/licenses/aws-mcp-NOTICE.txt +1 -0
  64. package/public/licenses/cloud-emulation-notices.txt +36619 -0
  65. package/public/licenses/dependency-notices.txt +6379 -0
  66. package/public/licenses/emulation-notices.txt +717 -0
  67. package/public/licenses/github-copilot-sdk-LICENSE.txt +21 -0
  68. package/public/licenses/memory-dependency-notices.txt +3319 -0
  69. package/public/licenses/openarchflow-LICENSE.txt +21 -0
  70. package/public/licenses/python-dependency-notices.txt +11951 -0
  71. package/scripts/terraform-render.mjs +8 -0
  72. package/server/__init__.py +0 -0
  73. package/server/abstraction.py +28 -0
  74. package/server/agent_runtime.py +153 -0
  75. package/server/app.py +257 -0
  76. package/server/architect.py +112 -0
  77. package/server/architecture_activity.py +67 -0
  78. package/server/attachments.py +101 -0
  79. package/server/cloud-emulation-requirements.txt +29 -0
  80. package/server/codex_app_server.py +219 -0
  81. package/server/codex_engineering_backend.py +266 -0
  82. package/server/codex_worker_policy.py +170 -0
  83. package/server/contracts.py +315 -0
  84. package/server/copilot_worker.py +16 -0
  85. package/server/dependency_mirror.py +54 -0
  86. package/server/design_patch.py +43 -0
  87. package/server/emulation-requirements.txt +8 -0
  88. package/server/emulation_adapters.py +20 -0
  89. package/server/emulation_routes.py +98 -0
  90. package/server/emulation_worker.py +351 -0
  91. package/server/engineering_artifacts.py +215 -0
  92. package/server/engineering_assets/application-runtime.json +4372 -0
  93. package/server/engineering_assets/architecture_work.schema.json +79 -0
  94. package/server/engineering_assets/materialize_runtime.py +62 -0
  95. package/server/engineering_assets/prepare_tools.py +96 -0
  96. package/server/engineering_assets/sql_validation.py +59 -0
  97. package/server/engineering_contexts.py +120 -0
  98. package/server/engineering_delivery.py +210 -0
  99. package/server/engineering_finalization.py +210 -0
  100. package/server/engineering_handoff.py +163 -0
  101. package/server/engineering_jobs.py +206 -0
  102. package/server/engineering_knowledge.py +75 -0
  103. package/server/engineering_reconciliation.py +159 -0
  104. package/server/engineering_routes.py +469 -0
  105. package/server/engineering_sessions.py +273 -0
  106. package/server/engineering_tools.py +166 -0
  107. package/server/generation_lint.py +18 -0
  108. package/server/local_providers.py +181 -0
  109. package/server/local_validation.py +236 -0
  110. package/server/memory-requirements.lock +181 -0
  111. package/server/memory-requirements.txt +6 -0
  112. package/server/memory_routes.py +82 -0
  113. package/server/memory_service.py +273 -0
  114. package/server/memory_worker.py +66 -0
  115. package/server/openai_voice.py +80 -0
  116. package/server/packaged_app.py +9 -0
  117. package/server/pricing.py +84 -0
  118. package/server/process_control_observation.py +31 -0
  119. package/server/prompts.py +123 -0
  120. package/server/public_faq_emulation_worker.py +44 -0
  121. package/server/requirements.lock +1618 -0
  122. package/server/requirements.txt +68 -0
  123. package/server/runtime_dependency_locks.py +27 -0
  124. package/server/runtime_evidence.py +93 -0
  125. package/server/settings.py +14 -0
  126. package/server/skills.py +103 -0
  127. package/server/storage_emulation_worker.py +160 -0
  128. package/server/structured_emulation_worker.py +48 -0
  129. package/server/terraform_routes.py +118 -0
  130. package/server/upstream/__init__.py +0 -0
  131. package/server/upstream/agent/__init__.py +1 -0
  132. package/server/upstream/agent/aws_architect.py +600 -0
  133. package/server/upstream/agent/config/__init__.py +1 -0
  134. package/server/upstream/agent/config/agent_config.py +82 -0
  135. package/server/upstream/agent/config/prompts.py +138 -0
  136. package/server/upstream/agent/rate_limiter.py +62 -0
  137. package/server/upstream/utils/__init__.py +1 -0
  138. package/server/upstream/utils/file_writer.py +43 -0
  139. package/server/validation_applicability.py +85 -0
  140. package/server/validation_jobs.py +252 -0
  141. package/server/validation_workers.py +48 -0
  142. package/server/voice_routes.py +91 -0
  143. package/server/voice_worker.py +26 -0
  144. package/specs/028-convergence-evaluation/evidence/20261110-ibm-invoice-native/registry-structured/qualification.json +72 -0
  145. package/specs/028-convergence-evaluation/evidence/20261110-invoice-runtime/durable-current/receipt.json +61 -0
  146. package/specs/029-general-purpose-engine/evidence/20261111-runtime-dependencies/sdk/receipt.json +22 -0
  147. package/src/ArchitectureActivity.jsx +54 -0
  148. package/src/ArchitectureWorkPanel.jsx +46 -0
  149. package/src/ArtifactChecks.jsx +49 -0
  150. package/src/BlockRequirements.jsx +13 -0
  151. package/src/BrainActivity.jsx +11 -0
  152. package/src/ChatMessage.jsx +19 -0
  153. package/src/ChatResizeHandle.jsx +6 -0
  154. package/src/CodePreview.jsx +8 -0
  155. package/src/ComponentReview.jsx +31 -0
  156. package/src/DeliveryViews.jsx +59 -0
  157. package/src/EmulationPanel.jsx +44 -0
  158. package/src/EngagementViews.jsx +385 -0
  159. package/src/EngineeringPanel.jsx +151 -0
  160. package/src/ImplementationDelivery.jsx +55 -0
  161. package/src/JourneyViews.jsx +400 -0
  162. package/src/MemoryPanel.jsx +46 -0
  163. package/src/OpenAIVoicePanel.jsx +65 -0
  164. package/src/OutputsView.jsx +65 -0
  165. package/src/TerraformView.jsx +57 -0
  166. package/src/WorkbenchDialogs.jsx +532 -0
  167. package/src/activity-presentation.mjs +28 -0
  168. package/src/ai-qualification-scenarios.mjs +31 -0
  169. package/src/approval-application-files.mjs +32 -0
  170. package/src/approval-applications.mjs +82 -0
  171. package/src/approval-spec-kit.mjs +30 -0
  172. package/src/architecture-activity.css +28 -0
  173. package/src/architecture-activity.mjs +63 -0
  174. package/src/architecture-work.mjs +176 -0
  175. package/src/artifact-work.mjs +103 -0
  176. package/src/async-documents.mjs +191 -0
  177. package/src/atflow.css +1140 -0
  178. package/src/atforma.css +748 -0
  179. package/src/atmem-tokens.css +79 -0
  180. package/src/aws-preflight.mjs +60 -0
  181. package/src/aws-public-faq.mjs +102 -0
  182. package/src/aws-validation-scenarios.mjs +10 -0
  183. package/src/aws-validation.mjs +48 -0
  184. package/src/azure-plan-mocks.mjs +25 -0
  185. package/src/azure-structured.mjs +133 -0
  186. package/src/bedrock-summary.mjs +152 -0
  187. package/src/bounded-rag.mjs +60 -0
  188. package/src/brand.css +9 -0
  189. package/src/canvas-view.mjs +28 -0
  190. package/src/capability-composition.mjs +44 -0
  191. package/src/chat-attachments.mjs +13 -0
  192. package/src/cloud-provider-locks.mjs +9 -0
  193. package/src/cloud-storage-scenarios.mjs +2 -0
  194. package/src/component-review.mjs +55 -0
  195. package/src/composition-spec-kit.mjs +30 -0
  196. package/src/consultation-context.mjs +15 -0
  197. package/src/consultation.mjs +52 -0
  198. package/src/container-contracts.mjs +5 -0
  199. package/src/container-inspection.mjs +75 -0
  200. package/src/container-runtime.mjs +30 -0
  201. package/src/container-security-inspection.mjs +49 -0
  202. package/src/container-terraform.mjs +109 -0
  203. package/src/conversation.mjs +17 -0
  204. package/src/core.mjs +863 -0
  205. package/src/cross-cloud-storage.mjs +100 -0
  206. package/src/delivery-capabilities.mjs +25 -0
  207. package/src/delivery.mjs +58 -0
  208. package/src/deployment-ownership.mjs +10 -0
  209. package/src/deployment-region.mjs +11 -0
  210. package/src/derive.mjs +31 -0
  211. package/src/design-build-flow.mjs +10 -0
  212. package/src/diagram-attention.mjs +24 -0
  213. package/src/discovery.mjs +359 -0
  214. package/src/document.mjs +170 -0
  215. package/src/emulation-feedback.mjs +61 -0
  216. package/src/emulation-guidance.mjs +37 -0
  217. package/src/engagement.mjs +274 -0
  218. package/src/engineering-client.mjs +73 -0
  219. package/src/engineering-defaults.mjs +17 -0
  220. package/src/engineering.css +31 -0
  221. package/src/enterprise-application.mjs +76 -0
  222. package/src/enterprise-aws-host-infrastructure.mjs +62 -0
  223. package/src/enterprise-aws-host-tests.mjs +15 -0
  224. package/src/enterprise-aws-infrastructure-tests.mjs +38 -0
  225. package/src/enterprise-aws-infrastructure.mjs +138 -0
  226. package/src/enterprise-google-infrastructure.mjs +84 -0
  227. package/src/enterprise-google-tests.mjs +25 -0
  228. package/src/estimate.mjs +188 -0
  229. package/src/existing-references.mjs +18 -0
  230. package/src/external-identities.mjs +17 -0
  231. package/src/faq-lambda-build.mjs +28 -0
  232. package/src/gcp-structured.mjs +104 -0
  233. package/src/generation-provider.mjs +7 -0
  234. package/src/generation-quality.mjs +69 -0
  235. package/src/handoff.mjs +141 -0
  236. package/src/ibm-registry.mjs +12 -0
  237. package/src/ibm-structured.mjs +103 -0
  238. package/src/identifiers.mjs +15 -0
  239. package/src/implementation-map.mjs +14 -0
  240. package/src/implementation-outcome.mjs +8 -0
  241. package/src/incomplete-terraform.mjs +9 -0
  242. package/src/integrations.ts +137 -0
  243. package/src/interface-contracts.mjs +30 -0
  244. package/src/invoice-application.mjs +66 -0
  245. package/src/invoice-aws-operations.mjs +136 -0
  246. package/src/invoice-aws.mjs +143 -0
  247. package/src/invoice-azure-operations.mjs +147 -0
  248. package/src/invoice-azure.mjs +134 -0
  249. package/src/invoice-builder.mjs +35 -0
  250. package/src/invoice-dependencies.mjs +43 -0
  251. package/src/invoice-gcp-operations.mjs +178 -0
  252. package/src/invoice-gcp.mjs +104 -0
  253. package/src/invoice-ibm-operations.mjs +278 -0
  254. package/src/invoice-ibm.mjs +142 -0
  255. package/src/invoice-operations.mjs +143 -0
  256. package/src/invoice-plan.mjs +45 -0
  257. package/src/invoice-region.mjs +6 -0
  258. package/src/invoice-spec-kit.mjs +61 -0
  259. package/src/invoice-state.mjs +7 -0
  260. package/src/invoice-terraform.mjs +29 -0
  261. package/src/invoice-tests.mjs +122 -0
  262. package/src/journey-workspace.css +72 -0
  263. package/src/journey.mjs +87 -0
  264. package/src/levels.mjs +145 -0
  265. package/src/local-agent.mjs +184 -0
  266. package/src/main.jsx +2458 -0
  267. package/src/model-policy-preflight.mjs +34 -0
  268. package/src/openai-voice.mjs +102 -0
  269. package/src/output-bundle.mjs +11 -0
  270. package/src/ownership-inspection.mjs +28 -0
  271. package/src/pack.mjs +201 -0
  272. package/src/pricing.mjs +31 -0
  273. package/src/production-state.mjs +8 -0
  274. package/src/project-copy.mjs +10 -0
  275. package/src/project-file.mjs +160 -0
  276. package/src/project-links.mjs +3 -0
  277. package/src/protected-state.mjs +43 -0
  278. package/src/public-faq-builder.mjs +19 -0
  279. package/src/public-faq-clouds.mjs +251 -0
  280. package/src/public-faq.mjs +122 -0
  281. package/src/pulumi.mjs +123 -0
  282. package/src/python-container.mjs +25 -0
  283. package/src/python-runtime.mjs +50 -0
  284. package/src/rag-handler.mjs +43 -0
  285. package/src/rag-web-assets.mjs +52 -0
  286. package/src/rag-web.mjs +68 -0
  287. package/src/records.mjs +177 -0
  288. package/src/resources.mjs +163 -0
  289. package/src/review.mjs +252 -0
  290. package/src/runtime/EnterpriseDocument.java +89 -0
  291. package/src/runtime/approved_http_destination.py +72 -0
  292. package/src/runtime/aws-lambda-qualification-lock.json +7 -0
  293. package/src/runtime/aws-python-lock.json +82 -0
  294. package/src/runtime/aws-web-python-lock.json +887 -0
  295. package/src/runtime/aws_json_model.py +42 -0
  296. package/src/runtime/azure-python-lock.json +863 -0
  297. package/src/runtime/azure-sources.json +8 -0
  298. package/src/runtime/azure-test-lock.json +23 -0
  299. package/src/runtime/azure_acceptance.py +192 -0
  300. package/src/runtime/azure_structured.py +153 -0
  301. package/src/runtime/bounded_rag.py +126 -0
  302. package/src/runtime/catalog_admin.py +70 -0
  303. package/src/runtime/cloud-sql-proxy-lock.json +8 -0
  304. package/src/runtime/cloud-sql-proxy-security-review.json +30 -0
  305. package/src/runtime/connector_cli.py +50 -0
  306. package/src/runtime/connector_sync.py +70 -0
  307. package/src/runtime/durable-python-lock.json +247 -0
  308. package/src/runtime/durable_workflow.py +325 -0
  309. package/src/runtime/enterprise-application-manifest.json +110 -0
  310. package/src/runtime/enterprise-application-sources.json +266 -0
  311. package/src/runtime/enterprise-auth-python-lock.json +592 -0
  312. package/src/runtime/enterprise-aws-host-bootstrap-source.json +1 -0
  313. package/src/runtime/enterprise-aws-host-probe-source.json +1 -0
  314. package/src/runtime/enterprise-aws-task-template.json +235 -0
  315. package/src/runtime/enterprise-document-lock.json +18 -0
  316. package/src/runtime/enterprise-document.Dockerfile +15 -0
  317. package/src/runtime/enterprise-runtime-aws-python-lock.json +1115 -0
  318. package/src/runtime/enterprise-runtime-azure-python-lock.json +1106 -0
  319. package/src/runtime/enterprise-runtime-gcp-python-lock.json +1060 -0
  320. package/src/runtime/enterprise-runtime-ibm-python-lock.json +1096 -0
  321. package/src/runtime/enterprise-runtime-python-lock.json +1058 -0
  322. package/src/runtime/enterprise-runtime.Dockerfile +15 -0
  323. package/src/runtime/enterprise-web-app.js +1 -0
  324. package/src/runtime/enterprise-web-entry.js +105 -0
  325. package/src/runtime/enterprise-web-lock.json +29 -0
  326. package/src/runtime/enterprise-web-notices.txt +229 -0
  327. package/src/runtime/enterprise-web.css +4 -0
  328. package/src/runtime/enterprise-web.html +8 -0
  329. package/src/runtime/enterprise_audit.py +91 -0
  330. package/src/runtime/enterprise_audit_schema.sql +25 -0
  331. package/src/runtime/enterprise_auth_schema.sql +67 -0
  332. package/src/runtime/enterprise_auth_store.py +241 -0
  333. package/src/runtime/enterprise_aws_host_bootstrap.py +120 -0
  334. package/src/runtime/enterprise_aws_host_probe.py +105 -0
  335. package/src/runtime/enterprise_aws_hosts.py +136 -0
  336. package/src/runtime/enterprise_aws_jobs.py +300 -0
  337. package/src/runtime/enterprise_aws_objects.py +93 -0
  338. package/src/runtime/enterprise_aws_transfer.py +83 -0
  339. package/src/runtime/enterprise_azure_batch_api.py +128 -0
  340. package/src/runtime/enterprise_azure_host.py +599 -0
  341. package/src/runtime/enterprise_azure_jobs.py +294 -0
  342. package/src/runtime/enterprise_azure_objects.py +234 -0
  343. package/src/runtime/enterprise_azure_pool.py +161 -0
  344. package/src/runtime/enterprise_azure_transfer.py +122 -0
  345. package/src/runtime/enterprise_configuration.py +136 -0
  346. package/src/runtime/enterprise_document.py +116 -0
  347. package/src/runtime/enterprise_document_cli.py +32 -0
  348. package/src/runtime/enterprise_document_contract.py +54 -0
  349. package/src/runtime/enterprise_document_job.py +109 -0
  350. package/src/runtime/enterprise_document_jobs.py +122 -0
  351. package/src/runtime/enterprise_document_jobs_schema.sql +23 -0
  352. package/src/runtime/enterprise_extraction_cache.py +186 -0
  353. package/src/runtime/enterprise_extraction_schema.sql +17 -0
  354. package/src/runtime/enterprise_google_jobs.py +275 -0
  355. package/src/runtime/enterprise_google_transfer.py +85 -0
  356. package/src/runtime/enterprise_http.py +212 -0
  357. package/src/runtime/enterprise_identity.py +52 -0
  358. package/src/runtime/enterprise_knowledge.py +152 -0
  359. package/src/runtime/enterprise_models.py +94 -0
  360. package/src/runtime/enterprise_native.py +181 -0
  361. package/src/runtime/enterprise_oauth.py +132 -0
  362. package/src/runtime/enterprise_operator.py +160 -0
  363. package/src/runtime/enterprise_parser_service.py +136 -0
  364. package/src/runtime/enterprise_parser_transport.py +68 -0
  365. package/src/runtime/enterprise_queries.py +255 -0
  366. package/src/runtime/enterprise_queries_schema.sql +27 -0
  367. package/src/runtime/enterprise_query_service.py +111 -0
  368. package/src/runtime/enterprise_secrets.py +110 -0
  369. package/src/runtime/enterprise_sessions.py +95 -0
  370. package/src/runtime/enterprise_sources.py +260 -0
  371. package/src/runtime/enterprise_web.py +39 -0
  372. package/src/runtime/enterprise_worker.py +68 -0
  373. package/src/runtime/export_contract_acceptance.py +18 -0
  374. package/src/runtime/faq-output-contract.json +40 -0
  375. package/src/runtime/faq-web-app.js +41 -0
  376. package/src/runtime/faq-web.css +1 -0
  377. package/src/runtime/faq-web.html +6 -0
  378. package/src/runtime/gcp-sources.json +9 -0
  379. package/src/runtime/gcp_acceptance.py +110 -0
  380. package/src/runtime/gcp_structured.py +150 -0
  381. package/src/runtime/http_acceptance.py +39 -0
  382. package/src/runtime/iap-web-app.js +36 -0
  383. package/src/runtime/iap-web-source.json +1 -0
  384. package/src/runtime/ibm-python-lock.json +856 -0
  385. package/src/runtime/ibm-sources.json +9 -0
  386. package/src/runtime/ibm_acceptance.py +133 -0
  387. package/src/runtime/ibm_structured.py +113 -0
  388. package/src/runtime/invoice-azapi-provider-lock.json +7 -0
  389. package/src/runtime/invoice-ibm-provider-lock.json +7 -0
  390. package/src/runtime/invoice-parser-lock.json +1199 -0
  391. package/src/runtime/invoice-parser-python-lock.json +56 -0
  392. package/src/runtime/invoice-parser.Dockerfile +190 -0
  393. package/src/runtime/invoice-sources.json +58 -0
  394. package/src/runtime/invoice-test-sources.json +24 -0
  395. package/src/runtime/invoice-web.css +2 -0
  396. package/src/runtime/invoice-web.html +12 -0
  397. package/src/runtime/invoice-web.js +112 -0
  398. package/src/runtime/invoice_configuration.py +17 -0
  399. package/src/runtime/invoice_document.py +95 -0
  400. package/src/runtime/invoice_extraction.py +96 -0
  401. package/src/runtime/invoice_http.py +129 -0
  402. package/src/runtime/invoice_identity.py +5 -0
  403. package/src/runtime/invoice_maintenance.py +40 -0
  404. package/src/runtime/invoice_native.py +77 -0
  405. package/src/runtime/invoice_object_store.py +153 -0
  406. package/src/runtime/invoice_operations.py +108 -0
  407. package/src/runtime/invoice_operator.py +79 -0
  408. package/src/runtime/invoice_operator_core.py +39 -0
  409. package/src/runtime/invoice_operator_job.py +147 -0
  410. package/src/runtime/invoice_parser_cli.py +17 -0
  411. package/src/runtime/invoice_parser_identity.py +39 -0
  412. package/src/runtime/invoice_parser_service.py +89 -0
  413. package/src/runtime/invoice_parser_transport.py +89 -0
  414. package/src/runtime/invoice_processing.py +24 -0
  415. package/src/runtime/invoice_retention.py +16 -0
  416. package/src/runtime/invoice_runtime_secrets.py +43 -0
  417. package/src/runtime/invoice_stage.py +80 -0
  418. package/src/runtime/invoice_web.py +39 -0
  419. package/src/runtime/invoice_worker.py +50 -0
  420. package/src/runtime/lambda_faq.py +5 -0
  421. package/src/runtime/parser-requirements.lock +4 -0
  422. package/src/runtime/policy_review.py +18 -0
  423. package/src/runtime/postgres-qualification-lock.json +21 -0
  424. package/src/runtime/public-faq-sources.json +22 -0
  425. package/src/runtime/public_catalog_admin.py +122 -0
  426. package/src/runtime/public_catalog_store.py +125 -0
  427. package/src/runtime/public_faq.py +144 -0
  428. package/src/runtime/public_faq_app.py +49 -0
  429. package/src/runtime/python-container-lock.json +18 -0
  430. package/src/runtime/rag-sources.json +10 -0
  431. package/src/runtime/rag_acceptance.py +60 -0
  432. package/src/runtime/rag_aws_adapter.py +95 -0
  433. package/src/runtime/rds-ca-source.json +9 -0
  434. package/src/runtime/rds-global-ca.pem +2888 -0
  435. package/src/runtime/state-contract-check-source.json +4 -0
  436. package/src/runtime/state_contract_check.py +338 -0
  437. package/src/runtime/structured-source.json +1 -0
  438. package/src/runtime/structured-web-app.js +71 -0
  439. package/src/runtime/structured-web-source.json +1 -0
  440. package/src/runtime/structured_http.py +105 -0
  441. package/src/runtime/structured_output.py +48 -0
  442. package/src/runtime/web-python-lock.json +802 -0
  443. package/src/runtime/web_user_admin.py +44 -0
  444. package/src/runtime/workflow_application.py +62 -0
  445. package/src/runtime/workflow_bindings.py +128 -0
  446. package/src/runtime/workflow_configuration.py +40 -0
  447. package/src/runtime/workflow_connection.py +105 -0
  448. package/src/runtime/workflow_contract.py +54 -0
  449. package/src/runtime/workflow_database.py +94 -0
  450. package/src/runtime/workflow_errors.py +6 -0
  451. package/src/runtime/workflow_http.py +178 -0
  452. package/src/runtime/workflow_identity.py +69 -0
  453. package/src/runtime/workflow_payload.py +118 -0
  454. package/src/runtime/workflow_process_stage.py +88 -0
  455. package/src/runtime/workflow_profile.py +91 -0
  456. package/src/runtime/workflow_review.py +106 -0
  457. package/src/runtime/workflow_role_bootstrap.py +104 -0
  458. package/src/runtime/workflow_schema.sql +72 -0
  459. package/src/runtime/workflow_worker.py +142 -0
  460. package/src/runtime-settings.mjs +15 -0
  461. package/src/s3-access.mjs +14 -0
  462. package/src/source-contracts.mjs +17 -0
  463. package/src/spec-kit.mjs +186 -0
  464. package/src/state-custody.mjs +32 -0
  465. package/src/state-inspection.mjs +45 -0
  466. package/src/state-spec-kit.mjs +13 -0
  467. package/src/storage-tests.mjs +25 -0
  468. package/src/structured-api.mjs +133 -0
  469. package/src/structured-contract.mjs +19 -0
  470. package/src/structured-operation-policy.mjs +2 -0
  471. package/src/structured-web.mjs +17 -0
  472. package/src/style.css +1 -0
  473. package/src/system-description.mjs +26 -0
  474. package/src/terraform-admission.mjs +66 -0
  475. package/src/terraform-composition.mjs +83 -0
  476. package/src/terraform-expressions.mjs +46 -0
  477. package/src/terraform-validation-coverage.mjs +11 -0
  478. package/src/terraform.mjs +128 -0
  479. package/src/text-statistics.mjs +51 -0
  480. package/src/upstream/openarchflow/format-payload.ts +26 -0
  481. package/src/upstream/openarchflow/import/mermaid.ts +205 -0
  482. package/src/upstream/openarchflow/import/sql-ddl.ts +109 -0
  483. package/src/upstream/openarchflow/layout.ts +54 -0
  484. package/src/upstream/openarchflow/providers/aws.ts +196 -0
  485. package/src/upstream/openarchflow/providers/azure.ts +126 -0
  486. package/src/upstream/openarchflow/providers/cloudnative.ts +71 -0
  487. package/src/upstream/openarchflow/providers/generic.ts +227 -0
  488. package/src/upstream/openarchflow/providers/integration.ts +22 -0
  489. package/src/upstream/openarchflow/providers/types.ts +2 -0
  490. package/src/upstream/openarchflow/templates.ts +937 -0
  491. package/src/upstream-catalog.mjs +10 -0
  492. package/src/useChatScroll.jsx +36 -0
  493. package/src/useEmulation.jsx +36 -0
  494. package/src/validation-receipt.mjs +10 -0
  495. package/src/visual-export.mjs +92 -0
  496. package/src/voice-conversation.mjs +117 -0
  497. package/src/work-intake.mjs +24 -0
  498. package/src/workflow-runtime-inventory.mjs +3 -0
@@ -0,0 +1,106 @@
1
+ """Explicit review/access/semantic policy supplied by trusted application code.
2
+
3
+ No domain fields, provider selection, executable loading or user configuration.
4
+ Semantic validators may reject data, never normalize it. Their implementation and
5
+ declared source dependencies are approval-bound; this is not a Python sandbox or
6
+ proof that a trusted validator is pure, bounded, or declares every dependency.
7
+ """
8
+ from dataclasses import dataclass
9
+ import hashlib
10
+ import json
11
+ from pathlib import Path, PurePosixPath
12
+ import re
13
+ import types
14
+ if __package__:
15
+ from .workflow_payload import PayloadContract, encoded
16
+ else:
17
+ from workflow_payload import PayloadContract, encoded
18
+
19
+
20
+ @dataclass(frozen=True, init=False)
21
+ class ReviewPolicy:
22
+ _encoded: bytes
23
+ _sources: tuple
24
+ _validator: object
25
+ _payload: PayloadContract
26
+
27
+ def __init__(self, payload, *, id, editable_fields, read_scope='owner',
28
+ inspection_ttl_seconds=300, validator=None, validation_sources=()):
29
+ if type(payload) is not PayloadContract:
30
+ raise ValueError('Supply the exact owned payload contract')
31
+ if type(id) is not str or not re.fullmatch(r'[a-z][a-z0-9-]{0,79}', id):
32
+ raise ValueError('Use a versioned owned review policy identity')
33
+ fields = payload.fields('result')
34
+ if (type(editable_fields) not in {list, tuple} or
35
+ any(type(field) is not str for field in editable_fields) or
36
+ len(set(editable_fields)) != len(editable_fields) or not set(editable_fields) <= set(fields)):
37
+ raise ValueError('Declare the editable top-level result fields explicitly')
38
+ if type(read_scope) is not str or read_scope not in {'owner', 'account'}:
39
+ raise ValueError('Use an explicit application read scope')
40
+ if inspection_ttl_seconds is not None and (type(inspection_ttl_seconds) is not int or not 1 <= inspection_ttl_seconds <= 3600):
41
+ raise ValueError('Use a bounded inspection lifetime or explicit None')
42
+ if type(validation_sources) not in {list, tuple, dict} or len(validation_sources) > 32:
43
+ raise ValueError('Declare bounded trusted validator source dependencies')
44
+ if validator is not None and (type(validator) is not types.FunctionType or validator.__closure__):
45
+ raise ValueError('Supply a trusted module-level semantic validator, not executable data')
46
+ if (validator is None) != (not validation_sources):
47
+ raise ValueError('A semantic validator requires its explicit source dependencies')
48
+ sources = []
49
+ entries = validation_sources.items() if type(validation_sources) is dict else [(Path(source).name,source) for source in validation_sources]
50
+ labels = set()
51
+ for label, source in entries:
52
+ if (type(label) is not str or len(label)>512 or '\\' in label or
53
+ PurePosixPath(label).is_absolute() or any(not re.fullmatch(r'[A-Za-z_][A-Za-z0-9_.-]{0,127}',part) or part in {'.','..'} for part in label.split('/'))):
54
+ raise ValueError('Use explicit portable relative validator dependency labels')
55
+ if label in labels:raise ValueError('Use explicit relative source labels for duplicate filenames')
56
+ labels.add(label)
57
+ path = Path(source)
58
+ if path.is_symlink() or not path.is_file() or path.stat().st_size > 1048576:
59
+ raise ValueError('Use bounded regular validator source files')
60
+ path = path.resolve()
61
+ sources.append((label, path, hashlib.sha256(path.read_bytes()).hexdigest()))
62
+ if validator is not None and Path(validator.__code__.co_filename).resolve() not in {path for _, path, _ in sources}:
63
+ raise ValueError('The semantic validator implementation must be source-bound')
64
+ mechanism = Path(__file__).resolve()
65
+ mechanism_sha256 = hashlib.sha256(mechanism.read_bytes()).hexdigest()
66
+ definition = {'version': 1, 'id': id, 'payloadContractSha256': payload.sha256,
67
+ 'mechanismSha256': mechanism_sha256,
68
+ 'editableFields': sorted(editable_fields), 'readScope': read_scope,
69
+ 'inspectionTtlSeconds': inspection_ttl_seconds,
70
+ 'validator': None if validator is None else {
71
+ 'entrypoint': validator.__qualname__,
72
+ 'sources': {label: sha for label, _, sha in sorted(sources)}}}
73
+ object.__setattr__(self, '_encoded', encoded(definition))
74
+ object.__setattr__(self, '_sources', tuple((path,sha) for _,path,sha in sources)+((mechanism, mechanism_sha256),))
75
+ object.__setattr__(self, '_validator', validator)
76
+ object.__setattr__(self, '_payload', payload)
77
+
78
+ @property
79
+ def data(self): return json.loads(self._encoded)
80
+
81
+ @property
82
+ def sha256(self): return hashlib.sha256(self._encoded).hexdigest()
83
+
84
+ def ensure_current(self):
85
+ for path, sha in self._sources:
86
+ if path.is_symlink() or not path.is_file() or path.stat().st_size > 1048576 or hashlib.sha256(path.read_bytes()).hexdigest() != sha:
87
+ raise ValueError('Review validator sources changed; qualify a new policy binding')
88
+
89
+ def validate_result(self, source, result):
90
+ self.ensure_current()
91
+ original = self._payload.validate('source', source)
92
+ value = self._payload.validate('result', result)
93
+ if self._validator is not None:
94
+ before = (encoded(original), encoded(value))
95
+ returned = self._validator(original, value)
96
+ if returned is not None or (encoded(original), encoded(value)) != before:
97
+ raise ValueError('Semantic validation must only accept or reject, never transform data')
98
+ return value
99
+
100
+ def validate_edit(self, source, previous, result):
101
+ value = self.validate_result(source, result)
102
+ previous = self._payload.validate('result', previous)
103
+ editable = set(self.data['editableFields'])
104
+ if encoded({k: v for k, v in previous.items() if k not in editable}) != encoded({k: v for k, v in value.items() if k not in editable}):
105
+ raise ValueError('Only explicitly editable result fields may change')
106
+ return value
@@ -0,0 +1,104 @@
1
+ """Operator-only native SQL identity bootstrap; never an application endpoint.
2
+
3
+ Create owned logins, preserve unrelated existing roles, and never implicitly rotate
4
+ an existing password. Google IAM users must first be created by this package's
5
+ native Cloud SQL user resource. Azure mappings use authoritative object/tenant IDs,
6
+ not display-name guesses. Execute only during an authorized destination bootstrap.
7
+ """
8
+ import json
9
+ import re
10
+ import uuid
11
+ from psycopg import sql
12
+ from psycopg.rows import tuple_row
13
+
14
+ def canonical_uuid(value):
15
+ if not isinstance(value,str)or str(uuid.UUID(value))!=value:raise ValueError('Use a canonical owned UUID')
16
+ return value
17
+
18
+ def role_marker(provider,deployment_id,purpose,binding):
19
+ return'atmem-owned-runtime-v1:'+json.dumps({'provider':provider,'deployment':deployment_id,'purpose':purpose,'principal':binding['principal']},sort_keys=True,separators=(',',':'))
20
+
21
+ def azure_principal(conn,name):
22
+ # Named output aliases avoid relying on case folding of Microsoft's documented
23
+ # camel-case output labels, while preserving its exact six-column contract.
24
+ with conn.cursor(row_factory=tuple_row)as cursor:
25
+ return cursor.execute('SELECT role_name::text,principal_type,object_id,tenant_id,mfa,admin FROM pg_catalog.pgaadauth_list_principals(false) AS mapped(role_name,principal_type,object_id,tenant_id,mfa,admin) WHERE role_name=%s',(name,)).fetchone()
26
+
27
+ def validate_runtime_bindings(*,provider,deployment_id,bindings,tenant_id=None):
28
+ canonical_uuid(deployment_id)
29
+ if provider not in {'aws','azure','gcp','ibm'}or not isinstance(bindings,dict)or set(bindings)!={'api','worker'}:raise ValueError('Use the complete owned native role bindings')
30
+ if provider=='azure':
31
+ canonical_uuid(tenant_id)
32
+ names=[]
33
+ for purpose,binding in bindings.items():
34
+ fields={'name','principal','created_by_package'}if provider=='gcp'else{'name','principal'}
35
+ if not isinstance(binding,dict)or set(binding)!=fields or not isinstance(binding['name'],str)or not re.fullmatch(r'[A-Za-z0-9_.@-]{1,63}',binding['name']):raise ValueError('Invalid native SQL role binding')
36
+ principal=binding['principal']
37
+ if provider in {'azure','ibm'}:canonical_uuid(principal)
38
+ elif provider=='aws':
39
+ if not isinstance(principal,str)or not re.fullmatch(r'arn:aws:iam::[0-9]{12}:role/[A-Za-z0-9+=,.@_/-]{1,512}',principal):raise ValueError('Use the exact owned workload role ARN')
40
+ else:
41
+ if(binding['created_by_package']is not True or not isinstance(principal,str)or not re.fullmatch(r'[a-z][a-z0-9-]{4,29}@[a-z][a-z0-9-]{4,28}[a-z0-9]\.iam\.gserviceaccount\.com',principal)or binding['name']!=principal.removesuffix('.gserviceaccount.com')):raise ValueError('Only the package-created service account IAM user may be admitted here')
42
+ names.append(binding['name'])
43
+ if len(set(names))!=2:raise ValueError('API and worker logins must be separate')
44
+ return bindings
45
+
46
+ def bootstrap_runtime_roles(conn,*,provider,deployment_id,bindings,passwords=None,tenant_id=None):
47
+ validate_runtime_bindings(provider=provider,deployment_id=deployment_id,bindings=bindings,tenant_id=tenant_id)
48
+ if provider=='azure'and conn.info.dbname!='postgres':raise ValueError('Azure principal mapping must run on the native postgres database before application schema bootstrap')
49
+ if provider=='ibm'and not callable(passwords):raise ValueError('Use the separate owned secret-store password reader')
50
+ # Serialize bootstrap for one deployment, including retries after a partial
51
+ # operator run. This lock does not confer ownership over an unrelated role.
52
+ conn.execute('SELECT pg_advisory_xact_lock(hashtextextended(%s,0))',('atmem-native-role-bootstrap:'+deployment_id,))
53
+ result={}
54
+ for purpose,binding in bindings.items():
55
+ name=binding['name'];identifier=sql.Identifier(name);marker=role_marker(provider,deployment_id,purpose,binding)
56
+ with conn.cursor(row_factory=tuple_row)as cursor:
57
+ existing=cursor.execute("SELECT r.oid,shobj_description(r.oid,'pg_authid'),r.rolsuper,r.rolcreatedb,r.rolcreaterole,r.rolreplication,r.rolbypassrls,r.rolcanlogin FROM pg_roles r WHERE rolname=%s",(name,)).fetchone()
58
+ if existing:
59
+ if any(existing[2:7])or not existing[7]:raise ValueError('Native runtime role must be a nonadministrative login')
60
+ if existing[1]!=marker:
61
+ if provider!='gcp'or existing[1]is not None:raise ValueError('Refusing to adopt or repoint an unrelated existing database role')
62
+ with conn.cursor(row_factory=tuple_row)as cursor:
63
+ parents=cursor.execute('SELECT p.rolname FROM pg_auth_members m JOIN pg_roles p ON p.oid=m.roleid WHERE m.member=%s',(existing[0],)).fetchall()
64
+ if not parents or not {row[0]for row in parents}<={'cloudsqliamuser','cloudsqliamserviceaccount'}:raise ValueError('The native service-account authentication marker is missing or broadened')
65
+ # Complete ownership/effective-grant admission still runs in the
66
+ # application database before runtime grants are installed.
67
+ conn.execute(sql.SQL('COMMENT ON ROLE {} IS {}').format(identifier,sql.Literal(marker)))
68
+ elif provider=='gcp':raise ValueError('Apply the owned Cloud SQL IAM user resource before SQL bootstrap')
69
+ elif provider=='azure':
70
+ conn.execute("SELECT pg_catalog.pgaadauth_create_principal_with_oid(%s,%s,'service',false,false)",(name,binding['principal']))
71
+ conn.execute(sql.SQL('COMMENT ON ROLE {} IS {}').format(identifier,sql.Literal(marker)))
72
+ else:
73
+ password=sql.SQL('NULL')
74
+ if provider=='ibm':
75
+ secret=passwords(purpose,binding['principal'])
76
+ if not isinstance(secret,str)or not 24<=len(secret.encode('utf-8'))<=500 or '\0'in secret:raise ValueError('Use a strong operator-managed SQL credential')
77
+ # Send a client-side SCRAM verifier rather than plaintext in SQL
78
+ # DDL/statement logs. The verifier remains sensitive DBA metadata.
79
+ verifier=conn.pgconn.encrypt_password(secret.encode(),name.encode(),algorithm=b'scram-sha-256').decode('ascii');password=sql.Literal(verifier)
80
+ conn.execute(sql.SQL('CREATE ROLE {} LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD {}').format(identifier,password))
81
+ if provider=='aws':
82
+ with conn.cursor(row_factory=tuple_row)as cursor:available=cursor.execute("SELECT 1 FROM pg_roles WHERE rolname='rds_iam'").fetchone()
83
+ if not available:raise ValueError('The native RDS IAM authentication role is missing')
84
+ conn.execute(sql.SQL('GRANT rds_iam TO {}').format(identifier))
85
+ conn.execute(sql.SQL('COMMENT ON ROLE {} IS {}').format(identifier,sql.Literal(marker)))
86
+ if provider=='azure':
87
+ mapped=azure_principal(conn,name)
88
+ if not mapped or len(mapped)!=6 or mapped[0]!=name or mapped[1]!='service'or mapped[2]!=binding['principal']or mapped[3]!=tenant_id or mapped[4]!=0 or mapped[5]!=0:raise ValueError('Native Entra role mapping differs from the owned service principal/tenant or has administrator/MFA flags')
89
+ # Re-read after native creation as well as on repeat operator runs. A
90
+ # provider function must not silently install an administrative login.
91
+ with conn.cursor(row_factory=tuple_row)as cursor:
92
+ flags=cursor.execute('SELECT rolsuper,rolcreatedb,rolcreaterole,rolreplication,rolbypassrls,rolcanlogin FROM pg_roles WHERE rolname=%s',(name,)).fetchone()
93
+ parents=cursor.execute('SELECT p.rolname FROM pg_auth_members m JOIN pg_roles p ON p.oid=m.roleid JOIN pg_roles child ON child.oid=m.member WHERE child.rolname=%s',(name,)).fetchall()
94
+ if not flags or any(flags[:5])or not flags[5]:raise ValueError('Native runtime role must be a nonadministrative login')
95
+ allowed={'rds_iam'}if provider=='aws'else{'cloudsqliamuser','cloudsqliamserviceaccount'}if provider=='gcp'else set()
96
+ if not {row[0]for row in parents}<=allowed:raise ValueError('Native runtime role has an unreviewed inherited authority')
97
+ if provider=='aws':
98
+ # Repair only the authentication membership of an already owned
99
+ # role. Never adopt unrelated logins or remove another grant.
100
+ conn.execute(sql.SQL('GRANT rds_iam TO {}').format(identifier))
101
+ if provider=='gcp'and not parents:raise ValueError('Native Cloud SQL IAM authentication membership is missing')
102
+ conn.execute(sql.SQL('ALTER ROLE {} CONNECTION LIMIT {}').format(identifier,sql.Literal(48 if purpose=='api'else 24)))
103
+ result[purpose]=name
104
+ return result
@@ -0,0 +1,72 @@
1
+ -- Apply only through the reviewed migration role, in its own database/schema.
2
+ -- Queue schema is supplied by the pinned Procrastinate dependency, not copied here.
3
+ CREATE TABLE workflow.schema_version (
4
+ version integer PRIMARY KEY CHECK (version = 2),
5
+ source_sha256 text NOT NULL,
6
+ queue_version text NOT NULL,
7
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp()
8
+ );
9
+ CREATE TABLE workflow.accounts (
10
+ id uuid PRIMARY KEY
11
+ );
12
+ CREATE TABLE workflow.memberships (
13
+ account_id uuid NOT NULL REFERENCES workflow.accounts(id),
14
+ subject text NOT NULL CHECK (octet_length(subject) BETWEEN 1 AND 500),
15
+ roles text[] NOT NULL CHECK (cardinality(roles) > 0 AND roles <@ ARRAY['user','reviewer','supervisor','owner']::text[]),
16
+ active boolean NOT NULL DEFAULT true,
17
+ authorization_lock bigint NOT NULL DEFAULT 0,
18
+ PRIMARY KEY (account_id, subject)
19
+ );
20
+ CREATE TABLE workflow.operations (
21
+ id uuid PRIMARY KEY,
22
+ account_id uuid NOT NULL REFERENCES workflow.accounts(id),
23
+ workflow_key text NOT NULL CHECK (octet_length(workflow_key) BETWEEN 1 AND 128),
24
+ kind text NOT NULL CHECK (kind IN ('document','draft','account_change')),
25
+ dedup_key text NOT NULL CHECK (octet_length(dedup_key) BETWEEN 1 AND 200),
26
+ created_by text NOT NULL,
27
+ -- Payload JSON must retain every accepted Unicode scalar, including U+0000.
28
+ -- Do not cast these fields to jsonb/text scalars: PostgreSQL cannot represent
29
+ -- NUL in text. Application contracts validate and canonically bind the JSON.
30
+ source_ref json NOT NULL CHECK (json_typeof(source_ref) = 'object'),
31
+ destination_contract jsonb NOT NULL CHECK (jsonb_typeof(destination_contract) = 'object'),
32
+ state text NOT NULL CHECK (state IN ('pending','processing','review','approved','dispatching','unknown','sent','dead')),
33
+ result json,
34
+ result_revision integer NOT NULL DEFAULT 0,
35
+ approved_hash text,
36
+ approved_by text,
37
+ lease_token uuid,
38
+ lease_until timestamptz,
39
+ execution_epoch bigint NOT NULL DEFAULT 0,
40
+ attempts integer NOT NULL DEFAULT 0,
41
+ queue_job_id bigint,
42
+ receipt json,
43
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
44
+ updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
45
+ UNIQUE (account_id, workflow_key, kind, dedup_key),
46
+ UNIQUE (id, account_id),
47
+ FOREIGN KEY (account_id, created_by) REFERENCES workflow.memberships(account_id, subject),
48
+ FOREIGN KEY (account_id, approved_by) REFERENCES workflow.memberships(account_id, subject),
49
+ CHECK ((lease_token IS NULL) = (lease_until IS NULL))
50
+ );
51
+ CREATE INDEX workflow_operations_recovery ON workflow.operations(state, lease_until);
52
+ CREATE TABLE workflow.results_history (
53
+ operation_id uuid NOT NULL,
54
+ account_id uuid NOT NULL,
55
+ revision integer NOT NULL CHECK (revision > 0),
56
+ result json NOT NULL CHECK (json_typeof(result) = 'object' AND octet_length(result::text) <= 70000),
57
+ actor text NOT NULL,
58
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
59
+ PRIMARY KEY (operation_id,revision),
60
+ FOREIGN KEY (operation_id,account_id) REFERENCES workflow.operations(id,account_id)
61
+ );
62
+ CREATE TABLE workflow.events (
63
+ sequence bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
64
+ operation_id uuid NOT NULL,
65
+ account_id uuid NOT NULL,
66
+ event text NOT NULL,
67
+ actor text NOT NULL,
68
+ detail jsonb NOT NULL CHECK (jsonb_typeof(detail) = 'object' AND octet_length(detail::text) <= 2000),
69
+ created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
70
+ FOREIGN KEY (operation_id, account_id) REFERENCES workflow.operations(id, account_id)
71
+ );
72
+ CREATE INDEX workflow_events_operation ON workflow.events(account_id, operation_id, sequence);
@@ -0,0 +1,142 @@
1
+ """Owned queue integration; concrete processors/HTTP adapters remain separate.
2
+
3
+ Task arguments contain an operation UUID only. Callbacks are trusted source wired
4
+ by the compiler/bootstrap, never model-provided paths, tools or Python code.
5
+ """
6
+ import asyncio
7
+ import logging
8
+ import time
9
+ import procrastinate
10
+ import psycopg
11
+ from durable_workflow import WorkflowStore,LostLease
12
+ from workflow_connection import DatabaseCredentialUnavailable
13
+ from workflow_errors import TemporaryWork,PermanentWork,ExternalOutcomeUnknown,DestinationNotAttempted,InvalidDispatch
14
+ from workflow_contract import bind_review_policy
15
+
16
+ def _transient_database_error(error,depth=0):
17
+ # ConnectorException and TaskGroup wrappers retain the native cause. Never
18
+ # retry a mixed group containing a programming/schema/authorization failure.
19
+ if depth>12:return False
20
+ if isinstance(error,BaseExceptionGroup):return bool(error.exceptions)and all(_transient_database_error(child,depth+1)for child in error.exceptions)
21
+ if isinstance(error,DatabaseCredentialUnavailable):return True
22
+ if isinstance(error,psycopg.OperationalError):
23
+ state=error.sqlstate
24
+ return state is None or state.startswith('08')or state in {'57P01','57P02','57P03'}
25
+ if error.__cause__ is not None:return _transient_database_error(error.__cause__,depth+1)
26
+ return False
27
+
28
+ def _namespace(value):
29
+ if not isinstance(value,str)or not value.isascii()or not value.replace('-','').isalnum()or not 1<=len(value)<=20:raise ValueError('Invalid owned workflow namespace')
30
+ return value
31
+
32
+ def producer_store(dsn,*,destination_contract,namespace='workflow',lease_seconds=600,payload_contract=None,operation_kind=None,review_policy=None):
33
+ """API-side store: synchronous outbox, no worker/model credentials needed."""
34
+ namespace=_namespace(namespace)
35
+ app=procrastinate.App(connector=procrastinate.SyncPsycopgConnector(conninfo=dsn,kwargs={'connect_timeout':5,'options':'-c search_path=pg_catalog,workflow,pg_temp'}))
36
+ def worker_only(operation_id):raise PermanentWork('Run the dedicated owned worker, not an API-side producer')
37
+ extract=app.task(name=namespace+'.extract',queue=namespace+'-extract')(worker_only)
38
+ dispatch=app.task(name=namespace+'.dispatch',queue=namespace+'-dispatch')(worker_only)
39
+ return WorkflowStore(dsn,extract,dispatch,destination_contract=destination_contract,lease_seconds=lease_seconds,payload_contract=payload_contract,operation_kind=operation_kind,review_policy=review_policy)
40
+
41
+ class WorkflowRuntime:
42
+ def __init__(self,dsn,processor,deliver,*,destination_contract=None,idempotent_destination=False,namespace='workflow',lease_seconds=600,retry_wait=5,payload_contract=None,operation_kind=None,review_policy=None):
43
+ if type(idempotent_destination)is not bool:raise ValueError('Invalid owned worker configuration')
44
+ namespace=_namespace(namespace)
45
+ if type(retry_wait)is not int or not 0<=retry_wait<=300:raise ValueError('Invalid retry policy')
46
+ for stage in [processor,deliver]:
47
+ if hasattr(stage,'timeout_seconds')and stage.timeout_seconds+5>=lease_seconds:raise ValueError('A stage deadline must leave room to commit inside the domain lease')
48
+ if hasattr(deliver,'idempotency_verified')and deliver.idempotency_verified!=idempotent_destination:raise ValueError('Worker replay policy must match the reviewed destination contract')
49
+ if destination_contract is None:destination_contract=getattr(deliver,'contract',None)
50
+ elif hasattr(deliver,'contract')and deliver.contract!=bind_review_policy(destination_contract,payload_contract,review_policy):raise ValueError('Worker and destination integration identities must match')
51
+ if review_policy is not None and hasattr(deliver,'contract')and deliver.contract!=bind_review_policy(destination_contract,payload_contract,review_policy):raise ValueError('Publisher must use the exact review policy binding')
52
+ self.processor=processor;self.deliver=deliver;self.idempotent_destination=idempotent_destination
53
+ async def refreshed_connection():return await asyncio.to_thread(dsn)
54
+ self.app=procrastinate.App(connector=procrastinate.PsycopgConnector(conninfo=refreshed_connection if callable(dsn)else dsn,min_size=1,max_size=8,max_lifetime=600,kwargs={'connect_timeout':5,'options':'-c search_path=pg_catalog,workflow,pg_temp -c statement_timeout=10000 -c lock_timeout=3000'}))
55
+ retry=procrastinate.RetryStrategy(max_attempts=5,wait=retry_wait,retry_exceptions=[TemporaryWork])
56
+ self.extract=self.app.task(name=namespace+'.extract',queue=namespace+'-extract',retry=retry)(self._extract)
57
+ self.dispatch=self.app.task(name=namespace+'.dispatch',queue=namespace+'-dispatch',retry=retry)(self._dispatch)
58
+ # The domain transaction is a synchronous psycopg connection. Keep its
59
+ # producer connector synchronous even while the async worker pool is open;
60
+ # never accidentally bridge that connection into an async cursor context.
61
+ self.store=producer_store(dsn,destination_contract=destination_contract,namespace=namespace,lease_seconds=lease_seconds,payload_contract=payload_contract,operation_kind=operation_kind,review_policy=review_policy)
62
+ async def _fail(self,row,reason,*,retryable=False,ambiguous=True):
63
+ try:await asyncio.to_thread(self.store.fail,str(row['id']),str(row['lease_token']),reason,retryable=retryable,ambiguous=ambiguous)
64
+ except LostLease:return
65
+ async def _extract(self,operation_id):
66
+ try:row=await asyncio.to_thread(self.store.claim_extract,operation_id)
67
+ except psycopg.OperationalError:raise TemporaryWork('Database connection temporarily unavailable before processing')from None
68
+ if row is None:return
69
+ try:
70
+ result=await asyncio.to_thread(self.processor,row)
71
+ await asyncio.to_thread(self.store.record_result,operation_id,str(row['lease_token']),result)
72
+ except LostLease:return
73
+ except TemporaryWork:
74
+ await self._fail(row,'model_unavailable',retryable=True);raise TemporaryWork('Processing temporarily unavailable')from None
75
+ except BaseException as error:
76
+ if isinstance(error,asyncio.CancelledError):raise
77
+ await self._fail(row,'invalid_result');raise PermanentWork('Processing requires review or recovery')from None
78
+ async def _dispatch(self,operation_id):
79
+ try:row=await asyncio.to_thread(self.store.claim_dispatch,operation_id,verified_idempotent_replay=self.idempotent_destination)
80
+ except psycopg.OperationalError:raise TemporaryWork('Database connection temporarily unavailable before dispatch')from None
81
+ if row is None:return
82
+ try:
83
+ receipt=await asyncio.to_thread(self.deliver,row,idempotency_key=str(row['id']),payload_sha256=row['approved_hash'])
84
+ await asyncio.to_thread(self.store.record_sent,operation_id,str(row['lease_token']),receipt)
85
+ except LostLease:return
86
+ except DestinationNotAttempted:
87
+ await self._fail(row,'destination_unavailable',retryable=True,ambiguous=False);raise TemporaryWork('Destination credential temporarily unavailable; no request was made')from None
88
+ except InvalidDispatch:
89
+ await self._fail(row,'destination_rejected',ambiguous=False);raise PermanentWork('Approved dispatch integrity requires review; no request was made')from None
90
+ except ExternalOutcomeUnknown:
91
+ await self._fail(row,'destination_unavailable',retryable=True,ambiguous=True)
92
+ if self.idempotent_destination:raise TemporaryWork('Destination acknowledgement unavailable; stable replay contract applies')from None
93
+ raise PermanentWork('External outcome requires reconciliation before another attempt')from None
94
+ except BaseException as error:
95
+ if isinstance(error,asyncio.CancelledError):raise
96
+ # An unexpected exception can happen after the external service
97
+ # accepted the request, including while committing its receipt.
98
+ await self._fail(row,'destination_unavailable',ambiguous=True)
99
+ raise PermanentWork('External outcome requires reconciliation')from None
100
+ async def recover_once(self):
101
+ # Native heartbeat-based stale detection, never duration-only retry of an
102
+ # actively heartbeating worker. Domain fencing protects resumed callbacks.
103
+ for owned_task in [self.extract,self.dispatch]:
104
+ stalled=await self.app.job_manager.get_stalled_jobs(task_name=owned_task.name,seconds_since_heartbeat=60)
105
+ for job in stalled:await self.app.job_manager.retry_job(job)
106
+ expired=await asyncio.to_thread(self.store.recover_expired)
107
+ repaired=await asyncio.to_thread(self.store.reconcile_notifications)
108
+ return list(dict.fromkeys([*expired,*repaired]))
109
+ async def run(self,*,concurrency=2,recovery_interval=30,**options):
110
+ if type(concurrency)is not int or not 1<=concurrency<=10 or type(recovery_interval)is not int or not 5<=recovery_interval<=300:raise ValueError('Invalid bounded worker options')
111
+ delay=1
112
+ while True:
113
+ started=time.monotonic()
114
+ try:
115
+ # Close even when the initial pool wait fails: retaining a
116
+ # partially opened pool would bypass fresh credentials on retry.
117
+ try:
118
+ # Admit the exact owned schema before queue registration,
119
+ # heartbeat/recovery writes or fetching a notification.
120
+ def admit():
121
+ with self.store.connect():pass
122
+ await asyncio.to_thread(admit)
123
+ await self.app.open_async()
124
+ async def recovery():
125
+ while True:
126
+ await self.recover_once();await asyncio.sleep(recovery_interval)
127
+ worker_options={'update_heartbeat_interval':10.0,'stalled_worker_timeout':90.0,**options}
128
+ async with asyncio.TaskGroup()as group:
129
+ task=group.create_task(recovery())
130
+ worker=group.create_task(self.app.run_worker_async(queues=[self.extract.queue,self.dispatch.queue],concurrency=concurrency,**worker_options))
131
+ try:await worker
132
+ finally:task.cancel()
133
+ finally:await self.app.close_async()
134
+ return
135
+ except Exception as error:
136
+ if not _transient_database_error(error):raise
137
+ # Domain leases, approval hashes and uncertain-delivery rules
138
+ # remain authoritative. Reopening a queue pool cannot resend an
139
+ # external action or reset an operation's attempts/lease.
140
+ logging.getLogger(__name__).warning('Queue database connection interrupted; reconnecting with fresh workload credentials')
141
+ if time.monotonic()-started>=30:delay=1
142
+ await asyncio.sleep(delay);delay=min(delay*2,30)
@@ -0,0 +1,15 @@
1
+ import {structuredContract} from './structured-contract.mjs';
2
+ const ranges={containerMemoryBytes:[1,Number.MAX_SAFE_INTEGER],memoryMb:[128,10240],functionTimeoutSeconds:[1,900],concurrency:[1,1000],maxInputBytes:[1,1000000],maxOutputTokens:[1,4096],maxPdfBytes:[1,20000000],maxPdfPages:[1,1000],retentionDays:[1,3653]};
3
+ export const LOG_RETENTION_DAYS=[1,3,5,7,14,30,60,90,120,150,180,365,400,545,731,1096,1827,2192,2557,2922,3288,3653];
4
+ export function runtimeSettings(config={}){
5
+ const result={};
6
+ if(config?.outputContract!=null)result.outputContract=structuredContract(config.outputContract);
7
+ for(const [name,[min,max]]of Object.entries(ranges)){
8
+ const value=config?.[name];if(value==null)continue;
9
+ if(!Number.isInteger(value)||value<min||value>max)throw Error(`Invalid ${name}: use an integer from ${min} to ${max}.`);
10
+ result[name]=value;
11
+ }
12
+ if(config?.logRetentionDays!=null){if(!LOG_RETENTION_DAYS.includes(config.logRetentionDays))throw Error('Choose a supported finite CloudWatch retention period.');result.logRetentionDays=config.logRetentionDays;}
13
+ if(config?.modelId!=null){if(typeof config.modelId!=="string"||config.modelId.length>150||!/^[a-z0-9][a-z0-9.-]*:[0-9]+$/.test(config.modelId))throw Error('Use a direct foundation-model ID including version.');result.modelId=config.modelId;}
14
+ return result;
15
+ }
@@ -0,0 +1,14 @@
1
+ // Explicit capabilities only: diagram labels never grant access.
2
+ export const S3_ACCESS_MODES = ['s3-read', 's3-read-write'];
3
+ export const IAM_PRINCIPAL_BINDING = 'aws-iam-principal';
4
+ export function storageAccessPlan(project, rows) {
5
+ const nodes=new Map(project.nodes.map(n=>[n.id,n]));
6
+ const resources=new Map(rows.map(r=>[r.id,r]));
7
+ const connections=project.edges.flatMap(edge=>{
8
+ const source=nodes.get(edge.source),target=resources.get(edge.target);
9
+ if(source?.data.binding!==IAM_PRINCIPAL_BINDING || source.data.provider!=='tools' || source.data.origin!=='existing' || !(target?.foundation&&S3_ACCESS_MODES.includes(edge.access) || (target?.compute||target?.summary)&&edge.access==='lambda-invoke' || target?.api&&edge.access==='api-invoke'))return [];
10
+ return [{id:edge.id,source:edge.source,target:edge.target,access:edge.access,principalVariable:`principal_${resources.get(edge.source).address}_arn`}];
11
+ });
12
+ const bindings=[...new Set(connections.map(e=>e.source))].map(id=>({id,variable:`principal_${resources.get(id).address}_arn`}));
13
+ return {connections,bindings};
14
+ }
@@ -0,0 +1,17 @@
1
+ import sources from './runtime/rag-sources.json' with {type:'json'};
2
+ export function sourceContractPlan(project,rows,retrievalPlan){
3
+ const catalogs=new Set(retrievalPlan.entries.map(e=>e.table.id)),byId=new Map(rows.map(r=>[r.id,r]));
4
+ const sources=project.nodes.filter(n=>n.data.origin==='existing'&&n.data.provider==='tools'&&n.data.binding==='normalized-source-contract');
5
+ const connections=project.edges.filter(e=>e.integration==='source-catalog-sync'&&catalogs.has(e.target)&&sources.some(n=>n.id===e.source));
6
+ return {sources:sources.filter(n=>connections.some(e=>e.source===n.id)).map(n=>byId.get(n.id)),connections};
7
+ }
8
+ export function sourceContractFiles(plan){
9
+ if(!plan.sourceContractPlan.sources.length)return {};
10
+ const files={};
11
+ const runtime=plan.ragPlan.entries[0].worker.address;
12
+ files['app-tests/connector_contract_test.py']=`import sys\nfrom pathlib import Path\nsys.path.insert(0,str(Path(__file__).resolve().parents[1]/"build/${runtime}"))\n`+sources['connector_acceptance.py'];
13
+ for(const name of ['catalog_admin.py','connector_sync.py','connector_cli.py'])files[`connectors/${name}`]=sources[name];
14
+ files['connectors/sources.json']=JSON.stringify(plan.sourceContractPlan.sources.map(s=>({sourceId:s.address,system:s.label,protocol:'normalized-snapshot-v1',vendorCompatibility:'not_verified',credential:'ATMEM_SOURCE_TOKEN environment variable; never a diagram/config secret',targetCatalogIds:plan.sourceContractPlan.connections.filter(e=>e.source===s.id).map(e=>e.target)})),null,2);
15
+ files['connectors/CONTRACT.md']='# Local source-contract qualification\n\nThese adapters consume a normalized snapshot contract from explicitly configured endpoints. They are not native Microsoft Graph or Confluence REST adapters. SharePoint/Confluence permission mapping, group expansion, inherited restrictions, API paging and tenant authentication must be independently qualified before real integration. Local fixtures prove this contract only.\n\nAn endpoint returns snapshotId, complete=true, permissionsComplete=true and documents (maximum 100). Each document supplies sourceId, sourceVersion, title, text, allowedSubjects and allowedRegions. The entire snapshot must be complete before publishing; missing entries are deletions. Unknown or incomplete permissions fail closed. Redirects are refused; HTTPS is required except with the explicit loopback fixture option. Credentials come from ATMEM_SOURCE_TOKEN.\n\nRun connector_cli.py with the exact source ID in sources.json, reviewed endpoint/catalog/account/region, a private checkpoint path and --confirm-sync. It journals pending inventory before writes and commits after reconciliation. Retry from the same checkpoint after failure; conditional revisions prevent blind overwrites. Use one designated sync runner per source. A local lock prevents overlapping runs; review a stale lock after a crash rather than blindly deleting it.\n\nSource-derived document access expires after 60 seconds unless refreshed by a complete authorized snapshot. Refresh more often than the lease, monitor failures and test timing. Expired documents are excluded before model invocation and response delivery. This favors access revocation over stale-source availability. Do not remove the lease to make outage tests pass.\n';
16
+ return files;
17
+ }