Under the run-tests pre-push hook, git exports GIT_DIR to the hook, so the commit_as_base helper in plugins/kyberforge/.apm/skills/factory-audit/tests/validate-provenance-skill.bats ran git -C "$tmp" init/add/commit/update-ref against this repo instead of its temp dir. Every push: 84 failures, core.bare=true set on the checkout, index emptied.
tests/run-tests.sh now unsets GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR before any suite runs, so no current or future suite inherits the caller's repo.
LESSONS.md: new entry; the 2026-07-05 "repo root is a bare checkout" lesson was likely this bug's symptom.
Verification
Reproduced with GIT_DIR pointed at a throwaway repo: 61 failures.
After the fix, same leaked env through run-tests.sh --bats-only: 463 tests, 0 failures.
This branch's own push ran the full pre-push hook set green; core.bare stayed false.
Merge order
Merge this before docs/delivery-team-adr (and any branch cut from main): until it lands, pushing a branch from a main-based checkout re-triggers the corruption.
## Summary
Under the `run-tests` pre-push hook, git exports `GIT_DIR` to the hook, so the `commit_as_base` helper in `plugins/kyberforge/.apm/skills/factory-audit/tests/validate-provenance-skill.bats` ran `git -C "$tmp" init/add/commit/update-ref` against **this repo** instead of its temp dir. Every push: 84 failures, `core.bare=true` set on the checkout, index emptied.
- `tests/run-tests.sh` now unsets `GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR` before any suite runs, so no current or future suite inherits the caller's repo.
- `LESSONS.md`: new entry; the 2026-07-05 "repo root is a bare checkout" lesson was likely this bug's symptom.
## Verification
- Reproduced with `GIT_DIR` pointed at a throwaway repo: 61 failures.
- After the fix, same leaked env through `run-tests.sh --bats-only`: 463 tests, 0 failures.
- This branch's own push ran the full pre-push hook set green; `core.bare` stayed `false`.
## Merge order
Merge this before `docs/delivery-team-adr` (and any branch cut from `main`): until it lands, pushing a branch from a `main`-based checkout re-triggers the corruption.
SemVer impact: PATCH.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
Git exports GIT_DIR to the hooks it runs, so under the run-tests pre-push
hook the validate-provenance-skill.bats fixtures' `git -C "$tmp"` calls
resolved to this repo: 84 failures, core.bare=true and an emptied index on
every push. run-tests.sh now unsets git's repo-locating variables before
any suite runs. Reproduced with GIT_DIR pointed at a throwaway repo (61
failures) and verified clean after the fix (463/463).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Under the
run-testspre-push hook, git exportsGIT_DIRto the hook, so thecommit_as_basehelper inplugins/kyberforge/.apm/skills/factory-audit/tests/validate-provenance-skill.batsrangit -C "$tmp" init/add/commit/update-refagainst this repo instead of its temp dir. Every push: 84 failures,core.bare=trueset on the checkout, index emptied.tests/run-tests.shnow unsetsGIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIRbefore any suite runs, so no current or future suite inherits the caller's repo.LESSONS.md: new entry; the 2026-07-05 "repo root is a bare checkout" lesson was likely this bug's symptom.Verification
GIT_DIRpointed at a throwaway repo: 61 failures.run-tests.sh --bats-only: 463 tests, 0 failures.core.barestayedfalse.Merge order
Merge this before
docs/delivery-team-adr(and any branch cut frommain): until it lands, pushing a branch from amain-based checkout re-triggers the corruption.SemVer impact: PATCH.
🤖 Generated with Claude Code
https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN