Skip to content

fix: preserve owner and Gateway access after plugin reload - #180109

Merged
shakkernerd merged 5 commits into
openclaw:mainfrom
enki:fix/plugin-reload-owner-continuation
Oct 22, 2026
Merged

shakkernerd merged 5 commits into
openclaw:mainfrom
enki:fix/plugin-reload-owner-continuation

Conversation

@enki

@enki enki commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157512. Follow-up to #178756.

What Problem This Solves

After an authenticated owner uses plugins(reloadAndResume), the automatic continuation can lose owner-only tools or retain owner identity while Gateway tools fail with operator run authority requires its admitted Gateway. Sending another owner message works around both failures, but should not be necessary.

User Impact

The same conversation can continue using owner-only plugin tools, its private Memory audience, and Gateway tools after the reload result. Failed reload responses can also be inspected without another owner message. Revoked authority, cancellation, and session replacement still prevent execution. No configuration or migration is required.

Why This Change Was Made

#178756 already captures host-issued continuation authority and detaches the handoff from the yielded invocation. Two pieces were missing: the resumed message did not bind the captured owner capability, and the resume was enqueued outside the retained Gateway context even though the reload itself ran inside it.

Bind the existing owner capability when preparing the plugin event, then enqueue the continuation under the existing retained Gateway authority while dropping the pre-reload plugin-registry selection. The new turn therefore binds to its admitted Gateway and selects the replacement plugin generation. It does not inherit the yielded turn's retired receipt or aborted run signal. Existing source revocation, exact Gateway binding, scopes, session lifetime, and cancellation checks remain enforced; no transport fallback or new authority is introduced.

The event remains internal_system, with CommandAuthorized = false and no fabricated sender. System and non-owner callers do not acquire owner access. This repairs the evidenced plugin handoff, not every restart-recovery path or the distinct initiating-turn failure in #157512. The same shared handoff also resumes guest PR preparation. It now retains the admitted Gateway under the guest’s existing authority; it does not grant owner or admin access.

Evidence

  • The original shipped CLI red/green captures and portable runner establish the owner-identity repair at 365e68be4c1. Those captures tested guarded local reads; they did not establish resumed Gateway dispatch.

  • Extending the existing regression to execute plugins.inspect after resume fails on that prior PR head in both successful- and failed-reload cases: 2 failed, 16 passed, with the exact missing-Gateway error. The real-Gateway E2E also fails after the replacement and successful owner-only read, returning that same error from plugins.inspect.

  • With the Gateway-context repair, 23 tests pass across plugin reload and the shared GitHub PR-preparation handoff. The expanded matrix checks actual Gateway dispatch after successful/failed reload responses and no inspection effects after revocation, cancellation, or session replacement. System/non-owner callers still cannot obtain the owner-only tool. Incoming committed-head unit shard: 21.75 s; the unit and E2E commands together take 53.05 s wall time. Incoming-head hosted CI completed with the inherited UI test-type failure attributed below.

  • The expanded committed real-Gateway E2E passes on 815114808002dfe1dad0f2ff00d712008c988365: an authenticated WebChat turn performs the initial read, actual plugin replacement, resumed owner-private read, and real plugins.inspect, followed by the final event and persisted transcript without another owner message. E2E shard: 10.33 s. Only inference HTTP is synthetic.

  • The full runtime build, core and both owning test typechecks, typed lint, formatting, normal commit hook, and independent P0-P2 review pass for this repair.

  • Shipped CLI red/green: the identical synthetic runner (hash below) fails on the deployed pre-repair build and succeeds on the committed repair. Selected unmodified terminal lines:

Runner SHA256: da1f5f88cce729a701ada23ffbe7176cb9e3bdb0f288b1294ce0063d13ea5785
Candidate: 0bff6fe211deea8b5f7296a1a784ae4e93665768 | OpenClaw 2026.10.5 | Node v24.22.1
Resumed actual owner_probe: {"record":"synthetic owner record","sessionKey":"<same-session>","sessionId":"<same-incarnation>","generation":2,"owner":true,"audience":"owner-private"}
FAIL: operator run authority requires its admitted Gateway
Candidate: 815114808002dfe1dad0f2ff00d712008c988365 | OpenClaw 2026.10.5 | Node v24.22.1
Resumed actual owner_probe: {"record":"synthetic owner record","sessionKey":"<same-session>","sessionId":"<same-incarnation>","generation":2,"owner":true,"audience":"owner-private"}
Resumed actual plugins.inspect: {"ok":true,"plugin":{"id":"owner-probe","enabled":true}}
Verified: two actual guarded tool executions; same exact session; replacement generation increased.
Verified: one owner chat.send; automatic resumed final event and persisted transcript.
PASS: owner-only local read and Gateway inspection survive automatic resume.

