Skip to content

Add safe sequential shared-worktree reuse - #68

Merged
MonaDevAI merged 1 commit into
mainfrom
feat/shared-worktree-reuse
Oct 14, 2026
Merged

MonaDevAI merged 1 commit into
mainfrom
feat/shared-worktree-reuse

Conversation

@MonaDevAI

Copy link
Copy Markdown
Contributor

Problem

Sequential bug-fix jobs can accumulate worktree folders and dependencies, and a new fix may inherit the selected checkout's previous feature commits instead of starting from the intended PR base. Reusing a folder must preserve older jobs' branches and resumable sessions.

Change

  • Add opt-in worktreeSetup.mode: "shared" for dashboard-managed fix-and-validate jobs.
  • Acquire the existing repository executor lease before checking the checkout and refreshing the configured remote base.
  • Create a separate job branch from the freshly fetched base in the same checkout; preserve local dependencies and ignored browser profiles without copying them.
  • Persist the assigned branch/base and reacquire it for held-job resumption, including dashboard restarts. A restart gets a fresh session and branch.
  • Reject dirty trees, in-progress Git operations, missing or incompatible saved branches, branch ownership conflicts, ignored-file overwrites, and branch switching while owned frontend/authentication sessions run.
  • Block direct mutable CLI launches in shared mode; show the assigned branch in the dashboard and document configuration and recovery.

Validation

  • Focused real-Git shared-worktree, dashboard lifecycle, and CLI regressions pass
  • Full npm run validate passes: 202 unit tests and 12 browser tests; lint, type checks, formatting, documentation, governance, policy, and recovery gates pass
  • npm pack --dry-run includes dashboard/shared-worktree.js
  • Documentation is updated
  • No credentials, tokens, private endpoints, or test data are included

The base was fast-forwarded to merged PR #66 without source changes after validation.

Risk

  • Shared mode is opt-in; existing isolated behavior and read-only validation remain unchanged.
  • New-job base refresh is noninteractive, bounded to 30 seconds, and fails rather than using a stale remote-tracking commit.
  • Uncommitted files require explicit preservation; there is no reset, stash, clean, automatic branch deletion, or forced worktree takeover.
  • Legacy jobs without shared-branch metadata must retain their original workspace policy. Shared mode must not be retroactively enabled on an unfinished legacy job.
  • This PR does not change the running developer dashboard, bypass authentication or approval, or implement parallel jobs sharing a writable checkout.

Refresh the configured base for new jobs and persist saved branch ownership for resume. Gate acquisition on clean state and confirmed process ownership without resetting or copying browser state.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 22c892d2-e1f2-436b-8bf5-5bbc49ddcf7d
Copilot AI balanced review requested due to automatic review settings October 14, 2026 21:28
@MonaDevAI
MonaDevAI merged commit 7857641 into main Oct 14, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Shared-checkout admission and recovery gaps can undermine safe branch ownership during execution.

6 open findings
What changed in this PR

Adds opt-in shared-checkout reuse for sequential dashboard jobs, extending existing executor admission and session recovery with job-specific branches.

Changes:

  • Refreshes the configured base and assigns separate branches for new jobs.
  • Persists branch ownership for resumption and displays it in the dashboard.
  • Blocks direct mutable CLI launches in shared mode and adds documentation and regression coverage.
File Description
test/​fixlab-cli.test.js Tests shared-mode CLI rejection.
test/​dashboard-shared-worktree.test.js Tests branch acquisition and preservation safeguards.
test/​dashboard-server.test.js Tests shared-job lifecycle and restart recovery.
docs/​repository-onboarding.md Documents configuration and recovery.
docs/​architecture.md Describes shared-checkout ownership.
dashboard/​shared-worktree.js Implements branch preparation, verification, and guidance.
dashboard/​server.js Integrates shared ownership into job orchestration.
dashboard/​public/​app.js Displays the assigned branch.
bin/​fixlab.js Rejects direct mutable shared-mode execution.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread dashboard/server.js
Comment on lines +3034 to +3035
resourcesRunning: Boolean(frontendConnection.handle) ||
frontendConnection.starting || Boolean(playwrightConnection.handle)
Comment thread dashboard/server.js
frontendConnection.starting || Boolean(playwrightConnection.handle)
});
if (job.sharedWorkspace) {
persistDashboardState();
Comment thread dashboard/server.js
Comment on lines +3037 to +3039
if (job.sharedWorkspace) {
persistDashboardState();
const readiness = inspectRepository(resolvedRepository);
Comment thread dashboard/server.js
owner.id !== sessions.id && owner.available && owner[resource]?.running
owner.id !== sessions.id && owner.available && (
owner[resource]?.running ||
(shared && resource === "job" && (owner.frontend?.running || owner.authentication?.running))
Comment on lines +111 to +112
if (resume) {
throw new Error("This older job has no saved shared-worktree branch. Resume it with its original workspace policy; do not guess its branch");
}
return `\nShared worktree contract:
- The dashboard has exclusively acquired this checkout on branch ${workspace.branch}, based on ${workspace.remote}/${workspace.baseBranch} at ${workspace.baseCommit}.
- Work in this checkout and on this exact branch. Do not create another worktree, switch branches, reset, stash, clean, or merge/rebase the base branch.
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.

2 participants