@treeseed/sdk 0.13.0-rc.76 → 0.13.0-rc.77

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.
@@ -1 +1 @@
1
- {"completedAt":"2026-09-02T04:39:08.629Z"}
1
+ {"completedAt":"2026-09-02T05:04:54.660Z"}
@@ -1493,12 +1493,175 @@ export declare const hostedTopologyRollbackApprovalSchema: z.ZodObject<{
1493
1493
  approvedAt: string;
1494
1494
  rollbackDigest: string;
1495
1495
  }>;
1496
+ export declare const hostedTopologyRollbackExecutionSchema: z.ZodEffects<z.ZodObject<{
1497
+ schemaVersion: z.ZodLiteral<"treeseed.hosted-topology-rollback-execution/v1">;
1498
+ rollback: z.ZodObject<{
1499
+ schemaVersion: z.ZodLiteral<"treeseed.hosted-topology-rollback/v1">;
1500
+ rollbackId: z.ZodString;
1501
+ sourceReceiptId: z.ZodString;
1502
+ environment: z.ZodEnum<["staging", "production"]>;
1503
+ operations: z.ZodArray<z.ZodObject<{
1504
+ resourceId: z.ZodString;
1505
+ action: z.ZodEnum<["restore", "delete-created", "noop"]>;
1506
+ providerResourceId: z.ZodString;
1507
+ targetDigest: z.ZodNullable<z.ZodString>;
1508
+ }, "strict", z.ZodTypeAny, {
1509
+ action: "noop" | "restore" | "delete-created";
1510
+ resourceId: string;
1511
+ providerResourceId: string;
1512
+ targetDigest: string | null;
1513
+ }, {
1514
+ action: "noop" | "restore" | "delete-created";
1515
+ resourceId: string;
1516
+ providerResourceId: string;
1517
+ targetDigest: string | null;
1518
+ }>, "many">;
1519
+ rollbackDigest: z.ZodString;
1520
+ }, "strict", z.ZodTypeAny, {
1521
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1522
+ environment: "production" | "staging";
1523
+ operations: {
1524
+ action: "noop" | "restore" | "delete-created";
1525
+ resourceId: string;
1526
+ providerResourceId: string;
1527
+ targetDigest: string | null;
1528
+ }[];
1529
+ rollbackId: string;
1530
+ sourceReceiptId: string;
1531
+ rollbackDigest: string;
1532
+ }, {
1533
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1534
+ environment: "production" | "staging";
1535
+ operations: {
1536
+ action: "noop" | "restore" | "delete-created";
1537
+ resourceId: string;
1538
+ providerResourceId: string;
1539
+ targetDigest: string | null;
1540
+ }[];
1541
+ rollbackId: string;
1542
+ sourceReceiptId: string;
1543
+ rollbackDigest: string;
1544
+ }>;
1545
+ sourceReceiptId: z.ZodString;
1546
+ topologyId: z.ZodString;
1547
+ environment: z.ZodEnum<["staging", "production"]>;
1548
+ sourcePlanDigest: z.ZodString;
1549
+ targetPlanDigest: z.ZodString;
1550
+ executionDigest: z.ZodString;
1551
+ }, "strict", z.ZodTypeAny, {
1552
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1553
+ environment: "production" | "staging";
1554
+ rollback: {
1555
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1556
+ environment: "production" | "staging";
1557
+ operations: {
1558
+ action: "noop" | "restore" | "delete-created";
1559
+ resourceId: string;
1560
+ providerResourceId: string;
1561
+ targetDigest: string | null;
1562
+ }[];
1563
+ rollbackId: string;
1564
+ sourceReceiptId: string;
1565
+ rollbackDigest: string;
1566
+ };
1567
+ topologyId: string;
1568
+ sourceReceiptId: string;
1569
+ sourcePlanDigest: string;
1570
+ targetPlanDigest: string;
1571
+ executionDigest: string;
1572
+ }, {
1573
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1574
+ environment: "production" | "staging";
1575
+ rollback: {
1576
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1577
+ environment: "production" | "staging";
1578
+ operations: {
1579
+ action: "noop" | "restore" | "delete-created";
1580
+ resourceId: string;
1581
+ providerResourceId: string;
1582
+ targetDigest: string | null;
1583
+ }[];
1584
+ rollbackId: string;
1585
+ sourceReceiptId: string;
1586
+ rollbackDigest: string;
1587
+ };
1588
+ topologyId: string;
1589
+ sourceReceiptId: string;
1590
+ sourcePlanDigest: string;
1591
+ targetPlanDigest: string;
1592
+ executionDigest: string;
1593
+ }>, {
1594
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1595
+ environment: "production" | "staging";
1596
+ rollback: {
1597
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1598
+ environment: "production" | "staging";
1599
+ operations: {
1600
+ action: "noop" | "restore" | "delete-created";
1601
+ resourceId: string;
1602
+ providerResourceId: string;
1603
+ targetDigest: string | null;
1604
+ }[];
1605
+ rollbackId: string;
1606
+ sourceReceiptId: string;
1607
+ rollbackDigest: string;
1608
+ };
1609
+ topologyId: string;
1610
+ sourceReceiptId: string;
1611
+ sourcePlanDigest: string;
1612
+ targetPlanDigest: string;
1613
+ executionDigest: string;
1614
+ }, {
1615
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1616
+ environment: "production" | "staging";
1617
+ rollback: {
1618
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1619
+ environment: "production" | "staging";
1620
+ operations: {
1621
+ action: "noop" | "restore" | "delete-created";
1622
+ resourceId: string;
1623
+ providerResourceId: string;
1624
+ targetDigest: string | null;
1625
+ }[];
1626
+ rollbackId: string;
1627
+ sourceReceiptId: string;
1628
+ rollbackDigest: string;
1629
+ };
1630
+ topologyId: string;
1631
+ sourceReceiptId: string;
1632
+ sourcePlanDigest: string;
1633
+ targetPlanDigest: string;
1634
+ executionDigest: string;
1635
+ }>;
1636
+ export declare const hostedTopologyRollbackExecutionApprovalSchema: z.ZodObject<{
1637
+ schemaVersion: z.ZodLiteral<"treeseed.hosted-topology-rollback-execution-approval/v1">;
1638
+ executionDigest: z.ZodString;
1639
+ environment: z.ZodEnum<["staging", "production"]>;
1640
+ decision: z.ZodLiteral<"approved">;
1641
+ approvedBy: z.ZodString;
1642
+ approvedAt: z.ZodString;
1643
+ }, "strict", z.ZodTypeAny, {
1644
+ schemaVersion: "treeseed.hosted-topology-rollback-execution-approval/v1";
1645
+ environment: "production" | "staging";
1646
+ decision: "approved";
1647
+ approvedBy: string;
1648
+ approvedAt: string;
1649
+ executionDigest: string;
1650
+ }, {
1651
+ schemaVersion: "treeseed.hosted-topology-rollback-execution-approval/v1";
1652
+ environment: "production" | "staging";
1653
+ decision: "approved";
1654
+ approvedBy: string;
1655
+ approvedAt: string;
1656
+ executionDigest: string;
1657
+ }>;
1496
1658
  export type HostedTopologyDeclaration = z.infer<typeof hostedTopologyDeclarationSchema>;
