Skip to content

Add intermediate representation structures#32

Merged
leynos merged 4 commits intomainfrom
codex/define-ir-data-structures-in-src/ir.rs
Jul 26, 2025
Merged

Add intermediate representation structures#32
leynos merged 4 commits intomainfrom
codex/define-ir-data-structures-in-src/ir.rs

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 26, 2025

Summary

  • define BuildGraph, Action and BuildEdge in src/ir.rs
  • export IR module in lib
  • document IR decisions in design doc
  • mark IR data structures as done on the roadmap
  • add IR unit tests using rstest
  • create cucumber feature and steps for BuildGraph

Testing

  • make fmt
  • make lint
  • make test
  • make markdownlint
  • make nixie (fails: too many arguments)

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

Summary by Sourcery

Introduce a backend-agnostic intermediate representation (IR) for the build system and accompany it with documentation and tests

New Features:

  • Add IR module defining BuildGraph, Action, and BuildEdge and export it in the public API

Documentation:

  • Document IR design decisions in the design doc and mark IR structures as done on the roadmap

Tests:

  • Add unit tests for IR structures with rstest and a cucumber feature with step definitions to validate BuildGraph behavior

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 26, 2025

Reviewer's Guide

This PR introduces the intermediate representation layer by defining BuildGraph, Action, and BuildEdge structs in a new IR module, exposes the module publicly, adds documentation and tests (unit and Cucumber) for the IR, and updates related design docs and roadmap.

Class diagram for new IR structures (BuildGraph, Action, BuildEdge)

classDiagram
    class BuildGraph {
        +HashMap<String, Action> actions
        +HashMap<PathBuf, BuildEdge> targets
        +Vec<PathBuf> default_targets
    }
    class Action {
        +Recipe recipe
        +Option<String> description
        +Option<String> depfile
        +Option<String> deps_format
        +Option<String> pool
        +bool restat
    }
    class BuildEdge {
        +String action_id
        +Vec<PathBuf> inputs
        +Vec<PathBuf> explicit_outputs
        +Vec<PathBuf> implicit_outputs
        +Vec<PathBuf> order_only_deps
        +bool phony
        +bool always
    }
    BuildGraph "1" o-- "*" Action : contains
    BuildGraph "1" o-- "*" BuildEdge : contains
    BuildEdge "1" --> "1" Action : references by action_id
Loading

File-Level Changes

Change Details Files
Implement IR data structures (BuildGraph, Action, BuildEdge)
  • Define BuildGraph with actions, targets, and default_targets
  • Implement Action struct mirroring Ninja rule fields
  • Implement BuildEdge struct capturing inputs, outputs, and flags
src/ir.rs
Expose IR module in the public API
  • Add pub mod ir declaration
src/lib.rs
Add IR unit tests
  • Test BuildGraph default state
  • Test inserting Action and BuildEdge into BuildGraph
tests/ir_tests.rs
Add Cucumber feature tests for BuildGraph
  • Extend CLI world to include BuildGraph
  • Add Gherkin steps for graph creation and assertions
  • Include ir.feature scenario for empty BuildGraph
tests/cucumber.rs
tests/steps/mod.rs
tests/steps/ir_steps.rs
tests/features/ir.feature
Update documentation and roadmap
  • Document IR design decisions in netsuke-design.md
  • Mark IR data structures as done in roadmap.md
docs/netsuke-design.md
docs/roadmap.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 26, 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 2 minutes and 41 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 d4070a8 and cc751f0.

📒 Files selected for processing (1)
  • AGENTS.md (4 hunks)

Summary by CodeRabbit

  • New Features

    • Introduced an intermediate representation (IR) for build graphs, including new structures for actions, build edges, and graph management.
    • Made the IR module publicly accessible for external use.
  • Documentation

    • Added a new design decisions section explaining the IR approach.
    • Updated the roadmap to mark IR data structures as complete.
    • Improved formatting in the AGENTS documentation for better readability.
  • Tests

    • Added unit tests and behaviour-driven tests for the new IR structures, covering creation, insertion, and duplication scenarios.
    • Implemented new Cucumber step definitions for IR-related scenarios.
  • Refactor

    • Updated enums to support cloning and equality checks for enhanced flexibility in handling recipes and lists.

Walkthrough

Introduce a new intermediate representation (IR) module defining BuildGraph, Action, and BuildEdge structs for a build system backend. Update documentation to explain IR design decisions and mark related roadmap tasks as complete. Add public IR module export, extend test world state, and introduce comprehensive unit and Cucumber tests for the IR.

Changes

File(s) Change Summary
src/ir.rs Add new IR module with BuildGraph, Action, and BuildEdge structs, including documentation.
src/lib.rs Export new public module ir.
docs/netsuke-design.md Add subsection detailing IR design decisions and rationale.
docs/roadmap.md Mark IR data structure task as complete in the roadmap.
tests/ir_tests.rs Add unit tests for IR: default state, insertion, and duplicate handling.
tests/features/ir.feature Add feature test for initial state of BuildGraph.
tests/cucumber.rs Extend CliWorld struct with optional build_graph field.
tests/steps/ir_steps.rs Add Cucumber step definitions for creating and inspecting BuildGraph.
tests/steps/mod.rs Add ir_steps module to test steps.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant BuildGraph
    participant Action
    participant BuildEdge

    Tester->>BuildGraph: Create new BuildGraph
    Tester->>Action: Create Action (with Recipe, metadata)
    Tester->>BuildGraph: Insert Action
    Tester->>BuildEdge: Create BuildEdge (linking inputs/outputs, flags)
    Tester->>BuildGraph: Insert BuildEdge as Target
    Tester->>BuildGraph: Set default targets
    Tester->>BuildGraph: Query actions, targets, defaults
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Suggested reviewers

  • codescene-delta-analysis

Poem

In the forge of code, a graph takes shape,
With actions and edges, no Ninja escape.
Docs now explain the choices so wise,
Tests ensure the IR never tells lies.
The roadmap ticks off a box with a grin—
Let the build adventures begin! 🚀

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/define-ir-data-structures-in-src/ir.rs

🪧 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 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 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> `tests/ir_tests.rs:9` </location>
<code_context>
+use std::path::PathBuf;
+
+#[rstest]
+fn build_graph_default_is_empty() {
+    let graph = BuildGraph::default();
+    assert!(graph.actions.is_empty());
+    assert!(graph.targets.is_empty());
+    assert!(graph.default_targets.is_empty());
+}
+
</code_context>

<issue_to_address>
Consider adding tests for edge cases such as duplicate action IDs or targets.

Adding tests for duplicate action IDs or targets will help confirm correct handling of these edge cases, such as whether duplicates are overwritten, cause errors, or are accepted.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
#[rstest]
fn build_graph_default_is_empty() {
    let graph = BuildGraph::default();
    assert!(graph.actions.is_empty());
    assert!(graph.targets.is_empty());
    assert!(graph.default_targets.is_empty());
}
=======
#[rstest]
fn build_graph_default_is_empty() {
    let graph = BuildGraph::default();
    assert!(graph.actions.is_empty());
    assert!(graph.targets.is_empty());
    assert!(graph.default_targets.is_empty());
}

#[test]
fn build_graph_duplicate_action_ids() {
    let mut graph = BuildGraph::default();
    let action1 = Action { id: "a".to_string(), ..Default::default() };
    let action2 = Action { id: "a".to_string(), ..Default::default() };
    // Insert first action
    graph.actions.insert(action1.id.clone(), action1.clone());
    // Insert duplicate action with same ID
    let prev = graph.actions.insert(action2.id.clone(), action2.clone());
    // Check if the duplicate overwrites the previous one
    assert_eq!(graph.actions.len(), 1);
    assert_eq!(graph.actions.get("a").unwrap(), &action2);
    assert_eq!(prev.unwrap(), action1);
}

#[test]
fn build_graph_duplicate_targets() {
    let mut graph = BuildGraph::default();
    let target1 = PathBuf::from("foo.txt");
    let target2 = PathBuf::from("foo.txt");
    // Insert first target
    graph.targets.insert(target1.clone(), BuildEdge::default());
    // Insert duplicate target
    let prev = graph.targets.insert(target2.clone(), BuildEdge::default());
    // Check if the duplicate overwrites the previous one
    assert_eq!(graph.targets.len(), 1);
    assert!(graph.targets.contains_key(&target1));
    assert!(prev.is_some());
}
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `docs/netsuke-design.md:1050` </location>
<code_context>
+### 5.5 Design Decisions
+
+The IR structures defined in `src/ir.rs` are minimal containers that mirror
+Ninja's conceptual model while remaining backend agnostic. `BuildGraph`
+collects all `Action`s and `BuildEdge`s in hash maps keyed by stable strings and
+`PathBuf`s so the graph can be deterministically traversed for snapshot tests.
</code_context>

<issue_to_address>
'backend agnostic' should be hyphenated as 'backend-agnostic' for correct grammar.

Compound adjectives before a noun should be hyphenated. Please use 'backend-agnostic'.
</issue_to_address>

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 tests/ir_tests.rs
Comment thread docs/netsuke-design.md Outdated
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 26, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f4214e9 and f7f7be4.

📒 Files selected for processing (9)
  • docs/netsuke-design.md (1 hunks)
  • docs/roadmap.md (1 hunks)
  • src/ir.rs (1 hunks)
  • src/lib.rs (1 hunks)
  • tests/cucumber.rs (1 hunks)
  • tests/features/ir.feature (1 hunks)
  • tests/ir_tests.rs (1 hunks)
  • tests/steps/ir_steps.rs (1 hunks)
  • tests/steps/mod.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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:

  • tests/cucumber.rs
  • tests/steps/mod.rs
  • src/lib.rs
  • tests/steps/ir_steps.rs
  • src/ir.rs
  • tests/ir_tests.rs
**/*.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/roadmap.md
  • docs/netsuke-design.md
🔇 Additional comments (13)
src/lib.rs (1)

8-8: LGTM: IR module correctly exposed.

The public module declaration properly exposes the new intermediate representation functionality.

src/ir.rs (1)

1-26: Excellent module documentation with practical example.

The module doc comment properly explains the purpose and includes a helpful usage example that demonstrates the key structs.

tests/steps/mod.rs (1)

2-2: LGTM: Module declaration follows existing pattern.

The ir_steps module is correctly added in alphabetical order, maintaining consistency with the existing structure.

tests/features/ir.feature (1)

1-8: Well-structured feature test for BuildGraph initialisation.

The Cucumber feature properly tests the initial empty state of BuildGraph with clear, readable steps that verify all key collections.

tests/cucumber.rs (1)

9-9: LGTM: BuildGraph correctly integrated into test world.

The build_graph field properly extends CliWorld with optional BuildGraph state, following the established pattern for test context fields.

docs/roadmap.md (1)

40-41: LGTM: Roadmap accurately reflects completed IR implementation.

The checklist update correctly marks the IR data structures task as complete, aligning with the implementation in src/ir.rs.

docs/netsuke-design.md (1)

1047-1057: Excellent documentation of IR design rationale.

The new subsection clearly explains the design decisions behind the IR structures, particularly the choice of hash map keys for deterministic traversal and the backend-agnostic approach. This documentation will be valuable for future maintainers.

tests/ir_tests.rs (4)

8-14: Clean test verifying default BuildGraph state.

The test correctly validates that a default BuildGraph has empty collections for actions, targets, and default targets.


16-42: Comprehensive test of Action and BuildEdge creation.

The test effectively validates the creation and insertion of IR structures, covering key fields like recipe, description, depfile, and flags. The assertions properly verify the graph state after insertions.


44-77: Robust duplicate action handling test.

The test correctly verifies that inserting a duplicate action ID overwrites the previous entry and returns the replaced value. The Recipe pattern matching ensures the correct action is stored.


79-112: Effective duplicate target testing.

The test properly validates duplicate target handling, confirming that the second BuildEdge overwrites the first and that the always flag is preserved correctly.

tests/steps/ir_steps.rs (2)

7-10: Clean BuildGraph creation step.

The step properly creates a default BuildGraph and stores it in the test world for subsequent assertions.


12-28: Well-implemented assertion steps for graph collections.

The steps correctly use .expect() for error handling and verify the lengths of actions, targets, and default targets collections. The parameterised expressions allow flexible count verification.

Comment thread src/ir.rs
Comment thread src/ir.rs
Comment thread src/ir.rs
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: 1

♻️ Duplicate comments (3)
src/ir.rs (3)

32-32: Past review comment addressed: Clone derive added.

The BuildGraph struct now includes the Clone derive as suggested in previous reviews, enabling cloning for testing and transformation scenarios.


43-43: Past review comment addressed: Essential derives added to Action.

The Action struct now includes Clone and PartialEq derives alongside Debug, addressing the previous suggestion for improved usability and testing capabilities.


54-54: Past review comment addressed: Essential derives added to BuildEdge.

The BuildEdge struct now includes Clone and PartialEq derives alongside Debug, enabling usage in collections and testing scenarios as previously suggested.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7f7be4 and d4070a8.

📒 Files selected for processing (3)
  • AGENTS.md (4 hunks)
  • src/ast.rs (2 hunks)
  • src/ir.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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 using Arc to reduce the amount of data returned.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in 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.
Prefer expect over allow.
Prefer .expect() over .unwrap().

Files:

  • src/ast.rs
  • src/ir.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 return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for 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/ast.rs
  • src/ir.rs
**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.md: Validate Markdown files using make markdownlint.
Run make fmt after any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by running make 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.

Files:

  • AGENTS.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:

  • AGENTS.md
🪛 LanguageTool
AGENTS.md

[locale-violation] ~46-~46: LICENSE must be spelled with a “c” when used as a noun in British English. Use “licence”.
Context: ...grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged ...

(LICENCE_LICENSE_NOUN_SINGULAR)


[uncategorized] ~160-~160: Possible missing comma found.
Context: ...(>=) version requirements is strictly forbidden as they introduce unacceptable risk a...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (7)
AGENTS.md (2)

12-13: Approve formatting improvements for 80-column wrapping.

The line wrapping changes correctly adhere to the markdown guideline of wrapping paragraphs and bullet points at 80 columns whilst preserving semantic content.

Also applies to: 28-34, 46-47, 157-161, 167-169


46-47: Ignore the LICENSE spelling suggestion.

The static analysis tool suggests changing "LICENSE" to "licence" for British English, but the text explicitly states this is an exception for community consistency. The current spelling is correct.

src/ast.rs (1)

109-109: Approve derive additions for IR compatibility.

Adding Clone and PartialEq derives to Recipe and StringOrList enums is appropriate and necessary for their usage in the new intermediate representation structures. These standard derives enable cloning and equality comparison without introducing complexity.

Also applies to: 175-175

src/ir.rs (4)

1-25: Approve comprehensive module documentation.

The module documentation effectively explains the IR's purpose as a backend-agnostic representation and provides a clear, practical example demonstrating typical usage patterns.


31-40: Approve BuildGraph design with deterministic key strategy.

The BuildGraph structure uses HashMap<String, Action> and HashMap<PathBuf, BuildEdge> with stable keys, enabling deterministic graph traversal essential for snapshot testing. The separation of actions and targets with default targets list provides clear organisation.


42-51: Approve Action struct design for build commands.

The Action struct appropriately mirrors Ninja rule concepts whilst remaining backend-agnostic. Fields like depfile, deps_format, and pool provide necessary build system flexibility without coupling to specific implementations.


53-70: Approve BuildEdge design for input-output relationships.

The BuildEdge struct effectively models build statements with clear separation of explicit inputs, outputs, and dependencies. The phony and always flags directly reflect manifest requirements, maintaining traceability from source to IR.

Comment thread AGENTS.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@leynos leynos merged commit fb790ee into main Jul 26, 2025
2 checks passed
@leynos leynos deleted the codex/define-ir-data-structures-in-src/ir.rs branch July 26, 2025 19:29
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