From 6a2b696926465d2067b9542994b79bed36f3bd3b Mon Sep 17 00:00:00 2001 From: Raghu Betina Date: Mon, 30 Nov 2026 15:35:41 -0600 Subject: [PATCH] Bind the workshop image to its tested sources The image publisher and its recipe now live in different repositories. Verify each input at the commit used for the published index and record the cold Codespace that ran it. This keeps future recipe changes from invalidating a qualified workshop image. Check recovery from the release download failure seen during cold setup. A retried asset must still match its original pinned checksum. --- .github/workflows/drawing-board.yml | 4 +- drawing-board/README.md | 39 +++++---- drawing-board/action.yml | 5 +- drawing-board/image/receipt.json | 49 +++++++---- drawing-board/script/check-agent-setup.mjs | 20 ++++- drawing-board/script/check-image-receipt.mjs | 90 +++++++++++++------- 6 files changed, 138 insertions(+), 69 deletions(-) diff --git a/.github/workflows/drawing-board.yml b/.github/workflows/drawing-board.yml index 460579b..1031098 100644 --- a/.github/workflows/drawing-board.yml +++ b/.github/workflows/drawing-board.yml @@ -11,7 +11,7 @@ on: candidate: description: Exact firstdraft/drawing-board commit to qualify required: true - default: 86bcb7f5bb13c5bb211fecdb09d5e831080d5643 + default: 6fb0694dfca90c41b326668435ed691b47de2ab6 permissions: contents: read @@ -27,7 +27,7 @@ jobs: - name: Select the exact template candidate id: candidate env: - CANDIDATE: ${{ inputs.candidate || '86bcb7f5bb13c5bb211fecdb09d5e831080d5643' }} + CANDIDATE: ${{ inputs.candidate || '6fb0694dfca90c41b326668435ed691b47de2ab6' }} run: | [[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ ]] echo "sha=$CANDIDATE" >> "$GITHUB_OUTPUT" diff --git a/drawing-board/README.md b/drawing-board/README.md index 0b33113..5890fde 100644 --- a/drawing-board/README.md +++ b/drawing-board/README.md @@ -53,7 +53,7 @@ The accepted cross-repository sequence and its safety boundaries live in | Drawing Board `bin/` | Installation diagnostics and optional Plan review | | Drawing Board `script/initialize-application` and inventory modules | Nested application's initial Git checkpoint | | Drawing Board `script/refresh-codespaces-private-port` | Existing Codespaces attachment behavior | -| `image/` | Dockerfile, locked build Features and the historical published-image receipt | +| `image/` | Dockerfile, locked build Features and the receipt for the workspace image the template uses | | `action.yml` | Source checks and two installation smokes in the exact caller checkout's Dev Container | | `image/action.yml`, `image/verify/action.yml` | Authorized image build, then AMD64 runtime / ARM64 metadata verification in a dependent job | | `script/check*` | Source, credential, installation, preservation, workshop-helper and Git-initialization checks | @@ -83,9 +83,9 @@ modules directly and keep their fixtures in temporary directories. They do not n Drawing Board's `contract` job checks out GitHub's exact PR merge candidate (or the pushed main commit), then calls `firstdraft/dockerfiles/drawing-board` at one full commit SHA. The action copies its `script/` and `image/` into an -owned ignored `tmp/` directory only in that disposable CI checkout, starts the actual candidate Dev Container with -the existing pinned `devcontainers/ci` action, and runs source checks plus the installation smoke twice. An always -step removes only that temporary directory. No maintainer code is committed to the template or retained in a +owned ignored `tmp/` directory in that disposable CI checkout and fetches the public recipe commit recorded in the +receipt. It starts the candidate Dev Container with the pinned `devcontainers/ci` action and runs the source checks +and the installation smoke twice. A final cleanup step removes the temporary directory. No maintainer code is committed to the template or retained in a student planning archive. Keep the original check name and read-only token permissions in the caller. This repository's own workflow tests changes against the explicit Drawing Board SHA in @@ -199,10 +199,12 @@ requirement. To update the image: 1. change `image/Dockerfile` or `image/.devcontainer.json` in this repository; 2. let the current Dev Container CLI regenerate `image/.devcontainer-lock.json`, then review every resolved Feature version and digest rather than editing the lock by hand; -3. after separate publication approval, update both Board image-action pins to the merged maintainer revision and - push one Board `devcontainer-image-candidate-safe-` tag (or use its existing manual dispatch); -4. verify both image platforms, then record the reviewed receipt and immutable digest, including the Board caller - revision and exact dockerfiles image-source revision; update the receipt checker for that successor provenance; +3. after separate publication approval, update both Board image-action pins to the merged maintainer revision. + Dispatch the image workflow from Board `main` once the pins merge, or publish from a retained + `devcontainer-image-candidate-safe-` tag. Future CI checkouts need the original Board commit. +4. verify both image platforms and record the immutable digest, Board caller revision and exact dockerfiles recipe + revision in `image/receipt.json`. Record the successful workflow attempt and hash that attempt's original log + archive from GitHub's Actions API. 5. prove a credential-free manifest read by immutable digest and update the receipt's observation; and 6. run the contracts, the built-container smoke twice, and one fresh non-prebuilt Codespace comparison before calling the successor digest qualified for the ordinary template. @@ -215,14 +217,16 @@ GitHub-tunneled development environment; client authentication remains key-only supersedes the per-container-host-key experiment, but does not approve consumption of its quarantined package. The candidate workflow remains Board-owned and uses its existing package-write job token. Its SHA-pinned build -and verification actions live here; they do not move a stable or `latest` tag. Keep verification in a separate job -with `needs: build`, because `devcontainers/ci` pushes during the build job's post phase. No image was published -during this relocation. -The consumed image's receipt binds its build inputs to the source commit, source tree, workflow run, platforms, -and manifest digest. The August receipt verifies its build inputs against Drawing Board history. This directory -holds the recipe for the next build. Its Ruby and locked Features can advance while the published template and its -installation smoke keep using the recorded image. The current receipt records both -anonymous access and the retained comparison Codespace as passed. That exact Codespace also proved that +and verification actions live here. The build publishes a tag for the Board commit. +Keep verification in a separate job with `needs: build`, because `devcontainers/ci` pushes during the build job's post phase. +The receipt binds the publishing workflow in Drawing Board and its image recipe in dockerfiles to their original Git +commits, trees and input bytes. It also records the platform digests, the installed AMD64 Ruby and PostgreSQL clients, +anonymous registry access and the fresh Codespace comparison. The next recipe can advance independently while the +template and installation check still use the qualified image. +Full-history CI verifies each source file at its recorded Git commit. A local mount without that history checks +the template's runtime pins against the recorded Codespace versions. The installation smoke checks the running tools. + +The August comparison Codespace proved that `script/selenium` resolves the Compose project from its runtime container identity; no speculative fallback was needed. The helper remains in use by `script/application-smoke` for the optional nested application and by `script/devcontainer-smoke` to verify that workspace setup has not started Selenium. Root-adopted applications use @@ -310,7 +314,8 @@ fallback. Review tools weekly as well as during releases. Fresh setup already selects the vendors' latest public Claude and Codex releases, and the First Draft plugin its catalog offers; verify those installers still work with the template. Review the pinned Render, Neon and Revyl CLIs, Ruby, Node, PostgreSQL, Dev Container Features, GitHub CLI, and Selenium/image -dependencies against their official releases. Render and Revyl pins carry each Linux asset's published SHA-256; +dependencies against their official releases. Render and Revyl pins carry each Linux asset's published SHA-256. +Setup retries a failed GitHub release download once with a fresh redirect and checks the same digest before installation. Revyl stays on the laptop kit's version unless the kit moves. Prepare small compatible updates and run the checks for the affected surface. A runtime pin must continue to match generated Foundations; record a concrete compatibility reason when retaining an older version. diff --git a/drawing-board/action.yml b/drawing-board/action.yml index eb64887..51b9dd6 100644 --- a/drawing-board/action.yml +++ b/drawing-board/action.yml @@ -17,8 +17,11 @@ runs: set -euo pipefail mkdir -p tmp directory="$(mktemp -d tmp/drawing-board-checks.XXXXXX)" - cp -R "$CHECKS_SOURCE/script" "$CHECKS_SOURCE/image" "$directory/" echo "directory=$directory" >> "$GITHUB_OUTPUT" + cp -R "$CHECKS_SOURCE/script" "$CHECKS_SOURCE/image" "$directory/" + recipe="$(jq -er '.recipe.commit | select(test("^[0-9a-f]{40}$"))' "$CHECKS_SOURCE/image/receipt.json")" + git init --quiet "$directory/published-recipe" + git -C "$directory/published-recipe" fetch --quiet --no-tags --depth=1 https://github.com/firstdraft/dockerfiles.git "$recipe" # Buildx 0.37.2 refuses the Dev Containers CLI's Compose build of its generated Dockerfile # (devcontainers/cli#1320). Keep 0.37.1, on the runner's own Docker engine, until a CLI # release fixes that. diff --git a/drawing-board/image/receipt.json b/drawing-board/image/receipt.json index 82e5165..50379ab 100644 --- a/drawing-board/image/receipt.json +++ b/drawing-board/image/receipt.json @@ -1,27 +1,35 @@ { - "format": "firstdraft.drawing-board-development-image/1", + "format": "firstdraft.drawing-board-development-image/2", "source": { "repository": "firstdraft/drawing-board", - "commit": "1488d6337847a0dfd7da9b7c11de895e81160421", - "tree": "4af88c915789dda2fa6d5e366e35f672981a5030", - "tag": "devcontainer-image-candidate-safe-1488d63" + "ref": "refs/heads/main", + "commit": "981e781cb77e60b8478a404bcb1456f2e9406bb7", + "tree": "0b07305413275ceb99e655c886b36a958f7d6db8" + }, + "recipe": { + "repository": "firstdraft/dockerfiles", + "commit": "f7ba4dbd3ff038d326a415186968e03371776bb5", + "tree": "e59a667a831ebccd3a0fc7fdbd21bf8003a3c5a6" }, "inputs": { - ".devcontainer/Dockerfile": "ff81e7bf2b56191d20d592429d29c1be30e0fabaffd9ae9f3c4f0f52e73cd480", - ".devcontainer/image/devcontainer.json": "5143f0ed66fd97b986b86f8be171516d194796ca3137f0a14d7580e0bb9bbe75", - ".devcontainer/image/devcontainer-lock.json": "9efc5a704e887e1c66679f574cfcb6d5eb9d0ff6b80e3fe3dffd9cbdc7db894b", - ".github/workflows/devcontainer-image.yml": "d442d1a1383fb470e5d3e6fa14f2a29b7b09b5dd33a44cfa93575c7467f806a7", - "script/devcontainer-image-smoke": "272260b7bbdbe61613e43ee3e73df2eaf3941442aaa6dc7a27a848d2da1e2134" + ".github/workflows/devcontainer-image.yml": "d28ea14cf1a4fb58e0ba36b785115d70d3f72538ac19c519f60b49f78cc24ee2", + "drawing-board/image/Dockerfile": "5a1b641bf68224435d9e73adc588911b088e90fed2d108453e36920670046acd", + "drawing-board/image/.devcontainer.json": "626aaf5ce0f4c7387dd13dd569a8b909cf828d6165421b042138d62002fee7bd", + "drawing-board/image/.devcontainer-lock.json": "0308491af2ed9565451ae5acbd151cebda6f42256db8c1e1f4de8bc865a43b82", + "drawing-board/image/action.yml": "09a877ef61e319af11acdb7df37d9d64014dc371549b13b3ec62dc9ec6680f44", + "drawing-board/image/verify/action.yml": "c10d63ef0da023ee91dec5c24d0ebb142dc670f36cb1dc64b99c7a62b4ad48ad", + "drawing-board/script/devcontainer-image-smoke": "b16ccfe7343c94bea6fef56214d50efcd064df7be9526f6672dc8b6094866235" }, "publication": { - "workflow_run": 33320822128, - "build_job": 99282366552, - "verify_job": 99284135796, + "workflow_run": 46513778683, + "workflow_attempt": 2, + "build_job": 142185403446, + "verify_job": 142192820203, "package": "ghcr.io/firstdraft/drawing-board-workspace", - "manifest": "sha256:06602be5cc829d5142c12b06c505dbf8353a3ade6751ca4bf01a785ea2c3e6e3", + "manifest": "sha256:bd687517bba9cfb91de62ddbf3f415f41096ec5c66a0bf56b6bf10ab116397cc", "platforms": { - "linux/amd64": "sha256:1c8a08347080623ce27daf13651327142eee2ac163907430614869435db2fdae", - "linux/arm64": "sha256:0d09a17e7618d69bc2fa1c57754cbb0453363a19f061686f517efceee59bde10" + "linux/amd64": "sha256:3d4e6f23756e053b4bcddf59999e97581ee871a64c3ed7a72b98a7869dec7839", + "linux/arm64": "sha256:cb90a7fee5eb86af1998c1ec4da3398ca446c612492aafc0b7b4ba8b2206d871" }, "visibility": "public", "anonymous_pull": "passed", @@ -33,7 +41,8 @@ "locked_feature_ids_present_once_in_metadata": true, "no_command_stays_running": true, "official_sshd_feature_starts_key_only_listener": true, - "postgresql_client": "18.6", + "ruby": "4.0.10", + "postgresql_client": "18.7", "psql_major": 18, "pg_dump_major": 18 }, @@ -42,7 +51,13 @@ "runtime": "not_observed" } }, - "workflow_log_sha256": "8c538bf40f5fa2fc6ead4b4f96afcfb779a0ec429e22c49b74d0df3fb0eb224d" + "workflow_log_sha256": "c569ec95809c5cfeb7b9a438f7c3754e1f9af960ba851a4b0b957fcaa0b54b66", + "comparison_codespace": { + "commit": "6fb0694dfca90c41b326668435ed691b47de2ab6", + "prebuild": false, + "ruby": "4.0.10", + "node": "24.18.0" + } }, "policy": { "ssh": { diff --git a/drawing-board/script/check-agent-setup.mjs b/drawing-board/script/check-agent-setup.mjs index 256d3a4..0ce778d 100644 --- a/drawing-board/script/check-agent-setup.mjs +++ b/drawing-board/script/check-agent-setup.mjs @@ -102,11 +102,19 @@ if (args.length === 2) { assert.equal(args[1], "-o"); const downloads = ${JSON.stringify(downloads)}; const assets = ${JSON.stringify(fixtureAssets)}; + const requested = new URL(args[3]); + const pinnedUrl = requested.origin + requested.pathname; const tool = Object.keys(downloads).find((name) => - new RegExp("^" + downloads[name].replace(/[.]/g, "[.]") + "(amd64|arm64)" + (name === "render" ? "[.]zip" : "") + "$").test(args[3])); + new RegExp("^" + downloads[name].replace(/[.]/g, "[.]") + "(amd64|arm64)" + (name === "render" ? "[.]zip" : "") + "$").test(pinnedUrl)); assert(tool, "Only the pinned Render and Revyl release assets may be downloaded: " + args[3]); - writeFileSync(args[2], assets[tool]); - appendFileSync(process.env.SETUP_TEST_INSTALLS, JSON.stringify({ agent: tool, args: [args[3].replace(/(amd64|arm64)/, "ARCH")] }) + "\\n"); + if (process.env.SETUP_TEST_EXPIRED_REDIRECT === "1") { + if (!requested.search) process.exit(22); + assert.match(requested.search, /^[?]download=[0-9]+$/); + } else { + assert.equal(requested.search, ""); + } + writeFileSync(args[2], process.env.SETUP_TEST_CORRUPT_ASSET === tool ? "wrong release bytes" : assets[tool]); + appendFileSync(process.env.SETUP_TEST_INSTALLS, JSON.stringify({ agent: tool, args: [pinnedUrl.replace(/(amd64|arm64)/, "ARCH")] }) + "\\n"); } `, 0o755); write(path.join(stubs, "unzip"), `#!/usr/bin/env node @@ -302,12 +310,18 @@ writeFileSync(path.join(prefix, "bin", name), "#!/usr/bin/env node\\nconsole.log run("bash", ["-o", "pipefail", "-c", 'curl -fsSL https://claude.ai/install.sh | bash']); run("bash", ["-o", "pipefail", "-c", 'curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh -s -- --release latest']); for (const agent of ["claude", "codex"]) assert.equal(run(path.join(home, ".local/bin", agent), ["--version"]), `${agent} 2.0.0`); + environment.SETUP_TEST_EXPIRED_REDIRECT = "1"; const rerun = run("bash", [path.join(devcontainer, "setup-agents")]); assert.equal(installs().length, 2 * expectedInstalls.length + 2); assert.deepEqual(byAgent(installs().slice(-expectedInstalls.length)), expectedInstalls, "Reruns must not reapply an obsolete client pin"); assert(rerun.includes("claude 2.0.0") && rerun.includes("codex 2.0.0")); assert(rerun.split("\n").includes(pluginVersion)); verifyPreserved(); + const corrupted = spawnSync("bash", [path.join(devcontainer, "setup-agents")], { + cwd: workspace, env: {...environment, SETUP_TEST_CORRUPT_ASSET: "render"}, encoding: "utf8", timeout: 30_000, + }); + assert.equal(corrupted.status, 1); + assert.match(corrupted.stderr, /render\.zip has SHA-256 [0-9a-f]{64}, not the pinned/); } finally { rmSync(temporary, { recursive: true, force: true }); } diff --git a/drawing-board/script/check-image-receipt.mjs b/drawing-board/script/check-image-receipt.mjs index 09592ac..fefc4cd 100755 --- a/drawing-board/script/check-image-receipt.mjs +++ b/drawing-board/script/check-image-receipt.mjs @@ -3,6 +3,7 @@ import childProcess from "node:child_process"; import crypto from "node:crypto"; import fs from "node:fs"; +import path from "node:path"; import {fileURLToPath} from "node:url"; import {parseEnv} from "node:util"; @@ -19,20 +20,24 @@ const required = (condition, message) => { } }; -required(receipt.format === "firstdraft.drawing-board-development-image/1", "The development-image receipt format changed."); +required(receipt.format === "firstdraft.drawing-board-development-image/2", "The development-image receipt format changed."); required([undefined, "0", "1"].includes(requireSourceCommit), "FIRSTDRAFT_REQUIRE_IMAGE_SOURCE_COMMIT must be 0, 1, or unset."); required(receipt.source?.repository === "firstdraft/drawing-board", "The development-image receipt must name its source repository."); required(gitObjectPattern.test(receipt.source?.commit ?? ""), "The development-image receipt must name one exact source commit."); required(gitObjectPattern.test(receipt.source?.tree ?? ""), "The development-image receipt must name one exact source tree."); -required(receipt.source?.tag === `devcontainer-image-candidate-safe-${receipt.source.commit.slice(0, 7)}`, "The development-image tag must identify its exact source commit."); - -const expectedInputPaths = [ - ".devcontainer/Dockerfile", - ".devcontainer/image/devcontainer.json", - ".devcontainer/image/devcontainer-lock.json", - ".github/workflows/devcontainer-image.yml", - "script/devcontainer-image-smoke", -].sort(); +required(receipt.recipe?.repository === "firstdraft/dockerfiles", "The image recipe must name its owning repository."); +required(gitObjectPattern.test(receipt.recipe?.commit ?? ""), "The image recipe must name the exact action revision."); +required(gitObjectPattern.test(receipt.recipe?.tree ?? ""), "The image recipe must name the exact source tree."); +const workflowPath = ".github/workflows/devcontainer-image.yml"; +const recipePaths = [ + "drawing-board/image/Dockerfile", + "drawing-board/image/.devcontainer.json", + "drawing-board/image/.devcontainer-lock.json", + "drawing-board/image/action.yml", + "drawing-board/image/verify/action.yml", + "drawing-board/script/devcontainer-image-smoke", +]; +const expectedInputPaths = [workflowPath, ...recipePaths].sort(); required(JSON.stringify(Object.keys(receipt.inputs ?? {}).sort()) === JSON.stringify(expectedInputPaths), "The development-image receipt must bind the exact reviewed source inputs."); for (const inputHash of Object.values(receipt.inputs)) { required(/^[0-9a-f]{64}$/.test(inputHash), "Each image input needs a SHA-256 digest."); @@ -40,6 +45,7 @@ for (const inputHash of Object.values(receipt.inputs)) { required(receipt.publication?.package === "ghcr.io/firstdraft/drawing-board-workspace", "The receipt must use the corrected workspace-image package."); required(Number.isSafeInteger(receipt.publication?.workflow_run) && receipt.publication.workflow_run > 0, "The receipt must bind one workflow run."); +required(Number.isSafeInteger(receipt.publication?.workflow_attempt) && receipt.publication.workflow_attempt > 0, "The receipt must identify the successful workflow attempt."); required(Number.isSafeInteger(receipt.publication?.build_job) && receipt.publication.build_job > 0, "The receipt must bind one build job."); required(Number.isSafeInteger(receipt.publication?.verify_job) && receipt.publication.verify_job > 0, "The receipt must bind one verification job."); required(sha256Pattern.test(receipt.publication?.manifest ?? ""), "The receipt must bind one immutable image index."); @@ -59,6 +65,7 @@ required(JSON.stringify(Object.keys(platforms["linux/amd64"] ?? {}).sort()) === "pg_dump_major", "postgresql_client", "psql_major", + "ruby", ].sort()), "The amd64 verification receipt must contain the exact maintained-image observations."); required(platforms["linux/amd64"]?.locked_feature_ids_present_once_in_metadata === true, "The amd64 locked-Feature-ID metadata check must be retained."); required(platforms["linux/amd64"]?.official_sshd_feature_starts_key_only_listener === true, "The amd64 maintained-SSH lifecycle check must be retained."); @@ -95,29 +102,54 @@ for (const path of trackedPaths) { required(!fs.readFileSync(path).includes(rejectedPackage), `The rejected package must not be consumed from ${path}.`); } -const sourceObject = childProcess.spawnSync("git", ["cat-file", "-e", `${receipt.source.commit}^{commit}`], { encoding: "utf8" }); -if (sourceObject.status === 0) { - const actualTree = childProcess.execFileSync("git", ["show", "-s", "--format=%T", receipt.source.commit], { encoding: "utf8" }).trim(); - required(actualTree === receipt.source.tree, "The development-image source tree does not match its commit."); - const versions = parseEnv(fs.readFileSync(".devcontainer/agent-versions.env", "utf8")); - for (const path of expectedInputPaths) { - const sourcePath = `${receipt.source.commit}:${path}`; - const sourceEntry = childProcess.spawnSync("git", ["cat-file", "-e", sourcePath]); - required(sourceEntry.status === 0, `The development-image source commit does not contain ${path}.`); - const sourceBytes = childProcess.execFileSync("git", ["show", sourcePath]); - const sourceSha256 = crypto.createHash("sha256").update(sourceBytes).digest("hex"); - required(sourceSha256 === receipt.inputs[path], `The development-image receipt does not match ${path} at its source commit.`); - if (path === ".devcontainer/Dockerfile") { - required(sourceBytes.toString().split("\n").includes(`ARG RUBY_VERSION=${versions.FOUNDATION_RUBY_VERSION}`), +function hasSourceTree(repository, source) { + const found = childProcess.spawnSync("git", ["-C", repository, "cat-file", "-e", `${source.commit}^{commit}`]); + if (found.status !== 0) { + required(requireSourceCommit !== "1", `Missing image source commit ${source.commit} in ${source.repository}.`); + return false; + } + const tree = childProcess.execFileSync("git", ["-C", repository, "rev-parse", `${source.commit}^{tree}`], {encoding: "utf8"}).trim(); + required(tree === source.tree, `Image source tree mismatch in ${source.repository}.`); + return true; +} + +function checkInput(inputPath, bytes) { + const digest = crypto.createHash("sha256").update(bytes).digest("hex"); + required(digest === receipt.inputs[inputPath], `The image receipt does not match ${inputPath}.`); +} + +if (hasSourceTree(".", receipt.source)) { + const workflow = childProcess.execFileSync("git", ["show", `${receipt.source.commit}:${workflowPath}`]); + checkInput(workflowPath, workflow); + const actions = workflow.toString().split("\n").map((line) => line.trim()); + for (const action of ["image", "image/verify"]) { + required(actions.includes(`- uses: firstdraft/dockerfiles/drawing-board/${action}@${receipt.recipe.commit}`), + `The image workflow must bind ${action} to its recorded recipe.`); + } +} + +const stagedRecipe = path.resolve(imageRoot, "../published-recipe"); +const recipeRepository = fs.existsSync(stagedRecipe) ? stagedRecipe : imageRoot; +const versions = parseEnv(fs.readFileSync(".devcontainer/agent-versions.env", "utf8")); +required(platforms["linux/amd64"].ruby === versions.FOUNDATION_RUBY_VERSION, + "The template Ruby pin must match the installed Ruby verified in the published image."); +const comparison = receipt.verification?.comparison_codespace; +required(comparison?.prebuild === false && gitObjectPattern.test(comparison?.commit ?? ""), + "The image comparison must identify the template commit tested in a fresh non-prebuilt Codespace."); +required(comparison.ruby === versions.FOUNDATION_RUBY_VERSION && comparison.node === versions.FOUNDATION_NODE_VERSION, + "The template Ruby and Node pins must match the versions installed in the comparison Codespace."); +if (hasSourceTree(recipeRepository, receipt.recipe)) { + for (const inputPath of recipePaths) { + const bytes = childProcess.execFileSync("git", ["-C", recipeRepository, "show", `${receipt.recipe.commit}:${inputPath}`]); + checkInput(inputPath, bytes); + if (inputPath === "drawing-board/image/Dockerfile") { + required(bytes.toString().split("\n").includes(`ARG RUBY_VERSION=${versions.FOUNDATION_RUBY_VERSION}`), "The template Ruby pin must match the Dockerfile of its published image."); } - if (path === ".devcontainer/image/devcontainer.json") { - const nodeVersion = JSON.parse(sourceBytes).features["ghcr.io/devcontainers/features/node:1"].version; + if (inputPath === "drawing-board/image/.devcontainer.json") { + const nodeVersion = JSON.parse(bytes).features["ghcr.io/devcontainers/features/node:1"].version; required(nodeVersion === versions.FOUNDATION_NODE_VERSION, "The template Node pin must match its published image."); } } -} else { - required(requireSourceCommit !== "1", "The development-image source commit is required but absent from this checkout."); } - console.log("Development image receipt contract passed.");