Repository navigation
refactor: simplify session assignment across channels - #161676
Conversation
Reuse the admitted run as the MCP authority source and keep session action restrictions in the core tool. Remove redundant adapter plumbing and retain the full handoff composition in the existing release-only tier. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: dcf1fabf-dd61-4437-a180-1ad5b273a3ac
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 4:05 AM ET / 08:05 UTC (Revision 4). ClawSweeper reviewWhat this changesThis PR simplifies shared session assignment and CLI/MCP authority plumbing, repairs collector completion during metadata publication, and updates the affected test fixtures. Merge readiness✅ Ready for maintainer review The PR retains useful work absent from current main. The reviewed assignment and publication paths preserve authorization and commit guards; no actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s session tools turn agent requests into Gateway operations that assign responsibility or control sessions. Admitted-run authority governs those operations, while worker-backed persistence publishes completion facts and releases queued work. flowchart TD
A[Channel or CLI agent turn] --> B[Live run admission]
B --> C[Shared session tool]
C --> D[Gateway authorization]
D --> E[Session persistence]
F[Collector completion] --> G[Writer admission and commit guards]
G --> E
E --> H[Published session facts and queued work]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -30, Tests +246, Other +1. Total +217 across 19 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one admitted-run authority source and the existing assignment writer, with completion publication serialized behind metadata writes. Do we have a high-confidence way to reproduce the issue? Yes, a focused source-backed scenario holds metadata publication while collector completion persists. The PR reports deterministic red/green results; this read-only review did not independently execute a current-main reproduction. Is this the best way to solve the issue? Yes. The patch removes duplicate plumbing and adjusts the existing publication owner while preserving dispatch, transaction, commit, and publication checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 739d436f3766. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Resolve the actual wrapper modify/delete conflict against current main. Keep the wrapper removed and preserve upstream normalization cleanup, creator-only archive and restore, and assigned-session Stop semantics. Focused boundary proof passes and independent P0-P2 review is scoped-clean. Co-authored-by: steipete <[email protected]>
Keep the upstream assignee self-archive regression on the actual non-owner posture and its issued operator authority after removing controlOnly. The unchanged assertion fails with the retired option and all 21 authority cases pass after migration. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 66f5d3b4-102b-4791-8296-fc5e5dace253
Integrate 79f0e9b for the observed cancellation fixture writer deadlock. The separate collector completion race remains under scoped repair. Co-authored-by: steipete <[email protected]>
Integrate the canonical publication owner from 5ad2c6b instead of retaining duplicate collector staging. Defer its initial session-fact assertion until admission joins the existing writer FIFO; native transaction, commit and host publication guards remain unchanged. Add real-worker before-commit and after-ACK regressions for the observed Stop slot-release failure. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 8a6f1107-834b-40b2-b9a0-6338d592ddba
Keep copied lint-status and changed-lint fixtures complete after typed runners gained their Kysely prerequisite. Preserve all process-lifetime, signal, timeout, and semantic-lint assertions. Co-authored-by: steipete <[email protected]> (cherry picked from commit e568672)
Integrate the named failing main input 54522d1 after reusing e568672 with its owner. Preserve the upstream operational run context and all assertions. The 59 fixture/generator cases and 53 Gateway/Stop cases pass on this base, along with focused type, lint, format and ratchet gates. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: f3b666e3-ce9e-4662-b32c-1e4a677d12c7
|
Merged via squash.
|
…rite Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. #161019 moved the collector registry write and publication into that writer turn and #161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: #161019's worker test stubs assertCurrent, and reverting #161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when #161676's deferral is reverted.
…rite (#162359) Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. #161019 moved the collector registry write and publication into that writer turn and #161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: #161019's worker test stubs assertCurrent, and reverting #161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when #161676's deferral is reverted.
* refactor: simplify shared session assignment Reuse the admitted run as the MCP authority source and keep session action restrictions in the core tool. Remove redundant adapter plumbing and retain the full handoff composition in the existing release-only tier. Co-authored-by: steipete <[email protected]> * refactor: simplify session assignment across channels Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: dcf1fabf-dd61-4437-a180-1ad5b273a3ac * test: migrate session archive fixture to shared inputs Keep the upstream assignee self-archive regression on the actual non-owner posture and its issued operator authority after removing controlOnly. The unchanged assertion fails with the retired option and all 21 authority cases pass after migration. Co-authored-by: steipete <[email protected]> * refactor: simplify session assignment across channels Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 66f5d3b4-102b-4791-8296-fc5e5dace253 * refactor: simplify session assignment across channels Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 8a6f1107-834b-40b2-b9a0-6338d592ddba * test(lint): include generated-type owner in runner fixtures Keep copied lint-status and changed-lint fixtures complete after typed runners gained their Kysely prerequisite. Preserve all process-lifetime, signal, timeout, and semantic-lint assertions. Co-authored-by: steipete <[email protected]> (cherry picked from commit e568672) * refactor: simplify session assignment across channels Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: f3b666e3-ce9e-4662-b32c-1e4a677d12c7 --------- Co-authored-by: steipete <[email protected]>
…rite (openclaw#162359) Scheduled main run 36780090668 failed sessions.abort-embedded.test.ts when a parent Stop's child-row writes (session timing, abort marker) overlapped the killed collector's terminal commit. A session-entry worker write holds the agent-database writer FIFO from its commit grant through settlement, and in that window the collector's retained generation reads as unavailable, so completion failed or was declined and never released its swarm scheduler slot. openclaw#161019 moved the collector registry write and publication into that writer turn and openclaw#161676 deferred the remaining pre-capture currency check into it. Neither added coverage for the collector path: openclaw#161019's worker test stubs assertCurrent, and reverting openclaw#161676's deferral leaves every existing test green. Add an end-to-end regression with real SQLite writers: after completion retains generation facts, hold a real child metadata write between its native commit and settlement. Completion must join that writer, keep the staged terminal row off the live registry while waiting, preserve the metadata write, reach terminal state and release its swarm slot. It fails with the original CI error when openclaw#161676's deferral is reverted.
Related: #154239
What Problem This Solves
Session assignment already lives in core, but its tool construction and CLI/MCP adapters carried redundant restriction flags and parallel copies of run authority.
User Impact
No intended user-visible or permission change from the cleanup itself. Assignment remains channel-independent, with the same visibility, sharing, caller-lifetime, and write-time checks. No configuration or migration is needed.
Why This Change Was Made
Use the exact admitted run as the single source of operator authority through CLI/MCP projection, caching, and Gateway resolution. The core sessions tool derives restrictions from sender posture rather than accepting a second control-only flag. Its assignment operation is inline instead of passing callbacks, types, and another flag through a single-use adapter.
The pre-target caller capture, dispatch assertion after awaited work, and synchronous pre-commit guard protect different authority windows and remain intact. Owner/senderless management, participant selection, collector Stop restrictions, standalone/attach denial, and broad registered-human/configured-agent handoffs are preserved.
The current-main reconciliation resolves an actual modify/delete conflict against
7c5997006c892b87432233f57c87188e97426e44. The wrapper stays removed, while its upstream normalization cleanup is retained inline. Current main’s creator-only archive/restore and creator-or-assignee Stop rules are preserved. A newly added upstream regression fixture now uses the actual non-owner posture and its issued operator authority instead of the retired constructor option; its assertion is unchanged.The unchanged full Discord HTTP-to-SQLite composition remains in the existing release-only inventory; direct edits to that test still select it. Normal core coverage includes an arbitrary external channel, WebChat, and senderless runs. This is not a Discord-specific implementation or a migration out of Discord code.
Evidence
The latest CI failure (
36831045574, job110267843364) was a copied lint fixture missing the generator imported by main54522d16a3c2. With its owner’s coordination, this branch reusese5686722415b(two inventory additions, author/coauthor preserved). On that producer base, all 59 fixture/generator cases passed (36.40s), and 53 Gateway/Stop boundary cases passed (101.28s). Core types (20.67s), Gateway types (15.21s), typed lint, format, diff and staged ratchets passed. No assertions or timeouts changed.The failed cancellation CI exposed a separate collector-completion race. This update incorporates canonical fixes
79f0e9bf1271e(the abort fixture deadlock) and5ad2c6b4b44c(publication admission), rather than retaining a second implementation. One remaining early assertion ran before that admission could join pending session metadata. The existing publication owner now defers that initial check when admission is present; transaction, commit, and host-publication checks remain intact.Before the fixture-only follow-up, 265 cancellation/publication cases across six files passed: 14 original Stop and new real-worker regression cases (51.39s wrapper), plus 251 lifecycle, registry-writer, metadata-publication and recovery cases (63.22s). The new cases took 2.206s and 1.310s. They cover metadata held before commit and after ACK, slot release, successor dispatch, metadata preservation, and retained delivery identity.
The regression fails both ways on the original production code. Canonical
5ad2c6b4b44c, with its frozenfs-safe0.21.3 dependencies, repairs the after-ACK case but still fails before commit (41.04s wrapper). The narrow admission-order refinement passes both. No retries, deadlines or assertions were weakened.Independent P0–P2 AutoReview of the unchanged production and cancellation regression is scoped-clean. Before the fixture-only follow-up, core types (16.94s), Gateway-methods types (14.99s), agents-other types (12.07s), typed lint, format, diff and ratchets passed. Prior proof below is retained for unchanged inputs.
Earlier cleanup proof passed 201 cases across nine files: 180 in four shards (253.52s) and 21 authority cases (8.32s). Real MCP handoff: 21.691s. Coverage includes assignment persistence, caller revocation, control permissions, full CLI preparation and channel-neutral assembly.
Historical complete
check:changedagainst7c5997006c89passed: core types, 27 test graphs, script types, lint, format, dead exports and ownership/import/schema guards. Its initial stale-constructor fixture failure was repaired and all 21 authority cases passed.Actual planner proof verified ordinary automatic exclusion, direct-test-change inclusion, and release inclusion of the retained MCP composition.
The original cleanup delta remains 15 files, +122/−173. The final candidate is 19 files, +391/−174, including the small canonical admission-order correction and its two-case real-worker regression. Production remains 30 lines smaller overall; it does not retain the earlier duplicate collector-publication adapter.
Historical costs, the earlier CI failure, and limitations
The original 118-case/11-file proof overlaps later results; counts are not additive. Original command:
pnpm test <file> --maxWorkers=1:Collector wall time included 65.85s cold worker compilation; its assertions took 14ms. No speed claim is inferred from runtime variation.
Earlier head
6ced0c5a1c31hit a plugin-help timeout in CI run 36676793140. An unchanged eight-case replay passed (20.68s; affected case 1.701s), but not the full concurrent shard. It remains unreproduced, not claimed fixed or pre-existing. No CI run was retried merely for green.CI run
36784173504on head55635cceeab7failed one Stop slot-release assertion and three abort-fixture cases. A bounded original 56-file/two-config replay after the fixture fix completed in 343.77s: 730/733 cases passed. It reproduced the separate Stop failure and also exposed a localchat.reset-visible-yieldtimeout, shutdown refusal and teardown ENOENT. The Stop race now has deterministic red/green proof; the visible-yield signature remains separately unattributed, not claimed fixed. The broad group has not been rerun until green. Local proof uses Node 26.8.2, while the failed CI job used Node 24.19.0.Unrun locally: full build/full repository suite and live channel or CLI backend. Hosted gates remain independently enforced on the final published head. This is production-boundary proof, not a Team deployment.
Worked on by
Work sessions
View the OpenClaw team session