Skip to main content

shape_command_output

Function shape_command_output 

Source
pub fn shape_command_output(
    command: &str,
    output: &str,
    exit_code: Option<i32>,
) -> String
Expand description

Shape the output of a host-native shell command whose exact command line is known (ctx_shape, fed by a host mod after the native tool ran). Unlike the wire funnel, the real command reaches the engine, so its command-gated policies (protected/verbatim commands, build/test guards, per-tool patterns) apply exactly as for ctx_shell. With a known exit_code the outcome-aware path runs (success compresses, failure keeps its diagnostics); without one the engine’s unknown-outcome guard applies. Lossy results carry the same deterministic CCR recovery handle (#482, #498).

The same rules as the wire funnel hold: an output that already ends with its way back is returned whole, and every shorter form leaves through attach_ccr — under protection only with a recovery copy bound to the output’s lineage, otherwise whole and noted with its code.

This route is no request: it holds no tool list of the host that will read the result. It therefore runs as a pass that knows no expand tool (sticky_tools::in_pass) instead of outside any pass, where the bare name ctx_expand would stand in. Under protection no stub is issued then: the output stays whole with recovery.handle_not_followable, and nothing is stored. Unprotected, the Community tee handle is unchanged.