feat: hand build-script results back through channel files #2890
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
baszalmstra
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.channelslists 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 inExecOutcomeafter 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 structuredChannelTooLargeerror 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_FILESis the first consumer:Output::run_build_scriptdeclares the channel and returns the parsed list,create_packagetakes it as a parameter, and the fixed path,package_files_list_pathandread_package_files_listare 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 underdebug run. One visible change: the variable is no longer part ofbuild_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_scriptforwarding channels and surfacing the bytes, the debug commands keeping the exit status of an overfilled channel,run_build_scriptreturning the parsed list, and the pure parser. Thepackage_files_overrideend-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:
The package should contain
bin/keep.shandbin/also-keep.shand nothing else, even though the script also createdbin/skip.shandshare/doc/skip.txt. Then run the same recipe with--sandboxon Linux or macOS and with--env-isolation strict(the default) andnone; the result should not change. Pass--keep-buildand look into the build directory: there should be no leftoverrattler-build-session-*directory and no package-files list.For the debug path:
debug runshould succeed, andecho "$RATTLER_BUILD_PACKAGE_FILES"insiderattler-build debug shellshould print a path under the build directory that is empty and writable. Finally, write an absurd amount into the variable from a script (for examplehead -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, whiledebug runshould only warn and keep the script's exit status.