geospec 0.0.0 → 0.1.0-beta.2
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/LICENSE +201 -0
- package/README.md +244 -0
- package/agent/doctrine.md +47 -0
- package/agent/geospec-authoring/SKILL.md +496 -0
- package/agent/geospec-authoring/api-classes.md +13 -0
- package/agent/geospec-authoring/api-constants.md +6 -0
- package/agent/geospec-authoring/api-functions.md +49 -0
- package/agent/geospec-authoring/api-index.md +362 -0
- package/agent/geospec-authoring/api-types.md +1700 -0
- package/agent/geospec-authoring/public-api-classes.md +22 -0
- package/agent/geospec-authoring/public-api-constants.md +19 -0
- package/agent/geospec-authoring/public-api-functions.md +196 -0
- package/agent/geospec-authoring/public-api-index.md +856 -0
- package/agent/geospec-authoring/public-api-types-2.md +1513 -0
- package/agent/geospec-authoring/public-api-types.md +2048 -0
- package/agent/resources.d.ts +19 -0
- package/agent/resources.js +26 -0
- package/agent/skills.d.cts +13 -0
- package/agent/skills.json +27 -0
- package/dist/assertion-client/client.d.mts +124 -0
- package/dist/assertion-client/client.mjs +2 -0
- package/dist/assertion-client/index.d.mts +5 -0
- package/dist/assertion-client/index.mjs +1 -0
- package/dist/config/index.d.mts +3 -0
- package/dist/config/index.mjs +1 -0
- package/dist/config/node/index.d.mts +3 -0
- package/dist/config/node/index.mjs +1 -0
- package/dist/config/node/load.d.mts +19 -0
- package/dist/config/node/load.mjs +1 -0
- package/dist/config/tau-project-artifact.d.mts +54 -0
- package/dist/config/tau-project-artifact.mjs +3 -0
- package/dist/config/types.d.mts +57 -0
- package/dist/config/validate.mjs +1 -0
- package/dist/create-geospec.d.mts +49 -0
- package/dist/create-geospec.mjs +1 -0
- package/dist/engine/client.d.mts +93 -0
- package/dist/engine/client.mjs +1 -0
- package/dist/engine/index.d.mts +3 -0
- package/dist/engine/index.mjs +1 -0
- package/dist/engine/matchers.d.mts +70 -0
- package/dist/engine/matchers.mjs +1 -0
- package/dist/engine/pmi.types.d.mts +78 -0
- package/dist/engine/protocol.d.mts +20 -0
- package/dist/engine/protocol.mjs +1 -0
- package/dist/geometry-unit.d.mts +12 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +1 -0
- package/dist/mesh/index.d.mts +4 -0
- package/dist/mesh/index.mjs +1 -0
- package/dist/mesh/types.d.mts +575 -0
- package/dist/model/errors.d.mts +20 -0
- package/dist/model/errors.mjs +2 -0
- package/dist/model/export-intent.d.mts +63 -0
- package/dist/model/export-intent.mjs +1 -0
- package/dist/model/index.d.mts +6 -0
- package/dist/model/index.mjs +1 -0
- package/dist/model/load-model.d.mts +25 -0
- package/dist/model/load-model.mjs +1 -0
- package/dist/model/native-model-loader.d.mts +119 -0
- package/dist/model/native-model-loader.mjs +1 -0
- package/dist/model/subject-assertions.mjs +1 -0
- package/dist/model/subject.d.mts +11 -0
- package/dist/model/subject.mjs +1 -0
- package/dist/model/types.d.mts +207 -0
- package/dist/runner/collector.d.mts +62 -0
- package/dist/runner/collector.mjs +2 -0
- package/dist/runner/discovery.d.mts +93 -0
- package/dist/runner/discovery.mjs +1 -0
- package/dist/runner/filter.d.mts +50 -0
- package/dist/runner/filter.mjs +1 -0
- package/dist/runner/index.d.mts +6 -0
- package/dist/runner/index.mjs +1 -0
- package/dist/runner/native/index.d.mts +4 -0
- package/dist/runner/native/index.mjs +1 -0
- package/dist/runner/native/native-pool-grants.d.mts +21 -0
- package/dist/runner/native/native-pool-grants.mjs +1 -0
- package/dist/runner/native/native-serial-runner.d.mts +29 -0
- package/dist/runner/native/native-serial-runner.mjs +1 -0
- package/dist/runner/pool/pool-messages.d.mts +94 -0
- package/dist/runner/run-geospec-module.d.mts +13 -0
- package/dist/runner/run-geospec-module.mjs +47 -0
- package/dist/runner/types.d.mts +743 -0
- package/dist/runner/worker/index.d.mts +4 -0
- package/dist/runner/worker/index.mjs +1 -0
- package/dist/runner/worker/no-matching-tests-issue.d.mts +12 -0
- package/dist/runner/worker/no-matching-tests-issue.mjs +1 -0
- package/dist/runner/worker/runner-types.d.mts +146 -0
- package/dist/runner/worker/serial-runner.mjs +1 -0
- package/dist/selector/types.d.mts +271 -0
- package/dist/step/types.d.mts +134 -0
- package/dist/vitest/adapter.d.mts +56 -0
- package/dist/vitest/adapter.mjs +3 -0
- package/dist/vitest/index.d.mts +4 -0
- package/dist/vitest/index.mjs +1 -0
- package/package.json +114 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/runner/native/native-pool-grants.d.ts
|
|
2
|
+
/** Deterministic caller-inclusive permits for the host-composed compiled worker pool. @module */
|
|
3
|
+
/**
|
|
4
|
+
* Assign a bounded CPU budget across already-selected worker isolates.
|
|
5
|
+
* The omitted budget is one permit per worker. A native pool must pass each
|
|
6
|
+
* returned grant to the engine it constructs inside the corresponding worker.
|
|
7
|
+
* A grant above one is admissible only for an engine with its own OCCT
|
|
8
|
+
* library instance: native workers that are threads of one process share one,
|
|
9
|
+
* so such a pool must use one worker or one permit per worker.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Worker count, optional total budget, and host CPU cap.
|
|
12
|
+
* @returns Grants in worker creation order.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
declare const allocateNativePoolGrants: (options: {
|
|
16
|
+
workers: number;
|
|
17
|
+
budget?: number;
|
|
18
|
+
hostCap: number;
|
|
19
|
+
}) => readonly number[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { allocateNativePoolGrants };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{let{workers:t,hostCap:n}=e,r=e.budget??t;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(r)||!Number.isSafeInteger(n)||t<1||r<t||r>n)throw RangeError(`Native pool requires positive workers and a caller-inclusive budget between workers and the host cap.`);let i=Math.floor(r/t),a=r%t;return Array.from({length:t},(e,t)=>i+ +(t<a))};export{e as allocateNativePoolGrants};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CreateGeoSpecNativeModelLoaderOptions, GeoSpecNativeModelEngine, ManagedGeoSpecNativeModelLoader } from "../../model/native-model-loader.mjs";
|
|
2
|
+
import { GeoSpecAssertionClientOptions } from "../../assertion-client/client.mjs";
|
|
3
|
+
import "../../assertion-client/index.mjs";
|
|
4
|
+
import { GeoSpecRunner, GeoSpecRunnerOptions } from "../worker/runner-types.mjs";
|
|
5
|
+
import "../worker/index.mjs";
|
|
6
|
+
//#region src/runner/native/native-serial-runner.d.ts
|
|
7
|
+
/** Native assertion options whose engine can also admit and release subjects. @public */
|
|
8
|
+
type GeoSpecNativeRunnerAssertions = Omit<GeoSpecAssertionClientOptions, 'engine'> & {
|
|
9
|
+
readonly engine: GeoSpecNativeModelEngine;
|
|
10
|
+
};
|
|
11
|
+
/** Options for the native serial runner. @public */
|
|
12
|
+
type GeoSpecNativeRunnerOptions = Omit<GeoSpecRunnerOptions, 'nativeAssertions' | 'nativeModelLoader'> & {
|
|
13
|
+
/** Actual protocol-3 engine used by authored assertions. */
|
|
14
|
+
readonly nativeAssertions: GeoSpecNativeRunnerAssertions;
|
|
15
|
+
/** Optional managed loader; the runner releases its subjects after every run. */
|
|
16
|
+
readonly nativeModelLoader?: ManagedGeoSpecNativeModelLoader;
|
|
17
|
+
/** Defaults used when the runner constructs its own native loader. */
|
|
18
|
+
readonly model?: Omit<CreateGeoSpecNativeModelLoaderOptions, 'engine'>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Compose compiled assertion and model bindings with the SDK's serial lifecycle.
|
|
22
|
+
*
|
|
23
|
+
* @param options - VM filesystem, native engine/client options and model defaults.
|
|
24
|
+
* @returns The ordinary GeoSpec runner lifecycle and event contract.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
declare const createNativeGeoSpecRunner: (options: GeoSpecNativeRunnerOptions) => GeoSpecRunner;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { GeoSpecNativeRunnerAssertions, GeoSpecNativeRunnerOptions, createNativeGeoSpecRunner };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createGeoSpecNativeModelLoader as e}from"../../model/native-model-loader.mjs";import{createSerialGeoSpecRunner as t}from"../worker/serial-runner.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??e({...i.model,engine:i.nativeAssertions.engine}),o=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=t({filesystem:i.filesystem,nativeAssertions:{...i.nativeAssertions,engine:l},nativeModelLoader:s,...i.builtinModules===void 0?{}:{builtinModules:i.builtinModules}});return{...u,async close(){try{await u.close()}finally{o.clear()}}}};export{i as createNativeGeoSpecRunner};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { GeoSpecRunResult } from "../types.mjs";
|
|
2
|
+
//#region src/runner/pool/pool-messages.d.ts
|
|
3
|
+
/** One schedulable work unit.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
type GeoSpecPoolShard = {
|
|
8
|
+
/** Stable shard id, unique within one pool run. */
|
|
9
|
+
id: number;
|
|
10
|
+
/** GeoSpec file this shard executes. */
|
|
11
|
+
file: string;
|
|
12
|
+
/** Exact-test pattern for split shards (R3: `(file, testNamePattern)` work units). */
|
|
13
|
+
testNamePattern?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Host → worker messages. */
|
|
16
|
+
/** @public */
|
|
17
|
+
type GeoSpecPoolHostMessage = {
|
|
18
|
+
type: 'initialize';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'run-shard';
|
|
21
|
+
shard: GeoSpecPoolShard;
|
|
22
|
+
testNamePattern?: string;
|
|
23
|
+
testTimeout?: number;
|
|
24
|
+
matcherWallBackstop?: number;
|
|
25
|
+
forensic?: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
/** List-only collection pass: register tests, run no bodies (R3 splitting). */
|
|
28
|
+
type: 'list-tests';
|
|
29
|
+
shardId: number;
|
|
30
|
+
file: string;
|
|
31
|
+
testTimeout?: number;
|
|
32
|
+
matcherWallBackstop?: number;
|
|
33
|
+
forensic?: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'shutdown';
|
|
36
|
+
};
|
|
37
|
+
/** Worker → host messages. */
|
|
38
|
+
/** @public */
|
|
39
|
+
type GeoSpecPoolWorkerMessage = {
|
|
40
|
+
type: 'ready';
|
|
41
|
+
} | {
|
|
42
|
+
type: 'initialized';
|
|
43
|
+
} | {
|
|
44
|
+
type: 'initialization-error';
|
|
45
|
+
message: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'file-start';
|
|
48
|
+
shardId: number;
|
|
49
|
+
file: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'forensic';
|
|
52
|
+
shardId: number;
|
|
53
|
+
name: string;
|
|
54
|
+
value: number;
|
|
55
|
+
unit: 'milliseconds' | 'count';
|
|
56
|
+
} | {
|
|
57
|
+
type: 'tests-listed';
|
|
58
|
+
shardId: number;
|
|
59
|
+
file: string;
|
|
60
|
+
names: string[];
|
|
61
|
+
} | {
|
|
62
|
+
type: 'list-error';
|
|
63
|
+
shardId: number;
|
|
64
|
+
file: string;
|
|
65
|
+
message: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'shard-complete';
|
|
68
|
+
shardId: number;
|
|
69
|
+
file: string;
|
|
70
|
+
result: GeoSpecRunResult;
|
|
71
|
+
durationMs: number;
|
|
72
|
+
primaryLoadKey?: string;
|
|
73
|
+
/** Worker-isolate resident memory at completion (heap + external), bytes. */
|
|
74
|
+
workerMemoryBytes?: number;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'shard-error';
|
|
77
|
+
shardId: number;
|
|
78
|
+
file: string;
|
|
79
|
+
message: string;
|
|
80
|
+
};
|
|
81
|
+
/** Minimal worker handle the host-agnostic pool drives (Node or Web Worker). */
|
|
82
|
+
/** @public */
|
|
83
|
+
type GeoSpecPoolWorkerHandle = {
|
|
84
|
+
postMessage(message: GeoSpecPoolHostMessage): void;
|
|
85
|
+
onMessage(listener: (message: GeoSpecPoolWorkerMessage) => void): void;
|
|
86
|
+
onExit(listener: (details: {
|
|
87
|
+
unexpected: boolean;
|
|
88
|
+
message?: string;
|
|
89
|
+
}) => void): void;
|
|
90
|
+
/** Hard-stop the worker thread (R11 watchdog primitive). */
|
|
91
|
+
terminate(): Promise<void> | void;
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
export { GeoSpecPoolHostMessage, GeoSpecPoolShard, GeoSpecPoolWorkerHandle, GeoSpecPoolWorkerMessage };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GeoSpecRunResult, RunGeoSpecModuleOptions } from "./types.mjs";
|
|
2
|
+
//#region src/runner/run-geospec-module.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Execute an ESM GeoSpec module using the shared Tau VM substrate.
|
|
5
|
+
*
|
|
6
|
+
* @param options - filesystem and test entry path.
|
|
7
|
+
* @returns collected test cases or structured VM issues.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
declare function runGeoSpecModule(options: RunGeoSpecModuleOptions): Promise<GeoSpecRunResult>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { runGeoSpecModule };
|
|
@@ -0,0 +1,47 @@
|
|
|
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{sha256Bytes as c}from"@taucad/runtime/kernel";import{createEsbuildModuleVm as l}from"@taucad/esbuild/vm";const u=`__GEOSPEC_RUN_BINDINGS__`,d=globalThis,f=()=>`geospec-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,p=e=>JSON.stringify(Object.entries(e.builtinModules??{}).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.version,t.globalName,t.code])),m=(e,t)=>e.byteLength===t.byteLength&&e.every((e,n)=>e===t[n]),h=(e,t)=>e instanceof Uint8Array&&t instanceof Uint8Array?m(e,t):e===t,g=async(e,{question:t,path:n})=>t===`exists`?e.exists(n):t===`utf8`?e.readFile(n,`utf8`):e.readFile(n),_=async(e,t)=>(await Promise.all(t.map(async t=>{try{return h(await g(e,t),t.answer)}catch{return!1}}))).every(Boolean),v=e=>{let t=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&&=h(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()]}},y=async e=>{let t=e.bundleCache?.get(e.entryPath);if(!(t===void 0||t.builtinIdentity!==p(e)||!await _(e.filesystem,t.bundlerReads)))return t},b=()=>{let e=d[u];if(e)return e;let t=new Map;return d[u]=t,t},x=e=>`
|
|
2
|
+
const getRunBinding = () => {
|
|
3
|
+
const binding = globalThis.${u}?.get(${JSON.stringify(e)});
|
|
4
|
+
if (!binding) {
|
|
5
|
+
throw new Error('GeoSpec runner binding is not active. Run the module through runGeoSpecModule().');
|
|
6
|
+
}
|
|
7
|
+
return binding;
|
|
8
|
+
};
|
|
9
|
+
`,S=e=>`
|
|
10
|
+
${x(e)}
|
|
11
|
+
|
|
12
|
+
export const describe = (name, fn) => getRunBinding().collector.describe(name, fn);
|
|
13
|
+
describe.skip = (name, fn) => getRunBinding().collector.describeSkip(name, fn);
|
|
14
|
+
|
|
15
|
+
export const it = (name, fn) => getRunBinding().collector.it(name, fn);
|
|
16
|
+
it.skip = (name, fn) => getRunBinding().collector.itSkip(name, fn);
|
|
17
|
+
|
|
18
|
+
export const test = it;
|
|
19
|
+
export const expectGeo = (subject) => getRunBinding().collector.expectGeo(subject);
|
|
20
|
+
`,C=e=>`
|
|
21
|
+
${x(e)}
|
|
22
|
+
export const GeoSpecModelLoadError = getRunBinding().geoSpecModelLoadError;
|
|
23
|
+
|
|
24
|
+
export const loadModel = async (options) => {
|
|
25
|
+
const binding = getRunBinding();
|
|
26
|
+
const loader = binding.nativeModelLoader;
|
|
27
|
+
if (typeof loader !== 'function') {
|
|
28
|
+
throw new GeoSpecModelLoadError([
|
|
29
|
+
{
|
|
30
|
+
code: 'GEOSPEC_MODEL_LOADER_UNAVAILABLE',
|
|
31
|
+
severity: 'error',
|
|
32
|
+
message: 'No GeoSpec model loader is active for this runner.',
|
|
33
|
+
suggestion: 'Run this test through the GeoSpec CLI or Tau browser test runner.',
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
return loader(options);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const createModelLoader = (defaults = {}) => {
|
|
41
|
+
const factory = getRunBinding().createModelLoader;
|
|
42
|
+
if (typeof factory !== 'function') {
|
|
43
|
+
throw new GeoSpecModelLoadError([{ code: 'GEOSPEC_MODEL_LOADER_UNAVAILABLE', severity: 'error', message: 'No managed GeoSpec model loader is active for this runner.' }]);
|
|
44
|
+
}
|
|
45
|
+
return factory(defaults);
|
|
46
|
+
};
|
|
47
|
+
`;async function w(m){let h=a(m.testNamePattern);if(!h.success)return{success:!1,issues:[h.issue]};let g=v(m.filesystem),_=await l({filesystem:g.filesystem}),x=s({...m.matcherWallBackstop===void 0?{}:{matcherWallBackstop:m.matcherWallBackstop},...m.forensic===void 0?{}:{forensic:m.forensic},nativeAssertions:m.nativeAssertions}),w=await y(m),T=f(),E=b(),D=new Set,O=[],k=async()=>{do{let e=[...D];await Promise.allSettled(e);for(let t of e)D.delete(t)}while(D.size>0)},A=m.nativeModelLoader,j=r(m.nativeAssertions),M=!0,N=A===void 0?void 0:n=>{let r=O.length,a=`${T}:load:${r+1}`;O.push({loadId:a,status:`unavailable`});let o=(async()=>{try{let i=await A(n),{load:o,...s}=i,c=t(i),l=o===void 0?void 0:{...structuredClone(o),loadId:a};return O[r]={loadId:a,status:l?.status??`unavailable`,subject:s,...l===void 0?{}:{evidence:l}},e({engine:m.nativeAssertions.engine,client:j,identity:s,...l===void 0?{}:{load:l},isLive:()=>M,...c===void 0?{}:{ensureResident:c}})}catch(e){throw O[r]={loadId:a,status:`failed`,error:e instanceof Error?e.message:String(e),...e instanceof i?{diagnostics:e.diagnostics}:{}},e}})();return D.add(o.catch(()=>void 0)),D.add(o),o};E.set(T,{collector:x,geoSpecModelLoadError:i,...N?{nativeModelLoader:N}:{},...N?{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=new Set,a=new Set,o,s=async i=>{let o=r,s=await N({...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}})}}:{}}),_.registerModule(`geospec`,{version:`0.0.0-poc`,code:S(T)}),_.registerModule(`geospec/model`,{version:`0.0.0-poc`,code:C(T)});for(let[e,t]of Object.entries(m.builtinModules??{}))_.registerModule(e,t);try{let e=w?.bundle??await _.bundle(m.entryPath);if(!e.success)return{success:!1,issues:e.issues,bundle:e};let t=g.reads();m.bundleCache!==void 0&&w===void 0&&t!==void 0&&m.bundleCache.set(m.entryPath,{builtinIdentity:p(m),runToken:T,bundle:e,bundlerReads:t});let n=await _.execute(w===void 0?e.code:e.code.replaceAll(w.runToken,T)),r=async()=>{let t={},n=g.reads()!==void 0;for(let e of w?.bundlerReads??g.observed()){if(e.question===`exists`||typeof e.answer==`boolean`)continue;let r=await c(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 O){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?O.some(e=>e.status!==`complete`)?`unavailable`:`complete`:`mixed`,modules:[{entryPath:m.entryPath,bundleSha256:await c(new TextEncoder().encode(w===void 0?e.code:e.code.replaceAll(w.runToken,T))),files:t,consistent:n}],loads:O}},i=e=>({discovered:x.tests.length,selected:e,completed:x.tests.filter(e=>e.status!==`not-run`&&e.status!==`skipped`).length,passed:x.tests.filter(e=>e.status===`passed`).length,failed:x.tests.filter(e=>e.status===`failed`).length,unsupported:x.tests.filter(e=>e.status===`unsupported`).length,inconclusive:x.tests.filter(e=>e.status===`inconclusive`).length,skipped:x.tests.filter(e=>e.status===`skipped`).length,notRun:x.tests.filter(e=>e.status===`not-run`).length});if(!n.success)return await k(),{success:!1,issues:n.issues,bundle:e,tests:x.tests,accounting:i(0),lineage:await r()};if(m.collectOnly===!0)return await x.waitForCompletion(m.testTimeout,/(?!)/u),await k(),{success:!0,passed:!1,tests:x.tests,bundle:e,accounting:i(0),lineage:await r()};await x.waitForCompletion(m.testTimeout,h.pattern),await k();let a=o(x.tests,h.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 k(),M=!1,E.delete(T),E.size===0&&Reflect.deleteProperty(d,u),_.dispose()}}export{w as runGeoSpecModule};
|