Skip to content

fix(gateway): keep model metadata available during plugin drains - #162301

Merged
steipete merged 7 commits into
mainfrom
steipete/perf-micro-config-reload-plugin-drain-20260919
Oct 1, 2026
Merged

steipete merged 7 commits into
mainfrom
steipete/perf-micro-config-reload-plugin-drain-20260919

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Model catalog and chat metadata RPCs waited behind the full plugin drain budget even when a failed replacement left the previous generation active. Later unrelated config edits could also retry the same unresolved plugin drain.

User Impact

Passive catalog, auth-status, and chat metadata readers retain the active publication while admitted plugin work drains. New execution and catalog mutations remain fenced. Ordinary calls stop entering before their drain is observed; retained calls and exact-owner memory cleanup keep their existing authority and physical settlement guarantees. Publication retires before resource cutover.

An automatic drain failure is recorded once for its generation and unresolved plugin paths. Explicit openclaw plugins reload <id> --wait, reversion, or generation settlement permits recovery. Reverting plugin A while changing plugin B works, including when the entries container was previously absent. Pure model-selection/provider config already hot-applied; the regression protects that behavior.

No new config option, schema, persisted state, protocol, or SDK surface. Existing installations need no migration; this changes in-process reload behavior.

Why This Change Was Made

The integration with main's downloaded-catalog publication owner (#158000) preserves its config advancement and degraded-startup gate. Downloaded catalogs wait outside the publication queue during plugin drains, and already-preparing candidates recheck the gate before commit. The superseded config-advancer helper is removed.

Evidence

A real isolated Gateway serves WebSocket plugins.reload, models.list, and chat.metadata with a synthetic registered plugin holding an admitted RPC. On baseline 5ca201627d3d, both readers remained blocked through the simulated 60,000 ms drain deadline while config.get responded. With the fix, both complete while reload is pending and retain the active registry after failure.

RPC Original Fixed, drain pending After failed drain
models.list Blocked through 60,000 ms simulated deadline 10.21 ms wall 13.00 ms
chat.metadata Blocked through 60,000 ms simulated deadline 9.11 ms wall 11.55 ms

These are individual fixture timings, not production percentiles. The synthetic plugin exercises the shared owner; no live Codex attempt or production deployment was performed.

Validation

All heavy checks ran on blacksmith-testbox, profile openclaw-check. All task leases are stopped. Independent Codex review of the complete candidate against the conflict-resolution base is clean at P0–P2.

  • Initial owner coverage: tbx_01m3thvk4zst8meqnaq3je08by passed 378 tests in 91.97 s, then 145 follow-up tests in 31.79 s, types, scoped lint, and selected guards. Earlier changed checks passed all 27 test graphs, formatting, ratchets, and dead-export scans.
  • Reader baseline proof: tbx_01m3tc8ac16h5dc89q7yggm0sr, run, node scripts/run-vitest.mjs src/gateway/server-plugins.lifecycle.readers.test.ts --maxWorkers=1. Fixed fixture: 9.873 s, 36.48 s cold wall.
  • Final catalog integration: tbx_01m3v3pbw9mf2cq3byytcmdzbe passed 37 tests across remote publication, hot-reload dispatch, auth adoption, lifecycle, and the reader fixture in 77.93 s. The table uses this capture. Core and affected test types, lint, and Madge passed.
  • Final Gateway/recovery proof: tbx_01m3v611tt9v41mq4chxgg0m3s passed 118 tests in 152.90 s: both real Gateway remote-catalog variants, 105 plugin recovery cases, and 11 SDK surface tests. The staged line-cap check against incoming main, scoped cleanup-owner lint, and final core types passed. The new catalog/drain regression costs 80 ms in the grouped run (97 ms after its observer-only lint correction).
  • Reload fixtures: tbx_01m3tv8198ve75sa08cq92x1y5 passed 255 tests in 36.63 s across reload handlers and config reload, plus the Gateway test type graph. tbx_01m3txr5rtwqke4e9wdnqnn872 (run) passed both wizard lease cases in 36.80 s cold wall; cases took 746 / 601 ms.
  • SDK budget proof: tbx_01m3v0vefkbp1vnegm8mp64gb3 passed all 11 surface tests in 14.15 s. Startup-fixture proof: tbx_01m3txc34nwss57j1q1nswevdt passed all 27 tests in 21.84 s; its real-process three-mode case took 2.763 s.

The observer-only correction passed the exact CI lint config with zero warnings/errors and all 11 catalog-publication tests in 34.51 s on tbx_01m3v8a5bmwgt7m0wgecqdyjqf; independent review is clean at P0–P2 and the lease is stopped. It restores the spy before invoking the original queue method through its actual receiver, with no suppression or production change.

Focused tests used node scripts/run-vitest.mjs <files> --maxWorkers=1 or pnpm test <file> --maxWorkers=1; types used pnpm tsgo:core and scripts/run-tsgo.mjs for affected test graphs. Lint used scripts/run-oxlint.mjs --type-aware --tsconfig tsconfig.core.json on changed production files.

Negative controls prove the regressions: original config handling retries three times instead of once; restoring the blanket failure latch blocks all four A-to-B recovery cases; removing queued reservation revalidation admits publication during a successor drain; removing cleanup authority checks admits a late active callback. Removing the remote-catalog commit guard publishes generation 300 when the held drain requires 200. That last wrapper expected a different diagnostic substring and exited 1, but the captured test assertion is the intended failure; source was restored in finally.

CI on the earlier production head also completed the reader fixture in 2.001 s, with pending-drain reads at 9.51 / 8.24 ms. Cleanup-authority cases cost 14 / 2 ms in CI. Final-head CI and both openclaw/ci-gate checks passed on 354b767966af (CI run). The PR merged as a3e4005ebc5a.

CI repairs and integration evidence

CI caught a type-only import cycle, an omitted source in the trusted wrapper inventory, and ordinary admission remaining open during call drain. Those are repaired. Closing admission exposed cross-provider memory teardown; an exact-instance cleanup scope now preserves it and fences both idle and already-active callbacks after scope closure. Existing memory and installed-package regressions remain strict. Memory-drain observation moved unchanged into the existing cleanup owner to satisfy the line cap.

Reload-handler and wizard fixtures mocked the entire installed-record facade and omitted the newly used canonical helper. They now mock the reader owner, leaving pure facade helpers real. The old mock reproduces the missing-export failure. The known-failed run was cancelled after capturing evidence to avoid repeated 120-second fixture timeouts.

An inherited startup-metadata fixture race polled its controller twice: it could observe “running” in the predicate and successful exit in the guard, then falsely report a handshake failure. The captured product outcome and process cleanup were correct. The final join uses the owned child's Popen.wait with the same five-second allowance and overall deadline; no assertion or timeout was relaxed.

The inherited Windows partition assertion was fixed upstream by #162310; its exact test passed on both this branch's original base and first head. No Windows assertion changed here.

Upstream #162256 removed one callable SDK export without lowering defaults. This PR shrinks the budgets exactly from 4,588 / 2,694 to the measured 4,587 / 2,693; counting logic and SDK surface are unchanged. The first integration used the failing CI run's exact main base and matched its merged tree before the numeric edit. A later actual conflict required incorporating main's catalog-publication owner, with the additional focused proof above.

Some native Testbox transfers timed out before execution. No passing proof is claimed for those attempts; fresh leases and committed-source fetch completed the outstanding checks. An initial test-graph command used unsupported selectors, and an uncommitted-merge ratchet initially selected the older fork. Corrected native commands and the exact staged base passed. No baseline increase, suppression, CI rerun, or validation bypass was used.

Keep the active model publication readable while admitted plugin work settles,
then retire it before resource replacement. Preserve execution fencing, auth
revocation, decision cancellation, rollback, and cleanup ownership.

Retain an automatic drain failure only while its original plugin configuration
delta remains unresolved. Allow explicit wait recovery and reversion alongside
changes to a different plugin without retrying unrelated failed work.

Validate on Blacksmith Testbox with real Gateway reader latency proof, 378
focused tests, 145 follow-up tests, negative controls, types, lint, and guards.
@clawsweeper

clawsweeper Bot commented Oct 1, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 354b767966af3d03d707260875f5e70b4a8a1c42
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/prepared-model-runtime-auth-publication.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete enabled auto-merge (squash) October 1, 2026 02:24
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 1, 2026, 4:33 AM ET / 08:33 UTC (Revision 6).

ClawSweeper review

What this changes

The PR keeps model and chat metadata readable during plugin drains, fences execution and catalog changes, and prevents automatic retries of unresolved failed drains.

Merge readiness

⛔ Blocked before merge - 3 items remain

The fix remains useful: current main still retires model metadata before plugin drainage finishes. No concrete introduced code defect was found; the previously requested published-updater validation remains outstanding.

Priority: P2
Reviewed head: 354b767966af3d03d707260875f5e70b4a8a1c42

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong boundary proof and coherent lifecycle changes support the patch, with existing-installation validation still needed.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded real Gateway WebSocket calls exercise the changed reload/publication boundary: metadata remains readable while a registered plugin call drains and after timeout restores the active registry. Focused authority and publication regressions supplement that proof. No stored-data contract changes; the separate repository-required published-updater cell remains outstanding.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded real Gateway WebSocket calls exercise the changed reload/publication boundary: metadata remains readable while a registered plugin call drains and after timeout restores the active registry. Focused authority and publication regressions supplement that proof. No stored-data contract changes; the separate repository-required published-updater cell remains outstanding.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head production and test hunks using the supplied introduction identities. The stale test merge was not used to infer removal of current-main behavior.
Still necessary on main and latest release: Fetched main still calls markPreparedModelRuntimeSnapshotsStale before admitted plugin work drains; the latest release also retains the earlier reload ordering. The merged downloaded-catalog work is an adjacent integration, not a fixing replacement for this reader behavior.
Real Gateway reader proof: The captured primary body, sourceRevision 2e6f33ef5b6cbb01e0b24cac38725acc2e5a7a7b416f18717e19826cbab42216, records a real isolated Gateway and WebSocket client exercising plugins.reload, models.list, and chat.metadata with a held registered-plugin RPC. Baseline readers blocked through the simulated 60-second deadline; fixed readers completed in 10.21/9.11 ms during drainage and 13.00/11.55 ms after failure. The inspected fixture uses the production reload and publication owners and verifies unchanged reader payloads and active registry identity.
Findings None None.
Security None None.

How this fits together

Gateway plugin reloads coordinate active plugin calls, model publications, and resource replacement. Model and chat metadata requests consume the published generation, while execution admission waits for reload settlement.

flowchart TD
  A[Plugin reload request] --> B[Reserve replacement]
  B --> C[Drain admitted work]
  D[Metadata requests] --> E[Active model publication]
  C --> E
  B --> F[Fence new execution]
  C --> G[Replace resources or restore runtime]
  G --> F
Loading

Before merge

  • Resolve merge risk (P1) - Existing-installation behavior remains unverified through the required published updater into this candidate; retained plugin settings, startup, and failed-drain recovery need that compatibility result.
  • Complete next step (P2) - Add the repository-required published-updater × candidate validation result to the PR body.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +312, Tests +592, Docs +12, Other +1. Total +917 across 48 files.

View PR surface stats
Area Files Added Removed Net
Source 20 463 151 +312
Tests 25 673 81 +592
Docs 2 13 1 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 48 1150 233 +917

Review metrics

Metric Value Why it matters
Production versus test growth production +312 net; tests/support +592 net Production growth is justified by separating drain admission from publication retirement and retaining scoped failure and cleanup ownership.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/plugins/memory-runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete the updater cell (recommended)
    Record a published-release updater installing this candidate with retained plugin configuration, then verify startup and failed-drain recovery.

Technical review

Best possible solution:

Keep the shared publication owner and exact-instance cleanup design, with existing-installation compatibility established through the published updater.

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

Yes: hold an admitted plugin RPC, request reload, and read models.list/chat.metadata during drainage. Current-main ordering supports the defect and the captured baseline demonstrates it; this review did not execute the scenario.

Is this the best way to solve the issue?

Yes: separating execution admission from passive publication reads fixes the owner boundary while retaining revocation, rollback, and resource-settlement checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs metadata stalls during plugin reloads with a bounded lifecycle impact.
  • merge-risk: 🚨 compatibility: Plugin replacement and teardown ordering change for existing installations, whose required published-updater validation is not recorded.
  • 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 (live_output): Recorded real Gateway WebSocket calls exercise the changed reload/publication boundary: metadata remains readable while a registered plugin call drains and after timeout restores the active registry. Focused authority and publication regressions supplement that proof. No stored-data contract changes; the separate repository-required published-updater cell remains outstanding.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded real Gateway WebSocket calls exercise the changed reload/publication boundary: metadata remains readable while a registered plugin call drains and after timeout restores the active registry. Focused authority and publication regressions supplement that proof. No stored-data contract changes; the separate repository-required published-updater cell remains outstanding.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head production and test hunks using the supplied introduction identities. The stale test merge was not used to infer removal of current-main behavior. (354b767966af)
  • Still necessary on main and latest release: Fetched main still calls markPreparedModelRuntimeSnapshotsStale before admitted plugin work drains; the latest release also retains the earlier reload ordering. The merged downloaded-catalog work is an adjacent integration, not a fixing replacement for this reader behavior. (src/gateway/server-reload-hot.ts:208, 83a449f8523c)
  • Real Gateway reader proof: The captured primary body, sourceRevision 2e6f33ef5b6cbb01e0b24cac38725acc2e5a7a7b416f18717e19826cbab42216, records a real isolated Gateway and WebSocket client exercising plugins.reload, models.list, and chat.metadata with a held registered-plugin RPC. Baseline readers blocked through the simulated 60-second deadline; fixed readers completed in 10.21/9.11 ms during drainage and 13.00/11.55 ms after failure. The inspected fixture uses the production reload and publication owners and verifies unchanged reader payloads and active registry identity. (src/gateway/server-plugins.lifecycle.readers.test.ts:96, 354b767966af)
  • Execution and cleanup authority: Passive publication access bypasses only the drain reservation. Execution acquisition remains gated, auth mutations invalidate affected owners immediately, and catalog candidates recheck drainage before commit. Memory cleanup grants access to exact retiring instances, closes its scope after raw settlement, and checks scope liveness before callback entry; regressions cover unrelated instances and delayed idle/active callbacks. (src/plugins/plugin-invocation-scope.ts:14, 354b767966af)
  • Upgrade gate remains applicable: Root policy requires a published-driver × candidate cell for changes touching plugin loading or service lifecycle. This branch changes plugin replacement and teardown ordering. The complete captured primary body records Gateway/recovery tests but no updater cell for this candidate; upgrade cells in the related catalog PR concern its different candidate. No stored-data format, config key, default, protocol, or public SDK change was found. (AGENTS.md:84, 354b767966af)
  • Re-review continuity: The preceding review had no findings and requested published-updater validation. GitHub's exact-head commit response verifies that the latest commit changes only the remote-publication test observer, restoring the spy before calling the queue through its receiver; it adds no upgrade evidence or production behavior. (src/agents/prepared-model-runtime.remote-publication.test.ts:155, 354b767966af)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Patrick-Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: 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.

  • Record the published-driver × candidate result with retained plugin settings, successful startup, and failed-drain recovery.

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-10-01T02:28:19.622Z sha 3673f7a :: blocked before merge. :: none
  • reviewed 2026-10-01T04:03:45.563Z sha 39781e0 :: blocked before merge. :: none
  • reviewed 2026-10-01T05:22:44.150Z sha a85c6fe :: blocked before merge. :: none
  • reviewed 2026-10-01T06:05:58.211Z sha 8cb91f1 :: blocked before merge. :: none
  • reviewed 2026-10-01T08:05:43.609Z sha d904baf :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 1, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 1, 2026
Integrate the exact main base already exercised by CI run 36818914037. The merged tree matches its tested source before lowering the two stale budgets by one, following the upstream removal in #162256.
Resolve the catalog-publication integration with current main while retaining its config-advancement owner. Recheck the plugin drain before publishing prepared catalog candidates, keep waits outside the publication queue, and preserve degraded startup settlement. Move memory cleanup observation to the existing cleanup owner without changing its warning policy.
@steipete
steipete merged commit a3e4005 into main Oct 1, 2026
246 checks passed
@steipete
steipete deleted the steipete/perf-micro-config-reload-plugin-drain-20260919 branch October 1, 2026 08:38
jalehman added a commit that referenced this pull request Oct 1, 2026
…the model runtime

A plugin reload gates model-runtime admission (the plugin drain from #162301,
then the replacement gate) until it commits, while its drain waits for the
admitted work, retained consumers, and turn leases that hold the reloading
instances. When such work asked for a model runtime (for example context-engine
maintenance calling runtime.llm.complete), it waited on the reload while the
reload waited on it.

Admission waits now refuse, with a retryable error, only work the pending drain
is joining: an invocation chain holding a live token on a reserved instance, a
retained invocation scope holding a consumer on one, or a live turn lease whose
generation includes one. Other work, including unrelated plugin calls and
channel reply dispatch, keeps waiting and resumes after the reload. Catalog
fallbacks no longer swallow the refusal.
jalehman added a commit that referenced this pull request Oct 2, 2026
… the model (#162484)

* fix(plugins): prevent reload hangs during plugin model calls

Reject replacement waits from live plugin invocations so donor work can settle. Keep unadmitted model-runtime readers waiting for the replacement publication.

Refs: oc-4bf-2e7.1

* fix(plugins): plugin work no longer deadlocks a reload by waiting on the model runtime

A plugin reload gates model-runtime admission (the plugin drain from #162301,
then the replacement gate) until it commits, while its drain waits for the
admitted work, retained consumers, and turn leases that hold the reloading
instances. When such work asked for a model runtime (for example context-engine
maintenance calling runtime.llm.complete), it waited on the reload while the
reload waited on it.

Admission waits now refuse, with a retryable error, only work the pending drain
is joining: an invocation chain holding a live token on a reserved instance, a
retained invocation scope holding a consumer on one, or a live turn lease whose
generation includes one. Other work, including unrelated plugin calls and
channel reply dispatch, keeps waiting and resumes after the reload. Catalog
fallbacks no longer swallow the refusal.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…nclaw#162301)

* fix(gateway): keep model metadata available during plugin drains

Keep the active model publication readable while admitted plugin work settles,
then retire it before resource replacement. Preserve execution fencing, auth
revocation, decision cancellation, rollback, and cleanup ownership.

Retain an automatic drain failure only while its original plugin configuration
delta remains unresolved. Allow explicit wait recovery and reversion alongside
changes to a different plugin without retrying unrelated failed work.

Validate on Blacksmith Testbox with real Gateway reader latency proof, 378
focused tests, 145 follow-up tests, negative controls, types, lint, and guards.

* fix(plugins): fence admission while preserving owned cleanup

* test(gateway): preserve plugin record helpers in reload fixture

* test: repair reload mocks and supervised process joins

* test(models): preserve queue receiver in drain observer
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
… the model (openclaw#162484)

* fix(plugins): prevent reload hangs during plugin model calls

Reject replacement waits from live plugin invocations so donor work can settle. Keep unadmitted model-runtime readers waiting for the replacement publication.

Refs: oc-4bf-2e7.1

* fix(plugins): plugin work no longer deadlocks a reload by waiting on the model runtime

A plugin reload gates model-runtime admission (the plugin drain from openclaw#162301,
then the replacement gate) until it commits, while its drain waits for the
admitted work, retained consumers, and turn leases that hold the reloading
instances. When such work asked for a model runtime (for example context-engine
maintenance calling runtime.llm.complete), it waited on the reload while the
reload waited on it.

Admission waits now refuse, with a retryable error, only work the pending drain
is joining: an invocation chain holding a live token on a reserved instance, a
retained invocation scope holding a consumer on one, or a live turn lease whose
generation includes one. Other work, including unrelated plugin calls and
channel reply dispatch, keeps waiting and resumes after the reload. Catalog
fallbacks no longer swallow the refusal.
steipete added a commit that referenced this pull request Oct 11, 2026
## What Problem This Solves

Agent runtime bookkeeping repeatedly restarted otherwise valid work when configuration, plugin, or catalog metadata changed during an asynchronous operation. This maintainer-requested simplification removes that speculative retry machinery.

## User Impact

Normal model selection, tool execution, credential checks, FIFO scheduling, and shutdown settlement remain. A request racing a reload may fail visibly and be retried by the caller; passive metadata may remain at its captured version until the next refresh. No configuration, protocol, SDK, schema, durability, retention, or permission contract changes.

## Why This Change Was Made

Prepared runtime acquisition and remote catalog adoption now take one preparation path rather than repeatedly rebinding and rebuilding. Admission still handles the concrete drain, retirement, and failed-activation recovery stages. Cache publication keeps its final currentness check; tool and credential effects keep their authority checks. Steering and Tool Search retain their actual owner, FIFO, and settlement contracts without comparing unrelated metadata.

Production: **519 net lines removed**. Tests that exclusively required the removed synthetic interleavings were removed with them. Open-parent borrowing, pending-auth cancellation, explicit MCP acquisition config, and queued-tool implementation checks remain. No new lint suppressions, timeouts, retries, or skips were added.

Scope proof also caught two nearby correctness issues: an earlier MCP reload could overwrite a new caller's explicit configuration, and snapshot reconciliation could prepend a separator to a later text block. Both are fixed with their existing boundary tests. Bootstrap fixtures now test the no-clobber fallback already shipped by the pinned fs-safe version; no dependency or storage policy changed.

## Best-effort tradeoffs accepted

| Removed guard | Provenance and accepted result |
| --- | --- |
| Per-batch context projection cancellation | #119607 measured the value of cooperative yielding; its mid-batch cancellation callbacks were synthetic coverage. Yielding and the final publication check stay; obsolete pure computation may finish unused. |
| Mixed-version module/cache repair | #119607 seeded an old global singleton inside a synthetic process. Normal upgrades restart the process; unsupported mixed-version module replacement no longer repairs that marker. |
| Runtime acquisition retry/rebind loop | #128138/#127217 exercised forced reload timing. A racing request now returns a visible supersession error; the next request uses the current owner. The actual no-spin incident in #153313 remains addressed. |
| Configured-generation re-admission | 171df4e / #168410 adds re-admission for a gated Docker reproduction with a catalog publication 0.3s after admission, not a human-user incident. A superseded request now fails visibly. Parent confinement remains fail-closed, with its security test retained. The retry-only WeakSet and two retry-specific tests are removed. |
| Repeated passive owner selection | a718c1c / #162484 added recursion alongside the real self-drain fix; that incident did not require recursive reselection. The self-drain refusal stays. Reads use one captured owner or fail visibly, rather than recursively trying later publications. |
| Remote catalog config reread/per-attempt cancellation | #158000 used synthetic config/auth churn. Adoption reads once and prepares once; an overlapping change can defer adoption until the next normal catalog check. |
| Parent-generation cancellation subscriptions during adoption | 504d290 / #158000 used the same synthetic churn. Parent replacement may leave bounded preparation running until its final owner/config check rejects it. Shutdown cancellation, candidate-retirement aborts, cleanup, and the final serialized effect check remain. |
| Three-attempt catalog adoption settlement recovery | The same synthetic churn caused a second retry protocol around owner publication. One attempt remains, with one final checked atomic rows/pricing commit. |
| Duplicate early publication checks/error relabeling | Same-tick checks and concurrent-change relabeling did not guard an effect. The final effect check stays; failures retain their actual reason. |
| Auth-batch sibling retry after supersession | f3c52bd / #152467 used synthetic tests that superseded one owner during a sibling build. The operation now settles with its original error instead of selectively rebuilding siblings. Credential authority checks remain. |
| Post-await cache-stale generation check | No human incident supports fencing this metadata flag. A config/auth change during discovery can let the older load clear a reused owner's stale marker; discovery may remain stale until another explicit refresh/reload. This does not grant credentials or execution authority. |
| Passive harness catalog cancellation | #134524 fixed the actual availability report #134460; replacement/closure guards were additional synthetic hardening. Completed discovery rows are retained, and later discovery observes replacement. |
| Native binding clock-only rechecks after worker waits | #158396 used clock-jump fixtures. An expired but unreplaced exact row can finish its prepared bookkeeping mutation; CAS takeover detection and current mutation authority still gate commit. One exact, unexpired lease check gates protected callback entry, and live effect assertions remain. |
| Tool Search ancestor reentrancy tracking | #140767 covered synthetic nested control calls, not a reachable production control target. FIFO/exclusion and real implementation settlement remain. |
| Complete steering metadata fingerprint | #163195 recorded a real production ordering/ownership incident. Its owner, pending-row, result-authority, and lease checks stay; metadata-only edits no longer invalidate already-captured prompt bytes. |
| Repeated MCP acquisition/reload replay | #138694 used synthetic crossed-publication choreography. A new runtime catches up once; later reloads target the published owner. A racing creation can fail and reconnect on the next acquisition. |
| MCP tools/list invalidation generations and replay | #125541/#125564 describe isolated protocol stress fixtures. A notification inside tools/list no longer triggers immediate replay; the next notification or explicit refresh replaces the inventory. Normal exit/reconnect, bounds, validation, and cleanup remain. |
| Failed-start replay crossed by config publication | #158088's test forces a config publication into an in-flight failed initialization. That request may now report its first failure; ordinary backoff and explicit-refresh retry remain. |

## Evidence

Candidate head: `d72afea0c17a45c677977e23937049d7c7fc43ec` (tree `51daca08d7288e906188bc25ec3d1896bf841349`).

Final exact-head CI: [run 38132644989](https://github.com/openclaw/openclaw/actions/runs/38132644989) completed successfully; all 82 jobs terminal with no failed or cancelled jobs. Full head-bound check census also confirms the CI gate and applicable security checks passed. Earlier failed/cancelled attempts are described below, not represented as passing proof.

- Independent P2 reviews completed. The catalog-staleness, duplicate steering metadata fingerprint, and auth-sibling retry findings are explicitly accepted tradeoffs listed above; steering result facts and destination eligibility remain checked at their owners. The latest native-lease callback-entry finding was accepted and fixed with one live lease check instead of restoring per-write expiry callbacks. Its new fake-clock regression failed before the fix by entering the protected callback after expiry.
- Conflict-only integration kept main's three repaired test fixtures byte-for-byte. All **22 conflict tests** passed (cursor, sandbox, bootstrap publication, lint suppressions); affected root/tools test graphs, core types, typed lint and both cycle checks passed. Runtime and Madge cycles remain **0**.
- The native callback-entry fix passed fresh P2 review and **24 focused tests** (21 native binding tests plus 3 lint-suppression tests), wrapper 212.01s; native test project 164.77s including 113.11s compiled-worker preparation. The added fake-clock case performs no real wait; the existing native suite exercises authority and worker settlement. Final affected types and typed lint are checked before push.
- CI run `38125430266` found one owned stale expectation: the remote-catalog integration still forced config/auth replacement while pricing was paused and demanded the removed immediate retry. Only that scenario was removed; both schema variants retain normal publication, pinned pricing, input validation, worker recovery and disable coverage and pass locally (141.35s project), with gateway test types, typed lint, lint suppressions (3/3), and fresh P2 review passing.
- The other root failure, `checks-node-changed-compact-small-11`, independently reproduced on clean main `fd1fd2ce0ef8cb7e9c4074c8f855eff8992a54c2`: `embedded-agent-runner.prompt-cache.test.ts` responses and in-history both raised `SqliteTranscriptMutationConflictError` in the session actor append path (2 failed / 2 passed). Investigation found a cold actor snapshot prevented the existing implicit-watermark retry. Fixed directly on main as `e65bd3be4134f1453bb4ab26e68704c678086b58` and integrated here: all 4 prompt-cache cases and 35 session-manager siblings plus lint-suppressions pass, including explicit stale rewrite refusal. The repair passed types, typed lint and fresh P2 review.
- Follow-up CI `38127338915` reached one more synthetic-only case: compaction's `mutate=input` row changes an internal selection object after starting acquisition. Removed only that row/branch under the campaign rule; five remaining compaction cases pass, along with lint-suppressions, affected types, typed lint and fresh P2 review. Its provenance is `c131ec041e1` / #139429, not a human report of post-call input mutation. The final conflict repair keeps main's equivalent streaming/steering refactors, removes the obsolete retry predicate, and passes 49 owner tests plus lint-suppressions. Cancelled jobs are not counted as passing; final-head hosted CI remains the gate. No CI job was rerun.
- CI `38130432441` had one inherited fixture failure: three `sessions-mutations.catalog-queue` cases selected their configured default while expecting override fields, after #169030 intentionally made that selection a default reset. Integrated main's existing fixture-only correction `194a08e59632`, retaining all assertions. The corrected file passes all 14 cases on clean main under Node and Bun; the three affected cases also pass under Bun on this branch (249.87s project, mostly transformation). Exact-head hosted CI remains the final gate.
- Focused effects suites: **43 passed** across inbound-registry, remote-publication, hot-reload-dispatch and tool-search-scheduling. This includes cancellation, parent confinement, ordinary rollback/failed-activation recovery, and queued implementation replacement. Single-worker wrapper 752.15s including 142.017s compiled-worker preparation; infra 432.15s and agents-core 115.09s. Final restored remote-publication file: **7 passed**, including first reply crossing catalog adoption and exact derived-parent confinement; wrapper 372.77s (184.30s worker preparation; 131.87s Vitest). These loaded-host timings are not a performance claim.
- Integrated native-binding suites: **20 passed**, including exact token cleanup, successor protection, and revocation. The same command passed all **3 lint-suppression tests**. Single-worker wrapper 354.47s including 145.31s worker preparation.
- Current core types and native-binding test graph passed; runtime cycles **0**, Madge cycles **0**; changed-file typed lint passed. The full changed-check run reached an old-base UI duplicate-import error already fixed on main by `48588a65222`; that fix was integrated and the affected UI graph passed. Remaining type graphs and static guards were completed separately without changing baselines.
- Isolated Linux scope run and canonical remaining projects exercised **19,900 passing tests**. Eight failures were investigated: three pinned removed synthetic retry paths and were deleted; five exposed the correctness/fixture issues described above and were repaired with focused proof. Existing platform skips were unchanged. This is combined incremental proof, not a claim that one final-head all-scope invocation was green.
- Final repair suites: **71 passed** across passive runtime, SSE recovery, startup backoff, bootstrap, stream reconciliation/markup/phase coverage; **12 passed** across sandbox/cursor coverage, followed by **2 passed** for the real-append cursor fixture. Final MCP regression retained stdio-exit recovery and HTTP failure semantics; it passed 64 cases but hit two unchanged local child-start deadlines (1s/2s). Those initial-start paths passed on the isolated Linux run; no timeout, retry, or skip was changed to mask the local failures.
- Full-core Linux lint passed with 13 existing max-lines warnings, none in changed files. Deadcode identified and drove removal of the unused owner-publication helper. Remaining findings were in unmodified config/state/Gateway/UI files. A separate fresh current-main checkout (`f4d601a006`) passed production deadcode and failed full-tree deadcode only on the unrelated `readActiveGatewayLockPortMock` export. The PR does not change any deadcode baseline.
- Blacksmith Testbox did not admit a runner within 15 minutes; AWS quota pressure supplied an undersized instance, which was released. The authorized Hetzner fallback supplied the Linux proof above. All owned remote leases are stopped. Hosted CI on the exact final head remains the landing gate; no CI jobs were rerun.

<details>
<summary>Audit coverage ledger and retained boundaries</summary>

| Mechanism (base lines) | Scenario and provenance | Decision |
| --- | --- | --- |
| context-cache-projection.ts:145-213, context.ts:87-109,146-169 | Cancellation/replacement during pure batched metadata computation. bf7840f / #119607 fixed a measured multi-second RPC stall by yielding and atomic publication. Mid-batch authority callbacks were extra cancellation machinery; no effect occurs in projection. | REMOVE repeated projection/early checks; KEEP cooperative yields and the caller's check immediately before publication. |
| context-runtime-state.ts:33-38 | bf7840f / #119607 seeds an old global singleton and new cache module in a synthetic child process; no human report of mixed code versions within one live process. | REMOVE old-module/cache-pair normalization, its only reuse flag, and the synthetic migration test. Ordinary process startup and same-version bundled singleton sharing remain. |
| prepared-model-runtime-lease.ts:149-164 | 8720fbf / #153386. Human report #153313 by stackingrockss includes the deployed Docker version, profiler samples, and repeated boot-loop observations. Its infinite retry was caused by non-idempotent runtime selection normalization. | KEEP normalized owner selection and a visible error when a settled replacement never published; REMOVE the acquisition retry loop entirely, so it cannot spin. |
| prepared-model-catalog-worker.ts:71-220 | 349aef7 / #150354. Human report #149538 by 609NFT describes copied production fleet state, 632 agents, 504 failed health probes and growing RSS. #161738 by matthematics1137 reports 92 worker lifetimes, OOMs and 1.285 TB written. | KEEP one bounded shared worker, borrower cleanup, failure logging, and ordinary crash recovery. These are measured resource and real concurrency contracts, not permission to retain unrelated reload fences. |
| prepared-model-runtime.refresh-scope.ts:240 | d56279c / #151597 by obviyus describes a controlled worker crash and synthetic Gateway regression, not a human production report. Later #161738 independently establishes actual recurring worker failures. | KEEP source-bound failure reporting and bounded recovery to avoid reintroducing the observed restart/discovery amplification. The #151597 PR alone is not accepted incident evidence. |
| prepared-model-runtime.resources.ts:30-127 | 73b4086 / #143109 contains native regressions and synthetic compiled CLI/Gateway proof, no linked human incident. | KEEP physical resource claims until ordinary concurrent borrowers settle and shutdown joins their cleanup; these are required cleanup mechanics, not a blanket historical-incident exemption. Inspected the complete resource owner; no extra reload retry protocol lives here. |
| prepared-model-runtime.plugin-lifetime.ts:230-319 | 382c987 / #159448 links #157842 by highfly-hi: five-agent Linux deployment with catalog-worker heap increasing 70-80 MB per scheduled turn, watchdog restarts and before/after version evidence. | KEEP final registry-reference release, current execution authority, and ordinary borrowed-resource settlement. Retained memory claims are scoped to physical lifecycle, not all historical publication machinery. |
| prepared-model-runtime.lifecycle.ts:101-164 | a718c1c / #162484 by jalehman records actual lossless-claw maintenance calls stuck about 45 minutes during reload until restart. a3e4005 / #162301 explicitly says synthetic Gateway, no production deployment. | KEEP refusal of plugin work waiting on its own drain and process-close settlement. #162301 is synthetic evidence, not an independent incident exemption. |
| prepared-model-runtime-lease.ts acquisition loop and borrowed-generation branch | 79e6755 / #128138 and related #127217 describe synthetic QA-channel/config replacement tests; #127217 explicitly reports that its pre-fix real-Gateway run still delivered replies. Retained inbound-registry tests exposed ordinary nested selected-parent borrowing as a distinct contract. | REMOVE retry/rebind loop. KEEP exact open-parent borrowing and selection confinement; a reload during new acquisition may fail that request visibly. |
| prepared-model-runtime.published-owner.ts:91-203 | a718c1c / #162484 added retry/recursive rereads alongside the real plugin-drain repair. That incident justifies self-drain refusal and ordinary settlement, not recursive passive owner reselection. | REMOVE repeated rereads/retries; wait once, then project or activate once. Pure catalog-stale bookkeeping no longer revalidates generation after its await. |
| prepared-model-runtime.configured-refresh.ts remote catalog adoption | 504d290 / #158000 has explicitly synthetic config/auth churn and fixture-provider proof; no human incident cited for the reread loop, per-attempt controllers or three-attempt owner settlement recovery. | REMOVE those race-specific retries, plus early duplicate currentness checks/error relabeling. KEEP the final owner/authority check, atomic rows/pricing commit, current catalog ordering, and ordinary cancellation/disposal. |
| prepared-model-runtime.configured-refresh.ts:396-430 parent subscriptions | 504d290 / #158000; same synthetic churn proof. Parent-generation subscriptions duplicate the final owner/generation/config check. | REMOVE parent-generation early cancellation listeners. KEEP shutdown and candidate-retirement cancellation, bounded work, cleanup, and the final serialized effect check. |
| prepared-model-runtime.owner.ts:612-631 batch supersession retry | f3c52bd / #152467. Tests force one auth owner to supersede while a sibling is building. No independent human incident identified for sibling retry. | REMOVE retry of the surviving batch; retain source-bound credential/current-owner checks and report the original publication failure. |
| prepared-model-runtime.owner.ts:124-134 unused publication probe | dd2d66c / #130856 introduced a helper returning matching/pending publication facts for acquisition retries. Its callers are gone; full-repository search finds only the definition. | REMOVE the dead helper/export. Credential-refresh cancellation remains supported by the direct, abortable configured-owner wait and its unchanged regression tests. |
| sandbox/registry.kernel.ts:396,420; sandbox/registry.ts:295 | 2889a99 / #151172 is not treated as an incident report. Read-only admission accepts older schemas; tableExists consumes admitted schema.tables facts, not repeated SQL/format validation. | KEEP the existing absent-table empty/null contract. No runtime foreign-commit or repeated validation probe exists in these calls. |
| harness/native-session/binding-leases.ts | cfef174 / #158396 moved writes to workers; elapsed-time rechecks were covered by synthetic clock-jump tests. 283d5e6 / #164197 supplies native successor authority behavior, not a blanket exemption. | REMOVE prepared callback plumbing and post-worker wall-clock-only rechecks. KEEP exact-row CAS, token/phase/failure checks, current mutation authority, bounded acquisition, renewal, and write settlement. |
| harness/context-engine-logical-turn.ts | #143491/#140023 supply synthetic lifecycle tests, not qualifying human incident evidence. The owner actually holds resources used by outstanding context-engine work. | KEEP ordinary work completion and deferred disposal until implementation settlement; no extra synthetic reload retry was retained here. |
| harness/model-catalog.ts:168-177,242-284,353 | 6c44634 / #134524 repairs human availability report #134460. Passive replacement/closure branches were additional maintainer hardening and synthetic variants, not that report's failure. | REMOVE passive isCurrent callbacks and ambient registry replacement checks. KEEP exact owned registry/config, provider outcomes, discovery, selection and the actual availability repair. |
| auth-profiles/oauth-refresh-peers.ts | #166183/#167002/#166659 are not claimed as human incident evidence. Refresh credentials rotate/revoke and carry account identity; copied historical peers must not replay spent tokens or inherit another account. | KEEP these credential/identity effect boundaries and ordinary uncertain-write settlement. No auth-profile schema, secrets, permissions or durability changes. |
| worktrees lifecycle/removal | Audited run-lease-owner.ts, service-preparation.ts, eviction.runtime.ts and gc-removal.ts. They coordinate destructive removal of user artifacts with live checkout/source handles, exact refs and ordinary parallel sessions. No PR title is treated as incident evidence. | KEEP current-row removal/exclusive source checks and rollback/cleanup custody for writes and deletion. Removing them would risk user artifacts, independently prohibited by the data-loss boundary. |
| tool-search-scheduling.ts | 9b93fc8 / #140767 adds ancestry reentrancy and queued object/mode identity checks with automated interactive/headless regressions. Production catalogs exclude control tools; recursive calls using the same runtime were synthetic only. | REMOVE unreachable nested-call ancestry. KEEP one exact queued implementation/mode check at the effect, catalog-ID authorization, FIFO/exclusion, abort and implementation settlement. |
| agent-steering-queue.ts:194-263 | 3f761a8 / #163195 records Peter's actual three-day production errors. The incident justifies owner/FIFO repair, not a fingerprint of every result label/task/time/outcome/origin/transcript field. | REMOVE full payload fingerprints and deep-equality invalidation. KEEP run-owner identity, prepared result authority, current requester store, pending-row effect checks, FIFO, exact lease/status acknowledgment and release. |
| agent-bundle-mcp-manager.ts and manager-install.ts | 89c1a09 / #138694 reports synthetic fail-before/real-transport proof but no cited actual-use incident for repeated crossed-publication acquisition/reload. | REMOVE the acquisition retry/rebind loop and repeated reload replay. KEEP the runtime-key queue, ordinary cleanup, one postcreation config catchup, requester credentials/authorization and live tool effect checks. |
| agent-bundle-mcp-runtime.ts catalog generations | 1cf8ea4 / #125564 and follow-up 1d03e5d / #167642 have synthetic notifications/listing interleavings, not human reports for replaying tools/list during its own response. | REMOVE catalog invalidation generations, replay of a notification arriving inside tools/list, and the impossible repeated replacement-retirement loop. KEEP listing single-flight, caching, bounds, diagnostics, normal reconnect, one retry for an actually exited previously healthy server, and execution authority. |
| prepared-model-runtime-lease.ts / plugin-lifetime.ts configured-generation re-admission | 171df4e / #168410, landed during this lane, describes a gated Docker reproduction with catalog publication 0.3s after admission, not an actual human-user incident. | REMOVE configured-generation retry and its now-unused WeakSet plus the two retry-only tests. KEEP fail-closed superseded-generation rejection and the new derived-parent confinement security test. |

</details>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…168981)

## What Problem This Solves

Agent runtime bookkeeping repeatedly restarted otherwise valid work when configuration, plugin, or catalog metadata changed during an asynchronous operation. This maintainer-requested simplification removes that speculative retry machinery.

## User Impact

Normal model selection, tool execution, credential checks, FIFO scheduling, and shutdown settlement remain. A request racing a reload may fail visibly and be retried by the caller; passive metadata may remain at its captured version until the next refresh. No configuration, protocol, SDK, schema, durability, retention, or permission contract changes.

## Why This Change Was Made

Prepared runtime acquisition and remote catalog adoption now take one preparation path rather than repeatedly rebinding and rebuilding. Admission still handles the concrete drain, retirement, and failed-activation recovery stages. Cache publication keeps its final currentness check; tool and credential effects keep their authority checks. Steering and Tool Search retain their actual owner, FIFO, and settlement contracts without comparing unrelated metadata.

Production: **519 net lines removed**. Tests that exclusively required the removed synthetic interleavings were removed with them. Open-parent borrowing, pending-auth cancellation, explicit MCP acquisition config, and queued-tool implementation checks remain. No new lint suppressions, timeouts, retries, or skips were added.

Scope proof also caught two nearby correctness issues: an earlier MCP reload could overwrite a new caller's explicit configuration, and snapshot reconciliation could prepend a separator to a later text block. Both are fixed with their existing boundary tests. Bootstrap fixtures now test the no-clobber fallback already shipped by the pinned fs-safe version; no dependency or storage policy changed.

## Best-effort tradeoffs accepted

| Removed guard | Provenance and accepted result |
| --- | --- |
| Per-batch context projection cancellation | openclaw#119607 measured the value of cooperative yielding; its mid-batch cancellation callbacks were synthetic coverage. Yielding and the final publication check stay; obsolete pure computation may finish unused. |
| Mixed-version module/cache repair | openclaw#119607 seeded an old global singleton inside a synthetic process. Normal upgrades restart the process; unsupported mixed-version module replacement no longer repairs that marker. |
| Runtime acquisition retry/rebind loop | openclaw#128138/openclaw#127217 exercised forced reload timing. A racing request now returns a visible supersession error; the next request uses the current owner. The actual no-spin incident in openclaw#153313 remains addressed. |
| Configured-generation re-admission | 8b13535 / openclaw#168410 adds re-admission for a gated Docker reproduction with a catalog publication 0.3s after admission, not a human-user incident. A superseded request now fails visibly. Parent confinement remains fail-closed, with its security test retained. The retry-only WeakSet and two retry-specific tests are removed. |
| Repeated passive owner selection | d92dc37 / openclaw#162484 added recursion alongside the real self-drain fix; that incident did not require recursive reselection. The self-drain refusal stays. Reads use one captured owner or fail visibly, rather than recursively trying later publications. |
| Remote catalog config reread/per-attempt cancellation | openclaw#158000 used synthetic config/auth churn. Adoption reads once and prepares once; an overlapping change can defer adoption until the next normal catalog check. |
| Parent-generation cancellation subscriptions during adoption | 27a0f6d / openclaw#158000 used the same synthetic churn. Parent replacement may leave bounded preparation running until its final owner/config check rejects it. Shutdown cancellation, candidate-retirement aborts, cleanup, and the final serialized effect check remain. |
| Three-attempt catalog adoption settlement recovery | The same synthetic churn caused a second retry protocol around owner publication. One attempt remains, with one final checked atomic rows/pricing commit. |
| Duplicate early publication checks/error relabeling | Same-tick checks and concurrent-change relabeling did not guard an effect. The final effect check stays; failures retain their actual reason. |
| Auth-batch sibling retry after supersession | 4616d20 / openclaw#152467 used synthetic tests that superseded one owner during a sibling build. The operation now settles with its original error instead of selectively rebuilding siblings. Credential authority checks remain. |
| Post-await cache-stale generation check | No human incident supports fencing this metadata flag. A config/auth change during discovery can let the older load clear a reused owner's stale marker; discovery may remain stale until another explicit refresh/reload. This does not grant credentials or execution authority. |
| Passive harness catalog cancellation | openclaw#134524 fixed the actual availability report openclaw#134460; replacement/closure guards were additional synthetic hardening. Completed discovery rows are retained, and later discovery observes replacement. |
| Native binding clock-only rechecks after worker waits | openclaw#158396 used clock-jump fixtures. An expired but unreplaced exact row can finish its prepared bookkeeping mutation; CAS takeover detection and current mutation authority still gate commit. One exact, unexpired lease check gates protected callback entry, and live effect assertions remain. |
| Tool Search ancestor reentrancy tracking | openclaw#140767 covered synthetic nested control calls, not a reachable production control target. FIFO/exclusion and real implementation settlement remain. |
| Complete steering metadata fingerprint | openclaw#163195 recorded a real production ordering/ownership incident. Its owner, pending-row, result-authority, and lease checks stay; metadata-only edits no longer invalidate already-captured prompt bytes. |
| Repeated MCP acquisition/reload replay | openclaw#138694 used synthetic crossed-publication choreography. A new runtime catches up once; later reloads target the published owner. A racing creation can fail and reconnect on the next acquisition. |
| MCP tools/list invalidation generations and replay | openclaw#125541/openclaw#125564 describe isolated protocol stress fixtures. A notification inside tools/list no longer triggers immediate replay; the next notification or explicit refresh replaces the inventory. Normal exit/reconnect, bounds, validation, and cleanup remain. |
| Failed-start replay crossed by config publication | openclaw#158088's test forces a config publication into an in-flight failed initialization. That request may now report its first failure; ordinary backoff and explicit-refresh retry remain. |

## Evidence

Candidate head: `d72afea0c17a45c677977e23937049d7c7fc43ec` (tree `51daca08d7288e906188bc25ec3d1896bf841349`).

Final exact-head CI: [run 38132644989](https://github.com/openclaw/openclaw/actions/runs/38132644989) completed successfully; all 82 jobs terminal with no failed or cancelled jobs. Full head-bound check census also confirms the CI gate and applicable security checks passed. Earlier failed/cancelled attempts are described below, not represented as passing proof.

- Independent P2 reviews completed. The catalog-staleness, duplicate steering metadata fingerprint, and auth-sibling retry findings are explicitly accepted tradeoffs listed above; steering result facts and destination eligibility remain checked at their owners. The latest native-lease callback-entry finding was accepted and fixed with one live lease check instead of restoring per-write expiry callbacks. Its new fake-clock regression failed before the fix by entering the protected callback after expiry.
- Conflict-only integration kept main's three repaired test fixtures byte-for-byte. All **22 conflict tests** passed (cursor, sandbox, bootstrap publication, lint suppressions); affected root/tools test graphs, core types, typed lint and both cycle checks passed. Runtime and Madge cycles remain **0**.
- The native callback-entry fix passed fresh P2 review and **24 focused tests** (21 native binding tests plus 3 lint-suppression tests), wrapper 212.01s; native test project 164.77s including 113.11s compiled-worker preparation. The added fake-clock case performs no real wait; the existing native suite exercises authority and worker settlement. Final affected types and typed lint are checked before push.
- CI run `38125430266` found one owned stale expectation: the remote-catalog integration still forced config/auth replacement while pricing was paused and demanded the removed immediate retry. Only that scenario was removed; both schema variants retain normal publication, pinned pricing, input validation, worker recovery and disable coverage and pass locally (141.35s project), with gateway test types, typed lint, lint suppressions (3/3), and fresh P2 review passing.
- The other root failure, `checks-node-changed-compact-small-11`, independently reproduced on clean main `8d45488ae2075bd14a50c881aff6e18c32182538`: `embedded-agent-runner.prompt-cache.test.ts` responses and in-history both raised `SqliteTranscriptMutationConflictError` in the session actor append path (2 failed / 2 passed). Investigation found a cold actor snapshot prevented the existing implicit-watermark retry. Fixed directly on main as `0fa340c21f484740ec7b4ed1169b7b02439aa970` and integrated here: all 4 prompt-cache cases and 35 session-manager siblings plus lint-suppressions pass, including explicit stale rewrite refusal. The repair passed types, typed lint and fresh P2 review.
- Follow-up CI `38127338915` reached one more synthetic-only case: compaction's `mutate=input` row changes an internal selection object after starting acquisition. Removed only that row/branch under the campaign rule; five remaining compaction cases pass, along with lint-suppressions, affected types, typed lint and fresh P2 review. Its provenance is `44d905388f9` / openclaw#139429, not a human report of post-call input mutation. The final conflict repair keeps main's equivalent streaming/steering refactors, removes the obsolete retry predicate, and passes 49 owner tests plus lint-suppressions. Cancelled jobs are not counted as passing; final-head hosted CI remains the gate. No CI job was rerun.
- CI `38130432441` had one inherited fixture failure: three `sessions-mutations.catalog-queue` cases selected their configured default while expecting override fields, after openclaw#169030 intentionally made that selection a default reset. Integrated main's existing fixture-only correction `a8ef16f77650`, retaining all assertions. The corrected file passes all 14 cases on clean main under Node and Bun; the three affected cases also pass under Bun on this branch (249.87s project, mostly transformation). Exact-head hosted CI remains the final gate.
- Focused effects suites: **43 passed** across inbound-registry, remote-publication, hot-reload-dispatch and tool-search-scheduling. This includes cancellation, parent confinement, ordinary rollback/failed-activation recovery, and queued implementation replacement. Single-worker wrapper 752.15s including 142.017s compiled-worker preparation; infra 432.15s and agents-core 115.09s. Final restored remote-publication file: **7 passed**, including first reply crossing catalog adoption and exact derived-parent confinement; wrapper 372.77s (184.30s worker preparation; 131.87s Vitest). These loaded-host timings are not a performance claim.
- Integrated native-binding suites: **20 passed**, including exact token cleanup, successor protection, and revocation. The same command passed all **3 lint-suppression tests**. Single-worker wrapper 354.47s including 145.31s worker preparation.
- Current core types and native-binding test graph passed; runtime cycles **0**, Madge cycles **0**; changed-file typed lint passed. The full changed-check run reached an old-base UI duplicate-import error already fixed on main by `ef175b247c9`; that fix was integrated and the affected UI graph passed. Remaining type graphs and static guards were completed separately without changing baselines.
- Isolated Linux scope run and canonical remaining projects exercised **19,900 passing tests**. Eight failures were investigated: three pinned removed synthetic retry paths and were deleted; five exposed the correctness/fixture issues described above and were repaired with focused proof. Existing platform skips were unchanged. This is combined incremental proof, not a claim that one final-head all-scope invocation was green.
- Final repair suites: **71 passed** across passive runtime, SSE recovery, startup backoff, bootstrap, stream reconciliation/markup/phase coverage; **12 passed** across sandbox/cursor coverage, followed by **2 passed** for the real-append cursor fixture. Final MCP regression retained stdio-exit recovery and HTTP failure semantics; it passed 64 cases but hit two unchanged local child-start deadlines (1s/2s). Those initial-start paths passed on the isolated Linux run; no timeout, retry, or skip was changed to mask the local failures.
- Full-core Linux lint passed with 13 existing max-lines warnings, none in changed files. Deadcode identified and drove removal of the unused owner-publication helper. Remaining findings were in unmodified config/state/Gateway/UI files. A separate fresh current-main checkout (`401216ac50`) passed production deadcode and failed full-tree deadcode only on the unrelated `readActiveGatewayLockPortMock` export. The PR does not change any deadcode baseline.
- Blacksmith Testbox did not admit a runner within 15 minutes; AWS quota pressure supplied an undersized instance, which was released. The authorized Hetzner fallback supplied the Linux proof above. All owned remote leases are stopped. Hosted CI on the exact final head remains the landing gate; no CI jobs were rerun.

<details>
<summary>Audit coverage ledger and retained boundaries</summary>

| Mechanism (base lines) | Scenario and provenance | Decision |
| --- | --- | --- |
| context-cache-projection.ts:145-213, context.ts:87-109,146-169 | Cancellation/replacement during pure batched metadata computation. 0dd154f / openclaw#119607 fixed a measured multi-second RPC stall by yielding and atomic publication. Mid-batch authority callbacks were extra cancellation machinery; no effect occurs in projection. | REMOVE repeated projection/early checks; KEEP cooperative yields and the caller's check immediately before publication. |
| context-runtime-state.ts:33-38 | 0dd154f / openclaw#119607 seeds an old global singleton and new cache module in a synthetic child process; no human report of mixed code versions within one live process. | REMOVE old-module/cache-pair normalization, its only reuse flag, and the synthetic migration test. Ordinary process startup and same-version bundled singleton sharing remain. |
| prepared-model-runtime-lease.ts:149-164 | 9505286 / openclaw#153386. Human report openclaw#153313 by stackingrockss includes the deployed Docker version, profiler samples, and repeated boot-loop observations. Its infinite retry was caused by non-idempotent runtime selection normalization. | KEEP normalized owner selection and a visible error when a settled replacement never published; REMOVE the acquisition retry loop entirely, so it cannot spin. |
| prepared-model-catalog-worker.ts:71-220 | 9d58cf2 / openclaw#150354. Human report openclaw#149538 by 609NFT describes copied production fleet state, 632 agents, 504 failed health probes and growing RSS. openclaw#161738 by matthematics1137 reports 92 worker lifetimes, OOMs and 1.285 TB written. | KEEP one bounded shared worker, borrower cleanup, failure logging, and ordinary crash recovery. These are measured resource and real concurrency contracts, not permission to retain unrelated reload fences. |
| prepared-model-runtime.refresh-scope.ts:240 | 3e7ca30 / openclaw#151597 by obviyus describes a controlled worker crash and synthetic Gateway regression, not a human production report. Later openclaw#161738 independently establishes actual recurring worker failures. | KEEP source-bound failure reporting and bounded recovery to avoid reintroducing the observed restart/discovery amplification. The openclaw#151597 PR alone is not accepted incident evidence. |
| prepared-model-runtime.resources.ts:30-127 | d70d026 / openclaw#143109 contains native regressions and synthetic compiled CLI/Gateway proof, no linked human incident. | KEEP physical resource claims until ordinary concurrent borrowers settle and shutdown joins their cleanup; these are required cleanup mechanics, not a blanket historical-incident exemption. Inspected the complete resource owner; no extra reload retry protocol lives here. |
| prepared-model-runtime.plugin-lifetime.ts:230-319 | 1233536 / openclaw#159448 links openclaw#157842 by highfly-hi: five-agent Linux deployment with catalog-worker heap increasing 70-80 MB per scheduled turn, watchdog restarts and before/after version evidence. | KEEP final registry-reference release, current execution authority, and ordinary borrowed-resource settlement. Retained memory claims are scoped to physical lifecycle, not all historical publication machinery. |
| prepared-model-runtime.lifecycle.ts:101-164 | d92dc37 / openclaw#162484 by jalehman records actual lossless-claw maintenance calls stuck about 45 minutes during reload until restart. 1f3038b / openclaw#162301 explicitly says synthetic Gateway, no production deployment. | KEEP refusal of plugin work waiting on its own drain and process-close settlement. openclaw#162301 is synthetic evidence, not an independent incident exemption. |
| prepared-model-runtime-lease.ts acquisition loop and borrowed-generation branch | 1977a39 / openclaw#128138 and related openclaw#127217 describe synthetic QA-channel/config replacement tests; openclaw#127217 explicitly reports that its pre-fix real-Gateway run still delivered replies. Retained inbound-registry tests exposed ordinary nested selected-parent borrowing as a distinct contract. | REMOVE retry/rebind loop. KEEP exact open-parent borrowing and selection confinement; a reload during new acquisition may fail that request visibly. |
| prepared-model-runtime.published-owner.ts:91-203 | d92dc37 / openclaw#162484 added retry/recursive rereads alongside the real plugin-drain repair. That incident justifies self-drain refusal and ordinary settlement, not recursive passive owner reselection. | REMOVE repeated rereads/retries; wait once, then project or activate once. Pure catalog-stale bookkeeping no longer revalidates generation after its await. |
| prepared-model-runtime.configured-refresh.ts remote catalog adoption | 27a0f6d / openclaw#158000 has explicitly synthetic config/auth churn and fixture-provider proof; no human incident cited for the reread loop, per-attempt controllers or three-attempt owner settlement recovery. | REMOVE those race-specific retries, plus early duplicate currentness checks/error relabeling. KEEP the final owner/authority check, atomic rows/pricing commit, current catalog ordering, and ordinary cancellation/disposal. |
| prepared-model-runtime.configured-refresh.ts:396-430 parent subscriptions | 27a0f6d / openclaw#158000; same synthetic churn proof. Parent-generation subscriptions duplicate the final owner/generation/config check. | REMOVE parent-generation early cancellation listeners. KEEP shutdown and candidate-retirement cancellation, bounded work, cleanup, and the final serialized effect check. |
| prepared-model-runtime.owner.ts:612-631 batch supersession retry | 4616d20 / openclaw#152467. Tests force one auth owner to supersede while a sibling is building. No independent human incident identified for sibling retry. | REMOVE retry of the surviving batch; retain source-bound credential/current-owner checks and report the original publication failure. |
| prepared-model-runtime.owner.ts:124-134 unused publication probe | e56f825 / openclaw#130856 introduced a helper returning matching/pending publication facts for acquisition retries. Its callers are gone; full-repository search finds only the definition. | REMOVE the dead helper/export. Credential-refresh cancellation remains supported by the direct, abortable configured-owner wait and its unchanged regression tests. |
| sandbox/registry.kernel.ts:396,420; sandbox/registry.ts:295 | 5c7e44c / openclaw#151172 is not treated as an incident report. Read-only admission accepts older schemas; tableExists consumes admitted schema.tables facts, not repeated SQL/format validation. | KEEP the existing absent-table empty/null contract. No runtime foreign-commit or repeated validation probe exists in these calls. |
| harness/native-session/binding-leases.ts | b272376 / openclaw#158396 moved writes to workers; elapsed-time rechecks were covered by synthetic clock-jump tests. ffd0759 / openclaw#164197 supplies native successor authority behavior, not a blanket exemption. | REMOVE prepared callback plumbing and post-worker wall-clock-only rechecks. KEEP exact-row CAS, token/phase/failure checks, current mutation authority, bounded acquisition, renewal, and write settlement. |
| harness/context-engine-logical-turn.ts | openclaw#143491/openclaw#140023 supply synthetic lifecycle tests, not qualifying human incident evidence. The owner actually holds resources used by outstanding context-engine work. | KEEP ordinary work completion and deferred disposal until implementation settlement; no extra synthetic reload retry was retained here. |
| harness/model-catalog.ts:168-177,242-284,353 | 01fd244 / openclaw#134524 repairs human availability report openclaw#134460. Passive replacement/closure branches were additional maintainer hardening and synthetic variants, not that report's failure. | REMOVE passive isCurrent callbacks and ambient registry replacement checks. KEEP exact owned registry/config, provider outcomes, discovery, selection and the actual availability repair. |
| auth-profiles/oauth-refresh-peers.ts | openclaw#166183/openclaw#167002/openclaw#166659 are not claimed as human incident evidence. Refresh credentials rotate/revoke and carry account identity; copied historical peers must not replay spent tokens or inherit another account. | KEEP these credential/identity effect boundaries and ordinary uncertain-write settlement. No auth-profile schema, secrets, permissions or durability changes. |
| worktrees lifecycle/removal | Audited run-lease-owner.ts, service-preparation.ts, eviction.runtime.ts and gc-removal.ts. They coordinate destructive removal of user artifacts with live checkout/source handles, exact refs and ordinary parallel sessions. No PR title is treated as incident evidence. | KEEP current-row removal/exclusive source checks and rollback/cleanup custody for writes and deletion. Removing them would risk user artifacts, independently prohibited by the data-loss boundary. |
| tool-search-scheduling.ts | 49f8d29 / openclaw#140767 adds ancestry reentrancy and queued object/mode identity checks with automated interactive/headless regressions. Production catalogs exclude control tools; recursive calls using the same runtime were synthetic only. | REMOVE unreachable nested-call ancestry. KEEP one exact queued implementation/mode check at the effect, catalog-ID authorization, FIFO/exclusion, abort and implementation settlement. |
| agent-steering-queue.ts:194-263 | 94acbe6 / openclaw#163195 records Peter's actual three-day production errors. The incident justifies owner/FIFO repair, not a fingerprint of every result label/task/time/outcome/origin/transcript field. | REMOVE full payload fingerprints and deep-equality invalidation. KEEP run-owner identity, prepared result authority, current requester store, pending-row effect checks, FIFO, exact lease/status acknowledgment and release. |
| agent-bundle-mcp-manager.ts and manager-install.ts | 1d60d3d / openclaw#138694 reports synthetic fail-before/real-transport proof but no cited actual-use incident for repeated crossed-publication acquisition/reload. | REMOVE the acquisition retry/rebind loop and repeated reload replay. KEEP the runtime-key queue, ordinary cleanup, one postcreation config catchup, requester credentials/authorization and live tool effect checks. |
| agent-bundle-mcp-runtime.ts catalog generations | 140dbbd / openclaw#125564 and follow-up 0818bcb / openclaw#167642 have synthetic notifications/listing interleavings, not human reports for replaying tools/list during its own response. | REMOVE catalog invalidation generations, replay of a notification arriving inside tools/list, and the impossible repeated replacement-retirement loop. KEEP listing single-flight, caching, bounds, diagnostics, normal reconnect, one retry for an actually exited previously healthy server, and execution authority. |
| prepared-model-runtime-lease.ts / plugin-lifetime.ts configured-generation re-admission | 8b13535 / openclaw#168410, landed during this lane, describes a gated Docker reproduction with catalog publication 0.3s after admission, not an actual human-user incident. | REMOVE configured-generation retry and its now-unused WeakSet plus the two retry-only tests. KEEP fail-closed superseded-generation rejection and the new derived-parent confinement security test. |

</details>
steipete added a commit that referenced this pull request Oct 15, 2026
…ply text (wave-4 bundle) (#172669)

* refactor(infra): remove redundant replay and freshness machinery

Trust successful migration statements inside their synchronous transactions,
reuse unchanged approval parses, share canonical package-root discovery,
namespace directory caches by plugin identity, and simplify ephemeral presence,
OS facts and suspension timer bookkeeping. Keep source validation, conflicts,
transaction durability, postcommit checks, security authority and write settlement.

Best-effort tradeoffs accepted

- Node-host own-write verification (#108457): no human successful-SQL-loss report; SQL errors still roll back, and independent source retirement checks remain.
- Workspace setup/attestation replay (#109147): no human driver-rewrite report; trust successful writes while retaining fingerprints and later source checks.
- APNs expected-ID replay (#108543): no human silent-insert-loss report; canonical parsing, tombstones and receipts remain.
- Device-auth presence assertion (#112663): no human successful-upsert-loss report; credential validation and transaction failure handling remain.
- Device-identity replay (#110392): no human silent-row-rewrite report; preserve independent post-await verification before source deletion.
- MCP OAuth replay (#161219): no human silent-write-loss report; canonical/source parsing and worker admission remain.
- Exec-approval read/parse/deep-compare replay (#114063): no human successful-driver-rewrite report; malformed policy stays fail-closed and actual authority is unchanged.
- Shared-auth target reread (#123349): no human silent-row-rewrite report; return the known SQL postimage and keep independent copy/flip/cleanup checks.
- Identical authored approval bytes (#168094) reuse the existing parse; changed normalized bytes still parse before publication.
- Plugin metadata fingerprinting (353d778): no human in-place metadata-mutation report; distinct objects remain isolated, and same-object edits use TTL/reset.
- Duplicate asset ancestor search (7224585): no human cached-miss incident; canonical realpath/wrapper discovery remains, while newly appearing packages need owner invalidation/restart.
- Presence logical clock (#134737): provenance is synthetic rollback/suspend tests; clock correction may temporarily retain or hide display rows until full update/reconnect, wall time catches up, or restart. TTL, capacity and connection privacy remain.
- Suspension timer generation (#130003): the removed test directly called a canceled callback; native timer cancellation and current-entry authority remain. An out-of-contract timer implementation could resume a renewed lease early.
- OS tuple-keyed cache (#135911): keep measured probe sharing and sticky labels; hot-patching OS identity needs restart rather than another namespace.
- Presence list type guards (409a160): callers supply validated arrays; existing normalization still owns their values.

Production +40/-228, net -188. Focused migration, asset/cache, presence/caller,
approval-publication and suspension/OS tests pass, as do production and infra-test
types, changed-file lint, assertion and suppression checks, and zero-cycle checks.
Independent final review has no actionable P0-P2 findings. No schema, durability,
retention, indexing, permission, recovery or public SDK change is intended.

Broad changed-check is not claimed green: the original base reproduces the
455-versus-454 environment budget failure. The initial Web Push Doctor timeout
remains unattributed; all Web Push production hunks were dropped and its exact
test passed on restored source. Full build and hosted CI remain unrun.

* refactor(agents): simplify reply preparation and refresh bookkeeping

Share typed actor-store adapters and prepared async auth reads. Reuse the
admitted memory-flush plan, retain last-good catalog views by provider, and
remove unused metadata bookkeeping and config projections. Preserve live
credential/effect authority, FIFO, transcript durability, and ordinary write
settlement. Net production reduction: 303 lines.

Best-effort tradeoffs accepted:
- Plugin-drain successors (#162301, synthetic): wait the current drain once;
  a later reload owns its own publication and recovery.
- A changed memory-flush plan during preparation (#162177/#121157, synthetic):
  finish with the admitted plan; the next turn resolves again.
- Per-row catalog freshness (#158113, synthetic): failed discovery retains
  the provider's last-good configured and supplemental overlays until success.
  Existing auth/profile/source gates and successful-empty replacement remain.
- MCP sibling invalidation during discovery (#138694, synthetic): a listing
  may briefly be stale; the next read observes the invalidation.
- Passive context metadata supersession (#119607, synthetic): late discovered
  metadata may win until refresh. Keep the single current-promise check before
  replacing configured limits, preserving the human capacity fix (#39857).
- Registration-time question answers (#110372/#134003, synthetic): a prompt
  can briefly race the answer; its terminal signal closes delivery.
- Duplicate or never-attached internal question registrations: both real
  producers attach once synchronously. Unsupported misuse loses its extra
  diagnostic/disposal wakeup; ordinary lifecycle rejection remains.
- Cancellation publication once/must-consume flags (#161124, synthetic): the
  sole internal producer invokes once. Keep active-scope/effect authority.
- In-flight placement-service replacement (#164744, synthetic): use the
  captured startup service, with its observation and writer authority intact.
- Compaction callback rebinding (#146732/#163264, synthetic): current work
  retains its captured callbacks and live assertion; later work captures anew.
- Re-entrant logging between synchronous run-owner checks: #162227 removed
  the awaited retry, making the second check redundant. Real post-await and
  mutation-effect checks remain.
- Startup diagnostic admission (#146792): the sole producer checks lifecycle
  immediately before recording. Remove only the recorder's duplicate check;
  preserve the human abort/recovery fix (#146692), reset, and admin redaction.

Release-note context: verbose diagnostics no longer include suppressed reply
text or background bash command contents. Execution and user replies remain
unchanged. Config show uses the same schema-aware redactor without cloning
an already detached result or redacting unused snapshot views.

Validation: touched core, messaging and Gateway-method type graphs passed;
49 changed TypeScript files passed targeted lint/format; runtime and Madge
cycles are both zero. Auth reader, question authority, memory flush, restart
claim, catalog worker, cancellation and compaction boundary proof is recorded
in the lane ledger. Final supplemental run: 392 tests passed, four failed
across 28 files, with final source verification. All 120 agents-support tests
passed, including refresh coalescing, publication, run-wait and compaction.
The four failures were an unchanged 120s ACP reset deadline and three MCP
fixtures settling before child startup markers (empty logs, existing 1-2s
connection/4s catalog deadlines). Narrow failed-case replay passed ACP reset
and two MCP cases; the one-second MCP retirement fixture still failed before
its first child marker. Clean lane-base comparison could not reach assertions:
the temporary checkout lacked workspace-local dependency links for worker
compilation. That case is unresolved, not proven inherited; coordinator-bundle
CI must adjudicate it. No deadline, retry, skip or assertion was weakened.
The final selected real-dispatch suppressed-reply logging regression passed
with completed source verification (one selected case, 202.58s wrapper).

Independent P0-P2 review completed four passes. Declined duplicate findings
about unsupported placement-service hot-swap (real observation/database/writer
authority remains) and alleged run-wait awaits (only synchronous logging lies
between the checks; real mutation and post-await checks remain).

Broad check-changed is NOT green: env-name budget 455/454 also fails on the
unchanged lane-base index, with no added env names; production/full-tree Knip
hit their existing 600s budget; the silent legacy-store scan was interrupted
after 782s. Those two scans are missing proof, not attributed inherited reds.
Hosted coordinator-bundle CI remains the broad gate. Owned mock/type/legacy
fixture findings were corrected and their targeted replays pass.

No changelog, dependency, database schema, durability, retention, permission,
or public API change is included. BELOW-500 branch-only coordinator handoff;
no lane PR or merge.

* chore: shrink stale reply assertion allowance

* test: align catalog publication calls with current contract
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…ply text (wave-4 bundle) (openclaw#172669)

* refactor(infra): remove redundant replay and freshness machinery

Trust successful migration statements inside their synchronous transactions,
reuse unchanged approval parses, share canonical package-root discovery,
namespace directory caches by plugin identity, and simplify ephemeral presence,
OS facts and suspension timer bookkeeping. Keep source validation, conflicts,
transaction durability, postcommit checks, security authority and write settlement.

Best-effort tradeoffs accepted

- Node-host own-write verification (openclaw#108457): no human successful-SQL-loss report; SQL errors still roll back, and independent source retirement checks remain.
- Workspace setup/attestation replay (openclaw#109147): no human driver-rewrite report; trust successful writes while retaining fingerprints and later source checks.
- APNs expected-ID replay (openclaw#108543): no human silent-insert-loss report; canonical parsing, tombstones and receipts remain.
- Device-auth presence assertion (openclaw#112663): no human successful-upsert-loss report; credential validation and transaction failure handling remain.
- Device-identity replay (openclaw#110392): no human silent-row-rewrite report; preserve independent post-await verification before source deletion.
- MCP OAuth replay (openclaw#161219): no human silent-write-loss report; canonical/source parsing and worker admission remain.
- Exec-approval read/parse/deep-compare replay (openclaw#114063): no human successful-driver-rewrite report; malformed policy stays fail-closed and actual authority is unchanged.
- Shared-auth target reread (openclaw#123349): no human silent-row-rewrite report; return the known SQL postimage and keep independent copy/flip/cleanup checks.
- Identical authored approval bytes (openclaw#168094) reuse the existing parse; changed normalized bytes still parse before publication.
- Plugin metadata fingerprinting (f31bc71): no human in-place metadata-mutation report; distinct objects remain isolated, and same-object edits use TTL/reset.
- Duplicate asset ancestor search (40fb74f): no human cached-miss incident; canonical realpath/wrapper discovery remains, while newly appearing packages need owner invalidation/restart.
- Presence logical clock (openclaw#134737): provenance is synthetic rollback/suspend tests; clock correction may temporarily retain or hide display rows until full update/reconnect, wall time catches up, or restart. TTL, capacity and connection privacy remain.
- Suspension timer generation (openclaw#130003): the removed test directly called a canceled callback; native timer cancellation and current-entry authority remain. An out-of-contract timer implementation could resume a renewed lease early.
- OS tuple-keyed cache (openclaw#135911): keep measured probe sharing and sticky labels; hot-patching OS identity needs restart rather than another namespace.
- Presence list type guards (3965f6b): callers supply validated arrays; existing normalization still owns their values.

Production +40/-228, net -188. Focused migration, asset/cache, presence/caller,
approval-publication and suspension/OS tests pass, as do production and infra-test
types, changed-file lint, assertion and suppression checks, and zero-cycle checks.
Independent final review has no actionable P0-P2 findings. No schema, durability,
retention, indexing, permission, recovery or public SDK change is intended.

Broad changed-check is not claimed green: the original base reproduces the
455-versus-454 environment budget failure. The initial Web Push Doctor timeout
remains unattributed; all Web Push production hunks were dropped and its exact
test passed on restored source. Full build and hosted CI remain unrun.

* refactor(agents): simplify reply preparation and refresh bookkeeping

Share typed actor-store adapters and prepared async auth reads. Reuse the
admitted memory-flush plan, retain last-good catalog views by provider, and
remove unused metadata bookkeeping and config projections. Preserve live
credential/effect authority, FIFO, transcript durability, and ordinary write
settlement. Net production reduction: 303 lines.

Best-effort tradeoffs accepted:
- Plugin-drain successors (openclaw#162301, synthetic): wait the current drain once;
  a later reload owns its own publication and recovery.
- A changed memory-flush plan during preparation (openclaw#162177/openclaw#121157, synthetic):
  finish with the admitted plan; the next turn resolves again.
- Per-row catalog freshness (openclaw#158113, synthetic): failed discovery retains
  the provider's last-good configured and supplemental overlays until success.
  Existing auth/profile/source gates and successful-empty replacement remain.
- MCP sibling invalidation during discovery (openclaw#138694, synthetic): a listing
  may briefly be stale; the next read observes the invalidation.
- Passive context metadata supersession (openclaw#119607, synthetic): late discovered
  metadata may win until refresh. Keep the single current-promise check before
  replacing configured limits, preserving the human capacity fix (openclaw#39857).
- Registration-time question answers (openclaw#110372/openclaw#134003, synthetic): a prompt
  can briefly race the answer; its terminal signal closes delivery.
- Duplicate or never-attached internal question registrations: both real
  producers attach once synchronously. Unsupported misuse loses its extra
  diagnostic/disposal wakeup; ordinary lifecycle rejection remains.
- Cancellation publication once/must-consume flags (openclaw#161124, synthetic): the
  sole internal producer invokes once. Keep active-scope/effect authority.
- In-flight placement-service replacement (openclaw#164744, synthetic): use the
  captured startup service, with its observation and writer authority intact.
- Compaction callback rebinding (openclaw#146732/openclaw#163264, synthetic): current work
  retains its captured callbacks and live assertion; later work captures anew.
- Re-entrant logging between synchronous run-owner checks: openclaw#162227 removed
  the awaited retry, making the second check redundant. Real post-await and
  mutation-effect checks remain.
- Startup diagnostic admission (openclaw#146792): the sole producer checks lifecycle
  immediately before recording. Remove only the recorder's duplicate check;
  preserve the human abort/recovery fix (openclaw#146692), reset, and admin redaction.

Release-note context: verbose diagnostics no longer include suppressed reply
text or background bash command contents. Execution and user replies remain
unchanged. Config show uses the same schema-aware redactor without cloning
an already detached result or redacting unused snapshot views.

Validation: touched core, messaging and Gateway-method type graphs passed;
49 changed TypeScript files passed targeted lint/format; runtime and Madge
cycles are both zero. Auth reader, question authority, memory flush, restart
claim, catalog worker, cancellation and compaction boundary proof is recorded
in the lane ledger. Final supplemental run: 392 tests passed, four failed
across 28 files, with final source verification. All 120 agents-support tests
passed, including refresh coalescing, publication, run-wait and compaction.
The four failures were an unchanged 120s ACP reset deadline and three MCP
fixtures settling before child startup markers (empty logs, existing 1-2s
connection/4s catalog deadlines). Narrow failed-case replay passed ACP reset
and two MCP cases; the one-second MCP retirement fixture still failed before
its first child marker. Clean lane-base comparison could not reach assertions:
the temporary checkout lacked workspace-local dependency links for worker
compilation. That case is unresolved, not proven inherited; coordinator-bundle
CI must adjudicate it. No deadline, retry, skip or assertion was weakened.
The final selected real-dispatch suppressed-reply logging regression passed
with completed source verification (one selected case, 202.58s wrapper).

Independent P0-P2 review completed four passes. Declined duplicate findings
about unsupported placement-service hot-swap (real observation/database/writer
authority remains) and alleged run-wait awaits (only synchronous logging lies
between the checks; real mutation and post-await checks remain).

Broad check-changed is NOT green: env-name budget 455/454 also fails on the
unchanged lane-base index, with no added env names; production/full-tree Knip
hit their existing 600s budget; the silent legacy-store scan was interrupted
after 782s. Those two scans are missing proof, not attributed inherited reds.
Hosted coordinator-bundle CI remains the broad gate. Owned mock/type/legacy
fixture findings were corrected and their targeted replays pass.

No changelog, dependency, database schema, durability, retention, permission,
or public API change is included. BELOW-500 branch-only coordinator handoff;
no lane PR or merge.

* chore: shrink stale reply assertion allowance

* test: align catalog publication calls with current contract
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 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 security-sensitive-changed 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