Repository navigation
test: handle teardown readdir race - #114
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change narrowly scopes ENOENT tolerance to descendant cleanup operations and adds a deterministic regression test covering the reported race.
Pull request overview
This PR fixes a flaky test-fixture teardown race in the server Shepherd test suite where a trusted-verification descendant directory can disappear between passing containment checks and the subsequent readdir, causing intermittent ENOENT failures during cleanup.
Changes:
- Add a pre-
readdirhook seam to deterministically reproduce the disappearance window in tests. - Update
removeServiceCaseRootcleanup traversal to tolerate descendant-onlyENOENTfrom directorychmodandreaddirwhile keeping other filesystem errors fail-loud. - Add a regression test covering the “accepted directory disappears before listing entries” scenario.
File summaries
| File | Description |
|---|---|
| apps/server/src/shepherd/service.test.ts | Makes teardown cleanup robust to descendant directory-disappearance races and adds a deterministic regression test. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
A clean exact-main pre-push run completed the functional paths but failed two Shepherd infrastructure-failure cases during fixture teardown with
ENOENTfromreaddiron a trusted-verification directory.Closes #112.
Root cause
The verifier cleanup and the test fixture cleanup can both remove the same accepted descendant.
removeServiceCaseRootalready tolerated disappearance around entry metadata and file chmod, but did not tolerate a directory disappearing after its containment check and immediately beforereaddir.Fix
readdirseam and regression.ENOENTfrom cleanupchmod/readdiras already removed.Test plan
ENOENTbefore the fix.git diff --checkpassed.npm run checkafter integration.Out of scope
Production lifecycle behavior, live verifier wiring #111, group chat #110, and documentation.