Repository navigation
Fix #1898: consult auto-detects slugless builder worktrees; errors never list projects - #1899
Merged
Merged
Conversation
…ver list projects getBuilderProjectState() disambiguated multiple project dirs with a regex that required a -<slug> after the worktree number. Spec 653 worktrees are ID-only (.builders/bugfix-N, .builders/spir-N), so every hand-run `consult --type ...` in a builder worktree fell through to a throw that joined every project dir name into one line (~95k chars at ~2300 dirs). Consult now resolves the worktree's project with porch's own detectProjectIdFromCwd(), moved verbatim into the pure lib/worktree-project-id.ts (porch/state.ts re-exports it) so consult does not import porch's state module. All three not-found errors are one short line: what was tried, the project count, and "pass --issue <N> or --project-id <id>". A bugfix worktree now resolves to its bugfix-N project only; the old code tried N-... first and could pick a same-numbered SPIR project.
…mment the --project-id fallback Mirror porch's findProjectInDir: a leftover name-matching dir without status.yaml no longer shadows the real project, and the error hint's count is projects only. Comment why --project-id keeps the bugfix-<id> fallback while a worktree-derived ID does not. Thread: CMAP verdicts (all APPROVE) and the tunnel teardown flake.
waleedkadous
added a commit
that referenced
this pull request
Nov 15, 2026
waleedkadous
added a commit
that referenced
this pull request
Nov 15, 2026
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.
Summary
From a slugless builder worktree (
.builders/bugfix-N,.builders/spir-N), a hand-runconsult -m <model> --protocol <p> --type <t>exited 1 withMultiple projects found: <every project dir>— one line of ~95k characters in a repo with ~2300 project dirs, and no hint to pass--issue. Consult now resolves the worktree's project exactly as porch does, and every not-found error is one short line.Fixes #1898
Root Cause
getBuilderProjectState()inpackages/codev/src/commands/consult/index.tsdisambiguated multiple project dirs with its own regex,/\.builders\/[^/]*?-?(\d+)-([^/]+)/, which requires a-<slug>after the number. Spec 653 made worktrees ID-only, so the regex matched no current worktree, and the code fell through to a throw that joined every dir name. Porch already had a correct resolver for the same job (detectProjectIdFromCwd()); consult kept a second, drifted copy. Porch-driven runs were unaffected because porch passes--project-id.Reproduced with the installed consult 3.3.7 from this worktree: exit 1, a 13,250-char line listing 341 dirs. Seven earlier builder threads in
codev/state/record the same failure.Fix
getBuilderProjectState()callsdetectProjectIdFromCwd()and matches the dir with porch's<id>/<id>-<slug>rule. Both ad-hoc regexes are gone. This covers slugless and slugged worktrees, subdirectories, and tracker keys.detectProjectIdFromCwd()moved verbatim into the purelib/worktree-project-id.ts, andporch/state.tsre-exports it, so porch callers and tests are unchanged. Importingporch/state.tsfrom consult directly pulled in its load-timepromisify(execFile), which broke 70 tests in suites that mocknode:child_process.--project-id, the worktree ID, or the cwd),<count> projects in codev/projects/, andpass --issue <N> or --project-id <id>. The project list is never printed.status.yaml, as in porch'sfindProjectInDir. A leftover name-matching dir can't shadow the real project, and the error's count covers projects only. (CMAP follow-up)bugfix-N-…project only. The old code triedN-…first and could pick a same-numbered SPIR project. The slugged-worktree test pins this.Behaviour note: worktree prefixes porch does not recognise (for example a legacy
.builders/experiment-12-slug) used to match consult's generic regex. They now get the short error, the same as porch. No current (Spec 653) worktree matched that regex anyway.Test Plan
consult/__tests__/bugfix-1898-builder-project-detect.test.tscovers a slugless root, a subdirectory, a slugged worktree, a SPIR worktree and a tracker-key worktree, each among several projects. It also bounds each error's length with 2,300+ project dirs. 7 of the original 8 fail on the old code; the tracker-key case already worked and stays as a guard. A 9th test, a status-less dir not shadowing the real project, fails without the CMAP follow-up. All 9 pass.pnpm --filter @cluesmith/codev build)codev/specsandcodev-skeleton/protocols/bugfix, gets past detection toNo PR found for branch(expected before the PR existed). A simulated.builders/task-abcdgives one 338-char line.CMAP
All three lanes ran through this PR's own build with no
--issue, so they exercised the fixed path, and each auto-persisted intocodev/projects/bugfix-1898-…/.The claude lane on the local build first failed with API 400
"thinking.type.enabled" is not supported. The worktree lockfile installs@anthropic-ai/claude-agent-sdk0.2.105; the installed consult ships 0.2.141. It was re-run with the installed consult and--project-id. That failure is unrelated to this PR.Flaky Tests
One of three full runs exited 1 on an unhandled Node-internal
ERR_INTERNAL_ASSERTION(http2 teardown inMockTunnelServer.stop) fromagent-farm/__tests__/tunnel-edge-cases.test.ts, with all tests passing. It is unrelated to consult and ran clean 5 of 5 times in isolation. The test is not skipped.Not fixed, and unrelated: from
.builders/<id>/packages/,findWorkspaceRoot()stops atpackages/because it contains this repo's owncodevpackage dir. That comes from this repo's layout and predates this change.🤖 Generated with Claude Code