Skip to content

Add opt-in Buck2 capture lifecycle hooks and invocation isolation - #2791

Merged
MarcusSorealheis merged 2 commits into
TraceMachina:mainfrom
MarcusSorealheis:buck2-worker-file-explorer
Sep 25, 2026
Merged

MarcusSorealheis merged 2 commits into
TraceMachina:mainfrom
MarcusSorealheis:buck2-worker-file-explorer

Conversation

@MarcusSorealheis

@MarcusSorealheis MarcusSorealheis commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What and why

Action wrappers cannot reliably save final worker files when cancellation or a timeout kills the wrapper before cleanup. Add opt-in Buck2 capture lifecycle hooks for single-use Linux workers: forward invocation metadata, start an operator-supplied collector, and wait for bounded finalization before deleting action files. File collection, authorization, storage, and retention remain the collector's responsibility. An opt-in Execution setting separates identical in-flight actions across Buck2 invocations while preserving completed action-cache hits.

How was this verified?

Ran the affected configuration, worker, scheduler, service, utility, and generated-protocol Bazel tests on macOS. The new overlap regressions pass for both memory and Redis scheduler storage, and completed-result cache hits remain shared. Corrected portable Linux-path validation for Windows and PATH-based helper lookup for Nix coverage; both affected unit-test suites pass locally, with cross-platform CI rerunning. The new regression runs real subprocesses through success, failure, cancellation, and timeout, holds the collector's acknowledgement open, and verifies that action files remain until final capture finishes. It also checks disconnect draining and confirms that Bazel never launches the collector. A separate test checks bounded shutdown of an unresponsive helper.

Regenerated the configuration reference and checked documentation anchors, configuration snippets, spelling, and prose. Linux integration with a real collector remains to be verified; this PR is a draft while that validation is pending.

Risk

Disabled by default. Enabling capture requires a fresh execution container per action; configuration rejects reusable workers, entrypoint wrappers, and separate action mount namespaces. Finalization can delay cleanup by the configured budget plus ten seconds. Capture failure is logged without changing the action's execution result.

The worker protocol gains an optional request-metadata field. Assignments without Buck2 invocation metadata skip capture. The helper and its ingest service must enforce access control and credential exclusions; this hook does not make action processes a security boundary.

AI assistance

I had help from several OpenAI models to draft and revise the implementation, tests, and documentation. I directed the feature scope and architecture, and the coding agent ran the checks described above.


This change is Reviewable

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nativelink Ready Ready Preview Sep 25, 2026 2:23pm UTC
nativelink-aidm Ready Ready Preview Sep 25, 2026 2:23pm UTC

Request Review

Keep overlapping Buck2 invocations on separate executions while sharing completed cache results. Hold action files through bounded collector finalization. Make Linux path validation portable and resolve test helpers through PATH for Nix coverage.

Use Linux path semantics on all configuration-test hosts, resolve test helper tools from the test environment for Nix coverage, and correct the invocation-isolation lint and documentation link.

@modernmedici modernmedici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pub failure_message_template: String,
}

/// Opt-in file capture for the actual container executing a Buck2 action.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MarcusSorealheis
MarcusSorealheis merged commit b00fb48 into TraceMachina:main Sep 25, 2026
47 checks passed

This branch was successfully deployed

2 active deployments
Preview – nativelink — d13fb666 Deployed Sep 25, 2026 by vercel[bot]
Preview – nativelink-aidm — d13fb666 Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants