Repository navigation
feat: T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it - #3461
Conversation
BoxSpec carries the expanded spec's lifecycle hooks, each with the declared_by table that names its declarer (BOX-068, BOX-179). A spec with no hook list writes no key.
The daemon composes the project's lifecycle hooks from the hooks with a project declared_by in spec.json, in place of the [session] hooks of minimal.toml and the hooks of the expanded entry (BOX-068, BOX-179). A loadout hook still arrives on the contribution with its loadout. The log line that stores the spec names how many hooks it carries.
A session create puts the expanded spec's lifecycle_hooks, each with its declared_by, into the box spec it sends. The daemon stores them in spec.json and composes the project's hooks from them (BOX-068, BOX-179).
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Every failing check on
Re-run the failed jobs. If the same checks go red again on this head, the next failed suite starts a round; if this red is not the flake, |
|
Reviewed: no findings; approval withheld, 3 threads unresolved at APPROVE withheld: 3 unresolved threads — minimal-foundry[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/tests.rs:7749. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
| /// directory (BOX-068). `None` when the box stores no spec, or when the | ||
| /// stored spec does not read as a Box Spec. | ||
| fn stored_spec_beside(project_path: &DaemonAbsPath) -> Option<mfile::spec::BoxSpec> { | ||
| let path = project_path | ||
| .as_utf8_path() | ||
| .parent()? | ||
| .join(boxes::store::SPEC_FILE); | ||
| let bytes = match std::fs::read(&path) { | ||
| Ok(bytes) => bytes, | ||
| Err(e) if e.kind() == std::io::ErrorKind::NotFound => return None, | ||
| Err(e) => { | ||
| tracing::warn!(spec_path = %path, error = %e, "could not read the stored box spec"); | ||
| return None; | ||
| } | ||
| }; | ||
| match serde_json_lenient::from_slice(&bytes) { | ||
| Ok(spec) => Some(spec), | ||
| Err(e) => { | ||
| tracing::warn!( | ||
| spec_path = %path, | ||
| error = %e, | ||
| "the stored box spec does not read as a box spec; \ | ||
| the project's hooks compose from the project as before" | ||
| ); | ||
| None | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Composes the project's lifecycle hooks from the stored spec `spec`, not | ||
| /// from the project's `minimal.toml` (BOX-068, BOX-179). The hooks whose | ||
| /// `declared_by` names the project replace every project hook: the ones |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in stored_spec_beside
When spec.json cannot be read or parsed, stored_spec_beside logs a warning and returns None. The daemon then composes the project's hooks from the project's minimal.toml and the client entry. The PR says the daemon composes from the stored spec and not from minimal.toml. A corrupt or unreadable spec.json therefore changes which hooks run, with no error. A NotFound for a box that should have a spec is also silent. Consider failing the compose in the read-error and parse-error cases.
What the reviewer checked
Err(e) => { tracing::warn!(... "could not read the stored box spec"); return None; }
Hand this to an agent
Act on a code-review finding.
File: crates/minimald/src/box_manager/composables.rs
Lines: 569-600
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
When spec.json cannot be read or parsed, `stored_spec_beside` logs a warning and returns None. The daemon then composes the project's hooks from the project's `minimal.toml` and the client entry. The PR says the daemon composes from the stored spec and not from `minimal.toml`. A corrupt or unreadable spec.json therefore changes which hooks run, with no error. A NotFound for a box that should have a spec is also silent. Consider failing the compose in the read-error and parse-error cases.
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.
There was a problem hiding this comment.
Addressed in 714cfc15af56: An unreadable spec.json now fails the compose instead of falling back to minimal.toml, with a test. A parse failure still falls back, because the daemon stores any spec with a whole v (spec_bytes), so a spec of another version is accepted by design. NotFound stays silent: a box created without a spec stores no spec.json.
…-stores-the-expanded-spec-with-each-ho
A box that stores spec.json no longer falls back to the hooks in minimal.toml when the file exists but cannot be read.
|
/revise Merge origin/main into this branch, and change nothing else. The arch review on f594dab did not run: its check run finished the second it started, with the title "Not posted" and no ruling. A new head starts a fresh arch review. Main is one commit ahead (#3433). Do not rewrite history and do not force-push. Add a merge commit. The three tests this task names must still pass. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
A box created with a project hook and a loadout hook stores spec.json with both hooks and their declared_by values. The daemon composes the project's hooks from that stored spec, not from minimal.toml. A stored spec that exists but cannot be read now fails the compose and does not fall back to minimal.toml. Notes from the agent: Revise round 1. stored_spec_beside now returns Result. A read error other than NotFound fails run_compose with 'reading the stored box spec at : ' and logs at error level. A parse error still falls back to the project, on purpose: spec_bytes in box_manager.rs stores any spec with a whole |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minimald/src/box_manager/composables.rs:612. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 2 of 10 on a /revise note: the coder changed nothing. No-op. The directive asks for a merge of origin/main. That merge is already on the branch: merge commit 192c820 brought in f7b6e36 (#3433), and origin/main has no commits that HEAD does not have. A fresh fetch was not possible because the remote refused the connection, so I checked the local origin/main only. A new merge commit with no change is an empty commit, so I made none. The branch head stays 714cfc1. That head already differs from f594dab, the head where the arch review did not run, so a review of 714cfc1 can run without a new commit. All three test lines pass. |
…-stores-the-expanded-spec-with-each-ho # Conflicts: # crates/minimald/src/box_manager/tests.rs
|
/revise The arch ruling on 714cfc1 is CONDITIONS. The runtime withheld its text, and Karl read it and passed it on. C2 is done: #3467 owns the leftover work, and the PR body names it under Residuals. Do C1, in full: C1 — The three tests this task names must still pass. Do not rewrite history and do not force-push. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
A merge of main before round 3, not counted against the cap (1 of 3), pushed as Resolved conflicts in:
Verify Converted to a draft: something above needs a person before review. A box created with a project hook and a loadout hook has a spec.json that lists both hooks, each with its declared_by. The daemon composes the box from that stored spec, not from minimal.toml. The branch now merges cleanly with main. Notes from the agent: This round resolved the merge conflict with main in crates/minimald/src/box_manager/tests.rs. Both sides appended tests at the end of the file. I kept the branch's declarer tests and main's client_and_daemon_digests_match_vectors_and_mismatch_refused test, and committed the merge. cargo clippy -p minimald --all-targets is clean. The merged main test also passes. No code change was necessary this round. The wire layer is still open on this branch: crates/boxes/src/wire/request.rs still has WireContribution::entry and WireBoxEntry. This round's directive asked only for the conflict resolution, so I did not change it. A person must decide if a later round removes them. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The daemon now stores each hook with its declarer, and the client and daemon digests stay equal. One path fails open. When spec.json exists but is not a v0 spec, stored_spec_beside logs a warning. The compose then takes the project hooks from minimal.toml. Line 500 of architecture.md says a box restarts from the spec stored in its record. The launch path already refuses that spec through box_runtime::stored_spec. Make the change in C1. Then the change conforms, and #3467 tracks the loadout hooks.
Ruled at dd09b1e against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| )); | ||
| } | ||
| }; | ||
| match serde_json_lenient::from_slice(&bytes) { |
There was a problem hiding this comment.
C1 · A parse failure here returns Ok(None). The compose then takes the project hooks from minimal.toml. That fails open. Line 500 says the box restarts from the spec stored in its record. Call crate::box_runtime::stored_spec(&bytes).map(Some) here. Then a spec that is not v0, or a hook with no declared_by, fails the compose. held_spec refuses the same spec at launch.
There was a problem hiding this comment.
Addressed in 8bdcefe0f769: stored_spec_beside now calls crate::box_runtime::stored_spec(&bytes).map(Some), so a stored spec that is not v0, or has a hook with no declared_by, fails the compose with InvalidInput.
| }; | ||
| assert!(composition.lifecycle_hooks().is_empty()); | ||
|
|
||
| // A stored spec that cannot be read fails the compose: the hooks never |
There was a problem hiding this comment.
C1 · This case covers a read error only. Add a case that writes a spec.json with "v": 0 and a hook with no declared_by. Assert that run_compose(..., true) returns Err.
There was a problem hiding this comment.
Addressed in 8bdcefe0f769: composes_from_stored_expanded_spec_not_minimal_toml now writes a v0 spec.json with a hook that has no declared_by, and asserts that run_compose(..., true) returns an InvalidInput Err.
|
/revise Arch ruling 1328 on dd09b1e replaces the C1 in my earlier note with a more specific one. Where the two differ, follow this one. In full:
C2 from the earlier ruling stays done: #3467 owns the leftover wire work. The three tests this task names must still pass. Do not rewrite history and do not force-push. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
…-stores-the-expanded-spec-with-each-ho
A spec.json that is not a v0 spec, or has a hook with no valid declared_by, now fails the compose with the InvalidInput refusal that held_spec gives at launch, in place of a fall back to minimal.toml.
|
Round 4 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
A box created with a project hook and a loadout hook stores spec.json with both declarers. The daemon composes the box's hooks from that stored spec. A stored spec that is not v0, or has a hook with no declared_by, now fails the compose and does not fall back to minimal.toml. Notes from the agent: Round 4 does the C1 ruling. stored_spec_beside now calls crate::box_runtime::stored_spec(&bytes).map(Some) and logs the refusal at error level. Its doc comment no longer says that another version composes from the project. The compose test has a new case: a v0 spec.json with a hook that has no declared_by makes run_compose(..., true) return an InvalidInput Err. cargo clippy -p minimald --all-targets is clean. C2 stays with #3467. |
|
/revise The Main's native CI is green, so this comes from this branch: its stored-spec read now requires
The three tests this task names must still pass. Do not rewrite history and do not force-push. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to the design. The stored spec keeps each hook with its declared_by, and --no-hooks stores an empty list (architecture.md lines 1170-1172). The daemon composes the project's hooks from that stored spec, and project hooks still run before loadout hooks (line 1253). The new commit makes the compose refuse a stored spec that a launch refuses, so the hooks never fall back to minimal.toml. The work that stays open, the entry fields and the task create's hooks, is filed as #3467.
Ruled at 8bdcefe against gominimal/arch@327e1b57d16b by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 3 unresolved threads — minimal-foundry[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/tests.rs:7719. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/revise The Main's native CI is green, so this comes from this branch: its stored-spec read now requires
The three tests this task names must still pass. Do not rewrite history and do not force-push. |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
/revise The Main's native CI is green, so this comes from this branch: its stored-spec read now requires
The three tests this task names must still pass. Do not rewrite history and do not force-push. |
…-stores-the-expanded-spec-with-each-ho
The compose parsed the whole spec.json as a v0 Box Spec. A stored spec can carry keys that parse refuses, such as io.exec_enabled, file_exports and network.vpn_network_names, and partial specs. The compose now reads v, entry, box.type and lifecycle_hooks, and refuses only a spec that is not JSON or a hook list it cannot use.
|
Round 7 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. A box created with a project hook and a loadout hook stores spec.json with both hooks and their declared_by tables. The daemon composes the project's hooks from that stored spec. A stored spec that also carries keys such as io.exec_enabled, file_exports or network.vpn_network_names still composes, and the 47 minimal tests from the directive pass again. Notes from the agent: Cause: commit 8bdcefe made the compose parse the whole spec.json through crate::box_runtime::stored_spec, the strict v0 BoxSpec parse. That parse needs |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
Since 8bdcefe0, this PR adds a clean merge of main and one commit. That commit makes the compose read only the v, entry, box.type and lifecycle_hooks keys of spec.json. It still refuses bytes that are not JSON and a hook list it cannot use, and the resume path still refuses a spec that is not v0. The PASS on 8bdcefe0 stands, and residual #3467 stays open. The PR body reports that the verify build exited 101. Fix that build before you merge.
Ruled at 717988e against gominimal/arch@327e1b57d16b by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 3 unresolved threads — minimal-foundry[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/composables.rs, minimal-arch[bot] crates/minimald/src/box_manager/tests.rs:7749. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 8 of 10 on a failed check suite: the coder changed nothing. No code change this round. The directive gives only the failed test-kvm job and its ci-linux-kvm-success aggregator. The log excerpt holds no failing test or step output: it holds only the source lines of the workflow's error echoes, and the post-job cleanup. The whole test-kvm job ran from 04:31:00 to 04:32:08, about 70 seconds. The second materialize step started at 04:31:11. A cold guest boot alone takes 40 to 70 s, so the job ended in the materialize steps or at the first VM harness, before the session e2e ran. The same session-e2e.sh ran on the native Linux lane at this head and the directive does not list it as failed. I found no VM-only path in this branch's change (stored spec read in run_compose, hooks on the create spec) that can fail that early. This box has no /dev/kvm, so I could not run the VM harnesses or |
T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it
slice: S6
kind: integration
covers: none
size: L
est: 300 code, 320 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the daemon log names the box and how many hooks it stored
observability: spec.json holds each hook with its declared_by
layers:
- spec:
- crates/mfile/src/spec.rs: the stored spec carries lifecycle_hooks with declared_by
- daemon:
- crates/minimald/src/box_manager.rs: store the received expanded spec as spec.json
- crates/minimald/src/box_manager/composables.rs: compose from the stored spec, not minimal.toml
- crates/minimald/src/box_manager/tests.rs: tests
test: cargo nextest run -p minimald stored_spec_keeps_each_hook_with_its_declarer_in_spec_json
test: cargo nextest run -p minimald composes_from_stored_expanded_spec_not_minimal_toml
- wire:
- crates/boxes/src/wire/request.rs: remove WireContribution::entry and WireBoxEntry
- client:
- crates/minimal/src/cmd/boxes/create.rs: send the expanded spec with each hook's declared_by
- crates/minimal/src/tests.rs: tests
test: cargo nextest run -p minimal created_box_spec_json_names_each_hook_declarer
produces: none
consumes:
- crates/mfile/src/expand.rs
proof: create a box with a project hook and a loadout hook, and read spec.json back with both declarers, while the daemon composes the box from that stored spec.
depends on:
- blocked by #3311
- blocked by #3387
When this task merges, the work #3282 and #3257 track is done. Close both by hand.
Residuals
WireContribution::entryandWireBoxEntry, and composevars,vars_lenient,patchesand the loadout hooks from the stored spec, not from the contribution.Proof
A session box created from a project with a project hook and a selected loadout hook stores both hooks in its spec.json. Each hook has its declared_by: { kind = "project" } for one and { kind = "loadout", name = "rust" } for the other.
min box specreads that file through GetBoxSpec. The daemon composes the project's hooks from the project-declared hooks in that stored spec, and not from the [session] hooks in minimal.toml. The daemon log line "stored the box spec" names the box id and the lifecycle_hooks count.Notes from the agent: Wire layer not done. The task says to remove WireContribution::entry and WireBoxEntry from crates/boxes/src/wire/request.rs. Code outside the layers still uses both types: crates/boxes/src/daemon/composer.rs (compose_entry and its tests) and crates/minimal/src/task.rs (the task create sets contribution.entry). The stored v0 BoxSpec also has no field for the entry's vars, vars_lenient or patches, so the daemon still needs the entry for those. Both types stay. The daemon now overrides only the entry's lifecycle_hooks with the stored spec's project hooks. A follow-up task needs those two files in its layers, and a spec that carries vars, vars_lenient and patches.
Design: BoxSpec gains
lifecycle_hooks: Option<Vec<SpecHook>>, serialized as a top-levellifecycle_hookslist and omitted when None. Each hook is the LifecycleHook table with adeclared_bytable. None means the client sent no list: a task create (task.rs is outside the layers, somin task runstill sends none), an older client, or an older stored spec. In that case the daemon composes hooks as before. The key is outside the projection, so the client and daemon digests stay equal (create_stores_client_digest_equal_to_daemon_digest passes).Only hooks with declared_by kind = project replace the project hooks in the composition. Loadout hooks still come in on the client contribution with their loadout source, so the daemon does not add them twice. With --no-ho…[truncated]
Tests
cargo nextest run -p minimald stored_spec_keeps_each_hook_with_its_declarer_in_spec_jsoncargo nextest run -p minimald composes_from_stored_expanded_spec_not_minimal_tomlcargo nextest run -p minimal created_box_spec_json_names_each_hook_declarerVerify
min task run agent-verifyexited 101, so this PR is a draft.Closes #3409