Skip to content

doc: deployment architecture — a services layer outside the system switch - #5764

Merged
dezren39 merged 1 commit into
mainfrom
design/deployment-architecture-services-layer
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
design/deployment-architecture-services-layer

Conversation

@dezren39

@dezren39 dezren39 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Design proposal from the WS-E pass (Drew, 2026-11-04): get services out of the system switch's blast radius.

Core of the design

  • Everything stays Nix-built; what we lack is a deployment layer. A single flake-built deploy binary gives every service its own generations: deploy <target> builds + activates just that service, deploy <target> rollback repoints to the previous generation, deploy <target> status is the audit surface. No system switch, no home-manager activation, no reboot.
  • Services are declared once (option set: package, args, env/secrets by name, ports, health check) and rendered to systemd, launchd, Cloudflare, or a container pin — generalizing the pattern pkgs/mcpx/modules/ and the forks' openchamber→opencode→mcpx cascade already prove in-tree.
  • The Cloudflare half adopts the 2026-10-31 deploy standard and extends it from 3 workers to all of them; deploy absorbs the existing <name>-deploy flake apps rather than replacing them.
  • Home-manager shrinks to its proper role (user environment, dotfiles) and defines no services.
  • Containers: from scratch via Nix (dockerTools/nix2container) for software we own — the lab-ops-hub crawler is the working precedent; third-party images stay digest-pinned. amd-crd currently has no definition in any repo and gets a definition-or-waiver decision.
  • VMs: declarative guests (nixvirt / microvm.nix, both seeded in the flake already) with a named, finite mutable carve-out class.

Grounded in a fresh inventory of the laptop, sandbox, and Cloudflare estate. Headline receipts: the hand-placed route-proxy unit is broken right now (ExecMainStatus 127, its start script missing); the laptop-agent's Nix module exists but a hand unit is what runs; darwin-nix's fleet-brokers module is enabled by no machine while the code flake re-declares the same brokers; pm-stack runs out of the primary checkout; sandbox quota-recorder has no installer and is hand-restored after every recycle.

Migration order: M1 route-proxy → M2 fleet three (laptop-agent + brokers) → M3 sandbox quota-recorder → M4 pm-stack off the checkout, with a parallel Cloudflare track. Each step reversible; the only system-flake change in the whole program is additive (the deploy package + deployTargets output).

Design + filings only — no migration is executed by this PR.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…itch

Design proposal (WS-E): a flake-built `deploy` tool and per-service
generations so services deploy without a system switch or home-manager
activation; generalizes the 2026-10-31 Cloudflare deploy standard;
containers from scratch via Nix; declarative libvirt/microVM guests
with a named mutable carve-out class. Grounded in a 2026-11-04
inventory of the laptop, sandbox, and Cloudflare estate.
@dezren39
dezren39 requested a review from a team as a code owner November 5, 2026 01:35
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5fdac06c-df72-4998-bda4-f9071f89a76c
Commits

Reviewing files that changed from the base of the PR and between c2bf5fc and 37f62be.

Files selected for processing: 1

  • doc/2026-11-04_deployment-architecture-services-layer.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T01:40:12.555912Z 37f62be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37f62be9c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +345 to +347
removed in the same change that proves it), and **none requires a system
switch to land** — the only system-flake change in the whole program is
adding the `deploy` package and the `deployTargets` output.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Define an explicit handoff of Home Manager unit ownership

For the M2 and M4 migrations, replacing the live unit files does not relinquish Home Manager's ownership: home/common/default.nix:876-904 declares both brokers, and nixos/services/pm-stack/default.nix:106 onward declares the PM units. The broker comment at home/common/default.nix:873-875 explicitly confirms that HM replaces hand-installed units on activation. Under this additive-only migration, a subsequent ordinary system switch can therefore restore the old broker binaries and checkout-backed PM services over the independently deployed generations. Include an ownership-removal activation, or specify a durable override strategy, and verify that migrated services survive a subsequent HM/system activation.

Useful? React with 👍 / 👎.

Comment on lines +199 to +201
Failure at any step: the profile flips back and the unit restarts on the
previous generation — deploy-rs's magic-rollback idea, with nix profiles
as the mechanism instead of a bespoke one. `rollback` is the same flip

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the previous unit configuration during rollback

When a deployment changes rendered unit arguments or environment and then fails its health check, the prescribed profile flip and restart leave systemd using the failed generation's loaded unit configuration. The previous executable can therefore restart with incompatible new arguments or environment instead of recovering the working generation. Forward activation explicitly writes the unit and reloads systemd, but the rollback recipe omits those corresponding steps; systemctl --help describes daemon-reload as “Reload systemd manager configuration.” Specify that rollback also restores or relinks the previous generation's rendered unit and performs daemon-reload before restarting.

Useful? React with 👍 / 👎.

user = "user"; # or a systemd DynamicUser where suitable
ports = [ 4801 ];
restart = "on-failure";
healthCheck = "http://100.99.113.103:4801/health";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the queue broker's unauthenticated health endpoint

For the fleet serve queue-broker target shown here, /health is not an ordinary HTTP health probe: pkgs/fleet/crates/fleet-queue/src/queue_broker.rs:640-645 permits unauthenticated GET requests only to /healthz, while other paths require authentication and POST. A GET to the configured URL therefore returns 401 without credentials or 405 with credentials, causing a healthy deployment to fail its activation check and roll back. Use http://100.99.113.103:4801/healthz, which is also the endpoint exercised by the broker smoke test.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant