Stage captured artifacts in per-attempt tempdirs and persist them through an explicit artifact sink instead of writing into run scratch cache. Server-managed and test-owned runs now write directly to ArtifactStore, while CLI worker runs keep the staged upload path. The local run summary now prints durable artifact identifiers and copy hints rather than scratch-cache paths, and the run-directory docs and integration coverage were updated to match.
6.1 KiB
| date | topic |
|---|---|
| 2026-04-08 | eliminate-scratch-artifact-cache |
Eliminate Scratch Artifact Cache
Problem Frame
The artifact collection pipeline uses scratch/cache/artifacts/files/ as a staging area for CLI uploads: files are downloaded from the sandbox to local disk, hashed, then uploaded to the server's ArtifactStore. Now that ArtifactStore (backed by object store) is the durable source of truth, this persistent local cache is unnecessary overhead. It adds disk usage and complicates the scratch directory contract. It also obscures a separate bug: server-managed runs currently start ArtifactLifecycle with no artifact sink configured, so collected artifacts are discarded. Eliminating the cache alone does not fix that bug; server-managed runs also need a direct ArtifactStore write path.
Requirements
Pipeline: Replace persistent cache with transient local staging
- R1.
collect_artifactsmust download each file from the sandbox into a transient per-attempt local directory tree that preserves each artifact's relative path, compute MD5/SHA256 from those transient local files, and keep that transient tree available until the configured artifact sink has finished consuming it, including upload retries. Delete the transient tree immediately after direct store writes or HTTP uploads finish. No persistentcache/artifacts/directory. - R2.
CapturedArtifactInfo(path, mime, hashes, bytes) must still be produced for each collected file and emitted viaArtifactCapturedevents.
Store: Write artifacts directly to ArtifactStore
- R3. When running server-side,
ArtifactLifecyclewrites collected artifacts directly to the server'sArtifactStore, fixing the current gap where server-managed runs configure no artifact sink and silently discard artifacts. - R4. When running via CLI, the existing HTTP upload path (
HttpArtifactUploader) continues to work. Internal uploader abstractions may change as needed, but the CLI must continue uploading artifacts to the server rather than writing directly toArtifactStore. - R5.
ArtifactLifecyclemust be configured with exactly one artifact sink for artifact-enabled runs: either a directArtifactStore-backed sink for server-managed runs or an HTTP uploader-backed sink for CLI runs. It must also hold aRunIdfor directArtifactStore::putcalls. The internal representation of that sink (enum, unified trait, or refined existing trait) is deferred to planning.
Scratch cleanup
- R6. Remove
artifact_cache_dir(),artifact_files_dir(), andartifact_stage_dir()fromRunScratchinfabro-config/src/storage.rs. - R7. Remove the
create_dir_all(self.artifact_files_dir())fromRunScratch::create(). - R8. Update
docs/reference/run-directory.mdxanddocs-internal/run-directory-keys.mdto remove allcache/artifacts/entries (includingcache/artifacts/files/). - R10. Update integration tests in
fabro-workflow/tests/it/integration.rsanddaytona_integration.rsthat assert onartifact_stage_dirpaths to verify artifacts viaArtifactStoreor uploader behavior instead of local filesystem paths.
CLI output
- R9. The post-run "=== Artifacts ===" output must stop printing local scratch paths. It should list durable artifact identifiers derived from stored metadata, at minimum
node_slug,retry, andrelative_path, and referencefabro artifact cpfor retrieval. - R11. Removing
artifact_stage_dir()must not change durable per-stage/per-attempt grouping. Artifacts must still be addressable byStageId, and CLI/server artifact surfaces must continue exposingnode_slug,retry, andrelative_pathfrom store-backed metadata rather than reconstructing local scratch paths.
Success Criteria
- Server-managed workflow runs produce artifacts in
ArtifactStore(previously they did not). - No
cache/artifacts/directory is created or written to during any workflow run. fabro artifact listandfabro artifact cpcontinue to work unchanged.- The post-run artifact summary prints logical artifact identifiers (
node_slug,retry,relative_path) instead of local scratch paths. ArtifactCapturedevents still contain correct hashes and byte counts.
Scope Boundaries
- No changes to
fabro artifact listorfabro artifact cpcommands. - No changes to the
Sandboxtrait (no streaming download API). - No changes to the HTTP artifact upload protocol between CLI and server.
runtime/blobs/(context value materialization) is a separate concern, unchanged.
Key Decisions
- Transient local staging, not persistent scratch cache: The
Sandboxtrait only hasdownload_file_to_local. Rather than adding a streaming API to all sandbox impls, use transient local files outsideRunScratch, but keep them alive until the configured sink has finished consuming them. - Server writes to ArtifactStore directly: The server already owns the
ArtifactStoreinstance. Server-managed runs should use that directly instead of relying on an uploader being present. - CLI keeps HTTP upload path: The CLI continues uploading artifacts to the server over HTTP. The internal uploader interface may change, but the wire protocol stays the same. Smaller blast radius than giving the CLI its own local
ArtifactStore.
Outstanding Questions
Deferred to Planning
- [Affects R5][Technical] What internal representation should
ArtifactLifecycleuse for the exactly-one artifact sink? Options: an enum with server/CLI variants, a new unified trait, or a refactor of the existing uploader trait. - [Affects R1][Technical] Should
collect_artifactsreturn transient local handles/paths alongsideCapturedArtifactInfo, or should store/upload happen inside the collection step while the transient files are definitely still present? - [Affects R1][Technical] Should transient staging use
tempfile::TempDir(auto-cleanup on drop) or manualstd::fs::remove_dir_all? The former is more robust against panics. - [Affects R9][Needs research] What does the current CLI output look like for artifacts, and what is the best replacement format? Check
lib/crates/fabro-cli/src/commands/run/output.rs.
Next Steps
-> /ce:plan for structured implementation planning