Skip to content

Add worktree preparation for project dependencies - #2388

Merged
jonathanKingston merged 7 commits into
mainfrom
copse/build-2376-29fb13
Sep 14, 2026
Merged

jonathanKingston merged 7 commits into
mainfrom
copse/build-2376-29fb13

Conversation

@jonathanKingston

@jonathanKingston jonathanKingston commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #2376.

Fresh worktrees can now check and prepare the project's own dependencies through one bounded capability. Preflight detects npm, pnpm, Yarn Classic/modern, or Bun from the package-manager declaration and lockfile, reports runtime requirements and dependency state, and returns an exact preparation plan. Optional native setup and other ecosystems use .copse/worktree-preparation.json to declare commands, inputs, and read-only checks. This repository's Electron/gortex setup uses that same declaration.

Preparation approval displays the actual install and declared setup commands, network policy, and selected project. The preflight fingerprint is required and rechecked before each step. Installs use frozen lockfiles and manager-specific lifecycle disabling through Socket Firewall. All subprocesses remain inside the OS sandbox; preflight and offline preparation have no network access. Writes stay in the selected project and fixed managed caches, with no unsandboxed fallback.

Workspace detection follows declared patterns and exclusions, including apps/ layouts. Readiness invalidates on runtime/manager identity, manifests, lockfiles, package configuration, patches, declared inputs, and opted-in version-check output. Nested project selection is confined to the execution root. Unknown projects and conflicting inputs receive configuration guidance; readiness covers dependencies and declared checks, not build/test success.

Compatibility includes npm, pnpm, Yarn 1/2/3/4, Bun text/binary locks, Yarn Plug'n'Play, and Python virtual-environment interpreter symlinks. Modern Yarn requires an exact version declaration so its build-disabling flags are unambiguous. Runtime installation/version switching and Windows sandbox support are separate capabilities.

Validation:

  • Full static gates: typecheck, lint, format, dead-code, test oracle, and e2e syntax.
  • Current foundation pnpm run check: all static gates and 9,235 tests passed, with no failures or skips.
  • Real sandbox smoke installs and offline reuse: npm 11.19.0, pnpm 10.34.5, Yarn 1.22.22/2.4.3/3.8.7/4.9.2, and Bun 1.4.2. Lifecycle markers remained absent. Yarn 2 was exercised on Node 22.22.2; other JS fixtures used Node 24.20.0. Yarn 2/3 additionally fetched a registry dependency through Socket Firewall.
  • Real declared Python virtual-environment setup and offline reuse passed. This repository's declared native-runtime check also passed read-only in the sandbox.
  • Focused Electron result-card and exact-plan approval tests passed; both screenshots were inspected.
  • Adversarial coverage includes malicious probes/scripts, symlink writes, offline isolation despite another agent's network grant, stale approval plans, redirected fingerprints, and legacy Yarn proxy/CA preservation.

Visual evidence: tests/e2e/screenshots/worktree-preparation-tools.png and tests/e2e/screenshots/worktree-preparation-approval.png.

The general contract and roadmap are in docs/plans/project-worktree-preparation.md. #2654 tracks automatic Python/Rust/Go adapters; #2655 tracks JVM/.NET/Ruby/PHP adapters. Declarations support these ecosystems now; automatic detection is not claimed before its adapter and real tests ship. #2377 and #2378 remain independent Git and edit-ownership workstreams.

Co-Authored-By: Copse noreply@copse.dev
Copse-Models: acp:codex-acp#gpt-5.6-sol, acp:claude-acp#opus[1m]

Current follow-up: #2669 adds automatic locked uv/Python preparation on top of this foundation. #2654 remains open for hash-locked pip, Cargo and Go.

CI repair: rebased onto main at a184d2792, including the data-stable model-intellect assertion. Backups now keep the checkout read-only while writing Git objects/refs/logs and the scratch index, preventing Linux sandbox placeholders from entering git add -A. Regression tests cover ordinary home-contained repositories, nested linked worktrees, exact snapshot contents, unchanged index/status, and denied writes to working files, config and hooks. The focused model-picker Electron test passed and its screenshot was inspected.

The read-only chat-store mount also excludes its scratch directory and active checkout, preserving their separate write grants on Linux. Current head: 31e5f3872. Full CI verification passed: precheck, Linux unit tests, build, benchmark, all eight e2e shards, and the aggregate CI gate.

The proposed-image e2e fixture now uses a real non-Git project to require approval. It no longer relies on a Git backup failing. The focused image and Changes-refresh specs both passed; the proposed-image screenshot was inspected and matches the existing reference.

@jonathanKingston jonathanKingston added the ci-full Force the full e2e suite (bypass the test-oracle thinning) on this PR label Sep 5, 2026
@copse-release-bot

copse-release-bot Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Reference screenshots ready for review

Review GitHub’s image diffs in screenshot PR #2671.
Merge it (or enable auto-merge) to apply the accepted PNGs to copse/build-2376-29fb13.

Rendered for 31e5f38729e0 by CI run 34762467104; the immutable artifact is reference-screenshot-candidates-34762467104.

If this source branch moves, a later successful render closes the stale review PR and replaces this link.

@jonathanKingston

Copy link
Copy Markdown
Collaborator Author

Validation found one blocking containment mismatch on current head.

The approval copy says writes are limited to the active worktree and Copse-managed caches, but runPreparationStep calls node:child_process.spawn directly. Socket Firewall mediates network access; it does not enforce filesystem write boundaries. readProjectPackage only checks mutable values in the checked-out package.json, so a branch can preserve name: copse-panel and the exact prepare:native string while replacing scripts/prepare-native-artifacts.mts. Approving prepare_worktree would then execute that branch-controlled script outside the project sandbox with ordinary host filesystem authority.

Please run both preparation subprocesses inside an enforcing sandbox whose only write grants are the execution root and the enumerated managed cache roots, and add an adversarial fixture proving a spoofed native-preparation script cannot write elsewhere. Until then, keep this draft. The focused screenshot itself looks clear, and the latest source CI is green, but those do not establish the bounded-write claim.

github-actions Bot added a commit that referenced this pull request Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🖥️ PR preview

jonathanKingston and others added 5 commits September 13, 2026 09:20
Introduce preflight and approved preparation tools backed by managed caches, explicit native artifact setup, cache-aware shell execution, and focused readiness and visual coverage.

Co-Authored-By: Copse <noreply@copse.dev>

Copse-Models: acp:codex-acp#gpt-5.6-sol, acp:claude-acp#opus[1m]
@jonathanKingston
jonathanKingston marked this pull request as ready for review September 14, 2026 12:14
@jonathanKingston
jonathanKingston merged commit 4dbdae7 into main Sep 14, 2026
24 checks passed
@jonathanKingston
jonathanKingston deleted the copse/build-2376-29fb13 branch September 14, 2026 12:14
github-actions Bot added a commit that referenced this pull request Sep 14, 2026
jonathanKingston added a commit that referenced this pull request Sep 25, 2026
## Outcome

The feature copy in `site/index.html` was last updated in early August.
Every `site/` change since then has only touched badges, links or the
architecture page. This PR updates the landing page to cover features
that have shipped since, limited to those that are **on by default**:

- **Tour:** a new fifth item, "Ship the pull request". It covers opening
a PR from the message box (#2324, #2047) and the PRs panel following
comments, reviews and individual CI checks (#2597). Its image,
`site/screenshots/create-pr-dialog.png`, is a 1200×800 downscale of the
existing e2e screenshot `tests/e2e/screenshots/create-pr-dialog.png`.
- **"Set the boundary" card:** adds allow, ask or block for each Copse
and MCP tool separately (#2688).
- **Other features:** the grid goes from 6 to 9 items.
- "Worktrees ready to work": dependencies are installed automatically
for Node, Python (uv), Go and Rust projects, and old worktrees can be
cleaned up in bulk (#2388, #2669, #2780, #2607).
- "Shells and a real browser": draw on a page to show the agent what to
change (#2934), and tabs come back after a relaunch.
- New: the agent can propose a new thread (#2334), image diffs in review
plus Copy image (#2637, #2760, #3038), and an unread marker plus a
one-click continue-plan suggestion (#1765, #1890).
- **Meta description and JSON-LD** now mention pull requests.

These features are deliberately **not** on the page because they're
experimental or not finished yet: SSH workspaces (marked
"(experimental)" in Settings), inline canvas, Apple Simulator and
Android, the VNC desktop viewer, container runs, Copse Reviewer,
automations, and multiple windows. For windows, `create-main-window.ts`
still throws "Agent actions are not available in secondary windows yet".
A separate investigation into which of these could be turned on by
default has been queued.

## Risk and review

Low. The site is static: this changes copy and adds one PNG. There's no
change to the app, and `site.js` and `styles.css` are untouched. The
site only deploys when `release` is pushed, not when this merges into
`main`. No independent review has happened yet.

## Validation

- `pnpm test -- sync-site-markdown`: 32 passed, 0 failed.
- `pnpm run site:md`: the generated Markdown copy includes the new
headings. The output is gitignored and not committed.
- `pnpm run check:local`: passed. Run on Node 22 in the cloud container,
where pnpm printed an engine warning.
- `pnpm run oracle -- --explain`: HIGH confidence, 0 mapped specs. The
full unit suite was deferred under the low-risk fast path; required PR
CI (`ci.yml`) will run it.
- Visual check: the page was rendered in headless Chromium at 1440×1000
and 390×844. After clicking "Ship the pull request", the tour image
switches to `create-pr-dialog.png` with naturalWidth 1200. The "Other
features" grid renders as 3×3 on desktop and a single column on mobile.
There's no horizontal scroll at 390px (`scrollWidth` is 390). This is a
static marketing page, not the Electron app, so there's no WebdriverIO
spec.

## Remaining work

- The new screenshot uses the app's current pink accent. The existing
site screenshots were captured when the app used a green accent, so
they're out of date too. Refreshing all of them from
`tests/e2e/screenshots/` would be a sensible follow-up.
- Browser tab restore is still listed under "Unreleased" in
`CHANGELOG.md`. Before the site is next deployed from `release`, check
that the published build includes it.

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

https://claude.ai/code/session_01GkUNKJuLswZxUawPMmtRzi

---
_Generated by [Claude
Code](https://claude.ai/code/session_01GkUNKJuLswZxUawPMmtRzi)_

Co-authored-by: Claude <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
github-pages — 31e5f387 Deployed Sep 14, 2026 by jonathanKingston via deploy / deploy #1020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Force the full e2e suite (bypass the test-oracle thinning) on this PR update-screenshots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepare any project worktree through a bounded, project-aware plan

1 participant