Repository navigation
fix(bin): keep inherited Git config entries when installing the trailer-strip hooks path - #6341
Conversation
|
|
Speaking as Kun's firstmate: Verdict: Tip vs main contract-class: restore VISION.md (each rule)
Greptile: FAILURE with non-blocking P2 (fish launch verification gap) — not a merge blocker once CI green; no P1. |
| result=$(isolated_pane_env GIT_CONFIG_COUNT="$count" fish -i -c \ | ||
| "source '$launch_file'; and exit 2; printf '\nSHELL-STILL-ALIVE\n'" 2>&1) | ||
| status=$? | ||
| expect_code 0 "$status" "invalid count must preserve the interactive fish pane" | ||
| assert_contains "$result" 'error: ' "count refusal must remain visible in fish" | ||
| assert_contains "$result" SHELL-STILL-ALIVE "count refusal killed the interactive fish pane" |
There was a problem hiding this comment.
The fish invalid-count check can pass even if the worker starts. The env-file helper supplies the expected error: text, and the worker probe’s final git config command can fail under the invalid count. That leaves source with a nonzero status, skips and exit 2, and satisfies the remaining assertions. The test therefore does not reliably catch a worker starting after a refused launch; it needs to check that the worker command was not reached.
7097fd2 to
2349ac4
Compare
…railer hooks path Problem: Every fleet launch prefixed the worker command with `export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0=...`. That replaced any `GIT_CONFIG_*` entries the pane already carried, so a scoped HTTPS credential setup such as `credential.helper=` followed by `credential.helper=!gh auth git-credential` was silently dropped. Git then fell back to the system or global helper (for example `osxkeychain` from the system gitconfig on macOS), so a worker meant to use a scoped token pushed with the user's personal credentials. Reproduction on main: GIT_CONFIG_COUNT=2 GIT_CONFIG_KEY_0=credential.helper GIT_CONFIG_VALUE_0= GIT_CONFIG_KEY_1=credential.helper GIT_CONFIG_VALUE_1='!gh auth git-credential' sh -c "<emitted launch>; git config --get-all credential.helper" prints none of the inherited entries, only the system helper (`osxkeychain` from Homebrew's system gitconfig on the reporting machine). Fix: The launch prefix now appends `core.hooksPath` at index `GIT_CONFIG_COUNT` and increments the count, resolved in the destination shell after any `config/launch-env-allowlist` filtering. The inherited count is validated as decimal before shell arithmetic, leading zeros are normalized (Git accepts `02`), and a count that cannot be extended within Git's signed int refuses. A refusal uses `return 1 2>/dev/null || exit 1`, so when the pane sources the launch file the error stays visible and the interactive shell survives instead of the pane dying with the message. Tests: `tests/fm-spawn-dispatch-profile.test.sh` gains a behavior test that runs the real emitted launch under sh, bash, and zsh with inherited credential-helper entries and counts `2` and `02`, then asks Git for `credential.helper` and `core.hooksPath`. The same test checks that an invalid or overflowing count refuses, and that sourcing the launch file from an interactive shell keeps that shell alive with the error visible. The exact-launch assertions in the dispatch-profile and Kimi suites now extract the emitted prefix through one `fm_test_launch_git_prefix` helper in `tests/lib.sh` instead of two hand-copied strings, whose content the behavior test covers. Risk: Top-level `return` outside a sourced file is unspecified by POSIX; verified on macOS sh (bash 3.2 in POSIX mode), bash, and zsh, and every path still ends nonzero before the worker command runs. The hook wrapper still unsets only `GIT_CONFIG_COUNT` and index 0, which is sufficient because Git ignores indexed entries once the count is unset. A launch that forwards `GIT_CONFIG_COUNT` without all of its indexed keys now fails in Git instead of being masked by the overwrite.
Install fish in the portable serial lane and run the credential-append and invalid-count refusal cases under fish. Under CI the spawn test fails instead of falling back to the static syntax check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…orbell The trust suite evaluated the whole launch command to find the final prompt argument, so it now also sourced the per-spawn git-config env file that the fake pane never writes. Drop that prefix the same way the dispatch suite does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The trust suite failed in CI because its copy of the launch parser missed the Git configuration prefix the dispatch suite's copies already stripped. Move the prefix and export stripping into tests/lib.sh next to fm_test_launch_git_prefix so the three parsers cannot drift again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tests env-file now writes the canonical (pwd -P) spelling of the hooks directory, matching what install records, so a symlinked path no longer makes the hook wrapper miss its own entry and silently skip the repository's hook. A new strip test passes a symlinked hooks path through env-file and fails without this change. The launch-env-allowlist test now also asserts the appended core.hooksPath, so a regression that drops the strip-hook entry only on the env -i path is caught. Without fish installed locally, the launch test now prints an explicit fish skip line and limits its pass message to sh, bash and zsh, instead of claiming every pane shell after only a static token check.
…configuration docs
The invalid-count refusal checks only asserted a nonzero status and the helper's own error text. If the launch line kept going after the refusal, the worker probe's final `git config` also failed under the bad count, so the checks still passed. The probe now prints a marker on stderr, and every refusal case in sh, bash, zsh and fish asserts the marker never appears. Dropping the `|| return 1 2>/dev/null || exit 1` guard from the launch line now fails the test.
Fixes kunchenguid#6339 On the Orca backend, `config/launch-env-allowlist` expands each allowlisted name in the destination pane, and that pane is an Orca terminal whose environment comes from the Orca app and the user's shell startup files. Allowlisted credentials therefore resolve to the user's personal values or to nothing, with no warning, while the same allowlist scopes tmux workers correctly. Add an opt-in `config/launch-env-tmux-session` naming one tmux session. On a fresh Orca spawn, before the worktree or terminal is allocated, fm-spawn reads each allowlisted name from that session's local environment with `tmux -u show-environment -t =<session> <name>`. The worker launches with the existing `env -i` boundary and operational floor, the snapshotted values in place of destination expansion, and `GIT_CONFIG_NOSYSTEM=1` so a system credential helper cannot answer for the worker. The source requires an allowlist, so tmux's automatic update-environment names such as `SSH_AUTH_SOCK` are never forwarded unless listed. A listed name missing from the session, an unreadable session, or a malformed selector refuses before allocation; an explicit `-NAME` record stays a deliberate unset. Values are shell-quoted only in the existing owner-only staged launch file, never terminal input, and the pane deletes that file as sourcing starts; a deletion failure refuses the worker launch and keeps the interactive shell. `-u` is required because tmux's non-UTF-8 client output replaces newlines and non-ASCII bytes in values with underscores. The source is opt-in and nothing changes for homes that do not create the file. When `config/backend` is orca, the allowlist is nonempty, and no source is configured, fm-spawn now prints a stderr warning that allowlisted names resolve from the Orca terminal, so the mismatch is no longer silent. It warns rather than refuses because refusing would stop every existing Orca home that uses an allowlist, which the triage asked not to assume. Other backends, relaunch (already refused on Orca), and secondmate inheritance are unchanged; the selector is not in the inherited configuration list. The scoped Git credential helper case also needs kunchenguid#6341, which stops fm-spawn's `core.hooksPath` entry from overwriting inherited `GIT_CONFIG_*` entries; this change does not depend on it. Tests in `tests/fm-spawn-orca-worktree.test.sh`: - A real-tmux regression on a private socket checks exact multiline UTF-8 values under absent and C locales through sh, Bash, and zsh, refusal of names that exist only server-globally or only inside another value, and exclusion of the automatic `SSH_AUTH_SOCK`. - Fake-Orca spawns execute the real staged launch file under synthetic personal credentials and cover the configured source, an empty allowlist, refusal before allocation for each invalid setting, file privacy and deletion before the worker runs, and the deletion-failure path. - The warning appears for a nonempty allowlist without a source and not for an empty allowlist or a configured source. Risk: the source keeps tmux and the named session as dependencies of Orca spawns, and secret values sit in a 0600 file under a 0700 directory until the pane sources it. It is not a filesystem sandbox; a worker can still read the user's credential files unless the harness restricts that. The hardened path was verified with the regressions above, not with a live Orca spawn.
8d119fa to
633c3ad
Compare
|
Speaking as Kun's firstmate: Verdict: Tip contract-class: restore VISION.md (each rule): One captain / Authority / Scripts / Restart / Delegation / Vendor / Scope — all align. Attestation: MATCH at tip. Live validation go (5/6). All required checks SUCCESS. Greptile P2 fish notes declined by author for scope (no workflow change) — non-blocking. Security tip: none (strengthens scoped helpers). Merging now. |
|
Speaking as Kun's firstmate: this is merged. Thank you @andrewli8 — really appreciate you taking the time on this. |
What Changed
bin/fm-spawn.shno longer overwrites the pane'sGIT_CONFIG_COUNT/KEY_0/VALUE_0with a singlecore.hooksPathentry. It now runs a newfm-git-strip-ai-trailers.sh env-file <hooks-dir> <out-file>subcommand inside the pane and sources the result. That subcommand writes one plainexportline into the private launch directory, adding the canonicalizedcore.hooksPathentry after whateverGIT_CONFIG_*entries the worker inherited. Inherited settings such as a scopedcredential.helpertherefore still apply, and the pane shell (fish included) only has to parse a simple command,&&,||, and the export list. TheLAUNCH_DIRderivation moved earlier in the script so the env file can be placed there.GIT_CONFIG_COUNTis not a decimal number, or is too large to add another entry within Git's signed int,env-fileexits with an error and the launch stops before the worker starts.GIT_CONFIG_*. They remove only the entries whosecore.hooksPathnames their own hooks directory, shift the remaining entries down, and then chain to the repository's own hook, so hooks like a git-lfspre-pushstill see inherited config.docs/configuration.mddescribes this behavior and the count refusal. Spawn, Claude-trust, and Kimi test suites now share a launch-command parser intests/lib.shthat understands the new prefix, and new tests cover env-file output, entry preservation in the wrappers, and refused counts.🤖 Generated with Claude Code
Risk Assessment
Testing
Built throwaway lab homes (bin/fm-lab-home.sh create, the committed tree checked out, a private tmux socket, TREEHOUSE_ROOT inside the lab, a local bare origin). Real fm-spawn.sh launched a raw-command probe worker into a real treehouse worktree. Ran it with a zsh pane at the target, with a zsh pane at the base commit (the bug reproduced), and with a fish 4.9.3 pane at the target; all target runs passed. The invalid and overflow count guard was exercised by sourcing a line in the same shape as the emitted launch prefix inside the live spawned zsh and fish worker panes. Setting a bad count for the whole pane makes git itself fail before treehouse get, so fm-spawn never reaches its own guard in that setup, and the worker never starts either way. Ran tests/fm-spawn-dispatch-profile.test.sh with fish on PATH; its fish-inclusive Git-config case passed. Ran tests/fm-git-strip-ai-trailers.test.sh: its two new regressions passed. Two earlier tests in that suite (unresolvable and valueless core.hooksPath) fail the same way at base 8c9c67de with the local git 2.46.2, so they predate this change. The suite stops at the first failure, so the new regressions ran with those two excluded. All labs, /tmp/fm-<id> dirs and the downloaded fish were removed. No UI surface is involved.git credential fillreturns the scoped token, not osxkeychai…Evidence: Target zsh pane: inherited credentials kept, hooksPath appended, trailer stripped, pre-push credential fill uses the scoped helper
Source: Target zsh pane: inherited credentials kept, hooksPath appended, trailer stripped, pre-push credential fill uses the scoped helper
Evidence: Base 8c9c67d: inherited credential helpers dropped (regression reproduced)
Source: Base 8c9c67de: inherited credential helpers dropped (regression reproduced)
Evidence: Target fish pane: spawn and credential preservation, plus live refusal of a bad or overflowing count
Source: Target fish pane: spawn and credential preservation, plus live refusal of a bad or overflowing count
Evidence: Target zsh pane: refusal of a bad or overflowing count, pane survives, worker never runs
Source: Target zsh pane: refusal of a bad or overflowing count, pane survives, worker never runs
Evidence: Lab-wide bad count: git fails before launch, worker never runs
Source: Lab-wide bad count: git fails before launch, worker never runs
Evidence: Lab-wide overflow count: git fails before launch, worker never runs
Source: Lab-wide overflow count: git fails before launch, worker never runs
Evidence: Lab driver script used for all runs
Source: Lab driver script used for all runs
Evidence: Target worker probe (zsh and fish identical)
Evidence: Base worker probe (before fix)
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ No issues found.
tests/fm-git-strip-ai-trailers.test.sh:454- test_unresolvable_project_hookspath_still_refuses and test_valueless_project_hookspath_still_refuses fail locally with git 2.46.2, and fail the same way at base 8c9c67d, so this change did not cause them. Because the suite stops at the first failure, the new regressions only ran locally with those two excluded. CI's git version decides whether they pass there.git credential fillreturns the scoped token, not osxkeychai…Lab spawn at target 633c3adf:bin/fm-lab-home.sh create+ private tmux socket + realfm-spawn.sh <id> projects/notes --mode local-only --yolo on --harness '/bin/sh probe.sh'with tmux server env GIT_CONFIG_COUNT=2 (credential.helper='' + scoped helper), zsh paneSame lab at base 8c9c67de for comparison (bug reproduced)Same lab at target with fish 4.9.3 as the pane shell. fish came from the official release .pkg payload (pkgutil --expand-full), ran from a temp dir only, and was deleted afterwards. No system install.Probe in the worker: dumped GIT_CONFIG_*,git config --get-all credential.helper, committed a message with a Co-Authored-By trailer, thengit pushto a local bare remote with a repo pre-push hook runninggit credential fillLive refusal: in the spawned zsh and fish worker panes, set GIT_CONFIG_COUNT=bad and 2147483647, sourced afm-git-strip-ai-trailers.sh env-file ... && . <file> || return 1 2>/dev/null || exit 1; /bin/sh probe.shline, and checked the error, source status 1, that the shell is still alive, and that the probe never ranLab-wide GIT_CONFIG_COUNT=bad and 2147483647 spawns: git fails intreehouse getbefore the launch and the worker never runsPATH=<temp fish>:$PATH bash tests/fm-spawn-dispatch-profile.test.sh(test_launch_preserves_inherited_git_config, fish included)bash tests/fm-git-strip-ai-trailers.test.sh(new regressions run with the two git-2.46-incompatible earlier tests excluded; both of those also fail at base)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.