issue-321: Add parse-time directory validation helper for worktree.dir #327
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-321/add-parse-time-directory-validation-helper-for-wor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
321: Add parse-time directory validation helper for worktree.dir
Closes #321 — 321.
Generated in 24m 01s.
Review findings
I'll start by reading the current state of the files involved in both findings.
Now let me look at the test file and check the ADR-022 reference for context on the error message format:
Let me check ADR-022 for the prescribed error message format:
The ADR doesn't prescribe the exact message format, so consistency with the
configFile.tsconvention (finding 1) is the right bar. Let me look at theloadConfigFiletest setup and the barrel export:I now have the full picture. Both findings are feasible and small. Let me apply the fixes:
Fix 1 (filePath prefix) — add an optional
filePathfield to the input, default toCONFIG_FILE_NAME, prefix all messages, and pass the real path fromloadConfigFile.Fix 2 (tilde widening) — check 1 becomes
dir.startsWith('~').Now update
loadConfigFileto pass the actual file path so messages match the other parse-time errors:Now update the tests. First the helper test — add the
~user/wtcase to the tilde test and afilePath-prefix test:Now update the
loadConfigFileintegration test to verify the full config path is used in the message:Let me verify the final helper file and check for any other callers of
validateWorktreeDirI might have missed:All callers are covered. Now let me confirm the gate commands in
package.jsonand run the gates:Build passes. Now run the config module tests, then the full suite:
Config module is green (15 helper tests now). Full suite and lint:
Lint passes, but prettier wants a reformat in the helper. Let me apply it:
Prettier only rewrapped the string concatenation. Re-verify all gates after the reformat:
All gates green. One final full-suite run and a look at the complete working-tree diff to confirm the change is clean:
All gates pass after the fixes:
filePathprefix test)Both Low findings are resolved in a single pass:
filePathfield toValidateWorktreeDirInput(defaultCONFIG_FILE_NAME), prefixed all fiveConfigFileErrormessages with${filePath}:, and passed the real config path fromloadConfigFileso the helper's errors now match therequireString/requireBooleanconvention. Tests cover the default, an explicit path, and the full path throughloadConfigFile.dir.startsWith('~'), so~user/...gets the tilde-specific "write the full absolute path" message instead of the generic absolute-path one; the message mentions~user, and the tilde test now includes a~david/wtcase.No commit/stage/push was performed; the working tree carries the remediation for the pipeline to capture.
Review Findings — 321
Summary
Both Low findings fixed in a single pass. (1)
ValidateWorktreeDirInputnow carries an optionalfilePath(defaultCONFIG_FILE_NAME); all five helperConfigFileErrormessages are prefixed${filePath}:, andloadConfigFilepasses the real config path — helper errors now match theconfigFile.tsvalidation-helper convention, verified by new tests at both the helper andloadConfigFilelevel. (2) The tilde check was widened todir.startsWith('~')so~user/...values get the dedicated tilde guidance, with a~david/wtcase added to the existing tilde test. All gates re-ran and passed: build (tsc) pass, tests pass (152 files / 2206 tests), lint pass, prettier pass. Nothing remains unresolved.Critical
High
Medium
Low
ConfigFileErrormessages (lines 53, 62, 81, 92, 97) omit thefilePath:prefix that every otherconfigFile.tsvalidation error includes (e.g.piloop-config.yaml: "worktree.dir" must be a non-empty string...vs the helper's"worktree.dir" must exist and be a directory...), so two errors from the same config file have inconsistent formats. Suggested fix: add an optionalfilePathfield toValidateWorktreeDirInput(defaultCONFIG_FILE_NAME) and prefix each message with${filePath}:, matching therequireString/requireBooleanconvention.~and~/, so the same-family shell shorthand~user/...(e.g.dir: ~david/wt) falls through to the generic "must be an absolute path" message instead of the tilde-specific "write the full absolute path" guidance. Suggested fix: widen check 1 todir.startsWith('~')(safe on POSIX — any~-prefixed path is non-absolute, so it would be rejected by check 2 anyway) and add a~user/wtcase to the existing tilde test.