Repository navigation
test: gate real-Herdr tests on a provisionable lab and assert resolver contracts, not host identity - #1
Merged
Conversation
command -v herdr proves a binary is on PATH and proves nothing about session state, so every real-Herdr test hard-failed on an ordinary machine where herdr is installed but no default session runs - the lab helper's fleet-state tripwire needs one. Add a gate command to bin/fm-herdr-lab.sh, the owner of that tripwire, so the gate and provisioning can never disagree, and route all ten gated tests through it.
Two tests read the identity of whatever harness and runtime session happened to launch the suite: fm-secondmate-harness stubbed process ancestry but left bin/fm-harness.sh's env markers ambient, and those are consulted FIRST - so CLAUDECODE=1 decided the result under claude, and an ambient PI_CODING_AGENT would have satisfied the no-Pi-marker case for the wrong reason. fm-session-start pins herdr_session=default in its fake-herdr fixtures, but a firstmate running inside a NAMED herdr session resolved that operator session instead, because ambient selection is the documented backend contract (fm_backend_herdr_session). Both now drop the ambient inputs on each call, the idiom run_session_start already used for harness markers.
…rage guard Adds the gate's own coverage: with a running default session it passes silently and provisioning really succeeds; with the session stopped, absent, unlistable, or herdr/jq missing it refuses with one reason line naming the cause. Each case also asserts the gate agrees with what provisioning would do, so the two cannot drift. A gate can also fail by skipping too much, which would look green. The required CI Herdr lane is what forbids that - it starts a default session and must run the real bodies - so --fail-on-gate-skip becomes repeatable, the lane lists the new token too, and a test binds that token to the lane.
Upstream kunchenguid#1282 forbids asserting implementation-source bytes, so the ci.yml grep is gone. The guarantee it protected - a renamed gate cause or token slipping past the required Herdr lane's over-skip guard - now runs through executables instead: the real bin/fm-herdr-lab.sh gate produces a real refusal reason, and the real runner must fail on it under the token.
…r and probe Herdr once
mattadams-dev
added a commit
that referenced
this pull request
Jul 31, 2026
…mmits) Conflicts: 8 test files, one uniform pattern - fork PR #1's provisionable-lab gate vs upstream's new inherited-pane hygiene at the same insertion point. Resolved as the union everywhere (gate first, then pane hygiene): the two changes are complementary, not competing. fm-secondmate-harness kept the fork side whole - upstream's seven assertions all exist there and the file's tail references the fork's nomarkers array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Make firstmate's own test suite green on an ordinary developer machine by fixing how 12 tests gate on their preconditions. These tests were red for environmental reasons, not because any production code was broken, and a suite that is red by default trains everyone to ignore red - which is exactly when a real regression slips through.
Two distinct causes
1. Eleven tests: an installed-but-not-running dependency hard-failed instead of skipping.
The real-Herdr tests gated on
command -v herdr, which passes whenever the binary is on PATH but proves nothing about session state. They then required a running default Herdr session and hard-failed when there wasn't one. The bug was the gate, not the environment.Fix: gate on whether an isolated lab can actually be provisioned, via a new
gatesubcommand onbin/fm-herdr-lab.sh. Its verdict derives from the samefm_herdr_lab_fleet_statecall thatprepare/provisionuse, so the gate and the provisioning tripwire can never disagree. Tests now skip with a reason naming the missing precondition instead of failing on something they cannot create.2. One test asserted a specific harness name.
fm-secondmate-harnessexpectedpiand gotclaude, because resolution reads the actual process ancestry of whatever harness runs the suite. An earlier partial fix stubbed ancestry with a fakeps, but that was insufficient:bin/fm-harness.shconsults its env markers first, soCLAUDECODE=1decided the result before the ancestry stub was ever reached, and an ambientPI_CODING_AGENTwould have satisfied the "no Pi marker" case for the wrong reason.Fix: drop every ambient marker per call and set only the ones each case is about, so the test asserts the resolver's contract rather than the host runtime's identity.
tests/fm-session-start.test.shhad the same class of ambient coupling (a named herdr session overriding its pinned fake fixture) and is corrected the same way.Both directions are proven
A gate that always skipped would hide the same regressions a red suite does, so the pass direction is proven too:
defaultsession (a hard safety constraint; the lab helper's tripwire requires that session to stay byte-identical).The lane derives its token from
bin/fm-herdr-lab.sh gate-tokenrather than repeating a string literal, so renaming the token cannot leave the lane guarding a string the gate no longer prints.bin/fm-test-run.shalso refuses an empty--fail-on-gate-skiptoken, since an empty token matches nothing and would silently disable the guard the caller asked for.No coverage was weakened
No test is disabled or deleted. The branch's test diff removes exactly one line - a fixture conditional in the fake-herdr stub - and no assertions.
Verification
Full suite on an ordinary machine (Herdr installed, no running default session): 95 total, 0 failed.
Before/after on the same machine,
--family real-herdr-gated:total=10 failed=10 skipped_gate=0total=10 failed=0 skipped_gate=9Cause 2 reproduced and confirmed fixed under deliberately hostile ambient env (
CLAUDECODE=1,HERDR_SESSION=co-captain).The CI guarantee was exercised by running the lane's exact command shape on a session-less machine: it failed with all ten flagged
required gate skip token seen.Follow-up filed separately
The gate, the runner's token guard, and the CI lane remain coupled. That structural redesign is deliberately not attempted here and is filed as its own task, starting from this improved state.