Skip to content

feat(claws): add local packages through the gateway and preserve setup - #174959

Closed
Patrick-Erichsen wants to merge 7 commits into
mainfrom
claw-local-package-install
Closed

Patrick-Erichsen wants to merge 7 commits into
mainfrom
claw-local-package-install

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Integrations cannot add a converted local Claw package through a running gateway: the gateway Add API only accepts ClawHub coordinates, while an offline writer cannot mutate live gateway state.

User Impact

An admin-authorized client can plan and add an absolute local package path on the gateway host. Installation uses the existing Claw checks, lifecycle, plugin consent, integrity validation, and rollback. Retrying an installation that rolled back before agent creation preserves its first-run instructions. Imported memory and skills no longer cause the first turn to discard custom setup instructions.

Why This Change Was Made

The source adapter feeds the existing Add owner:

local package or ClawHub coordinate
  → resolve and inspect
  → plan + integrity check
  → native Add lifecycle

Local planning and application require operator.admin. Remote clients must transfer their package to the gateway host first. Rollback retires the existing workspace setup state along with a workspace it created and removed.

Evidence

  • Before: local source payload rejected by the gateway schema. After: an actual handler test installs instructions, the exact avatar bytes, and BOOTSTRAP.md as an ordinary agent.
  • Before: failed Add → rollback → retry reports complete but omits BOOTSTRAP.md. After: the same actual-handler regression preserves the setup file.
  • Regression coverage follows native Add through first-turn workspace preparation: imported memory and skills preserve a custom BOOTSTRAP.md; stock-template cleanup and explicit completion retain their existing behavior.
  • Focused plan/apply, authorization, stale-source, schema, plugin handoff, and stateless rollback tests pass. Core type graphs, boundary checks, targeted lint and formatting pass.
  • The full build passes, including CLI startup and plugin SDK export checks.
  • Live isolated gateway proof at combined stack head e33e4d5ca2b: a fresh Stalk Bot installation completed a real agent turn with all 236 characters of custom setup instructions and 3,459 characters of memory injected without truncation. The setup file remains after the turn.
  • Real WebSocket authorization regression passes for local packages: admin installation succeeds, nonadmin plan/apply is rejected, and real device-token revocation at the pre-effect gate prevents agent creation and plugin publication. The catalog positive control remains covered. No authority predicate is mocked; assertions cover agent configuration, installed-plugin records, and extension directories.
  • Final setup regression and existing workspace sibling cases: 53 tests passed. Final runtime build passed; private workspace-logic changes do not alter the declaration/SDK export surface checked by the preceding full build.

Merge risk: reversible code change; affects the Claw Add source boundary and cleanup of newly created workspaces. Existing ClawHub behavior remains covered.

Prior-head CI blocker: the unchanged updater mock check also fails on scheduled main; the native classifier marks it pre-existing. That aggregate remains red; no exception or unrelated fix is included. The conflict-only stack restack onto acd27635 preserves all three core patches exactly; current-head CI must run separately.

Additional private-QA full-build check: SDK declarations exceed the private testing budget. An isolated captured-main build produces the same 456 public-reachable declaration files byte-for-byte (5,440,829 bytes versus the 5,340,536-byte cap). No budget change or unrelated repair is included. Runtime/UI artifacts were generated; the full command is recorded as failed.

Compatibility evidence is scoped to the existing state contract and production boundaries. Compared directly with v2026.10.4, setup state remains version 1, WorkspaceSetupState fields are identical, and the complete workspace_setup_state SQL definition is byte-identical. The PR changes no persisted schema or config format. Existing completed state skips reconciliation; rollback cleanup only retires a newly created, uncommitted workspace. The 48 passing workspace cases plus 5 native Add cases cover retained completed timestamps/content, stock cleanup, concurrent completion, custom pending setup, and explicit completion. This is not a claim that a full product upgrade was executed.

Paired saved runtime proof: before the setup fix (5ffb1320fcc), bootstrapExists=false and bootstrapInjected=false; after (e33e4d5ca2b), BOOTSTRAP.md injected 236/236 characters without truncation and remained present after the turn. The baseline predates the fix; it is not an exact current-merge-base replay.

Main refresh (2026-10-27)

Merged current main (cfccaef15a4) into this branch instead of rebasing, so the stacked #174960 keeps its history. Conflicts were resolved against main's publisher package names, Claw drafts, workspace attestation hashes, and rollback effect leases; the gateway validators were regenerated.

Main's Gateway Add now holds plural state leases (#184784), but its bootstrap setup-state write still requested generic worker admission, so lease admission refused every Claw that ships BOOTSTRAP.md ("State lease worker ownership was refused"). 8d64690136b passes the held lease identities to the worker and asserts them inside the transaction, as worktree capacity does. The existing local Add handler test fails on the unfixed code and passes with the fix; it now confirms the Gateway config-write application, which main's Add requires.

Local proof on ed5ea8ff143: 14 focused test files pass (Claw Add plan/apply/stateless/manifest, local handler, Gateway method scopes, workspace and bootstrap, agent creation, state-lease transactions; 2m17s wall with --maxWorkers=1); tsgo:core, core src test types, oxlint, oxfmt, protocol:check, and gateway:validators:check pass. The real-Gateway e2e was not rerun locally; PR CI covers it.

Upgrade compatibility after the refresh (ClawSweeper's data-model request): the PR's diff against main touches no persisted schema, migration, config, or Doctor file. Its only schema change is the Gateway wire protocol (Add request params and the plan-response manifest disclosure), which is not stored. Lease identities travel only in the in-process worker command. The workspace_setup_state table and WorkspaceSetupState shape belong to main and this PR leaves them unchanged. Existing completed setup still skips reconciliation; a never-completed workspace with a custom BOOTSTRAP.md now stays pending until setup completes, which is the intended fix.

@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@Patrick-Erichsen Patrick-Erichsen changed the title claw local package install feat(claws): add local packages through the gateway and preserve setup Oct 17, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper autofix

@github-actions

github-actions Bot commented Oct 17, 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: ed5ea8ff1438a37a5c85205f38b19620b90146f8
  • Maintainer: @Patrick-Erichsen
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/method-scopes.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • 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.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

@clawsweeper autofix is retired; ClawSweeper now only reviews.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 17, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

The required CI aggregate is currently blocked by the unchanged updater mock at src/cli/update-cli/update-command-service-maintenance-native.test-support.ts:52 (./update-command-database-context.js). All other selected CI lanes passed.

The native failure classifier marks this pre-existing. Independently, the scheduled main run at 8919729f0484e743af1a956f20f880bdba79a185 has the identical failure signature. The PR failing lane and required aggregate remain red; this is not a claim of green CI.

The first-turn native setup regression passes locally with 53 gateway/workspace tests, and live final-stack proof confirms custom setup and memory injection. No unrelated updater change or baseline exception is included. ClawSweeper review remains queued; its router reports that autofix is retired.

@Patrick-Erichsen
Patrick-Erichsen force-pushed the claw-local-package-install branch from e9e3c58 to e3caab2 Compare October 17, 2026 02:14
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds admin-authorized local Claw sources to Gateway Add and preserves first-run setup through rollback and workspace preparation.

Example: An administrator adds the package at /srv/claws/research-bot with custom BOOTSTRAP.md instructions.

  • Before: Gateway Add rejects the localPath source, and imported memory can cause custom setup instructions to be discarded.
  • After: Gateway Add creates an ordinary agent and retains its custom setup instructions until setup is explicitly completed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused implementation with meaningful runtime and authority evidence; upgrade compatibility remains unqualified.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Integrations cannot install a local Claw package through a running Gateway, and imported content can suppress required first-run setup.
Reason: The maintainer-directed capability fills a concrete transport gap while reusing the existing Add lifecycle and its security boundaries.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-directed PR adds a useful Gateway capability that current main lacks; no introduced code defect was identified.

Priority: P2
Reviewed head: ed5ea8ff1438a37a5c85205f38b19620b90146f8

Before merge

  • 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

None.

Tests

  • Missing end-to-end proof: Supply a redacted upgrade run from v2026.10.7 showing existing settings and completed/pending workspace setup remain intact.
Agent review details

How this fits together

Gateway plan/apply RPCs resolve a Claw source, review its resources and permissions, and invoke the existing Add lifecycle to create ordinary agents, workspace files, and dependencies.

flowchart TD
  A[Admin RPC client] --> B[Gateway authority checks]
  B --> C[Local or ClawHub source]
  C --> D[Existing Add planning and consent]
  D --> E[Native Add lifecycle]
  E --> F[Agent configuration and workspace]
  E --> G[Worker owned setup state]
Loading

Technical review

Best possible solution:

Extend the existing Gateway Add source boundary while retaining native consent, integrity checks, lease authority, rollback, and workspace setup ownership.

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

Current-main schemas establish the missing local-source path, and source inspection explains premature custom-bootstrap completion; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is a focused extension of existing owners, with no parallel installer, new persistent model, or unnecessary production machinery identified.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Gateway Claw source admission changes intended behavior with a stated reason (db0d3d0: Published ClawHub coordinates supplied the transport foundation for ordinary-agent Add.)
  • One-way Add lifecycle and rollback keeps the original intent (81662c5: Create ordinary resources without restoring an installed-Claw lifecycle; ordinary resource owners retain subsequent management.)
  • Automatic stale-bootstrap completion changes intended behavior with a stated reason (137f5c3: Prevent repeated onboarding when profile edits show completion but the model leaves the stock bootstrap file behind.)
  • Worker-held lifecycle leases keeps the original intent (71eacdf: Move runtime lease verification into existing workers while retaining original authority through publication and rollback.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still lacks local Gateway sources: The fetched main schema accepts only ClawCatalogCoordinateSchema for Add planning and application; the PR introduces the localPath alternative. (packages/gateway-protocol/src/schema/claws.ts:203, 7058d9e0dff2)
  • Existing source and lifecycle owners are reused: The adapter requires an absolute host path, uses the canonical manifest reader, and feeds existing planning, consent, integrity verification, and application owners. (src/claws/gateway-add-source.ts:23, ed5ea8ff1438)
  • Authority reaches the effect boundary: Local previews require admin authority before preparation and before disclosure; application retains the existing live-client guard, and bootstrap worker transactions check the complete held lease set at transaction and commit admission. (src/claws/add-state.worker.ts:20, ed5ea8ff1438)
  • Distinct authorization and setup regressions: The real-WebSocket suite covers admin success, read-only plan/apply rejection, and actual device-token revocation before plugin publication; the handler suite checks installed bytes, first-turn setup injection, stale-source rejection, explicit completion, and rollback retry. (src/gateway/server-claws-add-authority.e2e.test.ts:391, ed5ea8ff1438)
  • Original bootstrap repair intent: fix(agents): repair stale bootstrap completion #71230 introduced stale-bootstrap completion repair; this PR deliberately limits automatic cleanup to stock onboarding instructions while preserving custom package setup. (src/agents/workspace.ts:326, 137f5c3a8b3c)
  • Published runtime evidence and its limits: The author reports a real Gateway turn retaining all 236 setup characters and 3,459 memory characters, plus successful WebSocket authorization proof. Both prepared screenshots were inspected; the imported-agent screenshot supports identity and response behavior but does not independently show setup injection. The PR explicitly states that no full product upgrade was executed.

PR surface

Source +166, Tests +279, Docs +17. Total +462 across 19 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 14 1095 929 +166
Tests 4 290 11 +279
Docs 1 17 0 +17
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 1402 940 +462

Review metrics

Metric Value Why it matters
Production versus test changes Production +200/-62; tests +290/-11, excluding generated validators and documentation. Growth supplies the local-source adapter, shared authority checks, lease handoff, and distinct installation, rollback, and authorization regressions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Adds a bounded integration capability and repairs first-run setup preservation without evidence of an urgent released-user outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate latest-stable upgrade preservation through the affected workspace setup owner.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-17T02:29:38.967Z sha e3caab2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-17T02:50:23.851Z sha 50f3ddd :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 11:10 PM ET / October 27, 2026, 03:10 UTC (Revision 3).

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

The requested local-source authority proof is now published at 50f3ddd2761. The standard real-WebSocket Gateway test passes (37.65s test body; 103.82s including preparation): admin local installation succeeds; read-only local plan/apply is rejected; actual device-token revocation and connection closure prevent pending agent creation and plugin publication. Assertions inspect agent config, installed-plugin records, and extension directories. They do not claim absence of all temporary writes. Types, lint, formatting, and diff checks pass. Production code is unchanged by this follow-up.

For the compatibility request, I compared the actual v2026.10.4 source with the candidate: setup version 1, WorkspaceSetupState fields, and the full workspace_setup_state SQL definition are identical. The PR changes no stored schema or config format. Existing completed state skips reconciliation; rollback affects only a newly created, uncommitted workspace. The previously passing 48 workspace cases and 5 native Add cases cover retained state/content, pending/completed setup, and retry. A full product-upgrade exercise would test broader upstream changes, so this evidence is explicitly scoped to the stable-state contract and the affected production owners.

Saved real before/after receipts also qualify the setup behavior: pre-fix 5ffb1320fcc had bootstrapExists=false and bootstrapInjected=false; post-fix e33e4d5ca2b injected all 236 setup characters without truncation and retained the file after the turn. This is a real pre-fix runtime baseline, not an exact current-merge-base replay.

The PR body now records this proof and its limits. Current-head CI is running; prior-head CI passed all selected lanes except the separately proven upstream mock-exports failure. The private-QA declaration budget failure is also inherited: a separate captured-main build produced the same 456 public declaration files byte-for-byte. No budget or authority checks were weakened.

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 17, 2026
roboclaw-bot and others added 3 commits October 27, 2026 02:57
Resolve conflicts with the publisher-name catalog, Claw drafts, workspace
attestation hashes, and rollback effect leases on main.

Co-authored-by: Patrick-Erichsen <[email protected]>
Gateway Add runs bootstrap setup-state writes through its plural state
leases, but the worker requested generic admission, so lease admission
refused every Claw that ships BOOTSTRAP.md. Pass the held lease identities
to the worker and assert them inside the transaction, as worktree capacity
does.

Co-authored-by: Patrick-Erichsen <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants