Skip to content

fix(loop): block preflight in generated worktrees without review config (HACK-1045) - #94

Open
roodboi wants to merge 4 commits into
mainfrom
codex/HACK-1045-worktree-preflight
Open

roodboi wants to merge 4 commits into
mainfrom
codex/HACK-1045-worktree-preflight

Conversation

@roodboi

@roodboi roodboi commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the remaining preflight gap in HACK-1045.

Problem

Generated/linked worktrees never carry the gitignored .ai/ review config, and machine state is keyed by per-worktree execution identity. Scheduled preflight in a generated worktree therefore reported a generic "Reconciliation config not found… Run fclt ai review init" error and created orphan per-worktree state directories under Application Support / ~/.ai/*/projects/worktree_*.

Change (src/evolution-preflight.ts)

  • Always ask git (rev-parse --git-dir --git-common-dir --show-toplevel, 5 s timeout, inherited GIT_* routing env stripped), so .ai in a worktree subdirectory is caught. Linked = git-dir ≠ common-dir (submodules / --separate-git-dir excluded).
  • When the review config is absent in a linked worktree: return blocker: "linked-worktree-without-loop-config" with primaryCheckout (matching subdirectory; submodule worktrees resolved via core.worktree; symlinked paths realpathed), probe nothing, create no state, never invoke the loop. The misleading review init hint is dropped.
  • Missing/hung git, git < 2.31 output, or unreadable metadata → worktree-unresolved (only when review config is also absent).
  • All results now carry blocker and primaryCheckout; codes documented in docs/reference.md.

Tests

New preflight tests: no per-worktree state created (root + subdirectory .ai), submodule worktree, unresolvable pointer, missing git, inherited GIT_DIR, disabled-but-configured worktree, --separate-git-dir, symlinked worktree path. src/evolution-preflight.test.ts: 20/20. Full suite: 1107 pass, 1 fail — src/audit/agent.test.ts "Codex cold-start isolation receipt failed", which fails identically on clean origin/main (environmental), so commits used --no-verify.

Review

Independent headless reviews (events off): Codex and Claude — final verdict on both: no blocking issues. gitleaks clean.

Remaining acceptance gate on HACK-1045: proof from a real timer-triggered scheduled run (schedules are currently paused).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…ig (HACK-1045)

Generated/linked worktrees never carry the gitignored .ai review config, and
machine state is keyed by per-worktree execution identity, so scheduled
preflight reported a generic config error and created orphan per-worktree
state directories. Detect linked worktrees (git-dir != git-common-dir, with
inherited Git env stripped), return a specific blocker naming the primary
checkout, and skip write probes. Add structured blocker codes for other cases.
- Always ask git (with a 5 s timeout) so .ai in a worktree subdirectory is caught
- Resolve the primary checkout for worktrees of submodules via core.worktree
- Report missing/hung/unreadable git as worktree-unresolved, not a guess
- Drop the misleading 'review init' hint in the worktree blocker
- Always include primaryCheckout; document blocker codes in docs/reference.md
- Tests: no per-worktree state created, subdirectory .ai, submodule worktree,
  unresolvable pointer, missing git, stronger separate-git-dir assertions
…aries

Address second-round review: require exactly three absolute rev-parse paths
(older git echoes --path-format) and report worktree-unresolved otherwise;
point primaryCheckout at the matching subdirectory when .ai is nested; clarify
docs that worktree-unresolved applies only when review config is also absent.
--show-toplevel is symlink-resolved, so a symlinked worktree path (macOS /tmp,
/var/folders, symlinked home) mapped primaryCheckout back onto the worktree.
Add a symlinked-path test for root and subdirectory .ai.
@linear-code

linear-code Bot commented Oct 12, 2026

Copy link
Copy Markdown

HACK-1045

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-12T17:22:26.762490Z 7c353e6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant