2.8 KiB
2.8 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-dev-paths | Dev paths, repo root, and dev backend env | done | 1 | plan.md | ../../specs/platform/requirements/go-dev-launcher.md |
Task 01: Dev paths, repo root, and dev backend env
Port the pure path/env logic from apps/cli/src/{constants,kandev-env,dev}.ts into Go.
No process spawning in this task.
Acceptance
findRepoRoot(startDir)returns the nearest ancestor containing bothapps/backendandapps/web, also handling a start directory that is.../apps; it returns an error (not a fallback path) when no such ancestor exists.resolveDevBackendEnv(repoRoot)reproduces the three-way rule inapps/cli/src/dev.ts:125-167: inside a task workspace it setsKANDEV_HOME_DIR=<repoRoot>/.kandev-devand clearsKANDEV_DATABASE_PATH; outside one an explicitKANDEV_DATABASE_PATHwins; otherwise it uses the.kandev-devdefault.KANDEV_DEBUG_DEV_MODE=trueis set in all three branches, and the reported display DB path matches what the backend will derive.isInsideKandevTask(repoRoot)is true whenKANDEV_TASK_IDis set, or whenrepoRootis under<userHome>/.kandev/tasks/.
Verification
Use TDD. Add apps/backend/internal/launcher/devpaths_test.go covering each branch with
t.TempDir()-rooted fake trees (never the real filesystem root — see
apps/backend/CLAUDE.md, "Path/security tests"), then:
cd apps/backend && go test ./internal/launcher/ -run 'TestFindRepoRoot|TestResolveDevBackendEnv|TestIsInsideKandevTask' -race
Files
apps/backend/internal/launcher/devpaths.go(new)apps/backend/internal/launcher/devpaths_test.go(new)apps/backend/internal/launcher/constants.go— adddevKandevDotdir = ".kandev-dev",devKandevHome(repoRoot),kandevTasksDir(), andhealthTimeoutDevMS = 600000alongside the existinghealthTimeoutReleaseMS.
Inputs
apps/cli/src/dev.ts:112-167—resolveDevBackendEnv, including the comments explaining why dev always roots under.kandev-devand why a task-workspaceKANDEV_DATABASE_PATHis treated as leaked. Carry that reasoning across.apps/cli/src/kandev-env.ts— note its caveat that the path-prefix check is a defensive secondary signal, is case-sensitive, and does not resolve symlinks;KANDEV_TASK_IDremains the primary guarantee.apps/cli/src/constants.ts:47-56—DEV_KANDEV_DOTDIR,devKandevHome.- Existing
apps/backend/internal/launcher/constants.gofor the resolve-* naming style.
Risks
- Do not change
resolveHomeDir/resolveDataDir/resolveDatabasePath;start,run, andserviceall depend on their current env-reading behavior. os.UserHomeDir()can fail; mirror the existing.kandevrelative fallback rather than panicking.