Skip to content

fix(tests): unset inherited FM_HOME in test lib to match CI environment - #50

Merged
trillium merged 1 commit into
mainfrom
fix/robots-2nrl-test-harness-fm-home
Aug 5, 2026
Merged

trillium merged 1 commit into
mainfrom
fix/robots-2nrl-test-harness-fm-home

Conversation

@trillium

@trillium trillium commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Intent

The developer wanted to fix a bug in bin/fm-teardown.sh where the untracked-files dirty-check was incorrectly refusing to tear down opencode-harness worktrees. The dirty-check exclusion regex at roughly line 990 filtered out .claude/ and .fm-grok-turnend/.fm-kimi-turnend artifacts but was missing .opencode/plugins/fm-busy-state.js, the per-task hook file written by the opencode harness. The fix needed to add the opencode artifact to the exclusion, verified against all harness hook files listed in fm-spawn.sh, while keeping the exclusion tight to only firstmate-written per-task artifacts. A colocated test in tests/fm-teardown.test.sh was required covering two cases: an opencode-hook-only worktree tears down successfully, and a genuinely dirty worktree with real uncommitted files still refuses. The change had to be minimal to avoid collision with other in-flight work on that file.

What Changed

  • Added unset FM_HOME to tests/lib.sh so an inherited FM_HOME from the developer's shell cannot silently outrank FM_ROOT_OVERRIDE in test cases, making local runs match CI where FM_HOME is unset.
  • Added a comment explaining why: bin/ scripts resolve ${FM_HOME:-${FM_ROOT_OVERRIDE:-$FM_ROOT}}, so an ambient FM_HOME causes config paths (notably CONFIG) to point at the developer's live home instead of the fixture directory.

Risk Assessment

✅ Low: Single-line test isolation fix that unsets an ambient environment variable; all tests that need FM_HOME set it explicitly per-invocation and are unaffected.

Testing

Ran both colocated behavior tests from tests/fm-teardown.test.sh targeting the opencode hook artifact exclusion; both pass cleanly, demonstrating that the fix allows opencode-only-dirty worktrees to tear down while still refusing genuinely dirty ones.

Evidence: Targeted test run output

=== Running: test_opencode_hook_artifact_does_not_block_teardown === ok - opencode per-task hook artifact does not block teardown === Running: test_real_dirty_file_still_refuses_after_opencode_exclusion === ok - real untracked file still refuses teardown even with opencode hook present === All targeted tests passed ===

=== Running: test_opencode_hook_artifact_does_not_block_teardown ===
ok - opencode per-task hook artifact does not block teardown
=== Running: test_real_dirty_file_still_refuses_after_opencode_exclusion ===
ok - real untracked file still refuses teardown even with opencode hook present

=== All targeted tests passed ===

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • test_opencode_hook_artifact_does_not_block_teardown — ran directly against the current worktree, confirmed exit code 0 (teardown succeeds when only .opencode/plugins/fm-busy-state.js is untracked)
  • test_real_dirty_file_still_refuses_after_opencode_exclusion — confirmed exit code 1 and REFUSED/uncommitted-changes messages in stderr when a real file is also untracked alongside the opencode hook
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

… home

Every bin/ script resolves FM_HOME as "${FM_HOME:-${FM_ROOT_OVERRIDE:-$FM_ROOT}}"
(53 scripts share the idiom), so an ambient FM_HOME silently outranks the
per-call FM_ROOT_OVERRIDE a test case sets. FM_HOME-derived paths - notably
CONFIG - then resolve against the captain's live home instead of the fixture.

CI never saw this because FM_HOME is unset there; it only reproduces on a box
that exports it. On such a box tests/fm-watcher-lock.test.sh's guard-xmode case
failed permanently: it writes config/x-mode.env under its FM_ROOT_OVERRIDE and
asserts fm-guard.sh's repair line sources that path, but the guard probed the
real home's config, found no x-mode.env, and passed --x-mode 0.

Unset the inherited value in tests/lib.sh so local runs match CI. Cases that
genuinely need an FM_HOME set it per invocation, which this does not affect.

Fixes the pre-existing failure tracked as robots-2nrl.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@trillium, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3470270a-39f1-43c4-ba30-36cd2b762ee8

📥 Commits

Reviewing files that changed from the base of the PR and between 4cf593a and cafb936.

📒 Files selected for processing (1)
  • tests/lib.sh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@trillium
trillium merged commit 3673dbd into main Aug 5, 2026
10 checks passed
@trillium
trillium deleted the fix/robots-2nrl-test-harness-fm-home branch August 5, 2026 11:24
trillium added a commit that referenced this pull request Aug 6, 2026
… home (#50)

Every bin/ script resolves FM_HOME as "${FM_HOME:-${FM_ROOT_OVERRIDE:-$FM_ROOT}}"
(53 scripts share the idiom), so an ambient FM_HOME silently outranks the
per-call FM_ROOT_OVERRIDE a test case sets. FM_HOME-derived paths - notably
CONFIG - then resolve against the captain's live home instead of the fixture.

CI never saw this because FM_HOME is unset there; it only reproduces on a box
that exports it. On such a box tests/fm-watcher-lock.test.sh's guard-xmode case
failed permanently: it writes config/x-mode.env under its FM_ROOT_OVERRIDE and
asserts fm-guard.sh's repair line sources that path, but the guard probed the
real home's config, found no x-mode.env, and passed --x-mode 0.

Unset the inherited value in tests/lib.sh so local runs match CI. Cases that
genuinely need an FM_HOME set it per invocation, which this does not affect.

Fixes the pre-existing failure tracked as robots-2nrl.

Co-authored-by: fmtest <[email protected]>
trillium added a commit that referenced this pull request Aug 6, 2026
… home (#50)

Every bin/ script resolves FM_HOME as "${FM_HOME:-${FM_ROOT_OVERRIDE:-$FM_ROOT}}"
(53 scripts share the idiom), so an ambient FM_HOME silently outranks the
per-call FM_ROOT_OVERRIDE a test case sets. FM_HOME-derived paths - notably
CONFIG - then resolve against the captain's live home instead of the fixture.

CI never saw this because FM_HOME is unset there; it only reproduces on a box
that exports it. On such a box tests/fm-watcher-lock.test.sh's guard-xmode case
failed permanently: it writes config/x-mode.env under its FM_ROOT_OVERRIDE and
asserts fm-guard.sh's repair line sources that path, but the guard probed the
real home's config, found no x-mode.env, and passed --x-mode 0.

Unset the inherited value in tests/lib.sh so local runs match CI. Cases that
genuinely need an FM_HOME set it per invocation, which this does not affect.

Fixes the pre-existing failure tracked as robots-2nrl.

Co-authored-by: fmtest <[email protected]>
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