@voltro/protocol 0.69.1 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -761,6 +761,8 @@ export declare interface ClientDescriptor {
761
761
  readonly kind: 'query' | 'mutation' | 'action' | 'stream' | 'workflow';
762
762
  /** Mutation only: connection setup hooks require an explicit connection scope. */
763
763
  readonly idempotencyScope?: MutationIdempotencyScope | undefined;
764
+ /** Mutation only: same-key calls run in invocation order on the client. */
765
+ readonly serialize?: MutationSerialization | undefined;
764
766
  /** Query only: table(s) the cache should match this subscription against. */
765
767
  readonly source?: string | ReadonlyArray<string> | undefined;
766
768
  /** Mutation only: tables this mutation writes, with op. */
@@ -1549,6 +1551,26 @@ export declare const defineMutation: <const Name extends string, Input extends S
1549
1551
  * never ordinary business writes. Requires a live WebSocket even when dedup
1550
1552
  * is disabled; internal/public REST/agent-tool projections are refused. */
1551
1553
  readonly idempotencyScope?: MutationIdempotencyScope;
1554
+ /**
1555
+ * Run this mutation's calls to the SAME resource in invocation order, on the
1556
+ * client — for every caller of the tag, not one hook.
1557
+ *
1558
+ * A row lock serialises transactions, not the order a browser invoked them
1559
+ * in: two quick saves of one snapshot can take the lock in reverse order, and
1560
+ * the older snapshot then overwrites the newer one; server-side idempotency
1561
+ * does not see it, and `.version()` detects the conflict and replays the
1562
+ * OLDER write. `key` names the resource from the input; calls sharing a key
1563
+ * run one at a time, FIFO, per subject, the permit spanning connection
1564
+ * setup, the request, replay and its acknowledgement — optimistic previews
1565
+ * stay immediate. Different keys run independently. An unknown outcome (a
1566
+ * transport failure after the request started) blocks the key for that
1567
+ * subject rather than let a later write pass it; a subject change drops the
1568
+ * queue. `maxPending` bounds active plus waiting calls per subject (default
1569
+ * 32); admission beyond it rejects with `MutationSerialExecutionError`.
1570
+ * Declared here, on the mutation, so every `useMutation` of it orders the
1571
+ * same way. Not a durable outbox, a distributed lock or a cross-tab merge.
1572
+ */
1573
+ readonly serialize?: MutationSerialization<Schema.Schema.Type<Input>>;
1552
1574
  /** Optional declarative target(s) — drives auto-optimistic. */
1553
1575
  readonly target?: Target<Schema.Schema.Type<Input>, Schema.Schema.Type<Output>>;
1554
1576
  /** Declarative authorization guard(s) — the caller must hold the named
@@ -1858,6 +1880,17 @@ export declare const effectiveScopes: (subject: Subject) => ReadonlyArray<string
1858
1880
  */
1859
1881
  export declare const encodeEventKey: (key: unknown) => string;
1860
1882
 
1883
+ /** Encode a failure under `format`: the tagged body the desugar always wrote
1884
+ * (`{ error, …fields }`), Problem Details, or the format's own encoder. */
1885
+ export declare const encodeRestError: (format: RestFormat, error: RestFormatError, ctx: RestFormatContext) => RestFormatResponse;
1886
+
1887
+ /**
1888
+ * Encode a success value under `format`: the bare value, `{ data, next? }`, or
1889
+ * a JSON:API document; a cursor becomes a `Link` header under `link-header`.
1890
+ * `value` is already in wire form (dates, naming applied by `restViewSchema`).
1891
+ */
1892
+ export declare const encodeRestSuccess: (format: RestFormat, value: unknown, ctx: RestFormatContext) => RestFormatResponse;
1893
+
1861
1894
  /**
1862
1895
  * Read the `_tag` off a thrown error value, or `undefined` when it has none.
1863
1896
  *
@@ -2607,6 +2640,8 @@ export declare const isWireReachable: (descriptor: {
2607
2640
  readonly internal?: boolean | undefined;
2608
2641
  }) => boolean;
2609
2642
 
2643
+ export declare const JSONAPI_MEDIA_TYPE = "application/vnd.api+json; charset=utf-8";
2644
+
2610
2645
  /**
2611
2646
  * Build a scope cache. Hand it to `composeAuthStrategies({ scopeCache })` and
2612
2647
  * keep the handle: `invalidate(scopeCacheKey(subject))` from the mutation that
@@ -2686,6 +2721,8 @@ export declare interface MutationProcedureDescriptor<Name extends string, Input
2686
2721
  * re-executes on a new server-owned WebSocket identity and rejects HTTP RPC.
2687
2722
  * This does not grant access or restore application membership by itself. */
2688
2723
  readonly idempotencyScope?: MutationIdempotencyScope | undefined;
2724
+ /** Same-key calls run in invocation order on the client — see `defineMutation`. */
2725
+ readonly serialize?: MutationSerialization<Schema.Schema.Type<Input>> | undefined;
2689
2726
  /** Declarative target(s) — drives auto-optimistic on the client AND
2690
2727
  * surfaces which tables this mutation touches (debug, future
2691
2728
  * query-invalidation analytics). Mutations without a target run
@@ -2734,6 +2771,14 @@ export declare interface MutationProcedureDescriptor<Name extends string, Input
2734
2771
  readonly internal: boolean | undefined;
2735
2772
  }
2736
2773
 
2774
+ /** Same-resource ordering for a mutation's calls on the client — see `defineMutation`'s `serialize`. */
2775
+ export declare interface MutationSerialization<Input = unknown> {
2776
+ /** The resource a call writes, from its input; calls sharing it run in order. */
2777
+ readonly key: (input: Input) => string;
2778
+ /** Bound for active plus waiting calls per subject. Default 32. */
2779
+ readonly maxPending?: number;
2780
+ }
2781
+
2737
2782
  export declare const mutationToRpc: <Name extends string, Input extends Schema.Schema.Any, Output extends Schema.Schema.Any, Err extends Schema.Schema.All>(descriptor: MutationProcedureDescriptor<Name, Input, Output, Err>, extraErrors?: ExtraErrors) => Rpc.Rpc<Name, Input extends Schema.Struct.Fields ? Schema.Struct<Input> : Input, Output, Schema.Schema.All, never>;
2738
2783
 
2739
2784
  export declare interface NestedTargetFields<Input = unknown> {
@@ -2751,6 +2796,10 @@ export declare interface NestedTargetFields<Input = unknown> {
2751
2796
  readonly match?: ((value: unknown, input: Input) => boolean) | undefined;
2752
2797
  }
2753
2798
 
2799
+ /** `Link: <path?cursor=…>; rel="next"` — the current query with the cursor
2800
+ * parameter replaced. */
2801
+ export declare const nextLink: (ctx: RestFormatContext, cursor: string, param: string) => string;
2802
+
2754
2803
  /**
2755
2804
  * Project a runtime descriptor down to the subset the client needs.
2756
2805
  * Functions (`shape`, `identify`) are passed through by reference —
@@ -3310,6 +3359,20 @@ export declare interface PluginErrorSchema {
3310
3359
  readonly module: string;
3311
3360
  readonly name: string;
3312
3361
  };
3362
+ /**
3363
+ * How the `publicApi` REST projection answers this error. The projection
3364
+ * encodes a plugin's cross-cutting error the way it encodes a descriptor's
3365
+ * own declared error — tag and fields as the body — under this status
3366
+ * (`422` when absent, the status an undeclared-status descriptor error
3367
+ * gets), with these headers. A rate limiter names `429` and the
3368
+ * `Retry-After` / `RateLimit-*` headers here; a descriptor's own
3369
+ * `errorStatus` entry for the tag still wins. Without this the same
3370
+ * rejection that decoded typed on the rpc wire was a `500` on `/v1`.
3371
+ */
3372
+ readonly rest?: {
3373
+ readonly status: number;
3374
+ readonly headers?: (error: unknown) => Readonly<Record<string, string>>;
3375
+ };
3313
3376
  }
3314
3377
 
3315
3378
  /** A public raw-HTTP route a plugin serves on the framework listener. */
@@ -3319,9 +3382,22 @@ export declare interface PluginHttpRoute {
3319
3382
  * this union lacked PATCH; that reason is gone (the `'*'` mount remains
3320
3383
  * for its other job: one dispatcher per shared path + a precise 405). */
3321
3384
  readonly method: '*' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
3322
- /** Absolute path prefix, e.g. `/_voltro/storage`. Matches the path AND
3323
- * any sub-path (`/_voltro/storage/abc123`). */
3385
+ /** Absolute path, e.g. `/_voltro/storage`. Matched byte for byte: the
3386
+ * router folds case and a trailing slash to FIND the route, the dispatcher
3387
+ * then asks whether the request's path is one the route declared — so
3388
+ * `/Metrics` and `/metrics/` are not `/metrics`. A `:name` segment takes one
3389
+ * non-empty segment. Whether the route also owns its sub-paths is
3390
+ * `match`. */
3324
3391
  readonly path: string;
3392
+ /**
3393
+ * `'prefix'` (default): the route answers its path AND every sub-path
3394
+ * (`/_voltro/storage/abc123`) — a plugin that branches on the tail mounts
3395
+ * once. `'exact'`: the path alone — no sub-path, no trailing slash — which is
3396
+ * what a single document or a scrape endpoint is (`/openapi.json`,
3397
+ * `/metrics`), and what a path guard at the ingress can cover, because
3398
+ * exactly one spelling answers. A path ending in `/*` is a prefix either way.
3399
+ */
3400
+ readonly match?: 'prefix' | 'exact';
3325
3401
  readonly handle: (req: PluginHttpRouteRequest) => Promise<PluginHttpRouteResult>;
3326
3402
  /** Per-route body cap override (bytes) — wins over the listener's shared
3327
3403
  * `maxBodyBytes`. NOTE: routes SHARING a path share one body read, so the
@@ -3518,6 +3594,13 @@ export declare interface PluginHttpRouteResult {
3518
3594
  /** Stream the response (SSE) instead of sending `body`. See
3519
3595
  * {@link PluginHttpRouteStream}. */
3520
3596
  readonly stream?: PluginHttpRouteStream;
3597
+ /**
3598
+ * The error behind a `5xx` — for the server log line that names the
3599
+ * status, never for the wire. A route that maps a throw into a response
3600
+ * value has swallowed the reason by the time the transport logs the value;
3601
+ * this carries it alongside.
3602
+ */
3603
+ readonly cause?: unknown;
3521
3604
  /** Stream a BINARY response (a download, an export) instead of sending
3522
3605
  * `body` — see {@link PluginHttpRouteByteStream}. Never buffered by the
3523
3606
  * serve layer; never compressed (flush timing + Content-Length are the
@@ -3584,6 +3667,13 @@ export declare interface PluginInspectRequest {
3584
3667
  }
3585
3668
 
3586
3669
  export declare type PluginInspectResponse = {
3670
+ readonly kind: 'bytes';
3671
+ readonly status?: number;
3672
+ readonly contentType: string;
3673
+ readonly byteStream: PluginHttpRouteByteStream;
3674
+ /** Download metadata; transport-owned auth/CORS headers cannot be overridden. */
3675
+ readonly headers?: Readonly<Record<string, string>>;
3676
+ } | {
3587
3677
  readonly kind: 'json';
3588
3678
  readonly status?: number;
3589
3679
  readonly data: unknown;
@@ -3999,7 +4089,7 @@ export declare type PluginUninstallHook = (ctx: PluginLifecycleContext) => Effec
3999
4089
 
4000
4090
  /** The runtime-erased form of `PolicyGuardSpec` — a relationship check. */
4001
4091
  export declare interface PolicyCheckSpec {
4002
- readonly action: string;
4092
+ readonly action: string | ((input: unknown) => string);
4003
4093
  readonly resourceType: string;
4004
4094
  readonly resource: (input: unknown) => string | undefined;
4005
4095
  }
@@ -4044,7 +4134,7 @@ export declare type PolicyGuardResolver = (req: PolicyGuardRequest) => Effect.Ef
4044
4134
  */
4045
4135
  export declare interface PolicyGuardSpec<Input = unknown> {
4046
4136
  /** The action to authorize, as named in the resource policy's `actions`. */
4047
- readonly action: string;
4137
+ readonly action: string | ((input: Input) => string);
4048
4138
  /** Which registered resource policy governs the check. */
4049
4139
  readonly resourceType: string;
4050
4140
  /** PURE `input → resource id`. Returning undefined DENIES — an unidentifiable
@@ -4052,6 +4142,16 @@ export declare interface PolicyGuardSpec<Input = unknown> {
4052
4142
  readonly resource: (input: Input) => string | undefined;
4053
4143
  }
4054
4144
 
4145
+ export declare const PROBLEM_JSON = "application/problem+json; charset=utf-8";
4146
+
4147
+ /** RFC 9457 Problem Details for one failure: `type` from the tag, `title` from
4148
+ * the tag's words, `status`, `detail` from the message, the error's own fields
4149
+ * as extension members. */
4150
+ export declare const problemDetails: (error: RestFormatError) => Record<string, unknown>;
4151
+
4152
+ /** A stable, non-resolving URI for an error type: the tag as a URN. */
4153
+ export declare const problemTypeOf: (tag: string) => string;
4154
+
4055
4155
  export declare type ProcedureDescriptor = QueryProcedureDescriptor<string, Schema.Schema.Any, Schema.Schema.Any, Schema.Schema.All> | MutationProcedureDescriptor<string, Schema.Schema.Any, Schema.Schema.Any, Schema.Schema.All> | ActionProcedureDescriptor<string, Schema.Schema.Any, Schema.Schema.Any, Schema.Schema.All> | StreamProcedureDescriptor<string, Schema.Schema.Any, Schema.Schema.Any, Schema.Schema.All>;
4056
4156
 
4057
4157
  /** The shape of one procedure, as the pair of peers must agree on it. */
@@ -4074,11 +4174,82 @@ export declare const PROTOCOL_VERSION: 1;
4074
4174
 
4075
4175
  export declare type ProtocolVersion = typeof PROTOCOL_VERSION;
4076
4176
 
4177
+ /** The generated TypeScript client, as the app declares it. */
4178
+ export declare interface PublicApiClientConfig {
4179
+ /** The npm package name. Default `@app/api-client`. */
4180
+ readonly package?: string;
4181
+ /** Where the package is written, relative to the app root. Default `sdk/typescript`. */
4182
+ readonly out?: string;
4183
+ /** `'plain'` — the Promise client, no Effect anywhere; `'effect'` — the
4184
+ * Effect service; `'both'` — `.` plain and `./effect` Effect, with `effect`
4185
+ * an optional peer. Default `'both'`. */
4186
+ readonly flavor?: 'plain' | 'effect' | 'both';
4187
+ /** The package's `license` field (an SPDX id). */
4188
+ readonly license?: string;
4189
+ /** The package's version. Default `0.1.0`. */
4190
+ readonly packageVersion?: string;
4191
+ /** Generate for ONE API version (`'v2'`). */
4192
+ readonly apiVersion?: string;
4193
+ /** The client's default base URL. */
4194
+ readonly baseUrl?: string;
4195
+ }
4196
+
4197
+ /** The `publicApi:` block of an api `app.config.ts`, and the shape of a
4198
+ * descriptor's `publicApi.format` override (every field optional there). */
4199
+ export declare interface PublicApiProfileConfig {
4200
+ /** The profile every projection speaks. Default `'rpc'` — today's wire. */
4201
+ readonly profile?: PublicApiProfileName | RestFormat;
4202
+ readonly dates?: RestDates;
4203
+ readonly errors?: RestErrors;
4204
+ readonly envelope?: RestEnvelope;
4205
+ readonly pagination?: RestPagination;
4206
+ readonly cursorField?: string;
4207
+ readonly cursorParam?: string;
4208
+ readonly naming?: RestNaming;
4209
+ readonly etag?: boolean;
4210
+ /** `'required'`: `voltro doctor` reports a projection without a
4211
+ * `description` and an input/output field without a `description`
4212
+ * annotation — so a new projection does not reach the surface without text.
4213
+ * Default `'optional'`. */
4214
+ readonly docs?: 'required' | 'optional';
4215
+ /**
4216
+ * Files `voltro dev` writes beside `rpcGroup.generated.ts` on every boot, from
4217
+ * the mounted surface: `'openapi'` (`openapi.generated.json`) and the
4218
+ * collections — `'postman'`, `'bruno'`, `'insomnia'`, `'hoppscotch'` — as
4219
+ * committed, generated files, so a review diff shows the surface change and
4220
+ * a client imported once cannot drift; `'typescript'` keeps the generated
4221
+ * client package (`client`) written the same way. Off by default.
4222
+ */
4223
+ readonly artifacts?: ReadonlyArray<'openapi' | 'postman' | 'bruno' | 'insomnia' | 'hoppscotch' | 'typescript'>;
4224
+ /**
4225
+ * The app's decision about its generated TypeScript client — what
4226
+ * `voltro build api --target typescript` (and `voltro api-client build`)
4227
+ * produces without flags, and what `voltro dev` keeps written when
4228
+ * `artifacts` names `'typescript'`. `voltro api-client set …` writes this
4229
+ * block; a flag on the command line overrides a field for one run.
4230
+ */
4231
+ readonly client?: PublicApiClientConfig;
4232
+ }
4233
+
4234
+ export declare type PublicApiProfileName = 'rpc' | 'standard' | 'jsonapi';
4235
+
4077
4236
  export declare interface PublicApiSpec {
4078
4237
  /** Derived by kind when omitted: query→GET, mutation/action→POST. */
4079
4238
  readonly method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4080
4239
  /** Derived from the tag + version when omitted: `/<version>/<tag-as-path>`. */
4081
4240
  readonly path?: string;
4241
+ /**
4242
+ * Derive method and path from the resource instead of writing them — the
4243
+ * convention `crud.*` already follows, opt-in per descriptor. `'teams'` on a
4244
+ * query whose input carries `teamId` or `id` → `GET /v1/teams/{teamId}`,
4245
+ * without one → `GET /v1/teams`; on a mutation whose `target.op` is
4246
+ * `insert` → `POST /v1/teams`, `update` → `PATCH /v1/teams/{teamId}`,
4247
+ * `delete` → `DELETE /v1/teams/{teamId}`; an action, or a mutation without
4248
+ * a target, → `POST /v1/teams/{teamId}/<verb>` (the tag's last segment) when
4249
+ * the input carries the id, else `POST /v1/teams/<verb>`. An explicit
4250
+ * `method` or `path` wins over the derivation.
4251
+ */
4252
+ readonly resource?: string;
4082
4253
  /** Path version segment; multiple versions coexist as separate descriptors. */
4083
4254
  readonly version?: string;
4084
4255
  /** Additional API-key scopes required ON TOP of the handler's RBAC. */
@@ -4110,6 +4281,37 @@ export declare interface PublicApiSpec {
4110
4281
  * publicApi: { errorStatus: { AccessDeniedError: 403, NotFoundError: 404 } }
4111
4282
  */
4112
4283
  readonly errorStatus?: Readonly<Record<string, number>>;
4284
+ /**
4285
+ * The spec's tag group(s) for this operation. Default: the rpc tag's prefix
4286
+ * (`teams.list` → `teams`) — the first path segment, what a consumer looks
4287
+ * for, and what an SDK generator turns into a client class.
4288
+ */
4289
+ readonly tags?: ReadonlyArray<string>;
4290
+ /**
4291
+ * The spec's `operationId`. Default: the rpc tag in camelCase (`teams.list`
4292
+ * → `teamsList`) — the stable identifier a generator names methods from.
4293
+ */
4294
+ readonly operationId?: string;
4295
+ /**
4296
+ * Whether the operation documents a bearer requirement. Default: `'required'`
4297
+ * unless the descriptor declares `openAccess` — then `'optional'` (the key
4298
+ * strategy authenticates a bearer when one is sent, and an anonymous caller
4299
+ * is allowed through), which Swagger UI and generated clients read as
4300
+ * "send the token when you have one". `false` documents no scheme at all.
4301
+ */
4302
+ readonly security?: 'required' | 'optional' | false;
4303
+ /** A request/response example for the spec — the same semantics as a
4304
+ * `defineRestRoute` example. */
4305
+ readonly example?: {
4306
+ readonly request?: unknown;
4307
+ readonly response?: unknown;
4308
+ };
4309
+ /**
4310
+ * This projection's wire format, overriding the app's `publicApi` profile
4311
+ * (`app.config.ts`) for the one endpoint that must differ — every field
4312
+ * optional, the rest inherited. See `PublicApiProfileConfig`.
4313
+ */
4314
+ readonly format?: PublicApiProfileConfig;
4113
4315
  }
4114
4316
 
4115
4317
  /**
@@ -4377,6 +4579,19 @@ export declare const requireScope: (subject: Subject, scope: string) => Effect.E
4377
4579
  /** Drop every registration. Tests only — production registers once at module load. */
4378
4580
  export declare const resetPluginAliases: () => void;
4379
4581
 
4582
+ /** Resolve the input-selected action once. Invalid selectors deny rather than
4583
+ * widening to any action the subject happens to hold. Also used when an
4584
+ * approval persists the resolved guard for its later recheck. */
4585
+ export declare const resolvePolicyAction: (guard: PolicyCheckSpec, input: unknown) => string;
4586
+
4587
+ /**
4588
+ * The format one projection speaks: the app profile, then its building-block
4589
+ * overrides, then the descriptor's own `format`. A named profile is a
4590
+ * `RestFormat` with a name; an object is taken as-is and its fields overridden
4591
+ * the same way.
4592
+ */
4593
+ export declare const resolveRestFormat: (config: PublicApiProfileConfig | undefined, override?: Partial<PublicApiProfileConfig> | undefined) => RestFormat;
4594
+
4380
4595
  /**
4381
4596
  * Validate an author's access options and normalise them into the array every
4382
4597
  * enforcement path reads. Throws at DEFINITION time — module load, which is
@@ -4404,6 +4619,85 @@ export declare interface ResourceScopeRequest {
4404
4619
  */
4405
4620
  export declare type ResourceScopeResolver = (req: ResourceScopeRequest) => Effect.Effect<boolean, unknown>;
4406
4621
 
4622
+ export declare const REST_PROFILE_NAMES: ReadonlyArray<PublicApiProfileName>;
4623
+
4624
+ export declare type RestDates = 'iso' | 'epoch-ms';
4625
+
4626
+ export declare type RestEnvelope = 'none' | 'data' | 'jsonapi';
4627
+
4628
+ export declare type RestErrors = 'problem-details' | 'tagged';
4629
+
4630
+ /**
4631
+ * The wire format of one `publicApi` surface. `'standard'` and `'jsonapi'` are
4632
+ * named instances of this; an app's own object is the custom case.
4633
+ */
4634
+ export declare interface RestFormat {
4635
+ readonly name: string;
4636
+ /** `timestampMs` fields: RFC 3339 strings, or the epoch milliseconds the rpc wire carries. */
4637
+ readonly dates: RestDates;
4638
+ /** Failures: RFC 9457 `application/problem+json`, or the tagged object rpc carries. */
4639
+ readonly errors: RestErrors;
4640
+ /** Success bodies: the bare value, `{ data }`, or the JSON:API document. */
4641
+ readonly envelope: RestEnvelope;
4642
+ /** A cursor the handler returns in `cursorField`: as a `Link: <…>; rel="next"`
4643
+ * header (and `next` beside `data`), or left where the handler put it. */
4644
+ readonly pagination: RestPagination;
4645
+ /** The cursor field a paginated output carries. Default `nextCursor`. */
4646
+ readonly cursorField: string;
4647
+ /** The query parameter a cursor travels back in. Default `cursor`. */
4648
+ readonly cursorParam: string;
4649
+ /** Property names on the wire. */
4650
+ readonly naming: RestNaming;
4651
+ /** Weak `ETag` on GET answers, `If-None-Match` → 304. */
4652
+ readonly etag: boolean;
4653
+ /** Custom success encoding — receives the value already in wire form (dates,
4654
+ * naming applied). Replaces the envelope/pagination steps. */
4655
+ readonly encodeSuccess?: (value: unknown, ctx: RestFormatContext) => RestFormatResponse;
4656
+ /** Custom error encoding. Replaces `errors`. */
4657
+ readonly encodeError?: (error: RestFormatError, ctx: RestFormatContext) => RestFormatResponse;
4658
+ /** A hook over the OpenAPI operation the plugin emits for a projection. */
4659
+ readonly describe?: (operation: Record<string, unknown>, ctx: {
4660
+ readonly tag: string;
4661
+ readonly method: string;
4662
+ readonly path: string;
4663
+ }) => Record<string, unknown>;
4664
+ }
4665
+
4666
+ /** What a format sees when it encodes one response. */
4667
+ export declare interface RestFormatContext {
4668
+ /** The rpc tag, e.g. `teams.list`. */
4669
+ readonly tag: string;
4670
+ readonly method: string;
4671
+ /** The request path, for `Link` headers. */
4672
+ readonly path: string;
4673
+ /** The request's query string (without `?`). */
4674
+ readonly query: string;
4675
+ /** The first `source` table of the procedure, when it declares one — the
4676
+ * JSON:API resource `type`. */
4677
+ readonly source: string | undefined;
4678
+ readonly status: number;
4679
+ }
4680
+
4681
+ /** A failure the desugar or the projection is about to answer with. */
4682
+ export declare interface RestFormatError {
4683
+ readonly status: number;
4684
+ /** The typed error's `_tag` (`AccessDeniedError`), or a stable name for a
4685
+ * transport failure (`InvalidRequest`, `Unauthorized`, `Forbidden`, …). */
4686
+ readonly tag: string;
4687
+ /** A human-readable line. */
4688
+ readonly message: string;
4689
+ /** The error's own fields (a typed error), without `_tag`. */
4690
+ readonly fields: Readonly<Record<string, unknown>>;
4691
+ }
4692
+
4693
+ /** A response a format produced: body (already wire-shaped), headers, and the
4694
+ * media type when it is not `application/json`. */
4695
+ export declare interface RestFormatResponse {
4696
+ readonly body: unknown;
4697
+ readonly headers?: Readonly<Record<string, string>>;
4698
+ readonly contentType?: string;
4699
+ }
4700
+
4407
4701
  declare type RestGuard = (ctx: RestRouteContext) => RestGuardRejection | undefined | Promise<RestGuardRejection | undefined>;
4408
4702
 
4409
4703
  /**
@@ -4418,6 +4712,10 @@ declare interface RestGuardRejection {
4418
4712
 
4419
4713
  declare type RestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
4420
4714
 
4715
+ export declare type RestNaming = 'camelCase' | 'snake_case';
4716
+
4717
+ export declare type RestPagination = 'link-header' | 'body-cursor';
4718
+
4421
4719
  /** A schema-encoded REST body with an application-selected HTTP status and
4422
4720
  * response headers. The marker keeps ordinary domain objects unambiguous.
4423
4721
  * `output` still validates/encodes `body`; use `Schema.Void` with a 204 when
@@ -4427,6 +4725,8 @@ declare interface RestResponse<O> {
4427
4725
  readonly status: number;
4428
4726
  readonly body: O;
4429
4727
  readonly headers?: Readonly<Record<string, string | ReadonlyArray<string>>>;
4728
+ /** A media type other than `application/json` (a JSON:API document). */
4729
+ readonly contentType?: string;
4430
4730
  }
4431
4731
 
4432
4732
  /**
@@ -4474,6 +4774,17 @@ declare interface RestRouteDescriptor<I, O> {
4474
4774
  readonly summary?: string;
4475
4775
  readonly description?: string;
4476
4776
  readonly example?: RestRouteExample;
4777
+ /** The spec's `operationId` — set by a `publicApi` projection from its tag. */
4778
+ readonly operationId?: string;
4779
+ /** The spec's tag group(s) — set by a projection from its tag prefix. */
4780
+ readonly tags?: ReadonlyArray<string>;
4781
+ /**
4782
+ * Present on a `publicApi` projection: what the route projects, in the wire
4783
+ * form its profile speaks. The OpenAPI generator documents parameters,
4784
+ * bodies, responses and security from it; the desugar answers every refusal
4785
+ * through its format.
4786
+ */
4787
+ readonly projection?: RestRouteProjection;
4477
4788
  /** Replacement hint. Sets a `Deprecation: true` response header. */
4478
4789
  readonly deprecated?: string;
4479
4790
  /** ISO date. Sets a `Sunset:` header; past the date the route returns
@@ -4523,6 +4834,51 @@ declare interface RestRouteExample {
4523
4834
  readonly response?: unknown;
4524
4835
  }
4525
4836
 
4837
+ /**
4838
+ * What a `publicApi` projection is, for the two readers that need more than
4839
+ * the route: the OpenAPI generator and the desugar's refusals. `input` and
4840
+ * `output` are the WIRE schemas — the descriptor's, rewritten by the profile
4841
+ * (`restViewSchema`): a `timestampMs` is a `date-time` string under
4842
+ * `dates: 'iso'`, keys are snake_case under that naming. `input` carries the
4843
+ * path parameters as fields; `pathParams` says which.
4844
+ */
4845
+ declare interface RestRouteProjection {
4846
+ readonly tag: string;
4847
+ readonly kind: 'query' | 'mutation' | 'action';
4848
+ readonly version: string;
4849
+ readonly security: 'required' | 'optional' | 'none';
4850
+ /** `publicApi.idempotent` — the route honours `Idempotency-Key` (under the
4851
+ * app's idempotency binding); a client sends one per attempt. */
4852
+ readonly idempotent: boolean;
4853
+ readonly input: Schema.Schema.All;
4854
+ /** The wire names of the input fields bound from the path. */
4855
+ readonly pathParams: ReadonlyArray<string>;
4856
+ readonly output: Schema.Schema.All;
4857
+ /** The first `source` table, when the procedure declares one. */
4858
+ readonly source: string | undefined;
4859
+ /** Every failure the operation answers with a typed body, and its status:
4860
+ * the descriptor's `errorStatus` entries, `422` for the union's other tags,
4861
+ * and each plugin error that names a REST status. */
4862
+ readonly errorResponses: ReadonlyArray<{
4863
+ readonly status: number;
4864
+ readonly tag: string;
4865
+ readonly schema: Schema.Schema.All;
4866
+ }>;
4867
+ readonly format: RestFormat;
4868
+ }
4869
+
4870
+ /**
4871
+ * Rewrite a descriptor's schema into the shape the profile puts on the wire:
4872
+ * `timestampMs` (`DateFromNumber`) becomes an RFC 3339 string under
4873
+ * `dates: 'iso'`, and every struct's property names become `snake_case` under
4874
+ * `naming: 'snake_case'` — as a transformation, so decoding a wire value yields
4875
+ * the descriptor's own typed value and encoding the typed value yields the
4876
+ * wire form. `JSONSchema.make` of the result documents the wire (a
4877
+ * `format: date-time` string, the snake keys). Classes and other opaque
4878
+ * transformations pass through unchanged; a struct inside one keeps its keys.
4879
+ */
4880
+ export declare const restViewSchema: (schema: Schema.Schema.All, format: RestFormat) => Schema.Schema.All;
4881
+
4526
4882
  /** The id of a row, addressed in op paths as `/<id>`. */
4527
4883
  export declare type RowId = string | number;
4528
4884
 
@@ -4693,6 +5049,14 @@ export declare interface RpcInterceptorContext {
4693
5049
  * plugins (Sentry/Datadog) attach an error to the exact span, not just
4694
5050
  * the trace. Absent when no tracer is installed. */
4695
5051
  readonly spanId?: string;
5052
+ /**
5053
+ * `'rest'` when the call came through the `publicApi` projection (`/v1`);
5054
+ * absent on the rpc wire. A per-endpoint policy on the projection — the
5055
+ * descriptor's `publicApi.rateLimit` — applies to these calls only.
5056
+ */
5057
+ readonly surface?: 'rest';
5058
+ /** The descriptor's `publicApi` spec, on a projected call. */
5059
+ readonly publicApi?: PublicApiSpec;
4696
5060
  }
4697
5061
 
4698
5062
  /**
@@ -5055,6 +5419,11 @@ export declare const Subject: Schema.Union<[Schema.Struct<{
5055
5419
  type: Schema.Literal<["serviceAccount"]>;
5056
5420
  id: typeof Schema.String;
5057
5421
  tenantId: typeof Schema.String;
5422
+ /** Application actor used for audit columns; null means machine work with
5423
+ * no application actor. Identity only, never a permission grant. */
5424
+ auditActorId: Schema.optionalWith<Schema.NullOr<typeof Schema.String>, {
5425
+ exact: true;
5426
+ }>;
5058
5427
  scopes: Schema.optional<Schema.Array$<typeof Schema.String>>;
5059
5428
  metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
5060
5429
  }>, Schema.Struct<{
@@ -5088,21 +5457,29 @@ export declare const Subject: Schema.Union<[Schema.Struct<{
5088
5457
 
5089
5458
  export declare type Subject = typeof Subject.Type;
5090
5459
 
5460
+ /** Resolve an application audit actor from server-established identity.
5461
+ * Explicit null on a scoped machine identity survives persistence; it grants
5462
+ * no authority and must not be inferred from user-provided metadata. */
5463
+ export declare const subjectAuditActorId: (subject: Subject) => string | null;
5464
+
5091
5465
  export declare const SubjectIdentity: Schema.Union<[Schema.Struct<{
5092
- id: typeof Schema.String;
5093
5466
  type: Schema.Literal<["user"]>;
5467
+ id: typeof Schema.String;
5094
5468
  tenantId: typeof Schema.String;
5095
5469
  metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
5096
5470
  }>, Schema.Struct<{
5097
- id: typeof Schema.String;
5098
5471
  type: Schema.Literal<["apiKey"]>;
5472
+ id: typeof Schema.String;
5099
5473
  tenantId: typeof Schema.String;
5100
5474
  metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
5101
5475
  }>, Schema.Struct<{
5102
- id: typeof Schema.String;
5103
5476
  type: Schema.Literal<["serviceAccount"]>;
5477
+ id: typeof Schema.String;
5104
5478
  tenantId: typeof Schema.String;
5105
5479
  metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
5480
+ auditActorId: Schema.optionalWith<Schema.NullOr<typeof Schema.String>, {
5481
+ exact: true;
5482
+ }>;
5106
5483
  }>, Schema.Struct<{
5107
5484
  type: Schema.Literal<["anonymous"]>;
5108
5485
  id: typeof Schema.Null;
@@ -5125,8 +5502,8 @@ export declare const SubjectIdentity: Schema.Union<[Schema.Struct<{
5125
5502
  */
5126
5503
  credentialRejected: Schema.optional<typeof Schema.String>;
5127
5504
  }>, Schema.Struct<{
5128
- id: typeof Schema.String;
5129
5505
  type: Schema.Literal<["system"]>;
5506
+ id: typeof Schema.String;
5130
5507
  tenantId: typeof Schema.Null;
5131
5508
  metadata: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
5132
5509
  }>]>;
@@ -5164,37 +5541,38 @@ export declare class SubjectService extends SubjectService_base {
5164
5541
  }
5165
5542
 
5166
5543
  declare const SubjectService_base: Context.TagClass<SubjectService, "@voltro/Subject", {
5167
- readonly id: string;
5168
5544
  readonly type: "user";
5545
+ readonly id: string;
5169
5546
  readonly tenantId: string;
5170
5547
  readonly scopes?: readonly string[] | undefined;
5171
5548
  readonly metadata?: {
5172
5549
  readonly [x: string]: unknown;
5173
5550
  } | undefined;
5174
5551
  } | {
5175
- readonly id: string;
5176
5552
  readonly type: "apiKey";
5553
+ readonly id: string;
5177
5554
  readonly tenantId: string;
5178
5555
  readonly scopes?: readonly string[] | undefined;
5179
5556
  readonly metadata?: {
5180
5557
  readonly [x: string]: unknown;
5181
5558
  } | undefined;
5182
5559
  } | {
5183
- readonly id: string;
5184
5560
  readonly type: "serviceAccount";
5561
+ readonly id: string;
5185
5562
  readonly tenantId: string;
5186
5563
  readonly scopes?: readonly string[] | undefined;
5187
5564
  readonly metadata?: {
5188
5565
  readonly [x: string]: unknown;
5189
5566
  } | undefined;
5567
+ readonly auditActorId?: string | null;
5190
5568
  } | {
5191
- readonly id: null;
5192
5569
  readonly type: "anonymous";
5570
+ readonly id: null;
5193
5571
  readonly tenantId: string | null;
5194
5572
  readonly credentialRejected?: string | undefined;
5195
5573
  } | {
5196
- readonly id: string;
5197
5574
  readonly type: "system";
5575
+ readonly id: string;
5198
5576
  readonly tenantId: null;
5199
5577
  readonly scopes?: readonly string[] | undefined;
5200
5578
  readonly metadata?: {
@@ -5534,6 +5912,8 @@ export declare const toRpc: <Name extends string, Input extends Schema.Schema.An
5534
5912
  revision: Schema.optional<typeof Schema.Number>;
5535
5913
  }>]>, Schema.Schema.All>, typeof Schema.Never, never> | Rpc.Rpc<Name, Input extends Schema.Struct.Fields ? Schema.Struct<Input> : Input, Output, Schema.Schema.All, never> | Rpc.Rpc<Name, Input extends Schema.Struct.Fields ? Schema.Struct<Input> : Input, Stream<Output, Schema.Schema.All>, typeof Schema.Never, never>;
5536
5914
 
5915
+ export declare const toSnakeCase: (key: string) => string;
5916
+
5537
5917
  /**
5538
5918
  * Coerce a timestamp read (`Date` / epoch-ms number / ISO string) to
5539
5919
  * epoch milliseconds. Unrecognised inputs collapse to `0`.
@@ -6131,6 +6511,18 @@ export declare interface VoltroPlugin {
6131
6511
  * mounted when this runs, so the hook only records.
6132
6512
  */
6133
6513
  readonly onRestSurface?: (routes: ReadonlyArray<RestRouteDescriptor<any, any>>) => void;
6514
+ /**
6515
+ * Told the app's wire-reachable rpc procedures — every query, mutation,
6516
+ * action and stream discovery found, minus `internal` ones — once discovery
6517
+ * has run, on both boot paths. The procedure counterpart of
6518
+ * `onRestSurface`, for the same reason: a documentation plugin that wants
6519
+ * the descriptors otherwise asks the app to import them into
6520
+ * `app.config.ts`, which evaluates every descriptor module before discovery
6521
+ * on every load of the config — and `voltro serve` loads no TypeScript at
6522
+ * runtime, so a plugin cannot read them later either. Synchronous: records
6523
+ * only.
6524
+ */
6525
+ readonly onProcedureSurface?: (procedures: ReadonlyArray<ProcedureDescriptor>) => void;
6134
6526
  }
6135
6527
 
6136
6528
  /**
@@ -6335,15 +6727,110 @@ export declare const WorkflowAccessProperty: unique symbol;
6335
6727
  export declare const workflowCancelDescriptor: ActionProcedureDescriptor<"__voltro.workflow.cancel", Schema.Struct<{
6336
6728
  workflowName: typeof Schema.String;
6337
6729
  executionId: typeof Schema.String;
6338
- }>, Schema.Struct<{
6339
- ok: typeof Schema.Boolean;
6340
- }>, typeof Schema.Never>;
6730
+ control: Schema.optional<Schema.Struct<{
6731
+ requestId: typeof Schema.NonEmptyString;
6732
+ cause: Schema.optionalWith<Schema.Struct<{
6733
+ reason: typeof Schema.NonEmptyString;
6734
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
6735
+ }>, {
6736
+ exact: true;
6737
+ }>;
6738
+ }>>;
6739
+ }>, Schema.filter<Schema.Struct<{
6740
+ operation: Schema.Literal<["cancel", "resume"]>;
6741
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
6742
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
6743
+ snapshot: Schema.Struct<{
6744
+ id: typeof Schema.String;
6745
+ workflowName: typeof Schema.String;
6746
+ executionId: typeof Schema.String;
6747
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
6748
+ output: Schema.optional<typeof Schema.Unknown>;
6749
+ error: Schema.optional<Schema.Struct<{
6750
+ tag: Schema.NullOr<typeof Schema.String>;
6751
+ message: typeof Schema.String;
6752
+ }>>;
6753
+ }>;
6754
+ }>>, typeof Schema.Never>;
6341
6755
 
6342
6756
  export declare const WorkflowControlInputSchema: Schema.Struct<{
6343
6757
  workflowName: typeof Schema.String;
6344
6758
  executionId: typeof Schema.String;
6759
+ control: Schema.optional<Schema.Struct<{
6760
+ requestId: typeof Schema.NonEmptyString;
6761
+ cause: Schema.optionalWith<Schema.Struct<{
6762
+ reason: typeof Schema.NonEmptyString;
6763
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
6764
+ }>, {
6765
+ exact: true;
6766
+ }>;
6767
+ }>>;
6768
+ }>;
6769
+
6770
+ export declare type WorkflowControlIntent = Schema.Schema.Type<typeof WorkflowControlIntentSchema>;
6771
+
6772
+ /** Stable caller-owned intent for retry after an uncertain transport result. */
6773
+ export declare const WorkflowControlIntentSchema: Schema.Struct<{
6774
+ requestId: typeof Schema.NonEmptyString;
6775
+ cause: Schema.optionalWith<Schema.Struct<{
6776
+ reason: typeof Schema.NonEmptyString;
6777
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
6778
+ }>, {
6779
+ exact: true;
6780
+ }>;
6781
+ }>;
6782
+
6783
+ export declare const workflowControlQueryDescriptor: QueryProcedureDescriptor<"__voltro.workflow.control", Schema.Struct<{
6784
+ workflowName: typeof Schema.NonEmptyString;
6785
+ executionId: typeof Schema.NonEmptyString;
6786
+ operation: Schema.Literal<["cancel", "resume"]>;
6787
+ requestId: typeof Schema.NonEmptyString;
6788
+ }>, Schema.filter<Schema.Struct<{
6789
+ operation: Schema.Literal<["cancel", "resume"]>;
6790
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
6791
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
6792
+ snapshot: Schema.Struct<{
6793
+ id: typeof Schema.String;
6794
+ workflowName: typeof Schema.String;
6795
+ executionId: typeof Schema.String;
6796
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
6797
+ output: Schema.optional<typeof Schema.Unknown>;
6798
+ error: Schema.optional<Schema.Struct<{
6799
+ tag: Schema.NullOr<typeof Schema.String>;
6800
+ message: typeof Schema.String;
6801
+ }>>;
6802
+ }>;
6803
+ }>>, typeof Schema.Never>;
6804
+
6805
+ export declare type WorkflowControlReadInput = Schema.Schema.Type<typeof WorkflowControlReadInputSchema>;
6806
+
6807
+ export declare const WorkflowControlReadInputSchema: Schema.Struct<{
6808
+ workflowName: typeof Schema.NonEmptyString;
6809
+ executionId: typeof Schema.NonEmptyString;
6810
+ operation: Schema.Literal<["cancel", "resume"]>;
6811
+ requestId: typeof Schema.NonEmptyString;
6345
6812
  }>;
6346
6813
 
6814
+ export declare type WorkflowControlResult = Schema.Schema.Type<typeof WorkflowControlResultSchema>;
6815
+
6816
+ /** Acceptance is not execution completion; null means no resident receipt. */
6817
+ export declare const WorkflowControlResultSchema: Schema.filter<Schema.Struct<{
6818
+ operation: Schema.Literal<["cancel", "resume"]>;
6819
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
6820
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
6821
+ snapshot: Schema.Struct<{
6822
+ id: typeof Schema.String;
6823
+ workflowName: typeof Schema.String;
6824
+ executionId: typeof Schema.String;
6825
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
6826
+ output: Schema.optional<typeof Schema.Unknown>;
6827
+ error: Schema.optional<Schema.Struct<{
6828
+ tag: Schema.NullOr<typeof Schema.String>;
6829
+ message: typeof Schema.String;
6830
+ }>>;
6831
+ }>;
6832
+ }>>;
6833
+
6347
6834
  export declare type WorkflowDomainEventRow = Schema.Schema.Type<typeof WorkflowDomainEventRowSchema>;
6348
6835
 
6349
6836
  export declare const WorkflowDomainEventRowSchema: Schema.Struct<{
@@ -6416,12 +6903,230 @@ export declare type WorkflowParentClosePolicy = Schema.Schema.Type<typeof Workfl
6416
6903
 
6417
6904
  export declare const WorkflowParentClosePolicySchema: Schema.Literal<["cancel", "terminate", "abandon"]>;
6418
6905
 
6906
+ export declare const workflowQueuedCancelDescriptor: ActionProcedureDescriptor<"__voltro.workflow.queued.cancel", Schema.Struct<{
6907
+ cause: Schema.optionalWith<Schema.Struct<{
6908
+ reason: typeof Schema.NonEmptyString;
6909
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
6910
+ }>, {
6911
+ exact: true;
6912
+ }>;
6913
+ workflowName: typeof Schema.NonEmptyString;
6914
+ receiptId: typeof Schema.NonEmptyString;
6915
+ requestId: typeof Schema.NonEmptyString;
6916
+ }>, Schema.filter<Schema.Struct<{
6917
+ operation: Schema.Literal<["cancel"]>;
6918
+ workflowName: typeof Schema.NonEmptyString;
6919
+ receiptId: typeof Schema.NonEmptyString;
6920
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
6921
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
6922
+ observation: Schema.Union<[Schema.Struct<{
6923
+ kind: Schema.Literal<["pending"]>;
6924
+ }>, Schema.Struct<{
6925
+ kind: Schema.Literal<["admission"]>;
6926
+ outcome: Schema.Union<[Schema.Union<[Schema.Struct<{
6927
+ kind: Schema.Literal<["dropped"]>;
6928
+ at: typeof Schema.Number;
6929
+ retryAfterMs: typeof Schema.Number;
6930
+ }>, Schema.Struct<{
6931
+ kind: Schema.Literal<["skipped"]>;
6932
+ at: typeof Schema.Number;
6933
+ executionId: typeof Schema.String;
6934
+ runId: typeof Schema.String;
6935
+ }>, Schema.Struct<{
6936
+ kind: Schema.Literal<["superseded"]>;
6937
+ at: typeof Schema.Number;
6938
+ }>, Schema.Struct<{
6939
+ kind: Schema.Literal<["cancelled"]>;
6940
+ at: typeof Schema.Number;
6941
+ }>, Schema.Struct<{
6942
+ kind: Schema.Literal<["abandoned"]>;
6943
+ at: typeof Schema.Number;
6944
+ failureId: typeof Schema.NonEmptyString;
6945
+ }>]>, Schema.Struct<{
6946
+ kind: Schema.Literal<["rejected"]>;
6947
+ failureId: typeof Schema.NonEmptyString;
6948
+ }>]>;
6949
+ }>, Schema.Struct<{
6950
+ kind: Schema.Literal<["execution"]>;
6951
+ snapshot: Schema.Struct<{
6952
+ id: typeof Schema.String;
6953
+ workflowName: typeof Schema.String;
6954
+ executionId: typeof Schema.String;
6955
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
6956
+ output: Schema.optional<typeof Schema.Unknown>;
6957
+ error: Schema.optional<Schema.Struct<{
6958
+ tag: Schema.NullOr<typeof Schema.String>;
6959
+ message: typeof Schema.String;
6960
+ }>>;
6961
+ }>;
6962
+ }>, Schema.Struct<{
6963
+ kind: Schema.Literal<["unavailable"]>;
6964
+ reason: Schema.Literal<["missing-request", "missing-run", "unconfirmed-generation", "unbound-submission"]>;
6965
+ }>]>;
6966
+ }>>, typeof Schema.Never>;
6967
+
6968
+ export declare type WorkflowQueuedCancelInput = typeof WorkflowQueuedCancelInputSchema.Type;
6969
+
6970
+ export declare const WorkflowQueuedCancelInputSchema: Schema.Struct<{
6971
+ cause: Schema.optionalWith<Schema.Struct<{
6972
+ reason: typeof Schema.NonEmptyString;
6973
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
6974
+ }>, {
6975
+ exact: true;
6976
+ }>;
6977
+ workflowName: typeof Schema.NonEmptyString;
6978
+ receiptId: typeof Schema.NonEmptyString;
6979
+ requestId: typeof Schema.NonEmptyString;
6980
+ }>;
6981
+
6982
+ export declare type WorkflowQueuedCancellationResult = typeof WorkflowQueuedCancellationResultSchema.Type;
6983
+
6984
+ /** A queued caller has a receipt before any execution exists. Keep admission
6985
+ * evidence separate from an observed execution rather than fabricating IDs. */
6986
+ export declare const WorkflowQueuedCancellationResultSchema: Schema.filter<Schema.Struct<{
6987
+ operation: Schema.Literal<["cancel"]>;
6988
+ workflowName: typeof Schema.NonEmptyString;
6989
+ receiptId: typeof Schema.NonEmptyString;
6990
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
6991
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
6992
+ observation: Schema.Union<[Schema.Struct<{
6993
+ kind: Schema.Literal<["pending"]>;
6994
+ }>, Schema.Struct<{
6995
+ kind: Schema.Literal<["admission"]>;
6996
+ outcome: Schema.Union<[Schema.Union<[Schema.Struct<{
6997
+ kind: Schema.Literal<["dropped"]>;
6998
+ at: typeof Schema.Number;
6999
+ retryAfterMs: typeof Schema.Number;
7000
+ }>, Schema.Struct<{
7001
+ kind: Schema.Literal<["skipped"]>;
7002
+ at: typeof Schema.Number;
7003
+ executionId: typeof Schema.String;
7004
+ runId: typeof Schema.String;
7005
+ }>, Schema.Struct<{
7006
+ kind: Schema.Literal<["superseded"]>;
7007
+ at: typeof Schema.Number;
7008
+ }>, Schema.Struct<{
7009
+ kind: Schema.Literal<["cancelled"]>;
7010
+ at: typeof Schema.Number;
7011
+ }>, Schema.Struct<{
7012
+ kind: Schema.Literal<["abandoned"]>;
7013
+ at: typeof Schema.Number;
7014
+ failureId: typeof Schema.NonEmptyString;
7015
+ }>]>, Schema.Struct<{
7016
+ kind: Schema.Literal<["rejected"]>;
7017
+ failureId: typeof Schema.NonEmptyString;
7018
+ }>]>;
7019
+ }>, Schema.Struct<{
7020
+ kind: Schema.Literal<["execution"]>;
7021
+ snapshot: Schema.Struct<{
7022
+ id: typeof Schema.String;
7023
+ workflowName: typeof Schema.String;
7024
+ executionId: typeof Schema.String;
7025
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
7026
+ output: Schema.optional<typeof Schema.Unknown>;
7027
+ error: Schema.optional<Schema.Struct<{
7028
+ tag: Schema.NullOr<typeof Schema.String>;
7029
+ message: typeof Schema.String;
7030
+ }>>;
7031
+ }>;
7032
+ }>, Schema.Struct<{
7033
+ kind: Schema.Literal<["unavailable"]>;
7034
+ reason: Schema.Literal<["missing-request", "missing-run", "unconfirmed-generation", "unbound-submission"]>;
7035
+ }>]>;
7036
+ }>>;
7037
+
7038
+ export declare const workflowQueuedControlQueryDescriptor: QueryProcedureDescriptor<"__voltro.workflow.queued.control", Schema.Struct<{
7039
+ workflowName: typeof Schema.NonEmptyString;
7040
+ receiptId: typeof Schema.NonEmptyString;
7041
+ requestId: typeof Schema.NonEmptyString;
7042
+ }>, Schema.filter<Schema.Struct<{
7043
+ operation: Schema.Literal<["cancel"]>;
7044
+ workflowName: typeof Schema.NonEmptyString;
7045
+ receiptId: typeof Schema.NonEmptyString;
7046
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
7047
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
7048
+ observation: Schema.Union<[Schema.Struct<{
7049
+ kind: Schema.Literal<["pending"]>;
7050
+ }>, Schema.Struct<{
7051
+ kind: Schema.Literal<["admission"]>;
7052
+ outcome: Schema.Union<[Schema.Union<[Schema.Struct<{
7053
+ kind: Schema.Literal<["dropped"]>;
7054
+ at: typeof Schema.Number;
7055
+ retryAfterMs: typeof Schema.Number;
7056
+ }>, Schema.Struct<{
7057
+ kind: Schema.Literal<["skipped"]>;
7058
+ at: typeof Schema.Number;
7059
+ executionId: typeof Schema.String;
7060
+ runId: typeof Schema.String;
7061
+ }>, Schema.Struct<{
7062
+ kind: Schema.Literal<["superseded"]>;
7063
+ at: typeof Schema.Number;
7064
+ }>, Schema.Struct<{
7065
+ kind: Schema.Literal<["cancelled"]>;
7066
+ at: typeof Schema.Number;
7067
+ }>, Schema.Struct<{
7068
+ kind: Schema.Literal<["abandoned"]>;
7069
+ at: typeof Schema.Number;
7070
+ failureId: typeof Schema.NonEmptyString;
7071
+ }>]>, Schema.Struct<{
7072
+ kind: Schema.Literal<["rejected"]>;
7073
+ failureId: typeof Schema.NonEmptyString;
7074
+ }>]>;
7075
+ }>, Schema.Struct<{
7076
+ kind: Schema.Literal<["execution"]>;
7077
+ snapshot: Schema.Struct<{
7078
+ id: typeof Schema.String;
7079
+ workflowName: typeof Schema.String;
7080
+ executionId: typeof Schema.String;
7081
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
7082
+ output: Schema.optional<typeof Schema.Unknown>;
7083
+ error: Schema.optional<Schema.Struct<{
7084
+ tag: Schema.NullOr<typeof Schema.String>;
7085
+ message: typeof Schema.String;
7086
+ }>>;
7087
+ }>;
7088
+ }>, Schema.Struct<{
7089
+ kind: Schema.Literal<["unavailable"]>;
7090
+ reason: Schema.Literal<["missing-request", "missing-run", "unconfirmed-generation", "unbound-submission"]>;
7091
+ }>]>;
7092
+ }>>, typeof Schema.Never>;
7093
+
7094
+ export declare type WorkflowQueuedControlTarget = typeof WorkflowQueuedControlTargetSchema.Type;
7095
+
7096
+ export declare const WorkflowQueuedControlTargetSchema: Schema.Struct<{
7097
+ workflowName: typeof Schema.NonEmptyString;
7098
+ receiptId: typeof Schema.NonEmptyString;
7099
+ requestId: typeof Schema.NonEmptyString;
7100
+ }>;
7101
+
6419
7102
  export declare const workflowResumeDescriptor: ActionProcedureDescriptor<"__voltro.workflow.resume", Schema.Struct<{
6420
7103
  workflowName: typeof Schema.String;
6421
7104
  executionId: typeof Schema.String;
6422
- }>, Schema.Struct<{
6423
- ok: typeof Schema.Boolean;
6424
- }>, typeof Schema.Never>;
7105
+ control: Schema.optional<Schema.Struct<{
7106
+ requestId: typeof Schema.NonEmptyString;
7107
+ cause: Schema.optionalWith<Schema.Struct<{
7108
+ reason: typeof Schema.NonEmptyString;
7109
+ detail: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
7110
+ }>, {
7111
+ exact: true;
7112
+ }>;
7113
+ }>>;
7114
+ }>, Schema.filter<Schema.Struct<{
7115
+ operation: Schema.Literal<["cancel", "resume"]>;
7116
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
7117
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
7118
+ snapshot: Schema.Struct<{
7119
+ id: typeof Schema.String;
7120
+ workflowName: typeof Schema.String;
7121
+ executionId: typeof Schema.String;
7122
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
7123
+ output: Schema.optional<typeof Schema.Unknown>;
7124
+ error: Schema.optional<Schema.Struct<{
7125
+ tag: Schema.NullOr<typeof Schema.String>;
7126
+ message: typeof Schema.String;
7127
+ }>>;
7128
+ }>;
7129
+ }>>, typeof Schema.Never>;
6425
7130
 
6426
7131
  export declare type WorkflowRunEventRow = Schema.Schema.Type<typeof WorkflowRunEventRowSchema>;
6427
7132
 
@@ -6452,7 +7157,7 @@ export declare type WorkflowRunHandle = Schema.Schema.Type<typeof WorkflowRunHan
6452
7157
 
6453
7158
  export declare const WorkflowRunHandleSchema: Schema.Struct<{
6454
7159
  /** Stable handle callers pass to `useWorkflowRun(...)`. The durable execution
6455
- * id for a started run; the pending-intent id for a queued one. */
7160
+ * id for a started run; the durable caller-receipt id for a queued one. */
6456
7161
  id: typeof Schema.String;
6457
7162
  /** Workflow tag, e.g. `notes.summarise`. */
6458
7163
  workflowName: typeof Schema.String;
@@ -6472,6 +7177,7 @@ export declare const WorkflowRunHandleSchema: Schema.Struct<{
6472
7177
  executionId: Schema.NullOr<typeof Schema.String>;
6473
7178
  /**
6474
7179
  * `running` — the engine has it; starting is fire-and-return.
7180
+ * `succeeded` — a blocking start observed successful completion.
6475
7181
  * `queued` — flow control deferred it; see `deferral.dueAt`.
6476
7182
  * `dropped` — over a `rateLimit` cap. It will NOT run.
6477
7183
  * `skipped` — a `singleton: { mode: 'skip' }` key was held; `executionId`
@@ -6484,7 +7190,7 @@ export declare const WorkflowRunHandleSchema: Schema.Struct<{
6484
7190
  * a fresh start; a schedule keyed per day ran once and reported forty-seven
6485
7191
  * "starts" that were replays. See `workflow()`'s `idempotencyKey` doc.
6486
7192
  */
6487
- status: Schema.Literal<["running", "queued", "dropped", "skipped", "replayed"]>;
7193
+ status: Schema.Literal<["running", "succeeded", "queued", "dropped", "skipped", "replayed"]>;
6488
7194
  deferral: Schema.optional<Schema.Struct<{
6489
7195
  /** `debounce` | `batch` | `throttle` | `concurrency` | `paused` |
6490
7196
  * `rateLimit` | `singleton`. */
@@ -6560,6 +7266,21 @@ export declare const WorkflowRunsInputSchema: Schema.Struct<{
6560
7266
  limit: Schema.optional<typeof Schema.Number>;
6561
7267
  }>;
6562
7268
 
7269
+ export declare type WorkflowRunSnapshot = Schema.Schema.Type<typeof WorkflowRunSnapshotSchema>;
7270
+
7271
+ /** Observed execution state, distinct from admission/start handles. */
7272
+ export declare const WorkflowRunSnapshotSchema: Schema.Struct<{
7273
+ id: typeof Schema.String;
7274
+ workflowName: typeof Schema.String;
7275
+ executionId: typeof Schema.String;
7276
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
7277
+ output: Schema.optional<typeof Schema.Unknown>;
7278
+ error: Schema.optional<Schema.Struct<{
7279
+ tag: Schema.NullOr<typeof Schema.String>;
7280
+ message: typeof Schema.String;
7281
+ }>>;
7282
+ }>;
7283
+
6563
7284
  export declare const workflowRunsQueryDescriptor: QueryProcedureDescriptor<"__voltro.workflow.runs", Schema.Struct<{
6564
7285
  tag: Schema.optional<typeof Schema.String>;
6565
7286
  status: Schema.optional<Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>>;
@@ -6670,6 +7391,31 @@ export declare const WorkflowStartDeferralSchema: Schema.Struct<{
6670
7391
  intentId: Schema.NullOr<typeof Schema.String>;
6671
7392
  }>;
6672
7393
 
7394
+ export declare type WorkflowStartTerminalOutcome = typeof WorkflowStartTerminalOutcomeSchema.Type;
7395
+
7396
+ /** A settled admission outcome is not a terminal execution snapshot. In the
7397
+ * skipped case the identities belong to the incumbent, not to a new run. */
7398
+ export declare const WorkflowStartTerminalOutcomeSchema: Schema.Union<[Schema.Struct<{
7399
+ kind: Schema.Literal<["dropped"]>;
7400
+ at: typeof Schema.Number;
7401
+ retryAfterMs: typeof Schema.Number;
7402
+ }>, Schema.Struct<{
7403
+ kind: Schema.Literal<["skipped"]>;
7404
+ at: typeof Schema.Number;
7405
+ executionId: typeof Schema.String;
7406
+ runId: typeof Schema.String;
7407
+ }>, Schema.Struct<{
7408
+ kind: Schema.Literal<["superseded"]>;
7409
+ at: typeof Schema.Number;
7410
+ }>, Schema.Struct<{
7411
+ kind: Schema.Literal<["cancelled"]>;
7412
+ at: typeof Schema.Number;
7413
+ }>, Schema.Struct<{
7414
+ kind: Schema.Literal<["abandoned"]>;
7415
+ at: typeof Schema.Number;
7416
+ failureId: typeof Schema.NonEmptyString;
7417
+ }>]>;
7418
+
6673
7419
  /**
6674
7420
  * Per-step plugin interceptor. Wraps every `step()` (==
6675
7421
  * `Activity.make`) invocation inside a workflow body. Composed
@@ -6717,7 +7463,7 @@ export declare const workflowToRpc: <const Name extends string, Payload extends
6717
7463
  readonly errorSchema: Schema.Schema.All;
6718
7464
  }, extraErrors?: ExtraErrors) => Rpc.Rpc<Name, Payload extends Schema.Struct.Fields ? Schema.Struct<Payload> : Payload, Schema.Struct<{
6719
7465
  /** Stable handle callers pass to `useWorkflowRun(...)`. The durable execution
6720
- * id for a started run; the pending-intent id for a queued one. */
7466
+ * id for a started run; the durable caller-receipt id for a queued one. */
6721
7467
  id: typeof Schema.String;
6722
7468
  /** Workflow tag, e.g. `notes.summarise`. */
6723
7469
  workflowName: typeof Schema.String;
@@ -6737,6 +7483,7 @@ export declare const workflowToRpc: <const Name extends string, Payload extends
6737
7483
  executionId: Schema.NullOr<typeof Schema.String>;
6738
7484
  /**
6739
7485
  * `running` — the engine has it; starting is fire-and-return.
7486
+ * `succeeded` — a blocking start observed successful completion.
6740
7487
  * `queued` — flow control deferred it; see `deferral.dueAt`.
6741
7488
  * `dropped` — over a `rateLimit` cap. It will NOT run.
6742
7489
  * `skipped` — a `singleton: { mode: 'skip' }` key was held; `executionId`
@@ -6749,7 +7496,7 @@ export declare const workflowToRpc: <const Name extends string, Payload extends
6749
7496
  * a fresh start; a schedule keyed per day ran once and reported forty-seven
6750
7497
  * "starts" that were replays. See `workflow()`'s `idempotencyKey` doc.
6751
7498
  */
6752
- status: Schema.Literal<["running", "queued", "dropped", "skipped", "replayed"]>;
7499
+ status: Schema.Literal<["running", "succeeded", "queued", "dropped", "skipped", "replayed"]>;
6753
7500
  deferral: Schema.optional<Schema.Struct<{
6754
7501
  /** `debounce` | `batch` | `throttle` | `concurrency` | `paused` |
6755
7502
  * `rateLimit` | `singleton`. */