Skip to content

fix(claws): preserve ownership and recover partial installs - #163302

Closed
Patrick-Erichsen wants to merge 19 commits into
codex/claw-1093-v2-07-access-guardsfrom
codex/claw-1093-v2-09-recovery-adoption
Closed

Patrick-Erichsen wants to merge 19 commits into
codex/claw-1093-v2-07-access-guardsfrom
codex/claw-1093-v2-09-recovery-adoption

Conversation

@Patrick-Erichsen

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

Copy link
Copy Markdown
Contributor

Publication Refresh: October 7

Layer 7/16. Previous: #163300 | Next: #163303. Published checkpoint: 1b933f4f4899.

The stack now includes 45 previously local follow-up commits in four additional draft PRs, ending at #166801 (9e653a8ed286). Fresh combined-tip checks passed: 100 backend tests and 13 built-UI browser tests with a mocked Gateway. Before/after review captures are attached. Evidence below that names 6765a8741e4 remains historical evidence for that revision, not a new real-ClawHub run or per-layer CI result.

The stack remains draft and its first layer conflicts with current main. Reconciliation, exact-head CI/review, and the existing release gates remain outstanding. No merge or deployment is authorized by this publication.

What Problem This Solves

Interrupted installs and adopted agents can lose clear package ownership, making status, retry, or cleanup misleading.

User Impact

Partial Add remains recoverable; installed and adopted Claws show accurate status, including orphaned records. Add opens the agent's setup chat, while Remove discloses retained files/plugins and avoids guessing user file origin.

Why This Change Was Made

Gateway Update/Remove recheck live policy and authority; provenance keeps direct plugin, workspace, and ClawHub ownership separate from host model or delegation settings. The UI reconciles cards by package identity rather than only current agent metadata.

Evidence

Gateway worker, adopted ownership, package-ref, plugin trust, and Agents-status tests are included; pnpm check:changed passed at final stack tip 6765a8741e4. A source-host rehearsal added Research Briefing from local ClawHub, completed a real sourced chat task, then kept installed agents available with Labs off. Its reviewed Remove retained user-created files and Lobster while clearing the Claw-owned agent/resources. The installed-tarball host completed Add plus a real plugin-backed task, preserved chat/status with Labs off, and applied reviewed Remove; installed-CLI status then returned zero Claws. Inspected desktop/mobile Agents UI showed no Workflow card, while user-created task files and managed Lobster remained. A final packaged-host pass retained Project Manager after removing Workflow Operator and restarting the Gateway, with the Labs-off setting and user-file hashes unchanged.

Release gate: Land the OpenClaw stack together only after ClawHub #3883 and local publish-to-real-task lifecycle proof.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes size: XL labels Oct 2, 2026
@Patrick-Erichsen Patrick-Erichsen changed the title codex/claw 1093 v2 09 recovery adoption fix(claws): preserve ownership and recover partial installs Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Claws are installable agent packages; this branch improves partial-install recovery, preserves resource ownership, checks removal authority, and exposes orphaned installations in the Agents UI.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful recovery and ownership work has meaningful historical lifecycle evidence, but a retained defect and scoped authority/upgrade proof gaps prevent readiness.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Merge readiness

⛔ Blocked before merge - 9 items remain

This remains useful, distinct stack work. The prior Gateway-thread SQLite finding is still present, and final-effect authority and existing-state compatibility proof remain incomplete.

Priority: P2
Reviewed head: 1b933f4f48998024dd933c0ba098a62bc1665d5c

