Skip to content

fix: preserve runtime custody, inference history, and recovery (2026.11.7 forward ports) - #203901

Merged
RomneyDa merged 15 commits into
mainfrom
openclaw/qualified-source-repairs
Nov 23, 2026
Merged

RomneyDa merged 15 commits into
mainfrom
openclaw/qualified-source-repairs

Conversation

@tideclaw-bot

@tideclaw-bot tideclaw-bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Runtime handoffs can lose the information or resource ownership they were admitted with: historical inference usage, database captures, updater imports, authentication recovery, retained knowledge receipts, and child sends waiting for plugin reload. These failures can misreport usage, interrupt recovery, or strand admitted work.

User Impact

Preserves admitted runtime policy and historical usage, keeps captures and passive resources with their owning lifecycle, retains old updater imports during replacement, keeps provider readiness visible during sign-in recovery, replays knowledge receipts without duplicate inserts, and prevents a claimed child from being swept while its send is retained. No release, tag, dependency, SQLite-schema, or public-permission change is included.

Scope and provenance

The six source repairs were qualified together, not as six independently passing branches. The import matched all 131 non-generated source files byte-for-byte; the overlapping Gateway validator was regenerated from integrated schemas. Fresh integrated review found a policy-reader P1: a distinct harness listing config could replace the admitted policy reader. The follow-up preserves that reader, exercises both shared-catalog acquisition orders, and corrects historical-versus-live consumer contracts without casts or requiring historical cost.

  • Source range: e15246d4ff96d1e19478db79262c679809624198..e0adbf242d102481f4fd938fbb449712b6935d3c
  • Integrated base: b151c830713020fe0de9e37c3d21b76671fe0add
  • Consumer repair: b1b254a2e6f3e9645d98eac09a816d7eb2165079
  • Goal replay follow-up: 86cdda60ded67023ef648c800690f2e996a4a86b
  • Final type/TUI follow-ups: c8075920ea81c250b4402cba718866d094c7ce74, fdf5d316e897a447a8e0cea9182bf90ea2f9ffeb
  • Published head: 91d65e5650337e695fdc240763e0c3f370184116

Original author/coauthor trailers are preserved. Separate from release-metadata PR #203880; the unrelated qualification-only cron change is excluded.

Evidence

  • Fresh integrated canonical native review identified the policy-reader P1; corrected diffs completed scoped-clean P0–P3 reviews. Reviewers had limited unchanged context and did not independently execute tests. A transient-file-invalidated review was not accepted. No tracked source differs between final reviewed fdf5d316 and published 91d65e5.
  • Policy regression failed red in both acquisition orders; all 74 config-stamp/host-boundary tests passed (79.90s).
  • Stable affected-consumer run: 287 tests across 13 shards passed (222.62s), with one Windows short-path skip. Covers provider/history contracts, database/native lifetimes, updater imports, agent tools/prefix stability, UI, Codex resume/whole-skill results, and knowledge replay. An earlier source-edit-invalidated run was excluded.
  • Four historical/live fixture mismatches were corrected; affected typecheck/type-aware lint passed, plus 72 tests in three corrected files (62.24s).
  • Local core/UI/tooling typechecks, generated-validator, formatting and diff checks passed. Full build passed (199.5s); advisory CSS/boot budgets were not suppressed. These are bounded local results, not green merge-ref CI.
  • Follow-up consumer runs passed 228 historical/live tests, 138 runtime-selection/live-switch tests, 119 retained-import/tooling tests (one Windows skip), 11 RUN-generation resource tests (13.75s), and 167 shared Codex transcript tests (108.39s). Scoped review clean, 0.86 confidence, no independent tests.
  • Goal regression preserves the synthetic post-commit notification fault and requires successful admitted execution, committed metadata and same-request replay without another model run/user message: 1 selected passed, 69 filtered (18.79s). Affected type/lint/line-cap/allocation checks passed; scoped review clean (0.86).
  • Compaction narrows the existing optional owner with expectDefined; exact type leaf failed before/passed after, with all 13 runtime tests passing (10.47s). TUI asserts shared catalogOwner, retaining both admissions and one inventory-work assertion: three tests passed (2.97s). Affected checks and combined scoped review passed (0.94, diff-only).

Historical review reconciled

An independent read-only audit of current source and existing logs reconciles all three findings on historical head 813d2a:

  1. The missing mock export was in src/agents/agent-command.live-model-switch.test.ts, now preserving real exports, not the review-named src/commands/agent.runtime-config.test.ts. The actual consumer and prepared-runtime suites pass 138/138; the review-named command suite independently passes 6/6. Its unrelated narrow mock was not expanded.
  2. Snapshot assertions now verify shared catalog ownership, per-caller admitted reader binding, generation currency and revocation rather than wrapper identity.
  3. Postbuild expectations classify the recorded immutable-handoff module/symbol rather than only one release version. All 116 postbuild tests and three retained-import process cases pass; one Windows case is skipped.

The old advisory verdict is not current-source evidence of these defects. Maintainer/bot authorship does not exempt real-product proof.

Direct-source, runtime and visual proof

Direct-source alias proof uses the unbundled retention owner/worker, canonical TypeScript preload, unchanged assertions and --preserve-symlinks. Separately installed frozen standard-hoisted dependencies resolve the original pnpm-layout strip-ansi setup blocker without modifying managed dependencies. Selected test passed (35.10s); substituting only pre-fix retention owners from 07ff88e^ reproduced the original late import failure (install-alias/dist/late-old-hash.mjs); restored candidate owners passed (38.05s). No bundled owner/worker or synthetic loader; other variants were filtered.

Existing database/native child tests exercise real capture/preparation, native database operations and child-process custody. Historical-usage tests exercise production projection and serialized commit validation. Knowledge tests reconstruct persisted legacy/prefixed receipts through restarted storage/service owners and verify unchanged identity, payload rejection and no duplicate inserts. These are meaningful boundary proofs, not a claim of a completed real-agent historical/knowledge replay or installed upgrade.

Browser captures use the canonical synthetic harness: one before scenario, two after. Before owners are exact b151c830 bytes; after UI tree is frozen at d6a35d31. This is valid source-mode mocked-Gateway browser proof, not a complete base deployment or external authentication-service proof. UI evidence comment: all four images browser-verified decoded at 1280×1000 through the configured proxy with certificate verification enabled. Auth assertions include document retention, popup recovery and later real reload.

Prior combined-source evidence includes a real-model claimed-child flow proving reload admission/drain/replay, not bundled-byte hot-swap. Cancellation/replacement controls remain fixture-based. Local refusal-compaction previously failed before reaching its loopback server; that remains a setup/transport gap, not passing stream proof.

Terminal CI outcome and causal attribution

Not ready to land. Main CI 45113172591 completed failure on head 91d65e5650337e695fdc240763e0c3f370184116. Checkout logs identify exact merge e80ed29fd9aac66a17292ba00037c8cc4eb76aab against newer base b9bb7a99494aac52c3a6f9b1b29227bbfaaae84c. Nine substantive jobs failed, followed by the aggregate gate; all six test-type jobs, production types and all five PostgreSQL conformance jobs passed.

Validate 45113172007 / job 137489912500 also failed. Production Knip had zero entries; full-tree Knip reports exactly test/manual-release-approval.checks.ts and test/manual-release-approval.config.ts, matching the original-base reproduction. No ignore/baseline exception was added.

