Repository navigation
test(herdr): make real-herdr-gated lane portable across environments - #56
Conversation
Three suites in the real-herdr-gated family failed permanently on a captain box while the required Herdr CI lane stayed green, which is exactly the "permanently red trains everyone to ignore the suite" shape. All three were the suite reading the operator's environment instead of its own fixture. tests/herdr-test-safety.sh: unset an inherited FM_HOME, the same fix tests/lib.sh already carries, which these suites never got because they do not source it. For the Herdr backend this is a workspace-IDENTITY leak, not just a config-path one: fm_backend_herdr_workspace_label reads "$FM_HOME/.fm-secondmate-home", so an exported FM_HOME pointing at a SECONDMATE home labels the suite's primary workspace 2M-<scope> instead of 1M-FIRSTMATE. That broke fm-backend-herdr-smoke's restart-stability check (before=w1 after=) and fm-backend-herdr-prune-safety-e2e's adoption check (adopted :w2 instead of the pre-created w1). tests/fm-herdr-session-cleanup-e2e.test.sh: pin SHELL=/bin/bash before the lab server starts. That server hands its own login shell to every pane it RESTORES, and a per-create --env SHELL does not survive the stop/restore cycle this case exercises. Inheriting the operator's interactive shell means a zsh startup that forks a persistent helper leaves the restored pane with a child forever, so the childless bare idle-shell proof can never converge. tests/fm-afk-inject-herdr-e2e.test.sh: replace two fixed dwells that wait for a daemon-produced result with bounded polls (wait_for_log, wait_for_file). Scenario A's post-Enter digest wait and Scenario D's max-defer alarm wait were both races against the daemon's next poll under a serially-loaded box - the reported flake, plus the one it produced on a full-family run here. The negative dwell that proves the daemon does NOT inject while input is pending stays a fixed wait. Fixes robots-7jy9.
|
Warning Review limit reached
Next review available in: 32 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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
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. Comment |
The previous commit replaced the fixed sleeps in Scenarios B and C with wait_for_log, which fixed a real flake but silently weakened what those two cases actually test. Each of them carries two assertions, not one: - positive: the daemon eventually injects a digest - negative: marker_count == 1, i.e. it does NOT inject a SECOND one wait_for_log returns on the FIRST match. Counting markers immediately after it therefore samples the log at the earliest possible instant, so a duplicate digest injected on the daemon's next poll would arrive after the count and never be seen. The old sleep 10 / sleep 8 happened to cover that window; the bounded poll does not. Both cases stayed green while losing the ability to fail on exactly the bug they were written for - "swallowed Enter produces exactly ONE clean digest". Add a short explicit dwell between the positive wait and the count. A negative assertion has nothing to poll for, because the correct outcome is that nothing further happens, so it needs a dwell for the same reason Scenario A's pending-input wait does. The daemon runs at FM_POLL=1 here, so three seconds covers several poll cycles while remaining far shorter than the sleeps the positive waits replaced. Scenarios A and D need no equivalent: neither performs an "exactly one" count after its positive wait. Refs robots-7jy9.
…56) * tests: make the real-herdr-gated lane environment-independent Three suites in the real-herdr-gated family failed permanently on a captain box while the required Herdr CI lane stayed green, which is exactly the "permanently red trains everyone to ignore the suite" shape. All three were the suite reading the operator's environment instead of its own fixture. tests/herdr-test-safety.sh: unset an inherited FM_HOME, the same fix tests/lib.sh already carries, which these suites never got because they do not source it. For the Herdr backend this is a workspace-IDENTITY leak, not just a config-path one: fm_backend_herdr_workspace_label reads "$FM_HOME/.fm-secondmate-home", so an exported FM_HOME pointing at a SECONDMATE home labels the suite's primary workspace 2M-<scope> instead of 1M-FIRSTMATE. That broke fm-backend-herdr-smoke's restart-stability check (before=w1 after=) and fm-backend-herdr-prune-safety-e2e's adoption check (adopted :w2 instead of the pre-created w1). tests/fm-herdr-session-cleanup-e2e.test.sh: pin SHELL=/bin/bash before the lab server starts. That server hands its own login shell to every pane it RESTORES, and a per-create --env SHELL does not survive the stop/restore cycle this case exercises. Inheriting the operator's interactive shell means a zsh startup that forks a persistent helper leaves the restored pane with a child forever, so the childless bare idle-shell proof can never converge. tests/fm-afk-inject-herdr-e2e.test.sh: replace two fixed dwells that wait for a daemon-produced result with bounded polls (wait_for_log, wait_for_file). Scenario A's post-Enter digest wait and Scenario D's max-defer alarm wait were both races against the daemon's next poll under a serially-loaded box - the reported flake, plus the one it produced on a full-family run here. The negative dwell that proves the daemon does NOT inject while input is pending stays a fixed wait. Fixes robots-7jy9. * no-mistakes(review): replace fixed sleeps in Scenarios B and C with wait_for_log * tests: restore duplicate detection in afk-inject Scenarios B and C The previous commit replaced the fixed sleeps in Scenarios B and C with wait_for_log, which fixed a real flake but silently weakened what those two cases actually test. Each of them carries two assertions, not one: - positive: the daemon eventually injects a digest - negative: marker_count == 1, i.e. it does NOT inject a SECOND one wait_for_log returns on the FIRST match. Counting markers immediately after it therefore samples the log at the earliest possible instant, so a duplicate digest injected on the daemon's next poll would arrive after the count and never be seen. The old sleep 10 / sleep 8 happened to cover that window; the bounded poll does not. Both cases stayed green while losing the ability to fail on exactly the bug they were written for - "swallowed Enter produces exactly ONE clean digest". Add a short explicit dwell between the positive wait and the count. A negative assertion has nothing to poll for, because the correct outcome is that nothing further happens, so it needs a dwell for the same reason Scenario A's pending-input wait does. The daemon runs at FM_POLL=1 here, so three seconds covers several poll cycles while remaining far shorter than the sleeps the positive waits replaced. Scenarios A and D need no equivalent: neither performs an "exactly one" count after its positive wait. Refs robots-7jy9. --------- Co-authored-by: fmtest <[email protected]>
…56) * tests: make the real-herdr-gated lane environment-independent Three suites in the real-herdr-gated family failed permanently on a captain box while the required Herdr CI lane stayed green, which is exactly the "permanently red trains everyone to ignore the suite" shape. All three were the suite reading the operator's environment instead of its own fixture. tests/herdr-test-safety.sh: unset an inherited FM_HOME, the same fix tests/lib.sh already carries, which these suites never got because they do not source it. For the Herdr backend this is a workspace-IDENTITY leak, not just a config-path one: fm_backend_herdr_workspace_label reads "$FM_HOME/.fm-secondmate-home", so an exported FM_HOME pointing at a SECONDMATE home labels the suite's primary workspace 2M-<scope> instead of 1M-FIRSTMATE. That broke fm-backend-herdr-smoke's restart-stability check (before=w1 after=) and fm-backend-herdr-prune-safety-e2e's adoption check (adopted :w2 instead of the pre-created w1). tests/fm-herdr-session-cleanup-e2e.test.sh: pin SHELL=/bin/bash before the lab server starts. That server hands its own login shell to every pane it RESTORES, and a per-create --env SHELL does not survive the stop/restore cycle this case exercises. Inheriting the operator's interactive shell means a zsh startup that forks a persistent helper leaves the restored pane with a child forever, so the childless bare idle-shell proof can never converge. tests/fm-afk-inject-herdr-e2e.test.sh: replace two fixed dwells that wait for a daemon-produced result with bounded polls (wait_for_log, wait_for_file). Scenario A's post-Enter digest wait and Scenario D's max-defer alarm wait were both races against the daemon's next poll under a serially-loaded box - the reported flake, plus the one it produced on a full-family run here. The negative dwell that proves the daemon does NOT inject while input is pending stays a fixed wait. Fixes robots-7jy9. * no-mistakes(review): replace fixed sleeps in Scenarios B and C with wait_for_log * tests: restore duplicate detection in afk-inject Scenarios B and C The previous commit replaced the fixed sleeps in Scenarios B and C with wait_for_log, which fixed a real flake but silently weakened what those two cases actually test. Each of them carries two assertions, not one: - positive: the daemon eventually injects a digest - negative: marker_count == 1, i.e. it does NOT inject a SECOND one wait_for_log returns on the FIRST match. Counting markers immediately after it therefore samples the log at the earliest possible instant, so a duplicate digest injected on the daemon's next poll would arrive after the count and never be seen. The old sleep 10 / sleep 8 happened to cover that window; the bounded poll does not. Both cases stayed green while losing the ability to fail on exactly the bug they were written for - "swallowed Enter produces exactly ONE clean digest". Add a short explicit dwell between the positive wait and the count. A negative assertion has nothing to poll for, because the correct outcome is that nothing further happens, so it needs a dwell for the same reason Scenario A's pending-input wait does. The daemon runs at FM_POLL=1 here, so three seconds covers several poll cycles while remaining far shorter than the sleeps the positive waits replaced. Scenarios A and D need no equivalent: neither performs an "exactly one" count after its positive wait. Refs robots-7jy9. --------- Co-authored-by: fmtest <[email protected]>
Intent
The developer wanted to make the real-herdr-gated test lane environment-independent so it could run portably across different environments without breaking. They modified three test files — herdr-test-safety.sh, fm-herdr-session-cleanup-e2e.test.sh, and fm-afk-inject-herdr-e2e.test.sh — to remove environment-specific dependencies. The goal was to improve cross-environment portability for the herdr safety checks, session cleanup, and AFK injection end-to-end tests.
What Changed
sleepwaits infm-afk-inject-herdr-e2e.test.shwith boundedwait_for_log/wait_for_filepolls (30–45 s timeout), eliminating timing-dependent flakes in the AFK-inject scenarios (A–D) while addingsettle_for_duplicatedwells where negative "no second injection" assertions still need a fixed window.SHELL=/bin/bashbefore lab server startup infm-herdr-session-cleanup-e2e.test.shso restored panes always come back as a bare bash — preventing a permanently-local-red from a captain box's zsh startup that forks a persistent helper (which the childless-shell proof then rejects).unset FM_HOMEtoherdr-test-safety.shso an ambient captain-boxFM_HOMEcannot silently outrank the workspace identity a test intends, matching the behavior of CI whereFM_HOMEis unset.Risk Assessment
✅ Low: All three changes are targeted portability fixes — replacing racy fixed sleeps with bounded polling and unsetting environment variables that cause CI/local divergence — with no logic changes to the assertions under test.
Testing
Ran targeted validation of all three changed files. FM_HOME is correctly dropped when herdr-test-safety.sh is sourced. The new polling helpers (wait_for_log, wait_for_file, settle_for_duplicate) behave correctly under async conditions. Both E2E test suites ran to completion with all assertions green on herdr 0.8.0.
Evidence: Full test output transcript
=== FM_HOME unset behavior (herdr-test-safety.sh) === PASS: FM_HOME is unset after sourcing herdr-test-safety.sh === wait_for_log / wait_for_file helper functions === PASS: wait_for_log returns 0 when pattern appears asynchronously PASS: wait_for_log returns 1 on timeout (no spurious match) PASS: wait_for_file returns 0 when file appears asynchronously PASS: wait_for_file correctly ignores empty files === SHELL=/bin/bash pin precondition === PASS: /bin/bash exists and is executable (SHELL pin precondition satisfied) === fm-herdr-session-cleanup-e2e.test.sh === ok - real named lab reproduced the exact restored one-tab one-pane childless no-agent shell shape ok - real named lab cleanup closes only the exact stale pane and preserves exact focus ok - real named lab cleanup is idempotent and leaves the default fleet session to the teardown tripwire evidence: herdr=0.8.0 protocol=19 default-session-tripwire=armed === fm-afk-inject-herdr-e2e.test.sh (Scenarios A-D) === ok - real herdr Scenario A: partial input defers injection; digest arrives clean after idle ok - real herdr Scenario B: swallowed Enter (via the herdr shim) produces exactly one clean digest ok - real herdr Scenario C: a normal captain status injects exactly one clean single-line sentinel digest ok - real herdr Scenario D: a persistently pending composer raises the max-defer wedge alarm, preserves the buffer, and never crashes the daemon all real-herdr afk injection e2e tests passedPipeline
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.
FM_HOME=/some/captain/home bash -c '. tests/herdr-test-safety.sh; check FM_HOME unset'— verifies the new unset FM_HOME takes effect when herdr-test-safety.sh is sourcedDirect exercise ofwait_for_logandwait_for_filehelpers with async writers and timeout cases — confirms 0 on match, 1 on timeout, -s empty-file rejectionbash tests/fm-herdr-session-cleanup-e2e.test.sh— all 3 restored-shell session cleanup assertions pass with SHELL=/bin/bash pinbash tests/fm-afk-inject-herdr-e2e.test.sh— Scenarios A, B, C, D all pass with new event-driven wait_for_log/wait_for_file replacing fixed sleeps✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.