Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58aeaf6
fix(task): gate task patch declarations against [patches] policy
gominimal-aw-bot[bot] Oct 17, 2026
0156c19
fix(task): let a directory rule approve its contents and keep the ref…
gominimal-aw-bot[bot] Oct 18, 2026
4e4fa43
fix(task): require a patch verdict daemon-side and gate min session run
gominimal-aw-bot[bot] Oct 18, 2026
5c64e8f
fix(task): probe a symlinked patch directory at its target
gominimal-aw-bot[bot] Oct 18, 2026
f68b09a
fix(task): refuse patch declarations on an in-box min run
gominimal-aw-bot[bot] Oct 18, 2026
aad78f4
fix(task): require the resolved patch path to pass the allow step
gominimal-aw-bot[bot] Oct 18, 2026
55b975f
docs(reference): split the in-box min run sentence for the prose lint
gominimal-aw-bot[bot] Oct 18, 2026
e7c9fea
fix(task): walk symlinked subdirectories and follow dangling patch links
gominimal-aw-bot[bot] Oct 18, 2026
bcd6a25
fix(task): bind the patch verdict to each declaration's kind and mode
gominimal-aw-bot[bot] Oct 18, 2026
69642d4
fix(task): gate an echo task's patches like any other task's
gominimal-aw-bot[bot] Oct 18, 2026
4f2d05e
fix(boxes): refuse a task patch directory the deny walk cannot finish
gominimal-aw-bot[bot] Oct 18, 2026
ff709ba
fix(boxes): refuse a task patch directory that is a file as a file
gominimal-aw-bot[bot] Oct 18, 2026
ecfe800
fix(minimald): drop a task patch only from the map of its kind
gominimal-aw-bot[bot] Oct 18, 2026
ee024a7
docs(policy): say a ~/ task patch is matched by its path only
gominimal-aw-bot[bot] Oct 18, 2026
c258126
docs(policy): state the ~/ patch rule in the active voice
gominimal-aw-bot[bot] Oct 18, 2026
7db769d
Merge remote-tracking branch 'origin/main' into inbox-patch/fix/task-…
minimal-foundry[bot] Oct 20, 2026
4accca7
fix(task): close patch gate gaps found in review
minimal-foundry[bot] Oct 20, 2026
9bc5189
fix(minimald): refuse a ~/ task patch that leaves the session home
minimal-foundry[bot] Oct 20, 2026
4fa327f
docs(policy): describe the stricter task patch checks
minimal-foundry[bot] Oct 20, 2026
d1573a7
Merge remote-tracking branch 'origin/main' into inbox-patch/fix/task-…
minimal-foundry[bot] Oct 20, 2026
b5221dc
fix(task): recheck ~/ patch links per spawn and name the failing link
gominimal-aw-bot[bot] Oct 20, 2026
9d38f6f
fix(boxes): check every symlink alias in a task patch walk
gominimal-aw-bot[bot] Oct 20, 2026
ee87aee
Merge remote-tracking branch 'origin/main' into HEAD
gominimal-aw-bot[bot] Oct 20, 2026
0f7a023
style(boxes): apply rustfmt to the patch-gate compose code
gominimal-aw-bot[bot] Oct 21, 2026
ca81b33
Merge remote-tracking branch 'origin/main' into inbox-patch/fix/task-…
minimal-foundry[bot] Oct 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
805 changes: 804 additions & 1 deletion crates/boxes/src/core/compose.rs

Large diffs are not rendered by default.

1,012 changes: 1,012 additions & 0 deletions crates/boxes/src/core/compose/tests.rs

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions crates/minimal-client/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ pub fn attach_command(
id: boxes::SessionId,
wire: Option<&str>,
session_keys: Option<&boxes::keys::SessionKeys>,
) -> Result<std::process::Command, anyhow::Error> {
attach_command_with_env(sock, id, wire, session_keys, &[])
}

/// [`attach_command`], plus `channel_env`: extra variables sent on the
/// channel ahead of the exec request, each set on ssh and named in a
/// `SendEnv` option. `min session run` carries a task's `[patches]`
/// verdict ([`minimald_rpc::taskenv::TASK_PATCH_VERDICT`]) this way, which
/// the daemon reads from the channel config like the native client's
/// `set_env`.
pub fn attach_command_with_env(
sock: &Path,
id: boxes::SessionId,
wire: Option<&str>,
session_keys: Option<&boxes::keys::SessionKeys>,
channel_env: &[(&str, &str)],
) -> Result<std::process::Command, anyhow::Error> {
// ProxyCommand points at our own `proxy` subcommand so we don't
// depend on socat or nc being installed.
Expand Down Expand Up @@ -143,6 +159,10 @@ pub fn attach_command(
let (trace_var, trace_value) = trace_env();
ssh.env(trace_var, trace_value);
ssh.args(["-o", &format!("SendEnv={trace_var}")]);
for (name, value) in channel_env {
ssh.env(name, value);
ssh.args(["-o", &format!("SendEnv={name}")]);
}
ssh.args([
"-o",
"SendEnv=MINIMAL_SESSION_ID",
Expand Down Expand Up @@ -1024,6 +1044,39 @@ mod tests {
}
}

/// Channel env rides ahead of the command: each variable is set on ssh
/// and named in a `SendEnv` option before the host alias, so ssh sends
/// it as an env request rather than as part of the remote command.
#[test]
fn channel_env_is_set_and_sent_before_the_command() {
let sock = PathBuf::from("/tmp/x/providers/local-minimald0/ssh.sock");
let cmd = attach_command_with_env(
&sock,
boxes::SessionId::nil(),
Some("wire"),
None,
&[("MINIMAL_TASK_PATCH_VERDICT", r#"{"allow":[],"drop":[]}"#)],
)
.unwrap();
let args: Vec<_> = cmd
.get_args()
.map(|a| a.to_string_lossy().into_owned())
.collect();
let send = args
.iter()
.position(|a| a == "SendEnv=MINIMAL_TASK_PATCH_VERDICT")
.expect("named in a SendEnv option");
let host = args
.iter()
.position(|a| a == "local-minimald0")
.expect("host alias");
assert!(send < host, "options precede the host: {args:?}");
assert_eq!(args.last().map(String::as_str), Some("wire"));
assert!(cmd.get_envs().any(|(k, v)| {
k == "MINIMAL_TASK_PATCH_VERDICT" && v.is_some_and(|v| v == r#"{"allow":[],"drop":[]}"#)
}));
}

/// Every attach bounds its connect and handshake with the shared deadline;
/// only the non-interactive exec path adds keepalives, so a peer that
/// stops answering ends the exec instead of hanging it.
Expand Down
24 changes: 21 additions & 3 deletions crates/minimal-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,11 @@ impl Client {
///
/// `task_env` carries a task's `env_vars` already resolved against the
/// invoking shell: values under
/// [`TASK_ENV_PREFIX`](minimald_rpc::taskenv::TASK_ENV_PREFIX), and the
/// names to remove under
/// [`TASK_ENV_DROP`](minimald_rpc::taskenv::TASK_ENV_DROP). Only
/// [`TASK_ENV_PREFIX`](minimald_rpc::taskenv::TASK_ENV_PREFIX), the
/// variable names to remove under
/// [`TASK_ENV_DROP`](minimald_rpc::taskenv::TASK_ENV_DROP), and the
/// `[patches]` verdict on its declared patch paths under
/// [`TASK_PATCH_VERDICT`](minimald_rpc::taskenv::TASK_PATCH_VERDICT). Only
/// [`ExecRequest::TaskRun`](minimald_rpc::exec::ExecRequest::TaskRun) has
/// any to send; every other caller passes an empty
/// [`TaskEnv`](minimald_rpc::taskenv::TaskEnv) and the daemon behaves
Expand Down Expand Up @@ -645,6 +647,22 @@ impl Client {
.await
.context("set task env drop list")?;
}
// The patch verdict is the opposite: sent whenever the client gated,
// empty or not, because a daemon refuses a task that declares
// patches without one.
if let Some(verdict) = &task_env.patch {
let encoded = minimald_rpc::taskenv::encode_patch_verdict(verdict).map_err(|len| {
anyhow::anyhow!(
"the task's patch declarations are too large to send ({len} bytes, \
limit {}); declare fewer `patch` entries",
minimald_rpc::taskenv::TASK_PATCH_VERDICT_MAX_BYTES
)
})?;
channel
.set_env(true, minimald_rpc::taskenv::TASK_PATCH_VERDICT, encoded)
.await
.context("set task patch verdict")?;
}
channel
.exec(true, command)
.await
Expand Down
22 changes: 20 additions & 2 deletions crates/minimal/src/cmd/boxes/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ pub(crate) async fn box_via_ssh(
wire: Option<String>,
config_dir: Option<&std::path::Path>,
host_asks_for: Option<&str>,
) -> Result<(), anyhow::Error> {
session_via_ssh_with_env(sock, id, wire, config_dir, host_asks_for, &[]).await
}

/// [`box_via_ssh`], plus `channel_env` sent on the exec channel ahead
/// of the request (see [`minimal_client::attach::attach_command_with_env`]).
pub(crate) async fn session_via_ssh_with_env(
sock: &std::path::Path,
id: boxes::SessionId,
wire: Option<String>,
config_dir: Option<&std::path::Path>,
host_asks_for: Option<&str>,
channel_env: &[(&str, &str)],
) -> Result<(), anyhow::Error> {
// The command itself lives in minimal-client, shared with the dash TUI's
// suspend-attach-resume flow. The interactive path resolves the
Expand All @@ -213,8 +226,13 @@ pub(crate) async fn box_via_ssh(
} else {
None
};
let mut ssh =
minimal_client::attach::attach_command(sock, id, wire.as_deref(), session_keys.as_ref())?;
let mut ssh = minimal_client::attach::attach_command_with_env(
sock,
id,
wire.as_deref(),
session_keys.as_ref(),
channel_env,
)?;

// The session's record, read before the attach or the exec on a
// VM-backed host — one with a VM host daemon's control socket beside
Expand Down
16 changes: 15 additions & 1 deletion crates/minimal/src/cmd/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,20 @@ pub async fn cmd_session_run(
"found session"
);

box_via_ssh(
// Gate the task's declared patches against `[patches]` here, as `min
// task run` does: the daemon holds no policy, and refuses a task that
// declares patches without this verdict.
let verdict =
crate::task::gate_session_task_patches(global, r.project_path.as_utf8_path(), &args.task)?;
let verdict = minimald_rpc::taskenv::encode_patch_verdict(&verdict).map_err(|len| {
anyhow::anyhow!(
"the task's patch declarations are too large to send ({len} bytes, limit {}); \
declare fewer `patch` entries",
minimald_rpc::taskenv::TASK_PATCH_VERDICT_MAX_BYTES
)
})?;

session_via_ssh_with_env(
&sock,
r.id,
// No owns-box flag (NET-131): the task runs in a session someone
Expand All @@ -149,6 +162,7 @@ pub async fn cmd_session_run(
),
None,
None,
&[(minimald_rpc::taskenv::TASK_PATCH_VERDICT, verdict.as_str())],
)
.await
}
Expand Down
Loading
Loading