@treeseed/sdk 0.12.17 → 0.12.18

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.
@@ -12,7 +12,7 @@ import type { TreeseedCloseInput, TreeseedCiInput, TreeseedConfigInput, Treeseed
12
12
  type WorkflowWrite = NonNullable<TreeseedWorkflowContext['write']>;
13
13
  type WorkflowStatePayload = ReturnType<typeof resolveTreeseedWorkflowState>;
14
14
  type ReleaseCandidateMode = TreeseedReleaseCandidateMode;
15
- export type TreeseedWorkflowErrorCode = 'validation_failed' | 'merge_conflict' | 'missing_runtime_auth' | 'deployment_timeout' | 'confirmation_required' | 'unsupported_transport' | 'unsupported_state' | 'workflow_locked' | 'resume_unavailable' | 'workflow_contract_missing' | 'github_workflow_failed' | 'github_auth_unavailable' | 'hosted_reconcile_failed' | 'hosted_live_verification_failed';
15
+ export type TreeseedWorkflowErrorCode = 'validation_failed' | 'merge_conflict' | 'missing_runtime_auth' | 'deployment_timeout' | 'confirmation_required' | 'unsupported_transport' | 'unsupported_state' | 'workflow_locked' | 'resume_unavailable' | 'workflow_contract_missing' | 'github_workflow_failed' | 'github_auth_unavailable' | 'release_gate_failed' | 'hosted_reconcile_failed' | 'hosted_live_verification_failed';
16
16
  export declare class TreeseedWorkflowError extends Error {
17
17
  code: TreeseedWorkflowErrorCode;
18
18
  operation: TreeseedWorkflowOperationId;
@@ -1153,6 +1153,20 @@ export declare function workflowRelease(helpers: WorkflowOperationHelpers, input
1153
1153
  liveVerification: import("../workflow-support.js").TreeseedLiveHostedServiceCheckReport;
1154
1154
  reason?: undefined;
1155
1155
  };
1156
+ productionApiGuarantees: {
1157
+ ok: true;
1158
+ environment: string;
1159
+ runId: string;
1160
+ outputRoot: string;
1161
+ counts: {
1162
+ planned: number;
1163
+ passed: number;
1164
+ failed: number;
1165
+ skipped: number;
1166
+ blocked: number;
1167
+ releaseBlockingFailures: number;
1168
+ };
1169
+ };
1156
1170
  backMerge: {
1157
1171
  packages: {
1158
1172
  status: string;
@@ -159,6 +159,7 @@ import {
159
159
  } from "./session.js";
160
160
  import { checkedOutManagedWorkflowRepos } from "../operations/services/managed-repositories.js";
161
161
  import { runTreeseedLocalCleanup } from "../operations/services/local-cleanup.js";
162
+ import { runTreeseedGuarantees } from "../guarantees/index.js";
162
163
  import {
163
164
  classifyTreeseedBranchRole,
164
165
  resolveTreeseedWorkflowPaths
@@ -633,6 +634,49 @@ function productionReleaseImageRefEnv(selectedVersions) {
633
634
  }
634
635
  return refs;
635
636
  }
637
+ async function runReleaseApiGuarantees(root, environment, helpers, operation, sceneArtifacts) {
638
+ const env = {
639
+ ...helpers.context.env,
640
+ ...collectTreeseedConfigSeedValues(root, environment, helpers.context.env)
641
+ };
642
+ env.TREESEED_ACCEPTANCE_SERVICE_ID ??= env.TREESEED_API_WEB_SERVICE_ID ?? env.TREESEED_WEB_SERVICE_ID;
643
+ env.TREESEED_ACCEPTANCE_SERVICE_SECRET ??= env.TREESEED_API_WEB_SERVICE_SECRET ?? env.TREESEED_WEB_SERVICE_SECRET;
644
+ if (!env.TREESEED_ACCEPTANCE_SERVICE_ID || !env.TREESEED_ACCEPTANCE_SERVICE_SECRET) {
645
+ workflowError(operation, "release_gate_failed", `${environment} API release guarantees cannot run because API acceptance service credentials are missing.`, {
646
+ details: {
647
+ environment,
648
+ missing: [
649
+ !env.TREESEED_ACCEPTANCE_SERVICE_ID ? "TREESEED_ACCEPTANCE_SERVICE_ID" : null,
650
+ !env.TREESEED_ACCEPTANCE_SERVICE_SECRET ? "TREESEED_ACCEPTANCE_SERVICE_SECRET" : null
651
+ ].filter((value) => Boolean(value))
652
+ }
653
+ });
654
+ }
655
+ helpers.write(`[${operation}][workflow] Running ${environment} API release guarantees before root deployment.`);
656
+ return await withContextEnv(env, async () => {
657
+ const report = await runTreeseedGuarantees({
658
+ workspaceRoot: root,
659
+ filter: { ownerPackage: "@treeseed/api" },
660
+ environment,
661
+ evidenceTarget: "release",
662
+ sceneArtifacts
663
+ });
664
+ if (!report.ok) {
665
+ const diagnostics = report.diagnostics.filter((entry) => entry.severity === "error").slice(0, 20).map((entry) => `${entry.code}: ${entry.message}${entry.sourcePath ? ` (${entry.sourcePath})` : ""}`);
666
+ workflowError(operation, "release_gate_failed", `API release guarantees for ${environment} failed:
667
+ ${diagnostics.join("\n") || `See ${report.outputRoot}`}`, {
668
+ details: { environment, outputRoot: report.outputRoot, counts: report.counts, diagnostics: report.diagnostics }
669
+ });
670
+ }
671
+ return {
672
+ ok: report.ok,
673
+ environment: report.environment,
674
+ runId: report.runId,
675
+ outputRoot: report.outputRoot,
676
+ counts: report.counts
677
+ };
678
+ });
679
+ }
636
680
  function recordHostedDeploymentStatesFromRootGates(root, rootRelease, workflowGates) {
637
681
  const gates = Array.isArray(workflowGates) ? workflowGates.map((gate) => stringRecord(gate)).filter((gate) => Boolean(gate)) : [];
638
682
  const releaseRecord = stringRecord(rootRelease) ?? {};
@@ -5372,10 +5416,11 @@ ${blockers.join("\n")}`, {
5372
5416
  resumable: true
5373
5417
  };
5374
5418
  }),
5419
+ { id: "verify-published-artifacts", description: "Verify immutable registry artifacts exist after publish workflows", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5420
+ { id: "production-hosting", description: "Reconcile and live-verify production hosted resources before root deploy", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5421
+ { id: "production-api-guarantees", description: "Run production API release guarantees before root deploy", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5375
5422
  { id: "release-root", description: `Release market ${plannedRelease.rootVersion}`, repoName: rootRepo.name, repoPath: rootRepo.path, branch: STAGING_BRANCH, resumable: true },
5376
5423
  { id: "publish-wait", description: "Wait for production release workflows", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5377
- { id: "verify-published-artifacts", description: "Verify immutable registry artifacts exist after publish workflows", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5378
- { id: "production-hosting", description: "Reconcile and live-verify production hosted resources after publish", repoName: rootRepo.name, repoPath: rootRepo.path, branch: PRODUCTION_BRANCH, resumable: true },
5379
5424
  { id: "release-back-merge", description: "Back-merge production release history into staging", repoName: rootRepo.name, repoPath: rootRepo.path, branch: STAGING_BRANCH, resumable: true },
5380
5425
  { id: "workspace-link", description: "Restore local workspace links after release", repoName: rootRepo.name, repoPath: rootRepo.path, branch: STAGING_BRANCH, resumable: true }
5381
5426
  ],
@@ -5482,6 +5527,9 @@ ${rendered}`);
5482
5527
  });
5483
5528
  packageReleases.push(packageRelease);
5484
5529
  }
5530
+ const publishedArtifacts = await executeJournalStep(root, workflowRun.runId, "verify-published-artifacts", () => verifyPublishedReleaseArtifacts(selectedVersions));
5531
+ const productionHosting = await executeJournalStep(root, workflowRun.runId, "production-hosting", () => reconcileSaveHostedEnvironment(root, "prod", helpers, workflowRun.runId, "release", productionReleaseImageRefEnv(selectedVersions)));
5532
+ const productionApiGuarantees = await executeJournalStep(root, workflowRun.runId, "production-api-guarantees", () => runReleaseApiGuarantees(root, "prod", helpers, "release", normalizeSceneArtifactsMode(effectiveInput.sceneArtifacts)));
5485
5533
  const rootRelease = await executeJournalStep(root, workflowRun.runId, "release-root", () => {
5486
5534
  const rootInstall = runReleaseNpmInstall(root, { workspaceRoot: root });
5487
5535
  const changelog = updateReleaseChangelog(repoRoot(root), {
@@ -5532,8 +5580,6 @@ ${rendered}`);
5532
5580
  runId: workflowRun.runId,
5533
5581
  onProgress: (line, stream) => helpers.write(line, stream)
5534
5582
  }).then((workflowGates) => ({ workflowGates })));
5535
- const publishedArtifacts = await executeJournalStep(root, workflowRun.runId, "verify-published-artifacts", () => verifyPublishedReleaseArtifacts(selectedVersions));
5536
- const productionHosting = await executeJournalStep(root, workflowRun.runId, "production-hosting", () => reconcileSaveHostedEnvironment(root, "prod", helpers, workflowRun.runId, "release", productionReleaseImageRefEnv(selectedVersions)));
5537
5583
  const backMerge = await executeJournalStep(root, workflowRun.runId, "release-back-merge", () => {
5538
5584
  const packageBackMerges = checkedOutWorkspacePackageRepos(root).filter((pkg) => selectedPackageSet.has(pkg.name)).map((pkg) => backMergeProductionIntoStaging(pkg.dir, pkg.name, releaseAdminMessage({
5539
5585
  subject: `release: back-merge ${PRODUCTION_BRANCH} into ${STAGING_BRANCH}`,
@@ -5561,6 +5607,7 @@ ${rendered}`);
5561
5607
  publishWait: publishWait.workflowGates,
5562
5608
  publishedArtifacts,
5563
5609
  productionHosting,
5610
+ productionApiGuarantees,
5564
5611
  backMerge,
5565
5612
  workspaceLinks,
5566
5613
  releasedCommit: String(rootRelease.commit.commitSha ?? ""),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.12.17",
3
+ "version": "0.12.18",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {