← Back to Pull requests

feat: hand build-script results back through channel files #2890

Open
baszalmstra opened this pull request with 568 lines diff across 7 files
View on GitHub
baszalmstra baszalmstra commented on Oct 20, 2026 21:37 UTC
Author

Stacked on #2889.

A build script that wants to decide the package contents writes paths to $RATTLER_BUILD_PACKAGE_FILES. That variable pointed at a fixed file under the build directory which the orchestrator created, deleted before every run and read back by path afterwards. That only works when the script runs on the same file system as rattler-build, so a runner that executes somewhere else cannot honour it, and the mechanism was one-off: any other result a script might hand back would need the same dance again.

This makes it a primitive of the session. ExecSpec.channels lists environment variable names; for each one the session creates a fresh, empty, uniquely named file, sets the variable to its guest path in the command's environment (after isolation and the explicit variables, so it survives strict mode and beats a same-named recipe variable or secret), and returns the contents in ExecOutcome after the command exits, also when it failed. The session only moves bytes; what they mean stays with the caller. A file over 16 MiB is a structured ChannelTooLarge error that carries the exit status, and the read is bounded to the limit plus one byte so a file that keeps growing cannot blow up memory.

The session keeps those files in a subdirectory of SessionSpec.scratch_dir, which the caller provides and the session removes on drop: the build directory for builds, the test directory for package tests, the parent of the work directory for the debug commands. I deliberately kept it out of the process temporary directory, since a %TEMP% with a space would make the unquoted >> %RATTLER_BUILD_PACKAGE_FILES% idiom write elsewhere and silently fall back to packaging the whole prefix. The sandbox runner adds a write grant for that directory behind the mount grants.

RATTLER_BUILD_PACKAGE_FILES is the first consumer: Output::run_build_script declares the channel and returns the parsed list, create_package takes it as a parameter, and the fixed path, package_files_list_path and read_package_files_list are gone. The debug commands declare the same channel and discard its contents (ExecResultExt::into_status), so a script that appends to it behaves the same under debug run. One visible change: the variable is no longer part of build_env.sh/build_env.bat, so a wrapper run by hand outside rattler-build does not have it set. The docs now recommend the quoted >> "$RATTLER_BUILD_PACKAGE_FILES" form.

Testing

Unit tests on the local session cover two channels plus an untouched one, a fresh file per execution, distinct files for concurrent sessions, contents after a non-zero exit, the oversized error with an injected limit, the variable under strict isolation and over a same-named explicit variable, a name listed twice, an interactive command, and cleanup of the file and the session directory. Further tests cover the sandbox grant for the channel directory, run_script forwarding channels and surfacing the bytes, the debug commands keeping the exit status of an overfilled channel, run_build_script returning the parsed list, and the pure parser. The package_files_override end-to-end test now runs on Windows too. All of it passes on Windows; the real sandbox path is only compiled here.

Trying it by hand

Build the test recipe and inspect the result:

rattler-build build --recipe test-data/recipes/package_files_override --output-dir /tmp/out

The package should contain bin/keep.sh and bin/also-keep.sh and nothing else, even though the script also created bin/skip.sh and share/doc/skip.txt. Then run the same recipe with --sandbox on Linux or macOS and with --env-isolation strict (the default) and none; the result should not change. Pass --keep-build and look into the build directory: there should be no leftover rattler-build-session-* directory and no package-files list.

For the debug path:

rattler-build debug setup --recipe test-data/recipes/package_files_override --output-dir /tmp/dbg
rattler-build debug run

debug run should succeed, and echo "$RATTLER_BUILD_PACKAGE_FILES" inside rattler-build debug shell should print a path under the build directory that is empty and writable. Finally, write an absurd amount into the variable from a script (for example head -c 20000000 /dev/zero >> "$RATTLER_BUILD_PACKAGE_FILES"): the build should fail with the "channel file of RATTLER_BUILD_PACKAGE_FILES holds more than" error, while debug run should only warn and keep the script's exit status.

Diff: 568 lines (+426 / -142) across 7 files Reviewer: None requested Review duration: 61345m
All Vouch review confidence checks passed
Residual risk 0.40 = Change Risk (0.69) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.69 · 568 lines diff across 7 files
0.69
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.380
Shallow Review Depth shallow_review_depth
0.344
No Reviewer Assigned no_reviewer_assigned
0.120
Real PR Conversation Timeline
1 comments
"Review active on #2890"
general weight: 0.35
Reviewers
None requested
Assignees
baszalmstra baszalmstra
Labels
risk: medium confidence: 42.2% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 68.7% (HIGH) · Higher = larger blast radius
68.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 42.2% · Lower = rushed or shallow review
42.2%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 39.7% · Moderate risk
39.7%