Skip to content

fix(gsd): refresh root preferences into auto worktrees#3416

Closed
mastertyko wants to merge 11 commits intogsd-build:mainfrom
mastertyko:fix/3412-worktree-preferences-root-override
Closed

fix(gsd): refresh root preferences into auto worktrees#3416
mastertyko wants to merge 11 commits intogsd-build:mainfrom
mastertyko:fix/3412-worktree-preferences-root-override

Conversation

@mastertyko
Copy link
Copy Markdown
Contributor

@mastertyko mastertyko commented Apr 1, 2026

TL;DR

What: Refreshes the authoritative root PREFERENCES.md into auto worktrees before auto-mode uses worktree-local preferences.
Why: Stale copied preferences in the worktree could override newer root model settings and send auto-mode down the wrong model path.
How: Resync the root preferences file into the worktree during auto-worktree setup and cover both case-sensitive and case-insensitive filename variants.

What

This change keeps auto worktrees in sync with the project's root preferences file so auto-mode reads current model overrides instead of a stale copied snapshot.

Affected areas:

  • src/resources/extensions/gsd/auto-worktree.ts
  • src/resources/extensions/gsd/tests/worktree-preferences-sync.test.ts

Why

Closes #3412.

When the root project preferences changed after a worktree was created, auto-mode could keep reading the stale worktree copy. That meant root-level model overrides were silently ignored in exactly the path where we most want them to be authoritative.

How

The auto-worktree sync path now force-refreshes the root preferences file into the worktree before auto execution. The implementation also handles both PREFERENCES.md and preferences.md safely, with regression coverage for the refresh behavior.

Change type

  • fix — Bug fix
  • feat — New feature or capability
  • refactor — Code restructuring (no behavior change)
  • test — Adding or updating tests
  • docs — Documentation only
  • chore — Build, CI, or tooling changes

Scope

  • pi-tui — Terminal UI
  • pi-ai — AI/LLM layer
  • pi-agent-core — Agent orchestration
  • pi-coding-agent — Coding agent
  • gsd extension — GSD workflow
  • native — Native bindings
  • ci/build — Workflows, scripts, config

Breaking changes

  • No breaking changes
  • Yes — described above

Test plan

  • CI passes
  • New/updated tests included
  • Manual testing — steps described above
  • No tests needed — explained above

Verified locally with the full CI mirror gate:

  • npm run build
  • npm run typecheck:extensions
  • npm run test:unit
  • npm run test:integration

The final truth phase completed on the branch head in the issue worktree.

AI disclosure

  • This PR includes AI-assisted code — prepared with Codex and verified as described in the test plan above.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔴 PR Risk Report — CRITICAL

Files changed 11
Systems affected 4
Overall risk 🔴 CRITICAL

Affected Systems

Risk System
🔴 critical Auto Engine
🔴 critical State Machine
🟡 medium Async Jobs
🟡 medium Worktree
File Breakdown
Risk File Systems
🟡 src/resources/extensions/async-jobs/job-manager.ts Async Jobs
🔴 src/resources/extensions/gsd/auto-worktree.ts Auto Engine, Worktree
🔴 src/resources/extensions/gsd/state.ts State Machine
🟡 src/resources/extensions/gsd/worktree-manager.ts Worktree
src/resources/extensions/async-jobs/await-tool.test.ts (unclassified)
src/resources/extensions/gsd/tests/worktree-manager.test.ts (unclassified)
src/resources/extensions/gsd/tests/worktree-preferences-sync.test.ts (unclassified)
src/resources/extensions/gsd/tests/worktree-teardown-safety.test.ts (unclassified)
src/rtk.ts (unclassified)
src/tests/integration/pack-install.test.ts (unclassified)
src/tests/rtk.test.ts (unclassified)

⚠️ Critical risk — please verify: state persistence, auth token lifecycle, agent loop race conditions, RPC protocol compatibility.

@github-actions github-actions bot added the bug Something isn't working label Apr 1, 2026
@trek-e trek-e force-pushed the fix/3412-worktree-preferences-root-override branch from 15a4670 to ce78038 Compare April 5, 2026 03:43
@jeremymcs
Copy link
Copy Markdown
Collaborator

This PR has merge conflicts with the base branch. Please rebase or merge main to resolve before review can proceed.

🤖 Automated PR audit — 2026-04-04

@mastertyko mastertyko force-pushed the fix/3412-worktree-preferences-root-override branch from ce78038 to 6484d51 Compare April 6, 2026 18:53
@mastertyko
Copy link
Copy Markdown
Contributor Author

@jeremymcs Refreshed this PR onto the current main, reran the full local gate (npm run build, npm run typecheck:extensions, npm run test:unit, npm run test:integration), and pushed the updated branch. GitHub checks are green now.

@mastertyko
Copy link
Copy Markdown
Contributor Author

Closing this for now to keep the queue clean. The issue remains tracked in #3412 and can be reopened later as a cleaner standalone fix from current main.

@mastertyko mastertyko closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-mode uses stale worktree PREFERENCES.md, ignoring root model overrides

2 participants