1497
1659
  export type HostedResourceObservation = z.infer<typeof hostedResourceObservationSchema>;
1498
1660
  export type HostedTopologyPlan = z.infer<typeof hostedTopologyPlanSchema>;
1499
1661
  export type HostedTopologyApproval = z.infer<typeof hostedTopologyApprovalSchema>;
1500
1662
  export type AuthorizedHostedTopologyPlan = z.infer<typeof authorizedHostedTopologyPlanSchema>;
1501
1663
  export type HostedTopologyReceipt = z.infer<typeof hostedTopologyReceiptSchema>;
1664
+ export type HostedTopologyRollbackExecution = z.infer<typeof hostedTopologyRollbackExecutionSchema>;
1502
1665
  export declare function planHostedTopology(input: {
1503
1666
  declaration: HostedTopologyDeclaration;
1504
1667
  observations: HostedResourceObservation[];
@@ -1547,4 +1710,63 @@ export declare function authorizeHostedTopologyRollback(rollbackInput: z.input<t
1547
1710
  rollbackDigest: string;
1548
1711
  };
1549
1712
  };
1713
+ export declare function planHostedTopologyRollbackExecution(input: {
1714
+ rollback: z.input<typeof hostedTopologyRollbackSchema>;
1715
+ sourceReceipt: z.input<typeof hostedTopologyReceiptSchema>;
1716
+ sourcePlan: z.input<typeof hostedTopologyPlanSchema> | z.input<typeof authorizedHostedTopologyPlanSchema>;
1717
+ targetPlan: z.input<typeof hostedTopologyPlanSchema>;
1718
+ }): {
1719
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1720
+ environment: "production" | "staging";
1721
+ rollback: {
1722
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1723
+ environment: "production" | "staging";
1724
+ operations: {
1725
+ action: "noop" | "restore" | "delete-created";
1726
+ resourceId: string;
1727
+ providerResourceId: string;
1728
+ targetDigest: string | null;
1729
+ }[];
1730
+ rollbackId: string;
1731
+ sourceReceiptId: string;
1732
+ rollbackDigest: string;
1733
+ };
1734
+ topologyId: string;
1735
+ sourceReceiptId: string;
1736
+ sourcePlanDigest: string;
1737
+ targetPlanDigest: string;
1738
+ executionDigest: string;
1739
+ };
1740
+ export declare function authorizeHostedTopologyRollbackExecution(executionInput: z.input<typeof hostedTopologyRollbackExecutionSchema>, approvalInput: z.input<typeof hostedTopologyRollbackExecutionApprovalSchema>): {
1741
+ execution: {
1742
+ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1";
1743
+ environment: "production" | "staging";
1744
+ rollback: {
1745
+ schemaVersion: "treeseed.hosted-topology-rollback/v1";
1746
+ environment: "production" | "staging";
1747
+ operations: {
1748
+ action: "noop" | "restore" | "delete-created";
1749
+ resourceId: string;
1750
+ providerResourceId: string;
1751
+ targetDigest: string | null;
1752
+ }[];
1753
+ rollbackId: string;
1754
+ sourceReceiptId: string;
1755
+ rollbackDigest: string;
1756
+ };
1757
+ topologyId: string;
1758
+ sourceReceiptId: string;
1759
+ sourcePlanDigest: string;
1760
+ targetPlanDigest: string;
1761
+ executionDigest: string;
1762
+ };
1763
+ approval: {
1764
+ schemaVersion: "treeseed.hosted-topology-rollback-execution-approval/v1";
1765
+ environment: "production" | "staging";
1766
+ decision: "approved";
1767
+ approvedBy: string;
1768
+ approvedAt: string;
1769
+ executionDigest: string;
1770
+ };
1771
+ };
1550
1772
  export {};
@@ -169,6 +169,34 @@ const hostedTopologyRollbackApprovalSchema = z.object({
169
169
  approvedBy: z.string().min(1).max(256),
170
170
  approvedAt: timestamp
171
171
  }).strict();
172
+ const hostedTopologyRollbackExecutionSchema = z.object({
173
+ schemaVersion: z.literal("treeseed.hosted-topology-rollback-execution/v1"),
174
+ rollback: hostedTopologyRollbackSchema,
175
+ sourceReceiptId: z.string().regex(/^topology-receipt-[a-f0-9]{16}$/u),
176
+ topologyId: identifier,
177
+ environment: z.enum(["staging", "production"]),
178
+ sourcePlanDigest: digest,
179
+ targetPlanDigest: digest,
180
+ executionDigest: digest
181
+ }).strict().superRefine((execution, context) => {
182
+ const core = {
183
+ rollback: execution.rollback,
184
+ sourceReceiptId: execution.sourceReceiptId,
185
+ topologyId: execution.topologyId,
186
+ environment: execution.environment,
187
+ sourcePlanDigest: execution.sourcePlanDigest,
188
+ targetPlanDigest: execution.targetPlanDigest
189
+ };
190
+ if (deploymentDigest(core) !== execution.executionDigest) context.addIssue({ code: z.ZodIssueCode.custom, path: ["executionDigest"], message: "Hosted rollback execution digest does not bind its complete source and target closure." });
191
+ });
192
+ const hostedTopologyRollbackExecutionApprovalSchema = z.object({
193
+ schemaVersion: z.literal("treeseed.hosted-topology-rollback-execution-approval/v1"),
194
+ executionDigest: digest,
195
+ environment: z.enum(["staging", "production"]),
196
+ decision: z.literal("approved"),
197
+ approvedBy: z.string().min(1).max(256),
198
+ approvedAt: timestamp
199
+ }).strict();
172
200
  function observationMap(items, declaration) {
173
201
  const resources = new Map(declaration.resources.map((resource) => [resource.id, resource]));
174
202
  const observations = /* @__PURE__ */ new Map();
@@ -289,9 +317,46 @@ function authorizeHostedTopologyRollback(rollbackInput, approvalInput) {
289
317
  if (approval.rollbackDigest !== rollback.rollbackDigest || approval.environment !== rollback.environment) throw new Error("Hosted topology rollback approval does not bind the exact rollback and environment.");
290
318
  return { rollback, approval };
291
319
  }
320
+ function planHostedTopologyRollbackExecution(input) {
321
+ const rollback = hostedTopologyRollbackSchema.parse(input.rollback), sourceReceipt = hostedTopologyReceiptSchema.parse(input.sourceReceipt);
322
+ const sourcePlan = input.sourcePlan && typeof input.sourcePlan === "object" && "approval" in input.sourcePlan ? authorizedHostedTopologyPlanSchema.parse(input.sourcePlan) : hostedTopologyPlanSchema.parse(input.sourcePlan);
323
+ const targetPlan = hostedTopologyPlanSchema.parse(input.targetPlan);
324
+ if (sourceReceipt.receiptId !== rollback.sourceReceiptId || sourceReceipt.planDigest !== sourcePlan.planDigest) throw new Error("Hosted rollback execution source receipt is stale.");
325
+ if ([sourceReceipt.environment, sourcePlan.environment, targetPlan.environment].some((environment) => environment !== rollback.environment)) throw new Error("Hosted rollback execution environment does not match its source and target plans.");
326
+ if (sourceReceipt.topologyId !== sourcePlan.topologyId || sourcePlan.topologyId !== targetPlan.topologyId) throw new Error("Hosted rollback execution topology identity changed.");
327
+ const sourceActions = new Map(sourcePlan.actions.map((action) => [action.resourceId, action]));
328
+ const sourceResources = new Map(sourceReceipt.resources.map((resource) => [resource.resourceId, resource]));
329
+ const targetActions = new Map(targetPlan.actions.map((action) => [action.resourceId, action]));
330
+ if (sourceResources.size !== sourceActions.size || rollback.operations.length !== sourceActions.size || new Set(rollback.operations.map(({ resourceId }) => resourceId)).size !== sourceActions.size) throw new Error("Hosted rollback execution does not cover the complete source resource set.");
331
+ for (const operation of rollback.operations) {
332
+ const source = sourceActions.get(operation.resourceId), observed = sourceResources.get(operation.resourceId), target = targetActions.get(operation.resourceId);
333
+ if (!source || !observed || observed.providerResourceId !== operation.providerResourceId) throw new Error(`Hosted rollback execution source mismatch for ${operation.resourceId}.`);
334
+ if (operation.action === "delete-created") {
335
+ if (target) throw new Error(`Hosted rollback execution target must remove created resource ${operation.resourceId}.`);
336
+ } else if (!target || !operation.targetDigest || target.desiredDigest !== operation.targetDigest || target.provider !== source.provider || target.kind !== source.kind) {
337
+ throw new Error(`Hosted rollback execution target specification mismatch for ${operation.resourceId}.`);
338
+ }
339
+ }
340
+ if ([...targetActions.keys()].some((resourceId) => !sourceActions.has(resourceId))) throw new Error("Hosted rollback execution target introduces an unapproved resource.");
341
+ const core = {
342
+ rollback,
343
+ sourceReceiptId: sourceReceipt.receiptId,
344
+ topologyId: sourceReceipt.topologyId,
345
+ environment: rollback.environment,
346
+ sourcePlanDigest: sourcePlan.planDigest,
347
+ targetPlanDigest: targetPlan.planDigest
348
+ };
349
+ return hostedTopologyRollbackExecutionSchema.parse({ schemaVersion: "treeseed.hosted-topology-rollback-execution/v1", ...core, executionDigest: deploymentDigest(core) });
350
+ }
351
+ function authorizeHostedTopologyRollbackExecution(executionInput, approvalInput) {
352
+ const execution = hostedTopologyRollbackExecutionSchema.parse(executionInput), approval = hostedTopologyRollbackExecutionApprovalSchema.parse(approvalInput);
353
+ if (approval.executionDigest !== execution.executionDigest || approval.environment !== execution.environment) throw new Error("Hosted rollback execution approval does not bind the exact source, target, and environment.");
354
+ return { execution, approval };
355
+ }
292
356
  export {
293
357
  authorizeHostedTopologyPlan,
294
358
  authorizeHostedTopologyRollback,
359
+ authorizeHostedTopologyRollbackExecution,
295
360
  authorizedHostedTopologyPlanSchema,
296
361
  hostedProviderSchema,
297
362
  hostedResourceKindSchema,
@@ -301,8 +366,11 @@ export {
301
366
  hostedTopologyPlanSchema,
302
367
  hostedTopologyReceiptSchema,
303
368
  hostedTopologyRollbackApprovalSchema,
369
+ hostedTopologyRollbackExecutionApprovalSchema,
370
+ hostedTopologyRollbackExecutionSchema,
304
371
  hostedTopologyRollbackSchema,
305
372
  planHostedTopology,
306
373
  planHostedTopologyRollback,
374
+ planHostedTopologyRollbackExecution,
307
375
  verifyHostedTopologyReadback
308
376
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.13.0-rc.76",
3
+ "version": "0.13.0-rc.77",
4
4
  "description": "Portable TreeSeed contracts, standards, and typed remote control-plane clients.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {