Skip to content

fix(bin): resolve relative homes before persisting paths - #3

Merged
sparkus merged 6 commits into
mainfrom
fm/fix-secondmate-relative-status-path
Jul 29, 2026
Merged

fix(bin): resolve relative homes before persisting paths#3
sparkus merged 6 commits into
mainfrom
fm/fix-secondmate-relative-status-path

Conversation

@sparkus

@sparkus sparkus commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Intent

Prevent relative FM_HOME, FM_STATE_OVERRIDE, and FM_DATA_OVERRIDE values from baking unresolvable durable paths into generated charters or cross-process state, while preserving absolute path spellings unchanged.

What Changed

  • Resolve relative FM_HOME, FM_STATE_OVERRIDE, and FM_DATA_OVERRIDE values before generating briefs, launching agents, starting AFK mode, or persisting X-mode poll shims.
  • Preserve absolute path spellings, ignore inherited CDPATH, and report named errors when relative directories cannot be resolved.
  • Document the durable-path behavior and add regression coverage for relative homes, overrides, launch routes, and secondmate status paths.

Risk Assessment

✅ Low: The change is well-bounded, and the corrective commit closes the prior CDPATH path-redirection defect at every affected normalization boundary with focused competing-directory coverage.

Testing

At exact target 2fb2366 over base 488cbf7, four focused path-consumer test scripts passed; a retained CLI transcript demonstrates relative-home charter generation, absolute parent-status routing, persisted correlated output, and fail-loud invalid input, with the worktree left clean.

Evidence: Relative secondmate CLI transcript
$ FM_HOME=home bin/fm-brief.sh routing-sm --secondmate --no-projects

$ generated charter status/reporting lines
27:Optional helper: `bin/fm-secondmate-report.sh` can append a correlated status line for you, but a plain `echo` that includes the same `corr=<id>` is equally valid - do not depend on the helper being present.
36:   `echo "{state}: {one short line}" >> '/private/var/folders/bd/ky17fvwx45353ky4s2bg8ys80000gn/T/no-mistakes-evidence/01KYQK920C83W99WPGD8SSZGDT/relative-secondmate-cli/home/state/routing-sm.status'`

$ secondmate appends a real completion event to the charter destination
completed: corr=demo-relative-path absolute route verified

$ unresolved relative FM_HOME fails loudly
exit=1
error: FM_HOME directory cannot be resolved: missing-home

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 bin/fm-brief.sh:75 - Relative-path normalization inherits CDPATH. With an exported value such as CDPATH=.:.., cd &#34;$path&#34; can print its destination into the command substitution, producing a multi-line path; it can also select a same-named directory outside the caller's working directory. That corrupts the durable status/launch path this change is intended to fix. Clear CDPATH and use cd -- &#34;$path&#34; at this boundary and the equivalent sites in fm-spawn.sh, fm-afk-launch.sh, and fm-bootstrap.sh. Add a regression case with non-empty CDPATH.

🔧 Fix: Ignore inherited CDPATH during relative path normalization
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Inspected git diff 488cbf7804ab3f6b0625941df66f4df2fc869e02..2fb236610d879c34f1c66ecb36ac2615bf7834af and verified exact HEAD/base ancestry
  • bash tests/fm-brief.test.sh
  • bash tests/fm-spawn-dispatch-profile.test.sh
  • bash tests/fm-afk-launch.test.sh
  • bash tests/fm-x-mode.test.sh
  • Generated a secondmate charter using relative FM_HOME=home with a conflicting CDPATH, verified its absolute state/routing-sm.status route, appended and read back a correlated completion event, then verified missing relative FM_HOME exits 1 with a named diagnostic
  • Verified git status --short remained empty after testing
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Fix empty CDPATH assignments for ShellCheck
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

sparkus added 6 commits July 29, 2026 12:48
Resolve relative home, data, and state inputs before durable charter generation, and fail when caller-relative directories cannot be resolved.

Use absolute paths at the related spawn, AFK daemon, and X-mode cross-process handoffs so later processes cannot reinterpret them from another working directory.
@sparkus
sparkus merged commit 79d84b6 into main Jul 29, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant