71 lines
4.7 KiB
Markdown
71 lines
4.7 KiB
Markdown
# cc-ci-orchestrator
|
|
|
|
This repository configures the combined cc-ci NixOS host and its current
|
|
automation: the operator steering session, weekly recipe upgrader, public
|
|
report, and health-gated host updater. The CI server itself is imported from
|
|
the [cc-ci repository](https://git.autonomic.zone/recipe-maintainers/cc-ci).
|
|
|
|
| Current component | Location |
|
|
|---|---|
|
|
| Combined host and timers | `flake.nix`, `nix/hosts/cc-ci/`, `nix/modules/` |
|
|
| Operator session, weekly upgrade and report launchers | `scripts/cc-ci/agents.py`, `scripts/cc-ci/launch-{upgrader,report,supervisor}.py` |
|
|
| Recipe inventory, upstream notes, reporting tools | `data/cc-ci/used-recipes.md`, `data/cc-ci/upstream/`, `scripts/cc-ci/recipe-report.py` |
|
|
| Host provisioning and migration | [`docs/host-provisioning-and-migration.md`](docs/host-provisioning-and-migration.md) |
|
|
| Original Builder/Adversary build | [`archive/original-build/`](archive/original-build/README.md) |
|
|
|
|
Secrets and runtime state are gitignored. The completed two-loop build and historical plans are archived. Active executables live under `scripts/cc-ci/`; Nix units now call the new script paths directly.
|
|
No Builder or Adversary session should be running. The Nix
|
|
`cc-ci-loops` unit only records the boot ID; it does not launch retired loops.
|
|
|
|
## Host updates and recovery
|
|
|
|
- **The host updates itself weekly**: `cc-ci-auto-update.timer` (Tuesday 03:00 UTC,
|
|
`nix/modules/auto-update.nix`) runs `nix flake update` on all inputs, builds, activates with
|
|
`test`, runs the cc-ci health checks (swarm replicas, front doors, sops, acme-dns, fail2ban…),
|
|
and only then commits the generation + bootloader and pushes the health-checked `flake.lock` to
|
|
`main`; on any failure it re-activates the previous generation and restores the lock. It skips
|
|
itself while a CI run, the weekly upgrader, the report or the Sunday sweep is in flight. Outcome
|
|
in `/srv/cc-ci/.cc-ci-logs/auto-update-state` (one line) and `journalctl -u cc-ci-auto-update`;
|
|
`/cc-ci-status` §5 reads it. `/cc-ci-orchestrator-update` runs the same unit by hand.
|
|
The `cc-ci` input follows this flake's nixpkgs, so the CI server is rebuilt on the same nixpkgs.
|
|
- **Update only cc-ci's code** (harness/tests/modules): merge in the cc-ci repo, then
|
|
`nix flake update cc-ci` here and rebuild; also `git -C /etc/cc-ci pull --recurse-submodules`
|
|
so the deployed checkout the sweep runs from matches. Run the lock update **on this host**: a
|
|
lock written by a newer Nix elsewhere once failed here with `NAR hash mismatch in input
|
|
git+https://…cc-ci.git…&shallow=1`; re-running `nix flake update cc-ci` on the host fetched the
|
|
input properly and the rebuild went through.
|
|
- **Something is down**: `systemctl --failed`, `journalctl -u deploy-<x>`, `docker service ps <svc>`;
|
|
the cc-ci repo's `docs/runbook.md`. Host unreachable: Hetzner console → reboot lands on the last
|
|
`switch`ed generation; rescue mode + `nixos-enter` for anything worse (skill
|
|
`/hetzner-server-recovery`).
|
|
|
|
---
|
|
|
|
# Operating the orchestrator
|
|
|
|
The cc-ci orchestrator on this host is an **opencode agent** (`scripts/cc-ci/agents.toml`:
|
|
backend `opencode`, model configured in `scripts/cc-ci/agents.toml`), launched on boot by `cc-ci-orchestrator.service`
|
|
via `scripts/cc-ci/agents.py up orchestrator` into tmux session `cc-ci-orchestrator`, attached to
|
|
the shared opencode web server. Steer it from the web UI, **https://oc.ci.commoninternet.net**
|
|
(basic auth, user `oc`), where the weekly upgrader's and report's sessions show up too.
|
|
There is no Claude Code on this host: Claude sessions run on the notplants-orchestrator box and
|
|
operate the CI from there over ssh (`Host cc-ci` in that box's loops ssh config → this host).
|
|
|
|
```bash
|
|
# on the host
|
|
sudo -iu loops tmux attach -t cc-ci-orchestrator # the agent's terminal
|
|
systemctl restart cc-ci-orchestrator # relaunch it (fresh opencode session)
|
|
sudo -iu loops tmux ls # cc-ci-orchestrator, cc-ci-upgrader (+watchdog) during the weekly run
|
|
```
|
|
|
|
## Weekly upgrade run
|
|
|
|
`cc-ci-upgrade-all.timer` (Sat 22:00 America/New_York — weekend, off DeepSeek's weekday peak windows) starts `launch-upgrader.py`, which runs
|
|
`/upgrade-all` as an opencode agent (`upgrader.env`: `LOOP_MODEL`/`REPORT_MODEL`/`SUPERVISOR_MODEL`, all
|
|
`opencode-go/deepseek-v4.1-flash`) in tmux
|
|
`cc-ci-upgrader` with a usage-limit watchdog; the hourly `cc-ci-upgrade-supervisor.timer` drives a
|
|
stalled run to completion. Start one by hand with `systemctl start cc-ci-upgrade-all`; follow
|
|
`/srv/cc-ci/.cc-ci-logs/cc-ci-upgrader.log`; it ends with `UPGRADE RUN COMPLETE`, a summary in
|
|
`.cc-ci-logs/upgrades/upgrade-all-<date>.md`, and a report published to
|
|
`https://report.ci.commoninternet.net/week-<date>.html`.
|