Repository navigation
fix: let agents organize sessions without shell fallbacks - #136952
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 3:53 AM ET / 07:53 UTC. ClawSweeper reviewWhat this changesThe PR lets Gateway-bound agents manage visible sessions, including bounded multi-session patches, and strengthens interruption handling for session groups and resets. Regression provenancePossible 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 Review scores
Verification
How this fits togetherBuilt-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]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The detached authority transfer lacks an exact child-generation fence and can act on a successor session. PR surfaceSource +304, Tests +1359, Docs +30, Other +1. Total +1694 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7b67c28e2e96. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
The exact-head verification on
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. |
073c3ef to
53a5dc4
Compare
|
Both lifecycle findings and rank-up moves are addressed in the current head,
The branch is rebased onto There is no SQLite schema, stored representation, configuration, migration or protocol change. |
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.
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.
* 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
…off dispatch Same #136952 expectation miss as the gateway tool test: the in-process dispatch options now carry operatorRoleActor.
* 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
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.
…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.
…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
…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.
…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
* 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
…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.
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
sessionstool'spatchaction now accepts either one target or 1–100targets, through the existingsessions.patchManyowner. 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
7da11019930used Codex with roles enabled. It restored the archived fixture, moved two sessions into Verified and unpinned both with onepatch, 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.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 at04c6984443bpassed. Its real/tools/invokeendpoint 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 onlysessions/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).29a95369099reopened the earlier synthetic state. Live Gateway RPC and the open dashboard verified group rename and delete across two agent stores (updatedSessions: 2each); rename retained the destination membership and delete left both sessions ungrouped. Interruption/retry is established by the separate SQLite regressions.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: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:
After one restore and one two-target patch, both sessions are active in Verified and unpinned:
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.