Skip to content

fix(update): build adopted immutable releases without an isolated build account - #176532

Merged
steipete merged 3 commits into
mainfrom
upd/upd-l1692
Oct 19, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/upd-l1692

Conversation

@steipete

@steipete steipete commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Refs #168237

What Problem This Solves

Adopted immutable installations cannot provision the separate build identity yet, so requiring it makes every update fail. Preparation now falls back to an unprivileged operator account and warns about the missing isolation. Candidate dependency installation and build scripts never run as root through this fallback.

Behavior

A non-root caller keeps its identity. A root updater resolves a non-root owner from the recorded Gateway service account or actual installation/state-directory ownership, resolves its numeric UID/GID and account home, and uses the verified service toolchain path. If no non-root owner can be resolved, preparation refuses before acquiring the writer or creating staging, with instructions to run as the service user or provision the isolated build account. The worker independently rejects UID 0. Provisioned isolated-account checks and malformed/unreadable descriptor refusals remain intact.

Both account choices use the existing restricted systemd worker, private build/home/temp directories, exact-SHA acquisition, cgroup settlement, verification, sealing and publication owners. The root-owned outer directory permits traversal during the build, then becomes private before materialization. The warning names the selected account, appears immediately on stderr (including JSON mode), and remains in the update result. Sealed dist/build-info.json records builtBy: operator, isolation: none, account, UID and GID; Status and Doctor read those facts. No config option, dependency, SQLite schema or descriptor-version change.

Evidence

Rebased head: ed106a361c4763cf7a394a14c8f5e69c84b10df2, based on 6a43904e70446a7c9793f5e12e301c7e1f622ce5.

The conflict with #176488 was confined to src/cli/update-cli.immutable.test.ts. The resolution retains main's consolidated preparation/refusal tests and helpers, adds the warning callback to its preparation expectation, and preserves immediate human/JSON warning assertions. The production patches are unchanged; the SQLite/mock repair commit is patch-identical after rebase.

  • Node: all nine focused files passed: 94 tests. The complete status file passed 31/31, exit 0, 248.10 s Vitest / 386.58 s wrapper, including 115.596 s worker preparation. The other eight files passed 63/63, exit 0, 373.00 s wrapper across infra/CLI/commands groups.
  • Bun: all nine focused files passed: 94 tests, exit 0, 513.76 s wrapper; infra 362.57 s, CLI 60.32 s, commands 8.99 s. Both unsafe-history cases passed (2.868 / 1.936 s).
  • Mock-export ratchet: passed against the pinned main base using --no-merge-base. Targeted tsgo, oxlint, oxfmt and git diff --check passed. The default typecheck selection lacked tsrs/package.json; the repository-supported OPENCLAW_TYPECHECKER=tsgo selection passed without modifying dependencies.
  • Independent Codex review: no actionable P0/P1 findings after the rebase.

Clean-main comparison

After committing all work, the same assigned worktree was temporarily detached at clean main 6a43904e70446a7c9793f5e12e301c7e1f622ce5; no stash was used. The exact same full-file Node command ran to completion on main and on the rebased branch:

HOME="$PWD/.artifacts/home" OPENCLAW_STATE_DIR="$PWD/.artifacts/state" \
  OPENCLAW_VITEST_RUNTIME=node \
  node scripts/run-vitest.mjs src/cli/update-cli/status.test.ts --maxWorkers=1

Main exited 1: 1 passed / 30 failed, 180.47 s Vitest / 366.37 s wrapper. Its first failure was src/cli/update-cli/status.test.ts > local replacement (JSON: false, remote: false) (34.583 s): SQLite read-only worker snapshot cleanup failed, caused by SQLite snapshot still belongs to an active reader in sqlite-readonly-location-cleanup.ts (assertSnapshotReadersRetired / sealRetainedSnapshotTempDirectory). The retained cleanup failure cascaded through subsequent cases and teardown. That test passes on this branch, and the whole branch status file passes. The previously observed local replacement (JSON: true, remote: false) history omission did not reproduce on either checkout: main 19.006 s, branch 27.850 s. The clean-main cleanup failure is outside this PR; the old JSON-omission observation is not claimed as reproduced or fixed.

Regression and cost notes

The prior unsafe-history CI failure came from fixture setup: vi.resetModules() does not clear safe native SQLite admission retained in worker environment data. The fixture now saves, clears and restores that admission, following the SQLite owner's test pattern. All existing unsafe-version refusal, diagnostics, availability and retained-history assertions remain. Four mocks spread importOriginal, and exactly three obsolete mock-export baseline entries were removed.

Current focused coverage includes non-root operator, root/service owner, stat-based owner, root-only refusal before writer admission, unchanged provisioned builds, invalid/unreadable descriptors, immediate human/JSON warnings, recorded identity, worker root rejection and seal-failure preservation. The immutable-install dry-run case took 42.543 s under Node and 45.975 s under Bun; the CLI file took 136.35 s with 88% transformation. These costs are recorded without timeout, retry or assertion changes. The full check:changed SQLite inventory is omitted under the campaign's host-time budget; PR CI supplies broad proof.

All runs use isolated HOME and OPENCLAW_STATE_DIR. Linux/systemd identity and execution are projected at the OS boundary; real fixture files exercise staging, provenance, verification/sealing and publication preservation. This is not a live Linux install/build/activation claim. No live Linux run was repeated for this rebase.

Focused commands:

# Node: status separately as above; the other eight paths below without status.
# Bun: all nine paths below.
HOME="$PWD/.artifacts/home" OPENCLAW_STATE_DIR="$PWD/.artifacts/state" \
  OPENCLAW_VITEST_RUNTIME=bun OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1 \
  node scripts/run-vitest.mjs \
  src/cli/update-cli.immutable.test.ts \
  src/cli/update-cli/status.test.ts \
  src/commands/doctor-stale-runtime-build.test.ts \
  src/infra/update-immutable-build.test.ts \
  src/infra/update-immutable-build.worker.test.ts \
  src/infra/update-immutable-generation.test.ts \
  src/infra/update-immutable-inspection.test.ts \
  src/infra/update-immutable-install-record.test.ts \
  src/infra/update-immutable-install.test.ts --maxWorkers=1
HOME="$PWD/.artifacts/home" OPENCLAW_STATE_DIR="$PWD/.artifacts/state" \
  node --import ./scripts/tsx.mjs scripts/check-test-mock-exports.mts \
  --base 6a43904e70446a7c9793f5e12e301c7e1f622ce5 --no-merge-base

Pre-publish git fetch origin main completed at 77a403f1c15380ce71fcc53f0bb68ce5f4f2794e. No commits since the tested rebase base touched this PR's production/test owners or documentation. The later mock-export baseline change in dc6b38a0d98e removes an unrelated cron entry. The PR remained open/non-draft at the expected old head before the single force-with-lease push.

Whole-PR LOC against the rebased main: production +311/-72, tests +440/-13, docs +21/-5, baseline 0/-3; +772/-93 total. This rebase adds no production behavior beyond the reviewed feature and safety repair.

@clawsweeper

clawsweeper Bot commented Oct 18, 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 cli CLI command changes commands Command implementations size: M labels Oct 18, 2026
@steipete
steipete marked this pull request as ready for review October 18, 2026 21:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T00:18:58.852675Z ed106a3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR lets adopted immutable installations build as the operator when no separate build account is recorded and exposes that provenance in update status and Doctor.

Example: A root operator prepares another official-main release on an adopted Linux installation without descriptor.build.

  • Before: Preparation refuses because build-account adoption is unavailable.
  • After: Preparation uses the restricted build service as UID 0, warns, and records operator-build provenance before sealing.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, owner-approved implementation with a concrete CI defect; mocked OS boundaries do not establish the changed authority contract, and upgrade compatibility is not demonstrated.
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: An adopted immutable installation cannot prepare another release through the available CLI adoption workflow.
Reason: The feature owner explicitly approves replacing the staged refusal with a warning and operator execution; no additional product approval is needed.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this maintainer-owned PR addresses a current immutable-update refusal, but its new cgroup mock violates the required CI ratchet.

Priority: P2
Reviewed head: 8e1a09d1735301a58dc6fd98ee8e40a5745d9574

Before merge

  • Add real behavior proof - Authority-chain proof required: the changed build owner selects UID 0 when no build identity exists, but supplied tests mock systemd execution and cgroup settlement. Provide redacted native Linux output showing an allowed build, denied reads of runtime state/config, denied writes outside staging, rejection after update ownership is lost, and descendant extinction before materialization/publication; redact credentials, IPs, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve real exports in the new cgroup mock (P2) - This new closed mock has neither importOriginal pass-through nor an adjacent mock-isolation explanation, and the new file has no grandfathered baseline entry. scripts/check-test-mock-exports.mts therefore rejects it, consistent with the exact-head check's mock-exports failure annotation. Preserve the real module and override only isSystemdControlGroupEmpty, or document the concrete isolation requirement using the supported annotation; also prune the obsolete baseline entry left by converting update-immutable-install.test.ts to pass-through.
  • Resolve security review attention item - The accepted root fallback still needs native evidence that candidate execution cannot cross the retained filesystem and publication boundaries.
  • Resolve merge risk - The fallback changes the build principal to UID 0 and relies on native mount and capability restrictions to protect live state; that effective authority boundary remains unverified.
  • 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.

Findings

  • [P2] Preserve real exports in the new cgroup mock — src/infra/update-immutable-build.test.ts:14

Tests

  • Low-value test src/infra/update-immutable-build.test.ts: The mocked systemd command writes the artifact that the test reads back, so that assertion cannot detect a worker failure; remove this echo and retain the distinct launch/security contract assertions.
  • Missing end-to-end proof: No native Linux operator-build run demonstrates successful preparation, forbidden filesystem access denial, descendant settlement, or upgrade compatibility; only the Doctor reader is explicitly reported red on base and green on head.
