@greatwait/contracts 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/authority.d.ts +217 -0
  4. package/dist/authority.js +261 -0
  5. package/dist/callback-ownership.d.ts +58 -0
  6. package/dist/callback-ownership.js +71 -0
  7. package/dist/callback-safety.d.ts +38 -0
  8. package/dist/callback-safety.js +403 -0
  9. package/dist/compatibility.d.ts +82 -0
  10. package/dist/compatibility.js +115 -0
  11. package/dist/delivery.d.ts +401 -0
  12. package/dist/delivery.js +311 -0
  13. package/dist/endpoints.d.ts +305 -0
  14. package/dist/endpoints.js +179 -0
  15. package/dist/events.d.ts +62 -0
  16. package/dist/events.js +38 -0
  17. package/dist/first-value-journey.d.ts +305 -0
  18. package/dist/first-value-journey.js +466 -0
  19. package/dist/forecast.d.ts +443 -0
  20. package/dist/forecast.js +729 -0
  21. package/dist/identifiers.d.ts +109 -0
  22. package/dist/identifiers.js +131 -0
  23. package/dist/identity.d.ts +196 -0
  24. package/dist/identity.js +182 -0
  25. package/dist/index.d.ts +27 -0
  26. package/dist/index.js +27 -0
  27. package/dist/mcp.d.ts +51 -0
  28. package/dist/mcp.js +56 -0
  29. package/dist/oauth.d.ts +796 -0
  30. package/dist/oauth.js +708 -0
  31. package/dist/operations.d.ts +3985 -0
  32. package/dist/operations.js +1837 -0
  33. package/dist/partition.d.ts +771 -0
  34. package/dist/partition.js +206 -0
  35. package/dist/policy.d.ts +93 -0
  36. package/dist/policy.js +180 -0
  37. package/dist/problems.d.ts +158 -0
  38. package/dist/problems.js +104 -0
  39. package/dist/protocol.d.ts +308 -0
  40. package/dist/protocol.js +515 -0
  41. package/dist/scheduling-records.d.ts +395 -0
  42. package/dist/scheduling-records.js +284 -0
  43. package/dist/scheduling.d.ts +1098 -0
  44. package/dist/scheduling.js +1116 -0
  45. package/dist/secrets.d.ts +383 -0
  46. package/dist/secrets.js +272 -0
  47. package/dist/signatures.d.ts +704 -0
  48. package/dist/signatures.js +867 -0
  49. package/dist/tenancy.d.ts +178 -0
  50. package/dist/tenancy.js +145 -0
  51. package/dist/test-sink.d.ts +986 -0
  52. package/dist/test-sink.js +755 -0
  53. package/dist/time.d.ts +45 -0
  54. package/dist/time.js +128 -0
  55. package/dist/usage.d.ts +121 -0
  56. package/dist/usage.js +200 -0
  57. package/dist/webhooks.d.ts +116 -0
  58. package/dist/webhooks.js +161 -0
  59. package/dist/workspace.d.ts +92 -0
  60. package/dist/workspace.js +59 -0
  61. package/generated/v1/callback-delivery-signature.json +467 -0
  62. package/generated/v1/callback-endpoint-verification.json +59 -0
  63. package/generated/v1/callback-receiver.json +241 -0
  64. package/generated/v1/examples/attempts.list.response.json +24 -0
  65. package/generated/v1/examples/attempts.read.response.json +20 -0
  66. package/generated/v1/examples/credentials.create.request.json +5 -0
  67. package/generated/v1/examples/credentials.create.response.json +10 -0
  68. package/generated/v1/examples/credentials.list.response.json +17 -0
  69. package/generated/v1/examples/credentials.revoke.response.json +11 -0
  70. package/generated/v1/examples/credentials.rotate.request.json +3 -0
  71. package/generated/v1/examples/credentials.rotate.response.json +22 -0
  72. package/generated/v1/examples/endpoints.create.request.json +3 -0
  73. package/generated/v1/examples/endpoints.create.response.json +16 -0
  74. package/generated/v1/examples/endpoints.disable.response.json +15 -0
  75. package/generated/v1/examples/endpoints.list.response.json +21 -0
  76. package/generated/v1/examples/endpoints.read.response.json +14 -0
  77. package/generated/v1/examples/endpoints.rotateSigningKey.request.json +3 -0
  78. package/generated/v1/examples/endpoints.rotateSigningKey.response.json +23 -0
  79. package/generated/v1/examples/endpoints.update.request.json +3 -0
  80. package/generated/v1/examples/endpoints.update.response.json +13 -0
  81. package/generated/v1/examples/endpoints.verify.response.json +15 -0
  82. package/generated/v1/examples/forecast.read.response.json +28 -0
  83. package/generated/v1/examples/forecast.windows.response.json +21 -0
  84. package/generated/v1/examples/grants.list.response.json +17 -0
  85. package/generated/v1/examples/grants.revoke.response.json +16 -0
  86. package/generated/v1/examples/meta.scaffold.response.json +5 -0
  87. package/generated/v1/examples/meta.version.response.json +5 -0
  88. package/generated/v1/examples/occurrences.list.response.json +17 -0
  89. package/generated/v1/examples/occurrences.read.response.json +15 -0
  90. package/generated/v1/examples/occurrences.redeliver.response.json +16 -0
  91. package/generated/v1/examples/projects.create.request.json +3 -0
  92. package/generated/v1/examples/projects.create.response.json +5 -0
  93. package/generated/v1/examples/projects.list.response.json +9 -0
  94. package/generated/v1/examples/schedules.archive.response.json +25 -0
  95. package/generated/v1/examples/schedules.cancel.response.json +24 -0
  96. package/generated/v1/examples/schedules.create.request.json +9 -0
  97. package/generated/v1/examples/schedules.create.response.json +25 -0
  98. package/generated/v1/examples/schedules.list.response.json +23 -0
  99. package/generated/v1/examples/schedules.pause.response.json +23 -0
  100. package/generated/v1/examples/schedules.read.response.json +25 -0
  101. package/generated/v1/examples/schedules.replace.request.json +8 -0
  102. package/generated/v1/examples/schedules.replace.response.json +25 -0
  103. package/generated/v1/examples/schedules.resume.response.json +23 -0
  104. package/generated/v1/examples/sinkdeliveries.list.response.json +19 -0
  105. package/generated/v1/examples/sinkdeliveries.read.response.json +16 -0
  106. package/generated/v1/examples/testsinks.configure.request.json +3 -0
  107. package/generated/v1/examples/testsinks.configure.response.json +13 -0
  108. package/generated/v1/examples/testsinks.create.request.json +8 -0
  109. package/generated/v1/examples/testsinks.create.response.json +13 -0
  110. package/generated/v1/examples/testsinks.delete.response.json +13 -0
  111. package/generated/v1/examples/testsinks.list.response.json +20 -0
  112. package/generated/v1/examples/testsinks.read.response.json +14 -0
  113. package/generated/v1/examples/usage.read.response.json +20 -0
  114. package/generated/v1/first-value-journey.json +436 -0
  115. package/generated/v1/manifest.json +1037 -0
  116. package/generated/v1/openapi.json +23665 -0
  117. package/generated/v1/policy-matrix.json +305 -0
  118. package/generated/v1/schemas/attempts.list.query.json +16 -0
  119. package/generated/v1/schemas/attempts.list.response.json +175 -0
  120. package/generated/v1/schemas/attempts.read.response.json +168 -0
  121. package/generated/v1/schemas/credentials.create.request.json +39 -0
  122. package/generated/v1/schemas/credentials.create.response.json +88 -0
  123. package/generated/v1/schemas/credentials.list.query.json +16 -0
  124. package/generated/v1/schemas/credentials.list.response.json +124 -0
  125. package/generated/v1/schemas/credentials.revoke.response.json +84 -0
  126. package/generated/v1/schemas/credentials.rotate.request.json +11 -0
  127. package/generated/v1/schemas/credentials.rotate.response.json +171 -0
  128. package/generated/v1/schemas/endpoints.create.request.json +12 -0
  129. package/generated/v1/schemas/endpoints.create.response.json +115 -0
  130. package/generated/v1/schemas/endpoints.disable.response-headers.json +11 -0
  131. package/generated/v1/schemas/endpoints.disable.response.json +100 -0
  132. package/generated/v1/schemas/endpoints.list.query.json +16 -0
  133. package/generated/v1/schemas/endpoints.list.response.json +146 -0
  134. package/generated/v1/schemas/endpoints.read.response-headers.json +11 -0
  135. package/generated/v1/schemas/endpoints.read.response.json +100 -0
  136. package/generated/v1/schemas/endpoints.rotateSigningKey.request-headers.json +10 -0
  137. package/generated/v1/schemas/endpoints.rotateSigningKey.request.json +11 -0
  138. package/generated/v1/schemas/endpoints.rotateSigningKey.response-headers.json +11 -0
  139. package/generated/v1/schemas/endpoints.rotateSigningKey.response.json +118 -0
  140. package/generated/v1/schemas/endpoints.update.request-headers.json +10 -0
  141. package/generated/v1/schemas/endpoints.update.request.json +12 -0
  142. package/generated/v1/schemas/endpoints.update.response-headers.json +11 -0
  143. package/generated/v1/schemas/endpoints.update.response.json +100 -0
  144. package/generated/v1/schemas/endpoints.verify.request-headers.json +10 -0
  145. package/generated/v1/schemas/endpoints.verify.response-headers.json +11 -0
  146. package/generated/v1/schemas/endpoints.verify.response.json +100 -0
  147. package/generated/v1/schemas/forecast.read.query.json +26 -0
  148. package/generated/v1/schemas/forecast.read.response.json +100 -0
  149. package/generated/v1/schemas/forecast.windows.query.json +26 -0
  150. package/generated/v1/schemas/forecast.windows.response.json +94 -0
  151. package/generated/v1/schemas/grants.list.response.json +98 -0
  152. package/generated/v1/schemas/grants.revoke.response.json +95 -0
  153. package/generated/v1/schemas/meta.scaffold.response.json +36 -0
  154. package/generated/v1/schemas/meta.version.response.json +19 -0
  155. package/generated/v1/schemas/occurrences.list.query.json +16 -0
  156. package/generated/v1/schemas/occurrences.list.response.json +83 -0
  157. package/generated/v1/schemas/occurrences.read.response.json +76 -0
  158. package/generated/v1/schemas/occurrences.redeliver.request-headers.json +13 -0
  159. package/generated/v1/schemas/occurrences.redeliver.response-headers.json +10 -0
  160. package/generated/v1/schemas/occurrences.redeliver.response.json +168 -0
  161. package/generated/v1/schemas/projects.create.request.json +12 -0
  162. package/generated/v1/schemas/projects.create.response.json +25 -0
  163. package/generated/v1/schemas/projects.list.response.json +35 -0
  164. package/generated/v1/schemas/schedules.archive.request-headers.json +10 -0
  165. package/generated/v1/schemas/schedules.archive.response-headers.json +11 -0
  166. package/generated/v1/schemas/schedules.archive.response.json +189 -0
  167. package/generated/v1/schemas/schedules.cancel.request-headers.json +10 -0
  168. package/generated/v1/schemas/schedules.cancel.response-headers.json +11 -0
  169. package/generated/v1/schemas/schedules.cancel.response.json +189 -0
  170. package/generated/v1/schemas/schedules.create.request-headers.json +12 -0
  171. package/generated/v1/schemas/schedules.create.request.json +99 -0
  172. package/generated/v1/schemas/schedules.create.response-headers.json +15 -0
  173. package/generated/v1/schemas/schedules.create.response.json +189 -0
  174. package/generated/v1/schemas/schedules.list.query.json +16 -0
  175. package/generated/v1/schemas/schedules.list.response.json +170 -0
  176. package/generated/v1/schemas/schedules.pause.request-headers.json +10 -0
  177. package/generated/v1/schemas/schedules.pause.response-headers.json +11 -0
  178. package/generated/v1/schemas/schedules.pause.response.json +189 -0
  179. package/generated/v1/schemas/schedules.read.response-headers.json +11 -0
  180. package/generated/v1/schemas/schedules.read.response.json +189 -0
  181. package/generated/v1/schemas/schedules.replace.request-headers.json +10 -0
  182. package/generated/v1/schemas/schedules.replace.request.json +99 -0
  183. package/generated/v1/schemas/schedules.replace.response-headers.json +11 -0
  184. package/generated/v1/schemas/schedules.replace.response.json +189 -0
  185. package/generated/v1/schemas/schedules.resume.request-headers.json +10 -0
  186. package/generated/v1/schemas/schedules.resume.response-headers.json +11 -0
  187. package/generated/v1/schemas/schedules.resume.response.json +189 -0
  188. package/generated/v1/schemas/sinkdeliveries.list.query.json +16 -0
  189. package/generated/v1/schemas/sinkdeliveries.list.response.json +126 -0
  190. package/generated/v1/schemas/sinkdeliveries.read.response.json +98 -0
  191. package/generated/v1/schemas/testsinks.configure.request.json +66 -0
  192. package/generated/v1/schemas/testsinks.configure.response.json +115 -0
  193. package/generated/v1/schemas/testsinks.create.request.json +76 -0
  194. package/generated/v1/schemas/testsinks.create.response.json +115 -0
  195. package/generated/v1/schemas/testsinks.delete.response.json +115 -0
  196. package/generated/v1/schemas/testsinks.list.query.json +16 -0
  197. package/generated/v1/schemas/testsinks.list.response.json +161 -0
  198. package/generated/v1/schemas/testsinks.read.response.json +115 -0
  199. package/generated/v1/schemas/usage.read.query.json +15 -0
  200. package/generated/v1/schemas/usage.read.response.json +71 -0
  201. package/generated/v1/snippets/attempts.list.json +5 -0
  202. package/generated/v1/snippets/attempts.read.json +5 -0
  203. package/generated/v1/snippets/credentials.create.json +5 -0
  204. package/generated/v1/snippets/credentials.list.json +5 -0
  205. package/generated/v1/snippets/credentials.revoke.json +5 -0
  206. package/generated/v1/snippets/credentials.rotate.json +5 -0
  207. package/generated/v1/snippets/endpoints.create.json +5 -0
  208. package/generated/v1/snippets/endpoints.disable.json +5 -0
  209. package/generated/v1/snippets/endpoints.list.json +5 -0
  210. package/generated/v1/snippets/endpoints.read.json +5 -0
  211. package/generated/v1/snippets/endpoints.rotateSigningKey.json +5 -0
  212. package/generated/v1/snippets/endpoints.update.json +5 -0
  213. package/generated/v1/snippets/endpoints.verify.json +5 -0
  214. package/generated/v1/snippets/forecast.read.json +5 -0
  215. package/generated/v1/snippets/forecast.windows.json +5 -0
  216. package/generated/v1/snippets/grants.list.json +5 -0
  217. package/generated/v1/snippets/grants.revoke.json +5 -0
  218. package/generated/v1/snippets/meta.scaffold.json +5 -0
  219. package/generated/v1/snippets/meta.version.json +5 -0
  220. package/generated/v1/snippets/occurrences.list.json +5 -0
  221. package/generated/v1/snippets/occurrences.read.json +5 -0
  222. package/generated/v1/snippets/occurrences.redeliver.json +5 -0
  223. package/generated/v1/snippets/projects.create.json +5 -0
  224. package/generated/v1/snippets/projects.list.json +5 -0
  225. package/generated/v1/snippets/schedules.archive.json +5 -0
  226. package/generated/v1/snippets/schedules.cancel.json +5 -0
  227. package/generated/v1/snippets/schedules.create.json +5 -0
  228. package/generated/v1/snippets/schedules.list.json +5 -0
  229. package/generated/v1/snippets/schedules.pause.json +5 -0
  230. package/generated/v1/snippets/schedules.read.json +5 -0
  231. package/generated/v1/snippets/schedules.replace.json +5 -0
  232. package/generated/v1/snippets/schedules.resume.json +5 -0
  233. package/generated/v1/snippets/sinkdeliveries.list.json +5 -0
  234. package/generated/v1/snippets/sinkdeliveries.read.json +5 -0
  235. package/generated/v1/snippets/testsinks.configure.json +5 -0
  236. package/generated/v1/snippets/testsinks.create.json +5 -0
  237. package/generated/v1/snippets/testsinks.delete.json +5 -0
  238. package/generated/v1/snippets/testsinks.list.json +5 -0
  239. package/generated/v1/snippets/testsinks.read.json +5 -0
  240. package/generated/v1/snippets/usage.read.json +5 -0
  241. package/package.json +153 -0
@@ -0,0 +1,1098 @@
1
+ import { z } from "zod";
2
+ import { type CallbackTrigger, type ResponseClass } from "./signatures.js";
3
+ /**
4
+ * The scheduling resource family: schedules, the occurrences they produce, and
5
+ * the attempts made to deliver each occurrence.
6
+ *
7
+ * Three ideas make the difference between this and the legacy scheduler, where
8
+ * one row was the schedule, the occurrence and the delivery all at once.
9
+ *
10
+ * 1. **A schedule is a definition; an occurrence is a concrete instant.** A
11
+ * recurring series never advances by rewriting its row, because that loses
12
+ * the outcome of the occurrence it just overwrote. Each occurrence carries
13
+ * its own state, retries and terminal outcome.
14
+ * 2. **A generation makes a stale event harmless.** Replacing a definition
15
+ * increments it, so work already in flight against the old definition can be
16
+ * recorded but can never fire, retire, or advance the replacement.
17
+ * 3. **An attempt is immutable once classified.** A redelivery is a new
18
+ * attempt against the same occurrence; it never rewrites history.
19
+ *
20
+ * Nothing here carries an authority tuple. A scheduling resource belongs to the
21
+ * partition that stores it, and that partition is bound to exactly one
22
+ * `(organization, project, environment)` for its whole life — see
23
+ * `docs/architecture/system-architecture.md` section 3. Repeating the tuple on
24
+ * every row would invite two answers to the same question.
25
+ */
26
+ /**
27
+ * Every state a schedule can be in, in lifecycle order.
28
+ *
29
+ * `paused` is reversible and `cancelled` is terminal. `completed` is what a
30
+ * finite schedule reaches on its own — a one-shot that fired, or a series that
31
+ * ran out of occurrences — and is distinct from `cancelled` because "it
32
+ * finished" and "someone stopped it" are different answers to a support
33
+ * question.
34
+ */
35
+ export declare const SCHEDULE_STATUSES: readonly ["active", "paused", "cancelled", "completed"];
36
+ export declare const scheduleStatusSchema: z.ZodEnum<{
37
+ paused: "paused";
38
+ active: "active";
39
+ cancelled: "cancelled";
40
+ completed: "completed";
41
+ }>;
42
+ export type ScheduleStatus = z.infer<typeof scheduleStatusSchema>;
43
+ /**
44
+ * How promptly an occurrence expects to be dispatched.
45
+ *
46
+ * Two classes, not a numeric priority: a number invites callers to bid against
47
+ * each other, and a scheduler that honours arbitrary priorities cannot promise
48
+ * anything to anybody. `realtime` gets preference without starving `bulk`.
49
+ */
50
+ export declare const LATENCY_CLASSES: readonly ["realtime", "bulk"];
51
+ export declare const latencyClassSchema: z.ZodEnum<{
52
+ realtime: "realtime";
53
+ bulk: "bulk";
54
+ }>;
55
+ export type LatencyClass = z.infer<typeof latencyClassSchema>;
56
+ /**
57
+ * How long a receiver may take to answer, as a ladder rather than a number.
58
+ *
59
+ * **A ladder because every rung is a different product.** The first two are the
60
+ * ordinary path: a delivery is carried inside the partition's own dispatch and
61
+ * holds one of six in-flight slots for its whole duration, so the cost of a slow
62
+ * receiver is paid by every other schedule in that
63
+ * `(organization, project, environment)`. The rungs above are carried elsewhere
64
+ * and priced, because that is the only honest way to sell them.
65
+ *
66
+ * **Deliberately not a free-form integer.** A caller that could ask for 47
67
+ * seconds would be asking a question this product has no answer to: 47 is past
68
+ * the point where a delivery may occupy a partition slot and short of the point
69
+ * where it is worth carrying separately. The ladder is what makes "which side of
70
+ * the line is this" a decision somebody took rather than a comparison somebody
71
+ * wrote.
72
+ */
73
+ export declare const DELIVERY_DURATION_TIERS: readonly [5, 30, 300, 900, 1800, 3600, 43200, 86400];
74
+ /**
75
+ * What a schedule gets without asking, in seconds.
76
+ *
77
+ * Five, and it is a **six-fold tightening of the 30 seconds that shipped**. The
78
+ * reason is `DEFAULT_MAX_OUTSTANDING`: a partition dispatches six deliveries at
79
+ * once because Cloudflare permits six connections per invocation to be waiting
80
+ * for response headers, so a partition's throughput is six divided by how long a
81
+ * delivery takes. At 30 seconds that is twelve deliveries a minute for
82
+ * everything a customer has scheduled in one project and environment; at five it
83
+ * is seventy-two. The everyday reminder webhook this product is designed around
84
+ * answers in well under a second, and the schedules that do not now have
85
+ * somewhere to say so.
86
+ */
87
+ export declare const DEFAULT_DELIVERY_DURATION_SECONDS = 5;
88
+ /**
89
+ * The longest duration that is not a long-running schedule, in seconds.
90
+ *
91
+ * Thirty. A receiver that writes a row and calls one API can exceed five seconds
92
+ * without being a long-running job, and making that customer buy a plan to fix
93
+ * an occasional timeout would price the most ordinary failure there is. Above
94
+ * this the delivery is carried outside the partition and is a plan feature.
95
+ *
96
+ * EasyCron, which sells this ladder, allows **five seconds** on its free tier
97
+ * and nothing between that and twelve hours. The thirty-second rung is a
98
+ * deliberate difference from them rather than an oversight.
99
+ */
100
+ export declare const FREE_DELIVERY_DURATION_SECONDS = 30;
101
+ /**
102
+ * The longest a receiver may hold the request itself open, in seconds.
103
+ *
104
+ * Thirty minutes, and it is a platform fact rather than a commercial one. A
105
+ * `response` delivery is carried by a Workflow step holding a live socket, and
106
+ * Cloudflare restarts the Workers runtime a few times a week, giving in-flight
107
+ * requests a thirty-second grace period and terminating whatever is left. Their
108
+ * own limits page calls that "very unlikely" — which is true of a five-second
109
+ * delivery and inverts as the hold grows: at roughly three restarts a week a
110
+ * twelve-hour hold overlaps one about one time in five, and a twenty-four-hour
111
+ * hold about two in five.
112
+ *
113
+ * A terminated hold is not a lost occurrence — the watchdog settles it
114
+ * `network_ambiguous` and the ladder retries it — but `network_ambiguous` on a
115
+ * twelve-hour job means "your receiver may have run this, and we are about to
116
+ * ask it to run again". Selling that as a duration would be selling a coin flip.
117
+ *
118
+ * So the rungs above this are `callback` only. A `callback` receiver answers
119
+ * immediately and reports afterwards, so there is no hold for a restart to
120
+ * terminate — the attempt waits in one indexed row, which is not running when
121
+ * the runtime restarts. Cloudflare's own "limit timeouts to 30 minutes or less"
122
+ * advice lands on the same number from the same direction, which is the reason
123
+ * this constant is 1,800 rather than a round guess.
124
+ *
125
+ * **This is a ceiling on the mechanism, not on the ladder.** Every rung is still
126
+ * for sale and the duration is still what is priced; what a customer buying more
127
+ * than thirty minutes has to do is answer immediately and call us back.
128
+ */
129
+ export declare const RESPONSE_DELIVERY_MAX_DURATION_SECONDS = 1800;
130
+ export declare const deliveryDurationSecondsSchema: z.ZodLiteral<5 | 300 | 86400 | 30 | 900 | 1800 | 3600 | 43200>;
131
+ export type DeliveryDurationSeconds = z.infer<typeof deliveryDurationSecondsSchema>;
132
+ /** Whether a duration is past the point where it needs a plan that allows it. */
133
+ export declare function isLongRunningDuration(seconds: number): boolean;
134
+ /**
135
+ * How the receiver tells us the work finished.
136
+ *
137
+ * - `response` — it answers the POST when it is done, and we hold the request
138
+ * open for up to `maxDurationSeconds`. Nothing to build on the receiver's
139
+ * side; its own stack has to tolerate a request open that long, which is the
140
+ * customer's constraint rather than ours and is the one they will meet first.
141
+ * Available up to {@link RESPONSE_DELIVERY_MAX_DURATION_SECONDS}.
142
+ * - `callback` — it answers immediately to say it has the work, does the work,
143
+ * and calls the completion URL in the envelope when it is done. More to build
144
+ * on the receiver's side and no upper bound worth naming.
145
+ *
146
+ * **What is sold is the duration rather than the mechanism.** The operator
147
+ * settled that on 2026-08-12: `callback` costs this product almost nothing to
148
+ * run — an instance waiting for an event hibernates, one holding a socket does
149
+ * not — so pricing it separately would charge for the option we would rather
150
+ * every customer took.
151
+ *
152
+ * **Both were available at every rung until 2026-08-13**, and what changed is
153
+ * not the pricing but a measured platform limit: see
154
+ * {@link RESPONSE_DELIVERY_MAX_DURATION_SECONDS} for why a held-open request
155
+ * stops being a promise somebody can keep at the top three rungs. The ladder is
156
+ * untouched, and so is what a rung costs.
157
+ */
158
+ export declare const DELIVERY_COMPLETION_MODES: readonly ["response", "callback"];
159
+ export declare const deliveryCompletionModeSchema: z.ZodEnum<{
160
+ response: "response";
161
+ callback: "callback";
162
+ }>;
163
+ export type DeliveryCompletionMode = z.infer<typeof deliveryCompletionModeSchema>;
164
+ /**
165
+ * What to do when a recurring schedule comes due and its previous run has not
166
+ * finished.
167
+ *
168
+ * **There was no answer to this before long-running deliveries**, and the
169
+ * absence was deliberate rather than an oversight: `PartitionKernel.advanceSeries`
170
+ * never reads the head occurrence's state, because a series whose advance
171
+ * depended on delivery succeeding would stop a customer's daily schedule the
172
+ * first time their receiver had a bad afternoon. That reasoning is untouched for
173
+ * every schedule on the default duration, where a run lasts five seconds and an
174
+ * overlap is not a thing anyone can construct.
175
+ *
176
+ * It stops being true at twelve hours. An hourly schedule whose runs take twelve
177
+ * hours has twelve of them alive at once under the old rule, and no customer
178
+ * means that. So this setting exists **only on a long-running schedule**, which
179
+ * is the narrowest place it can live and still answer the question.
180
+ *
181
+ * - `skip` — do not run; record the occurrence as skipped. The default.
182
+ * - `queue` — run it when the previous one finishes.
183
+ */
184
+ export declare const DELIVERY_OVERLAP_POLICIES: readonly ["skip", "queue"];
185
+ export declare const deliveryOverlapPolicySchema: z.ZodEnum<{
186
+ skip: "skip";
187
+ queue: "queue";
188
+ }>;
189
+ export type DeliveryOverlapPolicy = z.infer<typeof deliveryOverlapPolicySchema>;
190
+ export declare const DEFAULT_DELIVERY_OVERLAP_POLICY: DeliveryOverlapPolicy;
191
+ /**
192
+ * A definition generation. Starts at 1 and increases on every replacement.
193
+ *
194
+ * Deliberately separate from `version`. `version` moves for any write at all,
195
+ * including a pause, and drives ETags; `generation` moves only when the *work*
196
+ * changes, and is what a due event is checked against. Folding them together
197
+ * would make pausing and resuming a schedule invalidate occurrences that are
198
+ * still perfectly valid.
199
+ */
200
+ export declare const generationSchema: z.ZodNumber;
201
+ export type Generation = z.infer<typeof generationSchema>;
202
+ /**
203
+ * A customer-supplied fairness key.
204
+ *
205
+ * Bounded in length and charset because it is used as a telemetry label and as
206
+ * a pacing lane: an unbounded key would let one caller mint unbounded
207
+ * cardinality in our metrics, and a key carrying arbitrary bytes would end up
208
+ * in a log line that nothing downstream can parse. It selects a lane within the
209
+ * caller's own partition and can never change the authority tuple or reach
210
+ * another Durable Object namespace.
211
+ */
212
+ export declare const PARTITION_KEY_MAX_LENGTH = 64;
213
+ export declare const partitionKeySchema: z.ZodString;
214
+ export type PartitionKey = z.infer<typeof partitionKeySchema>;
215
+ /**
216
+ * Every state one occurrence can be in.
217
+ *
218
+ * `ambiguous` is a first-class state rather than a kind of failure. When a
219
+ * request times out the receiver may or may not have acted, and calling that
220
+ * either "succeeded" or "failed" is how an occurrence is silently dropped or
221
+ * silently duplicated.
222
+ *
223
+ * `skipped_stale` records an occurrence that became due too late to be worth
224
+ * firing, or whose definition was replaced underneath it. It is deliberately
225
+ * not `cancelled`: a customer who cancelled something and a customer whose
226
+ * occurrence went stale need different explanations.
227
+ */
228
+ export declare const OCCURRENCE_STATES: readonly ["planned", "due", "dispatching", "retry_wait", "ambiguous", "succeeded", "terminal_failed", "cancelled", "skipped_stale"];
229
+ export declare const occurrenceStateSchema: z.ZodEnum<{
230
+ succeeded: "succeeded";
231
+ ambiguous: "ambiguous";
232
+ cancelled: "cancelled";
233
+ planned: "planned";
234
+ due: "due";
235
+ dispatching: "dispatching";
236
+ retry_wait: "retry_wait";
237
+ terminal_failed: "terminal_failed";
238
+ skipped_stale: "skipped_stale";
239
+ }>;
240
+ export type OccurrenceState = z.infer<typeof occurrenceStateSchema>;
241
+ /**
242
+ * The states an occurrence never leaves.
243
+ *
244
+ * Exported so a caller enumerates them rather than writing the list out and
245
+ * quietly missing one if another is ever added.
246
+ */
247
+ export declare const TERMINAL_OCCURRENCE_STATES: readonly ["succeeded", "terminal_failed", "cancelled", "skipped_stale"];
248
+ export declare function isTerminalOccurrenceState(state: OccurrenceState): boolean;
249
+ /**
250
+ * How one delivery attempt was classified. Immutable once set.
251
+ *
252
+ * These four are the attempt-level counterpart of `ResponseClass` in
253
+ * `signatures.ts`, which classifies a *response*. They are kept as separate
254
+ * vocabularies on purpose: a response class is a fact about what came back, and
255
+ * an attempt state is a fact about the attempt as a whole, including an attempt
256
+ * that never received a response at all. `attemptStateForResponse` is the only
257
+ * sanctioned mapping between them.
258
+ */
259
+ export declare const ATTEMPT_STATES: readonly ["succeeded", "retryable_failure", "terminal_failure", "ambiguous"];
260
+ export declare const attemptStateSchema: z.ZodEnum<{
261
+ succeeded: "succeeded";
262
+ ambiguous: "ambiguous";
263
+ retryable_failure: "retryable_failure";
264
+ terminal_failure: "terminal_failure";
265
+ }>;
266
+ export type AttemptState = z.infer<typeof attemptStateSchema>;
267
+ /** Safe diagnostic codes produced by the W3-03 delivery classifier. */
268
+ export declare const attemptDiagnosticSchema: z.ZodEnum<{
269
+ rate_limited: "rate_limited";
270
+ completion_timed_out: "completion_timed_out";
271
+ delivered: "delivered";
272
+ duplicate_inflight: "duplicate_inflight";
273
+ endpoint_unavailable: "endpoint_unavailable";
274
+ endpoint_unsafe: "endpoint_unsafe";
275
+ http_refused: "http_refused";
276
+ http_retryable: "http_retryable";
277
+ http_terminal: "http_terminal";
278
+ identity_conflict: "identity_conflict";
279
+ network_ambiguous: "network_ambiguous";
280
+ payload_unavailable: "payload_unavailable";
281
+ }>;
282
+ export type AttemptDiagnostic = z.infer<typeof attemptDiagnosticSchema>;
283
+ /**
284
+ * Bounded next-action hints for an attempt timeline.
285
+ *
286
+ * These are codes rather than prose so a client can render its own guidance
287
+ * without ever receiving an executor exception, destination, response body,
288
+ * payload, or secret. `review_retry_policy` names the historical category
289
+ * without promising that the occurrence still has automatic work to do.
290
+ */
291
+ export declare const ATTEMPT_REMEDIATIONS: readonly ["none", "review_retry_policy", "inspect_receiver", "verify_endpoint", "replace_payload", "contact_support", "review_before_redelivery"];
292
+ /**
293
+ * How much of one retained response header is published, in characters.
294
+ *
295
+ * The sender caps it at 256 **bytes**, and this is the schema's own bound on
296
+ * what may be presented — deliberately the looser of the two, because a schema
297
+ * that refused what the sender legitimately stored would make a delivery
298
+ * unreadable rather than a header untidy.
299
+ */
300
+ export declare const ATTEMPT_RESPONSE_HEADER_MAX_LENGTH = 256;
301
+ /** How much of a failed receiver's body is published, in characters. */
302
+ export declare const ATTEMPT_FAILURE_SNIPPET_MAX_LENGTH = 4096;
303
+ export declare const attemptRemediationSchema: z.ZodEnum<{
304
+ none: "none";
305
+ review_retry_policy: "review_retry_policy";
306
+ inspect_receiver: "inspect_receiver";
307
+ verify_endpoint: "verify_endpoint";
308
+ replace_payload: "replace_payload";
309
+ contact_support: "contact_support";
310
+ review_before_redelivery: "review_before_redelivery";
311
+ }>;
312
+ export type AttemptRemediation = z.infer<typeof attemptRemediationSchema>;
313
+ /** Derive the one safe next-action code a public attempt may expose. */
314
+ export declare function remediationForAttempt(diagnostic: AttemptDiagnostic): AttemptRemediation;
315
+ /**
316
+ * Why this immutable attempt exists.
317
+ *
318
+ * Automatic work has no causal attempt. A manual redelivery names the
319
+ * retained attempt the caller chose to follow, which preserves both identities
320
+ * and makes the new row an honest link instead of a rewrite of the old one.
321
+ *
322
+ * **Deliberately the same schema the signed callback envelope carries**, rather
323
+ * than a second declaration of the same shape. From W3-08 the attempt's trigger
324
+ * is what reaches the receiver, so a reader of the timeline and a receiver
325
+ * branching on the wire are looking at one fact. Two definitions would drift,
326
+ * and the failure mode of that drift is a receiver that re-runs work for a
327
+ * cause the history says never happened.
328
+ */
329
+ export declare const attemptTriggerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
330
+ kind: z.ZodLiteral<"automatic">;
331
+ }, z.core.$strip>, z.ZodObject<{
332
+ kind: z.ZodLiteral<"redelivery">;
333
+ sourceAttemptId: z.ZodString;
334
+ }, z.core.$strip>], "kind">;
335
+ export type AttemptTrigger = CallbackTrigger;
336
+ /**
337
+ * The largest elapsed time JSON can carry without losing integer precision.
338
+ *
339
+ * Runtime timeout policies are ordinarily much smaller, but their configured
340
+ * ceiling is not a public invariant. Bounding the wire at the safe-integer
341
+ * edge keeps corrupt or non-finite timing out without clamping honest durable
342
+ * evidence into a value the executor did not report.
343
+ */
344
+ export declare const ATTEMPT_DURATION_MAX_MS: number;
345
+ /** The attempt state a classified response produces. */
346
+ export declare function attemptStateForResponse(responseClass: ResponseClass): AttemptState;
347
+ /**
348
+ * The runtime's default bounds, in one place.
349
+ *
350
+ * **These are engineering defaults, not plan limits.** They exist because a
351
+ * partition has to bound its own growth to stay affordable and predictable, and
352
+ * every one of them is enforced by the storage layer today. What they are *not*
353
+ * is a commercial decision: `docs/product/vision-and-strategy.md` section 11
354
+ * names retained history, payload size, active schedules, realtime rate,
355
+ * endpoints and forecast horizon as **plan limits**, and puts limits and
356
+ * retention behind the W7 commercial gate. W7 sets the per-plan numbers; these
357
+ * are what a partition enforces until it does, and the partition store takes
358
+ * them as an argument precisely so a plan can supply its own.
359
+ *
360
+ * Durations are whole seconds, per `docs/contracts/v1-conventions.md`.
361
+ */
362
+ export declare const SCHEDULING_BOUNDS: {
363
+ /**
364
+ * Attempts made against one occurrence before it is terminal, including the
365
+ * first. Bounded so a permanently broken receiver cannot make one occurrence
366
+ * cost an unbounded amount of work.
367
+ */
368
+ readonly attemptsPerOccurrence: 8;
369
+ /**
370
+ * The longest fixed interval a recurring schedule may ask for, in seconds.
371
+ *
372
+ * Thirty days, which is the copied scheduler's `MAX_INTERVAL_SECONDS` kept
373
+ * rather than a new number invented beside it, and its reason is the
374
+ * platform's rather than the product's: a Durable Object alarm is not
375
+ * arbitrarily far in the future.
376
+ */
377
+ readonly everySecondsMax: number;
378
+ /**
379
+ * The shortest fixed interval a recurring schedule may ask for, in seconds.
380
+ *
381
+ * One minute, and this one is **not** inherited: the copy admits a one-second
382
+ * interval, which is 86,400 alarm wakes a day for a single schedule. A minute
383
+ * is also the finest instant a five-field cron expression can name, so both
384
+ * ways of expressing a recurrence promise the same granularity rather than
385
+ * one of them quietly promising more. Widening this later is additive by
386
+ * `classifyChange` and narrowing it is breaking, which is the direction to be
387
+ * conservative in.
388
+ */
389
+ readonly everySecondsMin: 60;
390
+ /**
391
+ * How long an idempotency receipt is honoured. A client retrying a create for
392
+ * longer than a day is not retrying, it is making a new request; keeping
393
+ * receipts beyond that turns the partition into an unbounded key/value store.
394
+ */
395
+ readonly idempotencyReceiptSeconds: number;
396
+ /**
397
+ * Concrete occurrences materialized **ahead of time** for one schedule.
398
+ *
399
+ * One, which is architecture section 15's default: a series is written one
400
+ * occurrence at a time rather than as a horizon, because a horizon multiplies
401
+ * row count by its own length and makes a replace rewrite all of it.
402
+ *
403
+ * **What it bounds is lead time, not live rows, and W2-04 settled that.**
404
+ * Read as "one non-terminal occurrence" it would forbid architecture section
405
+ * 6's own fire flow, which marks the current occurrence `due` and plans its
406
+ * successor in one transaction and therefore holds two. Read as this wording
407
+ * already says — materialized *ahead of time* — it means a schedule holds at
408
+ * most one `planned` occurrence whose instant has not yet arrived, which
409
+ * permits that transaction, permits an advance and a serve to land in either
410
+ * order within one wake, and still forbids the horizon it exists to forbid.
411
+ *
412
+ * Enforced by `PartitionStore.insertOccurrence`, where occurrences are
413
+ * planned, rather than by a unique index — an index cannot reference the
414
+ * present, and the present is what "ahead of time" is measured against.
415
+ */
416
+ readonly materializedOccurrencesPerSchedule: 1;
417
+ /**
418
+ * How long occurrence and attempt history is retained before it is swept.
419
+ * Long enough to explain last month's invoice, short enough that a busy
420
+ * partition's history does not outgrow its schedules.
421
+ */
422
+ readonly occurrenceHistorySeconds: number;
423
+ /**
424
+ * How far ahead a one-shot may be asked for as a *delay*, in seconds — about
425
+ * five years, which is the copied scheduler's `MAX_ONESHOT_SECONDS` kept
426
+ * rather than a new number invented beside it.
427
+ *
428
+ * It bounds `delaySeconds` and deliberately does not bound `at`. Narrowing a
429
+ * request field that is already published is breaking by `classifyChange`,
430
+ * and `at` shipped with W1-08; a horizon on both belongs with the plan limits
431
+ * W7 owns, which is where a customer-visible ceiling can be set once for
432
+ * every way of expressing the same instant.
433
+ */
434
+ readonly oneShotDelaySeconds: 158000000;
435
+ /**
436
+ * The customer payload carried to the callback, in bytes, measured on the
437
+ * UTF-8 encoding of the JSON the caller sent. 64 KiB comfortably fits the
438
+ * command-shaped payloads this product is for, and refuses the ones that are
439
+ * really a file transfer.
440
+ */
441
+ readonly payloadBytes: 65536;
442
+ /**
443
+ * How soon a one-shot has to be for `realtime` to be the class it gets by
444
+ * default, in seconds.
445
+ *
446
+ * Two minutes, which is the copied `validate.ts`'s own threshold kept rather
447
+ * than a number invented beside it: upstream classifies an `at` or a `delay`
448
+ * inside 120 seconds as realtime and everything else as bulk, on the
449
+ * reasoning that a wait that short is a human waiting on a screen. A caller
450
+ * who disagrees says so — `latencyClass` on the request is what makes this a
451
+ * default rather than a rule.
452
+ */
453
+ readonly realtimeOneShotSeconds: 120;
454
+ };
455
+ /**
456
+ * The longest cron expression this surface accepts, in characters.
457
+ *
458
+ * A five-field expression naming every value it could name is well under a
459
+ * hundred characters, so this refuses a field list built to make a parser work
460
+ * hard without refusing anything a human would write.
461
+ */
462
+ export declare const CRON_EXPRESSION_MAX_LENGTH = 120;
463
+ /**
464
+ * A cron expression, checked for shape and deliberately not for meaning.
465
+ *
466
+ * **What a schema can honestly promise here is the interesting part.** Whether
467
+ * an expression parses, whether its fields are in range, and whether it names
468
+ * an instant that ever arrives are all decisions belonging to the engine that
469
+ * resolves it — the partition, which owns timer authority and is the one place
470
+ * `cron-schedule` is a dependency. Encoding them here would mean either a
471
+ * second parser in this package or a JSON Schema pretending to a precision it
472
+ * does not have, and a published schema that lies about what it validates is
473
+ * worse than one that says less. So this bounds the length and the field count
474
+ * and stops; a request that passes it and cannot be resolved is refused by the
475
+ * partition as `invalid_request`, naming which part it could not resolve.
476
+ *
477
+ * Five fields, or the `@`-prefixed nicknames every cron understands. Six-field
478
+ * forms are not refused here — a six-field expression whose seconds field is
479
+ * zero says the same thing as its five-field spelling — but one that asks to
480
+ * fire on a second boundary is refused by the partition, because a minute is
481
+ * the granularity both arms of recurrence promise.
482
+ */
483
+ export declare const cronExpressionSchema: z.ZodString;
484
+ export type CronExpression = z.infer<typeof cronExpressionSchema>;
485
+ /**
486
+ * How a schedule recurs, as a caller reads it back.
487
+ *
488
+ * A discriminated union rather than three optional fields, because "which of
489
+ * these is set" is a question a client should not have to answer by
490
+ * elimination — and because a one-shot is a recurrence of one rather than an
491
+ * absence of recurrence, which is what lets every consumer `switch`
492
+ * exhaustively and be told by its compiler when a fourth kind arrives.
493
+ *
494
+ * `timeZone` is present on the `cron` arm and nowhere else, which is the
495
+ * conventions' rule made structural: a timezone means something alongside a
496
+ * wall-clock recurrence and nothing alongside an instant, where it would only
497
+ * invite a caller to believe an instant had been reinterpreted. It is required
498
+ * on that arm rather than optional, so a read always says which wall clock a
499
+ * cron schedule is on instead of leaving the caller to assume UTC.
500
+ */
501
+ export declare const recurrenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
502
+ kind: z.ZodLiteral<"at">;
503
+ }, z.core.$strip>, z.ZodObject<{
504
+ everySeconds: z.ZodNumber;
505
+ kind: z.ZodLiteral<"every">;
506
+ }, z.core.$strip>, z.ZodObject<{
507
+ cron: z.ZodString;
508
+ kind: z.ZodLiteral<"cron">;
509
+ timeZone: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
510
+ }, z.core.$strip>], "kind">;
511
+ export type Recurrence = z.infer<typeof recurrenceSchema>;
512
+ /**
513
+ * A schedule, as a client sees it.
514
+ *
515
+ * A callback schedule exposes the reusable endpoint it references, but never
516
+ * the payload stored for that endpoint and never its signing secret. The
517
+ * endpoint id is useful definition metadata; the encrypted payload is content
518
+ * and stays only in the authoritative partition.
519
+ */
520
+ export declare const scheduleSchema: z.ZodObject<{
521
+ archivedAt: z.ZodOptional<z.ZodString>;
522
+ createdAt: z.ZodString;
523
+ delivery: z.ZodOptional<z.ZodObject<{
524
+ completion: z.ZodEnum<{
525
+ response: "response";
526
+ callback: "callback";
527
+ }>;
528
+ maxDurationSeconds: z.ZodNumber;
529
+ onOverlap: z.ZodEnum<{
530
+ skip: "skip";
531
+ queue: "queue";
532
+ }>;
533
+ }, z.core.$strip>>;
534
+ endpoint: z.ZodOptional<z.ZodString>;
535
+ generation: z.ZodNumber;
536
+ id: z.ZodString;
537
+ latencyClass: z.ZodEnum<{
538
+ realtime: "realtime";
539
+ bulk: "bulk";
540
+ }>;
541
+ partitionKey: z.ZodOptional<z.ZodString>;
542
+ recurrence: z.ZodDiscriminatedUnion<[z.ZodObject<{
543
+ kind: z.ZodLiteral<"at">;
544
+ }, z.core.$strip>, z.ZodObject<{
545
+ everySeconds: z.ZodNumber;
546
+ kind: z.ZodLiteral<"every">;
547
+ }, z.core.$strip>, z.ZodObject<{
548
+ cron: z.ZodString;
549
+ kind: z.ZodLiteral<"cron">;
550
+ timeZone: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
551
+ }, z.core.$strip>], "kind">;
552
+ status: z.ZodEnum<{
553
+ paused: "paused";
554
+ active: "active";
555
+ cancelled: "cancelled";
556
+ completed: "completed";
557
+ }>;
558
+ updatedAt: z.ZodString;
559
+ version: z.ZodNumber;
560
+ }, z.core.$strip>;
561
+ export type Schedule = z.infer<typeof scheduleSchema>;
562
+ /**
563
+ * A page of schedules.
564
+ *
565
+ * Items are schedules rather than schedule *views*. A cross-partition listing is
566
+ * served from the D1 projection W2-06 built, and that projection holds a route
567
+ * and a summary rather than every partition's live occurrence — so a page that
568
+ * promised an occurrence would either lie about its freshness or force the
569
+ * listing back through every partition it spans. Detail is where the occurrence
570
+ * is authoritative, and detail is one call away.
571
+ */
572
+ export declare const schedulePageSchema: z.ZodObject<{
573
+ data: z.ZodArray<z.ZodObject<{
574
+ archivedAt: z.ZodOptional<z.ZodString>;
575
+ createdAt: z.ZodString;
576
+ delivery: z.ZodOptional<z.ZodObject<{
577
+ completion: z.ZodEnum<{
578
+ response: "response";
579
+ callback: "callback";
580
+ }>;
581
+ maxDurationSeconds: z.ZodNumber;
582
+ onOverlap: z.ZodEnum<{
583
+ skip: "skip";
584
+ queue: "queue";
585
+ }>;
586
+ }, z.core.$strip>>;
587
+ endpoint: z.ZodOptional<z.ZodString>;
588
+ generation: z.ZodNumber;
589
+ id: z.ZodString;
590
+ latencyClass: z.ZodEnum<{
591
+ realtime: "realtime";
592
+ bulk: "bulk";
593
+ }>;
594
+ partitionKey: z.ZodOptional<z.ZodString>;
595
+ recurrence: z.ZodDiscriminatedUnion<[z.ZodObject<{
596
+ kind: z.ZodLiteral<"at">;
597
+ }, z.core.$strip>, z.ZodObject<{
598
+ everySeconds: z.ZodNumber;
599
+ kind: z.ZodLiteral<"every">;
600
+ }, z.core.$strip>, z.ZodObject<{
601
+ cron: z.ZodString;
602
+ kind: z.ZodLiteral<"cron">;
603
+ timeZone: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
604
+ }, z.core.$strip>], "kind">;
605
+ status: z.ZodEnum<{
606
+ paused: "paused";
607
+ active: "active";
608
+ cancelled: "cancelled";
609
+ completed: "completed";
610
+ }>;
611
+ updatedAt: z.ZodString;
612
+ version: z.ZodNumber;
613
+ }, z.core.$strip>>;
614
+ freshness: z.ZodDiscriminatedUnion<[z.ZodObject<{
615
+ kind: z.ZodLiteral<"authoritative">;
616
+ }, z.core.$strip>, z.ZodObject<{
617
+ asOf: z.ZodString;
618
+ kind: z.ZodLiteral<"projected">;
619
+ lagSeconds: z.ZodNumber;
620
+ }, z.core.$strip>], "kind">;
621
+ nextCursor: z.ZodOptional<z.ZodString>;
622
+ }, z.core.$strip>;
623
+ export type SchedulePage = z.infer<typeof schedulePageSchema>;
624
+ /**
625
+ * One concrete occurrence of a schedule.
626
+ *
627
+ * `sequence` is the occurrence's position in its series, starting at 1, and is
628
+ * scoped to a generation: replacing a definition starts a new generation whose
629
+ * numbering starts again. Together `(schedule, generation, sequence)` is what
630
+ * makes an occurrence identifiable without depending on when it was written.
631
+ */
632
+ export declare const occurrenceSchema: z.ZodObject<{
633
+ attemptCount: z.ZodNumber;
634
+ generation: z.ZodNumber;
635
+ id: z.ZodString;
636
+ plannedFor: z.ZodString;
637
+ schedule: z.ZodString;
638
+ sequence: z.ZodNumber;
639
+ settledAt: z.ZodOptional<z.ZodString>;
640
+ state: z.ZodEnum<{
641
+ succeeded: "succeeded";
642
+ ambiguous: "ambiguous";
643
+ cancelled: "cancelled";
644
+ planned: "planned";
645
+ due: "due";
646
+ dispatching: "dispatching";
647
+ retry_wait: "retry_wait";
648
+ terminal_failed: "terminal_failed";
649
+ skipped_stale: "skipped_stale";
650
+ }>;
651
+ }, z.core.$strip>;
652
+ export type Occurrence = z.infer<typeof occurrenceSchema>;
653
+ /**
654
+ * One delivery attempt against one occurrence.
655
+ *
656
+ * `delivery` is the identifier the callback signature covers and the receiver
657
+ * dedupes on, so it is per-attempt rather than per-occurrence: a retry is a new
658
+ * delivery, and a receiver that saw the first one must be able to tell.
659
+ *
660
+ * `state` is absent while the attempt is in flight. That is the ambiguity the
661
+ * watchdog resolves, and modelling it as absent rather than defaulting it to a
662
+ * failure is what stops an in-flight attempt from being counted as one that
663
+ * came back.
664
+ */
665
+ /**
666
+ * Bounded, non-secret evidence about the response a receiver sent.
667
+ *
668
+ * **A closed allowlist rather than "the headers".** A response header is
669
+ * receiver-controlled text that lands in durable history and on a support
670
+ * screen, so the question is not "is this one dangerous" but "does this one
671
+ * earn its place": the media type explains what the snippet is, `Retry-After`
672
+ * explains a pacing decision the customer can see, and one receiver-side
673
+ * identifier turns "your receiver refused this" into something an integrator
674
+ * can look up in their own logs. Cookies, `Authorization` and
675
+ * `WWW-Authenticate` have no representation here at all.
676
+ */
677
+ export declare const attemptResponseHeaderSchema: z.ZodObject<{
678
+ name: z.ZodString;
679
+ value: z.ZodString;
680
+ }, z.core.$strip>;
681
+ export type AttemptResponseHeader = z.infer<typeof attemptResponseHeaderSchema>;
682
+ /**
683
+ * What a failing receiver said, bounded and access-controlled.
684
+ *
685
+ * Present only on a **failed** attempt whose response carried a text or JSON
686
+ * media type, and only where the plan retains one. A successful response body
687
+ * is never retained, and neither is a pending acknowledgement's: the customer
688
+ * content this product keeps is the content that helps somebody fix a broken
689
+ * receiver, and nothing else.
690
+ *
691
+ * `truncated` is carried rather than inferred from the length, because a body
692
+ * that is exactly the bound and a body that was cut at the bound are different
693
+ * facts and only one of them should show a customer an ellipsis.
694
+ */
695
+ export declare const attemptFailureSnippetSchema: z.ZodObject<{
696
+ contentType: z.ZodString;
697
+ text: z.ZodString;
698
+ truncated: z.ZodBoolean;
699
+ }, z.core.$strip>;
700
+ export type AttemptFailureSnippet = z.infer<typeof attemptFailureSnippetSchema>;
701
+ export declare const attemptSchema: z.ZodObject<{
702
+ attemptNumber: z.ZodNumber;
703
+ classifiedAt: z.ZodOptional<z.ZodString>;
704
+ delivery: z.ZodString;
705
+ diagnostic: z.ZodOptional<z.ZodEnum<{
706
+ rate_limited: "rate_limited";
707
+ completion_timed_out: "completion_timed_out";
708
+ delivered: "delivered";
709
+ duplicate_inflight: "duplicate_inflight";
710
+ endpoint_unavailable: "endpoint_unavailable";
711
+ endpoint_unsafe: "endpoint_unsafe";
712
+ http_refused: "http_refused";
713
+ http_retryable: "http_retryable";
714
+ http_terminal: "http_terminal";
715
+ identity_conflict: "identity_conflict";
716
+ network_ambiguous: "network_ambiguous";
717
+ payload_unavailable: "payload_unavailable";
718
+ }>>;
719
+ durationMs: z.ZodOptional<z.ZodNumber>;
720
+ id: z.ZodString;
721
+ occurrence: z.ZodString;
722
+ remediation: z.ZodOptional<z.ZodEnum<{
723
+ none: "none";
724
+ review_retry_policy: "review_retry_policy";
725
+ inspect_receiver: "inspect_receiver";
726
+ verify_endpoint: "verify_endpoint";
727
+ replace_payload: "replace_payload";
728
+ contact_support: "contact_support";
729
+ review_before_redelivery: "review_before_redelivery";
730
+ }>>;
731
+ failureSnippet: z.ZodOptional<z.ZodObject<{
732
+ contentType: z.ZodString;
733
+ text: z.ZodString;
734
+ truncated: z.ZodBoolean;
735
+ }, z.core.$strip>>;
736
+ responseHeaders: z.ZodOptional<z.ZodArray<z.ZodObject<{
737
+ name: z.ZodString;
738
+ value: z.ZodString;
739
+ }, z.core.$strip>>>;
740
+ responseStatus: z.ZodOptional<z.ZodNumber>;
741
+ startedAt: z.ZodString;
742
+ state: z.ZodOptional<z.ZodEnum<{
743
+ succeeded: "succeeded";
744
+ ambiguous: "ambiguous";
745
+ retryable_failure: "retryable_failure";
746
+ terminal_failure: "terminal_failure";
747
+ }>>;
748
+ trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
749
+ kind: z.ZodLiteral<"automatic">;
750
+ }, z.core.$strip>, z.ZodObject<{
751
+ kind: z.ZodLiteral<"redelivery">;
752
+ sourceAttemptId: z.ZodString;
753
+ }, z.core.$strip>], "kind">;
754
+ }, z.core.$strip>;
755
+ export type Attempt = z.infer<typeof attemptSchema>;
756
+ /** An authoritative page over one schedule's retained occurrences. */
757
+ export declare const occurrencePageSchema: z.ZodObject<{
758
+ data: z.ZodArray<z.ZodObject<{
759
+ attemptCount: z.ZodNumber;
760
+ generation: z.ZodNumber;
761
+ id: z.ZodString;
762
+ plannedFor: z.ZodString;
763
+ schedule: z.ZodString;
764
+ sequence: z.ZodNumber;
765
+ settledAt: z.ZodOptional<z.ZodString>;
766
+ state: z.ZodEnum<{
767
+ succeeded: "succeeded";
768
+ ambiguous: "ambiguous";
769
+ cancelled: "cancelled";
770
+ planned: "planned";
771
+ due: "due";
772
+ dispatching: "dispatching";
773
+ retry_wait: "retry_wait";
774
+ terminal_failed: "terminal_failed";
775
+ skipped_stale: "skipped_stale";
776
+ }>;
777
+ }, z.core.$strip>>;
778
+ nextCursor: z.ZodOptional<z.ZodString>;
779
+ freshness: z.ZodObject<{
780
+ kind: z.ZodLiteral<"authoritative">;
781
+ }, z.core.$strip>;
782
+ }, z.core.$strip>;
783
+ export type OccurrencePage = z.infer<typeof occurrencePageSchema>;
784
+ /** An authoritative occurrence detail response. */
785
+ export declare const occurrenceViewSchema: z.ZodObject<{
786
+ freshness: z.ZodObject<{
787
+ kind: z.ZodLiteral<"authoritative">;
788
+ }, z.core.$strip>;
789
+ occurrence: z.ZodObject<{
790
+ attemptCount: z.ZodNumber;
791
+ generation: z.ZodNumber;
792
+ id: z.ZodString;
793
+ plannedFor: z.ZodString;
794
+ schedule: z.ZodString;
795
+ sequence: z.ZodNumber;
796
+ settledAt: z.ZodOptional<z.ZodString>;
797
+ state: z.ZodEnum<{
798
+ succeeded: "succeeded";
799
+ ambiguous: "ambiguous";
800
+ cancelled: "cancelled";
801
+ planned: "planned";
802
+ due: "due";
803
+ dispatching: "dispatching";
804
+ retry_wait: "retry_wait";
805
+ terminal_failed: "terminal_failed";
806
+ skipped_stale: "skipped_stale";
807
+ }>;
808
+ }, z.core.$strip>;
809
+ }, z.core.$strip>;
810
+ export type OccurrenceView = z.infer<typeof occurrenceViewSchema>;
811
+ /** An authoritative page over one retained occurrence's immutable attempts. */
812
+ export declare const attemptPageSchema: z.ZodObject<{
813
+ data: z.ZodArray<z.ZodObject<{
814
+ attemptNumber: z.ZodNumber;
815
+ classifiedAt: z.ZodOptional<z.ZodString>;
816
+ delivery: z.ZodString;
817
+ diagnostic: z.ZodOptional<z.ZodEnum<{
818
+ rate_limited: "rate_limited";
819
+ completion_timed_out: "completion_timed_out";
820
+ delivered: "delivered";
821
+ duplicate_inflight: "duplicate_inflight";
822
+ endpoint_unavailable: "endpoint_unavailable";
823
+ endpoint_unsafe: "endpoint_unsafe";
824
+ http_refused: "http_refused";
825
+ http_retryable: "http_retryable";
826
+ http_terminal: "http_terminal";
827
+ identity_conflict: "identity_conflict";
828
+ network_ambiguous: "network_ambiguous";
829
+ payload_unavailable: "payload_unavailable";
830
+ }>>;
831
+ durationMs: z.ZodOptional<z.ZodNumber>;
832
+ id: z.ZodString;
833
+ occurrence: z.ZodString;
834
+ remediation: z.ZodOptional<z.ZodEnum<{
835
+ none: "none";
836
+ review_retry_policy: "review_retry_policy";
837
+ inspect_receiver: "inspect_receiver";
838
+ verify_endpoint: "verify_endpoint";
839
+ replace_payload: "replace_payload";
840
+ contact_support: "contact_support";
841
+ review_before_redelivery: "review_before_redelivery";
842
+ }>>;
843
+ failureSnippet: z.ZodOptional<z.ZodObject<{
844
+ contentType: z.ZodString;
845
+ text: z.ZodString;
846
+ truncated: z.ZodBoolean;
847
+ }, z.core.$strip>>;
848
+ responseHeaders: z.ZodOptional<z.ZodArray<z.ZodObject<{
849
+ name: z.ZodString;
850
+ value: z.ZodString;
851
+ }, z.core.$strip>>>;
852
+ responseStatus: z.ZodOptional<z.ZodNumber>;
853
+ startedAt: z.ZodString;
854
+ state: z.ZodOptional<z.ZodEnum<{
855
+ succeeded: "succeeded";
856
+ ambiguous: "ambiguous";
857
+ retryable_failure: "retryable_failure";
858
+ terminal_failure: "terminal_failure";
859
+ }>>;
860
+ trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
861
+ kind: z.ZodLiteral<"automatic">;
862
+ }, z.core.$strip>, z.ZodObject<{
863
+ kind: z.ZodLiteral<"redelivery">;
864
+ sourceAttemptId: z.ZodString;
865
+ }, z.core.$strip>], "kind">;
866
+ }, z.core.$strip>>;
867
+ nextCursor: z.ZodOptional<z.ZodString>;
868
+ freshness: z.ZodObject<{
869
+ kind: z.ZodLiteral<"authoritative">;
870
+ }, z.core.$strip>;
871
+ }, z.core.$strip>;
872
+ export type AttemptPage = z.infer<typeof attemptPageSchema>;
873
+ /** An authoritative attempt detail or redelivery response. */
874
+ export declare const attemptViewSchema: z.ZodObject<{
875
+ attempt: z.ZodObject<{
876
+ attemptNumber: z.ZodNumber;
877
+ classifiedAt: z.ZodOptional<z.ZodString>;
878
+ delivery: z.ZodString;
879
+ diagnostic: z.ZodOptional<z.ZodEnum<{
880
+ rate_limited: "rate_limited";
881
+ completion_timed_out: "completion_timed_out";
882
+ delivered: "delivered";
883
+ duplicate_inflight: "duplicate_inflight";
884
+ endpoint_unavailable: "endpoint_unavailable";
885
+ endpoint_unsafe: "endpoint_unsafe";
886
+ http_refused: "http_refused";
887
+ http_retryable: "http_retryable";
888
+ http_terminal: "http_terminal";
889
+ identity_conflict: "identity_conflict";
890
+ network_ambiguous: "network_ambiguous";
891
+ payload_unavailable: "payload_unavailable";
892
+ }>>;
893
+ durationMs: z.ZodOptional<z.ZodNumber>;
894
+ id: z.ZodString;
895
+ occurrence: z.ZodString;
896
+ remediation: z.ZodOptional<z.ZodEnum<{
897
+ none: "none";
898
+ review_retry_policy: "review_retry_policy";
899
+ inspect_receiver: "inspect_receiver";
900
+ verify_endpoint: "verify_endpoint";
901
+ replace_payload: "replace_payload";
902
+ contact_support: "contact_support";
903
+ review_before_redelivery: "review_before_redelivery";
904
+ }>>;
905
+ failureSnippet: z.ZodOptional<z.ZodObject<{
906
+ contentType: z.ZodString;
907
+ text: z.ZodString;
908
+ truncated: z.ZodBoolean;
909
+ }, z.core.$strip>>;
910
+ responseHeaders: z.ZodOptional<z.ZodArray<z.ZodObject<{
911
+ name: z.ZodString;
912
+ value: z.ZodString;
913
+ }, z.core.$strip>>>;
914
+ responseStatus: z.ZodOptional<z.ZodNumber>;
915
+ startedAt: z.ZodString;
916
+ state: z.ZodOptional<z.ZodEnum<{
917
+ succeeded: "succeeded";
918
+ ambiguous: "ambiguous";
919
+ retryable_failure: "retryable_failure";
920
+ terminal_failure: "terminal_failure";
921
+ }>>;
922
+ trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
923
+ kind: z.ZodLiteral<"automatic">;
924
+ }, z.core.$strip>, z.ZodObject<{
925
+ kind: z.ZodLiteral<"redelivery">;
926
+ sourceAttemptId: z.ZodString;
927
+ }, z.core.$strip>], "kind">;
928
+ }, z.core.$strip>;
929
+ freshness: z.ZodObject<{
930
+ kind: z.ZodLiteral<"authoritative">;
931
+ }, z.core.$strip>;
932
+ }, z.core.$strip>;
933
+ export type AttemptView = z.infer<typeof attemptViewSchema>;
934
+ /**
935
+ * A schedule together with the occurrence that is next to happen.
936
+ *
937
+ * One document rather than two calls, because "when does this next fire" is the
938
+ * question every caller has immediately after creating a schedule, and a client
939
+ * that has to make a second request to answer it will cache the first answer and
940
+ * be wrong.
941
+ */
942
+ export declare const scheduleViewSchema: z.ZodObject<{
943
+ occurrence: z.ZodObject<{
944
+ attemptCount: z.ZodNumber;
945
+ generation: z.ZodNumber;
946
+ id: z.ZodString;
947
+ plannedFor: z.ZodString;
948
+ schedule: z.ZodString;
949
+ sequence: z.ZodNumber;
950
+ settledAt: z.ZodOptional<z.ZodString>;
951
+ state: z.ZodEnum<{
952
+ succeeded: "succeeded";
953
+ ambiguous: "ambiguous";
954
+ cancelled: "cancelled";
955
+ planned: "planned";
956
+ due: "due";
957
+ dispatching: "dispatching";
958
+ retry_wait: "retry_wait";
959
+ terminal_failed: "terminal_failed";
960
+ skipped_stale: "skipped_stale";
961
+ }>;
962
+ }, z.core.$strip>;
963
+ schedule: z.ZodObject<{
964
+ archivedAt: z.ZodOptional<z.ZodString>;
965
+ createdAt: z.ZodString;
966
+ delivery: z.ZodOptional<z.ZodObject<{
967
+ completion: z.ZodEnum<{
968
+ response: "response";
969
+ callback: "callback";
970
+ }>;
971
+ maxDurationSeconds: z.ZodNumber;
972
+ onOverlap: z.ZodEnum<{
973
+ skip: "skip";
974
+ queue: "queue";
975
+ }>;
976
+ }, z.core.$strip>>;
977
+ endpoint: z.ZodOptional<z.ZodString>;
978
+ generation: z.ZodNumber;
979
+ id: z.ZodString;
980
+ latencyClass: z.ZodEnum<{
981
+ realtime: "realtime";
982
+ bulk: "bulk";
983
+ }>;
984
+ partitionKey: z.ZodOptional<z.ZodString>;
985
+ recurrence: z.ZodDiscriminatedUnion<[z.ZodObject<{
986
+ kind: z.ZodLiteral<"at">;
987
+ }, z.core.$strip>, z.ZodObject<{
988
+ everySeconds: z.ZodNumber;
989
+ kind: z.ZodLiteral<"every">;
990
+ }, z.core.$strip>, z.ZodObject<{
991
+ cron: z.ZodString;
992
+ kind: z.ZodLiteral<"cron">;
993
+ timeZone: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
994
+ }, z.core.$strip>], "kind">;
995
+ status: z.ZodEnum<{
996
+ paused: "paused";
997
+ active: "active";
998
+ cancelled: "cancelled";
999
+ completed: "completed";
1000
+ }>;
1001
+ updatedAt: z.ZodString;
1002
+ version: z.ZodNumber;
1003
+ }, z.core.$strip>;
1004
+ }, z.core.$strip>;
1005
+ export type ScheduleView = z.infer<typeof scheduleViewSchema>;
1006
+ /**
1007
+ * The four ways a caller may say when a schedule happens.
1008
+ *
1009
+ * Exported so a caller enumerates them rather than writing the list out and
1010
+ * quietly missing one when a fifth arrives.
1011
+ */
1012
+ export declare const RECURRENCE_REQUEST_FIELDS: readonly ["at", "cron", "delaySeconds", "everySeconds"];
1013
+ /**
1014
+ * What a caller sends to create or replace a schedule.
1015
+ *
1016
+ * Exactly one of `at`, `delaySeconds`, `everySeconds` and `cron`. A callback
1017
+ * schedule references a reusable endpoint and may carry any JSON value as its
1018
+ * data. Nothing here names an organization, project or environment: those come
1019
+ * from the verified principal, and the endpoint lookup is bound to that same
1020
+ * tuple. The idempotency key is not here either — it is a header, because a
1021
+ * retry of the *same* request must be byte-identical, and a key inside the body
1022
+ * would make every retry a different request from the one it is retrying.
1023
+ *
1024
+ * **All fields optional, with refinements, rather than a union.** A union of
1025
+ * object schemas accepts a body carrying two arms' fields, since each arm
1026
+ * strips what it does not know; the copied validator refuses that as
1027
+ * `ambiguous_schedule`, and a scheduler that silently picks one of two instants
1028
+ * a customer named is the worst kind of helpful.
1029
+ */
1030
+ export declare const scheduleRequestSchema: z.ZodObject<{
1031
+ at: z.ZodOptional<z.ZodString>;
1032
+ cron: z.ZodOptional<z.ZodString>;
1033
+ data: z.ZodOptional<z.ZodJSONSchema>;
1034
+ delaySeconds: z.ZodOptional<z.ZodNumber>;
1035
+ delivery: z.ZodOptional<z.ZodObject<{
1036
+ onOverlap: z.ZodOptional<z.ZodEnum<{
1037
+ skip: "skip";
1038
+ queue: "queue";
1039
+ }>>;
1040
+ completion: z.ZodOptional<z.ZodEnum<{
1041
+ response: "response";
1042
+ callback: "callback";
1043
+ }>>;
1044
+ maxDurationSeconds: z.ZodOptional<z.ZodLiteral<5 | 300 | 86400 | 30 | 900 | 1800 | 3600 | 43200>>;
1045
+ }, z.core.$strict>>;
1046
+ everySeconds: z.ZodOptional<z.ZodNumber>;
1047
+ endpoint: z.ZodOptional<z.ZodString>;
1048
+ latencyClass: z.ZodOptional<z.ZodEnum<{
1049
+ realtime: "realtime";
1050
+ bulk: "bulk";
1051
+ }>>;
1052
+ partitionKey: z.ZodOptional<z.ZodString>;
1053
+ timeZone: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
1054
+ }, z.core.$strict>;
1055
+ export type ScheduleRequest = z.infer<typeof scheduleRequestSchema>;
1056
+ /**
1057
+ * The class a request runs under: the caller's, or the one its recurrence
1058
+ * implies.
1059
+ *
1060
+ * **Retenanted from the copied `validate.ts` §9 defaulting**, which is the same
1061
+ * three rules in the same order — an explicit class wins; a `cron` or an
1062
+ * `every` is `bulk`; a one-shot is `realtime` when it is close and `bulk`
1063
+ * otherwise. What changes is only where the threshold is written down and that
1064
+ * a `delay` is measured against the clock the request arrived on rather than
1065
+ * read off a separate field, because this surface has already converted one
1066
+ * into the other by the time anything else looks at it.
1067
+ *
1068
+ * It lives here rather than in either adapter because REST and MCP must reach
1069
+ * the same class for the same body — the same reason `classifyIdempotency` is
1070
+ * here — and because a default that two surfaces derive separately is a default
1071
+ * they will eventually disagree about.
1072
+ *
1073
+ * `nowMs` is a parameter for the reason every clock in this package is: a rule
1074
+ * about "within two minutes" that reads its own clock cannot be asked what it
1075
+ * says one millisecond either side of the boundary.
1076
+ */
1077
+ /** Every delivery setting resolved, with nothing left optional. */
1078
+ export interface DeliverySettings {
1079
+ readonly completion: DeliveryCompletionMode;
1080
+ readonly maxDurationSeconds: number;
1081
+ readonly onOverlap: DeliveryOverlapPolicy;
1082
+ }
1083
+ /**
1084
+ * The delivery settings a request runs under: the caller's, or the defaults.
1085
+ *
1086
+ * Here rather than in either adapter for the same reason `deriveLatencyClass`
1087
+ * is: REST and MCP have to reach the same answer for the same body, and a
1088
+ * default two surfaces derive separately is a default they will eventually
1089
+ * disagree about.
1090
+ *
1091
+ * **`onOverlap` resolves to its default even for a schedule that cannot
1092
+ * overlap**, and that is deliberate rather than sloppy. The alternative is an
1093
+ * optional field the storage layer has to keep re-deciding about, and a stored
1094
+ * `skip` on a five-second one-shot describes something true — the previous run
1095
+ * is never still going — rather than something wrong.
1096
+ */
1097
+ export declare function deriveDeliverySettings(request: ScheduleRequest): DeliverySettings;
1098
+ export declare function deriveLatencyClass(request: ScheduleRequest, nowMs: number): LatencyClass;