Repository navigation
fix(plugins): keep admitted turns running during opted-in reloads - #184243
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: blocked before merge. What this changesThis PR lets explicitly opted-in plugin generations overlap while admitted turns finish using their original generation. Example: Change Memory Core configuration during 100-second parent and native-subagent turns.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open and unmerged: the overlap capability has clear value, no new concrete defect was found, and Peter’s explicit SDK/manifest hold remains active. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway plugin reload prepares and publishes registries consumed by agent admissions, tools, providers, hooks, and services; the existing retirement owner releases predecessor resources after admitted work settles. flowchart TD
A[Plugin reload request] --> B[Prepare successor]
B --> C[Publish successor]
C --> D[New turn admissions]
C --> E[Retained predecessor turns]
E --> F[Existing retirement owner]
F --> G[Stop services and dispose resources]
Technical reviewBest possible solution: Publish successors through the existing retirement owner while old turns retain exact scoped callables and current effect checks. Do we have a high-confidence way to reproduce the issue? Current main’s pre-registration drain explains the supplied 100-second-turn timeout reproduction; no target code was executed during this review. Is this the best way to solve the issue? Extending the existing retirement and prepared-runtime owners is coherent, and both-generation opt-in preserves the documented serialization boundary for other plugins. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99f7a303e3ff. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 26, 2026, 1:44 PM ET / 17:44 UTC (Revision 4). |
9c180a9 to
7932953
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7932953d75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| maintenance.owners.delete(schedule); | ||
| if (maintenance.schedule === schedule) { | ||
| maintenance.schedule = [...maintenance.owners].at(-1); | ||
| } | ||
| for (const job of jobs.values()) { | ||
| job.cancel(); |
There was a problem hiding this comment.
Re-arm standing-intent maintenance when restoring a predecessor
If an overlapping candidate is rolled back, restoring maintenance.schedule does not transfer its pending deadlines or trigger a predecessor sweep. For example, after an empty predecessor has exhausted its startup job, creating an intent while the candidate services are preparing schedules expiration only on the candidate; stopping that candidate cancels the job and leaves the restored predecessor with no timer. Expiration and cooldown maintenance then stop until another standing-intent operation happens. Schedule an immediate reconciliation on the restored owner (or transfer its deadlines). The new overlap test misses this because it creates the intent after stopping the retiring owner, which itself re-arms maintenance.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in the current head. Restoring the predecessor now invokes its own target reconciliation callback, rather than only restoring the schedule function. The new regression starts with an idle predecessor, creates intents for two predecessor-owned targets while the candidate is active, rolls back the candidate, and verifies both expiry deadlines are re-armed and processed without another intent operation. This regression failed before the correction and passed afterward; the focused standing-intent file passed all 22 cases.
1907353 to
cc874bc
Compare
34a8390 to
8f585ef
Compare
|
@clawsweeper re-review The rollback finding is addressed. The current head has fresh 100-second parent/native-subagent overlap proof with Memory Core, completed A/B stress and four A/A controls, and exact-base/candidate focused attribution replays documented in the body. Independent subagent review (autoreview route unavailable) has no accepted findings remaining. CI is not green: the deletion failure reproduces on base, while two QA setup timeouts remain unattributed. Please keep this PR unmerged pending the SDK/manifest design acknowledgment. |
… generation Continuation's own detached re-entries already drop the arming request's scope and operator grant, but they kept the arming turn's plugin generation: its registry selection, metadata snapshot, generation registry, prepared generation pin and plugin invocation scope. A delayed continuation armed before a plugin reload then ran on the predecessor generation (jump-12 finding F-1). For an opted-in plugin it reached the closed predecessor scope; for an ordinary one the stale pins outlived the retired generation. Wrap all three re-entries in upstream's runOutsideAdmittedGenerationScopes (openclaw#184243), the helper every upstream detached path uses, with the work admission outside and the generation drop inside, as in queue/drain.ts: - dispatchPendingContinuationWorkFromDetachedCallback (work wake, idle-retry recovery and hedge re-arms); - the delegate-dispatch hedge timer; - the terminal-notice live retry. The Gateway resolver, the dropped request scope and operator grant, the fresh detached work scope and the bounded retries are unchanged. Refs karmaterminal/openclaw-bootstrap#1727 Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 0b64649)
…closed plugin scope (#196700) fix(gateway): run the automatic activity recap outside the finished run's plugin scope When a Codex run ended, the automatic Activity recap never sent its request and the recap stayed at "updating". The Codex runtime emits the run-end event inside the run's plugin invocation scope, and the recap service scheduled the recap from that event without leaving the scope (since #169622). Since #184243, new prepared-model scopes take the caller's scope as their parent, so when the recap checked utility model auth after the run had finished, it hit "Plugin invocation scope is closed", and its own error handling hit the same closed scope. The run-end recap is now scheduled inside pluginInvocationContext.exit(...), the same pattern #191126 used for #191123. The RPC and archive recap paths are unchanged. Evidence: a built Gateway in Docker with the real Codex app-server and a stand-in endpoint. On main, two Codex runs sent no automatic recap request and stayed at "updating"; with debug logging the Gateway logged "Activity recap background work failed {"error":"Plugin invocation scope is closed"}". With this change two Codex runs each sent one recap request and the summary became current. The RPC-requested recap works on both, plain OpenAI runs recap on both, and plugin-invocation-scope.test.ts passes on both, so genuinely closed scopes still throw. Co-authored-by: Ayaan Zaidi <[email protected]>
…closed plugin scope (openclaw#196700) fix(gateway): run the automatic activity recap outside the finished run's plugin scope When a Codex run ended, the automatic Activity recap never sent its request and the recap stayed at "updating". The Codex runtime emits the run-end event inside the run's plugin invocation scope, and the recap service scheduled the recap from that event without leaving the scope (since openclaw#169622). Since openclaw#184243, new prepared-model scopes take the caller's scope as their parent, so when the recap checked utility model auth after the run had finished, it hit "Plugin invocation scope is closed", and its own error handling hit the same closed scope. The run-end recap is now scheduled inside pluginInvocationContext.exit(...), the same pattern openclaw#191126 used for openclaw#191123. The RPC and archive recap paths are unchanged. Evidence: a built Gateway in Docker with the real Codex app-server and a stand-in endpoint. On main, two Codex runs sent no automatic recap request and stayed at "updating"; with debug logging the Gateway logged "Activity recap background work failed {"error":"Plugin invocation scope is closed"}". With this change two Codex runs each sent one recap request and the summary became current. The RPC-requested recap works on both, plain OpenAI runs recap on both, and plugin-invocation-scope.test.ts passes on both, so genuinely closed scopes still throw. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Plugin reloads can wait 60 seconds for admitted parent and native-subagent turns, then return
UNAVAILABLEwhile new work waits behind the drain (#183995). Those turns still need their original tools and end hooks after preparation, so releasing their generation leases early is unsafe.This change lets explicitly audited plugins declare
generationOverlap: true. A prepared successor becomes available to new work while admitted turns keep their predecessor's callable authority until they finish.User Impact
Overlap remains default-off, and both affected generations must opt in. Channels and exclusive host resources stay serialized. This PR opts in only these two bundled plugins:
reload.turnHandoverbehavior remains separate.Old turns retain their original tools, providers, hooks, and end hooks. New admissions select the published successor. Credentials, approvals, cancellation, caller/source authority, and external-effect checks remain live.
Why This Change Was Made
Generation admission and host retirement remain the owners. The host prepares the successor before publication, publishes it for new work, and retains the predecessor until its last finite holder releases. Only then does retirement stop captured services and revoke/dispose the old authority and resources. Preparation failure leaves the predecessor active; rapid toggles retire intermediate generations independently; shutdown uses the same retirement owner.
runtimeRetentionexposes outstanding holders. The retirement prerequisite was not behavior-neutral alone, so it is included here.The manifest is the capability surface; there is no parallel generation manager. If a plugin declares both overlap and turn handover, overlap takes precedence, including when another affected plugin forces serialized replacement. Detached continuations leave the completed producer's scope before fresh admission while preserving Gateway identity, cancellation, target, placement, and commit checks.
Default-off leases construct no callable consumers. Opted-in instance selection happens once per immutable generation, scopes share their consumer/binding map, and disposal reuses existing settlement waiters. Duplicate lease construction, per-consumer completion promises, and recovery/occurrence machinery now owned by main have been removed. Knowledge's manifest matches main exactly.
Production runtime/manifests grow by 756 lines (three lines are formatting of the nested retry guard after this rebase); retained authority, deferred service/resource retirement, diagnostics, and complete caller migration require that growth. The broader requested exclusion filter is +1,112, including 337 benchmark lines and fixture/config entries. The exact 1,943-line test allocation covers overlap, serialized defaults, rollback, retirement, restart, authority, and caller migration; the extra nine lines ensure failed provider entry reaches fixture cleanup. No benchmark lint suppressions or shared perf README sections were added.
Evidence
Integration base:
2f504abebddca671613ede82dee5a704fd4d9478. Final head:9557ae6f45abf2fdb7af3f62c5202b08a93e01d5.Exact-head CI attribution and repair (October 30)
The failed run at
5bd7ebc0689784f783ea85268f8a469cd69fc181was investigated from the saved logs without downloading them again. Each reported Node/UI failure was replayed twice on that PR head and twice on pinned main, usingnice -n 10,--maxWorkers=8, uptime capture, the repository test wrapper, and the native UI-E2E config. The adjacent cron user-pin and legacy-pin controls were included.2f504abe5bd7ebc0reload-baselineerrorinstead ofokNO_REPLYtestokinstead oferrorsteeredinstead offollowupThe test-line failure exposed 2,757 lines of inherited debt: CI's merged tree had 6,309,440 lines against a 6,306,683 ceiling, while the PR itself added exactly 1,943 lines and already carried exactly 1,943 lines of allocation. Main #188620 repairs the stale shared census from #188561. The rebased guard passes: 6,309,968 test lines; 6,310,000 ceiling; 32 lines slack. No allocation increase, weakened assertion, timeout increase, or lint suppression was added.
Native classification is limited to the observed failures: Android failed Gradle classpath dependency resolution before native tests; Periphery rejected missing/invalid producer-execution metadata before report download/intersection. This PR changes neither native code nor those workflows. Native infrastructure was left unchanged.
All 55 PR-focused test files pass on the rebased head, including all 48 touched tests, lifecycle consumers, closure guards, and prompt/tool prefix stability (459.9 seconds through the native wrapper).
pnpm tsgo:core,pnpm tsgo:test:root,pnpm tsgo:extensions:test, and the explicit plugin-test typecheck leaf pass. The separately attributed failures above remain failures; this focused result does not claim they were fixed. Oxlint, oxfmt, andgit diff --checkpass.Fresh Codex autoreview is scoped-clean through P2, with no accepted findings in either pass. The rebase was conflict-free and all 13 prior patches replayed unchanged. Default-off and both audited opt-ins are unchanged. One push publishes the repaired integration. No CI rerun, Team access, or merge. New exact-head CI run is queued. The PR is open, ready, and mergeable.
Prior overlap and owner measurements
These measurements compare base
f9135d23491031bbc55bd265f5be07c246b6139bwith candidateb9a5f048a720b7273f94746108e3b1b6b3c2bdb5; they have not been rerun after this main integration.Five selected regressions failed with behavior assertions on that measurement base and passed on that candidate:
draininginstead of successor publicationPrior isolated Gateway proof: config patch 742 ms, fresh successor work completed 1,392 ms after the patch request, and
tools.effective15 ms. Parent/native-child provider holds lasted 100,000 / 100,515 ms. Their old tools,before_prompt_build, andagent_endused the original registration; four real Memory Core reads succeeded. Both predecessors disappeared after final release (first retirement poll: 3 ms), old service stop/dispose ran exactly once, reload status cleared, and graceful shutdown exited 0 with no closed-scope warnings. These are functional observations, not latency percentiles.Percentages above compare arm means. Default-off CPU pairs have mixed signs, and the first pair dominates the favorable mean: this is not a stable CPU win. Default-off allocation is small/mixed, without a consistent adverse pattern. The all-opted-in cost is consistent across all five pairs (CPU +22.6–34.6%; allocation +36.0–39.5%). This is the explicit cost of retaining callable authority for all 40 synthetic plugins; only two bundled plugins opt in.
Mean sampled host load (one-minute load average, before/after each arm): default-off timing 54.27 / 53.68, allocation 48.20 / 48.65; opted-in timing 52.85 / 51.53, allocation 51.20 / 51.06, base/candidate respectively. All 44 subprocesses completed successfully and runtime artifact hashes were unchanged.
Default-off leases retain the original 40 work references and add no consumer tracking. Opted-in leases add 40 work and 40 consumer references; releasing the lease restores its pre-lease baseline (40 registration call references remain). Tool identity is preserved.
The owner protocol uses 40 synthetic plugins, 16 calls per lease, 200 warmup leases, and five counterbalanced pairs × 4,000 leases per arm and instrumentation mode. CPU and sampled allocation run separately. Default-off and all-opted-in workloads are reported separately; the latter deliberately exercises 40 retained plugin consumers. Artifact and tool identities, return to pre-lease retention after release, and host load are recorded for each arm. Historical whole-Gateway stress and identical-source controls were inconclusive; no fresh whole-Gateway non-adverse claim is made here.