Skip to content

fix: preserve project and current task context in visible spawns - #145102

Merged
steipete merged 2 commits into
mainfrom
codex/visible-spawn-project-context
Sep 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/visible-spawn-project-context

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a visible child task could not start from the current conversation when its parent was still running. A worktree child also selected the agent's default workspace instead of the registered project when its parent worked directly in that project. Once those failures were removed, live testing exposed that a forked visible child could follow the parent's earlier assignment instead of its own task.

Related: #144583.

Why This Change Was Made

Resolve inherited worktree repositories through the parent's live registered project, with the existing preparation and rollback guards. Allow a same-agent spawn to snapshot its own active parent only while the admitted requester remains current; ordinary active-parent forks retain their existing restrictions. Reuse the native subagent task-message owner for visible children so the current assignment follows inherited history with explicit child context.

The existing session creation and transactional transcript-fork owners remain authoritative. This adds no protocol fields, storage schema, or configuration options.

User Impact

Visible tasks can start in a separate worktree of the selected project, retain context from the parent's first in-progress turn, and execute their own assignment while the parent continues. Explicit directory/project choices and cross-agent boundaries keep their existing behavior.

Evidence

  • 216 focused tests passed across Gateway session creation, requester lifetime, project worktrees, spawn dispatch, and child-task envelopes.
  • Independent Codex review: no actionable P0–P2 findings.
  • Full isolated Testbox pnpm build passed. Both real-provider live probes passed (2 tests, 33.85 seconds): EOF recovery and visible worktree spawn. All changed-code checks passed, including core/test typechecks, lint, dead exports, schema and storage guards.
  • EOF probe: locally truncates a real Responses stream and verifies automatic recovery without repeating a completed side effect.
  • Visible-child probe: a real Gateway forks the active first parent turn, creates a worktree in the registered project, completes the child README read with the inherited context marker, and lets the parent continue. Before the fix, project selection and active-parent admission failed; the bare task handoff then reproducibly followed the parent assignment despite receiving the child task last. The shared envelope passes the complete flow.
  • Live execution used an isolated Testbox and synthetic Git repository; no operator Gateway was changed.

CI note: the first merge-ref run failed core lint because a concurrent main change left the existing daemon-install test at 1,001 executable lines (limit 1,000). This PR inlines two one-use locals into unchanged assertions; no test, assertion, or limit was removed. Targeted lint and an independent review of that cleanup passed.

Final exact-head CI run passed. ClawSweeper reviewed the same head with no actionable findings.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 11, 2026
@steipete
steipete marked this pull request as ready for review September 11, 2026 17:28
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 1:44 PM ET / 17:44 UTC.

ClawSweeper review

What this changes

The PR preserves project selection and current conversation context when creating visible child sessions, clarifies their assigned task, and adds regression and live-provider coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still rejects active-parent forks and misses direct-project inheritance. No blocking defect was found in the introduced changes; the maintainer-owned work should remain open.

Priority: P2
Reviewed head: cd0bc2ae93ce25273cfd3fbb0e45ac8668c8816d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful boundary coverage, a relevant reported live run, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its captured body reports a successful real-Gateway project fork and child-task run; inspected production-boundary tests cover missing and retired authority, with no unresolved authority-chain gap identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its captured body reports a successful real-Gateway project fork and child-task run; inspected production-boundary tests cover missing and retired authority, with no unresolved authority-chain gap identified.
Evidence reviewed 9 items Current main still needs the repair: At fetched main, session creation rejects an active parent unless forkFrom is last-completed, while repository inheritance returns undefined for parents without a managed worktree. These are the two source-proven failures addressed by this branch.
Latest-release comparison: The supplied latest release still sends the bare task to visible children. No released implementation of the shared child-task envelope was established.
Active-fork authority remains narrowly scoped: The exception requires spawn provenance, inherited policy, matching requester and parent, the same agent, and a live assertion. The service carries that assertion into the existing transcript-copy and session-write commit guards; ordinary operator forks retain their restrictions.
Findings None None.
Security None None.

How this fits together

Visible child sessions are persistent tasks created through the Gateway from an agent's spawn request. Session creation selects their repository, copies requested conversation history, and starts the delegated task.

