What the run retention settings control in one service job
A service job enters through the tenant token routes. First, the job index writes a row with a status and a created time. Next, it adds an expiry time, which is the created time plus the window. Therefore, tenant run expiry starts the moment a job is accepted.
The default window is 168 hours, which is seven days. An environment variable named DALETPARSE_RUN_RETENTION_HOURS sets it. The value must be a whole number from 1 to 720, and the top value equals thirty days. These run retention settings apply to every tenant run on the service.
A bad value is not ignored. Instead, the check raises an error, and protected routes answer 503. Likewise, the web app fails at boot. As a result, a typo cannot silently keep data for years.
The public job record shows the expires_at value. Consequently, a caller can read the end date from the job list and plan its fetch before then. The batch queue article shows how that list is read.
How the cleanup pass finds and deletes expired run folders
The cleanup pass behind run retention settings runs at boot. It also runs when a protected route is called, but at most once every five minutes. Tenant run expiry therefore depends on traffic, not on a clock. A quiet service can keep an expired run until the next request or restart.
Only runs in a terminal state are removed, which means completed or failed. A queued or running job is never deleted, even when its expiry time has passed. Likewise, the pass skips any row that lacks a valid owner digest or a valid expiry.
The pass is also careful with paths. First, it skips symbolic links, and second, it skips any folder whose parent is not the runs root. When a folder goes, its index row goes with it. Therefore, good run retention settings depend on this narrow, safe deletion.
How an operator can check that the pass has run
The boot line in the queue log reports two counts. First, it counts the stalled jobs it marked as failed. Second, it counts the expired runs it removed. Therefore, a restart leaves a visible trace.
For routine checks, compare the expires_at values in the job list with the folders on disk. First, find a folder past its expiry. If it is still there, no protected route has been called since.
Why uploaded input files are deleted before the window ends
A finished tenant job loses its upload at once. This input file deletion happens after success, after failure and after a timeout. Moreover, the step sits in a final block, so a crash in the pipeline does not skip it. Input file deletion is thus reliable.
Under these run retention settings, only the result files wait for the end date. The input file often holds the most sensitive page images, and it is gone much sooner. If a delete fails, the code logs the error type name, but it does not log the file name.
Also, upload folders use owner-only permissions. The run folder is created with mode 0700, and the saved files use mode 0600. Meanwhile, the analyze route goes further, because it removes its whole working folder before it replies.
- Input file deletion removes the upload when the job ends.
- The result files stay until the expiry time.
- The analyze route keeps nothing after its reply.
Which runs the retention window does not cover at all
The cleanup handles tenant run expiry only. Several other runs fall outside it. A team should know each one before it relies on the setting.
- Web workspace runs follow the retention period your administrators set for them.
- Jobs from the multi-file statement route follow the same administrator setting.
- Debug conversations, which hold prompts and responses, are written under a debug folder that the pass does not touch.
An internal assessment of the code adds a warning for web workspace runs. It places run folders on encrypted storage with access limited to named staff. Administrators set their retention period with the same care. Therefore, the host operator needs a manual cleanup rule for web workspace runs and for debug files.
In addition, backups, log shipping and disk snapshots sit outside the code, as do web workspace runs. Likewise, any copy that your own callers make is outside the setting. Add each of them to your retention note, as the security controls page advises.
How to choose a retention window for your own team
Tune run retention settings to caller behavior. A caller that polls and fetches within minutes needs a short window. In contrast, a caller that may be offline over a weekend needs a longer one.
Next, check what reviewers need from run retention settings. If a reviewer may need to reopen a result, the window must cover that period. However, a reviewer should not depend on the service as a filing cabinet.
Finally, think about data minimization. Tenant run expiry should match how long reviewers reopen results. The shorter the window, the less personal data waits on disk. Your counsel confirms which duties apply to your files.
How a caller can keep each result on its own side
The safest pattern for run retention settings is simple. First, the caller polls until the job is complete. Then it stores the result in its own system. After that, the copy in the service is a convenience, not the record.
- Fetch the result as soon as the status shows completed.
- Store it under your own access rules and your own retention rule.
- Keep the run identifier next to it, so that you can trace the source.
What a written retention note should say before launch day
Overall, a short note beats a good intention. It should name the window and the person who may change it. It should also say how a change to run retention settings is tested. The value is an environment variable, so a restart applies it.
Next, the note should list each place where data waits. Those places are tenant runs, web workspace runs, debug files, backups and caller copies. For each place, name the owner and the rule for input file deletion and expiry. In addition, record the run retention settings in force when each batch was processed.
The job recovery rules explain why failed runs also wait for their expiry.