Skip to content

feat: give tasks durable project-optional workspaces - #15749

Merged
cryppadotta merged 79 commits into
masterfrom
codex/task-workspace-ownership
Oct 13, 2026
Merged

cryppadotta merged 79 commits into
masterfrom
codex/task-workspace-ownership

Conversation

@cryppadotta

@cryppadotta cryppadotta commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Thinking Path

  • Paperclip is the open source app people use to manage AI agents for work.
  • Tasks can start in the app or through chat channels.
  • A task may need files without belonging to a project.
  • The previous fallback could reuse a large agent directory and copy unrelated files into each run.
  • This pull request gives each task a durable workspace choice and keeps its project assignment separate.
  • The harness prepares folders and repositories, while agents submit typed intent.
  • Tasks keep their files across reassignment and resume, with less repeated file transfer.

Linked Issues or Issue Description

Subsystem affected

Cross-cutting: task admission, execution workspaces, runner tools, native file persistence, chat settings, and database contracts.

Problem or motivation

Projectless tasks can inherit an agent fallback directory. A short task can then spend minutes copying unrelated files. Project assignment also does not clearly express which folder or repository a task should use.

Proposed solution

Keep one durable execution-workspace binding per task. Create a stable company/task directory when no source is configured. Resolve app and channel choices through the same domain service. Let agents inspect and select authorized workspaces and request contained repositories. Apply changes at the next safe admission. Reuse verified input seeds and transfer changed output contents.

Alternatives considered

A separate binding and realization subsystem would duplicate existing workspace and recovery ownership. The chosen design extends the existing workspace aggregate. Recovery delta chains are deferred; changed input generations still use full seeds.

Roadmap alignment

This extends existing workspace, sandbox, artifact, and experimental chat support. The maintainer requested this work and one PR for the full change. Related work: #10856, #9231, and #15662. These cover adjacent workspace and transfer behavior; this PR adds the cross-layer task ownership contract.

What Changed

  • Add durable task workspace intent, revisions, pending changes, and company-scoped repository inventory.
  • Advance the task revision when accepting a pending choice. Reject superseded retries while preserving current-request idempotency and immutable active run inputs.
  • Keep source authorization separate from task project organization. Preserve explicit shared folders and immutable admitted roots.
  • Add optional connection and destination defaults with inheritance and explicit clearing.
  • Add workspace inspection, discovery, selection, and repository preparation tools to the runner contract.
  • Add projectless workspace navigation and settings controls.
  • Add sparse output checkpoints, verified seed reuse, nested repository persistence, and accurate finalization timing.
  • Reject incoherent returned checkpoint trees before any host mutation.
  • Support native and legacy Honeycomb root spans in the run query link.
  • Share configured-default, primary, creation-time and ID precedence between task creation, bulk creation and controller provisioning. Preserve existing creation validation, explicit choices and saved denial markers.
  • Make explicit isolated-source choices copy-only for controller provisioning, including standard local tasks and reopened workspaces. Suppress configured and built-in controller provision scripts for selected sandbox and SSH runs. Retain implicit trusted local defaults and the existing SSH remote provision path.
  • Batch bounded deleted-file commands after checking every parent path. Preserve NUL-delimited names, option protection, and rejection of unsafe ancestors.
  • Add regression tests and a layer-by-layer architecture and rollout plan in doc/plans/2026-10-09-task-workspaces.md.
  • Integrate current master and generate task migration 0336 after upstream migration 0335. Preserve data when replaying after earlier development migration numbers.
  • Add migration 0337 for durable physical-directory acquisition policy. Serialize anonymous admission with managed repository requests and credential promotion. Reject pending private clones as well as existing publications.
  • Preserve ordinary empty-inventory admission and immutable recovery without new repository acquisition. Reject new controller clones for low-trust tasks even in full-auto mode; verified public checkout reuse performs no fetching.
  • Accept eligible idle workspace repository requests and preserve destination execution defaults through Telegram group migration.
  • Verify Git checkout and metadata identities. Retain storage ownership after the original checkout disappears, and anchor worktree creation to the verified source.
  • Enforce physical-source privacy across overlapping folders and URI-only local sources. Retain configured owners before detachment and copy permissions before staging, including sibling repositories and closed-worktree reopening.
  • Reject writable folder aliases whose current or retained source trust is incompatible with the selected execution policy. Treat missing policy on an admitted run as standard; live edits cannot relabel local execution as sandboxed.
  • Recognize separately stored primary Git checkouts by Git directory identity, avoiding repeated unrelated-folder probes while preserving unresolved linked-worktree owner discovery.
  • Document checkpoint counts, restore timing, and terminal owner settlement in the canonical run-log guide.
  • Validate compatible child workspace choices before saving the child, using server-owned context and authoritative creator run/parent lineage.
  • Check physical source trust before copy/provision and defer new isolation proof until all access checks pass. Explicitly skip configured and built-in host provisioning for low-trust sandbox worktree creation, reuse, and rebuild.

