Skip to content

docgen: defensive ENOENT guards + status warns on missing pre-push hook - #2

Merged
decider merged 1 commit into
mainfrom
fix/docgen-defensive-enoent
May 23, 2026
Merged

docgen: defensive ENOENT guards + status warns on missing pre-push hook#2
decider merged 1 commit into
mainfrom
fix/docgen-defensive-enoent

Conversation

@decider

@decider decider commented May 23, 2026

Copy link
Copy Markdown
Owner

Two reliability fixes for the docgen auto-refresh chain.

1. analyzeOne survives a vanished target directory

The detached background docgen process (spawned by the pre-push hook) can race a parent automation that deletes the worktree right after git push returns. When that happens, writeFileSync throws ENOENT and the whole batch crashes — no doc commit ever lands.

Repro evidence from /tmp/docgen-push-hook.log on a downstream user — 5+ failed runs all with ENOENT: no such file or directory, open '/private/tmp/integrate-public-N/...'.

Fix: existsSync(target) check at the top of analyzeOne, mkdirSync(dirname(readmePath), {recursive: true}) before write, catch ENOENT/ENOTDIR/EACCES around writeFileSync, return {skipped: 'vanished'} cleanly.

2. docgen status warns when the pre-push hook isn't installed

Git hooks aren't versioned — every fresh clone starts without one, so auto-refresh quietly never fires. Operators had no signal. docgen status now scans all 4 candidate install locations for the DOCGEN_PRE_PUSH_HOOK_v1 marker and prints a loud yellow warning + install command if missing.

Tests

44/44 pass. No behavior change for the existing test suite — new guards only fire on conditions the existing tests don't simulate.

🤖 Generated with Claude Code

Targeted reliability patch (no Promise.allSettled change — kept the
existing throw-fast behavior since the --scope tests rely on it).

1. analyzeOne survives a vanished target directory — covers the
   worktree-cleanup race where another tool spawns + tears down a
   temp clone before our detached background docgen finishes.
   existsSync(target) check at the top, mkdirSync parent before
   write, ENOENT/ENOTDIR/EACCES try-catch around writeFileSync →
   returns {skipped: 'vanished'} cleanly.
2. docgen status loudly warns when the pre-push hook isn't installed
   on this clone. New checkPreHookInstalled scans all 4 install
   layouts for the DOCGEN_PRE_PUSH_HOOK_v1 marker.

44/44 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@decider
decider merged commit 86421fd into main May 23, 2026
1 check passed
@decider
decider deleted the fix/docgen-defensive-enoent branch May 23, 2026 18:36
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.

2 participants