Skip to content

fix(conn-server): new worktrees honour sparse patterns and worktreeSubmodules, as T3 - #313

Merged
nckrtl merged 5 commits into
mainfrom
audit3/worktree-options
Nov 24, 2026
Merged

nckrtl merged 5 commits into
mainfrom
audit3/worktree-options

Conversation

@nckrtl

@nckrtl nckrtl commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Third port audit, items 4 and 5: new worktrees honour sparse patterns and worktreeSubmodules (conn-vcs).

Problem

  • vcs.createWorktree left submodules empty under the recursive default.
  • orchestration.launchThread filled them even with worktreeSubmodules=none.
  • Neither applied t3.json's worktreeSparsePatternsPath, so an excluded tracked file was checked out.

T3

GitVcsDriverCore.ts:5344 (readWorktreeSparsePatterns, --no-checkout, sparse-checkout set --no-cone --stdin, checkout) and GitVcsDriverCore.ts:5447:

  • A worktree has submodules only if HEAD:.gitmodules exists.
  • The mode comes from resolveProjectFileBackedSetting: the setting, else t3.json at HEAD, else recursive.
  • It runs submodule init, then update, and on failure checks out the submodules that did clone.

Fix

  • create_worktree reads the sparse patterns before it creates the branch. A named file missing from the ref fails the worktree, and nothing is left behind.
  • submodule_mode and update_submodules are shared by vcs.createWorktree, launch and pull request checkout. Launch keeps its stage statuses and reports "disabled in settings|t3.json" as T3 does.
  • WorktreeRequest carries the project id, so the per-project setting applies.
  • Pull request checkout used to read t3.json from the working tree, and a failed update aborted it. It now reads t3.json from HEAD and only warns on a failed update, as T3 does. It still reads only the environment-level setting, not a project override.

Proof

  • a_sparse_worktree_leaves_out_what_t3_json_excludes: excluded files are absent, and a missing pattern file fails without leaving a branch.
  • submodule_mode_follows_the_setting_then_t3_json: precedence, t3.json read from HEAD, no .gitmodules, and none leaves the module empty.
  • The audit probe covers the real submodule clone end to end. A unit test cannot clone a local fixture: the process builder sets GIT_CONFIG_*, which blocks protocol.file.allow without writing to the decoy HOME.

Acceptance

The audit probe (audit-third.mjs, Rust mode) on this branch now gives T3's results, through the real WebSocket entry points and a real file-protocol submodule clone in a disposable HOME:

  • excludedPresent: false: the sparse-excluded tracked file is absent.
  • moduleAvailable: true: vcs.createWorktree fills the submodule under the recursive default.
  • modulePresentWhenOff: false: orchestration.launchThread leaves it empty with worktreeSubmodules=none.

Checks

These pass locally:

  • cargo test for conn-vcs, conn-source-control, conn-engine, conn-mcp, and the conn-server VCS, host and settings tests.
  • cargo clippy -D warnings on those crates.

Two engine checkpoint tests timed out at 5 s under load and passed when rerun alone. CI runs tools/check.sh on Linux.

Review fixes

  • t3.json is now read as parseT3ProjectFile reads it: lenient JSON (comments, trailing commas), decoded as a whole T3ProjectFile, so one invalid field rejects the whole file. The workspace's lenient parser moved from conn-provider-claude to conn_support::json. Tests: JSONC sparse patterns, JSONC worktreeSubmodules: "none", and an invalid document that now gives a full checkout and recursive submodules.
  • vcs.createWorktree finds the project by the cwd string, as findActiveByWorkspaceRoot does. There is no canonicalize on the runtime thread, and a symlink alias no longer takes another project's override. Test: create_worktree_takes_the_override_of_the_exact_workspace_root.

Round 3 (af1c7a8594): a repeated t3.json key takes its last value, as JSON.parse does, instead of rejecting the file. Test: a new case in submodule_mode_follows_the_setting_then_t3_json (fails before, passes after).

Follow-ups

  • Cancelling during sparse checkout leaks the worktree and its branch.

🤖 Generated with Claude Code

…bmodules, as T3

vcs.createWorktree left submodules empty under the recursive default, and thread launch
initialized them recursively even with worktreeSubmodules=none. Neither applied t3.json's
worktreeSparsePatternsPath. T3 does both in createWorktree (GitVcsDriverCore.ts).

conn_vcs::worktree now reads the sparse pattern file named by t3.json at the ref, checks out
--no-checkout, sets the non-cone patterns and checks out; a named file that is missing fails
the worktree and leaves no branch. submodule_mode resolves worktreeSubmodules as
resolveProjectFileBackedSetting does (the project's setting, else t3.json at HEAD, else
recursive), and update_submodules runs init, update and T3's partial-clone recovery.
vcs.createWorktree, thread launch (with its stage statuses, "disabled in settings|t3.json")
and pull request checkout now share them. Launch and delegated worktrees carry the project id
for the per-project setting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 23, 2026
nckrtl and others added 2 commits November 24, 2026 02:12
# Conflicts:
#	apps/conn-server/crates/conn-vcs/tests/repos.rs
…matches the root as given

`t3.json` is now lenient JSON (comments, trailing commas) decoded as a whole
`T3ProjectFile`, so one invalid field rejects the file as in `parseT3ProjectFile`.
The lenient parser moves from conn-provider-claude to conn-support so both use it.

`vcs.createWorktree` finds the project by the `cwd` string, as
`findActiveByWorkspaceRoot` does. It no longer canonicalizes every root on the
runtime thread, and a symlink alias no longer takes another project's override.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Decode t3.json through serde_json::Value, as JSON.parse keeps the last
of a repeated key, instead of rejecting the file and falling back to a
recursive submodule checkout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:XL and removed size:L labels Nov 24, 2026
# Conflicts:
#	apps/conn-server/crates/conn-support/src/lib.rs
@nckrtl
nckrtl merged commit 659f536 into main Nov 24, 2026
44 checks passed
@nckrtl

nckrtl commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Included in the merge train #327 (merged as ee7b1f9). Closing.

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

Labels

size:XL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant