@cleocode/contracts 2026.6.12 → 2026.6.14

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 (216) hide show
  1. package/dist/__tests__/operation-def.test.js +5 -1
  2. package/dist/__tests__/operation-def.test.js.map +1 -1
  3. package/dist/__tests__/provider-def.test.d.ts +12 -0
  4. package/dist/__tests__/provider-def.test.d.ts.map +1 -0
  5. package/dist/__tests__/provider-def.test.js +84 -0
  6. package/dist/__tests__/provider-def.test.js.map +1 -0
  7. package/dist/__tests__/sealed-credential.test.d.ts +19 -0
  8. package/dist/__tests__/sealed-credential.test.d.ts.map +1 -0
  9. package/dist/__tests__/sealed-credential.test.js +74 -0
  10. package/dist/__tests__/sealed-credential.test.js.map +1 -0
  11. package/dist/__tests__/service-provider.test.d.ts +17 -0
  12. package/dist/__tests__/service-provider.test.d.ts.map +1 -0
  13. package/dist/__tests__/service-provider.test.js +108 -0
  14. package/dist/__tests__/service-provider.test.js.map +1 -0
  15. package/dist/__tests__/skill-executor-contract.test.js +3 -0
  16. package/dist/__tests__/skill-executor-contract.test.js.map +1 -1
  17. package/dist/acceptance-gate.d.ts +2 -3
  18. package/dist/acceptance-gate.d.ts.map +1 -1
  19. package/dist/boundary.d.ts +52 -0
  20. package/dist/boundary.d.ts.map +1 -1
  21. package/dist/boundary.js +24 -19
  22. package/dist/boundary.js.map +1 -1
  23. package/dist/conduit.d.ts +171 -0
  24. package/dist/conduit.d.ts.map +1 -1
  25. package/dist/config/index.d.ts +23 -0
  26. package/dist/config/index.d.ts.map +1 -0
  27. package/dist/config/index.js +22 -0
  28. package/dist/config/index.js.map +1 -0
  29. package/dist/config.d.ts +104 -1
  30. package/dist/config.d.ts.map +1 -1
  31. package/dist/data-accessor.d.ts +21 -1
  32. package/dist/data-accessor.d.ts.map +1 -1
  33. package/dist/data-accessor.js.map +1 -1
  34. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts +21 -0
  35. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts.map +1 -0
  36. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +84 -0
  37. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -0
  38. package/dist/dispatch/identity.d.ts +1 -1
  39. package/dist/dispatch/identity.d.ts.map +1 -1
  40. package/dist/dispatch/identity.js +25 -0
  41. package/dist/dispatch/identity.js.map +1 -1
  42. package/dist/dispatch/operation-def.d.ts +20 -0
  43. package/dist/dispatch/operation-def.d.ts.map +1 -1
  44. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  45. package/dist/dispatch/operations-registry.js +1044 -182
  46. package/dist/dispatch/operations-registry.js.map +1 -1
  47. package/dist/docs/read.d.ts +2 -2
  48. package/dist/index.d.ts +25 -11
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +17 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/lease-ipc/__tests__/freeze.test.d.ts +15 -0
  53. package/dist/lease-ipc/__tests__/freeze.test.d.ts.map +1 -0
  54. package/dist/lease-ipc/__tests__/freeze.test.js +313 -0
  55. package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -0
  56. package/dist/lease-ipc/index.d.ts +17 -0
  57. package/dist/lease-ipc/index.d.ts.map +1 -0
  58. package/dist/lease-ipc/index.js +16 -0
  59. package/dist/lease-ipc/index.js.map +1 -0
  60. package/dist/lease-ipc/messages.d.ts +918 -0
  61. package/dist/lease-ipc/messages.d.ts.map +1 -0
  62. package/dist/lease-ipc/messages.js +476 -0
  63. package/dist/lease-ipc/messages.js.map +1 -0
  64. package/dist/lease-ipc/version.d.ts +41 -0
  65. package/dist/lease-ipc/version.d.ts.map +1 -0
  66. package/dist/lease-ipc/version.js +43 -0
  67. package/dist/lease-ipc/version.js.map +1 -0
  68. package/dist/llm/catalog-schema.d.ts +242 -0
  69. package/dist/llm/catalog-schema.d.ts.map +1 -0
  70. package/dist/llm/catalog-schema.js +153 -0
  71. package/dist/llm/catalog-schema.js.map +1 -0
  72. package/dist/llm/catalog-schema.json +139 -0
  73. package/dist/llm/index.d.ts +15 -0
  74. package/dist/llm/index.d.ts.map +1 -0
  75. package/dist/llm/index.js +14 -0
  76. package/dist/llm/index.js.map +1 -0
  77. package/dist/llm/interfaces.d.ts +23 -0
  78. package/dist/llm/interfaces.d.ts.map +1 -1
  79. package/dist/llm/oauth.d.ts +16 -2
  80. package/dist/llm/oauth.d.ts.map +1 -1
  81. package/dist/llm/onboarding.d.ts +126 -0
  82. package/dist/llm/onboarding.d.ts.map +1 -0
  83. package/dist/llm/onboarding.js +34 -0
  84. package/dist/llm/onboarding.js.map +1 -0
  85. package/dist/llm/provider-def.d.ts +254 -0
  86. package/dist/llm/provider-def.d.ts.map +1 -0
  87. package/dist/llm/provider-def.js +93 -0
  88. package/dist/llm/provider-def.js.map +1 -0
  89. package/dist/llm/sealed-credential.d.ts +164 -0
  90. package/dist/llm/sealed-credential.d.ts.map +1 -0
  91. package/dist/llm/sealed-credential.js +43 -0
  92. package/dist/llm/sealed-credential.js.map +1 -0
  93. package/dist/llm/system-of-use.d.ts +383 -0
  94. package/dist/llm/system-of-use.d.ts.map +1 -0
  95. package/dist/llm/system-of-use.js +238 -0
  96. package/dist/llm/system-of-use.js.map +1 -0
  97. package/dist/llm/system-resolver.d.ts +87 -11
  98. package/dist/llm/system-resolver.d.ts.map +1 -1
  99. package/dist/llm/system-resolver.js +14 -7
  100. package/dist/llm/system-resolver.js.map +1 -1
  101. package/dist/operations/__tests__/ensures-schema-registry.test.d.ts +17 -0
  102. package/dist/operations/__tests__/ensures-schema-registry.test.d.ts.map +1 -0
  103. package/dist/operations/__tests__/ensures-schema-registry.test.js +113 -0
  104. package/dist/operations/__tests__/ensures-schema-registry.test.js.map +1 -0
  105. package/dist/operations/admin.d.ts +124 -1
  106. package/dist/operations/admin.d.ts.map +1 -1
  107. package/dist/operations/ensures-schema-registry.d.ts +172 -0
  108. package/dist/operations/ensures-schema-registry.d.ts.map +1 -0
  109. package/dist/operations/ensures-schema-registry.js +226 -0
  110. package/dist/operations/ensures-schema-registry.js.map +1 -0
  111. package/dist/operations/entities.d.ts +110 -0
  112. package/dist/operations/entities.d.ts.map +1 -0
  113. package/dist/operations/entities.js +695 -0
  114. package/dist/operations/entities.js.map +1 -0
  115. package/dist/operations/llm.d.ts +116 -9
  116. package/dist/operations/llm.d.ts.map +1 -1
  117. package/dist/operations/output-contracts-data.d.ts.map +1 -1
  118. package/dist/operations/output-contracts-data.js +230 -0
  119. package/dist/operations/output-contracts-data.js.map +1 -1
  120. package/dist/operations/service.d.ts +68 -0
  121. package/dist/operations/service.d.ts.map +1 -0
  122. package/dist/operations/service.js +336 -0
  123. package/dist/operations/service.js.map +1 -0
  124. package/dist/operations/tasks.d.ts +109 -0
  125. package/dist/operations/tasks.d.ts.map +1 -1
  126. package/dist/operations/tasks.js.map +1 -1
  127. package/dist/operations/validate.d.ts +1 -12
  128. package/dist/operations/validate.d.ts.map +1 -1
  129. package/dist/operations/validate.js +1 -1
  130. package/dist/playbook.d.ts +116 -0
  131. package/dist/playbook.d.ts.map +1 -1
  132. package/dist/release/plan.d.ts +5 -5
  133. package/dist/session.d.ts +11 -0
  134. package/dist/session.d.ts.map +1 -1
  135. package/dist/session.js.map +1 -1
  136. package/dist/templates/manifest.d.ts +1 -1
  137. package/dist/tools/agent-tools.d.ts +231 -0
  138. package/dist/tools/agent-tools.d.ts.map +1 -0
  139. package/dist/tools/agent-tools.js +25 -0
  140. package/dist/tools/agent-tools.js.map +1 -0
  141. package/dist/tools/atomic.d.ts +19 -0
  142. package/dist/tools/atomic.d.ts.map +1 -1
  143. package/dist/tools/atomic.js +17 -0
  144. package/dist/tools/atomic.js.map +1 -1
  145. package/dist/tools/index.d.ts +2 -0
  146. package/dist/tools/index.d.ts.map +1 -1
  147. package/dist/tools/skill-executor.d.ts +7 -0
  148. package/dist/tools/skill-executor.d.ts.map +1 -1
  149. package/dist/tools/web-tools.d.ts +217 -0
  150. package/dist/tools/web-tools.d.ts.map +1 -0
  151. package/dist/tools/web-tools.js +31 -0
  152. package/dist/tools/web-tools.js.map +1 -0
  153. package/dist/vault/service-provider.d.ts +343 -0
  154. package/dist/vault/service-provider.d.ts.map +1 -0
  155. package/dist/vault/service-provider.js +857 -0
  156. package/dist/vault/service-provider.js.map +1 -0
  157. package/dist/workgraph.d.ts +12 -12
  158. package/package.json +14 -2
  159. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  160. package/src/__tests__/operation-def.test.ts +7 -1
  161. package/src/__tests__/provider-def.test.ts +93 -0
  162. package/src/__tests__/sealed-credential.test.ts +100 -0
  163. package/src/__tests__/service-provider.test.ts +129 -0
  164. package/src/__tests__/skill-executor-contract.test.ts +3 -0
  165. package/src/acceptance-gate.ts +2 -3
  166. package/src/boundary.ts +70 -20
  167. package/src/conduit.ts +200 -0
  168. package/src/config/index.ts +35 -0
  169. package/src/config.ts +106 -1
  170. package/src/data-accessor.ts +22 -1
  171. package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
  172. package/src/dispatch/identity.ts +25 -0
  173. package/src/dispatch/operation-def.ts +21 -0
  174. package/src/dispatch/operations-registry.ts +1083 -176
  175. package/src/index.ts +240 -25
  176. package/src/lease-ipc/__tests__/freeze.test.ts +342 -0
  177. package/src/lease-ipc/index.ts +75 -0
  178. package/src/lease-ipc/messages.ts +588 -0
  179. package/src/lease-ipc/version.ts +46 -0
  180. package/src/llm/catalog-schema.json +139 -0
  181. package/src/llm/catalog-schema.ts +184 -0
  182. package/src/llm/index.ts +29 -0
  183. package/src/llm/interfaces.ts +23 -0
  184. package/src/llm/oauth.ts +16 -2
  185. package/src/llm/onboarding.ts +131 -0
  186. package/src/llm/provider-def.ts +291 -0
  187. package/src/llm/sealed-credential.ts +166 -0
  188. package/src/llm/system-of-use.ts +503 -0
  189. package/src/llm/system-resolver.ts +91 -11
  190. package/src/operations/__tests__/ensures-schema-registry.test.ts +169 -0
  191. package/src/operations/admin.ts +144 -0
  192. package/src/operations/ensures-schema-registry.ts +260 -0
  193. package/src/operations/entities.ts +758 -0
  194. package/src/operations/llm.ts +120 -8
  195. package/src/operations/output-contracts-data.ts +264 -0
  196. package/src/operations/service.ts +360 -0
  197. package/src/operations/tasks.ts +119 -0
  198. package/src/operations/validate.ts +1 -14
  199. package/src/playbook.ts +117 -0
  200. package/src/session.ts +11 -0
  201. package/src/tools/agent-tools.ts +270 -0
  202. package/src/tools/atomic.ts +21 -0
  203. package/src/tools/index.ts +46 -0
  204. package/src/tools/skill-executor.ts +7 -0
  205. package/src/tools/web-tools.ts +247 -0
  206. package/src/vault/service-provider.ts +1137 -0
  207. package/dist/tessera.d.ts +0 -32
  208. package/dist/tessera.d.ts.map +0 -1
  209. package/dist/tessera.js +0 -11
  210. package/dist/tessera.js.map +0 -1
  211. package/dist/warp-chain.d.ts +0 -129
  212. package/dist/warp-chain.d.ts.map +0 -1
  213. package/dist/warp-chain.js +0 -13
  214. package/dist/warp-chain.js.map +0 -1
  215. package/src/tessera.ts +0 -35
  216. package/src/warp-chain.ts +0 -185
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Schema-drift guard for the `lease-ipc` v1.1 PARALLEL contract (T11627 ST-1).
3
+ *
4
+ * Pins the v1.1 protocol version and the exact request/response message-kind
5
+ * set. If a future change adds, removes, or renames a message kind without a
6
+ * coordinated dual (Rust + TS) edit, these assertions fail — forcing an
7
+ * explicit, reviewed decision rather than silent drift across the Rust/TS wire.
8
+ *
9
+ * Also asserts the Rust wire shape (snake_case keys, `direction` + `kind`
10
+ * discriminators, snake_case enum payloads) round-trips through the Zod schemas,
11
+ * proving the TypeScript and Rust sides agree on the same bytes — the exact JSON
12
+ * produced by `cleo_supervisor::lease_ipc::LeaseEnvelope::*::to_ndjson()`.
13
+ */
14
+
15
+ import { describe, expect, it } from 'vitest';
16
+ import {
17
+ isFrozenLeaseIpcVersion,
18
+ LEASE_IPC_MESSAGE_KINDS,
19
+ LEASE_IPC_PROTOCOL_VERSION,
20
+ LEASE_IPC_REQUEST_KINDS,
21
+ LEASE_IPC_RESPONSE_KINDS,
22
+ LeaseIpcEnvelopeSchema,
23
+ LeaseIpcRequestSchema,
24
+ LeaseIpcResponseSchema,
25
+ } from '../index.js';
26
+
27
+ describe('lease-ipc v1.1 freeze guard (T11627)', () => {
28
+ it('pins the parallel protocol version', () => {
29
+ expect(LEASE_IPC_PROTOCOL_VERSION).toBe('1.1.0');
30
+ });
31
+
32
+ it('the version differs from the frozen supervisor-ipc v1.0 wire version', () => {
33
+ // The two contracts are distinguished on the wire purely by this string;
34
+ // it MUST NOT collide with '1.0.0'.
35
+ expect(LEASE_IPC_PROTOCOL_VERSION).not.toBe('1.0.0');
36
+ expect(isFrozenLeaseIpcVersion('1.1.0')).toBe(true);
37
+ expect(isFrozenLeaseIpcVersion('1.0.0')).toBe(false);
38
+ });
39
+
40
+ it('pins the exact request kind set', () => {
41
+ expect([...LEASE_IPC_REQUEST_KINDS]).toEqual([
42
+ 'lease_acquire',
43
+ 'lease_release',
44
+ 'lease_renew',
45
+ 'rate_check',
46
+ 'tool_grant',
47
+ 'queue_admit',
48
+ 'worker_heartbeat',
49
+ ]);
50
+ });
51
+
52
+ it('pins the exact response kind set', () => {
53
+ expect([...LEASE_IPC_RESPONSE_KINDS]).toEqual([
54
+ 'lease_granted',
55
+ 'lease_queued',
56
+ 'lease_denied',
57
+ 'rate_result',
58
+ 'tool_granted',
59
+ 'lease_revoked',
60
+ 'child_killed_unresponsive',
61
+ 'queue_admit_result',
62
+ 'heartbeat_ack',
63
+ 'error',
64
+ ]);
65
+ });
66
+
67
+ it('the union schemas cover exactly the v1.1 kinds', () => {
68
+ for (const kind of LEASE_IPC_REQUEST_KINDS) {
69
+ const sample = sampleRequestFor(kind);
70
+ expect(LeaseIpcRequestSchema.safeParse(sample).success).toBe(true);
71
+ }
72
+ for (const kind of LEASE_IPC_RESPONSE_KINDS) {
73
+ const sample = sampleResponseFor(kind);
74
+ expect(LeaseIpcResponseSchema.safeParse(sample).success).toBe(true);
75
+ }
76
+ expect(LEASE_IPC_MESSAGE_KINDS).toHaveLength(
77
+ LEASE_IPC_REQUEST_KINDS.length + LEASE_IPC_RESPONSE_KINDS.length,
78
+ );
79
+ });
80
+
81
+ it('pins the EXACT complete v1.1 message-kind set', () => {
82
+ expect([...LEASE_IPC_MESSAGE_KINDS]).toEqual([
83
+ 'lease_acquire',
84
+ 'lease_release',
85
+ 'lease_renew',
86
+ 'rate_check',
87
+ 'tool_grant',
88
+ 'queue_admit',
89
+ 'worker_heartbeat',
90
+ 'lease_granted',
91
+ 'lease_queued',
92
+ 'lease_denied',
93
+ 'rate_result',
94
+ 'tool_granted',
95
+ 'lease_revoked',
96
+ 'child_killed_unresponsive',
97
+ 'queue_admit_result',
98
+ 'heartbeat_ack',
99
+ 'error',
100
+ ]);
101
+ });
102
+ });
103
+
104
+ describe('lease-ipc v1.1 wire-shape parity with Rust serde (T11627)', () => {
105
+ it('parses the exact JSON a Rust lease_acquire request envelope serializes', () => {
106
+ // Literal JSON shape produced by
107
+ // cleo_supervisor::lease_ipc::LeaseEnvelope::request(...).to_ndjson().
108
+ const wire = {
109
+ protocol_version: '1.1.0',
110
+ id: 'abc',
111
+ direction: 'request',
112
+ request: {
113
+ kind: 'lease_acquire',
114
+ scope: 'project',
115
+ lane: 'tasks',
116
+ holder_id: 'pid-42:tasks',
117
+ priority: 0,
118
+ ttl_ms: 30000,
119
+ reentrant: true,
120
+ },
121
+ };
122
+ const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
123
+ expect(parsed.success).toBe(true);
124
+ if (parsed.success && parsed.data.direction === 'request') {
125
+ expect(parsed.data.request.kind).toBe('lease_acquire');
126
+ }
127
+ });
128
+
129
+ it('parses the exact JSON a Rust lease_granted response envelope serializes', () => {
130
+ const wire = {
131
+ protocol_version: '1.1.0',
132
+ id: 'abc',
133
+ direction: 'response',
134
+ response: {
135
+ kind: 'lease_granted',
136
+ scope: 'global',
137
+ lane: 'brain',
138
+ holder_id: 'pid-42:brain',
139
+ epoch: 7,
140
+ ttl_ms: 30000,
141
+ expires_at_ms: 1000030000,
142
+ },
143
+ };
144
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
145
+ });
146
+
147
+ it('parses a Rust child_killed_unresponsive event envelope', () => {
148
+ const wire = {
149
+ protocol_version: '1.1.0',
150
+ id: 'evt-1',
151
+ direction: 'response',
152
+ response: {
153
+ kind: 'child_killed_unresponsive',
154
+ child_id: 'worker-1',
155
+ holder_id: 'pid-42:tasks',
156
+ scope: 'project',
157
+ reason: 'unresponsive past ttl',
158
+ },
159
+ };
160
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
161
+ });
162
+
163
+ it('parses a reused v1.0 error response shape ({ kind, code, message })', () => {
164
+ const wire = {
165
+ protocol_version: '1.1.0',
166
+ id: 'e',
167
+ direction: 'response',
168
+ response: { kind: 'error', code: 'E_LEASE_UNIMPLEMENTED', message: 'deferred handler' },
169
+ };
170
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
171
+ });
172
+
173
+ it('parses the exact JSON a Rust queue_admit request envelope serializes (T11630)', () => {
174
+ const wire = {
175
+ protocol_version: '1.1.0',
176
+ id: 'qa-1',
177
+ direction: 'request',
178
+ request: {
179
+ kind: 'queue_admit',
180
+ provider: 'anthropic',
181
+ priority_class: 'lead',
182
+ est_tokens: 1024,
183
+ child_id: 'worker-1',
184
+ },
185
+ };
186
+ const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
187
+ expect(parsed.success).toBe(true);
188
+ if (parsed.success && parsed.data.direction === 'request') {
189
+ expect(parsed.data.request.kind).toBe('queue_admit');
190
+ }
191
+ });
192
+
193
+ it('parses the exact JSON a Rust queue_admit_result response envelope serializes (T11630)', () => {
194
+ const wire = {
195
+ protocol_version: '1.1.0',
196
+ id: 'qa-1',
197
+ direction: 'response',
198
+ response: {
199
+ kind: 'queue_admit_result',
200
+ disposition: 'deferred',
201
+ retry_after_ms: 250,
202
+ tokens_remaining: 0,
203
+ queue_position: 2,
204
+ },
205
+ };
206
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(true);
207
+ });
208
+
209
+ it('parses the exact JSON a Rust worker_heartbeat request envelope serializes (T11628)', () => {
210
+ const wire = {
211
+ protocol_version: '1.1.0',
212
+ id: 'hb-1',
213
+ direction: 'request',
214
+ request: {
215
+ kind: 'worker_heartbeat',
216
+ child_id: 'worker-7',
217
+ in_flight_llm: true,
218
+ },
219
+ };
220
+ const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
221
+ expect(parsed.success).toBe(true);
222
+ if (parsed.success && parsed.data.direction === 'request') {
223
+ expect(parsed.data.request.kind).toBe('worker_heartbeat');
224
+ }
225
+ });
226
+
227
+ it('parses the exact JSON a Rust heartbeat_ack response envelope serializes (T11628)', () => {
228
+ const wire = {
229
+ protocol_version: '1.1.0',
230
+ id: 'hb-1',
231
+ direction: 'response',
232
+ response: { kind: 'heartbeat_ack' },
233
+ };
234
+ const parsed = LeaseIpcEnvelopeSchema.safeParse(wire);
235
+ expect(parsed.success).toBe(true);
236
+ if (parsed.success && parsed.data.direction === 'response') {
237
+ expect(parsed.data.response.kind).toBe('heartbeat_ack');
238
+ }
239
+ });
240
+
241
+ it('rejects an unknown message kind (proves the union is closed)', () => {
242
+ const wire = {
243
+ protocol_version: '1.1.0',
244
+ id: 'abc',
245
+ direction: 'request',
246
+ request: { kind: 'lease_teleport', scope: 'project', lane: 'tasks' },
247
+ };
248
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(false);
249
+ });
250
+
251
+ it('rejects an unknown scope/lane enum value (snake_case enums are closed)', () => {
252
+ const wire = {
253
+ protocol_version: '1.1.0',
254
+ id: 'abc',
255
+ direction: 'request',
256
+ request: {
257
+ kind: 'lease_acquire',
258
+ scope: 'session',
259
+ lane: 'tasks',
260
+ holder_id: 'h',
261
+ priority: 0,
262
+ ttl_ms: 1,
263
+ reentrant: false,
264
+ },
265
+ };
266
+ expect(LeaseIpcEnvelopeSchema.safeParse(wire).success).toBe(false);
267
+ });
268
+ });
269
+
270
+ /** Build a minimal valid request payload for the given kind. */
271
+ function sampleRequestFor(kind: (typeof LEASE_IPC_REQUEST_KINDS)[number]): unknown {
272
+ switch (kind) {
273
+ case 'lease_acquire':
274
+ return {
275
+ kind,
276
+ scope: 'project',
277
+ lane: 'tasks',
278
+ holder_id: 'h',
279
+ priority: 0,
280
+ ttl_ms: 30000,
281
+ reentrant: true,
282
+ };
283
+ case 'lease_release':
284
+ return { kind, scope: 'project', lane: 'tasks', holder_id: 'h', epoch: 1 };
285
+ case 'lease_renew':
286
+ return { kind, scope: 'project', lane: 'tasks', holder_id: 'h', epoch: 1 };
287
+ case 'rate_check':
288
+ return { kind, scope: 'global', lane: 'bulk', est_bytes: 4096 };
289
+ case 'tool_grant':
290
+ return { kind, tool: 'browser', holder_id: 'h' };
291
+ case 'queue_admit':
292
+ return {
293
+ kind,
294
+ provider: 'anthropic',
295
+ priority_class: 'lead',
296
+ est_tokens: 1024,
297
+ child_id: 'worker-1',
298
+ };
299
+ case 'worker_heartbeat':
300
+ return { kind, child_id: 'worker-1', in_flight_llm: true };
301
+ }
302
+ }
303
+
304
+ /** Build a minimal valid response payload for the given kind. */
305
+ function sampleResponseFor(kind: (typeof LEASE_IPC_RESPONSE_KINDS)[number]): unknown {
306
+ switch (kind) {
307
+ case 'lease_granted':
308
+ return {
309
+ kind,
310
+ scope: 'project',
311
+ lane: 'tasks',
312
+ holder_id: 'h',
313
+ epoch: 1,
314
+ ttl_ms: 30000,
315
+ expires_at_ms: 1000030000,
316
+ };
317
+ case 'lease_queued':
318
+ return { kind, scope: 'project', lane: 'tasks', ticket: 1, ahead: 0 };
319
+ case 'lease_denied':
320
+ return { kind, scope: 'global', code: 'E_LEASE_UNAVAILABLE', message: 'no arbiter' };
321
+ case 'rate_result':
322
+ return { kind, scope: 'global', ok: true, retry_after_ms: 0, tokens_remaining: 10 };
323
+ case 'tool_granted':
324
+ return { kind, tool: 'browser', holder_id: 'h' };
325
+ case 'lease_revoked':
326
+ return { kind, scope: 'project', lane: 'tasks', holder_id: 'h', reason: 'ttl expired' };
327
+ case 'child_killed_unresponsive':
328
+ return { kind, child_id: 'w1', holder_id: 'h', scope: 'project', reason: 'unresponsive' };
329
+ case 'queue_admit_result':
330
+ return {
331
+ kind,
332
+ disposition: 'deferred',
333
+ retry_after_ms: 250,
334
+ tokens_remaining: 0,
335
+ queue_position: 2,
336
+ };
337
+ case 'heartbeat_ack':
338
+ return { kind };
339
+ case 'error':
340
+ return { kind, code: 'E_X', message: 'x' };
341
+ }
342
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * `lease-ipc` v1.1 — PARALLEL DbWriterLease IPC contract barrel (T11627 ST-1).
3
+ *
4
+ * Re-exports the version constants and Zod message schemas + inferred types for
5
+ * the CLEO DbWriterLease arbitration surface. Runs **in parallel** to the
6
+ * byte-frozen `supervisor-ipc` v1.0 contract — see
7
+ * {@link LEASE_IPC_PROTOCOL_VERSION}. ST-1 ships the protocol surface with no
8
+ * consumer (zero behavior change); the local-mode arbiter (ST-2+) and the
9
+ * supervisor fast path (ST-5) consume it later.
10
+ *
11
+ * @task T11627
12
+ * @packageDocumentation
13
+ */
14
+
15
+ export type {
16
+ ChildKilledUnresponsiveResponse,
17
+ HeartbeatAckResponse,
18
+ LeaseAcquireRequest,
19
+ LeaseDeniedResponse,
20
+ LeaseErrorResponse,
21
+ LeaseGrantedResponse,
22
+ LeaseIpcEnvelope,
23
+ LeaseIpcRequest,
24
+ LeaseIpcRequestEnvelope,
25
+ LeaseIpcResponse,
26
+ LeaseIpcResponseEnvelope,
27
+ LeaseLane,
28
+ LeaseQueuedResponse,
29
+ LeaseReleaseRequest,
30
+ LeaseRenewRequest,
31
+ LeaseRevokedResponse,
32
+ LeaseScope,
33
+ QueueAdmitDisposition,
34
+ QueueAdmitRequest,
35
+ QueueAdmitResultResponse,
36
+ QueuePriorityClass,
37
+ RateCheckRequest,
38
+ RateResultResponse,
39
+ ToolGrantedResponse,
40
+ ToolGrantRequest,
41
+ WorkerHeartbeatRequest,
42
+ } from './messages.js';
43
+
44
+ export {
45
+ ChildKilledUnresponsiveResponseSchema,
46
+ HeartbeatAckResponseSchema,
47
+ LEASE_IPC_MESSAGE_KINDS,
48
+ LEASE_IPC_REQUEST_KINDS,
49
+ LEASE_IPC_RESPONSE_KINDS,
50
+ LeaseAcquireRequestSchema,
51
+ LeaseDeniedResponseSchema,
52
+ LeaseErrorResponseSchema,
53
+ LeaseGrantedResponseSchema,
54
+ LeaseIpcEnvelopeSchema,
55
+ LeaseIpcRequestEnvelopeSchema,
56
+ LeaseIpcRequestSchema,
57
+ LeaseIpcResponseEnvelopeSchema,
58
+ LeaseIpcResponseSchema,
59
+ LeaseLaneSchema,
60
+ LeaseQueuedResponseSchema,
61
+ LeaseReleaseRequestSchema,
62
+ LeaseRenewRequestSchema,
63
+ LeaseRevokedResponseSchema,
64
+ LeaseScopeSchema,
65
+ QueueAdmitDispositionSchema,
66
+ QueueAdmitRequestSchema,
67
+ QueueAdmitResultResponseSchema,
68
+ QueuePriorityClassSchema,
69
+ RateCheckRequestSchema,
70
+ RateResultResponseSchema,
71
+ ToolGrantedResponseSchema,
72
+ ToolGrantRequestSchema,
73
+ WorkerHeartbeatRequestSchema,
74
+ } from './messages.js';
75
+ export { isFrozenLeaseIpcVersion, LEASE_IPC_PROTOCOL_VERSION } from './version.js';