fix(web-app-docs): replay the host-install shape the generator also publishes

A role without a container stack gets guide mode host, and the README generator renders a git clone plus make install block for it instead of a docker run. The shape guard from 9aa65a7731 refused exactly that block, so every row replaying such a role died on "the block starts no container". That commit claimed the guard was exercised in both directions; what was exercised is that it fires, not that it fires only on something unpublishable. The same commit had dropped the checkout mount the host shape needs. The harness now dispatches on the shape: a docker run block keeps running on the stack host and deploying over ssh into the target, a git clone block is replayed inside the target against the mounted tree, and a block of neither shape still fails because nothing says which machine it addresses. The documentation that still described the two shapes is back in line with the code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-10-17 14:49:41 +02:00
1 parent eb07583e80
commit 862a1429fc
4 files changed
+73 -33

No files matched your search

@@ -26,13 +26,15 @@ Reading the block off the page rather than out of the tree is the point: a reade
Placeholders (`<your-domain>`, `<your-clearnet-resolver>`) are filled from the deployment's own values, and `<your-ssh-public-key>` / `<your-ssh-private-key-file>` from an ed25519 pair generated per run under `DOCS_TEST_WORK`.
The block runs on the stack host and deploys into a throwaway target container, which is what the published recipe describes: a managed server reached over SSH. [machine.sh](../../../../../roles/web-app-docs/files/test/machine.sh) brings that target up through [files/test/compose.yml](../../../../../roles/web-app-docs/files/test/compose.yml) under the project `docs-guide-<role>`, and tears it down with `down -v --rmi local`.
A block whose own `docker run` starts the published deploy image runs on the stack host and deploys into a throwaway target container, which is what that recipe describes: a managed server reached over SSH. [machine.sh](../../../../../roles/web-app-docs/files/test/machine.sh) brings that target up through [files/test/compose.yml](../../../../../roles/web-app-docs/files/test/compose.yml) under the project `docs-guide-<role>`, and tears it down with `down -v --rmi local`.
A role without a container stack publishes the other shape, a host install that configures the machine it runs on. That block is replayed inside the target instead of on the stack host, which is why the target mounts the checkout at the stack host's own path. A block of neither shape fails the test, because nothing tells the harness which of the two machines it addresses.
`HOST` is filled with the target's own bridge address, resolved once the container is up. The target joins the default bridge so the recipe's nested `docker run` can reach it; that bridge has no DNS, so the value must be an address rather than a name. The placeholder guard therefore runs after this fill, not before it.
The machine starts from the **distribution base image**, not from an image this project publishes, so the replay also exercises the installation. `MACHINE_BASE_IMAGE` is read as `INFINITO_PARENT_IMAGE` out of the `.env` of the mounted checkout, where the env layer has already composed it from the [meta/distros.yml](../../../../../meta/distros.yml) SPOT and honoured any `custom.env` override. A missing `.env` fails the test with a pointer to `make dotenv`. The one build step of [files/test/Dockerfile](../../../../../roles/web-app-docs/files/test/Dockerfile) runs [init.sh](../../../../../roles/web-app-docs/files/test/init.sh), which returns immediately when the base already carries `/sbin/init`.
The target receives nothing but an ssh server before the replay. [sshd.sh](../../../../../roles/web-app-docs/files/test/sshd.sh) installs one, authorizes the run's public key for `root`, and `machine.sh` waits for it to answer. Everything else arrives through the deploy, which is the claim under test.
Before a recipe replay the target receives nothing but an ssh server. [sshd.sh](../../../../../roles/web-app-docs/files/test/sshd.sh) installs one, authorizes the run's public key for `root`, and `machine.sh` waits for it to answer. Everything else arrives through the deploy, which is the claim under test.
The target carries no container engine of its own. The replayed deploy installs `docker-ce` and restarts `docker.service`; a target that already ran the distribution's engine fails that restart with `failed to load listeners: no sockets found via socket activation`, because the running `docker.socket` belongs to the package being replaced. Keeping the target bare removes the collision instead of working around it. Its `/var/lib/docker` is a named volume so the installed daemon lands on a real filesystem rather than stacking `fuse-overlayfs` on `fuse-overlayfs`.
+15 -7
View File
@@ -6,12 +6,14 @@ The CLI test of `web-app-docs` reads the Production block out of the running doc
| | What it is | What runs there |
| --- | --- | --- |
| 🖥️ **Stack host** | the worker the outer play already runs on | `test.sh`, `machine.sh`, and the published block itself |
| 🎯 **Target** | a throwaway container, project `docs-guide-<role>` | systemd and an ssh server, nothing else until the deploy lands |
| 🖥️ **Stack host** | the worker the outer play already runs on | `test.sh`, `machine.sh`, and a block that starts a container |
| 🎯 **Target** | a throwaway container, project `docs-guide-<role>` | systemd and an ssh server, nothing else until the deploy lands; a host install also runs there |
| 🐳 **Recipe container** | started by the block's own `docker run`, on the stack daemon | the deploy that the instructions tell a reader to run |
The target is what the instructions call "a managed server". It is deliberately bare: everything else it ends up with arrives through the deploy under test.
A role that ships no container stack publishes a host install instead of a recipe: a block that opens with `git clone` and configures the machine it runs on. The target is that machine, so the block is replayed inside it over the checkout mounted at `DOCS_TEST_SRC_DIR`, and the two clone lines are dropped so the replay reads the tree under test. A block that neither starts a container nor clones the repository fails the test.
## Schema
```mermaid
@@ -22,6 +24,7 @@ flowchart TD
EXTRACT["2️⃣ 📖 extract.py<br>reads the block off the live docs site"]
FILL["3️⃣ 🔑 ed25519 pair + placeholder fill<br>everything except HOST"]
MACHINE["4️⃣ 🚜 machine.sh"]
SHAPE{"🔀 docker run or git clone"}
ADDR["7️⃣ 📍 HOST = the target's bridge address"]
GUARD["8️⃣ 🚦 placeholder guard"]
BLOCK["9️⃣ ▶️ bash -e block.sh"]
@@ -31,6 +34,7 @@ flowchart TD
direction TB
INIT["5️⃣ ⚙️ systemd, no engine<br>Dockerfile + init.sh"]
SSHD["6️⃣ 🔐 sshd.sh<br>ssh server + run key for root"]
HOSTRUN["▶️ bash -e block.sh in the mounted checkout<br>clone lines dropped"]
DEPLOYED["🔟 📦 docker-ce and the role"]
end
@@ -38,10 +42,13 @@ flowchart TD
TEST --> EXTRACT --> FILL --> MACHINE
MACHINE -->|"🌉 compose up"| INIT
INIT -->|"⏳ await systemd"| SSHD
INIT -->|"⏳ await systemd"| SHAPE
SHAPE -->|"🐳 recipe"| SSHD
SHAPE -->|"🏠 host install"| HOSTRUN
SSHD --> ADDR --> GUARD --> BLOCK
BLOCK --> RECIPE
RECIPE -->|"🔗 ssh as root"| DEPLOYED
HOSTRUN --> DEPLOYED
MACHINE -.->|"🧹 trap EXIT"| TARGET
classDef host fill:#e8f0fe,stroke:#1a73e8,color:#102a43;
@@ -49,12 +56,12 @@ flowchart TD
classDef pivot fill:#fef7e0,stroke:#b06000,color:#3d2600;
classDef recipe fill:#f3e8fd,stroke:#8430ce,color:#2a0b45;
class TEST,EXTRACT,FILL,MACHINE,BLOCK host;
class INIT,SSHD,DEPLOYED target;
class ADDR,GUARD pivot;
class INIT,SSHD,HOSTRUN,DEPLOYED target;
class SHAPE,ADDR,GUARD pivot;
class RECIPE recipe;
```
🔵 stack host · 🟢 target · 🟣 the recipe's own container · 🟠 the two steps that bridge them
🔵 stack host · 🟢 target · 🟣 the recipe's own container · 🟠 the steps that bridge them
## Flow
@@ -65,6 +72,7 @@ flowchart TD
| 3️⃣ | 🔑 key pair and placeholders | an ed25519 pair per run under `DOCS_TEST_WORK`; every placeholder except `HOST` is substituted |
| 4️⃣ | 🚜 `machine.sh` brings the target up | from `compose.yml`, on the default bridge |
| 5️⃣ | ⚙️ the target boots | image built from `Dockerfile` + `init.sh`; `MACHINE_BASE_IMAGE` comes from `INFINITO_PARENT_IMAGE` in the checkout's `.env` |
| 🔀 | the shape decides where the block runs | `docker run` on the stack host, `git clone` inside the target; steps 6️⃣ to 9️⃣ are the first of the two |
| 6️⃣ | 🔐 `sshd.sh` is piped in | installs an ssh server, authorizes the run's public key for `root`, writes a `PermitRootLogin prohibit-password` drop-in |
| 7️⃣ | 📍 `HOST` is filled | `container inspect --type container` reads the bridge address; the bridge has no DNS, so it is an address and not a name |
| 8️⃣ | 🚦 the guard runs | fails on any remaining `<your-`; it runs **after** step 7, because the address does not exist before it |
@@ -81,7 +89,7 @@ flowchart TD
| `DOCS_TEST_MODE` | `templates/test.env.j2` | deployment mode; the test runs only for compose |
| `DOCS_TEST_DOMAIN` | `templates/test.env.j2` | fills `<your-domain>` |
| `DOCS_TEST_DNS` | `templates/test.env.j2` | fills `<your-clearnet-resolver>` |
| `DOCS_TEST_SRC_DIR` | `templates/test.env.j2` | checkout holding the generated `.env` |
| `DOCS_TEST_SRC_DIR` | `templates/test.env.j2` | checkout holding the generated `.env`; mounted into the target at the same path, where a host install replays from it |
| `DOCS_TEST_TIMEOUT` | `templates/test.env.j2` | wait for the on-demand documentation build |
| `DOCS_TEST_WORK` | `test.sh` | holds the replay key pair |
| `DOCS_TEST_REPLAY_PUBKEY` | `test.sh` | public half, consumed by `sshd.sh` |
@@ -13,6 +13,7 @@ services:
- /run
- /run/lock
volumes:
- ${DOCS_TEST_SRC_DIR}:${DOCS_TEST_SRC_DIR}
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- engine:/var/lib/docker
+53 -24
View File
@@ -6,7 +6,8 @@
#
# Env (test.env):
# DOCS_TEST_ROLE role under replay, names the compose project
# DOCS_TEST_SRC_DIR repository checkout, holds the generated .env
# DOCS_TEST_SRC_DIR repository checkout, holds the generated .env and
# carries the tree a host install replays from
# DOCS_TEST_WORK work directory, holds the replay key pair
# DOCS_TEST_REPLAY_PUBKEY public half, authorized for root on the target
@@ -86,6 +87,50 @@ await_ssh() {
return 1
}
guard_placeholders() {
if grep -q '<your-' "${BLOCK}"; then
echo "ERROR: the instructions carry a placeholder this test does not fill:" >&2
grep -o '<your-[a-z-]*>' "${BLOCK}" | sort -u >&2
return 1
fi
return 0
}
replay_over_ssh() {
echo "=== Giving the target an ssh server the published recipe can reach ==="
machine exec -T -e DOCS_TEST_REPLAY_PUBKEY machine sh -s <"${STAGE}/sshd.sh"
local address
address="$(target_address)"
if [ -z "${address}" ]; then
echo "the ${DOCS_TEST_ROLE} target reported no bridge address" >&2
return 1
fi
await_ssh "${address}"
sed -i "s#^HOST=.*#HOST=${address}#" "${BLOCK}"
guard_placeholders
echo "=== Replay image: $(sed -nE 's#^[[:space:]]*([^[:space:]]+) bash -c .*#\1#p' "${BLOCK}" | head -1 || true) ==="
echo "=== Replaying the instructions against ${address} ==="
(cd "${DOCS_TEST_WORK}" && bash -e "${BLOCK}")
}
replay_in_target() {
guard_placeholders
if ! machine exec -T machine test -f "${DOCS_TEST_SRC_DIR}/Makefile"; then
echo "the target carries no checkout at ${DOCS_TEST_SRC_DIR}, so the host install has no tree to replay from" >&2
return 1
fi
echo "=== Dropping the clone; ${DOCS_TEST_SRC_DIR} is the tree under test ==="
sed -i -E '/^git clone /d; /^cd core$/d' "${BLOCK}"
echo "=== Replaying the instructions inside the target ==="
machine exec -T -w "${DOCS_TEST_SRC_DIR}" machine bash -e -s <"${BLOCK}"
}
REPLAY_KEY="${DOCS_TEST_WORK}/docs-guide-${DOCS_TEST_ROLE}-key"
RECIPE_WORKDIR="${HOME}/.infinito.nexus"
if [ -e "${RECIPE_WORKDIR}" ]; then
@@ -94,8 +139,12 @@ else
RECIPE_WORKDIR_PREEXISTED=0
fi
if ! grep -qE '^docker run ' "${BLOCK}"; then
echo "the ${DOCS_TEST_ROLE} block starts no container; this harness replays it on the stack host and would configure the host itself" >&2
if grep -qE '^docker run ' "${BLOCK}"; then
REPLAY=replay_over_ssh
elif grep -qE '^git clone ' "${BLOCK}"; then
REPLAY=replay_in_target
else
echo "the ${DOCS_TEST_ROLE} block neither starts a container nor clones the repository, so this harness cannot tell whether it addresses a server or the machine it runs on" >&2
exit 1
fi
@@ -108,24 +157,4 @@ trap cleanup EXIT
machine up -d --build --pull always
await_systemd
echo "=== Giving the target an ssh server the published recipe can reach ==="
machine exec -T -e DOCS_TEST_REPLAY_PUBKEY machine sh -s <"${STAGE}/sshd.sh"
TARGET_ADDRESS="$(target_address)"
if [ -z "${TARGET_ADDRESS}" ]; then
echo "the ${DOCS_TEST_ROLE} target reported no bridge address" >&2
exit 1
fi
await_ssh "${TARGET_ADDRESS}"
sed -i "s#^HOST=.*#HOST=${TARGET_ADDRESS}#" "${BLOCK}"
if grep -q '<your-' "${BLOCK}"; then
echo "ERROR: the instructions carry a placeholder this test does not fill:" >&2
grep -o '<your-[a-z-]*>' "${BLOCK}" | sort -u >&2
exit 1
fi
echo "=== Replay image: $(sed -nE 's#^[[:space:]]*([^[:space:]]+) bash -c .*#\1#p' "${BLOCK}" | head -1 || true) ==="
echo "=== Replaying the instructions against ${TARGET_ADDRESS} ==="
(cd "${DOCS_TEST_WORK}" && bash -e "${BLOCK}")
"${REPLAY}"