feat(workspace): opt-in worktree file provisioning for gitignored-but-required files - #18
Open
gregberns wants to merge 2 commits into
Open
feat(workspace): opt-in worktree file provisioning for gitignored-but-required files#18gregberns wants to merge 2 commits into
gregberns wants to merge 2 commits into
Conversation
…-z8u, pre-wiring)
Completes the worktree-file-provisioning feature: maps the new worktree_provision_files config into DaemonConfig, calls ProvisionWorktreeFiles at the local worktree-creation site, and adds a focused unit test for the provisioning function. - projectconfig.go: copy raw.WorktreeProvisionFiles into DaemonConfig.WorktreeProvisionFiles (mirrors AllowedRepos / RemoteControlPrefix). Without this the config field was dead. - workloop.go: add a worktreeProvisionFiles field on the work-loop deps (sourced from cfg.ProjectCfg.Daemon.WorktreeProvisionFiles, mirroring allowedRepos) and call workspace.ProvisionWorktreeFiles(activeRepo, wtPath, ...) immediately after the worktree is created, LOCAL runs only (rbc == nil). Remote/SSH-worker worktrees live on another host and are skipped. A provision error is logged and non-fatal so a stray config entry never wedges dispatch. - provisionfiles_test.go: covers empty-list no-op, copy preserving content+mode (incl. nested parent-dir creation), missing-source warn-skip (no error, sibling still copied), and absolute / .. / bare-.. path rejection. Backward-compatible: empty/absent worktree_provision_files = current behavior, zero change. go build ./... and go test ./internal/workspace/... pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The daemon cuts a fresh
git worktreeper bead.git worktree addchecks out only tracked files, so a gitignored-but-required.env(consumed by adocker compose --env-file ../.envtest gate) is absent in the fresh worktree → the gate fails instantly (couldn't find env file) → the bead fails before any work runs.This deadlocked an entire fleet in the omatic-system-plan project; the workaround forces serial execution against one shared stack. This PR is the opt-in, durable fix.
Design
daemon.worktree_provision_files(a list of repo-root-relative paths).workspace.ProvisionWorktreeFiles(projectRoot, worktreePath, relPaths)copies each configured file from the canonical project root into the same relative path in the freshly created worktree (creating parent dirs, preserving mode).worktree_provision_files= a no-op; existing behavior is unchanged...-escaping paths are rejected; a missing source file is warn-skipped (optional input — only some developers may have it); a provision error at the call site is logged and non-fatal so a stray config entry never wedges dispatch.What this PR adds
The
ProvisionWorktreeFilesfunction + config field were banked in a prior WIP commit on this branch. This completes the wiring:internal/daemon/projectconfig.go— mapraw.Daemon.WorktreeProvisionFiles→DaemonConfig.WorktreeProvisionFiles(mirrorsAllowedRepos/RemoteControlPrefix).internal/daemon/workloop.go— add aworktreeProvisionFilesdeps field (sourced fromcfg.ProjectCfg.Daemon.WorktreeProvisionFiles, mirroringallowedRepos) and callProvisionWorktreeFilesafter worktree creation, gated onrbc == nil(local only).internal/workspace/provisionfiles_test.go— focused unit test.Testing
go build ./...— clean (0 errors).go test ./internal/workspace/...— ok (7 newProvisionWorktreeFilessubtests pass: empty-list no-op; copy preserving content+mode incl. nested parent-dir creation; missing-source warn-skip with sibling still copied; absolute /../ bare-..rejection).internal/daemonintegration/scenario failures (T3/T6/ReviewLoop/OrphanSweep/Reap —br --version handshake failed/ claim-timeout) were verified to fail identically on the parent commit without these changes; they are environmental and unrelated to this work.Does NOT touch
BeadsVersion/internal/release/manifest.go(deliberately excluded).🤖 Generated with Claude Code