Skip to content

fix(manifest): continue past unavailable directories - #309

Merged
bobtista merged 3 commits into
developmentfrom
fix/manifest-discovery-unavailable-directories
Jul 29, 2026
Merged

fix(manifest): continue past unavailable directories#309
bobtista merged 3 commits into
developmentfrom
fix/manifest-discovery-unavailable-directories

Conversation

@bobtista

@bobtista bobtista commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Prevent recursive manifest discovery from aborting when a nested directory is inaccessible or removed during enumeration.

Traverse directories individually, preserve cancellation, log skipped paths, and continue discovering manifests in accessible siblings.

Add deterministic coverage for inaccessible and concurrently removed directories.

Testing

  • Focused manifest tests: 8 passed.
  • Core Release suite: 1,211 passed.

Dependency

Stacked on #305. Retarget to development after #305 merges.

Closes #308

Greptile Summary

Updates manifest discovery to continue scanning accessible sibling directories when nested paths become unavailable.

  • Replaces all-directory enumeration with cancellation-aware, directory-by-directory traversal.
  • Logs and skips filesystem enumeration failures caused by unavailable paths.
  • Adds deterministic tests for inaccessible and concurrently removed directories.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs Introduces resilient, cancellation-aware recursive traversal that skips unavailable directories while preserving discovery in accessible siblings.
GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs Adds deterministic coverage for file and child-directory enumeration failures during recursive discovery.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Push manifest root] --> B{Pending directories?}
    B -->|No| Z[Discovery complete]
    B -->|Yes| C[Pop next directory]
    C --> D[Check cancellation]
    D --> E[Enumerate matching files]
    E -->|Unavailable| F[Log warning and skip files]
    E -->|Success| G[Process discovered manifests]
    F --> H[Enumerate child directories]
    G --> H
    H -->|Unavailable| I[Log warning and skip descendants]
    H -->|Success| J[Push child directories]
    I --> B
    J --> B
Loading

Reviews (4): Last reviewed commit: "test(manifest): cover directory enumerat..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Manifest discovery now uses injectable filesystem enumerators and iterative safe traversal. Unauthorized or unavailable directories are logged and skipped while accessible manifests continue to be discovered. A deterministic test covers inaccessible and removed sibling directories.

Changes

Manifest discovery resilience

Layer / File(s) Summary
Enumeration wiring and discovery entry point
GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs
Injectable file and directory enumerators are added, and manifest discovery uses the safe file enumerator.
Safe traversal and unavailable-directory validation
GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs, GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs
Iterative traversal handles UnauthorizedAccessException and IOException, while tests verify accessible manifests remain discoverable when sibling directories are unavailable.

Estimated code review effort: 4 (Complex) | ~40 minutes

Possibly related PRs

Poem

A bunny hops where folders wind,
Skips locked paths left behind.
JSON trails through roots of green,
Safe manifests still are seen.
“Keep exploring!” twitches my nose.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR satisfies #308 by skipping unavailable directories, preserving cancellation, and adding deterministic tests.
Out of Scope Changes check ✅ Passed The changes stay focused on manifest discovery traversal and tests, with no clear unrelated refactor or extra scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title uses a conventional commit prefix and clearly matches the manifest discovery fix.
Description check ✅ Passed The description is directly related to the manifest traversal change and added tests.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #308

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/manifest-discovery-unavailable-directories

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs 194 Test delegate should match production implementation by using parameterless overload
Files Reviewed (1 file)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs - 1 suggestion

Note: The implementation correctly addresses the PR objectives of preventing recursive manifest discovery from aborting when directories become inaccessible. The exception handling, cancellation support, and stack-based traversal are well implemented. The production code uses Directory.EnumerateDirectories(directory) without hardcoded patterns, but the test code still uses the old pattern with "*" and SearchOption.TopDirectoryOnly. This inconsistency should be addressed for test accuracy and maintainability.

Fix these issues in Kilo Cloud

Previous Review Summaries (3 snapshots, latest commit 2740efd)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 2740efd)

Status: 1 Issue Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs 184 Test delegate should match production implementation by using parameterless overload
Files Reviewed (1 file)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs - 1 suggestion

Note: The implementation correctly addresses the PR objectives of preventing recursive manifest discovery from aborting when directories become inaccessible. The exception handling, cancellation support, and stack-based traversal are well implemented. The production code uses Directory.EnumerateDirectories(directory) without hardcoded patterns, but the test code still uses the old pattern with "*" and SearchOption.TopDirectoryOnly. This inconsistency should be addressed for test accuracy and maintainability.

Fix these issues in Kilo Cloud

Previous review (commit cb8c001)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs
  • GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs

Note: The implementation correctly addresses the PR objectives of preventing recursive manifest discovery from aborting when directories become inaccessible. The exception handling, cancellation support, and stack-based traversal are well implemented. The previous issue about centralizing the directory wildcard pattern has been resolved by using the parameterless overload of Directory.EnumerateDirectories(directory), which avoids hardcoding the pattern in the source code.

Previous review (commit aff90d0)

