diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1f5161..9b39678 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,26 @@ jobs: if: matrix.os == 'ubuntu-latest' run: docker pull "$ASSERTLEDGER_CONTAINER_IMAGE" - run: pnpm check + - name: Set up Bun for the Windows x64 designated compatibility profile + if: matrix.os == 'windows-latest' && matrix.node == 22 + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.4.3 + - name: Create a fresh directory for the three qualification manifests + if: matrix.os == 'windows-latest' && matrix.node == 22 + shell: pwsh + run: | + $directory = Join-Path $env:RUNNER_TEMP ([guid]::NewGuid().ToString()) + New-Item -ItemType Directory -Path $directory -ErrorAction Stop | Out-Null + "ASSERTLEDGER_BUN143_EVIDENCE_DIR=$directory" >> $env:GITHUB_ENV + - name: Verify the additional designated runtime and replay its evidence + if: matrix.os == 'windows-latest' && matrix.node == 22 + env: + ASSERTLEDGER_BUN143_EXECUTABLE: bun + run: pnpm exec tsx --test tests/bun-143-windows-designated.test.ts + - name: Require v4, v5 and ordinary-exception evidence from this job + if: matrix.os == 'windows-latest' && matrix.node == 22 + run: pnpm exec tsx scripts/check-bun143-evidence.ts package: name: Package smoke test / Node ${{ matrix.node }} / ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c77580d..6b0c0c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +- The explicitly acknowledged Windows-native x64 backend supports an additional exact runtime + for designated Bun tests and witness import: Bun 1.4.3 at revision + `c6da4a4d3010e5553438c60f6bd76d981976867c`. Verification v4 and v5 record this runtime + in the designated profile and evidence. The primary Bun runtime is still 1.4.4. + - `doctor` accepts the detection overrides of `init`: `--package-manager`, `--test-command-json` (`-` reads stdin) and `--adapter-config`, also in `AssertLedger.doctor` options. A dry run that `init` accepts is now reproducible by `doctor`: these flags take the same values as for `init` diff --git a/docs/migration-bun-1.4.4.md b/docs/migration-bun-1.4.4.md index 4afd83d..a869349 100644 --- a/docs/migration-bun-1.4.4.md +++ b/docs/migration-bun-1.4.4.md @@ -1,11 +1,16 @@ # Qualified Bun runtime moves to 1.4.4 -The built-in Bun adapters qualify exactly one runtime. It moves from Bun 1.4.2 (revision +This records the primary runtime migration. A later, separately qualified Windows x64 +designated compatibility profile supports the exact Bun 1.4.3 release for verification v4/v5. +Its backend, evidence identity and limits are documented in [Witness import](witness-import.md#backend). +The Windows qualification job replays three manifests from a fresh directory. It requires +attributed assertions in both v4 and v5 and rejection of an ordinary exception. + +The primary runtime moves from Bun 1.4.2 (revision `744846f844374847c902b5e7fd59b4342a51ef99`, `bun --revision` prints `1.4.2+744846f84`) to Bun 1.4.4 (revision `38afee6c84fcf48c0edb2466aa4b27d287a59c30`, `bun --revision` prints `1.4.4+38afee6c8`). This is the identity of the official release binaries installed by CI. -There is no range: neither 1.4.2 nor 1.4.3 is accepted. A different revision is also refused even -when its reported version is 1.4.4; the version label alone does not qualify a rebuilt binary. +The primary profile requires this exact version and revision. This applies to the `bun-test` adapter (verification v3), the designated `bun-test-designated` adapter (verification v4 and v5, including the container and Windows-native backends), witness @@ -14,8 +19,8 @@ collector. ## What a different Bun now does -A Bun that is not exactly 1.4.4 is refused before any campaign executes. It is never a target -kill and never evidence: +For a runtime outside the exact identities admitted by the selected adapter and backend, +the version check runs before a campaign executes. - `verify` and `import-witness` exit 4 with `BUN_TEST_VERSION_UNSUPPORTED`; `explain` now names Bun 1.4.4 as the next action. diff --git a/docs/witness-import.md b/docs/witness-import.md index 3bab959..69cd6ba 100644 --- a/docs/witness-import.md +++ b/docs/witness-import.md @@ -62,6 +62,16 @@ test with the expected line, and every reference and neutral attempt must pass. ## Backend +On Windows x64, the Windows-native backend for designated tests can also import evidence +with Bun 1.4.3 revision `c6da4a4d3010e5553438c60f6bd76d981976867c`. The verifier checks the +actual executable's version, full revision, platform and architecture and records +`WINDOWS_NATIVE_UNSANDBOXED` and designated profile `1.1.0`. Both the v1 and v2 witness formats +use their usual matcher-attribution and preflight gates. The general runtime doctor, candidate +adapter, orchestration collector, container backend and other platforms retain their Bun 1.4.4 pin. +The 1.4.3 profile covers only designated Bun assertions, including Bun tests that invoke other +programs and assert on their outputs. It does not provide direct assertion attribution to Python, +PowerShell or Rust test functions. + The witness never selects its backend. The operator passes exactly one of: ```sh diff --git a/integrations/bun/driver.mjs b/integrations/bun/driver.mjs index 1e9f849..04b39c4 100644 --- a/integrations/bun/driver.mjs +++ b/integrations/bun/driver.mjs @@ -618,9 +618,6 @@ async function main() { timeout: 5_000, maxBuffer: MAX_OUTPUT_BYTES, }); - if (revision.status !== 0 || revision.stderr !== "" || revision.stdout.trim() !== BUN_REVISION) { - throw new Error("UNSUPPORTED_BUN_REVISION"); - } const candidates = JSON.parse(process.env.TESTFORGE_CANDIDATE_FILES ?? "[]"); if (!Array.isArray(candidates)) throw new Error("INVALID_CANDIDATES"); const normalizedBase = baseTests.map(normalizeRelativeFile); @@ -634,6 +631,37 @@ async function main() { if (selection !== undefined && normalizedCandidates.length > 0) { throw new Error("INVALID_DESIGNATED_SELECTION"); } + if (revision.status !== 0 || revision.stderr !== "") throw new Error("UNSUPPORTED_BUN_REVISION"); + if (revision.stdout.trim() !== BUN_REVISION) { + if ( + selection === undefined || + process.platform !== "win32" || + process.arch !== "x64" || + revision.stdout.trim() !== "1.4.3+c6da4a4d3" + ) + throw new Error("UNSUPPORTED_BUN_REVISION"); + // The CLI's usual revision display abbreviates the hash. The Windows profile pins the full + // executable revision and architecture; verify both again in the actual Bun process. + const compat = spawnSync( + executable, + ["-e", "console.log([Bun.version,Bun.revision,process.platform,process.arch].join(' '))"], + { + cwd: process.cwd(), + encoding: "utf8", + shell: false, + windowsHide: true, + timeout: 5_000, + maxBuffer: MAX_OUTPUT_BYTES, + }, + ); + if ( + compat.status !== 0 || + compat.stderr !== "" || + compat.stdout.trim() !== "1.4.3 c6da4a4d3010e5553438c60f6bd76d981976867c win32 x64" + ) { + throw new Error("UNSUPPORTED_BUN_REVISION"); + } + } await installHelper(await readFile(helperSourcePath, "utf8"), root); const junitFile = path.join(root, `__assertledger_bun_junit_${randomUUID()}.xml`); const evidenceKey = randomBytes(32); diff --git a/scripts/check-bun143-evidence.ts b/scripts/check-bun143-evidence.ts new file mode 100644 index 0000000..b74b407 --- /dev/null +++ b/scripts/check-bun143-evidence.ts @@ -0,0 +1,48 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import path from "node:path"; +import { parseEvidenceManifestV4, parseEvidenceManifestV5 } from "../src/contracts/index.js"; +import { replayEvidenceManifest } from "../src/core/index.js"; + +const directory = process.env.ASSERTLEDGER_BUN143_EVIDENCE_DIR; +assert.ok(directory, "The Windows qualification job must supply a fresh evidence directory"); +for (const [file, schema, decision, target] of [ + ["verified-4.0.0.json", "4.0.0", "VERIFIED", "ASSERTION_FAILURE"], + ["verified-5.0.0.json", "5.0.0", "VERIFIED", "ASSERTION_FAILURE"], + ["ordinary-exception.json", "4.0.0", "REJECTED", "PROCESS_CRASH"], +] as const) { + const recorded: unknown = JSON.parse(await readFile(path.join(directory, file), "utf8")); + const manifest = + schema === "4.0.0" ? parseEvidenceManifestV4(recorded) : parseEvidenceManifestV5(recorded); + assert.equal(replayEvidenceManifest(manifest).valid, true, file); + assert.equal(manifest.decision.status, decision, file); + assert.equal(manifest.isolation.level, "WINDOWS_NATIVE_UNSANDBOXED", file); + const configuration = manifest.evidenceContext.adapter.configuration; + assert.ok( + configuration && typeof configuration === "object" && !Array.isArray(configuration), + file, + ); + assert.equal(configuration.bunVersion, "1.4.3", file); + assert.equal(configuration.bunRevision, "c6da4a4d3010e5553438c60f6bd76d981976867c", file); + const profile = configuration.profile; + assert.ok(profile && typeof profile === "object" && !Array.isArray(profile), file); + assert.equal(profile.profileId, "bun-test-designated", file); + assert.equal(profile.profileVersion, "1.1.0", file); + assert.equal(profile.platform, "win32", file); + assert.equal(profile.arch, "x64", file); + for (const [world, outcome] of [ + ["reference", "PASS"], + ["neutral", "PASS"], + ["target", target], + ]) { + const rows = manifest.observations.filter( + (row) => row.worldId === world && row.candidateId === "designated", + ); + assert.deepEqual( + rows.map((row) => row.outcome), + [outcome, outcome], + file, + ); + } + console.log(`${file} replayed with decision ${decision}`); +} diff --git a/src/engine/adapters/bun-test-designated-profile.ts b/src/engine/adapters/bun-test-designated-profile.ts index 73e42df..76f0acf 100644 --- a/src/engine/adapters/bun-test-designated-profile.ts +++ b/src/engine/adapters/bun-test-designated-profile.ts @@ -22,3 +22,44 @@ export const BUN_TEST_DESIGNATED_ADAPTER_PROFILE = { supportsContainer: true, }, } as const; + +/** Separately qualified for the Windows-native v4/v5 backend only. */ +export const WINDOWS_X64_BUN_143_DESIGNATED_PROFILE = { + ...BUN_TEST_DESIGNATED_ADAPTER_PROFILE, + profileVersion: "1.1.0", + bunVersion: "1.4.3", + bunRevision: "c6da4a4d3010e5553438c60f6bd76d981976867c", + platform: "win32", + arch: "x64", + capabilities: { ...BUN_TEST_DESIGNATED_ADAPTER_PROFILE.capabilities, supportsContainer: false }, +} as const; + +export function permitsWindowsX64Bun143( + adapter: string, + backend: string, + hostPlatform: NodeJS.Platform, + hostArch: string, +): boolean { + return ( + adapter === "bun-test-designated" && + backend === "windows-native" && + hostPlatform === "win32" && + hostArch === "x64" + ); +} + +/** The regular Bun 1.4.4 profile has separate pins in each execution backend. */ +export function isWindowsX64Bun143( + version: string, + revision: string, + platform: unknown, + arch: unknown, +): boolean { + const profile = WINDOWS_X64_BUN_143_DESIGNATED_PROFILE; + return ( + version === profile.bunVersion && + revision === profile.bunRevision && + platform === profile.platform && + arch === profile.arch + ); +} diff --git a/src/engine/index.ts b/src/engine/index.ts index 4dae301..9d249e1 100644 --- a/src/engine/index.ts +++ b/src/engine/index.ts @@ -26,12 +26,12 @@ import { Readable, type Writable } from "node:stream"; import { pipeline } from "node:stream/promises"; import { fileURLToPath, pathToFileURL } from "node:url"; import { SyntaxKind } from "typescript/unstable/ast"; -import type { BunPreflightRefusal } from "../contracts/diagnostics.js"; import { assertKnownDiagnosticCodes, - knownDiagnosticCode, type KnownDiagnosticCode, + knownDiagnosticCode, } from "../contracts/diagnostic-catalogue.js"; +import type { BunPreflightRefusal } from "../contracts/diagnostics.js"; import { AdapterSchema, type AgenticBenchmarkAcquisitionRequest, @@ -49,10 +49,10 @@ import { parseRepositoryInitLockV2, parseRepositoryInitResult, parseRepositoryInitResultV2, - parseVersionedRepositoryInitResult, parseVerificationRequest, parseVersionedRepositoryInitConfig, parseVersionedRepositoryInitLock, + parseVersionedRepositoryInitResult, parseVersionedVerificationRequest, type RepositoryAuditV2, type RepositoryInitConfigV2, @@ -83,7 +83,12 @@ import { sealManifestArtifact, sha256Canonical, } from "../core/index.js"; -import { BUN_TEST_DESIGNATED_ADAPTER_PROFILE } from "./adapters/bun-test-designated-profile.js"; +import { + BUN_TEST_DESIGNATED_ADAPTER_PROFILE, + isWindowsX64Bun143, + permitsWindowsX64Bun143, + WINDOWS_X64_BUN_143_DESIGNATED_PROFILE, +} from "./adapters/bun-test-designated-profile.js"; import { BUN_TEST_ADAPTER_PROFILE } from "./adapters/bun-test-profile.js"; import { NODE_TEST_ADAPTER_PROFILE } from "./adapters/node-test-profile.js"; import { @@ -5167,12 +5172,20 @@ async function runBunExecutableProbe( environmentAllowlist: string[], timeoutMs: number, maximumOutputBytes: number, + windowsDesignated: boolean, ): Promise<{ execPath: string; bunVersion: string; bunRevision: string }> { const result = await runProcess({ executable, args: [ "-e", - "console.log(JSON.stringify({execPath:process.execPath,bunVersion:Bun.version,bunRevision:Bun.revision}))", + windowsDesignated + ? `const id = {execPath: process.execPath, bunVersion: Bun.version, bunRevision: Bun.revision}; + if (id.bunVersion === ${JSON.stringify(WINDOWS_X64_BUN_143_DESIGNATED_PROFILE.bunVersion)}) { + id.platform = process.platform; + id.arch = process.arch; + } + console.log(JSON.stringify(id));` + : "console.log(JSON.stringify({execPath:process.execPath,bunVersion:Bun.version,bunRevision:Bun.revision}))", ], cwd: repositoryRoot, environment: environmentFromAllowlist(environmentAllowlist), @@ -5190,7 +5203,10 @@ async function runBunExecutableProbe( } if ( !isRecord(report) || - Object.keys(report).sort().join("\0") !== "bunRevision\0bunVersion\0execPath" || + Object.keys(report).sort().join("\0") !== + (windowsDesignated && report.bunVersion === WINDOWS_X64_BUN_143_DESIGNATED_PROFILE.bunVersion + ? "arch\0bunRevision\0bunVersion\0execPath\0platform" + : "bunRevision\0bunVersion\0execPath") || typeof report.execPath !== "string" || report.execPath.length === 0 || typeof report.bunVersion !== "string" || @@ -5198,10 +5214,13 @@ async function runBunExecutableProbe( ) { throw new Error("BUN_TEST_EXECUTABLE_PROBE_FAILED"); } - if ( - report.bunVersion !== BUN_TEST_ADAPTER_PROFILE.bunVersion || - report.bunRevision !== BUN_TEST_ADAPTER_PROFILE.bunRevision - ) { + const current = + report.bunVersion === BUN_TEST_ADAPTER_PROFILE.bunVersion && + report.bunRevision === BUN_TEST_ADAPTER_PROFILE.bunRevision; + const designated143 = + windowsDesignated && + isWindowsX64Bun143(report.bunVersion, report.bunRevision, report.platform, report.arch); + if (!current && !designated143) { throw new Error("BUN_TEST_VERSION_UNSUPPORTED"); } return { @@ -5217,6 +5236,7 @@ async function probeBunTestExecutable( environmentAllowlist: string[], timeoutMs: number, maximumOutputBytes: number, + windowsDesignated = false, ): Promise { const first = await runBunExecutableProbe( requestedExecutable, @@ -5224,6 +5244,7 @@ async function probeBunTestExecutable( environmentAllowlist, timeoutMs, maximumOutputBytes, + windowsDesignated, ); let resolvedExecutable: string; try { @@ -5238,6 +5259,7 @@ async function probeBunTestExecutable( environmentAllowlist, timeoutMs, maximumOutputBytes, + windowsDesignated, ); if ( (await realpath(second.execPath)) !== resolvedExecutable || @@ -6812,6 +6834,12 @@ async function verifyPreparedCampaign( trustedLocalEnvironmentAllowlist(request), request.budgets.timeoutMsPerExecution, request.budgets.maximumOutputBytes, + permitsWindowsX64Bun143( + request.adapter.kind, + request.isolation.kind, + process.platform, + process.arch, + ), ) : await probeContainerBunExecutable( container, @@ -7101,7 +7129,11 @@ async function verifyPreparedCampaign( : request.adapter.kind === "bun-test-designated" && bunIdentity !== undefined ? { kind: "bun-test-designated", - profile: BUN_TEST_DESIGNATED_ADAPTER_PROFILE, + profile: + bunIdentity.bunRevision === + WINDOWS_X64_BUN_143_DESIGNATED_PROFILE.bunRevision + ? WINDOWS_X64_BUN_143_DESIGNATED_PROFILE + : BUN_TEST_DESIGNATED_ADAPTER_PROFILE, requestedExecutable: bunIdentity.requestedExecutable, resolvedExecutable: bunIdentity.resolvedExecutable, executableDigest: bunIdentity.executableDigest, diff --git a/tests/bun-143-windows-designated.test.ts b/tests/bun-143-windows-designated.test.ts new file mode 100644 index 0000000..50cf146 --- /dev/null +++ b/tests/bun-143-windows-designated.test.ts @@ -0,0 +1,142 @@ +import assert from "node:assert/strict"; +import { mkdtemp, rm, writeFile } from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import { describe, it } from "node:test"; +import { parseEvidenceManifestV4, parseEvidenceManifestV5 } from "../src/contracts/index.js"; +import { replayEvidenceManifest } from "../src/core/index.js"; +import { + isWindowsX64Bun143, + permitsWindowsX64Bun143, +} from "../src/engine/adapters/bun-test-designated-profile.js"; +import { verifyCampaign } from "../src/engine/index.js"; +import { designatedCampaign, designatedRepository, FAULT } from "./support/designated-campaign.js"; + +const executable = process.env.ASSERTLEDGER_BUN143_EXECUTABLE; +const revision = "c6da4a4d3010e5553438c60f6bd76d981976867c"; +const evidenceDirectory = process.env.ASSERTLEDGER_BUN143_EVIDENCE_DIR; + +async function retainManifest(name: string, manifest: unknown) { + if (evidenceDirectory) { + await writeFile(path.join(evidenceDirectory, name), JSON.stringify(manifest), { flag: "wx" }); + } +} + +const windowsNative = { + kind: "windows-native", + acknowledgedUnsafeExecution: true, + environmentAllowlist: ["PATH", "SystemRoot", "WINDIR", "TEMP", "TMP"], +}; + +it("admits only the exact version, full revision and platform of the additional profile", () => { + assert.equal(isWindowsX64Bun143("1.4.3", revision, "win32", "x64"), true); + for (const [version, hash, platform, arch] of [ + ["1.4.2", revision, "win32", "x64"], + ["1.4.3", revision.slice(0, 9), "win32", "x64"], + ["1.4.3", revision.slice(0, -1) + "0", "win32", "x64"], + ["1.4.3", revision, "linux", "x64"], + ["1.4.3", revision, "win32", "arm64"], + ] as const) { + assert.equal(isWindowsX64Bun143(version, hash, platform, arch), false); + } +}); + +it("offers compatibility only for the Windows x64 designated backend", () => { + assert.equal( + permitsWindowsX64Bun143("bun-test-designated", "windows-native", "win32", "x64"), + true, + ); + for (const [adapter, backend, platform, arch] of [ + ["bun-test", "windows-native", "win32", "x64"], + ["bun-test-designated", "trusted-local", "win32", "x64"], + ["bun-test-designated", "container", "win32", "x64"], + ["bun-test-designated", "windows-native", "linux", "x64"], + ["bun-test-designated", "windows-native", "win32", "arm64"], + ] as const) { + assert.equal(permitsWindowsX64Bun143(adapter, backend, platform, arch), false); + } +}); + +describe("Bun 1.4.3 Windows x64 designated qualification", { + skip: executable === undefined ? "Requires the dedicated Bun 1.4.3 runtime" : false, +}, () => { + for (const schemaVersion of ["4.0.0", "5.0.0"] as const) { + it(`attributes the designated matcher and records the actual runtime in evidence ${schemaVersion}`, async (context) => { + assert.equal(process.platform, "win32"); + assert.equal(process.arch, "x64"); + assert.ok(executable); + const root = await mkdtemp(path.join(os.tmpdir(), "assertledger-bun143-")); + context.after(() => rm(root, { recursive: true, force: true, maxRetries: 5 })); + await designatedRepository(root); + const request = designatedCampaign(root, executable, FAULT, { isolation: windowsNative }); + const manifest = + schemaVersion === "4.0.0" + ? parseEvidenceManifestV4(await verifyCampaign(request)) + : parseEvidenceManifestV5( + await verifyCampaign({ + ...request, + schemaVersion, + repository: { ...request.repository, snapshot: "test-closure", include: [] }, + adapter: { + ...request.adapter, + workingDirectory: "repository-root", + isolate: true, + trustedMatchers: [], + }, + }), + ); + assert.equal(manifest.decision.status, "VERIFIED"); + assert.equal(manifest.isolation.level, "WINDOWS_NATIVE_UNSANDBOXED"); + const adapter = manifest.evidenceContext.adapter.configuration as { + bunVersion: string; + bunRevision: string; + profile: { + bunVersion: string; + bunRevision: string; + capabilities: { supportsContainer: boolean }; + }; + }; + assert.equal(adapter.bunVersion, "1.4.3"); + assert.equal(adapter.bunRevision, revision); + assert.equal(adapter.profile.bunVersion, adapter.bunVersion); + assert.equal(adapter.profile.bunRevision, adapter.bunRevision); + assert.equal(adapter.profile.capabilities.supportsContainer, false); + for (const [world, expected] of [ + ["reference", "PASS"], + ["neutral", "PASS"], + ["target", "ASSERTION_FAILURE"], + ]) { + const rows = manifest.observations.filter( + (row) => row.worldId === world && row.candidateId !== null, + ); + assert.deepEqual( + rows.map((row) => row.outcome), + [expected, expected], + world, + ); + } + assert.equal(replayEvidenceManifest(manifest).valid, true); + await retainManifest(`verified-${schemaVersion}.json`, manifest); + }); + } + + it("does not credit an ordinary exception as a designated matcher failure", async (context) => { + assert.ok(executable); + const root = await mkdtemp(path.join(os.tmpdir(), "assertledger-bun143-nonassertion-")); + context.after(() => rm(root, { recursive: true, force: true, maxRetries: 5 })); + await designatedRepository(root); + const request = designatedCampaign( + root, + executable, + 'export const names = () => { throw new Error("calibration failure"); };', + { isolation: windowsNative }, + ); + const manifest = parseEvidenceManifestV4(await verifyCampaign(request)); + assert.notEqual(manifest.decision.status, "VERIFIED"); + assert.equal( + manifest.observations.some((row) => row.outcome === "ASSERTION_FAILURE"), + false, + ); + await retainManifest("ordinary-exception.json", manifest); + }); +});