fix(daemon): precheckout task repos before agent start (MUL-2454)#2915
Open
KiwiGaze wants to merge 1 commit into
Open
fix(daemon): precheckout task repos before agent start (MUL-2454)#2915KiwiGaze wants to merge 1 commit into
KiwiGaze wants to merge 1 commit into
Conversation
|
@KiwiGaze is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
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.
What does this PR do?
Fixes daemon-side repo isolation for local agent tasks so agents start with managed worktrees instead of needing to discover and run
multica repo checkoutthemselves.flowchart TD A["Daemon claims task"] --> B["registerTaskRepos(task.Repos)"] B --> C["Prepare or reuse isolated workdir"] C --> D["preCheckoutTaskRepos"] D --> E{"Repo cache ready?"} E -- "yes" --> F["Create managed git worktree under workdir"] E -- "no" --> G["Keep fallback checkout instructions"] F --> H["Inject runtime config with LocalPath"] G --> H H --> I["Start agent in isolated workdir"] I --> J["After completion: audit workdir for raw clones"]Root cause: agents could ignore the runtime brief and run raw
git clone, bypassing the daemon repo cache and per-task worktree isolation. This change moves the happy path into the daemon before the agent starts, while retaining the existing checkout command as a fallback when precheckout cannot complete.Related Issue
Fixes #2639
Type of Change
Changes Made
server/internal/daemon/daemon.goGetWorkspaceReposdoes not return them..git/clone directories in the task workdir.server/internal/daemon/execenv/execenv.goRepoContextForEnv.LocalPathfor already-created worktree paths.server/internal/daemon/execenv/runtime_config.gomultica repo checkoutfallback instructions when precheckout fails.How to Test
Run targeted daemon verification:
Manual test case: Project-Only Repo Precheckout Creates Managed Worktree
Setup:
https://github.com/octocat/Hello-World.git.multica repo checkoutorgit clone.Steps:
agent_task_queue.work_dir.<work_dir>/AGENTS.mdor<work_dir>/CLAUDE.mdand confirm the repository line saysalready checked out at <work_dir>/<repo-name>.<work_dir>/<repo-name>/.gitand confirm it is a file whose contents point into the daemon repo cache worktrees directory, not a.git/directory.task_messagerows for that task and confirm there are nogit cloneormultica repo checkouttool invocations.Expected result:
Local evidence from this PR branch:
Kiwi-Labsworkspace, usingHello-Worldas the project repo resource.Hello-World/READMEand a.gitpointer file under the task workdir.git cloneand zeromultica repo checkoutcommands for the verified runs.Known local caveat:
go test ./...currently fails in unrelatedserver/pkg/agentfake CLI timeout tests (codex,opencode,copilot,claude). The touched daemon, execenv, and repo-cache packages pass uncached.Checklist
Risks