Skip to content

Fix the Linux runtime contract end to end - #38

Merged
gitcommit90 merged 2 commits into
mainfrom
fix/linux-runtime-contract
Jul 29, 2026
Merged

Fix the Linux runtime contract end to end#38
gitcommit90 merged 2 commits into
mainfrom
fix/linux-runtime-contract

Conversation

@gitcommit90

@gitcommit90 gitcommit90 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Outcome

Fixes Linux channel provisioning by installing one immutable runtime manifest shared by the installer, root lifecycle helper, application, updater, image assets, and cache. Corrects nested unprivileged ID-map selection and makes same-version readiness repair a corrupted cache.

Real Linux acceptance

  • Fresh Ubuntu 24.04 unprivileged nested-LXC host installed runtime v2 with local ID map 1:65535.
  • Installed helper created a real channel container, ran as agent in /workspace, reached the internet, and retained its file across stop/start.
  • Full systemd application onboarding created a channel through /api/channels with computer_ready=true.
  • Resident run_command and Terminal both executed inside the same channel machine and mirrored files to the Files API.
  • Host reboot preserved the database, channel machine, owner marker, and both files with unchanged inodes.
  • Same-version retained update repaired an injected corrupt cache while preserving database/machine inodes and an unrelated firewall chain.

Source checks

  • npm run typecheck
  • npm run build
  • npm run test:site
  • node --test test/channel-computers.mjs
  • npm run test:onboarding-browser (20/20)
  • npm test: native-world completed 125/125 earlier in the run; later reruns exposed unrelated mock-provider fetch timing flakes at different assertions; isolated cowork rerun passed.
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Upgraded the Linux LXC runtime to version 2 with a validated, digest-pinned runtime manifest.
    • Added architecture-specific image verification and safer, atomic cache and image updates.
    • Improved support for unprivileged nested-LXC installations with correct subordinate ID mapping.
  • Bug Fixes

    • Systemd installations now require the exact installed helper and validate runtime readiness more thoroughly.
    • Corrupted same-version caches are automatically repaired.
    • Runtime configuration is preserved during updates and rollbacks and removed during uninstall.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Runtime v2 introduces a digest-qualified manifest shared by installation and execution, namespaced image and cache paths, contract-based cache validation and repair, nested-LXC subordinate-ID allocation, stricter systemd helper resolution, and host contract lifecycle updates.

Changes

LXC runtime v2

Layer / File(s) Summary
Manifest-driven installation
deploy/1helm-lxc-runtime-v2.conf, site/public/install-lxc-runtime.sh
The installer validates and installs the runtime-v2 manifest, uses manifest-qualified image paths and atomic asset replacement, allocates nested-LXC-safe subordinate IDs, and verifies the installed runtime.
Manifest-driven runtime readiness
scripts/1helm-lxc-runtime, test/fake-lxc-runtime.mjs, test/site.mjs
The runtime derives paths and image digests from the manifest, validates contract-qualified caches, repairs invalid caches, selects architecture-specific assets, and uses the active cache for container creation.
Host contract and systemd integration
site/public/{apply-linux-release.sh,install.sh,migrate-linux-host-contract.sh,uninstall-host.sh,update-host.sh}, src/server/channel-computers.ts, test/site.mjs
Host transactions preserve the runtime-v2 manifest, uninstall removes it, updates require runtime-v2 readiness, and systemd installations reject unsafe or missing helper paths.
Release contract documentation
CHANGELOG.md
The 0.0.28 changelog records the runtime manifest, systemd readiness, cache repair, and nested-LXC allocation fixes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Installer
  participant RuntimeManifest
  participant LxcRuntime
  participant ActiveCache
  Installer->>RuntimeManifest: install validated runtime-v2 manifest
  LxcRuntime->>RuntimeManifest: load runtime and image contract
  LxcRuntime->>ActiveCache: validate digest and contract
  ActiveCache-->>LxcRuntime: reuse or require repair
  LxcRuntime->>ActiveCache: prepare repaired cache
Loading

Possibly related PRs

  • gitcommit90/1Helm#37: Adjusts Linux LXC runtime state handling around the machines path used by the runtime installer and helper.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers outcome and testing, but it misses the required template sections like type, release notes, ledger, and post-merge. Rewrite it to match the template: add Summary, Type of change, Release notes, numbered acceptance ledger, Verification, and Post-merge sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing the Linux runtime contract end to end.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/linux-runtime-contract

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/1helm-lxc-runtime`:
- Around line 162-166: Extend the cache readiness validation around the rootfs
checksum and cache_contract check to also verify the extracted metadata
representation before accepting the cache. Persist or reuse a metadata digest,
and mark the cache invalid when metadata is corrupted even if the marker and
rootfs remain intact; add a regression test covering metadata corruption with
both preserved.

In `@site/public/install-lxc-runtime.sh`:
- Around line 74-85: Extend the manifest validation condition in the install
script to validate ONEHELM_LXC_IMAGE_BUILD before assigning IMAGE_BUILD and
completing installation. Use the same build-format validation expected by
scripts/1helm-lxc-runtime, while preserving the existing checks and
invalid-manifest failure behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eae76d42-11fa-4b06-bf02-f1634628161c

📥 Commits

Reviewing files that changed from the base of the PR and between 94e64a9 and 17b8e3b.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • deploy/1helm-lxc-runtime-v2.conf
  • scripts/1helm-lxc-runtime
  • site/public/apply-linux-release.sh
  • site/public/install-lxc-runtime.sh
  • site/public/install.sh
  • site/public/migrate-linux-host-contract.sh
  • site/public/uninstall-host.sh
  • site/public/update-host.sh
  • src/server/channel-computers.ts
  • test/fake-lxc-runtime.mjs
  • test/site.mjs

Comment thread scripts/1helm-lxc-runtime
Comment on lines +162 to +166
if [[ -f "$cache_dir/rootfs.tar.xz" ]] \
&& printf '%s %s\n' "$rootfs_sha" "$cache_dir/rootfs.tar.xz" | sha256sum -c - >/dev/null 2>&1; then
cache_rootfs_ok=1
fi
if [[ "$cache_contract" != "$expected_contract" || "$cache_rootfs_ok" -ne 1 ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Repair metadata corruption, not only rootfs corruption.

The readiness check validates only cached rootfs.tar.xz; it never verifies the metadata extracted at Line 171. A damaged metadata payload with an intact rootfs and 1helm-runtime-contract marker skips repair, leaving lxc-create to consume a corrupt cache. Validate the cached metadata representation too, or persist and verify its archive digest before accepting the cache. Add a regression test that corrupts metadata while preserving the marker and rootfs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/1helm-lxc-runtime` around lines 162 - 166, Extend the cache readiness
validation around the rootfs checksum and cache_contract check to also verify
the extracted metadata representation before accepting the cache. Persist or
reuse a metadata digest, and mark the cache invalid when metadata is corrupted
even if the marker and rootfs remain intact; add a regression test covering
metadata corruption with both preserved.

Comment on lines +74 to +85
[[ "${ONEHELM_LXC_RUNTIME_VERSION:-}" == "1helm-lxc-runtime-v2" \
&& "${ONEHELM_LXC_STATE_PATH:-}" == "/var/lib/1helm-lxc/machines" \
&& "${ONEHELM_LXC_IMAGE_SET:-}" =~ ^ubuntu-noble-[0-9]{8}-[0-9]{4}$ \
&& "${ONEHELM_LXC_IMAGE_RELEASE:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ \
&& "${ONEHELM_LXC_AMD64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_AMD64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ ]] \
|| { echo "The verified release has an invalid LXC runtime manifest." >&2; exit 1; }
LXC_PATH="$ONEHELM_LXC_STATE_PATH"
IMAGE_BUILD="$ONEHELM_LXC_IMAGE_BUILD"
IMAGE_RELEASE="$ONEHELM_LXC_IMAGE_RELEASE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate ONEHELM_LXC_IMAGE_BUILD before declaring installation successful.

Line 84 consumes this value, but Lines 74-81 do not validate it. A malformed manifest can pass installation and the version probe at Line 278, then fail every helper ready call because scripts/1helm-lxc-runtime rejects invalid build formats.

Proposed fix
    && "${ONEHELM_LXC_STATE_PATH:-}" == "/var/lib/1helm-lxc/machines" \
    && "${ONEHELM_LXC_IMAGE_SET:-}" =~ ^ubuntu-noble-[0-9]{8}-[0-9]{4}$ \
+   && "${ONEHELM_LXC_IMAGE_BUILD:-}" =~ ^[0-9]{8}_[0-9]{2}:[0-9]{2}$ \
    && "${ONEHELM_LXC_IMAGE_RELEASE:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[[ "${ONEHELM_LXC_RUNTIME_VERSION:-}" == "1helm-lxc-runtime-v2" \
&& "${ONEHELM_LXC_STATE_PATH:-}" == "/var/lib/1helm-lxc/machines" \
&& "${ONEHELM_LXC_IMAGE_SET:-}" =~ ^ubuntu-noble-[0-9]{8}-[0-9]{4}$ \
&& "${ONEHELM_LXC_IMAGE_RELEASE:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ \
&& "${ONEHELM_LXC_AMD64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_AMD64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ ]] \
|| { echo "The verified release has an invalid LXC runtime manifest." >&2; exit 1; }
LXC_PATH="$ONEHELM_LXC_STATE_PATH"
IMAGE_BUILD="$ONEHELM_LXC_IMAGE_BUILD"
IMAGE_RELEASE="$ONEHELM_LXC_IMAGE_RELEASE"
[[ "${ONEHELM_LXC_RUNTIME_VERSION:-}" == "1helm-lxc-runtime-v2" \
&& "${ONEHELM_LXC_STATE_PATH:-}" == "/var/lib/1helm-lxc/machines" \
&& "${ONEHELM_LXC_IMAGE_SET:-}" =~ ^ubuntu-noble-[0-9]{8}-[0-9]{4}$ \
&& "${ONEHELM_LXC_IMAGE_BUILD:-}" =~ ^[0-9]{8}_[0-9]{2}:[0-9]{2}$ \
&& "${ONEHELM_LXC_IMAGE_RELEASE:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ \
&& "${ONEHELM_LXC_AMD64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_AMD64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_ROOTFS_SHA256:-}" =~ ^[a-f0-9]{64}$ \
&& "${ONEHELM_LXC_ARM64_META_SHA256:-}" =~ ^[a-f0-9]{64}$ ]] \
|| { echo "The verified release has an invalid LXC runtime manifest." >&2; exit 1; }
LXC_PATH="$ONEHELM_LXC_STATE_PATH"
IMAGE_BUILD="$ONEHELM_LXC_IMAGE_BUILD"
IMAGE_RELEASE="$ONEHELM_LXC_IMAGE_RELEASE"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@site/public/install-lxc-runtime.sh` around lines 74 - 85, Extend the manifest
validation condition in the install script to validate ONEHELM_LXC_IMAGE_BUILD
before assigning IMAGE_BUILD and completing installation. Use the same
build-format validation expected by scripts/1helm-lxc-runtime, while preserving
the existing checks and invalid-manifest failure behavior.

@gitcommit90
gitcommit90 merged commit 0169c7c into main Jul 29, 2026
6 of 7 checks passed
@gitcommit90
gitcommit90 deleted the fix/linux-runtime-contract branch July 29, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant