Skip to content

ci(bosn): adapt Cargo jobs from Soldr admission #29

Closed

Description

@zackees

Context

bosn.toml currently forces CARGO_BUILD_JOBS = 1 for every managed Linux task. That was a safe stopgap for the heavyweight Wasmtime/Cranelift graph introduced by #25, but it serializes ordinary work even when the managed runner can safely sustain more concurrency.

Soldr 0.9.10 documents that CARGO_BUILD_JOBS controls Cargo's fan-out, while soldr --jobs / SOLDR_JOBS only caps the daemon and cannot cap Cargo. Soldr's current amalgamation admission code already recognizes published Rust amalgamations including kernal_api and gates them exclusively within the daemon, but the detector is pub(crate) and the released CLI exposes no stable machine-readable admission/probe command. In particular, an unreadable source currently means “not an amalgamation,” which is appropriate on its compile failure path but is not a safe signal for this repository to turn into a raised Cargo fan-out.

There is no matching kernal-api issue. Soldr #2781 owns compiler-time exclusive admission and Soldr #2878 owns the earlier Cargo-orchestration resource-control gap; this issue is deliberately narrower: replace this repository's permanent Bosn-wide CARGO_BUILD_JOBS=1 workaround only when Soldr can provide evidence-backed pre-build admission.

Proposal

Add a Bosn-facing adaptive Cargo-job policy for the managed Linux stack, driven solely by a documented, machine-readable Soldr amalgamation/admission result:

  1. Before a Bosn build/lint/test task begins its Cargo command, obtain Soldr's pre-build admission verdict for this workspace and its managed resource context.
  2. Choose CARGO_BUILD_JOBS=4 only for an explicit high-headroom/admitted verdict; choose 2 only for an explicit constrained-but-safe verdict; otherwise choose 1.
  3. Keep the daemon limit explicitly coherent with the selected Cargo limit (or document why it is intentionally distinct); do not assume soldr --jobs limits Cargo.
  4. Make the selected tier and detector verdict visible in task output so a CI/Bosn failure is diagnosable.

The detection contract must distinguish at least:

  • admitted at the 4-job tier;
  • admitted only at the 2-job tier;
  • explicit exclusive/oversized-amalgamation admission;
  • no applicable signal / degenerate input;
  • unavailable detector, malformed/unknown schema, timeout, or ambiguous result.

Only the first two may raise Cargo concurrency. Every other state is fail-safe at CARGO_BUILD_JOBS=1; an unavailable or ambiguous detector must never be treated as “no amalgamation.” Do not add a handwritten host-RAM/cgroup heuristic in kernal-api: Soldr owns resource detection and admission semantics.

Because the current released detector is crate-private, first define or consume a versioned Soldr CLI/API contract with a bounded schema and exit semantics. The Bosn integration must pin/verify the compatible Soldr version rather than parsing human diagnostics or daemon internals.

Acceptance criteria

  • RED: a deterministic policy test demonstrates that the present fixed environment always selects one Cargo job, including on an admitted fixture.
  • GREEN: mocked/recorded Soldr verdicts select 4, 2, and 1 exactly as specified; exclusive, no-signal, malformed, unavailable, timeout, and ambiguous verdicts all select 1.
  • GREEN: prove the command actually receives CARGO_BUILD_JOBS at the selected tier; prove daemon configuration is not mistaken for Cargo's cap.
  • GREEN: no bespoke host-memory/cgroup calculation is added to this repository; the implementation consumes a versioned Soldr result only.
  • GREEN: Bosn fmt, lint, and test retain their existing commands and work with warm managed caches, while reporting the chosen tier without leaking or restarting an unrelated active Bosn session.
  • GREEN: run the Wasmtime/Cranelift graph under each deterministic fixture tier and record maximum Cargo/compiler child count plus outcome. The 4- and 2-job tiers must not oversubscribe or OOM when Soldr admitted them; conservative paths remain green at 1.
  • GREEN: CI remains independent of an ambient Bosn/Soldr daemon state; an absent or incompatible Soldr detector fails safely to one job rather than failing open.

Decisions

  • Scope: kernal-api Bosn integration, with a Soldr-contract dependency. This repository owns bosn.toml and the fixed workaround; Soldr owns the detector and must expose a stable pre-build result before the workaround can be relaxed.
  • Adaptive tiers: 4, then 2, then 1. Higher tiers require an explicit Soldr admission; 1 is the conservative fallback.
  • No local memory heuristic. Reimplementing host/cgroup interpretation here would diverge from Soldr's resource scheduler and create conflicting policies.
  • Priority: P1. feat(wasm): add engine policy and strict module admission validation #25 makes this compilation graph common, and permanent serialization trades substantial validation latency for safety even on eligible runners.

Related

Activity

  1. added
    enhancement
    on Aug 27, 2026
  2. zackees commented on Aug 27, 2026

    @zackees
    CollaboratorAuthor

    OOM audit addendum — release boundary and required admission point

    This records the read-only postmortem for the first cold Wasmtime/Cranelift Bosn run and refines, rather than replaces, this issue's proposal.

    Observed failure boundary

    • Docker Desktop is globally constrained by .wslconfig to 8 GiB / 4 processors; Docker reports 7.756 GiB available to containers.
    • The managed kernal-api Bosn container had no per-container memory limit (memory.max=max; Docker Memory=0). Its effective budget was therefore the shared Docker-VM ceiling, not host RAM.
    • Other unrestricted containers were already alive in the failure window: the phase-0 Bosn workload started about 14 minutes earlier and the Soldr performance workload was also active. Representative later docker stats showed about 3.5 GiB and 0.9 GiB respectively; these measurements establish shared contention, not the exact historical peak.
    • Before the workaround, Cargo-derived build-script environment recorded NUM_JOBS=4. Soldr journals record compiler failures with exit -1: cranelift_codegen and axum during lint, then wasmparser during test, followed by another axum retry. The terminal failure was an external/SIGKILL-style termination, not a Rust allocation panic.
    • Setting CARGO_BUILD_JOBS=1 made the managed all-feature lint and test green. This is a safe mitigation, not root-cause proof.

    The failed container was replaced before this audit, so its cgroup-v2 memory.peak and memory.events are unavailable. The replacement container's zero OOM counters cannot prove or disprove the prior kill. Thus the supported conclusion is concurrency-sensitive shared-VM resource exhaustion/termination is most likely; a kernel/cgroup OOM kill remains unproven until a controlled reproduction records peak/events/PIDs/child counts.

    Soldr version and detector boundary

    The image pins and installed command use Soldr v0.9.10. That release's Rust-amalgamation allowlist recognizes zccache, not kernal_api. Current Soldr main adds kernal_api, but is ahead of v0.9.10 and is not evidence that the released image had that behavior.

    soldr cargo does invoke the embedded compile service through its compiler wrapper. This is not a soldr build-only facility. However, the gate runs only after Cargo has selected and dispatched a compiler request. It cannot reduce Cargo's initial fan-out, fingerprint/directory work, or already-concurrent compiler children. The detector is also crate-private and has no stable machine-readable pre-build verdict. Detector-only wrapper admission is therefore insufficient for this issue.

    Consequence for #29

    Keep CARGO_BUILD_JOBS=1 until Soldr supplies a versioned, pinned detector-capable release with a machine-readable pre-Cargo admission contract (or an equivalent front-door resource admission policy). The integration must select 4, 2, or 1 before launching Cargo; only explicit, validated 4/2 verdicts may raise the cap. Unknown, unavailable, malformed, timed-out, exclusive/oversized, or ambiguous verdicts must select 1. Emit the selected tier, Soldr version/verdict, cgroup/host telemetry, and maximum Cargo/compiler child counts for each validation run.

    Strong dependencies:

    • soldr#2781 — compiler-time amalgamation exclusivity; useful but necessarily downstream of Cargo dispatch.
    • soldr#2878 — Cargo-front-door memory admission; the direct prerequisite for this issue's safe relaxation.
    • soldr PR #2872 — cgroup-v2 peak/events telemetry model required to distinguish OOM from another external signal.
  3. zackees commented on Aug 27, 2026

    @zackees
    CollaboratorAuthor

    Follow-up evidence — detector is real on Soldr main, but too late to choose Cargo fan-out

    This is a source/release verification of the earlier audit, not a second proposal.

    • This checkout resolves soldr to C:\tools\python13\Scripts\soldr.exe; soldr --version reports 0.9.10. The Bosn image independently pins soldr==0.9.10. The latest GitHub release is likewise v0.9.10, published 2026-08-25.
    • Release v0.9.10's crates/soldr-daemon/src/amalgamation.rs has KNOWN_RUST_AMALGAMATIONS = [zccache]. It cannot recognize the kernal_api crate name.
    • Current Soldr main (observed at fa7a55f8…) changes that table to [kernal_api, zccache] and requires_exclusive_access(args, cwd) selects an exclusive Tokio RwLock permit. This is genuine compiler-service admission for a rustc --crate-name kernal_api request, after the request reaches the daemon.
    • The main implementation still cannot set CARGO_BUILD_JOBS before Cargo starts: the predicate is crate-private and takes an already-dispatched compiler argv. Its CompileResourceGate::acquire runs immediately before the embedded backend compile dispatch. It cannot limit Cargo fingerprint/directory scanning, Cargo's initial job scheduling, or compiler children already in flight.
    • Main's CLI documentation explicitly distinguishes the two controls: Soldr's --jobs / SOLDR_JOBS governs the daemon; Cargo parallelism must be selected by Cargo -j, -- --jobs, or inherited CARGO_BUILD_JOBS. host_pressure only reads/reports CARGO_BUILD_JOBS; it does not derive and export a safe value.

    Conclusion / action

    Updating the container/setup from 0.9.10 to a future release containing kernal_api would improve post-dispatch exclusivity, but it would not make adaptive Cargo fan-out effective and must not justify removing this repo's early bosn.toml CARGO_BUILD_JOBS=1 mitigation. Configuration can set a static cap before Cargo today; it cannot ask the released/main detector for a pre-Cargo verdict.

    Keep the cap until soldr#2878 supplies a versioned Cargo-front-door contract that emits a machine-readable selected tier before invoking Cargo. The safe fallback remains 1 for unknown/ambiguous/unavailable verdicts; only measured, explicit 2/4-tier approval should raise it. Validate any future setup update with the original cold Wasmtime/Cranelift path and record effective Cargo jobs, Soldr jobs/version/verdict, peak/events, and max Cargo/compiler children.

  4. added a commit that references this issue on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions