diff --git a/apps/server/src/send_requests/terminal/tests.rs b/apps/server/src/send_requests/terminal/tests.rs index 2c434f69e..c067bf5ed 100644 --- a/apps/server/src/send_requests/terminal/tests.rs +++ b/apps/server/src/send_requests/terminal/tests.rs @@ -835,6 +835,9 @@ async fn cancel_racing_a_pointer_paste_has_exactly_one_winner() { let context = person(); for run in 0..50 { let request_id = format!("race-{run}"); + // Counted before the send: a cancelled run leaves the terminal ready, so the next + // request can be pasted before the send returns. + let before = fixture.terminals.writes("b", "term-1").len(); fixture .send(input( &request_id, @@ -844,7 +847,6 @@ async fn cancel_racing_a_pointer_paste_has_exactly_one_winner() { )) .await .unwrap(); - let before = fixture.terminals.writes("b", "term-1").len(); let (cancel, ()) = tokio::join!(fixture.service.cancel(&context, &request_id), async { fixture.terminals.set_ready("b", "term-1"); }); diff --git a/docs/operations/release.md b/docs/operations/release.md index 6ebf35f4c..1391a17bb 100644 --- a/docs/operations/release.md +++ b/docs/operations/release.md @@ -375,7 +375,10 @@ server versions describe the same build. The calling checkout is not rewritten. The three packages compile sequentially into one shared Cargo target under the isolated run root; the workflow's cached repository `target` does not warm it. -The later builds reuse the first build's registry dependencies, and after each +The later builds reuse the first build's registry dependencies. Before each +build the harness drops the workspace crates' Cargo fingerprints, because the +protected baseline and previous-stable share a version and Cargo would otherwise +link one checkout's server into the other's package. After each build the harness renames its whole bundle directory into that build's own artifact root, so packages never mix. The macOS packaging children have a 90-minute bound, Windows children 60 minutes, and Linux children 45 minutes. Each checkout's frozen dependency install retains diff --git a/scripts/seeded-desktop-upgrade-smoke.test.ts b/scripts/seeded-desktop-upgrade-smoke.test.ts index df07ac74c..cd437c34f 100644 --- a/scripts/seeded-desktop-upgrade-smoke.test.ts +++ b/scripts/seeded-desktop-upgrade-smoke.test.ts @@ -51,6 +51,7 @@ import { createSeededUpgradeWdioConfig, ManagedProcessRegistry, parseSeededDesktopUpgradeSmokeArgs, + dropWorkspaceFingerprints, prepareSeededUpgradeBuild, redactAndBoundUpgradeEvidence, writeRemoteUploadCapabilityReceipt, @@ -981,6 +982,8 @@ describe("seeded packaging build budgets", () => { const layout = createSeededUpgradeRunLayout(root, "budget-fixture"); const triple = seededUpgradeRustTarget(platform, arch); const bundleAtStart: Record> = {}; + const fingerprintsAtStart: Record> = {}; + const hostFingerprintsAtStart: Record> = {}; // Stands in for `tauri build`: like Tauri, it adds to whatever bundle directory exists // and leaves compilation state beside it in the Cargo target it was given. const runCommand = vi.fn(async (command: Parameters[0]) => { @@ -998,6 +1001,20 @@ describe("seeded packaging build budgets", () => { NodeFS.mkdirSync(NodePath.dirname(path), { recursive: true }); NodeFS.writeFileSync(path, text); }; + const fingerprints = NodePath.join(release, ".fingerprint"); + fingerprintsAtStart[build] = NodeFS.existsSync(fingerprints) + ? NodeFS.readdirSync(fingerprints).toSorted() + : []; + // Local crates and a registry dependency, as Cargo names their fingerprints. + write(NodePath.join(fingerprints, "bibcode-server-0a1b2c", "lib-bibcode_server"), build); + write(NodePath.join(fingerprints, "serde-3d4e5f", "lib-serde"), build); + write(NodePath.join(fingerprints, "portable-pty-6a7b8c", "lib-portable_pty"), build); + const hostFingerprints = NodePath.join(target, "release", ".fingerprint"); + hostFingerprintsAtStart[build] = NodeFS.existsSync(hostFingerprints) + ? NodeFS.readdirSync(hostFingerprints).toSorted() + : []; + write(NodePath.join(hostFingerprints, "bibcode-desktop-9d0e1f", "build-script"), build); + write(NodePath.join(hostFingerprints, "serde-2c3d4e", "build-script"), build); write(NodePath.join(release, "deps", `${build}.rlib`), build); if (options.omitBundleFor !== build) { write(NodePath.join(bundle, packageName(platform)), `${build} package`); @@ -1029,6 +1046,7 @@ describe("seeded packaging build budgets", () => { SeededUpgradeCommandTimeoutError, runCommand, prepareSeededUpgradeBuild, + dropWorkspaceFingerprints, seededUpgradeBundleRoot, seededUpgradeVitePlusExecutable, seededUpgradeRustTarget, @@ -1057,6 +1075,8 @@ describe("seeded packaging build budgets", () => { return { ...context, bundleAtStart, + fingerprintsAtStart, + hostFingerprintsAtStart, rename, sharedBundle: seededUpgradeBundleRoot(layout.cargoTargetRoot, platform, arch), staged, @@ -1265,6 +1285,21 @@ describe("seeded packaging build budgets", () => { expect(NodeFS.existsSync(owned.sharedBundle)).toBe(false); }); + it("rebuilds the workspace crates in every build while registry dependencies stay shared", async () => { + const owned = fixture("linux", "x64"); + await owned.run(); + expect(owned.fingerprintsAtStart).toEqual({ + candidate: [], + "previous-stable": ["serde-3d4e5f"], + "protected-baseline": ["serde-3d4e5f"], + }); + expect(owned.hostFingerprintsAtStart).toEqual({ + candidate: [], + "previous-stable": ["serde-2c3d4e"], + "protected-baseline": ["serde-2c3d4e"], + }); + }); + it("stops before later builds when a build leaves no bundle to stage", async () => { const owned = fixture("linux", "x64", { omitBundleFor: "candidate" }); await expect(owned.run()).rejects.toThrow(/stage the candidate bundle/); diff --git a/scripts/seeded-desktop-upgrade-smoke.ts b/scripts/seeded-desktop-upgrade-smoke.ts index 8cfde5ea1..9146d51d0 100644 --- a/scripts/seeded-desktop-upgrade-smoke.ts +++ b/scripts/seeded-desktop-upgrade-smoke.ts @@ -2166,6 +2166,41 @@ export async function prepareSeededUpgradeBuild( await assertSeededUpgradeBuildVersion(input); } +/** + * The protected baseline is the candidate's source stamped with the previous-stable version, so + * it shares that build's workspace crate versions, and Cargo's mtime check took previous-stable's + * server as fresh and linked it into the protected build. Dropping only the workspace crates' + * fingerprints (and the patched portable-pty's) rebuilds them from this checkout while registry + * dependencies stay shared. + */ +export async function dropWorkspaceFingerprints( + cargoTargetDirectory: string, + platform: SeededUpgradePlatform, + arch: SeededUpgradeArch, +): Promise { + // Target units live under the triple; compiled build scripts under the host profile. + for (const fingerprints of [ + NodePath.join( + cargoTargetDirectory, + seededUpgradeRustTarget(platform, arch), + "release", + ".fingerprint", + ), + NodePath.join(cargoTargetDirectory, "release", ".fingerprint"), + ]) { + const entries = await NodeFS.promises.readdir(fingerprints).catch(() => []); + for (const entry of entries) { + // The desktop graph's local crates, including the patched portable-pty. + if (/^(bibcode-server|bibcode-desktop|portable-pty)-[0-9a-f]+$/.test(entry)) { + await NodeFS.promises.rm(NodePath.join(fingerprints, entry), { + recursive: true, + force: true, + }); + } + } + } +} + const buildPackagedApplication = async (input: { readonly arch: SeededUpgradeArch; readonly artifactDirectory: string; @@ -2190,6 +2225,7 @@ const buildPackagedApplication = async (input: { ); // Tauri adds to an existing bundle directory, so clear only it; Cargo's state stays reusable. await NodeFS.promises.rm(sharedBundle, { recursive: true, force: true }); + await dropWorkspaceFingerprints(input.cargoTargetDirectory, input.platform, input.arch); await runTimedBuildCommand({ artifactDirectory: input.artifactDirectory, command: seededUpgradeVitePlusExecutable,