Skip to content

test: handle teardown readdir race - #114

Merged
sanjey99 merged 1 commit into
mainfrom
fix/112-test-teardown-race
Sep 1, 2026
Merged

sanjey99 merged 1 commit into
mainfrom
fix/112-test-teardown-race

Conversation

@sanjey99

@sanjey99 sanjey99 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

A clean exact-main pre-push run completed the functional paths but failed two Shepherd infrastructure-failure cases during fixture teardown with ENOENT from readdir on a trusted-verification directory.

Closes #112.

Root cause

The verifier cleanup and the test fixture cleanup can both remove the same accepted descendant. removeServiceCaseRoot already tolerated disappearance around entry metadata and file chmod, but did not tolerate a directory disappearing after its containment check and immediately before readdir.

Fix

  • Add a deterministic pre-readdir seam and regression.
  • Treat only descendant ENOENT from cleanup chmod/readdir as already removed.
  • Keep the allocated root, sentinel/containment checks, and all other filesystem errors fail-loud.

Test plan

  • Observed the new regression fail with the expected ENOENT before the fix.
  • Three adjacent disappearance-race tests passed together: 3/3.
  • Server test-source typecheck passed.
  • git diff --check passed.
  • Combined exact-main npm run check after integration.

Out of scope

Production lifecycle behavior, live verifier wiring #111, group chat #110, and documentation.

@sanjey99
sanjey99 marked this pull request as ready for review September 1, 2026 03:31
Copilot AI lite review requested due to automatic review settings September 1, 2026 03:31
@sanjey99
sanjey99 merged commit 7e71d04 into main Sep 1, 2026
1 check passed

Copilot AI 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.

🟢 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-readdir hook seam to deterministically reproduce the disappearance window in tests.
  • Update removeServiceCaseRoot cleanup traversal to tolerate descendant-only ENOENT from directory chmod and readdir while 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.

@sanjey99
sanjey99 deleted the fix/112-test-teardown-race branch September 1, 2026 03:34
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.

Fix Shepherd test teardown directory-disappearance race

2 participants