fix(daemon): reuse managed workdirs for squad leaders#5429
Open
wjueyao wants to merge 5 commits into
Open
Conversation
|
@wjueyao is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Pre-merge design audit after tracing the role and session contracts:
The last point is locked by commit Fresh verification on the updated branch: All passed locally. |
Require matching managed-env metadata and task markers before reusing a squad leader's prior workdir. Cover spoofed path shapes and assert the provider receives the resume session. Refs: multica-ai#5535
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?
Squad-leader follow-ups on the same issue currently receive
prior_session_idand
prior_workdirfrom the server, but the daemon unconditionally skipsworkdir reuse for leader tasks. The subsequent per-cwd resume gate then drops
the prior session because the new task has a different workdir, so every
leader follow-up starts a fresh provider session.
This change allows leader tasks to reuse a prior workdir only when its
canonical path has the managed
{workspace}/{task}/workdirshape, its parentGC metadata identifies a completed non-local issue env for the same
workspace/issue, and its task-context marker matches the same agent/issue.
External, malformed, unmarked, and local-directory paths fail closed.
Non-leader behavior is unchanged.
Thinking path:
resume_session=trueandreuse_workdir=true, but the daemon loggeddropping prior session: workdir not reusedand started a new Codex thread.!task.IsLeaderTaskreuse condition inrunTask, beforegateResumeToReusedWorkdir.completed non-local GC metadata, and a matching daemon task marker.
coverage for lookalike paths, missing/mismatched metadata, and regular files.
Related Issue
Closes #5535
Regression introduced by #4951. Related to the same-issue session-resume contract tracked in #3435 and #3625.
Type of Change
Changes Made
shouldReusePriorWorkdirto distinguish completed daemon-managed leaderworkdirs from external or residual
local_directorypaths.task-context marker before preserving the provider session.
mismatched, metadata-free, local-directory, and non-directory paths.
How to Test
Commands run:
All scoped checks pass. I also ran
go test ./...; it exposed an unrelated,pre-existing timing failure in
TestExecuteAndDrain_CodexInactivityReportsToolResultTranscriptwhere Codexinitialization exceeded its 5-second deadline. The same test failed 2/3 times
when rerun alone, while
go test ./internal/daemon/... -count=1passed.Local dogfood
I built this branch as a local
multicabinary, started its daemon against areal workspace, and added a third follow-up comment to the same squad-assigned
issue and leader used for the reproduction.
f5bfb6c8-1a39-4307-8bb8-ecc189e787f94e0b1f0a-994a-42c2-a274-37d444db32f8f5bfb6c8/workdir.019f63b9-68ff-7521-875c-97455589ff2f.codex thread resumedwith that same thread ID.The fixed run completed successfully, and the agent independently reported the
same
CODEX_THREAD_ID. No builder or reviewer was dispatched.Risks
The reuse check canonicalizes both paths with
filepath.EvalSymlinks, rejectsnon-directories and symlink escapes, then requires parent GC metadata for the
same workspace/issue with
local_directory=falseplus a task marker for thesame agent/issue. Missing or malformed provenance fails closed. This means a
follow-up after an interrupted run with incomplete metadata may start fresh;
that availability trade-off preserves the local-directory lock invariant.
Checklist
apps/web/features/landing/i18n/) and relevant docs (apps/docs/content/docs/)apps/docs/content/docs/developers/conventions.zh.mdx(terminology, mixed-rule fortask/issue/skill)AI Disclosure
AI tool used: OpenAI Codex App / Codex CLI
Prompt / approach: Dogfood a minimal squad workflow, inspect the daemon and
task logs when same-issue leader follow-ups failed to resume, trace the workdir
reuse gate in source, then implement the smallest fail-closed fix with regression
tests before running scoped package, race, and vet checks.
Screenshots (optional)
Not applicable; daemon-only behavior change.