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
7 changes: 4 additions & 3 deletions .agents/skills/formal-json-value-identity/check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ if (args.includes("--full")) {
env.FORMAL_RUNS = value("--runs") ?? env.FORMAL_RUNS;
env.FORMAL_SEED = value("--seed") ?? env.FORMAL_SEED;

const build = spawnSync("pnpm", ["run", "--silent", "build"], { cwd: root, encoding: "utf8" });
const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc");
const build = spawnSync(process.execPath, [tsc], { cwd: root, encoding: "utf8" });
if (build.status !== 0) {
console.error(`${build.stdout}${build.stderr}`);
process.exit(TOOL_ERROR);
}
const ajs = path.join(root, "node_modules", ".bin", "ajs");
const test = spawnSync(ajs, ["module", "test", ".", "-f", "dist/test/formal-json-value-identity.test.js"], {
const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js");
const test = spawnSync(process.execPath, [ajs, "module", "test", ".", "-f", "dist/test/formal-json-value-identity.test.js"], {
cwd: root,
env,
encoding: "utf8",
Expand Down
7 changes: 4 additions & 3 deletions .agents/skills/formal-merge-repeated-keys/check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ if (args.includes("--full")) {
env.FORMAL_RUNS = value("--runs") ?? env.FORMAL_RUNS;
env.FORMAL_SEED = value("--seed") ?? env.FORMAL_SEED;

const build = spawnSync("pnpm", ["run", "--silent", "build"], { cwd: root, encoding: "utf8" });
const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc");
const build = spawnSync(process.execPath, [tsc], { cwd: root, encoding: "utf8" });
if (build.status !== 0) {
console.error(`${build.stdout}${build.stderr}`);
process.exit(TOOL_ERROR);
}
const ajs = path.join(root, "node_modules", ".bin", "ajs");
const test = spawnSync(ajs, ["module", "test", ".", "-f", "dist/test/formal-key-merge.test.js"], {
const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js");
const test = spawnSync(process.execPath, [ajs, "module", "test", ".", "-f", "dist/test/formal-key-merge.test.js"], {
cwd: root,
env,
encoding: "utf8",
Expand Down
21 changes: 11 additions & 10 deletions .agents/skills/formal-pipeline-chains/check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { parseArgs } from "node:util";

const TOOL_ERROR = 2;
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
const tsc = path.join(root, "node_modules", "typescript", "bin", "tsc");
const ajs = path.join(root, "node_modules", "@antelopejs", "core", "dist", "core", "cli", "index.js");

const PROPERTIES = [
{ name: "ChainsMatchReference", file: "dist/formal-pipeline-chains/pipeline-chains.test.js", runs: "CHAINS_RUNS", ci: 1000, full: 10_000 },
Expand All @@ -28,15 +30,16 @@ const { values } = parseArgs({
});

/**
* Runs a command to its end and answers its exit code and everything it printed.
* @param {string} command
* Runs a Node script to its end in this Node, which needs no shell on Windows, and answers its exit
* code and everything it printed.
* @param {string} script
* @param {string[]} args
* @param {Record<string, string>} [env]
* @returns {Promise<{ code: number, output: string }>}
*/
function run(command, args, env = {}) {
function run(script, args, env = {}) {
return new Promise((resolve) => {
const child = spawn(command, args, { cwd: root, env: { ...process.env, ...env } });
const child = spawn(process.execPath, [script, ...args], { cwd: root, env: { ...process.env, ...env } });
let output = "";
child.stdout.on("data", (chunk) => (output += chunk));
child.stderr.on("data", (chunk) => (output += chunk));
Expand Down Expand Up @@ -64,16 +67,14 @@ function counterexample(output) {
}

if (!values["no-build"]) {
const built = await run("pnpm", ["run", "build"]);
const built = await run(tsc, []);
if (built.code !== 0) {
console.error(`pnpm run build failed\n${built.output}`);
console.error(`tsc failed on the module\n${built.output}`);
process.exit(TOOL_ERROR);
}
}

const compiled = await run("pnpm", [
"exec",
"tsc",
const compiled = await run(tsc, [
"-p",
".agents/skills/formal-pipeline-chains/tsconfig.json",
"--outDir",
Expand All @@ -90,7 +91,7 @@ for (const property of PROPERTIES) {
if (values.seed) {
env.CHAINS_SEED = values.seed;
}
const { code, output } = await run("pnpm", ["exec", "ajs", "module", "test", ".", "-f", property.file], env);
const { code, output } = await run(ajs, ["module", "test", ".", "-f", property.file], env);
if (code === 0) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ async function Cleared(): Promise<void> {

/**
* Waits until the feed is open. A feed opens when it is first read, and a write before that is not
* delivered, so a document the chain passes is written until one is delivered. With no such
* delivered, so a document the chain passes is written until one is delivered, then deleted, and
* its removal awaited however late a loaded host delivers it. With no such
* document no write of the script is delivered either, and a pause is as good.
*/
async function Opened(reader: Reader, stages: readonly Stage[]): Promise<void> {
Expand All @@ -72,6 +73,7 @@ async function Opened(reader: Reader, stages: readonly Stage[]): Promise<void> {
await fixture.handles.items().insert(probe).run();
if (await reader.next(QUIET_MS)) {
await Cleared();
await reader.next(DELIVERY_MS);
await reader.drain(QUIET_MS);
return;
}
Expand Down
20 changes: 9 additions & 11 deletions src/test-external/distinct-large.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import { NativeWrite, RegisterSales, type SalesTables } from "./sales";
/** The bytes of JSON text each document holds. */
const DOCUMENT_BYTES = 400 * 1024;

/** The longest a dedup may take per row it reads, of a document whose numbers have at most 15 digits and no exponent. */
const MS_PER_ROW = 100;
/**
* The longest a dedup may take per row it reads, of a document whose numbers have at most 15 digits
* and no exponent. A respell quadratic in the text took over 1.1 s a row on an idle host, and the
* linear one up to 250 ms a row beside 4 busy loops per CPU.
*/
const MS_PER_ROW = 400;

/** The runs a dedup gets to come in under its budget, since a busy host only adds to its time. */
const ATTEMPTS = 3;

/**
* How many times the top-level budget a group's dedup gets: its numbering join and the unwrap of its
* keyed `JSON_OBJECTAGG` took 327 and 357 ms on the Windows runner, against 157 to 187 ms locally.
*/
const GROUP_BUDGETS = 2;

/** How many times `part` and a comma fill {@link DOCUMENT_BYTES}. */
function Fitting(part: string): number {
return Math.ceil(DOCUMENT_BYTES / (part.length + 1));
Expand Down Expand Up @@ -108,7 +106,7 @@ describe("a dedup of large external JSON documents", function () {
await NativeWrite(sql`DELETE FROM sales.w_accounts WHERE code LIKE 'jl%'`);
});

it("keeps one value per document at the top in under 0.1 s a row", async () => {
it("keeps one value per document at the top in under 0.4 s a row", async () => {
const budget = MS_PER_ROW * DOCUMENTS.length;
const [values, ms] = await Fastest(
() => Large().distinct("raw").run(),
Expand All @@ -130,8 +128,8 @@ describe("a dedup of large external JSON documents", function () {
expect(await SortBuffer()).to.equal(before);
});

it("keeps one value per document in a group in under 0.2 s a row, which 327 and 357 ms on Windows need", async () => {
const budget = MS_PER_ROW * DOCUMENTS.length * GROUP_BUDGETS;
it("keeps one value per document in a group in under 0.4 s a row", async () => {
const budget = MS_PER_ROW * DOCUMENTS.length;
const [groups, ms] = await Fastest(
() =>
Large()
Expand Down
10 changes: 7 additions & 3 deletions src/test/probe-many.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { randomBytes } from "node:crypto";

import { GetOptions } from "../config";
import { probe } from "../probe";
import { CommandCounter, PREPARE_COMMAND, Relay } from "./unit/probe-fixture";
import {
CommandCounter,
PREPARE_COMMAND,
Relay,
TIMEOUT_MS,
} from "./unit/probe-fixture";

const DATABASE = "probe_many";
const RELATIONS = 1000;
const READER = "probe_many_reader";
const SECRET = randomBytes(6).toString("hex");
/** A timeout the probe meets on each answer; the DMS check gives up after three of them. */
const TIMEOUT_MS = 400;
/** How many probe timeouts the DMS check waits before it gives up. */
const DEADLINE_IN_TIMEOUTS = 3;
/** What the probe prepares besides one statement per relation: the listing, one confirmed read and the `CREATE TABLE` check. */
const FIXED_PREPARES = 3;
Expand Down
7 changes: 5 additions & 2 deletions src/test/probe-steps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ const DATABASE = "probe_steps";
/** `ER_MAX_PREPARED_STMT_COUNT_REACHED`: the server's cap on prepared statements, whatever the account may do. */
const MAX_PREPARED_STATEMENTS = 1461;

/** How long the relay holds each chunk from the server, so a round trip takes at least that. */
const DELAY_MS = 100;
/**
* How long the relay holds each chunk from the server, so a round trip takes at least that. A
* loaded host adds over 100 ms to a round trip, which must stay under this.
*/
const DELAY_MS = 500;

/** Each step the probe takes after the sign-in, by the command that starts it. */
const STEPS = [
Expand Down
8 changes: 6 additions & 2 deletions src/test/unit/probe-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import path from "node:path";

import { IsString } from "../../implementations/database/guards";

/** How long a probe in these tests waits to connect and for each answer. */
export const TIMEOUT_MS = 1000;
/**
* How long a probe in these tests waits to connect and for each answer. Beside 4 busy loops per
* CPU, a probe took up to 4.7 s past a 1 s timeout to give up on a server that stopped answering,
* so a bound of twice this one holds on a loaded host.
*/
export const TIMEOUT_MS = 5000;

/** How long a test lets sockets settle before it counts the ones still open. */
export const CLOSE_SETTLE_MS = 1000;
Expand Down
Loading