Skip to content

feat: T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it - #3461

Draft
minimal-foundry[bot] wants to merge 6 commits into
mainfrom
agent/3409-the-daemon-stores-the-expanded-spec-with-each-ho
Draft

minimal-foundry[bot] wants to merge 6 commits into
mainfrom
agent/3409-the-daemon-stores-the-expanded-spec-with-each-ho

Conversation

@minimal-foundry

Copy link
Copy Markdown
Contributor

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 spec reads 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-level lifecycle_hooks list and omitted when None. Each hook is the LifecycleHook table with a declared_by table. None means the client sent no list: a task create (task.rs is outside the layers, so min task run still 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

line exit tail
cargo nextest run -p minimald stored_spec_keeps_each_hook_with_its_declarer_in_spec_json 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimald composes_from_stored_expanded_spec_not_minimal_toml 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal created_box_spec_json_names_each_hook_declarer 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify

min task run agent-verify exited 101, so this PR is a draft.

uild/debug/deps/libot-f7d366bdf87c04c2.rlib --extern p256=/work/build-cache/cargo-home/build/debug/deps/libp256-ec3d90cc52488749.rlib --extern paths=/work/build-cache/cargo-home/build/debug/deps/libpaths-38d338f2d2882e54.rlib --extern proptest=/work/build-cache/cargo-home/build/debug/deps/libproptest-44d491d1a8aa49a0.rlib --extern ratatui=/work/build-cache/cargo-home/build/debug/deps/libratatui-1fc20dde22a8a62b.rlib --extern reqwest=/work/build-cache/cargo-home/build/debug/deps/libreqwest-5de86acda4cea8f4.rlib --extern russh=/work/build-cache/cargo-home/build/debug/deps/librussh-ed15d7ff509bfc78.rlib --extern serde=/work/build-cache/cargo-home/build/debug/deps/libserde-a2d31a39ef0e3ca2.rlib --extern serde_json_lenient=/work/build-cache/cargo-home/build/debug/deps/libserde_json_lenient-d40e6f0e7b3e9eef.rlib --extern sha2=/work/build-cache/cargo-home/build/debug/deps/libsha2-c9bcb32104c3d8ae.rlib --extern switch=/work/build-cache/cargo-home/build/debug/deps/libswitch-6c812704e5da955c.rlib --extern tempfile=/work/build-cache/cargo-home/build/debug/deps/libtempfile-a0e916d9301e1bc8.rlib --extern tokio=/work/build-cache/cargo-home/build/debug/deps/libtokio-13fd64194b408f82.rlib --extern tokio_stream=/work/build-cache/cargo-home/build/debug/deps/libtokio_stream-f2be74d61837d3fa.rlib --extern toml=/work/build-cache/cargo-home/build/debug/deps/libtoml-2aea33601fef026d.rlib --extern toml_edit=/work/build-cache/cargo-home/build/debug/deps/libtoml_edit-c70767a08866b85f.rlib --extern tracing=/work/build-cache/cargo-home/build/debug/deps/libtracing-83feaaf26e80a884.rlib --extern tracing_subscriber=/work/build-cache/cargo-home/build/debug/deps/libtracing_subscriber-b9d261067ec6d0c0.rlib --extern unicode_width=/work/build-cache/cargo-home/build/debug/deps/libunicode_width-b88ae913615e5a0f.rlib --extern url=/work/build-cache/cargo-home/build/debug/deps/liburl-7dfaaabb254cca5f.rlib --extern uuid=/work/build-cache/cargo-home/build/debug/deps/libuuid-2ad4c678aa627cb6.rlib --extern version=/work/build-cache/cargo-home/build/debug/deps/libversion-26aec4f378b53f65.rlib --extern zeroize=/work/build-cache/cargo-home/build/debug/deps/libzeroize-839e2912eb255706.rlib -L native=/work/build-cache/cargo-home/build/debug/build/zstd-sys-0d91391d9ed43bde/out -L native=/work/build-cache/cargo-home/build/debug/build/ring-43aedddb25fbb121/out -L native=/work/build-cache/cargo-home/build/debug/build/aws-lc-sys-467e076f78a0a3c4/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-6abcf750100a3ada/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-nickel-4d55240ed02e956b/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out` (exit status: 101)
error: command `/usr/bin/cargo '--color=auto' test --no-run --message-format json-render-diagnostics --package mfile --package minimal --package minimald --locked` exited with code 101

Closes #3409

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).
@coderabbitai

coderabbitai Bot commented Nov 16, 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: 1561bd99-5711-48e2-9135-f31db01f49c4

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

Copy link
Copy Markdown
Contributor Author

Every failing check on f594dabda30e matches an open known-flake issue, so the failed suite started no revise round:

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, /revise <note> starts one now.

@agent-137
agent-137 marked this pull request as ready for review November 16, 2026 06:51
@agent-137
agent-137 requested a review from a team as a code owner November 16, 2026 06:51
@minimal-foundry

minimal-foundry Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewed: no findings; approval withheld, 1 thread unresolved at 714cfc15af56.

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.

@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 on lines +569 to +600
/// 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

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.

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.

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.

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.

A box that stores spec.json no longer falls back to the hooks in
minimal.toml when the file exists but cannot be read.
@agent-137

Copy link
Copy Markdown
Member

/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.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #3409. Your note is kept and goes into the next round here, which starts when that coder finishes.

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.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on the runtime's review findings, pushed as 714cfc15af56.

line exit tail
cargo nextest run -p minimald stored_spec_keeps_each_hook_with_its_declarer_in_spec_json 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimald composes_from_stored_expanded_spec_not_minimal_toml 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal created_box_spec_json_names_each_hook_declarer 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify min task run agent-verify exited 100.

               "span_id": "a77f1e3570be7da4",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "e354a81dccb09eba",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "c2a85d9b984cf60d",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "c2a85d9b984cf60d",
                "queued_behind": "0",
                "span_id": "fc5c4ab4f509ecb3",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "c2a85d9b984cf60d",
                "queued_behind": "0",
                "span_id": "69dcb4ed51e4964f",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "69dcb4ed51e4964f",
                "span_id": "948a9592b694aeaf",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "69dcb4ed51e4964f",
                "queued_behind": "0",
                "span_id": "30b4dd147405cb71",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 3 tests still running
        PASS [   2.289s] (1356/2829) minimald box_actor::tests::a_box_nobody_handed_an_address_publishes_at_the_answerers_grant
        PASS [   2.261s] (1357/2829) minimald box_actor::tests::a_contended_walk_never_replaces_a_present_verdict
        PASS [   2.300s] (1358/2829) minimald box_actor::tests::a_box_re_registered_inside_the_landing_window_keeps_its_grant
────────────
     Summary [  69.153s] 1358/2829 tests run: 1357 passed, 1 failed, 29 skipped
        FAIL [   2.925s] (1355/2829) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
warning: 1471/2829 tests were not run due to test failure (run with --no-fail-fast to run all tests, or run with --max-fail)
error: test run failed

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — crates/minimald/src/box_manager/composables.rs:612: 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 s

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 v, and creation_name also treats a spec that does not read as v0 as naming nothing. NotFound stays silent, because a box created without a spec (the first-slice path) stores no spec.json. composes_from_stored_expanded_spec_not_minimal_toml now also checks the unreadable case. cargo clippy -p minimald --all-targets is clean.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft November 16, 2026 07:27

@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 — 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).

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

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.

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.

T129 — The daemon stores the expanded spec with each hook's declarer, and composes from it

1 participant