@orkestrel/scaffold 0.0.125 → 0.0.126

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.
@@ -7,15 +7,16 @@
7
7
  `parse(chunk)` appends `chunk` to an internal buffer and splits it on `\n`: every
8
8
  line before the last is `\n`-terminated, hence complete, and is parsed to a record,
9
9
  while the final segment is held back for the next call, so a line split across chunk
10
- boundaries is reassembled the moment its closing `\n` arrives. Each trimmed line is
10
+ boundaries is reassembled the moment its closing `\n` arrives. Each complete line is
11
+ trimmed with the `String.prototype.trim` method, then
11
12
  filtered — a blank or whitespace-only line (including one whose only content was a
12
13
  CRLF's trailing `\r`) is skipped — so only plain records come back, and a line the
13
14
  stream never terminates is never emitted even when the buffered text already happens
14
15
  to be valid JSON. By default the parser refuses a line it cannot return: `parse`
15
16
  throws an `NDJSONError` with code `'SYNTAX'` for a complete line that is not valid
16
17
  JSON and `'RECORD'` for a complete line that is not a plain record. The throwing call
17
- returns no record, discards the lines after the refused line in the same call too, and
18
- leaves the parser cleared, as `clear()` leaves it. With `strict: false` the parser
18
+ returns no records, discards every held line, including earlier complete lines and
19
+ the trailing partial line, and leaves the parser cleared, as `clear()` leaves it. With `strict: false` the parser
19
20
  skips such a line instead, for a caller that prefers the records it can read over a
20
21
  refusal. Blank lines are skipped, and lines are split and trimmed, the same way in both
21
22
  modes. A chunk that is not a string throws `'SYNTAX'` in both modes, because joining it
@@ -379,7 +379,7 @@ else console.log(result.refusals?.deletion?.missing)
379
379
 
380
380
  ### Ask a native decision model
381
381
 
382
- For a model that Ollama serves on the System One endpoint, use the agent package's factory. A request carries the choice, noul, and score together. Ollama 0.40.0 serves the `tev1:0.8b` model on this path and refuses Mica with HTTP 400; the package makes no capability check.
382
+ For a model that Ollama serves on the System One endpoint, use the agent package's factory. A request carries the choice, noul, and score together. The wire keys are zero-based positions in question entry order; the judge maps the positional answers back to the caller's ids. Ollama 0.40.0 serves the `tev1:0.8b` model on this path and refuses Mica with HTTP 400; the package makes no capability check.
383
383
 
384
384
  ```ts
385
385
  import { measureAnswer, createSystemOneJudge } from '@orkestrel/agent'
@@ -846,7 +846,7 @@ The daemon session proofs run in the `src:server` project against `tests/src/ser
846
846
  - [`tests/src/server/OllamaDaemon.test.ts`](../tests/src/server/OllamaDaemon.test.ts) drives the lifecycle over the fake daemon: a shared startup behind a delayed version reply, verification before any model request, retained maintenance including a refused unload, an overlapping unload, and a refused restart; ordered requests through an optional transport and its global control, exact maintenance bytes across re-chunked replies, a retained transport reference after caller mutation, and transport refusals at each send boundary, with startup joining the child before rejecting and unload leaving it running until `stop`; a mismatched inventory digest refused with `model`, metadata-only requests, and the owned child joined before startup rejects; a stale executable digest and an occupied port, each refused before a child exists; silence, an exit before listening, a bind failure, and an exit before answering, each refused with the owned child gone; executable bytes replaced through the declared path during use, which `stop` reports as `false` with a `digest` error; and a stop and an abort that each end the daemon and its runner while an unrelated process survives.
847
847
  - [`tests/src/server/helpers.test.ts`](../tests/src/server/helpers.test.ts) proves the environment merge by case-folded name, the listen announcement match, the version and model comparisons, the bounded metadata exchange and its refusals, the retained bytes and their digests, the exact unload body, and the terminal reply check, over an in-process peer that answers the metadata routes.
848
848
  - [`tests/src/server/validators.test.ts`](../tests/src/server/validators.test.ts), [`tests/src/server/factories.test.ts`](../tests/src/server/factories.test.ts), and [`tests/src/server/errors.test.ts`](../tests/src/server/errors.test.ts) prove the declaration refusals before any spawn, the undeclared keys by path, the guards in lockstep with the shape, an unstarted session's release without a spawn, and the error brand, its context copy, its cause, and the guard's refusals.
849
- - [`tests/service/OllamaDaemon.test.ts`](../tests/service/OllamaDaemon.test.ts) starts a dedicated real daemon, verifies its receipt, unloads every declared model with the exact request body, and requires a confirmed stop without generation. An explicit `OLLAMA_DAEMON_DECLARATION` JSON value wins. Otherwise the proof resolves `OLLAMA_DAEMON_EXECUTABLE` or the `ollama` executable on `PATH` to its canonical path, computes its SHA-256, reads the provisioned service at `OLLAMA_HOST` for its version and the selected model's `/api/tags` digest, and chooses an ephemeral loopback port apart from 11434 and the provisioned service port. It runs only in the `service` project.
849
+ - [`tests/service/OllamaDaemon.test.ts`](../tests/service/OllamaDaemon.test.ts) starts a dedicated real daemon, verifies its receipt, unloads every declared model with the exact request body, and requires a confirmed stop without generation. An explicit `OLLAMA_DAEMON_DECLARATION` JSON value wins. Otherwise the proof resolves `OLLAMA_DAEMON_EXECUTABLE` or the `ollama` executable on `PATH` to its canonical path, computes its SHA-256, reads the provisioned service at `OLLAMA_HOST` for its version and the selected model's `/api/tags` digest, and chooses an ephemeral loopback port apart from 11434 and the provisioned service port. The executable must be the build the provisioned service runs, because the proof compares their versions: when `OLLAMA_HOST` names a held runner, set `OLLAMA_DAEMON_EXECUTABLE` to that runner's executable, or the proof takes the `ollama` on `PATH` and refuses with `Executable version differs`. It runs only in the `service` project.
850
850
 
851
851
  The hermetic projects — `src:core`, `src:server`, `setup`, `guides`, `conformance`, `policy`, and `config` — run with no Ollama daemon and no network beyond loopback. The `src:server` project starts no Ollama executable: its lifecycle proofs spawn the fake daemon and bind loopback ports only. The `service` project requires a warm local Ollama and, for the page proof, a Chromium-family browser and a built `dist`, and for the daemon session proof an executable on `PATH`, an `OLLAMA_DAEMON_EXECUTABLE` path, or an explicit `OLLAMA_DAEMON_DECLARATION` value; `distribution` packs and installs the artifact. The import guard reads `distribution` with the hermetic projects, because it never reaches the daemon; it leaves out `probe` and `service` alone, the two projects that may.
852
852
 
@@ -713,9 +713,9 @@ allowed.
713
713
  An `AggregateResult` gathers its subjects' `faults`, `repairs`, and `defaulted`, each once by path, and
714
714
  each subject keeps its own. A result crosses a boundary as `projectProgramResult` or
715
715
  `projectAggregateResult`, which `programResultContract` and `aggregateResultContract` admit. A
716
- definition crosses on `createProgramDefinitionContract().is`, never `parse`. `is` reads a nested
717
- `shape` as any JSON value and the guard reads it as a shape, so `shape: 42` passes `is` and
718
- `isProgramDefinition` refuses it: a definition crossing a boundary goes through the guard as well.
716
+ definition crosses on `createProgramDefinitionContract().is`, never `parse`. The contract validates
717
+ a nested `shape` through `shapeShape`, so both its `is` method and the `isProgramDefinition` guard
718
+ refuse a malformed declaration such as `shape: 42`.
719
719
 
720
720
  ### Success
721
721
 
@@ -555,7 +555,7 @@ eligible and contributes evidence a later consumer may act on.
555
555
 
556
556
  ### Publishing definitions and results
557
557
 
558
- `createQualificationDefinitionContract()` publishes a definition, its `schema` for an LLM, a tool, or MCP. Cross a definition on `is`, never `parse`, and hold the result, because building it walks the recursive expressions of its logical passes. `is` reads a nested `shape` as any JSON value and the guard reads it as a shape, so `shape: 42` passes `is` and `isQualificationDefinition` refuses it: a definition crossing a boundary goes through the guard as well. A result crosses as `projectQualificationResult`, which `qualificationResultContract` admits, because a premise's `actual` holds whatever the subject held and a derivation's `value` may be `NaN`.
558
+ `createQualificationDefinitionContract()` publishes a definition, its `schema` for an LLM, a tool, or MCP. Cross a definition on `is`, never `parse`, and hold the result, because building it walks the recursive expressions of its logical passes. The contract validates a nested `shape` through `shapeShape`, so both its `is` method and the `isQualificationDefinition` guard refuse a malformed declaration such as `shape: 42`. A result crosses as `projectQualificationResult`, which `qualificationResultContract` admits, because a premise's `actual` holds whatever the subject held and a derivation's `value` may be `NaN`.
559
559
 
560
560
  ### Validation
561
561
 
@@ -697,8 +697,9 @@ answers a read and grant no verb write authority that it did not already have.
697
697
  `new --bin` creates the executable entry, its test, and its scoped Vite and TypeScript wrappers. The
698
698
  `new --app browser` command selects the journey axis, creates its birth-owned wrapper, defines
699
699
  `appJourney` in the root configuration, and excludes the browser integration suite from
700
- `app:browser`. Its manifest declares `test:journey` and invokes it after `npm run test:app` in
701
- `test`. It also declares `journey: capture journey` and `capture: capture frames` for explicit
700
+ `app:browser`. Its manifest declares `test:journey`. A `private: true` workspace invokes it after
701
+ `npm run test:app` in `test`; a publishing workspace runs application and journey suites on demand,
702
+ outside release gates and chains. It also declares `journey: capture journey` and `capture: capture frames` for explicit
702
703
  scoped selections. A selection without a browser application emits no journey axis. `--styles`, `--themes`,
703
704
  `--showcase`, and `--extend` select the structural facts and the extensions, and Surfaces and extensions
704
705
  states what each emits and what each refuses. Creation leaves `setup` empty, and the remaining
@@ -940,11 +941,17 @@ in command order. A configuration value containing an unresolved shell expansion
940
941
  When a `test:*` script whose text names `vitest` names a configuration that the plan does not emit
941
942
  and the target does not hold, the non-blocking `projects` question names the script and configuration
942
943
  path. Its remedy asks you to add the configuration, or remove the script that names it and its
943
- invocation from the `test` chain. When the plan emits `test:journey` and no chain from `test` reaches
944
+ invocation from the `test` chain. In a `private: true` workspace, when the plan emits `test:journey` and no chain from `test` reaches
944
945
  `npm run test:journey` through literal `npm run` calls, that question asks you to insert the invocation
945
- after `npm run test:app`. These advisories belong to `configs`
946
- and remain report-only during `repair`: the command preserves a `test` chain the package owns and
947
- an unplanned script. A configuration emitted by the plan or present in the target does not raise
946
+ after `npm run test:app`. A publishing workspace requires neither application nor journey suites
947
+ in its gate chains. When a chain from `test` or `prepublishOnly` reaches their script names, names
948
+ their Vitest projects, or runs their planned application or journey wrappers through literal
949
+ `vitest run --config` calls, the question asks you to remove those invocations and run the suites on demand.
950
+ For reached projects and wrappers, the question includes the caller and its command.
951
+ These advisories belong to `configs`. `repair` and `overwrite` replace a byte-exact former generated
952
+ publishing `test` chain with the planned chain. An authored chain, including one with an extra step,
953
+ stays report-only; the commands preserve that chain and any unplanned script.
954
+ A configuration emitted by the plan or present in the target does not raise
948
955
  the absent configuration advisory.
949
956
 
950
957
  `audit` still completes the comparison and reports one non-blocking `projects` question when its
@@ -984,11 +991,16 @@ Each occupied framework face adds `check:<axis>:vue` and `build:<axis>:vue`; the
984
991
  Selected showcase pages add `showcase`, `showcase:<framework>`, `build:showcase`, and `build:showcase:<framework>`; application journeys add `test:journey:<framework>`.
985
992
  Its `test:src:<face>` script accepts, as its generated predecessor, the command that ran the project
986
993
  without building the face first, and `build:src:styles` accepts the styles-only build as the
987
- predecessor of the chain that builds themes after it. The `test` chain joins the region only as a
988
- generated predecessor: when it runs fewer steps than the planned chain and every step it runs is a planned step in the planned
994
+ predecessor of the chain that builds themes after it. A publishing `test` chain joins the region when
995
+ it matches byte for byte the planned chain with the generated `test:app`, `test:journey`, and framework
996
+ journey invocations inserted after `test:src`, where that blueprint emitted them before.
997
+ `repair` and `overwrite` remove those helper invocations from that exact predecessor.
998
+ The `test` chain also joins the region as a generated predecessor when it runs fewer steps than
999
+ the planned chain and every step it runs is a planned step in the planned
989
1000
  order, `repair` and `overwrite` write the planned chain in its place. That write lands only when
990
1001
  every step the planned chain adds runs a script the manifest declares or the region writes. The
991
- `test:src` and `test:app` aggregates sit outside the region, so a chain whose planned form adds an
1002
+ `test:src` and `test:app` aggregates sit outside the region. Only a private workspace's planned
1003
+ chain invokes `test:app`. A chain whose planned form adds an
992
1004
  aggregate the manifest lacks stays with the package, and the `projects` question keeps its remedy.
993
1005
  `audit` reports this chain write only through the `projects` question, so a planned step that
994
1006
  registers no Vitest project, such as `npm run test:guides`, lands on the next `repair` without an
@@ -1008,7 +1020,8 @@ The browser application's journey axis adds `journey` and `capture`. Their gener
1008
1020
  `capture journey` and `capture frames`, have no predecessor forms in the accepted set. Missing
1009
1021
  commands append; generated values remain writable; `replaceManifestScripts` preserves customized
1010
1022
  values while repairing siblings independently, so a selected or wrapped `journey` command survives
1011
- repair. Neither scoped command replaces `test:journey` in the gate chain.
1023
+ repair. Neither scoped command replaces `test:journey` in a private workspace's gate chain.
1024
+ Publishing workspaces keep application and journey suites outside release gates and chains.
1012
1025
 
1013
1026
  The range region and the script region are not groups. `package.json` is birth-owned, so the
1014
1027
  `manifest` group creates it when a workspace is first materialized and never rewrites it afterwards,
@@ -1373,7 +1386,9 @@ viewport, and provides `variant`
1373
1386
  as its name, `variants` as the declared list, and `capture` as a boolean. The root configuration
1374
1387
  reads `process.env.CAPTURE === '1'` for that boolean. The generated `test:journey` script runs
1375
1388
  `vitest run --config configs/app/vite.journey.config.ts --no-cache --reporter=dot`, and the generated
1376
- `test` chain runs it after the application projects. With the journey axis off, the ordinary
1389
+ `test` chain runs it after the application projects only in a private workspace. In a publishing
1390
+ workspace, application and journey suites run on demand outside release gates and chains.
1391
+ With the journey axis off, the ordinary
1377
1392
  browser project retains its integration suite.
1378
1393
 
1379
1394
  The same axis adds `journey: capture journey` and `capture: capture frames`, using the executable
@@ -1611,7 +1626,9 @@ keeps your variant list and passes the Vite mode to the root
1611
1626
  through `mergeOverride`, so a wrapper changes only the fields it names and the project keeps its
1612
1627
  include and exclude replacement, viewport, commands, and plugin rules. The manifest runs `test:journey` for the base
1613
1628
  application and `test:journey:<framework>`, the same command with `--mode <framework>`, for each
1614
- app-side browser extension, after `npm run test:app` in `test`.
1629
+ app-side browser extension. A private workspace runs them after `npm run test:app` in `test`.
1630
+ A publishing workspace keeps those scripts available on demand and invokes neither application
1631
+ nor journey suites from its release gates and chains.
1615
1632
 
1616
1633
  Scaffold seeds one birth-owned arrival journey per application at
1617
1634
  `tests/app/<application>/integration.test.ts`. The base journey imports `app/browser/main.ts`, and
@@ -2153,7 +2170,7 @@ extras pass through unchanged except for the selected showcase pair. Extras foll
2153
2170
  `ORKESTREL_RANGE_PATTERN`; foreign peers follow `FLOOR_RANGE_PATTERN`.
2154
2171
 
2155
2172
  A browser application with `showcase: true`, including its Vue face, selects exact
2156
- `vite-plugin-singlefile: 2.3.3`, Vite `^8.3.6` from scaffold's manifest, and the npm override
2173
+ `vite-plugin-singlefile: 2.3.3`, Vite `^8.3.7` from scaffold's manifest, and the npm override
2157
2174
  `"vite-plugin-singlefile@2.3.3": { "micromatch": "npm:picomatch@2.3.2" }`. This policy applies
2158
2175
  after extras. Online resolution excludes this pair from ordinary foreign-major updates; other
2159
2176
  dependencies retain their usual resolution. Repair preserves each package's runtime or development
@@ -2226,11 +2243,11 @@ The dependency tables select these floors:
2226
2243
  | TypeScript | `^6.0.3` | A selected `src/vue` or `app/vue` face |
2227
2244
  | Vitest | `^5.1.0` | Every workspace |
2228
2245
  | `@vitest/browser-playwright` | `^5.1.0` | Browser tooling |
2229
- | `oxlint` | `^1.91.0` | Every workspace |
2230
- | `oxfmt` | `^0.76.0` | Every workspace |
2246
+ | `oxlint` | `^1.93.0` | Every workspace |
2247
+ | `oxfmt` | `^0.77.0` | Every workspace |
2231
2248
  | `@microsoft/api-extractor` | `^7.60.1` | Declaration builds; uses its bundled TypeScript 6.0.3 engine |
2232
2249
  | `playwright` | `^1.64.1` | Browser tooling |
2233
- | Vite | `^8.3.6` | Every workspace |
2250
+ | Vite | `^8.3.7` | Every workspace |
2234
2251
  | `@types/node` | `^24.19.2` | Every workspace; generated workspaces support Node `>=22.18.0` |
2235
2252
 
2236
2253
  Node 26 types admit APIs that the supported runtime lacks. Inside the declared major the verbs
@@ -2984,7 +3001,9 @@ publishes at least one `src` environment or sheet face. In a publishing workspac
2984
3001
  and `service` run from `prepublishOnly`, and `conformance` and `tree` stay in `test`. In a
2985
3002
  `private: true` workspace, `distribution` is absent, `service` runs from `test`, and there is no
2986
3003
  `prepublishOnly`. In both kinds of workspace, `studies` runs on demand through `npm run test:studies`
2987
- alone, outside every gate and chain. The `policy` project reports an exporting root setup module that lacks its sibling proof or an import from `tests/setup.test.ts`.
3004
+ alone, outside every gate and chain. Application and journey suites run on demand outside release
3005
+ gates and chains in a publishing workspace, and remain in `test` in a private workspace.
3006
+ The `policy` project reports an exporting root setup module that lacks its sibling proof or an import from `tests/setup.test.ts`.
2988
3007
  Separately, a filled, exporting `tests/setup*.ts` module that no `tests/setup*.test.ts`
2989
3008
  proof covers raises the non-blocking `setup` question in `audit`, which names the modules and the proof to add.
2990
3009
  For setup modules the workspace authors, the workspace supplies the behavior proof; the setup modules scaffold seeds arrive with their sibling proofs.
@@ -123,7 +123,11 @@ Call `gradeStudyEvidence` from an adapter's grade method to traverse the declare
123
123
 
124
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.
125
125
 
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.
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. The agent, summary, and judge roles declare their 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
+ The `triage` role sends System One requests to `/v1/systemone`. Its `StudySystemOnePolicy` declares the pinned `model` and a positive safe `tokens` ceiling for the complete request. The transport reserves that ceiling, bounds request and response bytes and elapsed time, validates the complete JSON response through Agent's System One envelope guard, and charges the request once. Reported input and output usage stay known; absent readings stay unknown. Triage invents no generation options, finish reason, or Ollama timing. `isStudySystemOnePolicy` validates this policy independently of generation policies. A consumer passes `transport.fetch('triage', input, init)` as its System One judge's fetch collaborator.
129
+
130
+ A provider declares `triage` and `digest.triage` together. Both metadata passes verify the pin through tags and show, configuration identity retains it, and a declared daemon includes it in its verified maintenance population. A transport fault on this leg fails the trial even if the consumer catches it; it cannot produce successful recording completion. A well-transported answer the consumer semantically refuses remains the consumer's decision to refer onward. Study chooses no model name or probability cutoff.
127
131
 
128
132
  Recording reads version and optional procedure from the exchange sink's opening declaration. The transport refuses metadata or model pins that differ from that row. 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 the admitted execution sequence; a declared procedure also requires every step to finish. The parent composes the declaration, and the worker retains that row after verifying any maintenance prefix.
129
133
 
@@ -167,7 +171,7 @@ The `StudyAgentSummary` class measures one canonical array, the folded messages
167
171
 
168
172
  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.
169
173
 
170
- The `readStudyAgentMessages` function projects provider messages onto the role, content, and call fields a workload reads. The `buildStudyAgentAttempts` function projects a Ledger result's attempts 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.
174
+ The `readStudyAgentMessages` function projects provider messages onto the role, content, and call fields a workload reads. The `buildStudyAgentAttempts` function projects a Ledger result's attempts onto JSON. The `buildStudyOllamaModels` function pins the model and each declared judge or triage name and digest. The `buildStudyOllamaOptions` function projects a generation role policy onto provider options and adds `truncate` and `shift` as `false` only for a strict policy.
171
175
 
172
176
  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.
173
177
 
@@ -228,7 +232,7 @@ The `StudyOllamaReplay` class validates the complete retained history before con
228
232
 
229
233
  A live prefix must end between the end of preflight and the end of execution, inclusive; postflight runs live. An offline prefix must cover the complete history. Replay bounds come from the executing declaration: calls equal record calls plus metadata calls, bytes equal record bytes, and duration equals the profile's trial duration. The transport also enforces its executing recording bounds.
230
234
 
231
- Keyed replay selects `--replay <result> --roles <JSON roles> --offline <true|false>`, and `--roles` is exclusive with `--prefix` and `--extend`. The roles are a JSON list of distinct members of `agent`, `judge`, `summary`, and `metadata`. The `StudyOllamaKeyedReplay` class serves a listed role's request whose path, method, and body bytes equal a recorded attempt of that role in any trial of the sealed source, the first recorded when a request repeats, so every arm of a screen reads one draw for one request. The key holds the role, so an earlier attempt of another role hides no later one. A served reply marks its `wire` evidence row, a budget's `cut` row of it, and its usage `replayed`. The progress reader and the report count it under `replayed` and leave it out of what the execution spent: `prompt`, `cached`, `completion`, and `total` in progress, and every cost in the report. A served request still charges its enclosing budgets. Under `--offline false` every other request sends live, and `metadata` cannot be listed, because served inventory verifies the recording, not the daemon. Under `--offline true` every other request refuses before send, no daemon starts, and a replay no adapter reached refuses at close. An adapter passes the replay through the transport's `replay` option, which is how the transport knows what it served. A changed sealed source refuses with the `CUSTODY` code before any request or result directory. Keyed replay compares no runtime and no declaration, because the request's own bytes are the key, and it requires the source to declare the executing provider's model pins. The manifest and each sidecar declaration retain the source's result, seal, identity, roles, and offline behavior under `keyed`, and the report names them. The executing profile must declare recording.
235
+ Keyed replay selects `--replay <result> --roles <JSON roles> --offline <true|false>`, and `--roles` is exclusive with `--prefix` and `--extend`. The roles are a JSON list of distinct members of `agent`, `judge`, `triage`, `summary`, and `metadata`. The `StudyOllamaKeyedReplay` class serves a listed role's request whose path, method, and body bytes equal a recorded attempt of that role in any trial of the sealed source, the first recorded when a request repeats, so every arm of a screen reads one draw for one request. The key holds the role, so an earlier attempt of another role hides no later one. A served reply marks its `wire` evidence row, a budget's `cut` row of it, and its usage `replayed`. The progress reader and the report count it under `replayed` and leave it out of what the execution spent: `prompt`, `cached`, `completion`, and `total` in progress, and every cost in the report. A served request still charges its enclosing budgets. Under `--offline false` every other request sends live, and `metadata` cannot be listed, because served inventory verifies the recording, not the daemon. Under `--offline true` every other request refuses before send, no daemon starts, and a replay no adapter reached refuses at close. An adapter passes the replay through the transport's `replay` option, which is how the transport knows what it served. A changed sealed source refuses with the `CUSTODY` code before any request or result directory. Keyed replay compares no runtime and no declaration, because the request's own bytes are the key, and it requires the source to declare the executing provider's model pins. The manifest and each sidecar declaration retain the source's result, seal, identity, roles, and offline behavior under `keyed`, and the report names them. The executing profile must declare recording.
232
236
 
233
237
  The `StudyIdentity` interface retains location-independent runtime and content digests alongside the captured loading identities. Runtime binds the Node version, execution arguments, NODE_OPTIONS, platform, and architecture. Content binds admitted package names and versions, package manifests, dist files, source code files, selected entries, source root, and Study executable bytes, with paths relative to the admitted roots' common base. Fixture JSON and closure assets stay outside content. Replay requires equal runtime and permits different content; loading still uses the captured inventories and their existing custody checks.
234
238
 
@@ -240,6 +244,8 @@ The parent derives a live replay prefix ending immediately before each ancestor'
240
244
 
241
245
  The descendant retains a complete flat sidecar: its extended declaration and ancestor prefix, live maintenance, replayed request and response bytes with recorded chunk lengths, live execution, live postflight, and completion. Its manifest links the immediate ancestor, so a later segment needs only that complete descendant. Replayed goals emit their evidence again and count against recording calls; their send-to-settlement time follows the executing recording duration allowance.
242
246
 
247
+ Triage participates in open recording and in exact or capture procedures using its System One route and policy. Strict sidecar reading checks the same identity, ordering, receipts, and completion as for other roles. Prefix and keyed replay retain original response bytes and chunk lengths. An offline replay sends nothing, and a keyed triage miss cannot borrow another role's recorded answer. Replayed triage usage still charges admission budgets, while progress and reports attribute it to `triage`, count it as replayed, and exclude it from live spending. Continuation requires open recording, replays the ancestor goals, and sends only the grown horizon's suffix live. Keyed replay remains exclusive with `--extend`, and every keyed execution still requires recording.
248
+
243
249
  Check binds the ancestor's seal into the execution fingerprint and carries the resolved extension selector in its next argv. The launcher forwards that selector to both check and execute. Execute compares the same fingerprint before daemon startup. A frozen closure retains its ancestor-free fingerprint, so the grown study can be frozen independently before checking its continuation. The `StudyContinuation` record holds the admitted replay selection and immediate ancestor.
244
250
 
245
251
  Selection executes one segment of the declared population, and check and execute accept the same three selectors. `--trial <name>` keeps the one scheduled trial of that id. `--goals <first>..<last>` projects every scenario a selected trial names to the goals from first to last inclusive, by goal id. `--seed <result>:<trial>:<goal>` opens the selected trial from the `checkpoint` evidence row that a sealed result retained for that source trial and goal; the value splits at its last two colons, so the result can hold a drive letter, and a relative result must stay inside the consumer working directory. The manifest's scenarios and schedule hold the projection, and its `selection` record names the trial, the range, and the seed's source result, seal, trial, goal, and row digest beside the unchanged full-scenario fixture digest. Execute reads the seed through the source's custody checks and hands the row value to the driver's `open` method. A missing, unsealed, or changed source, a source trial outside its schedule, and a goal without exactly one row refuse with the `CUSTODY` code; `--seed` without `--trial` on a schedule of more than one trial, a trial outside the schedule, and a range that names an undeclared goal or ends before it starts refuse with the `CONFIG` code. Every selection refusal precedes any request and any result directory. Check binds the selection into the execution fingerprint and carries the selectors into its next argv, with the seed's result as a resolved directory, while a frozen closure keeps its selection-free fingerprint. The launcher forwards the selectors to both check and execute. Under a goal range, grade projects the rubric to the manifest's goals and retains the projection under its own digest; report names the selection, lists the dropped criterion ids under `unselected`, and covers only the arms and repetitions that hold a scheduled trial. A selector beside `--extend` refuses with the `CONFIG` code, and `--replay` requires the selection its source recorded.
@@ -294,7 +300,7 @@ isStudyExchangeAncestor(reference)
294
300
 
295
301
  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.
296
302
 
297
- 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.
303
+ 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, judge, and triage pins. Shared pins require 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.
298
304
 
299
305
  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.
300
306
 
@@ -308,7 +314,7 @@ The `matchesSystemError` predicate matches a system code only on an `Error` from
308
314
 
309
315
  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.
310
316
 
311
- 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.
317
+ 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 each judge or triage model together with its matching digest or omits both; declaring only one refuses the profile. A declared recap and a declared judge keep their finite bounds.
312
318
 
313
319
  A profile may carry an optional settings object of JSON values. The selected driver owns its interpretation; Study only validates the object, keeps an independent frozen copy, and refuses arrays, primitives, non-JSON values, and cycles. Settings are part of the resolved profile bytes, so changing one value changes the profile identity and the execution fingerprint. A profile without settings keeps the identity it had before the field existed.
314
320
 
@@ -510,8 +516,8 @@ The following declarations describe this concept.
510
516
  | `StudyOllamaModel` | interface | `{ name, digest }` | Pins one served model identity the inventory verifies. |
511
517
  | `StudyOllamaOptions` | type | `Pick<OllamaOptions, 'model' \| 'think' \| 'options' \| 'truncate' \| 'shift'>` | Holds the Ollama provider options one role's declared policy determines. |
512
518
  | `StudyOllamaPolicy` | interface | `{ model, options, think, strict, length }` | Declares one model role's exact wire policy. |
513
- | `StudyOllamaRequest` | interface | `{ role, path, model, output, bytes, options, strict, length }` | Holds validated wire dispatch facts without retaining payload text. |
514
- | `StudyOllamaRole` | type | `Extract<StudyRole, 'agent' \| 'summary' \| 'judge'>` | Names the model roles an Ollama study transport dispatches under a declared policy. |
519
+ | `StudyOllamaRequest` | interface | `{ tokens?, role, path, model, output, bytes, options, strict, length }` | Holds validated wire dispatch facts without retaining payload text. |
520
+ | `StudyOllamaRole` | type | `Extract<StudyRole, 'agent' \| 'summary' \| 'judge' \| 'triage'>` | Names the model roles an Ollama study transport dispatches under a declared policy. |
515
521
  | `StudyOllamaSnapshot` | interface | `{ url, init, dispatch }` | Holds one outbound request's facts as owned at admission. |
516
522
  | `StudyOllamaTerminal` | interface | `{ prompt, completion, reason }` | Holds a validated terminal's finish reason and actual usage, unknown when unreported. |
517
523
  | `StudyOllamaTransport` | class | `new (options: StudyOllamaTransportOptions) => StudyLatchInterface` | Admits and accounts Ollama wire requests under declared policies and latches failure. |
@@ -537,7 +543,7 @@ The following declarations describe this concept.
537
543
  | `StudyProgressTarget` | interface | `{ trial, goal, evidence }` | Holds one listed goal of a scheduled trial with exactly that goal's complete evidence rows. |
538
544
  | `StudyProgressTrial` | interface | `{ trial, horizon, ended, failure, goals }` | Holds the listed goals of one scheduled trial and whether its terminal record exists. |
539
545
  | `StudyProgressUsage` | interface | `{ role, calls, replayed, prompt, cached, completion, total, length }` | Holds one role's request readings over the `wire` evidence rows of one goal. |
540
- | `StudyProvider` | interface | `{ entry, url, model, judge, digest, daemon? }` | Holds caller-selected provider artifacts and model identities. |
546
+ | `StudyProvider` | interface | `{ entry, url, model, judge, triage?, digest, daemon? }` | Holds caller-selected provider artifacts and model identities. |
541
547
  | `StudyPurpose` | type | `'mechanism' \| 'quality' \| 'capacity'` | Names the evidence a study can establish. |
542
548
  | `StudyRange` | interface | `{ first, last }` | Holds an inclusive goal range named by its first and last goal ids. |
543
549
  | `StudyReference` | interface | `{ file, row? }` | Cites a retained trial file, or one evidence row of it by its zero-based position. |
@@ -555,7 +561,7 @@ The following declarations describe this concept.
555
561
  | `StudyResultStore` | class | `new (options: StudyResultStoreOptions) => StudyResultStoreInterface` | Owns append-only execution bytes and seals only a complete terminal population. |
556
562
  | `StudyResultStoreInterface` | interface | `{ create(), seal(), exchanges() }` | Owns execution custody from exclusive creation through complete sealing. |
557
563
  | `StudyResultStoreOptions` | interface | `{ directory, manifest }` | Holds the inert execution store configuration. |
558
- | `StudyRole` | type | `'agent' \| 'judge' \| 'summary' \| 'metadata' \| 'maintenance' \| 'tool'` | Names a request's measured responsibility. |
564
+ | `StudyRole` | type | `'agent' \| 'judge' \| 'triage' \| 'summary' \| 'metadata' \| 'maintenance' \| 'tool'` | Names a request's measured responsibility. |
559
565
  | `StudyRoom` | interface | `{ context, output, safety, recap, think }` | Holds the model context and generation allowance as separate measurements. |
560
566
  | `StudyRubric` | interface | `{ version, criteria }` | Holds a versioned grading declaration independently of execution. |
561
567
  | `StudyScenario` | interface | `{ id, goals }` | Holds ordered goals sharing state within an isolated trial. |
@@ -860,7 +866,7 @@ The following declarations describe this concept.
860
866
  | `StudyLabelSource` | interface | `{ trial, criterion }` | Names the source pair a neutral row stands for. |
861
867
  | `StudyOllamaKeyedReplay` | class | `new (options: StudyOllamaKeyedReplayOptions) => StudyOllamaReplayInterface` | Serves a listed role's request from the recorded exchange its role, path, method, and body bytes equal. |
862
868
  | `StudyOllamaKeyedReplayOptions` | interface | `{ histories, roles, url, signal, fetch? }` | Configures a keyed replay over verified histories. |
863
- | `StudyOllamaKeyedRole` | type | `Extract<StudyRole, 'agent' \| 'judge' \| 'summary' \| 'metadata'>` | Names the roles a keyed replay can serve. |
869
+ | `StudyOllamaKeyedRole` | type | `Extract<StudyRole, 'agent' \| 'judge' \| 'triage' \| 'summary' \| 'metadata'>` | Names the roles a keyed replay can serve. |
864
870
  | `StudyOllamaKeyedSelection` | interface | `{ result, roles, offline }` | Selects a sealed recording and the roles a keyed replay serves from it. |
865
871
  | `advanceStudyExchangeProgress` | function | `(progress: StudyExchangeProgress, row: StudyExchangeRow) => StudyExchangeProgress` | Validates the next row against the journal before it and derives the journal after it. |
866
872
  | `buildStudyExchangeProgress` | function | `(declaration: StudyExchangeDeclaration) => StudyExchangeProgress` | Builds the progress of a journal that holds only its declaration. |
@@ -911,6 +917,8 @@ The following declarations describe this concept.
911
917
  | `publishStudyBytes` | function | `(path: string, bytes: Uint8Array, part: string) => Promise<void>` | Publishes a record by writing it beside its path and renaming it there, so a reader of the path sees no partial bytes. |
912
918
  | `scanStudyJSONFaults` | function | `(value: unknown, path?: string) => readonly string[]` | Lists the members of a value that are not plain JSON data, by path, without reading an accessor. |
913
919
  | `studyVerdictShape` | const | `import("@orkestrel/contract").LiteralShape<readonly ["achieved", "unsuccessful", "unknown"]>` | Describes a verdict a judgment holds. |
920
+ | `StudySystemOnePolicy` | interface | `{ model, tokens }` | Declares the pinned System One model and the total token reservation for each request. |
921
+ | `isStudySystemOnePolicy` | function | `(value: unknown) => value is StudySystemOnePolicy` | Checks whether a value declares a pinned System One model and total token ceiling. |
914
922
 
915
923
  ## Methods
916
924
 
@@ -2261,6 +2269,7 @@ import {
2261
2269
  isStudyOllamaMetadata,
2262
2270
  isStudyOllamaModel,
2263
2271
  isStudyOllamaPolicy,
2272
+ isStudySystemOnePolicy,
2264
2273
  isStudyOllamaStep,
2265
2274
  validateStudyOllamaCapture,
2266
2275
  validateStudyOllamaStep,
@@ -2273,8 +2282,9 @@ validateStudyOllamaCapture(configured)
2273
2282
  isStudyOllamaMetadata(configured.metadata)
2274
2283
  isStudyOllamaModel(configured.models.model)
2275
2284
  isStudyOllamaPolicy(configured.roles.agent)
2276
- isStudyOllamaStep(configured.procedure?.[0])
2277
- validateStudyOllamaStep(configured.procedure?.[0], 'write', request, body)
2285
+ isStudySystemOnePolicy(configured.roles.triage)
2286
+ isStudyOllamaStep(configured.exchanges?.declaration?.procedure?.[0])
2287
+ validateStudyOllamaStep(configured.exchanges?.declaration?.procedure?.[0], 'write', request, body)
2278
2288
  buildStudyOllamaBytes(new TextEncoder().encode(body))
2279
2289
  ```
2280
2290
 
@@ -368,7 +368,7 @@ Before shape branching or property reads, the handler snapshots untrusted `args`
368
368
 
369
369
  22. **`createDatabaseTool` durability and ownership are narrower than they look.** A lazily re-minted database over the default in-memory driver yields an empty database — only the `DatabaseDefinition` schema persists in `store`, never rows; durable rows need a persistent driver factory registered in `DatabaseToolOptions.drivers`. A cached live database is never evolved in place. To adopt a new target `version`, create a new database id backed by a versioned persistent driver, or close the old tool lifecycle and construct a new tool whose stored definition carries the new schema metadata and stamp. `'destroy'` closes whatever handle is cached for the id, including an embedder-supplied `DatabaseToolOptions.databases` handle — the embedder relinquishes that handle's lifecycle to this tool for any id it wires in. `timeout`, when present, must be a nonnegative safe integer and is validated when the tool is constructed. Its fresh abort signal is passed only to `records`, `count`, `aggregate`, `add`, `set`, `update`, and `remove`, whose current table APIs accept operation options; it does not bound store resolution, construction, schema inspection, `get`, or `close`, and is not an outer deadline. The tool assumes the single-writer, non-reentrant model `@orkestrel/database` itself assumes — concurrent tool calls against one id are not serialized by this tool. Unlike `'records'` / `'find'` / `'links'`, `'get'` is uncapped by `DatabaseToolOptions.limit` (bounded only by the caller's `key` array size).
370
370
 
371
- 23. **`createEndpointTool` enforces its advertised inferred schema through the Tool door by default (`@orkestrel/contract`'s lenient `schemaToShape`), with an explicit `strict: false` opt-out.** `parameters` is inferred once at construction (`samplesToSchema` and `schemaToObject` over `definition.samples`, tuned by `EndpointToolOptions.format`/`enum`) — the door converts the same object-rooted schema on the first call and runs on every call's `args` before `definition.execute`. The parse coerces a scalar to its inferred type where the house parsers coerce (a number to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`) — `definition.execute` receives the coerced values (for example `7` sent for a string slot arrives as `'7'`), not the raw call args. A call that carries a key the closed inferred schema does not declare, misses a required key, or holds a value not coercible to its slot's type throws a `ToolError` with code `ARGUMENTS` carrying `context.faults`, and `definition.execute` is never called. Beyond that coercion, enforcement is structural: required keys, `enum` membership, and numeric bounds — `format` annotations (`email`, `date-time`, `uuid`, `uri`, ...) are never asserted, mirroring `@orkestrel/contract`'s own widening-only law for `schemaToShape` (a `format: true`-tuned endpoint still accepts a non-conforming string in that slot). `EndpointToolOptions.strict: false` disables that enforcement: the tool's `execute` calls `definition.execute` with the model-supplied `args` exactly as received, never parsed, coerced, or checked against the advertised schema. Under the door `args` is a null-prototype record, on which `String(args)` and `args.hasOwnProperty()` throw, so a handler reads it with `Object.hasOwn`. The execution context the tool's `execute` receives reaches `definition.execute` unchanged whether or not that enforcement runs, so a handler that reads `context.signal` observes the caller's cancellation. `createInferTool`'s own call args are, as before, always validated against `inferToolShape` (a hand-written shape) regardless — it is the schema inference's caller, not an inferred schema's consumer. `createEndpointTool`'s and `createInferTool`'s inferred schemas surface sample-derived strings verbatim (property names, and enum entries when opted in), so treat sample data intended for schema inference as untrusted content whenever the resulting schema will be advertised to other agents. `createInferTool`'s optional `candidates` call arg is the opposite seam: it checks values against the same call's freshly inferred schema (compiled per-call, because the schema itself is derived from that call's `samples`) and returns a uniform `{ index, valid, coercible, faults? }` entry per candidate. `valid` is a strict `.is` guard verdict, not a normalizing `.parse` — `7` against an inferred string slot is invalid (no coercion), where the same value would be silently coerced to `'7'` by `createEndpointTool`'s enforcement. `coercible` (`checker.parse(candidate) !== undefined`) answers that separate question directly — would `createEndpointTool`'s default enforcement admit this value — and, by the house parse/guard round-trip, is always `true` on a `valid: true` entry. `faults` is `checker.audit(candidate)`, which reports against `.is`'s strictness, so a strictly-invalid but coercible candidate (`7` against a string slot) yields `{ valid: false, coercible: true, faults: [{ reason: 'type', ... }] }` and an undeclared key is a named `extra` fault: every invalid candidate names why. `checker.is` / `.parse` / `.audit` are total over JSON-safe input — a JSON-safe hostile candidate (a `__proto__`-carrying object, deep nesting) reaches each of them and yields a bounded, non-throwing per-candidate verdict; a non-JSON-safe candidate (a throwing-getter `Proxy`) never reaches the checker — the Tool door refuses the whole call with a `ToolError`, with no per-candidate verdict. `candidates` is uncapped in count (any array length is accepted), but each individual check is bounded (`.audit`'s fault list and the checker's own schema are both bounded by the inference limits already governing `samples`), so the total per-call cost is linear in `candidates.length`.
371
+ 23. **`createEndpointTool` enforces its advertised inferred schema through the Tool door by default (`@orkestrel/contract`'s lenient `schemaToShape`), with an explicit `strict: false` opt-out.** `parameters` is inferred once at construction (`samplesToSchema` and `schemaToObject` over `definition.samples`, tuned by `EndpointToolOptions.format`/`enum`) — the door converts the same object-rooted schema on the first call and runs on every call's `args` before `definition.execute`. Admission permits only lossless repairs: a numeric string whose trimmed text equals the parsed number's own text, the exact strings `'true'` and `'false'` for a boolean, a literal's trimmed text, and a finite number for a string slot. For example, `' 30 '` can become `30` and `7` can become `'7'`, but `'30.0'`, `'007'`, and `'0x10'` cannot become numbers, and `'1'`, `'0'`, `1`, and `0` cannot become booleans. The `definition.execute` handler receives the admitted value without another parse. A call that carries a key the closed inferred schema does not declare, misses a required key, or needs a repair that loses information or cannot parse throws a `ToolError` with code `ARGUMENTS` carrying `context.faults`, and `definition.execute` is never called. Beyond those repairs, enforcement is structural: required keys, `enum` membership, and numeric bounds — `format` annotations (`email`, `date-time`, `uuid`, `uri`, ...) are never asserted, mirroring `@orkestrel/contract`'s own widening-only law for `schemaToShape` (a `format: true`-tuned endpoint still accepts a non-conforming string in that slot). `EndpointToolOptions.strict: false` disables that enforcement: the tool's `execute` calls `definition.execute` with the model-supplied `args` exactly as received, never parsed, coerced, or checked against the advertised schema. Under the door `args` is a null-prototype record, on which `String(args)` and `args.hasOwnProperty()` throw, so a handler reads it with `Object.hasOwn`. The execution context the tool's `execute` receives reaches `definition.execute` unchanged whether or not that enforcement runs, so a handler that reads `context.signal` observes the caller's cancellation. `createInferTool`'s own call args are, as before, always validated against `inferToolShape` (a hand-written shape) regardless — it is the schema inference's caller, not an inferred schema's consumer. `createEndpointTool`'s and `createInferTool`'s inferred schemas surface sample-derived strings verbatim (property names, and enum entries when opted in), so treat sample data intended for schema inference as untrusted content whenever the resulting schema will be advertised to other agents. `createInferTool`'s optional `candidates` call arg is the opposite seam: it checks values against the same call's freshly inferred schema (compiled per-call, because the schema itself is derived from that call's `samples`) and returns a uniform `{ index, valid, coercible, faults? }` entry per candidate. `valid` is a strict `.is` guard verdict, not a normalizing `.parse` — `7` against an inferred string slot is invalid (no coercion), where the same value would be silently coerced to `'7'` by `createEndpointTool`'s enforcement. `coercible` (`checker.parse(candidate) !== undefined`) reports parser success, not endpoint admission, and is always `true` on a `valid: true` entry. A candidate can parse while requiring a lossy repair that the endpoint refuses. `faults` is `checker.audit(candidate)`, which reports against `.is`'s strictness, so a strictly-invalid but coercible candidate (`7` against a string slot) yields `{ valid: false, coercible: true, faults: [{ reason: 'type', ... }] }` and an undeclared key is a named `extra` fault: every invalid candidate names why. `checker.is` / `.parse` / `.audit` are total over JSON-safe input — a JSON-safe malformed candidate (a `__proto__`-carrying object, deep nesting) reaches each of them and yields a bounded, non-throwing per-candidate verdict; a non-JSON-safe candidate (a throwing-getter `Proxy`) never reaches the checker — the Tool door refuses the whole call with a `ToolError`, with no per-candidate verdict. `candidates` is uncapped in count (any array length is accepted), but each individual check is bounded (`.audit`'s fault list and the checker's own schema are both bounded by the inference limits already governing `samples`), so the total per-call cost is linear in `candidates.length`.
372
372
 
373
373
  24. **The terminal seam speaks whole forms, and `@orkestrel/form` owns their shape.** `promptToolShape` bounds a call to `{ to, schema }` and `answerToolShape`'s `'answer'` arm to `{ id, values }`, each of `schema` and `values` admitted only as exact JSON — Toolbox does not restate the form schema as a second contract. `createPromptTool` then hands `schema` to `parseForm`; a refusal (an unknown control, a duplicate field name, a `'select'` / `'checkbox'` field without usable choices, any other schema fault) throws a typed `TOOL` `ToolboxError` and nothing parks, so a malformed schema can never become a form nobody can answer. A parsed schema becomes a live form through `createForm` and is passed to `manager.ask(from, to, form)`, whose settled `FormValues` is the tool's return value — one record keyed by field name, however many fields the form declared. `createAnswerTool` narrows `values` with `isFormValues` before `manager.answer`, so a non-form payload is refused as `TOOL` rather than reaching the parked form. Expiry reaches one code from either side: a `TerminalError('EXPIRE')` from the broker and a `FormError('ABANDONED')` from the form itself both re-surface as `EXPIRE`, so a caller branches on Toolbox's own code and never on which layer timed the form out. A failed apply carries the manager's `TerminalAnswerError` through: `context.reason` is `'unknown'` / `'rejected'` / `'target'`, and a `'rejected'` apply also carries the per-field `errors` in `context.errors` so the asking side can name which field failed.
374
374