geospec 0.1.0-beta.9 → 0.4.1-next.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -9
- package/agent/doctrine.md +2 -1
- package/agent/geospec-authoring/SKILL.md +3 -3
- package/agent/geospec-authoring/api-index.md +20 -92
- package/agent/geospec-authoring/api-types.md +85 -480
- package/agent/geospec-authoring/public-api-functions.md +21 -1
- package/agent/geospec-authoring/public-api-index.md +215 -319
- package/agent/geospec-authoring/public-api-types-2.md +480 -352
- package/agent/geospec-authoring/public-api-types-3.md +79 -215
- package/agent/geospec-authoring/public-api-types.md +334 -849
- package/agent/resources.js +12 -13
- package/agent/skills.json +2 -3
- package/dist/assertion-client/client.d.mts +14 -15
- package/dist/assertion-client/client.mjs +1 -1
- package/dist/cli/check.mjs +2 -0
- package/dist/cli/cli.d.mts +5 -5
- package/dist/cli/cli.mjs +20 -3
- package/dist/cli/node-host.d.mts +5 -4
- package/dist/cli/node-host.mjs +1 -1
- package/dist/cli/wire-value.mjs +1 -1
- package/dist/config/define-config.d.mts +2 -3
- package/dist/config/node/index.mjs +1 -1
- package/dist/config/node/load.d.mts +2 -3
- package/dist/config/node/load.mjs +1 -1
- package/dist/config/read-geospec-config.d.mts +10 -6
- package/dist/config/read-geospec-config.mjs +1 -1
- package/dist/config/types.d.mts +6 -7
- package/dist/create-geospec.d.mts +7 -6
- package/dist/engine/client.d.mts +15 -15
- package/dist/engine/client.mjs +1 -1
- package/dist/engine/matchers.d.mts +10 -11
- package/dist/engine/pmi.types.d.mts +11 -12
- package/dist/engine/protocol.d.mts +7 -8
- package/dist/engine/protocol.mjs +1 -1
- package/dist/geometry-unit.d.mts +2 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mesh/index.d.mts +2 -2
- package/dist/mesh/types.d.mts +8 -505
- package/dist/model/errors.d.mts +2 -3
- package/dist/model/load-model.d.mts +3 -4
- package/dist/model/mesh-evidence-matchers.d.mts +2 -3
- package/dist/model/native-model-loader.d.mts +14 -17
- package/dist/model/native-model-loader.mjs +1 -1
- package/dist/model/node/command-exporter.d.mts +3 -4
- package/dist/model/node/command-exporter.mjs +1 -1
- package/dist/model/node/index.mjs +1 -1
- package/dist/model/region-scope.d.mts +3 -6
- package/dist/model/region-scope.mjs +1 -1
- package/dist/model/subject.d.mts +2 -5
- package/dist/model/subject.mjs +1 -1
- package/dist/model/types.d.mts +19 -20
- package/dist/runner/collector.d.mts +7 -8
- package/dist/runner/collector.mjs +3 -1
- package/dist/runner/discovery.d.mts +10 -11
- package/dist/runner/discovery.mjs +5 -1
- package/dist/runner/filter.d.mts +6 -7
- package/dist/runner/filter.mjs +3 -1
- package/dist/runner/index.d.mts +3 -1
- package/dist/runner/index.mjs +1 -1
- package/dist/runner/native/native-pool-grants.d.mts +2 -3
- package/dist/runner/native/native-serial-runner.d.mts +4 -7
- package/dist/runner/native/native-serial-runner.mjs +1 -1
- package/dist/runner/node/engine.d.mts +5 -6
- package/dist/runner/node/index.mjs +1 -1
- package/dist/runner/node/node-vm-filesystem.d.mts +4 -5
- package/dist/runner/node/node-vm-filesystem.mjs +1 -1
- package/dist/runner/node/pool-runner.d.mts +15 -6
- package/dist/runner/node/pool-runner.mjs +1 -1
- package/dist/runner/node/pool-worker-entry.d.mts +9 -6
- package/dist/runner/node/pool-worker-entry.mjs +1 -1
- package/dist/runner/pool/events.mjs +1 -1
- package/dist/runner/pool/pool-messages.d.mts +8 -9
- package/dist/runner/pool/pool.d.mts +4 -6
- package/dist/runner/pool/pool.mjs +1 -1
- package/dist/runner/pool/shard-timings.d.mts +3 -4
- package/dist/runner/pool/worker-host.d.mts +6 -5
- package/dist/runner/pool/worker-host.mjs +1 -1
- package/dist/runner/run-geospec-module.d.mts +2 -3
- package/dist/runner/run-geospec-module.mjs +2 -2
- package/dist/runner/timeout-codes.d.mts +6 -8
- package/dist/runner/types.d.mts +56 -53
- package/dist/runner/worker/no-matching-tests-issue.d.mts +3 -4
- package/dist/runner/worker/runner-types.d.mts +17 -16
- package/dist/runner/worker/serial-runner.mjs +1 -1
- package/dist/selector/types.d.mts +22 -23
- package/dist/step/types.d.mts +4 -119
- package/dist/support/filesystem-errors.mjs +1 -0
- package/dist/support/hash.mjs +1 -0
- package/dist/support/path.mjs +1 -0
- package/dist/support/sha256.mjs +1 -0
- package/dist/support/types.d.mts +38 -0
- package/dist/vitest/adapter.d.mts +5 -6
- package/dist/vitest/adapter.mjs +1 -1
- package/dist/vitest/index.d.mts +0 -1
- package/dist/vitest/index.mjs +1 -1
- package/dist/vitest/node/index.d.mts +2 -0
- package/dist/vitest/node/index.mjs +1 -0
- package/dist/vitest/node/setup-project.d.mts +60 -0
- package/dist/vitest/node/setup-project.mjs +1 -0
- package/dist/vm/plain-module-vm.d.mts +13 -0
- package/dist/vm/plain-module-vm.mjs +8 -0
- package/dist/vm/types.d.mts +142 -0
- package/package.json +17 -9
- package/agent/geospec-authoring/api-types-2.md +0 -85
package/dist/runner/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compileGeoSpecTestNamePattern as e,filterGeoSpecTests as t,matchesGeoSpecTestName as n}from"./filter.mjs";import{geoSpecTimeoutCode as r,isGeoSpecTimeoutCode as i}from"./timeout-codes.mjs";import{GeoSpecAssertionError as a,clearCollectorGlobals as o,createCollector as s,installCollector as c}from"./collector.mjs";import{defaultGeoSpecIgnoredDirectories as l,defaultGeoSpecInclude as u,discoverGeoSpecFiles as d,isGeoSpecTestFile as f}from"./discovery.mjs";import{
|
|
1
|
+
import{compileGeoSpecTestNamePattern as e,filterGeoSpecTests as t,matchesGeoSpecTestName as n}from"./filter.mjs";import{geoSpecTimeoutCode as r,isGeoSpecTimeoutCode as i}from"./timeout-codes.mjs";import{GeoSpecAssertionError as a,clearCollectorGlobals as o,createCollector as s,installCollector as c}from"./collector.mjs";import{defaultGeoSpecIgnoredDirectories as l,defaultGeoSpecInclude as u,discoverGeoSpecFiles as d,isGeoSpecTestFile as f}from"./discovery.mjs";import{createPlainModuleVm as p}from"../vm/plain-module-vm.mjs";import{runGeoSpecModule as m}from"./run-geospec-module.mjs";export{a as GeoSpecAssertionError,o as clearCollectorGlobals,e as compileGeoSpecTestNamePattern,s as createCollector,p as createPlainModuleVm,l as defaultGeoSpecIgnoredDirectories,u as defaultGeoSpecInclude,d as discoverGeoSpecFiles,t as filterGeoSpecTests,r as geoSpecTimeoutCode,c as installCollector,f as isGeoSpecTestFile,i as isGeoSpecTimeoutCode,n as matchesGeoSpecTestName,m as runGeoSpecModule};
|
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
* @returns Grants in worker creation order.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
declare const allocateNativePoolGrants: (options: {
|
|
15
|
+
export declare const allocateNativePoolGrants: (options: {
|
|
16
16
|
workers: number;
|
|
17
17
|
budget?: number;
|
|
18
18
|
hostCap: number;
|
|
19
19
|
}) => readonly number[];
|
|
20
|
-
//#endregion
|
|
21
|
-
export { allocateNativePoolGrants };
|
|
20
|
+
//#endregion
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { CreateGeoSpecNativeModelLoaderOptions, GeoSpecNativeModelEngine, ManagedGeoSpecNativeModelLoader } from "../../model/native-model-loader.mjs";
|
|
2
2
|
import { GeoSpecAssertionClientOptions } from "../../assertion-client/client.mjs";
|
|
3
|
-
import "../../assertion-client/index.mjs";
|
|
4
3
|
import { GeoSpecRunner, GeoSpecRunnerOptions } from "../worker/runner-types.mjs";
|
|
5
|
-
import "../worker/index.mjs";
|
|
6
4
|
//#region src/runner/native/native-serial-runner.d.ts
|
|
7
5
|
/** Native assertion options whose engine can also admit and release subjects. @public */
|
|
8
|
-
type GeoSpecNativeRunnerAssertions = Omit<GeoSpecAssertionClientOptions, 'engine'> & {
|
|
6
|
+
export type GeoSpecNativeRunnerAssertions = Omit<GeoSpecAssertionClientOptions, 'engine'> & {
|
|
9
7
|
readonly engine: GeoSpecNativeModelEngine;
|
|
10
8
|
};
|
|
11
9
|
/** Options for the native serial runner. @public */
|
|
12
|
-
type GeoSpecNativeRunnerOptions = Omit<GeoSpecRunnerOptions, 'nativeAssertions' | 'nativeModelLoader'> & {
|
|
10
|
+
export type GeoSpecNativeRunnerOptions = Omit<GeoSpecRunnerOptions, 'nativeAssertions' | 'nativeModelLoader'> & {
|
|
13
11
|
/** Actual protocol-3 engine used by authored assertions. */
|
|
14
12
|
readonly nativeAssertions: GeoSpecNativeRunnerAssertions;
|
|
15
13
|
/** Optional managed loader; the runner releases its subjects after every run. */
|
|
@@ -24,6 +22,5 @@ type GeoSpecNativeRunnerOptions = Omit<GeoSpecRunnerOptions, 'nativeAssertions'
|
|
|
24
22
|
* @returns The ordinary GeoSpec runner lifecycle and event contract.
|
|
25
23
|
* @public
|
|
26
24
|
*/
|
|
27
|
-
declare const createNativeGeoSpecRunner: (options: GeoSpecNativeRunnerOptions) => GeoSpecRunner;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { GeoSpecNativeRunnerAssertions, GeoSpecNativeRunnerOptions, createNativeGeoSpecRunner };
|
|
25
|
+
export declare const createNativeGeoSpecRunner: (options: GeoSpecNativeRunnerOptions) => GeoSpecRunner;
|
|
26
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSerialGeoSpecRunner as e}from"../worker/serial-runner.mjs";import{createGeoSpecNativeModelLoader as t}from"../../model/native-model-loader.mjs";const n=new TextDecoder(`utf-8`,{fatal:!0}),r=(e,t)=>{let r=JSON.parse(n.decode(e));if(typeof r!=`object`||!r||!(`plan`in r))throw TypeError(`Native GeoSpec assertion requires a plan with admitted subjects.`);let{plan:i}=r;if(typeof i!=`object`||!i||!(`subjects`in i)||!Array.isArray(i.subjects)||i.subjects.length===0)throw TypeError(`Native GeoSpec assertion requires admitted subjects.`);for(let e of i.subjects){if(typeof e!=`object`||!e)throw TypeError(`Native GeoSpec assertion requires admitted subjects.`);let n=`subjectHash`in e;if(n===`contentHash`in e)throw TypeError(`Native GeoSpec assertion requires one admitted subject identity.`);let r=n?e.subjectHash:`contentHash`in e?e.contentHash:void 0;if(typeof r!=`string`||!t.has(r))throw TypeError(`Native GeoSpec subject was not admitted by this run.`)}},i=i=>{let a=i.nativeModelLoader??t({...i.model,engine:i.nativeAssertions.engine,...i.nativeAssertions.maximumWorkUnitLimit===void 0?{}:{maximumWorkUnitLimit:i.nativeAssertions.maximumWorkUnitLimit}}),o
|
|
1
|
+
import{createSerialGeoSpecRunner as e}from"../worker/serial-runner.mjs";import{createGeoSpecNativeModelLoader as t}from"../../model/native-model-loader.mjs";const n=new TextDecoder(`utf-8`,{fatal:!0}),r=(e,t)=>{let r=JSON.parse(n.decode(e));if(typeof r!=`object`||!r||!(`plan`in r))throw TypeError(`Native GeoSpec assertion requires a plan with admitted subjects.`);let{plan:i}=r;if(typeof i!=`object`||!i||!(`subjects`in i)||!Array.isArray(i.subjects)||i.subjects.length===0)throw TypeError(`Native GeoSpec assertion requires admitted subjects.`);for(let e of i.subjects){if(typeof e!=`object`||!e)throw TypeError(`Native GeoSpec assertion requires admitted subjects.`);let n=`subjectHash`in e;if(n===`contentHash`in e)throw TypeError(`Native GeoSpec assertion requires one admitted subject identity.`);let r=n?e.subjectHash:`contentHash`in e?e.contentHash:void 0;if(typeof r!=`string`||!t.has(r))throw TypeError(`Native GeoSpec subject was not admitted by this run.`)}},i=i=>{let a=i.nativeModelLoader??t({...i.model,engine:i.nativeAssertions.engine,...i.nativeAssertions.maximumWorkUnitLimit===void 0?{}:{maximumWorkUnitLimit:i.nativeAssertions.maximumWorkUnitLimit}}),o=/* @__PURE__ */ new Set,s=Object.assign(async e=>{let t=await a(e);return o.add(t.subjectHash),t},{async releaseAll(){try{await a.releaseAll()}finally{o.clear()}}}),c=i.nativeAssertions.engine,l={evaluateClaim(e){return r(e,o),c.evaluateClaim(e)},processRequest(e){let t=JSON.parse(n.decode(e));return typeof t==`object`&&t&&`method`in t&&t.method===`submitClaims`&&r(e,o),c.processRequest(e)},ingestSubject:(e,t,n)=>c.ingestSubject(e,t,n),subjectHandle:e=>c.subjectHandle(e),releaseSubject:e=>c.releaseSubject(e)},u=e({filesystem:i.filesystem,nativeAssertions:{...i.nativeAssertions,engine:l},nativeModelLoader:s,...i.builtinModules===void 0?{}:{builtinModules:i.builtinModules},...i.createModuleVm===void 0?{}:{createModuleVm:i.createModuleVm}});return{...u,async close(){try{await u.close()}finally{o.clear()}}}};export{i as createNativeGeoSpecRunner};
|
|
@@ -5,13 +5,13 @@ import { GeoSpecNativeModelEngine } from "../../model/native-model-loader.mjs";
|
|
|
5
5
|
*
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
type GeoSpecEngineBinding = 'napi' | 'wasm';
|
|
8
|
+
export type GeoSpecEngineBinding = 'napi' | 'wasm';
|
|
9
9
|
/**
|
|
10
10
|
* Options for {@link createNodeGeoSpecEngine}.
|
|
11
11
|
*
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
type CreateNodeGeoSpecEngineOptions = {
|
|
14
|
+
export type CreateNodeGeoSpecEngineOptions = {
|
|
15
15
|
/** Caller-inclusive CPU permits for the native addon; the WASM build is single-threaded and ignores them. */
|
|
16
16
|
readonly executionPermits?: number;
|
|
17
17
|
};
|
|
@@ -20,7 +20,7 @@ type CreateNodeGeoSpecEngineOptions = {
|
|
|
20
20
|
*
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
|
-
type NodeGeoSpecEngine = {
|
|
23
|
+
export type NodeGeoSpecEngine = {
|
|
24
24
|
readonly engine: GeoSpecNativeModelEngine & {
|
|
25
25
|
close(): void;
|
|
26
26
|
};
|
|
@@ -35,6 +35,5 @@ type NodeGeoSpecEngine = {
|
|
|
35
35
|
* @throws Error when the native addon is installed but cannot load, or the permits are invalid.
|
|
36
36
|
* @public
|
|
37
37
|
*/
|
|
38
|
-
declare const createNodeGeoSpecEngine: (options?: CreateNodeGeoSpecEngineOptions) => Promise<NodeGeoSpecEngine>;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { CreateNodeGeoSpecEngineOptions, GeoSpecEngineBinding, NodeGeoSpecEngine, createNodeGeoSpecEngine };
|
|
38
|
+
export declare const createNodeGeoSpecEngine: (options?: CreateNodeGeoSpecEngineOptions) => Promise<NodeGeoSpecEngine>;
|
|
39
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createGeoSpecNodePoolRunner as e,createNodeWorkerHandle as t}from"./pool-runner.mjs";import{
|
|
1
|
+
import{createGeoSpecNodePoolRunner as e,createNodeWorkerHandle as t}from"./pool-runner.mjs";import{createNodeGeoSpecEngine as n}from"./engine.mjs";import{createNodeVmFileSystem as r,resolveUnderRoot as i}from"./node-vm-filesystem.mjs";export{e as createGeoSpecNodePoolRunner,n as createNodeGeoSpecEngine,r as createNodeVmFileSystem,t as createNodeWorkerHandle,i as resolveUnderRoot};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VmFileSystem } from "
|
|
1
|
+
import { VmFileSystem } from "../../vm/types.mjs";
|
|
2
2
|
//#region src/runner/node/node-vm-filesystem.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Resolve one VM path to a real path under the root.
|
|
@@ -9,7 +9,7 @@ import { VmFileSystem } from "@taucad/esbuild/vm";
|
|
|
9
9
|
* @throws Error when the path escapes the root.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
declare const resolveUnderRoot: (root: string, path: string) => string;
|
|
12
|
+
export declare const resolveUnderRoot: (root: string, path: string) => string;
|
|
13
13
|
/**
|
|
14
14
|
* Create a Node `VmFileSystem` rooted at `root`.
|
|
15
15
|
*
|
|
@@ -17,6 +17,5 @@ declare const resolveUnderRoot: (root: string, path: string) => string;
|
|
|
17
17
|
* @returns A VM filesystem confined to `root`.
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
declare const createNodeVmFileSystem: (root: string) => VmFileSystem;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { createNodeVmFileSystem, resolveUnderRoot };
|
|
20
|
+
export declare const createNodeVmFileSystem: (root: string) => VmFileSystem;
|
|
21
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertRootedPath as e}from"
|
|
1
|
+
import{assertRootedPath as e}from"../../support/path.mjs";import{basename as t,dirname as n,isAbsolute as r,join as i,relative as a,resolve as o,sep as s}from"node:path";import{lstat as c,mkdir as l,open as u,readFile as d,realpath as f,rename as p,unlink as m}from"node:fs/promises";import{randomUUID as h}from"node:crypto";const g=(t,n)=>{let r=o(t),i=o(r,e(n)),c=a(r,i);if(c.startsWith(`..${s}`)||c===`..`)throw Error(`GeoSpec refused a path outside the project root: '${n}'.`);return i},_=(e,t)=>{let n=a(e,t);return n===``||!r(n)&&n!==`..`&&!n.startsWith(`..${s}`)},v=async e=>{let t=e;for(;;)try{return await c(t),t}catch(e){let{code:r}=e;if(r!==`ENOENT`&&r!==`ENOTDIR`)throw e;let i=n(t);if(i===t)throw e;t=i}},y=e=>{let r=o(e),a=f(r),s=async(e,t)=>{let[n,r]=await Promise.all([a,v(e)]);if(!_(n,await f(r)))throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused a symbolic link outside the project root: '${t}'.`),{code:`EACCES`});return e},y=async e=>s(g(r,e),e),b=async e=>{let t=await d(await y(e));return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)};return{exists:async e=>{try{let t=await u(await y(e),`r`);try{return(await t.stat()).isFile()||await t.readFile(),!0}finally{await t.close()}}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return!1;throw e}},readFile:(async(e,t)=>t===`utf8`?d(await y(e),`utf8`):b(e)),writeFile:async(e,o)=>{let d=g(r,e),v=n(d);await s(v,e),await l(v,{recursive:!0});let[y,b]=await Promise.all([a,f(v)]);if(!_(y,b))throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused a symbolic link outside the project root: '${e}'.`),{code:`EACCES`});let x=i(b,t(d));if((await c(x).catch(e=>{if(e.code!==`ENOENT`)throw e}))?.isSymbolicLink())throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused to replace a symbolic link: '${e}'.`),{code:`ELOOP`});let S=i(b,`.${t(d)}.${process.pid}.${h()}.tmp`);try{let t=await u(S,`wx`);try{await t.writeFile(o,`utf8`),await t.sync()}finally{await t.close()}let n=await f(v);if(n!==b||!_(y,n))throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused a changed parent directory: '${e}'.`),{code:`ELOOP`});if((await c(x).catch(e=>{if(e.code!==`ENOENT`)throw e}))?.isSymbolicLink())throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused to replace a symbolic link: '${e}'.`),{code:`ELOOP`});await p(S,x)}finally{await m(S).catch(()=>void 0)}},ensureDir:async e=>{let t=await y(e);await l(t,{recursive:!0});let[n,r]=await Promise.all([a,f(t)]);if(!_(n,r))throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused a symbolic link outside the project root: '${e}'.`),{code:`EACCES`})}}},b=(e,t,n)=>{let r=new Map(Object.entries(n).map(([t,n])=>[g(e,t),n])),i=t=>r.get(g(e,t));return{exists:async e=>i(e)!==void 0||t.exists(e),readFile:(async(e,n)=>{let r=i(e);return r===void 0?n===`utf8`?t.readFile(e,`utf8`):t.readFile(e):n===`utf8`?r:new TextEncoder().encode(r)}),writeFile:async(e,n)=>{if(i(e)!==void 0)throw Object.assign(/* @__PURE__ */ Error(`GeoSpec refused to write a path it serves from memory: '${e}'.`),{code:`EACCES`});await t.writeFile(e,n)},ensureDir:async e=>t.ensureDir(e)}};export{y as createNodeVmFileSystem,g as resolveUnderRoot,b as withInMemorySources};
|
|
@@ -9,7 +9,7 @@ import { GeoSpecPoolWorkerHandle, GeoSpecPoolWorkerMessage } from "../pool/pool-
|
|
|
9
9
|
*
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
type NodeWorkerLike = {
|
|
12
|
+
export type NodeWorkerLike = {
|
|
13
13
|
postMessage(value: unknown): void;
|
|
14
14
|
on(event: 'message', listener: (value: GeoSpecPoolWorkerMessage) => void): void;
|
|
15
15
|
on(event: 'exit', listener: (code: number) => void): void;
|
|
@@ -23,9 +23,9 @@ type NodeWorkerLike = {
|
|
|
23
23
|
* @returns The pool handle.
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
declare const createNodeWorkerHandle: (worker: NodeWorkerLike) => GeoSpecPoolWorkerHandle;
|
|
26
|
+
export declare const createNodeWorkerHandle: (worker: NodeWorkerLike) => GeoSpecPoolWorkerHandle;
|
|
27
27
|
/** Options for the Node pool. @public */
|
|
28
|
-
type GeoSpecNodePoolOptions = {
|
|
28
|
+
export type GeoSpecNodePoolOptions = {
|
|
29
29
|
/** Absolute project root. */
|
|
30
30
|
projectPath: string;
|
|
31
31
|
/** The `geospec.config.*` each worker imports for its exporters; absent to discover one in `projectPath`. */
|
|
@@ -35,6 +35,11 @@ type GeoSpecNodePoolOptions = {
|
|
|
35
35
|
* `GeoSpecExporterModule`). A host that composes its own exporters, such as `tau test`, passes them here.
|
|
36
36
|
*/
|
|
37
37
|
exporterModules?: readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* URL of a module each worker imports whose default export creates its module VM (see `GeoSpecModuleVmModule`);
|
|
40
|
+
* absent for GeoSpec's plain VM. A host that resolves npm packages in specs, such as `tau test`, passes it here.
|
|
41
|
+
*/
|
|
42
|
+
moduleVmModule?: string;
|
|
38
43
|
/** Number of outer worker isolates; defaults to one. */
|
|
39
44
|
workers?: number;
|
|
40
45
|
/**
|
|
@@ -46,6 +51,11 @@ type GeoSpecNodePoolOptions = {
|
|
|
46
51
|
budget?: number;
|
|
47
52
|
/** Non-verdict shard watchdog in milliseconds. */
|
|
48
53
|
shardTimeout?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Spec sources each worker serves from memory, keyed by project-rooted path, in place of the file on disk. A path
|
|
56
|
+
* here is never read from or written to the project; `geospec check` runs its bundled spec this way.
|
|
57
|
+
*/
|
|
58
|
+
sources?: Readonly<Record<string, string>>;
|
|
49
59
|
};
|
|
50
60
|
/**
|
|
51
61
|
* Create a pool with one engine and one set of exporters constructed inside each worker.
|
|
@@ -62,6 +72,5 @@ type GeoSpecNodePoolOptions = {
|
|
|
62
72
|
* gives any of several in-process workers more than one permit.
|
|
63
73
|
* @public
|
|
64
74
|
*/
|
|
65
|
-
declare const createGeoSpecNodePoolRunner: (options: GeoSpecNodePoolOptions) => GeoSpecRunner;
|
|
66
|
-
//#endregion
|
|
67
|
-
export { GeoSpecNodePoolOptions, NodeWorkerLike, createGeoSpecNodePoolRunner, createNodeWorkerHandle };
|
|
75
|
+
export declare const createGeoSpecNodePoolRunner: (options: GeoSpecNodePoolOptions) => GeoSpecRunner;
|
|
76
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{allocateNativePoolGrants as e}from"../native/native-pool-grants.mjs";import{createGeoSpecPoolRunner as t}from"../pool/pool.mjs";import{availableParallelism as n}from"node:os";import{Worker as r}from"node:worker_threads";const i=e=>{let t=!1,n;return{postMessage(n){n.type===`shutdown`&&(t=!0),e.postMessage(n)},onMessage(t){e.on(`message`,t)},onExit(r){e.on(`error`,e=>{n=e.message}),e.on(`exit`,e=>{r({unexpected:!t&&e!==0,...n===void 0?{}:{message:n}})})},async terminate(){t=!0,await e.terminate()}}},a=a=>{let o=a.workers??1;if(o>1&&a.budget!==void 0&&a.budget>o)throw RangeError(`Native pool workers share one process OCCT library: a budget above one permit per worker requires workers: 1.`);let s=e({workers:o,hostCap:n(),...a.budget===void 0?{}:{budget:a.budget}}),c=0;return t({workers:o,gracefulShutdown:!0,createWorker:()=>i(new r(new URL(import.meta.url.endsWith(`.ts`)?`./pool-worker-entry.ts`:`./pool-worker-entry.mjs`,import.meta.url),{workerData:{projectPath:a.projectPath,...a.configPath===void 0?{}:{configPath:a.configPath},...a.exporterModules===void 0?{}:{exporterModules:[...a.exporterModules]},grant:s[c++]}})),initializeWorker:e=>{e.postMessage({type:`initialize`})},...a.shardTimeout===void 0?{}:{shardTimeout:a.shardTimeout}})};export{a as createGeoSpecNodePoolRunner,i as createNodeWorkerHandle};
|
|
1
|
+
import{allocateNativePoolGrants as e}from"../native/native-pool-grants.mjs";import{createGeoSpecPoolRunner as t}from"../pool/pool.mjs";import{availableParallelism as n}from"node:os";import{Worker as r}from"node:worker_threads";const i=e=>{let t=!1,n;return{postMessage(n){n.type===`shutdown`&&(t=!0),e.postMessage(n)},onMessage(t){e.on(`message`,t)},onExit(r){e.on(`error`,e=>{n=e.message}),e.on(`exit`,e=>{r({unexpected:!t&&e!==0,...n===void 0?{}:{message:n}})})},async terminate(){t=!0,await e.terminate()}}},a=a=>{let o=a.workers??1;if(o>1&&a.budget!==void 0&&a.budget>o)throw RangeError(`Native pool workers share one process OCCT library: a budget above one permit per worker requires workers: 1.`);let s=e({workers:o,hostCap:n(),...a.budget===void 0?{}:{budget:a.budget}}),c=0;return t({workers:o,gracefulShutdown:!0,createWorker:()=>i(new r(new URL(import.meta.url.endsWith(`.ts`)?`./pool-worker-entry.ts`:`./pool-worker-entry.mjs`,import.meta.url),{workerData:{projectPath:a.projectPath,...a.configPath===void 0?{}:{configPath:a.configPath},...a.exporterModules===void 0?{}:{exporterModules:[...a.exporterModules]},...a.moduleVmModule===void 0?{}:{moduleVmModule:a.moduleVmModule},...a.sources===void 0?{}:{sources:{...a.sources}},grant:s[c++]}})),initializeWorker:e=>{e.postMessage({type:`initialize`})},...a.shardTimeout===void 0?{}:{shardTimeout:a.shardTimeout}})};export{a as createGeoSpecNodePoolRunner,i as createNodeWorkerHandle};
|
|
@@ -7,7 +7,7 @@ import { GeoSpecPoolHostMessage, GeoSpecPoolWorkerMessage } from "../pool/pool-m
|
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
type GeoSpecExporterModule = {
|
|
10
|
+
export type GeoSpecExporterModule = {
|
|
11
11
|
default: (context: {
|
|
12
12
|
readonly projectPath: string;
|
|
13
13
|
}) => Promise<readonly GeoSpecModelExporter[]>;
|
|
@@ -17,18 +17,22 @@ type GeoSpecExporterModule = {
|
|
|
17
17
|
*
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
|
-
type GeoSpecNodePoolWorkerOptions = {
|
|
20
|
+
export type GeoSpecNodePoolWorkerOptions = {
|
|
21
21
|
/** Absolute project root. */
|
|
22
22
|
readonly projectPath: string;
|
|
23
23
|
/** The `geospec.config.*` the run selected; absent to discover one in `projectPath`. */
|
|
24
24
|
readonly configPath?: string;
|
|
25
25
|
/** URLs of {@link GeoSpecExporterModule}s whose exporters precede the config's. */
|
|
26
26
|
readonly exporterModules?: readonly string[];
|
|
27
|
+
/** URL of a {@link GeoSpecModuleVmModule} whose default export creates this worker's module VM; absent for the plain VM. */
|
|
28
|
+
readonly moduleVmModule?: string;
|
|
27
29
|
/** This worker's caller-inclusive CPU grant for the native addon; absent for one permit. */
|
|
28
30
|
readonly grant?: number;
|
|
31
|
+
/** Spec sources served from memory, keyed by project-rooted path (see `GeoSpecNodePoolOptions.sources`). */
|
|
32
|
+
readonly sources?: Readonly<Record<string, string>>;
|
|
29
33
|
};
|
|
30
34
|
/** Parent-owned message boundary for the worker. @public */
|
|
31
|
-
type GeoSpecNodePoolPort = {
|
|
35
|
+
export type GeoSpecNodePoolPort = {
|
|
32
36
|
postMessage(message: GeoSpecPoolWorkerMessage): void;
|
|
33
37
|
on(event: 'message', listener: (message: GeoSpecPoolHostMessage) => void): void;
|
|
34
38
|
};
|
|
@@ -38,6 +42,5 @@ type GeoSpecNodePoolPort = {
|
|
|
38
42
|
* @param options - Project, config, exporter modules and the assigned grant.
|
|
39
43
|
* @public
|
|
40
44
|
*/
|
|
41
|
-
declare const startGeoSpecNodePoolWorker: (port: GeoSpecNodePoolPort, options: GeoSpecNodePoolWorkerOptions) => Promise<void>;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { GeoSpecExporterModule, GeoSpecNodePoolPort, GeoSpecNodePoolWorkerOptions, startGeoSpecNodePoolWorker };
|
|
45
|
+
export declare const startGeoSpecNodePoolWorker: (port: GeoSpecNodePoolPort, options: GeoSpecNodePoolWorkerOptions) => Promise<void>;
|
|
46
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadGeoSpecConfig as e}from"../../config/node/load.mjs";import{createGeoSpecNativeModelLoader as t}from"../../model/native-model-loader.mjs";import{
|
|
1
|
+
import{loadGeoSpecConfig as e}from"../../config/node/load.mjs";import{createGeoSpecNativeModelLoader as t}from"../../model/native-model-loader.mjs";import{createNodeGeoSpecEngine as n}from"./engine.mjs";import{createNodeVmFileSystem as r,withInMemorySources as i}from"./node-vm-filesystem.mjs";import{startGeoSpecPoolWorkerHost as a}from"../pool/worker-host.mjs";import{parentPort as o,workerData as s}from"node:worker_threads";import{memoryUsage as c}from"node:process";const l=async t=>{let[n,...r]=await Promise.all([e({projectPath:t.projectPath,...t.configPath===void 0?{}:{configPath:t.configPath}}),...(t.exporterModules??[]).map(async e=>await import(e))]);return[...(await Promise.all(r.map(async e=>e.default({projectPath:t.projectPath})))).flat(),...n.options.exporters??[]]},u=async(e,o)=>{let{engine:s}=await n(o.grant===void 0?{}:{executionPermits:o.grant});try{let n=r(o.projectPath),u=o.sources===void 0?n:i(o.projectPath,n,o.sources),d;if(o.moduleVmModule!==void 0){let e=await import(o.moduleVmModule);if(typeof e.default!=`function`)throw TypeError(`The module VM module '${o.moduleVmModule}' must default-export a CreateModuleVm.`);d=e.default}let f=t({engine:s,projectPath:o.projectPath,exporters:await l(o),readSource:async e=>{if(typeof e!=`string`)throw TypeError(`Node pool direct sources must be project-rooted paths or bytes.`);return u.readFile(e)}});a({filesystem:u,nativeAssertions:{engine:s},nativeModelLoader:f,...d===void 0?{}:{createModuleVm:d},postMessage:t=>{e.postMessage(t)},onHostMessage:t=>{e.on(`message`,t)},measureMemoryBytes:()=>{let e=c();return e.heapUsed+e.external},onShutdown:()=>{s.close()}})}catch(e){throw s.close(),e}};if(o!==null)try{await u(o,s)}catch(e){let t=e?.code;o.postMessage({type:`initialization-error`,message:e instanceof Error?e.message:String(e),...typeof t==`string`?{code:t}:{}}),o.close()}export{u as startGeoSpecNodePoolWorker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=()=>{let e
|
|
1
|
+
const e=()=>{let e=/* @__PURE__ */ new Set;return{on(t,n){let r=e=>{e.type===t&&n(e)};return e.add(r),()=>e.delete(r)},emit(t){for(let n of e)n(t)},clear(){e.clear()}}};export{e as createRunnerEventChannel};
|
|
@@ -4,17 +4,17 @@ import { GeoSpecRunResult } from "../types.mjs";
|
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
type GeoSpecPoolShard = {
|
|
7
|
+
export type GeoSpecPoolShard = {
|
|
8
8
|
/** Stable shard id, unique within one pool run. */
|
|
9
9
|
id: number;
|
|
10
10
|
/** GeoSpec file this shard executes. */
|
|
11
11
|
file: string;
|
|
12
|
-
/** Exact-test pattern for split shards (
|
|
12
|
+
/** Exact-test pattern for split shards (`(file, testNamePattern)` work units). */
|
|
13
13
|
testNamePattern?: string;
|
|
14
14
|
};
|
|
15
15
|
/** Host → worker messages. */
|
|
16
16
|
/** @public */
|
|
17
|
-
type GeoSpecPoolHostMessage = {
|
|
17
|
+
export type GeoSpecPoolHostMessage = {
|
|
18
18
|
type: 'initialize';
|
|
19
19
|
} | {
|
|
20
20
|
type: 'run-shard';
|
|
@@ -22,7 +22,7 @@ type GeoSpecPoolHostMessage = {
|
|
|
22
22
|
testNamePattern?: string;
|
|
23
23
|
testTimeout?: number;
|
|
24
24
|
} | {
|
|
25
|
-
/** List-only collection pass: register tests, run no bodies (
|
|
25
|
+
/** List-only collection pass: register tests, run no bodies (shard splitting). */
|
|
26
26
|
type: 'list-tests';
|
|
27
27
|
shardId: number;
|
|
28
28
|
file: string;
|
|
@@ -32,7 +32,7 @@ type GeoSpecPoolHostMessage = {
|
|
|
32
32
|
};
|
|
33
33
|
/** Worker → host messages. */
|
|
34
34
|
/** @public */
|
|
35
|
-
type GeoSpecPoolWorkerMessage = {
|
|
35
|
+
export type GeoSpecPoolWorkerMessage = {
|
|
36
36
|
type: 'ready';
|
|
37
37
|
} | {
|
|
38
38
|
type: 'initialized';
|
|
@@ -72,15 +72,14 @@ type GeoSpecPoolWorkerMessage = {
|
|
|
72
72
|
};
|
|
73
73
|
/** Minimal worker handle the host-agnostic pool drives (Node or Web Worker). */
|
|
74
74
|
/** @public */
|
|
75
|
-
type GeoSpecPoolWorkerHandle = {
|
|
75
|
+
export type GeoSpecPoolWorkerHandle = {
|
|
76
76
|
postMessage(message: GeoSpecPoolHostMessage): void;
|
|
77
77
|
onMessage(listener: (message: GeoSpecPoolWorkerMessage) => void): void;
|
|
78
78
|
onExit(listener: (details: {
|
|
79
79
|
unexpected: boolean;
|
|
80
80
|
message?: string;
|
|
81
81
|
}) => void): void;
|
|
82
|
-
/** Hard-stop the worker thread (
|
|
82
|
+
/** Hard-stop the worker thread (the watchdog primitive). */
|
|
83
83
|
terminate(): Promise<void> | void;
|
|
84
84
|
};
|
|
85
|
-
//#endregion
|
|
86
|
-
export { GeoSpecPoolHostMessage, GeoSpecPoolShard, GeoSpecPoolWorkerHandle, GeoSpecPoolWorkerMessage };
|
|
85
|
+
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../types.mjs";
|
|
2
1
|
import { GeoSpecRunner } from "../worker/runner-types.mjs";
|
|
3
2
|
import { GeoSpecPoolWorkerHandle } from "./pool-messages.mjs";
|
|
4
3
|
import { ShardTimings } from "./shard-timings.mjs";
|
|
@@ -8,7 +7,7 @@ import { ShardTimings } from "./shard-timings.mjs";
|
|
|
8
7
|
*
|
|
9
8
|
* @public
|
|
10
9
|
*/
|
|
11
|
-
type GeoSpecPoolOptions = {
|
|
10
|
+
export type GeoSpecPoolOptions = {
|
|
12
11
|
/** Spawn one worker running `startGeoSpecPoolWorkerHost`. */
|
|
13
12
|
createWorker: () => GeoSpecPoolWorkerHandle | Promise<GeoSpecPoolWorkerHandle>;
|
|
14
13
|
/** Optional one-time worker initialization performed after its ready signal. */
|
|
@@ -19,7 +18,7 @@ type GeoSpecPoolOptions = {
|
|
|
19
18
|
workers: number;
|
|
20
19
|
/** Optional scheduling telemetry. Absent = declared order, no memory class. */
|
|
21
20
|
timings?: ShardTimings;
|
|
22
|
-
/** Per-shard non-verdict watchdog, milliseconds
|
|
21
|
+
/** Per-shard non-verdict watchdog, milliseconds. */
|
|
23
22
|
shardTimeout?: number;
|
|
24
23
|
/** Split files whose recorded duration exceeds this. Milliseconds. */
|
|
25
24
|
splitThreshold?: number;
|
|
@@ -31,6 +30,5 @@ type GeoSpecPoolOptions = {
|
|
|
31
30
|
* @returns The runner lifecycle surface.
|
|
32
31
|
* @public
|
|
33
32
|
*/
|
|
34
|
-
declare const createGeoSpecPoolRunner: (options: GeoSpecPoolOptions) => GeoSpecRunner;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { GeoSpecPoolOptions, createGeoSpecPoolRunner };
|
|
33
|
+
export declare const createGeoSpecPoolRunner: (options: GeoSpecPoolOptions) => GeoSpecRunner;
|
|
34
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{geoSpecTimeoutCode as e}from"../timeout-codes.mjs";import{createNoMatchingGeoSpecTestsIssue as t}from"../worker/no-matching-tests-issue.mjs";import{accumulateFileResult as n}from"../worker/serial-runner.mjs";import{createRunnerEventChannel as r}from"./events.mjs";import{filesToSplit as i,planShards as a,selectShard as o}from"./shard-planner.mjs";import{assertRootedPath as s}from"@taucad/runtime/kernel";const c=(t,n)=>({code:e.shard,message:`GeoSpec shard '${t}' exceeded the ${n} ms non-verdict watchdog and its worker was terminated: infrastructure failure, not a geometry verdict.`,severity:`error`,type:`runtime`}),l=(e,t=`GEOSPEC_SHARD_FAILED`)=>({success:!1,issues:[{code:t,message:e,severity:`error`,type:`runtime`}]}),u=e=>({requestedFiles:[...e],completedFiles:[],notRunFiles:[...e],discoveryComplete:!1,discovered:0,selected:0,completed:0,passed:0,failed:0,unsupported:0,inconclusive:0,skipped:0,notRun:0,cancelled:!1,bailed:!1}),d=e=>{let t=`complete`,n=new Map;for(let r of e){r.lineage?.status===`mixed`?t=`mixed`:r.lineage?.status!==`complete`&&t!==`mixed`&&(t=`unavailable`);let e=r.lineage?.loads.flatMap(({evidence:e})=>{let t=e?.artifacts[0];return e?.exportOptions===void 0?[...(e?.artifacts??[]).flatMap(e=>e.sourcePath===void 0?[]:[{[e.sourcePath]:`sha256:${e.sha256}`}]),...e?.sourcePath===void 0||t===void 0?[]:[{[e.sourcePath]:`sha256:${t.sha256}`}]]:[]})??[];for(let i of[...r.lineage?.modules.map(e=>e.files)??[],...e,...r.lineage?.loads.map(e=>e.evidence?.sourceRevision?.files??{})??[]])for(let[e,r]of Object.entries(i))n.has(e)&&n.get(e)!==r&&(t=`mixed`),n.set(e,r)}return t},f=e=>{let t,n,r,i=()=>n===void 0?void 0:Object.assign(Error(n),r===void 0?{}:{code:r}),a,o=new Promise(e=>{a=e}),s,c,l=new Promise((e,t)=>{s=e,c=t});l.catch(()=>void 0);let u=!1,d=!1,f,p,m=new Promise((e,t)=>{f=e,p=t});m.catch(()=>void 0);let h=e=>{let n=t;t=void 0,n?.(e)};return e.onMessage(e=>{switch(e.type){case`ready`:a?.();break;case`initialized`:u?(u=!1,s?.()):d?f?.():s?.();break;case`initialization-error`:n=e.message,r=e.code,a?.(),c?.(i()),d&&p?.(i());break;case`shard-complete`:h({type:`complete`,message:e});break;case`tests-listed`:h({type:`listed`,names:e.names});break;case`shard-error`:case`list-error`:h({type:`error`,message:e.message})}}),e.onExit(e=>{n??=e.message??`the pool worker exited unexpectedly`,a?.(),c?.(i()),p?.(i()),h({type:`error`,message:n})}),{ready:o,initialized:l,shutdown:m,beginInitialization:()=>{u=!0},beginShutdown:()=>{d=!0},exited:()=>n,exitError:i,settle:async e=>n===void 0?new Promise(e=>{t=e}):{type:`error`,message:n}}},p=p=>{let h={closed:!1},g=()=>h.closed,_=()=>h.aborted,v=[],y=new WeakMap,b=r(),x=!1,S,C,w=async e=>{if(S!==void 0)return S;let t=(async()=>{for(;v.length<e&&!g();){let e=await p.createWorker();if(g()){await e.terminate();return}y.set(e,f(e)),v.push({handle:e,busy:!1,dead:!1,initialized:!1})}})();S=t;try{await t}finally{S===t&&(S=void 0)}},T=async(e,t,n)=>{let r=y.get(e.handle).settle(n.id);if(t(),p.shardTimeout===void 0)return r;let i=p.shardTimeout,a,o=new Promise(e=>{a=setTimeout(()=>{e({type:`timeout`,message:c(n.file,i).message})},i)});try{let t=await Promise.race([r,o]);return t.type===`timeout`&&(e.dead=!0,await e.handle.terminate()),t}finally{clearTimeout(a)}},E=()=>C===void 0?(h.closed=!0,h.aborted=`closed`,C=(async()=>{try{await S}catch{}let e=v.filter(e=>!e.dead&&y.get(e.handle)?.exited()===void 0);try{for(let t of e)y.get(t.handle).beginShutdown(),t.handle.postMessage({type:`shutdown`});p.gracefulShutdown&&await Promise.all(e.map(async e=>{let t=y.get(e.handle),n;try{await Promise.race([t.shutdown,new Promise((e,t)=>{n=setTimeout(()=>{t(Error(`Native pool shutdown timed out.`))},1e4)})])}finally{clearTimeout(n)}}))}finally{await Promise.all(v.map(async e=>e.handle.terminate())),v.length=0,b.emit({type:`close`}),b.clear()}})(),C):C;return{async run(r){let c=u(r.files);if(new Set(r.files).size!==r.files.length)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_DUPLICATE_FILES`,message:`GeoSpec requested files must be unique.`,severity:`error`,type:`runtime`}]};if(h.closed)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_RUNNER_CLOSED`,message:`GeoSpec runner is closed.`,severity:`error`,type:`runtime`}]};if(x)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_RUNNER_BUSY`,message:`GeoSpec runner already has an active run.`,severity:`error`,type:`runtime`}]};x=!0;try{delete h.aborted;let c=r.files.map(s),f=performance.now();b.emit({type:`run-start`,files:c});try{if(await w(Math.max(1,p.workers)),g())throw Error(`GeoSpec pool closed during worker creation.`);if(await Promise.all(v.map(async e=>y.get(e.handle).ready)),g())throw Error(`GeoSpec pool closed during worker initialization.`);for(let e of v){let t=y.get(e.handle).exitError();if(t!==void 0)throw t}if(p.initializeWorker&&await Promise.all(v.map(async e=>{if(e.initialized)return;let t=y.get(e.handle);t.beginInitialization(),await p.initializeWorker(e.handle),await t.initialized,e.initialized=!0})),g())throw Error(`GeoSpec pool closed during worker initialization.`)}catch(e){throw await E(),e}let x={passed:0,failed:0,selectedTests:0},S=[],C=[],D=new Map,O=c.length<v.length?[...new Set([...c,...i(c,p.timings,p.splitThreshold)])]:i(c,p.timings,p.splitThreshold);for(let[e,t]of O.entries()){let n=v[e%v.length],i={id:-1-e,file:t},a=await T(n,()=>{n.handle.postMessage({type:`list-tests`,shardId:i.id,file:t,...r.testTimeout===void 0?{}:{testTimeout:r.testTimeout}})},i);a.type===`listed`&&a.names.length>1&&new Set(a.names).size===a.names.length&&D.set(t,a.names)}let k=a({files:c,splitTests:D,...p.timings?{timings:p.timings}:{}}),A=new Map,j=new Map(c.map(e=>[e,k.filter(t=>t.file===e).length])),M=new Map,N=!1,P=0,F=async t=>{for(;!t.dead;){if(_()!==void 0)return;let n=o({pending:k,workerLoadKey:t.loadKey,heavyRunning:P});if(n===void 0)return;let[i]=k.splice(n,1);i.memoryClass===`heavy`&&(P+=1),t.busy=!0,b.emit({type:`file-start`,file:i.file});let a=performance.now(),s=await T(t,()=>{t.handle.postMessage({type:`run-shard`,shard:{id:i.id,file:i.file,...i.testNamePattern===void 0?{}:{testNamePattern:i.testNamePattern}},...r.testNamePattern===void 0?{}:{testNamePattern:String(r.testNamePattern)},...r.testTimeout===void 0?{}:{testTimeout:r.testTimeout}})},i),c=performance.now()-a;t.busy=!1,i.memoryClass===`heavy`&&--P;let u=s.type===`complete`?s.message.result:s.type===`timeout`?l(s.message,e.shard):l(s.type===`listed`?`the pool worker answered a shard with a test list`:s.message);s.type===`complete`&&(t.loadKey=s.message.primaryLoadKey??t.loadKey,p.timings?.record(i.timingKey,{durationMs:s.message.durationMs,peakRssBytes:s.message.workerMemoryBytes??0})),s.type===`timeout`&&C.push({code:e.shard,message:s.message,severity:`error`,type:`runtime`});let d=A.get(i.file);A.set(i.file,{result:d===void 0?u:m(d.result,u),durationMs:(d?.durationMs??0)+c}),M.set(i.file,(M.get(i.file)??0)+1),b.emit({type:`file-complete`,file:i.file,result:u,durationMs:c,...s.type===`complete`&&s.message.primaryLoadKey!==void 0?{primaryLoadKey:s.message.primaryLoadKey}:{},...s.type===`complete`&&s.message.workerMemoryBytes!==void 0?{workerMemoryBytes:s.message.workerMemoryBytes}:{}});let f=!u.success||!u.passed;if(r.bail===!0&&f){N=!0,k.length=0;return}}};await Promise.all(v.map(async e=>F(e))),p.timings?.save();let I=_();I!==void 0&&(C.push({code:`GEOSPEC_RUNNER_ABORTED`,message:I.length>0?`GeoSpec run aborted: ${I}`:`GeoSpec run aborted.`,severity:`error`,type:`runtime`}),x.failed+=1,b.emit({type:`abort`,reason:I}));for(let e of c){let t=A.get(e);t!==void 0&&(S.push({file:e,result:t.result,durationMs:t.durationMs}),n(x,t.result))}x.selectedTests===0&&x.failed===0&&(C.push(t()),x.failed+=1);let L=u(r.files);L.completedFiles=c.filter(e=>M.get(e)===j.get(e)),L.notRunFiles=c.filter(e=>!L.completedFiles.includes(e)),L.cancelled=I!==void 0,L.bailed=N,L.discoveryComplete=L.notRunFiles.length===0&&S.every(({result:e})=>e.success&&e.accounting!==void 0);for(let{result:e}of S)if(e.accounting!==void 0)for(let t of[`discovered`,`selected`,`completed`,`passed`,`failed`,`unsupported`,`inconclusive`,`skipped`,`notRun`])L[t]+=e.accounting[t];let R=d(S.map(({result:e})=>e)),z={success:L.discoveryComplete&&S.every(({result:e})=>e.success&&e.passed)&&R===`complete`&&x.failed===0&&C.length===0,passed:x.passed,failed:x.failed,selectedTests:x.selectedTests,files:S,accounting:L,lineageStatus:R,...C.length>0?{issues:C}:{},durationMs:performance.now()-f};return b.emit({type:`run-complete`,result:z}),z}finally{x=!1}},on:b.on,abort(e){h.aborted=e??`requested`},close:E}},m=(e,t)=>{let n=[...e.tests??[],...t.tests??[]].sort((e,t)=>(e.ordinal??1/0)-(t.ordinal??1/0)),r={status:d([e,t]),modules:[...e.lineage?.modules??[],...t.lineage?.modules??[]],loads:[...e.lineage?.loads??[],...t.lineage?.loads??[]]},i,a=n.map(e=>e.ordinal),o=e.accounting?.discovered;if(o!==void 0&&o===t.accounting?.discovered&&a.every(e=>e!==void 0&&Number.isSafeInteger(e)&&e>=0&&e<o)&&new Set(a).size===n.length){let e=e=>n.filter(t=>t.status===e).length;i={discovered:o,selected:n.length,completed:n.filter(e=>e.status!==`not-run`&&e.status!==`skipped`).length,passed:e(`passed`),failed:e(`failed`),unsupported:e(`unsupported`),inconclusive:e(`inconclusive`),skipped:e(`skipped`),notRun:Math.max(0,o-n.length)+e(`not-run`)}}let s={tests:n,lineage:r,...i===void 0?{}:{accounting:i}};return!e.success||!t.success?{success:!1,issues:[...e.success?[]:e.issues,...t.success?[]:t.issues],...e.bundle===void 0&&t.bundle===void 0?{}:{bundle:e.bundle??t.bundle},...s}:{success:!0,passed:e.passed&&t.passed&&i!==void 0&&r.status===`complete`,...s,bundle:e.bundle}};export{p as createGeoSpecPoolRunner,m as mergeShardResults};
|
|
1
|
+
import{geoSpecTimeoutCode as e}from"../timeout-codes.mjs";import{assertRootedPath as t}from"../../support/path.mjs";import{createNoMatchingGeoSpecTestsIssue as n}from"../worker/no-matching-tests-issue.mjs";import{accumulateFileResult as r}from"../worker/serial-runner.mjs";import{createRunnerEventChannel as i}from"./events.mjs";import{filesToSplit as a,planShards as o,selectShard as s}from"./shard-planner.mjs";const c=(t,n)=>({code:e.shard,message:`GeoSpec shard '${t}' exceeded the ${n} ms non-verdict watchdog and its worker was terminated: infrastructure failure, not a geometry verdict.`,severity:`error`,type:`runtime`}),l=(e,t=`GEOSPEC_SHARD_FAILED`)=>({success:!1,issues:[{code:t,message:e,severity:`error`,type:`runtime`}]}),u=e=>({requestedFiles:[...e],completedFiles:[],notRunFiles:[...e],discoveryComplete:!1,discovered:0,selected:0,completed:0,passed:0,failed:0,unsupported:0,inconclusive:0,skipped:0,notRun:0,cancelled:!1,bailed:!1}),d=e=>{let t=`complete`,n=/* @__PURE__ */ new Map;for(let r of e){r.lineage?.status===`mixed`?t=`mixed`:r.lineage?.status!==`complete`&&t!==`mixed`&&(t=`unavailable`);let e=r.lineage?.loads.flatMap(({evidence:e})=>{let t=e?.artifacts[0];return e?.exportOptions===void 0?[...(e?.artifacts??[]).flatMap(e=>e.sourcePath===void 0?[]:[{[e.sourcePath]:`sha256:${e.sha256}`}]),...e?.sourcePath===void 0||t===void 0?[]:[{[e.sourcePath]:`sha256:${t.sha256}`}]]:[]})??[];for(let i of[...r.lineage?.modules.map(e=>e.files)??[],...e,...r.lineage?.loads.map(e=>e.evidence?.sourceRevision?.files??{})??[]])for(let[e,r]of Object.entries(i))n.has(e)&&n.get(e)!==r&&(t=`mixed`),n.set(e,r)}return t},f=e=>{let t,n,r,i=()=>n===void 0?void 0:Object.assign(Error(n),r===void 0?{}:{code:r}),a,o=new Promise(e=>{a=e}),s,c,l=new Promise((e,t)=>{s=e,c=t});l.catch(()=>void 0);let u=!1,d=!1,f,p,m=new Promise((e,t)=>{f=e,p=t});m.catch(()=>void 0);let h=e=>{let n=t;t=void 0,n?.(e)};return e.onMessage(e=>{switch(e.type){case`ready`:a?.();break;case`initialized`:u?(u=!1,s?.()):d?f?.():s?.();break;case`initialization-error`:n=e.message,r=e.code,a?.(),c?.(i()),d&&p?.(i());break;case`shard-complete`:h({type:`complete`,message:e});break;case`tests-listed`:h({type:`listed`,names:e.names});break;case`shard-error`:case`list-error`:h({type:`error`,message:e.message})}}),e.onExit(e=>{n??=e.message??`the pool worker exited unexpectedly`,a?.(),c?.(i()),p?.(i()),h({type:`error`,message:n})}),{ready:o,initialized:l,shutdown:m,beginInitialization:()=>{u=!0},beginShutdown:()=>{d=!0},exited:()=>n,exitError:i,settle:async e=>n===void 0?new Promise(e=>{t=e}):{type:`error`,message:n}}},p=p=>{let h={closed:!1},g=()=>h.closed,_=()=>h.aborted,v=[],y=/* @__PURE__ */ new WeakMap,b=i(),x=!1,S,C,w=async e=>{if(S!==void 0)return S;let t=(async()=>{for(;v.length<e&&!g();){let e=await p.createWorker();if(g()){await e.terminate();return}y.set(e,f(e)),v.push({handle:e,busy:!1,dead:!1,initialized:!1})}})();S=t;try{await t}finally{S===t&&(S=void 0)}},T=async(e,t,n)=>{let r=y.get(e.handle).settle(n.id);if(t(),p.shardTimeout===void 0)return r;let i=p.shardTimeout,a,o=new Promise(e=>{a=setTimeout(()=>{e({type:`timeout`,message:c(n.file,i).message})},i)});try{let t=await Promise.race([r,o]);return t.type===`timeout`&&(e.dead=!0,await e.handle.terminate()),t}finally{clearTimeout(a)}},E=()=>(C===void 0&&(h.closed=!0,h.aborted=`closed`,C=(async()=>{try{await S}catch{}let e=v.filter(e=>!e.dead&&y.get(e.handle)?.exited()===void 0);try{for(let t of e)y.get(t.handle).beginShutdown(),t.handle.postMessage({type:`shutdown`});p.gracefulShutdown&&await Promise.all(e.map(async e=>{let t=y.get(e.handle),n;try{await Promise.race([t.shutdown,new Promise((e,t)=>{n=setTimeout(()=>{t(/* @__PURE__ */ Error(`Native pool shutdown timed out.`))},1e4)})])}finally{clearTimeout(n)}}))}finally{await Promise.all(v.map(async e=>e.handle.terminate())),v.length=0,b.emit({type:`close`}),b.clear()}})()),C);return{async run(i){let c=u(i.files);if(new Set(i.files).size!==i.files.length)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_DUPLICATE_FILES`,message:`GeoSpec requested files must be unique.`,severity:`error`,type:`runtime`}]};if(h.closed)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_RUNNER_CLOSED`,message:`GeoSpec runner is closed.`,severity:`error`,type:`runtime`}]};if(x)return{success:!1,passed:0,failed:1,selectedTests:0,files:[],accounting:c,lineageStatus:`unavailable`,issues:[{code:`GEOSPEC_RUNNER_BUSY`,message:`GeoSpec runner already has an active run.`,severity:`error`,type:`runtime`}]};x=!0;try{delete h.aborted;let c=i.files.map(t),f=performance.now();b.emit({type:`run-start`,files:c});try{if(await w(Math.max(1,p.workers)),g())throw Error(`GeoSpec pool closed during worker creation.`);if(await Promise.all(v.map(async e=>y.get(e.handle).ready)),g())throw Error(`GeoSpec pool closed during worker initialization.`);for(let e of v){let t=y.get(e.handle).exitError();if(t!==void 0)throw t}if(p.initializeWorker&&await Promise.all(v.map(async e=>{if(e.initialized)return;let t=y.get(e.handle);t.beginInitialization(),await p.initializeWorker(e.handle),await t.initialized,e.initialized=!0})),g())throw Error(`GeoSpec pool closed during worker initialization.`)}catch(e){throw await E(),e}let x={passed:0,failed:0,selectedTests:0},S=[],C=[],D=/* @__PURE__ */ new Map,O=c.length<v.length?[.../* @__PURE__ */ new Set([...c,...a(c,p.timings,p.splitThreshold)])]:a(c,p.timings,p.splitThreshold);for(let[e,t]of O.entries()){let n=v[e%v.length],r={id:-1-e,file:t},a=await T(n,()=>{n.handle.postMessage({type:`list-tests`,shardId:r.id,file:t,...i.testTimeout===void 0?{}:{testTimeout:i.testTimeout}})},r);a.type===`listed`&&a.names.length>1&&new Set(a.names).size===a.names.length&&D.set(t,a.names)}let k=o({files:c,splitTests:D,...p.timings?{timings:p.timings}:{}}),A=/* @__PURE__ */ new Map,j=new Map(c.map(e=>[e,k.filter(t=>t.file===e).length])),M=/* @__PURE__ */ new Map,N=!1,P=0,F=async t=>{for(;!t.dead;){if(_()!==void 0)return;let n=s({pending:k,workerLoadKey:t.loadKey,heavyRunning:P});if(n===void 0)return;let[r]=k.splice(n,1);r.memoryClass===`heavy`&&(P+=1),t.busy=!0,b.emit({type:`file-start`,file:r.file});let a=performance.now(),o=await T(t,()=>{t.handle.postMessage({type:`run-shard`,shard:{id:r.id,file:r.file,...r.testNamePattern===void 0?{}:{testNamePattern:r.testNamePattern}},...i.testNamePattern===void 0?{}:{testNamePattern:String(i.testNamePattern)},...i.testTimeout===void 0?{}:{testTimeout:i.testTimeout}})},r),c=performance.now()-a;t.busy=!1,r.memoryClass===`heavy`&&--P;let u=o.type===`complete`?o.message.result:o.type===`timeout`?l(o.message,e.shard):l(o.type===`listed`?`the pool worker answered a shard with a test list`:o.message);o.type===`complete`&&(t.loadKey=o.message.primaryLoadKey??t.loadKey,p.timings?.record(r.timingKey,{durationMs:o.message.durationMs,peakRssBytes:o.message.workerMemoryBytes??0})),o.type===`timeout`&&C.push({code:e.shard,message:o.message,severity:`error`,type:`runtime`});let d=A.get(r.file);A.set(r.file,{result:d===void 0?u:m(d.result,u),durationMs:(d?.durationMs??0)+c}),M.set(r.file,(M.get(r.file)??0)+1),b.emit({type:`file-complete`,file:r.file,result:u,durationMs:c,...o.type===`complete`&&o.message.primaryLoadKey!==void 0?{primaryLoadKey:o.message.primaryLoadKey}:{},...o.type===`complete`&&o.message.workerMemoryBytes!==void 0?{workerMemoryBytes:o.message.workerMemoryBytes}:{}});let f=!u.success||!u.passed;if(i.bail===!0&&f){N=!0,k.length=0;return}}};await Promise.all(v.map(async e=>F(e))),p.timings?.save();let I=_();I!==void 0&&(C.push({code:`GEOSPEC_RUNNER_ABORTED`,message:I.length>0?`GeoSpec run aborted: ${I}`:`GeoSpec run aborted.`,severity:`error`,type:`runtime`}),x.failed+=1,b.emit({type:`abort`,reason:I}));for(let e of c){let t=A.get(e);t!==void 0&&(S.push({file:e,result:t.result,durationMs:t.durationMs}),r(x,t.result))}x.selectedTests===0&&x.failed===0&&(C.push(n()),x.failed+=1);let L=u(i.files);L.completedFiles=c.filter(e=>M.get(e)===j.get(e)),L.notRunFiles=c.filter(e=>!L.completedFiles.includes(e)),L.cancelled=I!==void 0,L.bailed=N,L.discoveryComplete=L.notRunFiles.length===0&&S.every(({result:e})=>e.success&&e.accounting!==void 0);for(let{result:e}of S)if(e.accounting!==void 0)for(let t of[`discovered`,`selected`,`completed`,`passed`,`failed`,`unsupported`,`inconclusive`,`skipped`,`notRun`])L[t]+=e.accounting[t];let R=d(S.map(({result:e})=>e)),z={success:L.discoveryComplete&&S.every(({result:e})=>e.success&&e.passed)&&R===`complete`&&x.failed===0&&C.length===0,passed:x.passed,failed:x.failed,selectedTests:x.selectedTests,files:S,accounting:L,lineageStatus:R,...C.length>0?{issues:C}:{},durationMs:performance.now()-f};return b.emit({type:`run-complete`,result:z}),z}finally{x=!1}},on:b.on,abort(e){h.aborted=e??`requested`},close:E}},m=(e,t)=>{let n=[...e.tests??[],...t.tests??[]].sort((e,t)=>(e.ordinal??1/0)-(t.ordinal??1/0)),r={status:d([e,t]),modules:[...e.lineage?.modules??[],...t.lineage?.modules??[]],loads:[...e.lineage?.loads??[],...t.lineage?.loads??[]]},i,a=n.map(e=>e.ordinal),o=e.accounting?.discovered;if(o!==void 0&&o===t.accounting?.discovered&&a.every(e=>e!==void 0&&Number.isSafeInteger(e)&&e>=0&&e<o)&&new Set(a).size===n.length){let e=e=>n.filter(t=>t.status===e).length;i={discovered:o,selected:n.length,completed:n.filter(e=>e.status!==`not-run`&&e.status!==`skipped`).length,passed:e(`passed`),failed:e(`failed`),unsupported:e(`unsupported`),inconclusive:e(`inconclusive`),skipped:e(`skipped`),notRun:Math.max(0,o-n.length)+e(`not-run`)}}let s={tests:n,lineage:r,...i===void 0?{}:{accounting:i}};return!e.success||!t.success?{success:!1,issues:[...e.success?[]:e.issues,...t.success?[]:t.issues],...e.bundle===void 0&&t.bundle===void 0?{}:{bundle:e.bundle??t.bundle},...s}:{success:!0,passed:e.passed&&t.passed&&i!==void 0&&r.status===`complete`,...s,bundle:e.bundle}};export{p as createGeoSpecPoolRunner,m as mergeShardResults};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
type ShardTiming = {
|
|
14
|
+
export type ShardTiming = {
|
|
15
15
|
/** Wall duration of the last recorded run, in milliseconds. */
|
|
16
16
|
durationMs: number;
|
|
17
17
|
/** Highest RSS observed for this shard, in bytes. Monotonic. */
|
|
@@ -22,7 +22,7 @@ type ShardTiming = {
|
|
|
22
22
|
*
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
type ShardTimings = {
|
|
25
|
+
export type ShardTimings = {
|
|
26
26
|
/** Merge one observation. Peak RSS only ever grows. */
|
|
27
27
|
record(shard: string, timing: ShardTiming): void;
|
|
28
28
|
/** The hint for one shard, or `undefined` when unknown. */
|
|
@@ -32,5 +32,4 @@ type ShardTimings = {
|
|
|
32
32
|
/** Persist the table. Failure is silent: telemetry never fails a run. */
|
|
33
33
|
save(): void;
|
|
34
34
|
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { ShardTiming, ShardTimings };
|
|
35
|
+
//#endregion
|
|
@@ -7,7 +7,7 @@ import { GeoSpecPoolHostMessage, GeoSpecPoolWorkerMessage } from "./pool-message
|
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
type GeoSpecPoolWorkerHostOptions = {
|
|
10
|
+
export type GeoSpecPoolWorkerHostOptions = {
|
|
11
11
|
/** Filesystem containing the project and test modules. */
|
|
12
12
|
filesystem: GeoSpecRunnerOptions['filesystem'];
|
|
13
13
|
/** Native assertion client shared with this worker's model admissions. */
|
|
@@ -16,11 +16,13 @@ type GeoSpecPoolWorkerHostOptions = {
|
|
|
16
16
|
nativeModelLoader: ManagedGeoSpecNativeModelLoader;
|
|
17
17
|
/** Additional in-memory modules made available to the VM. */
|
|
18
18
|
builtinModules?: GeoSpecRunnerOptions['builtinModules'];
|
|
19
|
+
/** Module VM factory for every shard; defaults to GeoSpec's plain VM. */
|
|
20
|
+
createModuleVm?: GeoSpecRunnerOptions['createModuleVm'];
|
|
19
21
|
/** Post a message to the pool host. */
|
|
20
22
|
postMessage: (message: GeoSpecPoolWorkerMessage) => void;
|
|
21
23
|
/** Subscribe to pool-host messages. */
|
|
22
24
|
onHostMessage: (listener: (message: GeoSpecPoolHostMessage) => void) => void;
|
|
23
|
-
/** Sample this worker's resident memory in bytes
|
|
25
|
+
/** Sample this worker's resident memory in bytes, as telemetry; optional. */
|
|
24
26
|
measureMemoryBytes?: () => number | undefined;
|
|
25
27
|
/** Release platform resources on shutdown, after the native subjects are released. */
|
|
26
28
|
onShutdown?: () => Promise<void> | void;
|
|
@@ -31,6 +33,5 @@ type GeoSpecPoolWorkerHostOptions = {
|
|
|
31
33
|
* @param options - Worker filesystem, native engine, and message plumbing.
|
|
32
34
|
* @public
|
|
33
35
|
*/
|
|
34
|
-
declare const startGeoSpecPoolWorkerHost: (options: GeoSpecPoolWorkerHostOptions) => void;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { GeoSpecPoolWorkerHostOptions, startGeoSpecPoolWorkerHost };
|
|
36
|
+
export declare const startGeoSpecPoolWorkerHost: (options: GeoSpecPoolWorkerHostOptions) => void;
|
|
37
|
+
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{executeGeoSpecFile as e}from"../worker/serial-runner.mjs";import{sanitizePoolResult as t}from"./transport.mjs";const n=e=>e instanceof Error?e.message:String(e),r=e=>e.success?e.tests.map(e=>[...e.suite,e.name].join(` > `)):[],i=i=>{let a={filesystem:i.filesystem,nativeAssertions:i.nativeAssertions,nativeModelLoader:i.nativeModelLoader,...i.builtinModules?{builtinModules:i.builtinModules}:{}},o
|
|
1
|
+
import{executeGeoSpecFile as e}from"../worker/serial-runner.mjs";import{sanitizePoolResult as t}from"./transport.mjs";const n=e=>e instanceof Error?e.message:String(e),r=e=>e.success?e.tests.map(e=>[...e.suite,e.name].join(` > `)):[],i=i=>{let a={filesystem:i.filesystem,nativeAssertions:i.nativeAssertions,nativeModelLoader:i.nativeModelLoader,...i.builtinModules?{builtinModules:i.builtinModules}:{},...i.createModuleVm?{createModuleVm:i.createModuleVm}:{}},o=/* @__PURE__ */ new Map,s=async()=>{await i.nativeModelLoader.releaseAll()},c=async(e,t)=>{let n=e;try{await s()}catch(r){e.type!==`shard-error`&&e.type!==`list-error`&&(n=t(r))}try{i.postMessage(n)}catch(e){i.postMessage(t(e))}},l=Promise.resolve(),u=e=>{let t=l;l=(async()=>{try{await t}catch{}try{await e()}catch(e){try{i.postMessage({type:`initialization-error`,message:n(e)})}catch{}}})()},d=async l=>{if(l.type===`initialize`){i.postMessage({type:`initialized`});return}if(l.type===`shutdown`){o.clear();let e=!1,t;try{await s()}catch(n){e=!0,t=n}try{await i.onShutdown?.()}catch(n){e||(e=!0,t=n)}if(e){i.postMessage({type:`initialization-error`,message:n(t)});return}i.postMessage({type:`initialized`});return}if(l.type===`list-tests`){let t=e=>({type:`list-error`,shardId:l.shardId,file:l.file,message:n(e)}),i;try{let t=await e({runner:a,file:l.file,collectOnly:!0,bundleCache:o,...l.testTimeout===void 0?{}:{testTimeout:l.testTimeout}});i={type:`tests-listed`,shardId:l.shardId,file:l.file,names:r(t)}}catch(e){i=t(e)}await c(i,t);return}let{shard:u}=l;i.postMessage({type:`file-start`,shardId:u.id,file:u.file});let d=performance.now(),f=e=>({type:`shard-error`,shardId:u.id,file:u.file,message:n(e)}),p;try{let n=await e({runner:a,file:u.file,bundleCache:o,...u.testNamePattern===void 0?l.testNamePattern===void 0?{}:{testNamePattern:l.testNamePattern}:{testNamePattern:u.testNamePattern},...l.testTimeout===void 0?{}:{testTimeout:l.testTimeout}}),r=i.measureMemoryBytes?.();p={type:`shard-complete`,shardId:u.id,file:u.file,result:t(n),durationMs:performance.now()-d,...r===void 0?{}:{workerMemoryBytes:r}}}catch(e){p=f(e)}await c(p,f)};i.onHostMessage(e=>{u(async()=>d(e))}),i.postMessage({type:`ready`})};export{i as startGeoSpecPoolWorkerHost};
|
|
@@ -8,6 +8,5 @@ import { GeoSpecRunResult, RunGeoSpecModuleOptions } from "./types.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
declare function runGeoSpecModule(options: RunGeoSpecModuleOptions): Promise<GeoSpecRunResult>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { runGeoSpecModule };
|
|
11
|
+
export declare function runGeoSpecModule(options: RunGeoSpecModuleOptions): Promise<GeoSpecRunResult>;
|
|
12
|
+
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bindGeoSpecSubject as e,rawSubjectResidency as t,resolveGeoSpecSubject as n}from"../model/subject.mjs";import{createGeoSpecAssertionClient as r}from"../assertion-client/client.mjs";import{GeoSpecModelLoadError as i}from"../model/errors.mjs";import{compileGeoSpecTestNamePattern as a,filterGeoSpecTests as o}from"./filter.mjs";import{createCollector as s}from"./collector.mjs";import{defineConfigBuiltinCode as c}from"../config/define-config.mjs";import{
|
|
1
|
+
import{bindGeoSpecSubject as e,rawSubjectResidency as t,resolveGeoSpecSubject as n}from"../model/subject.mjs";import{createGeoSpecAssertionClient as r}from"../assertion-client/client.mjs";import{GeoSpecModelLoadError as i}from"../model/errors.mjs";import{compileGeoSpecTestNamePattern as a,filterGeoSpecTests as o}from"./filter.mjs";import{createCollector as s}from"./collector.mjs";import{defineConfigBuiltinCode as c}from"../config/define-config.mjs";import{createPlainModuleVm as l}from"../vm/plain-module-vm.mjs";import{sha256Bytes as u}from"../support/hash.mjs";const d=`__GEOSPEC_RUN_BINDINGS__`,f=globalThis,p=()=>`geospec-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,m=e=>JSON.stringify(Object.entries(e.builtinModules??{}).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.version,t.globalName,t.code])),h=(e,t)=>e.byteLength===t.byteLength&&e.every((e,n)=>e===t[n]),g=(e,t)=>e instanceof Uint8Array&&t instanceof Uint8Array?h(e,t):e===t,_=async(e,{question:t,path:n})=>t===`exists`?e.exists(n):t===`utf8`?e.readFile(n,`utf8`):e.readFile(n),v=async(e,t)=>(await Promise.all(t.map(async t=>{try{return g(await _(e,t),t.answer)}catch{return!1}}))).every(Boolean),y=e=>{let t=/* @__PURE__ */ new Map,n=!0,r=async(e,r,i)=>{try{let a=await i,o=t.get(`${e}:${r}`);return o===void 0?t.set(`${e}:${r}`,{question:e,path:r,answer:a instanceof Uint8Array?Uint8Array.from(a):a}):n&&=g(o.answer,a),a}catch(e){throw n=!1,e}};return{filesystem:{exists:async t=>r(`exists`,t,e.exists(t)),readFile:(async(t,n)=>n===`utf8`?r(`utf8`,t,e.readFile(t,`utf8`)):r(`bytes`,t,e.readFile(t))),writeFile:async(t,n)=>e.writeFile(t,n),ensureDir:async t=>e.ensureDir(t)},reads:()=>n?[...t.values()]:void 0,observed:()=>[...t.values()]}},b=async e=>{let t=e.bundleCache?.get(e.entryPath);if(t!==void 0&&t.builtinIdentity===m(e)&&await v(e.filesystem,t.bundlerReads))return t},x=()=>{let e=f[d];if(e)return e;let t=/* @__PURE__ */ new Map;return f[d]=t,t},S=e=>`
|
|
2
2
|
const getRunBinding = () => {
|
|
3
3
|
const binding = globalThis.${d}?.get(${JSON.stringify(e)});
|
|
4
4
|
if (!binding) {
|
|
@@ -44,4 +44,4 @@ export const createModelLoader = (defaults = {}) => {
|
|
|
44
44
|
}
|
|
45
45
|
return factory(defaults);
|
|
46
46
|
};
|
|
47
|
-
`;async function T(h){let g=a(h.testNamePattern);if(!g.success)return{success:!1,issues:[g.issue]};let _=y(h.filesystem),v=await
|
|
47
|
+
`;async function T(h){let g=a(h.testNamePattern);if(!g.success)return{success:!1,issues:[g.issue]};let _=y(h.filesystem),v=await(h.createModuleVm??l)({filesystem:_.filesystem}),S=s({...h.onTestEvent===void 0?{}:{onTestEvent:h.onTestEvent},nativeAssertions:h.nativeAssertions}),T=await b(h),E=p(),D=x(),O=/* @__PURE__ */ new Set,k=[],A=async()=>{do{let e=[...O];await Promise.allSettled(e);for(let t of e)O.delete(t)}while(O.size>0)},j=h.nativeModelLoader,M=r(h.nativeAssertions),N=!0,P=j===void 0?void 0:n=>{let r=k.length,a=`${E}:load:${r+1}`;k.push({loadId:a,status:`unavailable`});let o=(async()=>{try{let i=await j(n),{load:o,...s}=i,c=t(i),l=o===void 0?void 0:{...structuredClone(o),loadId:a};return k[r]={loadId:a,status:l?.status??`unavailable`,subject:s,...l===void 0?{}:{evidence:l}},e({engine:h.nativeAssertions.engine,client:M,identity:s,...l===void 0?{}:{load:l},isLive:()=>N,...c===void 0?{}:{ensureResident:c}})}catch(e){throw k[r]={loadId:a,status:`failed`,error:e instanceof Error?e.message:String(e),...e instanceof i?{diagnostics:e.diagnostics}:{}},e}})();return O.add(o.catch(()=>void 0)),O.add(o),o};D.set(E,{collector:S,geoSpecModelLoadError:i,...P?{nativeModelLoader:P}:{},...P?{createModelLoader:t=>{if(t.engine!==void 0||t.readSource!==void 0)throw TypeError(`Authored VM model defaults cannot replace the admitting host.`);let r=0,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o,s=async i=>{let o=r,s=await P({...t,...i}),c=n(s);return c.lease!==void 0&&a.add(c.lease),e({...c,isLive:()=>c.isLive()&&r===o})},c=e=>{let t=s(e);return i.add(t),t},l=async()=>{do{let e=[...i];await Promise.allSettled(e);for(let t of e)i.delete(t)}while(i.size>0);r+=1;let e=[];for(let t of a)try{t.dispose(),a.delete(t)}catch(t){e.push(t)}if(e.length>0)throw AggregateError(e,`GeoSpec model scope disposal failed.`)};return Object.assign(c,{dispose(){return o??=l().finally(()=>{o=void 0}),o}})}}:{}}),v.registerModule(`geospec`,{version:`0.0.0-poc`,code:C(E)}),v.registerModule(`geospec/model`,{version:`0.0.0-poc`,code:w(E)}),v.registerModule(`geospec/config`,{version:`0.0.0-poc`,code:c});for(let[e,t]of Object.entries(h.builtinModules??{}))v.registerModule(e,t);try{let e=T?.bundle??await v.bundle(h.entryPath);if(!e.success)return{success:!1,issues:e.issues,bundle:e};let t=_.reads();h.bundleCache!==void 0&&T===void 0&&t!==void 0&&h.bundleCache.set(h.entryPath,{builtinIdentity:m(h),runToken:E,bundle:e,bundlerReads:t});let n=await v.execute(T===void 0?e.code:e.code.replaceAll(T.runToken,E)),r=async()=>{let t={},n=_.reads()!==void 0;for(let e of T?.bundlerReads??_.observed()){if(e.question===`exists`||typeof e.answer==`boolean`)continue;let r=await u(typeof e.answer==`string`?new TextEncoder().encode(e.answer):e.answer);n&&=t[e.path]===void 0||t[e.path]===`sha256:${r}`,t[e.path]=`sha256:${r}`}let r=new Map(Object.entries(t));for(let e of k){let{evidence:t}=e;for(let e of t?.exportOptions===void 0?t?.artifacts??[]:[])if(e.sourcePath!==void 0){let t=`sha256:${e.sha256}`;n&&=!r.has(e.sourcePath)||r.get(e.sourcePath)===t,r.set(e.sourcePath,t)}if(t?.sourcePath!==void 0&&t.exportOptions===void 0){let e=t.artifacts[0];if(e!==void 0){let i=`sha256:${e.sha256}`;n&&=!r.has(t.sourcePath)||r.get(t.sourcePath)===i,r.set(t.sourcePath,i)}}for(let[t,i]of Object.entries(e.evidence?.sourceRevision?.files??{}))n&&=!r.has(t)||r.get(t)===i,r.set(t,i)}return{status:n?k.some(e=>e.status!==`complete`)?`unavailable`:`complete`:`mixed`,modules:[{entryPath:h.entryPath,bundleSha256:await u(new TextEncoder().encode(T===void 0?e.code:e.code.replaceAll(T.runToken,E))),files:t,consistent:n}],loads:k}},i=e=>({discovered:S.tests.length,selected:e,completed:S.tests.filter(e=>e.status!==`not-run`&&e.status!==`skipped`).length,passed:S.tests.filter(e=>e.status===`passed`).length,failed:S.tests.filter(e=>e.status===`failed`).length,unsupported:S.tests.filter(e=>e.status===`unsupported`).length,inconclusive:S.tests.filter(e=>e.status===`inconclusive`).length,skipped:S.tests.filter(e=>e.status===`skipped`).length,notRun:S.tests.filter(e=>e.status===`not-run`).length});if(!n.success)return await A(),{success:!1,issues:n.issues,bundle:e,tests:S.tests,accounting:i(0),lineage:await r()};if(h.collectOnly===!0)return await S.waitForCompletion(h.testTimeout,/(?!)/u),await A(),{success:!0,passed:!1,tests:S.tests,bundle:e,accounting:i(0),lineage:await r()};await S.waitForCompletion(h.testTimeout,g.pattern),await A();let a=o(S.tests,g.pattern),s=await r();return{success:!0,passed:s.status===`complete`&&a.every(e=>e.status===`passed`||e.status===`skipped`),tests:a,bundle:e,accounting:i(a.length),lineage:s}}finally{await A(),N=!1,D.delete(E),D.size===0&&Reflect.deleteProperty(f,d),v.dispose()}}export{T as runGeoSpecModule};
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* One timeout vocabulary for every GeoSpec host.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* it ran in the browser worker, the Node pool or the CLI:
|
|
5
|
+
* Each host reports the wall-clock bounds it applies with the same code, in
|
|
6
|
+
* the browser worker, the Node pool and the CLI alike:
|
|
8
7
|
*
|
|
9
8
|
* | Code | Bound | Set by | Hosts |
|
|
10
9
|
* | ----------------------- | --------------------------------------------- | --------------------------------------------- | --------------------- |
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
*
|
|
24
23
|
* @public
|
|
25
24
|
*/
|
|
26
|
-
declare const geoSpecTimeoutCode: {
|
|
25
|
+
export declare const geoSpecTimeoutCode: {
|
|
27
26
|
/** A test's async body outlived `testTimeout` / `--test-timeout`. */
|
|
28
27
|
readonly test: "GEOSPEC_TEST_TIMEOUT";
|
|
29
28
|
/** A pool shard outlived the non-verdict `--shard-timeout` watchdog. */
|
|
@@ -32,7 +31,7 @@ declare const geoSpecTimeoutCode: {
|
|
|
32
31
|
readonly run: "GEOSPEC_RUN_TIMEOUT";
|
|
33
32
|
};
|
|
34
33
|
/** One GeoSpec timeout code. @public */
|
|
35
|
-
type GeoSpecTimeoutCode = (typeof geoSpecTimeoutCode)[keyof typeof geoSpecTimeoutCode];
|
|
34
|
+
export type GeoSpecTimeoutCode = (typeof geoSpecTimeoutCode)[keyof typeof geoSpecTimeoutCode];
|
|
36
35
|
/**
|
|
37
36
|
* Whether a diagnostic or issue code belongs to the GeoSpec timeout family.
|
|
38
37
|
*
|
|
@@ -40,6 +39,5 @@ type GeoSpecTimeoutCode = (typeof geoSpecTimeoutCode)[keyof typeof geoSpecTimeou
|
|
|
40
39
|
* @returns True for {@link geoSpecTimeoutCode} values.
|
|
41
40
|
* @public
|
|
42
41
|
*/
|
|
43
|
-
declare const isGeoSpecTimeoutCode: (code: string) => code is GeoSpecTimeoutCode;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { GeoSpecTimeoutCode, geoSpecTimeoutCode, isGeoSpecTimeoutCode };
|
|
42
|
+
export declare const isGeoSpecTimeoutCode: (code: string) => code is GeoSpecTimeoutCode;
|
|
43
|
+
//#endregion
|