Verification

  • Fresh exact-head merge gates: all 55 checks succeeded, with four optional skips, on 753680b61c3fc51f7970fc0074f79e97d65fd9fc. Full CI, ci / verify, ci / e2e, Superagent and legacy Snyk passed. Greptile Apex completed at 5/5 on this same commit, with no unresolved review findings. Historical failed attempts and live acceptance qualifications remain recorded below.
  • Current head 753680b — canonical-default repair: full repository pnpm -r typecheck and pnpm build pass on frozen source. Three complete suites pass 69 cases with zero skips: source trust 21, controller classification 9, reopen 39. Four existing task-default cases and the complete six-case import suite pass another 10 cases; 134 unrelated issue cases were intentionally filtered. Four real configured/built-in hook baselines failed before the fix. The first complete 69-case run passed 67 and failed two stale nondefault fixtures; correcting their primary flags preserves their strict no-marker assertions, and the final complete run passes. No deadlines were changed.
  • Preceding ea970 CI/security: CI run 38330322424 passed full CI and E2E on its second attempt. Its first attempt failed an HTTP/2 child startup with loopback EADDRINUSE before the security assertion; one evidence-based transient retry was used. Superagent and legacy checks passed. Apex completed at 4/5 with the default-source mismatch repaired here. Those results do not satisfy this new head’s merge gate.
  • Retained ea970f4 source proof: full repository pnpm -r typecheck and pnpm build pass on frozen production source. All 565 distinct affected cases pass across completed suites: runtime/preparation/classification/session/environment 441, source trust 17, reopening 39, project/source privacy 47, child trust 13 and persistence eight. These include standard local and sandbox marker denial, no/partial/full assignment grants, fresh/reused/rebuilt workspaces, metadata replacement and selection clearing, default local provisioning, and private-file revocation after both skipped and failed provisioning. Source comments, code size, maps and catalog checks pass. Fresh exact-head gates for the current commit passed as reported above; this older source proof remains separate.
  • Retained repair attempts: the first seven-file batch remains failed at four failures/454 passes; four reconstruction fixtures lacked a repository origin, so the existing reconstruction guard rejected them. The complete corrected 17-case source suite passes with real origins. Initial lineage attempts and the 47-case attempt remain failed: their provision-failure case was first an explicit copy-only source, then lacked protected-project membership/assignment setup and the implicit isolation flag. The final fixture keeps all copy/privacy assertions, tests a valid implicit default failure, and adds a separate explicit script-suppression case. The complete final project suite passes 47/47; the focused diagnostic intentionally excluded 46 other cases and is not additional coverage. No deadlines or production authorization guards were weakened.
  • Previous head 474aed9: full CI and Apex 5/5 passed, but Superagent found the read-only source/controller provisioning issue repaired here. Its earlier 284 focused cases, full typecheck/build and disposable migration proofs remain qualified historical evidence. They do not count toward the new head’s merge gate.
  • Latest review repairs: accepting each pending choice atomically advances its CAS revision; A/B/retry-A regressions reject the superseded request before and after admission while preserving the live root and immutable run input. Writable physical aliases must match current and retained source trust. An existing run with no saved policy stays standard after live edits. Real heartbeat cases deny current and relocated-source aliases before adapter dispatch, retain read-only authorization, and preserve compatible sandbox runs.
  • Host provisioning: protected read-only configured sources reproduced configured and built-in controller scripts on both standard local and sandbox runs. Source assignment/write grants are not controller-execution approval. Actual sandbox and SSH selections now suppress controller provisioning; explicit, inherited, channel, foreign and nondefault source choices remain copy-only even on local runs. A deny-only workspace marker survives metadata replacement, selection clearing, reuse, rebuild and reopen. Host runtime-provision command discovery follows the same decision, including built-in fallback. Implicit trusted local defaults and taskless operator runs with no source retain their existing contract; SSH keeps its explicit remote command path. This change does not add sandbox provisioning transport. Earlier, a properly registered low-trust sandbox worktree reproduced host execution of its built-in provision script before adapter dispatch. The final heartbeat regression proves the host marker stays absent and the adapter still selects the sandbox. Two real-shell runtime cases cover configured and built-in scripts through fresh creation, realization reuse, persisted reuse, missing-folder rebuild, and ordinary trusted provisioning. The explicit server-selected capability suppresses both script resolution paths. Early copy checks also validate retained readers and create new isolation proof only after all physical, ACL and trust checks succeed. Primary-folder timing controls have narrower scope; they are not proof of every worktree path.
  • Run-log guide: documents checkpoint payload counts and null fallback values, restore timing without a success implication, and wall time through terminal owner settlement. These remain local run-log records.
  • Preserved earlier attempts: the preceding 386710 combined run passed 436/437 with one HTTP socket abort; its unchanged complete heartbeat retry passed 46/46. Intermediate trust and provisioning failures, including the real host marker baseline and fixture corrections, remain separate failed-attempt evidence. The final complete suites above ran on frozen repaired source; older attempts are not recast as passes.
  • Current contributor rules: source identity helpers now have a separate module. At that extraction, all 32 original declarations had equivalent parsed structure, including the eight moved helpers. The later child-creation fix adds validation to the trust guard. Split policy suites preserve test definitions and per-file isolation. Added explanatory source comments were removed with parsed-structure equality checks. Required Vitest environment directives and generated SQL separators remain. Parsed program equality does not prove that machine-read annotations have no effect. No code file crosses the 1,000-line threshold.
  • Storybook source review: reviewed affected production and fixture dependencies, preserved upstream feature folders and stable story IDs, and repaired GitHub defaults persistence and chat workspace-choice fixtures. Catalog checks, fixture cases, token gates and map checks pass. The later safety-recipe pass reviewed twelve workspace-dependent entries, retained their classifications and all 2,210 IDs, and updated only reviewed fingerprints and coverage notes. This is source reconciliation; no new Storybook browser, render, play or production Storybook build evidence is claimed.
  • Latest Apex repairs: effective low-trust reopening suppresses configured and built-in host scripts without relying on a future driver. Real marker tests cover task, agent, organizational and source restrictions, projectless/cross-project and same-source worktrees, plus trusted controls. Returned checkpoints require every nested entry’s parent to be a directory in the same returned snapshot before host writes, including unchanged files. A real disk-backed baseline lost a retained nested file; the repaired validator rejects it and preserves recovery evidence. Memory/disk, missing/file/symlink parents and coherent file-to-directory transitions pass. Native trace links select both native and legacy roots while retaining exact run-hash/service filters; no live Honeycomb query was executed. SQL cleanup removes only the three prose headers; statements, snapshots, journal and generated separators are unchanged.
  • Retained failed attempts: the pre-fix reopen marker baseline failed ten restricted cases while its two trusted controls passed. A first test cleanup missed newly inserted agent rows; cleanup was corrected. The invalid-checkpoint baseline failed after host data loss, and the query baseline passed hashing but failed native-root matching. The first migration-proof command could not find root tsx; the installed CLI runtime then passed the isolated disposable proof. These failures remain separate from the final passing results.
  • Preceding 17c9 verification: the child-creation repair passed 331 affected cases and full typecheck/build. Its exact-head full CI, E2E, security and legacy checks all passed, with four optional skips. Apex then completed at 2/5 with the four findings repaired here. None of that head’s checks or score count toward this head’s merge gate.
  • Child creation: a real database regression reproduced rejection of a compatible explicit workspace before the child was saved. The server now passes an internal prospective-task context, verifies the saved creator run and sponsor, and follows a bounded company-scoped parent chain. Current parent, child agent/project/policy and physical source policies must retain the saved boundary. Compatible direct and descendant children work without repeating policy in the client. Forged identities, unrelated parents, policy drift and arbitrary issue-less selection fail. An authenticated HTTP regression returns 201 for the allowed child and 403 for an unrelated parent. Existing task/run identity checks remain exact.
  • Preceding CI: bc6e216 passed all 55 successful checks, with four optional skips and a cancelled neutral review check. Both ci / verify and ci / e2e passed. The Greptile summary then reported 4/5 and the child-creation finding repaired here. Those checks do not satisfy this new head’s merge gate.
  • CI DOM repair: on 3452c67, the workspace/UI shard passed 4,473 cases and failed three chat-default DOM cases with document is not defined. Prose cleanup had removed their required Vitest environment annotation. Restoring that test-runner directive passes all three cases with the ordinary project configuration, without a command-line environment override. The failure remains recorded; no transient rerun was used.
  • Separate Git storage: authorize the actual shared Git directory and verified primary checkout owners. Metadata parents and unrelated sibling folders are not sources. A company-scoped fallback discovers separate primary checkouts; ordinary and registered layouts do not probe unrelated history. Capture retains authorized storage ownership after configuration and physical checkout removal, without creating isolation proofs. Real worktree realization uses the correct source bytes and SHA even when metadata lives inside another Git repository. The earlier complete 132-case trust and 179-case runtime suites passed at the qualified prior source snapshots; the current runtime suite includes all 181 cases.
  • Worktree compatibility: actual Git registration and common-source identity recover missing isolation proof after an upgrade or interrupted creation. Tests preserve HEAD, dirty edits and untracked work. Ordinary occupied folders, unrelated Git owners and unmaterialized copy intents still require source write authority.
  • Copy privacy: real Git/database/API regressions cover private sibling sources added after binding, existing and occupied copies, local file URLs and absolute paths, bare Git sources, URI-only private configured owners before first admission, source removal during staging, and permission revocation. Source permissions are retained before bytes are copied and rechecked before publication or adoption. File preview/download denies after configuration removal and grant revocation. Ordinary clones never create a worktree-isolation proof.
  • Reopening: local managed-base preparation and durable copy ownership occur outside the lifecycle transaction. Inside the lifecycle lock, read-only checks verify unchanged source/target identities without reversing the root-lock order. Tests cover concurrent duplicate reopen, denial before cloning, successful rebuild, and provision exit 42 retaining private output protections. Run/sponsor spoofing is rejected using authoritative database identity.
  • Retained unchanged-scope checks: on the preceding 3572d87 repair, 142 deletion/confinement/streaming cases, 70 chat/default cases, 26 migration cases and the two timeout reproductions passed. The Git-identity repair does not change those implementations; these results are retained evidence, not a new full-suite invocation.
  • Earlier feature validation: 42 Runner build-cache/build-script cases, 19 cleanup/native-resumption cases and 26 migration safety/snapshot checks passed. Disposable database proofs cover the complete migration chain, repeated replay and old development journals. Feature migrations 0336–0338 preserve upstream migrations through 0335, all upstream snapshots, and the journal prefix. The final copy repairs reuse existing text kinds; the master integration regenerates the same feature SQL under new migration numbers. Existing coverage also exercises low-trust clone denial, idle repository requests, Telegram defaults, sparse checkpoint capacity fallback, confined full export and retained root privacy.
  • CI evidence: the preceding 18a133a passed 54 checks with four optional skips, but a later local counterexample required correcting premature isolation proof. At 4c220a0, four jobs failed with explicit synchronized runner shutdowns and no test/type errors; their logs remain available in that CI run. Apex on 4c220a0 found the two issues fixed by this repair. Neither prior-head checks nor scores count toward the merge gate.
  • Deletion timeout repair: a fresh macOS streaming run timed out at the existing 300-second limit while deleting 40,000 files. The repair validates all paths in each bounded 64-entry batch before one delete command. Three new real-command cases and 138 existing confinement cases pass. The original four-lane streaming test passes in 288.19 seconds with the same data, assertions and deadline. This result is close to the local time limit; it is not a broad performance-margin claim.
  • Earlier Apex corrections: the actual Git source is selected before local authorization, preserving remote HTTPS fallback for missing configured folders. All 22 managed-clone cases and six existing privacy controls pass. Post-provision source revocation clears only the successful reopen’s pending generation; the full 13-case reopen suite proves dirty files stay protected and can be archived. Full repository typecheck/build pass after both corrections.
  • Full local suite: the pre-repair pnpm test:run attempt completed with 22 failures, 18,170 passes and 105 skips. Nineteen failures use feature tests added after that process started; their later frozen-source suites pass. No per-module source hash was captured, so the old failed result remains separate evidence. Fresh maximum-script audit and primary-agent reproductions pass their unchanged deadlines. The remaining macOS Git streaming timeout reproduced in per-file deletion; its repair and fresh result are reported above. This older invocation is not a clean final-head proof. Exact-head full CI must pass before merge.
  • Live acceptance at earlier commits: native local and Daytona passes 12/12 in both cells on 0c96230; legacy local passes 12/12 on 9b12a2e. Each covers three turns, controller restart, stable projectless files, idempotent repository preparation, commits plus dirty edits, exact artifacts, screenshots and cleanup. Later edge-case repairs use focused regressions and CI; these campaigns are not fresh evidence for the current head.
  • The local browser test-drive verified project assignment/removal, controller restart and exact continuation with the same workspace ID/root. A separate native local continuation hit the existing Codex OAuth unpriced-usage budget gate; that gate remains enabled.

Risks

  • Copy-only sources that previously depended on controller provisioning now skip those hooks. Sandbox workspace staging has no new automatic remote provision or runtime-provision transport; provider setup must use its existing runtime tools. Runtime service execution retains its existing contract.

  • Child workspace choices from admitted agents must have a verified parent chain within the existing 12-level low-trust ancestry limit. Missing or changed lineage and conflicting policies reject creation.

  • Existing writable aliases that combine incompatible source trust now fail before admission or publication. Choose a workspace compatible with the task's containment policy; ordinary file reads retain their existing authorization rules.

  • Low-trust tasks cannot start new controller-backed repository acquisition, including in full-auto mode. They may reuse verified existing public checkouts without fetching. Trusted acquisition still requires a provider decision in restrictive modes; trusted full-auto acquisition currently has no cumulative disk quota.

  • Anonymous and managed acquisition policies are permanent for a physical directory within a company. A different policy requires a different directory. Workspace relocation or deletion does not release the reservation. An existing checkout at a company-managed receipt identity also requires a fresh anonymous root, even when that checkout may contain public bytes; writable ownership markers cannot prove an exception.

  • Migration and native descriptor v3 require compatible controllers before new admissions. Rollback must retain recovery state and route admitted work to compatible controllers.

  • Workspace source permissions must remain effective after task reassignment. Tests cover retained privacy and concurrent binding.

  • Explicit shared folders can still have external writers. Final host scans remain required.

  • Changed input generations still pay for full seed creation and verification. Cache publication is capped at 16 generations/1GiB per workspace and 256 generations/256 workspace directories/8GiB per company. Saturation uses per-run seeds; cache repair and eviction are deferred to preserve existing reader and recovery references.

  • The local two-turn Codex journey is qualified. All three runtime paths passed their acceptance journeys at the commits listed above; later edge-case fixes use separate regression coverage. Current-head CI is reported above; a clean full local suite result is not claimed.

Model Used

OpenAI Codex, based on GPT-6, with code execution, repository tools, and coordinated agents. The session does not expose an exact serving-model identifier or context-window size. All architecture workers used the inherited model.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: # / Closes # / Refs # OR (b) described the issue in-PR following the relevant issue template
  • I have not referenced internal/instance-local Paperclip issues or links (only public GitHub #NNN / github.com/paperclipai/paperclip URLs)
  • My branch name describes the change (e.g. docs/..., fix/...) and contains no internal Paperclip ticket id or instance-derived details
  • I have run tests locally and they pass (focused suites; full local-suite limits documented above)
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • All Paperclip CI gates are green (753680b; full CI and E2E passed)
  • Greptile Apex is 5/5 with no open findings (753680b; completed exact-head review)
  • I will address all Greptile and reviewer comments before requesting merge

@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptileai review

Please review the full task workspace ownership change, including authorization retention, admission transitions, repository preparation, migration replay, and native persistence. The maintainer requested a single PR for this cross-layer change. Live local and Daytona verification is in progress.

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Critical impact] This head appears safe to merge; no blocking code issue was found.

Summary

Adds durable task workspaces independent of project assignment, with channel defaults, authorized repository preparation, and sparse file recovery.

  • Tasks keep a durable workspace choice apart from their project.
  • Agents can inspect and request workspaces and contained repositories.
  • Sandbox runs reuse verified workspace seeds and save sparse file checkpoints.
  • Chat connections can set project and workspace defaults for new tasks.
  • Workspace pages show task workspaces even when they have no project.
  • Workspace preparation checks source trust before copying or running host setup.

Reviews (52) · Last reviewed commit: "fix: share canonical project workspace d..." · Reviewed by Greptile

Comment thread server/src/services/heartbeat.ts Resolved
@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptileai review

Please review the updated source at d7ff016. The null source-project fallback is fixed, with a two-admission chat regression. Workspace discovery and selection now share one lifecycle predicate, tested through the native tool/API/database path. Persisted default workspace mode is normalized in session fingerprints; the actual Slack fresh-to-resume regression passes.

The private-file finding is already prevented transactionally by migration 0313: issues_record_workspace_privacy_source runs AFTER INSERT OR UPDATE OF execution_workspace_id and updates the workspace row, whose trigger retains prior _issuePrivacySources and adds current bindings. New migrated-database regressions exercise both issue creation and pending selection, detach a private writer, and verify unrelated readers remain denied. They pass. The binding helper is not the sole provenance writer.

The local UI-created projectless task has completed and its exact file bytes were independently verified. The three-cell legacy local/native local/native Daytona campaign is running at https://github.com/paperclipai/paperclip/actions/runs/37997836442. Full CI and remaining fixture repairs are still in progress; this remains a draft.

@cryppadotta
cryppadotta force-pushed the codex/task-workspace-ownership branch from d7ff016 to 85d86b2 Compare October 9, 2026 22:27
@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptile please review the latest head 85d86b2. The branch is rebased onto current master. Continuation source-project handling, workspace eligibility, and the E2E timing race are fixed. Full source authorization now covers retained workspace provenance and scoped access across entry points. Please also reassess the privacy-source finding in light of the existing transactional database trigger in migration 0313 and the fresh-database regression tests.

Comment thread server/src/services/issues.ts Resolved
@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptile please review head 18f982a. Live testing found and fixed the project picker sending legacy workspace-reset fields; it now changes only project organization and passes the browser retest. Native immutable task-root validation now preserves the existing ownership hold before filesystem work. E2E header and normalized tool-receipt matching were corrected from actual local/Daytona evidence. Authorization fixtures now contain real scoped user identities. Focused checks pass; full CI and the corrected three-environment campaign are running.

@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptile please review b39a7f6. All three latest findings are fixed with focused regressions: explicit sources cannot fall back, ordinary workspace PATCH updates invalidate older intent atomically and preserve active owners, and channel defaults use the canonical active/idle eligibility filter. Server typecheck and targeted tests pass. The live three-environment continuation campaign remains pinned to 18f982a and has not been interrupted; these later edge-case fixes have separate test provenance.

@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptileai please review the latest head a7acba6002. The three findings from the rebased review are fixed with regressions (b39a7f6, reviewed 5/5). The real three-environment E2E campaign then found that repository admission attempted to lock a checkout before cloning it. The latest commit locks its validated existing parent; the real-lock/real-Git regression verifies fresh publication, concurrent admissions, and retained dirty files (6/6 persistence tests pass). The corrected bounded E2E campaign is being rerun.

@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptileai please review the latest head 9036e3f74. The checkout publication lock is now per canonical repository target (a93e8b68d), addressing discussion_r4235911942 with real concurrent clone/reuse coverage. All 52 lock/persistence tests pass. The remaining CI fixture failures are fixed without production or assertion changes: comment batching 28/28, responsible-user invariants 13/13, and callback bridge 66/66 pass. Full build and workspace typecheck passed; fresh full-suite/CI validation is running.

cryppadotta and others added 15 commits October 9, 2026 21:19
Separate task organization from filesystem ownership. Add channel defaults, workspace and repository tools, safe admission transitions, and sparse native workspace persistence.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Add three full-stack workspace and repository resume journeys, synchronize operation documentation, and enforce non-enumerating task route authorization.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Keep organizational projects separate from source ownership, align workspace discovery with selection, normalize persisted defaults for session reuse, and preserve typed setup diagnostics. Add privacy provenance regressions and synchronize API/tool contracts.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Seed active memberships for reused task workspaces, respect retained-source deletion order, and remove a provider-speed race from the E2E oracle while preserving deferred-preparation checks.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Authorize every retained task and source project independently from organizational assignment, including native child creation, selection, reopening, and repository preparation.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Keep project edits organizational, validate immutable native task roots before materialization, align authorization fixtures, and correct live E2E evidence collection.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Fail closed for an unavailable configured source, invalidate superseded workspace intent atomically on ordinary task updates, and reuse canonical workspace eligibility in channel settings.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@cryppadotta
cryppadotta force-pushed the codex/task-workspace-ownership branch from 9036e3f to 6195c98 Compare October 10, 2026 02:21
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@cryppadotta

Copy link
Copy Markdown
Contributor Author

@greptileai apex review

Please review exact head 753680b. The configured-default/primary precedence finding is repaired through the shared task creation/bulk/provisioning resolver. Existing validation and deny-only restrictions remain intact. Final 79 affected checks and full repository typecheck/build pass; fresh CI and security scans are running.

@cryppadotta
cryppadotta merged commit f329b24 into master Oct 13, 2026
60 checks passed
@cryppadotta
cryppadotta deleted the codex/task-workspace-ownership branch October 13, 2026 01:45
nickyleach added a commit that referenced this pull request Oct 13, 2026
…16194)

## Thinking Path

> - Paperclip uses versioned PostgreSQL migrations to preserve
application data.
> - Drizzle uses schema snapshots to generate future migrations.
> - The database package already prunes snapshots to the five newest
files.
> - PR #15749 added three snapshots but left eight in the resulting
tree.
> - This PR removes the three excess files and documents the retention
requirements.
> - Coding agents and Greptile receive the same scoped rule for future
migration changes.

## Linked Issues or Issue Description

Refs #15749. Related: #16191 includes overlapping snapshot cleanup with
its new migration. This PR isolates the existing excess and the
repository rule; it has no dependency on that feature.

**What happened?**

The migration metadata directory contains snapshots 0331–0338. The
existing pruning script retains only the newest five, but the older
three were left in master.

**Expected behavior**

Keep snapshots 0334–0338. Commit snapshot pruning alongside additions
and recheck the combined tree after rebases or merges. Preserve all SQL
migrations and journal entries.

**Steps to reproduce**

At master commit e3029c6, list
`packages/db/src/migrations/meta/*_snapshot.json`. There are eight
files. Run `pnpm --filter @paperclipai/db prune:snapshots`; snapshots
0331–0333 are removed.

**Paperclip version or commit**

e3029c6. Repository maintenance; deployment mode is not applicable.

## What Changed

- Remove snapshots 0331–0333 using the existing pruning script.
- Add `rules/database-migration-snapshots.mdc` with retention,
generation, rebase, preservation, and review requirements.
- Register the rule in `.greptile/files.json` with matching scope
patterns.

## Verification

- Existing `prune:snapshots` script completed successfully via `npm run
--prefix packages/db prune:snapshots`.
- Existing migration numbering and safety checks passed, run with the
available tsx loader. Safety reported only baseline-covered historical
findings.
- A local assertion check confirmed exactly snapshots 0334–0338 remain,
with retained snapshots and journal byte-for-byte equal to the base. SQL
migrations are unchanged.
- A local assertion check verified that rule globs equal the Greptile
scope, all manifest paths exist, representative migration/schema files
match, and unrelated server/UI files do not match.
- `node scripts/check-maps.mjs` and `git diff --check` passed.
- Full application typecheck, test suite, and build were not run for
this metadata and review-rule-only change. No runtime code, schema, SQL,
or dependencies changed.

## Risks

Low risk. The five newest schema snapshots remain unchanged. Database
migration history is preserved. The rule supplies agent and review
guidance; it does not add a new CI enforcement gate. Recheck retention
if another migration merges first.

## Model Used

OpenAI GPT-6 via Codex, with reasoning and shell/file tools. The exact
runtime model ID and context-window size are not exposed in this
session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
devinfoley added a commit that referenced this pull request Oct 13, 2026
…16095)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Each task must have an isolated workspace that its agent can read.
> - Older project checkouts can contain worktrees for restricted tasks.
> - The source access check correctly rejects these shared checkouts.
> - A fresh task then fails even when its agent can clone the project
remote.
> - This pull request gives fresh default tasks a separate clone of the
same remote.
> - The task can start while the restricted task files remain protected.

## Linked Issues or Issue Description

**What happened?**

Fresh tasks fail with `Task workspace access is no longer available`
when their default project checkout contains a restricted task worktree.
The caller has access to the new task and its remote repository. The
shared local Git source is unsafe to copy.

**Expected behavior**

Use a separate clone of the same authorized remote for a fresh default
task. Keep source access checks and responsible-user Git credentials in
force.

**Steps to reproduce**

1. Put a restricted task worktree inside a project checkout.
2. Assign a new default task to an agent that cannot read the restricted
task.
3. Start the new task. The current source check fails before workspace
creation.
4. With this fix, the task uses a separate remote source. The restricted
files are absent. Later runs reuse the same owned source.

Related work: Refs #15749, Refs #15528. This change keeps their source
retention and workspace ownership checks.

## What Changed

- Add a remote source path scoped to the company and task.
- Clone through the run’s Git connection after the shared source fails
its access check.
- Reject reused workspaces, explicit selections, pinned branches, local
sources, credential-bearing URLs, and symlink paths.
- Check source access again before publishing the workspace.
- Resolve later runs from the verified recorded source. Ignore leftover
clones that the saved workspace does not own.
- Record provenance for new implicit Git defaults. Read the current task
binding before fallback. Preserve explicit, inherited and ambiguous
legacy checkout choices.
- Keep the effective task strategy during startup validation of matching
implicit defaults. Preserve the existing explicit-selection write check.
- Add regression coverage and document the fallback.

## Verification

- Merged master `c8efdbfba43` and resolved both rounds of catalog/index
conflicts. All upstream suites, classifications, source references and
story IDs are preserved. Both fix branches combine cleanly in either
merge order, with no catalog fingerprint drift.
- Passed locally: 313 focused source-isolation, preparation,
task-creation, binding and trust tests before the final startup fix. The
final fix passes all 100 source-trust, task-binding and
environment-selection tests. Earlier workspace-resolution and
persisted-source suites also passed.
- Real-Git regressions cover all three review findings. Reconstruction
ignores an unrecorded clone and preserves unpublished commits/files.
Explicit and parent-inherited checkout IDs without typed selections
retain their denial and branch tips without cloning or acquiring an
environment. A protected-project heartbeat completes and resumes using
the task’s Git strategy with read access. Explicit selection still
requires writes, and a mismatched default is rejected.
- Passed: the complete Storybook catalog check with no drift errors,
feature and agent map structure checks, and all 17 catalog/index script
tests. The generated index counts match the merged catalog. The current
upstream verification-route inventory remains unchanged. The catalog
contains all 262 authored suites and 2,481 story IDs.
- Passed: full workspace typecheck and build after the final guard
changes, on latest head `79d2adadcb6d3d7a04b9943a91bdb8b0b6abea6d`.
- Latest head `79d2adadcb6d3d7a04b9943a91bdb8b0b6abea6d`: complete CI
passed (54 successful checks, two intentional skips), including the full
general/serialized suites and all eight browser shards. Fresh Greptile
Apex review is 5/5 on this same commit, with no unresolved findings or
recommendations. The full local test command was attempted earlier
without a complete aggregate result; the complete suite result is from
CI.
- Manual check: configure a shared project checkout with a restricted
task worktree. Admit a fresh default task using the authorized remote.
Confirm separate Git storage and no restricted local branch or file.
Reuse, close and reopen the task workspace. Confirm that explicit,
literal branch and low-trust selections retain the denied source.

## Risks

- A clean remote clone excludes unpublished local work. The fallback
applies only to fresh default tasks and rejects existing workspace or
branch selections.
- A private remote can fail to clone when the responsible user lacks Git
credentials. The run then reports the failure; access checks are not
bypassed.
- Older untyped checkout bindings cannot prove default provenance. They
keep the source denial instead of silently dropping unpublished work.
- New implicit Git defaults use the existing workspace-intent contract.
The source directory uses existing instance storage. No schema migration
is required.

## Model Used

OpenAI GPT-6, model ID `gpt-6`, through Codex. Used reasoning,
repository inspection, code editing, terminal tools, and test execution.
The API session does not expose an exact context window size.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
cryppadotta added a commit that referenced this pull request Nov 1, 2026
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - A stopped sandbox can hold workspace files that still need a durable
copy.
> - File recovery must reopen the exact allocation and directory
recorded by the run.
> - Workspace preparation can place that directory below the allocation
root.
> - Daytona resume returned the allocation root even when recovery
needed the recorded child directory.
> - This pull request lets the file-recovery owner request that exact
directory.
> - Ordinary resume keeps its allocation-root behavior. The recovery
source checks stay strict.

## Linked Issues or Issue Description

**What happened?**

A stopped native run had a prepared remote workspace. The recovery
service stopped and retained its allocation. The next file-recovery step
failed with `source_binding_invalid` and `reopened_cwd_mismatch`.
Daytona resumed the correct allocation and matched its sentinel, but
returned the allocation root instead of the workspace directory recorded
on the lease.

**Expected behavior**

The file-recovery owner must reopen its exact recorded directory without
creating an allocation, an empty directory, or an agent turn. Ordinary
execution resume must keep returning the allocation root for normal
workspace preparation.

**Steps to reproduce**

1. Prepare a task workspace below a Daytona allocation root.
2. Stop and retain the allocation with unsaved workspace files.
3. Request source-bound file recovery.
4. Before this change, the provider returns the allocation root and the
strict cwd check rejects it.

**Paperclip version or commit**

Reproduced from `050365e09d88411960fc3bacc1c08c46c0d9b6fa`.

**Deployment mode**

Docker with the bundled Daytona provider. Local tests use synthetic
provider boundaries and disposable PostgreSQL.

Refs: #18517, #15749. Related retained-export work: #17916. That work
does not change the Daytona resume handler.

## What Changed

- Add an optional driver-only `requestedCwd` resume field to the SDK
contract and existing host forwarders.
- Set the field only after the owned file-recovery path verifies the
recorded source.
- Require Daytona to match the requested directory to the recorded lease
directory. Require a normalized absolute path without NUL bytes. Keep
the allocation and sentinel checks.
- Keep ordinary resume unchanged when the field is absent.
- Add provider, host, and real workspace-preparation regressions.
Document the separate directory contracts.

## Verification

- The original provider regression failed for reusable and ephemeral
leases. The scoped regression also failed to read a real retained file
from the wrong root. Ordinary resume controls passed before the fix.
- Current provider handler: **345/345 passed**. This includes
exact-directory, malformed, missing, foreign, sentinel, reusable,
ephemeral, ordinary-root, and real-file cases.
- Removing only the owned producer's cwd request makes its real
PostgreSQL regression fail with the original `reopened_cwd_mismatch`;
the source file was restored exactly afterward.
- Current host selection: **10/10 passed** against disposable PostgreSQL
17. It covers the inspected owner, sandbox forwarding, generic plugin
forwarding, normal resume without the field, same and later task
workspace preparation, and ownership rejection. The same-workspace
control retains saved bytes and does not append another workspace path.
- Current SDK and Daytona builds, server build, module boundaries, maps,
and diff checks passed. The server used its normal unchanged-Runner
cache. Its canonical input digest matched the previously verified build,
and the canonical assessor accepted the copied original stamp and
outputs. The changed SDK and server compiled from current source.
- Local package-wide validation exposed two unchanged 30-second timeouts
in the 145,000-member tar-listing cases. A single-file control
reproduced both timeouts. That test mocks this provider module. The
failures remain recorded; no timeout changed. The earlier package run
had 497 passes, two failures, and seven skips. It is historical evidence
from the abandoned broader resume experiment, not final-source package
acceptance.
- Initial host attempts timed out during database setup before any
assertion. The final host selection used the existing supported
pre-migrated disposable template. No test timeout changed.
- Greptile reviewed exact head
`8d0e577d1234ad394887255f13707c010dee6d24`: **5/5, no actionable issues,
zero review threads**. [Current
review](#18527 (comment)).
- The official [Ponytail
review](#18527 (comment))
also assessed exact head `8d0e577d1234ad394887255f13707c010dee6d24`:
**5/5, no findings**. Its check is terminal neutral; its completed
source assessment is not a test-execution claim.
- [Primary
CI](https://github.com/paperclipai/paperclip/actions/runs/41286802674)
initially lost its spot runner in the UI/CLI workspace lane. The log
records an explicit shutdown signal and no test assertion result. UI,
CLI, lane scripts and dependencies are unchanged; the adjacent
identical-source baseline lane passed. The single failed-lane retry
passed at the same source. The initial failure is retained. All
exact-head CI gates are now green.
- No live repair or image deployment is claimed by this PR.

Commands:

```sh
node packages/plugins/sandbox-providers/daytona/node_modules/vitest/vitest.mjs run --config packages/plugins/sandbox-providers/daytona/vitest.config.ts packages/plugins/sandbox-providers/daytona/src/plugin.test.ts
node node_modules/vitest/vitest.mjs run --project @paperclipai/server server/src/services/workspace-recovery.test.ts server/src/__tests__/environment-runtime.test.ts -t 'recovers a protected retained source|owned export directory|prepares the (same|later) task workspace|does not reopen a retained source|resumes only the exact stopped sandbox lifecycle|explicit export directory'
pnpm -C packages/plugins/sandbox-providers/daytona build
pnpm --filter @paperclipai/server build
node scripts/check-module-boundaries.mjs
node scripts/check-maps.mjs
git diff --check
```

## Risks

- A provider that does not support the optional field can still return a
different directory. Recovery keeps failing closed on that mismatch.
- Ordinary resumes omit the field. The tests cover the same workspace
and a later task so that normal preparation does not gain an extra path
prefix.
- The field grants no source ownership, stop proof, file-persistence
proof, or execution authority. Existing allocation, company, task, run,
claim, and cwd checks remain in force.
- No schema migration, retry-policy change, model replay, or
historical-row repair is included. Existing failed attempts remain
historical facts. Deployed file recovery still needs its normal
admission and independent persistence and physical-stop receipts.

## Model Used

- OpenAI GPT-6 through Codex. Used reasoning, source inspection, tool
use, and code execution. The exact serving model identifier and context
window are not exposed in this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
cryppadotta added a commit that referenced this pull request Nov 5, 2026
…19311)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Native agents discover reusable workspaces through
`list_workspaces`.
> - The tool returned every authorized workspace in one result.
> - A large inventory exceeded the durable command journal limit. The
result stayed pending, and session cleanup blocked the next turn.
> - This pull request limits discovery in SQL and returns explicit
continuation metadata.
> - Agents can inspect every authorized workspace without sending the
full inventory in one command.

## Linked Issues or Issue Description

Related: #15749 introduced the task workspace tools. No duplicate
pagination fix was found.

**What happened?**

A native workspace discovery call returned a multi-megabyte inventory.
Persisting its result failed with `command_payload_too_large`. The
preceding answer could still be saved, but cleanup retained the
unsettled tool call. A later turn failed before provider work with
`native_session_cleanup_quarantined`.

**Expected behavior**

Workspace discovery must return a manageable page. Agents must be able
to request the remaining authorized rows. Existing visibility checks and
journal integrity checks must stay effective.

**Steps to reproduce**

1. Create 2,000 task-selectable workspaces with ordinary repository
paths.
2. Call `list_workspaces` from an admitted native run.
3. On the old code, the real API regression returns 869,781 bytes. The
command journal allows about 510 KiB.
4. On the repaired code, follow `nextCursor` to inspect all rows. Pages
contain at most 100 rows and fit within 128 KiB.

**Paperclip version or commit**

Reproduced on source commit `7351a9d74f` before the repair.

**Deployment mode**

Isolated source checkout with real PostgreSQL and authenticated native
agent APIs. Hosted deployment and incident recovery remain separate.

## What Changed

- Validate workspace list limits and UUID cursors with a JSON Schema
pattern supported by strict validators. Return `workspaces`, `limit`,
`returnedCount`, `hasMore`, and `nextCursor`.
- Apply company, visibility, lifecycle, and cursor conditions before the
SQL limit. Order pages by workspace ID. Fetch one extra row to detect
continuation without a count query.
- Fit encoded pages within 128 KiB, including JSON escaping and Unicode.
If one summary cannot fit, return explicit string previews with
`truncatedFields`. The authorized detail API retains its full record.
- Keep existing unpaged summary callers on their array response and
recent-use order.
- Update the native tool descriptor, generated contracts, catalog
fixture, and execution documentation.
- Add regression coverage for large inventories, complete pagination,
stable pages, private and foreign rows, invalid inputs, and legacy
summary behavior. Add an opt-in two-turn live Codex acceptance check.

## Verification

- Red before repair: `task-workspace-api.test.ts -t "pages a large
authorized workspace inventory"` failed because the result was 869,781
bytes instead of below 128 KiB. The transport regression also failed at
2,284,671 bytes.
- Green after repair and review changes: 120 tests passed across the
workspace API, transport, routes, native authority, coordinator,
historical-question, and Codex vertical-slice suites. They cover
complete discovery, byte-sized pages, oversized individual summaries,
full detail retrieval, private/foreign/lifecycle exclusions, and strict
schema compatibility.
- Journal safety: two focused durable control-plane tests passed.
Oversized result rejection and lossless valid result delivery remain
effective.
- Tool catalog and reconciliation: 30 tests passed.
- `pnpm -r typecheck`: passed.
- `pnpm build`: passed again on final commit `bc10880da6`. Server
typecheck also passed after the review changes. The original affected
suites passed on the rebased first commit (31 tests), and the expanded
review regression set passed afterward (120 tests).
- Real provider acceptance passed again on final commit `bc10880da6`:
local macOS arm64, rebuilt native Runner, `gpt-6.1-sol`, high effort,
per-turn lifecycle, and 2,000 persisted workspaces. Both turns
succeeded. Persisted call inputs and results prove that the second page
uses the first result’s cursor, both calls succeed, their IDs do not
overlap, and the encoded results stay within 128 KiB. The second turn
kept the provider conversation and file. Both task locks were clear
after completion, and no recovered execution failure was recorded.
Duration: 166.92 seconds.
- Full local `pnpm test:run` stopped in the chat shard: 330 tests passed
and one Slack registration test failed with `socket hang up`. That exact
test passed in isolation without changes, and the final-head CI chat
shards passed. A broader local managed-Slack follow-up produced no
result after about eight minutes and was interrupted; it is not counted
as a pass. The original full-suite failure remains recorded.
- The first CI head failed native tool-schema compilation because strict
validators did not recognize `format: uuid`. The revised descriptor uses
a UUID pattern. The previously failing coordinator, native
vertical-slice, authority, and history suites now pass locally. The
stronger live cursor-receipt acceptance check passed. Final-head CI
completed on `bc10880da6`: 57 checks passed and five optional checks
were skipped, with no failures or pending checks. Greptile reviewed that
commit at 5/5; both prior findings are resolved.
- Dependency cost: paged discovery runs the existing visibility-scoped
summary query with an ID cursor and at most 101 returned rows. It adds
no count query, filesystem scan, provider call, or background worker.

## Risks

- Native `list_workspaces` now returns a page object instead of an
array. Individual summaries can be explicit previews when a single
record exceeds the byte budget. Its advertised descriptor and generated
contracts change together. Agents must follow `nextCursor` until null
for a complete inventory.
- Each page rechecks current visibility. Concurrent insertions,
deletions, or access changes require a fresh scan when a complete
point-in-time inventory is needed.
- No migration or journal-limit change. An existing cleanup quarantine
still requires normal recovery after deployment; this PR does not bypass
it.

## Model Used

OpenAI Codex, GPT-6 family, with reasoning, shell tools, code editing,
and test execution. The exact served model revision and context window
are not exposed in this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
cryppadotta added a commit that referenced this pull request Nov 6, 2026
…rectory (#19475)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agent Chat returns delegated-task completions to the chat that
started them, and the runner E2E `completion-updates` suite checks this
with real providers
> - The restart cell
(`completion-updates.runner-codex.local.handoff-completion-restart`)
failed before its server restart with "Timed out waiting for worker
waiting while originating chat is idle"
> - Since project-optional task workspaces (#15749), a task in a project
without a workspace runs in its isolated task directory. A native chat
runs in its isolated conversation directory. Native Codex can read only
that directory.
> - The fixture still wrote its brief wait scripts into the managed
project workspace and the agent home. Codex got EPERM on both scripts,
wrote the note from the task record, and finished. The worker never
reached the gate, so the setup poll timed out.
> - This pull request makes the waits name only cwd-relative files and
publishes each brief into the run's own isolated task directory
> - The benefit is that the restart cell reaches its real boundary again
(durable Done, source provider held at the gate, server restart) and
tests restart recovery instead of a stale fixture path

## Linked Issues or Issue Description

**What happened?**
The runner E2E cell
`completion-updates.runner-codex.local.handoff-completion-restart` timed
out in setup. The run ledger shows both agents report
`permission_denied` (EPERM) for `node .../wait-for-brief-*.cjs`. The
worker run cwd was `<instance>/isolated-workspaces/<company>/<issue>`.
The fixture wrote the script to the managed project workspace and the
agent home.

**What did you expect to happen?**
The worker waits at the brief gate while the chat is idle. Then the cell
releases the brief, holds the completion reply at its gate, and restarts
the server.

**Steps to reproduce**
`pnpm test:e2e:runner -- --max-automatic-retries 0 --id
completion-updates.runner-codex.local.handoff-completion-restart` on
master `6cafcaf89b`.

**Classification**
Test defect. The failure happens before the restart. Workspace isolation
is the intended product behavior.

## What Changed

- `tests/runner-e2e/chat-stories.ts`: add `workspaceChatBrief(nonce,
timeoutMs)`. It returns a bounded `node -e` command that reads and
writes only cwd-relative files, plus `at(dir)` to find the gate and
ready files in a workspace.
- `tests/runner-e2e/completion-update-flow.ts`: the worker and
completion instructions use that command. The fixture reads readiness
from, and publishes briefs to, `isolated-workspaces/<company>/<issue>`
for each delegated task and the source chat. The setup poll state now
records the worker run cwd. Cleanup releases every wait that is still
open.
- `tests/runner-e2e/chat-stories.test.ts`: regression test. It runs the
command from a temporary cwd, checks that the command names no host
path, and checks the nonce and timeout bounds. It was red before the
helper existed.
- `tests/runner-e2e/catalog.ts`: bump the `completion-updates`
definition to version 28 and set `workerBriefWorkspace:
"run-isolated-task-directory"`.
- `tests/runner-e2e/README.md`: describe the new brief location.

## Verification

- `npx vitest run --config tests/runner-e2e/vitest.config.ts
tests/runner-e2e/chat-stories.test.ts
tests/runner-e2e/completion-updates.test.ts
tests/runner-e2e/catalog.test.ts`: 108 passed.
- Live cell, native Codex `gpt-5.6-sol`, local runner: `pnpm
test:e2e:runner -- --max-automatic-retries 0 --id
completion-updates.runner-codex.local.handoff-completion-restart`.
Results are in the Verification comment below.
- Two earlier local attempts in this worktree failed in setup with
`harness_test_failed`. The worktree did not have a built
`paperclip-runnerd`. After `pnpm --filter @paperclipai/paperclip-runner
build`, the cell passed.

## Risks

- Low risk. The change is in test fixtures only. No product code
changes.
- The idle, busy, and multiple cells share this flow. They now also use
the isolated task directory. That is the same directory the product
selects for these tasks.
- The agent must run the inline command from its cwd. The instructions
say this, and the command fails closed (no gate) if the agent runs it
elsewhere.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with
tool use (shell, file edits). Default context window. Extended reasoning
on.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant