Skip to content

fix(worker): hold one fd per level of depth in list_files - #41

Merged
Viscous106 merged 3 commits into
mainfrom
fix/worker-walk-fds
Nov 2, 2026
Merged

Viscous106 merged 3 commits into
mainfrom
fix/worker-walk-fds

Conversation

@Aspirant200715

Copy link
Copy Markdown
Collaborator

Follow-up to #39 review nits.

What changed

  • _walk in workspace.py closes each directory's fd once it is done, as _find_name now does. Descriptors grow with depth, not directory count.
  • spec/receipt-v0.md: the truncation marker names the applied cap; the default still gives the 1048576 literal.

What I verified

  • Full control-plane suite: 532 passed (-m 'not gvisor'). ruff and pyright clean.
  • New tests: 300 directories under a low RLIMIT_NOFILE, and no fd left open after list_files. Both fail if finished directories are not closed.

Not verified

  • Not run against a real checkout with about 1000 directories under the default 1024 limit; the test uses a lowered limit instead.

Aspirant200715 and others added 3 commits November 1, 2026 00:05
- sandbox: bound the wait on a stuck exec stream after a timeout kill
- workspace: cap the nested .git scan and fail closed over the cap
- models: truncation marker names the cap actually applied
- tools, phi: SandboxError is one failed step / an inconclusive phi
_find_name kept every directory it found open until the scan ended, so a
checkout with about a thousand directories ran out of descriptors under
the usual 1024 soft limit. With the fail-closed handling in this PR, every
git step on such a checkout (diff, changed paths, the Phi path check) was
then refused. The scan now keeps only the directories on the current path
open.

@OfficialAbhinavSingh OfficialAbhinavSingh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

merged with main locally, full suite green (365 passed), ruff and pyright clean.

_walk now closes finished frames exactly like _find_name does, so descriptors grow with depth not directory count. the early return on _MAX_LIST_ENTRIES still gets everything closed, since the finally walks whatever is left in frames. the two new tests (low RLIMIT_NOFILE, and the open-fd count before/after) would both fail without the fix.

the receipt-v0.md wording is also correctly carried over from the 39 base.

@Viscous106 Viscous106 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed: ready.

@Viscous106
Viscous106 merged commit c66bd18 into main Nov 2, 2026
3 of 4 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Kanban Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants