Skip to content

fix(fleet): reject hexadecimal CPU limits - #105158

Merged
steipete merged 3 commits into
openclaw:mainfrom
mushuiyu886:fix/followup-104814
Jul 17, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
mushuiyu886:fix/followup-104814

Conversation

@mushuiyu886

Copy link
Copy Markdown
Contributor

Summary

  • Parse fleet create --cpus with the shared strict finite-number parser.
  • Reject hexadecimal CPU limits before loading the fleet runtime.
  • Preserve fractional CPU controls such as 1.5 and add regression coverage.

What Problem This Solves

openclaw fleet create tenant-a --cpus 0x10 previously used Number(value). The check interpreted the token as 16, then returned the original 0x10 string and eventually forwarded it to Docker or Podman as --cpus 0x10.

That turned a precise CLI input error into a late, runtime-specific failure after fleet setup had started. The fix performs strict decimal/scientific parsing at the public option boundary.

User Impact

Hexadecimal CPU syntax now fails immediately with --cpus must be a positive number. Valid positive fractional limits continue through the existing fleet runtime path.

Origin / follow-up

Competition / linked PR analysis

Searched open PRs and issues for fleet cpus, fleet create cpus, hexadecimal cpus, and strict cpus before implementation and immediately before proof. No equivalent open change was found.

  • Related open PR scan: no open PR covers fleet CPU parsing or the parseCpus boundary.
  • Public contract surface: only the accepted syntax of the existing --cpus <count> CLI option changes; its default, positive fractional values, and downstream runtime object remain unchanged.
  • Out of scope: CPU range policy, container runtime validation, service API redesign, and profile persistence.

Merge risk

  • Why it matters / User impact: invalid input currently reaches the container runtime and produces a less actionable late error.
  • Risk labels considered: compatibility.
  • Risk explanation: JavaScript-only numeric forms are rejected; positive decimal and scientific finite-number inputs remain valid.
  • Why acceptable: Docker/Podman CPU syntax is decimal, and OpenClaw already documents the option as a CPU count.
  • Maintainer-ready confidence: High; the patch is limited to the CLI parser and its direct regression suite.
  • Patch quality notes: None.
  • Target test file: src/cli/fleet-cli/register.test.ts.
  • Root cause: the ingestion source of truth used Number(value) as a predicate, so it validated a broader grammar than the unchanged string later passed to the container runtime.
  • Why this is root-cause fix: the patch restores the invariant at the owning CLI normalization boundary; malformed syntax cannot become a runtime object or subprocess argument.
  • What did NOT change: fleet service behavior, container argument construction, CPU defaults, or runtime-specific handling.
  • Architecture / source-of-truth check: src/cli/fleet-cli/register.ts is the sole shipped production creator and owns the public option boundary; parseStrictFiniteNumber is the shared normalization contract.
  • Scenario locked in: --cpus 0x10 rejects; --cpus 1.5 remains accepted.
  • Why this is the smallest reliable guardrail: one shared-parser substitution and one table-driven regression case.

Real behavior proof

  • Behavior or issue addressed: hexadecimal CPU syntax passed CLI validation and reached a late container-runtime failure.
  • Canonical reachability path: user/input source (fleet create --cpus CLI token) → ingestion/normalization (Commander invokes parseCpus) → runtime object (FleetCreateOptions and CellContainerProfile) → request/effect (Docker/Podman subprocess receives the --cpus argument).
  • Boundary crossed: local-runtime; production fleet Commander registration and real local container runtime discovery were executed with an isolated state directory.
  • Shared helper / provider constraint check: reused parseStrictFiniteNumber; no provider-owned constraint applies.
  • Real environment tested: Linux x64, Node.js 22.22.0, current PR worktree, isolated OpenClaw state/config, local Docker discovery path.
  • Exact steps or command run after this patch: executed production registerFleetCli parsing for fleet create proof-tenant --cpus 0x10 --no-start, then repeated with fractional control --cpus 1.5.
  • Evidence after fix:
INVALID_INPUT=0x10
INVALID_EXIT=1
INVALID_OUTPUT=option --cpus argument 0x10 is invalid; --cpus must be a positive number
CONTROL_INPUT=1.5
CONTROL_OBSERVATION=fractional CPU input passed CLI validation and reached src/fleet/containers.runtime.ts
RESULT=hexadecimal CPU syntax stopped before fleet side effects while the fractional control retained the production runtime path
  • Observed result after fix: hexadecimal syntax stops in Commander parsing; the fractional control proceeds into the real fleet/container runtime.
  • What was not tested: a successful container create was not completed because the local Docker security-options response was incompatible with this checkout; Windows, macOS, and Podman were not tested.
  • Fix classification: Root cause fix.

Review findings addressed

