Repository navigation
feat(minimal): T41 — Box spec lists a box's hooks with their declarer - #3490
minimal-foundry[bot] wants to merge 8 commits into
Conversation
The TOML render of a box's stored spec now opens with a comment list of its lifecycle hooks: one line for each event, with the command, the description and who declared the hook (minimal.toml or a loadout). The list is comments, so the render stays valid TOML (BCLI-022, BOX-179).
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Undrafting at |
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none seen. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 3 conditions · the full ruling
The hook list is in the correct crate, and the TOML body stays the stored spec. The description goes into a comment line without escapes. A newline in it can write lines that the stored spec does not hold, or forge a declarer. Line 490 of the design says that min box spec shows exactly what the box gets. C1 quotes the description and the script path as TOML strings. C2 marks inline commands, and C3 gives the test the name that the spec runs.
Ruled at 984d5ef against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| }; | ||
| let description = hook | ||
| .description() | ||
| .map(|d| format!(" \"{d}\"")) |
There was a problem hiding this comment.
C1 · This line writes the description raw into a comment. A description with a newline ends the comment and writes text that the stored spec does not hold. Render it with toml::Value::String(d.to_owned()).to_string(). Line 490 of the design says that min box spec shows exactly what the box gets.
There was a problem hiding this comment.
Addressed in 8bc803887c2f: The description now prints as a one-line TOML string with its line breaks escaped. I did not use toml's Display, because it can choose a multi-line string. The test covers a description with a newline.
| first | ||
| } | ||
| } | ||
| HookScriptBody::External(path) => format!("script {}", path.as_str()), |
There was a problem hiding this comment.
C1 · A path can hold a newline too. Quote it as a TOML string after script , as C1 does for the description.
There was a problem hiding this comment.
Addressed in 8bc803887c2f: The script path now prints as a quoted one-line TOML string after script , for example script "./cleanup.sh".
| for (event, script) in events { | ||
| let Some(script) = script else { continue }; | ||
| let command = match script.body() { | ||
| HookScriptBody::Inline(body) => { |
There was a problem hiding this comment.
C2 · Prefix the inline command with inline . The row must show inline or external, and an inline body that starts with script reads as an external script now.
There was a problem hiding this comment.
Addressed in 8bc803887c2f: An inline command now prints as inline "<first line>", followed by ... when the body has more lines.
| // BCLI-022, BOX-179: `min box spec <box>` lists each stored lifecycle | ||
| // hook with its event, its command, its description and its declarer. | ||
| #[tokio::test] | ||
| async fn box_spec_box_lists_hooks() { |
There was a problem hiding this comment.
C3 · Rename this test to box_spec_box_lists_hooks_with_declarer. The spec 28 verify line for the hook rows runs that name. Add the C1 case with a newline in a description here.
There was a problem hiding this comment.
Addressed in 8bc803887c2f: Renamed the test to box_spec_box_lists_hooks_with_declarer. It adds a loadout hook whose description holds a newline and a quote, and an external script hook.
| let description = hook | ||
| .description() | ||
| .map(|d| format!(" \"{d}\"")) | ||
| .unwrap_or_default(); | ||
| writeln!(out, "# {event}{description}: {command} ({declarer})")?; |
There was a problem hiding this comment.
MEDIUM · correctness · confidence 0.60 · in write_hook_list
The hook description goes into the comment line as is. A description is free-form and can hold a newline, for example a TOML multi-line string. The second line then has no #, so the TOML render is no longer valid TOML or no longer parses to the stored spec. The inline command is cut to its first line for this reason, but the description is not. Collapse the description to its first line, or replace line breaks, before you print it. Add a test with a multi-line description.
What the reviewer checked
.map(|d| format!(" "{d}"")) then writeln!(out, "# {event}{description}: ...")
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/box_spec.rs
Lines: 1131-1135
Category: correctness
Severity: medium (reviewer confidence 0.60)
Finding:
The hook description goes into the comment line as is. A description is free-form and can hold a newline, for example a TOML multi-line string. The second line then has no `#`, so the TOML render is no longer valid TOML or no longer parses to the stored spec. The inline command is cut to its first line for this reason, but the description is not. Collapse the description to its first line, or replace line breaks, before you print it. Add a test with a multi-line description.
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 8bc803887c2f: Line breaks in the description are escaped as \n inside a quoted string, so the row stays one comment line. The test asserts the row and parses the render as TOML.
…ists-a-box-s-hooks-with-their-declarer
|
/revise Head 1. C1: a hook's description and script path print as quoted TOML strings. 2. C2: an inline hook is marked 3. C3: the test name matches BCLI-022's verify line. |
|
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 description, an inline body or a script path with a line break ended the comment row and broke the TOML render. Each value now prints as a one-line TOML string, and an inline body says inline. The test takes the name the spec verify line runs.
|
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:
Notes from the agent: Revise round 1. Each description, inline first line and script path now prints as a one-line TOML basic string through the new one_line_string helper. The helper escapes quotes, backslashes and control characters. I did not use toml::Value::String(..).to_string(), because toml can render a string that holds a newline as a multi-line string, and that string also breaks the comment. The task test line filters by substring, so it still selects the renamed test. cargo clippy -p minimal --all-targets is clean. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to the design. min box spec <box> lists each stored hook as a comment row before the stored render. Each row shows the event, the description, inline or script, and the declarer. The rows keep the stored order, so project hooks come first (architecture.md line 1253). The fix commit escapes each value onto one line, so the render stays valid TOML. The test name now matches the BCLI-022 verify line.
Ruled at 8bc8038 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
An inline hook row now reads `inline echo rust`, unquoted, as the arch ruling asks. The description and the script path stay one-line TOML strings. toml::Value::String prints a string with a line break as a multi-line string, which ends the comment, so the escaper stays. The test adds a project hook whose description tries to forge a row, and checks that it gives exactly one row and the render is TOML.
|
Undrafting at |
|
Round 2 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review.
Notes from the agent: C1: the note asks for toml::Value::String(d.to_owned()).to_string(). I tried it. With toml 1.1.6 it prints a string that holds a newline as a multi-line """ string. That splits the row across lines, and the new forged-row test failed with it. So the description and the script path keep the hand-written one-line TOML escaper (one_line_string) from the previous round. It gives the result that C1 asks for: each hook on one comment row, and the render parses as TOML. C2: the inline arm now prints |
|
Undrafting at |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The last commit prints the first line of an inline hook body without an escape. str::lines() removes only \n. A lone \r or another control character in a stored body goes into the comment row as a raw character. Then the terminal can show a different command from the one the box runs, and the TOML render is not valid TOML. Line 490 of the architecture says min box spec shows exactly what an entry will get. Make the change in C1: put one_line_string() back on that line, and add a test with a \r in an inline body.
Ruled at 475b3a9 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| let command = match script.body() { | ||
| HookScriptBody::Inline(body) => { | ||
| let mut lines = body.trim().lines(); | ||
| let first = lines.next().unwrap_or_default(); |
There was a problem hiding this comment.
C1 · This line prints the first line of the inline body raw. lines() splits only on \n, so a lone \r or an ESC sequence stays. A raw \r lets the row show a different command from the one that runs (architecture.md line 490). Use one_line_string(lines.next().unwrap_or_default()) here, as at 8bc8038.
There was a problem hiding this comment.
Addressed in 11163f8b1a7d: The inline first line now goes through one_line_string, so a lone \r or an ESC prints escaped in the row.
| let header = format!( | ||
| "# The spec box {id} was created with.\n\ | ||
| # Lifecycle hooks:\n\ | ||
| # on_activate \"Warm the cache\": inline echo project (from minimal.toml)\n\ |
There was a problem hiding this comment.
C1 · Put the quoted inline forms back in these expected rows. Add a project hook whose inline value contains a lone \r. Assert that the row shows it escaped, and that no line of the render contains a raw \r.
There was a problem hiding this comment.
Addressed in 11163f8b1a7d: Restored the quoted inline rows, added a project hook with a lone \r in its inline value, and asserted it prints escaped with no raw \r in any line.
| } | ||
| }; | ||
| let events: [(&str, Option<&HookScript>); 4] = [ | ||
| ("on_activate", hook.on_activate()), | ||
| ("on_destroy", hook.on_destroy()), | ||
| ("on_attach", hook.on_attach()), | ||
| ("on_detach", hook.on_detach()), | ||
| ]; | ||
| for (event, script) in events { |
There was a problem hiding this comment.
LOW · correctness · confidence 0.55 · in write_hook_list
The first line of an inline command is printed raw into a # comment. str::lines splits only on \n, so a lone \r or another control character in the body stays in the comment line. A TOML parser rejects control characters in a comment, so the render stops being valid TOML. The description and script path use one_line_string for this reason. Apply the same escaping to the inline first line.
What the reviewer checked
format!("inline {first} ...") with
firstfrom body.trim().lines().next(), not passed through one_line_string
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/box_spec.rs
Lines: 1109-1117
Category: correctness
Severity: low (reviewer confidence 0.55)
Finding:
The first line of an inline command is printed raw into a `#` comment. `str::lines` splits only on `\n`, so a lone `\r` or another control character in the body stays in the comment line. A TOML parser rejects control characters in a comment, so the render stops being valid TOML. The description and script path use `one_line_string` for this reason. Apply the same escaping to the inline first line.
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 11163f8b1a7d: The inline first line is escaped with one_line_string, the same as the description and the script path, so the render stays valid TOML.
|
/revise Head 1. C1 (PRRT_kwDOPdfcxM64nr_x, PRRT_kwDOPdfcxM64nsAA) and minimal-review LOW (PRRT_kwDOPdfcxM64nsgp): escape an inline body's first line again.
2. Threads. Reply with the commit on the three threads above. Ruling 1357's C1, C2 and C3 threads (PRRT_kwDOPdfcxM64mOlk, PRRT_kwDOPdfcxM64mOlo, PRRT_kwDOPdfcxM64mOls, PRRT_kwDOPdfcxM64mOl1) and minimal-review's MEDIUM thread (PRRT_kwDOPdfcxM64mPPQ) were fixed by |
|
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. |
The first line of an inline hook body printed raw. str::lines splits only on \n, so a lone \r or another control character stayed in the comment row. The row now quotes it as a one-line TOML string, as it does the description and the script path. The test adds a project hook with a lone \r and checks that no line of the render holds a raw \r.
|
Round 3 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:
Notes from the agent: This round puts the one_line_string escaping back on the first line of an inline hook body. The previous round removed it. The expected rows in the test show the quoted inline forms again. A new project hook with an inline value that holds a lone \r checks that the row shows it escaped and that no line of the render holds a raw \r. |
…ists-a-box-s-hooks-with-their-declarer
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The fix commit escapes the first line of an inline hook body. A lone carriage return or another control character can no longer end the comment row or forge a row. The render is the spec as stored, as architecture.md line 477 requires. The test proves this with a hook that holds a lone \r. The loadout name in the declarer still prints raw. That line is outside this compare, and you can escape it in a follow-up.
Ruled at 11163f8 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
The directive names this value for the lone carriage-return case.
|
Round 4 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review.
Notes from the agent: Commit 11163f8 (round 3) already made the code change for item 1. The Inline arm of write_hook_list uses one_line_string(lines.next().unwrap_or_default()) and keeps the |
T41 — Box spec lists a box's hooks with their declarer
slice: S5
kind: task
covers: BCLI-022
size: S
est: 70 code, 80 tests
executor: agent
difficulty: routine
model: standard
diagnostics: none new
observability: none new
layers:
- client:
- crates/minimal/src/cmd/box_spec.rs:
min box spec <box>lists the stored lifecycle hooks, with the event, the command, its description and who declared it (BOX-179'sdeclared_by)- crates/minimal/src/tests.rs: the in-process minimald test harness gains this layer's tests
test: cargo nextest run -p minimal box_spec_box_lists_hooks
produces: none
consumes: none
proof:
min box spec <box>lists each stored lifecycle hook with its event, command, description and declarer.depends on:
- blocked by #2906
- blocked by #3409
Proof
min box spec <box>now opens its TOML render with a# Lifecycle hooks:comment list. It has one line for each event of each stored hook, with the event, the description, the command and its declarer, for example# on_attach: echo rust (from loadout rust). A box stored with an empty hook list shows# Lifecycle hooks: none.Notes from the agent: The list is in the TOML render only, as comment lines, so the output stays valid TOML. The -o json and -o yaml renders already carry the stored
lifecycle_hookswithdeclared_byunchanged, so this change does not touch them. An inline command with more than one line shows its first line and then.... An external script shows asscript <path>. A spec stored before hooks were stored has nolifecycle_hookskey and shows no list. The existing test box_spec_box_renders_stored_copy still passes. cargo clippy -p minimal --all-targets is clean.Tests
cargo nextest run -p minimal box_spec_box_lists_hooksVerify
min task run agent-verifyexited 100, so this PR is a draft.Closes #3283