Skip to content

test(#3996): cover mid-write cleanup, file modes, and missing parents - #4024

Draft
aheritier wants to merge 3 commits into
generated-media-streamingfrom
workspace-media-foundations
Draft

test(#3996): cover mid-write cleanup, file modes, and missing parents#4024
aheritier wants to merge 3 commits into
generated-media-streamingfrom
workspace-media-foundations

Conversation

@aheritier

@aheritier aheritier commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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 test and verify the workspace-media tests cover cleanup after interrupted writes, required permissions, and automatic creation of missing parents.

…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.
@aheritier aheritier added area/a2a Agent-to-Agent protocol, A2A server, inter-agent communication area/mcp MCP protocol, MCP tool servers, integration area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/test Test-only changes labels Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/a2a Agent-to-Agent protocol, A2A server, inter-agent communication area/mcp MCP protocol, MCP tool servers, integration area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) kind/test Test-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant