Skip to content

all: rename harness to stack - #192

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/attrs
May 7, 2026
Merged

twitchyliquid64 merged 1 commit into
mainfrom
tom/attrs

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented May 7, 2026 •

Copy link
Copy Markdown
Contributor
  • For now [harness] remains supported in the minimal.toml, but will be updated to [stack] on next minimal update
  • For now harnesses/<name>/harness.ncl remains supported in layers, with no change in syntax
  • Layer loading code + check code consults either harnesses/ or stacks/.
  • Minimal standard library now has a stack function to construct a stack, identical to the harness function we will eventually remove
  • A zillion references to harnesses in the code, error types, and print strings have been updated
  • Added a version int we can increment every time we meaningfully break the layer format, so the hash that keys the layer cache can be effectively invalidated

Summary by CodeRabbit

  • New Features

    • Introduced stack-based project configuration and checking system replacing harnesses.
  • Updates

    • Added --stacks CLI option and updated commands to reference "stack" in status and help text.
    • Initialization, checking, dumping, and update flows now prefer stacks/ layout and migrate harness→stack keys when needed.
    • Task resolution and generated configs now use stack-scoped package lists.
  • Chores

    • Bumped stdlib and workspace component versions.

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

Harness to Stack Refactoring

Layer / File(s) Summary
Stdlib / Types
crates/stdlib/minimal-ncl/minimal.ncl
Introduce Stack/StackMatcherEntry and replace 'Harness with 'Stack.
Decode root & schema
crates/decode/src/lib.rs
Layer now decodes stacks into layer.stacks; exports Stack/StackMatcher; FORMAT_VERSION updated.
Stacks implementation & tests
crates/decode/src/stacks.rs
Implement Stack and StackMatcher, decoding (from_term), matcher APIs, task synthesis, and update unit tests.
BuildDep decoding
crates/decode/src/builds.rs
Treat ObjTy::Stack consistently in BuildDep::from_term error path.
Loader discovery & hashing
crates/decode/src/load.rs
Discover top-level stacks/ dirs, generate stacks = [...] imports, and include FORMAT_VERSION in input hash; tests adjusted.
Graph storage & accessors
crates/graph/src/graph.rs, crates/graph/src/lib.rs
Store stacks: HashMap<String,Stack>; add stack()/iter_stacks(); add NoSuchStack/ConflictingStack errors; hydrate_task accepts optional stack.
Graph ingestion & loader
crates/graph/src/loader.rs
Ingest stacks with package validation, conflict rejection; best-effort cache cleanup on corrupted JSON.
Wire format
crates/graph/src/wire.rs
Replace HarnessRecord/TAG_HARNESS with StackRecord/TAG_STACK for sync+async wire serialization.
Check pipeline types & API
crates/check/src/lib.rs
Add mod stack; CheckObj::Stack(String); run_checks accepts stacks_dir; add stack-specific CheckResult helpers and futures builder.
Check implementation
crates/check/src/stack.rs
Add check_stack entrypoint and helpers: stack name, package validity, matcher regex/predicate checks, and file-based checks scoped to stack dir.
mfile: minimal file shape
crates/mfile/src/lib.rs
Add Stack struct; File uses stack: Option<Stack> with TOML alias harness; task hydration reads stack packages/env.
mctx: task source & resolution
crates/mctx/src/lib.rs
TaskSource::Stack replaces Harness; Context task listing/resolution, scaffolding_packages, and add_deps updated to use stack keys; tests updated.
crates/minimal CLI
crates/minimal/src/cmd_check.rs, cmd_init.rs, cmd_update.rs, cmd_status.rs, cmd_dump.rs
Replace --harnesses with --stacks; cmd_check selects stacks_dir (compat fallback to harnesses if present); cmd_init auto-detects stacks and writes [stack]; cmd_update renames harness→stack in minimal.toml when present.
Remote client & ot
crates/remote-client/src/lib.rs, crates/ot/src/lib.rs
Add CheckKind::CheckStacks; map remote harness-like responses to check::CheckObj::Stack.
Test fixtures
crates/mctx/testdata/*, decode tests
Remove harness fixture, add stacks/fake-stack/stack.ncl, and update test package names and expectations to stacks.
Version & manifests
.minimal/minimal.toml, Cargo.toml, crates/stdlib/Cargo.toml
Update upstream locked_commit and bump stdlib version 0.0.14 → 0.0.15.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly Related PRs

  • gominimal/minimal#161: Related to remote check messages / check RPC handling that this PR maps from harness→stack.
  • gominimal/minimal#172: Related minimal.toml write-back and sideload locked_commit update logic touched by this PR.

Suggested reviewers

  • evanspearman
  • msample
  • bryan-minimal

"🐰 I hopped through code to swap a name,
From harness to stack — so fresh, not tame.
Matchers and tasks now find their track,
Tests updated, and configs on my back.
A little hop, a tidy knack."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'all: rename harness to stack' accurately and concisely describes the main change: a comprehensive rename of the 'harness' concept to 'stack' across the entire codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/attrs

Comment @coderabbitai help to get the list of available commands and usage tips.

@twitchyliquid64

Copy link
Copy Markdown
Contributor Author

build-in-minimal failure is expected as I updated the repo minimal.toml to a new version.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Bump the wire-format version for this record schema change.

The body for tag 0x06 now decodes as StackRecord { stack }, but the stream still advertises version 1. Any cached graph written by the previous harness schema will still be treated as v1 and fail mid-read with Json instead of triggering explicit version invalidation. Increment STREAM_VERSION here, 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 win

Prefer one compatibility directory here instead of merging both.

These branches append both harnesses/ and stacks/ into the same stacks array. In a repo that carries both during migration, the same logical stack can be loaded twice; later decode folds stacks into a HashMap, so whichever import read_dir yields 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 win

Report a missing name as 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 be ObjTy::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_task currently drops every build command after the first one.

Lines 515-518 synthesize the default build task from cmds[0] only. For any stack whose build_cmd expands to multiple commands, minimal run build will 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 win

Don't hide an invalid stack as “task not found.”

Lines 587-597 return Ok(None) when minimal.toml references a stack name that doesn't exist. That masks a broken config as a missing task, which is especially confusing for stack-provided defaults like build. 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 win

Add 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 value

Nit: closure variable h is 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.harnesses field was not renamed to stacks — incomplete rename in the public API.

The PR renames "harness" → "stack" throughout, but CheckArgs still exposes pub harnesses: bool. All callers (including the test at line 1082) build CheckArgs { harnesses: … }, which is inconsistent with check::CheckObj::Stack returned on line 517. The proto wire field (harnesses) can stay for wire compat, but the Rust-side field should be stacks.

♻️ 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 compat

And 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3949779 and ec3e34c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (32)
  • .minimal/minimal.toml
  • Cargo.toml
  • crates/check/src/lib.rs
  • crates/check/src/stack.rs
  • crates/decode/src/builds.rs
  • crates/decode/src/lib.rs
  • crates/decode/src/load.rs
  • crates/decode/src/stacks.rs
  • crates/graph/src/graph.rs
  • crates/graph/src/lib.rs
  • crates/graph/src/loader.rs
  • crates/graph/src/wire.rs
  • crates/mctx/src/env.rs
  • crates/mctx/src/lib.rs
  • crates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.ncl
  • crates/mctx/testdata/fakerepo-with-stack/minimal.toml
  • crates/mctx/testdata/fakerepo-with-stack/packages/extra-build-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/extra-runtime-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/stack-build-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/stack-runtime-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/stacks/fake-stack/stack.ncl
  • crates/mfile/src/lib.rs
  • crates/minimal/src/cmd_check.rs
  • crates/minimal/src/cmd_dump.rs
  • crates/minimal/src/cmd_init.rs
  • crates/minimal/src/cmd_status.rs
  • crates/minimal/src/cmd_update.rs
  • crates/minimal/src/main.rs
  • crates/ot/src/lib.rs
  • crates/remote-client/src/lib.rs
  • crates/stdlib/Cargo.toml
  • crates/stdlib/minimal-ncl/minimal.ncl
💤 Files with no reviewable changes (1)
  • crates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.ncl

Comment thread crates/check/src/stack.rs Resolved
Comment thread crates/mctx/src/env.rs Resolved
Comment thread crates/mctx/src/lib.rs Resolved
Comment thread crates/mctx/src/lib.rs
Comment on lines 820 to 837
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"
)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Comment thread crates/minimal/src/cmd_dump.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Bump STREAM_VERSION to invalidate old wire streams cleanly.

The StackRecord JSON payload now uses field name stack instead of the previous harness. Since the tag value 0x06 is unchanged, old serialized streams will pass the version check but fail with a confusing JSON deserialization error when trying to find the missing stack field.

Incrementing STREAM_VERSION from 1 to 2 will ensure old streams are rejected cleanly at line 430/879 with UnsupportedVersion instead 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 value

Consider 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:

  1. Updating to [stack] to test the new format directly, or
  2. Renaming the directory to fakerepo-with-harness-compat if the intent is to test backwards compatibility

This 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 win

Potential duplicate stack entries when both harnesses/ and stacks/ exist.

The loader reads from both directories and appends all entries into the same stacks = [...] array. If a layer has both harnesses/foo/harness.ncl and stacks/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 win

Stale 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 value

Stale 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 value

Stale 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

📥 Commits

Reviewing files that changed from the base of the PR and between ec3e34c and eb5b17b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (32)
  • .minimal/minimal.toml
  • Cargo.toml
  • crates/check/src/lib.rs
  • crates/check/src/stack.rs
  • crates/decode/src/builds.rs
  • crates/decode/src/lib.rs
  • crates/decode/src/load.rs
  • crates/decode/src/stacks.rs
  • crates/graph/src/graph.rs
  • crates/graph/src/lib.rs
  • crates/graph/src/loader.rs
  • crates/graph/src/wire.rs
  • crates/mctx/src/env.rs
  • crates/mctx/src/lib.rs
  • crates/mctx/testdata/fakerepo-with-harness/harnesses/fake-harness/harness.ncl
  • crates/mctx/testdata/fakerepo-with-stack/minimal.toml
  • crates/mctx/testdata/fakerepo-with-stack/packages/extra-build-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/extra-runtime-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/stack-build-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/packages/stack-runtime-pkg/build.ncl
  • crates/mctx/testdata/fakerepo-with-stack/stacks/fake-stack/stack.ncl
  • crates/mfile/src/lib.rs
  • crates/minimal/src/cmd_check.rs
  • crates/minimal/src/cmd_dump.rs
  • crates/minimal/src/cmd_init.rs
  • crates/minimal/src/cmd_status.rs
  • crates/minimal/src/cmd_update.rs
  • crates/minimal/src/main.rs
  • crates/ot/src/lib.rs
  • crates/remote-client/src/lib.rs
  • crates/stdlib/Cargo.toml
  • crates/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

Comment thread crates/check/src/stack.rs
Comment on lines +134 to 138
return Ok(CheckResult::stack_name_fail(format!(
"stack defined in {}/stack.ncl has name {}",
stack,
s.as_str()
)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@twitchyliquid64
twitchyliquid64 merged commit b6e5af6 into main May 7, 2026
9 of 10 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/attrs branch May 7, 2026 22:29
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.

2 participants