@openpond/evals 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTRACT.md CHANGED
@@ -143,3 +143,9 @@ and excludes missing rewards. An empty scorable population remains null.
143
143
  `aggregateTasksetRunInWorker` from `@openpond/evals/metrics/node` verifies custom
144
144
  module bytes and uses the existing bounded isolated worker. A fixture metric
145
145
  does not qualify a model for learning or acceptance.
146
+
147
+ `aggregateTasksetRunInProcess` and `executeTasksetMetricInProcess` use an owned
148
+ Node subprocess for hosts without Node worker APIs. It strips authored TypeScript
149
+ inside its deadline, evaluates the verified source in the same deterministic
150
+ isolate, and exits before success, failure or cancellation settles. Importing
151
+ the metrics entrypoint does not require Node's type-stripping API on the host.
@@ -6,10 +6,10 @@ import { assertBoundedTaskJson } from "./task-schema.js";
6
6
  export async function executeJavaScriptIsolateInProcess(input) {
7
7
  input.signal?.throwIfAborted();
8
8
  validateJavaScriptIsolateInput(input);
9
- const { signal, ...data } = input;
9
+ const { signal, stripTypeScript, ...data } = input;
10
10
  const error = (suffix) => new Error(`${input.errorPrefix}_${suffix}`);
11
11
  // The authored source remains JSON data passed to QuickJS, never host code.
12
- const program = `globalThis.__openpondIsolateInput = JSON.parse(${JSON.stringify(JSON.stringify(data))});\n${javascriptIsolateProcessSource}`;
12
+ const program = `globalThis.__openpondIsolateInput = JSON.parse(${JSON.stringify(JSON.stringify(data))});\n${stripTypeScript ? 'globalThis.__openpondIsolateInput.source = require("node:module").stripTypeScriptTypes(globalThis.__openpondIsolateInput.source, { mode: "strip" });\n' : ""}${javascriptIsolateProcessSource}`;
13
13
  return new Promise((resolve, reject) => {
14
14
  const child = spawn("node", ["--max-old-space-size=64", "--input-type=commonjs", "-"], {
15
15
  stdio: ["pipe", "pipe", "pipe"],
@@ -1,5 +1,5 @@
1
- import { stripTypeScriptTypes } from "node:module";
2
1
  import { executeJavaScriptIsolateInWorker } from "./javascript-isolate-node.js";
2
+ import { executeJavaScriptIsolateInProcess } from "./javascript-isolate-process.js";
3
3
  import { aggregateTasksetEvaluationReceipts, aggregateTasksetRunReceipts, executeTasksetMetric } from "./metrics.js";
4
4
  /** Verifies original source before stripping TS, then waits for worker termination
5
5
  * on success, error or cancellation. Authored imports and host APIs are unavailable. */
@@ -12,8 +12,22 @@ export function aggregateTasksetEvaluationInWorker(input) {
12
12
  export function aggregateTasksetRunInWorker(input) {
13
13
  return aggregateTasksetRunReceipts(input, executeMetric);
14
14
  }
15
- const executeMetric = ({ source, module, exportName, scores, timeoutMs, signal }) => executeJavaScriptIsolateInWorker({
16
- source: /\.[cm]?ts$/.test(module) ? stripTypeScriptTypes(source, { mode: "strip" }) : source,
17
- exportName, value: scores, timeoutMs, signal,
18
- maxResultBytes: 1_024, deterministic: true, errorPrefix: "metric",
19
- });
15
+ /** Hosted callers use the same Node process ownership as verifier/environment
16
+ * execution. Type stripping happens in that process within its deadline. */
17
+ export function executeTasksetMetricInProcess(input) {
18
+ return executeTasksetMetric(input, executeProcessMetric);
19
+ }
20
+ export function aggregateTasksetRunInProcess(input) {
21
+ return aggregateTasksetRunReceipts(input, executeProcessMetric);
22
+ }
23
+ const executeMetric = async ({ source, module, exportName, scores, timeoutMs, signal }) => {
24
+ const javascript = /\.[cm]?ts$/.test(module)
25
+ ? (await import("node:module")).stripTypeScriptTypes(source, { mode: "strip" }) : source;
26
+ return executeJavaScriptIsolateInWorker({
27
+ source: javascript,
28
+ exportName, value: scores, timeoutMs, signal,
29
+ maxResultBytes: 1_024, deterministic: true, errorPrefix: "metric",
30
+ });
31
+ };
32
+ const executeProcessMetric = ({ source, module, exportName, scores, timeoutMs, signal }) => executeJavaScriptIsolateInProcess({ source, exportName, value: scores, timeoutMs, signal, stripTypeScript: /\.[cm]?ts$/.test(module),
33
+ maxResultBytes: 1_024, deterministic: true, errorPrefix: "metric" });
@@ -1,4 +1,6 @@
1
1
  import { type JavaScriptIsolateInput } from "./javascript-isolate.js";
2
2
  /** A Node subprocess owns the interpreter; completion always waits for its exit. */
3
- export declare function executeJavaScriptIsolateInProcess(input: JavaScriptIsolateInput): Promise<unknown>;
3
+ export declare function executeJavaScriptIsolateInProcess(input: JavaScriptIsolateInput & {
4
+ stripTypeScript?: boolean;
5
+ }): Promise<unknown>;
4
6
  //# sourceMappingURL=javascript-isolate-process.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"javascript-isolate-process.d.ts","sourceRoot":"","sources":["../../../../src/javascript-isolate-process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmE,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGvI,oFAAoF;AACpF,wBAAsB,iCAAiC,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAwDvG"}
1
+ {"version":3,"file":"javascript-isolate-process.d.ts","sourceRoot":"","sources":["../../../../src/javascript-isolate-process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmE,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGvI,oFAAoF;AACpF,wBAAsB,iCAAiC,CAAC,KAAK,EAAE,sBAAsB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAwDvI"}
@@ -6,4 +6,8 @@ import type { EvaluationResult } from "./runs.js";
6
6
  export declare function executeTasksetMetricInWorker(input: TasksetMetricExecutionInput): Promise<TasksetMetricResult>;
7
7
  export declare function aggregateTasksetEvaluationInWorker(input: TasksetEvaluationInput): Promise<EvaluationResult>;
8
8
  export declare function aggregateTasksetRunInWorker(input: TasksetRunEvaluationInput): Promise<TasksetMetricResult>;
9
+ /** Hosted callers use the same Node process ownership as verifier/environment
10
+ * execution. Type stripping happens in that process within its deadline. */
11
+ export declare function executeTasksetMetricInProcess(input: TasksetMetricExecutionInput): Promise<TasksetMetricResult>;
12
+ export declare function aggregateTasksetRunInProcess(input: TasksetRunEvaluationInput): Promise<TasksetMetricResult>;
9
13
  //# sourceMappingURL=metrics-node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-node.d.ts","sourceRoot":"","sources":["../../../../src/metrics-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyF,KAAK,sBAAsB,EAAE,KAAK,yBAAyB,EAAE,KAAK,2BAA2B,EAA8B,MAAM,cAAc,CAAC;AAChP,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;wFACwF;AACxF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE7G;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE3G;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE1G"}
1
+ {"version":3,"file":"metrics-node.d.ts","sourceRoot":"","sources":["../../../../src/metrics-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyF,KAAK,sBAAsB,EAAE,KAAK,yBAAyB,EAAE,KAAK,2BAA2B,EAA8B,MAAM,cAAc,CAAC;AAChP,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;wFACwF;AACxF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE7G;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE3G;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE1G;AAED;4EAC4E;AAC5E,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE9G;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAE3G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpond/evals",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Portable Tasksets, graders, evaluation runs, receipts, conformance fixtures, and Work evidence for OpenPond Harnesses",
5
5
  "license": "MIT",
6
6
  "type": "module",