Add ctx.actions.copy: a content-link action distinct from symlink - #3
Closed
thesayyn wants to merge 5 commits into
Closed
Add ctx.actions.copy: a content-link action distinct from symlink#3thesayyn wants to merge 5 commits into
thesayyn wants to merge 5 commits into
Conversation
Introduces LinkAction, a sibling to SymlinkAction that declares an output to be a content link of its input -- the same content re-addressed at a second exec path, sharing the input's digest, with no byte copy and no spawn. Unlike a symlink, a content link's contract is that it is realized as content (hard link, copy, reflink, or remote digest reuse) rather than a followable symbolic link, so its realpath is stable within the consuming tree (which tools such as Node.js require). Laydown remains the execution strategy's decision: the action only declares the relation and leaves a resolvable backing. Strategies that cannot materialize content (a purely symlinking sandbox, non-sandboxed local) do not honor the contract; that is an accepted limitation. Exposes ctx.actions.link(output, target_file). SymlinkAction is unchanged; the shared metadata-forwarding helper is reused. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017mFt5KqnN5CxwQVvHGC4zR
The producer/materialization design was the wrong vehicle. File relocation belongs in the path-mapping mechanism (PathMapper), where the action declares an exec-path rewrite and the execution strategy resolves the mapped path to content -- not in an action that materializes an output. Reverting to a clean baseline before rebuilding on PathMapper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017mFt5KqnN5CxwQVvHGC4zR
Reworks ctx.actions.link on top of the existing resolved-path metadata
mechanism instead of a producer action that materializes.
- FileArtifactValue: add a materializeAsContent() hint (default false) and a
createForContentLink() factory. Ordinary symlinks keep producing plain
resolved-symlink values (flag false), so symlink behavior is unchanged. The
hint is exactly what getResolvedPath()'s contract already permits ("an output
service is free to materialize the artifact in some other way").
- LinkAction: a declaration-only action -- no spawn, no filesystem write. It
only injects the output's metadata as a content-link value pointing at the
input's content. How the content is placed (hard link/copy/reflink/digest) is
left entirely to the execution strategy, as with path mapping.
- ctx.actions.link(output, target_file) exposes it.
- AbstractActionInputPrefetcher: never plant a content link as a followable
symlink; materialize its content at its own path instead.
Content is realized wherever a strategy can materialize it; a purely symlinking
sandbox or non-sandboxed local execution is an accepted non-goal.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mFt5KqnN5CxwQVvHGC4zR
Names the observable semantic (a content-identical file at a second path) rather than a laydown mechanism. "link"/"copy"/"clone" each overcommit to a mechanism or imply byte cost; "duplicate" describes what you get and leaves the (free) realization to the execution strategy. Renames LinkAction -> DuplicateAction and the actions/duplicate_action library accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017mFt5KqnN5CxwQVvHGC4zR
Settles on copy: it reads cleanly ("copy src to out"), names the observable
result, and aligns with the actions.copy direction in bazelbuild/proposals#396
rather than forking terminology. Renames DuplicateAction -> CopyAction and the
actions/copy_action library.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mFt5KqnN5CxwQVvHGC4zR
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.
No description provided.