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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
15 changes: 10 additions & 5 deletions docs/migration-bun-1.4.4.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions docs/witness-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 31 additions & 3 deletions integrations/bun/driver.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
48 changes: 48 additions & 0 deletions scripts/check-bun143-evidence.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
41 changes: 41 additions & 0 deletions src/engine/adapters/bun-test-designated-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
54 changes: 43 additions & 11 deletions src/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -49,10 +49,10 @@ import {
parseRepositoryInitLockV2,
parseRepositoryInitResult,
parseRepositoryInitResultV2,
parseVersionedRepositoryInitResult,
parseVerificationRequest,
parseVersionedRepositoryInitConfig,
parseVersionedRepositoryInitLock,
parseVersionedRepositoryInitResult,
parseVersionedVerificationRequest,
type RepositoryAuditV2,
type RepositoryInitConfigV2,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand All @@ -5190,18 +5203,24 @@ 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" ||
typeof report.bunRevision !== "string"
) {
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 {
Expand All @@ -5217,13 +5236,15 @@ async function probeBunTestExecutable(
environmentAllowlist: string[],
timeoutMs: number,
maximumOutputBytes: number,
windowsDesignated = false,
): Promise<BunExecutableIdentity> {
const first = await runBunExecutableProbe(
requestedExecutable,
repositoryRoot,
environmentAllowlist,
timeoutMs,
maximumOutputBytes,
windowsDesignated,
);
let resolvedExecutable: string;
try {
Expand All @@ -5238,6 +5259,7 @@ async function probeBunTestExecutable(
environmentAllowlist,
timeoutMs,
maximumOutputBytes,
windowsDesignated,
);
if (
(await realpath(second.execPath)) !== resolvedExecutable ||
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading