Skip to content

repo-fleet-hygiene:audit: discovery hard-fails (exit 2) on a non-repository .git marker instead of recording discovery-skip #4207

Closed

Description

@kyle-sexton

Problem

/repo-fleet-hygiene:audit D: aborts the whole run on the first directory under the root whose .git marker is not a working tree:

Error: not a Git working tree: D://packages/uv/sdists-v9

Exit code 2, no report. D:/packages/uv/sdists-v9/.git is a zero-byte file that uv writes into its cache. git rev-parse --show-toplevel fails with fatal: invalid gitfile format.

The skill and the add_target comment both document the opposite behavior: origin discovery records an UNKNOWN discovery-skip finding and the rest of the fleet is still audited ("a husk under --root must not abort every subsequent repository").

Cause

reject_target (skills/audit/scripts/audit-fleet.sh, ~line 1646) returns early only for origin == config. Every other origin, including discovery, reaches exit 2. So record_rejected_target discovery ... in add_target never runs. The unreadable-with-.git branch in discover_repositories (~line 1800) has the same problem.

Fix

Make reject_target return for discovery as well as config. Only cli and default should hard-fail. Add a test: a --root containing an empty .git file next to a real repository should produce a discovery-skip finding and still audit the repository.

Workaround

Pass --skip node_modules --skip vendor --skip .venv --skip packages.

Observed in repo-fleet-hygiene 0.23.29 on Windows 11 with Git Bash.

Activity

  1. added
    needs-triage
    on Sep 19, 2026
  2. added
    agent-ready
    status: ready
    and removed
    needs-triage
    on Sep 23, 2026
  3. added theissue type on Sep 23, 2026
  4. kyle-sexton commented on Sep 23, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during triage.

    Agent Brief

    Type: Bug
    Summary: Fix the discovery-origin git working-tree rejection so a non-repository .git marker under a root-scoped scan yields a discovery-skip finding and the fleet audit continues, rather than aborting the whole run.

    Current behavior:
    When fleet discovery walks a configured root and finds a directory whose .git is a non-working-tree marker (for example, an empty file a package-manager cache writes), the audit hard-fails: it prints an error and exits non-zero, so no report is produced and every other repository under the root goes unaudited. This rejection is meant to apply only to explicitly-configured or command-line targets, not to targets found by walking a root.

    Desired behavior:
    A .git marker that fails to resolve as a working tree during root-walk discovery must not abort the run. Instead the audit records a discovery-skip finding for that path (kind discovery-skip, confidence UNKNOWN) and continues auditing every other repository found under the root. Rejections for an explicitly-named repository target and the implicit default target continue to hard-fail as before, since those are targets the operator chose directly and give them something actionable.

    Key interfaces:

    • The target-rejection function's origin-based policy: it already returns (rather than exits) for a config origin; it must do the same for a discovery origin. Only an explicitly-named-repository origin and the implicit default origin remain hard-failing.
    • The root-walk discovery routine's handling of a .git marker that cannot be resolved as a working tree: it must record a discovery-skip finding for that path instead of propagating the rejection as a fatal error.
    • The discovery-skip finding kind already exists in the finding registry as UNKNOWN, non-actionable, "Path skipped; the rest of the fleet was audited" — this brief exercises that existing kind, not a new one.

    Acceptance criteria:

    • Running the fleet audit over a root containing one directory whose .git is a non-working-tree marker (an empty regular file) alongside one real Git repository exits with the audit's normal successful-run status and produces a full report.
    • The report contains a discovery-skip finding for the husk path.
    • The real repository under the same root is still audited and produces its own findings.
    • Running the audit against an explicitly-named repository target that is itself a non-working-tree .git marker still hard-fails with a non-zero exit, unchanged from current behavior.
    • Running the audit with no scope arguments against an implicit default target that is a non-working-tree .git marker still hard-fails with a non-zero exit and prints the existing remedy text, unchanged from current behavior.

    Out of scope:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions