docgen: defensive ENOENT guards + status warns on missing pre-push hook - #2
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 pushreturns. When that happens,writeFileSyncthrows ENOENT and the whole batch crashes — no doc commit ever lands.Repro evidence from
/tmp/docgen-push-hook.logon a downstream user — 5+ failed runs all withENOENT: no such file or directory, open '/private/tmp/integrate-public-N/...'.Fix:
existsSync(target)check at the top ofanalyzeOne,mkdirSync(dirname(readmePath), {recursive: true})before write, catchENOENT/ENOTDIR/EACCESaroundwriteFileSync, return{skipped: 'vanished'}cleanly.2.
docgen statuswarns when the pre-push hook isn't installedGit hooks aren't versioned — every fresh clone starts without one, so auto-refresh quietly never fires. Operators had no signal.
docgen statusnow scans all 4 candidate install locations for theDOCGEN_PRE_PUSH_HOOK_v1marker 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