Fixes the three gremlins observed 2026-07-18 (bead
age-gate-scripts-worktree-gitdir-p62wo):
1. **Gate scripts broke under hook env from linked worktrees** (#919
regression): new scripts/lib/repo-root.sh (GIT_*-scrubbed resolution,
BASH_SOURCE anchor, worktree-correct) swept across 32 scripts. Proof:
this PR's own push ran the pre-push gates from a linked worktree and
passed.
2. **core.bare=true recurrence**: mechanism proven (leaked GIT_DIR +
no-arg git init --bare rewrites the SHARED config); writer traced with
high confidence to a live Gas City city process (concrete suspect:
gascity cmd_rig_test.go runGitInTest, unscrubbed env + no-arg init
--bare — fork-side fix filed separately). Defense: new
always.git-config-hygiene gate fails fast on core.bare/test identities
with the repair command inline (--self-test proves fail-closed).
3. **Test/test@test.com identity leak**: writer convicted — our own
pre-push chain leaked GIT_DIR into go test, whose helpers wrote the
shared config via git -C (mechanism proven). Cut at both ends:
validate-go-fast scrubs env for children; every test git-helper set-site
scrubs; check-test-isolation gains a WARN-ratchet rule (baseline 3 →
FAIL at 0).
Gates: shellcheck rc=0 across 36 scripts; go build/vet clean;
655+379+149 tests; hygiene self-test; both originally-failing validators
pass under the repro env.
parity_only twins are GENERATED by codex-sync and verified by its byte-exact
drift gate; re-checking content rules on generated artifacts is the whack-a-mole.
lint-codex-native, runtime-sections, api-conformance, audit-parity, and
generated-artifacts now skip parity twins (treatment != bespoke) and check
hand-authored bespoke twins + the override layer only. A generated artifact is
verified by regenerate-and-diff, not by re-checking content rules.
Verified: bespoke Claude-isms still caught; parity twins with accurate cross-runtime
content (cass/cc-hooks) no longer trip the gates.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
age-yxl gated source references/** divergence but left SKILL.md-body divergence
ungated (the residual it filed). Same silent-staleness: a source SKILL.md body
edit with a stale twin is masked by a regen hash bump.
validate-codex-generated-artifacts.sh now requires a real non-marker twin
content change when a source SKILL.md *body* changed — scoped to the BODY on
purpose: frontmatter-only edits (hex-wiring fields the twin never carries:
consumes/produces/hexagonal_role/context_rel) need no twin change and stay green,
so legit hex-wiring pushes don't red main. Body-vs-frontmatter is detected by
comparing the frontmatter-stripped body across the scope's base ref
(head: HEAD~1..HEAD; worktree: HEAD..working; staged/upstream handled);
conservative — any ambiguity (new file, unresolved base) requires the twin.
TEST: 3 new cases — body divergence FAILs under both worktree and head scopes,
frontmatter-only change PASSes. Verified both FAIL tests fail against the
unfixed gate (guard the regression). Real-skill smoke: frontmatter-strip yields
the correct body on discovery/rpi/skill-builder.
Closes-scenario: age-j1g#skillmd-body-gate
Bounded-context: BC2-Skills
Evidence: tests/scripts/test-codex-generated-artifacts.sh
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PROBE (evidence, not inspection): built the post-mortem divergent state in a
worktree — edited skills/discovery/references/dag.md, ran regen-codex-hashes
(twin left stale), committed, ran both gates. check-codex-parity-drift.sh and
validate-codex-generated-artifacts.sh BOTH passed (exit 0). The audit is a
Claude-ism scanner that never reads source; the structural source->codex check
was satisfied by the regen marker bump alone (a counterfactual source-only
commit with zero codex files DID fail, proving the mechanism). Verdict: the
gate does NOT catch content divergence.
FIX (routed to the gate, per the verdict): validate-codex-generated-artifacts.sh
now requires a REAL twin content change to mirror a source references/** edit —
the generated .agentops-generated.json / .agentops-manifest.json bookkeeping no
longer satisfies the mirror requirement. Scoped to references/** (mirrored
near-verbatim) to avoid false-positiving the legit frontmatter-only/hex-wiring
flow that has no twin equivalent.
TEST: two new cases in test-codex-generated-artifacts.sh — divergence (regen
hash bump only) FAILs, mirrored edit PASSes. Verified the divergence test FAILs
against the unfixed gate (guards the regression) and PASSes against the fix.
DOCS: skill-builder/SKILL.md, AGENTS-CODEX.md, CLAUDE.md registry section now
state that editing an EXISTING skill needs a manual twin mirror (regen refreshes
hashes, not prose) — prior docs only warned about NEW skills. Dogfooded: this
commit's skill-builder edit is mirrored into its codex twin.
Closes-scenario: age-yxl#probe-and-gate-fix
Bounded-context: BC2-Skills
Evidence: .agents/learnings/2026-06-16-codex-twin-content-not-auto-mirrored.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The sync script overwrites manual edits to skills-codex/. Since codex
skills are now manually maintained, this script is a footgun.
Changes:
- sync-codex-native-skills.sh: exits with error + deprecation message
- validate-codex-generated-artifacts.sh: removed parity drift enforcement
(lines 138-186 that required source+codex to change together)
- install-codex.sh: skip sync call (skills-codex/ pre-built in bundle)
- install-codex-native-skills.sh: skip sync by default
Audit for drift manually: bash scripts/audit-codex-parity.sh