test(#3996): cover mid-write cleanup, file modes, and missing parents - #4024
Draft
aheritier wants to merge 3 commits into
Draft
test(#3996): cover mid-write cleanup, file modes, and missing parents#4024aheritier wants to merge 3 commits into
aheritier wants to merge 3 commits into
Conversation
…eation path Every session created against a local workspace now records the absolute workspace root that owns it, so generated files can later be resolved against the owning workspace instead of whatever cwd the viewer happens to run from: - delegated/nested sub-sessions inherit parent.WorkingDir - serve mcp / a2a / chatserver capture the server workspace once at startup instead of reading os.Getwd per request (or not at all) - embeddedchat conversations and `docker-agent new` capture the configured root or the creation-time cwd - --working-dir writes the absolutized path back into RuntimeConfig so a relative flag value cannot leak into persisted provenance - compaction runs inherit the compacted session's workspace Remote/headless surfaces (remote backend template, API templates without working_dir, ACP without client cwd, evaluation container transcripts) intentionally keep an empty WorkingDir and now document that choice. session.ResolveWorkingDir adds a bounded, cycle-safe, validated parent-chain fallback for old persisted sub-sessions with an empty WorkingDir; it rejects relative/malformed roots and never falls back to the process cwd. It is the primitive the generated-media resolver will build on.
Pure naming layer for saving generated media as workspace deliverables: sanitizes requested relative paths, derives the extension from the MIME type (reporting a corrected conflicting extension so callers can show a notice), classifies absolute/".."/invalid/reserved/symlink-escaping paths as a typed ErrPathEscape, and never overwrites — the final name is claimed with O_CREATE|O_EXCL, collisions retry with a dash suffix, and bytes are published atomically via a sibling temp file inside os.OpenRoot containment. Materialization wiring comes separately.
partialFailReader writes a genuine partial chunk on its first Read then fails on every subsequent Read, so the mid-write-failure tests reach atomicfile.Write's cleanup path AFTER a real os.CreateTemp'd file already has partial content on disk, rather than relying on a permission trick that prevents the temp file from ever being created. Also cover preserved file modes and creation under missing parent directories. This coverage backs the workspace media writer's reliance on atomicfile.Write for never-overwrite, no-residue semantics.
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.
What
Adds regression coverage for workspace-media foundations: mid-write cleanup, file modes, missing parent directories, and related server/runtime paths.
Why
Locks down safe filesystem behavior before generated-media materialization builds on it.
Validation
task test(including workspace-media, server, MCP, delegation, and writer tests).Test instructions
Run
task testand verify the workspace-media tests cover cleanup after interrupted writes, required permissions, and automatic creation of missing parents.