Table of contents
- Deploy control plane
- Summary
- Orchestration at a glance
- Flow
- Why OIDC instead of an xyOps key in CI
- Secrets
- Deploy targets
- API stacks: the deploy container
- Own applications: images built in CI, deployed by digest
- Container services: push with identity checks
- Job tokens and permissions:
- Operational rules
- Application deploys: apps own their deployment, not their infrastructure
- Bootstrap stacks and break-glass
- Rejected alternatives
- Open items
Deploy control plane
Status: accepted; implemented in cdk 0.3.0-dev.1+. Discovery is live on kratos; deploys pending. Decided 2026-11-17.
Summary
Forgejo CI builds, tests and packages. It never holds infrastructure secrets
and never applies changes. When main changes, CI requests a short-lived
OIDC ID token from Forgejo and hands it to xyOps. xyOps verifies the
token, then runs the deploy on a host we own with only the secrets that deploy
needs. Secrets live in xyOps. OpenTofu remains the engine for desired state.
| Layer | Does | Holds |
|---|---|---|
| Forgejo CI | Test, build, package, synthesize .yawn/, validate; publish tags and artifacts; hand off |
Registry push credentials. No infrastructure secrets, no xyOps key |
| xyOps | Verify the hand-off; run plans, applies and push deploys; nightly drift; notifications | Every infrastructure secret, granted per event |
Git (cdk, ops) |
Defines everything, including the fleet and which secret goes to which deploy | Nothing secret |
This is the industry "separate build from deploy" pattern (Terraform Cloud, Spacelift, Atlantis, Octopus), with xyOps as the self-hosted deployer.
Orchestration at a glance
PR ──> Forgejo CI: tests, synth, tofu validate, image build (no secrets)
merge to main
├─ CI builds and pushes app images by digest (registry credentials only)
└─ deploy workflow requests an OIDC ID token, calls the xyOps hand-off
└─ xyOps: yawn oidc-verify → fetch the token's commit →
├─ API stacks: tofu plan/apply in the deploy container
├─ own apps: pull the released digest, compose up, health check, roll back
└─ community-script LXCs: fleet_deploy on kratos (identity check,
snapshot, update, health check, roll back)
nightly (xyOps schedule): fleet_observe + yawn fleet-diff, re-plan every stack → ntfy on drift
Flow
- A PR runs CI: tests,
synth,tofu validate. No production secrets. - A merge to
mainruns the deploy workflow. It requests an ID token with an explicit audience and calls xyOps' fixed hand-off entry point with only the token. - The xyOps deploy job runs
yawn oidc-verify:- signature against Forgejo's published keys
(
https://code.yawn.dev/api/actions/.well-known/keys, RS256); - issuer, audience, repository and owner by immutable ID, event
push, refrefs/heads/main, the exact workflow file; - the run is newer than the last deployed run (replay and rollback guard).
- signature against Forgejo's published keys
(
- The job fetches the commit named in the token, never one supplied by a
caller, and confirms it is on
main. - It deploys:
- API stacks (Technitium, UniFi, Peekaping, Bifrost, xyOps, Forgejo):
tofu init -lockfile=readonly,plan -out,applyof that plan, in the dedicated deploy container. - Container services (community scripts on Proxmox LXCs): the push deploy below.
- API stacks (Technitium, UniFi, Peekaping, Bifrost, xyOps, Forgejo):
- It records the deployed run and reports to ntfy.
A nightly xyOps schedule re-plans every stack and runs yawn fleet-diff.
Why OIDC instead of an xyOps key in CI
Reviewing the first draft found that an xyOps API key with only run_jobs on
one category can still escape its scope: run_event merges caller-supplied
properties into the job, so a caller can add actions that launch any event
with a manual trigger, swap the plugin, or run disabled events (xyOps
lib/api/events.js api_run_event; scripts, uid and env are stripped, but
actions and plugin are not). With OIDC there is no key to steal, and the deploy
job decides what to run from verified claims, not caller parameters.
Forgejo-specific facts the verifier relies on (Forgejo 17 source):
ref_protectedis always"false". It proves nothing; branch protection is restored and checked separately.- Tokens last
ID_TOKEN_EXPIRATION_TIME(default 3600 s) and carry nojti. Replay is stopped by the newer-run rule, and the policy caps token age at 10 minutes. - Without an explicit
audience, the audience defaults to<forgejo>/<owner>, shared by every repository of that owner. The policy requires an explicit audience. - Jobs opt in with
enable-openid-connect: true. - Verified on code.yawn.dev (2026-11-17):
workflow_refis<owner>/<repo>/.forgejo/workflows/<file>@<ref>,ref_typeisbranch,subisrepo:<owner>-<owner_id>/<repo>-<repo_id>:ref:<ref>, RS256. - The deploy mode (plan or apply) is bound to the token: the workflow requests one of two audiences and the job reads the verified audience, so a caller cannot turn a plan request into an apply.
Secrets
- xyOps is the source of truth. Values are encrypted at rest (AES-256-GCM), granted per event, injected as environment variables at launch, and every use is logged. Admins can decrypt when needed.
- Values that OpenTofu would otherwise keep in state go through write-only
attributes (
xyops_secret.fields_wo) fed from ephemeral variables. Verified with the real provider: the value reaches xyOps and never appears in state; a new value with the samefields_wo_versionis not sent; bumping the version sends it. - cdk enforces this for the state passphrase:
Stack.Encryptrequires a sensitive and ephemeral variable, otherwise the value would appear in saved plans. - Not yet covered:
xyops_api_keystores the key in (encrypted) state. Create such keys outside OpenTofu until the provider supports write-only keys. - xyOps is backed up by PBS. Those backups contain both xyOps'
secret_keyand the ciphertext, so PBS must use client-side encryption with restricted access.
Deploy targets
API stacks: the deploy container
Every current john/ops stack only calls HTTP APIs, so it runs in a dedicated,
unprivileged LXC with xySat (xyOps' agent, which connects out to xyOps and
needs no inbound ports or SSH). It is not the Proxmox host: a bad job there
reaches one container and that job's tokens, not every guest.
Own applications: images built in CI, deployed by digest
CI builds and pushes application images (multi-arch) to the Forgejo registry and records the digest. Deploy jobs never build; they pull the exact digest from the release record of the verified commit (not from caller input), run Compose with it pinned, health-check, and roll back to the previous digest on failure. What runs in production is byte-for-byte what CI tested.
Container services: push with identity checks
Most services are community-script LXCs on kratos. We push: a fixed script
on the Proxmox host uses pct, so no agent or SSH is needed inside containers.
This was chosen over per-container agents (pull/GitOps) because adopting an
agent in every community-script container is more work than it saves.
The fleet is declared in code (fleet package, .yawn/fleet.json). Each entry
pins node, CTID, hostname, IP, privilege, install kind and, for community
scripts, the slug recorded in the container's /usr/bin/update
(SCRIPT_SLUG). The push deploy, for one service ID:
- Loads
fleet.jsonat the verified commit. - Observes the container (
pct config, the update entrypoint) and runsyawn fleet-check. Any mismatch refuses: wrong hostname, moved IP, privileged, different script, stopped. - Takes a
pct snapshot. - Runs the update (community scripts: the container's
/usr/bin/updatein unattended mode, still to be verified) or pushes reviewed config files. - Health-checks; on failure rolls back to the snapshot.
- Reports the new version.
Community-script updates install the latest upstream release; they cannot be
pinned in Git. Where pinning matters, mirror the update source or move that
service to Compose with a digest-pinned image. Snapshots do not cover bind
mounts; fleet-check warns about them.
yawn fleet-diff runs nightly: a declared service that is missing or wrong is
an error; a container nobody declared is a warning. Either way, ntfy is told,
so the code cannot quietly go stale.
Job tokens and permissions:
Forgejo ignores workflow permissions: (it shows a pre-execution warning). A
job token can always write its own repository (read-only for fork PRs). Least
privilege therefore comes from same-repository PR gates, branch protection,
secrets only on main or release tags, and Authorized Integrations with an OIDC
ID token for cross-repository access. Workflows declare no permissions:.
Operational rules
- Apply events: retries off, one shared concurrency limit per stack covering
deploy and drift, host
flock,tofu -lock-timeout. Never force-unlock automatically. - Give OpenTofu time to save state when a job is stopped: xySat sends SIGKILL 10 s after SIGTERM by default.
- Refuse to run with
TF_LOGset; use a temporary work directory removed on exit. - Pin OpenTofu
= 1.13.9everywhere and install providers from the verified mirror (yawn providers), with bothlinux_amd64andlinux_arm64hashes. - One state passphrase and S3 credential per stack.
- The stacks that manage xyOps itself keep a break-glass apply path from a workstation, with an offline token.
- Restore branch protection on every repository; Forgejo instance admins can
still bypass it, so the deploy job checks the commit is on
mainitself.
Application deploys: apps own their deployment, not their infrastructure
The infrastructure app declares one slot per application
(apps.New().Add(apps.App{...}), attached as apps.json): the source
repository (immutable IDs), the release tag prefix, the publish and
deploy workflow files, the image repository, the target, the health URL
and the xyOps secrets granted to that deploy. Containers, addresses, routes,
DNS and monitors stay in the infrastructure app; app repositories hold no
deployment details.
Release contract
Releases are automated: merging a version bump to main makes the release
workflow (john/release) create the v* tag with its own token and start the
publish workflow there. The trust boundary is the protected branch:
- Reviewed code reaches
mainonly through protected merges with green checks. v*tags are created only by the release workflow (tag protection).- Publish (at the tag) builds rootless and pushes the image, then sends
an ID token with audience
yawn-sign:<slot>and the digest to the deployer's sign job.yawn app-verify -mode signchecks the token came from the slot's publish workflow at a release tag; the job then checks the tag's commit is onmainwith green required checks, and signs the digest with cosign (key generated on the deployer, never exported; no transparency log). The signature carries slot, repository, tag and commit as annotations. - Deploy sends an ID token with audience
yawn-app:<slot>and the digest;yawn app-verify -mode deploychecks it came from the slot's deploy workflow;cosign verifychecks the signature with the public key pinned in the infrastructure app and the annotations match the token; only then does xyOps run the deploy job on the target host (xySat): pull by digest, recreate the one Compose service, health check, roll back on failure. Hosts additionally refuse unsigned images through their container signature policy.
The publish workflow can never deploy and the deploy workflow can never get a signature (each audience binds one workflow file).
Provider releases
Provider slots use the same contract for OpenTofu providers. The publish
workflow attaches zips and SHA256SUMS to the Forgejo release, then sends
its yawn-sign:<slot> token and sha256 of SHA256SUMS. After the same
checks (publish workflow at a release tag, tag on main, required checks
green), the deployer GPG-signs exactly that file with the provider-signing
key (generated on the deployer, never exported) and publishes the Provider
Registry Protocol index for the slot's address. OpenTofu then installs the
provider with a plain tofu init and verifies the signature itself.
Signing key
If the private key is lost, nothing running breaks and already-signed releases still deploy; new releases cannot be signed until the toolchain job generates a new key and the infrastructure app adds its public key (old and new side by side, old dropped after re-signing what is still wanted). If it is stolen, rotate and drop the old key immediately. The private key is not backed up. Who may operate the signer is governed by xyOps login (SSO).
Bootstrap stacks and break-glass
The stacks the control plane itself runs on (xyOps, the deployer, Forgejo,
runners) cannot be repaired through the control plane when it is broken. They
call Stack.Bootstrap() and declare their credentials with
Stack.Credentials(...). They still deploy through the hand-off normally;
additionally a human can run, from a trusted machine:
git switch main && git pull # bootstrap refuses anything but a clean origin/main
go run ./cmd/<app> # synth
yawn providers # verified provider mirror
export TF_CLI_CONFIG_FILE=$PWD/.yawn/.providers/tofurc
export TF_VAR_state_passphrase=... AWS_ACCESS_KEY_ID=... # the stack's declared credentials
yawn bootstrap -backend-config bucket=tofu-state xyops # add -plan to look only
yawn bootstrap refuses non-bootstrap stacks and missing credentials before
OpenTofu runs, passes only the declared credentials to OpenTofu (no TF_LOG,
TF_CLI_ARGS or anything else from the shell), plans to a saved file, runs
the same restart guard as the hand-off (-allow for approved CTIDs), asks for
the stack name, applies exactly that plan and requires a clean fresh plan.
Credentials for break-glass come from the operator's password manager, never
from Forgejo.
Rejected alternatives
- One repository per area (proxmox, edge, monitoring, ...): turns references into published outputs that must be bumped and deployed in order, and loses compile-time checks across areas. One app with many stacks gives the same isolation (state, vault, plan/apply, guard per stack). Split a repository only where the trust boundary differs (other committers, open source).
| Option | Why not (now) |
|---|---|
| Static xyOps key in CI | Scope escape via run_event actions; a stealable secret |
| Plan in CI, apply the saved plan in xyOps | CI would need every production secret; ephemeral values are not covered by the plan; any state change invalidates it |
| Separate secrets manager (OpenBao, Infisical) | Duplicates xyOps' encrypted, audited, PBS-backed store |
| Atlantis | Another always-on service holding every secret |
| Pull/GitOps with an agent per container | Agent adoption per community-script LXC; revisit for Compose services |
| Kubernetes with Flux or Argo | Whole-fleet migration |
Open items
- Verify community-scripts unattended update on one container.
- VersityGW version and bucket versioning (a known bug breaks S3 lockfiles on versioned buckets).
- Confirm whether xyOps
update_secretreplaces the whole field map. - Hand-off endpoint decided: a magic-link trigger whose only field is the ID
token. Magic links filter caller input to declared fields and reject
_xy_override_*; the magic key only lets a caller start the job, every decision comes from the verified token. - Declare the fleet from the reviewed discovery run (40 containers on kratos, 2026-11-17).
Design
Guides
Published from wiki/ (refs/tags/v0.3.1-dev.7, b10894966b5b). Edit the source in a pull request; wiki edits are replaced on the next publish.