8000 fix(minimald): fail the exec_enabled gate closed on a bad spec · gominimal/minimal@a8e3fe7 · GitHub
[go: up one dir, main page]

Skip to content

fix(minimald): fail the exec_enabled gate closed on a bad spec

Minimal Arch / arch-review failed Nov 3, 2026

CONDITIONS

Baseline. This re-reviews a8e3fe71 against the CONDITIONS on 3f855331 (this PR). I checked these facts. since.diff equals git diff 3f855331 a8e3fe71. pr.diff equals git diff 853df318 a8e3fe71. The compare is a clean merge of main (beab00d3, git diff-tree --cc empty: #2870, #2763, #2825) plus one branch commit, a8e3fe71, which makes the exec_enabled gate fail closed. The arch checkout 7a86ec7b has no arch-map.md, and no findings.json was staged. The ledger keeps only the first 400 characters of the prior ruling, so I could not read its conditions. I re-derived every requirement from the design, and I did not depend on the earlier list.

Governs: architecture.md line 497 (min box exec), the command reference (line 478), the [io] exec_enabled default (lines 879–882) and exit code 5 (line 366). Line 497 says that a detached or -t exec outlives its client, and that any exec ends on min box stop <box> --exec <id>. A stop ends "its process group — the command and the children it did not detach into their own session". A process that the command put in its own session survives. minimald enforces exec_enabled from the stored spec and refuses with exit 5, naming the key. exec_started carries principal, argv and PTY flag, and exec_exited carries the exit code or reason timeout.

Ruling. BOX-150, BOX-152 and BOX-153 conform. With the compare, the gate refuses a spec that it cannot read or parse (rule 7). BOX-151 deviates in two places. First, the change makes a tty exec lead a session that owns its PTY. An interactive shell then turns on job control and puts jobs in other process groups of that session, but the shim still kills only -pgid (C1). Before this change the exec had no controlling terminal, so job control was off and the group kill reached every child. Second, only managed execs register for a stop. A plain exec has an id but cannot be stopped, and the RPC says that it does not exist (C2). C3 asks for issues for the two pieces of work that the body leaves undone: the minimald-rpc and min client path, and the mfile field without which a real spec cannot set the key (rule 6).

Placement and boundaries. StopExec sits in minimald/src/rpc.rs and is dispatched like StopBox, with the same per-connection authorization and no new check. The design does not name the crate that owns RPC types, so the move to minimald-rpc is a residual (C3), not a deviation.

Not checked. I did not build or run anything. That an interactive shell on the new controlling terminal turns on job control is standard shell behaviour, not something observed here. exec_disabled_refuses_exit5 covers the shell, argv, attached and detached forms but not the tty form, which goes through the same gate before the mode branch.

Conditions

  • C1: crates/minimald/src/nsenter.rs shim_main: when take_terminal is set, the exec leads a session, so its end must reach every process group of that session, not only -pgid. In the main flow (not in a signal handler), at the group SIGTERM and again at the SIGKILL after GROUP_GRACE, signal each process group whose session id (field 6 of /proc/<pid>/stat in the box's PID namespace) equals the published CHILD_PGID. A process that called setsid has another session id and stays alive. Update the CHILD_PGID doc comment and the publish comment, which still say setpgid(0, 0). Add a test: a process under lead_session_on_terminal starts a child that calls setpgid(0, 0) into a new group of the same session, and a stop of the exec ends that child.
  • C2: Make a plain (attached) exec stoppable by its id. In crates/minimald/src/exec.rs run_attached_exec, register a stop for exec_id together with its box id. In crates/minimald/src/exec/process.rs, TimedBoxExec carries that CancellationToken and TimedProcess::wait selects on it, then ends the command with start_kill and wait_after_stop, as wait_or_stop does. stop_exec finds an attached exec through that registration and answers with its ExecExit, so rpc.rs stop_exec_answer no longer answers "box has no exec ." for a live exec. Remove the registration when the exec ends. Add a test: a stop of an attached exec ends it, writes its exec_exited event, and leaves the box running.
  • C3: File two issues and link them as residuals in the PR body. (a) Move StopExec, StopExecRequest and StopExecResponse from crates/minimald/src/rpc.rs into minimald-rpc, and add min box stop <box> --exec <id>. Until then no client can call the RPC. (b) Add io.exec_enabled (default true) to mfile::spec::BoxSpec. Until then a spec that sets the key fails the parse at launch, so the gate takes effect only on a hand-written spec.json.

Ruled at a8e3fe7 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5; arch_rulings 792, job 6d28916b-4b48-4dab-9151-d8885776bf28.

0