This article discusses a crucial architectural principle: avoiding canonical state on ephemeral, untrusted hosts, often referred to as 'free hosts' or 'worker planes'. It advocates for a clear separation of concerns, where the local repository holds the single source of truth, and remote workers are treated as disposable, stateless inference engines. The focus is on secure data flow, explicit contracts for input/output, and strict validation to maintain data integrity and security in distributed workflows.
Read original on Dev.to #architectureThe core architectural principle presented is the absolute necessity of keeping canonical state off disposable, untrusted hosts. This applies to any free or rented compute resource where you don't control the full lifecycle or its environment. The article likens these hosts to a 'hotel printer' – you send a task, collect the output, but never store your critical 'filing cabinet' (canonical state) there.
Many teams mistakenly clone full repositories and environment files onto free hosts. This creates a 'second source of truth' that is inherently fragile. It leads to inconsistencies, security vulnerabilities (exposing secrets), and a loss of control over the authoritative state of the codebase. The architecture quickly becomes a distributed system with conflicting states, which is a recipe for disaster.
The recommended data flow emphasizes a local-first, trusted repository as the sole writer to the origin. The process involves:
Principle: Worker as a Contract
The worker should be treated as a strict contract with typed input and typed output, not an interactive chat window or an open shell. This prevents command injection, ensures predictable behavior, and hardens the system against malicious or accidental side effects.
#!/usr/bin/env bash
# export-bundle.sh — canonical repo stays on your machine
set -euo pipefail
ROOT="$(git rev-parse --show-toplevel)"
REV="$(git rev-parse HEAD)"
OUT="${1:-/tmp/review-bundle.tgz}"
cd "$ROOT"
git archive --format=tar "$REV" \
--prefix="bundle/" \
':!(exclude).env' \
':!(exclude).env.*' \
':!(exclude)**/*.pem' \
':!(exclude)**/id_rsa' \
| gzip > "$OUT"
python3 - "$OUT" <<'PY'
import sys, tarfile, re
path = sys.argv[1]
deny = re.compile(r"(.env|.pem|id_rsa|secrets?)", re.I)
with tarfile.open(path, "r:gz") as tf:
names = [m.name for m in tf.getmembers() if m.isfile()]
bad = [n for n in names if deny.search(n)]
if bad:
raise SystemExit("refusing bundle; denied paths: " + ", ".join(bad))
print("bundle_ok files=%d rev_export" % len(names))
PY
echo "exported $OUT at $REV"This architectural pattern provides strong security and reliability guarantees. By ensuring the remote worker is disposable and stateless, and by strictly controlling its inputs and outputs, you mitigate risks associated with compromised hosts, data exfiltration, and unauthorized modifications to your canonical codebase.