Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 16 additions & 7 deletions test/e2e/live/dcode-base-image-runtime-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import fs from "node:fs";
import { readSandboxBaseImageResolutionMetadata } from "../../../src/lib/sandbox-base-image/label-codec.ts";
import type { SandboxBaseImageResolutionMetadata } from "../../../src/lib/sandbox-base-image/types.ts";
import {
DCODE_BASE_IMAGE_ONBOARD_PLATFORM,
type DcodeBaseImageContract,
type DcodePlatform,
parseDcodeBaseImageContract,
} from "../../../tools/e2e/dcode-base-image-contract.mts";
import { requireDcodeBaseImageReference } from "../fixtures/dcode-base-image.ts";
import {
DCODE_BASE_IMAGE_ENV,
requireDcodeBaseImageReference,
} from "../fixtures/dcode-base-image.ts";
import { readRegistrySandboxEntry } from "../fixtures/phases/index.ts";

export const DCODE_BASE_IMAGE_TARGET_ID = "ubuntu-repo-cloud-langchain-deepagents-code";

const REVISION_PATTERN = /^[0-9a-f]{40}$/u;
const DCODE_BASE_IMAGE_ONBOARD_PLATFORM: DcodePlatform = "linux/amd64";

export interface DcodeBaseImageRuntimeEvidence {
contractReference: string;
Expand Down Expand Up @@ -77,17 +80,23 @@ export function parseDcodeBaseImagePublicationEvidence(
);
}
const contract = parseDcodeBaseImageContract(evidence.base);
if (
requireDcodeBaseImageReference(environment) !==
contract.platformReferences[DCODE_BASE_IMAGE_ONBOARD_PLATFORM]
) {
if (requireDcodeBaseImageReference(environment) !== contract.reference) {
throw new Error(
`Deep Agents Code onboarding reference does not match the published ${DCODE_BASE_IMAGE_ONBOARD_PLATFORM} base contract`,
"Deep Agents Code onboarding reference does not match the published base contract",
);
}
return contract;
}

export function configureDcodeBaseImageOnboardReference(
contract: DcodeBaseImageContract | undefined,
environment: NodeJS.ProcessEnv = process.env,
): void {
if (!contract) return;
environment[DCODE_BASE_IMAGE_ENV] =
contract.platformReferences[DCODE_BASE_IMAGE_ONBOARD_PLATFORM];
}

export function loadDcodeBaseImagePublicationEvidence(
targetId: string,
evidencePath: string,
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/live/registry-targets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { cloudExperimentalChecksForOnboarding } from "./cloud-experimental-check
import { runE2eCloudExperimentalChecks } from "./cloud-experimental-checks.ts";
import {
captureDcodeBaseImageRuntimeEvidence,
configureDcodeBaseImageOnboardReference,
loadDcodeBaseImagePublicationEvidence,
} from "./dcode-base-image-runtime-evidence.ts";
import { buildLiveTargetRunPlan } from "./run-plan.ts";
Expand Down Expand Up @@ -101,6 +102,7 @@ for (const [targetIndex, target] of listTargets().entries()) {
target.id,
artifacts.pathFor("dcode-base-image.json"),
);
configureDcodeBaseImageOnboardReference(dcodeBaseContract);
requireRegistryTargetSecrets(target.id, target.requiredSecrets ?? [], secrets);

expect(
Expand Down
47 changes: 4 additions & 43 deletions test/e2e/support/dcode-base-image-contract.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";

import { describe, expect, it, vi } from "vitest";

import {
DCODE_BASE_IMAGE_ONBOARD_PLATFORM,
main,
validateDcodeBaseImageContract,
validateDcodeBaseImageImports,
} from "../../../tools/e2e/dcode-base-image-contract.mts";
Expand Down Expand Up @@ -63,16 +57,15 @@ describe("Deep Agents Code E2E base contract", () => {
expect(() => validateDcodeBaseImageContract(contract(override), expected)).toThrow(message);
});

it("proves both imports from the selected platform digest in a locked-down container (#9386)", () => {
it("proves both imports from the exact digest in a locked-down container (#9049)", () => {
const runDocker = vi.fn(() => "nemoclaw-dcode-base-imports-ok");
const platformReference = `${IMAGE}@sha256:${"c".repeat(64)}`;
validateDcodeBaseImageImports(platformReference, runDocker);
validateDcodeBaseImageImports(`${IMAGE}@${DIGEST}`, runDocker);

expect(runDocker).toHaveBeenCalledWith([
"run",
"--rm",
"--platform",
DCODE_BASE_IMAGE_ONBOARD_PLATFORM,
"linux/amd64",
"--network",
"none",
"--cap-drop",
Expand All @@ -84,45 +77,13 @@ describe("Deep Agents Code E2E base contract", () => {
"999:999",
"--entrypoint",
"/opt/venv/bin/python3",
platformReference,
`${IMAGE}@${DIGEST}`,
"-I",
"-c",
'import deepagents; import deepagents_code; print("nemoclaw-dcode-base-imports-ok")',
]);
});

it("emits the selected platform reference while preserving the full contract (#9386)", () => {
const directory = mkdtempSync(join(tmpdir(), "nemoclaw-dcode-base-contract-"));
const contractPath = join(directory, "contract.json");
const outputPath = join(directory, "github-output");
const contractValue = contract();
const platformReference = `${IMAGE}@sha256:${"c".repeat(64)}`;
const runDocker = vi.fn(() => "nemoclaw-dcode-base-imports-ok");
try {
writeFileSync(contractPath, JSON.stringify(contractValue), "utf8");

main(
[contractPath],
{
GITHUB_OUTPUT: outputPath,
PUBLICATION_HEAD_SHA: HEAD_SHA,
PUBLICATION_RUN_ATTEMPT: String(RUN_ATTEMPT),
PUBLICATION_RUN_ID: String(RUN_ID),
},
runDocker,
);

const [baseReferenceOutput, contractOutput] = readFileSync(outputPath, "utf8")
.trim()
.split("\n");
expect(baseReferenceOutput).toBe(`base_ref=${platformReference}`);
expect(JSON.parse(String(contractOutput).slice("contract=".length))).toEqual(contractValue);
expect(runDocker).toHaveBeenCalledWith(expect.arrayContaining([platformReference]));
} finally {
rmSync(directory, { force: true, recursive: true });
}
});

it("rejects missing or noisy import evidence (#9049)", () => {
expect(() => validateDcodeBaseImageImports(`${IMAGE}@${DIGEST}`, () => "")).toThrow(
/did not prove both required imports/u,
Expand Down
22 changes: 16 additions & 6 deletions test/e2e/support/dcode-base-image-runtime-evidence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { describe, expect, it } from "vitest";
import type { SandboxBaseImageResolutionMetadata } from "../../../src/lib/sandbox-base-image/types.ts";
import { DCODE_BASE_IMAGE, DCODE_BASE_IMAGE_ENV } from "../fixtures/dcode-base-image.ts";
import {
configureDcodeBaseImageOnboardReference,
DCODE_BASE_IMAGE_TARGET_ID,
loadDcodeBaseImagePublicationEvidence,
parseDcodeBaseImagePublicationEvidence,
Expand All @@ -23,7 +24,7 @@ const PUBLICATION_REVISION = "e".repeat(40);

function publicationEnvironment(overrides: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
return {
[DCODE_BASE_IMAGE_ENV]: AMD64_REFERENCE,
[DCODE_BASE_IMAGE_ENV]: INDEX_REFERENCE,
...overrides,
};
}
Expand Down Expand Up @@ -99,15 +100,24 @@ describe("Deep Agents Code published base runtime evidence", () => {
});
});

it("rejects the publication index instead of the validated platform reference (#9386)", () => {
it("selects the contract platform reference for live onboarding (#9386)", () => {
const environment = publicationEnvironment();
const contract = parseDcodeBaseImagePublicationEvidence(publicationEvidence(), environment);

configureDcodeBaseImageOnboardReference(contract, environment);

expect(environment[DCODE_BASE_IMAGE_ENV]).toBe(AMD64_REFERENCE);
});

it("rejects a valid official reference that differs from the publication contract", () => {
expect(() =>
parseDcodeBaseImagePublicationEvidence(
publicationEvidence(),
publicationEnvironment({
[DCODE_BASE_IMAGE_ENV]: INDEX_REFERENCE,
[DCODE_BASE_IMAGE_ENV]: `${DCODE_BASE_IMAGE}@sha256:${"f".repeat(64)}`,
}),
),
).toThrow(/does not match the published linux\/amd64 base contract/);
).toThrow(/does not match the published base contract/);
});

it("prefers the selected manual candidate over the trusted workflow SHA", () => {
Expand Down Expand Up @@ -192,7 +202,7 @@ describe("Deep Agents Code published base runtime evidence", () => {
loadDcodeBaseImagePublicationEvidence(
DCODE_BASE_IMAGE_TARGET_ID,
`/missing-dcode-base-evidence-${process.pid}.json`,
{ [DCODE_BASE_IMAGE_ENV]: AMD64_REFERENCE },
{ [DCODE_BASE_IMAGE_ENV]: INDEX_REFERENCE },
),
).toBeUndefined();
});
Expand All @@ -204,7 +214,7 @@ describe("Deep Agents Code published base runtime evidence", () => {
`/missing-dcode-base-evidence-${process.pid}.json`,
{
GITHUB_ACTIONS: "true",
[DCODE_BASE_IMAGE_ENV]: AMD64_REFERENCE,
[DCODE_BASE_IMAGE_ENV]: INDEX_REFERENCE,
},
),
).toThrow(/GitHub Actions run is missing published base evidence/);
Expand Down
17 changes: 7 additions & 10 deletions tools/e2e/dcode-base-image-contract.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { fileURLToPath } from "node:url";
const AGENT = "langchain-deepagents-code";
const IMAGE = "ghcr.io/nvidia/nemoclaw/langchain-deepagents-code-sandbox-base";
const PLATFORMS = ["linux/amd64", "linux/arm64"] as const;
export const DCODE_BASE_IMAGE_ONBOARD_PLATFORM = "linux/amd64" as const;
const DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/u;
const SHA_PATTERN = /^[0-9a-f]{40}$/u;
const IMPORT_MARKER = "nemoclaw-dcode-base-imports-ok";
Expand Down Expand Up @@ -121,7 +120,10 @@ export function validateDcodeBaseImageContract(
if (contract.sourceRevision !== expected.headSha) {
throw new Error("base contract source revision does not match the selected publication");
}
if (contract.run.id !== expected.runId || contract.run.attempt !== expected.runAttempt) {
if (
contract.run.id !== expected.runId ||
contract.run.attempt !== expected.runAttempt
) {
throw new Error("base contract run does not match the selected publication");
}
return contract;
Expand Down Expand Up @@ -170,11 +172,7 @@ function requiredInteger(value: string | undefined, label: string): number {
return positiveInteger(Number(value), label);
}

export function main(
argv = process.argv.slice(2),
env = process.env,
runDocker?: (args: string[]) => string,
): void {
export function main(argv = process.argv.slice(2), env = process.env): void {
if (argv.length !== 1) throw new Error("expected one managed base contract path");
const outputPath = env.GITHUB_OUTPUT ?? "";
if (!outputPath || outputPath.includes("\r") || outputPath.includes("\n")) {
Expand All @@ -188,11 +186,10 @@ export function main(
headSha: env.PUBLICATION_HEAD_SHA ?? "",
},
);
const baseReference = contract.platformReferences[DCODE_BASE_IMAGE_ONBOARD_PLATFORM];
validateDcodeBaseImageImports(baseReference, runDocker);
validateDcodeBaseImageImports(contract.reference);
appendFileSync(
outputPath,
`base_ref=${baseReference}\ncontract=${JSON.stringify(contract)}\n`,
`base_ref=${contract.reference}\ncontract=${JSON.stringify(contract)}\n`,
"utf8",
);
}
Expand Down
Loading