Repository navigation
Conversation
Every request gets <data>/jobs/<id>, created before it runs. A request refused or failed before the tool wrote anything (insufficient_memory, an invalid image request, a cancel) left an empty directory until the job expired, and across a restart until it was past keep_outputs_s. On a Strix Halo box a day of agent use left 47 empty directories (39 chat, 7 image, 1 video) among 453. A job that ends failed or cancelled now removes its directory when it is empty (rmdir: one with saved inputs or partial outputs stays for expire). The start-up sweep also removes empty directories whatever their age; it runs before any job exists, so they belong to no job.
jayleaton
requested changes
Nov 19, 2026
jayleaton
left a comment
Owner
There was a problem hiding this comment.
Thanks! The deletion paths only use server-generated job IDs or entries listed under the open jobs directory, so there's no path-traversal risk. Normal cleanup works for a worker's 400 and for a queue-full 503. Still needed:
- Blocking:
src/api/routes.zig:693andsrc/sched/scheduler.zig:1279and:1303. Terminal status becomes visible beforedropIfEmptyuses the job. With zero retention, expiry on another lane can free the job and its path before cleanup finishes. Please finish cleanup before publishing terminal status, and keep the job alive through completion signalling and active readers. Please add a finalization-vs-expiry test. - Blocking:
src/sched/jobs.zig:147. Startup checks that a fresh directory is empty and later callsdeleteTreeon it, so a file created in between is deleted even though it's inside the retention window. Please use the atomicdeleteDirfor fresh directories and keepdeleteTreefor expired ones. Please add a test where a fresh directory gains a file before cleanup. - Blocking:
src/sched/scheduler.zig:1974. The new test conflicts with #156's test at the end of the file. Please rebase and keep both tests. - Nit:
src/serve.zig:91. The startup log says every removal is age-based. Please update it to cover fresh empty directories.
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.
Independent; based on main.
Problem
Every request gets
<data>/jobs/<id>before it runs. A request refused or failed before its tool wrote anything (503insufficient_memory, an invalid image request, a cancel) left an empty directory. It stayed until the job expired, and across a restart until it was older thankeep_outputs_s. One day of agent use on a workstation left 47 empty job directories (39 chat, 7 image, 1 video) out of 453.Change
Job.dropIfEmptyremoves the job's directory only if it is empty (rmdir). It runs when a job ends failed or cancelled (finish,finishCancelled) and when the API abandons a job it could not set up.expireas before. Completed jobs are untouched.sweepalso removes empty job directories of any age. It runs before any job exists, so they belong to no job.Tests
sweepdrops an empty directory and leaves one with a file.zig build test-unitpasses;zig fmt --checkis clean.