Skip to content

fix: resume sessions with trusted runtime plugins absent at startup - #132804

Merged
steipete merged 5 commits into
mainfrom
codex/frv-gateway-e2e-contracts
Aug 30, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/frv-gateway-e2e-contracts

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

A resumed session could select a trusted runtime harness absent from Gateway startup and fail before execution. The same ownership gap affects selected providers and fallbacks in replies and scheduled turns. Prepare those owners before admission freezes the selected generation, then carry that exact lease through execution and cleanup. Concurrent selections remain isolated; nested work can borrow only owners already contained in an open, matching parent lease. Published inbound registry metadata stays unchanged.

Cron now acquires one lease during preparation using the executor’s per-agent configuration projection. The duplicate late acquisition and obsolete generation-scope wrapper are removed. Explicitly disabled or untrusted plugins remain unavailable.

The configured runtime owner also inventories the canonical subagent primary/fallback chain alongside ordinary configured candidates. Automatic subagent sessions can choose that separate chain after admission; ordinary fallbacks already worked. Execution policy still narrows user overrides and locked selections, and the strict borrowed-generation guard is unchanged. Copying session policy into outer admission would use stale state after queue waits.

Acceptance testing exposed another owner-boundary defect: the first chat.abort loaded unrelated chat history/send workflows before reaching cancellation. It now lazily dispatches directly to the existing abort handler. The old chat-map entry and single-use service wrapper are deleted; wire method, permissions, descriptor order, profile gate, and cancellation policy are unchanged. The auth-refresh fixture now captures the actual selected lease before ACK, proves it survives refresh, and proves the next lease is newer. It also records first-frame receipt directly and drains every RPC listener.

Evidence

  • Before/after reproduction: the published owner failed automatic subagent fallback with a superseded-generation error. The repair passes real Gateway RPCs using two distinct lazy provider plugins, retryable primary HTTP 503, persisted automatic-selection provenance, provider-specific prompt hooks, and the fallback response. A deterministic import-isolation regression fails the old cancellation route and passes the direct route.
  • Final Linux proof: normal frozen install, full build in 3m46.6s, 8 Gateway E2Es passed in 33.53s. Coverage includes copied-session success and disabled/untrusted rejection, cron and subagent fallback, configured cron harness selection, recurring registry ownership, and cold cancellation. Cancellation requires the exact run ID, actual provider request closure before cleanup, and exactly one provider request. These use local HTTP providers and synthetic trusted harnesses, not authenticated external Codex completion.
  • Linux tested tree: 78e0c984952c3717cbb52a461a4a58cef6e4af70. Complete tracked bytes/paths/modes were guarded through install, build, and tests; both build-stamp checks remained unchanged. The owned lease stopped after completion. The subsequent preintegration commit differed only by one changelog bullet.
  • Local ownership proof: 429 passed, 1 existing platform skip across 17 files. Cancellation/auth/persistence/registry/agent sibling proof: 586 passed across 11 files. Canonical check:changed passed structural, formatting, all three unused-export scans, production/test types, lint, and ownership guards. The final test-only oracle correction also passed focused lint and E2E typechecking.
  • One integration rebase onto pinned main 5b532a78ee1f697aeb484104f0aa980501b8fc1b incorporates known shutdown/clipboard repairs. Among PR-touched paths, only changelog context and inherited pending-work dispatch code changed. Fresh integration proof at 8b56ea1875ecb07f76053f07130eb1c48b46f777: 128 passed, 7 existing skips across 10 files, covering generation/fallback, auth refresh, lazy dispatch, suspension/node shutdown, config snapshots, registry diagnostics, state binding, and WAL. Dependency versions and lockfile are unchanged. Upstream state/bootstrap changes mean the retained Linux build is explicitly preintegration evidence, not a built test of this rebased head; exact-head hosted CI remains required before landing.
  • The first integrated CI run exposed three remaining integration failures: a full agent-scope fixture mock omitted newly used canonical policy exports, a direct chat fixture still used the removed chat-family abort entry, and the integrated dispatch file exceeded its existing lint limit. The final closeout at 622760472cc6471f983458c06cb7e0c74ca6b073 removes the full policy mock, uses canonical lazy handler dispatch in the fixture, and combines identical pre-connect/health returns (net −3 production lines). 188 tests passed across 7 files, including the full 136-case chat suite in its original order and all 8 static-startup cases. The fixture now observes a refresh failure before waiting for hook entry: the same broken-mock error surfaced in 85 ms, instead of timing out at 120 seconds. Assertions and timeouts are unchanged. Canonical changed-file gates and a fresh Codex P0–P2 review passed on the final repair.
  • A later changelog-only merge conflict suppressed pull-request CI at 622760472cc6471f983458c06cb7e0c74ca6b073. One justified refresh onto pinned main 4db43443acc1f636550d39fccb3017340cc42c78 resolves that conflict at b5038f732006a54f69ea24b06c546999340f92fc: all 45 non-changelog PR files retain identical blobs and modes, and the 46-path PR scope is unchanged. Fresh focused integration proof passed 185 tests across 6 files in 78.71s, covering auth ordering, prepared reply metadata and prompt bytes, configured/subagent fallback, WebSocket abort authorization, and pending-node lifecycle. Fresh Codex P0–P2 review found no actionable integration defects. The prior Linux proof remains preintegration; exact-head hosted CI is still required.
  • The next exact-head CI run passed the runtime repairs but failed two Matrix QA cleanup cases: their test helper tried to rebind a released TCP port, which another worker could already own. Final repair 454f371c1d3922c8135439e95548e0af15709227 replaces that global availability check with the fixture’s recorded fulfillment of the real proxy stop, and deletes the unused helper. A deterministic competing listener reproduces the old false EADDRINUSE after confirmed owner closure. Negative controls prove that omitted cleanup still fails the closure assertion and unjoined cleanup still fails the existing ordering assertion. The full canonical QA shard passed 228 files, 3,127 tests, 3 platform skips on the final patch (279.37s Vitest; 286.34s wrapper). The local macOS private-QA artifact build completed in 4m39.5s before this two-file test-only patch; production bytes are unchanged. Scoped canonical checks, including extension-test types and lint, and fresh Codex P0–P2 review passed. This increment changes zero production lines and removes 12 net test/support lines. Final exact-head hosted CI passed on 454f371c1d3922c8135439e95548e0af15709227: 176 successful jobs, 15 skipped, zero failures, attempt 1. The retained Linux proof remains explicitly preintegration evidence.
  • Direct Codex contract inspection: thread.rs:330–415 and thread_processor.rs:3519–3710. The original failure precedes native thread resumption. Final Codex P0–P2 review and independent integration-owner audit found no actionable defects.

Review closeout and follow-up

ClawSweeper’s latest completed review found the runtime and cancellation repairs correct. Its changelog-removal rank-up move is intentionally skipped: the maintainer explicitly requested these user-facing release-verification fixes in the changelog. All existing main entries are preserved. Its exact-head CI requirement is satisfied by run 33283439682; the production-growth justification is below. The reported persistent-data heuristic points at src/cron/isolated-agent/run.test-harness.ts: that diff replaces Vitest registry mocks with prepared-lease snapshots and a mocked release function; it does not change a store or schema.

Named follow-up: zero-output cancellation is reclassified as blocked failure. Existing runtime owners record zero-output abort as blocked recovery state, and canonical terminal projection prioritizes blocked. The first cold test run passed 7/8 because its expected undispatched timeout contract was wrong. The corrected test requires the precise existing error/failed/aborted result, nested aborted/blocked metadata, no runtime error, and provider closure. No global terminal-precedence change or permissive multi-status assertion is included here.

Production: +299/−201, net +98; tests/support: +1231/−355, net +876; changelog: +3. Production growth supplies immutable selected-generation ownership and configured candidate inventory. The final incremental fallback repair is net +12; direct cancellation routing is net −4. Duplicate execution-policy paths and wrappers were removed. This PR adds or changes zero config, environment, schema, protocol, or migration surfaces.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 29, 2026, 8:48 PM ET / August 30, 2026, 00:48 UTC.

ClawSweeper review

What this changes

The branch prepares trusted plugins selected by persisted sessions before execution, carries the resulting lease through Gateway, reply, embedded-agent, and cron paths, and routes cancellation through a dedicated lazy handler.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open for maintainer review. The runtime-owner and lazy-cancellation changes are coherent and covered by focused boundary tests, but the branch still edits the release-owned changelog without independently verifiable release-owner approval, and current-main source could not be fetched for a final behavior comparison.

Priority: P1
Reviewed head: 454f371c1d3922c8135439e95548e0af15709227
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The runtime patch has strong focused owner-boundary coverage; resolving the release-owned changelog deviation and refreshing against current main would complete review confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied exact-head Gateway and CI evidence is supplemental context.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied exact-head Gateway and CI evidence is supplemental context.
Evidence reviewed 7 items Prepared lease owner: Admission passes the selected provider and harness into the prepared-runtime acquisition, then retains the lease-selected generation for downstream execution.
Lease safety boundary: Borrowed snapshots require an open matching generation, matching runtime inputs, and a generation that contains every requested selected plugin.
Cancellation dispatch: The protocol descriptor preserves chat.abort permissions while assigning it to a dedicated lazy handler family, whose handler validates request parameters and retains existing authorization checks.
Findings 1 actionable finding [P3] Remove release-owned changelog entries
Security None None.

How this fits together

Gateway and scheduled agent runs resolve a model and its trusted plugin owners before executing under a prepared lease. A chat cancellation request is dispatched by Gateway and should reach the cancellation owner without loading unrelated chat workflows.

flowchart LR
A[Persisted session or cron job] --> B[Model and plugin selection]
B --> C[Prepared runtime lease]
C --> D[Gateway, reply, and cron execution]
E[chat.abort request] --> F[Lazy cancellation handler]
F --> G[Active run cancellation]
Loading

Decision needed

Question Recommendation
Should this normal PR retain the two release-owned CHANGELOG.md entries? Remove the entries: Keep the user-facing release context in the PR body or squash message and let release generation own CHANGELOG.md.

Why: The repository policy reserves changelog generation to the release process, while the PR body asserts an exception that could not be independently confirmed from the available discussion.

Before merge

  • Remove release-owned changelog entries (P3) - CHANGELOG.md is reserved for release generation, but this normal PR adds two release bullets. Keep the release context in the PR body or squash message unless release-owner approval for this exception is recorded.
  • Resolve merge risk (P1) - This changes plugin/provider activation for persisted selections that existing Gateway startup did not load; disabled and untrusted cases are covered, but final current-main compatibility review remains unavailable in this checkout.
  • Resolve merge risk (P1) - The bug fix has a net production increase of 98 lines; it is plausibly justified by carrying immutable selected-generation ownership across execution boundaries, but the branch should retain only that necessary owner-boundary code.
  • Resolve merge risk (P1) - The release-owned changelog entries remain in the branch despite the normal-PR policy.

Findings

  • [P3] Remove release-owned changelog entries — CHANGELOG.md:75-77
Agent review details

Security

None.

PR surface

Source +61, Tests +913, Docs +3. Total +977 across 48 files.

View PR surface stats
Area Files Added Removed Net
Source 26 347 286 +61
Tests 21 1183 270 +913
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 48 1533 556 +977

Review metrics

Metric Value Why it matters
Production versus test delta production +299/−201 (net +98); tests/support +1231/−355 (net +876); changelog +3 The production growth implements lease-generation ownership across runtime boundaries; the large test delta provides focused regression coverage, while the release-owned changelog addition needs resolution.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/cron/isolated-agent/run.test-harness.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Remove release-owned entries before merge (recommended)
    Drop the two changelog bullets and preserve their release context in the PR body or squash message.
  2. Accept an approved release exception
    A release owner can explicitly retain the entries after confirming that this PR is part of the release-owned changelog workflow.

Technical review

Best possible solution:

Keep the single prepared-lease flow and dedicated cancellation handler, remove the release-owned changelog entries, and complete an exact-current-main compatibility check before merge.

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

Yes, source provides a high-confidence boundary scenario: a persisted selected runtime absent from the configured startup registry must be acquired before execution, while disabled or untrusted owners must remain rejected. This review did not execute the scenario because the checkout is read-only.

Is this the best way to solve the issue?

Yes for the runtime and cancellation changes: selected owners are prepared at the lifecycle boundary and cancellation no longer imports unrelated chat workflows. The remaining changelog addition is not the repository’s normal release-note path.

Full review comments:

  • [P3] Remove release-owned changelog entries — CHANGELOG.md:75-77
    CHANGELOG.md is reserved for release generation, but this normal PR adds two release bullets. Keep the release context in the PR body or squash message unless release-owner approval for this exception is recorded.
    Confidence: 0.97

Overall correctness: patch is correct
Overall confidence: 0.72

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 88c17a49b1cc.

Labels

Label justifications:

  • P1: The PR repairs persisted-session and scheduled-run execution paths that can fail for active users when a trusted selected plugin was absent at startup.
  • merge-risk: 🚨 compatibility: Persisted-session execution now activates selected plugin owners that prior startup composition omitted, affecting existing runtime selection behavior.
  • merge-risk: 🚨 auth-provider: Selected provider plugins and their synthetic-auth handles can now enter the prepared runtime generation during admission.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the supplied exact-head Gateway and CI evidence is supplemental context.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Remove the two CHANGELOG.md entries or record explicit release-owner approval.
  • Run the focused runtime-owner compatibility checks against the exact current main merge result.

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 (5 earlier review cycles)
  • reviewed 2026-08-29T19:38:17.658Z sha 30720b6cab3b602a38ab59cf1c4905c40ca58e1e :: found issues before merge. :: [P1] Prepare fallback owners before Gateway admission | [P1] Prepare fallback owners before reply execution | [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-29T19:52:04.245Z sha 900f14c :: needs changes before merge. :: [P1] Prepare the entire fallback chain before Gateway admission | [P1] Prepare reply fallback owners before opening the reply lease
  • reviewed 2026-08-29T23:22:43.776Z sha 8b56ea1875ecb07f76053f07130eb1c48b46f777 :: found issues before merge. :: [P3] Remove release-owned changelog entries
  • reviewed 2026-08-30T00:08:15.470Z sha b5038f7 :: found issues before merge. :: [P3] Remove release-owned changelog entries
  • reviewed 2026-08-30T00:38:16.727Z sha 454f371 :: found issues before merge. :: [P3] Remove release-owned changelog entries

@steipete
steipete force-pushed the codex/frv-gateway-e2e-contracts branch from 30720b6 to 900f14c Compare August 29, 2026 19:43
@steipete
steipete marked this pull request as ready for review August 29, 2026 19:45
@steipete
steipete force-pushed the codex/frv-gateway-e2e-contracts branch from 900f14c to 8b56ea1 Compare August 29, 2026 23:15
@steipete
steipete requested a review from a team as a code owner August 29, 2026 23:15
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The configured owner now prepares the canonical subagent fallback chain before admission, addressing the remaining fallback-owner finding. Acceptance testing also exposed a cold cancellation delay; chat.abort now lazily dispatches directly to its existing owner, with the redundant chat entry and service wrapper removed.

The PR body records the exact preintegration Linux tree (8/8 real Gateway E2Es), fresh rebased-head integration proof (128 passed, 7 existing skips), clean P0–P2 review, and the named zero-output cancellation classification follow-up. The initial cold-test oracle failure is disclosed separately from the final passing proof.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
Carry the lease-selected immutable generation through Gateway, channel,
embedded, and cron execution. Reuse only matching imported owners, preserve
published metadata and inbound registries, and keep nested authority tied
to the exact open parent lease.

Consolidate cron preparation and execution on one selected lease using the
same per-agent configuration projection, and remove the duplicate late
acquisition and redundant scope wrapper.
@steipete
steipete force-pushed the codex/frv-gateway-e2e-contracts branch from 6227604 to b5038f7 Compare August 29, 2026 23:59
@steipete

Copy link
Copy Markdown
Contributor Author

Current-main compatibility closeout: a temporary, uncommitted merge of PR head 454f371c1d3922c8135439e95548e0af15709227 with pinned main 6b22716a81aa7a00f86933a339adec66bc1702ed produced tree deb2574d8bcfcf006f6ae29a51b57d8cced4763f without conflicts. All 48 PR file blobs and modes remained identical. Eight focused files passed 133 tests in 60.30s, covering configured/subagent fallback, inbound/selected registry isolation, plugin context, Gateway auth refresh, lazy cancellation, Code Mode import cancellation, and Codex app inventory/thread policy. Personal source inspection and an independent Codex-owner audit found no unresolved integration interaction. The temporary merge was aborted afterward, restoring the original clean PR head.

This is focused local merge-result proof, separate from the green exact-PR-head hosted CI and earlier preintegration Linux build/E2Es. Existing Vitest 4.1.11 lacks main's newly added CLI argument-validation hunk; no package versions changed, the valid test arguments were unchanged, and dependencies were not reconciled. No new source changes or PR push were needed for this check.

@steipete
steipete merged commit bee48f7 into main Aug 30, 2026
254 checks passed
@steipete
steipete deleted the codex/frv-gateway-e2e-contracts branch August 30, 2026 01:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…penclaw#132804)

* fix(agents): prepare selected runtime generations before admission

Carry the lease-selected immutable generation through Gateway, channel,
embedded, and cron execution. Reuse only matching imported owners, preserve
published metadata and inbound registries, and keep nested authority tied
to the exact open parent lease.

Consolidate cron preparation and execution on one selected lease using the
same per-agent configuration projection, and remove the duplicate late
acquisition and redundant scope wrapper.

* fix(agents): prepare configured subagent fallback owners

* fix(gateway): dispatch cancellation through its lazy owner

* test: repair runtime owner integration fixtures

* test(qa): assert Matrix proxy cleanup by owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant