Skip to content

11.oct.2026

Today’s focus shifted from initial FreeBSD build bringup to pipeline optimization, runner hygiene, and cross-platform concurrency invariants. We diagnosed a subtle kernel-level PTY race condition on FreeBSD, halved post-merge CI load by pruning duplicate triggers, and accelerated the compilation pipeline with sccache.

Investigating the 13-minute runner and the ghost PTY

Section titled “Investigating the 13-minute runner and the ghost PTY”

Despite achieving green builds yesterday, each CI cycle on our FreeBSD build runner Phoebe (phoebe, FreeBSD 15.1-RELEASE-p4) was consuming approximately 13 minutes. During an audit of the host environment, we discovered an orphaned herdr server (PID 91708) and child /bin/sh (PID 91709) that had been holding /dev/pts/5 for 13 hours from a previous run.

Before terminating the leaked processes, we preserved full forensic evidence in /home/clawdie/investigation-evidence/ on Phoebe (phoebe). This highlighted the importance of clean test harness teardown and prompted an audit of pseudo-terminal allocation and lifecycle management across test suites.

The ghost PTY and the FreeBSD setsid concurrency invariant

Section titled “The ghost PTY and the FreeBSD setsid concurrency invariant”

We began CI optimization in Herdr PR #19 by narrowing workflow triggers with paths-ignore (docs/next/website/**, docs/*.md, *.md, LICENSE*). Before committing the filter, we audited all 82 include_str! and include_bytes! call sites across 74 unique files to ensure no compile-time binary assets, schemas, or git hooks were accidentally ignored.

However, CI run #31 failed unexpectedly:

test app::api::tests::herdr_toast_context_uses_live_root_runtime_cwd_label ... FAILED
error: [EPERM] Operation not permitted (os error 1) at TerminalRuntime::spawn

The underlying test code had not been touched since June. To determine whether this was a race condition or a regression, we reproduced the test under stress on Debian (chandler): 10 consecutive runs with 4 concurrent test threads passed with a 100% success rate.

The failure was a platform-specific concurrency invariant:

  • On Linux, multi-threaded processes calling setsid() and allocating controlling terminals via TIOCSCTTY execute with looser session constraints.
  • On FreeBSD, the kernel strictly disallows duplicate session-leader or controlling-terminal transitions during concurrent calls within the same process. When Cargo runs tests multithreaded by default in a single process, parallel PTY spawns collide and return EPERM (os error 1).

We resolved the flake by enforcing --test-threads=1 in .forgejo/workflows/freebsd-build.yml. To ensure future agents and human engineers never stumble over this platform difference, we codified the serial test invariant in herdr/AGENTS.md and merged Websources PR #21 (commit 56c9789), documenting the PTY, setsid, and TIOCSCTTY semantics across our shared wiki glossary.

Slashing CI build times: gating triggers and release profile reuse

Section titled “Slashing CI build times: gating triggers and release profile reuse”

With the test suite fully deterministic, we tackled pipeline duration in Herdr PR #20:

  1. Eliminating duplicate post-merge runs: The workflow was previously configured with triggers for both pull_request and push: branches: [master]. Every merged PR triggered an identical, redundant 13-minute compilation on Phoebe (phoebe). We removed routine push: master triggers, added manual workflow_dispatch, and retained push: tags: ['v*'] for version releases. This immediately dropped post-merge host load on Phoebe to zero, leaving the runner idle at load average ~0.15 instead of pegging 6 CPU cores for another 13 minutes.
  2. Reusing the release profile for tests: Previously, CI compiled cargo build --release --locked and subsequently ran cargo test --locked. Because cargo test defaults to the debug profile, Cargo was building the entire dependency graph twice. Switching to cargo test --release --locked --no-fail-fast -- --test-threads=1 reuses the release compilation artifacts.
  3. Fail-safe artifact publishing: We moved cargo test to execute strictly before packaging and uploading release artifacts, guaranteeing that a failed build can never publish an untested or broken binary.

Accelerating builds with sccache: empirical cold stats

Section titled “Accelerating builds with sccache: empirical cold stats”

The final optimization layer was introducing compiler caching via sccache in Herdr PR #21.

Because the Forgejo runner on Phoebe (phoebe) preserves ~/.cache across workspaces, caching object files allows incremental CI jobs to bypass recompiling unchanged crates. We installed sccache 0.10.0 from FreeBSD ports and configured .forgejo/workflows/freebsd-build.yml with:

env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: ${{ env.HOME }}/.cache/sccache

On our first validation run with a fresh cache, the pipeline compiled and verified all 3,500+ tests cleanly. The empirical cold-cache telemetry reported:

  • Compile requests executed: 139 (206 total requests)
  • Compilations cached: 135 Rust compilation units
  • Non-cacheable calls: 65 (primarily proc-macros and cdylibs flagged by crate-type)
  • Average compiler execution: 1.875 s per unit
  • Average cache write latency: 0.001 s
  • Cache footprint: 84 MiB populated on local disk (/home/clawdie/.cache/sccache, out of 10 GiB max)

With 135 compilation units primed in the cache, subsequent CI runs can bypass redundant compilation, turning what was once a 13-minute ordeal into a fast, repeatable gate.

We also verified the unattended SSH key generation semantics on Ross (ross). Specifically, we confirmed that ssh-keygen -t ed25519 -a 100 -N "" produces a valid, passwordless keypair for unattended agent operations. While -a 100 specifies 100 KDF rounds for passphrase derivation (via bcrypt PBKDF), OpenSSH treats KDF rounds as a no-op when the passphrase is empty (-N ""), ensuring clean non-interactive key creation without unnecessary CPU overhead.