@selvajs/solve 2.0.0-beta.11 → 2.0.0-beta.13
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/README.md +17 -11
- package/dist/abort-CNJ8Sn4g.js +13 -0
- package/dist/abort-CNJ8Sn4g.js.map +1 -0
- package/dist/client.d.ts +34 -135
- package/dist/client.js +335 -240
- package/dist/client.js.map +1 -1
- package/dist/{outcome-DsNmx27P.d.ts → outcome-Bk9mnMi0.d.ts} +9 -28
- package/dist/{outcome-ai_9fm43.js → outcome-DNrffAXp.js} +48 -46
- package/dist/outcome-DNrffAXp.js.map +1 -0
- package/dist/server.d.ts +97 -222
- package/dist/server.js +657 -423
- package/dist/server.js.map +1 -1
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +1 -1
- package/package.json +9 -17
- package/dist/outcome-ai_9fm43.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-DNrffAXp.js","names":[],"sources":["../src/shared/solve-fn.ts","../src/shared/compute-diagnostics.ts","../src/shared/outcome.ts"],"sourcesContent":["import type { SolveDiagnostic } from '@selvajs/schemas';\n\n/**\n * The solve contract — what a solve returns and what a caller supplies to run one.\n *\n * Lives in `shared/` because both halves of the package speak it: `client/` calls a `SolveFn` and\n * stores its `SolveResult`; `server/` produces the payload one is built from.\n */\n\n/**\n * Marker the Grasshopper Message component prepends to a blocking error.\n *\n * Rhino.Compute flattens runtime messages to plain strings with no component attribution, so\n * this is the only way that path can tell a deliberate block from any other solve error. The\n * local WebSocket path carries `isGate` structurally and does not need it — but the component\n * writes the marker unconditionally, because the same definition runs on both.\n *\n * Changing this string breaks blocking on deployed Selva for every already-published\n * definition, since the text is baked into the .gh file's solve output, not the plugin.\n */\nexport const SOLVE_BLOCKED_MARKER = '[Selva:blocked]';\n\n/**\n * Marker the Message component prepends to a remark or warning — the non-blocking levels.\n *\n * Same reason as `SOLVE_BLOCKED_MARKER`: on Rhino.Compute nothing structural survives, and the\n * UI has to tell a message the author chose to write from an incidental Grasshopper warning.\n * Definitions saved before this existed lack it, so the reader falls back to the component name.\n */\nexport const SOLVE_AUTHORED_MARKER = '[Selva:msg]';\n\n/**\n * Marker for an authored message whose author chose Notify = Log.\n *\n * Still theirs — it keeps its attribution and its place in the message list — but it does not\n * interrupt. Errors never carry it: their result is withheld, so they always interrupt.\n */\nexport const SOLVE_LOG_ONLY_MARKER = '[Selva:log]';\n\n/**\n * One message a solve raised, with who raised it and whether it was deliberate (`isGate`).\n * Generated from `wire-schema.json`; both transports decode into it (see `outcome.ts`).\n */\nexport type { SolveDiagnostic };\n\n/**\n * `TMesh` is deliberately opaque and defaults to `unknown`: this package never inspects meshes, and\n * typing them would drag a renderer dependency into a package whose whole point is not having one.\n * The app that owns assembly (parse → `THREE.Object3D[]`) is the only place that knows the concrete\n * type, and it narrows by writing `SolveResult<THREE.Object3D>` at its own seam.\n */\nexport interface SolveResult<TMesh = unknown, TSource = unknown> {\n\toutputs: Record<string, unknown>;\n\tmeshes?: TMesh[];\n\terrors?: string[];\n\twarnings?: string[];\n\t/** Structured form of `errors`/`warnings`, including remarks. Absent from transports that report neither. */\n\tdiagnostics?: SolveDiagnostic[];\n\t/**\n\t * The definition refused this solve — a guard in the definition raised an error and its\n\t * outputs were withheld deliberately. Distinct from an errored solve that still returned\n\t * values, and from a transport failure: the solve ran and its answer is \"no\". Consumers\n\t * should show `errors` instead of treating the empty outputs as a result.\n\t */\n\tblocked?: boolean;\n\t/**\n\t * The solve was stopped before it finished. Always also `blocked`: what computed before\n\t * the stop is not a result. Absent from a transport that cannot tell.\n\t */\n\taborted?: boolean;\n\t/**\n\t * The unparsed payload this result was built from, passed through verbatim. Opaque here for the\n\t * same reason as `TMesh`: a consumer that must persist or re-submit exactly what it showed the\n\t * user narrows it at its own seam. Travels with the result through the driver's memo, so a\n\t * cached hit carries the source that produced it. Unlike `meshes` it needs no ownership policy —\n\t * it is inert data, not a GPU-backed handle.\n\t *\n\t * Supplied by the `SolveFn`, so it is present only when the one in use sets it\n\t * (`createComputeFetchSolveFn` does). A transport with no raw payload to hand back leaves it\n\t * absent — see `values` on telling absent from unsupported.\n\t */\n\tsource?: TSource;\n\t/**\n\t * The input set that produced this result, stamped by the driver rather than the `SolveFn` — a\n\t * memo hit never calls the `SolveFn`, so a consumer reading values captured inside it would pair\n\t * the on-screen result with whatever solved last. Keeping the pair atomic is the point: a commit\n\t * path holding a `SolveResult` cannot mismatch artifact and inputs.\n\t *\n\t * Present only from a driver that owns a request/response pair (`createRequestResponseDriver`).\n\t * A push driver cannot attribute an incoming frame to a request and must leave this absent\n\t * rather than guess — so `undefined` means \"this transport does not supply it\", not \"no solve\n\t * yet\", and a consumer that needs the pair requires a request/response driver. See `SolveDriver`.\n\t */\n\tvalues?: Record<string, unknown>;\n}\n\n/** Implementations should listen to `signal` and abort/clean up when it fires. */\nexport type SolveFn<TMesh = unknown, TSource = unknown> = (\n\tvalues: Record<string, unknown>,\n\tsignal: AbortSignal\n) => Promise<SolveResult<TMesh, TSource>>;\n","// Rhino.Compute reports runtime messages as flat strings, so everything the UI needs to tell a\n// deliberate message from incidental noise has to be recovered from the text. This is the one\n// place that parsing happens.\n//\n// Two decorations are applied by the server, in this order:\n// \"<author's text>: component \\\"<Name>\\\" (<guid>)\" — LogRuntimeMessages, every message\n// \"<n>. Solution exception:<marker> ...\" — the numbered-error wrapper\n// The local WebSocket path carries the same facts structurally and never comes through here.\n\nimport {\n\tSOLVE_AUTHORED_MARKER,\n\tSOLVE_BLOCKED_MARKER,\n\tSOLVE_LOG_ONLY_MARKER,\n\ttype SolveDiagnostic\n} from './solve-fn.js';\n\n/**\n * Compute's per-message attribution suffix. Anchored to the end and requiring the parenthesised\n * GUID, so an author who writes `component \"x\"` mid-sentence keeps their text intact.\n */\nconst ATTRIBUTION = /:\\s*component\\s+\"([^\"]*)\"\\s*\\(([0-9a-fA-F-]{36}|\\.\\.\\.)\\)\\s*$/;\n\n/** The Selva Message component's own name, as `LogRuntimeMessages` reports it. */\nconst MESSAGE_COMPONENT_NAME = 'Message';\n\nexport interface ParsedComputeMessage {\n\t/** The author's text, with the attribution suffix and any marker removed. */\n\tmessage: string;\n\t/** Component name from the attribution suffix, when present. */\n\tsource?: string;\n\t/** Carried the block marker: a Message component refused the solve. */\n\tblocked: boolean;\n\t/** Carried any marker: a Message component wrote this. */\n\tauthored: boolean;\n\t/** The author chose Notify = Log: list it, but do not interrupt. */\n\tlogOnly: boolean;\n}\n\n/**\n * Splits one Compute message string into the author's text and its attribution.\n *\n * Leaves the text alone when the suffix is absent — an exception thrown by a script component\n * has no attribution and must not be truncated on a guess.\n */\nexport function parseComputeMessage(raw: string): ParsedComputeMessage {\n\tconst blocked = raw.includes(SOLVE_BLOCKED_MARKER);\n\tconst logOnly = !blocked && raw.includes(SOLVE_LOG_ONLY_MARKER);\n\tconst authored = blocked || logOnly || raw.includes(SOLVE_AUTHORED_MARKER);\n\tlet message = raw;\n\n\tlet source: string | undefined;\n\tconst attribution = ATTRIBUTION.exec(message);\n\tif (attribution) {\n\t\tsource = attribution[1] || undefined;\n\t\tmessage = message.slice(0, attribution.index);\n\t}\n\n\tif (authored) {\n\t\tmessage = message\n\t\t\t.replace(SOLVE_BLOCKED_MARKER, '')\n\t\t\t.replace(SOLVE_AUTHORED_MARKER, '')\n\t\t\t.replace(SOLVE_LOG_ONLY_MARKER, '')\n\t\t\t// The numbered wrapper reads as noise next to the author's own sentence. Dropped only\n\t\t\t// when a marker proves the text is one of ours.\n\t\t\t.replace(/^\\s*\\d+\\.\\s*Solution exception:\\s*/, '');\n\t}\n\n\treturn { message: message.replace(/\\s{2,}/g, ' ').trim(), source, blocked, authored, logOnly };\n}\n\n/**\n * Rebuilds structured diagnostics from Compute's `errors`/`warnings` arrays.\n *\n * `isGate` comes from the marker the component writes. The component-name fallback is for\n * definitions saved before the non-blocking marker existed; `obj.Name` is the component's type\n * name, not its nickname, so renaming one on the canvas cannot change how it behaves.\n */\nexport function parseComputeDiagnostics(\n\terrors: readonly string[],\n\twarnings: readonly string[]\n): SolveDiagnostic[] {\n\tconst build = (raw: string, level: 'error' | 'warning'): SolveDiagnostic => {\n\t\tconst { message, source, authored, logOnly } = parseComputeMessage(raw);\n\t\tconst isGate = (authored || source === MESSAGE_COMPONENT_NAME) && !logOnly;\n\t\treturn { level, message, ...(source ? { source } : {}), ...(isGate ? { isGate } : {}) };\n\t};\n\treturn [\n\t\t...errors.map((raw) => build(raw, 'error')),\n\t\t...warnings.map((raw) => build(raw, 'warning'))\n\t];\n}\n","// The one place a solve's verdict becomes a `SolveResult`. The plugin decides the verdict\n// (`SolveOutcome`: diagnostics, blocked, aborted) once, and both transports carry it: the local\n// `outputs` envelope and the VektorNode fork's `selva` block. Each driver decodes it here, so a\n// rule about what a verdict means is written once rather than once per transport.\n//\n// A Compute response without a `selva` block (stock server, older plugin) falls back to\n// `outcomeFromComputeMessages`, which recovers what it can from the flattened strings. It cannot\n// see remarks or an abort.\n\nimport type { SolveOutcome } from '@selvajs/schemas';\nimport { parseComputeDiagnostics } from './compute-diagnostics.js';\nimport { SOLVE_BLOCKED_MARKER, type SolveDiagnostic, type SolveResult } from './solve-fn.js';\n\nexport type { SolveOutcome };\n\nfunction isLevel(value: unknown): value is SolveDiagnostic['level'] {\n\treturn value === 'error' || value === 'warning' || value === 'remark';\n}\n\n/**\n * One wire diagnostic, normalized: an unknown level reads as a remark, text is trimmed, and\n * `source`/`isGate` are omitted rather than null or false. Null when it carries no message.\n */\nexport function decodeDiagnostic(entry: unknown): SolveDiagnostic | null {\n\tif (!entry || typeof entry !== 'object') return null;\n\tconst d = entry as Record<string, unknown>;\n\tconst message = typeof d.message === 'string' ? d.message.trim() : '';\n\tif (!message) return null;\n\tconst source = typeof d.source === 'string' && d.source ? d.source : undefined;\n\treturn {\n\t\tlevel: isLevel(d.level) ? d.level : 'remark',\n\t\tmessage,\n\t\t...(source ? { source } : {}),\n\t\t...(d.isGate === true ? { isGate: true } : {})\n\t};\n}\n\nfunction normalizeOutcome(\n\tentries: readonly unknown[],\n\tblocked: boolean,\n\taborted: boolean\n): SolveOutcome {\n\tconst seen = new Set<string>();\n\tconst diagnostics: SolveDiagnostic[] = [];\n\tfor (const entry of entries) {\n\t\tconst d = decodeDiagnostic(entry);\n\t\tif (!d) continue;\n\t\tconst key = `${d.level}\\u0000${d.message}\\u0000${d.source ?? ''}\\u0000${d.isGate === true}`;\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tdiagnostics.push(d);\n\t}\n\treturn { diagnostics, blocked: blocked || aborted, aborted };\n}\n\n/**\n * Normalizes a wire outcome with `decodeDiagnostic`, dropping exact repeats, so the same verdict\n * decodes to the same object from either transport. Null when `wire` is not an outcome at all;\n * the caller then falls back. A verdict without a diagnostic list still counts: reading a refusal\n * as \"no outcome\" would let the solve through.\n */\nexport function decodeOutcome(wire: unknown): SolveOutcome | null {\n\tif (!wire || typeof wire !== 'object') return null;\n\tconst { diagnostics, blocked, aborted } = wire as Record<string, unknown>;\n\tconst hasList = Array.isArray(diagnostics);\n\tif (!hasList && blocked === undefined && aborted === undefined) return null;\n\t// `'true'` too: a flag that arrives stringified must fail closed, not let a refusal through.\n\tconst isTrue = (flag: unknown) => flag === true || flag === 'true';\n\treturn normalizeOutcome(hasList ? diagnostics : [], isTrue(blocked), isTrue(aborted));\n}\n\n/** The legacy verdict, read from Compute's flattened `errors`/`warnings` and their markers. */\nexport function outcomeFromComputeMessages(\n\terrors: readonly unknown[],\n\twarnings: readonly unknown[]\n): SolveOutcome {\n\tconst strings = (list: readonly unknown[]) => list.filter((m) => typeof m === 'string');\n\tconst errorText = strings(errors);\n\treturn normalizeOutcome(\n\t\tparseComputeDiagnostics(errorText, strings(warnings)),\n\t\t// Substring, not prefix: the server numbers each entry (\"1. Solution exception: ...\").\n\t\terrorText.some((e) => e.includes(SOLVE_BLOCKED_MARKER)),\n\t\tfalse\n\t);\n}\n\n/**\n * Builds the result a driver reports. A blocked or aborted outcome is \"no result\" whatever the\n * transport sent along: no outputs, no `source` (it holds the withheld outputs), and an empty mesh\n * list so the viewer clears. `errors` and `warnings` are derived from the diagnostics for hosts\n * that only want text.\n */\nexport function finalizeResult<TMesh, TSource>(\n\tpartial: { outputs: Record<string, unknown>; meshes?: TMesh[]; source?: TSource },\n\toutcome: SolveOutcome\n): SolveResult<TMesh, TSource> {\n\tconst rejected = outcome.blocked || outcome.aborted;\n\tconst meshes = rejected ? [] : partial.meshes;\n\treturn {\n\t\toutputs: rejected ? {} : partial.outputs,\n\t\t...(meshes !== undefined ? { meshes } : {}),\n\t\terrors: outcome.diagnostics.filter((d) => d.level === 'error').map((d) => d.message),\n\t\twarnings: outcome.diagnostics.filter((d) => d.level === 'warning').map((d) => d.message),\n\t\tdiagnostics: outcome.diagnostics,\n\t\tblocked: outcome.blocked,\n\t\taborted: outcome.aborted,\n\t\t...(partial.source !== undefined && !rejected ? { source: partial.source } : {})\n\t};\n}\n"],"mappings":"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"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { t as SolveInput } from "./solve-input-CUjVGYPC.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { UISchema } from "@selvajs/schemas";
|
|
3
|
+
import { GrasshopperClient, GrasshopperComputeResponse, SelvaEventTarget, SolveScheduler } from "@selvajs/compute/grasshopper";
|
|
4
|
+
import { DefinitionRef, DefinitionRef as DefinitionRef$1, ServerTiming, SolveDefinition } from "@selvajs/compute/core";
|
|
5
|
+
/** Rhino.Compute's own default `--timeout`, for a server that can't report its own. */
|
|
6
|
+
export declare const DEFAULT_SOLVE_DEADLINE_MS = 100000;
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* Ceiling on any solve deadline, whatever the server reports. Bounds how long a request, its
|
|
9
|
+
* live-event token and a delegated session stay open; past an hour a solve belongs in a job.
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export declare const MAX_SOLVE_DEADLINE_MS: number;
|
|
12
|
+
/** What Selva holds a solve to on one compute server. */
|
|
13
|
+
interface SolveLimits {
|
|
14
|
+
solveDeadlineMs: number;
|
|
15
|
+
/** `null` when the server didn't say: its own 413 is then the only check. */
|
|
16
|
+
maxRequestBytes: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Send a pointer to the server's cached definition instead of the `.gh`. Only on a server that
|
|
19
|
+
* answers a stale pointer with `definition_not_cached`: one that doesn't returns empty geometry.
|
|
20
|
+
*/
|
|
21
|
+
reuseDefinitionCache: boolean;
|
|
22
|
+
}
|
|
12
23
|
/** Minimal resolved-server shape the cache needs (a subset of the app's `ComputeServerConfig`). */
|
|
13
24
|
interface ResolvedServer {
|
|
14
25
|
id: string;
|
|
@@ -16,10 +27,11 @@ interface ResolvedServer {
|
|
|
16
27
|
/** Sent as the `RhinoComputeKey` header. */
|
|
17
28
|
apiKey?: string;
|
|
18
29
|
}
|
|
19
|
-
export declare function serverIdentity(server: Pick<ResolvedServer, 'id'>): ServerIdentity;
|
|
20
30
|
interface CachedClient {
|
|
21
31
|
client: GrasshopperClient;
|
|
22
32
|
scheduler: SolveScheduler;
|
|
33
|
+
/** Read from the server when the client was built; a changed server rebuilds the client. */
|
|
34
|
+
limits: SolveLimits;
|
|
23
35
|
}
|
|
24
36
|
/**
|
|
25
37
|
* Debug verbosity: `false` is silent, `true` gives concise cache/timing logs
|
|
@@ -27,68 +39,6 @@ interface CachedClient {
|
|
|
27
39
|
* dumps (incl. geometry) — a superset of `true`, not an independent setting.
|
|
28
40
|
*/
|
|
29
41
|
type ClientCacheDebug = boolean | 'verbose';
|
|
30
|
-
/** Config injected by the consuming app, so this module stays env-agnostic and testable. */
|
|
31
|
-
interface ClientCacheConfig {
|
|
32
|
-
/** Per-solve timeout forwarded to the scheduler (`ComputeLimits.solveDeadlineMs`). */
|
|
33
|
-
solveDeadlineMs: number;
|
|
34
|
-
cachesolve: boolean;
|
|
35
|
-
/** Reference large definitions by server cache key instead of re-uploading. */
|
|
36
|
-
reuseServerDefinitionCache: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Max solves that may wait in the FIFO queue, excluding in-flight solves
|
|
39
|
-
* (capped at `maxConcurrent`, itself driven by the server's probed child
|
|
40
|
-
* count). `0` = unbounded (`ComputeLimits.computeMaxQueueDepth`); a full
|
|
41
|
-
* queue rejects new solves with `QUEUE_FULL`.
|
|
42
|
-
*/
|
|
43
|
-
maxQueueDepth: number;
|
|
44
|
-
/**
|
|
45
|
-
* Max ms a solve may sit queued before executing; `0` = no deadline
|
|
46
|
-
* (`ComputeLimits.computeQueueWaitMs`). Too long a wait rejects with
|
|
47
|
-
* `QUEUE_TIMEOUT`.
|
|
48
|
-
*/
|
|
49
|
-
queueWaitMs: number;
|
|
50
|
-
/**
|
|
51
|
-
* Byte budget for this client's in-process solve cache. Applies per warm
|
|
52
|
-
* client — worst-case heap is this × `maxWarmComputeServers`. `0` disables
|
|
53
|
-
* the cache (`ComputeLimits.computeSolveCacheBytes`, env `COMPUTE_SOLVE_CACHE_MB`).
|
|
54
|
-
*/
|
|
55
|
-
responseCacheMaxBytes: number;
|
|
56
|
-
/**
|
|
57
|
-
* Largest compute response body read; past it the download is cancelled (`too_large`).
|
|
58
|
-
* Default: no limit.
|
|
59
|
-
*/
|
|
60
|
-
maxResponseBytes?: number;
|
|
61
|
-
debug: ClientCacheDebug;
|
|
62
|
-
/** Max distinct warm compute servers before the LRU evicts the oldest. Default 16. */
|
|
63
|
-
maxWarmComputeServers?: number;
|
|
64
|
-
/** Sink for the debug lines. `onDebugLog` only fires when `debug` is not `false`. */
|
|
65
|
-
onDebugLog?: (message: string) => void;
|
|
66
|
-
}
|
|
67
|
-
interface ClientCache {
|
|
68
|
-
/**
|
|
69
|
-
* Get (or create) the warm client + scheduler for a resolved compute server,
|
|
70
|
-
* keyed by its `id`. `definitionGuid`, when present, is stamped as the
|
|
71
|
-
* `X-Selva-Definition` header on this client's outbound solve/IO requests —
|
|
72
|
-
* inert routing/telemetry metadata until a pool router exists.
|
|
73
|
-
*/
|
|
74
|
-
getClient(server: ResolvedServer, opts?: {
|
|
75
|
-
definitionGuid?: string;
|
|
76
|
-
}): Promise<CachedClient>;
|
|
77
|
-
/** Dispose and drop the warm client for `id`, so the next request rebuilds against fresh connection details. */
|
|
78
|
-
evict(id: string | ServerIdentity): void;
|
|
79
|
-
/** Solve-cache counters summed across every warm client. Counters die with the client that owns them, so totals can fall over time. */
|
|
80
|
-
solveCacheStats(): SolveCacheStats;
|
|
81
|
-
/**
|
|
82
|
-
* Drop every retained solve result, keeping the warm clients (and their
|
|
83
|
-
* connections and server-side definition pointers) intact. Nothing expires
|
|
84
|
-
* these on its own — the byte budget is the only other pressure — so this is
|
|
85
|
-
* the operator's release valve when a definition's inputs no longer describe
|
|
86
|
-
* its output, e.g. it reads an external source that has since changed.
|
|
87
|
-
*/
|
|
88
|
-
clearSolveCaches(): void;
|
|
89
|
-
/** Dispose every warm client. Test seam / shutdown hook. */
|
|
90
|
-
disposeAll(): void;
|
|
91
|
-
}
|
|
92
42
|
interface SolveCacheStats {
|
|
93
43
|
warmClients: number;
|
|
94
44
|
entries: number;
|
|
@@ -98,7 +48,6 @@ interface SolveCacheStats {
|
|
|
98
48
|
/** Entries dropped under size/byte pressure (not replacement or manual clears). */
|
|
99
49
|
evictions: number;
|
|
100
50
|
}
|
|
101
|
-
export declare function createClientCache(config: ClientCacheConfig): ClientCache;
|
|
102
51
|
/**
|
|
103
52
|
* In-process cache of `.gh` definition bytes, keyed by immutable **version id**.
|
|
104
53
|
*
|
|
@@ -131,7 +80,7 @@ interface ByteRefOutcome {
|
|
|
131
80
|
/** A definition reference shaped for `@selvajs/compute`'s `DefinitionRef`. */
|
|
132
81
|
interface ByteCacheRef {
|
|
133
82
|
key: string;
|
|
134
|
-
load: () => Promise<Uint8Array>;
|
|
83
|
+
load: (signal?: AbortSignal) => Promise<Uint8Array>;
|
|
135
84
|
outcome: ByteRefOutcome;
|
|
136
85
|
}
|
|
137
86
|
interface ByteCacheStats {
|
|
@@ -141,65 +90,23 @@ interface ByteCacheStats {
|
|
|
141
90
|
entries: number;
|
|
142
91
|
bytes: number;
|
|
143
92
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
93
|
+
/** A pre-solve prep sub-phase: `[label, ms]`, surfaced as a `p_*` Server-Timing entry. */
|
|
94
|
+
type PrepMark = [string, number];
|
|
95
|
+
interface CacheVerdict {
|
|
96
|
+
fromCache: boolean;
|
|
97
|
+
definitionReuploaded?: boolean;
|
|
148
98
|
}
|
|
149
99
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
100
|
+
* skipped = scheduler never materialized bytes (pointer-known solve, the whole point of this
|
|
101
|
+
* path); hit = warm byte cache; miss = fell through to storage.
|
|
152
102
|
*/
|
|
153
|
-
|
|
103
|
+
type DefBytesVerdict = 'skipped' | 'hit' | 'miss';
|
|
154
104
|
/** Compute-response contract version. Bump (and document the change) whenever the envelope's shape changes in a way a consumer could observe. */
|
|
155
105
|
export declare const COMPUTE_CONTRACT_VERSION: 1;
|
|
156
106
|
export declare const COMPUTE_VERSION_HEADER = "X-Selva-Compute-Version";
|
|
157
|
-
|
|
158
|
-
interface SolvePipelineArgs {
|
|
159
|
-
/**
|
|
160
|
-
* Raw `.gh` bytes, or a byte-cache `DefinitionRef` whose bytes the scheduler
|
|
161
|
-
* materializes only when an upload is unavoidable — a pointer-known solve
|
|
162
|
-
* moves zero bytes.
|
|
163
|
-
*/
|
|
164
|
-
definitionSource: SolveDefinition$1;
|
|
165
|
-
/** Mutable load outcome for a `DefinitionRef` source, so the `def_bytes` Server-Timing verdict can be emitted. Omit for raw-bytes solves. */
|
|
166
|
-
byteRefOutcome?: ByteRefOutcome;
|
|
167
|
-
/** Persisted input params; only those with a `paramType` are sent to the solve. */
|
|
168
|
-
inputs: PipelineInput[];
|
|
169
|
-
/**
|
|
170
|
-
* A tree the caller already built with {@link buildSolveInputTree}; skips the
|
|
171
|
-
* pipeline's own build and solves this object directly.
|
|
172
|
-
*
|
|
173
|
-
* A caller coalescing concurrent solves needs this: a single-flight key
|
|
174
|
-
* derived from raw `{inputs, values}` would split two requests that transform
|
|
175
|
-
* to the same tree, which is the identity the scheduler actually caches on.
|
|
176
|
-
*/
|
|
177
|
-
inputTree?: DataTree[];
|
|
178
|
-
/** User-chosen values keyed by input id; missing keys fall back to the schema default. */
|
|
179
|
-
values: Record<string, unknown>;
|
|
180
|
-
client: CachedClient;
|
|
181
|
-
responseMaxBytes: number;
|
|
182
|
-
/** Only phrases the timeout message — the scheduler enforces the deadline itself. */
|
|
183
|
-
solveDeadlineMs: number;
|
|
184
|
-
/** Client's `Accept-Encoding`; gzip is applied only when it advertises `gzip`. */
|
|
185
|
-
acceptEncoding: string;
|
|
186
|
-
/** Per-solve live-event callback the compute server hands to the definition; absent when the caller opened no stream. */
|
|
187
|
-
selvaEvents?: SelvaEventTarget;
|
|
188
|
-
/**
|
|
189
|
-
* Forwarded to the scheduler so a client disconnect cancels the upstream
|
|
190
|
-
* compute call. Its `aborted` flag also distinguishes a client disconnect
|
|
191
|
-
* from the scheduler's own deadline firing.
|
|
192
|
-
*/
|
|
193
|
-
signal: AbortSignal;
|
|
194
|
-
/** Wall-clock origin (`performance.now()` at the top of the request) so `load`/`total` phase timings line up with the caller's pre-solve prep. */
|
|
195
|
-
loadStartMs: number;
|
|
196
|
-
/** Pre-solve "load" phase duration the caller already measured (auth + DB + fetch). */
|
|
197
|
-
defLoadMs: number;
|
|
198
|
-
/** Pre-solve prep sub-phase marks (`[label, ms]`), surfaced verbatim as `p_*` Server-Timing entries. */
|
|
199
|
-
prepMarks?: [string, number][];
|
|
200
|
-
}
|
|
201
|
-
/** Phase timings the pipeline measured; the caller uses them for debug logging. */
|
|
107
|
+
/** What the `Server-Timing` header carries for one caller, as data: read this, don't parse that. */
|
|
202
108
|
interface SolvePhaseMetrics {
|
|
109
|
+
defLoadMs: number;
|
|
203
110
|
treeBuildMs: number;
|
|
204
111
|
solveMs: number;
|
|
205
112
|
serializeMs: number;
|
|
@@ -208,6 +115,11 @@ interface SolvePhaseMetrics {
|
|
|
208
115
|
serializedBytes: number;
|
|
209
116
|
/** Null when compression was skipped. */
|
|
210
117
|
compressedBytes: number | null;
|
|
118
|
+
/** The compute server's own timing; null when it reports none. */
|
|
119
|
+
rhino: ServerTiming | null;
|
|
120
|
+
settle: CacheVerdict;
|
|
121
|
+
/** Absent for raw-bytes solves. */
|
|
122
|
+
defBytes?: DefBytesVerdict;
|
|
211
123
|
}
|
|
212
124
|
/** A ready-to-send response: body + headers + the solve result + phase metrics. */
|
|
213
125
|
interface SolveEnvelope {
|
|
@@ -218,20 +130,21 @@ interface SolveEnvelope {
|
|
|
218
130
|
result: GrasshopperComputeResponse;
|
|
219
131
|
metrics: SolvePhaseMetrics;
|
|
220
132
|
}
|
|
133
|
+
/** Whether an `Accept-Encoding` header takes gzip. `gzip;q=0` is a client refusing it. */
|
|
134
|
+
export declare function acceptsGzip(acceptEncoding: string): boolean;
|
|
221
135
|
/**
|
|
222
|
-
* `ok` carries the envelope; every other variant names an expected failure
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* `durationMs` on error variants is the solve wall time up to the failure, for
|
|
226
|
-
* the metric record.
|
|
136
|
+
* `ok` carries the envelope; every other variant names an expected failure:
|
|
137
|
+
* `SolveEngine.toWebResponse` maps each to a status. `durationMs` on error variants is the solve
|
|
138
|
+
* wall time up to the failure, for the metric record.
|
|
227
139
|
*/
|
|
228
|
-
type
|
|
140
|
+
type SolveEngineOutcome = {
|
|
229
141
|
kind: 'ok';
|
|
230
142
|
envelope: SolveEnvelope;
|
|
231
143
|
solveMs: number;
|
|
232
144
|
errorCount: number;
|
|
233
145
|
warningCount: number;
|
|
234
|
-
} |
|
|
146
|
+
} | SolveFailure;
|
|
147
|
+
type SolveFailure = {
|
|
235
148
|
kind: 'timeout';
|
|
236
149
|
durationMs: number;
|
|
237
150
|
message: string;
|
|
@@ -241,11 +154,21 @@ type SolveOutcome = {
|
|
|
241
154
|
} | {
|
|
242
155
|
kind: 'too_large';
|
|
243
156
|
} |
|
|
244
|
-
/**
|
|
157
|
+
/** The compute server refused the request body (its `RHINO_COMPUTE_MAX_REQUEST_SIZE`). */
|
|
158
|
+
{
|
|
159
|
+
kind: 'request_too_large';
|
|
160
|
+
durationMs: number;
|
|
161
|
+
message: string;
|
|
162
|
+
} |
|
|
163
|
+
/**
|
|
164
|
+
* Retryable: no result, through no fault of the request, and `retryAfterSeconds` is a backoff
|
|
165
|
+
* hint. Scheduler backpressure rejected the solve before it ran (`queue_full`,
|
|
166
|
+
* `queue_timeout`), or its client was shut down under it (`interrupted`).
|
|
167
|
+
*/
|
|
245
168
|
{
|
|
246
169
|
kind: 'shed';
|
|
247
170
|
durationMs: number;
|
|
248
|
-
reason: 'queue_full' | 'queue_timeout';
|
|
171
|
+
reason: 'queue_full' | 'queue_timeout' | 'interrupted';
|
|
249
172
|
retryAfterSeconds: number;
|
|
250
173
|
message: string;
|
|
251
174
|
} | {
|
|
@@ -253,71 +176,12 @@ type SolveOutcome = {
|
|
|
253
176
|
durationMs: number;
|
|
254
177
|
error: unknown;
|
|
255
178
|
};
|
|
256
|
-
export declare function runSolvePipeline(args: SolvePipelineArgs): Promise<SolveOutcome>;
|
|
257
|
-
/**
|
|
258
|
-
* Re-key a coalesced envelope to a single waiter's `Accept-Encoding`.
|
|
259
|
-
*
|
|
260
|
-
* The single-flight coalescer runs ONE pipeline execution for N identical
|
|
261
|
-
* concurrent solves and hands every waiter the same {@link SolveEnvelope},
|
|
262
|
-
* baked from the FIRST caller's `Accept-Encoding`. A later waiter with a
|
|
263
|
-
* different `Accept-Encoding` would otherwise get a body labelled with the
|
|
264
|
-
* wrong encoding — `Vary` can't help here, since it's one shared object, not a
|
|
265
|
-
* cache lookup. Encoding is deliberately left out of the coalesce key so mixed
|
|
266
|
-
* clients still coalesce; this adapts the shared result to each waiter instead.
|
|
267
|
-
*
|
|
268
|
-
* Only the correctness-critical direction is adapted: a gzip envelope served to
|
|
269
|
-
* a non-gzip waiter is gunzipped back to JSON. The reverse (plain JSON to a
|
|
270
|
-
* gzip-capable waiter) is left uncompressed — correct, just not maximally small.
|
|
271
|
-
*/
|
|
272
|
-
export declare function adaptEnvelopeToEncoding(envelope: SolveEnvelope, acceptEncoding: string): {
|
|
273
|
-
body: string | Uint8Array;
|
|
274
|
-
headers: Record<string, string>;
|
|
275
|
-
};
|
|
276
|
-
/** The input tree a solve sends: each input's value, or its schema default when it has none. */
|
|
277
|
-
export declare function buildSolveInputTree(inputs: SolveInput[], values: Record<string, unknown>): DataTree[];
|
|
278
|
-
/**
|
|
279
|
-
* In-process single-flight — dogpile protection for every solve.
|
|
280
|
-
*
|
|
281
|
-
* Always on, not gated behind a result cache being configured: the dogpile is worst
|
|
282
|
-
* when nothing else is caching, since N concurrent identical solves each pay a full
|
|
283
|
-
* Rhino round trip (the scheduler doesn't coalesce in-flight requests itself, and
|
|
284
|
-
* Rhino's `cachesolve` still costs a round trip per repeat). An earlier version
|
|
285
|
-
* gated this on cache config and so disabled it in exactly the deployments most
|
|
286
|
-
* exposed to a cold-key stampede — hot public definition plus a deploy.
|
|
287
|
-
*
|
|
288
|
-
* Per app instance, above `ISolveResultCache`. No cross-instance lease (Redis
|
|
289
|
-
* `SET NX`) yet.
|
|
290
|
-
*
|
|
291
|
-
* The shared promise resolves to one value for every waiter, so `work` must return
|
|
292
|
-
* something safe to share by reference — the solve pipeline's envelope qualifies
|
|
293
|
-
* because the app serializes it per response.
|
|
294
|
-
*/
|
|
295
|
-
interface SolveCacheSingleFlight {
|
|
296
|
-
/**
|
|
297
|
-
* Coalesces concurrent calls under the same key: the first caller runs `work`,
|
|
298
|
-
* later callers for that key await the same promise, and the key frees as soon
|
|
299
|
-
* as it settles.
|
|
300
|
-
*
|
|
301
|
-
* `onWaiterJoined` fires only on the owner's call, only while `work` is still
|
|
302
|
-
* running, each time another caller joins. Ownership changes what the owner's
|
|
303
|
-
* abort signal should mean: a solo run can cancel on its own client's
|
|
304
|
-
* disconnect, but a shared run can't without 499-ing every waiter.
|
|
305
|
-
*/
|
|
306
|
-
run<T>(key: string, work: () => Promise<T>, onWaiterJoined?: () => void): Promise<T>;
|
|
307
|
-
inFlight(): number;
|
|
308
|
-
}
|
|
309
|
-
interface SolveCacheSingleFlightOptions {
|
|
310
|
-
onJoin?: (key: string) => void;
|
|
311
|
-
}
|
|
312
|
-
export declare function createSolveCacheSingleFlight(options?: SolveCacheSingleFlightOptions): SolveCacheSingleFlight;
|
|
313
179
|
/**
|
|
314
180
|
* Subset of `ComputeLimits` (`@selvajs/server/compute`) the engine needs.
|
|
315
181
|
* Pass the resolved object through as-is — extra fields are ignored.
|
|
316
182
|
*/
|
|
317
183
|
interface SolveEngineLimits {
|
|
318
|
-
solveDeadlineMs: number;
|
|
319
184
|
computeResponseMaxBytes: number;
|
|
320
|
-
computeReuseDefinitionCache: boolean;
|
|
321
185
|
computeServerCachesolve: boolean;
|
|
322
186
|
computeMaxQueueDepth: number;
|
|
323
187
|
computeQueueWaitMs: number;
|
|
@@ -326,26 +190,20 @@ interface SolveEngineLimits {
|
|
|
326
190
|
}
|
|
327
191
|
interface SolveEngineOptions {
|
|
328
192
|
limits: SolveEngineLimits;
|
|
329
|
-
|
|
330
|
-
/** Max distinct warm compute servers before the LRU evicts the oldest. Default 16. */
|
|
193
|
+
/** Max distinct warm compute servers before the LRU evicts the oldest. */
|
|
331
194
|
maxWarmComputeServers?: number;
|
|
332
195
|
/** Concise cache/timing logs when truthy; `'verbose'` also dumps full lib-level requests/responses. Default off. */
|
|
333
196
|
debug?: ClientCacheDebug;
|
|
197
|
+
/** Sink for the debug lines. Without it they go nowhere. */
|
|
334
198
|
onDebugLog?: (message: string) => void;
|
|
335
199
|
/** Fired when a caller joins an already-in-flight solve instead of running its own. */
|
|
336
200
|
onSolveCoalesced?: (key: string) => void;
|
|
337
201
|
}
|
|
338
202
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* obtained ahead of time from `engine.definitionRef()` (e.g. to read bytes for
|
|
342
|
-
* schema extraction before solving) is passed through as-is — detected by its
|
|
343
|
-
* `outcome` field, which a plain `DefinitionRef` never has.
|
|
203
|
+
* A `ByteCacheRef` obtained ahead of time from `engine.definitionRef()` (e.g. to
|
|
204
|
+
* read bytes for schema extraction before solving) is passed through as-is.
|
|
344
205
|
*/
|
|
345
|
-
type SolveEngineDefinitionSource = Uint8Array | string | DefinitionRef$1 | ByteCacheRef
|
|
346
|
-
versionId: string;
|
|
347
|
-
load: () => Promise<Uint8Array>;
|
|
348
|
-
};
|
|
206
|
+
type SolveEngineDefinitionSource = Uint8Array | string | DefinitionRef$1 | ByteCacheRef;
|
|
349
207
|
interface SolveEngineSolveArgs {
|
|
350
208
|
server: ResolvedServer;
|
|
351
209
|
definitionSource: SolveEngineDefinitionSource;
|
|
@@ -356,15 +214,23 @@ interface SolveEngineSolveArgs {
|
|
|
356
214
|
* Ignored for the other source forms.
|
|
357
215
|
*/
|
|
358
216
|
definitionKey?: string;
|
|
359
|
-
|
|
217
|
+
/**
|
|
218
|
+
* The definition's inputs, from the schema you stored, never from the request: `id`, `nickname`,
|
|
219
|
+
* `paramType` and the bounds decide what reaches the definition, so a body that supplies them
|
|
220
|
+
* can drop a limit or fill a slot your host reserved.
|
|
221
|
+
*/
|
|
222
|
+
inputs: SolveInput[];
|
|
360
223
|
values: Record<string, unknown>;
|
|
361
224
|
signal: AbortSignal;
|
|
362
225
|
acceptEncoding?: string;
|
|
363
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* Stamped as `X-Selva-Definition` when this solve builds the server's warm client. The header
|
|
228
|
+
* is fixed per client, so later solves on that server carry the first definition's guid.
|
|
229
|
+
*/
|
|
364
230
|
definitionGuid?: string;
|
|
365
231
|
loadStartMs?: number;
|
|
366
232
|
defLoadMs?: number;
|
|
367
|
-
prepMarks?: [
|
|
233
|
+
prepMarks?: PrepMark[];
|
|
368
234
|
/**
|
|
369
235
|
* Per-solve live-event callback. A coalesced waiter shares the first caller's
|
|
370
236
|
* compute call, so only that caller's target reaches the definition; the
|
|
@@ -372,11 +238,6 @@ interface SolveEngineSolveArgs {
|
|
|
372
238
|
*/
|
|
373
239
|
selvaEvents?: SelvaEventTarget;
|
|
374
240
|
}
|
|
375
|
-
interface FrameworkAgnosticResponse {
|
|
376
|
-
status: number;
|
|
377
|
-
headers: Record<string, string>;
|
|
378
|
-
body: string | Uint8Array;
|
|
379
|
-
}
|
|
380
241
|
interface SolveEngineStats {
|
|
381
242
|
client: SolveCacheStats;
|
|
382
243
|
definitionBytes: ByteCacheStats;
|
|
@@ -389,11 +250,17 @@ export declare class SolveEngine {
|
|
|
389
250
|
private readonly clientCache;
|
|
390
251
|
private readonly byteCache;
|
|
391
252
|
private readonly singleFlight;
|
|
253
|
+
private readonly clientGenerations;
|
|
254
|
+
private lastClientGeneration;
|
|
392
255
|
constructor(options: SolveEngineOptions);
|
|
393
256
|
getClient(server: ResolvedServer, opts?: {
|
|
394
257
|
definitionGuid?: string;
|
|
395
258
|
}): Promise<CachedClient>;
|
|
396
|
-
definitionRef(versionId: string, load: () => Promise<Uint8Array>): ByteCacheRef;
|
|
259
|
+
definitionRef(versionId: string, load: (signal: AbortSignal) => Promise<Uint8Array>): ByteCacheRef;
|
|
260
|
+
/**
|
|
261
|
+
* Drops the warm client for `id`; call it when the server's URL or key changes. Solves already
|
|
262
|
+
* running finish on the old connection details first, so a revoked key stays in use until then.
|
|
263
|
+
*/
|
|
397
264
|
evictServer(id: string): void;
|
|
398
265
|
clearSolveCaches(): void;
|
|
399
266
|
/**
|
|
@@ -402,15 +269,23 @@ export declare class SolveEngine {
|
|
|
402
269
|
*/
|
|
403
270
|
clearDefinitionCache(): void;
|
|
404
271
|
stats(): SolveEngineStats;
|
|
405
|
-
solve(args: SolveEngineSolveArgs): Promise<
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
272
|
+
solve(args: SolveEngineSolveArgs): Promise<SolveEngineOutcome>;
|
|
273
|
+
/**
|
|
274
|
+
* The response for an outcome; the mapping from outcome to status lives here. Throws
|
|
275
|
+
* `compute_error`'s error: what it means for the caller is the host's to decide.
|
|
276
|
+
*/
|
|
277
|
+
toWebResponse(outcome: SolveEngineOutcome): Response;
|
|
278
|
+
/**
|
|
279
|
+
* Part of the coalesce key: after an eviction the id stays and the client changes, and a new
|
|
280
|
+
* caller joining a draining flight would get an answer from the old URL or key.
|
|
281
|
+
*/
|
|
282
|
+
private clientGeneration;
|
|
413
283
|
private resolveDefinitionSource;
|
|
414
284
|
}
|
|
415
|
-
|
|
285
|
+
/**
|
|
286
|
+
* What `SolveEngine.solve` takes as `inputs`, from a schema the host stored. The bounds live on
|
|
287
|
+
* the number widgets in the layout, not on `schema.inputs`, so without them nothing clamps.
|
|
288
|
+
*/
|
|
289
|
+
export declare function solveInputsFromSchema(schema: UISchema): SolveInput[];
|
|
290
|
+
export type { ByteCacheRef, ByteCacheStats, ByteRefOutcome, CachedClient, DefinitionRef, ResolvedServer, SolveCacheStats, SolveDefinition, SolveEngineDefinitionSource, SolveEngineLimits, SolveEngineOptions, SolveEngineOutcome, SolveEngineSolveArgs, SolveEngineStats, SolveEnvelope, SolveInput, SolveLimits, SolvePhaseMetrics };
|
|
416
291
|
//# sourceMappingURL=server.d.ts.map
|