8000 T20 — End an until-complete box at its timeout, and rerun activation hooks on resume when asked by minimal-foundry[bot] · Pull Request #3104 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

T20 — End an until-complete box at its timeout, and rerun activation hooks on resume when asked - #3104

Open
minimal-foundry[bot] wants to merge 1 commit into
mainfrom
agent/2415-end-an-until-complete-box-at-its-timeout-and-rer
Open

minimal-foundry[bot] wants to merge 1 commit into
mainfrom
agent/2415-end-an-until-complete-box-at-its-timeout-and-rer

Conversation

@minimal-foundry
Copy link
Copy Markdown
Contributor

T20 — End an until-complete box at its timeout, and rerun activation hooks on resume when asked

slice: S4
kind: task
covers: BOX-028, BOX-037
size: M
est: 220 code, 180 tests
executor: agent
difficulty: needs care
model: standard
diagnostics: daemon log names timeout kills
observability: exited event carries reason timeout
layers:
- spec:
- crates/mfile/src/spec.rs: resume-hooks key
test: cargo nextest run -p mfile spec_carries_hooks_on_resume
- runtime:
- crates/minimald/src/box_runtime.rs: timeout TERM then KILL
- crates/minimald/src/box_runtime/tests.rs: tests
test: cargo nextest run -p minimald until_complete_timeout_terms_then_kills_box_and_execs_reason_timeout
- hooks:
- crates/minimald/src/hooks.rs: reruns activation hook
- crates/minimald/src/box_actor/tests.rs: tests
test: cargo nextest run -p minimald hooks_on_resume_reruns_on_activate
produces: none
consumes: none
proof: A task past its timeout ends exited with reason timeout.
depends on:
- blocked by #2407
- blocked by #2410

Proof

Not delivered. A task past its timeout does not end exited with reason timeout at this branch. The only change is in the Box Spec: an entry with hooks_on_resume = true in minimal.toml now carries hooks_on_resume = true in the spec the client sends the daemon. The daemon reads this key nowhere yet.

Notes from the agent: Only the spec layer is done. The runtime and hooks layers cannot be done inside the files they name, so I did not attempt them and did not widen the diff. I did not run their two test lines, because neither test exists.

Runtime layer (BOX-037, test until_complete_timeout_terms_then_kills_box_and_execs_reason_timeout): crates/minimald/src/box_runtime.rs is the per-box Host loop over the entrypoint process only. It has no handle on exec processes and does not write the record. (1) The Box Spec (crates/mfile/src/spec.rs) has no timeout field, so the daemon has no timeout to enforce. The layer note for spec.rs names only the resume-hooks key. (2) The SIGTERM, grace, SIGKILL sequence over every box process, execs included, is in box_actor.rs (stop_box) and box_actor/host.rs (STOP_GRACE, the signal loop near line 2040). (3) The record is set to exited, with ExitEnding::Exit and the exited event, in box_actor.rs end_on_entrypoint_return. That function returns early when HostExit.requested is true, so a daemon kill never ends the box. Writing ExitEnding::Timeout and reason = "timeout" on the event needs a change there. A replan must name crates/minimald/src/box_actor.rs and box_actor/host.rs, and give spec.rs a timeout key. boxes::core::record::ExitEnding::Timeout and EndReason::Timeout already exist.

Hooks layer (BOX-028, test hooks_on_resume_reruns_on_activate): crates/minimald/src/hooks.rs says in its module doc that it does not decide when hooks fire. The resume path is box_actor.rs resume and resume_ended. A comment there says that BOX-027 runs no hook on resume. on_activate is fired from box_actor/setup.rs …[truncated]

Tests

line exit tail
cargo nextest run -p mfile spec_carries_hooks_on_resume 0 Applying loadouts: default Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling args v0.0.1 (/workbench/crates/args) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling paths v0.0.1 (/workbench/crates/paths) Compiling client-config v0.0.1 (/workbench/crat
cargo nextest run -p minimald until_complete_timeout_terms_then_kills_box_and_execs_reason_timeout 4 ompiling ecdsa v0.17.0 Compiling primeorder v0.14.0 Compiling close_fds v0.3.2 Compiling sendfd v0.4.4 Compiling caps v0.5.6 Compiling crossbeam-channel v0.5.16 Compiling curve25519-dalek v5.0.0 Compiling hak 8000 oniwa v1.7.2 (https://github.com/souk4711/hakoniwa.git?rev=0810ffa37620
cargo nextest run -p minimald hooks_on_resume_reruns_on_activate 4 Applying loadouts: default Running task runtime-implement-test-2 in box runtime-implement-test-2-1... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.0.1 (/workbe

Verify

min task run agent-verify passed ([tasks.verify]).

Closes #2415

An entry that sets `hooks_on_resume = true` now carries the key in the
spec the client sends the daemon (BOX-028), under the same top-level
name the expanded spec uses. A spec that does not set it leaves the key
out, so the bytes of specs stored before the key stay the same.
@coderabbitai
coderabbitai Bot commented Nov 6, 2026
Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eda4fdf2-4ce6-413a-bcd3-6ba83522e3c1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-foundry
minimal-foundry Bot commented Nov 6, 2026 •
Copy link
Copy Markdown
Contributor Author

Reviewed: 1 finding, none blocking at 5e3e67496c60.

Address the comments on the diff.

Clobber: none seen.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/mfile/src/spec.rs
Comment on lines +260 to +267
/// Whether an entry's own table sets `hooks_on_resume = true` (BOX-028).
/// The entry tables keep the key among the ones they do not read
/// themselves, so it is read from there.
fn hooks_on_resume(extra: &std::collections::HashMap<String, toml::Value>) -> bool {
extra
.get("hooks_on_resume")
.and_then(toml::Value::as_bool)
.unwrap_or(false)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM · correctness · confidence 0.70 · in hooks_on_resume

The key is read from extra, but File::warn_unknown_fields in crates/mfile/src/lib.rs still lists every extra key of [session] and [tasks.*] as unknown. So a user who sets hooks_on_resume = true gets a warning unknown fields in [session] section for a key that now works. The helper also turns a non-bool value such as "true" into false with no error. Exempt the key in the warning code and reject a non-bool value.

What the reviewer checked

lib.rs:1586-1599 filters only STORE_RULES_TABLE from session.extra; spec.rs:266 .and_then(toml::Value::as_bool).unwrap_or(false)

Hand this to an agent
Act on a code-review finding.

File:       crates/mfile/src/spec.rs
Lines:      260-267
Category:   correctness
Severity:   medium (reviewer confidence 0.70)

Finding:
The key is read from `extra`, but `File::warn_unknown_fields` in `crates/mfile/src/lib.rs` still lists every `extra` key of `[session]` and `[tasks.*]` as unknown. So a user who sets `hooks_on_resume = true` gets a warning `unknown fields in [session] section` for a key that now works. The helper also turns a non-bool value such as `"true"` into false with no error. Exempt the key in the warning code and reject a non-bool value.

First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.

👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disputed — not addressed: The facts hold, but both fixes are outside this task's layers (only crates/mfile/src/spec.rs). The warning filter is in File::warn_unknown_fields in crates/mfile/src/lib.rs. To reject a non-bool value, BoxSpec::for_session must return an error, which changes its callers in other crates. No change this round. A task that names crates/mfile/src/lib.rs and those callers must fix it.

@minimal-arch minimal-arch Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arch-review: CONDITIONS · 2 conditions · the full ruling

This head delivers only the spec layer of T20, and it puts hooks_on_resume in the wrong place. The design's Box Spec puts the key in [execution] (architecture.md lines 1095-1099, box.toml line 254). The change writes it as a new top-level v0 key. Move it into DocExecution as C1 says. The body says Closes #2415, but BOX-037 and the resume half of BOX-028 are not done. Change that to a partial and file the two residuals as C2 says. The escalation asks a person to replan the runtime and hooks layers onto box_actor.rs and box_actor/host.rs.

Ruled at 5e3e674 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.

Comment thread crates/mfile/src/spec.rs
/// Whether the box runs its lifecycle hooks.
pub hooks_enabled: bool,
/// Whether a resume of the box runs its `on_activate` hooks again
/// (BOX-028). Serialized as the top-level `hooks_on_resume` key, the
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C1 · The design's Box Spec puts hooks_on_resume in [execution] (architecture.md line 1099, box.toml line 254), not at the top level. Change this comment to say the field serializes as execution.hooks_on_resume.

Comment thread crates/mfile/src/spec.rs
hooks_enabled: bool,
/// Absent from a spec that does not set it, which reads as `false`.
#[serde(default, skip_serializing_if = "is_false")]
hooks_on_resume: bool,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C1 · Remove this top-level key. Add it to DocExecution with the same serde(default, skip_serializing_if = "is_false"). The module doc lists the top-level v0 exceptions, and this key has a box.toml home in [execution].

Comment thread crates/mfile/src/spec.rs
v: spec.v,
entry: spec.entry,
hooks_enabled: spec.hooks_enabled,
hooks_on_resume: spec.hooks_on_resume,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C1 · Set hooks_on_resume inside DocExecution { .. } here. Read it back from doc.execution in From<SpecDoc> for BoxSpec, with false when the table is absent.

@minimal-foundry
Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on the runtime's review findings: the coder changed nothing. This round changes nothing. The branch keeps the spec layer commit 5e3e674. The runtime and hooks layers cannot be done inside the files that the layers name, so I left them undone and did not widen the diff. Runtime layer (BOX-037): (1) box_actor.rs writes the exited state at about line 1716, and that write is hardwired to ExitEnding::Exit. A timeout ending needs a change there. (2) box_actor/host.rs builds HostParams at about line 1226, so a timeout value cannot reach box_runtime.rs without a change there. (3) The daemon BoxSpec in crates/mfile/src/spec.rs has no timeout field. Only crates/mfile/src/expand.rs carries timeout, as a string such as "2h". The spec.rs layer note covers the resume-hooks key only. Hooks layer (BOX-028): the resume decision i 9D56 s in box_actor.rs (resume, resume_ended), and activation hooks run from box_actor/setup.rs and box_actor/host.rs (run_session_hooks, has_hooks_for). hooks.rs can hold a helper, but no file in the layers can call it on resu…[truncated]

Review threads the coder judged:

  • 👎 invalid — crates/mfile/src/spec.rs:267: The facts hold, but both fixes are outside this task's layers (only crates/mfile/src/spec.rs). The warning filter is in File::warn_unknown_fields in crates/mfile/src/lib.rs. To reject a non-bool value, BoxSpec::for_session must return an error, which changes its callers in other crates. No change th

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T20 — End an until-complete box at its timeout, and rerun activation hooks on resume when asked

0 participants

0