fix: resolve operator snapshot paths beneath the configured registry root
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
||||
import { readFile as readFileAsync } from "node:fs/promises";
|
||||
import { parse, parseAllDocuments, stringify } from "yaml";
|
||||
import { resolveRuntimeBindings, type RuntimeBindings } from "./bindings.js";
|
||||
import { GitWorkspaceRepository } from "./git-repository.js";
|
||||
@@ -336,14 +337,19 @@ export async function renderActiveWorkspaceRuntime(options: {
|
||||
secretRoots: readonly string[];
|
||||
semanticRuntime: SemanticRuntimeConfig;
|
||||
}): Promise<ActiveRenderedWorkspaceRuntime> {
|
||||
const { workspace, revision } = await options.registry.read(options.workspaceId);
|
||||
const { revision } = await options.registry.read(options.workspaceId);
|
||||
const repository = new GitWorkspaceRepository(options.registryConfig);
|
||||
await repository.ensureLayout();
|
||||
// The persisted active state may reference host-side snapshot paths (written by another
|
||||
// process or installation). The operator always resolves the immutable snapshot beneath its
|
||||
// own configured registry root so the path is correct inside the container and on the host.
|
||||
const snapshotPath = options.registry.snapshotPath(revision.commit, revision.id);
|
||||
const workspace = parseWorkspaceYaml(await readFileAsync(snapshotPath, "utf8"));
|
||||
const rendered = renderWorkspaceRuntimeFromWorkspace({
|
||||
workspace,
|
||||
workspaceId: revision.id,
|
||||
workspaceRevision: revision.commit,
|
||||
revisionContentRoot: dirname(revision.snapshotPath),
|
||||
revisionContentRoot: dirname(snapshotPath),
|
||||
harnessDir: options.harnessDir,
|
||||
configPath: options.configPath,
|
||||
dataRoot: options.dataRoot,
|
||||
@@ -352,7 +358,7 @@ export async function renderActiveWorkspaceRuntime(options: {
|
||||
});
|
||||
return {
|
||||
...rendered,
|
||||
snapshotPath: revision.snapshotPath,
|
||||
snapshotPath,
|
||||
descriptorBlob: revision.blob,
|
||||
catalogBlob: (await repository.catalogBlob(revision.commit)).trim(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user