Skip to content

feat: save suggested cloud profiles on first use - #170875

Merged
steipete merged 2 commits into
mainfrom
snap/default-cloud
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
snap/default-cloud

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

What Problem This Solves

New Session requires a manually configured cloud-worker profile even when Crabbox on the Gateway host already has a configured backend or coordinator login.

Solution

Expose one separate suggestedProfile through environments.list. Crabbox discovers it through a manifest-declared lightweight artifact with lifecycle-owned caching; its provisioning plugin retains onStartup: false.

Selecting Cloud calls the admin-only environments.adoptSuggestedProfile method. Adoption refreshes discovery, saves cloudWorkers.profiles.cloud through the normal config.patch validation/concurrency/reload path, and returns the configured summary. Existing cloud profiles are returned untouched. Suggestions never enter dispatch, repository defaults, retention, or Doctor as virtual profiles.

The picker shows one Cloud item and provider icon. Saving errors use the existing error surface. Pending adoption cannot submit a session or overwrite a newer selection. Config publication retains live request authority.

The CI repair regenerates the Crabbox reference through pnpm plugins:inventory:gen, shares the catalog fixture without an unsafe array access, preserves real exports in four partial mocks, and removes the UI type-import cycle through the existing draft-place contract owner. No guard, budget, or mock baseline was changed.

Impact

Administrators can pick Cloud in New Session without writing a profile first. The saved profile uses Linux, the smallest advertised canonical class, an eight-hour TTL, 45-minute idle timeout and suspend, and warm images. Explicit profiles suppress the suggestion.

Updates need no migration or database changes. Adopted profiles use existing public configuration keys and reload behavior. Discovery verifies configured inputs; allocation retains its live preflights. Integrated AWS proof remains outside this lane.

Evidence

Rebased onto db87a3b6364584c0667bd527298e5a91fd836bac, including the landed Crabbox provider/profile changes. Each comparison below ran separately in the same worktree, first on pinned main and then on the rebased branch. Wall times include shared-host contention and compiler preparation.

Exact command Pinned main Rebased branch
pnpm test src/gateway/server.sessions.archive-worker-placement.test.ts --maxWorkers=1 10 passed; 352.21s 10 passed; 444.86s
pnpm test src/gateway/server.sessions.create.titles.test.ts --maxWorkers=1 6 passed, 2 failed; 195.26s 6 passed, 2 failed; 172.86s
pnpm test src/gateway/server.chat-steer-direct-command.test.ts --maxWorkers=1 2 passed; 135.36s 2 passed; 118.64s

The title failures are pre-existing: both revisions reproduce sessions.create preserves background title recovery after generator error and ... after delayed title, with the same assertion as CI: the mock expected no call but received one call. Their owner is unchanged. The archive and steering shard failures did not reproduce in either isolated comparison; these passing replays are not presented as fixes for the original failures.

Failed checks repaired and rerun:

  • pnpm tsgo:extensions:test — passed, 46.20s.
  • pnpm tsgo:test:ui — passed, 527.43s, including artifact-lock wait.
  • pnpm check:test-mock-exports --base db87a3b6364584c0667bd527298e5a91fd836bac — passed, 136.39s; baseline unchanged at 9709 grandfathered factories.
  • pnpm check:madge-import-cycles — passed, 259.29s; zero cycles.
  • pnpm plugins:inventory:check — passed, 1.17s; generator changed only the Crabbox Contracts line.
  • Formatting for all six repaired files — passed, 2.31s. git diff --check passed.
  • Core/UI scoped lint — passed, 126.86s, including artifact-lock wait:
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/server-methods/environments.suggested-profile.test.ts src/gateway/server-methods/environments.test.ts ui/src/pages/new-session/draft-place-contract.ts ui/src/pages/new-session/draft-suggested-cloud-profile.ts

The initial mixed core/extension scoped lint attempt stopped before linting: plugin SDK declaration preparation hit its unchanged 300000ms timeout (356.95s wall). Extension lint remains for PR CI; no timeout or artifact guard was bypassed. A fresh independent Codex review of the repair was scoped clean through P2.

Original feature proof, before this rebase (head b57b6eb1d3a032386fdf9901392d5b8c89c93507)

165 passed and one existing platform skip in 148.30s:

pnpm test src/gateway/server-methods/config.test.ts src/gateway/server-methods/environments.suggested-profile.test.ts extensions/crabbox/src/crabbox-worker-profile-suggestion.test.ts extensions/crabbox/src/crabbox-worker-provider.test.ts src/plugins/worker-profile-suggestions.test.ts packages/gateway-protocol/src/schema/environments.test.ts ui/src/pages/new-session/where-chip.test.ts ui/src/pages/new-session/suggested-cloud.test.ts --maxWorkers=1

Picker browser proof: two passed in 40.24s, including UI build:

OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/new-session-page.suggested-cloud.e2e.test.ts

The original full build passed in 6047.42s, with an identity-qualified cached refresh in 823.99s. Qualified Crabbox cold import passed in 16.82s, with 196.3 MB peak RSS. These are prior-head results; broad builds and suites were not repeated for the CI repair. The repair changes no visual behavior, so the inspected captures remain applicable.

Release-note context

New Session can discover a configured Crabbox backend and save a Cloud profile on first selection, removing the need to hand-author cloud-worker configuration. Existing profiles and admin authority remain canonical.

Before: no Cloud option without a configured profile

After: Cloud suggestion in the New Session picker

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-13T10:52:00.047689Z 6c83fe0 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime extensions: crabbox size: XL labels Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 6c83fe0803e47d9aac5b8c0abb6c2f08499a3c2d
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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: b57b6eb1d3

ℹ️ 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".

Comment on lines +65 to +68
const suggestion = await resolveSuggestedWorkerProfile({
config: snapshot.config,
refresh: true,
});

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 Bind adoption to the suggestion the user selected

When multiple eligible workerProfileSuggestions owners exist, the list can display owner B because owner A currently returns no suggestion, but adoption carries no suggestion identity and this fresh resolution can select A if its state has changed. The handler then persists A's profile even though the operator selected B, potentially routing a later paid worker dispatch through an unexpected backend; carry an owner/profile token from listing into adoption and reject a mismatch.

AGENTS.md reference: src/gateway/AGENTS.md:L22-L25

Useful? React with 👍 / 👎.

Comment on lines +83 to +88
return ({ refresh }) => {
if (refresh || !cached) {
cached = discover().catch((error: unknown) => {
dependencies.warn(`Crabbox profile discovery unavailable: ${String(error)}`);
return undefined;
});

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 Allow recovery after negative profile discovery

If the first discovery runs before Crabbox is configured, while its CLI is temporarily unavailable, or before a Linux class is advertised, this caches a promise resolving to undefined permanently. Subsequent catalog refreshes reuse that negative result, while the only caller passing refresh: true is the adoption RPC—which the UI cannot invoke because no suggestion is visible—so fixing the Crabbox setup does not expose Cloud until the Gateway restarts. Avoid permanently caching negative results or provide an independently reachable refresh path.

AGENTS.md reference: AGENTS.md:L78-L80

Useful? React with 👍 / 👎.

@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: 6b67e804e8

ℹ️ 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".

refresh: true,
});
authority.assertCurrent();
if (!suggestion || suggestion.id !== "cloud") {

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 Honor profile IDs allowed by the suggestion contract

A plugin can validly return any non-empty SuggestedWorkerProfile.id, and environments.list advertises that ID, but adoption rejects every ID except cloud. A third-party plugin returning a conforming suggestion such as gpu therefore presents a selectable item that always fails with UNAVAILABLE; either constrain the public type/schema/docs to the literal cloud or persist and return the refreshed suggestion under its declared ID.

AGENTS.md reference: src/plugins/AGENTS.md:L25-L29

Useful? React with 👍 / 👎.

);
}
const profiles = await listWorkerProfilesWithMachines(context);
const suggestedProfile = await listSuggestedWorkerProfile(context);

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 Skip admin-only discovery for non-admin list calls

When no cloud profiles exist, every first environments.list call awaits suggestion discovery before responding, even for read-only callers that cannot invoke the admin-only adoption method. On a host with an installed but hung Crabbox binary, this runs config show with its 60-second timeout and stalls the otherwise unrelated environment/device catalog; check admin scope before discovery so non-admin reads remain independent of this optional setup probe.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit febccf6 into main Oct 13, 2026
168 of 172 checks passed
@steipete
steipete deleted the snap/default-cloud branch October 13, 2026 11:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged with a pinned-head REST squash on 6c83fe0803e47d9aac5b8c0abb6c2f08499a3c2d; lead review and autoreview were clean.

The only red was checks-node-changed-compact-small-2-1 (shard agentic-control-plane-runtime-state-hosted-3, run 38385657488), which openclaw/ci-gate aggregates. It is inherited and load-sensitive, not caused by this PR:

  • Replaying the exact 21-file shard plan locally through scripts/ci-run-node-test-shard.mts gave identical results on this head and on main ffa6ea28bd19: the same two timeouts (server.worker-placement-startup-context.test.ts, server.required-worker-profile.public.test.ts) on both revisions, and all five files from the CI cascade passing on both.
  • With a logging crabbox stub first on PATH, the implicated gateway tests never invoked the Crabbox CLI, including when the stub slept 20 s, so the new suggestion discovery does not run in those paths.
    Earlier package-boundary and UI e2e failures were resolved by rebasing onto main.

steipete added a commit that referenced this pull request Oct 14, 2026
Shares the snapshot status rule between repository summaries and snapshot rows, and shares unassigned-preparation eligibility between repository grouping and unlabeled builds. Removes duplicate label arguments, a redeclared action props type, naming-only accessors, an input-only form-control helper, singleton fragments and consecutive store updates. Net production change: -41 lines across four Control UI files. No user-visible behavior change.

Related: #170892, #170895, #170875, #171176
Refs: #171684
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
Cloud is available in New Session without hand-writing a profile. When no cloud worker profiles exist and the Crabbox CLI on the Gateway host reports a usable provider, environments.list carries one non-dispatchable suggested profile discovered through a cached, manifest-declared Crabbox discovery path. Picking Cloud calls the new admin-only environments.adoptSuggestedProfile, which writes cloudWorkers.profiles.cloud through the normal config.patch owner (snapshot CAS and live-authority checks) and then selects it like any configured profile. Existing cloud profiles are returned untouched; dispatch, repository defaults and Doctor read only real config.

The saved profile uses Linux, the smallest advertised standard class, an 8 h lifetime, 45 min idle and suspend defaults, and warm images on.

Refs: openclaw#170875
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
Shares the snapshot status rule between repository summaries and snapshot rows, and shares unassigned-preparation eligibility between repository grouping and unlabeled builds. Removes duplicate label arguments, a redeclared action props type, naming-only accessors, an input-only form-control helper, singleton fragments and consecutive store updates. Net production change: -41 lines across four Control UI files. No user-visible behavior change.

Related: openclaw#170892, openclaw#170895, openclaw#170875, openclaw#171176
Refs: openclaw#171684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: crabbox gateway Gateway runtime security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant