Skip to content

Update design with command/script targets#5

Merged
leynos merged 4 commits intomainfrom
codex/add-command-and-script-options-to-targets
Jul 13, 2025
Merged

Update design with command/script targets#5
leynos merged 4 commits intomainfrom
codex/add-command-and-script-options-to-targets

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 12, 2025

Summary

  • document new command and script options for rules and targets
  • update code snippets reflecting the new schema

Testing

  • make fmt
  • make markdownlint
  • make nixie
  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_6872b6c0e33883228d643fad30bbe296

Summary by Sourcery

Introduce first-class command and script recipes for rules and targets, refactoring the manifest schema and Ninja generator to support and enforce these options, and update documentation accordingly.

New Features:

  • Allow specifying an inline command directly on a target without a rule
  • Add support for multi-line script blocks for both rules and targets

Enhancements:

  • Replace the command field in Rule and Target with tagged enums (Recipe and TargetRecipe) to enforce one-of exclusivity
  • Update Ninja generator to wrap script recipes in /bin/sh -e -c for consistent execution

Documentation:

  • Document the new command and script options in the design spec and update all related code examples
  • Update Markdown formatting guidance to ensure consistent line wrapping

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 12, 2025

Reviewer's Guide

This PR updates the design documentation to reflect new inline command and multi-line script support in rules and targets, enforces their mutual exclusivity via tagged Recipe and TargetRecipe enums, and describes script wrapping in the Ninja generator. It also applies a minor markdown reflow fix in AGENTS.md.

Entity relationship diagram for Rule, Target, and Action with Recipe and TargetRecipe

erDiagram
    RULE ||--o| RECIPE : uses
    TARGET ||--o| TARGET_RECIPE : uses
    ACTION ||--o| RECIPE : uses

    RECIPE { 
      string command
      string script
    }
    TARGET_RECIPE {
      string rule
      string command
      string script
    }
Loading

Class diagram for updated Rule, Target, and Action types with Recipe and TargetRecipe enums

classDiagram
    class Rule {
        +String name
        +Recipe recipe
        +Option<String> description
        +Option<String> deps
    }
    class Recipe {
    }
    Recipe <|-- Command
    Recipe <|-- Script
    class Command {
        +String command
    }
    class Script {
        +String script
    }

    class Target {
        +StringOrList name
        +TargetRecipe recipe
        +StringOrList sources
        +Option<StringOrList> order_only
        +Option<StringOrList> implicit
        +Option<StringOrList> outputs
        +Option<StringOrList> byproducts
        +Option<String> description
        +bool always
    }
    class TargetRecipe {
    }
    TargetRecipe <|-- RuleRef
    TargetRecipe <|-- CommandRef
    TargetRecipe <|-- ScriptRef
    class RuleRef {
        +String rule
    }
    class CommandRef {
        +String command
    }
    class ScriptRef {
        +String script
    }

    class Action {
        +Recipe recipe
        +Option<String> description
        +Option<String> depfile
        +Option<String> deps_format
    }
Loading

File-Level Changes

Change Details Files
Introduce and document inline command and multi-line script options with exclusivity in rules and targets
  • Extended IR validation to enforce one-of command/script for rules and one-of rule/command/script for targets
  • Added script field descriptions and examples for both rules and targets
  • Documented the Recipe and TargetRecipe tagged enums with kind-based deserialization
  • Noted how multi-line scripts are wrapped in /bin/sh -e -c during Ninja generation
docs/netsuke-design.md
Adjust markdown formatting in AGENTS.md
  • Reflowed the make fmt instruction line for consistent wrapping
AGENTS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 12, 2025

Warning

Rate limit exceeded

@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 74cd27e and 0da50c5.

📒 Files selected for processing (2)
  • AGENTS.md (1 hunks)
  • docs/netsuke-design.md (7 hunks)

Summary by CodeRabbit

  • Documentation

    • Updated documentation to clarify that rules and targets now support mutually exclusive command or script specifications, with validation enforced during manifest parsing.
    • Added details on how multi-line scripts are executed and how exclusivity is handled for command definitions in rules and targets.
  • New Features

    • Enhanced manifest expressiveness by supporting both single-line commands and multi-line scripts for rules and targets.

Summary by CodeRabbit

  • Documentation

    • Updated documentation to clarify that commands in rules and targets can now be specified as either a single-line command or a multi-line script, but not both.
  • New Features

    • Manifest now supports both single-line commands and multi-line scripts for reusable rules and individual targets, increasing flexibility for specifying build actions.

Walkthrough

Update the Netsuke build manifest schema and its Rust data structures to support specifying either a single-line command or a multi-line script for rules and targets, but not both. Adjust the documentation and Rust structs to reflect these mutually exclusive options and enforce validation of exclusivity.

Changes

File(s) Change Summary
docs/netsuke-design.md Clarify mutually exclusive command and script for rules and targets; describe shell script wrapping.
.../ast.rs, .../ir.rs Replace command and rule strings with enums Recipe and TargetRecipe supporting mutually exclusive variants (Command, Script, Rule).

Poem

In Netsuke’s manifest, a choice anew,
Command or script—pick only one to do!
Single lines or scripts with flair,
Rust enums now handle both with care.
Exclusive paths, the schema’s might,
Build rules flex in day or night.
🦀✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-command-and-script-options-to-targets

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Add validation in manifest parsing to enforce exactly one of command or script on rules and exactly one of rule, command, or script on targets.
  • Consider refactoring the mutually exclusive command/script/ rule fields into an enum rather than multiple Option to improve schema clarity and prevent invalid states.
  • Ensure the IR-to-Ninja backend is updated to detect and correctly emit script blocks (invoking /bin/sh) alongside regular commands.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add validation in manifest parsing to enforce exactly one of command or script on rules and exactly one of rule, command, or script on targets.
- Consider refactoring the mutually exclusive command/script/ rule fields into an enum rather than multiple Option<String> to improve schema clarity and prevent invalid states.
- Ensure the IR-to-Ninja backend is updated to detect and correctly emit script blocks (invoking /bin/sh) alongside regular commands.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
docs/netsuke-design.md (1)

339-346: Derive Deserialize on Rule

Example code shows #[serde(deny_unknown_fields)] without #[derive(Deserialize)], so it would not compile. Add the derive to keep the sample correct.

