Repository navigation
refactor: run immediate notifications through ordinary session execution - #167113
Conversation
|
🦞👀 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. What this changesThe branch routes immediate process, hook, restart, and session notifications through ordinary conversation execution while preserving producer ownership and delivery restrictions. Example: A user posts a hook wake with text "The sample import completed" and mode "now".
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this is an approved, distinct implementation slice, and current main still routes these notifications through heartbeat execution. No concrete blocking patch defect was identified. Priority: P2 Before mergeNone. FindingsNone. Provenance
Agent review detailsHow this fits togetherThe Gateway receives background results and trusted notifications for existing conversations. The ordinary reply executor admits those turns, retains conversation history and permissions, and delivers their results to the captured destination. flowchart TD
A[Background results and immediate notifications] --> B[Capture conversation and producer restrictions]
B --> C[Validate current session and authority]
C --> D[Ordinary conversation queue]
D --> E[Execute with conversation history]
E --> F[Recheck authority before effects]
F --> G[Deliver or record intentional silence]
Technical reviewBest possible solution: Use ordinary session execution for immediate producer-owned work, preserving its native authority and settlement owners, and complete periodic retirement with the approved Doctor migration in the final slice. Do we have a high-confidence way to reproduce the issue? Not applicable to the architectural request. Source confirms the separate heartbeat path on current main, and recorded Gateway proof plus the focused cancellation regression establish the associated failure mechanism. Is this the best way to solve the issue? Yes for this approved slice: the existing reply executor owns admission, queueing, execution, and delivery, while producer-specific lifetime and cancellation remain explicit. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7e80556f503d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (14 earlier review cycles; latest 8 shown)
Reviewed October 8, 2026, 7:27 PM ET / 23:27 UTC (Revision 15). |
fa245c6 to
2172049
Compare
2172049 to
bc9c57c
Compare
1b6afd1 to
007d055
Compare
f44994f to
8bb3563
Compare
8bb3563 to
9f714a8
Compare
Related: #134994, #135933, #164265. Second of three sequential slices; Claw deletion/Cron custody landed in #166889.
Comparison: base
61a5fc58ecce321bc0bb1b224b447f8d446d099e, head9f5cc13c3f9b18775fcdd0202140fec5ee0c9e5f.What Problem This Solves
Background completions and immediate notifications depend on heartbeat execution even though they belong to an existing conversation. This slice moves them into ordinary session execution. Doctor conversion and periodic heartbeat retirement remain one atomic final slice.
User Impact
Host exec completions, CLI watchdogs, ACP parent notifications, immediate HTTP hook wakes, restart continuations, and session-state notices enter the ordinary reply queue. They retain the originating history, physical session identity, account/thread route, permission ceiling, cancellation, and automatic-delivery opt-out. Busy sessions preserve FIFO order. Acceptance remains separate from terminal settlement; reset or replacement cannot redirect delayed work.
Watcher notices preserve one reconciliation per destination within the original 20-second window. A batch retains its original occurrences and acknowledges frozen watermarks only at adoption. Explicit consumption of one notice preserves surviving originals; whole-batch cancellation cannot restart work. Shutdown cancels newer buffered notices while older batches await adoption.
Cancellation before execution now preserves the preceding run's terminal state. Previously, a cancelled watchdog follow-up emitted a terminal event without identifying itself as unstarted. Its asynchronous projection overwrote the foreground timeout after deletion had captured its expected row, so deletion correctly refused the changed row. The ordinary runner now supplies the existing
executionStarted: falseandproviderStarted: falsefacts from the canonical reply-operation state. The existing projection guard handles them; deletion's CAS, authority checks, started-run cancellation, and non-cancellation preparation failures remain intact.Periodic heartbeats, node notices, and deferred
next-heartbeathooks retain their behavior until the final cutover. Stored configuration/data formats are unchanged here. No delivery options, migration, or deprecated SDK aliases are introduced. The deprecatedreply-runtimeexport budget stays 1. Peter's approved Doctor notice and breaking heartbeat SDK removal belong to the final slice.The SDK adds the
"event"discriminator while retaining existing values, including"heartbeat"; exhaustive plugin switches may need an event case. Existing reply-wrapper names, option fields, and callback signatures remain available. Event authority stays host-only, andsystem-event-runtime.enqueueSystemEventEntryretains its original two-argument contract.Why This Change Was Made
The existing reply executor owns admission, execution, and delivery. Producer-owned occurrences carry their original target and lifetime through that owner, including detached completion after the initiating request ends. Captured restrictions intersect current restrictions. Stop, deletion, plugin fallback interruption, and exact reply-operation settlement retain their native owners.
Main's newer selected-session database reader remains the initialization owner. The integration carries the event creation guard through its options helper and keeps event source authority independent of the retained database reader. The duplicate initialization parameter type is removed. Later commits, including watcher batching, reapplied unchanged.
Production is +3,401/−716 = +2,685; tests/support are +6,362/−1,576 = +4,786. The ordinary event target/handoff owner drives the increase. Main's code is not reintroduced, and generated output and test support are excluded. Each immediate occurrence has one owner. The remaining periodic executor retires with its migration in slice 3.
Evidence
The original watchdog failure reproduced through registered Gateway methods on the rebased candidate. Diagnostics established the exact sequence: foreground timeout persisted, deletion captured its post-cleanup row, then a different, unstarted cancellation overwrote nine terminal fields. Session/lifecycle identity stayed equal; this was a late write, not serialization order or stale cache. A deterministic deferred-boundary regression failed before the repair; its started-run control passed.
The repaired production path passed 129 focused tests across six files, including all six original watchdog cases, lifecycle projections, runner/backstop behavior, and suppression checks (420.04 seconds including preparation). The final regression was placed in the existing terminal-failures owner to respect the unchanged 1,000-line cap. That file passed 33 tests with one worker: 58.67 seconds for the file, 65.32 seconds including preparation. Assertions, deadlines, retries, skips and budgets were not weakened. These selections overlap and are not summed.
Earlier watcher proof covers 130 owner cases, plus the final 13-case notice suite and 20 wrapper/import-closure/suppression cases. Negative controls proved duplicate reconciliation turns, loss of a sibling after partial SDK consumption, and dispatch after shutdown with overlapping debounce windows. Core and affected messaging types, runtime cycles (0), Madge cycles (0), scoped typed lint, formatting and suppression checks pass. Fresh P2 autoreview is clean. The captured-terminal concern was resolved with complete production caller evidence; frozen-capture behavior was not changed.
The conflict integration separately passed 14 focused initialization/event-permission cases, core/messaging types and both cycle checks. Current base includes three independently proved main CI repairs: Gateway identity test routing (
c8283bcc86c), raw-wire restart refusal coverage (76ddbf697fc), and the OpenAI runtime-carrier fixture (e09e5ddfa52). The last two preserve current runtime behavior; they change tests only.Prior unchanged-cutover proof includes real process completion and exact polling cancellation; explicit non-main
sessions.createfollowed by socket reads; durable restart adoption; periodic-to-background-exec handoff; runtime build; SDK surface/export guards and complete committed-ref SDK API comparison. The SDK comparison found no export/entrypoint additions or removals and confirmed the two-argument enqueue contract. Paid inference and transport were synthetic where identified; process execution, queueing, authority, and persistence were real. Historical results do not replace current-head hosted CI.Previous exact-head CI and incorporated repairs
Head
9f714a8970d08cef08c0a7cc5ebd1c3dd485c1ec, run 37853773137, tested mergec52aa003df98bbb0b6097c18d60c4434016fea78on main674275e3808ed6c3f521aac391d0158c036dec29. The complete check census has 178 successes, five failures, 45 unselected skips, and one neutral result. CI itself has 144 successful jobs, four root failures plus its aggregate, and 21 unselected skips. No selected job is cancelled or zero-step. Current-head ClawSweeper completed with no findings.Every failure is recorded separately:
checks-node-changed-3(113574161702): the local-only skill-refresh fixture requested an implicit worktree base after main removed the local-HEAD fallback. Unchanged main424b6b1reproduced the exact missing-origin error. Main repair61a5fc58eccadds the explicit base. The unchanged assertions pass (52.831 seconds for the case; 130.36 seconds including preparation); suppression checks and P2 review pass. No runtime fallback is restored.checks-node-changed-compact-small-21(113574161762): the plugin reader fixture signaled on the legitimate pre-quiesce retained-work wait, then asserted admission had already closed. The original 31-file group reproduced the same assertion on unchanged main (336 passed, one failed). Main repairf59e4079321observes the post-quiesce call drain and retains the independent closed-admission, metadata, deadline, and rollback assertions. Focused proof, types, lint, suppression checks, and P2 review passed. This authority-related assertion is repaired, not waived.checks-ui-e2e (3/9)(113574157846): dashboard roster readiness at line 191 and retained prompt thumbnail at line 131. Both have exact independent main failures; natural main 37854167434/job/113574525857 proves thumbnail line 131, resolving the previous gap. Main9d606a28e0drepairs dashboard readiness;a5106ecf049repairs durable draft retirement before confirmed navigation. S2 changes no UI files.checks-ui-e2e (7/9)(113574157771): only sidebar roster readiness at line 189 failed. Its exact independent main failure is now repaired by9d606a28e0d. The previously failing writer-draft case passed this run.openclaw/ci-gate(113578653269): completed failure aggregating those four root jobs.The repaired watchdog shard, npm successor shard, lint, production and test types, build, SDK/package gates, and security-fast passed. All named main repairs are included in the current base. The subsequent rebase was conflict-free and all 13 commits are patch-identical. Current-head core types, runtime cycles (0), Madge cycles (0), and suppression checks pass. The current head requires its own hosted CI; prior failures are not represented as current passing proof. No merge exception is armed for unresolved failures or missing proof.
All known allocated test leases are stopped or terminal. One unpublished AWS allocation attempt still lacks its private cancellation receipt; exact status returns 404, no resource or owned process is visible, and that cleanup limitation remains recorded.
Production LOC by area
Against base
61a5fc58ecce321bc0bb1b224b447f8d446d099e. Tests, fixtures, support and generated output excluded.src/auto-reply/replysrc/config/sessionssrc/gateway/serversrc/sessionssrc/agentssrc/gatewaysrc/agents/cli-runnersrc/plugin-sdksrc/infrasrc/agents/subagents/spawnsrc/plugins/runtimesrc/agents/toolssrc/cron/isolated-agentsrc/auto-replysrc/auto-reply/reply/queue