The earlier deployed build and prior PR head have identical shared-handoff source. The new CLI run verifies a replacement generation, two guarded reads, the actual resumed Gateway inspection, one authenticated owner message, and automatic final/history. Fixture processes were stopped and joined. Incoming-head broad hosted CI completed with the inherited UI test-type failure documented below; dependency and security checks pass. The latest review accepts that attribution and reports no remaining author-facing blocker. Those incoming-head results are historical; the prepared head now passes the complete hosted CI gate.

All new proof uses synthetic state, records, credentials, and loopback model HTTP. It does not use private session transcripts or live Records data, and does not claim native Codex/vendor or browser-renderer coverage. No persisted representation, SDK, permission policy, or configuration contract changes.

Guest PR-preparation continuation

The existing preparation regression now lets the successful case enter real session-event admission instead of replacing it with a completed receipt. The resumed guest retains exactly operator.sessions.read and operator.sessions.write, executes github_publish, and reaches the real publication requester-admission owner with the same principal and scope ceiling. tools.effective remains denied for missing operator.read, and plugins.reload remains denied for missing operator.admin; neither denied handler executes. No additional human message is supplied, and no permission is expanded. External preparation/publication results and inference are synthetic; this test establishes the continuation and admission boundary, not a GitHub network push.

Remote validation of the source committed in c43e4b7883496d87cce23732321bcbce91411800 passes formatting, lint, the owning core-test-agents-tools graph, and all five preparation cases. Restoring the pre-fix shared handoff makes the authorized guest publication call fail with the exact missing-admitted-Gateway error while the other four preparation cases pass. Unchanged shared-handoff, session-event and real-Gateway reload proof is reused; the combined selected coverage is 46 cases. The final five-case fixture uses the session-only guest scopes rather than relying on inventory access.

The final preparation-file run takes 44.17 s in Vitest, including transform/import work; its native shard takes 73.97 s, including worker preparation. The one required runtime build takes 237.1 s. Prepared-head hosted CI passes, independent review is clean, and ClawSweeper reports Diamond with no findings; the incoming-head CI failure below is historical.

Incoming-head CI attribution

The completed check-test-types-core-3 job reports TS2353 at chat-details-output-intent.test.tsx:27 and :53: its fixture still supplies artifactsLoading, removed from ChatOutputsDesktopProps. This is an inherited UI source mismatch, not a reload/resume change.

The job checked merge f74dc11861100968317286cbdae31e5fd9d81fca onto upstream 4611232730583082f5c49bd79f1f68dfbfbd1b60. GitHub blob reads show the failing fixture on that base and the type owner on that base are byte-identical in the tested merge: blobs c7b6b77ea24c7d65ebd30404873a1003f5275709 and 6c5dad2218e3e7f508ac57ec3e25f917c6f8314b, respectively. This PR changes no UI file. The stale fixture is also still present at subsequently fetched upstream 52df852cd5be3b3691ef27d0942a4db7b2258eb1.

pnpm test:ci-failed 180109 classifies this as new because its comparison uses a passing main job without comparing selected scope; the direct base/merge source comparison above supplies the attribution. No full base typecheck was executed. No unrelated UI repair, dependency update, exception, or green-chasing rerun is added to this PR. The incoming head’s focused tests, owning typechecks, typed lint, runtime build, and shipped-CLI proof remain passing; the broad hosted gate is not claimed green.

Current prepared head

Head f68cf7d758eee297e1a87d0ddd9c733ab38b05b1 replays the same five commits onto cfba9b974f74e6d4faf8041a35986bda4424ec5d, which supplies the current schema-31 runtime baseline. All five patches are unchanged in range-diff. The retained Gateway, event-admission and publication-authorization contracts used by the focused proof are unchanged; the execution results above retain their original source identities. Independent review is clean for that unchanged contribution. Current prepared-head CI passes, and the exact-head ClawSweeper report is Diamond with no findings.

@clawsweeper

clawsweeper Bot commented Oct 22, 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 agents Agent runtime and tooling size: M labels Oct 22, 2026
@enki
enki marked this pull request as ready for review October 22, 2026 01:16
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves authenticated owner capabilities and the admitted Gateway when a conversation resumes after plugin reload or PR preparation.

Example: An owner calls plugins with action reloadAndResume and pluginId owner-probe.

  • Before: The automatic continuation loses owner_probe or plugins.inspect fails with “operator run authority requires its admitted Gateway.”
  • After: The continuation reads the owner-private record and successfully calls plugins.inspect without another owner message.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped-entry-point proof, meaningful authority-boundary regressions, and no identified correctness or scope defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Shipped-CLI red/green output exercises authenticated WebChat, actual plugin replacement, owner-private reads, resumed plugins.inspect, final delivery, and persisted history with synthetic inference; production-path regressions cover forbidden principals and invalidation before effects, and GitHub blob identity supports reuse on the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An authenticated conversation resumes after plugin reload but cannot use its owner-only or Gateway tools until the user sends another message.
Reason: Restores the documented continuation contract without new configuration, persisted formats, permission policy, or parallel lifecycle machinery.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR repairs a current continuation failure with a focused production change and convincing behavior proof; no actionable defects were found, and exact-head CI remains pending.

Priority: P2
Reviewed head: f68cf7d758eee297e1a87d0ddd9c733ab38b05b1

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared tool handoff yields a conversation, waits for cleanup, performs the requested operation, and submits its result through session-event admission to a new turn.

flowchart TD
A[Authenticated conversation] --> B[Shared tool handoff]
B --> C[Yield and settle original turn]
C --> D[Operation under retained authority]
D --> E[Session event with admitted Gateway]
E --> F[New turn selects current plugin registry]
F --> G[Guarded plugin and Gateway tools]
Loading

Technical review

Best possible solution:

Resume through existing session admission with the original live authority and Gateway binding while selecting the replacement plugin registry.

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

Current-main source confirms that continuation admission lacks the retained Gateway scope and plugin events lack owner-capability binding; supplied shipped-CLI red/green traces demonstrate both failures without executing target code during this review.

Is this the best way to solve the issue?

This is the smallest complete production repair: reuse the existing continuation and command-owner capability owners, preserve fresh turn admission, and discard only stale plugin-generation selection.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Detached shared tool handoff keeps the original intent (c1658c0: Detach background work and resume from the yielded caller's retired receipt and aborted signal while retaining captured operator authority.)
  • Session-event owner capability binding keeps the original intent (3d2f7ca: Run scheduled conversation work through ordinary session admission while preserving its authenticated source; the repair preserves that branch and binds an existing captured owner capability for plugin continuations.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +19, Tests +983. Total +1002 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 36 17 +19
Tests 3 997 14 +983
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 1033 31 +1002

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +36/-17 lines; tests +997/-14 lines The small repair reuses existing owners; test growth covers distinct authority invalidation cases, the guest consumer, and actual Gateway/plugin replacement.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Automatic continuation loses working tool access after an explicit maintenance action, with another authenticated message providing a workaround.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (6 earlier review cycles)
  • reviewed 2026-10-22T01:32:13.091Z sha ab032310dc79463a48647e9540440594df1f1904 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-22T02:13:42.544Z sha 365e68be4c1610ee8990ff51979249f653ebbafd :: needs maintainer review before merge. :: none
  • reviewed 2026-10-22T03:29:24.357Z sha 815114808002dfe1dad0f2ff00d712008c988365 :: needs changes before merge. :: none
  • reviewed 2026-10-22T04:37:24.793Z sha 815114808002dfe1dad0f2ff00d712008c988365 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-22T09:53:03.096Z sha 3350315d08485504dc2925e967abc0152957e64a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-22T10:15:29.106Z sha c43e4b7883496d87cce23732321bcbce91411800 :: needs maintainer review before merge. :: none

Reviewed October 22, 2026, 6:26 AM ET / 10:26 UTC (Revision 7).

@enki

enki commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Captured the shipped CLI path at PR head 365e68be4c1610ee8990ff51979249f653ebbafd and reproduced the failure on the independently built unpatched base d220033a2cee0c153875ed866be024eefba8de04, both with Node 24.22.1.

The same portable runner starts a separate built openclaw.mjs gateway run process, installs/consents a synthetic native Memory plugin through the shipped CLI, authenticates Control UI/WebChat, and sends one owner message. The tool reads an actual mode-0600 synthetic private record file after checking owner status, current invocation, unsandboxed session and current host-issued owner-private Memory audience. Actual plugin replacement, embedded tool execution, automatic continuation, final event and persisted history run through production code; only inference HTTP responses are scripted.

On the base, reload succeeds but the resumed factory has owner:false and a conversation audience. On this PR, both actual file reads succeed, the callable generation advances 1 → 2, and the exact session/incarnation remains unchanged. Session identifiers in these captures are replaced only after equality assertions. Neither capture contains tokens, network addresses or private paths.

Complete sanitized terminal capture: unpatched built Gateway
OpenClaw shipped CLI reload continuation proof
Runner SHA256: 50e1a38afac87910eca985a019b15530677d3dac04dde29d609b754c0156e3c1
Candidate: d220033a2cee0c153875ed866be024eefba8de04 | OpenClaw 2026.10.5 | Node v24.22.1
Isolation: temporary synthetic state, token and device identity; loopback scripted inference only.
Fixture installed and consented through shipped CLI.
Authenticated Control UI/WebChat connected (protocol 4).
Initial actual owner_probe: {"record":"synthetic owner record","sessionKey":"<same-session>","sessionId":"<same-incarnation>","generation":1,"owner":true,"audience":"owner-private"}
Actual plugins.reload result: {"ok":true,"restartRequired":false,"runtime":{"generation":3,"pluginIds":["owner-probe"]}}
Automatic resumed owner_probe available: false
Actual resumed factory: {"owner":false,"audience":"conversation","sameSession":true,"sameIncarnation":true,"sandboxed":false}
FAIL: Resumed authenticated owner tool unavailable
Complete sanitized terminal capture: PR built Gateway
OpenClaw shipped CLI reload continuation proof
Runner SHA256: 50e1a38afac87910eca985a019b15530677d3dac04dde29d609b754c0156e3c1
Candidate: 365e68be4c1610ee8990ff51979249f653ebbafd | OpenClaw 2026.10.5 | Node v24.22.1
Isolation: temporary synthetic state, token and device identity; loopback scripted inference only.
Fixture installed and consented through shipped CLI.
Authenticated Control UI/WebChat connected (protocol 4).
Initial actual owner_probe: {"record":"synthetic owner record","sessionKey":"<same-session>","sessionId":"<same-incarnation>","generation":1,"owner":true,"audience":"owner-private"}
Actual plugins.reload result: {"ok":true,"restartRequired":false,"runtime":{"generation":3,"pluginIds":["owner-probe"]}}
Automatic resumed owner_probe available: true
Resumed actual owner_probe: {"record":"synthetic owner record","sessionKey":"<same-session>","sessionId":"<same-incarnation>","generation":2,"owner":true,"audience":"owner-private"}
Verified: two actual guarded tool executions; same exact session; replacement generation increased.
Verified: one owner chat.send; automatic resumed final event and persisted transcript.
PASS
Portable runner and reproduction commands (Node 24.22.1)

Prepare each independent clean checkout with its frozen dependencies and canonical runtime build:

pnpm install --frozen-lockfile
node --import ./scripts/tsx.mjs scripts/build-all.mts runtime

Save the runner below as reload-proof.mjs. Run against the PR and base checkout respectively:

node ./reload-proof.mjs /path/to/pr-checkout fixed
node ./reload-proof.mjs /path/to/base-checkout base

The base run intentionally exits 1 after the authenticated initial read and successful reload. The PR run exits 0 after checking both actual reads, replacement generation, exact session, one owner message, resumed final event and history. Each run prints the runner hash; both captures above used 50e1a38afac87910eca985a019b15530677d3dac04dde29d609b754c0156e3c1.

--force acknowledges the generated local plugin source during installation; it does not change Gateway/plugin authentication. Raw diagnostics and synthetic credentials remain in a private temporary directory. Only the structured terminal output above is intended for sharing.

import assert from 'node:assert/strict';
import fs from 'node:fs';
import fsp from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import http from 'node:http';
import net from 'node:net';
import crypto from 'node:crypto';
import { spawn } from 'node:child_process';
import { once } from 'node:events';
import { pathToFileURL } from 'node:url';

const [repoArg, verdict = 'fixed'] = process.argv.slice(2);
assert(repoArg, 'usage: node openclaw-reload-shipped-proof.mjs <built-checkout> <fixed|base>');
const repo = fs.realpathSync(repoArg);
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openclaw-shipped-reload-'));
fs.chmodSync(root, 0o700);
const reportPath = path.join(root, 'public-transcript.txt');
const transcript = [];
function report(line) { transcript.push(line); console.log(line); fs.writeFileSync(reportPath, transcript.join('\n') + '\n', { mode: 0o600 }); }
function deferred() { let resolve, reject; const promise = new Promise((a,b)=>{resolve=a;reject=b}); promise.catch(()=>{}); return {promise,resolve,reject}; }
async function bounded(promise, ms, label) { let timer; try { return await Promise.race([promise, new Promise((_, reject)=>{timer=setTimeout(()=>reject(new Error(label)),ms)})]); } finally { clearTimeout(timer); } }
const timeout = setTimeout(()=>{ fs.writeFileSync(path.join(root,'fatal.txt'),'Proof lifetime exceeded'); gateway?.kill('SIGTERM'); process.exit(2); },120_000);
const state = path.join(root,'gateway-state');
const clientState = path.join(root,'client-state');
const home = path.join(root,'home');
const workspace = path.join(root,'workspace');
const pluginRoot = path.join(root,'owner-probe');
const empty = path.join(root,'empty-bundled');
const configPath = path.join(root,'openclaw.json');
for (const dir of [state,clientState,home,workspace,pluginRoot,empty]) fs.mkdirSync(dir,{recursive:true,mode:0o700});
const env = Object.fromEntries(['PATH','TMPDIR','LANG','LC_ALL','TERM'].filter(k=>process.env[k]).map(k=>[k,process.env[k]]));
Object.assign(env,{ HOME:home, OPENCLAW_STATE_DIR:state, OPENCLAW_CONFIG_PATH:configPath,
 OPENCLAW_DISABLE_BUNDLED_PLUGINS:'1',OPENCLAW_BUNDLED_PLUGINS_DIR:empty,OPENCLAW_SKIP_CHANNELS:'1',OPENCLAW_SKIP_CRON:'1',OPENCLAW_SKIP_BROWSER_CONTROL_SERVER:'1',OPENCLAW_SKIP_CANVAS_HOST:'1',OPENCLAW_SKIP_GMAIL_WATCHER:'1',OPENCLAW_SKIP_PROVIDERS:'1',
 NO_PROXY:'127.0.0.1,localhost',no_proxy:'127.0.0.1,localhost',OPENCLAW_LOG_LEVEL:'info' });
for (const key of Object.keys(process.env)) delete process.env[key];
Object.assign(process.env,env,{OPENCLAW_STATE_DIR:clientState});
const sessionKey='agent:main:dashboard:'+crypto.randomUUID();
const token=crypto.randomUUID();
const recordFile=path.join(root,'private-record.txt');
fs.writeFileSync(recordFile,'synthetic owner record',{mode:0o600});
const generationFile=path.join(root,'plugin-generation.txt');
const effectsFile=path.join(root,'probe-effects.jsonl');
const factoriesFile=path.join(root,'factory-facts.jsonl');
const finished=deferred(), failed=deferred(), hello=deferred();
let gateway,client,provider,step=0,first,last,reloadResult,ownerSends=0;
const rawLog=fs.openSync(path.join(root,'gateway.raw.log'),'a',0o600);
function writeSse(response,events) { response.writeHead(200,{'content-type':'text/event-stream','cache-control':'no-store',connection:'keep-alive'});response.end(events.map(e=>'data: '+JSON.stringify(e)+'\n\n').join('')+'data: [DONE]\n\n'); }
function tool(response,name,id,args) { const item={type:'function_call',id:'fc_'+id,call_id:'call_'+id,name,arguments:JSON.stringify(args)};writeSse(response,[{type:'response.output_item.added',output_index:0,item:{...item,arguments:''}},{type:'response.function_call_arguments.delta',item_id:item.id,output_index:0,delta:item.arguments},{type:'response.output_item.done',output_index:0,item},{type:'response.completed',response:{id:'resp_'+id,status:'completed',output:[item],usage:{input_tokens:1,output_tokens:1,total_tokens:2}}}]); }
function text(response,value) {const item={type:'message',id:'m_'+step,role:'assistant',status:'completed',content:[{type:'output_text',text:value,annotations:[]}]};writeSse(response,[{type:'response.output_item.added',output_index:0,item:{...item,status:'in_progress',content:[]}},{type:'response.output_text.delta',item_id:item.id,output_index:0,content_index:0,delta:value},{type:'response.output_item.done',output_index:0,item},{type:'response.completed',response:{id:'r_'+step,status:'completed',output:[item],usage:{input_tokens:1,output_tokens:1,total_tokens:2}}}]);}
function output(body,id) {const value=body.input.find(i=>i.type==='function_call_output'&&i.call_id==='call_'+id)?.output;assert(value!==undefined,'Missing actual tool output '+id);return JSON.parse(value);}
async function cli(args) {const fd=fs.openSync(path.join(root,'cli.raw.log'),'a',0o600);const child=spawn(process.execPath,[path.join(repo,'openclaw.mjs'),...args],{cwd:root,env,stdio:['ignore',fd,fd]});try{const [code]=await bounded(once(child,'close'),35_000,'CLI setup deadline');assert.equal(code,0,'CLI setup failed; see private raw log');}finally{if(child.exitCode===null)child.kill('SIGTERM');fs.closeSync(fd);}}
try {
 const build=JSON.parse(fs.readFileSync(path.join(repo,'dist/build-info.json'),'utf8'));
 report('OpenClaw shipped CLI reload continuation proof');
 report('Runner SHA256: '+crypto.createHash('sha256').update(fs.readFileSync(new URL(import.meta.url))).digest('hex'));
 report('Candidate: '+build.commit+' | OpenClaw '+build.version+' | Node '+process.version);
 report('Isolation: temporary synthetic state, token and device identity; loopback scripted inference only.');
 fs.writeFileSync(path.join(pluginRoot,'package.json'),JSON.stringify({name:'owner-probe',version:'1.0.0',openclaw:{extensions:['./index.cjs']}}));
 fs.writeFileSync(path.join(pluginRoot,'openclaw.plugin.json'),JSON.stringify({id:'owner-probe',kind:'memory',contracts:{tools:['owner_probe']},configSchema:{type:'object',additionalProperties:false}}));
 fs.writeFileSync(path.join(pluginRoot,'index.cjs'),`module.exports={id:'owner-probe',kind:'memory',register(api){
 const fs=require('node:fs');const g=${JSON.stringify(generationFile)};const generation=fs.existsSync(g)?Number(fs.readFileSync(g,'utf8'))+1:1;fs.writeFileSync(g,String(generation));
 api.registerMemoryCapability({providerRuntime:{open:async()=>({provider:null})}});
 api.registerTool({contextVersion:2,create(context){
 fs.appendFileSync(${JSON.stringify(factoriesFile)},JSON.stringify({owner:context.senderIsOwner,audience:context.memoryAudience?.kind,sessionKey:context.sessionKey,sessionId:context.sessionId,sandboxed:context.sandboxed})+'\\n');
 if(context.senderIsOwner!==true)throw new Error('Live authenticated private owner session required');context.assertInvocationCurrent();
 if(context.sessionKey!==${JSON.stringify(sessionKey)}||!context.sessionId||context.sandboxed)throw new Error('Exact live unsandboxed owner session incarnation required');
 if(context.memoryAudience?.kind!=='owner-private')throw new Error('Current private-agent Memory audience required');context.assertMemoryAudienceCurrent();
 return{name:'owner_probe',label:'Owner probe',description:'Read a synthetic owner-only record',parameters:{type:'object',properties:{}},async execute(){context.assertInvocationCurrent();context.assertMemoryAudienceCurrent();
 const record=fs.readFileSync(${JSON.stringify(recordFile)},'utf8');
 const result={record,sessionKey:context.sessionKey,sessionId:context.sessionId,generation,owner:context.senderIsOwner,audience:context.memoryAudience.kind};fs.appendFileSync(${JSON.stringify(effectsFile)},JSON.stringify(result)+'\\n');return{content:[{type:'text',text:JSON.stringify(result)}]};}};
 }},{name:'owner_probe'});}};`);
 provider=http.createServer((request,response)=>{void(async()=>{
  if(request.method==='GET'&&request.url==='/v1/models'){response.writeHead(200,{'content-type':'application/json'});response.end(JSON.stringify({data:[{id:'qa-reload-owner',object:'model'}]}));return;}
  assert.equal(request.method,'POST');assert.equal(request.url,'/v1/responses');let raw='';for await(const chunk of request)raw+=chunk;const body=JSON.parse(raw);
  fs.appendFileSync(path.join(root,'provider.raw.jsonl'),JSON.stringify(body)+'\n',{mode:0o600});
  if(JSON.stringify([body.instructions,...body.input.filter(i=>i.role==='developer'||i.role==='system')]).includes('Generate a concise session title')){text(response,'Reload proof');return;}
  switch(step++){
   case 0:assert(body.tools.some(t=>t.name==='owner_probe'),'Initial owner tool unavailable');tool(response,'owner_probe','initial',{});break;
   case 1:first=output(body,'initial');assert.equal(first.record,'synthetic owner record');assert.equal(first.owner,true);assert.equal(first.audience,'owner-private');report('Initial actual owner_probe: '+JSON.stringify({...first,sessionKey:'<same-session>',sessionId:'<same-incarnation>'}));tool(response,'plugins','reload',{action:'reloadAndResume',pluginId:'owner-probe'});break;
   case 2:{const event=body.input.flatMap(i=>Array.isArray(i.content)?i.content:[]).map(i=>i.text).find(t=>typeof t==='string'&&t.includes('Plugin reload result: '));assert(event,'Missing automatic reload result');const match=event.match(/Plugin reload result: (\{[^\n]*\})/);assert(match);reloadResult=JSON.parse(match[1]);assert.equal(reloadResult.ok,true);assert.deepEqual(reloadResult.runtime.pluginIds,['owner-probe']);report('Actual plugins.reload result: '+JSON.stringify({ok:reloadResult.ok,restartRequired:reloadResult.restartRequired,runtime:{generation:reloadResult.runtime.generation,pluginIds:reloadResult.runtime.pluginIds}}));const available=body.tools.some(t=>t.name==='owner_probe');report('Automatic resumed owner_probe available: '+available);assert(available,'Resumed authenticated owner tool unavailable');tool(response,'owner_probe','resumed',{});break;}
   case 3:last=output(body,'resumed');assert.deepEqual({...last,generation:0},{...first,generation:0});assert(last.generation>first.generation,'Plugin callable not replaced');report('Resumed actual owner_probe: '+JSON.stringify({...last,sessionKey:'<same-session>',sessionId:'<same-incarnation>'}));text(response,'Owner-only read succeeded after actual plugin reload.');break;
   default:throw new Error('Unexpected model request');
  }
 })().catch(error=>{failed.reject(error);response.writeHead(500,{'content-type':'application/json'});response.end(JSON.stringify({error:{message:error.message}}));});});
 await new Promise((resolve,reject)=>{provider.once('error',reject);provider.listen(0,'127.0.0.1',resolve);});
 const providerPort=provider.address().port;
 const listener=net.createServer();await new Promise(r=>listener.listen(0,'127.0.0.1',r));const port=listener.address().port;await new Promise(r=>listener.close(r));
 const cfg={agents:{defaults:{model:{primary:'mock-openai/qa-reload-owner'},models:{'mock-openai/qa-reload-owner':{agentRuntime:{id:'openclaw'},params:{transport:'sse',openaiWsWarmup:false}}},workspace,skipBootstrap:true,skills:[]},entries:{main:{}}},plugins:{enabled:true,allow:['owner-probe'],load:{paths:[pluginRoot]},slots:{memory:'owner-probe'}},tools:{allow:['plugins','owner_probe'],codeMode:false,toolSearch:false},models:{mode:'replace',providers:{'mock-openai':{baseUrl:'http://127.0.0.1:'+providerPort+'/v1',apiKey:'synthetic-placeholder',api:'openai-responses',request:{allowPrivateNetwork:true},models:[{id:'qa-reload-owner',name:'qa-reload-owner',api:'openai-responses',reasoning:false,input:['text'],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128000,maxTokens:4096}]}}},gateway:{mode:'local',port,bind:'loopback',auth:{mode:'token',token},controlUi:{allowedOrigins:['http://127.0.0.1']}}};
 fs.writeFileSync(configPath,JSON.stringify(cfg,null,2),{mode:0o600});
 await cli(['plugins','install',pluginRoot,'--link','--force','--accept-capabilities','--acknowledge-install-policy-warning']);report('Fixture installed and consented through shipped CLI.');
 gateway=spawn(process.execPath,[path.join(repo,'openclaw.mjs'),'gateway','run','--port',String(port),'--bind','loopback','--allow-unconfigured'],{cwd:root,env,stdio:['ignore',rawLog,rawLog]});
 const gatewayClosed=once(gateway,'close');gatewayClosed.then(([code])=>failed.reject(new Error('Gateway exited '+code))).catch(failed.reject);
 const {GatewayClient}=await import(pathToFileURL(path.join(repo,'dist/plugin-sdk/gateway-runtime.js')).href);
 client=new GatewayClient({url:'ws://127.0.0.1:'+port,token,env:{...env,OPENCLAW_STATE_DIR:clientState},origin:'http://127.0.0.1',clientName:'openclaw-control-ui',clientDisplayName:'Synthetic proof owner',clientVersion:'proof',mode:'webchat',role:'operator',scopes:['operator.admin'],onHelloOk:h=>{report('Authenticated Control UI/WebChat connected (protocol '+h.protocol+').');hello.resolve();},onEvent:event=>{if(event.event==='chat'&&event.payload?.sessionKey===sessionKey&&event.payload?.state==='final'&&JSON.stringify(event.payload.message).includes('Owner-only read succeeded after actual plugin reload.'))finished.resolve();},onReconnectPaused:info=>failed.reject(new Error('Gateway authentication paused '+info.code))});
 client.start();await bounded(Promise.race([hello.promise,failed.promise]),45_000,'Gateway authenticated startup deadline');
 ownerSends++;await client.request('chat.send',{sessionKey,message:'Read my synthetic owner record, reload owner-probe, and read it again automatically.',deliver:false,idempotencyKey:crypto.randomUUID()});
 await bounded(Promise.race([finished.promise,failed.promise]),45_000,'Continuation deadline');
 const history=await client.request('chat.history',{sessionKey});assert.equal(history.sessionId,first.sessionId);assert(JSON.stringify(history.messages).includes('Owner-only read succeeded after actual plugin reload.'));
 const effects=fs.readFileSync(effectsFile,'utf8').trim().split('\n').map(JSON.parse);assert.equal(effects.length,2);assert.deepEqual(effects,[first,last]);assert.equal(ownerSends,1);
 report('Verified: two actual guarded tool executions; same exact session; replacement generation increased.');report('Verified: one owner chat.send; automatic resumed final event and persisted transcript.');report('PASS');
}catch(error){fs.writeFileSync(path.join(root,'failure.raw.txt'),error.stack??String(error),{mode:0o600});if(error.message==='Resumed authenticated owner tool unavailable'&&fs.existsSync(factoriesFile)){const facts=fs.readFileSync(factoriesFile,'utf8').trim().split('\n').map(JSON.parse).at(-1);report('Actual resumed factory: '+JSON.stringify({owner:facts.owner,audience:facts.audience,sameSession:facts.sessionKey===first.sessionKey,sameIncarnation:facts.sessionId===first.sessionId,sandboxed:facts.sandboxed}));}
 report('FAIL: '+(error.message==='Resumed authenticated owner tool unavailable'?error.message:'setup or execution failed (private diagnostics retained)'));process.exitCode=1;
}finally{
 try{await client?.stopAndWait();}finally{if(gateway&&gateway.exitCode===null){gateway.kill('SIGTERM');await bounded(once(gateway,'close'),15_000,'Gateway cleanup deadline').catch(()=>{gateway.kill('SIGKILL');});}if(provider){provider.closeAllConnections();await new Promise(r=>provider.close(r));}fs.closeSync(rawLog);clearTimeout(timeout);}
 fs.writeFileSync('/tmp/openclaw-reload-shipped-'+verdict+'-artifact-path.txt',root,{mode:0o600});
}

The committed E2E regression additionally retains this authority contract in the test suite. No source changes were needed for this capture.

Limitations: the Memory slot/plugin, private record and inference service are synthetic. This verifies host-issued native Memory audience/currentness and a guarded filesystem read; it does not claim live Records/backend/vendor or browser-rendering validation. Fixture processes were stopped and joined. No operator Gateway state, private Records data or vendor credentials were copied or used.

@enki

enki commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added shipped CLI red/green proof for current head 365e68be4c1610ee8990ff51979249f653ebbafd, with complete sanitized terminal captures and a portable runner: #180109 (comment). PR body and committed real-Gateway regression are current; CI passes.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@shakkernerd
shakkernerd force-pushed the fix/plugin-reload-owner-continuation branch from c43e4b7 to f68cf7d Compare October 22, 2026 10:19
@shakkernerd

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 22, 2026
@shakkernerd
shakkernerd merged commit 41f55f5 into openclaw:main Oct 22, 2026
136 of 138 checks passed
@shakkernerd

Copy link
Copy Markdown
Contributor

Fixed: Automatic continuations after plugin reload and PR preparation retain their authorized Gateway access.

With thanks to @enki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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: XL 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