@stitchwire/client 0.0.0-stage → 0.31.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.
- package/LICENSE +21 -0
- package/README.md +296 -2
- package/dist/chunk-d3248e3w.js +728 -0
- package/dist/chunk-mva06nh4.js +709 -0
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +84 -0
- package/dist/enrollment.d.ts +1 -0
- package/dist/enrollment.js +503 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1680 -0
- package/dist/types/client/src/contracts.d.ts +1 -0
- package/dist/types/client/src/enrollment.d.ts +11 -0
- package/dist/types/client/src/index.d.ts +1 -0
- package/dist/types/contracts/src/door/client-error.d.ts +20 -0
- package/dist/types/contracts/src/door/common.d.ts +3 -0
- package/dist/types/contracts/src/door/event-lifecycle.d.ts +22 -0
- package/dist/types/contracts/src/door/local-contract.d.ts +466 -0
- package/dist/types/contracts/src/door/paths.d.ts +17 -0
- package/dist/types/contracts/src/door/request-bounds.d.ts +4 -0
- package/dist/types/contracts/src/door/requests.d.ts +47 -0
- package/dist/types/contracts/src/door/results.d.ts +319 -0
- package/dist/types/contracts/src/door/status.d.ts +859 -0
- package/dist/types/contracts/src/door/streams.d.ts +226 -0
- package/dist/types/contracts/src/enrollment/fleet-admission.d.ts +413 -0
- package/dist/types/contracts/src/enrollment/outcome.d.ts +29 -0
- package/dist/types/contracts/src/enrollment/request.d.ts +281 -0
- package/dist/types/contracts/src/enrollment/result.d.ts +713 -0
- package/dist/types/contracts/src/fleet/bundle.d.ts +209 -0
- package/dist/types/contracts/src/fleet/identity.d.ts +4 -0
- package/dist/types/contracts/src/fleet/manifest.d.ts +71 -0
- package/dist/types/contracts/src/fleet/status.d.ts +56 -0
- package/dist/types/contracts/src/peer-contract.d.ts +78 -0
- package/dist/types/contracts/src/protocol/bounds.d.ts +37 -0
- package/dist/types/contracts/src/protocol/broker-health.d.ts +384 -0
- package/dist/types/contracts/src/protocol/event.d.ts +222 -0
- package/dist/types/contracts/src/protocol/failure.d.ts +146 -0
- package/dist/types/contracts/src/protocol/identity.d.ts +11 -0
- package/dist/types/contracts/src/protocol/json-bounds.d.ts +6 -0
- package/dist/types/contracts/src/protocol/lane-url.d.ts +16 -0
- package/dist/types/contracts/src/protocol/paths.d.ts +7 -0
- package/dist/types/contracts/src/protocol/payload.d.ts +25 -0
- package/dist/types/contracts/src/protocol/presence.d.ts +66 -0
- package/dist/types/contracts/src/protocol/release.d.ts +61 -0
- package/dist/types/contracts/src/protocol/result.d.ts +41 -0
- package/dist/types/contracts/src/protocol/rpc.d.ts +106 -0
- package/dist/types/contracts/src/protocol/schema-parse.d.ts +23 -0
- package/dist/types/contracts/src/protocol/stream.d.ts +290 -0
- package/dist/types/contracts/src/protocol/topic.d.ts +185 -0
- package/dist/types/contracts/src/service/budgets.d.ts +3 -0
- package/dist/types/contracts/src/service/contract-descriptor.d.ts +9 -0
- package/dist/types/contracts/src/service/contracts.d.ts +430 -0
- package/dist/types/contracts/src/service/declaration.d.ts +122 -0
- package/dist/types/contracts/src/service/diagnostics.d.ts +104 -0
- package/dist/types/contracts/src/service/owner-route-path.d.ts +11 -0
- package/dist/types/contracts/src/service/policy-schema.d.ts +154 -0
- package/dist/types/contracts/src/service/request-bounds.d.ts +5 -0
- package/dist/types/contracts/src/service/service-contract.d.ts +112 -0
- package/dist/types/local-client/src/broker-health.d.ts +18 -0
- package/dist/types/local-client/src/client.d.ts +377 -0
- package/dist/types/local-client/src/contracts.d.ts +112 -0
- package/dist/types/local-client/src/declarations.d.ts +57 -0
- package/dist/types/local-client/src/door-paths.d.ts +18 -0
- package/dist/types/local-client/src/errno.d.ts +6 -0
- package/dist/types/local-client/src/error-chain.d.ts +25 -0
- package/dist/types/local-client/src/errors.d.ts +39 -0
- package/dist/types/local-client/src/event-sequence.d.ts +4 -0
- package/dist/types/local-client/src/feed.d.ts +8 -0
- package/dist/types/local-client/src/http.d.ts +20 -0
- package/dist/types/local-client/src/index.d.ts +13 -0
- package/dist/types/local-client/src/ingress.d.ts +31 -0
- package/dist/types/local-client/src/operation.d.ts +37 -0
- package/dist/types/local-client/src/options.d.ts +18 -0
- package/dist/types/local-client/src/paths.d.ts +52 -0
- package/dist/types/local-client/src/readers.d.ts +143 -0
- package/dist/types/local-client/src/service.d.ts +33 -0
- package/dist/types/local-client/src/status-readers.d.ts +756 -0
- package/dist/types/local-client/src/unary.d.ts +10 -0
- package/package.json +58 -4
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const FailureSchema: z.ZodEnum<{
|
|
3
|
+
cancelled: "cancelled";
|
|
4
|
+
denied: "denied";
|
|
5
|
+
exec: "exec";
|
|
6
|
+
none: "none";
|
|
7
|
+
offline: "offline";
|
|
8
|
+
rejected: "rejected";
|
|
9
|
+
timeout: "timeout";
|
|
10
|
+
transport: "transport";
|
|
11
|
+
}>;
|
|
12
|
+
export type Failure = z.infer<typeof FailureSchema>;
|
|
13
|
+
/** The machine-readable transport fact. `detail` explains it to a person; consumers branch here. */
|
|
14
|
+
export declare const TransportCauseSchema: z.ZodEnum<{
|
|
15
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
16
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
17
|
+
"no-connected-lane": "no-connected-lane";
|
|
18
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
19
|
+
"target-offline": "target-offline";
|
|
20
|
+
}>;
|
|
21
|
+
export type TransportCause = z.infer<typeof TransportCauseSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* What each transport cause means to the layers that report it, in one table: the wire's `failure`,
|
|
24
|
+
* the code of a service outcome, and whether the owner could have seen the call (`delivery`).
|
|
25
|
+
* A cause that appears with any other pairing is a contradiction, and the refinements reject it.
|
|
26
|
+
*/
|
|
27
|
+
export declare const TRANSPORT_CAUSES: {
|
|
28
|
+
readonly 'no-connected-lane': {
|
|
29
|
+
readonly failure: 'transport';
|
|
30
|
+
readonly serviceCode: 'unavailable';
|
|
31
|
+
readonly delivery: 'not-dispatched';
|
|
32
|
+
};
|
|
33
|
+
readonly 'presence-pending-timeout': {
|
|
34
|
+
readonly failure: 'transport';
|
|
35
|
+
readonly serviceCode: 'unavailable';
|
|
36
|
+
readonly delivery: 'not-dispatched';
|
|
37
|
+
};
|
|
38
|
+
readonly 'target-offline': {
|
|
39
|
+
readonly failure: 'offline';
|
|
40
|
+
readonly serviceCode: 'offline';
|
|
41
|
+
readonly delivery: 'not-dispatched';
|
|
42
|
+
};
|
|
43
|
+
readonly 'lane-lost-after-dispatch': {
|
|
44
|
+
readonly failure: 'transport';
|
|
45
|
+
readonly serviceCode: 'unavailable';
|
|
46
|
+
readonly delivery: 'unknown';
|
|
47
|
+
};
|
|
48
|
+
readonly 'acknowledgement-timeout': {
|
|
49
|
+
readonly failure: 'timeout';
|
|
50
|
+
readonly serviceCode: 'timeout';
|
|
51
|
+
readonly delivery: 'unknown';
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* What kind of "no" this is — the second dimension of a refusal, and the one a client can act on.
|
|
56
|
+
*
|
|
57
|
+
* `failure` says which layer refused; on its own it cannot say whether trying again is sensible.
|
|
58
|
+
* A node at its concurrency ceiling and a command outside the allowlist both arrive as `denied`,
|
|
59
|
+
* yet one clears itself in milliseconds and the other never will. Without this field the only way
|
|
60
|
+
* to tell them apart is to match English prose out of `detail` — which is not a contract, so every
|
|
61
|
+
* consumer ends up guessing, and the usual guess is "permanent": a healthy fleet drawn as broken.
|
|
62
|
+
*/
|
|
63
|
+
export declare const RefusalSchema: z.ZodEnum<{
|
|
64
|
+
capacity: "capacity";
|
|
65
|
+
none: "none";
|
|
66
|
+
policy: "policy";
|
|
67
|
+
request: "request";
|
|
68
|
+
}>;
|
|
69
|
+
export type Refusal = z.infer<typeof RefusalSchema>;
|
|
70
|
+
/** A whole hour is far past any admission window here; the ceiling exists so a peer cannot park a
|
|
71
|
+
* client for a day by writing one large number. */
|
|
72
|
+
export declare const MAX_RETRY_AFTER_MS = 3600000;
|
|
73
|
+
export declare const RetryAfterSchema: z.ZodNullable<z.ZodNumber>;
|
|
74
|
+
/** The classification of an answer that is not a refusal: every field says "nothing went wrong". */
|
|
75
|
+
export declare const NOT_REFUSED: {
|
|
76
|
+
readonly failure: 'none';
|
|
77
|
+
readonly refusal: 'none';
|
|
78
|
+
readonly retryAfterMs: null;
|
|
79
|
+
readonly transportCause: null;
|
|
80
|
+
readonly detail: '';
|
|
81
|
+
};
|
|
82
|
+
/** The required classification carried by every exact-version wire envelope that can say "no". */
|
|
83
|
+
export declare const RefusalFields: {
|
|
84
|
+
refusal: z.ZodEnum<{
|
|
85
|
+
capacity: "capacity";
|
|
86
|
+
none: "none";
|
|
87
|
+
policy: "policy";
|
|
88
|
+
request: "request";
|
|
89
|
+
}>;
|
|
90
|
+
/** Set only where the limit is a known-length window (a per-minute rate). An inflight or
|
|
91
|
+
* concurrency ceiling frees when someone else finishes, which is not a time — it stays `null`
|
|
92
|
+
* rather than inviting a client to sleep on an invented number. */
|
|
93
|
+
retryAfterMs: z.ZodNullable<z.ZodNumber>;
|
|
94
|
+
transportCause: z.ZodNullable<z.ZodEnum<{
|
|
95
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
96
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
97
|
+
"no-connected-lane": "no-connected-lane";
|
|
98
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
99
|
+
"target-offline": "target-offline";
|
|
100
|
+
}>>;
|
|
101
|
+
};
|
|
102
|
+
/** Keeps the two dimensions from contradicting each other on the wire: a classified refusal that
|
|
103
|
+
* claims success, or a retry hint on a refusal that will never clear, is a bug the receiver would
|
|
104
|
+
* otherwise have to defend against. */
|
|
105
|
+
export declare function refusalRefinement(value: {
|
|
106
|
+
failure: Failure;
|
|
107
|
+
refusal: Refusal;
|
|
108
|
+
retryAfterMs: number | null;
|
|
109
|
+
transportCause: TransportCause | null;
|
|
110
|
+
}, ctx: z.RefinementCtx): void;
|
|
111
|
+
/** One refusal, classified at the point that knows why — carried together so `failure` and
|
|
112
|
+
* `refusal` cannot be set from two different opinions about the same "no". */
|
|
113
|
+
export interface Refused {
|
|
114
|
+
failure: Failure;
|
|
115
|
+
refusal: Refusal;
|
|
116
|
+
detail: string;
|
|
117
|
+
retryAfterMs: number | null;
|
|
118
|
+
transportCause: TransportCause | null;
|
|
119
|
+
}
|
|
120
|
+
/** An ACL, a capability grant, an allowlist or a topic declaration says no. Retrying is pointless;
|
|
121
|
+
* a human has to change configuration. */
|
|
122
|
+
export declare function policyRefusal(detail: string): Refused;
|
|
123
|
+
/**
|
|
124
|
+
* A ceiling that frees on its own. The caller is not doing anything wrong and the data is intact —
|
|
125
|
+
* this is the case a client must never render as "unavailable".
|
|
126
|
+
*
|
|
127
|
+
* `failure` is a parameter for the same reason `requestRefusal` has one: admission REFUSES a call
|
|
128
|
+
* before it runs (`denied`), while a buffer that overflows mid-flight is not a refusal at all and
|
|
129
|
+
* keeps the code its layer already used. The class is the same; which layer hit the ceiling is not.
|
|
130
|
+
*
|
|
131
|
+
* The hint is clamped rather than trusted: every producer computes it from wall-clock deltas, and a
|
|
132
|
+
* clock stepped backwards further than the window would otherwise put a value past the schema
|
|
133
|
+
* ceiling into `.parse` — a thrown error inside a socket handler instead of a refusal.
|
|
134
|
+
*/
|
|
135
|
+
export declare function capacityRefusal(detail: string, retryAfterMs?: number | null, failure?: Failure): Refused;
|
|
136
|
+
/** The request itself does not fit a bound — too much stdin, too long a timeout, an argument shape
|
|
137
|
+
* the profile does not accept, a chunk over the stream ceiling. Identical retries fail identically.
|
|
138
|
+
*
|
|
139
|
+
* `failure` is a parameter because the same class arrives under two codes: a node REFUSES an
|
|
140
|
+
* oversized call (`denied`), while the broker REJECTS a frame that breaks the ceilings it enforces
|
|
141
|
+
* (`rejected`). Which layer said no and what kind of no it is are separate questions. */
|
|
142
|
+
export declare function requestRefusal(detail: string, failure?: Failure): Refused;
|
|
143
|
+
/** A failure that is not a classified refusal: nobody said no, something else went wrong. */
|
|
144
|
+
export declare function unclassifiedFailure(failure: Failure, detail: string): Refused;
|
|
145
|
+
/** A transport failure classified at the layer that observed the route transition. */
|
|
146
|
+
export declare function transportFailure(transportCause: TransportCause, detail: string): Refused;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A lowercase slug of at most 32 characters: how nodes, lanes and signing keys are named. */
|
|
3
|
+
export declare const SLUG_PATTERN: RegExp;
|
|
4
|
+
export declare const NodeIdSchema: z.ZodString;
|
|
5
|
+
export type NodeId = z.infer<typeof NodeIdSchema>;
|
|
6
|
+
/** Brokers one node dials at most: each is a lane it authenticates on and keeps connected. */
|
|
7
|
+
export declare const MAX_NODE_BROKERS = 8;
|
|
8
|
+
/** A command a node declares and a broker grant names: one slug-like name, never a pattern. */
|
|
9
|
+
export declare const CommandNameSchema: z.ZodString;
|
|
10
|
+
/** Wall-clock label only, not a cross-host latency measurement. */
|
|
11
|
+
export declare function nowIso(): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decoded UTF-8 byte may occupy six ASCII bytes as a JSON escape. The fixed allowance covers
|
|
3
|
+
* routing fields, delimiters and the bounded metadata outside the payload strings. This is a budget
|
|
4
|
+
* for the encoded body, never permission for a larger decoded payload.
|
|
5
|
+
*/
|
|
6
|
+
export declare function jsonEnvelopeBytes(payloadBytes: number): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Why a broker lane URL is refused, or `null`. This is the one rule for a broker address: `node.json`,
|
|
4
|
+
* an enrollment request, `doctor --broker` and `readBrokerHealth` all ask it.
|
|
5
|
+
*
|
|
6
|
+
* - It must be a URL.
|
|
7
|
+
* - It carries no credentials, query string or fragment: the node's token is its credential, and a
|
|
8
|
+
* lane has no parameters. A path is allowed (`wss://broker.example/edge`).
|
|
9
|
+
* - The lane carries the node's token and every call, stream and event, so it is TLS (`https:`,
|
|
10
|
+
* `wss:`) except to a broker on this machine, where `http:` and `ws:` are allowed.
|
|
11
|
+
*
|
|
12
|
+
* The reason never repeats the URL, which may hold credentials.
|
|
13
|
+
*/
|
|
14
|
+
export declare function laneUrlRefusal(value: string): string | null;
|
|
15
|
+
/** A broker lane URL in a schema, refused by `laneUrlRefusal` and by nothing else. */
|
|
16
|
+
export declare const LaneUrlSchema: z.ZodString;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** One spelling of one file: absolute, no control characters, no empty, `.` or `..` segment. */
|
|
3
|
+
export declare const AbsoluteFilePathSchema: z.ZodString;
|
|
4
|
+
export declare const UnixSocketPathSchema: z.ZodString;
|
|
5
|
+
/** A lowercase hexadecimal SHA-256. */
|
|
6
|
+
export declare const Sha256Schema: z.ZodString;
|
|
7
|
+
export type Sha256 = z.infer<typeof Sha256Schema>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The UTF-8 byte length of a string, as an encoder writes it (a lone surrogate is U+FFFD, three
|
|
4
|
+
* bytes). Browser-safe, no `Buffer`. It encodes slice by slice into one reused buffer instead of
|
|
5
|
+
* encoding the whole string: the schemas count every command's output, up to megabytes, and a copy
|
|
6
|
+
* per count is garbage of that size (`benchmark:utf8-length` measures both).
|
|
7
|
+
*/
|
|
8
|
+
export declare function utf8ByteLength(value: string): number;
|
|
9
|
+
/** One argument of a command or stream profile: non-empty, within the argument byte bound. */
|
|
10
|
+
export declare const BoundedArgSchema: z.ZodString;
|
|
11
|
+
/** `data` must be canonical base64 of exactly `bytes` bytes: what is declared is what was sent. */
|
|
12
|
+
export declare function base64PayloadRefinement(value: {
|
|
13
|
+
data: string;
|
|
14
|
+
bytes: number;
|
|
15
|
+
}, ctx: z.RefinementCtx): void;
|
|
16
|
+
/**
|
|
17
|
+
* The byte bounds on what a caller hands a command or a stream profile: the arguments joined by NUL
|
|
18
|
+
* (`name` is the field they live in) and the stdin body. `path` locates the object that holds them.
|
|
19
|
+
*/
|
|
20
|
+
export declare function addInputBoundIssues(ctx: z.RefinementCtx, input: {
|
|
21
|
+
name: 'argv' | 'args';
|
|
22
|
+
values: readonly string[];
|
|
23
|
+
stdin: string | null;
|
|
24
|
+
path?: readonly string[];
|
|
25
|
+
}): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What a node's disconnection MEANS, as far as the transport can honestly say.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately three values, not two, and the third is the important one:
|
|
6
|
+
*
|
|
7
|
+
* - `announced` — the node said goodbye (`client namespace disconnect`): a stopped service, an
|
|
8
|
+
* orderly shutdown. Its absence is explained.
|
|
9
|
+
* - `lost` — the link died (`ping timeout`, `transport close`). A sleeping laptop and a dead agent
|
|
10
|
+
* arrive here IDENTICALLY, and no field below will ever separate them: at the broker they are
|
|
11
|
+
* the same event. A consumer that needs the difference has to observe the node from inside it.
|
|
12
|
+
* Reading `lost` as "asleep, therefore fine" is exactly the rule this field exists to correct;
|
|
13
|
+
* the honest verdict on a long `lost` silence is "unknown", never "ok".
|
|
14
|
+
* - `broker-restart` — the BROKER went away (`server shutting down`), not the node. This record
|
|
15
|
+
* says nothing whatsoever about the node's health.
|
|
16
|
+
*
|
|
17
|
+
* A consumer should NOT branch on `broker-restart` in a presence snapshot, because it cannot
|
|
18
|
+
* arrive in one. The registry holding departures lives in the broker's memory and dies with the
|
|
19
|
+
* process that records its own shutdown, so after a restart every row reads `null` instead. The
|
|
20
|
+
* value is honest where these records survive, which is the audit journal. In a snapshot,
|
|
21
|
+
* the question "has this broker forgotten" is answered by `observingSince`, not by this kind.
|
|
22
|
+
*
|
|
23
|
+
* An unrecognised reason classifies as `lost`, never as `announced` — an absence nobody can
|
|
24
|
+
* explain is not an explained absence.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DepartureKindSchema: z.ZodEnum<{
|
|
27
|
+
announced: "announced";
|
|
28
|
+
"broker-restart": "broker-restart";
|
|
29
|
+
lost: "lost";
|
|
30
|
+
}>;
|
|
31
|
+
export type DepartureKind = z.infer<typeof DepartureKindSchema>;
|
|
32
|
+
export declare const DepartureSchema: z.ZodObject<{
|
|
33
|
+
at: z.ZodString;
|
|
34
|
+
reason: z.ZodString;
|
|
35
|
+
kind: z.ZodEnum<{
|
|
36
|
+
announced: "announced";
|
|
37
|
+
"broker-restart": "broker-restart";
|
|
38
|
+
lost: "lost";
|
|
39
|
+
}>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type Departure = z.infer<typeof DepartureSchema>;
|
|
42
|
+
export declare const PresenceSchema: z.ZodObject<{
|
|
43
|
+
nodeId: z.ZodString;
|
|
44
|
+
online: z.ZodBoolean;
|
|
45
|
+
serves: z.ZodBoolean;
|
|
46
|
+
connections: z.ZodNumber;
|
|
47
|
+
since: z.ZodNullable<z.ZodString>;
|
|
48
|
+
version: z.ZodNullable<z.ZodString>;
|
|
49
|
+
behind: z.ZodNullable<z.ZodEnum<{
|
|
50
|
+
major: "major";
|
|
51
|
+
minor: "minor";
|
|
52
|
+
patch: "patch";
|
|
53
|
+
}>>;
|
|
54
|
+
versionSeenAt: z.ZodNullable<z.ZodString>;
|
|
55
|
+
departure: z.ZodNullable<z.ZodObject<{
|
|
56
|
+
at: z.ZodString;
|
|
57
|
+
reason: z.ZodString;
|
|
58
|
+
kind: z.ZodEnum<{
|
|
59
|
+
announced: "announced";
|
|
60
|
+
"broker-restart": "broker-restart";
|
|
61
|
+
lost: "lost";
|
|
62
|
+
}>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
observingSince: z.ZodString;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
export type Presence = z.infer<typeof PresenceSchema>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What one machine reports about the build it carries.
|
|
4
|
+
*
|
|
5
|
+
* Two distinctions carry this record, and collapsing either produces a confident lie in exactly the
|
|
6
|
+
* case somebody went looking:
|
|
7
|
+
*
|
|
8
|
+
* - **"up to date" is not "we do not know."** A node that reached no broker has no opinion about the
|
|
9
|
+
* fleet's release. Drawn as current, it would look healthiest precisely when nothing verified it.
|
|
10
|
+
* - **What was last LEARNED is not when it was last ASKED.** `checkedAt` and `ok` describe the
|
|
11
|
+
* attempt; `latest` describes the knowledge. A node that cannot connect still reports honestly
|
|
12
|
+
* that it does not know, stamped with a failed attempt.
|
|
13
|
+
*
|
|
14
|
+
* A node learns `latest` in exactly one way, and it is worth stating because it looks like a
|
|
15
|
+
* tautology and is not: **being admitted proves the broker runs this version**, since a broker
|
|
16
|
+
* admits nothing else. Refusal teaches it nothing at all — the handshake deliberately gives an
|
|
17
|
+
* unauthenticated peer no error text — so a refused node says `latest: null`, which is the truth.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ReleaseStandingSchema: z.ZodObject<{
|
|
20
|
+
current: z.ZodNullable<z.ZodString>;
|
|
21
|
+
latest: z.ZodNullable<z.ZodString>;
|
|
22
|
+
latestAt: z.ZodNullable<z.ZodString>;
|
|
23
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
24
|
+
ok: z.ZodBoolean;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
/** How far a build is behind another. Null = level, ahead, or nothing to compare against. */
|
|
27
|
+
export declare const BehindBySchema: z.ZodNullable<z.ZodEnum<{
|
|
28
|
+
major: "major";
|
|
29
|
+
minor: "minor";
|
|
30
|
+
patch: "patch";
|
|
31
|
+
}>>;
|
|
32
|
+
export type BehindBy = z.infer<typeof BehindBySchema>;
|
|
33
|
+
/** Strictly three numbers. Anything else is not a version this scheme can rank. */
|
|
34
|
+
export declare const SEMVER: RegExp;
|
|
35
|
+
export declare const versionParts: (value: string) => [number, number, number];
|
|
36
|
+
export declare function compareVersions(left: string, right: string): number;
|
|
37
|
+
/**
|
|
38
|
+
* Classified once, by the side that owns the version scheme.
|
|
39
|
+
*
|
|
40
|
+
* Every consumer would otherwise reimplement this and they would disagree — one calling a node two
|
|
41
|
+
* minors back "slightly behind" while another calls the same node current.
|
|
42
|
+
*
|
|
43
|
+
* **The breaking axis is the leftmost position that is not zero.** Below 1.0.0 that is the MINOR
|
|
44
|
+
* position, which is what this project has lived under for its whole life. Reading the positions
|
|
45
|
+
* literally instead would make `major` unreachable and file every breaking jump under `minor`:
|
|
46
|
+
* 0.10 against 0.16 is six flag days reported as a moderate gap. The error would point in the
|
|
47
|
+
* reassuring direction, which is the expensive direction — an operator reads the word and acts on it.
|
|
48
|
+
*
|
|
49
|
+
* A node AHEAD of the fleet is not behind. That is a development build, and colouring it as a
|
|
50
|
+
* problem teaches people to ignore the colour.
|
|
51
|
+
*/
|
|
52
|
+
export declare function behindBy(current: string, latest: string | null): BehindBy;
|
|
53
|
+
/** Whether two builds can be ranked against each other at all. Distinguishing this from "level" is
|
|
54
|
+
* what stops an unrankable build being drawn as current. */
|
|
55
|
+
export declare function comparableVersions(current: string | null, latest: string | null): boolean;
|
|
56
|
+
/** How severe a classification is, so a node seen through two brokers reports the WORSE of them.
|
|
57
|
+
* Picking whichever lane was listed first understates the lag, and understating is the direction
|
|
58
|
+
* an operator acts on. */
|
|
59
|
+
export declare function worseBehind(left: BehindBy, right: BehindBy): BehindBy;
|
|
60
|
+
/** The newest release anyone in a set managed to confirm. Null when nobody knows. */
|
|
61
|
+
export declare function bestKnownRelease(seen: readonly (string | null)[]): string | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The fields of a finished call; the wire's `Result` and the door's `LocalResult` are built on them. */
|
|
3
|
+
export declare const ResultFields: {
|
|
4
|
+
refusal: z.ZodEnum<{
|
|
5
|
+
capacity: "capacity";
|
|
6
|
+
none: "none";
|
|
7
|
+
policy: "policy";
|
|
8
|
+
request: "request";
|
|
9
|
+
}>;
|
|
10
|
+
retryAfterMs: z.ZodNullable<z.ZodNumber>;
|
|
11
|
+
transportCause: z.ZodNullable<z.ZodEnum<{
|
|
12
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
13
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
14
|
+
"no-connected-lane": "no-connected-lane";
|
|
15
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
16
|
+
"target-offline": "target-offline";
|
|
17
|
+
}>>;
|
|
18
|
+
id: z.ZodUUID;
|
|
19
|
+
ts: z.ZodString;
|
|
20
|
+
/** Who produced it. The broker itself for a failure raised before any node saw the call. */
|
|
21
|
+
from: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"broker">]>;
|
|
22
|
+
code: z.ZodNumber;
|
|
23
|
+
stdout: z.ZodString;
|
|
24
|
+
stderr: z.ZodString;
|
|
25
|
+
failure: z.ZodEnum<{
|
|
26
|
+
cancelled: "cancelled";
|
|
27
|
+
denied: "denied";
|
|
28
|
+
exec: "exec";
|
|
29
|
+
none: "none";
|
|
30
|
+
offline: "offline";
|
|
31
|
+
rejected: "rejected";
|
|
32
|
+
timeout: "timeout";
|
|
33
|
+
transport: "transport";
|
|
34
|
+
}>;
|
|
35
|
+
detail: z.ZodString;
|
|
36
|
+
/** Set when a stream hit MAX_STREAM_BYTES, so a consumer never mistakes a cut answer for a
|
|
37
|
+
* complete one. */
|
|
38
|
+
truncated: z.ZodBoolean;
|
|
39
|
+
};
|
|
40
|
+
/** The same completed-call validation on wire, local door and forward-compatible SDK readers. */
|
|
41
|
+
export declare function resultRefinement(result: z.infer<z.ZodObject<typeof ResultFields>>, ctx: z.RefinementCtx): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Refused } from './failure.ts';
|
|
3
|
+
import { type NodeId } from './identity.ts';
|
|
4
|
+
export declare const InvocationSchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodUUID;
|
|
6
|
+
ts: z.ZodString;
|
|
7
|
+
from: z.ZodString;
|
|
8
|
+
to: z.ZodString;
|
|
9
|
+
argv: z.ZodArray<z.ZodString>;
|
|
10
|
+
stdin: z.ZodNullable<z.ZodString>;
|
|
11
|
+
timeoutMs: z.ZodNumber;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export type Invocation = z.infer<typeof InvocationSchema>;
|
|
14
|
+
export declare const ResultSchema: z.ZodObject<{
|
|
15
|
+
refusal: z.ZodEnum<{
|
|
16
|
+
capacity: "capacity";
|
|
17
|
+
none: "none";
|
|
18
|
+
policy: "policy";
|
|
19
|
+
request: "request";
|
|
20
|
+
}>;
|
|
21
|
+
retryAfterMs: z.ZodNullable<z.ZodNumber>;
|
|
22
|
+
transportCause: z.ZodNullable<z.ZodEnum<{
|
|
23
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
24
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
25
|
+
"no-connected-lane": "no-connected-lane";
|
|
26
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
27
|
+
"target-offline": "target-offline";
|
|
28
|
+
}>>;
|
|
29
|
+
id: z.ZodUUID;
|
|
30
|
+
ts: z.ZodString;
|
|
31
|
+
from: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"broker">]>;
|
|
32
|
+
code: z.ZodNumber;
|
|
33
|
+
stdout: z.ZodString;
|
|
34
|
+
stderr: z.ZodString;
|
|
35
|
+
failure: z.ZodEnum<{
|
|
36
|
+
cancelled: "cancelled";
|
|
37
|
+
denied: "denied";
|
|
38
|
+
exec: "exec";
|
|
39
|
+
none: "none";
|
|
40
|
+
offline: "offline";
|
|
41
|
+
rejected: "rejected";
|
|
42
|
+
timeout: "timeout";
|
|
43
|
+
transport: "transport";
|
|
44
|
+
}>;
|
|
45
|
+
detail: z.ZodString;
|
|
46
|
+
truncated: z.ZodBoolean;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type Result = z.infer<typeof ResultSchema>;
|
|
49
|
+
/** The broker's immediate answer to `rpc:call`: did the envelope get as far as a target socket?
|
|
50
|
+
* A rejection here is final and carries no `Result` — there was nothing to execute. */
|
|
51
|
+
export declare const AdmissionSchema: z.ZodObject<{
|
|
52
|
+
refusal: z.ZodEnum<{
|
|
53
|
+
capacity: "capacity";
|
|
54
|
+
none: "none";
|
|
55
|
+
policy: "policy";
|
|
56
|
+
request: "request";
|
|
57
|
+
}>;
|
|
58
|
+
retryAfterMs: z.ZodNullable<z.ZodNumber>;
|
|
59
|
+
transportCause: z.ZodNullable<z.ZodEnum<{
|
|
60
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
61
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
62
|
+
"no-connected-lane": "no-connected-lane";
|
|
63
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
64
|
+
"target-offline": "target-offline";
|
|
65
|
+
}>>;
|
|
66
|
+
accepted: z.ZodBoolean;
|
|
67
|
+
failure: z.ZodEnum<{
|
|
68
|
+
cancelled: "cancelled";
|
|
69
|
+
denied: "denied";
|
|
70
|
+
exec: "exec";
|
|
71
|
+
none: "none";
|
|
72
|
+
offline: "offline";
|
|
73
|
+
rejected: "rejected";
|
|
74
|
+
timeout: "timeout";
|
|
75
|
+
transport: "transport";
|
|
76
|
+
}>;
|
|
77
|
+
detail: z.ZodString;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
export type Admission = z.infer<typeof AdmissionSchema>;
|
|
80
|
+
/**
|
|
81
|
+
* The one place a version is checked. `version` is the node's release, and the broker refuses a
|
|
82
|
+
* socket that does not match its own — so a half-finished rollout presents itself as a refusal on
|
|
83
|
+
* the machine that was missed, rather than as unexplained behaviour on a fleet that looks healthy.
|
|
84
|
+
*/
|
|
85
|
+
export declare const HandshakeSchema: z.ZodObject<{
|
|
86
|
+
nodeId: z.ZodString;
|
|
87
|
+
token: z.ZodString;
|
|
88
|
+
serves: z.ZodBoolean;
|
|
89
|
+
version: z.ZodString;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type Handshake = z.infer<typeof HandshakeSchema>;
|
|
92
|
+
export declare function syntheticResult(id: string, refused: Refused, from?: NodeId | 'broker'): Result;
|
|
93
|
+
/**
|
|
94
|
+
* A caller withdrawing a call it is no longer waiting for.
|
|
95
|
+
*
|
|
96
|
+
* A command runs on another machine, and a caller that walked away would leave it running to its
|
|
97
|
+
* own deadline — up to an hour of work nobody would read. `stream:cancel` says the same for a
|
|
98
|
+
* stream; this says it for a unary call.
|
|
99
|
+
*/
|
|
100
|
+
export declare const CancelSchema: z.ZodObject<{
|
|
101
|
+
id: z.ZodUUID;
|
|
102
|
+
from: z.ZodString;
|
|
103
|
+
to: z.ZodString;
|
|
104
|
+
reason: z.ZodString;
|
|
105
|
+
}, z.core.$strict>;
|
|
106
|
+
export type Cancel = z.infer<typeof CancelSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/** The first validation issue as one line an operator can act on: where, then what. */
|
|
3
|
+
export declare function firstIssue(error: {
|
|
4
|
+
issues: Array<{
|
|
5
|
+
path: PropertyKey[];
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
}): string;
|
|
9
|
+
/** A parse that says why it refused in one line instead of throwing. */
|
|
10
|
+
export type SchemaParse<T> = (value: unknown) => {
|
|
11
|
+
ok: true;
|
|
12
|
+
value: T;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
detail: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Validate with a schema and report its first issue.
|
|
19
|
+
*
|
|
20
|
+
* The one place a file's refusal reason is written, so every reader of the same schema — the node
|
|
21
|
+
* agent, the CLI, an owner's own tooling — says the same words for the same mistake.
|
|
22
|
+
*/
|
|
23
|
+
export declare function schemaParse<Schema extends z.ZodType>(schema: Schema): SchemaParse<z.output<Schema>>;
|