Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/drawing-board.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
candidate:
description: Exact firstdraft/drawing-board commit to qualify
required: true
default: d6ba8002a2a7555bc428c3660796d982a55ff339
default: 86bcb7f5bb13c5bb211fecdb09d5e831080d5643

permissions:
contents: read
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Select the exact template candidate
id: candidate
env:
CANDIDATE: ${{ inputs.candidate || 'd6ba8002a2a7555bc428c3660796d982a55ff339' }}
CANDIDATE: ${{ inputs.candidate || '86bcb7f5bb13c5bb211fecdb09d5e831080d5643' }}
run: |
[[ "$CANDIDATE" =~ ^[0-9a-f]{40}$ ]]
echo "sha=$CANDIDATE" >> "$GITHUB_OUTPUT"
Expand Down
30 changes: 15 additions & 15 deletions drawing-board/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ release the workspace dependency early. Keep the existing five-second cadence; t
saves about four seconds locally but adds sustained polling, and Codespaces rejected the startup-only interval.
See the [follow-up startup measurements](docs/STARTUP_FOLLOWUP.md).

The template itself does not contain generated application source. For the internal alpha, Drawing Board's
`AGENTS.md` selects explicit `--output .` approval: the application replaces the workspace layout, original material
moves under `.firstdraft/design/`, and the same Git repository holds both. The primary **Use this template → Open in a
Drawing Board's workshop uses the installed Skill's current-folder Compile after the user approves the review.
Projects with published Screens pass the current approved revision. The application replaces the workspace layout,
original material moves under `.firstdraft/design/`, and the same Git repository holds both. The primary **Use this template → Open in a
codespace** route starts without a remote. Inspect and commit the staged baseline, then publish it from VS Code or
the [Codespaces publication API](https://github.com/firstdraft/drawing-board/blob/main/AGENTS.md#save-the-app-to-github) to the user's own private repository before
setup or edits. Preserve and use an existing remote when the user chooses
repository-first creation. Do not run the nested initializer or application smoke after root adoption, including their
relocated copies. The optional `--output ./application` mode keeps an ignored, separate nested application. Its initializer remains
a student tool; its optional `script/application-smoke` qualification runner lives here and is not needed by students. **Compile and publish through First Draft** selects the separate
`--github` Publication mode; **Create GitHub repository** saves the existing workspace and does not Compile again.
relocated copies. The optional `--output ./application` mode keeps an ignored, separate nested application.
Its initializer commits the reviewed Screens when supplied. Students run the initializer before setup.
The optional nested `script/application-smoke` runner lives here. **Create GitHub repository** saves the existing workspace.
The accepted cross-repository sequence and its safety boundaries live in
[DIRECT_COMPILATION_PLAN.md](docs/DIRECT_COMPILATION_PLAN.md).

Expand All @@ -61,11 +61,11 @@ The accepted cross-repository sequence and its safety boundaries live in
| `script/application-smoke`, `script/selenium` | Optional nested-app qualification; not the root materialization path |
| `docs/` | Relocation inventory and retained investigation/qualification evidence |

The nested initializer follows the generated application's own ignore rules. The only artifact-owned paths allowed to
bypass those rules are `.firstdraft/submitted-foundation-plan.json` and `.firstdraft/gaps.json`. Any other ignored
path is preserved and stops initialization; a future generated ignored file must update this narrow allowlist and
its exact-byte fixture in the same coordinated release. Canonical `0644` and `0755` modes are part of the generated
artifact contract; a mismatch requires a fresh compile into an absent directory rather than local mode repair.
The nested initializer follows the generated application's ignore rules. It explicitly stages the submitted Plan,
GapSet, and any delivered `.firstdraft/design/sketches/board.json` with the HTML and assets it declares. Other
ignored files stop initialization and stay on disk. The first commit preserves the delivered bytes. Compiler
artifact files have canonical `0644` or `0755` modes. The CLI writes screen copies under the user's umask, and
Git stores them as non-executable files.
A mode mismatch aborts initialization before the nested repository exists. Preserve that directory under the
Drawing Board's ignored, bind-mounted `tmp/` before recompiling; never use `/tmp` or the container home, and never
delete or overwrite it to manufacture an absent destination.
Expand Down Expand Up @@ -218,10 +218,10 @@ The candidate workflow remains Board-owned and uses its existing package-write j
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 retained receipt describes the prior Board publication, not a build from this new location. Its historical
source commit and blobs are still checked against Board Git history. The relocated Dockerfile and lockfile are
byte-identical; the image configuration differs only in relative build paths. The receipt binds the source revision, source
tree, workflow run, platforms, and manifest digest consumed by the template. The current receipt records both
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
`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
Expand Down
12 changes: 6 additions & 6 deletions drawing-board/image/.devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "1.10.0",
"resolved": "ghcr.io/devcontainers/features/docker-outside-of-docker@sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e",
"integrity": "sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e"
"version": "1.10.3",
"resolved": "ghcr.io/devcontainers/features/docker-outside-of-docker@sha256:b499ed838d362615b0681c2eca96525b009ecdbc1f2679351930b10fd3894bcd",
"integrity": "sha256:b499ed838d362615b0681c2eca96525b009ecdbc1f2679351930b10fd3894bcd"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "1.1.1",
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:94879eebb6a0e4e2f197de9f12db7427cb4a25b82d93c55239ce8c8fc394a1b4",
"integrity": "sha256:94879eebb6a0e4e2f197de9f12db7427cb4a25b82d93c55239ce8c8fc394a1b4"
"version": "1.1.3",
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:bd7ab48a832228f633239277552c30b353867fef2e5b037e064b4e64f0b843f2",
"integrity": "sha256:bd7ab48a832228f633239277552c30b353867fef2e5b037e064b4e64f0b843f2"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "1.7.1",
Expand Down
6 changes: 3 additions & 3 deletions drawing-board/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=4.0.5
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION@sha256:e1bd336b0f49207a2a235299f7163bf00687b24582b911be21a58f0e5c1198cd
# Match the compiled Foundation's .ruby-version.
ARG RUBY_VERSION=4.0.10
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION@sha256:e2833c30003e96c81b35c7eefa48bc34f50f4002790d76ffae5e80f33348b34f

LABEL org.opencontainers.image.source="https://github.com/firstdraft/drawing-board"
LABEL org.opencontainers.image.description="First Draft Drawing Board development environment"
Expand Down
14 changes: 8 additions & 6 deletions drawing-board/script/check
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const expectedFeatures = [
"ghcr.io/devcontainers/features/sshd:1",
"ghcr.io/rails/devcontainer/features/postgres-client:1",
].sort();
if (imageConfiguration.build.dockerfile !== "Dockerfile" || imageConfiguration.build.context !== ".") {
console.error("The image build must use its own directory.");
process.exit(1);
}
const configuredFeatures = Object.keys(imageConfiguration.features ?? {}).sort();
const lockedFeatures = Object.keys(lockfile.features ?? {}).sort();
if (JSON.stringify(configuredFeatures) !== JSON.stringify(expectedFeatures) ||
Expand Down Expand Up @@ -147,8 +151,8 @@ required(compose.includes("condition: service_healthy"), "The workspace must wai
required(!/^\s{6}selenium:\s*$/m.test(compose.split(" selenium:")[0]), "Selenium must not block ordinary workspace startup.");
required(compose.includes("selenium/standalone-chromium:4.47.0-20260808@sha256:1d3d834a2ce93f26cc0d0ae3c61abd189755b32649f5c356c6c5cf9502aa397e"), "Selenium must use the reviewed release and image digest.");
required(!compose.split(" selenium:")[1].split(" postgres:")[0].includes("restart:"), "Selenium must remain stopped after a workspace restart until requested again.");
required(dockerfile.includes("ARG RUBY_VERSION=4.0.5"), "The Drawing Board Ruby image must match generated Foundations.");
required(dockerfile.includes("ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION@sha256:e1bd336b0f49207a2a235299f7163bf00687b24582b911be21a58f0e5c1198cd"), "Use the reviewed Rails Dev Container image digest.");
required(dockerfile.includes("ARG RUBY_VERSION=4.0.10"), "The Drawing Board Ruby image must match generated Foundations.");
required(dockerfile.includes("ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION@sha256:e2833c30003e96c81b35c7eefa48bc34f50f4002790d76ffae5e80f33348b34f"), "Use the reviewed Rails Dev Container image digest.");
required(!dockerfile.includes("apt-get install") && !dockerfile.includes("openssh-server"), "OpenSSH lifecycle must remain owned by the maintained sshd Feature.");
required(!dockerfile.includes("ENTRYPOINT"), "The Dockerfile must not replace the maintained Feature entrypoint chain.");
required(dockerfile.includes("'AuthenticationMethods publickey'") &&
Expand All @@ -174,10 +178,8 @@ if grep -q '^FIRSTDRAFT_' .devcontainer/agent-versions.env; then
exit 1
fi

if ! grep -Fqx "ARG RUBY_VERSION=$FOUNDATION_RUBY_VERSION" "$checks/../image/Dockerfile" || \
! grep -Fq "\"ghcr.io/devcontainers/features/node:1\": { \"version\": \"$FOUNDATION_NODE_VERSION\" }" "$checks/../image/.devcontainer.json" || \
! grep -Fqx " image: postgres:$FOUNDATION_POSTGRES_VERSION" .devcontainer/compose.yaml; then
echo "The Drawing Board runtime pins must match the current generated Foundation." >&2
if ! grep -Fqx " image: postgres:$FOUNDATION_POSTGRES_VERSION" .devcontainer/compose.yaml; then
echo "The Drawing Board PostgreSQL pin must match its Compose service." >&2
exit 1
fi

Expand Down
27 changes: 12 additions & 15 deletions drawing-board/script/check-image-receipt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import childProcess from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import {fileURLToPath} from "node:url";
import {parseEnv} from "node:util";

const imageRoot = fileURLToPath(new URL("../image/", import.meta.url));
const receiptPath = imageRoot + "receipt.json";
Expand Down Expand Up @@ -33,22 +34,9 @@ const expectedInputPaths = [
"script/devcontainer-image-smoke",
].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 [sourcePath, localPath] of [
[".devcontainer/Dockerfile", "Dockerfile"],
[".devcontainer/image/devcontainer-lock.json", ".devcontainer-lock.json"],
]) {
const actual = crypto.createHash("sha256").update(fs.readFileSync(imageRoot + localPath)).digest("hex");
required(actual === receipt.inputs[sourcePath], `The development-image receipt does not match ${localPath}.`);
for (const inputHash of Object.values(receipt.inputs)) {
required(/^[0-9a-f]{64}$/.test(inputHash), "Each image input needs a SHA-256 digest.");
}
const configuration = JSON.parse(fs.readFileSync(imageRoot + ".devcontainer.json", "utf8"));
required(configuration.build.dockerfile === "Dockerfile" && configuration.build.context === ".",
"The relocated image build must use its own directory.");
// Only path relocation changes the recipe; the historical source is verified below.
const originalConfiguration = fs.readFileSync(imageRoot + ".devcontainer.json", "utf8")
.replace('"dockerfile": "Dockerfile"', '"dockerfile": "../Dockerfile"')
.replace('"context": "."', '"context": "../.."');
required(crypto.createHash("sha256").update(originalConfiguration).digest("hex") ===
receipt.inputs[".devcontainer/image/devcontainer.json"], "The relocated image recipe changed beyond its paths.");

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.");
Expand Down Expand Up @@ -111,13 +99,22 @@ const sourceObject = childProcess.spawnSync("git", ["cat-file", "-e", `${receipt
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}`),
"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;
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.");
Expand Down
37 changes: 37 additions & 0 deletions drawing-board/script/check-initialize-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,43 @@ try {
const expected = filesystemInventory(applicationRoot, expectedPaths);

copyApplication("custom-application");
const screenPrefix = ".firstdraft/design/sketches";
const board = {
screens: [{id: "plants", name: "Plants", source: "pages/plants.html"}],
assets: ["styles/shared.css", "assets/leaves.png", "assets/label.woff2"],
};
const screenFiles = new Map([
["board.json", JSON.stringify(board) + "\n"],
["pages/plants.html", "<main>Plants</main>\r\n"],
["styles/shared.css", "main { color: green; }\n"],
["assets/leaves.png", Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])],
["assets/label.woff2", Buffer.alloc(16 * 1024 * 1024 + 1, 0x57)],
]);
for (const ignoresFirstDraft of [true, false]) {
const destination = ignoresFirstDraft ? "screens-ignored" : "screens-tracked";
const screenApp = copyApplication(destination);
if (!ignoresFirstDraft) writeAt(screenApp, ".gitignore", "/.env*\n/config/*.key\n/node_modules\n");
writeAt(screenApp, "app/models/.keep", "");
for (const [name, bytes] of screenFiles) writeAt(screenApp, `${screenPrefix}/${name}`, bytes, 0o600);

const extra = `${screenPrefix}/unlisted.css`;
writeAt(screenApp, extra, "local file\n");
const rejected = runInitializer(destination);
assert.notEqual(rejected.status, 0, "an undeclared screen file must stop initialization");
assert.equal(fs.readFileSync(path.join(screenApp, extra), "utf8"), "local file\n");
assert.equal(fs.existsSync(path.join(screenApp, ".git")), false);
fs.unlinkSync(path.join(screenApp, extra));

const paths = [...expectedPaths, "app/models/.keep", ...Array.from(screenFiles.keys(), (name) => `${screenPrefix}/${name}`)].sort();
const before = filesystemInventory(screenApp, paths);
const initializedScreens = runInitializer(destination, {GIT_TRACE: "1"});
assert.equal(initializedScreens.status, 0, initializedScreens.stderr);
const committed = committedInventory(screenApp, path.join(screenApp, ".git"));
assertSameInventory(before, committed, "Nested screen bundle");
assert.equal(committed.find((file) => file.path === `${screenPrefix}/assets/label.woff2`).mode, "100644");
assert.equal(execFileSync("git", ["-C", screenApp, "status", "--porcelain"], {encoding: "utf8"}), "");
}

const envApplication = copyApplication("env-application");
writeAt(envApplication, ".env", "SECRET=do-not-commit\n", 0o600);
const keyApplication = copyApplication("key-application");
Expand Down
8 changes: 8 additions & 0 deletions drawing-board/script/devcontainer-image-smoke
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ socket.on("data", (chunk) => {
});
NODE

expected_ruby="$(sed -nE 's/^ARG RUBY_VERSION=([0-9]+\.[0-9]+\.[0-9]+)$/\1/p' "${repo_root}/../image/Dockerfile")"
ruby_version="$(docker exec "${container}" ruby -e 'print RUBY_VERSION')"
[[ -n "${expected_ruby}" && "${ruby_version}" == "${expected_ruby}" ]] || {
echo "The published image uses Ruby ${ruby_version}, expected ${expected_ruby} from its Dockerfile." >&2
exit 1
}
echo "Ruby ${ruby_version} passed."

psql_version="$(docker exec "${container}" psql --version)"
pg_dump_version="$(docker exec "${container}" pg_dump --version)"
printf '%s\n%s\n' "${psql_version}" "${pg_dump_version}"
Expand Down