Files
Heimdall/skills/compose-disposable-recipe/SKILL.md
T
arnaud.dartois bc7ddccfe3
Heimdall Gitea / Detect CI scope (push) Successful in 5s
Heimdall Gitea / Build and tests (push) Skipped
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 2s
docs: document Infisical secret workflows (#322)
Closes #321
Closes #323

## Résumé
- Ajoute un skill projet pour utiliser le MCP Infisical sans divulguer les valeurs et relie les workflows concernés.
- Définit une évaluation automatique des releases et du SemVer, sans demander à l’utilisateur si une release est souhaitée ou quel numéro choisir.
- Les docs/skills seules ne déclenchent pas de release.

## Évaluation de release
Aucune release pour cette PR : elle ne contient que de la documentation et des skills. La version stable reste `1.0.0`; aucun tag ne sera créé.

## Validation
- `git diff origin/main...HEAD --check` : réussi.
- Inventaire Infisical limité aux noms de clés; aucune valeur secrète dans le diff.
- Les checks Gitea de la première révision passaient; les nouveaux checks sont en cours après la mise à jour.
- Tests applicatifs non exécutés : changement documentaire uniquement.

Reviewed-on: #322
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-10 16:29:15 +01:00

9.1 KiB

name, description
name description
compose-disposable-recipe Build and acceptance-test Heimdall changes in a disposable Docker Compose stack, isolated from deployed data and configuration.

Disposable Compose acceptance

Follow Infisical secrets when the surrounding task also needs real credentials. Acceptance projects must always use generated synthetic values and must never retrieve deployment secrets from Infisical.

Use this skill for every Heimdall behavior, deployment, or operational change. Read the relevant project skill too; for first administrator setup, use first-admin-bootstrap.

When implementation or acceptance preparation has independent branches, use parallel development with Orca to assign bounded work. Keep the final Compose run, cleanup verification, and acceptance evidence under one coordinator so the combined change is validated as a whole.

Track the change and its acceptance evidence in a Gitea issue; follow the Gitea ticket workflow. Put the project name, exact local image tags and cleanup verification in the issue or linked PR, and close the ticket only after the recipe and other required gates pass.

Safety and isolation

  • Build from the current source with a unique Compose project name. Do not test against the production hostname, database, image volumes, secrets, or credentials.
  • Put generated .env and secret files under a temporary directory outside the repository. Use synthetic test identities and cryptographically random local passwords.
  • Use an unused loopback host port and Compose-managed volumes whose names include the unique project name. Do not join production or shared networks.
  • Give each locally built acceptance image a project-unique tag, for example heimdall:<project>-acceptance; do not build under latest, local, or a tag that existed before the recipe. Use a temporary Compose override to set the unique image tag while preserving the source build context. Record all generated tags before starting.
  • Never use broad Docker cleanup such as docker system prune, docker image prune, or docker rmi $(docker images -q). Remove only the test project with docker compose -p <unique-name> down --volumes --remove-orphans.
  • After teardown, check that the project has no containers, volumes, or networks. For every locally built image tag, run docker image rm <exact-recipe-tag> if it exists, then verify docker image inspect <exact-recipe-tag> fails. Remove the temporary Compose override/env/source files. Do not remove shared upstream base images (for example PostgreSQL, .NET SDK, or MediaMTX) or images owned by another recipe/project.
  • Put teardown and exact-tag image removal in the same cleanup trap so both success and failure paths clean up. Do not reuse another acceptance recipe's locally built image: build a uniquely tagged image for this recipe and remove it in this recipe's cleanup path.
  • A recipe is not complete until every local application image tag created by that recipe has been removed and verified absent. docker compose down does not remove images. Apply this even when the behavioral assertion fails; keep generated upstream/base images and unrelated project images untouched.
  • These requirements apply to every Docker-based acceptance recipe, including SDK-only test containers, third-party mocks, one-shot helpers, and failure/partial-build paths. Such recipes must explicitly state whether they build any local images. If they build none, leave upstream images intact and still verify cleanup of project containers, volumes, and networks. If they build any local image (Heimdall or helper), record its unique tag before build and remove/verify it absent in the same EXIT cleanup trap, even if Compose startup or the build fails.
  • Cleanup must preserve the recipe's original exit status, attempt teardown and removal of every recorded tag independently, and report cleanup failures rather than silently declaring acceptance complete. Never use --rmi all because it can remove shared or unrelated images.
  • Mandatory local image cleanup: before the first build, enumerate and record every recipe-owned image tag that may be created (application, SDK/test harness, mock, one-shot helper). Use a unique tag for each locally built image. The EXIT trap must remove each exact recorded tag after project teardown and verify it is absent, regardless of whether build, startup, assertions, or teardown failed. Do not count an image as shared merely because its Dockerfile uses a shared base; only remove recipe-built tags, and retain upstream images. If no image is built locally, explicitly say so and verify the project resources are gone. Never leave recipe-created local images behind.

Required cleanup trap pattern

Use one EXIT trap installed before the first build or Compose start. Record exact local tags in an array before building; leave the array empty when the recipe builds no images. Cleanup actions must be independent so a failed Compose teardown cannot skip image and temporary-file cleanup. Preserve the original status and return a failure if any cleanup verification fails:

# Initialize these exact paths before installing the trap. Omit source_copy if
# the recipe does not create a source archive.
temp_dir=$(mktemp -d "${TMPDIR:-/tmp}/${project}.XXXXXX")
env_file="$temp_dir/acceptance.env"
compose_override="$temp_dir/compose.override.yml"
source_copy="$temp_dir/source-copy.tar"

cleanup() {
  status=$?
  trap - EXIT
  cleanup_failed=0
  docker compose -p "$project" --env-file "$env_file" -f "$compose_file" \
    down --volumes --remove-orphans || cleanup_failed=1
  # Query all three resource kinds by Compose project label; do not infer
  # absence from `compose down`'s exit code alone.
  containers=$(docker ps -aq --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
  volumes=$(docker volume ls -q --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
  networks=$(docker network ls -q --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
  [[ -z "$containers" && -z "$volumes" && -z "$networks" ]] || cleanup_failed=1
  for tag in "${local_image_tags[@]}"; do
    docker image rm "$tag" >/dev/null 2>&1 || true
    docker image inspect "$tag" >/dev/null 2>&1 && cleanup_failed=1
  done
  # Remove only the files this recipe generated; rmdir fails visibly if
  # anything unexpected remains in the temporary directory.
  rm -f -- "$env_file" "$compose_override" "$source_copy" || cleanup_failed=1
  rmdir -- "$temp_dir" || cleanup_failed=1
  if (( cleanup_failed )); then
    printf 'Disposable recipe cleanup failed for project %s\\n' "$project" >&2
    status=1
  fi
  exit "$status"
}
trap cleanup EXIT

The label queries must succeed and return empty results for containers, volumes, and networks. Do not include upstream images in local_image_tags. Recipe records must state the project name, whether local images were built, exact tags and absence checks (or explicitly “none”), plus project-resource cleanup results. A Docker recipe that reports teardown without the image-tag check is incomplete.

Acceptance workflow

  1. Inspect the Compose file and interpolation requirements before starting it. Generate a temporary environment file with unique database/JWT secrets and a distinct loopback port.

  2. Generate a temporary Compose image override. For example:

    services:
      heimdall:
        image: heimdall:${ACCEPTANCE_PROJECT}-central
    

    Put ACCEPTANCE_PROJECT=<unique-name> in the temporary env file and include both Compose files in every command. This overrides only the image tag; the checked-in source build context is retained. Use similarly unique tags for any Agent or helper image built from this checkout.

  3. Start the minimal Central + PostgreSQL stack from source with docker compose -p <unique-name> --env-file <temp-env> -f docker/docker-compose.yml -f <temp-image-override> up -d --build.

  4. Wait for the Central health check and probe the changed behavior through its HTTP/API/UI boundary. Exercise both the expected success path and the relevant rejection/restart path.

  5. Capture only sanitized logs or response codes needed to explain a failure. Never print passwords, tokens, connection strings, or full environment files.

  6. Install an EXIT trap before the first build/start operation. The trap must preserve the test command's exit status, run docker compose ... down --volumes --remove-orphans, verify no project containers/volumes/networks remain, remove every recorded project-unique locally built image tag and verify each is absent, then delete each explicitly named generated environment, secret, override, and copied-source file with rm -f. Finish with rmdir on the one temporary directory; a non-empty directory must make cleanup fail visibly. Attempt each cleanup action even if an earlier action fails. Retain shared upstream/base images. Do not use recursive deletion, Compose --rmi all, or broad prune commands.

If Docker access is unavailable, request the required local permission or explain the blocker; do not substitute a production deployment or claim the recipe passed.