Status: 1 Existing Issue Found | Recommendation: Address existing review comments before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs 27 Directory wildcard pattern "*" should be centralized in FileTypes constants (existing comment)
Files Reviewed (2 files)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs - No issues found
  • GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs - 1 existing issue

Note: The implementation correctly addresses the PR objectives of preventing recursive manifest discovery from aborting when directories become inaccessible. The exception handling, cancellation support, and stack-based traversal are well implemented. The only concern is the existing suggestion to centralize the directory wildcard pattern for consistency with the project's coding standards.

Fix these issues in Kilo Cloud


Reviewed by glm-4.7 · Input: 36.5K · Output: 7K · Cached: 453.8K

@bobtista
bobtista force-pushed the fix/manifest-discovery-unavailable-directories branch from aff90d0 to cb8c001 Compare July 28, 2026 10:52
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 28, 2026
@bobtista

Copy link
Copy Markdown
Author

@coderabbitai review

The stacked branch was rebased onto the latest #305, and the explicit directory wildcard was removed by using Directory.EnumerateDirectories(directory).

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

@bobtista I’ll review the rebased changes, including the updated directory enumeration behavior.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bobtista
bobtista changed the base branch from fix/manifest-discovery-pattern to development July 29, 2026 12:27
@bobtista
bobtista dismissed coderabbitai[bot]’s stale review July 29, 2026 12:27

The base branch was changed.

@bobtista
bobtista force-pushed the fix/manifest-discovery-unavailable-directories branch from cb8c001 to 2740efd Compare July 29, 2026 12:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs`:
- Around line 146-196: Extend
DiscoverManifestsAsync_WithUnavailableDescendants_ContinuesDiscoveringAccessibleManifests
to make the injected directory enumerator throw an expected
UnauthorizedAccessException or IOException for one unavailable subdirectory,
while continuing to enumerate accessible siblings. Ensure the assertions still
verify the accessible manifest is discovered, thereby covering the
enumerateDirectories exception branch in EnumerateFilesSafely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 07a417a6-89c1-43b2-824f-058918dd514b

📥 Commits

Reviewing files that changed from the base of the PR and between a783b36 and 2740efd.

📒 Files selected for processing (2)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs
  • GenHub/GenHub/Features/Manifest/ManifestDiscoveryService.cs

_loggerMock.Object,
_cacheMock.Object,
EnumerateFiles,
directory => Directory.EnumerateDirectories(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Test delegate should match production implementation

The test uses the old pattern with hardcoded "*" and SearchOption.TopDirectoryOnly, but the production code was updated to use the parameterless overload Directory.EnumerateDirectories(directory) to avoid hardcoding the directory wildcard pattern. For consistency and accuracy, the test should match the production implementation.

Suggested change
directory => Directory.EnumerateDirectories(
directory => Directory.EnumerateDirectories(directory));

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@bobtista

Copy link
Copy Markdown
Author

@coderabbitai The coverage gap was real — the test injected failures only into the file enumerator, while the directory enumerator was the real Directory.EnumerateDirectories, so the _enumerateDirectories catch in EnumerateFilesSafely was never exercised.

Fixed in ace7451. The test now injects an EnumerateDirectories seam that throws UnauthorizedAccessException for an unlistable/ directory, which contains a nested unreachable.json manifest. Discovery skips that subtree and still finds the accessible manifest, so Assert.Single covers both the exception branch and the continue-past behaviour.

Verified the test actually pins the branch: with the catch around _enumerateDirectories removed, it fails with System.UnauthorizedAccessException : Injected unlistable directory.; restored, all 8 ManifestDiscoveryServiceTests pass.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@bobtista Thanks for identifying and correcting that gap. Injecting the EnumerateDirectories failure now directly covers the intended catch-and-continue path, and the removal-of-catch failure confirms the test is properly pinned.


✏️ Learnings added
Learnt from: bobtista
URL: https://github.com/community-outpost/GenHub/pull/309

Timestamp: 2026-07-29T12:51:48.839Z
Learning: In `GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Manifest/ManifestDiscoveryServiceTests.cs`, tests for `ManifestDiscoveryService.EnumerateFilesSafely` must inject failures through the matching enumeration seam. To exercise the `_enumerateDirectories` `UnauthorizedAccessException` handling branch, inject an `EnumerateDirectories` delegate that throws for the target directory; a failure injected only through the file enumerator does not cover that directory-enumeration catch path.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

throw new UnauthorizedAccessException("Injected unlistable directory.");
}

return Directory.EnumerateDirectories(directory, "*", SearchOption.TopDirectoryOnly);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Test delegate should match production implementation

The test uses the old pattern with hardcoded "*" and SearchOption.TopDirectoryOnly, but the production code uses the parameterless overload Directory.EnumerateDirectories(directory) to avoid hardcoding the directory wildcard pattern. For consistency and accuracy, the test should match the production implementation.

Suggested change
return Directory.EnumerateDirectories(directory, "*", SearchOption.TopDirectoryOnly);
return Directory.EnumerateDirectories(directory);

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@bobtista
bobtista merged commit 8e07339 into development Jul 29, 2026
7 checks passed
@kilo-code-bot kilo-code-bot Bot mentioned this pull request Jul 30, 2026
6 tasks
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.

1 participant