Repository navigation
feat: prepare existing PRs from ordinary chats - #178756
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 real behavior proof before merge. What this changesThis PR lets an ordinary sandboxed chat adopt an existing PR into a new managed workspace and resume in the same conversation. Example: A guest shares their own PR URL after creating notes.md in an ordinary chat.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep this maintainer-authored PR open: it adds useful continuation behavior, but historical-file selection has a correctness defect. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe agent tool yields its turn to Gateway workspace admission, which allocates and binds a managed checkout, imports verified PR source, and resumes the conversation; file readers use persisted message identity to select earlier files. flowchart LR
A[Conversation agent] --> B[Yielded tool handoff]
B --> C[Gateway requester authority]
C --> D[Managed workspace owner]
D --> E[Verified PR source]
D --> F[Session workspace binding]
F --> G[Current and historical file reads]
F --> H[Same conversation resume]
Technical reviewBest possible solution: Reuse the existing adoption owners while preserving historical-source identity through transcript rewrites and refusing ambiguous selection instead of silently opening current files. Do we have a high-confidence way to reproduce the issue? The pinned prerequisite rejects unbound sandbox preparation before import; source also establishes the introduced generation-mismatch fallback, without executing target code. Is this the best way to solve the issue? Reusing allocation, binding, yielding, and file-authority owners is appropriate, but a mutable transcript cursor generation cannot safely serve as the sole durable historical-source boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 765ae71d6a68. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Deferred caller authority and persisted historical-source access still need final-effect authorization evidence. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +562, Tests +548, Docs +39. Total +1149 across 37 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed October 20, 2026, 4:45 PM ET / 20:45 UTC. |
e844170 to
281af0a
Compare
caa6bcd to
8af4aba
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
f6be118 to
4ec70bc
Compare
…ged preparation test
4ec70bc to
07a9be6
Compare
|
Added: an ordinary sandboxed conversation can now continue its author's own PR in a new managed workspace while earlier file links keep opening the original files read-only. |
|
Follow-up: #180109 fixes the remaining The synthetic regression covers successful and failed reload responses, revocation, cancellation, session replacement, and system/non-owner callers. It exercises real dispatch/admission and guarded plugin-tool execution, with a fixture model runner and reload RPC response; it does not claim actual plugin replacement or live Records proof. |
An ordinary sandboxed conversation can now continue its author's existing PR: prepare_pr yields the turn, adopts a new managed workspace bound to the PR head, and resumes in the same conversation. Files from before the transition stay in their original source, and earlier message links, including tool-row file links, open them read-only. Code Mode agents reach the yielding call directly, the resume runs under its own authority, and an undelivered result leaves a visible notice. prepare_pr stays hidden from sessions that run directly on the host.
What Problem This Solves
A sandboxed conversation that starts without a project can inspect its author's existing PR, but
github_publishprepare_prrequires a managed workspace to be bound already. A natural continuation request, where the PR link arrives after the conversation has started, therefore fails: the registered preparation action rejects the unbound conversation with "Run prepare_pr from this conversation's sandboxed agent in a managed workspace." before importing the PR.User Impact
The same conversation can now prepare the PR in a new session-owned workspace and keep working. Files from before the transition stay in their original source, earlier message links, including Read, Edit and Write tool-row file links, open them read-only (previews, downloads and relative HTML assets), and sibling conversations keep their workspaces. Current PR files remain editable through the existing Files source precondition; an editor opened before the transition cannot overwrite a same-named current file, even with identical bytes.
Adoption waits for a clear current-session boundary. Queued or preparing input, background commands and unobserved results, pending children, and terminals cause a visible refusal without draining or cancelling that work. Existing managed preparation and plugin reload keep their behavior. This extends preparation only: the original PR identity check, verified linked author, publisher eligibility and guest restrictions stay with their existing owners, and nothing here publishes, merges or creates a replacement PR.
Why This Change Was Made
Changing the active turn's directory in place would leave tools and pending work associated with the previous source. Preparation therefore yields the requesting turn, waits for its cleanup, uses the existing managed-workspace allocation and binding operations, and resumes through the existing session-event path. The plugin-reload handoff becomes the shared session tool handoff for both callers. GitHub eligibility and live authority are checked again around binding and import, and an uncertain commit result preserves an already-accepted checkout for retry.
The handoff's background work and its resume start from a context-free async root, so neither carries the yielded turn's retired tool receipt or aborted run signal; plugin reload, which shares this handoff, gets the same behavior. While preparation would yield,
github_publishis a direct-only tool, assessions_yieldis, so agents that call tools through Code Modeexecstill reach it as a direct call: a yield cannot finish from inside an exec. If the resumed result cannot be delivered, the conversation receives one assistant message naming the reason, the result and the next step instead of staying silent.One private session relation records the original admitted file source and the persisted-message boundary. Rendered markdown links and tool-row file links both pass their message identity, and existing preview, download and HTML-asset routes use it to read the original files under current access checks; those responses carry no editable hash or current managed-source descriptor. Canonical persistent and incognito transcript rewrites carry the relation forward using surviving message identities and their committed positions. Removing the original boundary message preserves earlier surviving links, and an unresolved relation refuses access instead of falling back to the current source. The relation follows the existing reset/detach lifecycle, is omitted from public and plugin session projections, and lives in the existing session entry; the storage note in
docs/reference/database-schemas/storage-changes.mddescribes it. There is no schema change.prepare_prstays behind the shared visibility rule from #179725 (canPrepareGitHubPullRequest), which now also admits an enabled, writable, unbound sandbox on the local Docker or Podman backend, the only source adoption supports. Sessions that run directly on the host, or in a remote sandbox, never seeprepare_pror its adoption text.Two supporting corrections keep repository checks honest about the new code:
scripts/database-worker-inventory.mjsclassifies that operation by its callers instead of counting it as main-thread SQL.scripts/pr-lib/wrapper-components.txt) lists the new runtime importsession-prior-workspace-boundary.ts.preparePullRequestSession). Adoption compares the original file selection, which includes selected skill libraries, against the full entry at binding; reading it without the snapshot made every conversation that had already run a turn fail with "Session workspace changed during file access".It builds on the PR preparation, actions and refresh work in #178233, #178281 and #178298, which have landed. The general Files source descriptor and reopen recovery come from #178336; this diff adds adoption-specific enforcement and historical-source reads.
Evidence
Before the change
On the base, the decisive handoff test fails all three cases (prepared, failed and stopped). An ordinary sandboxed conversation's
prepare_prreaches the registeredsessions.github.actionendpoint directly from the active turn, without yielding or carrying the adoption identity, and that action then refuses the unbound conversation.Behavior proof
src/gateway/session-pr-workspace-adoption.test.tsruns the real path with real Git, persistence and file effects and synthetic GitHub and container I/O. It covers a yielded handoff that adopts one empty owner, actual managed allocation and the SQLite binding, and original message files kept separate from same-named current files across previews, downloads, relative assets, and stale or fresh saves. It also covers sibling conversations keeping their source.src/agents/tools/github-publish-tool.handoff.test.tscovers the yield, the retained operator identity, and Stop and failure results through the in-process Gateway.chat-message.forwarded-attribution.test.tschecks that a tool-row file link in a persisted message opens with that message identity, in a plain group and in a run frame; it fails without the change. All three pass on this head. The sandboxed scenario ran on a Linux box with Docker.Remote validation on this head
The checks ran through the repository's remote test recipe with literal file selection:
Three related files fail with the same tests and assertions when run alone on the base without this change, so they are not caused by it:
src/gateway/server.incognito-transcript-reconcile.test.tsfails at Gateway startup because its fixture still writesagents.defaults.heartbeat, which feat(automations): migrate heartbeat jobs through Doctor #179387 removed from the schema.src/gateway/server.sessions.delete-lifecycle.test.tsfails "sessions.delete returns unavailable when active run does not stop".ui/src/pages/chat/components/chat-message-attachment-admission.test.tsfails "admits paste through viewport (grouped=false)".The two checks that failed on the previous head (
checks-fast-baseline-ratchetsandchecks-node-compact-small-2) were caused by this PR. The full transcript replacement added a SQLite read that the worker ratchet counted as main-thread SQL, and the PR wrapper inventory missed the new boundary module. Both are corrected above and pass remotely. The landed preparation test that expected an unbound sandbox to dispatch directly now keeps only its managed-workspace case, because the unbound case yields and is owned by the handoff test.Integrated handoff and Code Mode proof
A live check on a guest lab against the previous head found a silent failure: the guest's agent called
prepare_prinside Code Modeexec, the yield aborted that exec, and the resume then failed with "agent tool caller authority is no longer active" because it ran inside the yielded turn's caller context.github-publish-tool.handoff.test.tsnow runs the tool through the real Code Mode surface with a production-shaped caller (turn receipt and run abort signal) and checks the resume context and a failed-resume notice:Lint, types and 11 related files (160 tests) pass on the corrected tree, covering the PR preparation, refresh, adoption, plugin reload and Code Mode lifecycle tests.
A second live run on the corrected head confirmed the direct call and the visible resume, and found that adoption still failed with "Session workspace changed during file access".
session-pr-workspace-adoption.test.tsnow also drives the registeredprepare_prhandler's adopting branch with the real session read, allocation, binding, file-source checks and PR association write, then reads the earlier message's file (original bytes, no edit hash). Only GitHub I/O and the container runtime are synthetic. Without the skills-snapshot read it fails with the lab's error; with it, it passes.Live check on a guest lab
A guest with a linked GitHub account, in an ordinary sandboxed chat created without a worktree, wrote and linked
notes.md, then asked to continue their own PR.github_publishyielded withstarted; the conversation resumed withpreparedat the fork's head commit and listed the PR's changed files. The session was bound to the PR in a new managed workspace with the private original-source relation. Both earlier message ids opened the originalnotes.mdwithout an edit hash or source descriptor, the current PR workspace returned its own files with a hash and source, and the public session read omitted the relation. Later commits change only the visibility rule and tool text.Remaining
Hosted CI on this head and review of the visibility change are pending. On the rebased head, lint, every baseline ratchet, docs and types pass, and the 219 related files pass except two unrelated tests that fail the same way on the base (
server.sessions.delete-lifecycle.test.ts,chat-message-attachment-admission.test.ts) andchat-html-file.browser.test.ts, which passes alone on this head.