From ffd728b061791369d8e0acf40dbccbc7014f81c7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Aveni" Date: Thu, 8 Oct 2026 07:45:52 -0700 Subject: [PATCH] Keep pin-upgraded workbench paths relative for relocation --- src/capability-language/pin-upgrades.ts | 4 ++-- test/pin-upgrades.test.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/capability-language/pin-upgrades.ts b/src/capability-language/pin-upgrades.ts index 4f5d9aa..6dcc60b 100644 --- a/src/capability-language/pin-upgrades.ts +++ b/src/capability-language/pin-upgrades.ts @@ -481,13 +481,13 @@ export const applyPinUpgrades = async ( quixos: compiled.lock.quixos, directResources: [...compiled.directResources.entries()].map(([bindingKey, node]) => { const [kind, binding] = bindingKey.split("\0"); - return { kind, binding, resourceKey: node.key, directory: node.directory }; + return { kind, binding, resourceKey: node.key, directory: path.relative(plan.workbench, node.directory) }; }), resources: [...resources.values()].map((node) => ({ key: node.key, kind: node.kind, source: node.source, - directory: node.directory, + directory: path.relative(plan.workbench, node.directory), ...(node.resource.kind === "build" ? {} : { diff --git a/test/pin-upgrades.test.ts b/test/pin-upgrades.test.ts index 1dff5f1..0508a2b 100644 --- a/test/pin-upgrades.test.ts +++ b/test/pin-upgrades.test.ts @@ -8,6 +8,7 @@ import { execFile as callback } from "node:child_process"; import { planPinUpgrades, applyPinUpgrades, + discoverUpgradeSpec, reviewUpgradeCandidate, type UpgradeEffects, } from "../src/capability-language/pin-upgrades.js"; @@ -153,6 +154,21 @@ test( await run(workbench, "git", ["--git-dir", path.join(workbench, "remotes/named.git"), "show-ref"]), new RegExp(commit), ); + assert.equal(graph.resources[0].directory, "resources/Named"); + assert.equal(graph.directResources[0].directory, "resources/Named"); + // A retained workbench can move without keeping its original absolute path + // alive. Recovery journals remain bound to their original writer/root. + const relocated = `${workbench}-relocated`; + context.after(() => fs.rm(relocated, { recursive: true, force: true })); + await fs.cp(workbench, relocated, { recursive: true }); + const discovered = await discoverUpgradeSpec(relocated); + assert.equal(discovered.nodes[1]!.directory, "resources/Named"); + const relocatedPlan = await planPinUpgrades(relocated, { ...discovered, bootstrap: true }); + assert.equal(relocatedPlan.workbench, relocated); + assert.deepEqual( + relocatedPlan.nodes.map((node) => node.directory), + ["resources/Named", "root"], + ); }, );