Full test sweep for the worktree decision table #325

Closed
opened 2026-11-05 21:44:30 +00:00 by david · 1 comment
Owner

Summary

Confirm every branch of ADR-022's decision table and every worktree.dir path rule has a named test, plus batch and resume assertions. A verification pass — no production-code changes expected.

Background

Earlier steps in this series implement the worktree: section end to end:

  • config schema + shape validation (src/config/services/configFile.ts),
  • the parse-time dir validation helper (src/config/helpers/validateWorktreeDir.ts),
  • worktree routing (src/shared/git/services/resolveWorktree.ts),
  • the CLI early-fetch gate (src/cli/services/runCli.ts).

This final step walks the decision table and the code paths, adding tests for anything missing. If a test exposes a real gap (a missing error path, a routing bug), fix the code and list the fix in the PR description.

Decision table (ADR-022 §2):

Section enabled dir Expected behavior
absent — — bare: default parent (dirname(repo)); normal: run in place
present absent → true present create/reuse a worktree under dir (both repo kinds); validated at parse time
present true absent ConfigFileError
present false present today's behavior; dir never validated
present false absent today's behavior; no error

Depends on: #320, #321, #322, #323.

Implementation Details

Test areas (extend the existing test files; no new seams):

  • Config (src/config/services/configFile.test.ts): section shape (enabled only, dir only, both); all five decision-table rows; relative worktree.dir → error; ~ and ~/x → tilde-specific error; dir equal to / inside the repo root → error; parent-of-repo and sibling (/srv/wt2 vs /srv/wt) → pass; dir pointing at a file → error; unknown key inside the section → error.
  • Worktree resolution (src/shared/git/services/resolveWorktree.test.ts): worktreeDir used as parentDir; registry wins over worktreeDir; normal clone creates a worktree when worktreeDir is set; normal clone runs in place when worktreeDir is undefined.
  • CLI (src/cli/services/runCli.test.ts): widened early-fetch gate for a normal clone with enabled: true; no early fetch for a normal clone with the section absent or disabled; ConfigFileError from a bad dir → error.json with kind: 'config', exit 1; resolveWorkDirFn/fetchIssueFn doubles matching the current signatures.
  • Batch and resume: a resume reuses the registry entry, ignoring a changed worktree.dir; the batch-mode per-issue behavior matches what the early-fetch step documented (regression assertion — batch runs in the launch repo unless that step found the batch path routes through worktree resolution).

Acceptance Criteria

  • Every decision-table row has at least one named test.
  • Each dir rule (tilde, relative, equal-to-root, inside-root, sibling, parent, file, missing) has at least one named test.
  • The batch and resume assertions above exist and pass.
  • No production-code changes — or any that fix a real gap are listed in the PR description.
  • npm run lint and npm test are clean.

Test Plan

Run npm test — the full suite is the verification. Spot-check the new tests by name in the output.

## Summary Confirm every branch of ADR-022's decision table and every `worktree.dir` path rule has a named test, plus batch and resume assertions. A verification pass — no production-code changes expected. ## Background Earlier steps in this series implement the `worktree:` section end to end: - config schema + shape validation (`src/config/services/configFile.ts`), - the parse-time `dir` validation helper (`src/config/helpers/validateWorktreeDir.ts`), - worktree routing (`src/shared/git/services/resolveWorktree.ts`), - the CLI early-fetch gate (`src/cli/services/runCli.ts`). This final step walks the decision table and the code paths, adding tests for anything missing. If a test exposes a real gap (a missing error path, a routing bug), fix the code and list the fix in the PR description. Decision table (ADR-022 §2): | Section | `enabled` | `dir` | Expected behavior | | --- | --- | --- | --- | | absent | — | — | bare: default parent (`dirname(repo)`); normal: run in place | | present | absent → `true` | present | create/reuse a worktree under `dir` (both repo kinds); validated at parse time | | present | `true` | absent | `ConfigFileError` | | present | `false` | present | today's behavior; `dir` never validated | | present | `false` | absent | today's behavior; no error | **Depends on:** #320, #321, #322, #323. ## Implementation Details Test areas (extend the existing test files; no new seams): - **Config** (`src/config/services/configFile.test.ts`): section shape (`enabled` only, `dir` only, both); all five decision-table rows; relative `worktree.dir` → error; `~` and `~/x` → tilde-specific error; `dir` equal to / inside the repo root → error; parent-of-repo and sibling (`/srv/wt2` vs `/srv/wt`) → pass; `dir` pointing at a file → error; unknown key inside the section → error. - **Worktree resolution** (`src/shared/git/services/resolveWorktree.test.ts`): `worktreeDir` used as `parentDir`; registry wins over `worktreeDir`; normal clone creates a worktree when `worktreeDir` is set; normal clone runs in place when `worktreeDir` is undefined. - **CLI** (`src/cli/services/runCli.test.ts`): widened early-fetch gate for a normal clone with `enabled: true`; no early fetch for a normal clone with the section absent or disabled; `ConfigFileError` from a bad `dir` → `error.json` with `kind: 'config'`, exit 1; `resolveWorkDirFn`/`fetchIssueFn` doubles matching the current signatures. - **Batch and resume**: a resume reuses the registry entry, ignoring a changed `worktree.dir`; the batch-mode per-issue behavior matches what the early-fetch step documented (regression assertion — batch runs in the launch repo unless that step found the batch path routes through worktree resolution). ## Acceptance Criteria - [ ] Every decision-table row has at least one named test. - [ ] Each `dir` rule (tilde, relative, equal-to-root, inside-root, sibling, parent, file, missing) has at least one named test. - [ ] The batch and resume assertions above exist and pass. - [ ] No production-code changes — or any that fix a real gap are listed in the PR description. - [ ] `npm run lint` and `npm test` are clean. ## Test Plan Run `npm test` — the full suite is the verification. Spot-check the new tests by name in the output.
david closed this issue 2026-11-06 04:26:50 +00:00
Author
Owner

pi-loop opened and merged a pull request for this issue: #331

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-loop/pulls/331
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
2025-12-31
Dependencies

No dependencies set

Reference
david/pi-loop#325
No description provided.