Skip to content

fix(backends): refuse an hc below the verified version floor - #8001

Closed
LuizBrugnera wants to merge 2 commits into
kunchenguid:mainfrom
LuizBrugnera:fm/hc-version-floor
Closed

LuizBrugnera wants to merge 2 commits into
kunchenguid:mainfrom
LuizBrugnera:fm/hc-version-floor

Conversation

@LuizBrugnera

@LuizBrugnera LuizBrugnera commented Oct 30, 2026 •

Copy link
Copy Markdown

Intent

Follow-up to #7963 (the experimental, explicit-only hc / herdr-core runtime backend), offered on that PR as "a minimum hc --version check in container_ensure with a clear message, which helps when nodes run different hc versions" and accepted by its author for after it landed.
Goal: container_ensure, the spawn-time gate, reads hc --version and refuses an hc older than 0.1.13, the oldest herdr-core this backend was measured on, or a version it cannot read, before any terminal is created, with an update hint (hc update).
A -pre or +build suffix is ignored, so a prerelease of a newer version passes; anything else that is not plain dotted digits is refused.
The version probe drops HC_SOCKET like every other hc call.
Scope is only the floor: the HC_SOCKET drop originally planned next to it already landed in #7963, so it is not repeated here, and nothing else changes.
Tests: a fake-hc case pins refusal of older, missing and non-numeric versions with the core never touched, and acceptance of 0.1.13, a newer prerelease, 0.2.0 and 1.0 (disabling the check makes it fail); the real-hc smoke suite passes through the same gate with hc 0.1.14, and the verification table records the hc --version output shape on 0.1.13 and 0.1.14.
Keep #7963's names; no private host names, IPs, accounts or people; one sentence per line in Markdown.

What Changed

  • fm_backend_hc_container_ensure in bin/backends/hc.sh now reads hc --version, with HC_SOCKET dropped, before it touches the core. It refuses any hc older than FM_BACKEND_HC_MIN_VERSION=0.1.13, and any output it cannot parse as a version, with an error that names the floor and suggests hc update. The new helper fm_backend_hc_version_at_least compares the version numerically part by part. It drops a -pre or +build suffix first and rejects anything else that is not plain dotted digits.
  • The fake hc stub in tests/fm-backend-hc.test.sh now answers --version. A new test checks that hc 0.1.12, hc 0.0.99, a bare hc, hc 0.1.x and empty output are refused before any server call. It also checks that hc 0.1.13, hc 0.1.15-rc.1, hc 0.2.0 and hc 1.0 are accepted.
  • docs/hc-backend.md now lists hc 0.1.13 or newer as a prerequisite and says a spawn refuses an older or unreadable version. docs/verification/runtime-backends.md adds a row recording the hc --version output shape on 0.1.13 and 0.1.14.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: This is a small, contained spawn-time gate on the explicit-only hc backend: container_ensure is the only caller ahead of create_task (bin/fm-spawn.sh:5078), the version probe drops HC_SOCKET, and tracing the comparator through the floor, prerelease, unreadable and newer-version inputs gave the right answer each time.

Testing

hc is not on PATH. I copied a real herdr-core 0.1.14 binary, left in /tmp by an earlier session, into a scratch directory and drove the adapter against private cores only. I ran the real-hc smoke suite, which passes through container_ensure. I ran the fake-hc unit suite, the gate in 13 version cases, and a mutation check showing the new test catches a disabled gate. Everything passed, and the scratch directories were removed.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Spawn gate with real hc 0.1.14: container_ensure passes and the full real-hc smoke lifecycle (create, send, capture, cwd, agent_state, kill) succeeds ✅ pass live hc-smoke-real-0.1.14.txt
An hc older than 0.1.13 (0.1.12, 0.0.99, 0.1.12-rc.1) is refused with a message naming 0.1.13 and 'hc update', and no core is started ✅ pass live hc-version-floor-gate.txt
An unreadable version (empty output, bare 'hc', '0.1.x', or --version exiting non-zero) is refused before the core is touched ✅ pass live hc-version-floor-gate.txt
Versions at or above the floor (0.1.13, 0.1.15-rc.1, 0.2.0+build.7, 1.0, 0.1.13.1) are accepted and the private core starts ✅ pass live hc-version-floor-gate.txt
The version probe drops an exported HC_SOCKET ✅ pass live hc-version-floor-gate.txt (probe env: HC_SOCKET=<unset> with HC_SOCKET=/nonexistent/sock exported)
The new fake-hc test fails when the floor check is disabled ⏸️ untested no The previous payload recorded this only as a unit-test mutation check, not a run against the live product, so it did not establish a live result. The mutation run itself reported 'not ok - container_e…
Evidence: Real-hc smoke suite through the version gate (hc 0.1.14)

Source: Real-hc smoke suite through the version gate (hc 0.1.14)

$ hc --version
hc 0.1.14
$ bash tests/fm-backend-hc-smoke.test.sh
ok - hc smoke: create_task started fmt3175707:t1
ok - hc smoke: current_path follows the shell's cwd
ok - hc smoke: send_text_line ran the command and capture shows its output
ok - hc smoke: agent_state reads dead for a shell and alive for an agent-named foreground
ok - hc smoke: kill closes and removes the terminal
FM_TEST_COMPLETE
exit=0
Evidence: container_ensure version-floor matrix against a real core (refuse/accept, HC_SOCKET dropped, no core on refusal)

Source: container_ensure version-floor matrix against a real core (refuse/accept, HC_SOCKET dropped, no core on refusal)

--- hc --version -> __real__
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
--- hc --version -> hc\ 0.1.12
  container_ensure rc=1 output: error: hc 'hc 0.1.12' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> hc\ 0.0.99
  container_ensure rc=1 output: error: hc 'hc 0.0.99' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> hc
  container_ensure rc=1 output: error: hc 'hc' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> ''
  container_ensure rc=1 output: error: hc 'unknown' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> hc\ 0.1.x
  container_ensure rc=1 output: error: hc 'hc 0.1.x' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> hc\ 0.1.12-rc.1
  container_ensure rc=1 output: error: hc 'hc 0.1.12-rc.1' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> __fail__
  container_ensure rc=1 output: error: hc 'unknown' is older than 0.1.13, the oldest herdr-core this backend was verified on, or its version is unreadable; update it with 'hc update'
  probe env: HC_SOCKET=<unset>
  core socket created: 
--- hc --version -> hc\ 0.1.13
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
--- hc --version -> hc\ 0.1.15-rc.1
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
--- hc --version -> hc\ 0.2.0+build.7
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
--- hc --version -> hc\ 1.0
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
--- hc --version -> hc\ 0.1.13.1
  container_ensure rc=0 output: fmv3188208
  probe env: HC_SOCKET=<unset>
  core socket created: yes
Evidence: Fake-hc backend suite

Source: Fake-hc backend suite

$ bash tests/fm-backend-hc.test.sh
1..13
ok - hc: explicit-only, spawn-capable, with its tool set
ok - hc: create_task starts an independent labeled terminal and refuses a duplicate
ok - hc: fm-control interrupt delivers the harness's interrupt key
ok - hc: another task's, another home's, or an unlabeled terminal gets no input and no close
ok - hc: an empty session never falls through to the ambient core
ok - hc: an inherited HC_SOCKET never overrides the session pin
ok - hc: agent_state maps foreground, finished, not_found and core errors onto the shared vocabulary
ok - hc: agent_state reads a shell wrapper's process group before calling it dead
ok - hc: kill ends and removes the terminal and refuses when it survives
ok - hc: teardown's expected label refuses another task's terminal and closes the matching one
ok - hc: capture, visible capture, and current path read the recorded terminal
ok - hc: endpoint validation requires window to equal hc_session:hc_terminal
ok - hc: container_ensure refuses an hc older than the verified floor or with no readable version
FM_TEST_COMPLETE
exit=0

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.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Spawn gate with real hc 0.1.14: container_ensure passes and the full real-hc smoke lifecycle (create, send, capture, cwd, agent_state, kill) succeeds ✅ pass live hc-smoke-real-0.1.14.txt
An hc older than 0.1.13 (0.1.12, 0.0.99, 0.1.12-rc.1) is refused with a message naming 0.1.13 and 'hc update', and no core is started ✅ pass live hc-version-floor-gate.txt
An unreadable version (empty output, bare 'hc', '0.1.x', or --version exiting non-zero) is refused before the core is touched ✅ pass live hc-version-floor-gate.txt
Versions at or above the floor (0.1.13, 0.1.15-rc.1, 0.2.0+build.7, 1.0, 0.1.13.1) are accepted and the private core starts ✅ pass live hc-version-floor-gate.txt
The version probe drops an exported HC_SOCKET ✅ pass live hc-version-floor-gate.txt (probe env: HC_SOCKET=<unset> with HC_SOCKET=/nonexistent/sock exported)
The new fake-hc test fails when the floor check is disabled ⏸️ untested no The previous payload recorded this only as a unit-test mutation check, not a run against the live product, so it did not establish a live result. The mutation run itself reported 'not ok - container_e…
  • PATH=&lt;scratch hc 0.1.14&gt;:$PATH bash tests/fm-backend-hc-smoke.test.sh (real herdr-core, private core)
  • bash tests/fm-backend-hc.test.sh (fake-hc suite including test_container_ensure_refuses_an_hc_below_the_version_floor)
  • Ran the real fm_backend_hc_container_ensure (sourced through bin/fm-backend.sh) against real hc 0.1.14. A scratch shim changed only the --version output (13 cases), with HC_SOCKET exported. Each case recorded the exit code, the message, the HC_SOCKET value the probe saw, and whether a core socket was created.
  • Mutation check: disabled the floor check in bin/backends/hc.sh, confirmed the new test fails ('container_ensure must refuse version hc 0.1.12'), then restored the file (clean worktree)
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → no changes applied ✅
  • ⚠️ linter found issues (exit code 1)

🔧 No changes applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

container_ensure, the spawn-time gate, now reads `hc --version` and
refuses anything older than 0.1.13, the oldest herdr-core this backend
was measured on, or a version it cannot read, before any terminal is
created. A node with a stale hc then fails with an update hint instead of
partway through a spawn, which matters once several machines run
different hc releases. A `-pre` or `+build` suffix is ignored, so a
prerelease of a newer version passes.

A fake-hc case pins the refusal (older, missing, or non-numeric
versions, with the core never touched) and the accepted versions; the
real-hc smoke suite passes through the same gate with hc 0.1.14.
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the failed-probe issue is fixed.

Reviews (2) · Last reviewed commit: "fix(hc): refuse a version probe that exi..." · Reviewed by Greptile

Comment thread bin/backends/hc.sh Resolved
Capture the full `hc --version` output and check its exit status before
taking the first line, so a probe that prints a valid version but fails
is refused like an unreadable version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarceloCajueiro

Copy link
Copy Markdown

Hi! I'm following this one closely: I'm waiting on the hc backend work to move my Firstmate setup to the Herdr desktop app. A version floor check would save me from silent breakage when my hc and the adapter drift apart.

If anything is needed to move this forward (testing on macOS against a real Herdr.app/herdr-core, reproducing a review finding, or picking up a follow-up), I'm happy to help. Just let me know.

@LuizBrugnera

Copy link
Copy Markdown
Author

Superseded by #8037, which ships the same version-floor and failed-probe checks with a stricter 0.1.14 floor.

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.

3 participants