flowchart TD
  A[Parent agent and assigned task] --> B[Visible spawn request]
  B --> C[Validate live requester]
  C --> D[Resolve registered project]
  C --> E[Copy current conversation]
  D --> F[Create child session and worktree]
  E --> F
  F --> G[Run explicit child assignment]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +148, Tests +701, Docs +2. Total +851 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 8 172 24 +148
Tests 6 726 25 +701
Docs 2 7 5 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 905 54 +851

Review metrics

Metric Value Why it matters
Production versus test growth Net production +148 lines; tests +701 lines Production growth implements scoped requester and project checks; most added code exercises lifecycle failures and real-provider behavior.

Technical review

Best possible solution:

Keep visible spawning on the shared task-envelope, session-creation, and worktree owners, with live requester checks guarding inherited context and repository selection.

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

Yes, from source: a visible fork during an active parent turn hits main's active-work rejection, and a direct-project parent lacks the managed-worktree binding required for inheritance. This read-only review did not execute either failure.

Is this the best way to solve the issue?

Yes. The patch extends existing owners, preserves explicit selections and ordinary fork restrictions, and uses one task envelope for hidden and visible children.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48a32fc72206.

Labels

Label changes:

  • add P2: This repairs a bounded visible-delegation workflow without evidence of a broader runtime outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its captured body reports a successful real-Gateway project fork and child-task run; inspected production-boundary tests cover missing and retired authority, with no unresolved authority-chain gap identified.

Label justifications:

  • P2: This repairs a bounded visible-delegation workflow without evidence of a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its captured body reports a successful real-Gateway project fork and child-task run; inspected production-boundary tests cover missing and retired authority, with no unresolved authority-chain gap identified.

Evidence

What I checked:

  • Current main still needs the repair: At fetched main, session creation rejects an active parent unless forkFrom is last-completed, while repository inheritance returns undefined for parents without a managed worktree. These are the two source-proven failures addressed by this branch. (src/gateway/session-worktree-preparation.ts:25, 48a32fc72206)
  • Latest-release comparison: The supplied latest release still sends the bare task to visible children. No released implementation of the shared child-task envelope was established. (src/agents/tools/sessions-spawn-visible.ts:335, 3a9d69db306c)
  • Active-fork authority remains narrowly scoped: The exception requires spawn provenance, inherited policy, matching requester and parent, the same agent, and a live assertion. The service carries that assertion into the existing transcript-copy and session-write commit guards; ordinary operator forks retain their restrictions. (src/gateway/server-methods/session-create-spawn.ts:26, cd0bc2ae93ce)
  • Project inheritance checks current ownership: Direct-project inheritance checks the session incarnation, archive state, project ID, session root, absence of a managed binding, and current registry root. Existing preparation and rollback owners consume the composed guard. (src/gateway/session-worktree-preparation.ts:38, cd0bc2ae93ce)
  • Boundary and revocation coverage: The new live/missing/retired cases exercise the real in-process router and SQLite creation path, asserting that rejected requests create no child row and never dispatch the child. Worktree cases cover archive, replacement, rebinding, unregistration, explicit overrides, and cross-agent selection. Child chat execution is mocked in the authority fixture; these tests were inspected, not executed during this review. (src/gateway/local-request-context.session-tools.test.ts:115, cd0bc2ae93ce)
  • Supplied live evidence matches the changed flow: The captured PR body reports successful isolated Testbox execution of the real Gateway visible-spawn probe: active first-turn inheritance, a separate registered-project worktree, the child's README result and inherited marker, and parent continuation. The inspected harness exercises those assertions through Gateway requests and the OpenClaw runtime. It does not depend on the Codex harness. The report is contributor-supplied; this review did not rerun it. (src/gateway/server-methods/sessions-create.visible-spawn.live.test.ts:44, cd0bc2ae93ce)

Likely related people:

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

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.

@steipete
steipete merged commit 58a6953 into main Sep 11, 2026
192 of 193 checks passed
@steipete
steipete deleted the codex/visible-spawn-project-context branch September 11, 2026 17:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant