Repository navigation
all: rename harness to stack - #192
Conversation
📝 WalkthroughWalkthroughThis PR renames and migrates "harness" to "stack" across the codebase: types and Nickel stdlib, decode/loader, graph storage and wire format, the check pipeline (check_stack), CLI flags/commands, minimal.toml handling, task resolution, test fixtures, and version pins. ChangesHarness to Stack Refactoring
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
|
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
crates/graph/src/wire.rs (1)
29-37:⚠️ Potential issue | 🟠 Major | ⚡ Quick winBump the wire-format version for this record schema change.
The body for tag
0x06now decodes asStackRecord { stack }, but the stream still advertises version1. Any cached graph written by the previous harness schema will still be treated as v1 and fail mid-read withJsoninstead of triggering explicit version invalidation. IncrementSTREAM_VERSIONhere, or accept both field names during decode.Minimal fix
-const STREAM_VERSION: u32 = 1; +const STREAM_VERSION: u32 = 2;Also applies to: 195-198, 504-506
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/graph/src/wire.rs` around lines 29 - 37, The stream still advertises STREAM_VERSION = 1 while TAG_STACK (TAG_STACK constant and its decoder in the StackRecord path) now decodes as StackRecord { stack }, causing old cached data to be misread; fix by incrementing the STREAM_VERSION constant (and any other identical occurrences of that constant in this file) to a new version number, or alternatively update the TAG_STACK decoding logic to accept both the old and new field names; update the STREAM_VERSION symbol and ensure all readers (places that reference STREAM_VERSION/TAG_STACK and the StackRecord decoder) are consistent so old caches trigger explicit version invalidation.crates/decode/src/load.rs (1)
289-325:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPrefer one compatibility directory here instead of merging both.
These branches append both
harnesses/andstacks/into the samestacksarray. In a repo that carries both during migration, the same logical stack can be loaded twice; later decode folds stacks into aHashMap, so whichever importread_diryields last silently wins. Pick a single source of truth here instead of merging both directories.Suggested direction
src.push_str("\tstacks = [\n"); - // TODO: Remove after May 2026 (harnesses kept for compatibility). - match std::fs::read_dir(layer_dir.as_ref().join("harnesses")) { - Err(e) => { - if e.kind() != std::io::ErrorKind::NotFound { - return Err(e.into()); - } - } - Ok(d) => { - for e in d { - let e = e?; - if e.file_type()?.is_dir() { - src.push_str(" import \""); - src.push_str(e.path().to_str().unwrap()); - src.push_str("/harness.ncl\",\n"); - } - } - } - } - match std::fs::read_dir(layer_dir.as_ref().join("stacks")) { - Err(e) => { - if e.kind() != std::io::ErrorKind::NotFound { - return Err(e.into()); - } - } - Ok(d) => { - for e in d { - let e = e?; - if e.file_type()?.is_dir() { - src.push_str(" import \""); - src.push_str(e.path().to_str().unwrap()); - src.push_str("/stack.ncl\",\n"); - } - } - } - } + let stack_root = if layer_dir.as_ref().join("stacks").is_dir() { + Some((layer_dir.as_ref().join("stacks"), "stack.ncl")) + } else if layer_dir.as_ref().join("harnesses").is_dir() { + Some((layer_dir.as_ref().join("harnesses"), "harness.ncl")) + } else { + None + }; + if let Some((dir, entrypoint)) = stack_root { + for e in std::fs::read_dir(dir)? { + let e = e?; + if e.file_type()?.is_dir() { + src.push_str(" import \""); + src.push_str(e.path().to_str().unwrap()); + src.push_str("/"); + src.push_str(entrypoint); + src.push_str("\",\n"); + } + } + } src.push_str("\t],\n");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/decode/src/load.rs` around lines 289 - 325, The code currently merges entries from both layer_dir.join("harnesses") and layer_dir.join("stacks") into the same "stacks" array causing duplicate logical stacks; change the logic to prefer one source and only fall back to the other: first attempt to read layer_dir.join("stacks") and use its entries if present, and only if that directory is NotFound or empty, fall back to layer_dir.join("harnesses") for compatibility; update the blocks around the existing read_dir calls (the matches that reference layer_dir.as_ref().join("harnesses") and layer_dir.as_ref().join("stacks")) so you do not append from both but select one source and then push its imports into src.crates/decode/src/stacks.rs (2)
463-471:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winReport a missing
nameas a stack error, not a builder error.This branch still sets
obj: ObjTy::Builder, so malformed stacks get the wrong schema name in the diagnostic. It should beObjTy::Stack.Suggested fix
let name = match name { Some(name) => name, None => { return Err(Error::MissingField { files: program.files(), - obj: ObjTy::Builder, + obj: ObjTy::Stack, pos: rt.pos(program.pos_table()), field: "name", }); } };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/decode/src/stacks.rs` around lines 463 - 471, The missing-name branch currently reports Err::MissingField with obj: ObjTy::Builder; change that to obj: ObjTy::Stack so malformed stacks produce stack (not builder) diagnostics — update the match arm that returns Err::MissingField (the code handling the None case for the local name variable) to use ObjTy::Stack instead of ObjTy::Builder.
509-518:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
build_taskcurrently drops every build command after the first one.Lines 515-518 synthesize the default
buildtask fromcmds[0]only. For any stack whosebuild_cmdexpands to multiple commands,minimal run buildwill no longer match the stack's actual build behavior. Either preserve the full sequence in the task action, or reject multi-command stacks here.crates/mctx/src/lib.rs (1)
587-597:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDon't hide an invalid stack as “task not found.”
Lines 587-597 return
Ok(None)whenminimal.tomlreferences a stack name that doesn't exist. That masks a broken config as a missing task, which is especially confusing for stack-provided defaults likebuild. This path should surface the missing-stack error instead of silently falling through.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/mctx/src/lib.rs` around lines 587 - 597, The code currently treats a missing stack as "task not found" by returning Ok(None) when graph.stack(&h_conf.name) is None; change this to surface the missing-stack error instead of silently returning Ok(None). In the block that checks mfile.stack and calls graph.stack(&h_conf.name), return or propagate an explicit error (with context including h_conf.name) when graph.stack(...) is None, rather than falling through to the task-not-found path; keep the existing behavior of hydrating defaults via mfile.hydrate_task_defaults(&mut task) and only return Ok(None) when stack.task_by_name(name) is genuinely missing. Ensure the error type you return matches the surrounding function's error handling so callers receive a clear "stack not found" error instead of a missing-task result.
🧹 Nitpick comments (3)
crates/mfile/src/lib.rs (1)
744-745: ⚡ Quick winAdd explicit alias regression tests for
[stack]and[harness].Given this is the compatibility seam, a focused parse test for both keys would reduce migration risk.
Proposed test addition
+ #[test] + fn stack_and_harness_alias_both_deserialize_into_stack() { + let legacy: File = toml::from_str(indoc! { + r#" + [harness] + use = "legacy-stack" + build_packages = ["b1"] + runtime_packages = ["r1"] + "# + }).unwrap(); + assert_eq!(legacy.stack.as_ref().unwrap().name, "legacy-stack"); + + let modern: File = toml::from_str(indoc! { + r#" + [stack] + use = "modern-stack" + build_packages = ["b2"] + runtime_packages = ["r2"] + "# + }).unwrap(); + assert_eq!(modern.stack.as_ref().unwrap().name, "modern-stack"); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/mfile/src/lib.rs` around lines 744 - 745, Add focused regression parse tests that verify explicit alias handling for the [stack] and [harness] keys: create two tests (e.g., test_parse_stack_alias and test_parse_harness_alias) in crates/mfile/src/lib.rs or the tests module that feed manifest snippets containing the legacy alias sections (like "[stack]" and "[harness]") into the same parser used elsewhere (call the parser function used in this file, e.g., whatever constructs the tasks/stack structures in lib.rs) and assert the resulting structure matches expected values (for example that stack becomes Some(...) where previously stack: None and tasks contains the expected entries). Ensure the tests exercise the compatibility seam by asserting parsed output fields (stack and tasks) equal the canonical representation the rest of the code expects.crates/minimal/src/cmd_status.rs (1)
15-15: 💤 Low valueNit: closure variable
his a leftover from the harness era.-let stack = ctx.minimal_file().stack.as_ref().map(|h| h.name.clone()); +let stack = ctx.minimal_file().stack.as_ref().map(|s| s.name.clone());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minimal/src/cmd_status.rs` at line 15, The closure in the expression creating `stack` uses the leftover name `h`; rename that closure parameter to a clearer identifier (for example `header` or `stack_item`) in the `ctx.minimal_file().stack.as_ref().map(|h| h.name.clone())` expression so it reads like `map(|header| header.name.clone())`, keeping the rest of the logic unchanged.crates/remote-client/src/lib.rs (1)
574-581: ⚡ Quick win
CheckArgs.harnessesfield was not renamed tostacks— incomplete rename in the public API.The PR renames "harness" → "stack" throughout, but
CheckArgsstill exposespub harnesses: bool. All callers (including the test at line 1082) buildCheckArgs { harnesses: … }, which is inconsistent withcheck::CheckObj::Stackreturned on line 517. The proto wire field (harnesses) can stay for wire compat, but the Rust-side field should bestacks.♻️ Proposed rename
pub struct CheckArgs { pub filter_names: Vec<String>, pub skip_checkers: Vec<String>, pub packages: bool, pub profiles: bool, - pub harnesses: bool, + pub stacks: bool, pub remote_cache_gcs_bucket: Option<String>, }And update the proto mapping (line 480):
- harnesses: args.harnesses, + harnesses: args.stacks, // proto wire field kept for backwards compatAnd the test construction (line 1082):
- harnesses: false, + stacks: false,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/remote-client/src/lib.rs` around lines 574 - 581, Rename the public Rust field CheckArgs::harnesses to CheckArgs::stacks (keep the proto wire name "harnesses" for compatibility but map it to the new field), update the proto-to-Rust mapping that constructs CheckArgs so it assigns the proto harnesses value into the new stacks field, and update all callers/tests that construct CheckArgs (e.g., the test building CheckArgs at the former line ~1082) to use stacks: …; ensure code paths that expect check::CheckObj::Stack continue to match the renamed field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/check/src/stack.rs`:
- Around line 24-55: The code currently checks for harness.ncl first and loads
it if present; change the existence check to prefer stack.ncl and only fall back
to harness.ncl when stack.ncl is missing. Update the conditional around
Program::new_from_source (the block assigning program_res using
stacks_dir.join(&stack).join("harness.ncl") and
stacks_dir.join(&stack).join("stack.ncl")) so it tests for "stack.ncl".exists()
first and uses that path for the import, otherwise use "harness.ncl".
In `@crates/mctx/src/env.rs`:
- Around line 189-193: The env session currently always passes
upstream_dir.join("stacks") when check_all or flag_stacks is set, which skips
older layers using harnesses/; update the logic in crates::mctx::env.rs where
the Option for stacks is built (the block referencing check_all, flag_stacks and
upstream_dir) to mirror cmd_check.rs fallback: if
upstream_dir.join("harnesses").exists() return
Some(upstream_dir.join("harnesses")) else return
Some(upstream_dir.join("stacks")), so check::run_checks will probe harnesses
first and fall back to stacks.
In `@crates/mctx/src/lib.rs`:
- Around line 820-837: The AddDepMode branches (in add_deps logic) only check
doc["stack"] and fail if absent; modify them to accept legacy [harness] by first
checking doc["stack"].as_table_mut(), falling back to
doc["harness"].as_table_mut() if stack is missing, and if you touched harness,
either write updates back under "stack" (migrate: copy/rename "harness" table to
"stack" before calling upsert_toml_packages_list) or perform upsert directly on
the harness table so both formats remain supported; update the branches using
the same upsert_toml_packages_list(h, "...", &resolved) and preserve the
existing println/error behavior.
- Around line 718-721: The code currently calls
graph.stack(&stack.name).unwrap() inside scaffolding_packages (or the function
containing this diff) which will panic on a missing configured stack; replace
the unwrap with a non-panicking check that returns an Err instead: call
graph.stack(&stack.name) and if it yields Some(h) extend out with
h.build_packages and h.runtime_packages, otherwise return a descriptive Err
(e.g., using anyhow::anyhow! or the crate's error type) like "configured stack
'<name>' not found" so the function returns the existing Result error path
instead of panicking.
---
Outside diff comments:
In `@crates/decode/src/load.rs`:
- Around line 289-325: The code currently merges entries from both
layer_dir.join("harnesses") and layer_dir.join("stacks") into the same "stacks"
array causing duplicate logical stacks; change the logic to prefer one source
and only fall back to the other: first attempt to read layer_dir.join("stacks")
and use its entries if present, and only if that directory is NotFound or empty,
fall back to layer_dir.join("harnesses") for compatibility; update the blocks
around the existing read_dir calls (the matches that reference
layer_dir.as_ref().join("harnesses") and layer_dir.as_ref().join("stacks")) so
you do not append from both but select one source and then push its imports into
src.
In `@crates/decode/src/stacks.rs`:
- Around line 463-471: The missing-name branch currently reports
Err::MissingField with obj: ObjTy::Builder; change that to obj: ObjTy::Stack so
malformed stacks produce stack (not builder) diagnostics — update the match arm
that returns Err::MissingField (the code handling the None case for the local
name variable) to use ObjTy::Stack instead of ObjTy::Builder.
In `@crates/graph/src/wire.rs`:
- Around line 29-37: The stream still advertises STREAM_VERSION = 1 while
TAG_STACK (TAG_STACK constant and its decoder in the StackRecord path) now
decodes as StackRecord { stack }, causing old cached data to be misread; fix by
incrementing the STREAM_VERSION constant (and any other identical occurrences of
that constant in this file) to a new version number, or alternatively update the
TAG_STACK decoding logic to accept both the old and new field names; update the
STREAM_VERSION symbol and ensure all readers (places that reference
STREAM_VERSION/TAG_STACK and the StackRecord decoder) are consistent so old
caches trigger explicit version invalidation.
In `@crates/mctx/src/lib.rs`:
- Around line 587-597: The code currently treats a missing stack as "task not
found" by returning Ok(None) when graph.stack(&h_conf.name) is None; change this
to surface the missing-stack error instead of silently returning Ok(None). In
the block that checks mfile.stack and calls graph.stack(&h_conf.name), return or
propagate an explicit error (with context including h_conf.name) when
graph.stack(...) is None, rather than falling through to the task-not-found
path; keep the existing behavior of hydrating defaults via
mfile.hydrate_task_defaults(&mut task) and only return Ok(None) when
stack.task_by_name(name) is genuinely missing. Ensure the error type you return
matches the surrounding function's error handling so callers receive a clear
"stack not found" error instead of a missing-task result.
---
Nitpick comments:
In `@crates/mfile/src/lib.rs`:
- Around line 744-745: Add focused regression parse tests that verify explicit
alias handling for the [stack] and [harness] keys: create two tests (e.g.,
test_parse_stack_alias and test_parse_harness_alias) in crates/mfile/src/lib.rs
or the tests module that feed manifest snippets containing the legacy alias
sections (like "[stack]" and "[harness]") into the same parser used elsewhere
(call the parser function used in this file, e.g., whatever constructs the
tasks/stack structures in lib.rs) and assert the resulting structure matches
expected values (for example that stack becomes Some(...) where previously
stack: None and tasks contains the expected entries). Ensure the tests exercise
the compatibility seam by asserting parsed output fields (stack and tasks) equal
the canonical representation the rest of the code expects.
In `@crates/minimal/src/cmd_status.rs`:
- Line 15: The closure in the expression creating `stack` uses the leftover name
`h`; rename that closure parameter to a clearer identifier (for example `header`
or `stack_item`) in the `ctx.minimal_file().stack.as_ref().map(|h|
h.name.clone())` expression so it reads like `map(|header|
header.name.clone())`, keeping the rest of the logic unchanged.
In `@crates/remote-client/src/lib.rs`:
- Around line 574-581: Rename the public Rust field CheckArgs::harnesses to
CheckArgs::stacks (keep the proto wire name "harnesses" for compatibility but
map it to the new field), update the proto-to-Rust mapping that constructs
CheckArgs so it assigns the proto harnesses value into the new stacks field, and
update all callers/tests that construct CheckArgs (e.g., the test building
CheckArgs at the former line ~1082) to use stacks: …; ensure code paths that
expect check::CheckObj::Stack continue to match the renamed field.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 83914961-b4e6-4c95-9e4b-0ccc02b0dc24
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (32)
.minimal/minimal.tomlCargo.tomlcrates/check/src/lib.rscrates/check/src/stack.rscrates/decode/src/builds.rscrates/decode/src/lib.rscrates/decode/src/load.rscrates/decode/src/stacks.rscrates/graph/src/graph.rscrates/graph/src/lib.rscrates/graph/src/loader.rscrates/graph/src/wire.rscrates/mctx/src/env.rscrates/mctx/src/lib.rscrates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.nclcrates/mctx/testdata/fakerepo-with-stack/minimal.tomlcrates/mctx/testdata/fakerepo-with-stack/packages/extra-build-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/extra-runtime-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/stack-build-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/stack-runtime-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/stacks/fake-stack/stack.nclcrates/mfile/src/lib.rscrates/minimal/src/cmd_check.rscrates/minimal/src/cmd_dump.rscrates/minimal/src/cmd_init.rscrates/minimal/src/cmd_status.rscrates/minimal/src/cmd_update.rscrates/minimal/src/main.rscrates/ot/src/lib.rscrates/remote-client/src/lib.rscrates/stdlib/Cargo.tomlcrates/stdlib/minimal-ncl/minimal.ncl
💤 Files with no reviewable changes (1)
- crates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.ncl
| AddDepMode::BuildPackages => { | ||
| if let Some(h) = doc["harness"].as_table_mut() { | ||
| if let Some(h) = doc["stack"].as_table_mut() { | ||
| did_edit |= upsert_toml_packages_list(h, "build_packages", &resolved); | ||
| println!("Added [{}] to harness.build_packages", resolved.join(",")); | ||
| println!("Added [{}] to stack.build_packages", resolved.join(",")); | ||
| } else { | ||
| return Err(Error::Other(anyhow!( | ||
| "could not find [harness] in minimal.toml: needed for update" | ||
| "could not find [stack] in minimal.toml: needed for update" | ||
| ))); | ||
| } | ||
| } | ||
| AddDepMode::RuntimePackages => { | ||
| if let Some(h) = doc["harness"].as_table_mut() { | ||
| if let Some(h) = doc["stack"].as_table_mut() { | ||
| did_edit |= upsert_toml_packages_list(h, "runtime_packages", &resolved); | ||
| println!("Added [{}] to harness.runtime_packages", resolved.join(",")); | ||
| println!("Added [{}] to stack.runtime_packages", resolved.join(",")); | ||
| } else { | ||
| return Err(Error::Other(anyhow!( | ||
| "could not find [harness] in minimal.toml: needed for update" | ||
| "could not find [stack] in minimal.toml: needed for update" | ||
| ))); |
There was a problem hiding this comment.
Keep add_deps compatible with legacy [harness] configs.
The PR notes say [harness] remains supported in minimal.toml for now, but Lines 820-837 only look for [stack]. That means minimal add-deps now fails on still-supported repos until they migrate manually. Please update whichever section exists, or transparently migrate [harness] to [stack] during the write.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/mctx/src/lib.rs` around lines 820 - 837, The AddDepMode branches (in
add_deps logic) only check doc["stack"] and fail if absent; modify them to
accept legacy [harness] by first checking doc["stack"].as_table_mut(), falling
back to doc["harness"].as_table_mut() if stack is missing, and if you touched
harness, either write updates back under "stack" (migrate: copy/rename "harness"
table to "stack" before calling upsert_toml_packages_list) or perform upsert
directly on the harness table so both formats remain supported; update the
branches using the same upsert_toml_packages_list(h, "...", &resolved) and
preserve the existing println/error behavior.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/graph/src/wire.rs (1)
29-29:⚠️ Potential issue | 🟠 Major | ⚡ Quick winBump
STREAM_VERSIONto invalidate old wire streams cleanly.The
StackRecordJSON payload now uses field namestackinstead of the previousharness. Since the tag value0x06is unchanged, old serialized streams will pass the version check but fail with a confusing JSON deserialization error when trying to find the missingstackfield.Incrementing
STREAM_VERSIONfrom 1 to 2 will ensure old streams are rejected cleanly at line 430/879 withUnsupportedVersioninstead of a JSON parse error.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/graph/src/wire.rs` at line 29, The STREAM_VERSION constant needs to be incremented so old wire streams that contain the previous StackRecord field name ("harness") are rejected cleanly; update the const STREAM_VERSION from 1 to 2 so deserialization will hit the UnsupportedVersion path (instead of attempting to JSON-decode into StackRecord and failing due to the renamed field), ensuring streams with tag 0x06 no longer produce confusing JSON errors.
🧹 Nitpick comments (5)
crates/mctx/testdata/fakerepo-with-stack/minimal.toml (1)
4-11: 💤 Low valueConsider updating test fixture to use
[stack]section header.The directory is named
fakerepo-with-stack, but the TOML still uses[harness]as the section header. While this works due to the serde alias for backwards compatibility, consider either:
- Updating to
[stack]to test the new format directly, or- Renaming the directory to
fakerepo-with-harness-compatif the intent is to test backwards compatibilityThis would make the test intent clearer.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/mctx/testdata/fakerepo-with-stack/minimal.toml` around lines 4 - 11, The test fixture uses the legacy section header `[harness]` but the directory indicates it should exercise the new format; update the TOML by replacing the `[harness]` section header with `[stack]` (keeping the same keys `use`, `build_packages`, `runtime_packages` and the `tasks.task-inherits-stack` entry) so the test explicitly exercises the new stack format; alternatively, if you intend to test backwards compatibility instead, rename the directory `fakerepo-with-stack` to `fakerepo-with-harness-compat` to make the intent explicit.crates/decode/src/load.rs (1)
289-325: ⚡ Quick winPotential duplicate stack entries when both
harnesses/andstacks/exist.The loader reads from both directories and appends all entries into the same
stacks = [...]array. If a layer has bothharnesses/foo/harness.nclandstacks/foo/stack.ncl, both would be included, potentially causing duplicate or conflicting stack definitions during the transition period.Consider adding deduplication by name, or documenting that layers should not have overlapping entries in both directories.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/decode/src/load.rs` around lines 289 - 325, The code building the stacks array in load.rs appends imports from both harnesses and stacks directories into src, which can create duplicate stack entries when the same layer name exists in both; update the logic around layer_dir and src to deduplicate by directory basename (e.g., track seen names in a HashSet) before calling src.push_str for either the harnesses branch or the stacks branch so that if a directory "foo" was already added from harnesses it is skipped when scanning stacks (refer to the read_dir match blocks, the for loops adding "import \".../harness.ncl\"" and "import \".../stack.ncl\"", and the variable names layer_dir and src) and ensure proper error handling for path-to-string conversion remains.crates/minimal/src/cmd_init.rs (1)
1-1: ⚡ Quick winStale doc comment still references "harness".
The module-level doc comment mentions "harness" but should say "stack" to align with the rename.
-//! Command to initialize a minimal file based on matching the source tree to a valid harness. +//! Command to initialize a minimal file based on matching the source tree to a valid stack.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minimal/src/cmd_init.rs` at line 1, The module-level doc comment in cmd_init.rs still uses the old term "harness"; update that top-of-file doc comment to replace "harness" with "stack" so the documentation matches the recent rename (check the module-level comment in crates/minimal/src/cmd_init.rs and change the wording accordingly).crates/check/src/lib.rs (2)
1-2: 💤 Low valueStale doc comment still references "harnesses".
//! Implements `minimal check` logic - for linting Minimal configuration including -//! `minimal.toml`, packages, profiles, and harnesses. +//! `minimal.toml`, packages, profiles, and stacks.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/check/src/lib.rs` around lines 1 - 2, The crate-level documentation at the top of crates/check/src/lib.rs still mentions "harnesses" which is stale; update the top doc comment (the //! ... block in lib.rs that begins "Implements `minimal check` logic") to remove or replace the word "harnesses" with the current concept (e.g., tests, runners, or omit it) so the comment accurately describes what `minimal check` lints (minimal.toml, packages, profiles, etc.).
341-341: 💤 Low valueStale comment references "harness".
- /// Limits the number of concurrent package/harness/profile checks. + /// Limits the number of concurrent package/stack/profile checks.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/check/src/lib.rs` at line 341, The doc comment "Limits the number of concurrent package/harness/profile checks." is stale because it references "harness"; update that comment in crates/check/src/lib.rs to remove or replace "harness" (e.g., "Limits the number of concurrent package/test/profile checks." or "Limits the number of concurrent package/profile/test checks.") so the wording matches current terminology used by the package checking logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/check/src/stack.rs`:
- Around line 134-138: The error message uses a hardcoded "{stack}/stack.ncl"
path; update the CheckResult::stack_name_fail call to reference the actual
filename that was loaded (the variable used when loading the file earlier)
instead of the hardcoded path so the message correctly reflects whether
harness.ncl or stack.ncl was loaded; keep using the existing variables (e.g.,
stack and s) but replace the literal "{stack}/stack.ncl" string with the
variable holding the loaded file path.
---
Outside diff comments:
In `@crates/graph/src/wire.rs`:
- Line 29: The STREAM_VERSION constant needs to be incremented so old wire
streams that contain the previous StackRecord field name ("harness") are
rejected cleanly; update the const STREAM_VERSION from 1 to 2 so deserialization
will hit the UnsupportedVersion path (instead of attempting to JSON-decode into
StackRecord and failing due to the renamed field), ensuring streams with tag
0x06 no longer produce confusing JSON errors.
---
Nitpick comments:
In `@crates/check/src/lib.rs`:
- Around line 1-2: The crate-level documentation at the top of
crates/check/src/lib.rs still mentions "harnesses" which is stale; update the
top doc comment (the //! ... block in lib.rs that begins "Implements `minimal
check` logic") to remove or replace the word "harnesses" with the current
concept (e.g., tests, runners, or omit it) so the comment accurately describes
what `minimal check` lints (minimal.toml, packages, profiles, etc.).
- Line 341: The doc comment "Limits the number of concurrent
package/harness/profile checks." is stale because it references "harness";
update that comment in crates/check/src/lib.rs to remove or replace "harness"
(e.g., "Limits the number of concurrent package/test/profile checks." or "Limits
the number of concurrent package/profile/test checks.") so the wording matches
current terminology used by the package checking logic.
In `@crates/decode/src/load.rs`:
- Around line 289-325: The code building the stacks array in load.rs appends
imports from both harnesses and stacks directories into src, which can create
duplicate stack entries when the same layer name exists in both; update the
logic around layer_dir and src to deduplicate by directory basename (e.g., track
seen names in a HashSet) before calling src.push_str for either the harnesses
branch or the stacks branch so that if a directory "foo" was already added from
harnesses it is skipped when scanning stacks (refer to the read_dir match
blocks, the for loops adding "import \".../harness.ncl\"" and "import
\".../stack.ncl\"", and the variable names layer_dir and src) and ensure proper
error handling for path-to-string conversion remains.
In `@crates/mctx/testdata/fakerepo-with-stack/minimal.toml`:
- Around line 4-11: The test fixture uses the legacy section header `[harness]`
but the directory indicates it should exercise the new format; update the TOML
by replacing the `[harness]` section header with `[stack]` (keeping the same
keys `use`, `build_packages`, `runtime_packages` and the
`tasks.task-inherits-stack` entry) so the test explicitly exercises the new
stack format; alternatively, if you intend to test backwards compatibility
instead, rename the directory `fakerepo-with-stack` to
`fakerepo-with-harness-compat` to make the intent explicit.
In `@crates/minimal/src/cmd_init.rs`:
- Line 1: The module-level doc comment in cmd_init.rs still uses the old term
"harness"; update that top-of-file doc comment to replace "harness" with "stack"
so the documentation matches the recent rename (check the module-level comment
in crates/minimal/src/cmd_init.rs and change the wording accordingly).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a45307f3-3fcf-4877-8e0c-368fc5c25217
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (32)
.minimal/minimal.tomlCargo.tomlcrates/check/src/lib.rscrates/check/src/stack.rscrates/decode/src/builds.rscrates/decode/src/lib.rscrates/decode/src/load.rscrates/decode/src/stacks.rscrates/graph/src/graph.rscrates/graph/src/lib.rscrates/graph/src/loader.rscrates/graph/src/wire.rscrates/mctx/src/env.rscrates/mctx/src/lib.rscrates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.nclcrates/mctx/testdata/fakerepo-with-stack/minimal.tomlcrates/mctx/testdata/fakerepo-with-stack/packages/extra-build-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/extra-runtime-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/stack-build-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/packages/stack-runtime-pkg/build.nclcrates/mctx/testdata/fakerepo-with-stack/stacks/fake-stack/stack.nclcrates/mfile/src/lib.rscrates/minimal/src/cmd_check.rscrates/minimal/src/cmd_dump.rscrates/minimal/src/cmd_init.rscrates/minimal/src/cmd_status.rscrates/minimal/src/cmd_update.rscrates/minimal/src/main.rscrates/ot/src/lib.rscrates/remote-client/src/lib.rscrates/stdlib/Cargo.tomlcrates/stdlib/minimal-ncl/minimal.ncl
💤 Files with no reviewable changes (1)
- crates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.ncl
✅ Files skipped from review due to trivial changes (9)
- crates/mctx/testdata/fakerepo-with-stack/packages/stack-runtime-pkg/build.ncl
- crates/stdlib/Cargo.toml
- Cargo.toml
- crates/mctx/testdata/fakerepo-with-stack/stacks/fake-stack/stack.ncl
- crates/minimal/src/main.rs
- crates/mctx/testdata/fakerepo-with-stack/packages/stack-build-pkg/build.ncl
- .minimal/minimal.toml
- crates/graph/src/loader.rs
- crates/mctx/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (6)
- crates/remote-client/src/lib.rs
- crates/decode/src/builds.rs
- crates/mctx/src/env.rs
- crates/graph/src/lib.rs
- crates/stdlib/minimal-ncl/minimal.ncl
- crates/graph/src/graph.rs
| return Ok(CheckResult::stack_name_fail(format!( | ||
| "stack defined in {}/stack.ncl has name {}", | ||
| stack, | ||
| s.as_str() | ||
| ))); |
There was a problem hiding this comment.
Error message may reference wrong filename.
If harness.ncl was loaded (lines 25-39), the error message at line 135 incorrectly says the stack was "defined in {stack}/stack.ncl". The message should reflect which file was actually loaded.
+ // Track which file was loaded for accurate error messages
+ let stack_ncl_path = stacks_dir.join(&stack).join("stack.ncl");
+ let harness_ncl_path = stacks_dir.join(&stack).join("harness.ncl");
+ let (loaded_file, program_res) = if stack_ncl_path.exists() {
+ ("stack.ncl", Program::new_from_source(...))
+ } else {
+ ("harness.ncl", Program::new_from_source(...))
+ };
// Then use `loaded_file` in the error message🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/check/src/stack.rs` around lines 134 - 138, The error message uses a
hardcoded "{stack}/stack.ncl" path; update the CheckResult::stack_name_fail call
to reference the actual filename that was loaded (the variable used when loading
the file earlier) instead of the hardcoded path so the message correctly
reflects whether harness.ncl or stack.ncl was loaded; keep using the existing
variables (e.g., stack and s) but replace the literal "{stack}/stack.ncl" string
with the variable holding the loaded file path.
[harness]remains supported in theminimal.toml, but will be updated to[stack]on nextminimal updateharnesses/<name>/harness.nclremains supported in layers, with no change in syntaxharnesses/orstacks/.stackfunction to construct a stack, identical to theharnessfunction we will eventually removeSummary by CodeRabbit
New Features
Updates
Chores