Skip to content

feat(agentsapi): select plugin-owned self-hosted executors - #161609

Merged
sjf-oa merged 9 commits into
mainfrom
sjf/agentsapi-executor-controller
Oct 4, 2026
Merged

sjf-oa merged 9 commits into
mainfrom
sjf/agentsapi-executor-controller

Conversation

@sjf-oa

@sjf-oa sjf-oa commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

Self-hosted Agents API sessions need an executor on infrastructure chosen by the operator. The Gateway owns the conversation, while a selected plugin supplies the workspace and connects an executor when the API requests it. Healthy turns should not require another connection check or SSH round trip.

What Problem This Solves

Operators need a supported plugin contract for connecting and retiring self-hosted executors without replaying conversation input during connection recovery.

User Impact

Each native session gets its own executor lifecycle, reused across turns. Executors may share one persistent VM, remote host, container, or workspace, or use separately isolated environments. Sharing is an optional deployment choice. Operators can also continue managing executors externally.

The public setup guide explains prerequisites, controller-plugin registration, configuration, session ownership, recovery, reset, and verification. The contract does not include a universal SSH launcher. Operators supply or install a controller appropriate to their infrastructure.

Maintainer design decision: retain the narrow, opt-in controller SDK contract and persisted controller ownership. Keep infrastructure and process management in the selected plugin, preserve externally managed executors, and require native settlement before session ownership is removed.

Why This Change Was Made

  • Registers controllers through api.registerAgentExecutorController({ workspaceDirectory, ensure, retire }), selected by plugins.entries.agentsapi.config.executorController.
  • Persists the session, environment, and controller binding. Processes environment_connection actions while input is pending, including actions already present before subscription and after stream recovery.
  • Retains the original input and reconciles saved state. Connection recovery does not silently replace the conversation or replay commands.
  • Keeps the executor between turns and interruptions. Reset and deletion require confirmed native settlement before discarding the binding. Failed status reads, cancellation, or authentication preserve ownership for retry; already-settled executor retirement remains best effort.
  • Reacquires agent-scoped API-key authentication for cleanup after Gateway restart. Failed cleanup handles are evicted so repaired credentials take effect on retry.
  • Propagates required cleanup failure through the host reset boundary. Explicit and automatic conversation reset check cleanup before changing the saved session; optional reset observers retain their best-effort behavior.
  • Uses the public plugin SDK for the controller contract; process and transport implementation stay in the deployment plugin.

This branch is based directly on main; it does not include the separate cron PR.

Upgrade Behavior

Changing an existing session's controller requires reset. Retire earlier factory-owned sessions with the previous version before upgrading; their saved bindings have no plugin owner and are not silently reassigned. Compatible hosted and externally managed sessions remain supported.

Evidence

Validation of the main-based candidate:

  • All nine Agents API test files passed: 180 tests. Eleven shared native-binding, load-plan, and registry test files passed: 90 tests. This includes hosted/external compatibility, pending input and connection recovery, session persistence, reset/deletion/rollback, exact controller selection, original class receivers, and revoked authority.
  • Required-cleanup registry and /new regressions fail on the previous code for swallowed errors and session mutation before failure, respectively. The repaired registry passed 15 tests in 68.00 seconds wall, with the new case taking 27 ms. Session initialization passed eight tests in 54.05 seconds wall, with the new case taking 2.527 seconds. The 22 existing lifecycle-hook tests also passed. Wall times include compiled worker preparation.
  • All nine targeted cleanup regressions failed against the previous implementation. All 28 persistence tests then passed on the repair, including status/cancel errors, restart authentication, missing keys, OAuth credentials, lost authority, and successful retry. Final pnpm test extensions/agentsapi/agentsapi-harness.persistence.test.ts --maxWorkers=1 cost: 111.69 seconds wall, including runner/worker preparation; Vitest reported 106.94 seconds under concurrent validation load. CI per-file time is not separately reported.
  • The Gateway session lifecycle suite passed all 16 tests through the real handlers and SQLite owners, with clean source-integrity verification: 156.42 seconds wall, 148.34 seconds Vitest. The new reset/deletion cases took 5.795 and 3.563 seconds; they protect local session generation preservation and successful retry at the actual entry point.
  • Fresh independent review passed with no actionable P0-P2 findings. The approved lifecycle repairs are separate commits quoting ClawSweeper's request.
  • Core, core-test, extension, extension-test and script types passed. Formatting, SDK exports/surface/boundaries, database and test ratchets, configuration metadata, all three dead-export scans and documentation MDX sanity passed. The CI test-catch annotation was corrected and its canonical type-aware lint replay passed. All 14,881 internal link targets passed the non-anchor audit. Configuration baseline was regenerated with the canonical generator.
  • Native ARM64 Docker builds and offline packaged-image verification passed. Full runtime proof, source/image identities and diagnostic receipts cover shared persistent files, distinct executors, healthy-turn reuse, three concurrent Slack sessions, Gateway restart, recovery without duplicate writes, required-cleanup failure and retry, Slack /new, and saved hosted/external sessions upgraded from the PR's exact main base.
  • Packaged controller authority proof used the real plugin loader, controller registration, registry retirement and owner revocation around a real child-process file write. Allowed I/O succeeded; stale and completed operations were rejected before that I/O. The relevant controller code is unchanged in the final candidate.
  • The repository-wide link audit reports an unchanged main-branch link: plugins/hooks.md:134 :: /plugins/hooks/reference#sessions-and-compaction :: fragment not found (terminal: /plugins/hooks/reference#sessions-and-compaction). Neither page is changed here.

Measured cleanup-test costs (CI reports individual case durations, not isolated file wall time):

Suite Host runner wall seconds CI sum of case seconds
Harness registry, 15 cases 68.00 0.034
Session initialization, 8 cases 54.05 1.222
Gateway lifecycle, 16 cases 156.42 37.728
Agents API persistence, 28 cases 111.69 40.436

The new registry, initialization, Gateway reset and Gateway deletion cases took 0.004, 0.889, 3.361 and 2.252 seconds in CI, respectively.

@clawsweeper

clawsweeper Bot commented Sep 30, 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.

@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: 🧂 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. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 6:12 PM ET / 22:12 UTC (Revision 24).

ClawSweeper review

What this changes

Adds an optional plugin controller for connecting, reusing, and retiring self-hosted Agents API executors, with persisted ownership and retryable session cleanup.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main lacks plugin-selected executor controllers. No actionable correctness or security findings remain, and the new evidence resolves the previous authority, cleanup-retry, and saved-session compatibility blockers.

Priority: P2
Reviewed head: f71b67ab416a10241e46cb0cb569083852450c2c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong source-linked runtime evidence supports a coherent patch with no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.
Evidence reviewed 9 items Introduced changes and merge ownership: Reviewed the pinned merge-base-to-head changes. The raw test-merge parents are exactly c376ffd followed by f71b67a; its corresponding production changes preserve base-branch work.
Still necessary on current main: Fetched main retains bindings without controller/executor fields and has no controller resolver. The supplied merged related PRs address MCP normalization and worker-owned binding settlement, rather than executor selection. A supplemental GitHub title search was denied by the limited read interface; source and supplied related-item inspection succeeded.
Complete runtime evidence inspected: Read #161609 (comment) in full. Its SHA-256 matches the captured source identity 772c71ac3ce252003c5a23ff79e0051e81893932c87104cab614dce9d3751150. Real ARM64 Docker Gateway/Agents API traces show concurrent executors, healthy reuse, recovery without duplicate writes, failed reset/deletion retaining local and native ownership, and successful explicit retries after restart.
Findings None None.
Security None None.

How this fits together

The Agents API harness connects OpenClaw conversations to native agent sessions. Selected controller plugins manage executor infrastructure, while the harness preserves conversation identity and coordinates cleanup.

flowchart TD
  A[Conversation input] --> B[Agents API harness]
  B <--> C[Saved session binding]
  B --> D[Native connection request]
  D --> E[Selected controller plugin]
  E --> F[Self-hosted executor]
  B --> G[Native settlement and cleanup]
  G --> C
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +880, Tests +1702, Docs +290, Generated 0, Other +3. Total +2875 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 27 1145 265 +880
Tests 10 1831 129 +1702
Docs 3 312 22 +290
Config 0 0 0 0
Generated 2 3 3 0
Other 1 5 2 +3
Total 43 3296 421 +2875

Review metrics

Metric Value Why it matters
Configuration surface 1 optional setting; 0 changed defaults Controller selection is explicit and preserves the externally managed execution path.
Production versus test growth Production +1140/−265; tests/support +1831/−129 TypeScript growth implements the documented controller, recovery, and cleanup contracts rather than another storage owner.

Technical review

Best possible solution:

Keep native identity and settlement in the existing harness, with infrastructure management delegated through the documented opt-in controller contract.

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

Not applicable as a feature request; the supplied real Gateway failure traces establish the cleanup defects and their repaired retention/retry behavior.

Is this the best way to solve the issue?

Yes. The narrow controller contract preserves existing external management, uses the existing registry and binding owners, and avoids a universal infrastructure launcher.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded, opt-in execution improvement with no demonstrated urgent user regression.
  • merge-risk: 🚨 compatibility: The PR adds a public plugin contract and persisted ownership fields; exact-base saved-session proof covers compatibility for the introduced changes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The controller resolver is exercised through the packaged loader with allowed file I/O and rejection after revocation or completion. Real ARM64 Gateway/Agents API traces cover executor reuse/recovery, failed cleanup retaining ownership, successful retries after restart, and compatible saved hosted/external sessions; tested production code matches the reviewed behavior.

Evidence

What I checked:

  • Introduced changes and merge ownership: Reviewed the pinned merge-base-to-head changes. The raw test-merge parents are exactly c376ffd followed by f71b67a; its corresponding production changes preserve base-branch work. (f71b67ab416a)
  • Still necessary on current main: Fetched main retains bindings without controller/executor fields and has no controller resolver. The supplied merged related PRs address MCP normalization and worker-owned binding settlement, rather than executor selection. A supplemental GitHub title search was denied by the limited read interface; source and supplied related-item inspection succeeded. (extensions/agentsapi/agentsapi-binding-record.ts:3, e557d807ffba)
  • Complete runtime evidence inspected: Read feat(agentsapi): select plugin-owned self-hosted executors #161609 (comment) in full. Its SHA-256 matches the captured source identity 772c71ac3ce252003c5a23ff79e0051e81893932c87104cab614dce9d3751150. Real ARM64 Docker Gateway/Agents API traces show concurrent executors, healthy reuse, recovery without duplicate writes, failed reset/deletion retaining local and native ownership, and successful explicit retries after restart. (284b35305685)
  • Runtime proof remains applicable: The tested runtime commit was unavailable locally, so GitHub tree and exact-content reads supplied comparison evidence. Registry cleanup, reply-session reset, the cleanup error, and its SDK export have identical blobs at tested runtime and reviewed head. The harness difference is formatting only; other differences are tests and SDK budget accounting. GitHub's diverged compare view was not treated as an endpoint diff. (extensions/agentsapi/agentsapi-harness.ts:225, f71b67ab416a)
  • Final-effect authority proof: The complete proof comment records a real packaged plugin loader and registry lifecycle around child-process filesystem I/O. Current authority creates the file; registry retirement, owner revocation during awaited preparation, and retained authority after completion reject before writing. The controller resolver, registration, capture, and public API files are unchanged from the authority-proof source. (src/plugins/agent-executor-controller.ts:69, a8d1b87d6319)
  • Stored-state compatibility: The new ownership fields are optional for existing bindings. Exact-base hosted and externally managed sessions continued after candidate image replacement with unchanged local/native identities, fingerprints, configuration, and external files/processes. Release v2026.9.8 has no executor ownership fields; its earlier authFingerprint format is pre-existing base evolution, not introduced by this PR. Ownerless factory-controlled bindings concern earlier branch versions and have an explicit documented cutover. (extensions/agentsapi/agentsapi-binding-record.ts:27, fc23bc864e45)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (23 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-03T02:54:56.656Z sha 2535257 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T10:09:17.121Z sha ff798a14930a0b9dacf0bf01c89e09e4f4cf7c30 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T10:18:17.768Z sha 414b227c6d196e2a8498aa7bb6762bb099ac60d8 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T10:30:00.931Z sha afec6e6 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T20:56:00.954Z sha eb2636f5e303cf0a9ab8727d63dbd2b44c877f34 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T21:09:37.639Z sha a8d1b87 :: needs real behavior proof before merge. :: [P1] Keep native settlement failures out of best-effort cleanup
  • reviewed 2026-10-04T21:33:33.262Z sha 83e8c1a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T21:51:51.273Z sha bec9c1d8eadf67d862f82a1f5fb5aa9fa06f345c :: needs real behavior proof before merge. :: none

@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-executor-controller branch 2 times, most recently from d84ed11 to 0fa140a Compare September 30, 2026 07:04
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-executor-controller branch from 0fa140a to f974cc4 Compare October 1, 2026 09:29
@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 scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling extensions: codex labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

Current revision: f71b67ab416a10241e46cb0cb569083852450c2c

This PR no longer changes files in the maintainer security-review tier.

Separate CODEOWNERS requirements still apply to security policy and enforcement files.

@sjf-oa
sjf-oa changed the base branch from main to sjf/cron-current-agent-tools October 1, 2026 09:30
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation app: web-ui App: web-ui labels Oct 1, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 2, 2026
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-executor-controller branch from 2535257 to ad826c4 Compare October 4, 2026 10:00
@sjf-oa
sjf-oa force-pushed the sjf/cron-current-agent-tools branch from 6a4a5b9 to e08f34a Compare October 4, 2026 10:00
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-executor-controller branch from ad826c4 to ff798a1 Compare October 4, 2026 10:02
@sjf-oa
sjf-oa force-pushed the sjf/cron-current-agent-tools branch from e08f34a to fe759c3 Compare October 4, 2026 10:11
@sjf-oa
sjf-oa force-pushed the sjf/agentsapi-executor-controller branch 2 times, most recently from 414b227 to afec6e6 Compare October 4, 2026 10:21
sjf added 9 commits October 4, 2026 13:45
ClawSweeper requested: "Require acknowledged settlement or a durable execution fence before removing ownership, and preserve the binding on failure; only retirement of already-settled executor resources should be best effort."

Propagate native settlement failures, reacquire agent-scoped API-key authentication after restart, and invalidate failed cleanup handles so repaired authentication takes effect on retry. Keep executor retirement best effort only after native settlement. Cover reset, deletion, restart, authentication, and revoked cleanup authority.
ClawSweeper requested: "Require acknowledged settlement or a durable execution fence before removing ownership, and preserve the binding on failure; only retirement of already-settled executor resources should be best effort."

Propagate required cleanup through the host reset boundary and run it before automatic session replacement. Join sibling hooks before releasing mutation admission while preserving ordinary optional-hook behavior.
@sjf-oa

sjf-oa commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Cleanup repair and runtime proof

Current head: f71b67ab416a10241e46cb0cb569083852450c2c.

The approved settlement repair now preserves native ownership when status reads, cancellation or authentication fail. The host also propagates required cleanup failure before changing the local session, including the real /new entry point, and waits for sibling cleanup callbacks to settle. Ordinary optional reset hooks retain their existing best-effort behavior. The implementation commits quote the review request.

The maintainer-selected design retains the narrow opt-in controller contract and persisted controller ownership, with infrastructure/process management in the selected plugin and externally managed sessions preserved.

Live runtime evidence

Tested on 2026-10-04, America/Los_Angeles. All images ran natively as linux/arm64, with a local Docker Gateway and real Agents API sessions. Controller-managed executors ran as independent processes on one persistent remote host and shared workspace.

Role Source Immutable local image
Original PR baseline a8d1b87d6319bca89efd649e0f02c696c4a282fe sha256:6e24a2b85d6ccc7215d0acc24cb5419a5ded542ac878eaca32baa55e4414ab1a
Intermediate candidate, concurrency/recovery 714c9b7cf79b2728dfb63156c23225964e144a24 sha256:46de4cfdbc3e8b1c803943fd10c57dba326e56775c2dae2451608f3338a22b85
Final runtime, strict lifecycle and Slack rollover 284b35305685b7b47cb2fd6fbd519133ea518b8d sha256:b686781c633fbd5579124ca2ad83559e4de0457609225b14deb4a6c35a13d6d2
PR's exact main base for upgrade proof a406897d6dd9ac1a510d1760cea3516ce5b7913e sha256:42cd66ddc96c119cf19b5f8251ef87862fd0f4a1ad93249ac50ea8bf0a380766

The published head differs from the final runtime source only in test fixtures, formatting, and SDK export accounting. The tested runtime is identified above rather than claiming a different commit was built.

Actual Gateway failure and recovery

A private test-only transport wrapper rejected one exact native-session GET or cancellation POST with ECONNRESET. It did not fabricate API responses. Reads from an independent observer bypassed the wrapper. All unaffected requests used the real service.

Commands below represent the actual private proof driver. <proof-root>, local session keys, native session identifiers, remote host, and workspace paths are explicit substitutions for private operational values. The driver invoked the shipped openclaw/plugin-sdk/gateway-runtime client against the running authenticated Gateway; it is not an OpenClaw CLI command.

python3 <proof-root>/gateway-call.py sessions.reset \
  '{"key":"<session-B>","expectedSessionId":"<local-session-B>"}' \
  --head 284b35305685b7b47cb2fd6fbd519133ea518b8d \
  --record final-read-fault-reset.json

python3 <proof-root>/gateway-call.py sessions.delete \
  '{"key":"<session-C1>","expectedSessionId":"<local-session-C1>"}' \
  --head 284b35305685b7b47cb2fd6fbd519133ea518b8d \
  --record final-cancel-fault-delete.json

Original baseline: the injected session-read failure still produced sessions.reset: {ok:true}, removed the persisted native binding, and stopped executor PID 518697. This was the real failing Gateway entry point.

Final runtime, GET failure: the RPC returned the following actual error text (the trailing truncation was returned by the Gateway):

{
  "ok": false,
  "method": "sessions.reset",
  "error": {
    "name": "GatewayClientRequestError",
    "message": "AgentHarnessSessionCleanupError: Connection error. | fetch failed | PR161609 proof injected connection reset | ECONNRESET <- Error: Connection error. <- TypeError: fetch failed <- Error: PR161609 proof injected connection reset: code=ECONNR...",
    "code": "UNAVAILABLE"
  }
}

The local session ID, lifecycle revision and updated timestamp were unchanged. The same persisted native binding and executor PID 520887 remained. After removing the fault, one explicit reset retry succeeded: the real API reported idle at 14:47:21 PDT, then the controller reported that executor absent at 14:47:22 PDT. Sibling executors and shared files remained.

Final runtime, active cancellation failure: actual Gateway input started a bounded foreground sleep 180. The observed child PID 566894 belonged to executor PID 539624. A task-only Gateway crash/restart left the independent native session in_progress. The exact cancellation POST was rejected; sessions.delete returned the same UNAVAILABLE cleanup error above, with method sessions.delete. The local session remained readable, its native binding remained, executor PID 539624 remained, and an independent API read still reported in_progress.

After removing that fault, one explicit deletion retry produced the following extracted receipt fields in order. Time fields are rendered in Pacific time, and identifiers are consistently replaced with native-C1.

{"time":"2026-10-04 14:51:41 PDT","session":"native-C1","operation":"session-read","httpStatus":200,"nativeStatus":"in_progress"}
{"time":"2026-10-04 14:52:05 PDT","session":"native-C1","operation":"cancel","httpStatus":202}
{"time":"2026-10-04 14:52:05 PDT","session":"native-C1","operation":"session-read","httpStatus":200,"nativeStatus":"in_progress"}
{"time":"2026-10-04 14:52:11 PDT","session":"native-C1","operation":"session-read","httpStatus":200,"nativeStatus":"idle"}
{"time":"2026-10-04 14:52:18 PDT","session":"native-C1","operation":"controller.stop","state":"ABSENT"}
{"time":"2026-10-04 14:52:22 PDT","operation":"sessions.delete","ok":true,"deleted":true}

The backend session remained queryable and idle afterward. This proves cancellation settlement before local retirement, not deletion of the native API session or revocation of independently held API credentials.

Shared workspace, concurrency and process recovery

Two separate top-level Slack requests created two native sessions and executor PIDs 518697 and 520887. The first wrote one newline-terminated marker to <workspace>/shared-proof.txt; the second read it and appended another marker. Both returned the exact same shared contents. A healthy follow-up retained the original session/process with no additional controller ensure.

The Gateway image replacement preserved PID 520887, its native session ID, and the shared file. A subsequent Slack follow-up returned both original lines without another ensure.

Three new top-level Slack requests were admitted within 3.3 seconds. They overlapped, used three separate native sessions and PIDs 539624, 539770, and 539814, and each completed with its own single appended marker plus the same shared file contents. Replies completed at 14:29:35, 14:29:37, and 14:29:43 PDT.

A scoped idle-executor stop removed PID 539814. One follow-up through the same Slack session caused a second ensure and replacement PID 541394, retained the same native session ID, and appended proof-161609-recovered-once exactly once. Sibling processes remained unchanged.

Slack-visible rollover on final runtime

A real /new message in one owned Slack thread retired only that thread's old native session/executor at 14:52:50 PDT. A distinct native session/executor was created at 14:52:58 PDT. Its follow-up used the native terminal to read the shared file and its predecessor's per-session marker file. Both contents were preserved. The recovered sibling executor PID 541394 remained alive.

Exact-main saved-session upgrade

PASS: created real hosted and externally managed self-hosted sessions on the PR's exact main base, then replaced only the Gateway image with the final runtime. Both configurations omitted the executor controller. The same saved state/configuration was reused, without reset, native-session replacement or binding edits.

Before/after records for both modes remained byte-for-byte equal as JSON values: the same local session ID, native session ID and configuration fingerprint; neither record acquired controller/executor fields. The independently managed external executor retained PID 574374 and its existing file.

Extracted terminal receipts:

{"hosted":{"localIdentityEqual":true,"nativeIdentityEqual":true,"fingerprintEqual":true},"external":{"localIdentityEqual":true,"nativeIdentityEqual":true,"fingerprintEqual":true,"executorPidEqual":true,"fileEqual":true}}
{"mode":"openai_hosted","phase":"main baseline","status":"ok","successfulToolNames":["bash"],"reply":"31 * 37 = 1147; proof-161609-current-main-hosted"}
{"mode":"openai_hosted","phase":"candidate continuation","status":"ok","successfulToolNames":["bash","memory_search"],"reply":"proof-161609-current-main-hosted; 41 * 43 = 1763","runtimeMs":20943}
{"mode":"self_hosted, externally managed","phase":"main baseline","status":"ok","successfulToolNames":["bash"],"file":"proof-161609-current-main-external\n"}
{"mode":"self_hosted, externally managed","phase":"candidate continuation","status":"ok","successfulToolNames":["bash"],"file":"proof-161609-current-main-external\n","calculation":1763,"runtimeMs":15951}

Replies above normalize Markdown while preserving returned values. The exact PR-base main source and final candidate source are identified in the image table. This is saved-session image upgrade proof, not a claim that a published updater binary or every older release was exercised.

Packaged executor-controller authority proof

PASS, tested source a8d1b87d6319bca89efd649e0f02c696c4a282fe in native arm64 image sha256:6e24a2b85d6ccc7215d0acc24cb5419a5ded542ac878eaca32baa55e4414ab1a.

An isolated plugin registered through the real packaged loader and public api.registerAgentExecutorController API. The harness resolved it through the packaged agent-harness-runtime SDK export. The harness used the real core registry lifecycle owners, markPluginRegistryRetired and revokePluginRecord, to revoke authority during an awaited callback. These lifecycle controls are harness internals, not additional public plugin APIs. No registry authority was mocked. The container had no network, credentials, or Gateway state.

The controller resolver, operation context, captured registration, registration owner, public plugin API and API builder are unchanged between this tested source and the final candidate. The later repair changes required session cleanup at the harness and host reset boundaries, covered separately by the live Gateway evidence.

Actual command, with the original host fixture path replaced by the explicitly marked placeholder <proof-directory>:

docker --context colima run --rm --network none --read-only \
  --user 501:20 --tmpfs /tmp:rw,size=256m \
  --mount type=bind,source=<proof-directory>,target=/proof,readonly \
  --entrypoint node \
  sha256:6e24a2b85d6ccc7215d0acc24cb5419a5ded542ac878eaca32baa55e4414ab1a \
  /proof/proof.mjs healthy

Separate invocations used registry-retirement and owner-revocation in place of healthy. All three completed with exit status 0. Containers were removed by --rm.

The fixture's actual registered callback and side effect were:

globalThis[Symbol.for('authority-proof.controller')] = {
  workspaceDirectory: state,
  async ensure(_binding, context) {
    retained = context;
    started.resolve();
    await gate.promise;
    context.assertCurrent();
    const child = spawnSync(process.execPath, [
      '-e',
      'require("node:fs").writeFileSync(process.argv[1],"authorized child write")',
      target,
    ], { encoding: 'utf8' });
    assert.equal(child.status, 0, child.stderr);
  },
  async retire() {},
};

The plugin entry registered that implementation with api.registerAgentExecutorController(globalThis[Symbol.for('authority-proof.controller')]). The harness awaited started.promise, retired the registry or revoked its plugin record, then released gate. context.assertCurrent() is immediately before the real child-process spawn. With current authority, the child wrote authorized.txt; the harness read the actual file and asserted its contents equaled authorized child write.

Actual stdout, healthy case:

{
  "status": "PASS",
  "mode": "healthy",
  "commit": "a8d1b87d6319bca89efd649e0f02c696c4a282fe",
  "architecture": "arm64",
  "ok": true,
  "fileCreated": true,
  "signalAborted": false,
  "filesystem": [
    "authorized.txt"
  ],
  "scope": "Real packaged loader, registry lifecycle and child-process filesystem I/O. No backend or Gateway claim."
}

Actual stdout, registry retired while the callback awaited its gate:

{
  "status": "PASS",
  "mode": "registry-retirement",
  "commit": "a8d1b87d6319bca89efd649e0f02c696c4a282fe",
  "architecture": "arm64",
  "ok": false,
  "error": "Agent executor controller plugin \"authority-proof\" is no longer available",
  "fileCreated": false,
  "signalAborted": true,
  "filesystem": [],
  "scope": "Real packaged loader, registry lifecycle and child-process filesystem I/O. No backend or Gateway claim."
}

Actual stdout, plugin owner revoked while the callback awaited its gate:

{
  "status": "PASS",
  "mode": "owner-revocation",
  "commit": "a8d1b87d6319bca89efd649e0f02c696c4a282fe",
  "architecture": "arm64",
  "ok": false,
  "error": "Agent executor controller plugin \"authority-proof\" is no longer available",
  "fileCreated": false,
  "signalAborted": false,
  "filesystem": [],
  "scope": "Real packaged loader, registry lifecycle and child-process filesystem I/O. No backend or Gateway claim."
}

The initial proof fixture incorrectly required record-only revocation to abort the signal. Source inspection showed that revokePluginRecord marks the owner revoked; assertCurrent() enforces that authority loss even when the signal remains un-aborted. The fixture was corrected to test that actual contract. No product code changed for this proof.

The healthy invocation also checked retained authority after completion:

assert.throws(() => {
  retained.assertCurrent();
  fs.writeFileSync(`${state}/late.txt`, 'late write');
}, /operation has completed/);
assert.equal(fs.existsSync(`${state}/late.txt`), false);

This passed before the healthy stdout was emitted. It proves the retained callback cannot use the completed operation's authority to reach that file write. It does not prove automatic prevention of arbitrary plugin code that ignores the contract, termination of an already-started child, backend rejection of an old session, or Gateway/Slack end-to-end behavior.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: agentsapi gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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