No reviewer findings yet. Pre-submit review confirmed that fractional CPU values are an intentional control case, so the fix uses strict finite-number parsing rather than an integer-only parser.

Regression Test Plan

  • RED: the new 0x10 case resolved instead of rejecting on the pre-fix implementation.
  • GREEN: all 15 focused fleet CLI registration tests passed.
  • Focused oxfmt --check passed for both changed files.
  • Focused oxlint passed for both changed files.
  • Runtime proof covered hexadecimal rejection and fractional control behavior.

Risk / Compatibility

Low. The change removes accidental JavaScript coercion without narrowing documented positive fractional CPU values.

What was not changed

  • No fleet service or container runtime changes.
  • No CPU default or range changes.
  • No Docker/Podman command construction changes.
  • No dependency or schema changes.

Root Cause

The parser used Number(value) only as a predicate but returned the original string. For 0x10, the predicate saw the valid number 16 while the downstream runtime received the different token 0x10. Strict parsing at the external boundary keeps validation and transported syntax aligned.

This is not a downstream fallback: it fixes the source invariant where untrusted CLI text is converted into the trusted fleet runtime object. Once the token leaves that boundary as cpus: string, no later consumer can distinguish an intentionally supported value from syntax accepted only by JavaScript coercion.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes fleet size: XS labels Jul 12, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 5:39 AM ET / 09:39 UTC.

Summary
The PR changes fleet create --cpus to use the shared strict finite-number parser and adds regression coverage rejecting hexadecimal CPU input.

PR surface: Source +1, Tests +4. Total +5 across 2 files.

Reproducibility: yes. Current main deterministically accepts 0x10 through Number(value) and retains the original token for downstream container arguments; the PR body also supplies after-fix production CLI proof.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • [P2] No repair lane is needed; this correct implementation PR should remain open for ordinary maintainer merge review and exact-head checks.

Security
Cleared: The parser-and-test-only diff adds no dependency, workflow, secret, permission, package-resolution, downloaded-code, or execution surface.

Review details

Best possible solution:

Merge the focused CLI-boundary fix after normal exact-head checks, while leaving CPU storage and downstream container argument construction unchanged.

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

Yes. Current main deterministically accepts 0x10 through Number(value) and retains the original token for downstream container arguments; the PR body also supplies after-fix production CLI proof.

Is this the best way to solve the issue?

Yes. Reusing the existing strict finite-number contract at the sole public CLI ingestion boundary is narrower and more maintainable than adding runtime-specific validation or changing the stored CPU type.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cc3dfc9ded87.

Label changes

Label justifications:

  • P2: This fixes a bounded fleet CLI validation bug that otherwise turns invalid input into a late container-runtime error.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body shows after-fix production Commander parsing rejecting 0x10 before fleet side effects and a 1.5 control reaching the real fleet/container runtime path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body shows after-fix production Commander parsing rejecting 0x10 before fleet side effects and a 1.5 control reaching the real fleet/container runtime path.
Evidence reviewed

PR surface:

Source +1, Tests +4. Total +5 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 7 2 +5

What I checked:

  • Current-main bug is source-reproducible: parseCpus validates with Number(value) but returns the original string, so 0x10 passes as numeric value 16 while the hexadecimal token remains unchanged. (src/cli/fleet-cli/register.ts:31, cc3dfc9ded87)
  • Patch fixes the owning boundary: The PR replaces only the overly broad predicate with parseStrictFiniteNumber, retains the existing positive check and returned string, and adds a direct 0x10 CLI rejection case. (src/cli/fleet-cli/register.ts:33, 11b8a13a11b3)
  • Shared parser matches the intended contract: Existing tests accept decimal, fractional, and scientific tokens while explicitly rejecting 0x10 and partial numeric strings. (src/infra/parse-finite-number.test.ts:45, cc3dfc9ded87)
  • Downstream preserves the original token: Fleet profile validation separately coerces the CPU string with Number, then container argument construction passes profile.cpus unchanged to --cpus, confirming that strict syntax enforcement belongs before the runtime object is created. (src/fleet/cell-profile.ts:220, cc3dfc9ded87)
  • Docker parser contract inspected directly: Docker CLI resource option source parses CPU values through Go numeric parsers rather than JavaScript coercion; no dependency contract establishes bare 0x10 as supported CPU-count syntax.
  • Re-review continuity: The two changed files are identical between the previously reviewed SHA and current head; the later commit only merged main, so the prior empty finding set remains applicable. (src/cli/fleet-cli/register.ts:1, 11b8a13a11b3)

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-12T08:54:17.316Z sha 84db03e :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 12, 2026
@steipete
steipete merged commit 9ff25ca into openclaw:main Jul 17, 2026
119 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes fleet P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

2 participants