Repository navigation
fix(update): isolate immutable release builds from runtime privileges - #168237
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR moves immutable release builds into an unprivileged systemd service before root verifies and publishes the generation. Example: A dependency lifecycle script runs during immutable release preparation on Linux.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain Keep this PR open: it provides useful updater privilege isolation, but the descriptor format needs a coordinated cutover before adoption. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe native immutable updater consumes an adopted installation descriptor and exact Git SHA, builds off-path, and produces a sealed generation plus a preparation receipt. flowchart TD
A[Immutable update command] --> B[Native executor authority]
B --> C[Unprivileged systemd build]
C --> D[Build cgroup settlement]
D --> E[Private root materialization]
E --> F[Generation verification and sealing]
F --> G[Release publication and receipt]
Technical reviewBest possible solution: Keep the unprivileged builder and private root publication, with a coordinated descriptor transition qualified before adoption. Do we have a high-confidence way to reproduce the issue? Current-main source establishes that dependency installation and candidate builds execute within the root-only immutable updater; no runtime reproduction was run during this read-only review. Is this the best way to solve the issue? Reusing the existing Git preflight inside an installed unprivileged worker is a coherent solution, provided descriptor compatibility and the final publication boundary are qualified. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f55b31f50edb. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The source adds meaningful isolation, but the build-to-root authority boundary still needs final-effect qualification. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +415, Tests +24, Docs +18, Other -1. Total +456 across 12 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 10, 2026, 2:54 AM ET / 06:54 UTC (Revision 3). |
|
The inspect-only retention foundation is now in #168403, rebased over the landed build-isolation owner. It uses descriptor v3 and the existing immutable control-store migration owner; migration-preservation #168321 introduces no competing descriptor version or store. The package capability marker remains unpublished. Real v3 adoption, including the combined build descriptor and retained recovery readers, must remain gated until that bridge is qualified. This foundation performs no collection, deletion, or implicit inventory backfill. |
|
Merged at The only underlying red in CI run 38032064398 was The exact-head changed gate passed on Hetzner Crabbox |
…openclaw#168237) * fix(update): isolate immutable release builds from runtime privileges * fix(update): keep build materialization private until sealing
Resolve a non-root owner before writer admission, emit the selected-account warning immediately, and retain the identity in sealed release provenance. Restore the build worker root guard and verify staging access under its actual identity. Refs #168237
Use the existing sealed staging worker when no isolated build identity is provisioned, and warn on operator builds. Record build provenance in the sealed release for status and Doctor without changing immutable control descriptors. Refs #168237
Resolve a non-root owner before writer admission, emit the selected-account warning immediately, and retain the identity in sealed release provenance. Restore the build worker root guard and verify staging access under its actual identity. Refs #168237
…76532) Immutable-layout installs adopted via adopt-immutable have no isolated build account (descriptor.build, #168237), so every update refused. When no build account is provisioned, the update now builds the candidate as a proven non-root account (the invoking operator, or when run as root, the install's non-root owner from the service definition or install ownership), warns at selection time, and records the build account/UID/GID in the sealed build-info.json for status and Doctor. If no non-root account can be established the update refuses before any mutation; the build worker independently rejects root. Provisioned build accounts and seal verification are unchanged. The fallback runs with that account's own authority (including its groups); provisioning the isolated build account restores full isolation. Refs #168237
…enclaw#176532) Immutable-layout installs adopted via adopt-immutable have no isolated build account (descriptor.build, openclaw#168237), so every update refused. When no build account is provisioned, the update now builds the candidate as a proven non-root account (the invoking operator, or when run as root, the install's non-root owner from the service definition or install ownership), warns at selection time, and records the build account/UID/GID in the sealed build-info.json for status and Doctor. If no non-root account can be established the update refuses before any mutation; the build worker independently rejects root. Provisioned build accounts and seal verification are unchanged. The fallback runs with that account's own authority (including its groups); provisioning the isolated build account restores full isolation. Refs openclaw#168237
What Problem This Solves
Immutable release preparation currently executes dependency lifecycle scripts and builds in the root updater. This change moves that work into a constrained Linux build service and keeps privileged sealing/publication behind verified process settlement.
User Impact
The native immutable descriptor can declare a separate build account, fixed UID/GID, protected toolchain directory, and resource/headroom limits. The build receives a fresh environment, cannot write the installation or runtime state, and runs with lower CPU/I/O priority. Root publishes only a materialized, root-owned, verified generation after all build descendants are gone. Install/build/space failures preserve the serving PID and current pointer.
This is a staged native-updater slice: no CLI/config flag or automatic descriptor migration enables build adoption. Existing descriptors without a build identity retain inspection/no-op/prepared-generation reuse, while new preparation reports that build adoption is required. The immutable owner is absent from the released v2026.9.9 tree; this does not change that published driver's behavior. Production adoption and the full bridge/activation qualification remain gated on the dependent rollout work.
Why This Change Was Made
Reuse the existing Git preflight in an installed unprivileged worker rather than introduce another builder. One systemd cgroup owns the entire build, including detached children; a root-owned parent separates its writable stage from the publication copy. The existing generation owner materializes ownership and rejects shared or executable Git configuration before root verification. Runtime-user write/headroom admission is separate from build-filesystem capacity.
Production source grows by 415 lines (the requested test/docs-filtered diff is 564 insertions and 150 deletions, net +414 including one removed mock-inventory row) because the missing OS identity, resource, environment and descendant-settlement contract needs a native service owner and an installed process entrypoint. The old root build path is removed, and the existing activation service shares the same cgroup-population reader.
Evidence
Final candidate:
a8971f861d5bedf21be2fde7ac26bb279ae067de. Independent review of the complete diff is clean through P2. No source changes followed that review.The real Linux fixture uses build UID 1 and runtime UID 65534, a real systemd service/cgroup, a private runtime filesystem, and a synthetic Git origin whose main advances after target selection. Before this change, the updater executes install/build as root. Afterward, six protected accesses are denied, the parent environment sentinel is absent, detached children are extinct before root copies code, and the selected full SHA remains fixed. Every injected failure preserves the old service PID and current pointer.
The same fixture against the explicitly compiled worker passed success in 1.199 s and injected build failure in 0.941 s. These are fixture timings, not a full product-build speed comparison.
All current remote proof used Hetzner Crabbox
cbx_8585bea7f68e, Ubuntu / Node 24.21.0:run-oxlintpassed;node scripts/run-vitest.mjs src/infra/*immutable*.test.ts --maxWorkers=1passed 160 tests in 83.07 s. Nine root-only launcher cases skipped under the lease user. The subsequent OS fixture stopped at checkout traversal before building; the corrected fixture ran below.node --import ./scripts/tsx.mjs .local/lane728/linux-proof.mtspassed all six cases. The wrapper then stopped because CI had disposed its optional compiler cache.node scripts/lib/vitest-worker-compiler.mts <fresh-directory>and the compiled-worker fixture passed. The exact-main Doctor baseline reproduced the CI assertion. Export-name collision guard passed; eager-import and PR-wrapper closure suites passed 20 tests in 24.49 s. The changed gate stopped at a missing hostrgbinary; the host tool was installed before the final gate below.node scripts/check-changed.mjs --base 5033097b75dd6a8582a07a6b22969a75d750d8f7 --head a8971f861d5bedf21be2fde7ac26bb279ae067de --timed— passed, exit 0, 33m27s command time (including all 27 serial test-typecheck shards, core types, lint, dead exports, and source guards).Earlier authorized Ubuntu / Node 26 rig proof passed 168 tests in 12 immutable sibling files (230.33 s including cold worker compilation). The two changed suites passed 28 tests with
node scripts/run-vitest.mjs src/infra/update-immutable-generation.test.ts src/infra/update-immutable-install.test.ts --maxWorkers=1(70.10 s Vitest / 74.58 s wrapper); both configuration-rejection regressions fail on the original implementation. The broader final sibling run above took 83.07 s; these are remote validation costs, not a per-file CI time attribution. Blacksmith Testboxtbx_01m4hx50hmzq141pfdqh2xqjfxinstalled frozen dependencies, but two sync attempts timed out before validation. AWS capacity was unavailable, so the authorized Hetzner fallback completed the current proof. Earlier leases were stopped.CI attribution and limits
CI run 38032064398 has one underlying failure:
checks-node-changed-compact-small-19, casedelegates git Doctor without reusing its suspended parent (migrated)insrc/cli/update-cli/update-command-doctor-requester.test.ts:187. The aggregate gate reflects that failure. The identical assertion (expected [Function isCurrent] to throw an error) reproduces on unchanged main baselinee67e13cf1e2a92097b317835f484198e20690c81: 1 failed / 1 passed, 14.52 s Vitest, 34.49 s wrapper. The test, Doctor/requester/state/config/process owners, dependencies and harness are identical between that baseline and CI's tested merge30398508032be73a161b9ad7dcd6ae325ec3e3ae. The added immutable worker registry entry is not selected by this test. This qualifies the inherited-failure landing exception; it does not turn the failed test into a pass.The OS fixture uses a synthetic package manager/build, not a full OpenClaw build or live Gateway activation. Runtime capacity failure uses a full private tmpfs, not a configured per-user filesystem quota. No production update or adoption was performed; full bridge/activation and published-driver qualification remain with the dependent rollout slices.