Skip to content

fix(local-ai): make llama runtime validation deterministic - #1605

Merged
RomneyDa merged 1 commit into
mainfrom
fix/deterministic-llama-runtime-validation
Oct 2, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/deterministic-llama-runtime-validation

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace the install-time llama-server --version probe with deterministic size and SHA-256 verification of the complete runnable x64 and ARM64 payload
  • reacquire an incomplete or byte-mismatched runtime during ordinary reconciliation while retaining the verified model and rollback receipt
  • reject a missing or unsafe llama-server-impl.dll before native process startup, avoiding the Windows loader modal

The persistent loop had two parts. The installer executed the freshly extracted launcher as a validation probe, so first-use security scanning could turn acquisition into a timeout and partial rollback. A later normal setup pass treated that incomplete runtime as fatal instead of reacquiring it. Signing may still improve reputation and scan latency, but it is not required for correctness after this change.

Ownership is now explicit: archive acquisition establishes immutable source bytes, the runtime inspector verifies the installed runnable closure without executing it, and StartLocalAiRuntimeStep owns native execution and health deadlines.

Related: #1596 and openclaw/openclaw#163093. The signed-runtime publisher in #1603 remains separate defense in depth.

Required proof pools

  • windows-11-arm64: architecture-specific runtime manifests and native ARM64 build behavior changed.

Validation

Current head ce2be9d3:

  • git diff --check: passed
  • focused SetupEngine inspector and reconciliation regressions: 10 passed, 0 failed
  • focused Connection startup and model-integrity regressions: 3 passed, 0 failed
  • focused Shared catalog-manifest regression: 1 passed, 0 failed
  • exact x64 and ARM64 manifest comparison against the four pinned b11026 archives: no differences in file names, sizes, or SHA-256 values
  • AutoReview: clean after resolving one P1 incomplete-loader-closure finding and one P2 reused-runtime-integrity finding
  • Parallels Windows 11 ARM64 full build: passed
  • Parallels Shared tests: 4,222 passed, 36 skipped, 0 failed
  • Parallels Tray tests: 3,889 passed, 0 failed
  • Parallels focused SetupEngine regressions: 10 passed, 0 failed
  • Parallels focused Connection regressions: 2 passed, 1 platform-dependent symlink test skipped, 0 failed

The first Parallels attempt exposed a missing machine-wide ARM64 VC++ redistributable in the repository's unpackaged ONNX/native-load test host. That test path does not exercise Local AI's shipped runtime delivery: #1596 packages the three required VC runtime DLLs and stages them app-local beside llama-server.exe, so the production Local AI path does not depend on a machine-wide redistributable. Installing the redistributable here was only a clean-VM validation prerequisite; afterward the native-load test and complete required validation rerun were green. The VM's automatic 128 GB memory sizing also exceeded available host backing space; the successful run used a fixed 64 GB allocation without changing the guest checkout or test commands.

Real behavior proof

The current-head regression suite proves all three boundaries:

  1. A catalog-pinned payload made of non-executable test files is accepted when every size and digest matches. This proves inspection does not launch the payload.
  2. Missing llama-server-impl.dll, a missing architecture-specific CPU backend, or a same-size byte replacement is rejected and returned to acquisition.
  3. Runtime startup with a missing implementation DLL fails before constructing a native process specification, so Windows cannot show the loader modal.

Interactive reproduction of antivirus first-scan timing is not deterministic. The Parallels proof instead verifies the exact current-head Windows build and required suites, while the focused tests force each persistent-loop state directly.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@RomneyDa RomneyDa added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 9:13 AM ET / 13:13 UTC (Revision 3).

ClawSweeper review

What this changes

The PR verifies downloaded llama runtime files by size and hash, repairs incomplete installations while retaining verified models, and checks the implementation library before startup.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release still execute the runtime during installation validation. Inspection found no concrete introduced defect, and the member-authored work should remain open for landing.

Priority: P2
Reviewed head: ce2be9d39814e6187e027e9bf7b4f8b5ef584732

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch with appropriate regression coverage and reported required ARM64 validation; no blocking correctness finding was established.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor gate does not apply to this MEMBER-authored PR. Reported exact-head Windows tests exercise filesystem inspection, retained-model reconciliation, and pre-process rejection; they do not establish live antivirus recovery. No stored-format contract changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor gate does not apply to this MEMBER-authored PR. Reported exact-head Windows tests exercise filesystem inspection, retained-model reconciliation, and pre-process rejection; they do not establish live antivirus recovery. No stored-format contract changes are introduced.
Evidence reviewed 11 items Pinned introduction and merge scope: Read all nine introduced file diffs between the pinned merge base and head. The test merge's raw parents are exactly fetched main followed by the original head; its result retains the main-only setup-window changes.
Deterministic inspection: The production inspector checks architecture-specific required files, rejects missing files and reparse points, and compares complete SHA-256 digests without creating a native process.
Existing-install recovery: An invalid runtime with a verified model now returns an acquisition result retaining the original receipt and additional model assets. The unchanged setup-step owner carries that baseline into existing rollback handling.
Findings None None.
Security None None.

How this fits together

Companion's Local AI setup acquires pinned native runtime archives and model files, then records the installation for the runtime service. Inspection determines whether setup can reuse those files or must reacquire them before native startup.

flowchart TD
  A[Pinned runtime archives] --> B[Runtime acquisition]
  B --> C[File size and hash inspection]
  D[Existing installation] --> C
  C --> E{Payload valid?}
  E -->|No| B
  E -->|Yes| F[Retain verified model and receipt]
  F --> G[Native startup and health checks]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +167/-112 (net +55), tests +188/-67 (net +121) Production growth primarily supplies explicit architecture-specific integrity manifests, with focused regression coverage.

Technical review

Best possible solution:

Keep acquisition byte-verifiable, preserve verified models during runtime repair, and leave execution and health deadlines with the runtime owner.

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

No deterministic live antivirus-timing reproduction is established. Current-main source confirms the executable-probe timeout and fatal incomplete-runtime path, while focused tests force the relevant failure states.

Is this the best way to solve the issue?

Yes. Checking pinned payload bytes within acquisition and retaining execution checks in the runtime owner is a focused solution that reuses the existing recovery and rollback pipeline.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Local AI installation and recovery improvement with no demonstrated broader runtime emergency.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary external-contributor gate does not apply to this MEMBER-authored PR. Reported exact-head Windows tests exercise filesystem inspection, retained-model reconciliation, and pre-process rejection; they do not establish live antivirus recovery. No stored-format contract changes are introduced.

Evidence

What I checked:

  • Pinned introduction and merge scope: Read all nine introduced file diffs between the pinned merge base and head. The test merge's raw parents are exactly fetched main followed by the original head; its result retains the main-only setup-window changes. (b4cb926cf8ff)
  • Deterministic inspection: The production inspector checks architecture-specific required files, rejects missing files and reparse points, and compares complete SHA-256 digests without creating a native process. (src/OpenClaw.SetupEngine/LlamaRuntimeInstaller.cs:269, ce2be9d39814)
  • Existing-install recovery: An invalid runtime with a verified model now returns an acquisition result retaining the original receipt and additional model assets. The unchanged setup-step owner carries that baseline into existing rollback handling. (src/OpenClaw.SetupEngine/LocalAiInstallReconciler.cs:233, ce2be9d39814)
  • Startup boundary: The implementation-library check runs before native process construction. The added regression verifies failed startup and an absent process specification when that library is missing. (src/OpenClaw.Connection/LocalAi/LlamaServerRuntimeService.cs:1043, ce2be9d39814)
  • Current-main necessity: Fetched main still starts llama-server with --version, imposes a 30-second inspection timeout, and validates version output. It does not implement this deterministic inspection. (src/OpenClaw.SetupEngine/LlamaRuntimeInstaller.cs:300, 407bc7728826)
  • Latest-release comparison: GitHub content inspection at v2026.9.4 confirms the old executable-probe timeout and version-output validation remain in the release. The local release object was unavailable, so the release source was read through GitHub. (src/OpenClaw.SetupEngine/LlamaRuntimeInstaller.cs, 3c43751b2bac)

Likely related people:

  • Dallin Romney: Raw commit 4c9a7a8 adds src/OpenClaw.SetupEngine/LlamaRuntimeInstaller.cs:151 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4c9a7a829a27; files: src/OpenClaw.SetupEngine/LlamaRuntimeInstaller.cs)
  • Karen Lai: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Pedro Larroy: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-02T12:36:57.280Z sha ce2be9d :: needs changes before merge. :: none
  • reviewed 2026-10-02T13:03:21.437Z sha ce2be9d :: needs maintainer review before merge. :: none

@RomneyDa

RomneyDa commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@RomneyDa RomneyDa removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 2, 2026
@RomneyDa
RomneyDa merged commit d34c6cc into main Oct 2, 2026
59 of 63 checks passed
@RomneyDa
RomneyDa deleted the fix/deterministic-llama-runtime-validation branch October 2, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant