@orkestrel/scaffold 0.0.104 → 0.0.105
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/bin/main.js +3 -3
- package/dist/bin/main.js.map +1 -1
- package/dist/host/agents/orchestration.md +3 -3
- package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +72 -0
- package/dist/host/agents/skills/orkestrel-parallel/agents/openai.yaml +4 -0
- package/dist/host/agents/skills/orkestrel-parallel/references/harnesses.md +12 -0
- package/dist/host/claude/agents/orkestrel.md +7 -7
- package/dist/host/claude/agents/verifier.md +1 -1
- package/dist/host/claude/skills/orkestrel-parallel/SKILL.md +11 -0
- package/dist/host/codex/agents/verifier.toml +3 -1
- package/dist/host/guides/agent.md +90 -54
- package/dist/host/guides/form.md +8 -8
- package/dist/host/guides/ollama.md +275 -18
- package/dist/host/guides/study.md +589 -39
- package/dist/host/guides/table.md +14 -14
- package/dist/host/guides/test.md +94 -67
- package/dist/host/manifest.json +41 -13
- package/dist/host/tests/policy.test.ts +2 -2
- package/dist/host/tests/setupPolicy.ts +1 -1
- package/dist/src/core/index.cjs +4 -3
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.js +4 -3
- package/dist/src/core/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Bounded comparative execution with captured artifacts and separate grading.
|
|
4
4
|
|
|
5
|
-
The host-independent engine is exported from `@orkestrel/study`; custody and native workers are exported from `@orkestrel/study/server`.
|
|
5
|
+
The host-independent engine is exported from `@orkestrel/study`; custody and native workers are exported from `@orkestrel/study/server`. Study requires Node.js 22.18.0 or later. TypeScript consumers of the server entry must install `@types/node` because its declarations import `node:` modules. The core entry needs no Node.js types.
|
|
6
6
|
|
|
7
7
|
## Execution and evidence
|
|
8
8
|
|
|
@@ -10,15 +10,19 @@ Declare the question, purpose, arms, scenarios, repetition order, and rubric bef
|
|
|
10
10
|
|
|
11
11
|
The request meter reserves token and byte ceilings before an adapter dispatches work. Request, goal, trial, and series limits bound enclosing work. Missing actual usage remains unknown and consumes the admitted ceiling. Capacity, infrastructure, deadline, and interruption are operational outcomes; a product never awards its own task verdict. An error that carries a failure keeps that attribution; a study error without one reads as capacity for the `CAPACITY` code and as deadline for the `DEADLINE` code. A branded `BudgetError` from any module copy reads as capacity with a `budget` stop and retains its source readings. Every other rejection reads as infrastructure, including an unbranded budget lookalike.
|
|
12
12
|
|
|
13
|
-
A study error stamps an own `STUDY_ERROR_BRAND` descriptor whose value is the error itself. `isStudyError` requires that descriptor with an `Error` subclass, the
|
|
13
|
+
A study error stamps an own, non-enumerable, non-writable `STUDY_ERROR_BRAND` descriptor whose value is the error itself. `isStudyError` requires that descriptor with an `Error` subclass, a declared code, and valid optional failure attribution. Subclasses can replace the name. The guard validates the Error name, message, and optional stack. Failure stop readings retain their declared number type, including nonfinite values; serialized admission and the standalone stop guard require finite readings. Failure stops are checked structurally, including class instances and inherited fields; serialized admission retains its exact-record checks. The guard reads through the contract package's captured reflection inside its never-throw boundary, so a study error thrown by another package, ESM, CommonJS, or captured module copy keeps its code and attribution. The brand uses the global symbol registry: the brand recognizes the contract without proving its origin. An unbranded older copy, an inherited or borrowed brand, a transparent proxy, malformed failure attribution, and a property-only lookalike read as infrastructure.
|
|
14
|
+
|
|
15
|
+
The `ArtifactError` class stamps `ARTIFACT_ERROR_BRAND` under the global key `@orkestrel/study.ArtifactError`. Its guard recognizes subclasses and other installed or module copies through the identity stamp, a code from `ARTIFACT_ERROR_CODES`, and the declared Error members. A look-alike without the brand, a transparent proxy, a plain branded object, and malformed members return false.
|
|
16
|
+
|
|
17
|
+
Within one module format, the root and server entries share one `StudyError` class, so both `instanceof StudyError` and `isStudyError` recognize server errors. The ESM and CommonJS builds carry separate classes. Across module formats, recognize a server error with `isStudyError`; `instanceof StudyError` is false.
|
|
14
18
|
|
|
15
19
|
A product that exceeds its goal, trial, or series output allowance is omitted from custody with a capacity failure. Previously admitted products remain retained, and the remaining horizon is explicitly unexecuted. A genuine custody write or metadata-capacity failure still rejects execution and leaves the result unsealed.
|
|
16
20
|
|
|
17
21
|
Each observation and attempt records an explicit execution fact. An observation is executed when the engine dispatched its goal to the session, and unexecuted when it fills the horizon after a terminal failure; an unexecuted observation holds a failure and no product, usage, or duration. An attempt is executed when it entered trial execution without an inherited terminal series failure, including a failure before the driver opened, so the fact does not claim that the driver was opened. Executed goals form a prefix of the horizon, and an executed goal that fails ends it. Both facts are required booleans, never inferred from a product, usage, duration, or failure message, and custody refuses an attempt that omits one or contradicts them. A terminal attempt holds a failure whenever a goal failed or went unexecuted. Study carries no format counter; the artifact inventory records the exact implementation fingerprints, and the definition, rubric, and label versions are caller-authored metadata that identify supplied content.
|
|
18
22
|
|
|
19
|
-
A ticket reports `settled` from its own settlement, never from `signal.aborted`: a worker ticket whose signal aborted is unsettled locally because the parent owns that failure. After work
|
|
23
|
+
A ticket reports `settled` from its own settlement, never from `signal.aborted`: a worker ticket whose signal aborted is unsettled locally because the parent owns that failure. After work throws, call `failStudyTicket` with the caught value. It leaves a ticket that already settled or aborted untouched, so no request is accounted twice. Otherwise it fails the ticket once with the reading `readStudyFailure` gives the value; an optional role replaces any role that reading carries, and without one the carried role, then the ticket's admitted role, applies. A refusal thrown by the ticket's own settlement propagates. A consumer that must account known bytes when an operation throws, or finish an expected refusal, keeps that choice in its own code.
|
|
20
24
|
|
|
21
|
-
The driver receives a borrowed admission interface and an evidence sink. The concrete engine owns the meter's closing lifecycle. Native workers await parent admission and acknowledge request settlement; each trial runs in a fresh child. Trusted adapters can access native resources, so process supervision is not a
|
|
25
|
+
The driver receives a borrowed admission interface and an evidence sink. The concrete engine owns the meter's closing lifecycle. Native workers await parent admission and acknowledge request settlement; each trial runs in a fresh child. Trusted adapters can access native resources, so process supervision is not a sandbox for untrusted code.
|
|
22
26
|
|
|
23
27
|
Execution custody creates a result directory exclusively, appends evidence, retains terminal attempts, and seals only a complete scheduled population. A result without a seal remains interrupted. Offline reading verifies the seal's exact file inventory and digests. Changed execution bytes refuse custody verification.
|
|
24
28
|
|
|
@@ -75,7 +79,7 @@ const sealed = reading.status === 'sealed' && reading.seal.id === seal.id // tru
|
|
|
75
79
|
|
|
76
80
|
## Limits
|
|
77
81
|
|
|
78
|
-
Captured identities bind admitted files, module selections, and Node runtime settings.
|
|
82
|
+
Captured identities bind admitted files, module selections, and Node runtime settings. Recorded replay reproduces exact application HTTP bodies through the declared collaborator; it identifies neither the entire machine nor the external service, TLS records, or transfer framing. Neutral semantic identifiers omit treatment and model names, but input and product text can reveal design details. This guide's executable examples prove local admission and custody; they do not establish GPU capacity or model quality.
|
|
79
83
|
|
|
80
84
|
## Captured loading
|
|
81
85
|
|
|
@@ -83,9 +87,13 @@ Select canonical absolute package roots and built ESM entries under each package
|
|
|
83
87
|
|
|
84
88
|
Admit every package root reached by native dependency resolution, including installed copies alongside a selected local package. Distinct canonical roots may share a package name; each root and its captured bytes retain their own identity. Repeated roots refuse inspection, and imports into omitted roots refuse loading before evaluation.
|
|
85
89
|
|
|
86
|
-
Select a consumer-owned source directory separately when the adapter needs strip-only TypeScript. Its graph cannot overlap a built package graph. Source JSON assets
|
|
90
|
+
Select a consumer-owned source directory separately when the adapter needs strip-only TypeScript. Its graph cannot overlap a built package graph. Source JSON files cannot be executable imports. Explicit assets retain exact file bytes in custody without granting import eligibility. Fixture and rubric bytes retain separate execution identities. Native package exports and extension rules still govern resolution. The inventory records package manifests, captured files, explicit assets, selected entries, Node version, and runtime settings.
|
|
91
|
+
|
|
92
|
+
Select excluded built files to refuse every import edge that reaches them; exclusion leaves the inventory identity unchanged. Run loading in a disposable worker and terminate the worker afterwards. A process admits one loaded inventory. Trusted code can use native process APIs, evaluation, and external services; the loader does not replay those resources or sandbox untrusted code.
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
Call the `materialize` method with an absent absolute destination under an existing physical parent. Materialization preserves the admitted physical forest, including nested node_modules and duplicate package copies. It copies exact bytes and verifies source before and after copying and the entire destination before returning. Explicit assets join the existing aggregate capture limits. Different source or destination volumes, overlap, occupied destinations, links and redirected ancestors, aliases, unsafe names, duplicate keys, and stale source references refuse before copying through them. A refusal before copying writes nothing; an occupied destination stays unchanged. A refusal during copying, including source drift or a link added mid-copy, can leave an incomplete destination without closure.json.
|
|
95
|
+
|
|
96
|
+
The portable closure digest binds sorted member keys, byte digests, sizes, and relative package identities. It excludes source provenance and the destination path. The relocated loader identity retains its canonical paths and runtime settings separately. Path checks and reads do not provide an atomic filesystem snapshot, concurrent hardlink-race resistance, or crash recovery.
|
|
89
97
|
|
|
90
98
|
### Inspect selected bytes
|
|
91
99
|
|
|
@@ -115,20 +123,79 @@ Call `gradeStudyEvidence` from an adapter's grade method to traverse the declare
|
|
|
115
123
|
|
|
116
124
|
An Agent-backed consumer passes the admitted Agent namespace to the shared instrumentation, which imports Agent types only and constructs nothing from an installed Agent copy. Request measurements, the nominal Agent error, and daemon timing keep the types their owning Agent and Ollama packages export; Study declares no copy of them. The `StudyAgentObserver` class delegates every provider call unchanged and records one size reading before each dispatch. The gauge is explicit: without one, a reading carries no projection. The enforced option selects the usage policy separately from observation, so a passive reading refuses no return. The `StudyAgentJudge` class binds a real judge to a `StudyLatchInterface` owner, so a caught classification failure stays visible to the study.
|
|
117
125
|
|
|
118
|
-
The `StudyOllamaTransport` class admits
|
|
126
|
+
The `StudyOllamaTransport` class admits model requests through the goal's meter and metadata through an independent declared budget for calls, bytes, and duration. Metadata has no model-meter parent. Each response retains its byte and duration limits, actual usage precedes a policy refusal, and the first operational failure keeps its identity. Each model role declares its exact Ollama options, think allowance, strict truncate and shift fields, and length-finish policy. Maintenance attribution carries no generation policy. The transport refuses an undeclared role and keeps unreported usage unknown. The `prepare` method binds later requests to one goal until the `clear` or `close` method ends it, and refuses with the `FAULT` code while a goal is bound or a response is open. The `fetch` and `verify` methods refuse with the `FAULT` code when no goal is bound, and `verify` retains that refusal. A request admitted before `clear` keeps its goal, and each goal's checkpoint joins only that goal's first observed dispatch.
|
|
127
|
+
|
|
128
|
+
Recording requires version, procedure, and exchange sink together. Preflight and postflight verify version, tags, and show for each distinct pinned model. Ordered exact steps compare UTF-8 bytes and verify their declared SHA-256 receipt; capture steps require their declared positive safe byte length and forbid body or input members. Goal, role, route, policy, and order are checked before sending. A second request and verification during request admission refuse. The sink supplies each HTTP ordinal, which joins dispatch and wire evidence even without passive observation. An attempt retains request bytes before sending. A validated response retains native status, selected headers, exact bytes, and chunk lengths; a failure retains bounded partial bytes and cannot produce completion. Successful postflight appends completion after every declared step has finished. The worker owns the preceding declaration and any maintenance prefix.
|
|
129
|
+
|
|
130
|
+
The transport owns its configuration before validation and snapshots each outbound URL, settings, headers, and request correlation before awaiting admission. Later caller mutation cannot change the admitted request. Cancellation signals, the timing callback, and the optional fetch collaborator retain their live identity.
|
|
131
|
+
|
|
132
|
+
The `StudyOllamaTransportOptions` interface accepts an optional `fetch` collaborator with the `StudyOllamaFetchFunction` signature. Omit the option to keep native fetch. When supplied, the collaborator receives the validated Study role, URL, encoded body, headers, bounded signal, and `redirect: 'error'` at the send boundary. Agent and summary keep distinct roles even when they share a model. Construction refuses a present non-callable collaborator with the `CONFIG` code.
|
|
133
|
+
|
|
134
|
+
The collaborator returns a native `Response` and never settles a Study ticket. Study keeps request validation, admission, dispatch evidence, response status and byte bounds, terminal and timing checks, cancellation, accounting, and the failure latch. A synchronous throw, HTTP refusal, incomplete stream, abort, or cap follows the existing accounting path. Caller abort, the request deadline, and the `close` method settle a pending collaborator wait with the signal's reason even if the collaborator ignores cancellation; Study accounts the request once, retains the failure, and cancels a response that arrives later.
|
|
135
|
+
|
|
136
|
+
### Forward admitted requests by role
|
|
137
|
+
|
|
138
|
+
Supply the forwarding function inside the process that constructs the transport. This example retains the roles and delegates the supplied request settings to native fetch.
|
|
119
139
|
|
|
120
|
-
|
|
140
|
+
```ts
|
|
141
|
+
import type { StudyRole } from '@orkestrel/study'
|
|
142
|
+
import type { StudyOllamaTransportOptions } from '@orkestrel/study/server'
|
|
143
|
+
import { StudyOllamaTransport } from '@orkestrel/study/server'
|
|
144
|
+
|
|
145
|
+
declare const configured: StudyOllamaTransportOptions
|
|
146
|
+
const roles: StudyRole[] = []
|
|
147
|
+
const transport = new StudyOllamaTransport({
|
|
148
|
+
...configured,
|
|
149
|
+
fetch: (role, input, init) => {
|
|
150
|
+
roles.push(role)
|
|
151
|
+
return globalThis.fetch(input, init)
|
|
152
|
+
},
|
|
153
|
+
})
|
|
154
|
+
// Prepare the goal, then use transport.fetch or transport.verify as usual.
|
|
155
|
+
// Study reads each returned response before completing its accounting.
|
|
156
|
+
```
|
|
121
157
|
|
|
122
158
|
The server entry adds a trace, a gauged summary, and a scripted provider over the same admitted Agent capabilities. The consumer passes those capabilities as `runtime`; none of the three imports an Agent runtime. The consumer keeps its model prompts, treatment options, origin joins, and grade policy.
|
|
123
159
|
|
|
124
160
|
The `StudyAgentTrace` class numbers each measured request and retains its context, estimate, and capacity-refusal rows for the active goal. Ordinals, dispatch numbers, and role identities continue across a trial's goals. The `observe` option selects those measurement and refusal rows. When it is `false`, `append` still retains a domain row for an active goal, and a row outside a goal is dropped. The `start` method refuses with the `CONFIG` code while a goal is active and leaves that goal and its rows unchanged. The `flush` method appends the rows to a `StudySinkInterface` in order, keeps rows appended during the flush, and ends the goal and clears its rows, including when custody refuses a row. A `flush` with no active goal does nothing, and a `flush` while another is pending refuses with the `CONFIG` code and leaves the pending one untouched. The `origins` handler joins each measured message to its consumer origin.
|
|
125
161
|
|
|
126
|
-
The `StudyAgentSummary` class measures one canonical array, the folded messages followed by the instruction, and sends the very same array to the provider. Construction refuses with the `CONFIG` code unless `limit` is a positive safe integer
|
|
162
|
+
The `StudyAgentSummary` class measures one canonical array, the folded messages followed by the instruction, and sends the very same array to the provider. Construction refuses with the `CONFIG` code unless `limit` is a positive safe integer and the copied gauge passes `isStudyAgentGauge`: its `scale` is finite and greater than 0 and its `overhead` is finite and at least 0. The summary reads each gauge field once and keeps that validated copy. The guard admits extra members; a consumer that requires exact settings keys composes its own key check. A projection that reaches `limit` fails with the `CAPACITY` code before any request is sent. A summary outside an active goal, or with blank content after its evidence row, fails with the `FAULT` code.
|
|
127
163
|
|
|
128
164
|
The `StudyAgentScript` class serves declared inert responses through the Agent provider boundary. Its constructor takes an explicit encoded `bytes` bound and refuses a value that is not a nonnegative safe integer. The `prepare` method keeps an owned snapshot of a goal's responses, so later caller mutation cannot change a served call. The `prepare` method refuses with the `CONFIG` code while a goal is prepared, and the `clear` method ends the prepared goal. A stream refuses with the `CONFIG` code when no goal is prepared, and a stream already running when `clear` is called finishes under its own goal. The `isStudyAgentResponse` guard accepts a response with JSON calls and sets no limit on content, call count, or `consume`; the consumer composes its own workload bounds. A stream abandoned after admission accounts for an Agent budget cut without latching a failure. Other abandoned streams fail the admitted request with the run signal's reason, or a `FAULT` when the signal carries none.
|
|
129
165
|
|
|
130
166
|
The `readStudyAgentMessages` function projects provider messages onto the role, content, and call fields a workload reads. The `buildStudyAgentReadings` function projects a Ledger result's readings onto JSON. The `buildStudyOllamaModels` function pins the model, and the judge when the provider declares both its name and digest. The `buildStudyOllamaOptions` function projects a role policy onto provider options and adds `truncate` and `shift` as `false` only for a strict policy.
|
|
131
167
|
|
|
168
|
+
The `buildStudyAgentToolResult` function projects an executed Agent tool call into its `id`, `name`, owned JSON `arguments`, boolean `success`, and owned JSON `value` or string `error`. The `buildStudyAgentToolDenial` function projects a denied call into its `id` and `name`, with a `reason` only when it is a string. Both refuse a malformed call with the `FAULT` code. The result projection also refuses a missing boolean `success`, non-JSON arguments or value, and a malformed failure error. Tool accounting, expected refusals, and workload grading remain in the consumer.
|
|
169
|
+
|
|
170
|
+
Both projections use `readStudyAgentToolCall` to read each foreign call field once and validate the fresh envelope. The reader retains the arguments record by reference; the result projection owns its JSON copy.
|
|
171
|
+
|
|
172
|
+
### Read an Agent tool call
|
|
173
|
+
|
|
174
|
+
Read the envelope before projecting executed or denied evidence.
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { readStudyAgentToolCall } from '@orkestrel/study/server'
|
|
178
|
+
|
|
179
|
+
const call = readStudyAgentToolCall({ id: 'c1', name: 'write', arguments: { path: 'note.txt' } })
|
|
180
|
+
// { id: 'c1', name: 'write', arguments: { path: 'note.txt' } }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Inspect Agent tool evidence
|
|
184
|
+
|
|
185
|
+
Validate the gauge independently of settings keys, then retain the Agent's executed or denied call.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { isStudyAgentGauge } from '@orkestrel/study'
|
|
189
|
+
import { buildStudyAgentToolResult, buildStudyAgentToolDenial } from '@orkestrel/study/server'
|
|
190
|
+
|
|
191
|
+
const gauge = isStudyAgentGauge({ scale: 1, overhead: -0, label: 'summary' }) // true
|
|
192
|
+
const call = { id: 'c1', name: 'write', arguments: { path: 'note.txt' } }
|
|
193
|
+
const result = buildStudyAgentToolResult(call, { success: true, value: 'stored' })
|
|
194
|
+
// { id: 'c1', name: 'write', arguments: { path: 'note.txt' }, success: true, value: 'stored' }
|
|
195
|
+
const denial = buildStudyAgentToolDenial(call, 'refused')
|
|
196
|
+
// { id: 'c1', name: 'write', reason: 'refused' }
|
|
197
|
+
```
|
|
198
|
+
|
|
132
199
|
## Stop attribution
|
|
133
200
|
|
|
134
201
|
A `StudyFailure` record carries an optional reading under `stop`. The `StudyStop` record names the ceiling's `layer`, its `id`, its `max`, and the `consumed` tally including the refused charge. The `StudyLayer` union admits `scope`, `window`, `custody`, `meter`, `budget`, and `model`. A deadline has cause `deadline` and layer `scope`; its id names the duration allowance. An absent reading stays undefined in memory and projects to null through `studyStopToJSON`. The `isStudyStop` guard admits finite source readings, including negative and fractional values. Translation, IPC admission, and custody admission preserve those readings without clamping or relabelling them.
|
|
@@ -141,8 +208,30 @@ The Ollama transport appends a `stop` evidence row after its `wire` row when com
|
|
|
141
208
|
|
|
142
209
|
## Native command
|
|
143
210
|
|
|
211
|
+
Recording declares `record.bytes` on the profile. The manifest retains the same declaration, and the parent reserves that complete allowance separately for each trial before starting workers. The allowance covers every serialized sidecar byte, including base64 expansion, opening and terminal rows, and LF framing. It consumes series custody without consuming goal evidence or model quota. Recording profiles explicitly supply `settings.version`, `settings.metadata`, and `settings.procedure`; the worker validates those declarations before constructing the adapter driver.
|
|
212
|
+
|
|
213
|
+
The `StudyExchangeSink` class owns the trial's exclusive exchanges.jsonl descriptor. Its `next` property derives the next HTTP ordinal from accepted attempts, including a verified maintenance prefix. Callers await every append before sending or appending another row. The sink reserves failure-terminal space before an attempt and retains its first refusal. A failure omits response when no reply arrived or its bytes did not fit the sidecar allowance; the reason names which. Caught refusals prevent successful completion.
|
|
214
|
+
|
|
215
|
+
The store admits exchanges.jsonl only when recording is declared. Sealing requires each scheduled trial's complete sidecar, exact declaration order, paired identities, valid raw-body receipts, and one ordered dispatch and wire evidence row per HTTP ordinal. Duplicate, orphaned, reordered, failed, partial, missing, and unrequested histories refuse with the CUSTODY code. Every other unknown file remains refused. The `readStudyExchanges` function reverifies the complete seal and this evidence join before returning a replay history.
|
|
216
|
+
|
|
217
|
+
Replay execution requires `--replay <result> --prefix <JSON trial counts> --offline <true|false>`. Each positive prefix counts complete HTTP exchanges, including metadata and maintenance. The command verifies every selected trial before adapter validation or worker startup, and each worker rechecks its selected history. Replay requires the recording's exact Node runtime identity; another Node version, including a patch release, refuses before any worker starts. The executing profile supplies replay bounds. A supervisor fingerprint also pins changed execution bounds before dependent replay work.
|
|
218
|
+
|
|
219
|
+
The `StudyOllamaReplay` class validates the complete retained history before construction succeeds. Its projected procedure supplies recorded exact bodies inside the prefix, including bodies originally admitted as capture. A capture declaration without a sealed completed history cannot replay. A changed request inside the prefix refuses without forwarding. After the prefix, only an explicit live collaborator can send requests. Offline replay consumes the complete recorded population and constructs no daemon or native sender. Recorded maintenance consumes prefix positions without sending unload requests. Its `check` method refuses an incomplete prefix, unread responses, or a retained mismatch; its `close` method releases response readers.
|
|
220
|
+
|
|
221
|
+
The process driver accepts `StudyProcessDriverOptions`. Its optional `prepare` callback runs in the parent before session construction, preserves the reserved destination and allowance, and never crosses structured cloning or IPC. Offline replay refuses a preparation callback. A worker verifies any retained maintenance prefix before resuming the sidecar and projects those ordinals into its first goal's evidence.
|
|
222
|
+
|
|
223
|
+
A provider's optional `daemon` declaration makes live execution own a dedicated Ollama session at the provider URL. The declaration pins a canonical absolute executable, its SHA-256 digest, the exact version, explicit environment overrides, and distinct model names and inventory digests equal to the provider's model and judge pins. A shared model and judge pin requires one entry. A maintenance-only model, a relative executable, port 11434, a missing model digest, or conflicting environment-name casing refuses at profile load. The daemon owns the effective OLLAMA_HOST value. Without this declaration, the provider URL selects an external daemon.
|
|
224
|
+
|
|
225
|
+
The `StudyDaemonSession` class starts and verifies the daemon before trial execution. The manifest's `host.daemon` string retains the verified startup identity; startup version and inventory probes belong to no trial sidecar. Before each trial worker opens, preparation unloads the declared models in order. The `StudyDaemonTrial` class synchronizes each maintenance attempt before sending, retains status, allowed headers, original sender chunk lengths, and exact body bytes, and closes the prefix after daemon validation. A failed exchange retains a failure row. The worker joins the maintenance ordinals to the scenario's first declared goal. Every execution ending awaits daemon stop and process-tree join; an unconfirmed cleanup refuses completion. Offline replay constructs no daemon or preparation callback and sends no maintenance request.
|
|
226
|
+
|
|
144
227
|
Install the package in the consumer workspace, then run the study executable from that workspace. The selected declaration lives at studies/<name>/study.json, and its declared rubric path resolves inside that same directory. Its driver field selects a bundle at studies/<driver>/ containing scenarios/<scenario>.json, profiles/<profile>.json, and the adapter module index.ts. Several declarations can share one driver bundle while each keeps its own rubric. The profile defaults to local. JSON declarations use the public definition, scenario, profile, and rubric contracts.
|
|
145
228
|
|
|
229
|
+
The `readStudyDeclaration` function reads the selected definition, scenarios in declared order, and the rubric the definition names. It returns a `StudyDeclaration` record with the driver bundle and each scenario's bundle-relative fixture path and exact byte digest. It refuses a definition name or scenario identity that differs from its selection. The command uses this reader before reading the selected profile, so the refusal order is definition, scenarios, rubric, profile. The `StudyPreparation` record carries the driver's directory as `bundle`.
|
|
230
|
+
|
|
231
|
+
The `readStudyDeclarationBytes` function reads an already resolved, contained declaration path under the custody metadata allowance. A missing declaration, scenario, rubric, or profile, or a declaration path reached through a symbolic link or junction, refuses with the `CONFIG` code and exit code 64. The reader refuses a link before traversing it. Its diagnostic names the missing path or linked component relative to the consumer root with forward slashes. A missing result refuses with the `CUSTODY` code and exit code 1, naming the result selector as supplied. Result and grading storage retain their custody refusals.
|
|
232
|
+
|
|
233
|
+
The `matchesSystemError` predicate matches a system code only on an `Error` from this realm and returns false for a throwing code accessor. Structured cloning, such as a worker's `postMessage`, drops a Node error's system code, so the cloned error does not match.
|
|
234
|
+
|
|
146
235
|
A profile selects the Agent runtime entry in its required agent field and the package under study in its required subject field. The two fields can name the same entry or two entries, including entries from different installed copies of Agent. Each selected entry is captured and loaded once, and the driver receives both namespaces under the declared roles. The selected entries and their bytes are part of the execution identity.
|
|
147
236
|
|
|
148
237
|
The recap allowance of the room and the judge of the provider are optional. A study that produces no recap omits the recap allowance. A provider declares its judge model and its judge digest together or omits both; declaring only one refuses the profile. A declared recap and a declared judge keep their finite bounds.
|
|
@@ -151,23 +240,34 @@ A profile may carry an optional settings object of JSON values. The selected dri
|
|
|
151
240
|
|
|
152
241
|
The command supports explicit operations with operation-specific flags. Every flag takes a value and can appear once.
|
|
153
242
|
|
|
154
|
-
| Operation | Command
|
|
155
|
-
| ------------- |
|
|
156
|
-
| Validate | study check <study> [--profile <name>]
|
|
157
|
-
| Execute | study execute <study> [--profile <name>] [--out <path>] [--expected <sha256>] | Execution result identity and suggested independent grading arguments |
|
|
158
|
-
| Grade | study grade <result> --rubric <path>
|
|
159
|
-
| Import labels | study label <result> --grading <sha256> --labels <path>
|
|
160
|
-
| Report | study report <result> --grading <sha256>
|
|
243
|
+
| Operation | Command | Result |
|
|
244
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
|
|
245
|
+
| Validate | study check <study> [--profile <name>] [--closure <directory>] | Fingerprint and suggested pinned execution arguments |
|
|
246
|
+
| Execute | study execute <study> [--profile <name>] [--out <path>] [--expected <sha256>] [--closure <directory>] [--replay <result> --prefix <JSON trial counts> --offline <true\|false>] | Execution result identity and suggested independent grading arguments |
|
|
247
|
+
| Grade | study grade <result> --rubric <path> | Immutable grading identity and suggested report arguments |
|
|
248
|
+
| Import labels | study label <result> --grading <sha256> --labels <path> | Another immutable grading identity and suggested report arguments |
|
|
249
|
+
| Report | study report <result> --grading <sha256> | Whole-horizon results for the selected grading |
|
|
250
|
+
| Freeze | study freeze <study> --profile <name> --to <directory> | Verified closure publication and relocated check fingerprint |
|
|
161
251
|
|
|
162
252
|
Success writes a JSON document. The next field contains suggested argv and never executes it automatically. Execution returns a result identity independently of the original study selector. Result selection accepts an identity under tmp/studies, a contained root-relative path, or an absolute path. Relative output paths stay inside the consumer working directory; existing output directories refuse execution. A relative result, --out, --rubric or --labels path, and a declared rubric path, separates its names with forward slashes and names no . or .. segment; profile paths resolve against the consumer root. Without --out, execution writes its result under tmp/studies by its new identity; the suggested execution arguments a check returns carry no --out.
|
|
163
253
|
|
|
254
|
+
Freeze retains the selected declarations, exact scenario and profile bytes, the adapter graph, every admitted package member, and the trusted runtime entry. It validates the relocated selection in a fresh captured child, rechecks source and destination, and writes closure.json exclusively after those checks pass. The publication retains the original execution identity, the relocated identity, and the relocated fingerprint separately. A validation-time write leaves the destination available for inspection with no publication marker; retry with an absent destination.
|
|
255
|
+
|
|
256
|
+
Check and execute accept --closure <directory>. Each operation verifies the published member census and bytes, uses the relocated root, entry, profile, and adapter, and compares the fresh check to the retained relocated identity. Only the root closure.json marker sits outside the copied-member census. An added file, omitted member, or changed non-entry dependency or asset refuses validation. The suggested execution arguments retain the closure selection for the supervisor.
|
|
257
|
+
|
|
164
258
|
Check returns a fingerprint for the declared execution selection. Pass that fingerprint through --expected to pin execution. Both check and execute require a quality profile to declare a qualification path. Execute then requires that path to select a sealed capacity result with the same identity, bounds, schedule, and scenarios and no operational failures. Check validates the declaration offline without opening the capacity result. Capacity and mechanism studies execute without a qualification. Grade names an exact independent rubric path. Label and report require an exact grading identity; no operation guesses a grading version. Imported labels are caller-supplied bytes, not a labeler invoked by this command. A labeled grading binds the preceding grading's instrument, so equal labels over different gradings retain different identities.
|
|
165
259
|
|
|
260
|
+
The `validateStudyInputs` function enforces the quality qualification requirement after the existing population, profile, room, reference, and coverage checks. Direct callers receive the same `CONFIG` refusal as the command when a quality profile omits its qualification. Capacity and mechanism inputs require no qualification.
|
|
261
|
+
|
|
262
|
+
A labeled grading's instrument combines the executable entry's byte hash with the inventory digest for its owning Study package. The inventory binds the exact bytes of `package.json` and every `.js`, `.mjs`, `.cjs`, and `.json` file under `dist`, including the server and core entries, with the selected entry, canonical paths, package identity, file sizes, Node version, runtime arguments, `NODE_OPTIONS`, platform, and architecture. Declaration and source-map files are excluded from module capture unless explicitly selected as custody-only assets. Changing an admitted manifest, module, or explicit asset changes its inventory digest. Label identities are host-sensitive, as grading identities are.
|
|
263
|
+
|
|
166
264
|
Help succeeds on stdout when --help appears anywhere. Empty arguments and invalid public grammar report on stderr with exit code 64. Operational diagnostics carry a study:CODE prefix and the refused token or path when applicable. Other exits are 0 for success, 124 for deadline, 130 for interruption, and 1 for operational failure. Private child routes require the native IPC boundary.
|
|
167
265
|
|
|
266
|
+
The `study --version` command prints the installed Study package's version and a newline without reading consumer declarations or starting child work. The `readStudyVersion` function reads that package's manifest at run time, independently of the consumer's manifest. Additional version arguments refuse with exit code 64; `--help` still takes precedence. A missing or empty runtime version refuses with the `CONFIG` code.
|
|
267
|
+
|
|
168
268
|
An adapter error response preserves the `CONFIG` code and translates other returned codes to `FAULT`.
|
|
169
269
|
|
|
170
|
-
Check, grade, label, and report have a fixed 60-second allowance. Execution checks first, then uses the declared series duration with a 15-second cleanup allowance. The command supervises process trees; consumer adapters remain trusted code.
|
|
270
|
+
Check, freeze, grade, label, and report have a fixed 60-second allowance. Execution checks first with the selected closure, then forwards the complete closure and replay selections unchanged and uses the declared series duration with a 15-second cleanup allowance. The command supervises process trees; consumer adapters remain trusted code.
|
|
171
271
|
|
|
172
272
|
## Guide parity
|
|
173
273
|
|
|
@@ -187,6 +287,8 @@ The following declarations describe this concept.
|
|
|
187
287
|
| Name | Kind | Summary |
|
|
188
288
|
| ---------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
189
289
|
| `ARTIFACT_BYTES` | const | Bounds all captured input bytes to 128 MiB. |
|
|
290
|
+
| `ARTIFACT_ERROR_BRAND` | const | Marks artifact errors across module formats and installations. |
|
|
291
|
+
| `ARTIFACT_ERROR_CODES` | const | Lists the artifact refusal codes. |
|
|
190
292
|
| `ARTIFACT_DEPTH` | const | Bounds directory nesting below each selected root. |
|
|
191
293
|
| `ARTIFACT_FILES` | const | Bounds admitted files before another capture is allocated. |
|
|
192
294
|
| `ARTIFACT_FILE_BYTES` | const | Bounds one captured input file to 16 MiB. |
|
|
@@ -315,6 +417,7 @@ The following declarations describe this concept.
|
|
|
315
417
|
| `StudyMeterOptions` | interface | Supplies the request allowance and all enclosing admission scopes. |
|
|
316
418
|
| `StudyObservation` | interface | Holds the retained outcome of a scheduled goal. |
|
|
317
419
|
| `StudyOllamaActivity` | interface | Holds one active goal's accounting and attribution. |
|
|
420
|
+
| `StudyOllamaFetchFunction` | type | Sends one validated, admitted request under its Study role and returns the native response. |
|
|
318
421
|
| `StudyOllamaModel` | interface | Pins one served model identity the inventory verifies. |
|
|
319
422
|
| `StudyOllamaOptions` | type | Holds the Ollama provider options one role's declared policy determines. |
|
|
320
423
|
| `StudyOllamaPolicy` | interface | Declares one model role's exact wire policy. |
|
|
@@ -384,9 +487,13 @@ The following declarations describe this concept.
|
|
|
384
487
|
| `StudyWorker` | class | Executes one verified trial behind parent-authorized admission and custody. |
|
|
385
488
|
| `buildStudyAgentDispatch` | function | Builds the evidence join of a wire request to its canonical dispatch. |
|
|
386
489
|
| `buildStudyAgentParts` | function | Projects a request's structural components onto plain JSON without storing a total. |
|
|
490
|
+
| `readStudyAgentToolCall` | function | Reads an Agent tool call into a validated envelope from one read of each foreign field. |
|
|
491
|
+
| `buildStudyAgentToolResult` | function | Builds the JSON evidence form of an Agent tool call and its executed result. |
|
|
492
|
+
| `buildStudyAgentToolDenial` | function | Builds the JSON evidence form of an Agent tool call the Agent denied before dispatch. |
|
|
387
493
|
| `buildStudyAgentReadings` | function | Builds the JSON evidence form of a Ledger result's logical classifier readings. |
|
|
388
494
|
| `buildStudyAgentRevision` | function | Builds a request revision by hashing its canonical rendering exactly as rendered. |
|
|
389
495
|
| `buildStudyOllamaModels` | function | Declares the pinned serving identities the Ollama transport verifies, keyed by the label their inventory evidence carries. |
|
|
496
|
+
| `buildStudyOllamaBytes` | function | Encodes exact application bytes with their decoded size and SHA-256 identity. |
|
|
390
497
|
| `buildStudyOllamaOptions` | function | Builds the provider options one role's declared wire policy determines. |
|
|
391
498
|
| `buildStudyOllamaRaw` | function | Builds a reading of the raw prompt text an encoded request body carries, as sent. |
|
|
392
499
|
| `buildStudyOllamaSnapshot` | function | Builds an owned snapshot of one outbound request before anything is awaited. |
|
|
@@ -414,13 +521,14 @@ The following declarations describe this concept.
|
|
|
414
521
|
| `decodeStudyJSON` | function | Decodes strict UTF-8 custody bytes and parses their JSON text. |
|
|
415
522
|
| `drainStudyChild` | function | Releases inherited output handles a bounded time after native exit. |
|
|
416
523
|
| `encodeStudyJSON` | function | Encodes deterministic JSON bytes without synthesizing execution metadata. |
|
|
417
|
-
| `failStudyTicket` | function | Records an error
|
|
524
|
+
| `failStudyTicket` | function | Records an error thrown by admitted work as the failure of its ticket. |
|
|
418
525
|
| `failureToStudyError` | function | Converts an operational reading to its throwable boundary. |
|
|
419
526
|
| `gradeStudyEvidence` | function | Grades every declared trial and criterion pair through the consumer's predicate. |
|
|
420
527
|
| `hashStudyBytes` | function | Computes the lowercase SHA-256 identity of exact bytes or UTF-8 text. |
|
|
421
528
|
| `isArtifactError` | function | Narrows a caught value to an artifact refusal. |
|
|
422
529
|
| `isStudyAdapter` | function | Checks whether a factory returned the complete consumer adapter contract. |
|
|
423
530
|
| `isStudyAgentResponse` | function | Checks whether a scripted response has JSON calls and workload controls. |
|
|
531
|
+
| `isStudyAgentGauge` | function | Checks whether a value is a gauge with a finite positive scale and a finite nonnegative overhead. |
|
|
424
532
|
| `isStudyAgentRuntime` | function | Checks whether a namespace exposes the Agent capabilities the instrumentation invokes. |
|
|
425
533
|
| `isStudyBounds` | function | Checks whether nested scopes admit no larger allowance than their parent. |
|
|
426
534
|
| `isStudyCause` | const | Checks whether a value names an operational ending. |
|
|
@@ -437,7 +545,7 @@ The following declarations describe this concept.
|
|
|
437
545
|
| `isStudyCustodyTrial` | function | Checks whether a scheduled trial has exact valid identity fields. |
|
|
438
546
|
| `isStudyDefinition` | function | Checks whether a study freezes a complete arm order for every repetition. |
|
|
439
547
|
| `isStudyDigest` | function | Checks whether a byte identity is a lowercase SHA-256 digest. |
|
|
440
|
-
| `isStudyError` | function | Narrows a caught value to
|
|
548
|
+
| `isStudyError` | function | Narrows a caught value to a branded study error with valid failure attribution. |
|
|
441
549
|
| `isStudyErrorCode` | function | Checks whether a value names a supported study error code. |
|
|
442
550
|
| `isStudyEvidence` | function | Checks append-only public evidence. |
|
|
443
551
|
| `isStudyFrame` | function | Checks the complete transport envelope before domain handling. |
|
|
@@ -501,6 +609,12 @@ The following declarations describe this concept.
|
|
|
501
609
|
| `validateStudyOllamaCompletion` | function | Checks terminal policy after the actual wire cost has been retained. |
|
|
502
610
|
| `validateStudyOllamaInventory` | function | Verifies that each pinned name resolves to one inventory entry with its pinned digest. |
|
|
503
611
|
| `validateStudyOllamaRoles` | function | Validates declared role policies against the pinned inventory before any dispatch. |
|
|
612
|
+
| `validateStudyOllamaRecording` | function | Validates independent metadata bounds and the complete optional recording group. |
|
|
613
|
+
| `validateStudyOllamaStep` | function | Admits one model request against its next exact or capture declaration. |
|
|
614
|
+
| `isStudyOllamaMetadata` | function | Checks whether a value declares independent positive metadata allowances. |
|
|
615
|
+
| `isStudyOllamaModel` | function | Checks whether a value pins a served model name and SHA-256 digest. |
|
|
616
|
+
| `isStudyOllamaPolicy` | function | Checks whether a value declares a complete finite model-generation policy. |
|
|
617
|
+
| `isStudyOllamaStep` | function | Checks whether a value declares exclusive exact or capture admission with a valid receipt. |
|
|
504
618
|
| `validateStudyRuntime` | function | Refuses a profile that omits the actual host runtime's declared dependency bytes. |
|
|
505
619
|
| `valueToWire` | function | Projects optional domain fields into the JSON wire representation. |
|
|
506
620
|
| `writeStudyBytes` | function | Writes an exclusive regular record and synchronizes it before reporting success. |
|
|
@@ -516,20 +630,135 @@ The following declarations describe this concept.
|
|
|
516
630
|
| `parseStudyReading` | function | Parses a foreign reading into a number a stop can retain. |
|
|
517
631
|
| `computeStudyAdmittedStop` | function | Computes the stop of a request whose actual usage crossed the ceiling it was admitted under. |
|
|
518
632
|
| `computeStudyOutputStop` | function | Computes the stop of a product the output allowances cannot hold. |
|
|
633
|
+
| `StudyDeclaration` | interface | Holds a parsed study declaration with its driver bundle, scenarios, scenario fixtures, and rubric. |
|
|
634
|
+
| `readStudyDeclaration` | function | Reads a study declaration, its driver's scenarios, and its rubric as the command resolves them. |
|
|
635
|
+
| `readStudyDeclarationBytes` | function | Reads one declaration file and refuses a missing or linked path with its root-relative path. |
|
|
636
|
+
| `readStudyVersion` | function | Reads the version of the study package that owns an executable entry. |
|
|
637
|
+
| `matchesSystemError` | function | Reports whether a caught value is a Node error carrying the given system code. |
|
|
638
|
+
| `StudyDaemon` | interface | Pins an executable and the model population an execution owns until cleanup. |
|
|
639
|
+
| `StudyDaemonModel` | interface | Pins one model the declared daemon verifies and unloads before each trial. |
|
|
640
|
+
| `StudyRecord` | interface | Bounds the serialized exchange sidecar retained for each scheduled trial. |
|
|
641
|
+
| `ArtifactErrorCode` | type | Names the refused boundary of a captured or materialized artifact graph. |
|
|
642
|
+
| `ArtifactMember` | interface | Maps one admitted physical file to its exact bytes inside a materialized forest. |
|
|
643
|
+
| `ArtifactClosure` | interface | Binds a verified physical forest to its relocated selections and complete membership. |
|
|
644
|
+
| `ArtifactLoaderInterface` | interface | Captures, verifies, loads, and materializes one admitted physical artifact graph. |
|
|
645
|
+
| `computeArtifactClosureDigest` | function | Computes a destination-independent digest of members and relative package identities. |
|
|
646
|
+
| `isArtifactClosure` | function | Checks a bounded materialization record before any path is used. |
|
|
647
|
+
| `isArtifactKey` | function | Checks whether a key names portable, non-credential members within a closure. |
|
|
648
|
+
| `isArtifactLoaderOptions` | function | Checks the bounded loader selections retained in a publication. |
|
|
649
|
+
| `isArtifactMember` | function | Checks the exact file identity and provenance of a closure member. |
|
|
650
|
+
| `isStudyClosure` | function | Checks a closure publication before using its command inputs. |
|
|
651
|
+
| `matchesArtifactCredential` | function | Checks whether a portable segment identifies credentials. |
|
|
652
|
+
| `readArtifactPhysical` | function | Checks every existing physical ancestor before using a canonical absolute path. |
|
|
653
|
+
| `readStudyClosure` | function | Reads and independently verifies an exclusively published closure. |
|
|
654
|
+
| `relocateArtifactPath` | function | Relocates an original path through a closure's retained physical forest. |
|
|
655
|
+
| `resolveArtifactBase` | function | Finds the common physical parent that preserves every selected path's relative resolution. |
|
|
656
|
+
| `resolveArtifactMember` | function | Resolves a portable member key without traversing outside its destination. |
|
|
657
|
+
| `resolveStudyClosurePath` | function | Resolves a profile path through a retained physical relocation when selected. |
|
|
658
|
+
| `verifyArtifactClosure` | function | Verifies complete copied membership, path safety, exact bytes, and portable identity. |
|
|
659
|
+
| `StudyOllamaMetadata` | interface | Bounds metadata calls, encoded bytes, and elapsed milliseconds outside model quotas. |
|
|
660
|
+
| `StudyOllamaStage` | type | Names the ordered verification, model work, and daemon maintenance stages. |
|
|
661
|
+
| `StudyOllamaStepIdentity` | interface | Declares an ordered model request's goal, responsibility, route, and wire policy. |
|
|
662
|
+
| `StudyOllamaExactStep` | interface | Declares an exact UTF-8 request body and its SHA-256 input receipt. |
|
|
663
|
+
| `StudyOllamaCaptureStep` | interface | Declares a captured request's positive safe byte length without predicting its content. |
|
|
664
|
+
| `StudyOllamaStep` | type | Separates exact request admission from length-declared capture admission. |
|
|
665
|
+
| `StudyOllamaReplaySelection` | interface | Selects a sealed recording and an explicit replay prefix for every scheduled trial. |
|
|
666
|
+
| `StudyOllamaReplayOptions` | interface | Configures exact recorded replies and optional live continuation after a declared prefix. |
|
|
667
|
+
| `StudyOllamaReplayInterface` | interface | Answers an exact recorded prefix through the role-aware transport collaborator. |
|
|
668
|
+
| `StudyExchangeDestination` | interface | Holds the parent-reserved destination of one trial's exchange sidecar. |
|
|
669
|
+
| `StudyExchangeBytes` | interface | Retains an application HTTP body's exact bytes independently of text decoding. |
|
|
670
|
+
| `StudyExchangeIdentity` | interface | Binds one HTTP exchange to its trial-local position and declared execution stage. |
|
|
671
|
+
| `StudyExchangeDeclaration` | interface | Declares the complete trial procedure before any exchange attempt is appended. |
|
|
672
|
+
| `StudyExchangeAttempt` | interface | Retains admitted request bytes durably before the corresponding send begins. |
|
|
673
|
+
| `StudyExchangeReply` | interface | Retains response status, headers, and original application-body chunk lengths. |
|
|
674
|
+
| `StudyExchangeResponse` | interface | Retains a fully consumed response only after status and terminal validation succeed. |
|
|
675
|
+
| `StudyExchangeFailure` | interface | Retains an attempted exchange's failure and any bounded response bytes already observed. |
|
|
676
|
+
| `StudyExchangeCompletion` | interface | Closes a sidecar after the declared procedure and postflight have fully completed. |
|
|
677
|
+
| `StudyExchangeRow` | type | Names every admitted row of the bounded per-trial exchange sidecar. |
|
|
678
|
+
| `StudyRecordedExchange` | interface | Holds a strictly verified successful request and response pair. |
|
|
679
|
+
| `StudyExchangeHistory` | interface | Binds complete ordered exchanges to a verified sealed sidecar and its declaration. |
|
|
680
|
+
| `StudyExchangeSinkInterface` | interface | Owns serialized exchange appends under a reserved trial byte allowance. |
|
|
681
|
+
| `StudyExchangeSinkOptions` | interface | Supplies an exclusive sidecar descriptor and its parent-reserved byte allowance. |
|
|
682
|
+
| `StudyFreezeRequest` | interface | Requests exclusive materialization and captured validation before publishing closure.json. |
|
|
683
|
+
| `StudyClosure` | interface | Publishes a validated closure with relocated command inputs and execution provenance. |
|
|
684
|
+
| `StudyTrialPreparationFunction` | type | Prepares one trial's external resources before its worker starts. |
|
|
685
|
+
| `StudyProcessDriverOptions` | interface | Supplies parent-only trial preparation separately from serializable worker options. |
|
|
686
|
+
| `StudyExchangeSink` | class | Retains ordered exchange rows under a parent-reserved serialized byte allowance. |
|
|
687
|
+
| `StudyOllamaReplay` | class | Answers declared HTTP prefixes from complete ordered recorded application bytes. |
|
|
688
|
+
| `isStudyRecord` | function | Checks whether a recording declaration bounds every serialized sidecar byte. |
|
|
689
|
+
| `isStudyExchangeBytes` | function | Checks whether encoded body bytes have their exact canonical base64 and SHA-256 identity. |
|
|
690
|
+
| `isStudyExchangeIdentity` | function | Checks whether an exchange carries an admissible ordered HTTP identity. |
|
|
691
|
+
| `isStudyExchangeReply` | function | Checks whether a retained reply describes bounded successful application bytes and chunks. |
|
|
692
|
+
| `isStudyExchangeDeclaration` | function | Checks whether the opening row declares a finite ordered procedure and serving identities. |
|
|
693
|
+
| `isStudyExchangeRow` | function | Checks whether a sidecar row has exactly its declared fields and verified byte identities. |
|
|
694
|
+
| `isStudyExchangeHistory` | function | Checks whether a history has verified row shapes before its complete relational validation. |
|
|
695
|
+
| `buildStudyExchangeSequence` | function | Projects the declaration onto its complete ordered HTTP identity population. |
|
|
696
|
+
| `projectStudyExchangeIdentity` | function | Projects only the repeated identity fields of a retained HTTP exchange. |
|
|
697
|
+
| `validateStudyExchangeRequest` | function | Validates the exact declaration order and request bytes of an admitted exchange. |
|
|
698
|
+
| `validateStudyExchangeRows` | function | Validates a serialized journal prefix or its complete successful population. |
|
|
699
|
+
| `readStudyExchangeRows` | function | Reads strict complete LF-framed exchange rows with verified bodies and declaration joins. |
|
|
700
|
+
| `validateStudyExchangeHistory` | function | Validates complete history envelopes again before a replay may perform dependent work. |
|
|
701
|
+
| `validateStudyExchangeEvidence` | function | Joins recorded exchanges to exactly one dispatch and wire evidence identity per ordinal. |
|
|
702
|
+
| `readStudyTrialExchanges` | function | Reads and joins a complete trial sidecar before or after sealing. |
|
|
703
|
+
| `readStudyExchanges` | function | Reads a sealed trial's exact complete exchange history after reverifying its entire result. |
|
|
704
|
+
| `isStudyExchangeDestination` | function | Checks whether a worker destination has an absolute sidecar path and finite reservation. |
|
|
705
|
+
| `isStudyReplaySelection` | function | Checks whether replay explicitly selects a sealed directory and per-trial prefix counts. |
|
|
706
|
+
| `readStudyRecordingDeclaration` | function | Reads the executing profile's explicit recording declarations before a worker starts. |
|
|
707
|
+
| `readStudyPreparedDestination` | function | Validates parent preparation output without permitting a destination or allowance substitution. |
|
|
708
|
+
| `readStudyReplayHistory` | function | Rechecks the sealed source and this trial's prefix under the executing profile declaration. |
|
|
709
|
+
|
|
710
|
+
| API | Kind | Summary |
|
|
711
|
+
| --------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
|
712
|
+
| `StudyDaemonSession` | class | Owns the declared daemon and its serial trial preparation through permanent cleanup. |
|
|
713
|
+
| `StudyDaemonTrial` | class | Records one trial's daemon maintenance before handing its verified prefix to a worker. |
|
|
714
|
+
| `StudyDaemonSessionOptions` | interface | Supplies the resolved provider, trial population, workspace, and execution cancellation. |
|
|
715
|
+
| `StudyDaemonTrialOptions` | interface | Supplies one reserved sidecar and its complete maintenance declaration. |
|
|
716
|
+
| `isStudyDaemon` | function | Checks whether an owned daemon declaration pins an absolute executable and distinct models. |
|
|
519
717
|
|
|
520
718
|
## Methods
|
|
521
719
|
|
|
720
|
+
#### `StudyDaemonSession`
|
|
721
|
+
|
|
722
|
+
The execution host composes these methods.
|
|
723
|
+
|
|
724
|
+
| Method | Summary |
|
|
725
|
+
| --------- | ------------------------------------------------------------------ |
|
|
726
|
+
| `start` | Starts the daemon and returns its verified execution provenance. |
|
|
727
|
+
| `prepare` | Unloads the declared population before opening one trial worker. |
|
|
728
|
+
| `stop` | Stops and joins the owned tree and refuses an unconfirmed cleanup. |
|
|
729
|
+
|
|
730
|
+
#### `StudyDaemonTrial`
|
|
731
|
+
|
|
732
|
+
The preparation sender composes these methods.
|
|
733
|
+
|
|
734
|
+
| Method | Summary |
|
|
735
|
+
| --------- | -------------------------------------------------------------------------------------- |
|
|
736
|
+
| `execute` | Unloads declared models, drains the journal, and returns its exact retained identity. |
|
|
737
|
+
| `fetch` | Retains each request before sending and preserves the sender's native response chunks. |
|
|
738
|
+
|
|
522
739
|
The following tables name the callable members.
|
|
523
740
|
|
|
524
741
|
#### `ArtifactLoader`
|
|
525
742
|
|
|
526
743
|
The declaration exposes these methods.
|
|
527
744
|
|
|
528
|
-
| Method
|
|
529
|
-
|
|
|
530
|
-
| `inspect`
|
|
531
|
-
| `load`
|
|
532
|
-
| `
|
|
745
|
+
| Method | Summary |
|
|
746
|
+
| ------------- | -------------------------------------------------------------------------- |
|
|
747
|
+
| `inspect` | Reads and identifies admitted files without evaluating selected modules. |
|
|
748
|
+
| `load` | Imports one selected entry through synchronous captured-byte hooks. |
|
|
749
|
+
| `materialize` | Copies the inspected physical forest into an exclusive absent destination. |
|
|
750
|
+
| `verify` | Refuses byte and population drift since inspection. |
|
|
751
|
+
|
|
752
|
+
#### `ArtifactLoaderInterface`
|
|
753
|
+
|
|
754
|
+
The declaration exposes these methods.
|
|
755
|
+
|
|
756
|
+
| Method | Summary |
|
|
757
|
+
| ------------- | -------------------------------------------------------------------------- |
|
|
758
|
+
| `inspect` | Captures the complete admitted population without evaluating modules. |
|
|
759
|
+
| `verify` | Refuses changed bytes or membership after inspection. |
|
|
760
|
+
| `load` | Loads an admitted entry through captured-byte hooks in a fresh process. |
|
|
761
|
+
| `materialize` | Copies the inspected physical forest into an exclusive absent destination. |
|
|
533
762
|
|
|
534
763
|
#### `Resolution`
|
|
535
764
|
|
|
@@ -835,23 +1064,61 @@ The declaration exposes these methods.
|
|
|
835
1064
|
|
|
836
1065
|
The declaration exposes these methods.
|
|
837
1066
|
|
|
838
|
-
| Method
|
|
839
|
-
|
|
|
840
|
-
| `create`
|
|
841
|
-
| `
|
|
842
|
-
| `
|
|
843
|
-
| `
|
|
1067
|
+
| Method | Summary |
|
|
1068
|
+
| ----------- | --------------------------------------------------------------------------------- |
|
|
1069
|
+
| `create` | Exclusively creates the result directory and initial manifest bytes. |
|
|
1070
|
+
| `exchanges` | Reserves a trial's entire exchange allowance before any worker starts. |
|
|
1071
|
+
| `finish` | Closes evidence admission, drains admitted appends, and writes a terminal record. |
|
|
1072
|
+
| `seal` | Seals exact execution inventory after every scheduled trial has terminated. |
|
|
1073
|
+
| `start` | Exclusively creates the evidence sink for an exact scheduled trial. |
|
|
1074
|
+
|
|
1075
|
+
#### `StudyExchangeSink`
|
|
1076
|
+
|
|
1077
|
+
The declaration exposes these methods.
|
|
1078
|
+
|
|
1079
|
+
| Method | Summary |
|
|
1080
|
+
| -------- | ---------------------------------------------------------------------------------------- |
|
|
1081
|
+
| `append` | Appends one owned row after validating order and reserving its complete serialized size. |
|
|
1082
|
+
| `close` | Closes admission, drains accepted writes and synchronizes the owned descriptor. |
|
|
1083
|
+
|
|
1084
|
+
#### `StudyExchangeSinkInterface`
|
|
1085
|
+
|
|
1086
|
+
The declaration exposes these methods.
|
|
1087
|
+
|
|
1088
|
+
| Method | Summary |
|
|
1089
|
+
| -------- | ----------------------------------------------------------------------------------- |
|
|
1090
|
+
| `append` | Appends one validated row after reserving its complete serialized size. |
|
|
1091
|
+
| `close` | Closes admission and synchronizes all admitted writes without inventing completion. |
|
|
1092
|
+
|
|
1093
|
+
#### `StudyOllamaReplay`
|
|
1094
|
+
|
|
1095
|
+
The declaration exposes these methods.
|
|
1096
|
+
|
|
1097
|
+
| Method | Summary |
|
|
1098
|
+
| ------- | -------------------------------------------------------------------------- |
|
|
1099
|
+
| `check` | Refuses a mismatch, an unread response or an incompletely consumed prefix. |
|
|
1100
|
+
| `close` | Closes admission and cancels retained replay responses. |
|
|
1101
|
+
|
|
1102
|
+
#### `StudyOllamaReplayInterface`
|
|
1103
|
+
|
|
1104
|
+
The declaration exposes these methods.
|
|
1105
|
+
|
|
1106
|
+
| Method | Summary |
|
|
1107
|
+
| ------- | ----------------------------------------------------------------------------------- |
|
|
1108
|
+
| `check` | Refuses a latched mismatch, an unread response, or an incompletely consumed prefix. |
|
|
1109
|
+
| `close` | Closes admission and cancels or drains owned response readers. |
|
|
844
1110
|
|
|
845
1111
|
#### `StudyResultStoreInterface`
|
|
846
1112
|
|
|
847
1113
|
The declaration exposes these methods.
|
|
848
1114
|
|
|
849
|
-
| Method
|
|
850
|
-
|
|
|
851
|
-
| `create`
|
|
852
|
-
| `
|
|
853
|
-
| `
|
|
854
|
-
| `
|
|
1115
|
+
| Method | Summary |
|
|
1116
|
+
| ----------- | ------------------------------------------------------------------------------------------ |
|
|
1117
|
+
| `create` | Exclusively creates the result directory and initial manifest bytes. |
|
|
1118
|
+
| `exchanges` | Reserves a declared trial's sidecar allowance and returns its exclusive write destination. |
|
|
1119
|
+
| `finish` | Retains the terminal record for one scheduled trial. |
|
|
1120
|
+
| `seal` | Seals a complete terminal population with its exact execution-byte inventory. |
|
|
1121
|
+
| `start` | Opens append-only evidence custody for one scheduled trial. |
|
|
855
1122
|
|
|
856
1123
|
#### `StudyScope`
|
|
857
1124
|
|
|
@@ -917,7 +1184,7 @@ The declaration exposes these methods.
|
|
|
917
1184
|
| --------- | -------------------------------------------------------------- |
|
|
918
1185
|
| `execute` | Executes one validation or grading operation in a fresh child. |
|
|
919
1186
|
|
|
920
|
-
Task and trial children settle on their close event, which waits for inherited output handles. After a child's native exit those handles are destroyed
|
|
1187
|
+
Task and trial children settle on their close event, which waits for inherited output handles. After a child's native exit those handles are destroyed after `STUDY_DRAIN_DURATION` (1 second) elapses, so a descendant that holds the output cannot leave the parent unsettled. A task still rejects for a missing complete response, and a session still rejects its start and fulfills its close. This releases only the parent's read handles: a descendant that survives an exited root is outside discoverable-tree cleanup and is neither found nor terminated. Linux behavior is unverified.
|
|
921
1188
|
|
|
922
1189
|
#### `StudyTaskWorker`
|
|
923
1190
|
|
|
@@ -1293,7 +1560,7 @@ import { isStudyAdapter } from '@orkestrel/study/server'
|
|
|
1293
1560
|
isStudyAdapter({}) // false
|
|
1294
1561
|
```
|
|
1295
1562
|
|
|
1296
|
-
### Fail an
|
|
1563
|
+
### Fail an admitted request
|
|
1297
1564
|
|
|
1298
1565
|
Use the exported declaration with its documented arguments.
|
|
1299
1566
|
|
|
@@ -1716,6 +1983,34 @@ await trace.flush(sink) // appends one `note` row for the goal `count`
|
|
|
1716
1983
|
trace.goal // undefined
|
|
1717
1984
|
```
|
|
1718
1985
|
|
|
1986
|
+
### Validate recorded admission
|
|
1987
|
+
|
|
1988
|
+
Validate the owned recording group, then check its next model request before dispatch.
|
|
1989
|
+
|
|
1990
|
+
```ts
|
|
1991
|
+
import type { StudyOllamaTransportOptions, StudyOllamaRequest } from '@orkestrel/study/server'
|
|
1992
|
+
import {
|
|
1993
|
+
buildStudyOllamaBytes,
|
|
1994
|
+
isStudyOllamaMetadata,
|
|
1995
|
+
isStudyOllamaModel,
|
|
1996
|
+
isStudyOllamaPolicy,
|
|
1997
|
+
isStudyOllamaStep,
|
|
1998
|
+
validateStudyOllamaRecording,
|
|
1999
|
+
validateStudyOllamaStep,
|
|
2000
|
+
} from '@orkestrel/study/server'
|
|
2001
|
+
|
|
2002
|
+
declare const configured: StudyOllamaTransportOptions
|
|
2003
|
+
declare const request: StudyOllamaRequest
|
|
2004
|
+
declare const body: string
|
|
2005
|
+
validateStudyOllamaRecording(configured)
|
|
2006
|
+
isStudyOllamaMetadata(configured.metadata)
|
|
2007
|
+
isStudyOllamaModel(configured.models.model)
|
|
2008
|
+
isStudyOllamaPolicy(configured.roles.agent)
|
|
2009
|
+
isStudyOllamaStep(configured.procedure?.[0])
|
|
2010
|
+
validateStudyOllamaStep(configured.procedure?.[0], 'write', request, body)
|
|
2011
|
+
buildStudyOllamaBytes(new TextEncoder().encode(body))
|
|
2012
|
+
```
|
|
2013
|
+
|
|
1719
2014
|
### Own transport inputs
|
|
1720
2015
|
|
|
1721
2016
|
Copy declared configuration and mutable request headers before asynchronous admission.
|
|
@@ -1806,6 +2101,53 @@ import { computeStudyOutputStop } from '@orkestrel/study'
|
|
|
1806
2101
|
computeStudyOutputStop(2048, 1024, []) // { layer: 'scope', id: 'Goal bytes', max: 1024, consumed: 2048 }
|
|
1807
2102
|
```
|
|
1808
2103
|
|
|
2104
|
+
### Read a study declaration
|
|
2105
|
+
|
|
2106
|
+
Read the selected declaration and its driver fixtures before selecting a profile.
|
|
2107
|
+
|
|
2108
|
+
```ts
|
|
2109
|
+
import type { StudyDeclaration } from '@orkestrel/study/server'
|
|
2110
|
+
import { readStudyDeclaration } from '@orkestrel/study/server'
|
|
2111
|
+
|
|
2112
|
+
declare const root: string
|
|
2113
|
+
const declaration: StudyDeclaration = await readStudyDeclaration(root, 'assessment')
|
|
2114
|
+
```
|
|
2115
|
+
|
|
2116
|
+
### Read declaration bytes
|
|
2117
|
+
|
|
2118
|
+
Pass an already resolved and contained declaration path.
|
|
2119
|
+
|
|
2120
|
+
```ts
|
|
2121
|
+
import { readStudyDeclarationBytes } from '@orkestrel/study/server'
|
|
2122
|
+
|
|
2123
|
+
declare const root: string
|
|
2124
|
+
declare const path: string
|
|
2125
|
+
await readStudyDeclarationBytes(root, path)
|
|
2126
|
+
```
|
|
2127
|
+
|
|
2128
|
+
### Read the installed version
|
|
2129
|
+
|
|
2130
|
+
Pass the installed executable entry to read its owning package's manifest.
|
|
2131
|
+
|
|
2132
|
+
```ts
|
|
2133
|
+
import { readStudyVersion } from '@orkestrel/study/server'
|
|
2134
|
+
|
|
2135
|
+
declare const entry: string
|
|
2136
|
+
readStudyVersion(entry)
|
|
2137
|
+
```
|
|
2138
|
+
|
|
2139
|
+
### Match a system error
|
|
2140
|
+
|
|
2141
|
+
Match a caught Error without accepting an unbranded record.
|
|
2142
|
+
|
|
2143
|
+
```ts
|
|
2144
|
+
import { matchesSystemError } from '@orkestrel/study/server'
|
|
2145
|
+
|
|
2146
|
+
const error = Object.assign(new Error('Missing declaration'), { code: 'ENOENT' })
|
|
2147
|
+
matchesSystemError(error, 'ENOENT') // true
|
|
2148
|
+
matchesSystemError({ code: 'ENOENT' }, 'ENOENT') // false
|
|
2149
|
+
```
|
|
2150
|
+
|
|
1809
2151
|
### Helper calls
|
|
1810
2152
|
|
|
1811
2153
|
Supply the argument tuple from each helper's signature.
|
|
@@ -1964,6 +2306,58 @@ declare const validateStudyRuntimeArguments: Parameters<typeof validateStudyRunt
|
|
|
1964
2306
|
validateStudyRuntime(...validateStudyRuntimeArguments)
|
|
1965
2307
|
```
|
|
1966
2308
|
|
|
2309
|
+
### Call closure helpers
|
|
2310
|
+
|
|
2311
|
+
Supply the declared selections, captured records, and physical paths.
|
|
2312
|
+
|
|
2313
|
+
```ts
|
|
2314
|
+
import {
|
|
2315
|
+
computeArtifactClosureDigest,
|
|
2316
|
+
isArtifactClosure,
|
|
2317
|
+
isArtifactKey,
|
|
2318
|
+
isArtifactLoaderOptions,
|
|
2319
|
+
isArtifactMember,
|
|
2320
|
+
isStudyClosure,
|
|
2321
|
+
matchesArtifactCredential,
|
|
2322
|
+
readArtifactPhysical,
|
|
2323
|
+
readStudyClosure,
|
|
2324
|
+
relocateArtifactPath,
|
|
2325
|
+
resolveArtifactBase,
|
|
2326
|
+
resolveArtifactMember,
|
|
2327
|
+
resolveStudyClosurePath,
|
|
2328
|
+
verifyArtifactClosure,
|
|
2329
|
+
} from '@orkestrel/study/server'
|
|
2330
|
+
|
|
2331
|
+
declare const digest: Parameters<typeof computeArtifactClosureDigest>
|
|
2332
|
+
computeArtifactClosureDigest(...digest)
|
|
2333
|
+
declare const closure: Parameters<typeof isArtifactClosure>
|
|
2334
|
+
isArtifactClosure(...closure)
|
|
2335
|
+
declare const key: Parameters<typeof isArtifactKey>
|
|
2336
|
+
isArtifactKey(...key)
|
|
2337
|
+
declare const options: Parameters<typeof isArtifactLoaderOptions>
|
|
2338
|
+
isArtifactLoaderOptions(...options)
|
|
2339
|
+
declare const member: Parameters<typeof isArtifactMember>
|
|
2340
|
+
isArtifactMember(...member)
|
|
2341
|
+
declare const publication: Parameters<typeof isStudyClosure>
|
|
2342
|
+
isStudyClosure(...publication)
|
|
2343
|
+
declare const credential: Parameters<typeof matchesArtifactCredential>
|
|
2344
|
+
matchesArtifactCredential(...credential)
|
|
2345
|
+
declare const physical: Parameters<typeof readArtifactPhysical>
|
|
2346
|
+
readArtifactPhysical(...physical)
|
|
2347
|
+
declare const reader: Parameters<typeof readStudyClosure>
|
|
2348
|
+
readStudyClosure(...reader)
|
|
2349
|
+
declare const relocation: Parameters<typeof relocateArtifactPath>
|
|
2350
|
+
relocateArtifactPath(...relocation)
|
|
2351
|
+
declare const base: Parameters<typeof resolveArtifactBase>
|
|
2352
|
+
resolveArtifactBase(...base)
|
|
2353
|
+
declare const target: Parameters<typeof resolveArtifactMember>
|
|
2354
|
+
resolveArtifactMember(...target)
|
|
2355
|
+
declare const selection: Parameters<typeof resolveStudyClosurePath>
|
|
2356
|
+
resolveStudyClosurePath(...selection)
|
|
2357
|
+
declare const verification: Parameters<typeof verifyArtifactClosure>
|
|
2358
|
+
verifyArtifactClosure(...verification)
|
|
2359
|
+
```
|
|
2360
|
+
|
|
1967
2361
|
### Call ArtifactLoader methods
|
|
1968
2362
|
|
|
1969
2363
|
Supply an instance of the declared contract.
|
|
@@ -1976,6 +2370,8 @@ declare const inspect: Parameters<ArtifactLoader['inspect']>
|
|
|
1976
2370
|
instance.inspect(...inspect)
|
|
1977
2371
|
declare const load: Parameters<ArtifactLoader['load']>
|
|
1978
2372
|
instance.load(...load)
|
|
2373
|
+
declare const materialize: Parameters<ArtifactLoader['materialize']>
|
|
2374
|
+
instance.materialize(...materialize)
|
|
1979
2375
|
declare const verify: Parameters<ArtifactLoader['verify']>
|
|
1980
2376
|
instance.verify(...verify)
|
|
1981
2377
|
```
|
|
@@ -2460,6 +2856,8 @@ Supply an instance of the declared contract.
|
|
|
2460
2856
|
import type { StudyResultStore } from '@orkestrel/study/server'
|
|
2461
2857
|
|
|
2462
2858
|
declare const instance: StudyResultStore
|
|
2859
|
+
declare const exchanges: Parameters<StudyResultStore['exchanges']>
|
|
2860
|
+
instance.exchanges(...exchanges)
|
|
2463
2861
|
declare const create: Parameters<StudyResultStore['create']>
|
|
2464
2862
|
instance.create(...create)
|
|
2465
2863
|
declare const finish: Parameters<StudyResultStore['finish']>
|
|
@@ -2478,6 +2876,8 @@ Supply an instance of the declared contract.
|
|
|
2478
2876
|
import type { StudyResultStoreInterface } from '@orkestrel/study/server'
|
|
2479
2877
|
|
|
2480
2878
|
declare const instance: StudyResultStoreInterface
|
|
2879
|
+
declare const exchanges: Parameters<StudyResultStoreInterface['exchanges']>
|
|
2880
|
+
instance.exchanges(...exchanges)
|
|
2481
2881
|
declare const create: Parameters<StudyResultStoreInterface['create']>
|
|
2482
2882
|
instance.create(...create)
|
|
2483
2883
|
declare const finish: Parameters<StudyResultStoreInterface['finish']>
|
|
@@ -2626,8 +3026,158 @@ declare const execute: Parameters<StudyWorker['execute']>
|
|
|
2626
3026
|
instance.execute(...execute)
|
|
2627
3027
|
```
|
|
2628
3028
|
|
|
3029
|
+
### Declare and compose daemon staging
|
|
3030
|
+
|
|
3031
|
+
The command owns staging for ordinary execution. A custom execution host can compose the same session and preparation contracts.
|
|
3032
|
+
|
|
3033
|
+
```ts
|
|
3034
|
+
import { isStudyDaemon } from '@orkestrel/study'
|
|
3035
|
+
import { StudyDaemonSession, StudyDaemonTrial } from '@orkestrel/study/server'
|
|
3036
|
+
import { createOllamaDaemon } from '@orkestrel/ollama/server'
|
|
3037
|
+
import type { StudyDaemonSessionOptions, StudyDaemonTrialOptions } from '@orkestrel/study/server'
|
|
3038
|
+
|
|
3039
|
+
isStudyDaemon({ executable: 'ollama' }) // false
|
|
3040
|
+
declare const options: StudyDaemonSessionOptions
|
|
3041
|
+
const session = new StudyDaemonSession(options)
|
|
3042
|
+
declare const prepare: Parameters<StudyDaemonSession['prepare']>
|
|
3043
|
+
try {
|
|
3044
|
+
await session.start()
|
|
3045
|
+
await session.prepare(...prepare)
|
|
3046
|
+
} finally {
|
|
3047
|
+
await session.stop()
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
declare const trialOptions: StudyDaemonTrialOptions
|
|
3051
|
+
const trial = new StudyDaemonTrial(trialOptions)
|
|
3052
|
+
declare const declaration: Parameters<typeof createOllamaDaemon>[0]
|
|
3053
|
+
const daemon = createOllamaDaemon({
|
|
3054
|
+
...declaration,
|
|
3055
|
+
fetch: (input, init) =>
|
|
3056
|
+
new URL(new Request(input, init).url).pathname === '/api/generate'
|
|
3057
|
+
? trial.fetch(input, init)
|
|
3058
|
+
: globalThis.fetch(input, init),
|
|
3059
|
+
})
|
|
3060
|
+
try {
|
|
3061
|
+
await daemon.start()
|
|
3062
|
+
await trial.execute(daemon)
|
|
3063
|
+
} finally {
|
|
3064
|
+
await daemon.destroy()
|
|
3065
|
+
}
|
|
3066
|
+
```
|
|
3067
|
+
|
|
2629
3068
|
## Tests
|
|
2630
3069
|
|
|
3070
|
+
The staging proofs drive the real command and worker over a Node protocol daemon on an ephemeral loopback port. The daemon records whether each unload's attempt was already readable on disk. The source suite proves repeated maintenance prefixes, exact ordinal joins, offline replay without a daemon or request, and startup, trial, unload, and cancellation cleanup while an unrelated sentinel survives. Setup proofs validate fixture declarations without starting a child.
|
|
3071
|
+
|
|
3072
|
+
### Call exchange and replay helpers
|
|
3073
|
+
|
|
3074
|
+
Supply validated declarations, retained bytes, or a selected sealed result as each contract requires.
|
|
3075
|
+
|
|
3076
|
+
```ts
|
|
3077
|
+
import { isStudyRecord } from '@orkestrel/study'
|
|
3078
|
+
import {
|
|
3079
|
+
buildStudyExchangeSequence,
|
|
3080
|
+
isStudyExchangeBytes,
|
|
3081
|
+
isStudyExchangeDeclaration,
|
|
3082
|
+
isStudyExchangeDestination,
|
|
3083
|
+
isStudyExchangeHistory,
|
|
3084
|
+
isStudyExchangeIdentity,
|
|
3085
|
+
isStudyExchangeReply,
|
|
3086
|
+
isStudyExchangeRow,
|
|
3087
|
+
isStudyReplaySelection,
|
|
3088
|
+
projectStudyExchangeIdentity,
|
|
3089
|
+
readStudyExchangeRows,
|
|
3090
|
+
readStudyExchanges,
|
|
3091
|
+
readStudyPreparedDestination,
|
|
3092
|
+
readStudyRecordingDeclaration,
|
|
3093
|
+
readStudyReplayHistory,
|
|
3094
|
+
readStudyTrialExchanges,
|
|
3095
|
+
validateStudyExchangeEvidence,
|
|
3096
|
+
validateStudyExchangeHistory,
|
|
3097
|
+
validateStudyExchangeRequest,
|
|
3098
|
+
validateStudyExchangeRows,
|
|
3099
|
+
} from '@orkestrel/study/server'
|
|
3100
|
+
|
|
3101
|
+
declare const isStudyRecordArguments: Parameters<typeof isStudyRecord>
|
|
3102
|
+
isStudyRecord(...isStudyRecordArguments)
|
|
3103
|
+
declare const buildStudyExchangeSequenceArguments: Parameters<typeof buildStudyExchangeSequence>
|
|
3104
|
+
buildStudyExchangeSequence(...buildStudyExchangeSequenceArguments)
|
|
3105
|
+
declare const isStudyExchangeBytesArguments: Parameters<typeof isStudyExchangeBytes>
|
|
3106
|
+
isStudyExchangeBytes(...isStudyExchangeBytesArguments)
|
|
3107
|
+
declare const isStudyExchangeDeclarationArguments: Parameters<typeof isStudyExchangeDeclaration>
|
|
3108
|
+
isStudyExchangeDeclaration(...isStudyExchangeDeclarationArguments)
|
|
3109
|
+
declare const isStudyExchangeDestinationArguments: Parameters<typeof isStudyExchangeDestination>
|
|
3110
|
+
isStudyExchangeDestination(...isStudyExchangeDestinationArguments)
|
|
3111
|
+
declare const isStudyExchangeHistoryArguments: Parameters<typeof isStudyExchangeHistory>
|
|
3112
|
+
isStudyExchangeHistory(...isStudyExchangeHistoryArguments)
|
|
3113
|
+
declare const isStudyExchangeIdentityArguments: Parameters<typeof isStudyExchangeIdentity>
|
|
3114
|
+
isStudyExchangeIdentity(...isStudyExchangeIdentityArguments)
|
|
3115
|
+
declare const isStudyExchangeReplyArguments: Parameters<typeof isStudyExchangeReply>
|
|
3116
|
+
isStudyExchangeReply(...isStudyExchangeReplyArguments)
|
|
3117
|
+
declare const isStudyExchangeRowArguments: Parameters<typeof isStudyExchangeRow>
|
|
3118
|
+
isStudyExchangeRow(...isStudyExchangeRowArguments)
|
|
3119
|
+
declare const isStudyReplaySelectionArguments: Parameters<typeof isStudyReplaySelection>
|
|
3120
|
+
isStudyReplaySelection(...isStudyReplaySelectionArguments)
|
|
3121
|
+
declare const projectStudyExchangeIdentityArguments: Parameters<typeof projectStudyExchangeIdentity>
|
|
3122
|
+
projectStudyExchangeIdentity(...projectStudyExchangeIdentityArguments)
|
|
3123
|
+
declare const readStudyExchangeRowsArguments: Parameters<typeof readStudyExchangeRows>
|
|
3124
|
+
readStudyExchangeRows(...readStudyExchangeRowsArguments)
|
|
3125
|
+
declare const readStudyExchangesArguments: Parameters<typeof readStudyExchanges>
|
|
3126
|
+
readStudyExchanges(...readStudyExchangesArguments)
|
|
3127
|
+
declare const readStudyPreparedDestinationArguments: Parameters<typeof readStudyPreparedDestination>
|
|
3128
|
+
readStudyPreparedDestination(...readStudyPreparedDestinationArguments)
|
|
3129
|
+
declare const readStudyRecordingDeclarationArguments: Parameters<
|
|
3130
|
+
typeof readStudyRecordingDeclaration
|
|
3131
|
+
>
|
|
3132
|
+
readStudyRecordingDeclaration(...readStudyRecordingDeclarationArguments)
|
|
3133
|
+
declare const readStudyReplayHistoryArguments: Parameters<typeof readStudyReplayHistory>
|
|
3134
|
+
readStudyReplayHistory(...readStudyReplayHistoryArguments)
|
|
3135
|
+
declare const readStudyTrialExchangesArguments: Parameters<typeof readStudyTrialExchanges>
|
|
3136
|
+
readStudyTrialExchanges(...readStudyTrialExchangesArguments)
|
|
3137
|
+
declare const validateStudyExchangeEvidenceArguments: Parameters<
|
|
3138
|
+
typeof validateStudyExchangeEvidence
|
|
3139
|
+
>
|
|
3140
|
+
validateStudyExchangeEvidence(...validateStudyExchangeEvidenceArguments)
|
|
3141
|
+
declare const validateStudyExchangeHistoryArguments: Parameters<typeof validateStudyExchangeHistory>
|
|
3142
|
+
validateStudyExchangeHistory(...validateStudyExchangeHistoryArguments)
|
|
3143
|
+
declare const validateStudyExchangeRequestArguments: Parameters<typeof validateStudyExchangeRequest>
|
|
3144
|
+
validateStudyExchangeRequest(...validateStudyExchangeRequestArguments)
|
|
3145
|
+
declare const validateStudyExchangeRowsArguments: Parameters<typeof validateStudyExchangeRows>
|
|
3146
|
+
validateStudyExchangeRows(...validateStudyExchangeRowsArguments)
|
|
3147
|
+
```
|
|
3148
|
+
|
|
3149
|
+
### Call exchange sink methods
|
|
3150
|
+
|
|
3151
|
+
Supply the worker-owned sink or its declared interface.
|
|
3152
|
+
|
|
3153
|
+
```ts
|
|
3154
|
+
import type { StudyExchangeSink, StudyExchangeSinkInterface } from '@orkestrel/study/server'
|
|
3155
|
+
|
|
3156
|
+
declare const sink: StudyExchangeSink
|
|
3157
|
+
declare const append: Parameters<StudyExchangeSink['append']>
|
|
3158
|
+
sink.append(...append)
|
|
3159
|
+
sink.close()
|
|
3160
|
+
declare const contract: StudyExchangeSinkInterface
|
|
3161
|
+
declare const row: Parameters<StudyExchangeSinkInterface['append']>
|
|
3162
|
+
contract.append(...row)
|
|
3163
|
+
contract.close()
|
|
3164
|
+
```
|
|
3165
|
+
|
|
3166
|
+
### Call replay methods
|
|
3167
|
+
|
|
3168
|
+
Supply a replay over a completely verified selected history.
|
|
3169
|
+
|
|
3170
|
+
```ts
|
|
3171
|
+
import type { StudyOllamaReplay, StudyOllamaReplayInterface } from '@orkestrel/study/server'
|
|
3172
|
+
|
|
3173
|
+
declare const replay: StudyOllamaReplay
|
|
3174
|
+
replay.check()
|
|
3175
|
+
replay.close()
|
|
3176
|
+
declare const contract: StudyOllamaReplayInterface
|
|
3177
|
+
contract.check()
|
|
3178
|
+
contract.close()
|
|
3179
|
+
```
|
|
3180
|
+
|
|
2631
3181
|
See the behavioral proofs in the following directories.
|
|
2632
3182
|
|
|
2633
3183
|
- [tests/src/core](../tests/src/core)
|