Skip to content

refactor(sessions): simplify maintenance ownership - #175778

Merged
steipete merged 2 commits into
mainfrom
deslop/r05-4-maintenance-20261015
Oct 17, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/r05-4-maintenance-20261015

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintenance/deletion repeats work already owned by the same native operation: UUID-addressed preparation slots plus a release RPC, repeated lease reads, receipt identity echoes, and caller-side checks of typed worker result tags. These layers obscure the actual safety boundaries: current rows and protection, operation-bound commit settlement, archive-before-delete, and native cleanup.

User Impact

No intended feature, storage-format or migration change. Normal maintenance/deletion keeps current protection, archive-before-delete, live ownership and accepted-write settlement. An unusually overlapping discretionary maintenance pass may fail/retry, and a canceled/lost-reply pass can leave one bounded preparation until the next prepare, metadata cleanup or native close. No operator action is required on healthy paths.

Why This Change Was Made

Keep one bounded worker-owned maintenance preparation, consumed by metadata cleanup or replaced by the next preparation/ordinary close. Reuse the validated lease row for its receipt and perform lease drainage/checks in one synchronous transaction. Correlate private planning, reclamation, and scoped archive requests with their actual result types; retain decoding at unknown transport/committed-facts boundaries. Remove the archive recorder's second schema ensure and the second clone of an already-detached commit-time deleted entry.

Published original head614a03abe11a89db8e6aa371b7e37f06a8ee11bf removed122 net production lines. The signed ten-file CI repair and complete own-orphan cleanup at52d5637c0113a14cf6dffbafb04a8bf672282e1f has an actual delta against pinned main df0358c of 134 net production lines removed across25 production files (+137/-271); all29 files +180/-459. Fresh complete-caller review is scoped-clean P0-P2 with no accepted/actionable findings; a subsequent mechanical extraction names the identical execution-release callback without changing order or semantics. Focused proof is complete with the unresolved local failures disclosed below; new-head hosted CI completed successfully. Main's PostgreSQL lease-read fix (#175069) and consolidated reclamation tests are preserved. Schemas, persisted formats, retention, permissions, public config/protocol/SDK contracts, and standalone session-memory machinery are unchanged. This smaller maintenance/deletion area split follows campaign rule11; overlapping donors are counted once.

Best-effort tradeoffs accepted

The provenance below distinguishes original additions from later extractions. Inspected descriptions provide synthetic/internal boundary evidence, not a cited human wrong-operation/echo/slot-identity incident.

Removed guard/mechanism Original provenance Accepted case and outcome
Duplicate preparation ID and two-slot capacity checks 7555e3f88132, #158251 Automatic maintenance coalesces per store, but a retiring predecessor can overlap a successor. Unusual overlapping discretionary passes may fail/retry instead of retaining independent snapshots.
Cleanup-only preparation release RPC and its separate admission source Same #158251 introduction A canceled/lost-reply pass may leave one bounded readonly preparation until the next prepare, metadata cleanup, or ordinary native close. Actual write/close settlement remains required.
Orphaned preparation-release interface and six empty caller stubs Orphaned by this PR's removal of the last real release-RPC producer Remove only an artificial empty async yield. Source and owned-execution cleanup still run in order, retain both failures, and join real native settlement. Synthetic microtask/reentry timing is best effort; no actual cleanup is lost.
Second lease SELECT and its missing-receipt guard 7ab507770f3, #140897 No await separates exact lease validation and receipt construction; consume that validated row. Native-exit receipt identity and later effect checks remain.
Per-row lease-existence re-reads between drain transactions 8a5b4af66074, #111678: original new-file addition; cooperative-interleaving audit/test proof, not a cited human reread incident One synchronous transaction owns row selection, stale cleanup, live refusal and deletion fences, so the former gaps between transactions no longer need a second existence query. A blocking live lease may roll back earlier stale bookkeeping; the next drain retries it. The original deletion/authorization and cross-process live-lease protections remain.
Pending receipt's seven command-identity echoes 1f8e5985e10b, #165151 The operation-bound kernel constructs these fields from the same input. A future kernel/binding programming error loses a second echo comparison, not authorization. Unknown-facts tag decoding stays.
Rediscovery of the actor's already-typed pending receipt Same #165151 introduction; activated by #170712 Trust the typed operation result; retain missing-receipt errors, actual DB/session/hash ownership, transaction AND commit grants, current authority, and unknown-outcome no-replay.
Entry planning operation check 26dffe7468cd, #160858 The private typed entry request receives its corresponding producer result; no duplicate caller check for an internally wrong tag.
History planning operation check Same #160858 introduction Same paired producer contract; actual historical generation/source decisions remain.
Check planning operation check Same #160858 introduction Same paired producer contract; actual deletion/protection checks remain.
Scoped archive materialize result tag 7ab507770f3, #140897 One paired FIFO request is in flight; an internally buggy worker is not rechecked at this application caller.
Scoped archive publish result tag Same #140897 introduction Same paired FIFO contract; actual publication, file/native cleanup and error retirement remain.
Scoped archive final-read result tag 31172cf54466, #149223 Trust the paired read result type; preserve complete exact-run answer retrieval and current access checks.
Scoped archive page-read result tag 4c7c64734452, #157247 Trust the paired page result type; preserve bounded preview/page behavior and security revalidation.
Lifecycle historical-generation reclamation tag 789513231d7d, #126035 Typed plan/result correlation replaces only the duplicated wrong-kind assertion.
Lifecycle entry reclamation tag Same #126035 introduction Same correlation; current empty-state alternate and commit authority remain.
Lifecycle artifacts reclamation tag a1566b2dbfd, #163269 The typed plan/result correlation also makes this caller assertion unreachable; preserve the worker wire boundary and actual artifact/deletion authority.
History-eviction reclamation tag Same #126035 introduction Same correlation; archive-before-delete and source/generation checks remain.
Archive publish-prepare result tag 1ed98e67c92c, #155988 Trust the actual typed dispatcher; physical owner translation/current settlement remain.
Archive publish-record result tag Same #155988 introduction Same dispatcher contract; no archive durability or retry change.
Maintenance plan result tag c9584688c461, #148630 The result relation keeps both plan and stale outcomes; wrong internal tags are not rechecked at every caller.
Maintenance finalize result tag Same #148630 introduction Committed subsets, retained-execution alternate, FIFO and publication ordering remain.
Maintenance age result tag 2ff5d6fbb21d, #172985 The relation retains maintenance-plan-stale for age AND plan;64-entry fairness/continuation and real protection checks remain.
Recorder's repeated archive-schema ensure fc4d5d744fad, #123495, not later extraction#147946 Recording follows nonempty schema-establishing preparation or existing pending rows and only UPDATEs. Unsupported record-without-prepare/offline table removal gets the ordinary missing-table failure.
Second deleted-entry clone 0a8e3604ba24, #98236, not later worker move Return the already-detached commit-time decode, not a plan/cache/public-input alias. Recipient mutation isolation remains; no supported behavior is relaxed.

Human incidents remain KEEP: #138555 reported a truncated child answer after cleanup; exact-run complete-answer/archive retrieval is preserved. #110152 reported Windows EPERM/fsync and long database delays; archive durability and off-thread responsiveness stay. Native cleanup recovery, failed-close custody/retry, and bounded contention handling also remain unchanged.

Keep the measured planning-outside-writer/refresh-at-admission path from #171154. This PR claims no new performance measurement. No dormant foundation or standalone session-memory backend, factory, registry, expiry, federation or tests are removed.

Evidence

Repaired exact-head hosted CI passed: run39073995568 completed SUCCESS on52d5637c0113a14cf6dffbafb04a8bf672282e1f, including openclaw/ci-gate. Complete head check census:148 completed,90success/54conditional skips/1neutral CodeQL/3canceled non-product automation checks, zero failures/pending/foreign-head checks. Canceled dispatch and PR-context jobs have newer same-head successes; auto-response has a same-head successful run and a canceled later automation invocation, not an omitted product suite. Neutral CodeQL is not claimed as a successful alert comparison. Both current-head hosted reviews report no actionable findings and no before-merge action; their noted absent shipped CLI/Gateway E2E remains disclosed and outside this campaign's local proof budget. No CI rerun was requested. The original failure attribution and local timing gaps below remain historical evidence, not green local-suite claims.

Original exact-head CI39060215095 failed. Two lint diagnostics in the unreachable artifact result-kind assertion and three maintenance preparation/native-join assertions are ours, not inherited. The published repair removes the impossible assertion, excludes explicit verification SELECTs from operation-only SQL observation, and gives the existing maintenance-plan preparation its existing native failure-retirement policy, with the preparation hook inside that boundary. Kept path-replacement/row-preservation/zero-host-SQL assertions are not relaxed. The first four-file repair passed targeted types and independent review but exposed a new local max-lines error; the smaller complete owner cut removes its six orphaned empty release callbacks and preserves actual ordered cleanup. Fresh complete ten-file/caller review is scoped-clean P0-P2 (confidence0.96); the subsequent mechanical callback extraction preserves its behavior and removes two code lines.

Current repair proof has passed18-root targeted types, ten-file lint/format, all nine selected maintenance cases (including the three original CI failures), and the unchanged real late-protection keeper. Affected consumers add ten passing cases: three Gateway corrections, two rewrite alias-retarget variants, legacy post-await authority, raw-event append, two single-reset cases and batched reset. All runtime wrappers completed final generation verification: 20 passing cases and four unresolved local timeouts, not an aggregate passing invocation. Gateway accepted-correction shutdown expired its unchanged120000ms timer at120142ms; cold restoration expired the same unchanged limit in turn/locked-owner/locked-SDK modes at121201/124538/136540ms. These remain unresolved local evidence, not proven product regressions or baseline attribution. Actual owners were inspected, without establishing a concrete cause. No timeout/retry/skip/assertion change or failed-case rerun was made. Runtime and static import cycles both pass with zero cycles; wrapper inventory1PASS (18filtered), source closure3PASS and mandatory lint suppressions14PASS completed their wrappers (120.28/81.65/103.56s). Whitespace passes. The remaining-proof script joined exit1, deliberately preserving its runtime failures after passing all final guards. New exact-head hosted CI completed successfully.

All seven PostgreSQL-infra failures on that original head match scheduled main39058564617@ec36f9b9617a8d668a660d97e262a861453d9246/job117471751210 individually: archive restore240000ms, following backup-create no-local-state error at414, Doctor v30/foreign=false120000ms, Matrix225450000ms, Matrix405 expected0 to be2, database port60000ms and update-preflight120000ms. The five failing test files and backup-create owner are byte-identical at PR base/head and baseline. PostgreSQL integrations passed; Git-backup passed and is not included in this attribution. This historical attribution does not waive our defects or new-head CI.

Targeted types and type-aware lint for all22 source/test roots passed, as did formatting and whitespace. The complete composed area received a fresh independent P0-P2 review with full owner/producer/keeper context and final source verification: scoped-clean, no accepted/actionable findings. This is not reuse of the older component reviews. Retired release-RPC references are absent across src/test/docs/scripts/packages/extensions/config. Changed-file classification was inspected through check-changed --dry-run; its printed broad commands were not executed locally.

The first unit lease file passed2 cases and the infra lease-owner file passed17. The original fourteen-file invocation was deliberately interrupted after73 minutes of proof/58 minutes of runtime execution, including39 minutes in runtime-config. Its wrapper joined exit143 and all tracked descendants exited. It is NOT a completed passing invocation or successful final generation-verification result. Remaining broad runtime coverage moves to exact-head hosted CI under the busy-host proof policy; it was not rerun locally for green.

Six unresolved local cases expired their unchanged timers:

Case Limit / observed milliseconds
Archive-read unique-generation continuation 120000 /121222
Archive-read short final answer beyond runtime string limit 30000 /30227
Archive-session reuse across deletion generations/database close 120000 /126831
Archive-session idle reuse, worker not exited 120000 /124515
Archive-session idle reuse, worker exited 120000 /124503
Archive-session joins scoped done before close 120000 /141606

The actual diagnostics are elapsed timers, not completed assertion failures. They remain unresolved/inconclusive local evidence, not passing suites or proven baseline failures. No timeout, retry, skip or assertion was changed. Other archive/read/reclamation cases passed, including complete multiline imported-event deletion/final lookup, both compressed archive reads, off-main publication, sequential deletion reuse, failed-publisher/result-recording committed archive recovery, FIFO-independent queued retirement and scoped publication before close. Partial case results are not presented as an aggregate green suite. The previously unrun three real lease-drain cases passed with successful final worker-generation verification; prior runtime/static cycles, wrapper inventory and source closure passed. The mandatory suppression guard exposed a separate existing main fixture defect, reproduced on fresh main and fixed independently by df0358 without changing the allowlist. Integration for that named gate preserved all18 production postimages and adapted only main's consolidated late-protection test. Fresh conflicted-root types/type-aware lint/format and the retained real late-protection case passed (1case,8filtered;799.48s shard,91%transform/5%tests), with final worker-generation verification complete (926.50s wrapper). Fresh runtime/static cycles both passed0. Fresh wrapper inventory passed1 case (18filtered;218.48s wrapper), source closure passed3 (121.12s wrapper), and mandatory lint suppressions passed14 (125.81s wrapper). The full rebase-proof script completed exit0, with no timeout/retry/skip/suppression/allowlist change. No broad local suite, whole-graph tsgo, standalone build or E2E is run under the campaign host budget. Exact-head hosted CI remains mandatory.

@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@steipete
steipete marked this pull request as ready for review October 17, 2026 18:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T22:13:28.701903Z 52d5637 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes redundant session-maintenance preparation, lease queries, worker-result checks, and cleanup callbacks.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source supports the simplification and resolves both earlier findings; validation confidence remains limited to reported integration coverage with disclosed unresolved timeouts.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its complete body reports production-owner integration coverage, including repaired native retirement, but supplies no current-head shipped-entry-point trace.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Redundant maintenance bookkeeping makes the storage lifecycle harder to maintain without adding intended user-visible behavior.
Reason: The maintainer-authored direction explicitly accepts the bounded lifecycle tradeoffs, and the diff simplifies existing owners without adding configuration or changing stored formats.

Merge readiness

✅ Ready for maintainer review

Both prior findings are addressed, and no new actionable defect was found; this maintainer-authored PR remains open while exact-head CI completes.

Priority: P2
Reviewed head: 52d5637c0113a14cf6dffbafb04a8bf672282e1f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head shipped CLI or Gateway maintenance/deletion trace is supplied; the reported after-fix coverage exercises production owners through integration tests.
Agent review details

How this fits together

Session storage receives maintenance and deletion requests, runs planning and durable mutations through existing database workers, and publishes committed changes and retained transcript archives.

flowchart TD
  A[Maintenance and deletion requests] --> B[Existing execution owner]
  B --> C[Worker preparation]
  C --> D[SQLite transaction]
  D --> E[Commit settlement]
  E --> F[Archive publication]
  F --> G[Lifecycle cleanup]
Loading

Technical review

Best possible solution:

Retain the existing execution and storage owners with this smaller implementation, subject to the normal exact-head CI gate.

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

This is a refactor rather than a new bug report; the previous review's two concrete failures are addressed by the repair diff and reported focused validation.

Is this the best way to solve the issue?

The change follows the existing owners and removes duplicate internal checks while preserving current-row validation, live admission, commit settlement, and archive durability.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Native-retirement finding addressed: Maintenance supplies retireNativeOnFailure, and the preparation check now executes inside runExisting, whose existing failure path joins native retirement. (src/config/sessions/session-accessor.sqlite-replacement-worker.ts:268, 52d5637c0113)
  • SQL-measurement finding addressed: The observer asserts zero operation SQL before restoration, excludes the explicit loadSessionEntry verification, then resumes observing the next maintenance pass; row-preservation assertions remain. (src/config/sessions/session-accessor.sqlite-maintenance-preparation.test-support.ts:281, 52d5637c0113)
  • Lease protection remains transaction-owned: One synchronous transaction checks maintenance ownership, removes stale leases, refuses live target leases, and checks foreign-agent deletion fences. (src/state/openclaw-agent-db-lease.ts:597, 52d5637c0113)
  • Receipt echoes are distinct from authorization: The paired pending-input kernel constructs receipt identity from its command, checks current session and accepted-row ownership, and retains transaction and commit admission before settlement. (src/config/sessions/session-pending-input-operations.kernel.ts:121, 52d5637c0113)
  • Accepted maintenance tradeoffs: The maintainer-authored body explicitly accepts overlapping discretionary passes failing or retrying, a bounded abandoned preparation, and stale bookkeeping rolling back behind a live lease; these accepted cases require no renewed product decision. (52d5637c0113)
  • Validation disclosure and current checks: The complete body reports focused maintenance and consumer coverage while preserving unresolved local timeouts. Current-head CI remains in progress; the inspected check response contained no failed checks. (52d5637c0113)

Likely related people:

  • Peter Steinberger: Raw commit 7555e3f adds src/state/openclaw-agent-execution-maintenance.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7555e3f88132; files: src/state/openclaw-agent-execution-maintenance.ts)
  • Heming Zeng: Raw commit 7895132 adds src/config/sessions/session-accessor.sqlite-reclamation.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 789513231d7d; files: src/config/sessions/session-accessor.sqlite-reclamation.ts)

PR surface

Source -134, Tests -145. Total -279 across 29 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 25 137 271 -134
Tests 4 43 188 -145
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 29 180 459 -279

Review metrics

Metric Value Why it matters
Production versus test delta Production +137/-271; tests and test support +43/-188 The net reduction removes duplicate bookkeeping and obsolete release-RPC scaffolding while retaining meaningful lifecycle assertions.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a focused internal maintenance refactor without an established urgent user-facing regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T19:12:36.243Z sha 614a03a :: needs changes before merge. :: [P2] Retire the prepared native generation after path replacement | [P2] Exclude the verification read from the host-SQL measurement

Reviewed October 17, 2026, 6:15 PM ET / 22:15 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Repair head 52d5637 and PR body are current. Original changed-path lint and maintenance assertion failures are repaired; all three maintenance failures now pass focused proof. Full proof and four unresolved local consumer timeouts remain disclosed in the body. No timeout, retry, skip, assertion or suppression relaxation. New exact-head CI remains the broad gate.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit de645a1 into main Oct 17, 2026
157 of 160 checks passed
@steipete
steipete deleted the deslop/r05-4-maintenance-20261015 branch October 17, 2026 23:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 18, 2026
A revoked maintenance caller must not retire the shared native generation
retained by another admitted reply. Remove the maintenance-specific forced
retirement and its unused preparation option. This follows #175778's intended
contract: one stopped read-only preparation is owned by the worker until its
next preparation, metadata cleanup, or ordinary close.

Keep hard physical-owner loss distinct. On an exceptional execution exit,
check the captured canonical native file and join its retirement if that file
was replaced or disappeared. Caller aliases cannot select a different target
for this cleanup. Existing native-failure and accepted-work settlement remain.

Extend the existing refusal cases to hold and read an independent admission.
The caller-revocation case previously produced the same lost-native-owner
signature as hourly 39085230454. The original hourly initialization failure
has not been reproduced, so its exact triggering event remains unconfirmed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
* refactor(sessions): simplify maintenance ownership

* fix(storage): settle failed maintenance preparation in its native scope
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…175987)

A revoked maintenance caller must not retire the shared native generation
retained by another admitted reply. Remove the maintenance-specific forced
retirement and its unused preparation option. This follows openclaw#175778's intended
contract: one stopped read-only preparation is owned by the worker until its
next preparation, metadata cleanup, or ordinary close.

Keep hard physical-owner loss distinct. On an exceptional execution exit,
check the captured canonical native file and join its retirement if that file
was replaced or disappeared. Caller aliases cannot select a different target
for this cleanup. Existing native-failure and accepted-work settlement remain.

Extend the existing refusal cases to hold and read an independent admission.
The caller-revocation case previously produced the same lost-native-owner
signature as hourly 39085230454. The original hourly initialization failure
has not been reproduced, so its exact triggering event remains unconfirmed.
RomneyDa added a commit that referenced this pull request Oct 23, 2026
…2026.10.7 (#181465)

* fix(backup): keep a supported older exec approval policy in snapshots (#164297)

Snapshot sanitization replaced any policy the strict persisted parser rejected
with a fail-closed deny-all document, so a backup taken before `doctor --fix`
migrated an older but supported policy lost its allowlist. Restoring the archive
installed deny-all instead of the saved rules.

Fall back to the legacy parser Doctor already uses, which converts the older
shape (agents.default, missing ids, commandText) into the current
representation, and keep fail-closed for genuinely malformed rows.

(cherry picked from commit e68d50a)
Co-authored-by: RomneyDa <[email protected]>

* fix(linux): saved Gateway dashboards need pairing approval after every restart (#158908)

* fix(linux): saved Gateway dashboards need pairing approval after every restart

Saved Gateway dashboards were built as incognito WebKit views, so the
Control UI lost its browser device identity and paired device token on
every switch and restart, and the Gateway asked for approval again.

Give each saved Gateway its own private WebKit data directory, keyed by
the credential namespace and profile id, matching the per-profile
website data store on native macOS. Storage for Gateways that are no
longer saved is deleted at the next launch, because WebKitGTK keeps a
data directory in use until the app exits.

Closes #156945

* fix(linux): removed Gateway saved again must pair a fresh dashboard

Dashboard storage was keyed by the endpoint-derived profile id, so
removing a Gateway and saving the same address again in one session
reopened the removed profile's storage and its paired device token.

Each saved profile now records a random storage id when it is first
saved. Renames and credential edits keep it; removal drops it, so the
same endpoint saved again gets new storage and must pair again.
Profiles saved before this change fall back to a stable key. Storage
helpers are compiled only where they are used, and the symlink test is
Unix-only so Windows test builds compile.

(cherry picked from commit c65a353)
Co-authored-by: RomneyDa <[email protected]>

* fix(sessions): preserve readers across maintenance refusal (#175987)

A revoked maintenance caller must not retire the shared native generation
retained by another admitted reply. Remove the maintenance-specific forced
retirement and its unused preparation option. This follows #175778's intended
contract: one stopped read-only preparation is owned by the worker until its
next preparation, metadata cleanup, or ordinary close.

Keep hard physical-owner loss distinct. On an exceptional execution exit,
check the captured canonical native file and join its retirement if that file
was replaced or disappeared. Caller aliases cannot select a different target
for this cleanup. Existing native-failure and accepted-work settlement remain.

Extend the existing refusal cases to hold and read an independent admission.
The caller-revocation case previously produced the same lost-native-owner
signature as hourly 39085230454. The original hourly initialization failure
has not been reproduced, so its exact triggering event remains unconfirmed.

(cherry picked from commit 30b7adf)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 380c53c)

* fix: preserve borrowers after PostgreSQL agent opening refusal (#179320)

Fixes PostgreSQL agent-opening refusals retiring peer borrowers after an opening lease has already committed.

The caller receives its original refusal, its lease is removed after native exit, and peers can retry. A refusal before native open preserves SQLite's clean-restart seal. Unknown outcomes and genuine native or cleanup failures retain their existing invalidation and retirement behavior.

This is the explicitly separated opening-refusal follow-up to merged #179230. Producer parity alone cannot fix this outcome: the refused worker tries to release its lease in a new shared-state transaction under its already-refused operation. PostgreSQL correctly rejects that transaction, replacing refusal provenance and making settlement unknown.

Prepared workers now defer pre-open refusal cleanup to the existing host-owned `cleanupRetiredAgentDatabaseLease` / `agentDatabases.releaseExitedLease` path after native exit. That existing command carries the host's typed `refused-before-open` or `unknown` outcome. The lease owner still validates and deletes the exact lease; it preserves verification only for the explicit pre-open refusal. Missing facts never establish refusal.

This field is an internal message between processes of the same build. No public SDK/plugin contract, persisted format, schema, configuration, version, or successful-open ownership changes. Synchronous opens retain their cleanup. The PG current-operation refusal guard and native `!captured.committed` classification remain unchanged. No dedicated cleanup command was added.

Lazy `database.prepareWrite` now retains the refusal wrapper until the existing worker reply owner serializes the original error and typed outcome. The existing refusal reply branch handles factory and lazy opens, records the outcome for the matching actor after admission cleanup, and clears it before later dispatch can touch native state. Host cleanup reads the outcome only after native retirement. This resolves the accepted review finding without reusing an earlier request’s custody.

Author simplification retains one cleanup owner and one command. The full PR has +62/-44 production lines, +117/-3 test/registry lines, and seven documentation lines. The repair strengthens the two existing real refused-open seal regressions with original-error and no-operation assertions; the broker fixture only adopts the existing actor outcome state.

| Contract | RED | GREEN / candidate status |
| --- | --- | --- |
| PG refusal after committed opening lease preserves peer | Main-source baseline 39562254889/job119096566538; producer parity alone still RED in 39568439138/job119116916734 | Final head3643 passes both real engine cases in [39599121710/job119219532025](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532025): SQLite2,275ms, PG2,832ms |
| SQLite clean-restart seal survives refused open, both preparation modes | Previous head48ad,39576377942/job119143384085: both cases fail at line74 with missing `.seal` | [Final CI/job119219533530](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219533530): both cases PASS (prepared false560ms / true470ms) |
| Exact lease removal, original refusal, no user operation, successful peer write | Real production worker/store sequence, independently confirms committed lease; no fabricated receipt | PASS in the final PG conformance regression |
| Synchronous owner and genuine cleanup-failure retirement | Existing authority/integrity/lease-owner contracts | Existing local63PASS/1opt-in SKIP, new local22PASS; all affected owner/transport suites passed final CI |

All three PostgreSQL conformance shards actually executed and passed on final head `3643c3c5bb50878de0fb97858b2b11420cecface` in [CI39599121710](https://github.com/openclaw/openclaw/actions/runs/39599121710): [1/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532025), [2/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532043), [3/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219531982). Logs confirm all14 producer/bootstrap/preferences/peer cases ran, plus both SQLite seal regressions. All required checks, type/lint/source contracts, and affected SQLite suites passed. No CI exception or rule bypass is needed.

Formatting and final targeted type-aware lint passed. Both complete-diff Codex P0–P2 reviews completed clean, including the final shared refusal branch consolidation. Local registration/synchronous-authority suites passed22 cases; the next infra carrier blocked on host I/O before cases and was cancelled, exit143, with children joined and slot released. Final CI supplies the remaining runtime proof. The prior48ad run exposed the real seal regression; it was fixed rather than weakened or relabeled. The draft synchronize run skipped CI and is excluded from proof.

No latency or throughput claim is made. The production peer regression takes about5.1s for both engines in final CI; the two existing SQLite seal cases take about1.0s together. No public SDK/plugin, persisted-format, schema, configuration, or successful-open ownership change is introduced.

(cherry picked from commit 8cd9bf2)
Co-authored-by: RomneyDa <[email protected]>

* fix(macos): show actual Gateway version and keep recovery visible (#181389)

* fix(macos): show actual bundled Gateway status and recovery

* fix(macos): keep pending Gateway recovery actionable

---------

Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit bd36d90)
Co-authored-by: RomneyDa <[email protected]>

* fix(macos): ignore stale receipts during gateway repair (#167459)

Backport the live-dispatch receipt behavior needed by the release line so historical checkpoints cannot veto a valid bundled Gateway repair, and only the receipt actually dispatched is completed.

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

* test(release): use stable worker dispatch fixture

The stable line records worker-open dispatch as a boolean state, before the request-custody abstraction introduced on main. Exercise the same reply settlement contract with the branch-native dispatched state.

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

* refactor(release): isolate opening refusal classification

Keep the stable branch database modules below their existing line-cap limits while preserving the backported host-owned lease cleanup semantics.

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

* fix(release): complete stable database guard adaptation

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

* fix(copilot): document stable transcript assertion invariants

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

---------

Co-authored-by: wangmiao0668000666 <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: dOR <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 23, 2026
…2026.10.10 (#181464)

* fix(backup): keep a supported older exec approval policy in snapshots (#164297)

Snapshot sanitization replaced any policy the strict persisted parser rejected
with a fail-closed deny-all document, so a backup taken before `doctor --fix`
migrated an older but supported policy lost its allowlist. Restoring the archive
installed deny-all instead of the saved rules.

Fall back to the legacy parser Doctor already uses, which converts the older
shape (agents.default, missing ids, commandText) into the current
representation, and keep fail-closed for genuinely malformed rows.

(cherry picked from commit e68d50a)
Co-authored-by: RomneyDa <[email protected]>

* fix(linux): saved Gateway dashboards need pairing approval after every restart (#158908)

* fix(linux): saved Gateway dashboards need pairing approval after every restart

Saved Gateway dashboards were built as incognito WebKit views, so the
Control UI lost its browser device identity and paired device token on
every switch and restart, and the Gateway asked for approval again.

Give each saved Gateway its own private WebKit data directory, keyed by
the credential namespace and profile id, matching the per-profile
website data store on native macOS. Storage for Gateways that are no
longer saved is deleted at the next launch, because WebKitGTK keeps a
data directory in use until the app exits.

Closes #156945

* fix(linux): removed Gateway saved again must pair a fresh dashboard

Dashboard storage was keyed by the endpoint-derived profile id, so
removing a Gateway and saving the same address again in one session
reopened the removed profile's storage and its paired device token.

Each saved profile now records a random storage id when it is first
saved. Renames and credential edits keep it; removal drops it, so the
same endpoint saved again gets new storage and must pair again.
Profiles saved before this change fall back to a stable key. Storage
helpers are compiled only where they are used, and the symlink test is
Unix-only so Windows test builds compile.

(cherry picked from commit c65a353)
Co-authored-by: RomneyDa <[email protected]>

* fix(sessions): preserve readers across maintenance refusal (#175987)

A revoked maintenance caller must not retire the shared native generation
retained by another admitted reply. Remove the maintenance-specific forced
retirement and its unused preparation option. This follows #175778's intended
contract: one stopped read-only preparation is owned by the worker until its
next preparation, metadata cleanup, or ordinary close.

Keep hard physical-owner loss distinct. On an exceptional execution exit,
check the captured canonical native file and join its retirement if that file
was replaced or disappeared. Caller aliases cannot select a different target
for this cleanup. Existing native-failure and accepted-work settlement remain.

Extend the existing refusal cases to hold and read an independent admission.
The caller-revocation case previously produced the same lost-native-owner
signature as hourly 39085230454. The original hourly initialization failure
has not been reproduced, so its exact triggering event remains unconfirmed.

(cherry picked from commit 30b7adf)
Co-authored-by: RomneyDa <[email protected]>

* fix: preserve borrowers after PostgreSQL agent opening refusal (#179320)

Fixes PostgreSQL agent-opening refusals retiring peer borrowers after an opening lease has already committed.

The caller receives its original refusal, its lease is removed after native exit, and peers can retry. A refusal before native open preserves SQLite's clean-restart seal. Unknown outcomes and genuine native or cleanup failures retain their existing invalidation and retirement behavior.

This is the explicitly separated opening-refusal follow-up to merged #179230. Producer parity alone cannot fix this outcome: the refused worker tries to release its lease in a new shared-state transaction under its already-refused operation. PostgreSQL correctly rejects that transaction, replacing refusal provenance and making settlement unknown.

Prepared workers now defer pre-open refusal cleanup to the existing host-owned `cleanupRetiredAgentDatabaseLease` / `agentDatabases.releaseExitedLease` path after native exit. That existing command carries the host's typed `refused-before-open` or `unknown` outcome. The lease owner still validates and deletes the exact lease; it preserves verification only for the explicit pre-open refusal. Missing facts never establish refusal.

This field is an internal message between processes of the same build. No public SDK/plugin contract, persisted format, schema, configuration, version, or successful-open ownership changes. Synchronous opens retain their cleanup. The PG current-operation refusal guard and native `!captured.committed` classification remain unchanged. No dedicated cleanup command was added.

Lazy `database.prepareWrite` now retains the refusal wrapper until the existing worker reply owner serializes the original error and typed outcome. The existing refusal reply branch handles factory and lazy opens, records the outcome for the matching actor after admission cleanup, and clears it before later dispatch can touch native state. Host cleanup reads the outcome only after native retirement. This resolves the accepted review finding without reusing an earlier request’s custody.

Author simplification retains one cleanup owner and one command. The full PR has +62/-44 production lines, +117/-3 test/registry lines, and seven documentation lines. The repair strengthens the two existing real refused-open seal regressions with original-error and no-operation assertions; the broker fixture only adopts the existing actor outcome state.

| Contract | RED | GREEN / candidate status |
| --- | --- | --- |
| PG refusal after committed opening lease preserves peer | Main-source baseline 39562254889/job119096566538; producer parity alone still RED in 39568439138/job119116916734 | Final head3643 passes both real engine cases in [39599121710/job119219532025](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532025): SQLite2,275ms, PG2,832ms |
| SQLite clean-restart seal survives refused open, both preparation modes | Previous head48ad,39576377942/job119143384085: both cases fail at line74 with missing `.seal` | [Final CI/job119219533530](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219533530): both cases PASS (prepared false560ms / true470ms) |
| Exact lease removal, original refusal, no user operation, successful peer write | Real production worker/store sequence, independently confirms committed lease; no fabricated receipt | PASS in the final PG conformance regression |
| Synchronous owner and genuine cleanup-failure retirement | Existing authority/integrity/lease-owner contracts | Existing local63PASS/1opt-in SKIP, new local22PASS; all affected owner/transport suites passed final CI |

All three PostgreSQL conformance shards actually executed and passed on final head `3643c3c5bb50878de0fb97858b2b11420cecface` in [CI39599121710](https://github.com/openclaw/openclaw/actions/runs/39599121710): [1/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532025), [2/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219532043), [3/3](https://github.com/openclaw/openclaw/actions/runs/39599121710/job/119219531982). Logs confirm all14 producer/bootstrap/preferences/peer cases ran, plus both SQLite seal regressions. All required checks, type/lint/source contracts, and affected SQLite suites passed. No CI exception or rule bypass is needed.

Formatting and final targeted type-aware lint passed. Both complete-diff Codex P0–P2 reviews completed clean, including the final shared refusal branch consolidation. Local registration/synchronous-authority suites passed22 cases; the next infra carrier blocked on host I/O before cases and was cancelled, exit143, with children joined and slot released. Final CI supplies the remaining runtime proof. The prior48ad run exposed the real seal regression; it was fixed rather than weakened or relabeled. The draft synchronize run skipped CI and is excluded from proof.

No latency or throughput claim is made. The production peer regression takes about5.1s for both engines in final CI; the two existing SQLite seal cases take about1.0s together. No public SDK/plugin, persisted-format, schema, configuration, or successful-open ownership change is introduced.

(cherry picked from commit 8cd9bf2)
Co-authored-by: RomneyDa <[email protected]>

* fix(macos): show actual Gateway version and keep recovery visible (#181389)

* fix(macos): show actual bundled Gateway status and recovery

* fix(macos): keep pending Gateway recovery actionable

---------

Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Dallin Romney <[email protected]>
(cherry picked from commit bd36d90)
Co-authored-by: RomneyDa <[email protected]>

* test(release): align opening refusal coverage with beta harness

The beta line predates the mixed-agent host installer used by the upstream PostgreSQL conformance fixture. Keep the production settlement repair and its broker coverage without importing a test harness that cannot boot on this branch.

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

* fix(release): restore beta guard compile and changelog record

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

---------

Co-authored-by: wangmiao0668000666 <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: dOR <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L 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.

1 participant