Before merge

  • Add real behavior proof - Authority-chain proof required: historical source-host and installed-tarball Add/task/Remove rehearsals support the allowed lifecycle path, but supplied evidence does not show non-admin and in-flight revoked callers rejected before final CLI removal I/O. Older-adoption digest compatibility remains unverified, and inspected later-stack dialog images do not cover this layer's changed UI. Add redacted terminal/log evidence and relevant screenshots, removing keys, private endpoints, IP addresses, phone numbers, and user data; update the PR body for automatic re-review, or ask a maintainer to comment @clawsweeper re-review.
  • [P2] Keep migration-state queries off the Gateway thread (P2) - The new policy getter calls readCurrentConfigForPolicyCheck, which synchronously reads deferred plugin migrations from SQLite. applyClawUpdateForGateway invokes this getter during initial planning and subsequent effect checks, so an ordinary Update can block the Gateway serving thread on database work. Prepare fresh migration facts through the worker-backed reader and consume them in synchronous guards without querying SQLite. This prior finding remains unchanged at the current head.
  • Resolve security concern: Verify revocation before child removal effects - Gateway authority reaches the child through polling and cancellation. Available tests establish signal propagation, not that a revoked caller is rejected before the child's next configuration, filesystem, or plugin removal effect.
  • Resolve merge risk - Prove that a non-admin caller and a caller revoked during removal cannot reach subsequent removal I/O through the real Gateway-to-CLI boundary; polling and mocked cancellation do not establish that guarantee.
  • Resolve merge risk - Verify older adopted ownership records across status, tool admission, Update, and ownership release while preserving operator model/delegation settings; changed persisted digest semantics lack complete upgrade evidence.
  • Resolve merge risk - Provide relevant inspected before/after UI evidence for orphaned installations, setup-chat navigation, and retained-plugin removal disclosure; the supplied later-layer dialog captures cover different changes.
  • Resolve merge risk - The stack owner must reconcile the conflicting stack base, propagate repairs, and satisfy the recorded ClawHub and publish-to-real-task gates before landing; later-tip checks do not validate this layer's current merge result.
  • Complete next step - Have the stack owner coordinate the retained policy-reader repair and base reconciliation, propagate changes through dependent layers, and satisfy the recorded landing gates.
  • 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

  • [P2] [P2] Keep migration-state queries off the Gateway thread — src/gateway/server-methods/claws-lifecycle.ts:129
  • [medium] Verify revocation before child removal effects — src/claws/gateway-remove-apply.ts:146
Agent review details

How this fits together

Claws lifecycle operations turn reviewed package plans into agent configuration, workspace files, plugins, and scheduled jobs. SQLite ownership records support subsequent status, recovery, updates, and removal through the CLI and Gateway.

flowchart TD
A[Package and operator settings] --> B[Reviewed lifecycle plan]
B --> C[Live authority and ownership checks]
C --> D[CLI and worker operations]
D --> E[Agent resources]
D --> F[SQLite ownership records]
F --> G[Agents status and recovery]
Loading

Technical review

Best possible solution:

Keep one lifecycle owner that preserves operator-owned settings, reports recoverable partial state, and fences every removal effect with current request authority.

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

Yes, from source: Gateway Update calls a synchronous policy getter that queries SQLite migration state on the serving thread. Runtime tests were not executed under this read-only review.

Is this the best way to solve the issue?

Partly: reusing lifecycle and ownership owners is appropriate, but the policy getter must use worker-prepared migration facts, and the composed removal boundary needs final-effect authority proof.

Full review comments:

  • [P2] [P2] Keep migration-state queries off the Gateway thread — src/gateway/server-methods/claws-lifecycle.ts:129
    The new policy getter calls readCurrentConfigForPolicyCheck, which synchronously reads deferred plugin migrations from SQLite. applyClawUpdateForGateway invokes this getter during initial planning and subsequent effect checks, so an ordinary Update can block the Gateway serving thread on database work. Prepare fresh migration facts through the worker-backed reader and consume them in synchronous guards without querying SQLite. This prior finding remains unchanged at the current head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Repair and validate through the stack owner (recommended)
    Move migration-state reads off the Gateway thread, propagate the repair through dependent layers, and supply final-effect authority, existing-state, and relevant UI evidence.

Security

Needs attention: No unrelated supply-chain execution change was found, but the cross-process removal authority boundary still needs final-effect verification.

Evidence

Security concerns:

  • [medium] Verify revocation before child removal effects — src/claws/gateway-remove-apply.ts:146
    Gateway authority reaches the child through polling and cancellation. Available tests establish signal propagation, not that a revoked caller is rejected before the child's next configuration, filesystem, or plugin removal effect.
    Confidence: 0.92

What I checked:

  • Pinned introduction and clean checkout: Reviewed the introduced delta from 513f3cf to the exact original head. The checkout remained clean. The supplied test merge is stale and cannot establish what merging would remove from current main. (1b933f4f4899)
  • Prior finding remains: Gateway Update still passes readCurrentConfigForPolicyCheck as its policy getter. That reader synchronously calls readDeferredPluginMigrations, which opens SQLite and queries migration_runs. The handler has no changes relative to the previously reviewed head. (src/gateway/server-methods/claws-lifecycle.ts:129, 1b933f4f4899)
  • Policy-reader implementation: The synchronous reader obtains fresh migration rows directly; separate asynchronous and prepared-migration readers already exist. Gateway Update invokes the synchronous getter repeatedly during planning and effect checks. (src/config/io.runtime.ts:257, 1b933f4f4899)
  • Authority boundary and supplemental tests: Removal now polls Gateway authority every 50 milliseconds and forwards cancellation to a child CLI, whose SIGTERM listener stops forward effects. The Gateway test mocks the child runner, and the CLI test invokes the listener directly; neither establishes rejection before final removal I/O through the composed production boundary. (src/claws/gateway-remove-apply.ts:125, 1b933f4f4899)
  • Persisted ownership compatibility: Adopted-agent status, Update planning, and tool consent now accept ownership digests that exclude operator model and delegation settings while retaining legacy full-digest reads. Source and regression tests support the intended compatibility path, but the captured publication does not provide an older-adoption upgrade result covering those consumers. (src/claws/tool-policy-runtime.ts:82, 1b933f4f4899)
  • Inspected visual evidence has narrower coverage: Both prepared images were inspected locally. They show the before/after synthetic manifest-review dialog from fix(claws): review verified manifests and respect host plugin policy #166798, with the after image including grouped manifest and artifact facts. They do not demonstrate this layer's orphaned-install attention section, setup-chat transition, or retained-plugin removal disclosure. (ui/src/pages/agents-home/view.ts:170, 1b933f4f4899)

PR surface

Source +853, Tests +2326, Docs 0. Total +3179 across 73 files.

View PR surface stats
Area Files Added Removed Net
Source 41 1101 248 +853
Tests 31 2477 151 +2326
Docs 1 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 73 3583 404 +3179

Review metrics

Metric Value Why it matters
Production versus test growth production net +853 lines; tests net +2,323 lines Production growth serves ownership fencing, partial recovery, and orphaned-install UI; the larger test delta provides supplemental regression coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded lifecycle reliability work within an experimental dependent stack, without evidence of an urgent released regression.
  • merge-risk: 🚨 compatibility: Adopted ownership digest interpretation changes, and unsupported cron provenance now blocks lifecycle operations.
  • merge-risk: 🚨 security-boundary: Gateway authority crosses into a mutating CLI child, and revocation-before-final-effect coverage remains incomplete.
  • merge-risk: 🚨 availability: The introduced synchronous policy getter queries SQLite during Gateway Update and can block the serving thread.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Repair the policy getter and verify Gateway Update performs no main-thread SQLite queries.
  • Prove non-admin rejection and in-flight revocation before final removal I/O through the real Gateway and CLI owners.
  • Provide older-adoption upgrade results and inspected before/after captures for this layer's changed UI.

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-02T06:15:53.431Z sha 4a683a0 :: needs real behavior proof before merge. :: [P2] [P2] Keep migration-state queries off the Gateway thread
  • reviewed 2026-10-02T11:08:35.688Z sha 4a683a0 :: needs real behavior proof before merge. :: [P2] [P2] Keep migration-state queries off the Gateway thread

Reviewed October 7, 2026, 7:25 PM ET / 23:25 UTC (Revision 3).

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Closing as superseded: #171623 replaced the Claws plan/review/update/remove lifecycle with a one-way Add operation, and main no longer has the lifecycle modules this layer changes. Any hardening here that still matters should be redone against the new Add flow.

Closed by Roboclaw at the author's request after an audit of his open PRs. The branch is kept, so this can be reopened if needed.

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 cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants