Skip to content

Add Rust-extension state-machine guidance - #49

Draft
leynos wants to merge 2 commits into
mainfrom
add-rust-state-machine-guidance
Draft

Add Rust-extension state-machine guidance#49
leynos wants to merge 2 commits into
mainfrom
add-rust-state-machine-guidance

Conversation

@leynos

@leynos leynos commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • add the state-machine modelling guidance to generated AGENTS.md files when
    use_rust enables the Rust extension
  • distinguish caller-driven typestate from parser-, frame-, socket-, channel-,
    and scheduler-driven runtime ADTs
  • require state owners to encapsulate correlated transitions and mandatory
    finalization
  • preserve ordinary booleans for independent observations
  • add a regression test proving the wording appears in Rust-enabled renders and
    remains absent from Python-only renders

Scope

The guidance sits entirely inside the existing {% if use_rust %} block. Pure
Python projects therefore retain their current generated instructions.

Validation

  • reviewed the two-file branch diff and conditional placement through the
    GitHub connector
  • added a parameterized render test for both use_rust = false and
    use_rust = true
  • no local repository checkout was available in this session; draft PR CI should
    run the parent-template test, lint, type-check, Markdown, and spelling gates

Summary by Sourcery

Guide Rust-enabled projects toward explicit, well-encapsulated state-machine designs in generated AGENTS.md files.

New Features:

  • Add Rust-extension guidance for modelling state machines, choosing between typestate and runtime ADTs, encapsulating transitions and finalization, and retaining independent booleans.

Enhancements:

  • Scope the new guidance to generated AGENTS.md files for Rust-enabled projects while preserving Python-only output.

Tests:

  • Add parameterized render coverage confirming the guidance appears only when the Rust extension is enabled.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Warning

Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


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

@sourcery-ai

sourcery-ai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR extends the Rust-only section of the AGENTS.md template with guidance for modelling state machines, choosing caller-driven typestate versus runtime ADTs, and encapsulating transitions and cleanup. A parameterized render test verifies that all guidance appears when use_rust is enabled and remains absent for Python-only projects.

Flow diagram for Rust-only state-machine guidance rendering

flowchart TD
    Render[Render AGENTS.md template] --> RustCheck{use_rust enabled?}
    RustCheck -->|yes| Guidance[Include state-machine modelling guidance]
    RustCheck -->|no| PythonOnly[Retain Python-only instructions]
    Guidance --> Typestate[Choose caller-driven typestate when applicable]
    Guidance --> RuntimeADT[Choose runtime ADT for parser, frame, socket, channel, or scheduler transitions]
    Guidance --> Encapsulation[Encapsulate correlated transitions and finalization]
    Guidance --> Booleans[Keep independent observations as booleans]
Loading

File-Level Changes

Change Details Files
Add Rust-specific state-machine modelling guidance to the generated agent instructions.
  • Explain when to use enums, typestate, runtime ADTs, or runtime stacks based on transition ownership.
  • Require state owners to encapsulate correlated transitions and mandatory cleanup.
  • Clarify that independent observations should remain booleans.
template/AGENTS.md.jinja
Verify the guidance is rendered only for Rust-enabled projects.
  • Add a parameterized Copier render test covering both Rust-enabled and Python-only configurations.
  • Assert each guidance fragment is present or absent according to the use_rust setting.
tests/test_agents_state_machine_guidance.py

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

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.

1 participant