Failure Attribution and limits
Abort-session fence Same failure reproduced on original base.
Imported-PR rejection messages Three failures reproduced on original base.
Doctor heartbeat recovery Three failures reproduced on original base.
Codex revoked/reassigned source messages Two reproduced on original base; early failure does not prove later no-effect assertions ran.
Docs formatting src/update/AGENTS.md is absent from this branch. Newer-base/merge blob match (056136fb309943a2d816ea267e3d8dc718c3cafa); canonical formatting of fetched base bytes fails. Unrelated instructions unchanged.
Toast browser Test expects false, owner emits "live"; both blobs match newer base/merge. Source-level inherited mismatch, not a separate full-base browser execution.
Hook-token reload Inherited: real isolated E2E on exact head and original base both fail line 524 with [] instead of the old token-source name. Head 48.71s; base selected body 8.285s. Startup/auth, approval, config patch/reload and second approval all execute unchanged.
Chat-abort initiator / membership authority Inherited: real isolated head and original-base runs both reproduce both CI assertions: aborted vs final at line 439, and INVALID_REQUEST vs FORBIDDEN at line 468/149. Head 97.91s; base 107.50s. No mid-request authorization restriction or expectation edit added.
Node-worker launch wire Original CI timeout still unexplained: head and original base pass (101.62s / 100.60s). The exact failing merge also passes all assertions (85.81s total; 43.62s test body), including load-wave completion, workspace settlement, node shutdown, Gateway restart and audit replay. This tests merge-context drift but does not establish a CI root cause or waive its 240s timeout.

The causal runs used the existing network-none isolated runner, matching pinned Bun, prepared Playwright image, and invocation-local umask 077; no host security or artifact fence was disabled. Explicit E2E config selected existing offline native-archive projection and private-QA/declaration build. The exact-merge source manifest was verified before the successful run. Earlier missing-lockfile/index preparation failures are separate setup evidence, not product verdicts.

Unmodified worker tests hit the runner's 2 GiB /tmp versus approximately 4 GiB required by worktree disk admission. All three passing comparisons used identical qualification-only command.tempParentDir patches to the existing disk-backed fixture root, preserving default executable/arguments, assertions and timeouts. Patches were restored byte-for-byte afterward; no runner or fixture change is committed. Owned proof processes completed; containers are confirmed absent; the published working tree is clean.

Historical Talk replay also failed identically on original base. Historical Darwin dependency-cache initialization lacks matching platform/base execution. The finalization-size fixture encodes retired 512 KiB despite an inherited 16 MiB contract; source-contract attribution only. No permission weakening, timeout inflation, blind full-CI rerun or suppression was used.

Test allocation

Combined branch originally had +1,330 net test lines, default allowance 400 and history credits 53; source candidate had +1,329 and 876 combined credits. Consumer/Goal regressions add 72 lines: allocation 948 (1,001 total credits), +1,401 lines; exact-base gate passes. Shared allowance unchanged; six repairs get one default allowance. Qualification-only worker patches were excluded and restored.

Remaining qualification and governance

  • Failed CI: the enforced openclaw/ci-gate remains failed. The exact-merge worker timeout is not causally attributed despite three passing targeted comparisons. No merge or CI rerun was requested by this continuation. A supported inherited-failure landing requires scoped authority, complete attribution and protected-writer capability; it does not turn red CI green or waive behavior/security proof.
  • Latest-stable upgrade: not demonstrated. Root AGENTS.md:83 and docs/install/updating.md:543 require the published-driver × candidate cell retaining settings/existing data. The local supported Docker route is unavailable because the Docker socket is absent. The existing Package Acceptance custom published-upgrade-survivor lane is a remote option, pinned to this candidate and the actual latest-stable baseline at execution, with required package/plugin preparation. No remote dispatch or engine substitution was performed.
  • Real-product replay: a targeted isolated real-agent historical-usage/legacy-knowledge flow remains unproven. Existing native/storage proofs and the real-model retained-child scenario are retained, not misrepresented as this flow.
  • Windows 8.3: untested on Linux; needs Windows and a short-name-capable volume. This is a recorded platform limitation, not automatically an unconditional Linux landing gate.
  • Visual delivery: originating-chat screenshot attachment delivery remains open; PR images/rendering are verified.
  • Review governance: live rules show zero general required approvals plus code-owner review; no changed path matches current restricted CODEOWNERS paths. The current-head sensitive guard records maintainer status and no separate secops approval required. This does not waive applicable owner involvement or later enforcement. ClawSweeper is advisory; its historical score is not an independent required approval.

Worked on by

tideclaw-bot and others added 8 commits November 23, 2026 03:29
Keep the prepared runtime policy reader authoritative when the harness
provides a distinct listing config. Prove live revocation at the host tool
surface for both shared-catalog acquisition orders.

Record the combined six-repair regression allocation without changing
the shared test-line allowance.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 3af5c551-c472-449f-9ee3-8ed1b7d71458
@clawsweeper

clawsweeper Bot commented Nov 23, 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 app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: codex extensions: ollama extensions: copilot plugin: knowledge size: XL labels Nov 23, 2026
@tideclaw-bot

Copy link
Copy Markdown
Collaborator Author

Current-revision Control UI proof

Synthetic provider data in the canonical Control UI browser harness, 1280×1000. Before: b151c830713020fe0de9e37c3d21b76671fe0add; after UI tree: d6a35d31af8f6b828fad110e462e1479b1209c5d, unchanged at published head 813d2a194c3c6dccd3bf85dab52a737c1a39e5c2. The after UI tree is frozen; the before uses exact Git bytes for the two changed production UI owners. This is source-mode browser proof with mocked Gateway responses, not a complete base-repository deployment.

Clean comparison

Before — provider setup is incorrectly downgraded to “No models available.”

Before: setup incorrectly downgraded

After — provider setup stays “Ready,” while the probe accurately reports “No models available.”

After: ready setup with unchanged probe failure

Annotated comparison

Before: incorrect setup status and separate probe highlighted

After: ready setup retained and probe result highlighted

Browser assertions: before 1/1; after 2/2. The additional auth scenario proves pending-probe/sign-in navigation fencing, document retention through popup authentication, and real reload after recovery. Clean frames and readable measured annotations were individually inspected and sanitized. Originating-chat attachment delivery remains a separate completion gate.

@tideclaw-bot
tideclaw-bot marked this pull request as ready for review November 23, 2026 03:44
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 91d65e5650337e695fdc240763e0c3f370184116
  • Maintainer: @tideclaw-bot
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/embedded-agent-tool-authored-source-reply.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/prepared-model-runtime-auth.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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR preserves runtime ownership, historical inference usage, updater imports, authentication recovery, knowledge receipt replay, and retained child sends.

Example: OpenAI setup is ready, but Test access returns status no_model.

  • Before: The provider heading changes to “No models available.”
  • After: The heading stays “Ready,” while the separate probe result reports “No models available.”

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful repairs with inspected visual evidence, but required runtime/upgrade proof is incomplete and exact-head CI exposes three concrete test-consumer migration defects.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Runtime transitions can lose historical accounting, interrupt recovery, or strand admitted work.
Reason: The source supports concrete failures, and maintainer authorship establishes direction for the combined repair.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: these maintainer-authored repairs address behavior still present on main, but three patch-caused test integration failures need correction.

Priority: P2
Reviewed head: 813d2a194c3c6dccd3bf85dab52a737c1a39e5c2

Before merge

  • Preserve the config-reader export in affected command-test mocks (P2) - The new unconditional fallback calls createRuntimeConfigReader during lease admission, but src/commands/agent.runtime-config.test.ts:83 replaces runtime-snapshot.js with an exhaustive mock that omits it. Exact-head CI reaches this line through runLocalAgentCommand and throws before the command assertions run. Update the affected mock to preserve the real export and rerun the consumer suite.
  • Migrate snapshot identity assertions to the policy-binding contract (P2) - Returning a caller-specific snapshot when its policy reader differs intentionally changes object identity, but existing consumers still require identity with the catalog owner's snapshot or another lease. Exact-head CI fails prepared-model-runtime.test.ts:899 and prepared-model-runtime.cancelled-admission.test.ts:313. Update these tests to verify shared inventory, current generation and correct policy binding instead of requiring the wrapper objects to be identical.
  • Recognize the added release's inline denial in postbuild coverage (P2) - The newly recorded 2026.9.36 entry resolves isCurrentManagedServiceUpdateHandoffProcess to the existing inline immutable-handoff shim, which correctly returns false. test/scripts/runtime-postbuild.test.ts:745 expects false only for 2026.9.37 and otherwise expects the origin symbol string, so the added inventory deterministically fails the postbuild compatibility test. Use the existing inline-export classification for that expectation while retaining coverage of every recorded export.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Preserve the config-reader export in affected command-test mocks — src/agents/prepared-model-runtime-lease.ts:139-144
  • [P2] Migrate snapshot identity assertions to the policy-binding contract — src/agents/prepared-model-runtime.capture.ts:111-117
  • [P2] Recognize the added release's inline denial in postbuild coverage — scripts/lib/update-compat-inventory.json:48145-48148

Tests

  • Missing end-to-end proof: Provide redacted runtime traces for the repaired history, custody, receipt-replay and reload paths, browser diagnostics for authentication recovery, and a latest-stable upgrade preserving settings and existing data; redact credentials, IPs, phone numbers and private endpoints.
Agent review details

How this fits together

The agent runtime carries admitted policy, transcript history, and resource ownership through workers, plugin reloads, updates, and UI recovery.

flowchart LR
  A[User request] --> B[Runtime admission]
  B --> C[Prepared model runtime]
  C --> D[Agent and plugin execution]
  D --> E[Worker and database owners]
  D --> F[Retained handoffs]
  E --> G[Transcript and usage]
  G --> H[Control UI]
Loading

Technical review

Best possible solution:

Keep the repairs in their existing owners and complete the affected test-consumer migrations without weakening policy, cancellation, or upgrade assertions.

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

Current-main source shows the missing-cost dereference and strict legacy-receipt rejection; supplied screenshots demonstrate the provider-status case, while exact-head CI independently exposes the test failures listed below.

Is this the best way to solve the issue?

The repairs generally restore ownership and history contracts at existing boundaries, and the retained compatibility paths have named release or incident reasons.

Full review comments:

  • [P2] Preserve the config-reader export in affected command-test mocks — src/agents/prepared-model-runtime-lease.ts:139-144
    The new unconditional fallback calls createRuntimeConfigReader during lease admission, but src/commands/agent.runtime-config.test.ts:83 replaces runtime-snapshot.js with an exhaustive mock that omits it. Exact-head CI reaches this line through runLocalAgentCommand and throws before the command assertions run. Update the affected mock to preserve the real export and rerun the consumer suite.
    Confidence: 0.99
  • [P2] Migrate snapshot identity assertions to the policy-binding contract — src/agents/prepared-model-runtime.capture.ts:111-117
    Returning a caller-specific snapshot when its policy reader differs intentionally changes object identity, but existing consumers still require identity with the catalog owner's snapshot or another lease. Exact-head CI fails prepared-model-runtime.test.ts:899 and prepared-model-runtime.cancelled-admission.test.ts:313. Update these tests to verify shared inventory, current generation and correct policy binding instead of requiring the wrapper objects to be identical.
    Confidence: 0.98
  • [P2] Recognize the added release's inline denial in postbuild coverage — scripts/lib/update-compat-inventory.json:48145-48148
    The newly recorded 2026.9.36 entry resolves isCurrentManagedServiceUpdateHandoffProcess to the existing inline immutable-handoff shim, which correctly returns false. test/scripts/runtime-postbuild.test.ts:745 expects false only for 2026.9.37 and otherwise expects the origin symbol string, so the added inventory deterministically fails the postbuild compatibility test. Use the existing inline-export classification for that expectation while retaining coverage of every recorded export.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Database capture and passive native-resource custody keeps the original intent (31c35d5: The executor refactor retained physical database identity and accepted-write custody; perf(infra): keep worker reference transitions local #184282 separately established host-owned worker liveness.)
  • Historical usage and prepared-runtime policy keeps the original intent (19ecf40: Config stamping kept model catalogs current after updates; the repair preserves that catalog ownership while separating the caller's admitted policy binding and historical accounting shape.)
  • Retained updater imports keeps the original intent (a355200: fix(update): retain late imports on Bun #183429 preserves original module identities and generation bytes during installation replacement.)
  • Provider status and browser authentication recovery changes intended behavior with a stated reason (7ce2d10: Provider status reflected failed access checks, while fix: offer sign-in when a proxy refuses an open Control UI tab's reconnect #201729 reused browser sign-in recovery to preserve an open tab; the new no_model exception distinguishes an unattempted inference from failed access.)
  • Knowledge receipt replay changes intended behavior with a stated reason (0b305a2: fix(knowledge): keep historical claims distinct and reject changed retries #200140 rejects changed retries and preserves distinct historical assertions; the legacy reconstruction retains those checks for modern receipts.)
  • Retained child sends keeps the original intent (bca8823: The earlier self-held-send implementation continues sends after plugin reload; this repair lets the sweep owner consume the retained handoff's existing live fact.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/commands/agent.runtime-config.test.ts --maxWorkers=1
  • pnpm test src/agents/prepared-model-runtime.test.ts src/agents/prepared-model-runtime.cancelled-admission.test.ts src/agents/prepared-model-runtime-config-stamp.test.ts --maxWorkers=1
  • pnpm test test/scripts/runtime-postbuild.test.ts test/scripts/update-compat-extended-stable.test.ts --maxWorkers=1
  • Run affected test typecheck, lint, and formatting checks through the repository wrappers.
  • git diff --check

What I checked:

  • Reviewed introduction and current head: The introduced range is b151c83..813d2a1; GitHub still reports that head as open, ready for review, mergeable, and blocked. (813d2a194c3c)
  • Historical-cost failure remains on main: Current main still dereferences usage.cost.input unconditionally in worker projection, although replay preparation preserves historical usage without recorded cost. (src/worker/assistant-message-projection.ts:49, 7d0cc1ec8157)
  • New config-reader dependency breaks a test consumer: Exact-head CI reports missing createRuntimeConfigReader on the runtime-snapshot mock; src/commands/agent.runtime-config.test.ts supplies an exhaustive mock without that export. (src/agents/prepared-model-runtime-lease.ts:144, 813d2a194c3c)
  • Snapshot identity consumers were not migrated: Exact-head CI fails object-identity assertions in prepared-model-runtime.test.ts:899 and prepared-model-runtime.cancelled-admission.test.ts:313 after the new policy-binding wrapper creates caller-specific snapshots. (src/agents/prepared-model-runtime.capture.ts:114, 813d2a194c3c)
  • Added release inventory breaks postbuild expectation: The added 2026.9.36 inventory includes the inline immutable-handoff denial shim, but runtime-postbuild.test.ts recognizes its false result only for 2026.9.37; exact-head CI reports that mismatch. (scripts/lib/update-compat-inventory.json:48148, 813d2a194c3c)
  • Inspected visual evidence: All four downloaded images were inspected and show the stated before/after provider-status change; the evidence comment explicitly identifies mocked Gateway responses and source-mode browser proof. (ui/src/pages/model-providers/view-status.tsx:136, 813d2a194c3c)

Likely related people:

  • Peter Steinberger: Raw commit 19ecf40 adds src/agents/prepared-model-runtime.owner.ts:59 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 19ecf4014615; files: src/agents/prepared-model-runtime.owner.ts)
  • Vincent Koc: Raw commit 8c1c9ef adds src/agents/prepared-model-runtime.owner.ts:82 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8c1c9ef764bb; files: src/agents/prepared-model-runtime.owner.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: These are useful runtime and recovery repairs with focused test integration blockers, without evidence of an emergency requiring higher priority.
  • add merge-risk: 🚨 compatibility: The public Message/Context contract now represents historical usage.cost as optional; this distinction is part of the maintainer-authored repair direction.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: These are useful runtime and recovery repairs with focused test integration blockers, without evidence of an emergency requiring higher priority.
  • merge-risk: 🚨 compatibility: The public Message/Context contract now represents historical usage.cost as optional; this distinction is part of the maintainer-authored repair direction.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 22, 2026, 11:06 PM ET / November 23, 2026, 04:06 UTC.

tideclaw-bot and others added 7 commits November 23, 2026 04:08
Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 1ee8e850-b796-4dd8-8e03-e0d9d208e030
Identity notifications use the existing non-throwing post-commit publisher. Assert committed custody and replay instead of the retired duplicate publication failure path.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 2a890df0-3b98-46d7-a0f0-23dffc50a4bb
Use the existing presence assertion before reading catalogOwner. Reproduced TS18048 on the exact test graph; the graph and all 13 delegate resource cases pass with the narrowing.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>
Compare the retained catalog owner rather than per-admission policy snapshot identity. The original assertion reproduced red; all three TUI runtime tests, targeted types, lint and formatting pass.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 07b6e2bb-7854-4b59-87f9-e02cfaaaf268
@RomneyDa
RomneyDa merged commit e58ca10 into main Nov 23, 2026
239 of 252 checks passed
@RomneyDa
RomneyDa deleted the openclaw/qualified-source-repairs branch November 23, 2026 05:58
@tideclaw-bot

Copy link
Copy Markdown
Collaborator Author

Final qualification evidence (November 23, 2026)

PR #203901 is merged at e58ca10 (head91d65e5650337e695fdc240763e0c3f370184116). Qualification continued without source changes.

  • Real-agent replay passed: exact-source local Gateway/model recalled historical content while retaining usage without cost. Actual Knowledge dispatcher replay returned the original retained claim, created no duplicates, and refused changed payload under the same request ID. Direct worker launch/inference projection checks also passed; no remote-worker network-roundtrip claim. Credentials remained local and audit found zero raw-value matches.
  • Latest-stable installed upgrade passed: run45118671907, job137512910982, published-upgrade-survivor/base,617s. Published [email protected] upgraded through its actual updater to exact-head package SHA2565fd0a79e3e5bfecbbcce34e70f63916b9f4a77fba685014e50ec3102bd686442. Recorded build identity changed from release-e31bbf056de3 to91d65e565033 despite equal version strings. Settings/workspace/session survival, migrations, plugin-path preservation, cleanup, Gateway health/readiness and status passed. Restart was manual; no automatic-restart/idempotence or complete first-hop snapshot claim.
  • Overall Package Acceptance remains failed: npm12 installed/launched the candidate but the independent installed-tree budget rejected48,050entries versus47,500. Existing main run45112229424/job137494108740 already failed this budget at48,004entries. No budget weakening; this is not an all-green package result.
  • Original CI worker timeout remains unexplained: passing head/base/exact-merge comparisons do not identify the original240s timeout's cause or retroactively make CI45113172591 green. Other recorded baseline attributions remain unchanged.

This evidence supplements the earlier pending upgrade/replay paragraphs; the full report and checked artifacts are retained in the qualification worktree. No release or registry-image publication was performed.

@RomneyDa RomneyDa changed the title fix: preserve runtime custody, inference history, and recovery fix: preserve runtime custody, inference history, and recovery (2026.11.7 forward ports) Nov 23, 2026
obviyus added a commit that referenced this pull request Nov 23, 2026
…icit nil (#204023)

Two scheduled-`main` reds are fixed: `test/scripts/sqlite-schema-assets.test.ts` and the `macos-swift (tests)` SwiftLint step.

Part of #204008.

## Problem

1. `sqlite-schema-assets.test.ts` (both cases) fails on `main` since the 06:45 UTC scheduled run: `TypeError: The "path" argument must be of type string. Received undefined` in `retainUpdateRuntimeImports`. #203901 changed that function's second argument from a list of paths to `{ sourcePath, identityPath }` records and updated its production caller. The test still passed bare paths.
2. `macos-swift (tests)` fails SwiftLint `implicit_optional_initialization` at `apps/macos/Sources/OpenClaw/OnboardingAISetupSupport.swift:295` (`var actionLabel: String? = nil`), added by #203379. Ordinary PRs do not run this lane, so only scheduled `main` CI saw it.

## Solution

- The test now builds `{ sourcePath, identityPath }` records (the same path for both, because the test does not relocate identity).
- Drop `= nil`. An optional `var` already defaults to `nil` in the memberwise initializer, and `Decodable` decoding is unchanged.

## Evidence

- `sqlite-schema-assets.test.ts`: the `main` copy fails both cases locally with the same `TypeError`; this branch passes both.
- SwiftLint 0.65.1 (the version `scripts/install-swift-tools.sh` pins) with `config/swiftlint.yml --strict`: `main` file 1 error (`implicit_optional_initialization` at 295:13), this branch 0 errors. Run with SourceKit disabled, because this host has no Xcode; this rule is syntax-only.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…1766)

(cherry picked from commit 9156690)

Release adaptation: Keep the stable full-prefix test. Exercise in-budget and omitted tool results using stable’s 16 MiB cap; stable no longer sizes this context from contextTokenBudget.

Companion audit: #204028, #203901, #202306 and #203536 are separate finalizer-budget, custody, project-transfer and context-window changes; not dependencies of the timestamp guard.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
* fix(tlon): gate group DMs by club approval

* fix(tlon): persist configured club grants

* docs(config): record Tlon club policy surface

* test(tlon): keep sender role cases under lint limit

* fix(tlon): preserve direct settings events

* fix(tlon): narrow settings event records without assertions

(cherry picked from commit 6eb70d4)

Release adaptation: regenerate stable config docs counts/hashes and bundled channel metadata; no source conflicts. Channel count +6, core/plugin unchanged. The assertion ratchet generator confirms the same Tlon-only shrink; unrelated pre-existing UI ratchet entries are excluded.

Companion disposition: #204126 is a missing optional user-facing warning about later club invitees; existing prompts already disclose unverified participant input and future messages. #203928 is not applicable to approval/routing, only image download lifetime. #204219, #203470, #203901 and #203063 overlap only generated/ratchet files, not applicable; regenerate from stable inputs. No later PR or commit-SHA mentions.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…law#203901)

* fix: keep database captures and passive resources alive correctly

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve inference history and admitted runtime policy

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: retain updater imports and supported upgrade boundaries

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve provider readiness while authentication recovers

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: replay retained knowledge receipts without duplicate assertions

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: keep claimed child sends reachable during plugin reload

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve admitted policy through harness tool listing

Keep the prepared runtime policy reader authoritative when the harness
provides a distinct listing config. Prove live revocation at the host tool
surface for both shared-catalog acquisition orders.

Record the combined six-repair regression allocation without changing
the shared test-line allowance.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve runtime custody, inference history, and recovery

Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 3af5c551-c472-449f-9ee3-8ed1b7d71458

* fix: align runtime repair consumers and break type cycle

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/qualified-source-repairs

Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 1ee8e850-b796-4dd8-8e03-e0d9d208e030

* test: preserve Goal replay after notification failure

Identity notifications use the existing non-throwing post-commit publisher. Assert committed custody and replay instead of the retired duplicate publication failure path.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/qualified-source-repairs

Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 2a890df0-3b98-46d7-a0f0-23dffc50a4bb

* test: narrow standalone compaction runtime owner

Use the existing presence assertion before reading catalogOwner. Reproduced TS18048 on the exact test graph; the graph and all 13 delegate resource cases pass with the narrowing.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>

* test: verify TUI runtime publication ownership

Compare the retained catalog owner rather than per-admission policy snapshot identity. The original assertion reproduced red; all three TUI runtime tests, targeted types, lint and formatting pass.

Co-authored-by: vincentkoc <[email protected]>

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/qualified-source-repairs

Worked on by:
- @vincentkoc
- @RomneyDa

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 07b6e2bb-7854-4b59-87f9-e02cfaaaf268

---------

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…icit nil (openclaw#204023)

Two scheduled-`main` reds are fixed: `test/scripts/sqlite-schema-assets.test.ts` and the `macos-swift (tests)` SwiftLint step.

Part of openclaw#204008.

## Problem

1. `sqlite-schema-assets.test.ts` (both cases) fails on `main` since the 06:45 UTC scheduled run: `TypeError: The "path" argument must be of type string. Received undefined` in `retainUpdateRuntimeImports`. openclaw#203901 changed that function's second argument from a list of paths to `{ sourcePath, identityPath }` records and updated its production caller. The test still passed bare paths.
2. `macos-swift (tests)` fails SwiftLint `implicit_optional_initialization` at `apps/macos/Sources/OpenClaw/OnboardingAISetupSupport.swift:295` (`var actionLabel: String? = nil`), added by openclaw#203379. Ordinary PRs do not run this lane, so only scheduled `main` CI saw it.

## Solution

- The test now builds `{ sourcePath, identityPath }` records (the same path for both, because the test does not relocate identity).
- Drop `= nil`. An optional `var` already defaults to `nil` in the memberwise initializer, and `Decodable` decoding is unchanged.

## Evidence

- `sqlite-schema-assets.test.ts`: the `main` copy fails both cases locally with the same `TypeError`; this branch passes both.
- SwiftLint 0.65.1 (the version `scripts/install-swift-tools.sh` pins) with `config/swiftlint.yml --strict`: `main` file 1 error (`implicit_optional_initialization` at 295:13), this branch 0 errors. Run with SourceKit disabled, because this host has no Xcode; this rule is syntax-only.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
Plugin session forks (`runForkedTurn`, `forkSession`; for example Better Prompt and Skill Workshop reviews) always ran on the built-in runtime. On a Claude CLI chat signed in with a Claude subscription:

- With only the CLI's own `claude` login, `runForkedTurn` failed with `No API key found for provider "claude-cli"`.
- With a Claude subscription token stored in OpenClaw, `runForkedTurn` sent the token to the Anthropic API directly, which bills metered extra usage instead of the plan (`cliBackendDispatch` notes in `run/params.ts`).
- `forkSession` refused every CLI runtime: `Session forks are not supported for CLI runtime claude-cli.`

OpenClaw already has one owner for "run this embedded run on the subscription CLI": `cliBackendDispatch: "subscription-auth"` (Active Memory's recall uses it). The fork owner opts into it; no new path:

- `runSessionFork` sets `cliBackendDispatch: "subscription-auth"`. Eligibility is unchanged: subscription (oauth/token) or unresolvable credentials go to the CLI; API keys keep the request replay and its prompt cache.
- Dispatch accepts the fork's in-memory conversation (`sessionManager`), and sends the CLI only the tools that may execute (`toolExecutionAllow`; an empty list is a tool-free run).
- Dispatch now picks the CLI account the way a new CLI session does. Before, it passed only an explicit pin, so a stored Claude token never reached the CLI (`Not logged in · Please run /login`); Active Memory recalls had the same gap.
- Runs that grant the plugin's own tools or set `maxTokens` keep the direct route: neither reaches a CLI process.
- Dispatch carries the run's policy facts to the CLI: a run under another session's policy (a fork's `sandboxSessionKey`) passes that session's entry, the requester fields and `internal_system` provenance into the CLI's Gateway tool grant, so restricted-sender limits apply to the fork as to the chat's own turns.

Accepted: a CLI fork starts a fresh CLI session with the conversation as context, so it does not reuse the chat's cache, and each fork leaves one Claude session file under `~/.claude/projects`, as Active Memory's CLI recalls already do. The source chat's native session is never resumed or written.

Permission modes (maintainer decision, now in `docs/gateway/permission-modes.md`): the `sessionRoot` boundary is enforced on the built-in runtime; CLI-backed chats use the CLI's own controls, and owner turns' Gateway tools are not limited to `sessionRoot`. Live, on a Claude CLI chat in `workspace` mode, an ordinary turn and a fork both read a file outside the workspace through `mcp__openclaw__read`, and the same chat on the built-in runtime refuses both with `Path escapes sandbox root`. A CLI fork therefore has the same file access as the chat's own CLI turns.

Not covered: Gemini CLI on a Google login (OpenClaw cannot limit its tools under OAuth), and harnesses that own their login with no limited one-shot turn (Copilot, Muse, `acp-*`).

Real product, tier source (`ocx src`), isolated foreground Gateway, no API key in the environment or auth store; profiles: Claude subscription setup token, ChatGPT OAuth, Grok OAuth. Each chat: one turn ("Remember PELICAN-42"), then forks through a probe plugin.

| Route | `runForkedTurn` `[read, ls]` | `forkSession` | `runForkedTurn` cache read |
|---|---|---|---|
| `claude-cli`, Claude token | `PELICAN-42 \| FORK-READ-OK 7f3a` (dispatched to Claude CLI) | `PELICAN-42` | 6,985 |
| ChatGPT OAuth, built-in | `PELICAN-42 \| FORK-READ-OK 7f3a` | `PELICAN-42` (cache read 9,856) | 10,112 |
| Codex app-server | `PELICAN-42 \| FORK-READ-OK 7f3a` | `PELICAN-42` (19,584) | 8,704 |
| Grok OAuth | `PELICAN-42 \| FORK-READ-OK 7f3a` | `PELICAN-42` (1,152) | 1,152 |

- `main` on the same Claude chat: `runForkedTurn` ran on the Anthropic API with the token (cache read 0, cache write 23,872), `forkSession` refused.
- Every route: source transcript hash, message count and native binding unchanged; the Claude source session file holds only the chat's own turn.
- Better Prompt 0.2.2 (`start` → `take` through `plugins.sessionAction`) produced an improved prompt on the Claude CLI chat and on the ChatGPT chat.
- Dispatch tests: a fork runs on the CLI with only its own tools from its in-memory session; plugin tool grants and output caps keep the passthrough.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit b7bf937)

Release adaptation: retain staged Gateway permission-mode documentation and enforcement; omit the superseded upstream documentation exception.

Companions: #202941 and #202646 are present-equivalent (9ec8d08 and 087c816); #201554 is staged as 5647120. #202957 is not applicable (reverts a separate native-tools path). #204219, #203999, #203901, #203919, #203601 and #203271 are independent prewarm, lifecycle, recovery, review or default-routing changes; not required for the selected fork path.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8a592a33b7866a1306c60468e4aaf2c9fb23a93f)
obviyus added a commit that referenced this pull request Nov 24, 2026
…#204609)

## Problem
When the Gateway restarts, restart recovery tries to deliver finished subagent results that are still owed to their requesting chat. It re-admits the saved requester first. When that admission is refused because the requester's access has ended, `session-restart-resume-custody.ts` only logged a warning. The result was never settled, so it was retried and refused again at every restart. The user saw nothing, not even that a result was lost.

On one production deployment this showed as 88 refusal lines over 6 restart bursts, for 38 child results in 20 chats. 36 of those rows are in `subagent_runs`, created 10-29 to 11-23, and most are weeks old. The same rows were refused at every restart.

The refusal itself is correct and does not change: one-time admission says replayed work checks its requester again when it starts.

## Fix
`session-restart-resume-custody.ts` settles a definitely refused completion once:

- **Closed refusal list.** Only an explicit ended-access marker settles: a `GatewayOperatorRecoveryAuthorizationError` whose cause is `GatewayOperatorAccessDeniedError` with `grant-revoked` or `access-record-inactive` (the saved plugin grant or access record ended or was replaced), or `UserProfileNotFoundError` (the saved profile is gone). Everything else stays pending and retries at the next restart, as before. That includes refusals without a cause (listed below), thrown policy errors (`policy-check-failed`), an unavailable access owner, timeouts and database errors.
- **Settle.** The run record keeps the completion and its delivery payload. Delivery becomes `discarded` with `lastError` naming the reason, `suppressCompletionDelivery` retires the obligation and the pending requester wake is cleared, so the row leaves the restart pending set. Nothing is deleted.
- **Notice.** The original requesting chat, and only that chat (the session ID of the chat whose pending results recovery holds), gets one `openclaw.system-note`: "A background task's result couldn't be delivered because the access it ran under has ended." It names no requester, grant or result. Several results settled in the same chat in one pass produce one notice. The notice is written before the rows settle, so a failed notice leaves them pending. A repeated notice for the same results is not written twice. The row's `details` hold only `source` and a SHA-256 digest of the settled run IDs (the dedupe key), so no run, child or requester ID enters the chat row.
- **7-day cutoff.** A result whose latest recorded time is more than 7 days before the settle settles without a chat notice. Each recovery pass logs one count-only line for them. The latest recorded time is the maximum of `completion.capturedAt`, `completion.fallbackCapturedAt`, `execution.endedAt` (stored rows keep it under `parentCompletion.execution.endedAt`), `delivery.payload.endedAt`, `delivery.createdAt`, `delivery.enqueuedAt`, `delivery.lastAttemptAt` and `delivery.suspendedAt`. The row's `createdAt` is used only when none of these exist. This errs toward notifying. `requesterSettleWake.nextAttemptAt` is a future schedule and is not used.

Docs: `docs/gateway/restart-recovery.md` describes the settle, the notice and the cutoff.

## Expected effect on first deploy (production counts as of 2026-11-24, by the latest recorded time per row)
- 7 days or newer: 9 rows in 6 chats, so 6 chats get one notice each.
- Older than 7 days: 27 rows in 15 chats settle silently, with one summary log line per recovery pass. One chat is in both groups.
- 2 of the 38 refused ids are not in `subagent_runs` and are unaffected.
- After that, those rows are no longer retried at restart.

Related: #204551 (weeks-old pending child results are the same "results without a settled owner" class).

## No-cause refusal sites (classified; none settle)
Every `GatewayOperatorRecoveryAuthorizationError` thrown without a cause, at head:
- `src/gateway/operator-admission.ts:264`: OpenClaw ID disabled in config (policy).
- `src/gateway/operator-admission.ts:271`: tunnel principal not found while OpenClaw ID is not enabled (config state).
- `src/gateway/operator-admission.ts:274`: tunnel principal no longer current (membership).
- `src/gateway/operator-admission.ts:291` (`refuse()`): profile id changed, shared session generation mismatch, auth method disabled, password fallback generation changed, device token or key not current. Mixed. The shared generation is compared against state the new process rebuilds, so it cannot be certified as a policy-only decision.
- `src/gateway/operator-admission.ts:310`: channel identity missing or not current (identity).
- `src/gateway/operator-admission.ts:422`: live ingress binding aborted or profile changed (live sources only).
- `src/gateway/operator-admission.ts:439`, `:474`, `:479`: person-principal auth error, role excludes the agent, no scopes left (policy).
- `src/gateway/operator-run-recovery.ts:91`: role no longer grants the start (policy).
- `src/gateway/remote-ingress-principal-recovery.ts:88`, `:114`: ingress grant missing, ingress identity or scope changed.

Because `:291` mixes policy with rebuilt process state, no-cause refusals are excluded rather than marked; they keep today's retry. Every refusal seen in production carries `grant-revoked` (88 log lines) or `access-record-inactive` (3 log lines), so this exclusion does not change the expected counts. A revoked device keeps being refused at every restart (test below), as before this change.

## Which change made weeks-old rows eligible (investigation only)
Neither candidate changes eligibility. #203839 (92e92d7) changes how a recovered cohort owns its queued settle input. #203901 (e58ca10) changes only yielded children that wait for a message. The pending-child filter in `recoverRequesterCompletionCustody` is identical at 648619c and e2973f9. So these rows were already eligible before the deploy.

The refusal path is #202513 (3ad2cce). For a role-enforced person, the legacy session-principal wake used to take its scopes from the current role. It now uses the recorded session source as the authority, and that source's saved plugin grant is checked. Not bisected end to end.

These old results should be settled, not delivered: their requester's access has ended, and one-time admission re-checks replayed work at start.

## Evidence
- `src/gateway/session-restart-resume-custody.refusal.test.ts` uses real custody, the real SQLite registry and real chat transcripts, and replaces only requester admission to choose the exact refusal:
  - refused children settle once across two restarts, one notice in the requesting chat, none in another chat (`grant-revoked` and `access-record-inactive`);
  - a result older than 7 days settles with no notice and with the summary line; a fresh one notifies;
  - an old row (created and ended 30 days ago) whose result was captured yesterday notifies;
  - a refusal without an ended-access cause, a thrown policy error, an unavailable owner and a database error each stay pending across two restarts, with no notice;
  - the notice row contains no run ID or child session key;
  - when the notice cannot be written, the refused child stays pending, the failure stays inside that chat's recovery (recovered siblings keep custody; local review finding), and the next restart settles it with one notice.
  - On merge base a3443e9 the settle cases fail (`expected 2 to be 1`: the refused child is re-admitted at the second restart; `expected 'pending' to be 'discarded'`). The recent-capture case fails the same way (`expected 'pending' to be 'discarded'`); base 4 failed, 4 passed. On the head, 9/9 pass; with `session-restart-resume-custody.test.ts`, 26/26.
- `session-restart-resume-custody.test.ts`, new case: a requester whose paired device token was revoked after the spawn is still refused by the real admission at both restarts, and its result stays pending.
- `test/gateway-restart-resume.e2e.test.ts` on the head: 5/6 pass. The remaining case, `restart markers survive graceful shutdown (blocked store: false)`, also fails on main. It is a shutdown-ordering assertion (`[close-backfill-proof]` after the clean-close receipt), and in the earlier main run an `Unexpected end of JSON input` from the mock provider harness. No completion refusal is logged in either run. Filed as #204596.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…201373)

Baseline adaptation: Bound admission and inline reply observation in the shipped sessions_send owner without importing the upstream executor split, self-held replay, or steering changes. Handoff retains accepted replies with the existing continuation or registry owner. Preserve receipts on caller revocation and use the existing error schema for uncertain admission timeout, matching the targeted fixes in #203901 and #202139.

(cherry picked from commit da8fd16)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c6c889760104d608842b9e97e308aad201f1ca30)
tideclaw-bot pushed a commit that referenced this pull request Nov 25, 2026
…#204609)

## Problem
When the Gateway restarts, restart recovery tries to deliver finished subagent results that are still owed to their requesting chat. It re-admits the saved requester first. When that admission is refused because the requester's access has ended, `session-restart-resume-custody.ts` only logged a warning. The result was never settled, so it was retried and refused again at every restart. The user saw nothing, not even that a result was lost.

On one production deployment this showed as 88 refusal lines over 6 restart bursts, for 38 child results in 20 chats. 36 of those rows are in `subagent_runs`, created 10-29 to 11-23, and most are weeks old. The same rows were refused at every restart.

The refusal itself is correct and does not change: one-time admission says replayed work checks its requester again when it starts.

## Fix
`session-restart-resume-custody.ts` settles a definitely refused completion once:

- **Closed refusal list.** Only an explicit ended-access marker settles: a `GatewayOperatorRecoveryAuthorizationError` whose cause is `GatewayOperatorAccessDeniedError` with `grant-revoked` or `access-record-inactive` (the saved plugin grant or access record ended or was replaced), or `UserProfileNotFoundError` (the saved profile is gone). Everything else stays pending and retries at the next restart, as before. That includes refusals without a cause (listed below), thrown policy errors (`policy-check-failed`), an unavailable access owner, timeouts and database errors.
- **Settle.** The run record keeps the completion and its delivery payload. Delivery becomes `discarded` with `lastError` naming the reason, `suppressCompletionDelivery` retires the obligation and the pending requester wake is cleared, so the row leaves the restart pending set. Nothing is deleted.
- **Notice.** The original requesting chat, and only that chat (the session ID of the chat whose pending results recovery holds), gets one `openclaw.system-note`: "A background task's result couldn't be delivered because the access it ran under has ended." It names no requester, grant or result. Several results settled in the same chat in one pass produce one notice. The notice is written before the rows settle, so a failed notice leaves them pending. A repeated notice for the same results is not written twice. The row's `details` hold only `source` and a SHA-256 digest of the settled run IDs (the dedupe key), so no run, child or requester ID enters the chat row.
- **7-day cutoff.** A result whose latest recorded time is more than 7 days before the settle settles without a chat notice. Each recovery pass logs one count-only line for them. The latest recorded time is the maximum of `completion.capturedAt`, `completion.fallbackCapturedAt`, `execution.endedAt` (stored rows keep it under `parentCompletion.execution.endedAt`), `delivery.payload.endedAt`, `delivery.createdAt`, `delivery.enqueuedAt`, `delivery.lastAttemptAt` and `delivery.suspendedAt`. The row's `createdAt` is used only when none of these exist. This errs toward notifying. `requesterSettleWake.nextAttemptAt` is a future schedule and is not used.

Docs: `docs/gateway/restart-recovery.md` describes the settle, the notice and the cutoff.

## Expected effect on first deploy (production counts as of 2026-11-24, by the latest recorded time per row)
- 7 days or newer: 9 rows in 6 chats, so 6 chats get one notice each.
- Older than 7 days: 27 rows in 15 chats settle silently, with one summary log line per recovery pass. One chat is in both groups.
- 2 of the 38 refused ids are not in `subagent_runs` and are unaffected.
- After that, those rows are no longer retried at restart.

Related: #204551 (weeks-old pending child results are the same "results without a settled owner" class).

## No-cause refusal sites (classified; none settle)
Every `GatewayOperatorRecoveryAuthorizationError` thrown without a cause, at head:
- `src/gateway/operator-admission.ts:264`: OpenClaw ID disabled in config (policy).
- `src/gateway/operator-admission.ts:271`: tunnel principal not found while OpenClaw ID is not enabled (config state).
- `src/gateway/operator-admission.ts:274`: tunnel principal no longer current (membership).
- `src/gateway/operator-admission.ts:291` (`refuse()`): profile id changed, shared session generation mismatch, auth method disabled, password fallback generation changed, device token or key not current. Mixed. The shared generation is compared against state the new process rebuilds, so it cannot be certified as a policy-only decision.
- `src/gateway/operator-admission.ts:310`: channel identity missing or not current (identity).
- `src/gateway/operator-admission.ts:422`: live ingress binding aborted or profile changed (live sources only).
- `src/gateway/operator-admission.ts:439`, `:474`, `:479`: person-principal auth error, role excludes the agent, no scopes left (policy).
- `src/gateway/operator-run-recovery.ts:91`: role no longer grants the start (policy).
- `src/gateway/remote-ingress-principal-recovery.ts:88`, `:114`: ingress grant missing, ingress identity or scope changed.

Because `:291` mixes policy with rebuilt process state, no-cause refusals are excluded rather than marked; they keep today's retry. Every refusal seen in production carries `grant-revoked` (88 log lines) or `access-record-inactive` (3 log lines), so this exclusion does not change the expected counts. A revoked device keeps being refused at every restart (test below), as before this change.

## Which change made weeks-old rows eligible (investigation only)
Neither candidate changes eligibility. #203839 (92e92d7) changes how a recovered cohort owns its queued settle input. #203901 (e58ca10) changes only yielded children that wait for a message. The pending-child filter in `recoverRequesterCompletionCustody` is identical at 648619c and e2973f9. So these rows were already eligible before the deploy.

The refusal path is #202513 (3ad2cce). For a role-enforced person, the legacy session-principal wake used to take its scopes from the current role. It now uses the recorded session source as the authority, and that source's saved plugin grant is checked. Not bisected end to end.

These old results should be settled, not delivered: their requester's access has ended, and one-time admission re-checks replayed work at start.

## Evidence
- `src/gateway/session-restart-resume-custody.refusal.test.ts` uses real custody, the real SQLite registry and real chat transcripts, and replaces only requester admission to choose the exact refusal:
  - refused children settle once across two restarts, one notice in the requesting chat, none in another chat (`grant-revoked` and `access-record-inactive`);
  - a result older than 7 days settles with no notice and with the summary line; a fresh one notifies;
  - an old row (created and ended 30 days ago) whose result was captured yesterday notifies;
  - a refusal without an ended-access cause, a thrown policy error, an unavailable owner and a database error each stay pending across two restarts, with no notice;
  - the notice row contains no run ID or child session key;
  - when the notice cannot be written, the refused child stays pending, the failure stays inside that chat's recovery (recovered siblings keep custody; local review finding), and the next restart settles it with one notice.
  - On merge base a3443e9 the settle cases fail (`expected 2 to be 1`: the refused child is re-admitted at the second restart; `expected 'pending' to be 'discarded'`). The recent-capture case fails the same way (`expected 'pending' to be 'discarded'`); base 4 failed, 4 passed. On the head, 9/9 pass; with `session-restart-resume-custody.test.ts`, 26/26.
- `session-restart-resume-custody.test.ts`, new case: a requester whose paired device token was revoked after the spawn is still refused by the real admission at both restarts, and its result stays pending.
- `test/gateway-restart-resume.e2e.test.ts` on the head: 5/6 pass. The remaining case, `restart markers survive graceful shutdown (blocked store: false)`, also fails on main. It is a shutdown-ordering assertion (`[close-backfill-proof]` after the clean-close receipt), and in the earlier main run an `Unexpected end of JSON input` from the mock provider harness. No completion refusal is logged in either run. Filed as #204596.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit b3dfd35)
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…openclaw#204609)

## Problem
When the Gateway restarts, restart recovery tries to deliver finished subagent results that are still owed to their requesting chat. It re-admits the saved requester first. When that admission is refused because the requester's access has ended, `session-restart-resume-custody.ts` only logged a warning. The result was never settled, so it was retried and refused again at every restart. The user saw nothing, not even that a result was lost.

On one production deployment this showed as 88 refusal lines over 6 restart bursts, for 38 child results in 20 chats. 36 of those rows are in `subagent_runs`, created 10-29 to 11-23, and most are weeks old. The same rows were refused at every restart.

The refusal itself is correct and does not change: one-time admission says replayed work checks its requester again when it starts.

## Fix
`session-restart-resume-custody.ts` settles a definitely refused completion once:

- **Closed refusal list.** Only an explicit ended-access marker settles: a `GatewayOperatorRecoveryAuthorizationError` whose cause is `GatewayOperatorAccessDeniedError` with `grant-revoked` or `access-record-inactive` (the saved plugin grant or access record ended or was replaced), or `UserProfileNotFoundError` (the saved profile is gone). Everything else stays pending and retries at the next restart, as before. That includes refusals without a cause (listed below), thrown policy errors (`policy-check-failed`), an unavailable access owner, timeouts and database errors.
- **Settle.** The run record keeps the completion and its delivery payload. Delivery becomes `discarded` with `lastError` naming the reason, `suppressCompletionDelivery` retires the obligation and the pending requester wake is cleared, so the row leaves the restart pending set. Nothing is deleted.
- **Notice.** The original requesting chat, and only that chat (the session ID of the chat whose pending results recovery holds), gets one `openclaw.system-note`: "A background task's result couldn't be delivered because the access it ran under has ended." It names no requester, grant or result. Several results settled in the same chat in one pass produce one notice. The notice is written before the rows settle, so a failed notice leaves them pending. A repeated notice for the same results is not written twice. The row's `details` hold only `source` and a SHA-256 digest of the settled run IDs (the dedupe key), so no run, child or requester ID enters the chat row.
- **7-day cutoff.** A result whose latest recorded time is more than 7 days before the settle settles without a chat notice. Each recovery pass logs one count-only line for them. The latest recorded time is the maximum of `completion.capturedAt`, `completion.fallbackCapturedAt`, `execution.endedAt` (stored rows keep it under `parentCompletion.execution.endedAt`), `delivery.payload.endedAt`, `delivery.createdAt`, `delivery.enqueuedAt`, `delivery.lastAttemptAt` and `delivery.suspendedAt`. The row's `createdAt` is used only when none of these exist. This errs toward notifying. `requesterSettleWake.nextAttemptAt` is a future schedule and is not used.

Docs: `docs/gateway/restart-recovery.md` describes the settle, the notice and the cutoff.

## Expected effect on first deploy (production counts as of 2026-11-24, by the latest recorded time per row)
- 7 days or newer: 9 rows in 6 chats, so 6 chats get one notice each.
- Older than 7 days: 27 rows in 15 chats settle silently, with one summary log line per recovery pass. One chat is in both groups.
- 2 of the 38 refused ids are not in `subagent_runs` and are unaffected.
- After that, those rows are no longer retried at restart.

Related: openclaw#204551 (weeks-old pending child results are the same "results without a settled owner" class).

## No-cause refusal sites (classified; none settle)
Every `GatewayOperatorRecoveryAuthorizationError` thrown without a cause, at head:
- `src/gateway/operator-admission.ts:264`: OpenClaw ID disabled in config (policy).
- `src/gateway/operator-admission.ts:271`: tunnel principal not found while OpenClaw ID is not enabled (config state).
- `src/gateway/operator-admission.ts:274`: tunnel principal no longer current (membership).
- `src/gateway/operator-admission.ts:291` (`refuse()`): profile id changed, shared session generation mismatch, auth method disabled, password fallback generation changed, device token or key not current. Mixed. The shared generation is compared against state the new process rebuilds, so it cannot be certified as a policy-only decision.
- `src/gateway/operator-admission.ts:310`: channel identity missing or not current (identity).
- `src/gateway/operator-admission.ts:422`: live ingress binding aborted or profile changed (live sources only).
- `src/gateway/operator-admission.ts:439`, `:474`, `:479`: person-principal auth error, role excludes the agent, no scopes left (policy).
- `src/gateway/operator-run-recovery.ts:91`: role no longer grants the start (policy).
- `src/gateway/remote-ingress-principal-recovery.ts:88`, `:114`: ingress grant missing, ingress identity or scope changed.

Because `:291` mixes policy with rebuilt process state, no-cause refusals are excluded rather than marked; they keep today's retry. Every refusal seen in production carries `grant-revoked` (88 log lines) or `access-record-inactive` (3 log lines), so this exclusion does not change the expected counts. A revoked device keeps being refused at every restart (test below), as before this change.

## Which change made weeks-old rows eligible (investigation only)
Neither candidate changes eligibility. openclaw#203839 (7b99025) changes how a recovered cohort owns its queued settle input. openclaw#203901 (9e3b3a0) changes only yielded children that wait for a message. The pending-child filter in `recoverRequesterCompletionCustody` is identical at edcaafd and 954c6f8. So these rows were already eligible before the deploy.

The refusal path is openclaw#202513 (f1b2b4a). For a role-enforced person, the legacy session-principal wake used to take its scopes from the current role. It now uses the recorded session source as the authority, and that source's saved plugin grant is checked. Not bisected end to end.

These old results should be settled, not delivered: their requester's access has ended, and one-time admission re-checks replayed work at start.

## Evidence
- `src/gateway/session-restart-resume-custody.refusal.test.ts` uses real custody, the real SQLite registry and real chat transcripts, and replaces only requester admission to choose the exact refusal:
  - refused children settle once across two restarts, one notice in the requesting chat, none in another chat (`grant-revoked` and `access-record-inactive`);
  - a result older than 7 days settles with no notice and with the summary line; a fresh one notifies;
  - an old row (created and ended 30 days ago) whose result was captured yesterday notifies;
  - a refusal without an ended-access cause, a thrown policy error, an unavailable owner and a database error each stay pending across two restarts, with no notice;
  - the notice row contains no run ID or child session key;
  - when the notice cannot be written, the refused child stays pending, the failure stays inside that chat's recovery (recovered siblings keep custody; local review finding), and the next restart settles it with one notice.
  - On merge base ad80d6c the settle cases fail (`expected 2 to be 1`: the refused child is re-admitted at the second restart; `expected 'pending' to be 'discarded'`). The recent-capture case fails the same way (`expected 'pending' to be 'discarded'`); base 4 failed, 4 passed. On the head, 9/9 pass; with `session-restart-resume-custody.test.ts`, 26/26.
- `session-restart-resume-custody.test.ts`, new case: a requester whose paired device token was revoked after the spawn is still refused by the real admission at both restarts, and its result stays pending.
- `test/gateway-restart-resume.e2e.test.ts` on the head: 5/6 pass. The remaining case, `restart markers survive graceful shutdown (blocked store: false)`, also fails on main. It is a shutdown-ordering assertion (`[close-backfill-proof]` after the clean-close receipt), and in the earlier main run an `Unexpected end of JSON input` from the mock provider harness. No completion refusal is logged in either run. Filed as openclaw#204596.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…n its own part (#203174)

Root cause: src/shared/assistant-answer-text.ts:24 picks only text blocks that carry a signature as the answer, which is meant for OpenAI Responses item ids. Since #170534 (first shipped in 2026.11.5) it also picks empty signed blocks. Gemini 3 sends its thought signature on a separate empty part after the answer, so the selected answer is `""`, the turn is marked empty rather than silent, and the `NO_REPLY` text is delivered.

Fixes #203131

Thanks @Avi711 for the clear report and trace.

## What Problem This Solves

With Gemini 3 on a `google-generative-ai` provider, a reply of exactly `NO_REPLY` reaches the chat as the text "NO_REPLY" instead of ending the turn silently. It happens in direct chats and in automations that announce their result. 2026.8.2 stayed silent.

## User Impact

Gemini 3 replies of exactly `NO_REPLY` end the turn silently again, in direct chats and in announced automations. Normal Gemini answers are delivered as before.

## Why This Change Was Made

Signed-block selection now applies only to OpenAI Responses messages, where a text signature is an output item id. A Gemini thought signature is not an item id, so Gemini answers use all of their text blocks.

The Google stream reader still keeps the signature-only part as its own block. That keeps the next request byte-identical: the signature is replayed as its own empty part, as Gemini sent it. Attaching the signature to the previous text block would change those replayed bytes. Responses answer selection is unchanged.

## Evidence

Real Gateway (`ocx src`, isolated profile state) with the QA channel recording deliveries and a local `google-generative-ai` fixture that streams `{"text":"NO_REPLY"}` and then `{"text":"","thoughtSignature":"..."}`. Base is the merge base 423ae09.

| Check | Base | This PR |
|---|---|---|
| Direct chat, exact `NO_REPLY` | "NO_REPLY" delivered | nothing delivered |
| Announced automation, exact `NO_REPLY` | "NO_REPLY" delivered (`deliveryStatus: delivered`) | nothing delivered (`not-delivered`) |
| Normal answer with trailing signature part, 2 turns | delivered once per turn | delivered once per turn |
| Next request replays the signature | `[{"text":"Here is…"},{"text":"","thoughtSignature":"Q2lN…Sw=="}]` | identical bytes |

The new regression test fails on base (`disposition: 'empty'`, expected `'silent'`) and passes here; its OpenAI Responses row (signed empty item still wins) passes on both.

Observed proof lines: #203174 (comment)

Merge danger: two-way door. No stored state, config or published contract changes; a revert fully restores the old behavior. Blast radius: answer text selection for non-Responses messages that carry text signatures (Google Gemini), which now use all of their text blocks.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit fcfb114)

Follow-ups: e58ca10 fix: preserve runtime custody, inference history, and recovery (#203901) [not selected for this narrow backport]; 44f7c52 fix: keep automations silent when the model closes its reasoning before NO_REPLY (#203432) [not selected for this narrow backport]; 6c2ff33 fix(cron): optional-silent cron run fails after the agent collects its collector child's result (#164949) [not selected for this narrow backport]; a9c1dd8 fix(agents): answer Control UI users once after a child finishes (#204098) [separately ordered lane row]

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…ction

Release adaptation: Bind the stable harness policy before tool preparation; preserve scoped configs and workspace floors. Leave mixed artifact, SQL, startup and model-lease restructuring out.

Companion audit: Release-only SHA is outside pinned main. Keep the matching #203901 host binding only; #204023 is CI/macOS and #204609 is separate restart settlement. The captured reader and artifact retry already exist.

(cherry picked from commit a38363b)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* perf(agents): prepare fallback rate-limit routes with model snapshots

Reuse configured fallback models within the admitted config snapshot and share provider handles across configured normalization hooks. Preserve cold resolution for standalone or mismatched snapshots and reload route facts with their owning snapshot.

* fix(agents): preserve static model selection during fallback preparation

Skip projection for agents without configured fallbacks. Match the production plugin-runtime scope in fallback benchmarks and regressions so both variants use the same retained registry.

(cherry picked from commit 2b58c8e)

Companion audit: #201632 is selected to preserve registry and metadata ownership for the fallback hot path. #200605, #203901, #203095 and #202618 make independent TUI, custody, module separation and model listing changes; none is required by this port.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex extensions: copilot extensions: ollama gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: knowledge rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants