@apexops/cli 0.10.0-next.0

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 (401) hide show
  1. package/assets/capability-packs/azure-governance-discovery/source/scripts/discover.py +1189 -0
  2. package/assets/capability-packs/azure-governance-discovery/source/scripts/render_governance.py +676 -0
  3. package/assets/capability-packs/registry.v1.json +73 -0
  4. package/assets/client-projection-metadata/copilot-cli-agent-tools.json +92 -0
  5. package/assets/client-projections/github-copilot-cli/.github/agents/apex-architect.agent.md +78 -0
  6. package/assets/client-projections/github-copilot-cli/.github/agents/apex-operator.agent.md +71 -0
  7. package/assets/client-projections/github-copilot-cli/.github/agents/apex-planner.agent.md +79 -0
  8. package/assets/client-projections/github-copilot-cli/.github/agents/apex-requirements.agent.md +69 -0
  9. package/assets/client-projections/github-copilot-cli/.github/agents/apex.agent.md +52 -0
  10. package/assets/client-projections/github-copilot-cli/.github/copilot-instructions.md +13 -0
  11. package/assets/client-projections/github-copilot-cli/.github/mcp.json +54 -0
  12. package/assets/client-projections/github-copilot-cli/.github/skills/apex-architecture/SKILL.md +36 -0
  13. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/SKILL.md +65 -0
  14. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
  15. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
  16. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
  17. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
  18. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
  19. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
  20. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
  21. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
  22. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/requirements.md +42 -0
  23. package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
  24. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/SKILL.md +52 -0
  25. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
  26. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
  27. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
  28. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
  29. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
  30. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
  31. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
  32. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
  33. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
  34. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/SKILL.md +58 -0
  35. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
  36. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
  37. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/SKILL.md +36 -0
  38. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
  39. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
  40. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
  41. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
  42. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
  43. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
  44. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/SKILL.md +59 -0
  45. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
  46. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
  47. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
  48. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
  49. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
  50. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/naming.md +47 -0
  51. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
  52. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
  53. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
  54. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
  55. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/SKILL.md +50 -0
  56. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
  57. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
  58. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
  59. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
  60. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
  61. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/SKILL.md +52 -0
  62. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
  63. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
  64. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/SKILL.md +58 -0
  65. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
  66. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
  67. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/SKILL.md +52 -0
  68. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
  69. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
  70. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/SKILL.md +53 -0
  71. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
  72. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
  73. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/SKILL.md +45 -0
  74. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
  75. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
  76. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/SKILL.md +54 -0
  77. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
  78. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
  79. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/SKILL.md +35 -0
  80. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
  81. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
  82. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
  83. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/SKILL.md +49 -0
  84. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
  85. package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
  86. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
  87. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
  88. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
  89. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
  90. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
  91. package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
  92. package/assets/client-projections/github-copilot-cli/.github/skills/apex-codegen/SKILL.md +32 -0
  93. package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
  94. package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
  95. package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
  96. package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
  97. package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
  98. package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/SKILL.md +44 -0
  99. package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/references/styling.md +33 -0
  100. package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/references/syntax.md +99 -0
  101. package/assets/client-projections/github-copilot-cli/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
  102. package/assets/client-projections/github-copilot-cli/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
  103. package/assets/client-projections/github-copilot-cli/.github/skills/apex-operations/SKILL.md +34 -0
  104. package/assets/client-projections/github-copilot-cli/.github/skills/apex-planning/SKILL.md +36 -0
  105. package/assets/client-projections/github-copilot-cli/.github/skills/apex-requirements/SKILL.md +43 -0
  106. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/SKILL.md +47 -0
  107. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
  108. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
  109. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
  110. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
  111. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
  112. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
  113. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
  114. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
  115. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
  116. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
  117. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/SKILL.md +45 -0
  118. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
  119. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
  120. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
  121. package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/test-design.md +13 -0
  122. package/assets/client-projections/github-copilot-cli/.github/skills/apex-workflow/SKILL.md +37 -0
  123. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-architect.agent.md +87 -0
  124. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-codegen.agent.md +54 -0
  125. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-operator.agent.md +75 -0
  126. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-planner.agent.md +89 -0
  127. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-requirements.agent.md +78 -0
  128. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-reviewer.agent.md +45 -0
  129. package/assets/client-projections/github-copilot-vscode/.github/agents/apex-validator.agent.md +50 -0
  130. package/assets/client-projections/github-copilot-vscode/.github/agents/apex.agent.md +71 -0
  131. package/assets/client-projections/github-copilot-vscode/.github/copilot-instructions.md +13 -0
  132. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-architecture/SKILL.md +36 -0
  133. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/SKILL.md +65 -0
  134. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
  135. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
  136. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
  137. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
  138. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
  139. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
  140. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
  141. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
  142. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/requirements.md +42 -0
  143. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
  144. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/SKILL.md +52 -0
  145. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
  146. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
  147. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
  148. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
  149. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
  150. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
  151. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
  152. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
  153. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
  154. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/SKILL.md +58 -0
  155. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
  156. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
  157. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/SKILL.md +36 -0
  158. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
  159. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
  160. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
  161. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
  162. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
  163. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
  164. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/SKILL.md +59 -0
  165. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
  166. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
  167. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
  168. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
  169. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
  170. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/naming.md +47 -0
  171. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
  172. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
  173. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
  174. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
  175. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/SKILL.md +50 -0
  176. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
  177. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
  178. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
  179. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
  180. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
  181. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/SKILL.md +52 -0
  182. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
  183. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
  184. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/SKILL.md +58 -0
  185. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
  186. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
  187. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/SKILL.md +52 -0
  188. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
  189. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
  190. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/SKILL.md +53 -0
  191. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
  192. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
  193. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/SKILL.md +45 -0
  194. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
  195. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
  196. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/SKILL.md +54 -0
  197. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
  198. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
  199. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/SKILL.md +35 -0
  200. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
  201. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
  202. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
  203. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/SKILL.md +49 -0
  204. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
  205. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
  206. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
  207. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
  208. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
  209. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
  210. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
  211. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
  212. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-codegen/SKILL.md +32 -0
  213. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
  214. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
  215. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
  216. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
  217. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
  218. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/SKILL.md +44 -0
  219. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/references/styling.md +33 -0
  220. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/references/syntax.md +99 -0
  221. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
  222. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
  223. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-operations/SKILL.md +34 -0
  224. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-planning/SKILL.md +36 -0
  225. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-requirements/SKILL.md +43 -0
  226. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/SKILL.md +47 -0
  227. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
  228. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
  229. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
  230. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
  231. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
  232. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
  233. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
  234. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
  235. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
  236. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
  237. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/SKILL.md +45 -0
  238. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
  239. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
  240. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
  241. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/test-design.md +13 -0
  242. package/assets/client-projections/github-copilot-vscode/.github/skills/apex-workflow/SKILL.md +37 -0
  243. package/assets/client-projections/github-copilot-vscode/.vscode/mcp.json +21 -0
  244. package/assets/config/capability-packs.v1.json +43 -0
  245. package/assets/config/defaults.v1.json +98 -0
  246. package/assets/config/improvement-policy.v1.json +37 -0
  247. package/assets/config/quality-scorecard.v1.json +105 -0
  248. package/assets/config/recipe-packs.v1.json +29 -0
  249. package/assets/config/runtime-bundle.v1.json +84 -0
  250. package/assets/config/toolchain.v1.json +134 -0
  251. package/assets/config/workflow.v1.json +876 -0
  252. package/assets/customizations/.github/agents/apex-architect.agent.md +80 -0
  253. package/assets/customizations/.github/agents/apex-codegen.agent.md +51 -0
  254. package/assets/customizations/.github/agents/apex-operator.agent.md +68 -0
  255. package/assets/customizations/.github/agents/apex-planner.agent.md +82 -0
  256. package/assets/customizations/.github/agents/apex-requirements.agent.md +71 -0
  257. package/assets/customizations/.github/agents/apex-reviewer.agent.md +42 -0
  258. package/assets/customizations/.github/agents/apex-validator.agent.md +47 -0
  259. package/assets/customizations/.github/agents/apex.agent.md +64 -0
  260. package/assets/customizations/.github/copilot-instructions.md +13 -0
  261. package/assets/customizations/.github/mcp.json +54 -0
  262. package/assets/customizations/.github/skills/apex-architecture/SKILL.md +36 -0
  263. package/assets/customizations/.github/skills/apex-artifacts/SKILL.md +65 -0
  264. package/assets/customizations/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
  265. package/assets/customizations/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
  266. package/assets/customizations/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
  267. package/assets/customizations/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
  268. package/assets/customizations/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
  269. package/assets/customizations/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
  270. package/assets/customizations/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
  271. package/assets/customizations/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
  272. package/assets/customizations/.github/skills/apex-artifacts/templates/requirements.md +42 -0
  273. package/assets/customizations/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
  274. package/assets/customizations/.github/skills/apex-azure-adr/SKILL.md +52 -0
  275. package/assets/customizations/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
  276. package/assets/customizations/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
  277. package/assets/customizations/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
  278. package/assets/customizations/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
  279. package/assets/customizations/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
  280. package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
  281. package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
  282. package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
  283. package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
  284. package/assets/customizations/.github/skills/apex-azure-compliance/SKILL.md +58 -0
  285. package/assets/customizations/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
  286. package/assets/customizations/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
  287. package/assets/customizations/.github/skills/apex-azure-compute/SKILL.md +36 -0
  288. package/assets/customizations/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
  289. package/assets/customizations/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
  290. package/assets/customizations/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
  291. package/assets/customizations/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
  292. package/assets/customizations/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
  293. package/assets/customizations/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
  294. package/assets/customizations/.github/skills/apex-azure-defaults/SKILL.md +59 -0
  295. package/assets/customizations/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
  296. package/assets/customizations/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
  297. package/assets/customizations/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
  298. package/assets/customizations/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
  299. package/assets/customizations/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
  300. package/assets/customizations/.github/skills/apex-azure-defaults/references/naming.md +47 -0
  301. package/assets/customizations/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
  302. package/assets/customizations/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
  303. package/assets/customizations/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
  304. package/assets/customizations/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
  305. package/assets/customizations/.github/skills/apex-azure-deploy/SKILL.md +50 -0
  306. package/assets/customizations/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
  307. package/assets/customizations/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
  308. package/assets/customizations/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
  309. package/assets/customizations/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
  310. package/assets/customizations/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
  311. package/assets/customizations/.github/skills/apex-azure-governance/SKILL.md +52 -0
  312. package/assets/customizations/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
  313. package/assets/customizations/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
  314. package/assets/customizations/.github/skills/apex-azure-kusto/SKILL.md +58 -0
  315. package/assets/customizations/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
  316. package/assets/customizations/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
  317. package/assets/customizations/.github/skills/apex-azure-prepare/SKILL.md +52 -0
  318. package/assets/customizations/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
  319. package/assets/customizations/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
  320. package/assets/customizations/.github/skills/apex-azure-quotas/SKILL.md +53 -0
  321. package/assets/customizations/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
  322. package/assets/customizations/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
  323. package/assets/customizations/.github/skills/apex-azure-rbac/SKILL.md +45 -0
  324. package/assets/customizations/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
  325. package/assets/customizations/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
  326. package/assets/customizations/.github/skills/apex-azure-resources/SKILL.md +54 -0
  327. package/assets/customizations/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
  328. package/assets/customizations/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
  329. package/assets/customizations/.github/skills/apex-azure-storage/SKILL.md +35 -0
  330. package/assets/customizations/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
  331. package/assets/customizations/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
  332. package/assets/customizations/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
  333. package/assets/customizations/.github/skills/apex-azure-validate/SKILL.md +49 -0
  334. package/assets/customizations/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
  335. package/assets/customizations/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
  336. package/assets/customizations/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
  337. package/assets/customizations/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
  338. package/assets/customizations/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
  339. package/assets/customizations/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
  340. package/assets/customizations/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
  341. package/assets/customizations/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
  342. package/assets/customizations/.github/skills/apex-codegen/SKILL.md +32 -0
  343. package/assets/customizations/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
  344. package/assets/customizations/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
  345. package/assets/customizations/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
  346. package/assets/customizations/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
  347. package/assets/customizations/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
  348. package/assets/customizations/.github/skills/apex-mermaid/SKILL.md +44 -0
  349. package/assets/customizations/.github/skills/apex-mermaid/references/styling.md +33 -0
  350. package/assets/customizations/.github/skills/apex-mermaid/references/syntax.md +99 -0
  351. package/assets/customizations/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
  352. package/assets/customizations/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
  353. package/assets/customizations/.github/skills/apex-operations/SKILL.md +34 -0
  354. package/assets/customizations/.github/skills/apex-planning/SKILL.md +36 -0
  355. package/assets/customizations/.github/skills/apex-requirements/SKILL.md +43 -0
  356. package/assets/customizations/.github/skills/apex-terraform-import/SKILL.md +47 -0
  357. package/assets/customizations/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
  358. package/assets/customizations/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
  359. package/assets/customizations/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
  360. package/assets/customizations/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
  361. package/assets/customizations/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
  362. package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
  363. package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
  364. package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
  365. package/assets/customizations/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
  366. package/assets/customizations/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
  367. package/assets/customizations/.github/skills/apex-terraform-test/SKILL.md +45 -0
  368. package/assets/customizations/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
  369. package/assets/customizations/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
  370. package/assets/customizations/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
  371. package/assets/customizations/.github/skills/apex-terraform-test/references/test-design.md +13 -0
  372. package/assets/customizations/.github/skills/apex-workflow/SKILL.md +37 -0
  373. package/assets/customizations/.vscode/mcp.json +21 -0
  374. package/assets/customizations/README.md +22 -0
  375. package/assets/customizations/manifest.json +251 -0
  376. package/assets/manifest.json +5027 -0
  377. package/dist/assets.d.ts +69 -0
  378. package/dist/assets.js +336 -0
  379. package/dist/cli.d.ts +4 -0
  380. package/dist/cli.js +643 -0
  381. package/dist/dependency-revision.d.ts +5 -0
  382. package/dist/dependency-revision.js +21 -0
  383. package/dist/errors.d.ts +19 -0
  384. package/dist/errors.js +34 -0
  385. package/dist/index.d.ts +7 -0
  386. package/dist/index.js +7 -0
  387. package/dist/mcp.d.ts +5 -0
  388. package/dist/mcp.js +210 -0
  389. package/dist/provider-runtime.d.ts +27 -0
  390. package/dist/provider-runtime.js +229 -0
  391. package/dist/provider-transfer.d.ts +52 -0
  392. package/dist/provider-transfer.js +533 -0
  393. package/dist/service.d.ts +806 -0
  394. package/dist/service.js +3817 -0
  395. package/dist/state-transfer.d.ts +51 -0
  396. package/dist/state-transfer.js +559 -0
  397. package/dist/version.d.ts +2 -0
  398. package/dist/version.js +2 -0
  399. package/dist/workflow-validators.d.ts +80 -0
  400. package/dist/workflow-validators.js +843 -0
  401. package/package.json +57 -0
@@ -0,0 +1,51 @@
1
+ import { type EnvelopeBindings } from "@apexops/capabilities";
2
+ export declare const STATE_TRANSFER_KIND = "apex-repository-state";
3
+ export declare const STATE_TRANSFER_MAX_BUNDLE_BYTES: number;
4
+ export declare const STATE_TRANSFER_MAX_FILE_BYTES: number;
5
+ export interface StateTransferFile {
6
+ readonly path: string;
7
+ readonly bytes: number;
8
+ readonly sha256: string;
9
+ readonly content: string;
10
+ }
11
+ export interface StateTransferBindings extends EnvelopeBindings {
12
+ readonly claimHash: string;
13
+ readonly projectId: string;
14
+ readonly runId: string;
15
+ readonly ownerEpoch: number;
16
+ readonly recipient: string;
17
+ readonly repository: string;
18
+ readonly branch: string;
19
+ readonly commit: string;
20
+ readonly workflowId: string;
21
+ readonly journalHead: string;
22
+ readonly claimExpiresAt: string;
23
+ readonly approvalEnvironment?: string;
24
+ }
25
+ export interface StateTransferBundle {
26
+ readonly implementation: "apex-state-transfer";
27
+ readonly version: 1;
28
+ readonly bindings: StateTransferBindings;
29
+ readonly files: readonly StateTransferFile[];
30
+ }
31
+ export interface StateTransferExportOptions {
32
+ readonly claimHash: string;
33
+ readonly recipient: string;
34
+ readonly ttlMs: number;
35
+ }
36
+ export declare function createStateTransferBundle(root: string, options: StateTransferExportOptions, now?: Date): Promise<StateTransferBundle>;
37
+ export declare function exportStateTransfer(root: string, outputPath: string, options: StateTransferExportOptions, dependencies?: {
38
+ readonly now?: () => Date;
39
+ }): Promise<{
40
+ path: string;
41
+ sha256: string;
42
+ files: number;
43
+ expiresAt: string;
44
+ }>;
45
+ export declare function importStateTransfer(root: string, envelopeValue: unknown, recipient: string, now?: () => Date): Promise<{
46
+ projectId: string;
47
+ runId: string;
48
+ files: number;
49
+ claimHash: string;
50
+ }>;
51
+ //# sourceMappingURL=state-transfer.d.ts.map
@@ -0,0 +1,559 @@
1
+ import { lstat, readFile, readdir } from "node:fs/promises";
2
+ import { isAbsolute, join, posix, relative, resolve, sep } from "node:path";
3
+ import { BoundEnvelopeTransport } from "@apexops/capabilities";
4
+ import { SECRET_FIELD_PATTERN, SECRET_VALUE_PATTERN } from "@apexops/contracts";
5
+ import { EventJournal, atomicWriteBytes, canonicalJsonBytes, sha256Bytes, sha256Json, } from "@apexops/kernel";
6
+ export const STATE_TRANSFER_KIND = "apex-repository-state";
7
+ export const STATE_TRANSFER_MAX_BUNDLE_BYTES = 16 * 1024 * 1024;
8
+ export const STATE_TRANSFER_MAX_FILE_BYTES = 4 * 1024 * 1024;
9
+ const HASH_PATTERN = /^[0-9a-f]{64}$/;
10
+ const IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/;
11
+ const SAFE_POLICY_ASSERTIONS = new Map([
12
+ ["runtime/defaults.v1.json/securityInvariants/hardcodedSecretsAllowed", false],
13
+ ["runtime/defaults.v1.json/securityInvariants/secretValuesInGitAllowed", false],
14
+ ["runtime/defaults.v1.json/evidence/genericSecretScanRequired", true],
15
+ ["runtime/defaults.v1.json/telemetry/authorizationEvidenceSeparable", true],
16
+ ]);
17
+ function safeRelativePath(path) {
18
+ return (path.length > 0 &&
19
+ !isAbsolute(path) &&
20
+ !path.includes("\\") &&
21
+ path !== "." &&
22
+ path !== ".." &&
23
+ !path.startsWith("../") &&
24
+ posix.normalize(path) === path);
25
+ }
26
+ function prohibitedStatePath(path) {
27
+ return /(?:^|\/)(?:credentials?(?:\.json)?|terraform\.tfstate(?:\.[^/]*)?|[^/]+\.tfplan(?:\.enc)?|state-plans?)(?:\/|$)/i.test(path);
28
+ }
29
+ function requireIdentifier(value, label) {
30
+ if (typeof value !== "string" || !IDENTIFIER_PATTERN.test(value))
31
+ throw new Error(`${label} is invalid`);
32
+ return value;
33
+ }
34
+ function requireHash(value, label) {
35
+ if (typeof value !== "string" || !HASH_PATTERN.test(value))
36
+ throw new Error(`${label} must be a SHA-256 hash`);
37
+ return value;
38
+ }
39
+ function parseJson(bytes, path) {
40
+ try {
41
+ return JSON.parse(bytes.toString("utf8"));
42
+ }
43
+ catch {
44
+ throw new Error(`State transfer file is not valid JSON: ${path}`);
45
+ }
46
+ }
47
+ function secretPaths(value, path, findings) {
48
+ if (typeof value === "string") {
49
+ if (SECRET_VALUE_PATTERN.test(value))
50
+ findings.push(path);
51
+ return;
52
+ }
53
+ if (Array.isArray(value)) {
54
+ value.forEach((entry, index) => secretPaths(entry, `${path}/${index}`, findings));
55
+ return;
56
+ }
57
+ if (value === null || typeof value !== "object")
58
+ return;
59
+ for (const [key, entry] of Object.entries(value)) {
60
+ const entryPath = `${path}/${key.replaceAll("~", "~0").replaceAll("/", "~1")}`;
61
+ if (SECRET_FIELD_PATTERN.test(key) &&
62
+ !(SAFE_POLICY_ASSERTIONS.has(entryPath) && SAFE_POLICY_ASSERTIONS.get(entryPath) === entry)) {
63
+ findings.push(entryPath);
64
+ }
65
+ secretPaths(entry, entryPath, findings);
66
+ }
67
+ }
68
+ function validateJsonSafety(bytes, path) {
69
+ const value = parseJson(bytes, path);
70
+ const findings = [];
71
+ secretPaths(value, path, findings);
72
+ if (findings.length > 0) {
73
+ throw new Error(`State transfer contains secret-bearing JSON paths: ${[...new Set(findings)].sort().join(", ")}`);
74
+ }
75
+ return value;
76
+ }
77
+ async function readRegular(path, label) {
78
+ const info = await lstat(path);
79
+ if (info.isSymbolicLink() || !info.isFile())
80
+ throw new Error(`${label} is not a regular file: ${path}`);
81
+ if (info.size > STATE_TRANSFER_MAX_FILE_BYTES)
82
+ throw new Error(`${label} exceeds the 4 MiB file limit: ${path}`);
83
+ return await readFile(path);
84
+ }
85
+ async function readOptionalRegular(path, label) {
86
+ try {
87
+ return await readRegular(path, label);
88
+ }
89
+ catch (error) {
90
+ if (error.code === "ENOENT")
91
+ return undefined;
92
+ throw error;
93
+ }
94
+ }
95
+ async function walkRegularFiles(root, directory = root) {
96
+ const files = [];
97
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
98
+ const path = join(directory, entry.name);
99
+ if (entry.isSymbolicLink())
100
+ throw new Error(`State transfer source contains a symlink: ${path}`);
101
+ if (entry.isDirectory())
102
+ files.push(...(await walkRegularFiles(root, path)));
103
+ else if (entry.isFile())
104
+ files.push(relative(root, path).split(sep).join("/"));
105
+ else
106
+ throw new Error(`State transfer source is not a regular file: ${path}`);
107
+ }
108
+ return files.sort();
109
+ }
110
+ function referencedHashes(bytes) {
111
+ return [...new Set(bytes.toString("utf8").match(/[0-9a-f]{64}/g) ?? [])].sort();
112
+ }
113
+ async function collectObjectClosure(apexRoot, seedFiles) {
114
+ const pending = [...new Set(seedFiles.flatMap(referencedHashes))].sort();
115
+ const objects = new Map();
116
+ while (pending.length > 0) {
117
+ const hash = pending.shift();
118
+ if (objects.has(hash))
119
+ continue;
120
+ const objectPath = join(apexRoot, "objects", "sha256", hash.slice(0, 2), hash.slice(2));
121
+ const bytes = await readOptionalRegular(objectPath, "State transfer object");
122
+ if (bytes === undefined)
123
+ continue;
124
+ if (sha256Bytes(bytes) !== hash)
125
+ throw new Error(`State transfer object hash mismatch: ${hash}`);
126
+ validateJsonSafety(bytes, `objects/sha256/${hash.slice(0, 2)}/${hash.slice(2)}`);
127
+ objects.set(hash, bytes);
128
+ for (const reference of referencedHashes(bytes))
129
+ if (!objects.has(reference))
130
+ pending.push(reference);
131
+ pending.sort();
132
+ }
133
+ return objects;
134
+ }
135
+ function bundleFile(path, bytes) {
136
+ if (!safeRelativePath(path))
137
+ throw new Error(`Unsafe state transfer path: ${path}`);
138
+ if (prohibitedStatePath(path))
139
+ throw new Error(`State transfer path is prohibited: ${path}`);
140
+ if (path !== ".gitignore")
141
+ validateJsonSafety(bytes, path);
142
+ return { path, bytes: bytes.byteLength, sha256: sha256Bytes(bytes), content: bytes.toString("base64") };
143
+ }
144
+ async function currentState(root, claimHash, recipient, now) {
145
+ requireHash(claimHash, "Transfer claim hash");
146
+ if (recipient.trim().length === 0)
147
+ throw new Error("State transfer recipient is required");
148
+ const apexRoot = resolve(root, ".apex");
149
+ const selection = parseJson(await readRegular(join(apexRoot, "config.json"), "APEX selection"), "config.json");
150
+ const projectId = requireIdentifier(selection.projectId, "Selected project");
151
+ const runId = requireIdentifier(selection.runId, "Selected run");
152
+ const runRoot = join(apexRoot, "projects", projectId, "runs", runId);
153
+ const run = parseJson(await readRegular(join(runRoot, "run.json"), "Selected run"), "run.json");
154
+ if (run.projectId !== projectId || run.runId !== runId || !Number.isInteger(run.ownerEpoch) || run.ownerEpoch < 1) {
155
+ throw new Error("Selected run does not match APEX config");
156
+ }
157
+ const claimPath = join(runRoot, "transfers", `${claimHash}.json`);
158
+ const claimBytes = await readRegular(claimPath, "Transfer claim");
159
+ const claim = validateJsonSafety(claimBytes, relative(apexRoot, claimPath).split(sep).join("/"));
160
+ if (sha256Json(claim) !== claimHash)
161
+ throw new Error("Transfer claim hash/path mismatch");
162
+ if (claim.projectId !== projectId || claim.runId !== runId)
163
+ throw new Error("Transfer claim project/run mismatch");
164
+ if (claim.recipient !== recipient)
165
+ throw new Error("Transfer claim recipient mismatch");
166
+ if (claim.nextEpoch !== run.ownerEpoch + 1)
167
+ throw new Error("Transfer claim owner epoch is stale");
168
+ if (!Number.isFinite(Date.parse(claim.expiresAt)) || Date.parse(claim.expiresAt) <= now.getTime()) {
169
+ throw new Error("Transfer claim has expired");
170
+ }
171
+ const journal = new EventJournal(join(runRoot, "journal"));
172
+ const events = await journal.replay();
173
+ if (!events.some((event) => event.type === "transfer-requested" &&
174
+ event.ownerEpoch === run.ownerEpoch &&
175
+ event.payload.claimHash === claimHash)) {
176
+ throw new Error("Transfer claim is not recorded at the current owner epoch");
177
+ }
178
+ const journalHead = requireHash(await journal.head(), "State transfer journal head");
179
+ return { apexRoot, selection: { projectId, runId }, run, claim, claimPath, journalHead };
180
+ }
181
+ export async function createStateTransferBundle(root, options, now = new Date()) {
182
+ if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0)
183
+ throw new Error("State transfer TTL must be positive");
184
+ const state = await currentState(root, options.claimHash, options.recipient, now);
185
+ if (now.getTime() + options.ttlMs > Date.parse(state.claim.expiresAt)) {
186
+ throw new Error("State transfer envelope cannot outlive its writer-transfer claim");
187
+ }
188
+ const runRoot = join(state.apexRoot, "projects", state.selection.projectId, "runs", state.selection.runId);
189
+ const paths = new Set([
190
+ "config.json",
191
+ "apex.lock.json",
192
+ `projects/${state.selection.projectId}/project.json`,
193
+ ]);
194
+ if ((await readOptionalRegular(join(state.apexRoot, ".gitignore"), "APEX gitignore")) !== undefined) {
195
+ paths.add(".gitignore");
196
+ }
197
+ try {
198
+ for (const entry of await readdir(join(state.apexRoot, "runtime"), { withFileTypes: true })) {
199
+ if (entry.isSymbolicLink())
200
+ throw new Error(`State transfer runtime contains a symlink: ${entry.name}`);
201
+ if (entry.isFile() && entry.name.endsWith(".json"))
202
+ paths.add(`runtime/${entry.name}`);
203
+ }
204
+ }
205
+ catch (error) {
206
+ if (error.code !== "ENOENT")
207
+ throw error;
208
+ }
209
+ for (const path of await walkRegularFiles(runRoot)) {
210
+ paths.add(`projects/${state.selection.projectId}/runs/${state.selection.runId}/${path}`);
211
+ }
212
+ const sourceFiles = [];
213
+ for (const path of [...paths].sort()) {
214
+ sourceFiles.push({
215
+ path,
216
+ bytes: await readRegular(join(state.apexRoot, ...path.split("/")), "State transfer file"),
217
+ });
218
+ }
219
+ const runPrefix = `projects/${state.selection.projectId}/runs/${state.selection.runId}/`;
220
+ const objects = await collectObjectClosure(state.apexRoot, sourceFiles.filter(({ path }) => path.startsWith(runPrefix)).map(({ bytes }) => bytes));
221
+ for (const [hash, bytes] of objects) {
222
+ sourceFiles.push({ path: `objects/sha256/${hash.slice(0, 2)}/${hash.slice(2)}`, bytes });
223
+ }
224
+ const files = sourceFiles
225
+ .sort((left, right) => left.path.localeCompare(right.path))
226
+ .map(({ path, bytes }) => bundleFile(path, bytes));
227
+ const bindings = {
228
+ claimHash: options.claimHash,
229
+ projectId: state.selection.projectId,
230
+ runId: state.selection.runId,
231
+ ownerEpoch: state.run.ownerEpoch,
232
+ recipient: options.recipient,
233
+ repository: state.claim.repository,
234
+ branch: state.claim.branch,
235
+ commit: state.claim.commit,
236
+ workflowId: state.claim.workflowId,
237
+ journalHead: state.journalHead,
238
+ claimExpiresAt: state.claim.expiresAt,
239
+ ...(state.claim.approvalEnvironment === undefined ? {} : { approvalEnvironment: state.claim.approvalEnvironment }),
240
+ };
241
+ const bundle = { implementation: "apex-state-transfer", version: 1, bindings, files };
242
+ if (canonicalJsonBytes(bundle).byteLength > STATE_TRANSFER_MAX_BUNDLE_BYTES) {
243
+ throw new Error("State transfer plaintext bundle exceeds the 16 MiB limit");
244
+ }
245
+ return bundle;
246
+ }
247
+ export async function exportStateTransfer(root, outputPath, options, dependencies = {}) {
248
+ if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0)
249
+ throw new Error("State transfer TTL must be positive");
250
+ const now = dependencies.now?.() ?? new Date();
251
+ const bundle = await createStateTransferBundle(root, options, now);
252
+ const envelope = new BoundEnvelopeTransport(() => now).create(canonicalJsonBytes(bundle), {
253
+ kind: STATE_TRANSFER_KIND,
254
+ recipient: options.recipient,
255
+ ttlMs: options.ttlMs,
256
+ bindings: bundle.bindings,
257
+ });
258
+ const bytes = canonicalJsonBytes(envelope);
259
+ await atomicWriteBytes(resolve(outputPath), bytes);
260
+ return {
261
+ path: resolve(outputPath),
262
+ sha256: sha256Bytes(bytes),
263
+ files: bundle.files.length,
264
+ expiresAt: envelope.metadata.expiresAt,
265
+ };
266
+ }
267
+ function allowedBundlePath(path, bindings) {
268
+ if (prohibitedStatePath(path))
269
+ return false;
270
+ const runPrefix = `projects/${bindings.projectId}/runs/${bindings.runId}/`;
271
+ return (path === ".gitignore" ||
272
+ path === "config.json" ||
273
+ path === "apex.lock.json" ||
274
+ /^runtime\/[^/]+\.json$/.test(path) ||
275
+ path === `projects/${bindings.projectId}/project.json` ||
276
+ path.startsWith(runPrefix) ||
277
+ /^objects\/sha256\/[0-9a-f]{2}\/[0-9a-f]{62}$/.test(path));
278
+ }
279
+ function decodeEntry(entry, bindings) {
280
+ if (!safeRelativePath(entry.path) || !allowedBundlePath(entry.path, bindings)) {
281
+ throw new Error(`State transfer path is outside the allowlist: ${entry.path}`);
282
+ }
283
+ if (!Number.isInteger(entry.bytes) || entry.bytes < 0 || entry.bytes > STATE_TRANSFER_MAX_FILE_BYTES) {
284
+ throw new Error(`State transfer file size is invalid: ${entry.path}`);
285
+ }
286
+ if (!HASH_PATTERN.test(entry.sha256) ||
287
+ !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(entry.content)) {
288
+ throw new Error(`State transfer file encoding is invalid: ${entry.path}`);
289
+ }
290
+ const bytes = Buffer.from(entry.content, "base64");
291
+ if (bytes.toString("base64") !== entry.content ||
292
+ bytes.byteLength !== entry.bytes ||
293
+ sha256Bytes(bytes) !== entry.sha256) {
294
+ throw new Error(`State transfer file integrity check failed: ${entry.path}`);
295
+ }
296
+ const objectMatch = /^objects\/sha256\/([0-9a-f]{2})\/([0-9a-f]{62})$/.exec(entry.path);
297
+ if (objectMatch !== null && `${objectMatch[1]}${objectMatch[2]}` !== entry.sha256) {
298
+ throw new Error(`State transfer object path does not match its content: ${entry.path}`);
299
+ }
300
+ if (entry.path !== ".gitignore")
301
+ validateJsonSafety(bytes, entry.path);
302
+ return bytes;
303
+ }
304
+ function validateJournal(entries, bindings) {
305
+ const prefix = `projects/${bindings.projectId}/runs/${bindings.runId}/journal/`;
306
+ const journal = [...entries]
307
+ .filter(([path]) => path.startsWith(prefix))
308
+ .sort(([left], [right]) => left.localeCompare(right));
309
+ let previousHash = null;
310
+ for (const [index, [path, bytes]] of journal.entries()) {
311
+ const name = path.slice(prefix.length);
312
+ const event = parseJson(bytes, path);
313
+ const expectedSequence = index + 1;
314
+ if (name !== `${String(expectedSequence).padStart(16, "0")}.json` || event.sequence !== expectedSequence) {
315
+ throw new Error(`State transfer journal sequence is invalid: ${path}`);
316
+ }
317
+ if (event.projectId !== bindings.projectId ||
318
+ event.runId !== bindings.runId ||
319
+ event.previousHash !== previousHash) {
320
+ throw new Error(`State transfer journal chain is invalid: ${path}`);
321
+ }
322
+ if (sha256Json(event.payload) !== event.payloadHash) {
323
+ throw new Error(`State transfer journal payload is invalid: ${path}`);
324
+ }
325
+ const { hash, ...withoutHash } = event;
326
+ if (typeof hash !== "string" || sha256Json(withoutHash) !== hash) {
327
+ throw new Error(`State transfer journal hash is invalid: ${path}`);
328
+ }
329
+ previousHash = hash;
330
+ }
331
+ if (previousHash !== bindings.journalHead)
332
+ throw new Error("State transfer journal head does not match bindings");
333
+ }
334
+ function validateObjectClosure(entries, bindings) {
335
+ const objectPrefix = "objects/sha256/";
336
+ const objects = new Map();
337
+ for (const [path, bytes] of entries) {
338
+ if (path.startsWith(objectPrefix))
339
+ objects.set(path.slice(objectPrefix.length).replace("/", ""), bytes);
340
+ }
341
+ const runPrefix = `projects/${bindings.projectId}/runs/${bindings.runId}/`;
342
+ const pending = [
343
+ ...new Set([...entries].filter(([path]) => path.startsWith(runPrefix)).flatMap(([, bytes]) => referencedHashes(bytes))),
344
+ ];
345
+ const referenced = new Set();
346
+ while (pending.length > 0) {
347
+ const hash = pending.shift();
348
+ const bytes = objects.get(hash);
349
+ if (bytes === undefined || referenced.has(hash))
350
+ continue;
351
+ referenced.add(hash);
352
+ pending.push(...referencedHashes(bytes));
353
+ }
354
+ const unreferenced = [...objects.keys()].filter((hash) => !referenced.has(hash));
355
+ if (unreferenced.length > 0)
356
+ throw new Error("State transfer contains unreferenced objects");
357
+ }
358
+ function requireBindings(value) {
359
+ if (value === null || typeof value !== "object" || Array.isArray(value))
360
+ throw new Error("State transfer bindings are invalid");
361
+ const bindings = value;
362
+ requireHash(bindings.claimHash, "State transfer claim hash");
363
+ requireHash(bindings.journalHead, "State transfer journal head");
364
+ requireIdentifier(bindings.projectId, "State transfer project");
365
+ requireIdentifier(bindings.runId, "State transfer run");
366
+ if (typeof bindings.claimExpiresAt !== "string" || !Number.isFinite(Date.parse(bindings.claimExpiresAt))) {
367
+ throw new Error("State transfer claim expiry is invalid");
368
+ }
369
+ if (bindings.approvalEnvironment !== undefined &&
370
+ (typeof bindings.approvalEnvironment !== "string" || bindings.approvalEnvironment.trim().length === 0)) {
371
+ throw new Error("State transfer approval environment is invalid");
372
+ }
373
+ if (!Number.isInteger(bindings.ownerEpoch) || (bindings.ownerEpoch ?? 0) < 1)
374
+ throw new Error("State transfer owner epoch is invalid");
375
+ for (const key of ["recipient", "repository", "branch", "commit", "workflowId"]) {
376
+ if (typeof bindings[key] !== "string" || bindings[key].trim().length === 0) {
377
+ throw new Error(`State transfer ${key} is required`);
378
+ }
379
+ }
380
+ const expected = [
381
+ ...(bindings.approvalEnvironment === undefined ? [] : ["approvalEnvironment"]),
382
+ "branch",
383
+ "claimExpiresAt",
384
+ "claimHash",
385
+ "commit",
386
+ "journalHead",
387
+ "ownerEpoch",
388
+ "projectId",
389
+ "recipient",
390
+ "repository",
391
+ "runId",
392
+ "workflowId",
393
+ ];
394
+ if (Object.keys(bindings).sort().join("\0") !== expected.join("\0"))
395
+ throw new Error("State transfer bindings shape is invalid");
396
+ return bindings;
397
+ }
398
+ function validateBundle(value, envelopeBindings) {
399
+ if (value === null || typeof value !== "object" || Array.isArray(value))
400
+ throw new Error("State transfer bundle is invalid");
401
+ const bundle = value;
402
+ if (bundle.implementation !== "apex-state-transfer" || bundle.version !== 1 || !Array.isArray(bundle.files)) {
403
+ throw new Error("Unsupported state transfer bundle");
404
+ }
405
+ const bindings = requireBindings(bundle.bindings);
406
+ if (sha256Json(bindings) !== sha256Json(envelopeBindings)) {
407
+ throw new Error("State transfer envelope bindings do not match the bundle");
408
+ }
409
+ const seen = new Set();
410
+ const entries = bundle.files.map((entry) => {
411
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry))
412
+ throw new Error("State transfer file entry is invalid");
413
+ const typed = entry;
414
+ if (typeof typed.path !== "string" || seen.has(typed.path))
415
+ throw new Error("State transfer contains duplicate or invalid paths");
416
+ seen.add(typed.path);
417
+ return { path: typed.path, bytes: decodeEntry(typed, bindings) };
418
+ });
419
+ if (entries.map(({ path }) => path).join("\0") !== [...seen].sort().join("\0")) {
420
+ throw new Error("State transfer files are not in deterministic path order");
421
+ }
422
+ return { bundle: bundle, entries };
423
+ }
424
+ async function assertNoSymlinkAncestors(apexRoot, destination) {
425
+ const relativePath = relative(apexRoot, destination);
426
+ let current = apexRoot;
427
+ for (const segment of relativePath.split(sep).slice(0, -1)) {
428
+ current = join(current, segment);
429
+ try {
430
+ const info = await lstat(current);
431
+ if (info.isSymbolicLink() || !info.isDirectory())
432
+ throw new Error(`State transfer destination ancestor is unsafe: ${current}`);
433
+ }
434
+ catch (error) {
435
+ if (error.code === "ENOENT")
436
+ return;
437
+ throw error;
438
+ }
439
+ }
440
+ }
441
+ async function assertApexRootSafe(apexRoot) {
442
+ try {
443
+ const info = await lstat(apexRoot);
444
+ if (info.isSymbolicLink() || !info.isDirectory()) {
445
+ throw new Error(`State transfer APEX root is unsafe: ${apexRoot}`);
446
+ }
447
+ }
448
+ catch (error) {
449
+ if (error.code !== "ENOENT")
450
+ throw error;
451
+ }
452
+ }
453
+ function requiredEntry(entries, path) {
454
+ const value = entries.get(path);
455
+ if (value === undefined)
456
+ throw new Error(`State transfer is missing required file: ${path}`);
457
+ return value;
458
+ }
459
+ export async function importStateTransfer(root, envelopeValue, recipient, now = () => new Date()) {
460
+ if (envelopeValue === null || typeof envelopeValue !== "object" || Array.isArray(envelopeValue)) {
461
+ throw new Error("State transfer envelope is invalid");
462
+ }
463
+ const envelope = envelopeValue;
464
+ if (Object.keys(envelope).sort().join("\0") !== ["metadata", "payload"].join("\0")) {
465
+ throw new Error("State transfer envelope shape is invalid");
466
+ }
467
+ if (envelope.metadata === null || typeof envelope.metadata !== "object" || Array.isArray(envelope.metadata)) {
468
+ throw new Error("State transfer envelope metadata is invalid");
469
+ }
470
+ const maxEncodedPlaintextBytes = Math.ceil(STATE_TRANSFER_MAX_BUNDLE_BYTES / 3) * 4;
471
+ if (typeof envelope.payload !== "string" || envelope.payload.length > maxEncodedPlaintextBytes) {
472
+ throw new Error("State transfer payload exceeds the 16 MiB limit");
473
+ }
474
+ if (envelope.metadata.kind !== STATE_TRANSFER_KIND)
475
+ throw new Error("State transfer envelope kind is invalid");
476
+ const bindings = requireBindings(envelope.metadata.bindings);
477
+ if (bindings.recipient !== recipient)
478
+ throw new Error("State transfer binding recipient mismatch");
479
+ const plaintext = new BoundEnvelopeTransport(now).open(envelope, recipient);
480
+ if (plaintext.byteLength > STATE_TRANSFER_MAX_BUNDLE_BYTES)
481
+ throw new Error("State transfer plaintext exceeds 16 MiB");
482
+ const { bundle, entries } = validateBundle(parseJson(plaintext, "state-transfer-bundle"), bindings);
483
+ const files = new Map(entries.map(({ path, bytes }) => [path, bytes]));
484
+ validateJournal(files, bindings);
485
+ validateObjectClosure(files, bindings);
486
+ const config = parseJson(requiredEntry(files, "config.json"), "config.json");
487
+ if (config.projectId !== bindings.projectId || config.runId !== bindings.runId) {
488
+ throw new Error("State transfer config does not match its bindings");
489
+ }
490
+ const projectPath = `projects/${bindings.projectId}/project.json`;
491
+ const runPath = `projects/${bindings.projectId}/runs/${bindings.runId}/run.json`;
492
+ const claimPath = `projects/${bindings.projectId}/runs/${bindings.runId}/transfers/${bindings.claimHash}.json`;
493
+ const project = parseJson(requiredEntry(files, projectPath), projectPath);
494
+ const run = parseJson(requiredEntry(files, runPath), runPath);
495
+ const claim = parseJson(requiredEntry(files, claimPath), claimPath);
496
+ if (project.projectId !== bindings.projectId ||
497
+ run.projectId !== bindings.projectId ||
498
+ run.runId !== bindings.runId) {
499
+ throw new Error("State transfer project/run files do not match bindings");
500
+ }
501
+ if (run.ownerEpoch !== bindings.ownerEpoch || claim.nextEpoch !== bindings.ownerEpoch + 1) {
502
+ throw new Error("State transfer owner epoch does not match bindings");
503
+ }
504
+ if (sha256Json(claim) !== bindings.claimHash ||
505
+ claim.projectId !== bindings.projectId ||
506
+ claim.runId !== bindings.runId ||
507
+ claim.recipient !== bindings.recipient ||
508
+ claim.repository !== bindings.repository ||
509
+ claim.branch !== bindings.branch ||
510
+ claim.commit !== bindings.commit ||
511
+ claim.workflowId !== bindings.workflowId ||
512
+ claim.approvalEnvironment !== bindings.approvalEnvironment) {
513
+ throw new Error("State transfer claim does not match bindings");
514
+ }
515
+ if (Date.parse(claim.expiresAt) <= now().getTime())
516
+ throw new Error("State transfer claim has expired");
517
+ if (claim.expiresAt !== bindings.claimExpiresAt ||
518
+ Date.parse(envelope.metadata.expiresAt) > Date.parse(bindings.claimExpiresAt)) {
519
+ throw new Error("State transfer envelope expiry exceeds its claim");
520
+ }
521
+ const lock = parseJson(requiredEntry(files, "apex.lock.json"), "apex.lock.json");
522
+ if (sha256Json(lock) !== run.runtimeLockHash)
523
+ throw new Error("State transfer runtime lock hash mismatch");
524
+ const apexRoot = resolve(root, ".apex");
525
+ await assertApexRootSafe(apexRoot);
526
+ const preflight = [];
527
+ for (const entry of entries) {
528
+ const destination = resolve(apexRoot, ...entry.path.split("/"));
529
+ if (destination !== apexRoot && !destination.startsWith(`${apexRoot}${sep}`))
530
+ throw new Error(`State transfer path escapes .apex: ${entry.path}`);
531
+ if (entry.path.startsWith("local/") || entry.path === "local")
532
+ throw new Error("State transfer cannot overwrite .apex/local");
533
+ await assertNoSymlinkAncestors(apexRoot, destination);
534
+ try {
535
+ const info = await lstat(destination);
536
+ if (info.isSymbolicLink() || !info.isFile())
537
+ throw new Error(`State transfer destination is unsafe: ${entry.path}`);
538
+ const existing = await readFile(destination);
539
+ if (!existing.equals(entry.bytes))
540
+ throw new Error(`State transfer destination differs: ${entry.path}`);
541
+ preflight.push({ destination, bytes: entry.bytes, exists: true });
542
+ }
543
+ catch (error) {
544
+ if (error.code !== "ENOENT")
545
+ throw error;
546
+ preflight.push({ destination, bytes: entry.bytes, exists: false });
547
+ }
548
+ }
549
+ for (const entry of preflight)
550
+ if (!entry.exists)
551
+ await atomicWriteBytes(entry.destination, entry.bytes, { refuseOverwrite: true });
552
+ return {
553
+ projectId: bundle.bindings.projectId,
554
+ runId: bundle.bindings.runId,
555
+ files: entries.length,
556
+ claimHash: bundle.bindings.claimHash,
557
+ };
558
+ }
559
+ //# sourceMappingURL=state-transfer.js.map
@@ -0,0 +1,2 @@
1
+ export declare const APEX_VERSION: "0.10.0-next.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const APEX_VERSION = "0.10.0-next.0";
2
+ //# sourceMappingURL=version.js.map