Agent review details

How this fits together

The immutable updater takes an adopted installation and exact official commit, builds in private staging, settles descendants, verifies and seals the artifact, and publishes a prepared generation for the activation owner.

flowchart TD
  A[Update CLI] --> B[Immutable preparation owner]
  B --> C[Build identity selection]
  C --> D[Restricted systemd worker]
  D --> E[Descendant settlement]
  E --> F[Materialize and record provenance]
  F --> G[Verify seal and publish]
  G --> H[Activation owner]
Loading

Technical review

Best possible solution:

Keep the approved fallback in the existing build owner, repair the mock ratchet violation, and establish native isolation before merging.

Do we have a high-confidence way to reproduce the issue?

Current main explicitly rejects preparation without descriptor.build, while CLI adoption does not provision that identity; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Using the existing worker and publication owner is the smallest coherent implementation of the approved fallback, with artifact provenance avoiding a competing control-state representation.

Full review comments:

  • [P2] Preserve real exports in the new cgroup mock — src/infra/update-immutable-build.test.ts:14
    This new closed mock has neither importOriginal pass-through nor an adjacent mock-isolation explanation, and the new file has no grandfathered baseline entry. scripts/check-test-mock-exports.mts therefore rejects it, consistent with the exact-head check's mock-exports failure annotation. Preserve the real module and override only isSystemdControlGroupEmpty, or document the concrete isolation requirement using the supported annotation; also prune the obsolete baseline entry left by converting update-immutable-install.test.ts to pass-through.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify the operator build boundary (recommended)
    Exercise the real Linux build service as root, demonstrate denied runtime state/config access and writes outside staging, and verify descendant extinction before publication.
  2. Pause the fallback
    Retain the existing refusal until the operator-build security boundary can be demonstrated.

Provenance checked

  • Absent-account refusal and build admission changes intended behavior with a stated reason (ec2c1fa: The earlier isolation change deliberately staged provisioning and refused new preparation without a separate identity.)
  • Exact-SHA worker and object reuse keeps the original intent (895b5dd: Reuse verified installed Git objects without executing Git in the protected predecessor, then dissociate before building.)
  • Doctor runtime provenance keeps the original intent (c7ad6ef: Report stale built runtimes conservatively without failing Doctor or warning during an update.)
  • Immutable preparation and publication keeps the original intent (99babf2: Prepare and seal an exact generation off-path while preserving the serving release and leaving activation to its owner.)

Testing

Proof path: in-process harness.

Security

Needs attention: The accepted root fallback still needs native evidence that candidate execution cannot cross the retained filesystem and publication boundaries.

Evidence

What I checked:

PR surface

Source +78, Tests +214, Docs +7. Total +299 across 15 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 150 72 +78
Tests 6 219 5 +214
Docs 1 12 5 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 381 82 +299

Review metrics

Metric Value Why it matters
Production versus test changes Production +150/-72; tests +219/-5 Production growth supports operator selection and sealed provenance without a new control schema; the new build fixture includes redundant mock-generated artifact assertions.

Labels

Label changes:

  • add P2: This repairs a limited, advanced Linux immutable-update workflow rather than a general installation outage.
  • add merge-risk: 🚨 security-boundary: Dependency and candidate build execution can now use UID 0; the accepted direction does not establish the effectiveness of the retained native restrictions.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This repairs a limited, advanced Linux immutable-update workflow rather than a general installation outage.
  • merge-risk: 🚨 security-boundary: Dependency and candidate build execution can now use UID 0; the accepted direction does not establish the effectiveness of the retained native restrictions.
  • 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 that root candidate execution cannot access runtime state/config or write outside staging, and that lost update ownership prevents publication after awaited work.
  • Demonstrate fresh preparation and an upgrade from the latest stable with existing settings, data, and older control readers intact.

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 execution lanes are retired.

Reviewed October 18, 2026, 6:10 PM ET / 22:10 UTC.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b4e50c59f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}
throw new Error(
`No non-root immutable build owner could be determined; no changes were made. Run openclaw update as the service user, or provision the isolated build account: ${provisioning}.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop recommending a caller mode that preparation rejects

When root cannot resolve a non-root build owner, this error tells the operator to retry as the service user, but every non-dry-run preparation calls requireUpdater() first, which rejects any effective UID other than 0. The documented non-root branch is therefore unreachable through openclaw update, leaving affected users with a recovery step that can never succeed; either support that invocation path or provide an actionable root-side remedy.

AGENTS.md reference: AGENTS.md:L73-L76

Useful? React with 👍 / 👎.

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
@steipete
steipete merged commit 7ef2a23 into main Oct 19, 2026
137 of 140 checks passed
@steipete
steipete deleted the upd/upd-l1692 branch October 19, 2026 00:32
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

cli CLI command changes commands Command implementations docs Improvements or additions to documentation 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