Skip to content

fix(gateway): name the requested directory when it is not a git checkout - #178664

Merged
steipete merged 1 commit into
mainfrom
steipete/worktree-source-error
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/worktree-source-error

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When sessions_spawn or sessions.create asked for a managed worktree (worktree: true) of a caller-supplied cwd that is not a git checkout (for example a mistyped or not-yet-created repo path), the request failed with:

agent workspace is not a git checkout

The cwd was correctly used as the worktree source, but the message blamed the agent workspace and named no path, so a parent couldn't tell its own cwd was wrong. Live, a fleet parent whose cwd pointed at a missing repo got this for all 12 spawns and reported it as a workspace problem.

User Impact

Callers can identify and correct the requested working directory from the error message. The default agent-workspace case keeps its existing wording. No migration or configuration change is required.

Why This Change Was Made

session-request-error.ts, which owns session-request error text, gains nonGitWorktreeSourceMessage:

  • A caller-selected directory is named: requested working directory is not a git checkout: <path>.
  • The default agent-workspace case keeps its existing wording.

The call site in session-worktree-preparation.ts stays the same size (that file is at its line cap).

Evidence

server.sessions.create.workspace-policy.test.ts ("uses a non-git Gateway cwd directly but not as a worktree source") now asserts the precise message. It is red on base (1 failed) and green with the fix; the file passes 17/17, and server.sessions.create-worktree-spawn.test.ts passes 22/22 (default-workspace wording unchanged). oxlint/oxfmt are clean, and the line-cap ratchet passes.

Landing check note: the direct oxlint rerun reports the existing session-worktree-preparation.ts max-lines warning (725 counted lines; cap 700). The base produces the identical warning, and this change does not grow that file. Formatting and diff whitespace checks pass.

@steipete
steipete marked this pull request as ready for review October 20, 2026 18:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T19:07:57.854415Z a04156c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper

clawsweeper Bot commented Oct 20, 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 gateway Gateway runtime size: XS labels Oct 20, 2026
@steipete
steipete enabled auto-merge (squash) October 20, 2026 18:50
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR names a caller-selected working directory when managed worktree creation rejects it as a non-Git directory.

Example: Create a managed worktree with cwd=/tmp/unversioned-repo, an existing directory outside any Git checkout.

  • Before: agent workspace is not a git checkout
  • After: requested working directory is not a git checkout: /tmp/unversioned-repo

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and worthwhile; behavioral evidence is limited to reported harness results.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored exemption applies to ordinary live proof; the body reports focused RPC harness success but contains no post-fix shipped-entry-point capture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A caller supplying a non-Git directory receives an error blaming the agent workspace and cannot identify the rejected path.
Reason: The diagnostic identifies the incorrect input with minimal code, and the supplied maintainer-authored status establishes direction.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a misleading diagnostic still present on main, with no introduced correctness or security findings.

Priority: P3
Reviewed head: a04156c6231255403b74296e9115f03065210626

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No post-fix live Gateway output is supplied; the reported red/green regression exercises the in-process sessions.create handler.
Agent review details

How this fits together

Gateway session creation selects the requested or default workspace, validates its worktree source, and returns a structured RPC error when Git discovery fails.

flowchart TD
  A[Session caller] --> B[Sessions create RPC]
  B --> C[Workspace selection]
  C --> D[Git checkout discovery]
  D --> E[Session request error formatter]
  E --> F[Caller receives invalid request]
Loading

Technical review

Best possible solution:

Keep the existing worktree validation owner and return the selected directory in its rejection while preserving default-workspace wording.

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

Current main demonstrably selects an explicit workspace and then emits the default-workspace error when Git discovery fails; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a focused fix using the existing error-text owner and regression case, with no new state, duplicate validation, or unrelated behavior.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Verified introduced change: The pinned introduction changes only the error formatter, its existing rejection call site, and the existing caller-visible regression assertion. (src/gateway/session-request-error.ts:31, a04156c62312)
  • Current main still has the misleading diagnostic: Workspace selection prefers params.workspace, but the non-Git rejection unconditionally identifies the agent workspace. (src/gateway/session-worktree-preparation.ts:685, b7c858fcf245)
  • Production caller and regression boundary: The RPC handler passes projectRoot or requestedCwd as the explicit workspace; the updated test invokes sessions.create and asserts the resulting error rather than testing the formatter alone. (src/gateway/server-methods/sessions-create.ts:467, a04156c62312)
  • Discussion and supplied validation: The full body reports a live pre-fix spawn incident and red-on-base/green-on-head regression results; all three comments contain review status rather than additional behavioral evidence. (a04156c62312)
  • Exact-head CI remains pending: The aggregate CI gate is pending; dependency and sensitive-surface status checks pass, and the inspected check page establishes no diff-caused failure. (a04156c62312)
  • Feature history and local history limit: Feature history shows sustained worktree and session refactoring by Peter Steinberger and project-selection repairs by Shakker; following history reached an unavailable older object, so the original introduction is not established. (src/gateway/session-worktree-preparation.ts:685, b7c858fcf245)

Likely related people:

  • Shakker: Raw commit da65be6 adds src/gateway/session-worktree-preparation.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: da65be64a321; files: src/gateway/session-worktree-preparation.ts)

PR surface

Source +9, Tests 0. Total +9 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 11 2 +9
Tests 1 1 1 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 12 3 +9

Labels

Label changes:

  • add P3: This improves an advanced worktree caller's diagnostic without changing creation success, validation, or authorization.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This improves an advanced worktree caller's diagnostic without changing creation success, validation, or authorization.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:02 PM ET / 19:02 UTC.

@steipete
steipete merged commit 19753a7 into main Oct 20, 2026
203 of 207 checks passed
@steipete
steipete deleted the steipete/worktree-source-error branch October 20, 2026 19:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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