Skip to content

fix: let agents organize sessions without shell fallbacks - #136952

Merged
steipete merged 6 commits into
mainfrom
codex/session-tools-bulk-patch
Sep 3, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/session-tools-bulk-patch

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136818. Related: #120850.

What Problem This Solves

Fixes an issue where agents organizing sessions could see an empty inventory or get “session not found” for a valid archive target when Gateway roles were configured. Shared group or settings changes also required one tool call per session.

Why This Change Was Made

The built-in Gateway bridge supplies explicit system authority for trusted background calls while preserving authenticated operator restrictions and per-method scopes. Foreground mutations revalidate the admitted caller at the synchronous commit boundary. Accepted self-archive, cancellation, and child cleanup retain their Gateway and effective actor after the initiating turn ends; an attribution profile does not replace that actor.

The existing sessions tool's patch action now accepts either one target or 1–100 targets, through the existing sessions.patchMany owner. Single and batch forms share parsing, visibility checks, model override handling, and session identity guards. Results identify succeeded and failed input indexes, with diagnostics bounded to 3,840 bytes. Validated duplicate targets reject before mutation; individual target failures preserve successful siblings. Current-session archival keeps its deferred single-target behavior.

Group rename/delete share one owner flow: prepare the rename destination, retain the source catalog and sidebar while guarded member writes run, then retire the source only if its catalog row is unchanged and no old members remain. Interrupted operations retain discoverable partial progress, preserve concurrent edits, report retry guidance, and refresh open clients. Retrying completes remaining work without rollback after authority expires.

Reset admission remains caller-bound until destructive cleanup starts. The reset owner then finishes only the captured existing lifecycle, preserving concurrent replacements; missing-session creation keeps its commit-time caller checks.

No new RPC, configuration option, SQLite schema, migration, or stored representation is introduced. The new patch helper serializes tool results, not a new persistence format.

User Impact

Agents can list and organize their allowed sessions through dedicated tools, apply one group/settings update to multiple sessions, and archive or restore using the current session ID. The background shell management tool is labeled “Background Shell” instead of “Gateway Process.”

Evidence

  • Pre-fix actual-router/SQLite reproduction returned an empty list and rejected an archive with the correct target ID. Batch regressions also failed before implementation.
  • Coverage exercises persisted batch changes, stale IDs, visibility/incognito restrictions, caller closure at commit, deferred cleanup, operator/system actor precedence, and group consistency across multiple agent stores. Group cases cover interruption, retry, destination removal, late member assignment, and concurrent source-default changes.
  • The original isolated dashboard proof at 7da11019930 used Codex with roles enabled. It restored the archived fixture, moved two sessions into Verified and unpinned both with one patch, then verified both active. Tool trace: sessions_list → sessions_list → sessions → sessions → sessions_list; batch result: succeeded: [0, 1], failed: []. No shell calls. This proves the batch workflow before the later group-consistency and cleanup-actor changes.
  • At 04c6984443b, 44 authority/router tests, all 22 background-runtime tests, production types, the exact CI test-type stripe 3/5, scoped typed lint, formatting, and independent Codex review pass. Reset proof includes 30 cleanup/concurrency tests and the final 8-case concurrency rerun. Earlier unchanged batch coverage includes 61 single/batch tests. The full supported build at 04c6984443b passed. Its real /tools/invoke endpoint listed sessions across two agents, applied one two-target group/pin patch (succeeded: [0, 1], no errors), verified both rows, archived/restored the target, and verified final state using only sessions/sessions_list. Live Gateway RPC on the same build also passed group rename/delete across both agent stores, normal reset (preserved session ID, cleared usage), and incognito reset (deleted the session).
  • The rebased full build at 29a95369099 reopened the earlier synthetic state. Live Gateway RPC and the open dashboard verified group rename and delete across two agent stores (updatedSessions: 2 each); rename retained the destination membership and delete left both sessions ungrouped. Interruption/retry is established by the separate SQLite regressions.
  • Exact-head CI passed at 04c6984443b76cc5e895ab0fb522c6f7455057cf (attempt 2), including all selected Node, Gateway/agent, Windows, macOS Swift, Android, and iOS lanes. Workflow Sanity also passed. The only retry in the passing run was Windows checkout after a runner PermissionError, before tests started. A parallel hosted recovery passed Windows but hit the native startup watchdog described below; its remaining duplicate iPad capture was cancelled after the original iPad capture passed. No source or global CI settings were changed for these runner recoveries.

Against base b637075f4e92b9ac7c75f580aecc1bde5b1c8494:

Area Added Removed Net
Production 626 322 +304
Tests/test support 1,381 22 +1,359
Docs 31 1 +30
Generated display resource 1 0 +1
Assertion ratchet 1 1 0

Production growth provides bounded batch input/results (+159), authority/lifetime and group consistency (+140), and the display label (+5). Parsing and rename/delete ownership are shared; no parallel mutation path was added. Existing session data remains readable and writable without migration. Codex's dynamic tool boundary was inspected directly; OpenClaw retains ownership of authorization and persistence.

Follow-ups: make the new-main queued-expiry test independently safe on a cold filtered run (its 1-second admission wait expired during lazy import initialization; the full 22-test file passed unchanged), and improve native cancellation-fixture startup diagnostics/isolation. The hosted recovery hit one five-second pre-command watchdog in ExecHostSocketCancellationTests; it never reached the cancellation step, while the full Swift suite passed on the same commit in the original run. No timeout or assertion was weakened.

Live dashboard evidence

Synthetic fixture before restoration and bulk patch:

Before session organization

After one restore and one two-target patch, both sessions are active in Verified and unpinned:

After session organization

These screenshots show the completed dashboard workflow at the original live-tested commit. The actual-router/SQLite regressions establish the role defect and lifecycle races; the later group/reset runs establish the built-runtime behavior. CI also caught two interactions with newer main: cleanup now uses its canonical AbortSignal, and the inventory fixture explicitly includes the third session permitted by its new cross-agent default.

@steipete steipete self-assigned this Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 3, 2026
@steipete
steipete marked this pull request as ready for review September 3, 2026 03:52
@steipete
steipete requested a review from a team as a code owner September 3, 2026 03:52
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 3:53 AM ET / 07:53 UTC.

ClawSweeper review

What this changes

The PR lets Gateway-bound agents manage visible sessions, including bounded multi-session patches, and strengthens interruption handling for session groups and resets.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: the role-aware session access and bulk patch work remains needed, but detached cleanup can delete a successor session at the reused child key.

Priority: P1
Reviewed head: 04c6984443b76cc5e895ab0fb522c6f7455057cf

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The main session-access path is substantially covered, but the detached-cleanup race is a merge blocker.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 6 items Introduced detached cleanup: This PR introduces a wrapper that clears the worker caller identity before non-create cleanup calls, allowing accepted cleanup to outlive the source turn.
Unfenced rollback request: Visible-session rollback deletes by child key only and does not preserve the created session identity or lifecycle revision.
Delete fence is optional: The delete handler only rejects a changed session when optional expected identity fields are supplied; otherwise it snapshots the entry present when detached cleanup arrives.
Findings 1 actionable finding [P1] Fence detached cleanup to the created child session
Security Needs attention Detached cleanup can delete a successor session: Cleanup dispatches deletion by key after dropping caller identity, so a replacement at that key can satisfy optional identity checks intended for the original child.

How this fits together

Built-in agent tools use the local Gateway to list and mutate persisted sessions. Gateway role filtering and lifecycle checks decide which session records may be changed before results return to the agent.

flowchart LR
  A[Built-in agent tool] --> B[In-process Gateway bridge]
  B --> C[Role-aware session access]
  C --> D[Session lifecycle checks]
  D --> E[SQLite session records]
  E --> F[Results to agent]
Loading

Before merge

  • Fence detached cleanup to the created child session (P1) - The new cleanup wrapper drops the caller identity, then rollback calls sessions.delete with only the child key. Because delete treats expected session identity and lifecycle revision as optional, a reset or replacement admitted before cleanup can be deleted as though it were the original child. Preserve the created entry's session ID and lifecycle revision through abort/delete cleanup so the existing changed-session check rejects a successor.
  • Resolve security concern: Detached cleanup can delete a successor session - Cleanup dispatches deletion by key after dropping caller identity, so a replacement at that key can satisfy optional identity checks intended for the original child.
  • Resolve merge risk (P1) - Detached cleanup can delete a replacement session at the same child key because it omits the created session's identity and lifecycle revision.
  • Complete next step (P2) - Fence detached child cleanup to the created session identity and lifecycle revision, add the successor-race Gateway/SQLite regression, and complete exact-head Gateway, agent, and session-state checks before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Fence detached cleanup to the created child session — src/gateway/worker-environments/worker-session-tool-executor.ts:206-211
  • [high] Detached cleanup can delete a successor session — src/gateway/worker-environments/worker-session-tool-executor.ts:209
Agent review details

Security

Needs attention: The detached authority transfer lacks an exact child-generation fence and can act on a successor session.

PR surface

Source +304, Tests +1359, Docs +30, Other +1. Total +1694 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 16 626 322 +304
Tests 9 1381 22 +1359
Docs 1 31 1 +30
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 1 +1
Total 28 2040 346 +1694

Review metrics

Metric Value Why it matters
Production and test delta production +304 net; tests/test support +1,359 net; docs +30 net The broad production growth supports the batch capability and lifecycle protections, but the detached-cleanup ownership gap must be repaired.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/sessions-tool-patch.ts, unknown-data-model-change: src/agents/tools/sessions-tool-patch.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136818
Summary: This PR is the candidate repair for the canonical role-aware session-access issue; its detached-cleanup race is an introduced defect in that repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Fence detached cleanup (recommended)
    Preserve the created child identity and lifecycle revision through rollback, then add a Gateway/SQLite successor-race regression.

Technical review

Best possible solution:

Fence detached abort/delete cleanup to the exact child created by this operation, prove the replacement race cannot affect a successor, then complete exact-head checks.

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

Yes, from source: create a visible child, close the worker turn, replace or reset that child before detached cleanup is admitted, and observe that cleanup deletes by key without an expected identity.

Is this the best way to solve the issue?

No: retaining only Gateway cleanup context is insufficient; the cleanup request must retain the created child generation so the existing delete fence rejects a successor.

Full review comments:

  • [P1] Fence detached cleanup to the created child session — src/gateway/worker-environments/worker-session-tool-executor.ts:206-211
    The new cleanup wrapper drops the caller identity, then rollback calls sessions.delete with only the child key. Because delete treats expected session identity and lifecycle revision as optional, a reset or replacement admitted before cleanup can be deleted as though it were the original child. Preserve the created entry's session ID and lifecycle revision through abort/delete cleanup so the existing changed-session check rejects a successor.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7b67c28e2e96.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The introduced race can remove a current child session during an ordinary agent session workflow.
  • merge-risk: 🚨 security-boundary: Detached cleanup crosses initiating-turn closure without retaining an exact child-generation fence.
  • merge-risk: 🚨 session-state: Cleanup intended for an earlier child can delete its successor at the same key.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

Security concerns:

  • [high] Detached cleanup can delete a successor session — src/gateway/worker-environments/worker-session-tool-executor.ts:209
    Cleanup dispatches deletion by key after dropping caller identity, so a replacement at that key can satisfy optional identity checks intended for the original child.
    Confidence: 0.92

Acceptance criteria:

  • [P1] Replace or reset the created child before detached cleanup and verify the successor survives.
  • [P1] Complete exact-head Gateway, agent, and session-state checks.

What I checked:

Likely related people:

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

Rank-up moves

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

  • Fence cleanup to the exact session generation created by this operation.
  • Add a Gateway/SQLite regression that replaces the child before detached cleanup runs.
  • Let exact-head Gateway, agent, and session-state checks complete successfully.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-03T04:00:36.825Z sha 7da1101 :: blocked before merge. :: none
  • reviewed 2026-09-03T04:11:54.549Z sha 7da1101 :: blocked before merge. :: [P2] Preserve group catalog/member consistency on caller expiry
  • reviewed 2026-09-03T04:39:26.830Z sha 804e441 :: blocked before merge. :: [P1] Transfer reset ownership before destructive cleanup | [P2] Preserve group catalog/member consistency on caller expiry
  • reviewed 2026-09-03T06:19:24.055Z sha 53a5dc41becc788b16c60138efde9107a64e128a :: blocked before merge. :: none
  • reviewed 2026-09-03T06:49:02.411Z sha 04c6984 :: blocked before merge. :: none

@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

The exact-head verification on 7da11019930 is complete, and the PR body now includes the synthetic dashboard screenshots and results.

  • Role/lifetime boundary: 82 Gateway tests and 19 bridge tests passed against this source, including actual-router/SQLite coverage for scoped and inherited restricted operators, unknown synthetic denial, mixed-actor deferred cleanup, expired foreground callers, patch/patchMany/assignOwner, group commits, and reset. The separate agent-owned reset finish-after-lifecycle-rotation contract remains green. The final independent Codex P0–P2 review found no actionable defects.
  • Runtime batch proof: the built dashboard restored the archived fixture with its current session ID, applied exactly one two-target patch, and re-listed both persisted rows as active, unpinned, and in Verified. The result was succeeded: [0, 1], failed: []. The captured tool sequence contains only session tools. Lifecycle/replacement tests (7) and single/batch session-tool tests (61) also passed. The dashboard fixture uses an authorized admin; restricted-role and post-closure rejection are proven at the actual Gateway router/storage boundary, not inferred from the screenshots.
  • Production growth: +159 lines provide generalized bounded patch input/results, +140 enforce caller identity/lifetime and explicit cleanup transfer at existing owners, and +5 clarify the shell tool label. Parsing is shared and mutation ownership remains canonical. This is the owner-reviewed scope requested by the maintainer; no parallel mutator was added.
  • Data-model classification: sessions-tool-patch.ts serializes bounded model-visible tool results; it does not store them in a new persistence format. No SQLite schema, migration, schema version, stored representation, configuration option, or Gateway protocol changed. The existing state was created before the final build, then reopened and successfully restored/patched by the final build. No data migration is required.

These address the listed verification, growth, and compatibility requests. The fresh review has no code/security finding; the pending CI run is the remaining landing gate. No source changes followed the review.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Sep 3, 2026
@steipete
steipete force-pushed the codex/session-tools-bulk-patch branch from 073c3ef to 53a5dc4 Compare September 3, 2026 06:10
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Both lifecycle findings and rank-up moves are addressed in the current head, 53a5dc41bec.

  • Group rename/delete now retain the source catalog and sidebar while guarded member writes complete. Interrupted work stays discoverable and retryable, concurrent catalog edits are preserved, and clients refresh even on failure. The regressions assert catalog/member coherence across both agent stores, interruption before and after partial progress, retry, destination removal, late members, and concurrent source edits. The focused group/handler/router set passed 48 tests. A live Gateway and open dashboard also verified rename/delete across two agent stores, reopening state created by the earlier build.
  • Reset now hands completion of an existing lifecycle to the reset owner immediately before destructive cleanup. Normal rotation and incognito deletion finish after caller closure; exact identity, lifecycle revision and SQLite compare-and-swap preserve replacements. Missing-row creation still checks live authority through commit. The actual built-in bridge → Gateway handler → reset owner reproduced both failures before the fix. The 30-test reset cleanup/concurrency set passed, followed by the final 8-test concurrency rerun after fixture type cleanup. The reset correction is net-neutral in production lines.

The branch is rebased onto dc73b1aa54eb. That comparison found an interaction with the new owner-attribution authority field; cleanup now preserves the effective foreground actor. Both new regressions failed before the fix, and all 44 authority/router tests passed. Independent Codex reviews of the group, integration, and reset corrections are clean; production and exact affected test types, typed lint, and formatting passed.

There is no SQLite schema, stored representation, configuration, migration or protocol change. sessions-tool-patch.ts serializes bounded model-visible tool results; it is not a persistence format. Existing-state reopening was verified by the live group run. Final-head CI and the final supported build/live reset check are running; their results will be recorded before landing.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
steipete added a commit that referenced this pull request Sep 3, 2026
Main's #136952 minted the system actor for owner-sender dispatch without
updating these expectations, leaving checks-node-compact-small-4 and
checks-node-compact-large-16 red on main. Fixed here because this PR is
landing on that main.
steipete added a commit that referenced this pull request Sep 3, 2026
Align the update tool and /update exact-call assertions with the shared
in-process Gateway actor introduced by #136952. Preserve owner checks,
trusted routing, admin scopes, abort propagation, and the update timeout.

Reuse Peter Steinberger's two-line fix from commit
0fee3dc in #137041, separated so this CI
prerequisite can land independently of its UI and Android changes.

Four failures reproduced on main 993ad30. All 50 owner and sibling
tests pass after the correction. Production delta: zero lines.
steipete added a commit that referenced this pull request Sep 3, 2026
* fix(agents): fence visible child cleanup to creation identity

Retain the created session ID and lifecycle revision for failed visible spawns.
Initialize the revision alongside a new session identity and preserve existing
rows. Reuse guarded subagent cleanup and remove abort-then-delete rollback.
Report removed, changed, or unconfirmed cleanup without widening permission.

Follow-up to #136952. Production delta: -23 lines.

Validation: real Gateway/SQLite replacement and reset regressions, active-child
cleanup, 259 focused tests, production and affected test types, scoped typed
lint, independent Codex review, full build, and live Gateway creation/deletion
fences. No schema, migration, configuration, or protocol changes.

* test(gateway): align authority assertions and scope rollback fixture
steipete added a commit that referenced this pull request Sep 3, 2026
…off dispatch

Same #136952 expectation miss as the gateway tool test: the in-process
dispatch options now carry operatorRoleActor.
steipete added a commit that referenced this pull request Sep 3, 2026
* chore(gateway): deslop owner profile change

* fix(gateway): keep the owner profile out of merges, roles, and catalog counts

* fix(ui): explain GitHub rows for the shared owner profile

* refactor(state): reuse protocol user profile types

* fix(state): restore a merged owner profile on connect

Unreleased owner-profile builds allowed email linking to merge gateway-owner
into a person and move gateway.local/owner to that person. Generic profile
resolution then followed merged_into, so shared-secret reconnects inherited
the person's role, catalog identity, and personal GitHub connection. Guards
that checked only resolved IDs also missed the owner tombstone.

Restore the raw canonical owner and its provider identity in one profile-write
transaction. Reuse a legacy UUID owner only when it is unmerged; otherwise
create the canonical owner. Leave the person's emails, role, and GitHub state
untouched, invalidate cached aliases after commit, and warn once per repair.
Check both raw and resolved IDs at email, role, and verified GitHub mutations.
This repairs unreleased state without schema changes or a Doctor migration.

Proof: 10 new state regressions failed before the fix; the real-server
reconnect regression also reproduced successful tombstone linking and leaked
person ID, policy, and GitHub account. All 39 focused owner/reconnect tests
now pass. The requested state, gateway, and UI suites pass 270 tests across
16 files. Update the user-model owner paragraph with next-connect repair
behavior. Follow-up repair for #137022.

Preserve the requested reuse of raw, unmerged legacy UUID bindings. If an old
merge already repointed that binding and no canonical owner row exists, the
schema has no authoritative original-owner ID to distinguish it from a valid
legacy binding; this historical ambiguity remains outside this repair.

Validation: node scripts/check-changed.mjs passed, including core/test/UI
types, changed-file lint, full-tree dead exports, storage guards, and zero
runtime import cycles. git diff --check is clean.

* fix(state): repair merged owner profiles through doctor

Earlier unshipped owner merges left gateway-owner pointing at a person and
moved its local identity. Connection-time recovery repaired durable profile
rows during authentication, contrary to the runtime/Doctor ownership boundary.

Apply the maintainer decision for #137022: Doctor --fix owns the idempotent
repair, while non-fix Doctor reports the finding and recovery hint. Restore
the raw canonical owner and local identity atomically, preserve personal
emails, roles, and GitHub identities, and invalidate aliases after commit.
Reuse an unmerged legacy UUID only when no canonical owner exists.

Runtime rejects merged or misdirected owner rows with a typed repair-required
error naming openclaw doctor --fix. Existing WS and HTTP catches warn and
continue unidentified. Preserve missing-owner creation, name adoption, and
all earlier merge, role, GitHub, and canonical-ID guards. No schema change.

Proof: pre-change runtime cases returned instead of throwing; Doctor preview
and repair sequence omitted the finding/repair; real-server reconnect allowed
users.self instead of FORBIDDEN. The requested state/gateway/UI suites plus
Doctor preview pass 352 tests across 19 files. The seven migration tests also
pass with alias assertions before any runtime writer. Real reconnect proves
absent authenticated profile and presence user, the logged Doctor hint, and
canonical identity after explicit repair with the person's state preserved.

Validation: node scripts/check-changed.mjs, pnpm build, git diff --check,
and independent Codex autoreview at P0-P2. Docs describe Doctor repair and
reconnect. The existing historical ambiguity of an unmerged UUID identity
already repointed to a person with no canonical row remains unchanged.

* test(agents): expect the system actor on owner update dispatch

Main's #136952 minted the system actor for owner-sender dispatch without
updating these expectations, leaving checks-node-compact-small-4 and
checks-node-compact-large-16 red on main. Fixed here because this PR is
landing on that main.

* test(gateway): trace merged-owner effects before and after doctor repair
steipete added a commit that referenced this pull request Sep 3, 2026
Keep the exact update-tool and chat-command dispatch assertions aligned
with the host-minted system actor added by #136952. Preserve every routing,
scope, timeout, signal and resolver expectation; change no authorization
or update implementation.

Both stale expectations failed in CI for #137181 and reproduced in focused
runs before the edit. The repaired suites pass 31 cases; actor, caller and
update-owner siblings pass 87. Rebased memory watcher/configuration scopes
pass 90 and 343 cases. The complete five-file changed gate and fresh
independent Codex autoreview pass at the configured review scope.
steipete added a commit that referenced this pull request Sep 3, 2026
…em in nodes status (#137090)

* feat(nodes): retain offline host stats and show CLI summaries

Persist the current session's last host-stats snapshot when recording its
generation-bound disconnect. Keep previous stats when a connection ends
without a new snapshot, validate stored snapshots on read, and project them
for offline node.list/node.describe rows with their original updatedAtMs.
Connected nodes continue to use only live session stats.

Show compact load, used/total memory, and free-disk summaries in nodes status
and nodes describe, with a last-known age for offline nodes. Reuse the shared
binary byte formatter and leave CLI JSON output unchanged. Update the node,
protocol, and CLI docs. This builds on live node host stats from #136859.

Maintainer decision (Peter, chat, 2026-09-03): persist the last host-stats
snapshot on the paired node record as an additive lastHostStats field in
the existing node_surface_json column. No SQLite schema change or schema
version bump.

* fix(nodes): persist host stats when received

Record accepted host stats against the pairing generation before connection
replacement can discard the live session. Keep persistence best effort and
independent of the node event result, and reuse the generation-scoped node
surface writer for disconnect metadata without carrying stats at close.

Preserve last-known offline stats and their original receipt timestamp in
node.list, node.describe, and CLI summaries. Cover replacement ordering,
stale connections and generations, reopened readers, and persistence failure.

Reworks the offline host stats persistence in PR #137090.

* test(agents): expect the system operator actor in gateway tool dispatch

#136952 added operatorRoleActor to in-process Gateway dispatch options and
updated its own test, but the gateway tool's exact-options expectation for
update.run still lacked it, leaving main red on three cases. Carried in this
landing PR.

* test(auto-reply): expect the system operator actor in the update handoff dispatch

Same #136952 expectation miss as the gateway tool test: the in-process
dispatch options now carry operatorRoleActor.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…36952)

* fix: let agents organize sessions without shell fallbacks

* test: preserve generic session gateway callback type

* fix: preserve session group consistency on interruption

* fix: preserve effective authority for deferred session cleanup

* fix: complete accepted session resets after caller closure

* fix: align session cleanup with invocation abort signals
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…7196)

Align the update tool and /update exact-call assertions with the shared
in-process Gateway actor introduced by openclaw#136952. Preserve owner checks,
trusted routing, admin scopes, abort propagation, and the update timeout.

Reuse Peter Steinberger's two-line fix from commit
0fee3dc in openclaw#137041, separated so this CI
prerequisite can land independently of its UI and Android changes.

Four failures reproduced on main 385c9d9. All 50 owner and sibling
tests pass after the correction. Production delta: zero lines.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…law#137183)

* fix(agents): fence visible child cleanup to creation identity

Retain the created session ID and lifecycle revision for failed visible spawns.
Initialize the revision alongside a new session identity and preserve existing
rows. Reuse guarded subagent cleanup and remove abort-then-delete rollback.
Report removed, changed, or unconfirmed cleanup without widening permission.

Follow-up to openclaw#136952. Production delta: -23 lines.

Validation: real Gateway/SQLite replacement and reset regressions, active-child
cleanup, 259 focused tests, production and affected test types, scoped typed
lint, independent Codex review, full build, and live Gateway creation/deletion
fences. No schema, migration, configuration, or protocol changes.

* test(gateway): align authority assertions and scope rollback fixture
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
* chore(gateway): deslop owner profile change

* fix(gateway): keep the owner profile out of merges, roles, and catalog counts

* fix(ui): explain GitHub rows for the shared owner profile

* refactor(state): reuse protocol user profile types

* fix(state): restore a merged owner profile on connect

Unreleased owner-profile builds allowed email linking to merge gateway-owner
into a person and move gateway.local/owner to that person. Generic profile
resolution then followed merged_into, so shared-secret reconnects inherited
the person's role, catalog identity, and personal GitHub connection. Guards
that checked only resolved IDs also missed the owner tombstone.

Restore the raw canonical owner and its provider identity in one profile-write
transaction. Reuse a legacy UUID owner only when it is unmerged; otherwise
create the canonical owner. Leave the person's emails, role, and GitHub state
untouched, invalidate cached aliases after commit, and warn once per repair.
Check both raw and resolved IDs at email, role, and verified GitHub mutations.
This repairs unreleased state without schema changes or a Doctor migration.

Proof: 10 new state regressions failed before the fix; the real-server
reconnect regression also reproduced successful tombstone linking and leaked
person ID, policy, and GitHub account. All 39 focused owner/reconnect tests
now pass. The requested state, gateway, and UI suites pass 270 tests across
16 files. Update the user-model owner paragraph with next-connect repair
behavior. Follow-up repair for openclaw#137022.

Preserve the requested reuse of raw, unmerged legacy UUID bindings. If an old
merge already repointed that binding and no canonical owner row exists, the
schema has no authoritative original-owner ID to distinguish it from a valid
legacy binding; this historical ambiguity remains outside this repair.

Validation: node scripts/check-changed.mjs passed, including core/test/UI
types, changed-file lint, full-tree dead exports, storage guards, and zero
runtime import cycles. git diff --check is clean.

* fix(state): repair merged owner profiles through doctor

Earlier unshipped owner merges left gateway-owner pointing at a person and
moved its local identity. Connection-time recovery repaired durable profile
rows during authentication, contrary to the runtime/Doctor ownership boundary.

Apply the maintainer decision for openclaw#137022: Doctor --fix owns the idempotent
repair, while non-fix Doctor reports the finding and recovery hint. Restore
the raw canonical owner and local identity atomically, preserve personal
emails, roles, and GitHub identities, and invalidate aliases after commit.
Reuse an unmerged legacy UUID only when no canonical owner exists.

Runtime rejects merged or misdirected owner rows with a typed repair-required
error naming openclaw doctor --fix. Existing WS and HTTP catches warn and
continue unidentified. Preserve missing-owner creation, name adoption, and
all earlier merge, role, GitHub, and canonical-ID guards. No schema change.

Proof: pre-change runtime cases returned instead of throwing; Doctor preview
and repair sequence omitted the finding/repair; real-server reconnect allowed
users.self instead of FORBIDDEN. The requested state/gateway/UI suites plus
Doctor preview pass 352 tests across 19 files. The seven migration tests also
pass with alias assertions before any runtime writer. Real reconnect proves
absent authenticated profile and presence user, the logged Doctor hint, and
canonical identity after explicit repair with the person's state preserved.

Validation: node scripts/check-changed.mjs, pnpm build, git diff --check,
and independent Codex autoreview at P0-P2. Docs describe Doctor repair and
reconnect. The existing historical ambiguity of an unmerged UUID identity
already repointed to a person with no canonical row remains unchanged.

* test(agents): expect the system actor on owner update dispatch

Main's openclaw#136952 minted the system actor for owner-sender dispatch without
updating these expectations, leaving checks-node-compact-small-4 and
checks-node-compact-large-16 red on main. Fixed here because this PR is
landing on that main.

* test(gateway): trace merged-owner effects before and after doctor repair
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
…em in nodes status (openclaw#137090)

* feat(nodes): retain offline host stats and show CLI summaries

Persist the current session's last host-stats snapshot when recording its
generation-bound disconnect. Keep previous stats when a connection ends
without a new snapshot, validate stored snapshots on read, and project them
for offline node.list/node.describe rows with their original updatedAtMs.
Connected nodes continue to use only live session stats.

Show compact load, used/total memory, and free-disk summaries in nodes status
and nodes describe, with a last-known age for offline nodes. Reuse the shared
binary byte formatter and leave CLI JSON output unchanged. Update the node,
protocol, and CLI docs. This builds on live node host stats from openclaw#136859.

Maintainer decision (Peter, chat, 2026-09-03): persist the last host-stats
snapshot on the paired node record as an additive lastHostStats field in
the existing node_surface_json column. No SQLite schema change or schema
version bump.

* fix(nodes): persist host stats when received

Record accepted host stats against the pairing generation before connection
replacement can discard the live session. Keep persistence best effort and
independent of the node event result, and reuse the generation-scoped node
surface writer for disconnect metadata without carrying stats at close.

Preserve last-known offline stats and their original receipt timestamp in
node.list, node.describe, and CLI summaries. Cover replacement ordering,
stale connections and generations, reopened readers, and persistence failure.

Reworks the offline host stats persistence in PR openclaw#137090.

* test(agents): expect the system operator actor in gateway tool dispatch

openclaw#136952 added operatorRoleActor to in-process Gateway dispatch options and
updated its own test, but the gateway tool's exact-options expectation for
update.run still lacked it, leaving main red on three cases. Carried in this
landing PR.

* test(auto-reply): expect the system operator actor in the update handoff dispatch

Same openclaw#136952 expectation miss as the gateway tool test: the in-process
dispatch options now carry operatorRoleActor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

Session tools lose role-aware visibility and need generalized bulk patch targets

1 participant