Chapters

DOC-04 / Technical reference · Chapter 09

Deployment & infrastructure of Synedre OS

This chapter describes the deployment pipeline of Synedre OS and its tenants, detailing the asymmetry between `./deploy` (preprod, AI-driven) and `./ship` (production, gated by the `auto_ship_allowed` fleet), as well as the associated build, drift, secrets, and commit rules.

Deployment & infrastructure

This section describes the release pipeline for the Synedre OS harness and its tenants: the asymmetry between the two main entry points, the YAML-driven dispatcher, the build-on-host + archive + upload pattern (no build on the target VPS), the special case of the mothership self-deploy, the single inventory source, the secrets doctrine, and the commit-before-deploy rule.

1. ./deploy vs ./ship asymmetry

Two entry points coexist at the repository root. They do not do the same thing and do not have the same owner.

./deploy ./ship
Target Preprod (or mothership live runtime / PROD for founder sites without preprod) Production
Owner AI / worker / cascade, systematic Fleet-gated (auto_ship_allowed): AI/tick if enabled, manual intervention otherwise
Git Auto-commit of dirty state + stays on the preprod branch git checkout main → git pull → git merge preprod -X theirs → git push origin main, then return to preprod (EXIT trap)
Dirty guard Silent auto-commit unless on main (hard refusal) Blocking: refusal if working tree is dirty, unless --allow-dirty
Drift check Single hardwired preprod target; any other tenant → explicit skip. --skip-drift bypass available. Hub schema check (blocking) + prod tenant DB schema if target is known — two targets. No --skip-drift equivalent: hub drift is strictly blocking here.
Drift auto-apply Generates and applies missing idempotent DDL statements in a single transaction (CREATE TABLE IF NOT EXISTS, ALTER TABLE ADD COLUMN IF NOT EXISTS). Active by default. Can be disabled on a per-run basis via environment variable. Applied before any build or reload. — (drift applied manually before shipping)
Post-deploy smoke HTTP smoke + automated visual smoke, non-blocking (can be disabled via environment variable). Process manager environment check then HTTP smoke + content/JSON checks.
Migrations — Lists pending .sql files for the relevant scope — non-blocking, not auto-applied.
Closing — Proposes closing worksites in test state (post-ship step).

Doctrine:

  • ./ship <tenant> = Production, fleet-gated (field auto_ship_allowed from the client VPS inventory table: true by default → AI/tick may ship; false → excluded, manual ship only). An unattended nightly ship additionally requires proof of a green QA run.
  • ./deploy <tenant> = always the AI, systematically and without prompting — including on the mothership where ./deploy performs a live rebuild of the runtime (no dedicated preprod).
        ┌─────────────┐   ./deploy <tenant>   ┌──────────────┐
  AI →  │  preprod     │ ──────────────────→  │  preprod /    │
        │  branch      │   (auto, N times)     │  live runtime │
        └─────────────┘                        └──────────────┘
                │
                │  Preprod review, validation
                ▼
        ┌─────────────┐   ./ship <tenant>      ┌──────────────┐
 ship → │ merge preprod│ ──────────────────→  │  PRODUCTION   │
        │  → main      │   (fleet-gated)        │              │
        └─────────────┘                        └──────────────┘

Founder public site without preprod exception: ./deploy on a founder's public site is refused — that site has no preprod (it runs on a dedicated VPS). It can only be modified via ./ship.

Founder tenants without preprod exception (mothership, founder sites): for these tenants, ./deploy points directly to production. The deploy = preprod boundary does not hold — the AI triggers ./deploy but it modifies production. This is intentional: no dedicated preprod for founder sites. ./ship remains available (preprod→main merge + full ceremony), and these founder tenants have auto_ship_allowed = true by default.

1b. ./ship pipeline detail (numbered steps)

./ship <tenant> runs the following steps in order:

  1. Flag parsing: --allow-dirty (bypass dirty guard), --no-close (skip post-ship), remainder forwarded to the dispatcher.
  2. Blocking dirty guard: working tree cleanliness check → exits with an error if dirty (unless --allow-dirty).
  3. EXIT trap cleanup: guaranteed return to preprod even on error; a checkout failure is reported loudly (prevents getting stuck on main).
  4. Root-owned file cleanup: removal of build artefacts left by previous deployments that would block subsequent writes.
  5. Hub drift (blocking): hub schema check — no bypass. Then prod tenant DB drift if target is known.
  6. preprod → main merge: checkout main, pull, merge preprod -X theirs, push origin main.
  7. Migrations: display of pending files (see § 1c) — non-blocking, not auto-applied.
  8. Agent audit: non-blocking report on the state of declared agents.
  9. Prod deployment: dispatcher call with the tenant and the --all flag (see § 2).
  10. Prod smoke: process manager environment check before HTTP smoke + content/JSON checks.
  11. Post-ship close: proposal to close worksites in test state (skipped via --no-close).
--skip-drift asymmetry: ./deploy accepts --skip-drift to bypass the preprod drift check (urgent CI hotfix). ./ship has no equivalent — hub drift is strictly blocking there: a ship to production on a divergent schema is never allowed.

1c. DB migrations during ship

The ship displays pending .sql files but never applies them: the automated migration runner has been disabled and no runner is connected on the production database side — this is the real hard constraint. The block is purely informational (non-blocking): it prints the commands to be run manually.

The tenant → migration scope mapping prevents mixing mothership migrations with tenant migrations:

Tenant (argument) Scope → migrations/<scope>/ folder
Mothership / hub mothership
An e-commerce client A (preprod and prod) Dedicated client A scope
An e-commerce client B and its aliases Dedicated client B scope
Founder site Founder site scope
all Special case — aggregation of all scopes
other Fallback: tenant name used directly

Special case all: aggregates all targets via a recursive search in the migrations/ folder, excluding _applied/ and applied/ subfolders (already-run migrations). Other scopes simply list the .sql files in the corresponding folder.

2. Routing of ./deploy <tenant> and ./ship <tenant>

Both entry points route each tenant to a dedicated script or to the generic dispatcher. The dispatcher is driven by a YAML configuration file (deploy.yaml) that describes, for each tenant, the target host, the build flags, and the steps to execute.

Tenant (argument) ./deploy → ./ship →
Mothership (default) Health lock check then dedicated mothership deploy script (or build-on-host variant if HOST_BUILD=1) Same dedicated mothership script
Founder public site (no preprod) Refused — no preprod Generic dispatcher
Mothership site (synedre.com) Generic dispatcher → direct PROD Generic dispatcher ⚠️ process manager environment check potentially blocking if tenant not declared in the check script
Main product (CodeMyShop) Generic dispatcher → direct PROD (no longer a distinct preprod); smoke enabled Generic dispatcher
Main product demo Generic dispatcher → demo staging —
Client A (with preprod) Generic dispatcher → preprod; no smoke (preprod behind basic authentication) Generic dispatcher → prod (without the --target flag, the YAML config points to prod)
Client B Generic dispatcher → client B preprod; smoke enabled ⚠️ No dedicated prod target block: falls through to the fallback (likely errors out if no prod VPS is declared). Only certain aliases trigger the "No prod" message.
Annexe founder site Generic dispatcher → PROD; smoke enabled Generic dispatcher
all 5 background parallel jobs: mothership, main product (PROD), client A (preprod), client B, annexe founder site. Post-job smoke across all targets. ⚠️ The all smoke tests the product demo but the job deploys the production storefront — inconsistency to be fixed. 3 parallel jobs: mothership, founder public site, main product. Smoke across all three targets.
--list / -l Dump of the client VPS inventory table (see § 6) —
other Fallback: legacy Ansible script → preprod Fallback: legacy Ansible script → prod
Convergence toward a single dispatcher: all remote tenants except the mothership go through the generic dispatcher for both ./deploy and ./ship. The mothership retains its dedicated script because self-deploy is architecturally distinct (local Docker build, no network transfer).
⚠️ all smoke inconsistency: ./deploy all deploys the main product directly to production, but the subsequent smoke tests the demo staging environment. The production storefront is not verified in this path — a point to fix in the all mode smoke loop.

The YAML-driven dispatcher

The standard deployment pipeline applies to all remotely hosted tenants, with the exception of Synedre OS, which has its own self-deployment procedure. It is driven by a per-tenant YAML configuration file that is validated at each execution before any action is taken on the infrastructure.

Configuration file resolution

When the pipeline is invoked, the system identifies the YAML file to use according to the following rule:

  • The name vaisseau-mère is reserved and triggers a distinct internal branch — this branch is currently inert in practice: no corresponding configuration file exists on disk, and Synedre OS is in any case routed upstream to its own procedure before reaching this point.
  • Any other tenant identifier resolves to the deploy.yaml file (or deploy.<target>.yaml if an explicit target is supplied) located in that tenant's directory.

Note: The dispatcher's "vaisseau-mère" branch is documented but produces no operational effect. It is kept as a dead reference to prevent silent regressions upon a future activation.

Pipeline steps

  1. Argument parsing: the pipeline expects a full-deployment flag (--all, required), an optional target (--target=<X>, with the = sign required), and a cache-clear flag (--clean, optional).
  2. YAML resolution and validation: a Python validator reads the tenant configuration file, checks its conformance to the schema, and exposes the resolved parameters to the shell environment. Any validation error immediately halts the pipeline.
  3. Initialisation: cache-clear flags and the deployment timer are set up.
  4. Start banner: run metadata is displayed (tenant, target, timestamp).
  5. Schema drift check: if the drift section is declared in the YAML, the system compares the actual database state against the expected schema.
  6. Automatic drift apply: enabled by default, the system generates and applies the missing idempotent DDL statements (CREATE TABLE IF NOT EXISTS, ALTER TABLE ADD COLUMN IF NOT EXISTS) in a single transaction. The schema is updated before any build or reload. This behaviour can be disabled on a per-run basis via a dedicated environment variable.
  7. Background audit hook launch: asynchronous start of the agent audit, if configured.
  8. i18n route generation (pre-build): if the seed_i18n section is present, the system queries the tenant database (category and localised metadata tables) via the SSH/Docker connection and produces the JSON file of localised route segments consumed during the build. This step is non-blocking: if the database is unreachable, the build falls back to hardcoded values.
  9. Nuxt build: compilation of the tenant frontend.
  10. Post-build i18n seeding: injection of translations into the database if seed_i18n is declared.
  11. Source maps: source maps are uploaded if the corresponding hook is enabled.
  12. Packaging: a compressed archive of the build is created in the system's temporary directory.
  13. Background Git push: if the git_push hook is enabled, the push to the repository is performed in parallel.
  14. Archive transfer: the archive is securely transferred to the client VPS.
  15. Remote reload: according to the variant declared in the YAML —
    • pm2: graceful reload or forced restart of the application process;
    • docker: container restart via Compose.
  16. Recurring job installation: if the cron section is declared, the system creates or updates the crontab entries for the SSH user on the client VPS (and not on the vaisseau-mère). Each block is idempotently tagged: the old block is removed before rewriting. An empty list triggers a full cleanup of the block. Doctrine: recurring jobs run as close as possible to their database, on the VPS that hosts them.
  17. Asynchronous hook synchronisation: the pipeline waits for the Git push and agent audit to complete.
  18. Health check: the health URL is polled until a valid response is received or the configured maximum wait time is reached.
  19. End banner: run summary is displayed (duration, status).

YAML configuration file schema

Each tenant's configuration file is validated by the Python validator embedded in the repository. The recognised sections are as follows:

Section Required Description
name Yes Kebab-case tenant identifier (regex ^[a-z0-9][a-z0-9_-]*$).
build Yes Local build parameters: relative client path (local_client, required) and Node environment (node_env, default production).
ssh Yes Client VPS connection: host (required), user (default ubuntu), SSH key (optional).
drift No Declaration of schema drift monitoring and automatic application.
seed_i18n No Parameters for generating and seeding i18n routes from the database.
remote Yes Reload variant (pm2 or docker) and associated parameters.
health Yes Health URL to poll after deployment (url, required) and maximum wait time (max_wait, default 45 s).
hooks No Optional hooks: agent audit, source map upload, Git push.
cron No List of recurring jobs to install on the client VPS (entries {key, schedule, command, comment}).

Variant consistency guardrails

The validator enforces strict mutual exclusion rules depending on the chosen variant:

  • pm2 variant: the PM2 application name (pm2_app) is required; Docker-specific parameters (container, subdir) are forbidden.
  • docker variant: the container name (container) is required; PM2 parameters are forbidden.

Validation of the cron section

Each entry in the recurring job list is validated against the following constraints:

  • key: kebab-case identifier unique within the tenant;
  • schedule: crontab expression with exactly 5 fields;
  • command: non-empty command to execute;
  • comment: optional descriptive label.

A cron section declared as empty ([]) is intentionally forwarded to the installer, which interprets this signal as an instruction to fully clean up the crontab block associated with the tenant.

Configuration example

The example below illustrates the structure of a complete configuration file for a tenant deployed using the pm2 variant:

name: <tenant-name>
build:
  local_client: codemyshop/tenants/<tenant-name>
  node_env: production
ssh:
  host: <client-vps-address>
remote:
  variant: pm2
  dir: /var/www/codemyshop/app/codemyshop/tenants/<tenant-name>
  pm2_app: <tenant-name>-nuxt
  pm2_remote_user: <ssh-user>
health:
  url: https://<tenant-domain>
hooks:
  git_push: <tenant-name>

Build-host pattern, compression and transfer (no build on the client VPS)

This is the central invariant for remotely hosted tenants: the client VPS never compiles. The Nuxt bundle is produced on the mothership (host machine), compressed, transferred, extracted and then reloaded on the target VPS. The startup log explicitly reports this mode.

  ┌──────────────────────── MOTHERSHIP (host) ────────────────────────┐
  │ 1. npm install --prefer-offline (monorepo root delta)             │
  │ 2. npx vitest run <product-url-suite>   (smoke invariants URL)    │
  │ 3. npx nuxi build <client-local>          → .output/              │
  │ 4. tar -I pigz -cf /tmp/<name>-build.tar.gz -C <client> .output  │
  └────────────────────────────────┬──────────────────────────────────┘
                                   │ secure transfer to /tmp/
                                   ▼
  ┌────────────────────────── CLIENT VPS ─────────────────────────────┐
  │ 5. mv .output .output_old        (rollback ready)                 │
  │ 6. tar -I <decompressor> -xf /tmp/<archive>                      │
  │ 7. pm2 reload <app> --update-env   |   docker compose restart <c> │
  │ 8. if online → rm .output_old                                     │
  │    else      → print 'mv .output_old .output' + exit 1           │
  └────────────────────────────────┬──────────────────────────────────┘
                                   │
                                   ▼  HTTP 200 poll (configurable max delay)
                             health check

Deployment step details

  • Nuxt compilation: purge of the .output directory (and .nuxt if the --clean option is enabled), offline dependency installation, then a blocking smoke test on product URL shape invariants before triggering the build. If an incremental build fails, a retry with a full clean is performed automatically.
  • Compression: packaging of the .output directory with pigz if available, otherwise falling back to gzip (systematic fallback).
  • Transfer: secure copy to the target VPS temporary directory, followed by deletion of the local archive after upload.
  • Docker reload (containerised runtime): remote connection, .output → .output_old rotation, extraction into the configured directory, deletion of the conflicting native CJS cache within the output tree, container restart, status check; otherwise rollback.
  • Graceful PM2 reload (direct Node runtime): pm2 reload <app> --update-env — preserves active connections. Supports a dedicated remote user. Optionally creates a symbolic link for back-office static assets (prevents file resolution errors on uploads).
  • Hard PM2 restart (first deployment or explicit configuration): full deletion and recreation of the PM2 process, followed by a process list save.
  • Health check: HTTP polling loop until a 200 status code is received or the maximum delay is reached (45 seconds by default).
  • Log banners: visual framing of the deployment with phase-based time segmentation.
  • Per-tenant cron installer: deployment and activation of scheduled tasks specific to each remote tenant.

Rollback strategy

.output_old is retained throughout the entire reload phase. It is purged only if the process comes back online successfully. On failure (process or container not started), the script only prints the suggested restore command and exits with error code 1 — the restore is intentionally manual: no automatic rollback is executed. The environment variable SHIP_KEEP_ROLLBACK=1 forces retention of .output_old even on success.

Pre-build lockfile consistency guard

Before any deployment of the mothership's main frontend, a verification script detects two blocking misalignments before any npm install or nuxi build:

  1. Insufficient cssnano version in the lockfile (missing transitive PostCSS dependencies → silently broken build).
  2. Nuxt version below the required threshold in the main project manifest (risk of bundler misalignment).

A non-blocking warning is emitted if Vite version overrides are detected. Any other discrepancy triggers an exit 1 with an explicit corrective message and cancels the deployment. The suggested fix is a full dependency reinstall from scratch.

Post-deployment smoke: three validation layers

The post-deployment validation pipeline is structured into three complementary levels.

Layer 1 — HTTP checks

A curl request is made against each URL declared for the tenant. A 5xx response code is blocking; a 4xx code generates a non-blocking warning. The list of covered tenants is declared in the smoke script; an internal loop automatically covers all registered tenants, while certain tenants are checked individually from the main deployment script.

Layer 2 — JSON content shape verification

This layer validates the shape of the JSON returned by the main navigation API. It was introduced after an incident revealed that a tenant was returning HTTP 200 for two days while the JSON response contained an error indicator, causing empty navigation and a footer rendered as raw keys — invisible to an HTTP-only check. Tenants covered by this layer are those with database-driven navigation; tenants without structured navigation or whose empty navigation is confirmed and intentional are excluded.

Layer 3 — Visual smoke (non-blocking)

After the two preceding layers, an automated visual check is chained: a driven browser captures a screenshot of the page and a multimodal verdict is rendered. This check is cleanly skipped (without latency) if no visual verification configuration is defined for the tenant in question. It is active by default and can be disabled via an environment variable.

python3 -m <visual-smoke-module> <tenant>

False-positive mitigation: remote process environment variable verification

An HTTP 200 health check is not sufficient to validate a PM2 deployment. A documented incident showed that a process redeployed without any database connection variables returned 500 on all SSR routes driven by data (navigation, footer, reviews, internationalisation), yet the HTTP smoke returned 200 because the page rendered an empty but syntactically valid HTML skeleton — for two days.

For this reason, before any HTTP check, the delivery pipeline runs an environment control script that verifies remotely whether the critical variables are present in the active PM2 process environment. Return codes are as follows:

  • 0 — all critical variables are present.
  • 1 — missing variables (blocking).
  • 2 — remote connection or process unreachable (blocking).

Non-PM2 targets (mothership, dedicated test environments) are skipped with exit 0.

Mothership self-deployment

Network boundary: no client site on the mothership

The mothership VPS is the sensitive machine: orchestration, Hub, secrets and internal services. It must not host or publish any client or demonstration site, including behind basic authentication or a no-index directive. Such measures do not eliminate the network entry point nor the risk of lateral movement from a CMS or its container toward the internal Docker network.

Client staging environments temporarily exposed live exclusively on a dedicated Synedre buffer server, before migration to the client's dedicated VPS. An Nginx configuration guard enforces a closed allowlist: only the Hub and its application upstream are permitted. This guard is blocking at pre-commit and can also audit the running configuration state.

Self-deployment mechanism

The mothership's main frontend does not follow the build-host/transfer pattern described above. It is a local self-deployment: compilation takes place inside the mothership's own application Docker container, via a dedicated script.

Specifics compared to remote tenants:

  • No staging environment: the main frontend deployment targets the administration cockpit live production directly, with no intermediate environment.
  • Local transfer via container copy: a minimal tar of the source code (excluding .nuxt, .output, and node_modules) is copied directly into the application container without network transit. Before extraction, the Nuxt incremental compilation cache (.nuxt) is set aside and restored after the new source code is injected — this is the key performance lever of self-deployment (incremental build, not a full cold build).
  • In-container compilation: Nuxt compilation runs inside the running container. The previous version remains live throughout the build. After compilation: graceful container stop (5 seconds), copy of the .output directory to the host, then container recreation (which re-reads the environment file — fixing a prior incident where environment variables were not reloaded).
  • No PM2: the container starts the compiled Node server directly, without an intermediate process manager.
  • Standalone bundle: the mothership frontend no longer extends the shared e-commerce framework layer (significant archive size reduction).
  • npm acceleration: a sha256 fingerprint of the lockfile is persisted inside the container. If the lockfile has not changed since the last deployment, the npm install step is skipped.
  • Build UUID health check: the health check is not limited to an HTTP 200 — it compares the expected build UUID (read from the host-side build manifest) with the one served by the container's health API. This guarantees that the new build is actually active, and not the old one served by a partial reload.
  • Opt-in accelerated variant: an environment variable activates an alternative mode (host-side build + atomic swap), providing an approximately 35% time saving.
  • Single command: ./deploy synedre-os is the sole entry point for publishing the mothership. The ./ship command explicitly rejects this target (return code 2).

Fleet Topology Inventory — Single Source of Truth

The complete fleet topology (machines, SSH users, database containers) is stored in a central table in the mothership's database. This is the sole authoritative source: Markdown architecture documents may be outdated; only this table reflects the actual state. Duplicating or hardcoding the topology in any other file is prohibited.

The ./deploy --list command queries this table and displays the active fleet as an aligned table. The sort order places the mothership first, then critical tenants, then the remaining ones in alphabetical order. Only entries marked active are displayed.

Table Structure

Column Role
Tenant identifier Primary logical key for the tenant
Environment production | staging | infra | legacy | audit
SSH access & URL VPS address, public domain, SSH user and key
Associated database Container, database name, user, name of the environment variable holding the password (never the value itself)
Web runtime Application container, presence of a PrestaShop store, presence of a Nuxt front end
Business criticality Criticality level, monthly recurring revenue, subscribed plan
Automatic ship allowed Boolean indicating whether a production deployment can be triggered without human validation ⚠️ (field present; the exact consumer must be verified before use)
Deployment codename Identifier to copy when composing the exact ./deploy / ./ship command
Client codename Foreign key to the client federation table (spine introduced late May 2026)

Current Fleet State

The active fleet includes one infra entry for the mothership itself, several production tenants (PrestaShop stores or Nuxt front ends), one staging Nuxt tenant, and a few special cases:

  • Two dormant side-projects formally carry the production environment — they are orphaned production entries, not legacy or audit entries.
  • One tenant appears as a double entry: one production row with a Nuxt front end, one legacy row without Nuxt. These two rows are distinct and must not be aggregated.
  • A tenant previously in audit mode was decommissioned on June 12, 2026 (one-off engagement completed): its entry was set inactive, its folder and legacy .env file were removed, and the client history is retained in the federation table.

Operational doctrine: before each ./deploy or ./ship, open the tenant record in the hub to copy the exact deployment codename. Never type the codename from memory.

Secrets Doctrine — Five Scope Levels

Each secret has a single canonical file. The same key appearing in two locations is treated as a bug. The internal reference documentation defines five scope levels:

# Scope Description Git-versioned
1 Single tenant Environment file specific to a single tenant, read by its application container and deployment descriptor ❌
2 Mothership — core Secrets for the cockpit and the mothership's primary Nuxt container ❌
3 Mothership — host Secrets used by host-level scripts (crons, automation, SSH access to client VPSes) ❌
4 Cross-project Keys shared across all projects: AI provider API keys, data encryption key, master SMTP relay — stored off-repository on the mothership VPS ❌ (off-repo)
5 Public templates Empty .env.example files intended for open-source contributors ✅

Load Order and Conflict Resolution

The mothership's primary application container loads environment files in the following order: cross-project file → core file → host file. When a key is duplicated, the host file takes precedence. Consequently, the same variable must never be placed in two different scope levels.

P0 Anti-Leak Rule

No plaintext secret may appear in a versioned file. When a tracked file must reference a secret, it cites only the environment variable name and the .env* file that carries it — never the value. Examples:

  • A tenant's deployment descriptor references the name of the variable holding the database password, not the password itself.
  • The inventory table stores the name of the environment variable for each client VPS's credentials.
  • Mail access (IMAP, SMTP) lives in the host file, referenced by variable name.

Hard Rule: Commit Before Any Deployment

A past incident illustrates the risk: a fix applied locally without being committed was overwritten by a synchronization that occurred during a subsequent action, causing several hours of production downtime. The root cause: a locally modified file only survives in the build directory; the deployment script systematically restores the Git state before building, discarding any uncommitted changes.

Repository Cleanliness Safeguard

A dedicated script checks whether the repository is clean before each operation. It returns three states: clean, modified, or untracked. Its scope is limited to the relevant target — a mothership file does not block a tenant ship, and vice versa.

  • ./deploy: if uncommitted changes are detected, the system performs a silent automatic commit (timestamped message of the pre-deployment snapshot type) followed by a background push. Exception: if the current branch is main, the deployment is immediately rejected — no automatic commit is ever made on the main branch.
  • ./ship: if uncommitted changes are detected, the ship is blocked with a message requesting that changes be committed first (./commit) before retrying. A --allow-dirty flag exists for intentional hotfixes only.

End-of-Session Hook

An end-of-session hook blocks the session from closing if the repository is not clean. The operational rule is without exception: no completed work remains uncommitted. The agent commits; the human operator never types git add / git commit commands manually.

Appendix — Reference Files

Component Role
Deployment entry point (preprod) Launches the preprod environment and routes to the correct tenant
Production entry point Gated production trigger (automatic ship subject to the authorized fleet; one tenant requires explicit human validation) + full production ceremony
YAML-driven dispatcher Orchestrates remote tenant deployments from their configuration descriptor
Deployment helpers library Reusable functions: build, packaging, upload, reload, healthcheck, banner, cron
Descriptor parser Reads and validates a tenant's deployment configuration file; exposes sections: build, SSH, drift detection, i18n, remote, healthcheck, hooks, cron
Mothership self-deployment script Build and swap of the primary application container via Docker
Accelerated self-deployment variant Build on the host then atomic container swap
Git cleanliness safeguard Checks repository state before deploy/ship
Lock-file consistency safeguard Checks for lock-file skew before mothership self-deployment
HTTP smoke test suite Verifies HTTP responses and content/JSON presence after each deployment, across all covered tenants
PM2 environment checker Inspects environment variables loaded in PM2 before production smoke tests; tenants without PM2 are cleanly skipped
Deployment descriptor specification Full schema for the tenant configuration file, with four canonical examples
VPS runbook SSH, PM2, Docker procedures, certificate renewal
Secrets documentation Five-level secrets doctrine
Inventory table (database) Single source of truth for fleet topology

⚠️ The general workflow document is partially obsolete: it still describes a preprod infrastructure decommissioned in May 2026 as well as a legacy ship script that is no longer the active pipeline. In case of conflict, defer to the script source code (./deploy, ./ship, self-deployment script) rather than to that document.