Skip to content

Git workspace scanner produces no diagnostic output when it fails or finds nothing #58

Description

@JoshuaRowePhantom

Summary

GitWorkspaceScanTool and GitWorkspaceDiscoveryTool swallow all errors silently and
produce no observable output — no log messages, no result summary, no per-run status on
the tool-relationship entity. When the tool does not discover repositories there is no
way to determine whether it ran, what it scanned, what it skipped, or why it produced no
results.

Missing diagnostics

No logger

Neither GitWorkspaceScanTool nor GitWorkspaceDiscoveryTool accepts an
ILogger / ILoggerFactory. All exception paths and intermediate states are invisible.

Swallowed exceptions with no trace

GitWorkspaceScanTool.GetLocalFixedDriveRoots:

catch (IOException)
{
    return [];    // no log; caller cannot tell drives failed to enumerate
}

GitWorkspaceScanTool.EnumerateGitRepositories:

catch (Exception exception) when (exception is IOException or UnauthorizedAccessException)
{
    continue;     // no log; unknown how many directories were skipped
}

GitWorkspaceDiscoveryTool.DiscoverGitWorktreePaths:

catch (Exception exception) when (exception is UnauthorizedAccessException or DirectoryNotFoundException or IOException)
{
    continue;     // same problem
}

GitWorkspaceDiscoveryTool.GetGitMetadata:

catch (RepositoryNotFoundException) { return new GitMetadata(); }
catch (LibGit2SharpException)       { return new GitMetadata(); }
// both silent; no indication which repo failed LibGit2 open

WorkspaceToolExecutionResult carries no summary

WorkspaceToolExecutionResult has no fields for:

  • Repos found / skipped counts
  • Directories scanned
  • Errors encountered
  • Scan roots actually used

The caller (ScheduledToolHost) has no data to surface to the user or persist on the
entity.

tool-relationship entity not updated with run outcome

ScheduledToolHost stamps last-started before the run but never writes a
last-result, last-error, or repositories-found field back to the entity after
completion. There is no way to inspect the outcome of the last run without attaching a
debugger.

Proposed fixes

  1. Inject ILogger<GitWorkspaceScanTool> (and similarly for
    GitWorkspaceDiscoveryTool). Log:

    • Information: scan roots resolved, scan started/completed, repo count
    • Warning: drive enumeration failed, individual directory access denied (once per
      root, not per directory to avoid log spam)
    • Error: data layer write failure
  2. Add result fields to WorkspaceToolExecutionResult:

    public int RepositoriesFound { get; init; }
    public int DirectoriesSkipped { get; init; }
    public IReadOnlyList<string> ScanRootsUsed { get; init; }
    public string? ErrorSummary { get; init; }
  3. Persist run outcome on tool-relationship entity. After each run,
    ScheduledToolHost writes the result summary to fields such as
    last-result-repositories-found, last-result-error so it is visible in the UI and
    queryable from the database.

  4. Surface scan roots actually used in the result so operators can confirm the tool
    is scanning the expected paths.

Affected files

  • Phantom.Workspaces/Tools/GitWorkspaceScanTool.cs
  • Phantom.Workspaces/Tools/GitWorkspaceDiscoveryTool.cs
  • Phantom.Workspaces/ScheduledTools/ScheduledToolHost.cs
  • Phantom.Workspaces.Data.Core/JsonSchemas/tool-relationship.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingverifiedIssue has been verified

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions