Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Summary by CodeRabbit
WalkthroughFlatten the manifest schema by removing the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ManifestParser
participant Recipe
User->>ManifestParser: Provide manifest YAML (command/script/rule at top level)
ManifestParser->>Recipe: Deserialize, check for command/script/rule fields
Recipe-->>ManifestParser: Return variant based on present field (error if multiple/none)
ManifestParser-->>User: Parsed manifest structure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (3)docs/**/*.md📄 CodeRabbit Inference Engine (AGENTS.md)
Files:
**/*.md📄 CodeRabbit Inference Engine (AGENTS.md)
Files:
⚙️ CodeRabbit Configuration File
Files:
**/*.rs📄 CodeRabbit Inference Engine (AGENTS.md)
Files:
⚙️ CodeRabbit Configuration File
Files:
🧠 Learnings (1)📚 Learning: applies to docs/src/ast.rs : implement the yaml parsing logic to deserialize a static netsukefile in...Applied to files:
🧬 Code Graph Analysis (1)tests/ast_tests.rs (1)
🔇 Additional comments (8)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Reviewer's GuideThis PR streamlines the manifest syntax by flattening the ER diagram for flattened manifest fieldserDiagram
NETSUKE_MANIFEST ||--o{ TARGET : contains
NETSUKE_MANIFEST ||--o{ RULE : contains
TARGET {
StringOrList name
String command
String script
StringOrList rule
String description
}
RULE {
string name
string command
string script
StringOrList rule
string description
}
Class diagram for updated Recipe deserialization and manifest structureclassDiagram
class NetsukeManifest {
+Vec<Target> targets
+Vec<Rule> rules
}
class Target {
+StringOrList name
+Recipe recipe
+Vec<StringOrList> sources
+Option<String> description
}
class Rule {
+String name
+Recipe recipe
+Option<String> description
+Vec<String> tags
}
class Recipe {
<<enum>>
Command(command: String)
Script(script: String)
Rule(rule: StringOrList)
}
NetsukeManifest "1" o-- "*" Target
NetsukeManifest "1" o-- "*" Rule
Target "1" o-- "1" Recipe
Rule "1" o-- "1" Recipe
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/ast.rs:119` </location>
<code_context>
Rule { rule: StringOrList },
}
+impl<'de> Deserialize<'de> for Recipe {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ #[derive(Deserialize)]
+ struct RawRecipe {
+ command: Option<String>,
+ script: Option<String>,
+ rule: Option<StringOrList>,
+ }
+
+ let raw = RawRecipe::deserialize(deserializer)?;
</code_context>
<issue_to_address>
Manual deserialization logic for Recipe does not provide detailed error context.
Consider updating the error messages to specify which fields are present or missing to aid in debugging manifest issues.
</issue_to_address>
### Comment 2
<location> `tests/ast_tests.rs:96` </location>
<code_context>
targets:
- name: hello
- recipe: {}
+ command: {}
"#;
assert!(manifest::from_str(yaml).is_err());
</code_context>
<issue_to_address>
Test for empty command/script/rule fields is present, but consider adding similar tests for 'script' and 'rule'.
Please add tests for empty 'script' and 'rule' fields to ensure all mutually exclusive fields are properly validated.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (20)
docs/netsuke-design.md(5 hunks)src/ast.rs(5 hunks)src/manifest.rs(1 hunks)tests/ast_tests.rs(19 hunks)tests/data/action_invalid.yml(1 hunks)tests/data/actions.yml(1 hunks)tests/data/circular.yml(1 hunks)tests/data/duplicate_outputs.yml(1 hunks)tests/data/duplicate_outputs_multi.yml(1 hunks)tests/data/duplicate_rules.yml(1 hunks)tests/data/empty_rule.yml(1 hunks)tests/data/invalid_version.yml(1 hunks)tests/data/minimal.yml(1 hunks)tests/data/missing_rule.yml(1 hunks)tests/data/multiple_rules_per_target.yml(1 hunks)tests/data/phony.yml(1 hunks)tests/data/rule_not_found.yml(1 hunks)tests/data/rules.yml(1 hunks)tests/data/unknown_field.yml(1 hunks)tests/ninja_snapshot_tests.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
src/manifest.rstests/ast_tests.rstests/ninja_snapshot_tests.rssrc/ast.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
src/manifest.rstests/ast_tests.rstests/ninja_snapshot_tests.rssrc/ast.rs
docs/**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
docs/**/*.md: Use the markdown files within thedocs/directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in thedocs/directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Files:
docs/netsuke-design.md
**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.md: Documentation must use en-GB-oxendict spelling and grammar, except for the naming of the "LICENSE" file.
Validate Markdown files usingmake markdownlint.
Runmake fmtafter any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by runningmake nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown must be wrapped at 120 columns.
Tables and headings in Markdown must not be wrapped.
Use dashes (-) for list bullets in Markdown.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.
Files:
docs/netsuke-design.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) spelling and grammar
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
docs/netsuke-design.md
🧠 Learnings (1)
📚 Learning: applies to docs/src/ast.rs : implement the yaml parsing logic to deserialize a static netsukefile in...
Learnt from: CR
PR: leynos/netsuke#0
File: docs/roadmap.md:0-0
Timestamp: 2025-08-03T23:02:56.706Z
Learning: Applies to docs/src/ast.rs : Implement the YAML parsing logic to deserialize a static Netsukefile into the NetsukeManifest AST.
Applied to files:
src/ast.rs
🔇 Additional comments (23)
tests/data/action_invalid.yml (1)
1-8: Changes correctly reflect the new flattened manifest schema.The test fixture properly demonstrates an invalid action case where neither
commandnorruleis specified, and the comment accurately describes the expected failure behaviour.src/ast.rs (4)
13-13: Documentation example correctly updated.The example YAML string properly demonstrates the flattened syntax with
commanddirectly under the target.
119-149: Well-implemented custom deserializer for Recipe enum.The implementation correctly enforces mutual exclusivity of recipe fields with clear error messages. The use of
iter().count()on Options is an elegant way to validate exactly one field is present.
95-96: Correct use of serde flatten attribute.The
#[serde(flatten)]attribute properly inlines Recipe fields into the Rule structure, achieving the desired flattened YAML format.
162-163: Consistent flattening approach for Target struct.The
#[serde(flatten)]attribute maintains consistency with the Rule struct implementation.src/manifest.rs (1)
22-22: Documentation example properly updated.The example correctly demonstrates the flattened syntax without the recipe wrapper.
tests/data/circular.yml (1)
5-8: Test fixture correctly updated to flattened syntax.The circular dependency test case maintains its purpose while adopting the new manifest structure.
tests/data/minimal.yml (1)
4-4: Minimal test case properly updated.The fixture correctly demonstrates the simplest valid manifest with the flattened syntax.
tests/data/empty_rule.yml (1)
5-5: Clarify handling of an emptyrulearrayThe manifest now serialises an empty list for
rule. Verify that the parser surfaces the intended validation error (or lack thereof) with the flattened schema, and update the negative-test assertion if the error message changed.tests/data/phony.yml (1)
4-4: Flattening ofcommandfield is correctPromotion of
commandto the target level aligns with the new schema. No further action required.tests/data/missing_rule.yml (1)
5-5: Ensure missing-rule diagnostic still triggersWith the
rulefield flattened, confirm that the parser still produces the expected “rule not found” failure and that the test asserts against the new error text if it changed.tests/data/rule_not_found.yml (1)
5-5: Validate unresolved-rule pathMaintain the negative-test assertion for an undefined rule after the schema change; update expected error wording if necessary.
tests/data/unknown_field.yml (1)
5-5: Flattenedcommandfield acceptedThe target now directly declares
command, which is in line with the new manifest design. The fixture keepsextrato exercise the unknown-field path; no additional changes needed.tests/data/duplicate_outputs_multi.yml (1)
7-12: No issues – schema flattening looks correct
Thecommandfield is now placed at the target level, matching the new manifest format. The fixture continues to express the duplicate-output situation the test intends.tests/data/invalid_version.yml (1)
4-4: Preserve the negative-case intent
The file now includes a top-levelcommand, so the only remaining error driver is the invalid version string. That still covers the intended failure path, so the fixture remains valid for its purpose.tests/data/duplicate_outputs.yml (1)
5-8: LGTM – fixture matches flattened manifest
Both entries expose the duplicate outputs scenario with the new syntax. No further action required.tests/data/actions.yml (1)
4-7: Align actions and targets with flattened syntax
The directcommandkeys conform to the updated deserialiser. Test coverage is preserved.tests/ninja_snapshot_tests.rs (2)
34-35: Escape$to silencerustfmtlints
rustfmtsometimes flags$out/$inin raw strings as macro placeholders. Escape them ($$out) or annotate the string with#[expect(clippy::...)]narrowly to avoid future CI breakages.Also applies to: 38-38
34-39: Keep raw-string indentation consistent
The embedded YAML keeps its indentation, but lines 34 and 38 were re-indented one space relative to their peers. Align them to column 9 to avoid spurious diff noise in future edits.- - name: touch - command: "python3 -c 'import os,sys; open(sys.argv[1],\"a\").close()' $out" + - name: touch + command: "python3 -c 'import os,sys; open(sys.argv[1],\"a\").close()' $out"Likely an incorrect or invalid review comment.
tests/data/multiple_rules_per_target.yml (1)
10-12: Verify intended failure path for multiple rules per targetThe fixture supplies a list under
rule. The design doc (Section 5.4, line 1107) states that multiple rules are not yet supported and should triggerIrGenError::MultipleRules. Ensure a test exercises this fixture and still expects a parse/IR‐generation failure after the schema change.tests/data/rules.yml (2)
4-4: Flatten recipe block correctly
commandnow sits at the top level, matching the new schema and keeping the YAML concise.
8-8: Reference rule directly on target
Directly assigningrule: compilealigns with the simplified manifest and remains clear.tests/data/duplicate_rules.yml (1)
10-13: Targets correctly reference their rules
hello.oandworld.onow use the flattenedrulefield and point to distinct rule names, satisfying the updated schema.
Summary
Testing
make fmtmake markdownlintmake lintmake testmake nixie(fails: failed copying files from cache to destination for package @mermaid-js/mermaid-cli)https://chatgpt.com/codex/tasks/task_e_6891af74508c8322a0aee165f115ab68
Summary by Sourcery
Simplify manifest syntax by flattening recipe fields so that command, script, or rule keys appear directly at the top level of targets, rules, and actions, and by implementing custom untagged deserialization for the Recipe enum to enforce mutual exclusivity.
New Features:
command,script, andrulefields instead of nestedrecipeblocks for targets, rules, and actions.Enhancements:
kindtagging on the Recipe enum and add#[serde(flatten)]to embed its fields directly into Rule and Target structs.Documentation:
Tests: