The Git-backed Porch repository exposes PackageDraft.UpdateResources as a snapshot update, but its current implementation can accept resource names that escape the package and can leave a draft in a partially changed state when one entry is invalid. Make resource updates safe and transactional while preserving the existing Git package lifecycle.
For a draft created or updated through the public repository interfaces, every resource key must be a non-empty, relative path within the package: reject absolute paths, .. traversal, any . or .. path segment, and conflicting keys where one key is a file and another is beneath it. Validate the complete snapshot before creating a commit; if validation fails, return an error and leave the draft’s previously committed resources unchanged, and the draft must remain closable.
A successful UpdateResources call represents the complete package snapshot for that commit. After Close, GetResources must contain exactly the supplied keys and byte-for-byte string contents: omitted files from the prior revision are deleted, existing files are replaced rather than duplicated, and new nested files are materialized under the package. Existing lifecycle behavior (draft references and normal Close/ListPackageRevisions operation) must continue to work.