Skip to content

feat(#3996): add workspace media writes and session provenance - #4024

Open
aheritier wants to merge 4 commits into
mainfrom
workspace-media-foundations
Open

feat(#3996): add workspace media writes and session provenance#4024
aheritier wants to merge 4 commits into
mainfrom
workspace-media-foundations

Conversation

@aheritier

@aheritier aheritier commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

What and why

Add collision-safe workspace media writes, nested parent creation, MIME-corrected extensions, no-overwrite publication, and cleanup on failure. Persist absolute local workspace provenance across session creation surfaces and resolve it through a bounded parent walk. Relative nesting, MIME correction, collision handling, no overwrite, and partial success are retained. This is production infrastructure, not a test-only change.

Part of #3996. Review this PR against its immediate parent, #4023, rather than the aggregate stack against main.

Publication hard-links a complete sibling temporary file to an unused final name atomically; concurrent destination creation cannot be overwritten. Filesystems without hard-link support fail safely.

Commit inventory

Head: 8cd7c8d6182ec1a60d9a404268f88887f19c80fa; parent SHA: dfca90319859bd683dd1103d48ed43ed043bddd2.

Validation

Build, test compilation, owning-package tests and the named fixture passed at this PR head.

Exact deterministic fixture command:

go test -v -count=1 ./pkg/atomicfile ./pkg/workspacemedia ./pkg/session -run 'TestWrite|Test.*WorkingDir'

Matched top-level tests: pkg/atomicfile: 6; pkg/session: 11; pkg/workspacemedia: 21.

Deterministic scope: the named local fixture exercises this PR boundary with disposable configuration/stores and fake or loopback providers as applicable. Every listed package ran nonzero matching top-level tests.

Deferred/live scope: Live provider, remote CI, and platform execution are not claimed by this deterministic receipt. The final stack head passed build, lint, full tests, an uncached full suite, focused race tests and documentation checks in disposable environments. Remote CI is tracked by the checks below; no new paid-provider or active-database validation was run.

@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
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 7d14235 to 8ddf26c Compare August 24, 2026 15:13
@aheritier
aheritier force-pushed the workspace-media-foundations branch 2 times, most recently from 3033054 to 8480264 Compare August 25, 2026 08:15
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 8480264 to 750b125 Compare August 25, 2026 20:24
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 750b125 to 3ef730d Compare August 26, 2026 11:09
@aheritier
aheritier force-pushed the workspace-media-foundations branch 2 times, most recently from b90d66a to 3ef730d Compare September 1, 2026 16:13
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 3ef730d to 85b7e3b Compare September 1, 2026 16:30
aheritier

This comment was marked as resolved.

@aheritier
aheritier force-pushed the workspace-media-foundations branch from 3fea84b to 4400283 Compare September 8, 2026 07:57
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 4400283 to f0afe11 Compare September 8, 2026 17:31
@aheritier
aheritier force-pushed the workspace-media-foundations branch from f0afe11 to 8cd7c8d Compare September 8, 2026 20:34
@aheritier aheritier changed the title test(#3996): cover mid-write cleanup, file modes, and missing parents feat(#3996): add workspace media writes and session provenance Sep 8, 2026
@aheritier
aheritier marked this pull request as ready for review September 8, 2026 20:38
@aheritier
aheritier requested a review from a team as a code owner September 8, 2026 20:38
@dgageot
dgageot force-pushed the workspace-media-foundations branch from 8cd7c8d to f7404fe Compare September 9, 2026 07:41
dgageot
dgageot previously approved these changes Sep 9, 2026
@aheritier
aheritier force-pushed the workspace-media-foundations branch from f7404fe to 0b4142d Compare September 9, 2026 11:56
@dgageot
dgageot force-pushed the workspace-media-foundations branch from 0b4142d to 932bd80 Compare September 9, 2026 12:15
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 932bd80 to f349c29 Compare September 9, 2026 12:56
@aheritier
aheritier force-pushed the workspace-media-foundations branch from f349c29 to 65d9e2c Compare September 9, 2026 13:32
@aheritier
aheritier force-pushed the workspace-media-foundations branch from 65d9e2c to 3c1b2cd Compare September 9, 2026 14:07
Base automatically changed from generated-media-streaming to main September 9, 2026 15:55
…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.
Sanitize workspace-relative paths, derive MIME extensions and publish complete sibling temporary files through an atomic no-replace hard link. Retry collision suffixes without overwriting files created during publication. Confine operations to os.Root and fail safely on filesystems without hard-link support. Regression coverage preserves concurrent destination writes and verifies failed-write cleanup.
Exercise atomicfile.Write cleanup after real partial data has reached its
temporary file, with and without an existing destination. Drain the test
reader's prefix across arbitrary buffer sizes before injecting an error,
and pin that reader contract directly with a small-buffer test.

Use non-default creation permissions to make chmod coverage load-bearing,
retain overwrite retightening and missing-parent errors, and verify that
a publish-rename failure leaves no temporary file or altered destination.
Rename local session fixtures to sess so package-qualified constructors
remain unambiguous when testing persisted workspace provenance. Keep the
fixture setup and assertions unchanged.
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.

2 participants