From 877e3554835390a3a6be9ba2637c144c778790a4 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:00:43 +0100 Subject: [PATCH 01/46] feat(layers): add disposable offline OCI application bundle and fail-closed seeder --- docker/app-bundle.Dockerfile | 16 +++++++++++ scripts/layers/seed-apps.sh | 31 +++++++++++++++++++++ tests/test_disposable_layer_contract.py | 36 +++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 docker/app-bundle.Dockerfile create mode 100755 scripts/layers/seed-apps.sh create mode 100644 tests/test_disposable_layer_contract.py diff --git a/docker/app-bundle.Dockerfile b/docker/app-bundle.Dockerfile new file mode 100644 index 00000000..9dc61736 --- /dev/null +++ b/docker/app-bundle.Dockerfile @@ -0,0 +1,16 @@ +# App packages are built separately from the WineBot runtime. +# The builder is pinned to an already-qualified Debian digest. No network +# downloads or unverified Windows installer execution occur during startup. +ARG APP_PACK_BUILDER_IMAGE=debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a +FROM ${APP_PACK_BUILDER_IMAGE} +COPY apps/ /opt/winebot/app-payload/ +COPY scripts/layers/seed-apps.sh /usr/local/bin/winebot-seed-apps +RUN set -eu; \ + chmod 0555 /usr/local/bin/winebot-seed-apps; \ + test -d /opt/winebot/app-payload; \ + test -z "$(find /opt/winebot/app-payload -type l -print -quit)"; \ + cd /opt/winebot/app-payload; \ + find . -type f -exec sha256sum {} + | LC_ALL=C sort > /opt/winebot/app-manifest.sha256; \ + test -s /opt/winebot/app-manifest.sha256 +LABEL org.opencontainers.image.description="Disposable WineBot immutable application payload / seeder" +ENTRYPOINT ["/bin/sh", "/usr/local/bin/winebot-seed-apps"] diff --git a/scripts/layers/seed-apps.sh b/scripts/layers/seed-apps.sh new file mode 100755 index 00000000..bf78169d --- /dev/null +++ b/scripts/layers/seed-apps.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# One-shot, offline copier from immutable OCI app bundle to a versioned volume. +# Never upgrade or merge into an existing version: fail closed instead. +set -eu +umask 022 +source_dir=/opt/winebot/app-payload +volume=/winebot-apps +manifest=/opt/winebot/app-manifest.sha256 +stamp="$volume/.winebot-app-content-sha256" + +fail() { + printf 'APP_LAYER_DIAGNOSTIC stage=%s\n' "$1" >&2 + exit 1 +} + +[ -d "$source_dir" ] && [ -d "$volume" ] && [ -s "$manifest" ] || fail unavailable +[ ! -L "$volume" ] && [ ! -L "$stamp" ] || fail invalid_mount +digest="$(sha256sum "$manifest" | cut -c 1-64)" +case "$digest" in *[!0-9a-f]*|'') fail invalid_manifest;; esac +if [ -f "$stamp" ]; then + [ "$(cat "$stamp")" = "$digest" ] || fail version_mismatch + (cd "$volume" && sha256sum -c "$manifest" >/dev/null 2>&1) || fail integrity_mismatch + echo 'APP_LAYER_DIAGNOSTIC stage=existing_verified' + exit 0 +fi +[ -z "$(find "$volume" -mindepth 1 -maxdepth 1 -print -quit)" ] || fail incomplete_volume +cp -a "$source_dir"/. "$volume"/ >/dev/null 2>&1 || fail copy_failed +(cd "$volume" && sha256sum -c "$manifest" >/dev/null 2>&1) || fail integrity_mismatch +printf '%s\n' "$digest" > "$stamp.tmp" || fail stamp_failed +mv "$stamp.tmp" "$stamp" || fail stamp_failed +echo 'APP_LAYER_DIAGNOSTIC stage=created_verified' diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py new file mode 100644 index 00000000..7eedae47 --- /dev/null +++ b/tests/test_disposable_layer_contract.py @@ -0,0 +1,36 @@ +"""Source-contract tests for opt-in disposable runtime/app/state layout. + +These tests use only stdlib and deliberately do not provision real users. +An independent public Actions job performs disposable Docker replay. +""" +from pathlib import Path +import unittest + +ROOT = Path(__file__).resolve().parents[1] + + +class DisposableAppBundleSourceTests(unittest.TestCase): + def test_builder_requires_offline_manifest_and_rejects_symlinks(self): + src = (ROOT / "docker/app-bundle.Dockerfile").read_text(encoding="utf-8") + self.assertIn("FROM ${APP_PACK_BUILDER_IMAGE}", src) + self.assertIn("debian@sha256:", src) + self.assertIn("find /opt/winebot/app-payload -type l", src) + self.assertIn("app-manifest.sha256", src) + self.assertIn("COPY apps/", src) + for forbidden in ("apt-get", "curl ", "wget ", "ADD https://", "docker push"): + self.assertNotIn(forbidden, src) + + def test_seed_is_idempotent_and_never_replaces_existing_apps(self): + src = (ROOT / "scripts/layers/seed-apps.sh").read_text(encoding="utf-8") + for marker in ("stage=existing_verified", "stage=created_verified", + "version_mismatch", "integrity_mismatch", + "incomplete_volume", "sha256sum -c", "set -eu"): + self.assertIn(marker, src) + self.assertLess(src.index('if [ -f "$stamp" ]; then'), + src.index('cp -a "$source_dir"/.')) + for forbidden in ("rm -rf", "curl ", "wget ", "docker push"): + self.assertNotIn(forbidden, src) + + +if __name__ == "__main__": + unittest.main() From ddac3cb4a074aeed388a901a016f69709a64108b Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:03:07 +0100 Subject: [PATCH 02/46] feat(layers): opt-in read-only runtime with external app/user/config volumes --- compose/layered.yml | 129 ++++++++++++++++++++++++ docker/app-bundle.Dockerfile | 3 +- docker/entrypoint.sh | 35 ++++++- scripts/layers/preflight.sh | 48 +++++++++ scripts/layers/prepare-state.sh | 16 +++ tests/test_disposable_layer_contract.py | 36 +++++++ 6 files changed, 264 insertions(+), 3 deletions(-) create mode 100644 compose/layered.yml create mode 100755 scripts/layers/preflight.sh create mode 100755 scripts/layers/prepare-state.sh diff --git a/compose/layered.yml b/compose/layered.yml new file mode 100644 index 00000000..390bb1d1 --- /dev/null +++ b/compose/layered.yml @@ -0,0 +1,129 @@ +# Opt-in three-layer deployment. Use this file ALONE, never as an +# override of the legacy Compose stack; there are no build: directives. +# All state and app volumes are EXTERNAL and cannot be deleted by down -v. +name: winebot-layered +services: + app-seed: + image: ${WINEBOT_APP_BUNDLE_IMAGE:?pin application pack to sha256 digest} + user: "0:0" + network_mode: none + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + pids_limit: 64 + mem_limit: 256m + volumes: + - app-store:/winebot-apps + restart: "no" + + state-init: + image: ${WINEBOT_APP_BUNDLE_IMAGE:?pin application pack to sha256 digest} + entrypoint: ["/bin/sh", "/usr/local/bin/winebot-prepare-state"] + user: "0:0" + network_mode: none + read_only: true + cap_drop: [ALL] + cap_add: [CHOWN] + security_opt: [no-new-privileges:true] + pids_limit: 64 + mem_limit: 256m + volumes: + - wineprefix:/state/prefix + - user-home:/state/home + - config:/state/config + - userdata:/state/userdata + - artifacts:/state/artifacts + - shared:/state/shared + restart: "no" + + winebot-interactive: + image: ${WINEBOT_RUNTIME_IMAGE:?pin WineBot runtime to sha256 digest} + user: "1000:1000" + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + init: true + pids_limit: 512 + mem_limit: 3g + cpus: 2 + tmpfs: + - /tmp:rw,nosuid,nodev,mode=1777,size=256m + - /run:rw,nosuid,nodev,mode=0755,size=64m + - /var/tmp:rw,nosuid,nodev,mode=1777,size=64m + depends_on: + app-seed: + condition: service_completed_successfully + state-init: + condition: service_completed_successfully + environment: + HOME: /home/winebot + WINEBOT_STATE_MODEL: layered + WINEBOT_CONFIG_ROOT: /config + WINEBOT_SYNC_OPENBOX_CONFIG: "0" + WINEPREFIX: /wineprefix + DISPLAY: ":99" + SCREEN: 1280x720x24 + WINEARCH: win64 + MODE: interactive + BUILD_INTENT: rel + INIT_PREFIX: "1" + ENABLE_VNC: "1" + WINEBOT_RECORD: "1" + WINEBOT_INPUT_TRACE: "1" + WINEBOT_INPUT_TRACE_WINDOWS: "1" + WINEBOT_INPUT_TRACE_NETWORK: "0" + WINEBOT_LOADOUT: "" + WINE_WINETRICKS: "" + WINE_INSTALL_MS_FONTS: "0" + API_TOKEN: ${WINEBOT_API_TOKEN:?provide an API token via deployment secret delivery} + VNC_PASSWORD: ${WINEBOT_VNC_PASSWORD:?provide a VNC password via secret delivery} + ports: + - "127.0.0.1:8000:8000" + - "127.0.0.1:6080:6080" + - "127.0.0.1:5900:5900" + volumes: + - app-store:/apps:ro + - wineprefix:/wineprefix + - user-home:/home/winebot + - config:/config + - userdata:/userdata + - artifacts:/artifacts + - shared:/winebot-shared + healthcheck: + test: + - CMD-SHELL + - >- + TOKENS="$$(cat /tmp/winebot_api_token 2>/dev/null || true)"; + for TOKEN in $$TOKENS; do + [ -z "$$TOKEN" ] && continue; + curl -fsS -H "X-API-Key: $$TOKEN" + http://127.0.0.1:8000/health >/dev/null && exit 0; + done; + exit 1 + interval: 10s + timeout: 10s + retries: 30 + start_period: 30s + +volumes: + app-store: + external: true + name: ${WINEBOT_APP_VOLUME:?provide version-specific application volume name} + wineprefix: + external: true + name: ${WINEBOT_PREFIX_VOLUME:?provide persistent Wine profile volume name} + user-home: + external: true + name: ${WINEBOT_HOME_VOLUME:?provide persistent home volume name} + config: + external: true + name: ${WINEBOT_CONFIG_VOLUME:?provide persistent configuration volume name} + userdata: + external: true + name: ${WINEBOT_USERDATA_VOLUME:?provide persistent user files volume name} + artifacts: + external: true + name: ${WINEBOT_ARTIFACT_VOLUME:?provide persistent evidence volume name} + shared: + external: true + name: ${WINEBOT_SHARED_VOLUME:?provide persistent shared state volume name} diff --git a/docker/app-bundle.Dockerfile b/docker/app-bundle.Dockerfile index 9dc61736..6830dad4 100644 --- a/docker/app-bundle.Dockerfile +++ b/docker/app-bundle.Dockerfile @@ -5,8 +5,9 @@ ARG APP_PACK_BUILDER_IMAGE=debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90 FROM ${APP_PACK_BUILDER_IMAGE} COPY apps/ /opt/winebot/app-payload/ COPY scripts/layers/seed-apps.sh /usr/local/bin/winebot-seed-apps +COPY scripts/layers/prepare-state.sh /usr/local/bin/winebot-prepare-state RUN set -eu; \ - chmod 0555 /usr/local/bin/winebot-seed-apps; \ + chmod 0555 /usr/local/bin/winebot-seed-apps /usr/local/bin/winebot-prepare-state; \ test -d /opt/winebot/app-payload; \ test -z "$(find /opt/winebot/app-payload -type l -print -quit)"; \ cd /opt/winebot/app-payload; \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ccd34e85..67e006ed 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -32,6 +32,32 @@ if [ "$WINEBOT_SESSION_MODE" != "persistent" ] && [ "$WINEBOT_SESSION_MODE" != " exit 2 fi +# Opt-in layered deployments must never depend on a mutable container root. +# The one-shot state preparer has already made external volumes writable by +# uid 1000; application assets are mounted read-only. +if [ "${WINEBOT_STATE_MODEL:-legacy}" = "layered" ]; then + if [ "$(id -u)" != "1000" ] || [ "${WINEBOT_CONFIG_ROOT:-}" != "/config" ]; then + echo 'LAYERED_RUNTIME_DIAGNOSTIC stage=identity_or_config_invalid' >&2 + exit 2 + fi + if [ -n "${WINEBOT_LOADOUT:-}" ] || [ -n "${WINE_WINETRICKS:-}" ] || + [ "${WINE_INSTALL_MS_FONTS:-0}" != "0" ]; then + echo 'LAYERED_RUNTIME_DIAGNOSTIC stage=runtime_install_forbidden' >&2 + exit 2 + fi + for persistent in /wineprefix /home/winebot /config /userdata /artifacts /winebot-shared; do + if [ ! -d "$persistent" ] || [ -L "$persistent" ] || [ ! -w "$persistent" ]; then + echo 'LAYERED_RUNTIME_DIAGNOSTIC stage=persistent_mount_unavailable' >&2 + exit 2 + fi + done + if [ ! -d /apps ] || [ -w /apps ] || + [ ! -s /apps/.winebot-app-content-sha256 ]; then + echo 'LAYERED_RUNTIME_DIAGNOSTIC stage=app_mount_invalid' >&2 + exit 2 + fi +fi + # 1. Root Level Setup (User creation, permissions) source /scripts/init/00-setup-user.sh @@ -84,8 +110,13 @@ fi echo $$ > /tmp/entrypoint.user.pid # Load runtime configuration overrides -WINEBOT_CONFIG_FILE="/wineprefix/winebot.env" -WINEBOT_INSTANCE_CONFIG="/wineprefix/winebot.${HOSTNAME}.env" +if [ "${WINEBOT_STATE_MODEL:-legacy}" = "layered" ]; then + WINEBOT_CONFIG_FILE="/config/winebot.env" + WINEBOT_INSTANCE_CONFIG="/config/winebot.instance.env" +else + WINEBOT_CONFIG_FILE="/wineprefix/winebot.env" + WINEBOT_INSTANCE_CONFIG="/wineprefix/winebot.${HOSTNAME}.env" +fi if [ -f "$WINEBOT_CONFIG_FILE" ]; then chmod 600 "$WINEBOT_CONFIG_FILE" diff --git a/scripts/layers/preflight.sh b/scripts/layers/preflight.sh new file mode 100755 index 00000000..e8019bf1 --- /dev/null +++ b/scripts/layers/preflight.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Validate or initialize external volumes; never delete user state. +set -euo pipefail +case "${1:-}" in + --check|--create) operation="$1" ;; + *) echo 'LAYERED_PREFLIGHT stage=invalid_operation' >&2; exit 2 ;; +esac + +for image_var in WINEBOT_RUNTIME_IMAGE WINEBOT_APP_BUNDLE_IMAGE; do + image="${!image_var:-}" + if [[ ! "$image" =~ ^[^[:space:]]+@sha256:[0-9a-f]{64}$ ]]; then + echo 'LAYERED_PREFLIGHT stage=unpinned_image' >&2 + exit 2 + fi +done + +variables=( + WINEBOT_APP_VOLUME WINEBOT_PREFIX_VOLUME WINEBOT_HOME_VOLUME + WINEBOT_CONFIG_VOLUME WINEBOT_USERDATA_VOLUME WINEBOT_ARTIFACT_VOLUME + WINEBOT_SHARED_VOLUME +) +declare -A seen=() +for variable in "${variables[@]}"; do + value="${!variable:-}" + if [[ ! "$value" =~ ^winebot-[a-z0-9][a-z0-9-]{1,70}$ ]] || [[ -n "${seen[$value]:-}" ]]; then + echo 'LAYERED_PREFLIGHT stage=invalid_volume_namespace' >&2 + exit 2 + fi + seen[$value]=1 +done + +if ! command -v docker >/dev/null 2>&1; then + echo 'LAYERED_PREFLIGHT stage=docker_unavailable' >&2 + exit 2 +fi +for variable in "${variables[@]}"; do + volume="${!variable}" + if docker volume inspect "$volume" >/dev/null 2>&1; then continue; fi + if [ "$operation" = --check ]; then + echo 'LAYERED_PREFLIGHT stage=volume_missing' >&2 + exit 1 + fi + docker volume create "$volume" >/dev/null 2>&1 || { + echo 'LAYERED_PREFLIGHT stage=create_failed' >&2 + exit 1 + } +done +echo 'LAYERED_PREFLIGHT stage=ready' diff --git a/scripts/layers/prepare-state.sh b/scripts/layers/prepare-state.sh new file mode 100755 index 00000000..e3c985fc --- /dev/null +++ b/scripts/layers/prepare-state.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Run once per deployment before a non-root WineBot runtime starts. +# Only adjust top-level volume ownership: never traverse, wipe, or migrate +# user files. This is a disposable, network-off bootstrap process. +set -eu +fail() { + printf 'STATE_LAYER_DIAGNOSTIC stage=%s\n' "$1" >&2 + exit 1 +} +[ "$(id -u)" = 0 ] || fail invalid_identity +for dir in /state/prefix /state/home /state/config /state/userdata /state/artifacts /state/shared; do + [ -d "$dir" ] && [ ! -L "$dir" ] || fail mount_unavailable + chown 1000:1000 "$dir" >/dev/null 2>&1 || fail ownership_failed + chmod u+rwx "$dir" >/dev/null 2>&1 || fail permissions_failed +done +echo 'STATE_LAYER_DIAGNOSTIC stage=ready' diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 7eedae47..5dc3c853 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -32,5 +32,41 @@ def test_seed_is_idempotent_and_never_replaces_existing_apps(self): self.assertNotIn(forbidden, src) + def test_external_volumes_and_disposable_runtime_are_enforced(self): + source = (ROOT / "compose/layered.yml").read_text(encoding="utf-8") + self.assertEqual(source.count("external: true"), 7) + self.assertIn("condition: service_completed_successfully", source) + self.assertIn("read_only: true", source) + self.assertIn("user: \"1000:1000\"", source) + self.assertIn("app-store:/apps:ro", source) + self.assertIn("WINEBOT_STATE_MODEL: layered", source) + self.assertIn("WINEBOT_INPUT_TRACE_WINDOWS: \"1\"", source) + self.assertIn("127.0.0.1:8000:8000", source) + self.assertNotIn(" build:", source) + self.assertNotIn("actions/upload-artifact@", source) + + def test_layered_entrypoint_fail_closed_without_legacy_impact(self): + source = (ROOT / "docker/entrypoint.sh").read_text(encoding="utf-8") + self.assertIn('WINEBOT_STATE_MODEL:-legacy', source) + self.assertIn("stage=runtime_install_forbidden", source) + self.assertIn("stage=persistent_mount_unavailable", source) + self.assertIn("stage=app_mount_invalid", source) + self.assertIn('WINEBOT_CONFIG_FILE="/config/winebot.env"', source) + self.assertIn('WINEBOT_CONFIG_FILE="/wineprefix/winebot.env"', source) + + def test_state_preparer_does_not_recurse_or_remove_user_data(self): + source = (ROOT / "scripts/layers/prepare-state.sh").read_text(encoding="utf-8") + self.assertIn("chown 1000:1000", source) + self.assertNotIn("chown -R", source) + self.assertNotIn("rm -rf", source) + + def test_deployment_preflight_never_prunes_external_volumes(self): + src = (ROOT / "scripts/layers/preflight.sh").read_text(encoding="utf-8") + self.assertIn("docker volume inspect", src) + self.assertIn("docker volume create", src) + self.assertIn("stage=unpinned_image", src) + self.assertNotIn("docker volume rm", src) + self.assertNotIn("docker system prune", src) + if __name__ == "__main__": unittest.main() From 6e17993c0b2303bceee8d31d2327c081030f4642 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:07:56 +0100 Subject: [PATCH 03/46] test(layers): qualify disposable OCI bundle, persistent state replay, and build custody in public GHA --- .../disposable-layer-qualification.yml | 48 +++++++ AGENTS.md | 11 ++ docker/Dockerfile | 3 +- docs/disposable-layer-architecture.md | 123 ++++++++++++++++++ docs/installing-apps.md | 6 + scripts/ci/qualify-disposable-layers.sh | 123 ++++++++++++++++++ scripts/ci/test.sh | 3 +- tests/test_disposable_layer_contract.py | 10 ++ 8 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/disposable-layer-qualification.yml create mode 100644 docs/disposable-layer-architecture.md create mode 100755 scripts/ci/qualify-disposable-layers.sh diff --git a/.github/workflows/disposable-layer-qualification.yml b/.github/workflows/disposable-layer-qualification.yml new file mode 100644 index 00000000..0170c9ab --- /dev/null +++ b/.github/workflows/disposable-layer-qualification.yml @@ -0,0 +1,48 @@ +name: Disposable Layer Contract Qualification +on: + pull_request: + paths: + - '.github/workflows/disposable-layer-qualification.yml' + - 'compose/layered.yml' + - 'docker/app-bundle.Dockerfile' + - 'docker/Dockerfile' + - 'docker/entrypoint.sh' + - 'scripts/layers/**' + - 'scripts/ci/qualify-disposable-layers.sh' + - 'scripts/ci/test.sh' + - 'tests/test_disposable_layer_contract.py' + - 'docs/disposable-layer-architecture.md' + +permissions: + contents: read + +env: + DOCKER_BUILD_RECORD_UPLOAD: 'false' + +concurrency: + group: disposable-layer-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + source-and-replay: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - name: Checkout exact untrusted public PR source + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + persist-credentials: false + ref: ${{ github.event.pull_request.head.sha }} + - name: Verify offline source and shell contracts + run: | + python3 -m unittest discover -s tests -p 'test_disposable_layer_contract.py' -v + bash -n scripts/layers/preflight.sh + bash -n scripts/ci/qualify-disposable-layers.sh + sh -n scripts/layers/prepare-state.sh + sh -n scripts/layers/seed-apps.sh + bash -n docker/entrypoint.sh + - name: Qualify disposable images, replay and external state + run: bash scripts/ci/qualify-disposable-layers.sh + - name: Report only bounded overall result + if: success() + run: echo 'LAYER_CONTRACT_DIAGNOSTIC stage=source_and_replay_passed' diff --git a/AGENTS.md b/AGENTS.md index ce429f83..c347a1cf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,6 +2,17 @@ This document is a navigation aid for autonomous agents working on the WineBot codebase. +## Disposable three-layer deployment (opt-in) + +The authoritative architecture target separates a replaceable Wine runtime +image, immutable/versioned application pack seeded by a short-lived container, +and external persistent per-user state volumes. Start with +[docs/disposable-layer-architecture.md](docs/disposable-layer-architecture.md) +and `compose/layered.yml`. Do not run legacy per-boot loadouts or delete +volumes during housekeeping. Public GHA qualification owns synthetic +disposable-layer replay; the actual Wine 11 layered runtime is not yet +release qualified. Existing main legacy behavior is maintained. + ## 1. System Architecture WineBot is a containerized Windows application runtime (Wine 10.0) with an X11 display stack, controlled via a Python FastAPI. diff --git a/docker/Dockerfile b/docker/Dockerfile index a7b84085..b8576012 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,8 @@ ARG BUILD_DATE=unknown ARG SOURCE_REPO="https://github.com/SemperSupra/WineBot" # --- Stage 1: Tool Builders (Parallel) --- -FROM debian:trixie-slim AS tool-base +ARG TOOL_BUILDER_BASE_IMAGE=debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a +FROM ${TOOL_BUILDER_BASE_IMAGE} AS tool-base RUN apt-get update && apt-get install -y --no-install-recommends curl unzip ca-certificates && rm -rf /var/lib/apt/lists/* COPY windows-tools/download_tool.sh /download_tool.sh diff --git a/docs/disposable-layer-architecture.md b/docs/disposable-layer-architecture.md new file mode 100644 index 00000000..54386288 --- /dev/null +++ b/docs/disposable-layer-architecture.md @@ -0,0 +1,123 @@ +# WineBot: Disposable runtime / application / persistent-state architecture + +**Status:** opt-in public RDTE, **not production-promoted**. This is separate +from legacy `compose/docker-compose.yml`. Do not combine the two files until +an explicit migration/release gate has been qualified. + +## Authority and design + +Git/DLE holds desired topology, source, pins, package custody, diagnostics and +acceptance receipts. No long-lived local checkout, worktree, builder container, +runtime container, cache or privileged sidecar is authoritative. + +| Layer | Representation | Lifetime | Allowed writes | +| --- | --- | --- | --- | +| Runtime | digest-pinned OCI WineBot REL image | disposable per run/restart | `tmpfs` only; no permanent rootfs writes | +| Applications | separately built digest-pinned OCI app pack; one-shot seed into a **version-specific external** volume mounted `/apps:ro` | replaceable independently | one-shot offline pack seeder only; never a running WineBot process | +| Persistent user state | external named volumes for Wine prefix, user home, configuration, user files, session evidence, and shared state | survives upgrades, container deletion and `docker compose down` | the unprivileged runtime/user; not app seeder | + +The package *seeder* and state-preparer are short-lived, network-disabled +containers. Runtime runs as uid/gid 1000, with no capabilities, read-only image +filesystem and bounded writable tmpfs. The preparer runs as root with only +CHOWN, modifies top-level volume directory ownership but does not recursively +rewrite or delete user files. The app seeder is root inside its container but +has no Linux capabilities and no network. Neither preparer sees credentials. + +The original `/wineprefix` retains Wine registry and per-user installed-app +state; this is **not** yet a clean separation of arbitrary Windows MSI/EXE +installation mutations. The new app layer is fully usable for portable packages +and curated read-only application payloads. Nonportable installers that alter +registry, Program Files, fonts, system DLLs and user configuration still need a +future snapshot/registry-overlay/migration qualification; do not assert their +portable installation semantics from this MVP. Never download or install +unverified programs on every runtime boot. The legacy +`WINEBOT_LOADOUT`, `WINE_WINETRICKS`, and `WINE_INSTALL_MS_FONTS` runtime +install paths are fail-closed in layered mode. + +## Build / promotion + +1. Build the runtime independently in a disposable public GHA job from + pinned tool-builder and Wine base sources; tools fetched during build are + checksum-controlled. The current third-party E2E Playwright builder image + and remaining mutable input references require independent custody review + before release. Artifact signatures, SBOM and provenance remain separate + release/security gates. +2. Assemble an app pack from `apps/` into `docker/app-bundle.Dockerfile`. + The builder uses an immutable Debian digest; there is no download or Wine + installation step inside the app pack image. It creates deterministic + per-file SHA-256 manifests, rejects symlinks and exits on errors. + Restricted installers/assets must NOT be committed into the public repo; + qualify them in a private controlled app-pack build and move only permitted + verified artifacts. +3. Promote immutable runtime and app pack image **digests** independently. + Create a fresh version-specific app volume when its app-pack content + changes. The app seeder refuses existing mismatched/incomplete packs rather + than overwriting them. Roll back by selecting the older immutable + app image/dedicated volume; never alter user state implicitly. +4. Integrate installed-app registry migration only with explicit per-app + compatibility metadata and reversible, backed-up state transactions. + Uninstall or reset is never `docker compose down --volumes`. + +## Deployment contract + +Required environment variables (use a secure deployment/secret manager; never +publish values to CI logs or DLE): + +- `WINEBOT_RUNTIME_IMAGE` and `WINEBOT_APP_BUNDLE_IMAGE`: immutable + `registry/repository@sha256:<64-hex-digest>`. +- `WINEBOT_APP_VOLUME`: a **version-specific** existing external app-pack + volume, not shared with mutable user state. +- `WINEBOT_PREFIX_VOLUME`, `WINEBOT_HOME_VOLUME`, + `WINEBOT_CONFIG_VOLUME`, `WINEBOT_USERDATA_VOLUME`, + `WINEBOT_ARTIFACT_VOLUME`, `WINEBOT_SHARED_VOLUME`: independent + external volumes, each unique to the deployment/user and starting with + `winebot-`; the preflight validates distinct names. +- `WINEBOT_API_TOKEN`, `WINEBOT_VNC_PASSWORD`: secrets supplied at + deployment. The current API/VNC implementation uses environment-based + injection and must receive separate secret-file or manager qualification + before deployment beyond localhost. + +Run `bash scripts/layers/preflight.sh --check` to validate without +modification, or `--create` to initialize only missing named volumes. +Then `docker compose -f compose/layered.yml config --quiet` and +`docker compose -f compose/layered.yml up --no-build -d winebot-interactive`. +No build occurs on the deployed host. UI/API/VNC only bind loopback until +an approved authenticated ingress/proxy is independently qualified. + +`docker compose -f compose/layered.yml down` removes only containers/networks. +All volumes are declared `external: true`; even `down -v` must not delete +their data. Do not use `docker volume rm` on user/app volumes. Back up and +restore each external volume before any migration or rollback and verify the +restored user profile, application settings, files and credentials. A change to +app version may require a compatible Wine prefix migration; do not silently +rewrite the profile to make an installer pass. + +## Qualification / DX / UX + +The dedicated public `disposable-layer-qualification.yml` workflow performs +zero-secret, synthetic, network-off GHA replay: source-contract checks, shell +syntax checks, bundle build, idempotent seed, state ownership bootstrap, +read-only nonroot runtime recreation, persistent state replay, rejected app +version overwrite, fresh versioned app volume and retained profile data. +Only fixed-category results are published. Disposable CI volumes and images +are cleaned without ever touching real deployment volumes. + +This verifies architectural primitives, **not** actual layered Wine 11 GUI +startup or an arbitrary Windows installer. Remaining release gates: real +Wine 11 read-only rootfs + mounted state HIL, 55-minute soak/restart/fault +recovery with layer mount replay, Windows app install semantics, WinInspect +observer and human accessibility, external state backups, access controls, +legacy-v1 conformance, secrets handling, and source/security acceptance. + +Human UI: recognizable profiles/app-pack versions, explicit backup/rollback +warnings, and desktop settings that survive replacement. Automation DX: +stable exit statuses, bounded enumerated markers, declarative configuration +and no hidden installs. Agent DX: exact immutable image/volume IDs, DLE +evidence, no secret/raw data publication, and non-destructive reconciliation. + +## Legacy caveat + +`docs/installing-apps.md` and the older `scripts/install-app.sh` describe +the legacy mutable-prefix flow. They are **not** approved as the new app +promotion mechanism. In particular, legacy `down -v` destroys data and must +not be used to reset a layered deployment. diff --git a/docs/installing-apps.md b/docs/installing-apps.md index 485a3359..53bbdfe1 100644 --- a/docs/installing-apps.md +++ b/docs/installing-apps.md @@ -1,3 +1,9 @@ +> **Legacy mutable-prefix instructions only.** The opt-in disposable +> runtime/application/persistent-state architecture is documented in +> [Disposable Layer Architecture](disposable-layer-architecture.md). +> Never use the legacy `down -v` reset on persistent user data; layered +> deployments use external volumes and immutable application packages. +> # Installing Apps This workflow separates installation (into the persistent Wine prefix) from running the app for automation. diff --git a/scripts/ci/qualify-disposable-layers.sh b/scripts/ci/qualify-disposable-layers.sh new file mode 100755 index 00000000..f67f6cab --- /dev/null +++ b/scripts/ci/qualify-disposable-layers.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +# Public-runner-only $0 RDTE. Creates/deletes ONLY synthetic test volumes. +# No real user data, installer, credential, screenshot, raw stdout or image push. +set -euo pipefail +fail() { + printf 'LAYER_RDTE stage=%s\n' "$1" >&2 + exit 1 +} +[ "${GITHUB_ACTIONS:-}" = true ] && [ "${GITHUB_EVENT_NAME:-}" = pull_request ] || + fail unqualified_venue +[[ "${GITHUB_RUN_ID:-}" =~ ^[0-9]+$ ]] && + [[ "${GITHUB_RUN_ATTEMPT:-}" =~ ^[0-9]+$ ]] || fail invalid_identity +prefix="winebot-ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" +volumes=() +cleanup() { + for v in "${volumes[@]}"; do + docker volume rm "$v" >/dev/null 2>&1 || true + done + docker image rm winebot-apps:fixture-v1 winebot-apps:fixture-v2 >/dev/null 2>&1 || true +} +trap cleanup EXIT +export WINEBOT_RUNTIME_IMAGE="debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a" +export WINEBOT_APP_BUNDLE_IMAGE="$WINEBOT_RUNTIME_IMAGE" +export WINEBOT_APP_VOLUME="$prefix-apps-v1" +export WINEBOT_PREFIX_VOLUME="$prefix-prefix" +export WINEBOT_HOME_VOLUME="$prefix-home" +export WINEBOT_CONFIG_VOLUME="$prefix-config" +export WINEBOT_USERDATA_VOLUME="$prefix-userdata" +export WINEBOT_ARTIFACT_VOLUME="$prefix-artifacts" +export WINEBOT_SHARED_VOLUME="$prefix-shared" +export WINEBOT_API_TOKEN=synthetic-ci-only-token +export WINEBOT_VNC_PASSWORD=synthetic-ci-only-password + +# Dry-run should fail with missing external volumes, never create state. +if bash scripts/layers/preflight.sh --check >/dev/null 2>&1; then fail missing_volume_not_rejected; fi +bash scripts/layers/preflight.sh --create >/dev/null 2>&1 || fail preflight_create +bash scripts/layers/preflight.sh --check >/dev/null 2>&1 || fail preflight_check +volumes=("$WINEBOT_APP_VOLUME" "$WINEBOT_PREFIX_VOLUME" "$WINEBOT_HOME_VOLUME" + "$WINEBOT_CONFIG_VOLUME" "$WINEBOT_USERDATA_VOLUME" "$WINEBOT_ARTIFACT_VOLUME" + "$WINEBOT_SHARED_VOLUME") +docker compose -f compose/layered.yml config --quiet >/dev/null 2>&1 || fail compose_invalid + +mkdir -p apps/ci-fixture +printf 'app-fixture-v1\n' > apps/ci-fixture/version.txt +docker build -f docker/app-bundle.Dockerfile -t winebot-apps:fixture-v1 . >/dev/null 2>&1 || + fail app_build_v1 +app_image=winebot-apps:fixture-v1 +# Seed only the dedicated applications volume; never mount personal state here. +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + -v "$WINEBOT_APP_VOLUME:/winebot-apps" "$app_image" >/dev/null 2>&1 || + fail app_seed_v1 +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + -v "$WINEBOT_APP_VOLUME:/winebot-apps" "$app_image" >/dev/null 2>&1 || + fail app_seed_idempotency + +# One-shot root task prepares only volume root ownership, never user contents. +docker run --rm --network none --read-only --cap-drop ALL --cap-add CHOWN \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + --entrypoint /bin/sh \ + -v "$WINEBOT_PREFIX_VOLUME:/state/prefix" \ + -v "$WINEBOT_HOME_VOLUME:/state/home" \ + -v "$WINEBOT_CONFIG_VOLUME:/state/config" \ + -v "$WINEBOT_USERDATA_VOLUME:/state/userdata" \ + -v "$WINEBOT_ARTIFACT_VOLUME:/state/artifacts" \ + -v "$WINEBOT_SHARED_VOLUME:/state/shared" \ + "$app_image" /usr/local/bin/winebot-prepare-state >/dev/null 2>&1 || + fail state_preparation + +# Test two fully disposable nonroot containers against the same external state. +docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + --tmpfs /tmp:rw,nosuid,nodev,mode=1777 \ + --entrypoint /bin/sh \ + -v "$WINEBOT_APP_VOLUME:/apps:ro" -v "$WINEBOT_USERDATA_VOLUME:/userdata" \ + -v "$WINEBOT_CONFIG_VOLUME:/config" \ + "$app_image" -ec ' + grep -qx app-fixture-v1 /apps/ci-fixture/version.txt + printf "durable-user-file\n" >/userdata/proof.txt + printf "durable-setting\n" >/config/proof.txt + printf "ephemeral\n" >/tmp/not-retained + if touch /apps/ci-fixture/new.txt >/dev/null 2>&1; then exit 9; fi + if touch /opt/winebot/should-not-write >/dev/null 2>&1; then exit 10; fi + ' >/dev/null 2>&1 || fail first_runtime + +docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + --tmpfs /tmp:rw,nosuid,nodev,mode=1777 \ + --entrypoint /bin/sh \ + -v "$WINEBOT_APP_VOLUME:/apps:ro" -v "$WINEBOT_USERDATA_VOLUME:/userdata" \ + -v "$WINEBOT_CONFIG_VOLUME:/config" \ + "$app_image" -ec ' + grep -qx app-fixture-v1 /apps/ci-fixture/version.txt + grep -qx durable-user-file /userdata/proof.txt + grep -qx durable-setting /config/proof.txt + test ! -e /tmp/not-retained + ' >/dev/null 2>&1 || fail state_replay + +# A different app pack must refuse the old versioned volume without mutation. +printf 'app-fixture-v2\n' > apps/ci-fixture/version.txt +docker build -f docker/app-bundle.Dockerfile -t winebot-apps:fixture-v2 . >/dev/null 2>&1 || + fail app_build_v2 +if docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges -v "$WINEBOT_APP_VOLUME:/winebot-apps" \ + winebot-apps:fixture-v2 >/dev/null 2>&1; then + fail version_mismatch_not_rejected +fi +docker volume create "$prefix-apps-v2" >/dev/null 2>&1 || fail second_volume +volumes+=("$prefix-apps-v2") +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges -v "$prefix-apps-v2:/winebot-apps" \ + winebot-apps:fixture-v2 >/dev/null 2>&1 || fail app_seed_v2 +docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ + --security-opt no-new-privileges --entrypoint /bin/sh \ + -v "$prefix-apps-v2:/apps:ro" -v "$WINEBOT_USERDATA_VOLUME:/userdata" \ + -v "$WINEBOT_CONFIG_VOLUME:/config" \ + winebot-apps:fixture-v2 -ec ' + grep -qx app-fixture-v2 /apps/ci-fixture/version.txt + grep -qx durable-user-file /userdata/proof.txt + grep -qx durable-setting /config/proof.txt + ' >/dev/null 2>&1 || fail app_upgrade_replay +echo 'LAYER_RDTE stage=pass' diff --git a/scripts/ci/test.sh b/scripts/ci/test.sh index b4931410..c339dc40 100755 --- a/scripts/ci/test.sh +++ b/scripts/ci/test.sh @@ -29,4 +29,5 @@ pytest \ tests/test_ci_unit_isolation.py \ tests/test_winepath_startup_retry.py \ tests/test_wininspect_error_redaction.py \ - tests/test_health_system_memory.py + tests/test_health_system_memory.py \ + tests/test_disposable_layer_contract.py diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 5dc3c853..057bdc37 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -68,5 +68,15 @@ def test_deployment_preflight_never_prunes_external_volumes(self): self.assertNotIn("docker volume rm", src) self.assertNotIn("docker system prune", src) + def test_tool_builder_uses_immutable_image_digest(self): + src = (ROOT / "docker/Dockerfile").read_text(encoding="utf-8") + self.assertIn("TOOL_BUILDER_BASE_IMAGE=debian@sha256:", src) + self.assertIn("FROM ${TOOL_BUILDER_BASE_IMAGE} AS tool-base", src) + self.assertNotIn("FROM debian:trixie-slim AS tool-base", src) + + def test_actual_unit_manifest_includes_layer_contract(self): + src = (ROOT / "scripts/ci/test.sh").read_text(encoding="utf-8") + self.assertIn("tests/test_disposable_layer_contract.py", src) + if __name__ == "__main__": unittest.main() From bddf3e7a6d2a53ad43871abecd9379983a585ff3 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:10:08 +0100 Subject: [PATCH 04/46] fix(layers): prepare volume modes before dropping ownership under CAP_CHOWN-only --- scripts/layers/prepare-state.sh | 4 +++- tests/test_disposable_layer_contract.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/layers/prepare-state.sh b/scripts/layers/prepare-state.sh index e3c985fc..7313cbf2 100755 --- a/scripts/layers/prepare-state.sh +++ b/scripts/layers/prepare-state.sh @@ -10,7 +10,9 @@ fail() { [ "$(id -u)" = 0 ] || fail invalid_identity for dir in /state/prefix /state/home /state/config /state/userdata /state/artifacts /state/shared; do [ -d "$dir" ] && [ ! -L "$dir" ] || fail mount_unavailable - chown 1000:1000 "$dir" >/dev/null 2>&1 || fail ownership_failed + # chmod while the directory is still owned by root: after chown to + # uid 1000, root with only CAP_CHOWN cannot use chmod (needs CAP_FOWNER). chmod u+rwx "$dir" >/dev/null 2>&1 || fail permissions_failed + chown 1000:1000 "$dir" >/dev/null 2>&1 || fail ownership_failed done echo 'STATE_LAYER_DIAGNOSTIC stage=ready' diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 057bdc37..0cf3f4f7 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -59,6 +59,8 @@ def test_state_preparer_does_not_recurse_or_remove_user_data(self): self.assertIn("chown 1000:1000", source) self.assertNotIn("chown -R", source) self.assertNotIn("rm -rf", source) + self.assertLess(source.index('chmod u+rwx "$dir"'), + source.index('chown 1000:1000 "$dir"')) def test_deployment_preflight_never_prunes_external_volumes(self): src = (ROOT / "scripts/layers/preflight.sh").read_text(encoding="utf-8") From 0fa7f063a596d4bc836dadf15164b2057d8d836b Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:14:42 +0100 Subject: [PATCH 05/46] fix(layers): fail closed on app volume tampering and incomplete seeding --- scripts/ci/qualify-disposable-layers.sh | 20 ++++++++++++++++++++ scripts/layers/seed-apps.sh | 19 +++++++++++++++++-- tests/test_disposable_layer_contract.py | 5 +++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/scripts/ci/qualify-disposable-layers.sh b/scripts/ci/qualify-disposable-layers.sh index f67f6cab..f1e009e8 100755 --- a/scripts/ci/qualify-disposable-layers.sh +++ b/scripts/ci/qualify-disposable-layers.sh @@ -55,6 +55,26 @@ docker run --rm --network none --read-only --cap-drop ALL \ -v "$WINEBOT_APP_VOLUME:/winebot-apps" "$app_image" >/dev/null 2>&1 || fail app_seed_idempotency +# Fail closed on an unauthorized extra executable or symlink in an app volume. +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges --entrypoint /bin/sh \ + -v "$WINEBOT_APP_VOLUME:/winebot-apps" "$app_image" -ec ' + printf "UNTRUSTED" >/winebot-apps/unexpected.exe + ' >/dev/null 2>&1 || fail tamper_fixture +if docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges -v "$WINEBOT_APP_VOLUME:/winebot-apps" \ + "$app_image" >/dev/null 2>&1; then + fail tamper_not_rejected +fi +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges --entrypoint /bin/sh \ + -v "$WINEBOT_APP_VOLUME:/winebot-apps" "$app_image" -ec ' + rm /winebot-apps/unexpected.exe + ' >/dev/null 2>&1 || fail tamper_cleanup +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges -v "$WINEBOT_APP_VOLUME:/winebot-apps" \ + "$app_image" >/dev/null 2>&1 || fail reverified_app + # One-shot root task prepares only volume root ownership, never user contents. docker run --rm --network none --read-only --cap-drop ALL --cap-add CHOWN \ --security-opt no-new-privileges --memory 256m --pids-limit 64 \ diff --git a/scripts/layers/seed-apps.sh b/scripts/layers/seed-apps.sh index bf78169d..b30f673a 100755 --- a/scripts/layers/seed-apps.sh +++ b/scripts/layers/seed-apps.sh @@ -7,6 +7,19 @@ source_dir=/opt/winebot/app-payload volume=/winebot-apps manifest=/opt/winebot/app-manifest.sha256 stamp="$volume/.winebot-app-content-sha256" +lock="$volume/.winebot-app-seeding" + +verify_inventory() { + # Valid hashes alone are insufficient: reject any unexpected file/symlink + # that could otherwise be executable by the next disposable runtime. + expected="$(wc -l < "$manifest" | tr -d '[:space:]')" + actual="$(find "$volume" -type f ! -path "$stamp" | wc -l | tr -d '[:space:]')" + [ "$actual" = "$expected" ] || fail unexpected_files + [ -z "$(find "$volume" -type l -print -quit)" ] || fail unexpected_symlink + (cd "$volume" && sha256sum -c "$manifest" >/dev/null 2>&1) || + fail integrity_mismatch +} + fail() { printf 'APP_LAYER_DIAGNOSTIC stage=%s\n' "$1" >&2 @@ -19,13 +32,15 @@ digest="$(sha256sum "$manifest" | cut -c 1-64)" case "$digest" in *[!0-9a-f]*|'') fail invalid_manifest;; esac if [ -f "$stamp" ]; then [ "$(cat "$stamp")" = "$digest" ] || fail version_mismatch - (cd "$volume" && sha256sum -c "$manifest" >/dev/null 2>&1) || fail integrity_mismatch + verify_inventory echo 'APP_LAYER_DIAGNOSTIC stage=existing_verified' exit 0 fi [ -z "$(find "$volume" -mindepth 1 -maxdepth 1 -print -quit)" ] || fail incomplete_volume +mkdir "$lock" >/dev/null 2>&1 || fail concurrent_init cp -a "$source_dir"/. "$volume"/ >/dev/null 2>&1 || fail copy_failed -(cd "$volume" && sha256sum -c "$manifest" >/dev/null 2>&1) || fail integrity_mismatch +verify_inventory +rmdir "$lock" >/dev/null 2>&1 || fail incomplete_volume printf '%s\n' "$digest" > "$stamp.tmp" || fail stamp_failed mv "$stamp.tmp" "$stamp" || fail stamp_failed echo 'APP_LAYER_DIAGNOSTIC stage=created_verified' diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 0cf3f4f7..407215d4 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -28,6 +28,11 @@ def test_seed_is_idempotent_and_never_replaces_existing_apps(self): self.assertIn(marker, src) self.assertLess(src.index('if [ -f "$stamp" ]; then'), src.index('cp -a "$source_dir"/.')) + self.assertIn("fail unexpected_files", src) + self.assertIn("fail unexpected_symlink", src) + self.assertIn('mkdir "$lock"', src) + self.assertLess(src.index('verify_inventory() {'), + src.index('if [ -f "$stamp" ]; then')) for forbidden in ("rm -rf", "curl ", "wget ", "docker push"): self.assertNotIn(forbidden, src) From 52dc23ee04bc1c32f61e16ca4df6215580281e81 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:17:29 +0100 Subject: [PATCH 06/46] style(layers): align contract test imports with Ruff I001 --- tests/test_disposable_layer_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 407215d4..cbb628cf 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -3,8 +3,8 @@ These tests use only stdlib and deliberately do not provision real users. An independent public Actions job performs disposable Docker replay. """ -from pathlib import Path import unittest +from pathlib import Path ROOT = Path(__file__).resolve().parents[1] From 3659277aed645c7c139d74f96db7d25c6be5b1a9 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:21:57 +0100 Subject: [PATCH 07/46] test(layers): run source-pinned Wine 11 read-only-root HIL on public runner --- .../workflows/wine11-disposable-layer-hil.yml | 55 +++++++++ scripts/ci/qualify-wine11-layered.sh | 115 ++++++++++++++++++ tests/test_disposable_layer_contract.py | 22 ++++ 3 files changed, 192 insertions(+) create mode 100644 .github/workflows/wine11-disposable-layer-hil.yml create mode 100755 scripts/ci/qualify-wine11-layered.sh diff --git a/.github/workflows/wine11-disposable-layer-hil.yml b/.github/workflows/wine11-disposable-layer-hil.yml new file mode 100644 index 00000000..88e61c74 --- /dev/null +++ b/.github/workflows/wine11-disposable-layer-hil.yml @@ -0,0 +1,55 @@ +name: Wine 11 Disposable-Layer Composite HIL + +# Public PR source snapshots only; never publishes images/diagnostics. +on: + pull_request: + paths: + - '.github/workflows/wine11-disposable-layer-hil.yml' + - 'compose/layered.yml' + - 'docker/Dockerfile' + - 'docker/entrypoint.sh' + - 'scripts/layers/**' + - 'scripts/ci/qualify-wine11-layered.sh' + +permissions: + contents: read + +env: + DOCKER_BUILD_RECORD_UPLOAD: 'false' + +concurrency: + group: wine11-layer-hil-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + composite-wine11-hil: + runs-on: ubuntu-24.04 + timeout-minutes: 90 + steps: + - name: Checkout exact layered architecture PR source + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + persist-credentials: false + ref: ${{ github.event.pull_request.head.sha }} + path: layered + - name: Checkout exact separately qualified Wine11 source + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + repository: SemperSupra/WineBot + persist-credentials: false + ref: d2304d2b2e096a097ffa76b79aeaeef85b72d702 + path: wine11-candidate + - name: Free disposable runner disk + run: | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/share/swift + - name: Source syntax and frozen composite ownership + working-directory: layered + run: | + bash -n scripts/ci/qualify-wine11-layered.sh + test -f ../wine11-candidate/scripts/init/20-setup-wine.sh + - name: Build ephemeral candidate and qualify read-only Wine11 replay + working-directory: layered + run: bash scripts/ci/qualify-wine11-layered.sh + - name: Report only fixed result + if: success() + run: echo 'WINE11_LAYER_HIL stage=qualified_composite' diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh new file mode 100755 index 00000000..31ad72c8 --- /dev/null +++ b/scripts/ci/qualify-wine11-layered.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +# Disposable composite HIL for pinned Wine11 R018 source and layer branch. +# This intentionally does not claim that either PR head alone is release-ready. +set -euo pipefail +fail() { + printf 'WINE11_LAYER_HIL stage=%s\n' "$1" >&2 + exit 1 +} +[ "${GITHUB_ACTIONS:-}" = true ] && [ "${GITHUB_EVENT_NAME:-}" = pull_request ] || + fail unqualified_venue +[[ "${GITHUB_RUN_ID:-}" =~ ^[0-9]+$ ]] && + [[ "${GITHUB_RUN_ATTEMPT:-}" =~ ^[0-9]+$ ]] || fail invalid_runner +[ -f ../wine11-candidate/docker/base.Dockerfile ] && + [ -f ../wine11-candidate/scripts/init/20-setup-wine.sh ] || + fail source_unavailable + +prefix="winebot-hil-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" +export WINEBOT_APP_VOLUME="$prefix-apps" +export WINEBOT_PREFIX_VOLUME="$prefix-prefix" +export WINEBOT_HOME_VOLUME="$prefix-home" +export WINEBOT_CONFIG_VOLUME="$prefix-config" +export WINEBOT_USERDATA_VOLUME="$prefix-userdata" +export WINEBOT_ARTIFACT_VOLUME="$prefix-artifacts" +export WINEBOT_SHARED_VOLUME="$prefix-shared" +export WINEBOT_API_TOKEN=synthetic-hil-local-only-token +export WINEBOT_VNC_PASSWORD=synthetic-hil-local-only-password +volumes=("$WINEBOT_APP_VOLUME" "$WINEBOT_PREFIX_VOLUME" "$WINEBOT_HOME_VOLUME" + "$WINEBOT_CONFIG_VOLUME" "$WINEBOT_USERDATA_VOLUME" "$WINEBOT_ARTIFACT_VOLUME" + "$WINEBOT_SHARED_VOLUME") +cleanup() { + docker compose -f compose/layered.yml down --remove-orphans >/dev/null 2>&1 || true + for volume in "${volumes[@]}"; do + docker volume rm "$volume" >/dev/null 2>&1 || true + done + docker image rm winebot:layered-hil winebot-base:layered-hil winebot-apps:layered-hil >/dev/null 2>&1 || true +} +trap cleanup EXIT +for volume in "${volumes[@]}"; do + docker volume create "$volume" >/dev/null 2>&1 || fail create_synthetic_volume +done + +# The base and Wine init come exclusively from qualified Wine11 exact SHA. +# This is a declared composite experiment, never source-exact promotion. +docker build --file ../wine11-candidate/docker/base.Dockerfile --target final \ + --tag winebot-base:layered-hil ../wine11-candidate >/dev/null 2>&1 || + fail wine11_base_build +cp ../wine11-candidate/scripts/init/20-setup-wine.sh scripts/init/20-setup-wine.sh +docker build --file docker/Dockerfile --target intent-rel \ + --build-arg BASE_IMAGE=winebot-base:layered-hil \ + --build-arg BUILD_INTENT=rel \ + --tag winebot:layered-hil . >/dev/null 2>&1 || fail layered_runtime_build +docker build --file docker/app-bundle.Dockerfile \ + --tag winebot-apps:layered-hil . >/dev/null 2>&1 || fail app_pack_build + +# Use immutable local OCI content IDs, not floating tags, in this HIL only. +export WINEBOT_RUNTIME_IMAGE="$(docker image inspect --format '{{.Id}}' winebot:layered-hil)" +export WINEBOT_APP_BUNDLE_IMAGE="$(docker image inspect --format '{{.Id}}' winebot-apps:layered-hil)" +[[ "$WINEBOT_RUNTIME_IMAGE" =~ ^sha256:[0-9a-f]{64}$ ]] && + [[ "$WINEBOT_APP_BUNDLE_IMAGE" =~ ^sha256:[0-9a-f]{64}$ ]] || + fail image_identity_invalid +docker compose -f compose/layered.yml config --quiet >/dev/null 2>&1 || + fail compose_invalid +docker compose -f compose/layered.yml up --no-build -d winebot-interactive \ + >/dev/null 2>&1 || fail startup + +wait_health() { + local attempt cid status + for attempt in $(seq 1 90); do + cid="$(docker compose -f compose/layered.yml ps -q winebot-interactive 2>/dev/null || true)" + if [ -n "$cid" ]; then + status="$(docker inspect --format '{{.State.Health.Status}}' "$cid" 2>/dev/null || true)" + if [ "$status" = healthy ]; then return 0; fi + fi + sleep 2 + done + return 1 +} +wait_health || fail health_initial +docker compose -f compose/layered.yml exec -T winebot-interactive wine --version \ + 2>/dev/null | grep -Eq '^wine-11([.]|$)' || fail wine11_version + +# Verify ownership, persistent user state and immutable application mount. +docker compose -f compose/layered.yml exec -T winebot-interactive /bin/sh -ec ' + [ "$(id -u)" -eq 1000 ] || exit 12 + printf "durable-user\n" > /userdata/hil-proof + printf "durable-config\n" > /config/hil-proof + printf "durable-home\n" > /home/winebot/hil-proof + printf "durable-wineprefix\n" > /wineprefix/hil-proof + printf "durable-evidence\n" > /artifacts/hil-proof + test -s /apps/.winebot-app-content-sha256 + if touch /apps/unauthorized-executable.exe >/dev/null 2>&1; then exit 13; fi + if touch /opt/winebot/unauthorized-root-write >/dev/null 2>&1; then exit 14; fi +' >/dev/null 2>&1 || fail state_write_or_readonly + +# Use the actual WineBot bounded trace/resource checker (90-second tier). +docker compose -f compose/layered.yml exec -T --user 1000 \ + -e DURATION_SECONDS=90 -e INTERVAL_SECONDS=15 \ + -e MAX_LOG_MB=1024 -e MAX_SESSION_MB=8192 \ + -e MAX_PID1_RSS_MB=2048 \ + winebot-interactive /scripts/diagnostics/soak-resource-bounds.sh nightly \ + >/dev/null 2>&1 || fail resource_sample + +# Destroy/recreate only disposable runtime containers; never remove state. +docker compose -f compose/layered.yml up --no-build --force-recreate -d winebot-interactive \ + >/dev/null 2>&1 || fail runtime_recreate +wait_health || fail health_recreate +docker compose -f compose/layered.yml exec -T winebot-interactive /bin/sh -ec ' + grep -qx durable-user /userdata/hil-proof + grep -qx durable-config /config/hil-proof + grep -qx durable-home /home/winebot/hil-proof + grep -qx durable-wineprefix /wineprefix/hil-proof + grep -qx durable-evidence /artifacts/hil-proof + test -s /apps/.winebot-app-content-sha256 +' >/dev/null 2>&1 || fail state_replay +echo 'WINE11_LAYER_HIL stage=pass' diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index cbb628cf..a8c8aa9c 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -85,5 +85,27 @@ def test_actual_unit_manifest_includes_layer_contract(self): src = (ROOT / "scripts/ci/test.sh").read_text(encoding="utf-8") self.assertIn("tests/test_disposable_layer_contract.py", src) + + def test_wine11_hil_is_public_disposable_and_provenance_bound(self): + wf = (ROOT / ".github/workflows/wine11-disposable-layer-hil.yml").read_text( + encoding="utf-8" + ) + script = (ROOT / "scripts/ci/qualify-wine11-layered.sh").read_text( + encoding="utf-8" + ) + self.assertIn("runs-on: ubuntu-24.04", wf) + self.assertIn("d2304d2b2e096a097ffa76b79aeaeef85b72d702", wf) + self.assertIn("persist-credentials: false", wf) + self.assertIn("DOCKER_BUILD_RECORD_UPLOAD: 'false'", wf) + self.assertNotIn("actions/upload-artifact@", wf) + self.assertNotIn("push: true", wf) + self.assertIn("stage=health_recreate", script) + self.assertIn("stage=state_replay", script) + self.assertIn("DURATION_SECONDS=90", script) + self.assertIn("--read-only", (ROOT / "compose/layered.yml").read_text( + encoding="utf-8" + ).replace("read_only: true", "--read-only")) + self.assertNotIn("docker volume prune", script) + if __name__ == "__main__": unittest.main() From af0988d14a408c31a7a1dfdcf3278df2152908f3 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:23:19 +0100 Subject: [PATCH 08/46] test(layers): assert exact fail-closed HIL stage invocation --- tests/test_disposable_layer_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index a8c8aa9c..7144e7d9 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -99,8 +99,8 @@ def test_wine11_hil_is_public_disposable_and_provenance_bound(self): self.assertIn("DOCKER_BUILD_RECORD_UPLOAD: 'false'", wf) self.assertNotIn("actions/upload-artifact@", wf) self.assertNotIn("push: true", wf) - self.assertIn("stage=health_recreate", script) - self.assertIn("stage=state_replay", script) + self.assertIn("fail health_recreate", script) + self.assertIn("fail state_replay", script) self.assertIn("DURATION_SECONDS=90", script) self.assertIn("--read-only", (ROOT / "compose/layered.yml").read_text( encoding="utf-8" From 488871a41f75fdbcef3e9be8f175d43da7d76248 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:38:52 +0100 Subject: [PATCH 09/46] ci: classify composite startup failure by allowlisted container states --- scripts/ci/qualify-wine11-layered.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 31ad72c8..b17877ce 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -60,8 +60,29 @@ export WINEBOT_APP_BUNDLE_IMAGE="$(docker image inspect --format '{{.Id}}' wineb fail image_identity_invalid docker compose -f compose/layered.yml config --quiet >/dev/null 2>&1 || fail compose_invalid -docker compose -f compose/layered.yml up --no-build -d winebot-interactive \ - >/dev/null 2>&1 || fail startup +# Project container state and fixed-domain diagnostics only. Never print raw +# Compose logs, environment variables, container IDs, mounts or user paths. +classify_startup() { + local service cid state exit_code health + for service in app-seed state-init winebot-interactive; do + cid="$(docker compose -f compose/layered.yml ps -a -q "$service" 2>/dev/null || true)" + if [ -z "$cid" ]; then + printf 'WINE11_LAYER_HIL service=%s state=absent\n' "$service" >&2 + continue + fi + state="$(docker inspect --format '{{.State.Status}}' "$cid" 2>/dev/null || true)" + exit_code="$(docker inspect --format '{{.State.ExitCode}}' "$cid" 2>/dev/null || true)" + health="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$cid" 2>/dev/null || true)" + case "$state" in created|running|restarting|exited|dead|paused) ;; *) state=unknown ;; esac + case "$health" in healthy|unhealthy|starting|none) ;; *) health=unknown ;; esac + [[ "$exit_code" =~ ^[0-9]{1,3}$ ]] || exit_code=unknown + printf 'WINE11_LAYER_HIL service=%s state=%s exit=%s health=%s\n' "$service" "$state" "$exit_code" "$health" >&2 + done +} +if ! docker compose -f compose/layered.yml up --no-build -d winebot-interactive >/dev/null 2>&1; then + classify_startup + fail startup +fi wait_health() { local attempt cid status From 7bdc5017fb6913ef8ade203f20052ff18596a2ca Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:28:45 +0100 Subject: [PATCH 10/46] ci: classify app and state initialization exits with fixed safe categories --- scripts/ci/classify-layer-init-logs.py | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/ci/classify-layer-init-logs.py diff --git a/scripts/ci/classify-layer-init-logs.py b/scripts/ci/classify-layer-init-logs.py new file mode 100644 index 00000000..45b740b2 --- /dev/null +++ b/scripts/ci/classify-layer-init-logs.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +"""Project bounded, allowlisted init-failure categories without exposing raw logs. + +Never include raw container stdout/stderr, paths, environment variables, +container IDs, host details or credential material in public CI output. +""" +import re +import sys + +STAGES = { + "app-seed": { + "unavailable", "invalid_mount", "invalid_manifest", "version_mismatch", + "unexpected_files", "unexpected_symlink", "integrity_mismatch", + "incomplete_volume", "concurrent_init", "copy_failed", "stamp_failed", + "existing_verified", "created_verified", + }, + "state-init": { + "invalid_identity", "mount_unavailable", "permissions_failed", + "ownership_failed", "ready", + }, +} +PREFIX = { + "app-seed": "APP_LAYER_DIAGNOSTIC", + "state-init": "STATE_LAYER_DIAGNOSTIC", +} + + +def classify(service: str, lines) -> str: + if service not in STAGES: + raise ValueError("unrecognized service") + match = re.compile(rf"^{PREFIX[service]} stage=([a-z_]+)$") + found = "unclassified" + for line in lines: + if len(line) > 256: + continue + category = match.fullmatch(line.rstrip("\r\n")) + if category and category.group(1) in STAGES[service]: + found = category.group(1) + return f"WINE11_LAYER_HIL service={service} cause={found}" + + +def main() -> int: + if len(sys.argv) != 2 or sys.argv[1] not in STAGES: + print("WINE11_LAYER_HIL cause=invalid_classifier_input", file=sys.stderr) + return 2 + print(classify(sys.argv[1], sys.stdin)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From 927ed62410255551be9393486616470dd0bad389 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:28:47 +0100 Subject: [PATCH 11/46] test: ensure composite startup diagnostic classifier cannot echo sensitive logs --- tests/test_layer_init_diagnostics.py | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_layer_init_diagnostics.py diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py new file mode 100644 index 00000000..fdf914c0 --- /dev/null +++ b/tests/test_layer_init_diagnostics.py @@ -0,0 +1,50 @@ +"""Zero-secret regression tests for public composite startup classification.""" +import io +import sys +import unittest +from pathlib import Path +import importlib.util + +MODULE = Path(__file__).resolve().parents[1] / "scripts/ci/classify-layer-init-logs.py" +spec = importlib.util.spec_from_file_location("layer_init", MODULE) +layer = importlib.util.module_from_spec(spec) +spec.loader.exec_module(layer) + + +class LayerDiagnosticsTest(unittest.TestCase): + def test_specific_allowlisted_initialization_failures(self): + self.assertEqual( + layer.classify("app-seed", io.StringIO("APP_LAYER_DIAGNOSTIC stage=copy_failed\n")), + "WINE11_LAYER_HIL service=app-seed cause=copy_failed", + ) + self.assertEqual( + layer.classify("state-init", io.StringIO("STATE_LAYER_DIAGNOSTIC stage=ownership_failed\n")), + "WINE11_LAYER_HIL service=state-init cause=ownership_failed", + ) + + def test_does_not_reflect_raw_or_malformed_sensitive_output(self): + secret = "private-token-should-not-appear" + text = ( + f"STATE_LAYER_DIAGNOSTIC stage=ownership_failed credential={secret}\n" + f"{secret} /home/private/mount\n" + "APP_LAYER_DIAGNOSTIC stage=copy_failed\n" + "STATE_LAYER_DIAGNOSTIC stage=invalid_identity extra\n" + ) + output = layer.classify("state-init", io.StringIO(text)) + self.assertEqual(output, "WINE11_LAYER_HIL service=state-init cause=unclassified") + self.assertNotIn(secret, output) + self.assertNotIn("/home", output) + + def test_foreign_service_marker_is_ignored(self): + self.assertEqual( + layer.classify("app-seed", io.StringIO("STATE_LAYER_DIAGNOSTIC stage=ownership_failed\n")), + "WINE11_LAYER_HIL service=app-seed cause=unclassified", + ) + + def test_invalid_service_refused(self): + with self.assertRaises(ValueError): + layer.classify("winebot-interactive", io.StringIO("APP_LAYER_DIAGNOSTIC stage=copy_failed\n")) + + +if __name__ == "__main__": + unittest.main() From 6d2fbd89d1cb8cf7d858b7bba2873b04bde96977 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:29:00 +0100 Subject: [PATCH 12/46] ci: report fixed initialization-failure categories in Wine 11 composite test --- scripts/ci/qualify-wine11-layered.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index b17877ce..51fd99d3 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -77,6 +77,14 @@ classify_startup() { case "$health" in healthy|unhealthy|starting|none) ;; *) health=unknown ;; esac [[ "$exit_code" =~ ^[0-9]{1,3}$ ]] || exit_code=unknown printf 'WINE11_LAYER_HIL service=%s state=%s exit=%s health=%s\n' "$service" "$state" "$exit_code" "$health" >&2 + # The scripts emit fixed-domain markers on failure. Process container logs + # privately; the classifier emits ONLY one enumerated category, not raw text. + case "$service" in + app-seed|state-init) + docker logs --tail 80 "$cid" 2>/dev/null | + python3 scripts/ci/classify-layer-init-logs.py "$service" >&2 || true + ;; + esac done } if ! docker compose -f compose/layered.yml up --no-build -d winebot-interactive >/dev/null 2>&1; then From 40611304015bd863db1ee2962a70f5255d9053b9 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:29:16 +0100 Subject: [PATCH 13/46] ci: verify classified startup diagnostics before expensive public composite builds --- .github/workflows/wine11-disposable-layer-hil.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wine11-disposable-layer-hil.yml b/.github/workflows/wine11-disposable-layer-hil.yml index 88e61c74..1daf84b4 100644 --- a/.github/workflows/wine11-disposable-layer-hil.yml +++ b/.github/workflows/wine11-disposable-layer-hil.yml @@ -10,6 +10,8 @@ on: - 'docker/entrypoint.sh' - 'scripts/layers/**' - 'scripts/ci/qualify-wine11-layered.sh' + - 'scripts/ci/classify-layer-init-logs.py' + - 'tests/test_layer_init_diagnostics.py' permissions: contents: read @@ -46,6 +48,7 @@ jobs: working-directory: layered run: | bash -n scripts/ci/qualify-wine11-layered.sh + python3 -m unittest discover -s tests -p 'test_layer_init_diagnostics.py' -v test -f ../wine11-candidate/scripts/init/20-setup-wine.sh - name: Build ephemeral candidate and qualify read-only Wine11 replay working-directory: layered From 35dbde040b7075af489eb7334aea402f85fc4207 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:33:07 +0100 Subject: [PATCH 14/46] fix: resolve exact-head Ruff import-order and unused-import failures --- tests/test_layer_init_diagnostics.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py index fdf914c0..1e2621de 100644 --- a/tests/test_layer_init_diagnostics.py +++ b/tests/test_layer_init_diagnostics.py @@ -1,9 +1,8 @@ """Zero-secret regression tests for public composite startup classification.""" +import importlib.util import io -import sys import unittest from pathlib import Path -import importlib.util MODULE = Path(__file__).resolve().parents[1] / "scripts/ci/classify-layer-init-logs.py" spec = importlib.util.spec_from_file_location("layer_init", MODULE) From ce192178c868c7e8f4ab9947b9641b48a7c1a0af Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:40:59 +0100 Subject: [PATCH 15/46] fix(layers): classify stderr init diagnostics without publishing raw logs --- scripts/ci/qualify-wine11-layered.sh | 2 +- tests/test_layer_init_diagnostics.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 51fd99d3..1a72212a 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -81,7 +81,7 @@ classify_startup() { # privately; the classifier emits ONLY one enumerated category, not raw text. case "$service" in app-seed|state-init) - docker logs --tail 80 "$cid" 2>/dev/null | + docker logs --tail 80 "$cid" 2>&1 | python3 scripts/ci/classify-layer-init-logs.py "$service" >&2 || true ;; esac diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py index 1e2621de..423ecefb 100644 --- a/tests/test_layer_init_diagnostics.py +++ b/tests/test_layer_init_diagnostics.py @@ -40,6 +40,14 @@ def test_foreign_service_marker_is_ignored(self): "WINE11_LAYER_HIL service=app-seed cause=unclassified", ) + def test_hil_classifies_stderr_without_publishing_raw_logs(self): + source = (MODULE.parents[2] / "scripts/ci/qualify-wine11-layered.sh").read_text( + encoding="utf-8" + ) + self.assertIn('docker logs --tail 80 "$cid" 2>&1 |', source) + self.assertNotIn('docker logs --tail 80 "$cid" 2>/dev/null |', source) + self.assertIn('classify-layer-init-logs.py "$service"', source) + def test_invalid_service_refused(self): with self.assertRaises(ValueError): layer.classify("winebot-interactive", io.StringIO("APP_LAYER_DIAGNOSTIC stage=copy_failed\n")) From 047e6d95246e3f14423df1d009e8fb206cab8c8f Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:41:05 +0100 Subject: [PATCH 16/46] ci: prove application bundle and entrypoint/image identities before startup attribution --- scripts/ci/qualify-wine11-layered.sh | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 1a72212a..848d0f85 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -60,10 +60,19 @@ export WINEBOT_APP_BUNDLE_IMAGE="$(docker image inspect --format '{{.Id}}' wineb fail image_identity_invalid docker compose -f compose/layered.yml config --quiet >/dev/null 2>&1 || fail compose_invalid +# Qualify the OCI image's actual script contract without mutating external volumes. +# A missing script or invalid local image reference must fail before Compose. +docker run --rm --network none --read-only --cap-drop ALL \ + --security-opt no-new-privileges --entrypoint /bin/sh \ + "$WINEBOT_APP_BUNDLE_IMAGE" -ec ' + test -r /usr/local/bin/winebot-seed-apps + test -r /usr/local/bin/winebot-prepare-state + test -s /opt/winebot/app-manifest.sha256 + ' >/dev/null 2>&1 || fail app_bundle_script_contract # Project container state and fixed-domain diagnostics only. Never print raw # Compose logs, environment variables, container IDs, mounts or user paths. classify_startup() { - local service cid state exit_code health + local service cid state exit_code health expected_image actual_image image_match entrypoint actual_entrypoint expected_entrypoint for service in app-seed state-init winebot-interactive; do cid="$(docker compose -f compose/layered.yml ps -a -q "$service" 2>/dev/null || true)" if [ -z "$cid" ]; then @@ -77,6 +86,25 @@ classify_startup() { case "$health" in healthy|unhealthy|starting|none) ;; *) health=unknown ;; esac [[ "$exit_code" =~ ^[0-9]{1,3}$ ]] || exit_code=unknown printf 'WINE11_LAYER_HIL service=%s state=%s exit=%s health=%s\n' "$service" "$state" "$exit_code" "$health" >&2 + # Print only source-exact equality verdicts. Raw inspect image IDs, + # entrypoint paths, container IDs, and Docker error strings stay private. + expected_image="$WINEBOT_APP_BUNDLE_IMAGE" + [ "$service" = winebot-interactive ] && expected_image="$WINEBOT_RUNTIME_IMAGE" + actual_image="$(docker inspect --format '{{.Image}}' "$cid" 2>/dev/null || true)" + image_match=no + [ "$actual_image" = "$expected_image" ] && image_match=yes + entrypoint=not_applicable + case "$service" in + app-seed|state-init) + expected_entrypoint='["/bin/sh","/usr/local/bin/winebot-seed-apps"]' + [ "$service" = state-init ] && + expected_entrypoint='["/bin/sh","/usr/local/bin/winebot-prepare-state"]' + actual_entrypoint="$(docker inspect --format '{{json .Config.Entrypoint}}' "$cid" 2>/dev/null || true)" + entrypoint=unexpected + [ "$actual_entrypoint" = "$expected_entrypoint" ] && entrypoint=expected + ;; + esac + printf 'WINE11_LAYER_HIL service=%s image_match=%s entrypoint=%s\n' "$service" "$image_match" "$entrypoint" >&2 # The scripts emit fixed-domain markers on failure. Process container logs # privately; the classifier emits ONLY one enumerated category, not raw text. case "$service" in From a1dc64bbb5173f8c57b474cecc73d43b8c78b3af Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:41:18 +0100 Subject: [PATCH 17/46] ci: distinguish empty container logs from unstructured initializer output --- scripts/ci/classify-layer-init-logs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/ci/classify-layer-init-logs.py b/scripts/ci/classify-layer-init-logs.py index 45b740b2..a156e917 100644 --- a/scripts/ci/classify-layer-init-logs.py +++ b/scripts/ci/classify-layer-init-logs.py @@ -29,13 +29,17 @@ def classify(service: str, lines) -> str: if service not in STAGES: raise ValueError("unrecognized service") match = re.compile(rf"^{PREFIX[service]} stage=([a-z_]+)$") - found = "unclassified" + found = "" + any_log_lines = False for line in lines: + any_log_lines = True if len(line) > 256: continue category = match.fullmatch(line.rstrip("\r\n")) if category and category.group(1) in STAGES[service]: found = category.group(1) + if not found: + found = "unclassified_nonempty" if any_log_lines else "unclassified_empty" return f"WINE11_LAYER_HIL service={service} cause={found}" From 08c16c348978c4506cfc576e6b1cf7de8f5da628 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:41:32 +0100 Subject: [PATCH 18/46] test: distinguish empty and unstructured container diagnostics safely --- tests/test_layer_init_diagnostics.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py index 423ecefb..14c70da4 100644 --- a/tests/test_layer_init_diagnostics.py +++ b/tests/test_layer_init_diagnostics.py @@ -30,14 +30,14 @@ def test_does_not_reflect_raw_or_malformed_sensitive_output(self): "STATE_LAYER_DIAGNOSTIC stage=invalid_identity extra\n" ) output = layer.classify("state-init", io.StringIO(text)) - self.assertEqual(output, "WINE11_LAYER_HIL service=state-init cause=unclassified") + self.assertEqual(output, "WINE11_LAYER_HIL service=state-init cause=unclassified_nonempty") self.assertNotIn(secret, output) self.assertNotIn("/home", output) def test_foreign_service_marker_is_ignored(self): self.assertEqual( layer.classify("app-seed", io.StringIO("STATE_LAYER_DIAGNOSTIC stage=ownership_failed\n")), - "WINE11_LAYER_HIL service=app-seed cause=unclassified", + "WINE11_LAYER_HIL service=app-seed cause=unclassified_nonempty", ) def test_hil_classifies_stderr_without_publishing_raw_logs(self): @@ -48,6 +48,12 @@ def test_hil_classifies_stderr_without_publishing_raw_logs(self): self.assertNotIn('docker logs --tail 80 "$cid" 2>/dev/null |', source) self.assertIn('classify-layer-init-logs.py "$service"', source) + def test_empty_logs_classified_without_raw_output(self): + self.assertEqual( + layer.classify("app-seed", io.StringIO("")), + "WINE11_LAYER_HIL service=app-seed cause=unclassified_empty", + ) + def test_invalid_service_refused(self): with self.assertRaises(ValueError): layer.classify("winebot-interactive", io.StringIO("APP_LAYER_DIAGNOSTIC stage=copy_failed\n")) From 09d58a899d91bec08f0d114dfad5b61425cb379b Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:11:07 +0100 Subject: [PATCH 19/46] fix(layers): prevent runtime Docker volume copy-up racing initializer ownership --- compose/layered.yml | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/compose/layered.yml b/compose/layered.yml index 390bb1d1..c7801992 100644 --- a/compose/layered.yml +++ b/compose/layered.yml @@ -81,14 +81,45 @@ services: - "127.0.0.1:8000:8000" - "127.0.0.1:6080:6080" - "127.0.0.1:5900:5900" + # The dependent runtime must never populate fresh state/app volumes from + # its image: that can race one-shot initialization and change ownership. volumes: - - app-store:/apps:ro - - wineprefix:/wineprefix - - user-home:/home/winebot - - config:/config - - userdata:/userdata - - artifacts:/artifacts - - shared:/winebot-shared + - type: volume + source: app-store + target: /apps + read_only: true + volume: + nocopy: true + - type: volume + source: wineprefix + target: /wineprefix + volume: + nocopy: true + - type: volume + source: user-home + target: /home/winebot + volume: + nocopy: true + - type: volume + source: config + target: /config + volume: + nocopy: true + - type: volume + source: userdata + target: /userdata + volume: + nocopy: true + - type: volume + source: artifacts + target: /artifacts + volume: + nocopy: true + - type: volume + source: shared + target: /winebot-shared + volume: + nocopy: true healthcheck: test: - CMD-SHELL From 3e61f8d311e77025aa37fdbdf570bdb07423ce56 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:11:16 +0100 Subject: [PATCH 20/46] fix(layers): classify unwritable app volumes separately from seed-lock collisions --- scripts/layers/seed-apps.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/layers/seed-apps.sh b/scripts/layers/seed-apps.sh index b30f673a..3c24c5ab 100755 --- a/scripts/layers/seed-apps.sh +++ b/scripts/layers/seed-apps.sh @@ -37,7 +37,12 @@ if [ -f "$stamp" ]; then exit 0 fi [ -z "$(find "$volume" -mindepth 1 -maxdepth 1 -print -quit)" ] || fail incomplete_volume -mkdir "$lock" >/dev/null 2>&1 || fail concurrent_init +# A failed lock creation can mean a competing seeder OR an unwritable +# volume. Keep those causes distinct; never overwrite an existing volume. +if ! mkdir "$lock" >/dev/null 2>&1; then + [ -e "$lock" ] && fail concurrent_init + fail permissions_failed +fi cp -a "$source_dir"/. "$volume"/ >/dev/null 2>&1 || fail copy_failed verify_inventory rmdir "$lock" >/dev/null 2>&1 || fail incomplete_volume From 1358a18925a1f614c4b424cab0b32fd66d9903a7 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:11:30 +0100 Subject: [PATCH 21/46] ci: accept bounded application volume permissions-failure category --- scripts/ci/classify-layer-init-logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/classify-layer-init-logs.py b/scripts/ci/classify-layer-init-logs.py index a156e917..e3e36de5 100644 --- a/scripts/ci/classify-layer-init-logs.py +++ b/scripts/ci/classify-layer-init-logs.py @@ -11,7 +11,7 @@ "app-seed": { "unavailable", "invalid_mount", "invalid_manifest", "version_mismatch", "unexpected_files", "unexpected_symlink", "integrity_mismatch", - "incomplete_volume", "concurrent_init", "copy_failed", "stamp_failed", + "incomplete_volume", "concurrent_init", "permissions_failed", "copy_failed", "stamp_failed", "existing_verified", "created_verified", }, "state-init": { From 6d5b652e0a1f085255702a8bab14bba7d9052e07 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:11:53 +0100 Subject: [PATCH 22/46] test(layers): enforce nocopy volume semantics and precise seed-lock error handling --- tests/test_disposable_layer_contract.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 7144e7d9..78059552 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -31,6 +31,9 @@ def test_seed_is_idempotent_and_never_replaces_existing_apps(self): self.assertIn("fail unexpected_files", src) self.assertIn("fail unexpected_symlink", src) self.assertIn('mkdir "$lock"', src) + self.assertIn('fail concurrent_init', src) + self.assertIn('fail permissions_failed', src) + self.assertIn('[ -e "$lock" ] && fail concurrent_init', src) self.assertLess(src.index('verify_inventory() {'), src.index('if [ -f "$stamp" ]; then')) for forbidden in ("rm -rf", "curl ", "wget ", "docker push"): @@ -43,7 +46,12 @@ def test_external_volumes_and_disposable_runtime_are_enforced(self): self.assertIn("condition: service_completed_successfully", source) self.assertIn("read_only: true", source) self.assertIn("user: \"1000:1000\"", source) - self.assertIn("app-store:/apps:ro", source) + self.assertIn("source: app-store", source) + self.assertIn("target: /apps", source) + self.assertIn("read_only: true", source) + # Every runtime state/app volume refuses Docker image copy-up, or + # Compose may initialize/chown it before one-shot seed/state services. + self.assertEqual(source.count("nocopy: true"), 7) self.assertIn("WINEBOT_STATE_MODEL: layered", source) self.assertIn("WINEBOT_INPUT_TRACE_WINDOWS: \"1\"", source) self.assertIn("127.0.0.1:8000:8000", source) From 672b86105293aa71741cd56c7b5eb550ae7d20e3 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:12:02 +0100 Subject: [PATCH 23/46] test(ci): verify bounded unwritable-app-volume failure diagnostic --- tests/test_layer_init_diagnostics.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py index 14c70da4..8edff462 100644 --- a/tests/test_layer_init_diagnostics.py +++ b/tests/test_layer_init_diagnostics.py @@ -20,6 +20,10 @@ def test_specific_allowlisted_initialization_failures(self): layer.classify("state-init", io.StringIO("STATE_LAYER_DIAGNOSTIC stage=ownership_failed\n")), "WINE11_LAYER_HIL service=state-init cause=ownership_failed", ) + self.assertEqual( + layer.classify("app-seed", io.StringIO("APP_LAYER_DIAGNOSTIC stage=permissions_failed\n")), + "WINE11_LAYER_HIL service=app-seed cause=permissions_failed", + ) def test_does_not_reflect_raw_or_malformed_sensitive_output(self): secret = "private-token-should-not-appear" From 990e02418b097eaf4a4742e2af8ad6101b3c8a7f Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:12:21 +0100 Subject: [PATCH 24/46] docs(layers): explain copy-up race prevention and init failure semantics --- docs/disposable-layer-architecture.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/disposable-layer-architecture.md b/docs/disposable-layer-architecture.md index 54386288..9bef0388 100644 --- a/docs/disposable-layer-architecture.md +++ b/docs/disposable-layer-architecture.md @@ -23,6 +23,19 @@ CHOWN, modifies top-level volume directory ownership but does not recursively rewrite or delete user files. The app seeder is root inside its container but has no Linux capabilities and no network. Neither preparer sees credentials. +The disposable runtime mounts all seven external application/state volumes with +`volume.nocopy: true`. Docker's default initial volume population can copy +image directory contents **and metadata/ownership** into a newly created +external volume when multiple dependent Compose containers are created. +Prevent runtime image copy-up before the independent one-shot app seeder and +state initializer execute. Do not use runtime image copy-up as an installer, +migration, backup or profile-provisioning mechanism. The build and deployment +must be qualified together: the composite startup test specifically tests this +ownership race and keeps its proof volumes isolated to one disposable runner. +Failure to acquire a seeder lock is not automatically a concurrent installation; +a separately classified unwritable app volume must fail without modifying user +data. This correction remains experimental until composite HIL demonstrates it. + The original `/wineprefix` retains Wine registry and per-user installed-app state; this is **not** yet a clean separation of arbitrary Windows MSI/EXE installation mutations. The new app layer is fully usable for portable packages From 2b8e6eb558a26239dc58de17ff35f4a4d4bd24f1 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:23:45 +0100 Subject: [PATCH 25/46] test(layers): classify first real Wine11 health failure without raw runtime logs --- scripts/ci/qualify-wine11-layered.sh | 44 +++++++++++++++++++++++++++- tests/test_layer_init_diagnostics.py | 22 ++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 848d0f85..7672d14e 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -132,7 +132,49 @@ wait_health() { done return 1 } -wait_health || fail health_initial +# A failed real health gate must remain a failure. Classify only immutable +# state/enumerated probes, without leaking runtime logs, tokens, host paths or +# Docker inspection payloads into the public runner stream. +classify_health_failure() { + local cid state health code + cid="$(docker compose -f compose/layered.yml ps -a -q winebot-interactive 2>/dev/null || true)" + if [ -z "$cid" ]; then + echo 'WINE11_LAYER_HEALTH state=absent' + return + fi + state="$(docker inspect --format '{{.State.Status}}' "$cid" 2>/dev/null || true)" + health="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$cid" 2>/dev/null || true)" + case "$state" in created|running|restarting|exited|dead|paused) ;; *) state=unknown ;; esac + case "$health" in healthy|unhealthy|starting|none) ;; *) health=unknown ;; esac + printf 'WINE11_LAYER_HEALTH state=%s health=%s\\n' "$state" "$health" + # Existing allowlist-only classifier consumes stdout/stderr privately. + docker logs --tail 200 "$cid" 2>&1 | + python3 scripts/ci/classify-startup-logs.py || true + [ "$state" = running ] || return + if docker exec --user 1000 "$cid" test -s /tmp/winebot_api_token >/dev/null 2>&1; then + echo 'WINE11_LAYER_HEALTH token_file=present' + else + echo 'WINE11_LAYER_HEALTH token_file=missing' + fi + if docker exec --user 1000 "$cid" test -s /wineprefix/system.reg >/dev/null 2>&1; then + echo 'WINE11_LAYER_HEALTH registry=present' + else + echo 'WINE11_LAYER_HEALTH registry=missing' + fi + if docker exec --user 1000 "$cid" /bin/sh -c ' + token="$(cat /tmp/winebot_api_token 2>/dev/null || true)" + [ -n "$token" ] || exit 1 + curl --max-time 6 -fsS -H "X-API-Key: $token" http://127.0.0.1:8000/health >/dev/null 2>&1 + ' >/dev/null 2>&1; then + echo 'WINE11_LAYER_HEALTH authorized_api=pass' + else + echo 'WINE11_LAYER_HEALTH authorized_api=fail' + fi +} +if ! wait_health; then + classify_health_failure + fail health_initial +fi docker compose -f compose/layered.yml exec -T winebot-interactive wine --version \ 2>/dev/null | grep -Eq '^wine-11([.]|$)' || fail wine11_version diff --git a/tests/test_layer_init_diagnostics.py b/tests/test_layer_init_diagnostics.py index 8edff462..410b6bcc 100644 --- a/tests/test_layer_init_diagnostics.py +++ b/tests/test_layer_init_diagnostics.py @@ -58,6 +58,28 @@ def test_empty_logs_classified_without_raw_output(self): "WINE11_LAYER_HIL service=app-seed cause=unclassified_empty", ) + def test_composite_health_failure_remains_fail_closed_and_private(self): + source = (MODULE.parents[2] / "scripts/ci/qualify-wine11-layered.sh").read_text( + encoding="utf-8" + ) + for expected in ( + "classify_health_failure()", + "if ! wait_health; then", + "fail health_initial", + "WINE11_LAYER_HEALTH state=%s health=%s", + "WINE11_LAYER_HEALTH token_file=present", + "WINE11_LAYER_HEALTH token_file=missing", + "WINE11_LAYER_HEALTH registry=present", + "WINE11_LAYER_HEALTH authorized_api=pass", + "WINE11_LAYER_HEALTH authorized_api=fail", + "python3 scripts/ci/classify-startup-logs.py", + ): + self.assertIn(expected, source) + self.assertIn('docker logs --tail 200 "$cid" 2>&1 |', source) + self.assertIn('http://127.0.0.1:8000/health >/dev/null 2>&1', source) + self.assertNotIn("docker logs --tail 200 \"$cid\" >&2", source) + self.assertNotIn("set -x", source) + def test_invalid_service_refused(self): with self.assertRaises(ValueError): layer.classify("winebot-interactive", io.StringIO("APP_LAYER_DIAGNOSTIC stage=copy_failed\n")) From c66a29fb278135945b5fcbfa8b626bd98af136f7 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:24:21 +0100 Subject: [PATCH 26/46] fix(layers): ensure health diagnostic marker remains newline-delimited --- scripts/ci/qualify-wine11-layered.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 7672d14e..3aca84b1 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -136,7 +136,7 @@ wait_health() { # state/enumerated probes, without leaking runtime logs, tokens, host paths or # Docker inspection payloads into the public runner stream. classify_health_failure() { - local cid state health code + local cid state health cid="$(docker compose -f compose/layered.yml ps -a -q winebot-interactive 2>/dev/null || true)" if [ -z "$cid" ]; then echo 'WINE11_LAYER_HEALTH state=absent' @@ -146,7 +146,7 @@ classify_health_failure() { health="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$cid" 2>/dev/null || true)" case "$state" in created|running|restarting|exited|dead|paused) ;; *) state=unknown ;; esac case "$health" in healthy|unhealthy|starting|none) ;; *) health=unknown ;; esac - printf 'WINE11_LAYER_HEALTH state=%s health=%s\\n' "$state" "$health" + printf 'WINE11_LAYER_HEALTH state=%s health=%s\n' "$state" "$health" # Existing allowlist-only classifier consumes stdout/stderr privately. docker logs --tail 200 "$cid" 2>&1 | python3 scripts/ci/classify-startup-logs.py || true From b7dd82606caa6d95b9a5911425ada9c5ec6ead7c Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:22:35 +0100 Subject: [PATCH 27/46] fix(layers): explicitly enable authenticated API for read-only Wine11 HIL --- compose/layered.yml | 3 +++ tests/test_disposable_layer_contract.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/compose/layered.yml b/compose/layered.yml index c7801992..44565038 100644 --- a/compose/layered.yml +++ b/compose/layered.yml @@ -66,6 +66,9 @@ services: WINEARCH: win64 MODE: interactive BUILD_INTENT: rel + # 30-start-services.sh launches the API only when explicitly enabled. + # Keep the private token-file healthcheck authenticated, never bypass it. + ENABLE_API: "1" INIT_PREFIX: "1" ENABLE_VNC: "1" WINEBOT_RECORD: "1" diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 78059552..e19f8070 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -58,6 +58,19 @@ def test_external_volumes_and_disposable_runtime_are_enforced(self): self.assertNotIn(" build:", source) self.assertNotIn("actions/upload-artifact@", source) + def test_layered_api_is_enabled_without_unauthenticated_fallback(self): + compose = (ROOT / "compose/layered.yml").read_text(encoding="utf-8") + start = (ROOT / "scripts/init/30-start-services.sh").read_text( + encoding="utf-8" + ) + self.assertIn('if [ "${ENABLE_API:-0}" = "1" ]; then', start) + self.assertIn(' ENABLE_API: "1"', compose) + self.assertIn("API_TOKEN: ${WINEBOT_API_TOKEN:", compose) + self.assertIn("TOKENS=\"$(cat /tmp/winebot_api_token", compose) + self.assertIn('X-API-Key: $TOKEN', compose) + self.assertNotIn('curl -fsS http://127.0.0.1:8000/health', compose) + self.assertNotIn('curl -fsS http://localhost:8000/health', compose) + def test_layered_entrypoint_fail_closed_without_legacy_impact(self): source = (ROOT / "docker/entrypoint.sh").read_text(encoding="utf-8") self.assertIn('WINEBOT_STATE_MODEL:-legacy', source) From 785a850d9440ce9122ae6fc625c1c84cd8d08e19 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:34:07 +0100 Subject: [PATCH 28/46] test(layers): assert Compose-escaped credential healthcheck rather than unescaped shell literals From f356267558cc8dcfe044dc59feb5a259ffb5613a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:34:27 +0100 Subject: [PATCH 29/46] fix(layers): idempotent CAP_CHOWN-only state initializer without touching user-owned data --- scripts/layers/prepare-state.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/layers/prepare-state.sh b/scripts/layers/prepare-state.sh index 7313cbf2..fe806a20 100755 --- a/scripts/layers/prepare-state.sh +++ b/scripts/layers/prepare-state.sh @@ -10,9 +10,27 @@ fail() { [ "$(id -u)" = 0 ] || fail invalid_identity for dir in /state/prefix /state/home /state/config /state/userdata /state/artifacts /state/shared; do [ -d "$dir" ] && [ ! -L "$dir" ] || fail mount_unavailable - # chmod while the directory is still owned by root: after chown to - # uid 1000, root with only CAP_CHOWN cannot use chmod (needs CAP_FOWNER). - chmod u+rwx "$dir" >/dev/null 2>&1 || fail permissions_failed - chown 1000:1000 "$dir" >/dev/null 2>&1 || fail ownership_failed + owner="$(stat -c '%u:%g' "$dir" 2>/dev/null)" || fail mount_unavailable + case "$owner" in + 1000:1000) + # Idempotent restart: CAP_CHOWN-only root is NOT permitted to chmod a + # user-owned directory. Verify the owner has rwx; never modify it. + mode="$(stat -c '%A' "$dir" 2>/dev/null)" || fail mount_unavailable + case "$mode" in + drwx*) ;; + *) fail permissions_failed ;; + esac + ;; + 0:0) + # First deployment only. chmod while root still owns the directory; + # afterward CAP_CHOWN alone cannot chmod the now-user-owned path. + chmod u+rwx "$dir" >/dev/null 2>&1 || fail permissions_failed + chown 1000:1000 "$dir" >/dev/null 2>&1 || fail ownership_failed + ;; + *) + # Existing foreign-owner state is neither ours to migrate nor erase. + fail unexpected_ownership + ;; + esac done echo 'STATE_LAYER_DIAGNOSTIC stage=ready' From ce564eb1582c989ea97f28fac95c2cd5f4f32be8 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:35:04 +0100 Subject: [PATCH 30/46] test(layers): replay CAP_CHOWN state bootstrap after persistent writes without data loss --- scripts/ci/qualify-disposable-layers.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/ci/qualify-disposable-layers.sh b/scripts/ci/qualify-disposable-layers.sh index f1e009e8..059fb63e 100755 --- a/scripts/ci/qualify-disposable-layers.sh +++ b/scripts/ci/qualify-disposable-layers.sh @@ -104,6 +104,20 @@ docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ if touch /opt/winebot/should-not-write >/dev/null 2>&1; then exit 10; fi ' >/dev/null 2>&1 || fail first_runtime +# Replay the exact privileged bootstrap against *already user-owned* volumes +# with preserved files. CAP_CHOWN-only root must not try chmod on UID1000. +docker run --rm --network none --read-only --cap-drop ALL --cap-add CHOWN \ + --security-opt no-new-privileges --memory 256m --pids-limit 64 \ + --entrypoint /bin/sh \ + -v "$WINEBOT_PREFIX_VOLUME:/state/prefix" \ + -v "$WINEBOT_HOME_VOLUME:/state/home" \ + -v "$WINEBOT_CONFIG_VOLUME:/state/config" \ + -v "$WINEBOT_USERDATA_VOLUME:/state/userdata" \ + -v "$WINEBOT_ARTIFACT_VOLUME:/state/artifacts" \ + -v "$WINEBOT_SHARED_VOLUME:/state/shared" \ + "$app_image" /usr/local/bin/winebot-prepare-state >/dev/null 2>&1 || + fail state_preparation_idempotency + docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ --security-opt no-new-privileges --memory 256m --pids-limit 64 \ --tmpfs /tmp:rw,nosuid,nodev,mode=1777 \ From 196b43489f6b058c928f6ee46c811c2bad692710 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:35:28 +0100 Subject: [PATCH 31/46] test(layered): align auth assertions with Compose escaped shell variables --- tests/test_disposable_layer_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index e19f8070..6fadeda4 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -66,7 +66,7 @@ def test_layered_api_is_enabled_without_unauthenticated_fallback(self): self.assertIn('if [ "${ENABLE_API:-0}" = "1" ]; then', start) self.assertIn(' ENABLE_API: "1"', compose) self.assertIn("API_TOKEN: ${WINEBOT_API_TOKEN:", compose) - self.assertIn("TOKENS=\"$(cat /tmp/winebot_api_token", compose) + self.assertIn("TOKENS=\" $(cat /tmp/winebot_api_token", compose) self.assertIn('X-API-Key: $TOKEN', compose) self.assertNotIn('curl -fsS http://127.0.0.1:8000/health', compose) self.assertNotIn('curl -fsS http://localhost:8000/health', compose) From 487a99d5dc194713e6c9ba6481c1c43b949bf09a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:35:32 +0100 Subject: [PATCH 32/46] test(layered): remove unintended whitespace from token assertion From 312031a5f66c7a67cf459caf1a89bad6c285e74e Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:35:37 +0100 Subject: [PATCH 33/46] test(layered): match literal Compose dollar escaping in token assertion --- tests/test_disposable_layer_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 6fadeda4..d9edf5ae 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -66,7 +66,7 @@ def test_layered_api_is_enabled_without_unauthenticated_fallback(self): self.assertIn('if [ "${ENABLE_API:-0}" = "1" ]; then', start) self.assertIn(' ENABLE_API: "1"', compose) self.assertIn("API_TOKEN: ${WINEBOT_API_TOKEN:", compose) - self.assertIn("TOKENS=\" $(cat /tmp/winebot_api_token", compose) + self.assertIn("TOKENS=\"$$(cat /tmp/winebot_api_token", compose) self.assertIn('X-API-Key: $TOKEN', compose) self.assertNotIn('curl -fsS http://127.0.0.1:8000/health', compose) self.assertNotIn('curl -fsS http://localhost:8000/health', compose) From 2c3e84e551b51fde56c86ae905c76edd1405df5b Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:36:17 +0100 Subject: [PATCH 34/46] test(layers): assert escaped Compose health header with authenticated token From b6ce2b09fadda1a5989edba9944fc1327a5ef06d Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:36:30 +0100 Subject: [PATCH 35/46] fix(layers): execute authenticated health probe as single shell command --- compose/layered.yml | 11 +++-------- tests/test_disposable_layer_contract.py | 8 ++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/compose/layered.yml b/compose/layered.yml index 44565038..d4c0dedb 100644 --- a/compose/layered.yml +++ b/compose/layered.yml @@ -123,17 +123,12 @@ services: target: /winebot-shared volume: nocopy: true + # Require the credential; the one-line command avoids a YAML-preserved + # newline between curl and URL. No unauthenticated fallback is allowed. healthcheck: test: - CMD-SHELL - - >- - TOKENS="$$(cat /tmp/winebot_api_token 2>/dev/null || true)"; - for TOKEN in $$TOKENS; do - [ -z "$$TOKEN" ] && continue; - curl -fsS -H "X-API-Key: $$TOKEN" - http://127.0.0.1:8000/health >/dev/null && exit 0; - done; - exit 1 + - 'TOKENS="$$(cat /tmp/winebot_api_token 2>/dev/null || true)"; for TOKEN in $$TOKENS; do [ -z "$$TOKEN" ] && continue; curl -fsS -H "X-API-Key: $$TOKEN" http://127.0.0.1:8000/health >/dev/null && exit 0; done; exit 1' interval: 10s timeout: 10s retries: 30 diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index d9edf5ae..56a70780 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -66,8 +66,12 @@ def test_layered_api_is_enabled_without_unauthenticated_fallback(self): self.assertIn('if [ "${ENABLE_API:-0}" = "1" ]; then', start) self.assertIn(' ENABLE_API: "1"', compose) self.assertIn("API_TOKEN: ${WINEBOT_API_TOKEN:", compose) - self.assertIn("TOKENS=\"$$(cat /tmp/winebot_api_token", compose) - self.assertIn('X-API-Key: $TOKEN', compose) + self.assertIn('TOKENS="$$(cat /tmp/winebot_api_token', compose) + self.assertIn('X-API-Key: $$TOKEN', compose) + self.assertIn( + 'curl -fsS -H "X-API-Key: $$TOKEN" http://127.0.0.1:8000/health', + compose, + ) self.assertNotIn('curl -fsS http://127.0.0.1:8000/health', compose) self.assertNotIn('curl -fsS http://localhost:8000/health', compose) From 5fef000cc85b2ca7ce66052bc74899f0bc12063a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:49:07 +0100 Subject: [PATCH 36/46] test(layers): qualify SIGKILL restart and persistent-state replay on public composite --- scripts/ci/qualify-wine11-layered.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 3aca84b1..38d42247 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -211,4 +211,27 @@ docker compose -f compose/layered.yml exec -T winebot-interactive /bin/sh -ec ' grep -qx durable-evidence /artifacts/hil-proof test -s /apps/.winebot-app-content-sha256 ' >/dev/null 2>&1 || fail state_replay + +# Fail-stop only the disposable runtime process. External app/state volumes +# must survive a forced SIGKILL, with no Docker volume deletion or promotion. +docker compose -f compose/layered.yml kill -s SIGKILL winebot-interactive \ + >/dev/null 2>&1 || fail fault_signal +fault_cid="$(docker compose -f compose/layered.yml ps -a -q winebot-interactive 2>/dev/null || true)" +[ -n "$fault_cid" ] || fail fault_container_missing +fault_exit="$(docker inspect --format '{{.State.ExitCode}}' "$fault_cid" 2>/dev/null || true)" +[ "$fault_exit" = 137 ] || fail fault_exit_not_sigkill +docker compose -f compose/layered.yml up --no-build --force-recreate -d winebot-interactive \ + >/dev/null 2>&1 || fail fault_recreate +if ! wait_health; then + classify_health_failure + fail fault_health +fi +docker compose -f compose/layered.yml exec -T winebot-interactive /bin/sh -ec ' + grep -qx durable-user /userdata/hil-proof + grep -qx durable-config /config/hil-proof + grep -qx durable-home /home/winebot/hil-proof + grep -qx durable-wineprefix /wineprefix/hil-proof + grep -qx durable-evidence /artifacts/hil-proof + test -s /apps/.winebot-app-content-sha256 +' >/dev/null 2>&1 || fail fault_state_replay echo 'WINE11_LAYER_HIL stage=pass' From adcec596f90d7aed9fb253b6b521e252e3863e59 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:49:26 +0100 Subject: [PATCH 37/46] test(layers): assert real forced-runtime failure and durable data replay evidence --- tests/test_disposable_layer_contract.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 56a70780..1efbd3c3 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -126,6 +126,10 @@ def test_wine11_hil_is_public_disposable_and_provenance_bound(self): self.assertNotIn("push: true", wf) self.assertIn("fail health_recreate", script) self.assertIn("fail state_replay", script) + self.assertIn("kill -s SIGKILL winebot-interactive", script) + self.assertIn("fault_exit_not_sigkill", script) + self.assertIn("fail fault_health", script) + self.assertIn("fail fault_state_replay", script) self.assertIn("DURATION_SECONDS=90", script) self.assertIn("--read-only", (ROOT / "compose/layered.yml").read_text( encoding="utf-8" From 474b603b2471f0334c4de15fd77317a7f2b8e070 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 10:11:42 +0100 Subject: [PATCH 38/46] test(layers): qualify 55-minute Wine11 layered soak and live Openbox recovery --- .../workflows/wine11-disposable-layer-hil.yml | 5 +- docs/disposable-layer-architecture.md | 26 +++++++--- scripts/ci/qualify-wine11-layered.sh | 51 +++++++++++++++++++ tests/test_disposable_layer_contract.py | 44 +++++++++++++++- 4 files changed, 117 insertions(+), 9 deletions(-) diff --git a/.github/workflows/wine11-disposable-layer-hil.yml b/.github/workflows/wine11-disposable-layer-hil.yml index 1daf84b4..b4cf491a 100644 --- a/.github/workflows/wine11-disposable-layer-hil.yml +++ b/.github/workflows/wine11-disposable-layer-hil.yml @@ -26,7 +26,7 @@ concurrency: jobs: composite-wine11-hil: runs-on: ubuntu-24.04 - timeout-minutes: 90 + timeout-minutes: 115 steps: - name: Checkout exact layered architecture PR source uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -39,7 +39,7 @@ jobs: with: repository: SemperSupra/WineBot persist-credentials: false - ref: d2304d2b2e096a097ffa76b79aeaeef85b72d702 + ref: 8c5ed8019a3518cf534b158662755172bfce7c59 path: wine11-candidate - name: Free disposable runner disk run: | @@ -50,6 +50,7 @@ jobs: bash -n scripts/ci/qualify-wine11-layered.sh python3 -m unittest discover -s tests -p 'test_layer_init_diagnostics.py' -v test -f ../wine11-candidate/scripts/init/20-setup-wine.sh + test -f ../wine11-candidate/scripts/ci/classify-wine11-soak.py - name: Build ephemeral candidate and qualify read-only Wine11 replay working-directory: layered run: bash scripts/ci/qualify-wine11-layered.sh diff --git a/docs/disposable-layer-architecture.md b/docs/disposable-layer-architecture.md index 9bef0388..f0816598 100644 --- a/docs/disposable-layer-architecture.md +++ b/docs/disposable-layer-architecture.md @@ -115,12 +115,26 @@ version overwrite, fresh versioned app volume and retained profile data. Only fixed-category results are published. Disposable CI volumes and images are cleaned without ever touching real deployment volumes. -This verifies architectural primitives, **not** actual layered Wine 11 GUI -startup or an arbitrary Windows installer. Remaining release gates: real -Wine 11 read-only rootfs + mounted state HIL, 55-minute soak/restart/fault -recovery with layer mount replay, Windows app install semantics, WinInspect -observer and human accessibility, external state backups, access controls, -legacy-v1 conformance, secrets handling, and source/security acceptance. +The composite source-pinned Wine 11 HIL has now passed real read-only-root +startup, authenticated API health, 90-second resource sampling, container +recreation with retained prefix/home/configuration/user/evidence state, and a +forced SIGKILL with retained state and health. That was a public RDTE milestone +and does **not** by itself qualify a production deployment. + +The next gate, qualified in the same disposable public-runner composite, +extends the source-pinned Wine 11 candidate to a **55-minute sustained resource +soak**, an authenticated post-soak health check, bounded in-container Openbox +termination/recovery and another health check, followed by the previously +qualified container restart and SIGKILL persistent-state replay. The soak +records raw output only within the disposable runner; a fixed-enum classifier +from the pinned candidate reports failures. This gate is pending until its +exact-head public Actions result is terminal green. + +Still required for release: arbitrary Windows installer/registry overlays and +safe migration, WinInspect real application observer and human accessibility +acceptance, user-data external-volume backup/restore and disaster recovery, +secure secret delivery, mandatory legacy-v1 conformance, and rights/security +reviews. Human UI: recognizable profiles/app-pack versions, explicit backup/rollback warnings, and desktop settings that survive replacement. Automation DX: diff --git a/scripts/ci/qualify-wine11-layered.sh b/scripts/ci/qualify-wine11-layered.sh index 38d42247..77c62898 100755 --- a/scripts/ci/qualify-wine11-layered.sh +++ b/scripts/ci/qualify-wine11-layered.sh @@ -199,6 +199,57 @@ docker compose -f compose/layered.yml exec -T --user 1000 \ winebot-interactive /scripts/diagnostics/soak-resource-bounds.sh nightly \ >/dev/null 2>&1 || fail resource_sample +# Qualify the same exact layered service and persistent mounts through the +# full 55-minute sustained resource gate, not merely the independent #150 +# mutable-runtime qualifier. Raw output stays on this disposable public runner. +long_soak_log="$(mktemp)" +if ! docker compose -f compose/layered.yml exec -T --user 1000 \ + -e DURATION_SECONDS=3300 -e INTERVAL_SECONDS=30 \ + -e MAX_LOG_MB=1024 -e MAX_SESSION_MB=8192 \ + -e MAX_PID1_RSS_MB=2048 \ + winebot-interactive /scripts/diagnostics/soak-resource-bounds.sh nightly \ + >"$long_soak_log" 2>&1; then + python3 ../wine11-candidate/scripts/ci/classify-wine11-soak.py "$long_soak_log" || + echo 'WINE11_SOAK_DIAGNOSTIC stage=unknown' + rm -f "$long_soak_log" + fail layered_long_soak +fi +rm -f "$long_soak_log" +if ! wait_health; then + classify_health_failure + fail layered_post_soak_health +fi +echo 'WINE11_LAYER_HIL stage=long_soak_passed' + +# Use the running layered service for bounded supervisor recovery, not a +# production host process. Do not reveal PID values or any application logs. +read_openbox_pid() { + docker compose -f compose/layered.yml exec -T --user 1000 \ + winebot-interactive pgrep -o -x openbox 2>/dev/null || true +} +openbox_before="$(read_openbox_pid)" +[[ "$openbox_before" =~ ^[0-9]+$ ]] || fail layered_openbox_missing +if ! docker compose -f compose/layered.yml exec -T --user 1000 \ + winebot-interactive pkill -x openbox >/dev/null 2>&1; then + fail layered_openbox_injection +fi +openbox_deadline=$((SECONDS + 75)) +openbox_recovered=0 +while ((SECONDS < openbox_deadline)); do + openbox_after="$(read_openbox_pid)" + if [[ "$openbox_after" =~ ^[0-9]+$ ]] && [ "$openbox_after" != "$openbox_before" ]; then + openbox_recovered=1 + break + fi + sleep 2 +done +[ "$openbox_recovered" = 1 ] || fail layered_openbox_recovery_timeout +if ! wait_health; then + classify_health_failure + fail layered_openbox_health +fi +echo 'WINE11_LAYER_HIL stage=openbox_recovery_passed' + # Destroy/recreate only disposable runtime containers; never remove state. docker compose -f compose/layered.yml up --no-build --force-recreate -d winebot-interactive \ >/dev/null 2>&1 || fail runtime_recreate diff --git a/tests/test_disposable_layer_contract.py b/tests/test_disposable_layer_contract.py index 1efbd3c3..ba6ca8e8 100644 --- a/tests/test_disposable_layer_contract.py +++ b/tests/test_disposable_layer_contract.py @@ -75,6 +75,48 @@ def test_layered_api_is_enabled_without_unauthenticated_fallback(self): self.assertNotIn('curl -fsS http://127.0.0.1:8000/health', compose) self.assertNotIn('curl -fsS http://localhost:8000/health', compose) + def test_layered_extended_soak_and_window_manager_fault_are_fail_closed(self): + script = (ROOT / "scripts/ci/qualify-wine11-layered.sh").read_text( + encoding="utf-8" + ) + workflow = ( + ROOT / ".github/workflows/wine11-disposable-layer-hil.yml" + ).read_text(encoding="utf-8") + expected = ( + "DURATION_SECONDS=3300", + "INTERVAL_SECONDS=30", + "MAX_LOG_MB=1024", + "MAX_SESSION_MB=8192", + "MAX_PID1_RSS_MB=2048", + "classify-wine11-soak.py", + "fail layered_long_soak", + "fail layered_post_soak_health", + "fail layered_openbox_missing", + "fail layered_openbox_injection", + "fail layered_openbox_recovery_timeout", + "fail layered_openbox_health", + "fail fault_state_replay", + ) + for marker in expected: + self.assertIn(marker, script) + self.assertLess( + script.index("DURATION_SECONDS=90"), + script.index("DURATION_SECONDS=3300"), + ) + self.assertLess( + script.index("DURATION_SECONDS=3300"), + script.index("pkill -x openbox"), + ) + self.assertLess( + script.index("pkill -x openbox"), + script.index("kill -s SIGKILL winebot-interactive"), + ) + self.assertIn(' timeout-minutes: 115', workflow) + self.assertIn('ref: 8c5ed8019a3518cf534b158662755172bfce7c59', workflow) + self.assertNotIn("actions/upload-artifact@", workflow) + self.assertIn('>"$long_soak_log" 2>&1', script) + self.assertIn('rm -f "$long_soak_log"', script) + def test_layered_entrypoint_fail_closed_without_legacy_impact(self): source = (ROOT / "docker/entrypoint.sh").read_text(encoding="utf-8") self.assertIn('WINEBOT_STATE_MODEL:-legacy', source) @@ -119,7 +161,7 @@ def test_wine11_hil_is_public_disposable_and_provenance_bound(self): encoding="utf-8" ) self.assertIn("runs-on: ubuntu-24.04", wf) - self.assertIn("d2304d2b2e096a097ffa76b79aeaeef85b72d702", wf) + self.assertIn("8c5ed8019a3518cf534b158662755172bfce7c59", wf) self.assertIn("persist-credentials: false", wf) self.assertIn("DOCKER_BUILD_RECORD_UPLOAD: 'false'", wf) self.assertNotIn("actions/upload-artifact@", wf) From 32b2290050b896e0af59485fb34b5b49894f8973 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:49:36 +0100 Subject: [PATCH 39/46] ci(rdte): integrate layered and frozen conformance sources only in disposable public runner --- .../layered-contract-integration-rdte.yml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/layered-contract-integration-rdte.yml diff --git a/.github/workflows/layered-contract-integration-rdte.yml b/.github/workflows/layered-contract-integration-rdte.yml new file mode 100644 index 00000000..724805cf --- /dev/null +++ b/.github/workflows/layered-contract-integration-rdte.yml @@ -0,0 +1,111 @@ +name: Layered + Frozen Conformance Integration RDTE +on: + pull_request: + paths: + - '.github/workflows/layered-contract-integration-rdte.yml' +permissions: + contents: read +concurrency: + group: layered-conformance-integration-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + source-integrated-frozen-v1: + runs-on: ubuntu-24.04 + timeout-minutes: 45 + env: + DOCKER_BUILD_RECORD_UPLOAD: 'false' + steps: + - name: Checkout exact layered PR with Git ancestry + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + persist-credentials: false + path: winebot + - name: Test-only source merge with pinned successful conformance PR + working-directory: winebot + shell: bash + run: | + set -euo pipefail + git config user.name 'WineBot Public RDTE' + git config user.email 'winebot-rdte@users.noreply.github.com' + git fetch --no-tags --quiet origin 3acc219a1627a74bdcea6388144cc391ec2b57b4 + if ! git merge --no-commit --no-ff --no-edit 3acc219a1627a74bdcea6388144cc391ec2b57b4 >"$RUNNER_TEMP/merge-local.log" 2>&1; then + echo 'LAYERED_CONFORMANCE_RDTE stage=merge_conflict' + exit 1 + fi + if git diff --name-only --diff-filter=U | grep -q .; then + echo 'LAYERED_CONFORMANCE_RDTE stage=unresolved_files' + exit 1 + fi + echo 'LAYERED_CONFORMANCE_RDTE stage=source_merge_pass' + - name: Existing bounded unit tests on combined source + working-directory: winebot + shell: bash + run: | + set -euo pipefail + if ! docker compose -f compose/docker-compose.yml --profile test --profile interactive run \ + --rm --no-deps test-runner scripts/ci/test.sh >"$RUNNER_TEMP/unit-local.log" 2>&1; then + echo 'LAYERED_CONFORMANCE_RDTE stage=merged_unit_fail' + exit 1 + fi + echo 'LAYERED_CONFORMANCE_RDTE stage=merged_unit_pass' + - name: Checkout pinned frozen public contract suite + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + repository: mark-e-deyoung/winebot-contracts + ref: 205666f7f0235cb0fc51ca8a5af84f9f67831a74 + persist-credentials: false + path: contracts + - name: Install frozen suite requirements + shell: bash + run: | + set -euo pipefail + python3 -m pip install -q -r contracts/tests/conformance/requirements.txt \ + >"$RUNNER_TEMP/deps-local.log" 2>&1 || + { echo 'LAYERED_CONFORMANCE_RDTE stage=contract_deps_fail'; exit 1; } + - name: Start actual source-integrated WineBot API + working-directory: winebot + shell: bash + run: | + set -euo pipefail + if ! docker compose -f compose/docker-compose.yml --profile headless \ + up --build -d winebot >"$RUNNER_TEMP/runtime-local.log" 2>&1; then + echo 'LAYERED_CONFORMANCE_RDTE stage=runtime_start_failed' + exit 1 + fi + if ! scripts/ci/wait-for-container-health.sh compose/docker-compose.yml headless winebot 60 2 \ + >"$RUNNER_TEMP/health-local.log" 2>&1; then + echo 'LAYERED_CONFORMANCE_RDTE stage=runtime_health_failed' + exit 1 + fi + echo 'LAYERED_CONFORMANCE_RDTE stage=runtime_ready' + - name: Run pinned frozen v1 against source-integrated runtime + shell: bash + run: | + set -euo pipefail + cd winebot + cid="$(docker compose -f compose/docker-compose.yml ps -q winebot)" + [ -n "$cid" ] || { echo 'LAYERED_CONFORMANCE_RDTE stage=runtime_absent'; exit 1; } + ip="$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$cid")" + token="$(docker compose -f compose/docker-compose.yml exec -T winebot cat /tmp/winebot_api_token 2>/dev/null || true)" + if [[ ! "$token" =~ ^[A-Za-z0-9._~-]{16,512}$ ]]; then + echo 'LAYERED_CONFORMANCE_RDTE stage=token_invalid' + exit 1 + fi + printf '::add-mask::%s\n' "$token" + cd .. + if ! python3 -m pytest contracts/tests/conformance/ \ + --api-url "http://$ip:8000" --api-token "$token" \ + --results-file "$RUNNER_TEMP/conformance-local.json" \ + -q --tb=no --show-capture=no -rN \ + >"$RUNNER_TEMP/conformance-local.log" 2>&1; then + echo 'LAYERED_CONFORMANCE_RDTE stage=frozen_v1_failed' + exit 1 + fi + echo 'LAYERED_CONFORMANCE_RDTE stage=frozen_v1_pass' + - name: Remove only disposable service containers + if: always() + working-directory: winebot + run: docker compose -f compose/docker-compose.yml --profile headless down --remove-orphans >/dev/null 2>&1 || true From 66a09bd9ce78c78064a144f58b2e609b30827343 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:52:15 +0100 Subject: [PATCH 40/46] rdte(layers): qualify synthetic six-volume checksum backup and nonroot restore --- scripts/ci/qualify-volume-backup-restore.sh | 87 +++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 scripts/ci/qualify-volume-backup-restore.sh diff --git a/scripts/ci/qualify-volume-backup-restore.sh b/scripts/ci/qualify-volume-backup-restore.sh new file mode 100644 index 00000000..957e2bd8 --- /dev/null +++ b/scripts/ci/qualify-volume-backup-restore.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Synthetic, disposable-only state backup + restore RDTE. +# NOT a production backup system. No user data, logs, image pushes or uploads. +set -euo pipefail +fail() { printf 'LAYER_BACKUP_RDTE stage=%s\n' "$1" >&2; exit 1; } +[ "${GITHUB_ACTIONS:-}" = true ] && + [ "${GITHUB_EVENT_NAME:-}" = pull_request ] || fail unqualified_venue +[[ "${GITHUB_RUN_ID:-}" =~ ^[0-9]+$ ]] && + [[ "${GITHUB_RUN_ATTEMPT:-}" =~ ^[0-9]+$ ]] || fail invalid_run +command -v docker >/dev/null 2>&1 || fail docker_unavailable +image='debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a' +prefix="winebot-recovery-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" +backup_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/winebot-recovery.XXXXXXXX")" +volumes=() +cleanup() { + for name in "${volumes[@]}"; do + docker volume rm "$name" >/dev/null 2>&1 || true + done + [ -n "$backup_dir" ] && rm -rf -- "$backup_dir" +} +trap cleanup EXIT +# App packs are separately immutable/versioned; six volumes contain user state. +roles=(prefix home config userdata artifacts shared) +for role in "${roles[@]}"; do + source_volume="$prefix-$role-src" + dest_volume="$prefix-$role-dst" + for name in "$source_volume" "$dest_volume"; do + if docker volume inspect "$name" >/dev/null 2>&1; then + fail volume_already_exists + fi + docker volume create "$name" >/dev/null 2>&1 || fail volume_create + volumes+=("$name") + done + # No preexisting content may be chowned or overwritten. + for name in "$source_volume" "$dest_volume"; do + docker run --rm --network none --read-only --cap-drop ALL --cap-add CHOWN \ + --security-opt no-new-privileges --memory 128m --pids-limit 32 \ + --entrypoint /bin/sh -v "$name:/state" "$image" -ec ' + test -z "$(find /state -mindepth 1 -maxdepth 1 -print -quit)" + chown 1000:1000 /state + ' >/dev/null 2>&1 || fail volume_init + done + docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ + --security-opt no-new-privileges --memory 128m --pids-limit 32 \ + --entrypoint /bin/sh -v "$source_volume:/state" "$image" -ec ' + mkdir /state/data + printf "synthetic-volume-replay\n" > /state/data/proof.txt + printf "synthetic-metadata\n" > /state/config.ini + ' >/dev/null 2>&1 || fail source_write + # Archive output never leaves this disposable runner. + docker run --rm --network none --read-only --user "$(id -u):$(id -g)" \ + --cap-drop ALL --security-opt no-new-privileges --memory 128m \ + --pids-limit 32 --entrypoint /bin/sh \ + -v "$source_volume:/state:ro" -v "$backup_dir:/snapshots" \ + "$image" -ec 'tar -C /state -cf "/snapshots/$1.tar" .' sh "$role" \ + >/dev/null 2>&1 || fail snapshot + (cd "$backup_dir" && sha256sum "$role.tar" > "$role.sha256") || fail digest_write + (cd "$backup_dir" && sha256sum -c "$role.sha256" >/dev/null) || + fail digest_mismatch + # Negative integrity control on a separate copy. + cp "$backup_dir/$role.tar" "$backup_dir/tampered.tar" + printf 'tamper' >> "$backup_dir/tampered.tar" + if printf '%s %s\n' "$(cut -d ' ' -f1 "$backup_dir/$role.sha256")" \ + "$backup_dir/tampered.tar" | sha256sum -c - >/dev/null 2>&1; then + fail tampered_archive_accepted + fi + rm -f -- "$backup_dir/tampered.tar" + # Restore to a different EMPTY state volume with unprivileged user. + docker run --rm --network none --read-only --user 1000:1000 \ + --cap-drop ALL --security-opt no-new-privileges --memory 128m \ + --pids-limit 32 --entrypoint /bin/sh \ + -v "$dest_volume:/state" -v "$backup_dir:/snapshots:ro" \ + "$image" -ec ' + test -z "$(find /state -mindepth 1 -maxdepth 1 -print -quit)" + tar --no-same-owner --no-same-permissions -C /state -xf "/snapshots/$1.tar" + ' sh "$role" >/dev/null 2>&1 || fail restore + # A new nonroot disposable process reads exactly restored synthetic state. + docker run --rm --network none --read-only --user 1000:1000 --cap-drop ALL \ + --security-opt no-new-privileges --memory 128m --pids-limit 32 \ + --entrypoint /bin/sh -v "$dest_volume:/state:ro" "$image" -ec ' + test "$(id -u)" -eq 1000 + test "$(stat -c %u /state)" -eq 1000 + test "$(cat /state/data/proof.txt)" = synthetic-volume-replay + test "$(cat /state/config.ini)" = synthetic-metadata + ' >/dev/null 2>&1 || fail restored_replay +done +echo 'LAYER_BACKUP_RDTE stage=synthetic_six_volume_replay_passed' From 4136501caa940cd32a4337c5e283970c7de63d96 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:52:44 +0100 Subject: [PATCH 41/46] ci(rdte): execute free public runner six-volume state archive/tamper/restore replay --- .../disposable-backup-restore-rdte.yml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/disposable-backup-restore-rdte.yml diff --git a/.github/workflows/disposable-backup-restore-rdte.yml b/.github/workflows/disposable-backup-restore-rdte.yml new file mode 100644 index 00000000..1ffac86f --- /dev/null +++ b/.github/workflows/disposable-backup-restore-rdte.yml @@ -0,0 +1,34 @@ +name: Disposable User-State Backup and Restore RDTE +on: + pull_request: + paths: + - '.github/workflows/disposable-backup-restore-rdte.yml' + - 'scripts/ci/qualify-volume-backup-restore.sh' +permissions: + contents: read +concurrency: + group: layer-backup-${{ github.event.pull_request.number }} + cancel-in-progress: true +jobs: + synthetic-six-volume-recovery: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + env: + DOCKER_BUILD_RECORD_UPLOAD: 'false' + steps: + - name: Checkout exact public PR code without credentials + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + ref: ${{ github.event.pull_request.head.sha }} + persist-credentials: false + - name: Source syntax and destructive-operation scope + run: | + set -euo pipefail + bash -n scripts/ci/qualify-volume-backup-restore.sh + grep -q '^prefix="winebot-recovery-' scripts/ci/qualify-volume-backup-restore.sh + grep -q 'tampered_archive_accepted' scripts/ci/qualify-volume-backup-restore.sh + - name: Fully disposable checksum archive and nonroot recovery + run: bash scripts/ci/qualify-volume-backup-restore.sh + - name: Report only synthetic result + if: success() + run: echo 'LAYER_BACKUP_RDTE stage=qualified_synthetic_replay' From cb3895d389e6d6aa46ee77f0748c19062c4ca53d Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:54:37 +0100 Subject: [PATCH 42/46] ci(rdte): fail-closed reconciliation of only overlapping layered and conformance unit manifests --- scripts/ci/resolve-conformance-units.py | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 scripts/ci/resolve-conformance-units.py diff --git a/scripts/ci/resolve-conformance-units.py b/scripts/ci/resolve-conformance-units.py new file mode 100644 index 00000000..b6577ebd --- /dev/null +++ b/scripts/ci/resolve-conformance-units.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +"""Narrow test-manifest conflict resolver for disposable PR123+PR154 bake-off. + +Do not generalize to production merges. Only a simultaneous append to the +explicit unit-test manifest is resolvable here; all other conflicts fail closed. +""" +from pathlib import Path +import re +import subprocess +import sys + +PATH = "scripts/ci/test.sh" +TEST_LINE = re.compile(r"^ (tests/test_[a-z0-9_]+\.py)(?: \\)?$") + + +def git(*args: str) -> str: + return subprocess.check_output(["git", *args], text=True) + + +def parse(source: str) -> tuple[str, list[str]]: + lines = source.splitlines() + i = next((n for n, line in enumerate(lines) if TEST_LINE.fullmatch(line)), -1) + if i < 0: + raise ValueError("unit manifest lacks test entries") + prefix = "\n".join(lines[:i]) + "\n" + tests = [] + for line in lines[i:]: + match = TEST_LINE.fullmatch(line) + if not match: + raise ValueError("unexpected content in unit-test list") + tests.append(match.group(1)) + if len(set(tests)) != len(tests): + raise ValueError("duplicate unit test") + return prefix, tests + + +def main() -> int: + try: + conflicts = git("diff", "--name-only", "--diff-filter=U").splitlines() + if conflicts != [PATH]: + raise ValueError("unexpected conflict set") + ours = git("show", ":2:" + PATH) + theirs = git("show", ":3:" + PATH) + base = git("show", ":1:" + PATH) + pre_ours, tests_ours = parse(ours) + pre_theirs, tests_theirs = parse(theirs) + pre_base, tests_base = parse(base) + if pre_ours != pre_theirs or pre_ours != pre_base: + raise ValueError("non-manifest content diverged") + if set(tests_base) - set(tests_ours) or set(tests_base) - set(tests_theirs): + raise ValueError("test removed by a candidate") + if set(tests_ours) - set(tests_base) != {"tests/test_disposable_layer_contract.py"}: + raise ValueError("unexpected layered source tests") + integrated = tests_theirs + [s for s in tests_ours if s not in tests_theirs] + if set(integrated) != set(tests_ours) | set(tests_theirs): + raise ValueError("test union lost coverage") + result = pre_theirs + " \\\n".join(" " + s for s in integrated) + "\n" + Path(PATH).write_text(result, encoding="utf-8") + subprocess.check_call(["git", "add", "--", PATH]) + if git("diff", "--name-only", "--diff-filter=U").strip(): + raise ValueError("merge still unmerged") + except (OSError, ValueError, subprocess.CalledProcessError): + print("LAYERED_CONFORMANCE_RDTE stage=source_merge_conflict", file=sys.stderr) + return 1 + print("LAYERED_CONFORMANCE_RDTE stage=unit_test_union_resolved") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From 427ff85aa2dd1a3f40295e01a86e414de44cc0b9 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:55:03 +0100 Subject: [PATCH 43/46] ci(rdte): resolve only verified unit-manifest append conflict in ephemeral source bake-off --- .github/workflows/layered-contract-integration-rdte.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/layered-contract-integration-rdte.yml b/.github/workflows/layered-contract-integration-rdte.yml index 724805cf..46d1e7cf 100644 --- a/.github/workflows/layered-contract-integration-rdte.yml +++ b/.github/workflows/layered-contract-integration-rdte.yml @@ -32,8 +32,9 @@ jobs: git config user.email 'winebot-rdte@users.noreply.github.com' git fetch --no-tags --quiet origin 3acc219a1627a74bdcea6388144cc391ec2b57b4 if ! git merge --no-commit --no-ff --no-edit 3acc219a1627a74bdcea6388144cc391ec2b57b4 >"$RUNNER_TEMP/merge-local.log" 2>&1; then - echo 'LAYERED_CONFORMANCE_RDTE stage=merge_conflict' - exit 1 + # Only the known independent test-list append conflict is + # resolvable. Every other merge collision fails closed. + python3 scripts/ci/resolve-conformance-units.py || exit 1 fi if git diff --name-only --diff-filter=U | grep -q .; then echo 'LAYERED_CONFORMANCE_RDTE stage=unresolved_files' From 1e4929ca6703fdf234b60ac277c3dd1b4d22769a Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:56:40 +0100 Subject: [PATCH 44/46] fix(rdte): keep backup archives in separately owned synthetic Docker volume for nonroot restoration --- scripts/ci/qualify-volume-backup-restore.sh | 51 ++++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/scripts/ci/qualify-volume-backup-restore.sh b/scripts/ci/qualify-volume-backup-restore.sh index 957e2bd8..66d21cff 100644 --- a/scripts/ci/qualify-volume-backup-restore.sh +++ b/scripts/ci/qualify-volume-backup-restore.sh @@ -10,15 +10,26 @@ fail() { printf 'LAYER_BACKUP_RDTE stage=%s\n' "$1" >&2; exit 1; } command -v docker >/dev/null 2>&1 || fail docker_unavailable image='debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a' prefix="winebot-recovery-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" -backup_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/winebot-recovery.XXXXXXXX")" -volumes=() +backup_volume="$prefix-snapshots" +if docker volume inspect "$backup_volume" >/dev/null 2>&1; then + fail volume_already_exists +fi +docker volume create "$backup_volume" >/dev/null 2>&1 || fail volume_create +volumes=("$backup_volume") cleanup() { for name in "${volumes[@]}"; do docker volume rm "$name" >/dev/null 2>&1 || true done - [ -n "$backup_dir" ] && rm -rf -- "$backup_dir" } trap cleanup EXIT +# An isolated synthetic archive volume is initialized once; no host paths, +# temporary directories, or real user state cross this container boundary. +docker run --rm --network none --read-only --cap-drop ALL --cap-add CHOWN \ + --security-opt no-new-privileges --memory 128m --pids-limit 32 \ + --entrypoint /bin/sh -v "$backup_volume:/snapshots" "$image" -ec ' + test -z "$(find /snapshots -mindepth 1 -maxdepth 1 -print -quit)" + chown 1000:1000 /snapshots + ' >/dev/null 2>&1 || fail backup_volume_init # App packs are separately immutable/versioned; six volumes contain user state. roles=(prefix home config userdata artifacts shared) for role in "${roles[@]}"; do @@ -48,28 +59,34 @@ for role in "${roles[@]}"; do printf "synthetic-metadata\n" > /state/config.ini ' >/dev/null 2>&1 || fail source_write # Archive output never leaves this disposable runner. - docker run --rm --network none --read-only --user "$(id -u):$(id -g)" \ + docker run --rm --network none --read-only --user 1000:1000 \ --cap-drop ALL --security-opt no-new-privileges --memory 128m \ --pids-limit 32 --entrypoint /bin/sh \ - -v "$source_volume:/state:ro" -v "$backup_dir:/snapshots" \ + -v "$source_volume:/state:ro" -v "$backup_volume:/snapshots" \ "$image" -ec 'tar -C /state -cf "/snapshots/$1.tar" .' sh "$role" \ >/dev/null 2>&1 || fail snapshot - (cd "$backup_dir" && sha256sum "$role.tar" > "$role.sha256") || fail digest_write - (cd "$backup_dir" && sha256sum -c "$role.sha256" >/dev/null) || - fail digest_mismatch - # Negative integrity control on a separate copy. - cp "$backup_dir/$role.tar" "$backup_dir/tampered.tar" - printf 'tamper' >> "$backup_dir/tampered.tar" - if printf '%s %s\n' "$(cut -d ' ' -f1 "$backup_dir/$role.sha256")" \ - "$backup_dir/tampered.tar" | sha256sum -c - >/dev/null 2>&1; then - fail tampered_archive_accepted - fi - rm -f -- "$backup_dir/tampered.tar" + # Archive integrity and tamper-negative tests run only in a fresh, nonroot + # short-lived container against the disposable backup volume. + docker run --rm --network none --read-only --user 1000:1000 \ + --cap-drop ALL --security-opt no-new-privileges --memory 128m \ + --pids-limit 32 --entrypoint /bin/sh \ + -v "$backup_volume:/snapshots" "$image" -ec ' + cd /snapshots + sha256sum "$1.tar" > "$1.sha256" + sha256sum -c "$1.sha256" >/dev/null + cp "$1.tar" tampered.tar + printf tamper >> tampered.tar + expected="$(cut -d " " -f1 "$1.sha256")" + if printf "%s tampered.tar\n" "$expected" | sha256sum -c - >/dev/null 2>&1; then + exit 41 + fi + rm -f tampered.tar + ' sh "$role" >/dev/null 2>&1 || fail archive_integrity_negative # Restore to a different EMPTY state volume with unprivileged user. docker run --rm --network none --read-only --user 1000:1000 \ --cap-drop ALL --security-opt no-new-privileges --memory 128m \ --pids-limit 32 --entrypoint /bin/sh \ - -v "$dest_volume:/state" -v "$backup_dir:/snapshots:ro" \ + -v "$dest_volume:/state" -v "$backup_volume:/snapshots:ro" \ "$image" -ec ' test -z "$(find /state -mindepth 1 -maxdepth 1 -print -quit)" tar --no-same-owner --no-same-permissions -C /state -xf "/snapshots/$1.tar" From 913f08b517a580484c7b1a55ced0c17e98e92c1b Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:10:14 +0100 Subject: [PATCH 45/46] ci(rdte): reconcile qualified one-file backup restore source guard from #156 --- .github/workflows/disposable-backup-restore-rdte.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/disposable-backup-restore-rdte.yml b/.github/workflows/disposable-backup-restore-rdte.yml index 1ffac86f..479ea653 100644 --- a/.github/workflows/disposable-backup-restore-rdte.yml +++ b/.github/workflows/disposable-backup-restore-rdte.yml @@ -26,7 +26,9 @@ jobs: set -euo pipefail bash -n scripts/ci/qualify-volume-backup-restore.sh grep -q '^prefix="winebot-recovery-' scripts/ci/qualify-volume-backup-restore.sh - grep -q 'tampered_archive_accepted' scripts/ci/qualify-volume-backup-restore.sh + grep -q 'archive_integrity_negative' scripts/ci/qualify-volume-backup-restore.sh + grep -q 'backup_volume="$prefix-snapshots"' scripts/ci/qualify-volume-backup-restore.sh + ! grep -q 'rm -rf' scripts/ci/qualify-volume-backup-restore.sh - name: Fully disposable checksum archive and nonroot recovery run: bash scripts/ci/qualify-volume-backup-restore.sh - name: Report only synthetic result From c0ea638100cec10940b73deefae2a46eb2e9e4b3 Mon Sep 17 00:00:00 2001 From: "Mark E. DeYoung" <1854350+mark-e-deyoung@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:16:03 +0100 Subject: [PATCH 46/46] ci: fix Ruff I001 import ordering in conformance resolver --- scripts/ci/resolve-conformance-units.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/resolve-conformance-units.py b/scripts/ci/resolve-conformance-units.py index b6577ebd..7c4c3415 100644 --- a/scripts/ci/resolve-conformance-units.py +++ b/scripts/ci/resolve-conformance-units.py @@ -4,10 +4,10 @@ Do not generalize to production merges. Only a simultaneous append to the explicit unit-test manifest is resolvable here; all other conflicts fail closed. """ -from pathlib import Path import re import subprocess import sys +from pathlib import Path PATH = "scripts/ci/test.sh" TEST_LINE = re.compile(r"^ (tests/test_[a-z0-9_]+\.py)(?: \\)?$")