-#[serde(deny_unknown_fields)]
-pub struct Rule {
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Rule {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5ae2a1 and f517de4.

📒 Files selected for processing (1)
  • docs/netsuke-design.md (5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.md

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • AGENTS.md
**/*.md

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • AGENTS.md

⚙️ CodeRabbit Configuration File

🪛 LanguageTool
docs/netsuke-design.md

[uncategorized] ~167-~167: Loose punctuation mark.
Context: ...hat defines a reusable action. - name: A unique string identifier for the rule...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~169-~169: Loose punctuation mark.
Context: ...ng identifier for the rule. - command: A single command string to be executed....

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~174-~174: Loose punctuation mark.
Context: ...$inand $outvariables. -script`: A multi-line script declared with the Y...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~198-~198: Loose punctuation mark.
Context: ...for building this target. - command: A single command string to run directly...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~200-~200: Loose punctuation mark.
Context: ...un directly for this target. - script: A multi-line script passed to the inter...

(UNLIKELY_OPENING_PUNCTUATION)

Comment thread docs/netsuke-design.md Outdated
Comment thread docs/netsuke-design.md
Comment thread docs/netsuke-design.md Outdated
Comment thread docs/netsuke-design.md
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (2)
docs/netsuke-design.md (2)

171-183: Wrap bullet-point lines to 80 columns
These bullet entries are still over-long, repeating an issue flagged in the
earlier review. Break them after logical clause boundaries so every line sits
within the 80-column limit.


205-214: Wrap target-level bullets to 80 columns
The command/script exclusivity bullets again exceed the style-guide width.
Re-flow them as requested previously.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f517de4 and 74cd27e.

📒 Files selected for processing (1)
  • docs/netsuke-design.md (7 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.md

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • AGENTS.md
**/*.md

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • AGENTS.md

⚙️ CodeRabbit Configuration File

🪛 LanguageTool
docs/netsuke-design.md

[uncategorized] ~169-~169: Loose punctuation mark.
Context: ...hat defines a reusable action. - name: A unique string identifier for the rule...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~171-~171: Loose punctuation mark.
Context: ...ng identifier for the rule. - command: A single command string to be executed....

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~176-~176: Loose punctuation mark.
Context: ...$inand $outvariables. -script`: A multi-line script declared with the Y...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~182-~182: Would you like to use the Oxford spelling “deserialize”? The spelling ‘deserialise’ is also correct.
Context: ...id states. Internally, these options deserialise into an enum Recipe to ensure the e...

(OXFORD_SPELLING_Z_NOT_S)


[uncategorized] ~205-~205: Loose punctuation mark.
Context: ...for building this target. - command: A single command string to run directly...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~207-~207: Loose punctuation mark.
Context: ...un directly for this target. - script: A multi-line script passed to the inter...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~211-~211: Would you like to use the Oxford spelling “deserialization”? The spelling ‘deserialisation’ is also correct.
Context: ...ser validates this exclusivity during deserialisation. This union deserialises into an enu...

(OXFORD_SPELLING_Z_NOT_S)


[style] ~213-~213: Would you like to use the Oxford spelling “deserializes”? The spelling ‘deserialises’ is also correct.
Context: ...y during deserialisation. This union deserialises into an enum TargetRecipe so that the...

(OXFORD_SPELLING_Z_NOT_S)

Comment thread docs/netsuke-design.md Outdated
Comment thread docs/netsuke-design.md
Comment on lines +746 to +749
When an action's `recipe` is a script, the generated rule wraps the script in
an invocation of `/bin/sh -e -c` so that multi-line scripts execute
consistently across platforms.

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.

🧹 Nitpick (assertive)

Wrap explanatory lines to 80 columns

The newly added explanation of the /bin/sh -e -c wrapper breaches the 80-column
limit. Re-wrap for consistency with documentation guidelines.

🤖 Prompt for AI Agents
In docs/netsuke-design.md around lines 746 to 749, the explanation about the
`/bin/sh -e -c` wrapper exceeds the 80-column line length limit. Reformat the
text by inserting line breaks to ensure no line goes beyond 80 characters,
maintaining readability and consistency with the documentation style.

Comment thread docs/netsuke-design.md Outdated
Comment thread docs/netsuke-design.md
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 13, 2025

@sourcery-ai review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Consider consolidating the Recipe and TargetRecipe enums into a single generic enum (or a shared type) since they share identical structure, to reduce duplication and ensure consistent behaviour across rules and targets.
  • Add a serde alias or default variant for manifests that don’t include the new kind tag so existing configs without explicit kind fields continue to deserialize correctly and avoid breaking backward compatibility.
  • Make the shell invocation for multi-line scripts configurable (or respect shebangs) instead of hardcoding /bin/sh -e -c, so users can opt into other interpreters or platform-specific shells.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider consolidating the `Recipe` and `TargetRecipe` enums into a single generic enum (or a shared type) since they share identical structure, to reduce duplication and ensure consistent behaviour across rules and targets.
- Add a serde alias or default variant for manifests that don’t include the new `kind` tag so existing configs without explicit `kind` fields continue to deserialize correctly and avoid breaking backward compatibility.
- Make the shell invocation for multi-line scripts configurable (or respect shebangs) instead of hardcoding `/bin/sh -e -c`, so users can opt into other interpreters or platform-specific shells.

## Individual Comments

### Comment 1
<location> `AGENTS.md:139` </location>
<code_context>
-  files and fix table markup.
+- Run `make fmt` after any documentation changes to format all Markdown files
+  and fix table markup.
 - Validate Markdown Mermaid diagrams using by running `make nixie`.
 - Markdown paragraphs and bullet points must be wrapped at 80 columns.
 - Code blocks must be wrapped at 120 columns.
</code_context>

<issue_to_address>
Typo: 'using by running' should be 'by running'.

It should read: 'Validate Markdown Mermaid diagrams by running `make nixie`.'
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
- Validate Markdown Mermaid diagrams using by running `make nixie`.
=======
- Validate Markdown Mermaid diagrams by running `make nixie`.
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread AGENTS.md Outdated
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 13, 2025

@sourcery-ai resolve

@leynos leynos merged commit e45ca28 into main Jul 13, 2025
1 check passed
@leynos leynos deleted the codex/add-command-and-script-options-to-targets branch July 13, 2025 09:24
This was referenced Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant