Skip to content

fix: project chats can't publish their checkout ("already has another source") - #195039

Merged
obviyus merged 5 commits into
mainfrom
fix/pr-adoption-project-sessions
Nov 8, 2026
Merged

obviyus merged 5 commits into
mainfrom
fix/pr-adoption-project-sessions

Conversation

@obviyus

@obviyus obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: publishing a PR from a project chat fails with "This conversation already has another source. Its files were preserved." when the agent publishes a committed checkout with github_publish and workspacePath.

User Impact

Project chats that work directly in their project's checkout, or in a linked worktree of it, can publish through the Gateway again. Previously, almost every Control UI chat started inside a project hit this refusal.

A project chat that tries to publish a checkout from a different repository gets a clear error instead. Nothing is created or moved.

Why This Change Was Made

#178756 added workspace adoption for sandboxed ordinary chats and refused any chat already tied to another source, including any projectId. #184531 extended adoption to local chats with an authorized task checkout, but projectId stayed on the refusal list. Neither PR's review discussed project chats.

This change lets a project chat adopt a local checkout only when that checkout belongs to the project's repository. Repository identity comes from git worktree list, so linked worktrees count as the same repository. This keeps the existing rule that a project chat's managed worktree comes from that project's repository, which worktree-workspace-migration.ts depends on. Without a local source (the sandbox path), project chats are still refused. The project must stay unchanged until the prepared worktree is committed.

The publisher itself is unchanged: credentials stay in the Gateway, the accepted commit and tree are pinned, the branch is updated with compare-and-swap, the push uses a lease, and requests are journaled for recovery.

Evidence

  • New cases in github-publication-session-access.test.ts:
    • project: a project chat publishes its main checkout.
    • foreign project: a project chat publishing another repository's checkout is refused with "different repository", with no worktree and no push or PR.
    • linked project worktree: a project chat publishes a linked worktree of its project. During publication, another chat switches that folder to a new branch and commits. The test asserts that the change landed, and that only the accepted commit was published.
  • On unmodified origin/main, all three project cases fail with the exact user-facing "another source" error. With this change, github-publication-session-access and session-pr-workspace-adoption pass 23/23 on the rebased head; format and lint are clean.
  • Production measurement on one Gateway (Jun 3 – Nov 8):
    • 7 "another source" refusals, all in openclaw project chats with no managed worktree.
    • 8 managed publications ever.
    • 134 shell gh pr create fallbacks across 49 chats.
  • Replay of the refusal decision against those 7 failed publishes: 5 checkout paths still exist, and all resolve to the registered project root. The fix admits all 5; the other 2 folders were deleted.
  • Not covered: a full typecheck, and live publication through a running Gateway from a project chat or a guest account.
  • server.sessions.create.workspace-policy.test.ts has 6 failures that are identical on unmodified origin/main.
  • Related: 2fa5c4160a2b already removed the readiness select_bound_session remedy, which also led agents to give up on unbound chats.

@clawsweeper

clawsweeper Bot commented Nov 8, 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: M labels Nov 8, 2026
@obviyus
obviyus enabled auto-merge (squash) November 8, 2026 05:46
@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. labels Nov 8, 2026
@obviyus
obviyus disabled auto-merge November 8, 2026 05:58
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR lets project chats publish local checkouts belonging to their project's repository.

Example: A chat for the project at /work/openclaw publishes a committed checkout at /work/openclaw-task.

  • Before: Publication stops with “This conversation already has another source.”
  • After: A linked checkout of the same repository can be adopted and published.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful, focused repair with a definite repository-comparison defect, a failed test-budget gate, and incomplete authority evidence for the changed path.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An agent in a project chat cannot publish its committed project checkout through github_publish.
Reason: The maintainer-authored direction restores a useful existing publication workflow without adding configuration, APIs, or another publication owner.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this maintainer-authored PR addresses a current publication failure, but its repository comparison rejects valid linked-worktree projects and its test growth fails the test-line gate.

Priority: P2
Reviewed head: 791e7d28c1fce6a1788ef464be1ff927875523e8

Before merge

  • Add real behavior proof - Authority-chain proof required: the added registered-RPC tests exercise real Git and binding with synthetic GitHub transport, while revocation scenarios use non-project sessions; demonstrate an allowed project-chat publication and rejection of the nearest unauthorized requester, including revocation before binding, push, and PR creation, through the real authority owners. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Normalize the project's repository identity before comparing roots (P2) - Registering /work/task, a linked worktree of /work/repo, stores /work/task as project.repoRoot because project registration uses git rev-parse --show-toplevel. Publishing that project's own checkout resolves repository.repoRoot to /work/repo because resolveRepositoryIdentity selects the primary worktree. This comparison therefore reports “different repository” for the project's own repository and leaves that supported project setup unable to publish. Resolve repository identity for the project path too, and cover a project registered from a linked worktree.
  • Account for the added regression-test lines (P2) - The introduced patch adds 63 net test lines without a config/test-lines-allocations record. The required baseline job explicitly reports test-lines failed, and the repository test-line ratchet requires consolidation or a justified allocation for this growth. Keep the distinct regression coverage and add the scoped allocation required by the existing budget contract, without raising the shared baseline.
  • Resolve security review attention item - No concrete authorization bypass was found, but the newly admitted project-session path needs final-effect authority verification.
  • Resolve merge risk - The newly admitted project-session path has not established that requester revocation remains effective through workspace binding, push, and PR creation.

Findings

  • [P2] Normalize the project's repository identity before comparing roots — src/gateway/session-pr-workspace-adoption.ts:170-180
  • [P2] Account for the added regression-test lines — src/gateway/github-publication-session-access.test.ts:76-79

Tests

  • Missing end-to-end proof: Supply project-chat publication evidence through the shipped handoff and final-effect authority checks for foreign and revoked requesters, with sensitive values redacted.
Agent review details

How this fits together

The Gateway receives a session publication request and checkout path, validates requester and workspace ownership, binds a managed worktree, and hands publication to the existing GitHub coordinator.

flowchart LR
  A[Project chat] --> B[Publication RPC]
  B --> C[Requester authority]
  C --> D[Workspace adoption]
  D --> E[Managed session worktree]
  E --> F[GitHub publication coordinator]
  F --> G[Push and pull request]
Loading

Technical review

Best possible solution:

Compare both checkouts through the existing repository identity resolver while retaining the existing adoption, binding, and publication owners.

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

Current-main source deterministically rejects an otherwise eligible project session because projectId alone triggers the competing-source refusal; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Extending the existing adoption owner is appropriate, but repository identity must be normalized on both sides rather than comparing a primary checkout with a recorded project checkout path.

Full review comments:

  • [P2] Normalize the project's repository identity before comparing roots — src/gateway/session-pr-workspace-adoption.ts:170-180
    Registering /work/task, a linked worktree of /work/repo, stores /work/task as project.repoRoot because project registration uses git rev-parse --show-toplevel. Publishing that project's own checkout resolves repository.repoRoot to /work/repo because resolveRepositoryIdentity selects the primary worktree. This comparison therefore reports “different repository” for the project's own repository and leaves that supported project setup unable to publish. Resolve repository identity for the project path too, and cover a project registered from a linked worktree.
    Confidence: 0.98
  • [P2] Account for the added regression-test lines — src/gateway/github-publication-session-access.test.ts:76-79
    The introduced patch adds 63 net test lines without a config/test-lines-allocations record. The required baseline job explicitly reports test-lines failed, and the repository test-line ratchet requires consolidation or a justified allocation for this growth. Keep the distinct regression coverage and add the scoped allocation required by the existing budget contract, without raising the shared baseline.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify project-session authority before merging (recommended)
    The PR owner should demonstrate allowed publication and rejection of a foreign or revoked requester before binding and final GitHub effects.

Provenance checked

  • Project-source refusal and workspace binding changes intended behavior with a stated reason (c1658c0: Ordinary-chat PR preparation preserved existing sources and refused competing sources; the PR explains why an admitted local checkout from the project's own repository is compatible with that invariant.)
  • Local checkout publication and regression suite keeps the original intent (01689fd: Allow authorized local task checkouts to publish through existing binding and publication owners while preserving source files, preferences, and live requester authority.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but the newly admitted project-session path needs final-effect authority verification.

Evidence

What I checked:

PR surface

Source +23, Tests +63. Total +86 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 25 2 +23
Tests 1 234 171 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 259 173 +86

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +23 net lines; tests +63 net lines The focused production change reuses existing owners, and the added cases cover distinct project, foreign-repository, and linked-worktree behavior.

Labels

Label changes:

  • add P2: Project-chat publication is broken, with a limited affected workflow and an existing shell publication workaround.
  • add merge-risk: 🚨 security-boundary: The patch admits project sessions to workspace binding and credentialed publication that previously rejected them; final-effect authority evidence for that path remains incomplete.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Project-chat publication is broken, with a limited affected workflow and an existing shell publication workaround.
  • merge-risk: 🚨 security-boundary: The patch admits project sessions to workspace binding and credentialed publication that previously rejected them; final-effect authority evidence for that path remains incomplete.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 November 8, 2026, 12:58 AM ET / 05:58 UTC.

obviyus and others added 5 commits November 8, 2026 11:38
Project chats that work directly in the project checkout were refused by PR
workspace adoption with "This conversation already has another source",
because any projectId counted as a competing source. #184531 let local chats
publish an authorized task checkout but left project chats out.

Allow a project chat to adopt a local checkout only when that checkout belongs
to the project's repository, so a project chat with a worktree still means the
worktree comes from that project's repository. Without a local source (the
sandbox path), project chats are still refused, and the project must stay
unchanged until the worktree is saved.

Co-authored-by: obviyus <[email protected]>
CI runners have no global Git identity, so the plain git commits in the new
project-chat cases failed there. Use the same fixed identity and isolated config
as the publication fixture.

Co-authored-by: obviyus <[email protected]>
Keeps the new project-chat cases within the test-lines ratchet.

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus force-pushed the fix/pr-adoption-project-sessions branch from 25abfd8 to 279f117 Compare November 8, 2026 06:10
@obviyus
obviyus merged commit f4976c9 into main Nov 8, 2026
107 checks passed
@obviyus
obviyus deleted the fix/pr-adoption-project-sessions branch November 8, 2026 06:23
@obviyus

obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
… source") (openclaw#195039)

* fix: let project chats publish their local checkout

Project chats that work directly in the project checkout were refused by PR
workspace adoption with "This conversation already has another source",
because any projectId counted as a competing source. openclaw#184531 let local chats
publish an authorized task checkout but left project chats out.

Allow a project chat to adopt a local checkout only when that checkout belongs
to the project's repository, so a project chat with a worktree still means the
worktree comes from that project's repository. Without a local source (the
sandbox path), project chats are still refused, and the project must stay
unchanged until the worktree is saved.

Co-authored-by: obviyus <[email protected]>

* test: give project publication fixtures a git identity

CI runners have no global Git identity, so the plain git commits in the new
project-chat cases failed there. Use the same fixed identity and isolated config
as the publication fixture.

Co-authored-by: obviyus <[email protected]>

* fix: explain a removed project instead of a repository mismatch

Co-authored-by: obviyus <[email protected]>

* test: reuse the publication fixture's git for project cases

Keeps the new project-chat cases within the test-lines ratchet.

Co-authored-by: obviyus <[email protected]>

* test: fold the project outcome condition

Co-authored-by: obviyus <[email protected]>

---------

Co-authored-by: obviyus <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
… source") (openclaw#195039)

Backport the bounded runtime fix for LOCAL11.8; preserve unrelated baseline behavior.

(cherry picked from commit f4976c9)

Co-authored-by: obviyus <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c3253039580ec385a8b432286b82822b956089de)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant