Files
Bo f091314f49 fix: harden GC factory recovery; kill the core.bare test git-env leak at the test layer (#923)
Follow-ups on the bead-native Gas City factory (#917) plus the durable
fix for the recurring core.bare corruption class
(age-cmdao-core-bare-pollution-ek8v, recurred 2026-07-18).

## GC factory hardening (7 commits)
- crash-replayable bead transitions; program/refinery recovery
reconciliation
- ordered rejection recovery; rescope fenced on source closure
- guarded direct rescope dispatch and successor reduction
- ship the managed Gas City template

## core.bare / git-env test isolation
- New `cli/internal/testsupport.ScrubGitDiscoveryEnv()` called from
`TestMain` in all 11 packages whose tests shell out to git (cmd/ao,
adapters/gate, archcheck, canon, doctor, eval, gates, goals, paths,
quality, vibecheck). Mechanism reproduced: hook-injected `GIT_DIR` at a
linked worktree gitdir redirects fixture `git init` into the SHARED
.git/config (`core.bare=true`). Complements #922 (per-helper scrubs +
hygiene gate) with package-wide process-level scrubbing.
- Unit tests pin the scrub behavior and the var list; convention
documented in both go.md standards (codex twin regenerated).
- Verified under a hostile hook-shaped env against a decoy repo: suites
green, decoy and real repo untouched.

## Merge reconciliation
- Adopted main's hermetic `aoBinary` (build-from-source flag matrix;
supersedes the equivalent fix made independently here).
- Repaired the auto-merge-corrupted
`skills-codex/.agentops-manifest.json` by reset + `regen-all.sh` (check
passes clean).

Full `go test ./...`: 49 packages ok, rc=0.
2026-07-18 18:43:28 -04:00

44 lines
1.2 KiB
Go

package testsupport
import (
"os"
"testing"
)
func TestScrubGitDiscoveryEnv_UnsetsEveryDiscoveryVar(t *testing.T) {
for _, key := range GitDiscoveryEnvVars {
t.Setenv(key, "/tmp/decoy-repo/.git")
}
ScrubGitDiscoveryEnv()
for _, key := range GitDiscoveryEnvVars {
if got, ok := os.LookupEnv(key); ok {
t.Errorf("expected %s to be unset after scrub, still set to %q", key, got)
}
}
}
func TestGitDiscoveryEnvVars_CoverHookInjectedSet(t *testing.T) {
// Guard the list itself: these are the vars git sets when running hooks
// (githooks(5) / git(1) ENVIRONMENT). Dropping one silently reopens the
// ek8v redirection hole, so removal must be a deliberate edit here.
want := map[string]bool{
"GIT_DIR": true,
"GIT_WORK_TREE": true,
"GIT_INDEX_FILE": true,
"GIT_PREFIX": true,
"GIT_OBJECT_DIRECTORY": true,
"GIT_COMMON_DIR": true,
"GIT_NAMESPACE": true,
}
if len(GitDiscoveryEnvVars) != len(want) {
t.Fatalf("GitDiscoveryEnvVars has %d entries, want %d", len(GitDiscoveryEnvVars), len(want))
}
for _, key := range GitDiscoveryEnvVars {
if !want[key] {
t.Errorf("unexpected var %q in GitDiscoveryEnvVars", key)
}
}
}