Repository navigation
fix(plugins): prevent stale credential reads and stuck cleanup on reload - #153187
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 24, 2026, 6:01 PM ET / 22:01 UTC (Revision 19). ClawSweeper reviewWhat this changesThe branch binds prepared credential reads to an active plugin instance, lets decision-provider calls settle independently of disposal, documents the SDK behavior, and updates lifecycle and test fixtures. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful work: current main still permits plugin-ID-only prepared credential reads and retains the decision-host disposal wait. The patch has no definite introduced defect, but its intentional public SDK behavior change needs attributable owner confirmation, and the security-sensitive change needs approval for this head. Priority: P2 Review scores
Verification
How this fits togetherThe plugin runtime prepares credentials and admits provider calls for the Gateway. Reload retires an instance while in-flight calls settle, then a replacement instance can serve new requests. flowchart LR
A[Prepared credential snapshot] --> B[Plugin invocation]
B --> C{Instance still accepting?}
C -->|Yes| D[Credential read]
C -->|No| E[Unavailable result]
D --> F[Decision provider]
F --> G[Result or retirement]
Decision needed
Why: The change is intentional and documented, but it can alter existing plugin behavior; the claimed owner acceptance is from a separate discussion rather than an attributable decision on this PR. Before merge
Agent review detailsSecurityNone. PR surfaceSource +52, Tests +371, Docs +5. Total +428 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep exact-instance credential authority and physical decision settlement if the SDK owner accepts immediate revocation; record that contract decision and obtain current-head security approval before merging. Do we have a high-confidence way to reproduce the issue? Yes, from source and the recorded earlier boundary runs: main admits a plugin-ID-only read, and the PR's loaded-plugin and Gateway reload scenarios exercise retirement and replacement. I did not execute the current head. Is this the best way to solve the issue? Yes, conditionally: the patch repairs authority at the credential owner and settlement at the decision host without a second credential store. The public callback contract needs owner confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8feac27a59f8. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (18 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
✅ Maintainer security changes approvedA maintainer approved this revision with an explicit security approval comment.
A later push requires a fresh approval comment for an external contributor's PR. |
abc6a1e to
2e838e7
Compare
2e838e7 to
96f24c2
Compare
4732826 to
6343528
Compare
Fence prepared capability reads to the exact live plugin instance and release decision-provider leases independently from disposal cleanup. Co-authored-by: jalehman <[email protected]>
Co-authored-by: jalehman <[email protected]>
Co-authored-by: jalehman <[email protected]>
Co-authored-by: jalehman <[email protected]>
Keep ordinary non-joining calls separate from cleanup admission, so forced retirement revokes their results and nested callbacks. Recheck the decision owner before accepting provider output when a sibling delays host shutdown. Preserve cleanup producers, host-error attribution, and physical settlement. Retain the runtime-frame reload regression now repaired by upstream openclaw#155925. Co-authored-by: jalehman <[email protected]>
Let the history fixture drain admitted work and close its native owners before resetting the task registry. Preserve the restored environment by resetting process state without clearing persistence. A timerless native-borrow regression fails the previous ordering. Join the existing maintenance finalization receipt before the fork fixture checks stale-session removal instead of imposing a five-second worker-startup deadline. Keep the real deletion, fork, transcript, and authority assertions unchanged. Co-authored-by: jalehman <[email protected]>
Reuse the CI-only fixture repairs from 8a53ee3 without its unrelated activation changes. Preserve the canonical catalog completion waits and direct read-context owner. That upstream work is credited to PollyBot13 and Patrick Erichsen. Join asynchronous home database retirement before the task registry performs its synchronous close, and retain a real read until its async cleanup owner releases it. Keep live shared-server teardown unchanged. Seed task-page fixtures through one real in-memory backing store and make their during-scan injection one-shot. Preserve authorization, churn, pagination and yield-budget assertions, and verify writes survive backing reads. Consume complete codesign output under pipefail instead of stopping grep after its first match. Keep strict signature verification, Developer ID, team, app identity and GUI ownership checks unchanged. Exercise both large valid signature orders and precise denial causes. Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
Merged short-route resolution combined plain cached/revalidated results with RPC results carrying an owner predicate. The plain union absorbed the richer shape, so checking for isCurrent narrowed that property to unknown and broke all five core test-type CI stripes. Carry each selected resolution's existing owner predicate alongside its data and consume it directly. Cached/revalidated paths keep their existing owner; RPC/prepared paths retain the post-hello connection and retirement checks. Validation: reproduce TS2322 through the exact UI-e2e tsgo graph on clean main (52.01s), then pass the same graph after repair (52.15s). All 82 existing route ownership, cold boot, cache, identity, and handoff tests pass (3.35s wrapper). Formatting, typed lint, diff checks, and independent P2 review pass. No tests added. Repairs the main failure seen in CI run 35828176263. Co-authored-by: jalehman <[email protected]>
Co-authored-by: jalehman <[email protected]>
Carry the canonical test-only extraction from 3a5709f to resolve the actual conflict with main. Preserve the announcement-entry signal, complete root-work joins, all terminal/delivery/task assertions and cleanup ordering. Only two test files change. No production, package, SDK, runtime or update behavior changes; unrelated Codex implementation and sibling test changes are excluded. Independent P0-P2 review found no actionable defect. The predecessor cef1c9771a73 passed CI35910679645 (130 successful jobs, 17 skipped) and the isolated published 2026.9.4-to-candidate upgrade cell. These retain their source identity; current-head CI remains separate. Co-authored-by: jalehman <[email protected]>
6343528 to
3f4b910
Compare
|
/allow-security-sensitive-change |
|
Merged via squash.
|
…oad (openclaw#153187) Fix stale prepared-credential reads and plugin cleanup that can wait on itself during decision-provider reload. Require the exact accepting plugin instance and active invocation before reading prepared secrets. Keep physical decision settlement with its host while separating ordinary non-joining calls from cleanup authority; reject results after owner revocation. Preserve the canonical fixture repairs and the original lifecycle regressions. Josh Lehman accepted the documented immediate-quiescence revocation contract and authorized landing. Exact-head CI36064270062 passed (123 successful jobs,19 skipped), and the repository security-sensitive guard accepted current-head maintainer approval. Fresh independent P0-P2 review found no actionable defect. Historical local-runtime and paging-causation gaps remain documented in the PR; no skipped check is represented as passing. Original implementation by Jon Brown (@jb510). Co-authored-by: Jon Brown <[email protected]> Co-authored-by: jalehman <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
Backport #153187: de3010b Backport #139131: 104e67f Keep prepared input reads with the exact active plugin invocation and use nonjoining ordinary work without granting cleanup authority. Preserve physical disposal settlement and provider-owned Copilot routing scope across credential ownership, peer refresh, adoption and Doctor. Adapt the frozen identity-less shortcuts without importing OIDC identity features. Scope normalization matches formatting for absent, empty and whitespace-only persisted metadata. No credential schema or config change. Targeted corrected proof and independent review pass. Earlier broad/built proof remains bound to its source tree; current composed CI and packaging qualification remain separate. Co-authored-by: Jon Brown <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]> Co-authored-by: VasuBansal7576 <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
What Problem This Solves
Fixes stale prepared-credential reads and cleanup that waits on itself when a decision provider finishes during plugin reload.
User Impact
Decision providers can finish retiring without reading a replacement instance's prepared credential or deadlocking disposal. The general getPreparedPluginSecretInput() SDK contract requires an active invocation on the exact accepting plugin instance: quiescence removes further reads immediately, including for still-finishing callbacks. Draining permits cleanup, not continued credential acquisition. Providers must handle an unavailable read and must not reuse a prior value across reload.
Josh Lehman (@jalehman) explicitly accepted the documented immediate-quiescence revocation contract in the originating discussion and authorized landing this PR. RoboClaw records that human decision here on his behalf; this is not a GitHub comment authored by Josh. The change applies to this helper, not all plugin credential paths; it does not erase values already returned or revoke vendor credentials. The current-head security approval has separately been accepted by the repository guard (see Evidence).
Why This Change Was Made
Credential authority follows the exact instance and live invocation, rather than a reusable plugin ID. Decision-host settlement remains the physical-completion owner. Ordinary calls that do not join disposal no longer inherit cleanup admission, and decision results recheck owner revocation before being accepted.
Original implementation by Jon Brown (@jb510). Follow-up review, owner-level repair, and explicitly requested rebase coordinated by RoboClaw for Josh Lehman (@jalehman). Canonical CI fixture repairs by Peter Steinberger are retained through main commits 8ce411c, 46dfea6, and b21237a. The CI-only fixture work from 8a53ee3 credits PollyBot13 and Patrick Erichsen; canonical participant-write cleanup from f63d91e is preserved.
Work sessions
Evidence
Landing readback — 2026-09-24: exact head
3f4b9105090bf063a990f55f56fb55c75b14ea58passed CI 36064270062: 123 successful jobs, 19 skipped, zero failures; production/test types, selected Node lanes and the aggregate gate passed. The security guard acknowledgment accepts the current-head approval, withroboclaw-botas the verified Maintain-role account acting on Josh’s explicit request. That account/action attribution is distinct from the human SDK-contract decision recorded above. ClawSweeper’s 22:02 review found no code or security defect; its remaining contract/approval concerns predate these recorded confirmations. Historical local-runtime and paging-causation limitations below remain explicit, but they are not represented as current CI failures.Published head:
3f4b9105090bf063a990f55f56fb55c75b14ea58(tree7156785df668abf2858e3cb0f53bf49b875f98c3), refreshed onto pinned main1ab1bb09789aa46ad872178d341cf36164bdc407after the focused canonical-adoption update encountered merge conflicts. All ten original commits retain their exact authors, author dates, messages and requested Josh coauthor trailers; eight replay patch-identically. The two integrations retain upstream decision-dispatch diagnostics alongside the non-joining lifecycle lease, and move the original history fixture's drain-before-reset behavior into upstream's extracted shared helper. The final sole import conflict retains the newly landed notification observer fromf8e5e7ba68e(#157589), instead of restoring our old direct scope spy. No timeouts or assertions were weakened.Canonical fixes adopted: rotation repair #156858, commit
a5f1d0996a1f80a789628af19ec304c08369607b, revalidates owner departures between the asynchronous session read and admission. Cron fixture repair #156863, commite2c13543763e1b0d57294d62d31edcb1730bb531, supplies synthetic outbound adapters instead of accidentally bootstrapping real channel runtimes. Both canonical commits are ancestors of this head; all seven affected files match pinned main exactly. The earlier compaction fixture fixc947420aand yield/placement completion joins4d1c5d19remain adopted. Our unpublished compaction alternative and other unfinished diagnostics remain inactive and excluded.Verification: formatting and whitespace checks pass. Fresh independent review of the initial two-fix adoption was scoped-clean with no findings; the conflict integration has a separate fresh review recorded below. The upstream rotation repair includes nine deterministic owner regressions (40.56 s cold one-worker command); the cron repair's negative control observed one real bootstrap before and zero after, reducing its affected case from 32–59 s to 1.6–2.2 s under contention. Those are upstream-source results, not tests newly executed on this PR head, and the exact historical 120-second hosted cron timeout was not reproduced there.
Fresh execution limitation: the first exact-tree isolated run passed formatting but stopped at an incorrect typecheck invocation before tests. The corrected AWS attempt was refused before command execution because the coordinator supplied a malformed SSH host key. The local-container fallback was stopped before source execution when its isolation preflight detected a credential-bearing proxy environment. No guard was relaxed, no credentialed fork tests were run, and task-owned leases/containers were released. Fresh candidate typecheck and focused tests remain unrun; exact-head hosted CI is the remaining validation route. No new-head green claim is made.
Prior CI and paging attribution: CI on previous head
96f24c2finished with 126 successful jobs, 17 skipped and four failures: rotation, cron, task paging, plus the aggregate gate. Rotation and cron now have the canonical repairs above. For paging, the original 40-file group passed 160/160 tests on unmodified pinned maindf47b734and actual tested based996f7b3(main proof, base proof). These used owned disk-backed temporary storage, two CPUs/workers and Node 24.19.0/pnpm 12.4.2; 16 GiB versus hosted CI's 8 GiB is a pressure-equivalence limitation. The corresponding original CI-merge replaycd357d8aremains incomplete after execution-control interruptions. Passing main/base does not establish PR causation or a fix. The writer that produced the original zero-of-10,000 in-memory task projection remains unidentified; no speculative repair was added. A passing updated head would not by itself close that historical attribution gap.Exact-head CI is queued on
3f4b9105090bf063a990f55f56fb55c75b14ea58; it has not passed yet. GitHub reports the PR mergeable (remaining gates blocked). Fresh P0–P2 independent review of the conflict integration was scoped-clean, no findings, confidence 0.86, with the runtime execution gap explicitly stated. The final refresh only resolves the canonical notification-observer import and preserves that reviewed lifecycle composition. No merge, auto-merge or security approval was requested.Historical feature proof at 7daf33112c0 passed 2 forced-retirement regressions plus 315 decision, prepared-secret, plugin-lifecycle, provider and real native-SDK cases. Formatting, typed lint, core and owning test-graph typechecks, graph-boundary, ratchet and import-cycle checks passed. Sibling proof at 7daf33112c0 additionally passed 245 explicit invocation, callback, constructor, iterator, reflection and native-SDK cases, including the retained same-version reload-identity regression (31 ms). The original feature behavior and regression cases are retained; the dispatch integration described above composes them with upstream diagnostics. these earlier results are not claimed as newly executed on the refreshed head.
New regression cost:
/usr/bin/time -p pnpm test src/plugins/plugin-instance-registry.test.ts --maxWorkers=1on 7daf33112c0 took 23.08 s wall, including cold compilation. The two fake-clock cases took 95 ms and 4 ms in the preceding pack. Individual hosted case seconds were not extracted from that historical run.The earlier feature review raised one P2 proposal to deny credentials in all cleanup callbacks, even while an instance is accepting. That proposal was rejected as broader than the accepted contract: every read still requires the exact active, accepting instance; cleanup receives no exemption after quiescence. This is an explained review disagreement, not a clean automated verdict. No accepted findings remain unresolved.
The earlier rebase replayed the original contributor commits and follow-ups patch-identically onto pinned main b568ad2. The current merge incorporates later main fixes without dropping the lifecycle repair, the awaited task-history drain, or the invocation reload-identity regression. Where main already adopted an equivalent signing or UI fix, the PR diff now keeps main's implementation.
Earlier secretless proof reproduced the sibling-delayed stale result and forced-retirement late-result/late-callback failures before the owner repairs, then passed afterward:
Completed published-driver upgrade cell
The source-owned
published-upgrade-survivor/custom-plugin-siblingscell passed oncef1c9771a73in isolated AWS/Docker. It installed published[email protected], invoked that installation’s updater against the candidate tarball, and retained an update receipt with before 2026.9.4 → after 2026.9.5,candidateInstallMode: updater,updateOutcome: success, and no recovery. The one selected lane passed once in 152 seconds.The retained lane log and source-owned assertions confirm the enabled local plugin loaded before and after update, seven actual plugin executions in the private canary, Doctor-contract execution, and preservation of the original plugin source/config. Candidate package SHA-256:
c1a07ef62e9358d7b62a54e532f969058375c683e0a54e439589dc67e5dd1537. The exact source/tree guards and package hash passed; the lease is released with cleanup complete. The subsequent change touches only test files, so no production update behavior changed.Evidence limit: exported summaries, phase logs, package/hash and before/after receipt are retained; scheduler-owned raw process-start/sibling JSON artifacts were outside the exported directory. The summary’s complete first-hop exit snapshot is unavailable. No independent raw process-start identity claim is made. This proves the source-owned package-upgrade/plugin-loading cell, not an unchanged old npm TypeSafe SDK consumer, new live-provider access, systemd replacement, or the generic later health/status/rollback cells. Existing loaded-plugin/reload and TypeSafe evidence remains separate.
The Team Gateway was not updated or restarted by this proof. No provider keys, IAM role, Tailscale or credential hydration were used.
Earlier repair receipts (historical)
CI on EF completed with 128 successful jobs, 17 skipped and two failures (registry delivery assertion plus aggregate). Its compiler/type jobs passed. The then-current historical CI is retained for provenance, not current-head status.
That historical update backported only the canonical registry-test hunk from
0a5178c483b, preserving Vincent Koc’s authorship without its unrelated browser refactor. Announcement entry and actual root-work settlement are awaited before the unchanged delivered/terminal/task/exactly-once/no-recovery assertions and before fixture reset. No production behavior, timeout or assertion was weakened.Fresh isolated proof passed all 186 registry-file cases, formatting and typed lint, with candidate-tree checks before/after matching the published tree. Before repair, the isolated target failed at premature reset with an active native borrower; that is not a separate reproduction of the exact earlier CI delivery assertion. Independent P0–P2 review was scoped-clean, and the lease is released with cleanup complete.
Later completed evidence supersedes the interrupted status in the historical notes below: retained candidate run passed 4,209 test executions: 113 route cases, 14 storage/RPC cases, 20 × 27 cursor cases, and 3,542 tests in the original 201-selector/two-config Gateway group. Two opt-in benchmarks were skipped. Three owning type graphs, format and typed lint passed. This is completed proof for its identified candidate, not a claim that the later merged head has finished CI.
The previously pending published-driver upgrade cell passed. See the completed-cell record above for source identity, package/version evidence, plugin assertions and the raw-diagnostic export limitation.
Human-only current-revision security approval and attributable owner confirmation remain separate. No merge or auto-merge request has been made.
CI fixture repairs and current verification
Previous-head CI had four failed test jobs plus the aggregate gate. Repairs preserve assertions, permission checks and signer requirements:
Completed pre-refresh secretless evidence:
run_01a09aac54f99baa3f73e57ab26fc32b. This is actual generated Bash with OS fixtures, not native macOS signing/TCC/LaunchServices validation.run_277d20a2ace2d1408934f7aa62ef2232.Gateway restarts interrupted collection and gap continuations; they are not reported as test failures or completed stress proof. All four associated leases are confirmed released with cleanup complete. Retained logs/archives preserve the work; coordinator terminal receipts for interrupted runs can remain incomplete. ClawSweeper revision 14 found no actionable code defect on the preceding head, but requires a published-driver-to-candidate update proof cell under repository policy. That head passed docs, lint, production types, test types, and 150 other checks; one test shard failed because
subagent-registry.test.tschecked delivery before announcement and root work had settled. The latest commit retains the assertions and joins those owners; its isolated 186-case file run, formatting, and typed lint were reported passing. Exact-head hosted CI remains pending. Human-only current-revision security approval and attributable SDK-owner confirmation remain separate; neither has been supplied by this update.Original contributor's loaded-plugin and live-provider evidence (historical)
The following evidence was supplied with the original implementation. It is not a claim that RoboClaw reran a credentialed provider on the rebased head.
Loaded-plugin behavior proof
The prepared-secret suite loads a temporary plugin through
loadOpenClawPlugins, starts an admitted callback, begins disposal, loads a same-ID replacement, and verifies all three lifecycle outcomes: the replacement readsreplacement-key, the predecessor callback receives no credential, and predecessor disposal resolves with{ errors: [] }.Command:
Result: 3 tests passed in the integrated source checkout, including the loaded-plugin replacement case. This verifies the lifecycle patch with the correct dependency tree; it is separate from live-host validation.
Real provider runtime proof
A temporary loopback Gateway was run locally with OpenClaw
2026.9.5and an isolated state directory. The TypeSafe plugin used the host's existing protected file credential through aSecretRef(source=file,provider=typesafe,id=value). The credential was never printed, copied, or logged.A temporary plugin called
api.runtime.decisions.evaluatewith the nativetypesafe/jev-latestprovider:For the reload case, a local HTTPS CONNECT test proxy held the real TypeSafe request without inspecting or logging its encrypted contents. While that request was in flight:
The reload completed promptly (
plugins.reloadcompleted in 365 ms); it did not wait on itself. After restarting the temporary Gateway without the hold, a second real TypeSafe decision succeeded:This demonstrates normal credential access, fencing of an in-flight retiring provider call, completed cleanup, and successful post-reload provider use through the native decision runtime.