Repository navigation
Harden AutoCTO: input validation, gh error handling, deterministic scan (fixes #1) - #2
Merged
Merged
Conversation
analyze/report previously printed a normal-looking empty report when given a path that does not exist, so a typo was indistinguishable from a real but empty repository. scan_repo now raises FileNotFoundError / NotADirectoryError, and the analyze, report, and plan commands catch it and exit with a clean one-line error and a non-zero code. Updated the repo test to assert the new behavior. Fixes #1 Co-Authored-By: Claude Opus 4.8 <[email protected]>
Staff-engineer audit + repair across every module. No new features; each change closes a crash path or nondeterminism. Test count 13 -> 32. github.py: wrap every gh failure (bad repo, auth, network, timeout, unparseable output) in a readable GhError hierarchy instead of leaking CalledProcessError / TimeoutExpired / JSONDecodeError; validate owner/name and limit up front. cli.py: _llm() no longer crashes when the Personal LLM core is absent - it degrades to a stub that reports why. All gh-backed commands catch the broad GhError; report --repo downgrades a fetch failure to a warning and still writes the local report. repo.py: deterministic primary_language on ties (alphabetical); os.walk that prunes ignored dirs in place (never descends into .git/node_modules/venv) and skips unreadable subtrees via onerror instead of aborting. Tests: new test_cli.py (CliRunner exit codes, no leaked tracebacks), full gh-failure matrix, determinism + nested-prune cases. 32/32 pass offline. Co-Authored-By: Claude Opus 4.8 <[email protected]>
zaidwhy
added a commit
that referenced
this pull request
Sep 28, 2026
Raise on a missing or non-directory path in scan_repo
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.
Hardening pass over AutoCTO so it has no soft spots. No new features - every change closes a real crash path or nondeterminism. Test count went 13 -> 32, all offline.
What was fragile
ghfailure crashed with a raw traceback - a nonexistent repo, not being authenticated, no access, a rate limit, or a network blip all raised an uncaughtCalledProcessError;TimeoutExpiredand malformed JSON were unhandled too. OnlyGhNotAvailablewas caught.report/plancrashed when the Personal LLM core was not installed - theimport personal_llmin_llm()was outside any guard, so a fresh clone that skipped the core install got a traceback instead of the documented graceful degradation.primary_languagewas nondeterministic on ties -max()over a filesystem-ordered dict, so the same repo could report a different primary language across machines..git,node_modules,venv) and could abort on aPermissionErrorin a locked subtree.Changes
github.py: aGhErrorbase (withGhNotAvailableas a subclass) surfaces every failure - badowner/name, non-positive limit, non-zero exit (with stderr), timeout, spawn failure, unparseable / non-array output - as a readable error.cli.py:_llm()degrades to a stub that reports the reason and never raises; all gh-backed commands catch the broadGhError;report --repodowngrades a fetch failure to a warning and still writes the local report. Also fixes analyze/report silently reports a missing path as an empty repo #1 (missing/non-directory path now errors cleanly with exit 1).repo.py: deterministicprimary_language(alphabetical tie-break);os.walkthat prunes ignored dirs in place (never descends into them, faster on big repos) and skips unreadable subtrees viaonerror.Tests
test_cli.py: TyperCliRunnerasserts exit codes and that no raw traceback leaks on any error path.test_github.py: full failure matrix (missing gh, bad repo, non-zero exit, timeout, bad/non-array JSON, empty output, happy path).test_repo.py: missing path, non-directory, nested-ignore prune, deterministic tie, empty repo.pytest tests/ -q-> 32 passed.Live-verified
triageon a missing repo and a malformed repo string,report --repoon a missing repo (warns, still writes), andanalyze .(venv/.git pruned) - all clean, correct exit codes, no tracebacks.Fixes #1