Repository navigation
feat(cron): run scheduled children in their parent conversation's workspace and sandbox - #179669
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. |
859d601 to
fac8f7f
Compare
93a19b3 to
365ccc3
Compare
fac8f7f to
fc8567e
Compare
365ccc3 to
dc6fcd2
Compare
fc8567e to
941c2b0
Compare
dc6fcd2 to
3b24d61
Compare
|
Codex review: needs maintainer review before merge. What this changesScheduled child sessions inherit their creating conversation’s workspace and required sandbox, with inherited workspace access ending when the parent resets. Example: A conversation’s working directory contains QA_PARENT_WS_MARKER.txt with PARENT-WS-MARKER.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful and has no remaining actionable findings; the documentation correction resolves the previous P3, and normal CI is still running. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron admits a stored job against its parent conversation, passes workspace and sandbox facts into run preparation, and enforces current authority at embedded tool effects and CLI process execution. flowchart TD
StoredJob --> OccurrenceAdmission
ParentConversation --> OccurrenceAdmission
OccurrenceAdmission --> WorkspacePreparation
WorkspacePreparation --> EmbeddedTools
WorkspacePreparation --> CLIProcess
ParentReset --> EmbeddedTools
ParentReset --> CLIProcess
Technical reviewBest possible solution: Land the existing focused change once the normal current-head merge gates pass. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the default-workspace path, and supplied Gateway output independently records the missing marker before the change; this read-only review ran no target code. Is this the best way to solve the issue? The patch is a focused extension of occurrence admission and existing workspace, generation, sandbox, and process-lifecycle owners; the reset watcher addresses CLI-native effects that embedded tool checks cannot stop. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d7e7e402df15. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +167, Tests +187, Docs 0. Total +354 across 14 files. Added test files: 0. View PR surface stats
LabelsLabel 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 (4 earlier review cycles)
Reviewed October 23, 2026, 10:50 PM ET / October 24, 2026, 02:50 UTC (Revision 5). |
d0a6f04 to
3352363
Compare
3b24d61 to
11ec125
Compare
|
@clawsweeper re-review Fixed the P3 at |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…kspace and sandbox (openclaw#179669) * feat(cron): run scheduled children in their parent conversation's workspace and sandbox * fix(cron): keep scheduled child runs at root file scope Josh decided child automations stay limited to root (their own workspace), not the parent's file scope. The context now records root for every placement except in-session runs, matching what runs today. * fix(cron): end inherited workspace access with the parent and enforce its sandbox on existing roots A child running in its parent conversation's bound workspace now carries the parent's generation check: workspace preparation composes it, and the prompt executor passes it as the admitted run's source assertion, so embedded tool authority refuses every later effect once the parent resets. The CLI host-placement check also receives the occurrence's inherited sandbox requirement, since an existing cron root keeps its row and never takes creation metadata. * fix(cron): stop a CLI child working in its parent's workspace when the parent resets A CLI backend's native file tools never reach OpenClaw's tool check, so the parent's live check alone let a CLI child keep writing to the inherited workspace after the parent reset. Admission now watches committed changes to the parent row while a bound child runs and aborts a signal once the parent stops being current; the CLI run's abort signal includes it, so the process ends with the parent. * docs(cron): describe parent workspace inheritance for detached runs * docs(cron): removed or archived parents pause linked jobs
Builds on #178933, #179834, #178965, #179011 and #179062 (all merged).
Related: #178812
Related: #178811
What Problem This Solves
Fixes: a scheduled child of a conversation runs in the agent's default workspace, not the workspace, working directory or managed worktree its parent conversation is bound to. A child of a sandboxed conversation can also run without a sandbox.
User Impact
User impact: an automation created from a conversation that is bound to a workspace, working directory or managed worktree now runs its child sessions there, with that conversation's ownership checks.
/new) or removed while the child runs in its workspace, the run ends: the child's next OpenClaw tool effect is refused, and a CLI backend's process is stopped so its own file tools cannot keep writing there. It never keeps working in the former conversation's workspace.session:<key>) jobs, operator jobs and unbound jobs keep their current workspace selection.root: a child automation is limited to its own workspace and does not get its parent conversation's file scope. Josh decided this on 2026-10-21 ("Keep root."; design row 36, resolved decision 9).Why This Change Was Made
occurrence.childParent: the parent row when it persists a workspace binding, its sandbox requirement, andassertCurrent, which fails once the parent resets or the occurrence settles. Run preparation and workspace selection use it and don't read the parent again. The parent row's workspace uses the same persisted-binding rule run preparation applies (resolveIngressWorkspaceOverrideForSessionRun).prepareCronSessionWorkspaceapplies the existing ownership and worktree checks to the parent's row, not the run session's row, and every workspace step checks the parent. The in-session target path is unchanged.parent-reset-watch.ts) and aborts a signal once the parent stops being current; the CLI run's abort signal includes it, so the process ends with the parent.sandbox: "required"makes the child sandboxed. An existing cron root keeps its row and never takes creation metadata, so the CLI host-placement check also receives the occurrence's inherited requirement directly.rootfor child runs, matching what runs today; only in-session runs record their session's scope. No consumer reads this field yet, so behavior is unchanged.childParent, so the run keeps the legacy run-session workspace instead of failing, and the minted context fails closed for grants that only the parent gets.Evidence
run.session-workspace-authority.test.ts): a job created through the automations tool from a bound conversation runs through the real cron service with persisted session rows./newreset of the parent during the run (resetSessionEntryLifecycle), the admitted run's assertion refuses, and nothing is read from the former workspace.run.sandbox-admission.test.ts): with an existing persisted, unstamped cron root and the agent's sandbox mode off, a child whose parent requires a sandbox fails closed before the CLI process launches; the same root with an unsandboxed parent launches the real CLI stub. Without the placement fix the first case launches the CLI on the host.execution-context-admissioncovers removed and archived parents (pause), a reset parent (runs, no binding), a missing worktree (pause naming the path), a child getting its parent's bound row, sandbox requirement and live check (which fails after a parent reset and after the occurrence settles), an unbound parent's child getting only its sandbox requirement, an in-session job keeping its own binding, a failed read (no pause), and the notice.execution-context-admission.test.ts): a bound child's signal aborts with the parent's failure on a change to the parent row, ignores other rows, stays live while the parent is current, and stops after the occurrence settles.docs/automation/cron-jobs/payloads.mdnow describes which detached runs inherit the creating conversation's workspace and what a reset does mid-run.tsgo:core,tsgo:core:testandtsgo:test:srcare clean; type-aware oxlint and oxfmt are clean; the line-cap and mock-export ratchets pass.Live behavior proof (real Gateway, code at head
4618fc07eb9)A QA scenario creates conversations with
sessions.createbound to a working directory (cwd) that holds a marker file, schedules child jobs from inside them, and force-runs the jobs on a real Gateway child process (mock-openai). The CLI lane uses a local fake CLI backend that reports its launch directory and writes files with its own (native) file I/O, so those writes never pass OpenClaw's tool check. The scenarios, the fake CLI and the gated probe tool are local proof tooling only, not part of this PR.main/ previous headQA_PARENT_WS_MARKER.txtPARENT-WS-MARKERfrom the parent's directorymain(ddbf65c9215) fails:File not found: <qa-suite>/workspace/QA_PARENT_WS_MARKER.txt(agent default workspace)cwd=<parent dir> marker=PARENT-WS-MARKERsource execution authority is no longer active; no tool result after the reset reaches the modelsessions.reset; the write after the gate never happens; run endssource execution authority is no longer actived1920578643fails: process still alive after the reset, writesQA_CLI_HOLD_AFTER.txtinto the parent's directory, run reportsokCLI reset case, before and after the fix
Upgrade proof (latest stable
2026.10.6→ this PR)On an isolated state directory,
2026.10.6creates a conversation bound to a working directory, a job linked to it and an unlinked job, then stops. This PR'sdoctor --fixruns on the same state, and this PR's Gateway starts on it.workspaceDir,spawnedCwd, label and session id are unchanged.cwd=<parent dir> marker=PARENT-WS-MARKER); the pre-upgrade unlinked job runs in the agent workspace (marker=missing (ENOENT)); a linked job created after the upgrade also runs in the parent's directory. All three runs use the CLI runtime.sandboxfield is read unchanged; its inheritance is covered byrun.sandbox-admission.test.tsagainst a real CLI process.