Files
f0d695ec97
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Failing after 7s
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Failing after 6s
QRun-IO/ci-policy: native / native-result (push) Successful in 6s
chore: preserve paused QBit work and document remaining issues
Save the current implementation and README, status, and known-issue documentation at the user-requested stop. No completed release or deployment is claimed.

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: GPT-6 Codex <noreply@openai.com>
2026-11-04 10:45:28 -06:00

59 lines
3.4 KiB
JavaScript

// Copyright (C) 2026 Kingsrook, LLC.
// SPDX-License-Identifier: Apache-2.0
// Fixed trusted qualification corpus only. This is not a production compiler route.
import { mkdir, writeFile } from "node:fs/promises";
import { createHash } from "node:crypto";
import { fileURLToPath } from "node:url";
import { compile } from "../../worker/dist/compiler.js";
import { PROTOCOL, TOOLCHAIN, sourceHash } from "../../worker/dist/protocol.js";
if(process.versions.node !== "24.22.2")
{
throw new Error("QUALIFICATION_NODE_VERSION");
}
const destination = new URL("../target/native-fixtures/", import.meta.url);
await mkdir(destination, { recursive: true });
const sdk = 'import type { Context, Qqq } from "@qqq/sdk";\n';
const cases = [
{ name: "state", files: [
{ path: "main.ts", content: sdk + `import { bump, stamp, random } from './state.js';
await Promise.resolve();
export async function main(context: Context, qqq: Qqq) {
const rows = await qqq.query('purchaseOrder', ['id'], [], 1);
return { count: bump(), stamp, random, id: rows[0]?.id, actor: context.payload.actor };
}` },
{ path: "state.ts", content: "let count = 0; export function bump() { return ++count; } export const stamp = Date.now(); export const random = Math.random();" },
] },
{ name: "unicode", files: [
{ path: "main.ts", content: "import { a } from './a.js'; import { b } from './b.js'; import { c } from './c.js'; export async function main() { return { label: a + b + c }; }" },
...["a", "b", "c"].map((name, index) => ({ path: `${name}.ts`, content: `/*${"é".repeat(180000)}*/\nexport const ${name} = ${JSON.stringify(["café ", "漢字 ", "Привет"][index])};` })),
] },
{ name: "plain", files: [{ path: "main.ts", content: "export async function main() { return { label: 'plain' }; }" }] },
{ name: "script-error", files: [{ path: "main.ts", content: "export async function main() { throw new Error('fixed trusted fixture'); }" }] },
];
const hashes = [];
for(const fixture of cases)
{
const request = { protocol: PROTOCOL, type: "compile", requestId: `trusted-${fixture.name}`, strict: true,
toolchainId: TOOLCHAIN, entryPoint: "main.ts", files: fixture.files, sourceSha256: sourceHash(fixture.files) };
const result = compile(request);
if(result.success !== true || typeof result.bundle !== "string")
{
throw new Error(`TRUSTED_COMPILE_REFUSED:${fixture.name}`);
}
const record = { name: fixture.name, entryPoint: "main.ts", sourceSha256: request.sourceSha256,
toolchainId: TOOLCHAIN, bundle: result.bundle, sha256: createHash("sha256").update(result.bundle).digest("hex") };
if(fixture.name === "unicode" && Buffer.byteLength(record.bundle) <= 1024 * 1024)
{
throw new Error("UNICODE_BOUNDARY_NOT_EXERCISED");
}
const serialized = JSON.stringify(record);
await writeFile(new URL(`${fixture.name}.json`, destination), serialized, "utf8");
await writeFile(new URL(`${fixture.name}.sources.json`, destination), JSON.stringify(request), "utf8");
hashes.push({ name: fixture.name, sha256: createHash("sha256").update(serialized).digest("hex"), artifactSha256: record.sha256 });
}
await writeFile(new URL("manifest.json", destination), JSON.stringify({ scope: "fixed trusted TypeScript compiler fixtures", node: process.versions.node, toolchain: TOOLCHAIN, files: hashes }, null, 2), "utf8");
process.stdout.write(`Compiled ${cases.length} fixed trusted fixtures into ${fileURLToPath(destination)}\n`);