Skip to content

fix(update): isolate immutable release builds from runtime privileges - #168237

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-update-slice3-build-isolation-20260919
Oct 10, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-update-slice3-build-isolation-20260919

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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.

Current source fixture case Time Result
Build, materialize, seal and verify 2.882 s Passed
Dependency installation failure 2.559 s Old PID/pointer preserved
Build failure 2.580 s Old PID/pointer preserved
Build filesystem capacity failure 0.061 s Old PID/pointer preserved
Runtime filesystem capacity failure 0.072 s Old PID/pointer preserved
Runtime-user write failure 0.071 s Old PID/pointer preserved

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:

  • Lint and sibling run: focused run-oxlint passed; node scripts/run-vitest.mjs src/infra/*immutable*.test.ts --maxWorkers=1 passed 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.
  • Source OS proof: node --import ./scripts/tsx.mjs .local/lane728/linux-proof.mts passed all six cases. The wrapper then stopped because CI had disposed its optional compiler cache.
  • Compiled proof and baseline: 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 host rg binary; the host tool was installed before the final gate below.
  • Final changed gate: 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 Testbox tbx_01m4hx50hmzq141pfdqh2xqjfx installed 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, case delegates git Doctor without reusing its suspended parent (migrated) in src/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 baseline e67e13cf1e2a92097b317835f484198e20690c81: 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 merge 30398508032be73a161b9ad7dcd6ae325ec3e3ae. 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.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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.

  • Before: The script runs inside the root updater.
  • After: The script runs under a separate build UID with restricted filesystem access and resource limits.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, focused isolation work with a persisted-format blocker and insufficient authority-boundary proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Dependency lifecycle scripts inherit root privileges during immutable release preparation.
Reason: The staged isolation work removes an unnecessary privilege grant while preserving the serving generation and existing updater ownership.

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
Reviewed head: a8971f861d5bedf21be2fde7ac26bb279ae067de

Before merge

  • Add real behavior proof - Authority-chain proof required: provide redacted logs or terminal output from the installed immutable worker and native publisher showing a successful preparation, denied build-account access to installation/runtime files, detached-descendant extinction before root materialization, and executor revocation preventing release rename; the reported synthetic fixture and blocked compiled-worker scenario do not establish these final effects. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Version build descriptors before persisting them (P2) - Passing the newly accepted build argument to adoptImmutableInstall persists build metadata while still writing version 1 or 2. The prior immutable control and retained-recovery readers use a strict schema without that field, so reading this record fails with an unrecognized build key even though its version claims compatibility. The later coordination comment identifies this exact mismatch. Keep build metadata unwritable until the bridge is qualified, or implement the coordinated version-3 reader/writer transition in the existing persistence owner before adoption.
  • Resolve security concern: Qualify build isolation and publication fencing - The reported fixture has no inspectable trace showing rejection of the build principal's forbidden filesystem effects or executor revocation preventing release rename; no concrete bypass was established by source inspection.
  • Resolve merge risk - Before merge, establish that the build principal cannot reach protected filesystem effects and that revoked executor authority prevents release publication.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Persisted descriptor versions - 1c88dd2: Version 2 explicitly enabled activation while retaining strict descriptor readers; the new build shape lacks the coordinated version transition requested in discussion.

Findings

  • [P2] Version build descriptors before persisting them — src/infra/update-immutable-install-schema.ts:57
  • [medium] Qualify build isolation and publication fencing — src/infra/update-immutable-install.ts:518

Provenance

  • Persisted descriptor versions changes intended behavior without addressing why it exists (1c88dd2: Version 2 explicitly enabled activation while retaining strict descriptor readers; the new build shape lacks the coordinated version transition requested in discussion.)
  • Earlier file history: original intent not found (unknown: git log --follow reached a missing historical object, and an older git show also failed; available main history and GitHub-verified foundation PRs establish the reviewed behavior.)

Tests

  • Missing end-to-end proof: Show the installed worker preparing a generation through the native updater, including protected-access rejection, descendant settlement, revoked-authority publication rejection, and preserved existing installation state.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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:

  • [P2] Version build descriptors before persisting them — src/infra/update-immutable-install-schema.ts:57
    Passing the newly accepted build argument to adoptImmutableInstall persists build metadata while still writing version 1 or 2. The prior immutable control and retained-recovery readers use a strict schema without that field, so reading this record fails with an unrecognized build key even though its version claims compatibility. The later coordination comment identifies this exact mismatch. Keep build metadata unwritable until the bridge is qualified, or implement the coordinated version-3 reader/writer transition in the existing persistence owner before adoption.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f55b31f50edb.

Merge-risk options

Maintainer options:

  1. Hold for authority qualification (recommended)
    Keep the staged slice open until final-effect evidence establishes filesystem isolation and publication fencing.

Provenance checked

  • Immutable build preparation changes intended behavior with a stated reason (99babf2: Introduced off-path exact-SHA preparation while keeping the serving Gateway running; this PR explains why lifecycle execution moves out of root.)
  • Activation cgroup settlement keeps the original intent (1c88dd2: Activation required descendant extinction before pointer publication; extraction preserves that population check and shares it with builds.)

Testing

Proof path: in-process harness.

Security

Needs attention: The source adds meaningful isolation, but the build-to-root authority boundary still needs final-effect qualification.

Evidence

Security concerns:

  • [medium] Qualify build isolation and publication fencing — src/infra/update-immutable-install.ts:518
    The reported fixture has no inspectable trace showing rejection of the build principal's forbidden filesystem effects or executor revocation preventing release rename; no concrete bypass was established by source inspection.
    Confidence: 0.95

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 99babf2 adds src/infra/update-immutable-install.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 99babf272543; files: src/infra/update-immutable-install.ts)

PR surface

Source +415, Tests +24, Docs +18, Other -1. Total +456 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 564 149 +415
Tests 2 61 37 +24
Docs 1 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 12 643 187 +456

Review metrics

Metric Value Why it matters
Production versus tests Production +564/-149; tests +61/-37 Production growth adds the native identity, sandbox, installed worker, and settlement contract while removing root build execution.
Native descriptor surface 8 new build fields; 0 new CLI flags Build identity, toolchain, and resource settings extend the persisted native descriptor despite adoption remaining staged.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: New persisted build metadata is accepted under descriptor versions whose older readers reject it.

Label justifications:

  • P2: Useful hardening of a staged Linux immutable updater with limited current exposure.
  • merge-risk: 🚨 security-boundary: The change transfers build output across an unprivileged-to-root boundary and requires final-effect authority proof.
  • merge-risk: 🚨 compatibility: New persisted build metadata is accepted under descriptor versions whose older readers reject it.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for the build principal's forbidden filesystem accesses and prove executor revocation prevents release publication.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-10T05:44:50.414Z sha 7496e65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T05:52:29.232Z sha 7496e65 :: needs real behavior proof before merge. :: none

Reviewed October 10, 2026, 2:54 AM ET / 06:54 UTC (Revision 3).

@steipete
steipete marked this pull request as ready for review October 10, 2026 05:47
@steipete

steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 10, 2026
@steipete
steipete merged commit ec2c1fa into main Oct 10, 2026
158 of 161 checks passed
@steipete
steipete deleted the steipete/perf-micro-update-slice3-build-isolation-20260919 branch October 10, 2026 08:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged at ec2c1fa02cd6cef871315ed53e0df469921d62f1 under the authorized inherited-failure exception.

The only underlying red in CI run 38032064398 was checks-node-changed-compact-small-19: delegates git Doctor without reusing its suspended parent (migrated) expected isCurrent to throw. The identical assertion reproduced on unchanged main e67e13cf1e2a92097b317835f484198e20690c81 (1 failed / 1 passed; 14.52 s Vitest). Its test and relevant input trees match CI's tested merge 30398508032be73a161b9ad7dcd6ae325ec3e3ae; the aggregate gate only reflects that failure.

The exact-head changed gate passed on Hetzner Crabbox cbx_8585bea7f68e in 33m27s. Final source and compiled-worker Linux isolation fixtures passed, 160 sibling tests passed, and 20 closure tests plus the export guard passed. Independent review was clean through P2. The native merge helper stopped before dispatch at its installed tooling trust check; the explicitly authorized REST fallback merged the pinned head. The lease is stopped. No production adoption or deployment was performed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…openclaw#168237)

* fix(update): isolate immutable release builds from runtime privileges

* fix(update): keep build materialization private until sealing
steipete added a commit that referenced this pull request Oct 18, 2026
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
steipete added a commit that referenced this pull request Oct 19, 2026
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
steipete added a commit that referenced this pull request Oct 19, 2026
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
steipete added a commit that referenced this pull request Oct 19, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant