Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions capabilities/computation/measure/burst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { checkedWorker } from '@on.auto/definitions';
import { programPool, type ProgramRequest } from '@on.auto/workflow-engine/dsl';

import { computationBounds } from '../src/run/run-bounds.ts';
import { formatted, functionOf, inTurn, median, request } from './common.ts';
import { formatted, functionOf, handed, inTurn, median, request } from './common.ts';

const jobs = 200;

Expand All @@ -24,7 +24,11 @@ const twoModules: Naming = (index) => (index % 2 === 0 ? {} : withASchema);
const oneModule: Naming = (index) => (index % 2 === 0 ? { worker: checkedWorker, context: null } : withASchema);

async function burstOf(naming: Naming): Promise<number> {
const pool = programPool({ workers: permits, heapMegabytes: computationBounds.heapMegabytes });
const pool = programPool({
handed,
workers: permits,
heapMegabytes: computationBounds.heapMegabytes,
});
const started = performance.now();
await Promise.all(
Array.from({ length: jobs }, (_, index) =>
Expand Down
6 changes: 5 additions & 1 deletion capabilities/computation/measure/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { handedWorkersWithChecks } from '@on.auto/definitions/check';
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { programPool, type Json, type ProgramPool, type ProgramRequest } from '@on.auto/workflow-engine/dsl';

import { computationBounds } from '../src/run/run-bounds.ts';

export const handed = await handedWorkersWithChecks(shippedFilesOnDisk);

export function millisecondsOf(work: () => void): number {
const started = performance.now();
work();
Expand Down Expand Up @@ -46,5 +50,5 @@ export function request(
}

export function poolOfOne(): ProgramPool {
return programPool({ workers: 1, heapMegabytes: computationBounds.heapMegabytes });
return programPool({ handed, workers: 1, heapMegabytes: computationBounds.heapMegabytes });
}
9 changes: 7 additions & 2 deletions capabilities/computation/measure/workers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { programPool, workerStackMegabytes, type ProgramPool } from '@on.auto/workflow-engine/dsl';

import { computationBounds, mebibytes } from '../src/run/run-bounds.ts';
import { formatted, functionOf, inTurn, poolOfOne, request } from './common.ts';
import { formatted, functionOf, handed, inTurn, poolOfOne, request } from './common.ts';

const blocking = new URL(`data:text/javascript,${encodeURIComponent('while (true) {}')}`);

Expand All @@ -24,7 +24,12 @@ const bombs: readonly Bomb[] = [
];

async function termination(): Promise<string> {
const pool = programPool({ workers: 1, heapMegabytes: computationBounds.heapMegabytes, worker: blocking });
const pool = programPool({
handed,
workers: 1,
heapMegabytes: computationBounds.heapMegabytes,
worker: blocking,
});
const ended = await pool.run(request(functionOf('return input;'), 1, 500));
await pool.close();
return `a worker that never answers, under a deadline of 500 ms: ended ${ended.ran}, after ${formatted(ended.milliseconds, 1)} ms`;
Expand Down
16 changes: 8 additions & 8 deletions capabilities/computation/src/testing/computation-runs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { CapabilityAnswer, PreparedDefinition, Capability, RunContext } from '@on.auto/definitions';
import { checkingWithin, noLongestRuns, nothingSaved, recordingJournal } from '@on.auto/definitions/testing';
import {
checkingWithin,
measuredPoolSettings,
noLongestRuns,
nothingSaved,
recordingJournal,
} from '@on.auto/definitions/testing';
import { allPermissions, type Conflict, type InvalidInput, type Unavailable } from '@on.auto/operations';
import { programPool, type PoolSettings, type ProgramPool } from '@on.auto/workflow-engine/dsl';
import { Effect, type Exit, type Schema } from 'effect';
Expand Down Expand Up @@ -41,17 +47,11 @@ afterEach(async () => {
await Promise.all(pools.splice(0).map((pool) => pool.close()));
});

const measured: Readonly<Record<string, string>> = Object.fromEntries(
Object.entries(process.env).flatMap(([key, value]: readonly [string, string | undefined]) =>
key === 'NODE_V8_COVERAGE' && value !== undefined ? [[key, value]] : [],
),
);

export function poolOf(settings: Partial<PoolSettings> = {}): ProgramPool {
const pool = programPool({
workers: computationBounds.workers,
heapMegabytes: computationBounds.heapMegabytes,
environment: measured,
...measuredPoolSettings,
...settings,
});
pools.push(pool);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { measuredPoolSettings } from '@on.auto/definitions/testing';
import { memoryLedger } from '@on.auto/operations/testing';
import { makePredictionFunctionAdapter } from '@on.auto/prediction';
import { testPorts, weeklyOrders } from '@on.auto/prediction/testing';
Expand All @@ -11,7 +12,7 @@ import { recordingStarts, recordingWorkflows } from '../testing/recording-starts

const runId = '0199a3c4-7d2e-7c1a-9b3f-555555555553';

const pool = programPool({ workers: 1, heapMegabytes: 256 });
const pool = programPool({ workers: 1, heapMegabytes: 256, ...measuredPoolSettings });

afterAll(() => pool.close());

Expand Down
4 changes: 2 additions & 2 deletions capabilities/coordination/src/testing/expression-checks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { checkedAtSave } from '@on.auto/definitions/check';
import { checksAwaitedAtMostMs } from '@on.auto/definitions/testing';
import { checksAwaitedAtMostMs, measuredPoolSettings } from '@on.auto/definitions/testing';
import { programPool, type ProgramPool } from '@on.auto/workflow-engine/dsl';
import { afterAll } from 'vitest';

Expand All @@ -13,6 +13,6 @@ afterAll(async () => {
});

export const testExpressionCheck: ExpressionCheck = (job) => {
pool ??= programPool({ workers: 1, heapMegabytes: 256 });
pool ??= programPool({ workers: 1, heapMegabytes: 256, ...measuredPoolSettings });
return checkedAtSave(pool, job, checksAwaitedAtMostMs);
};
3 changes: 2 additions & 1 deletion capabilities/coordination/src/testing/test-host.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { machineSandboxOf } from '@on.auto/workflow-engine/dsl';
import { openWorkflowHost, type WorkflowHost } from '@on.auto/workflow-host';
import { recordedReactions, recordedWaiting } from '@on.auto/workflow-host/testing';
Expand All @@ -11,7 +12,7 @@ import { testPlaybookNames } from './test-sandbox.ts';
export function testHost(nested: Playbook): Promise<WorkflowHost> {
return openWorkflowHost({
database: { store: 'sqlite', file: ':memory:' },
machine: workflowMachineOptionsOf(machineSandboxOf(), testPlaybookNames),
machine: workflowMachineOptionsOf(machineSandboxOf(shippedFilesOnDisk), testPlaybookNames),
perform: definitionCalls(nested.executeNested),
settle: nested.settle,
reports: {
Expand Down
6 changes: 5 additions & 1 deletion capabilities/coordination/src/testing/test-sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { playbookOwnNamesOf, type PlaybookOwnNames } from '@on.auto/definitions';
import { echo } from '@on.auto/definitions/testing';
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import {
reusedSandbox,
type MachineOptions,
Expand All @@ -12,7 +13,10 @@ import { workflowFacts } from '../capability/workflow.ts';
import { workflowPolicyOf, type WorkflowPolicy } from '../document/workflow-functions.ts';
import { workflowMachineOptionsOf, workflowMachineSettingsOf } from '../runs/workflow-machine-options.ts';

export const testSandbox: MachineSandbox = reusedSandbox(await freshInstance(unitMemoryBytes), () => 0);
export const testSandbox: MachineSandbox = reusedSandbox(
await freshInstance(shippedFilesOnDisk, unitMemoryBytes),
() => 0,
);

export const testPlaybookNames: PlaybookOwnNames = playbookOwnNamesOf([echo, workflowFacts]);

Expand Down
5 changes: 3 additions & 2 deletions capabilities/prediction/measure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { programPool } from '@on.auto/workflow-engine/dsl';
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { handedWorkersOf, programPool } from '@on.auto/workflow-engine/dsl';

import { rebuiltOn, type Folding, type History } from './measure/dataset-rebuild.ts';
import { dailyOrders, seriesMeasured, testedDailyOrders } from './measure/order-history.ts';
Expand Down Expand Up @@ -69,7 +70,7 @@ async function testedOn({ store, aDatabase }: MeasuredStore, history: History):
}

async function measuredOn(measured: MeasuredStore): Promise<void> {
const pool = programPool({ workers: 1, heapMegabytes: 256 });
const pool = programPool({ handed: await handedWorkersOf(shippedFilesOnDisk), workers: 1, heapMegabytes: 256 });
const history = { days, liveDays, filters: pool.evaluations.filters };
try {
await untestedOn(measured, history);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { filterSandboxOf } from '@on.auto/workflow-engine/dsl';
import { Effect } from 'effect';
import { describe, expect, it } from 'vitest';

import { datasetFolder } from '../dataset/dataset-folder.ts';
import { datasetsPortOn } from '../dataset/datasets-port.ts';
import { uploadedWeeklyOrders, weeklyOrders, weeklyOrdersWith } from '../testing/weekly-orders.ts';
import { isLive, liveFolded } from './dataset-predicates.ts';
import type { SettingsOf } from './dataset-stores.ts';
import { north } from './orders.ts';
import { alphaKey, projectedDatasets } from './projected-datasets.ts';
import { alphaKey, projectedDatasets, testDatasetFolder } from './projected-datasets.ts';

const alpha = { org: 'acme', playbook: 'alpha' };

Expand All @@ -25,7 +23,7 @@ function staleWriteTest(settingsOf: SettingsOf): void {
const row = await datasets.until(dataSha256, liveFolded(1));
const untouched = await datasets.until(idle.dataSha256, isLive);
await datasets.stop();
const folder = datasetFolder({ filters: filterSandboxOf(), triesBeforeStall: Number.POSITIVE_INFINITY });
const folder = testDatasetFolder();
const unchanged = folder.unchanged(row);
const stale = {
row: Object.assign({}, row, { checkpointText: '["0"]' }),
Expand Down
18 changes: 13 additions & 5 deletions capabilities/prediction/src/dataset-testing/projected-datasets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { filterSandboxOf } from '@on.auto/workflow-engine/dsl';
import { someFolder, type DatabaseSettings } from '@on.auto/workflow-host';
import { projectedFolders, type ProjectedFolders } from '@on.auto/workflow-host/testing';
Expand Down Expand Up @@ -81,11 +82,18 @@ function readingOf(folders: ProjectedFolders): Pick<ProjectedDatasets, 'datasets
};
}

export async function projectedDatasets(
settings: DatabaseSettings,
folding: Partial<Omit<DatasetFolding, 'filters'>> = {},
): Promise<ProjectedDatasets> {
const folder = datasetFolder({ filters: filterSandboxOf(), triesBeforeStall: Number.POSITIVE_INFINITY, ...folding });
type Folding = Partial<Omit<DatasetFolding, 'filters'>>;

export function testDatasetFolder(folding: Folding = {}): ReturnType<typeof datasetFolder> {
return datasetFolder({
filters: filterSandboxOf(shippedFilesOnDisk),
triesBeforeStall: Number.POSITIVE_INFINITY,
...folding,
});
}

export async function projectedDatasets(settings: DatabaseSettings, folding: Folding = {}): Promise<ProjectedDatasets> {
const folder = testDatasetFolder(folding);
const folders = await projectedFolders(settings, [someFolder(folder)]);
onTestFinished(folders.close);
return {
Expand Down
3 changes: 2 additions & 1 deletion capabilities/prediction/src/dataset/dataset-matching.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { filterSandboxOf } from '@on.auto/workflow-engine/dsl';
import type { PageEvent } from '@on.auto/workflow-host';
import { Effect } from 'effect';
Expand Down Expand Up @@ -36,7 +37,7 @@ describe('the matching of a dataset whose filters name their data before their t
it('tests an event against the data tests of the filters of its own type alone, matching each type first', async () => {
const matching = datasetMatchingOf(
dataNamedFirst,
filterSandboxOf(() => 0),
filterSandboxOf(shippedFilesOnDisk, () => 0),
);

const match = await Effect.runPromise(matching.matchOf(placed));
Expand Down
16 changes: 8 additions & 8 deletions capabilities/prediction/src/testing/prediction-runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import type {
SavedDefinition,
SavedDefinitions,
} from '@on.auto/definitions';
import { checkingWithin, noLongestRuns, onTheStandingClock, recordingJournal } from '@on.auto/definitions/testing';
import {
checkingWithin,
measuredPoolSettings,
noLongestRuns,
onTheStandingClock,
recordingJournal,
} from '@on.auto/definitions/testing';
import { allPermissions, contentOfText } from '@on.auto/operations';
import { programPool, type ProgramPool } from '@on.auto/workflow-engine/dsl';
import { Effect, type Exit, type Schema } from 'effect';
Expand All @@ -24,14 +30,8 @@ afterEach(async () => {
await Promise.all(pools.splice(0).map((pool) => pool.close()));
});

const measured: Readonly<Record<string, string>> = Object.fromEntries(
Object.entries(process.env).flatMap(([key, value]: readonly [string, string | undefined]) =>
key === 'NODE_V8_COVERAGE' && value !== undefined ? [[key, value]] : [],
),
);

export function poolOf(): ProgramPool {
const pool = programPool({ workers: 1, heapMegabytes: 256, environment: measured });
const pool = programPool({ workers: 1, heapMegabytes: 256, ...measuredPoolSettings });
pools.push(pool);
return checkingWithin(pool);
}
Expand Down
8 changes: 6 additions & 2 deletions capabilities/recall/measure/folds.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { handedWorkersWithChecks } from '@on.auto/definitions/check';
import { shippedFilesOnDisk } from '@on.auto/operations/shipped-files-on-disk';
import { programPool, type FoldRequest, type Json, type JsonObject } from '@on.auto/workflow-engine/dsl';
import { Effect, Result } from 'effect';

Expand All @@ -6,6 +8,8 @@ import { parseRecallDocument } from '../src/document/document-parsing.ts';
import { recallBounds, recallFolding } from '../src/run/recall-bounds.ts';
import { campaignReviews } from '../src/testing/campaign-reviews.ts';

const handed = await handedWorkersWithChecks(shippedFilesOnDisk);

export interface Folded {
readonly events: number;
readonly pages: number;
Expand All @@ -20,7 +24,7 @@ const document = Result.getOrThrow(parseRecallDocument(campaignReviews));
const { details } = document;

async function strippedFold(): Promise<string> {
const pool = programPool({ workers: 1, heapMegabytes: recallBounds.heapMegabytes });
const pool = programPool({ handed, workers: 1, heapMegabytes: recallBounds.heapMegabytes });
const { module = details.fold } = await Effect.runPromise(documentCheck(pool)(document));
await pool.close();
return module;
Expand Down Expand Up @@ -73,7 +77,7 @@ async function foldedInPages(
events: number,
size: number,
): Promise<Progress & { readonly pages: number }> {
const pool = programPool({ workers: 1, heapMegabytes: recallBounds.heapMegabytes });
const pool = programPool({ handed, workers: 1, heapMegabytes: recallBounds.heapMegabytes });
const starts = Array.from({ length: Math.ceil(events / size) }, (_, index) => index * size);
const done = await starts.reduce<Promise<Progress>>(
async (before, start) => {
Expand Down
9 changes: 2 additions & 7 deletions capabilities/recall/src/testing/recall-runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { CapabilityAnswer, PreparedDefinition, Capability, RunContext } fro
import {
checkingWithin,
checksAwaitedAtMostMs,
measuredPoolSettings,
noLongestRuns,
nothingSaved,
recordingJournal,
Expand Down Expand Up @@ -44,17 +45,11 @@ afterEach(async () => {
await Promise.all(pools.splice(0).map((pool) => pool.close()));
});

const measured: Readonly<Record<string, string>> = Object.fromEntries(
Object.entries(process.env).flatMap(([key, value]: readonly [string, string | undefined]) =>
key === 'NODE_V8_COVERAGE' && value !== undefined ? [[key, value]] : [],
),
);

export function poolOf(settings: Partial<PoolSettings> = {}): ProgramPool {
const pool = programPool({
workers: 2,
heapMegabytes: recallBounds.heapMegabytes,
environment: measured,
...measuredPoolSettings,
...settings,
});
pools.push(pool);
Expand Down
Loading
Loading