Repository navigation
feat: T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it - #3461
feat: T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it#3461minimal-foundry[bot] wants to merge 6 commits into
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, 1 thread unresolved at APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minimald/src/box_manager/composables.rs:612. 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 found. If that was not intentional, restore the earlier change. |
| /// 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. |
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.
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