Skip to content

Implement Bevy/DDlog scaffolding#1

Open
leynos wants to merge 3 commits intomainfrom
codex/implement-phase-0-and-update-architecture-doc
Open

Implement Bevy/DDlog scaffolding#1
leynos wants to merge 3 commits intomainfrom
codex/implement-phase-0-and-update-architecture-doc

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 8, 2025

Summary

  • set up initial Bevy app and DDlog handle
  • compile src/lille.dl in build.rs when ddlog executable is available
  • expose new Bevy resource helpers
  • document updated architecture and dependencies
  • update contribution guide for new nixie Mermaid validator

Testing

  • cargo fmt -- --check
  • cargo clippy --quiet (fails: no matching package named differential-datalog)
  • cargo test --quiet (fails: no matching package named differential-datalog)
  • nixie docs/architecture.md

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

Summary by Sourcery

Set up foundational Bevy and DDlog scaffolding by replacing the legacy Piston loop with a Bevy App, inserting a placeholder DDlog handle resource, and extending the build script to compile the DDlog program when the compiler is present.

New Features:

  • Introduce a minimal Bevy App setup with default plugins and a hello_world startup system
  • Add a placeholder DdlogHandle resource and corresponding Bevy startup system
  • Integrate DDlog compilation of src/lille.dl into the build process when the ddlog compiler is detected

Enhancements:

  • Replace the custom game loop and Piston prototype with a Bevy-based application entry point
  • Expose Bevy resource helpers and re-export key items in the crate’s public API
  • Add Bevy as a project dependency in Cargo.toml

Build:

  • Watch src/lille.dl for changes and invoke the ddlog compiler in build.rs if available
  • Enhance build.rs to download a font fallback and emit warnings on failures

Documentation:

  • Update architecture.md to document the new Bevy/DDlog scaffolding and legacy Piston prototype
  • Revise AGENTS.md to use nixie for Mermaid diagram validation

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 8, 2025

Reviewer's Guide

Scaffolds a Bevy-based game runtime with placeholder DDlog integration by enhancing the build script to compile DDlog programs, refactoring the main loop into a Bevy App with systems, adding a ddlog_handle module, updating dependencies, and revising documentation to reflect the new architecture.

Sequence Diagram: New Application Startup Process

sequenceDiagram
    actor User
    participant MainFunction as "main()"
    participant BevyApp as "Bevy App"
    participant InitDdlogSystem as "init_ddlog_system()"
    participant HelloWorldSystem as "hello_world()"
    participant DdlogHandleResource as "DdlogHandle (Resource)"

    User->>MainFunction: Execute program
    MainFunction->>BevyApp: App::new()
    MainFunction->>BevyApp: .add_plugins(DefaultPlugins)
    MainFunction->>BevyApp: .add_startup_system(init_ddlog_system)
    MainFunction->>BevyApp: .add_systems(Startup, hello_world)
    MainFunction->>BevyApp: .run()
    BevyApp-->>InitDdlogSystem: Calls startup system
    InitDdlogSystem->>DdlogHandleResource: commands.insert_resource(DdlogHandle)
    InitDdlogSystem-->>BevyApp: Returns
    BevyApp-->>HelloWorldSystem: Calls startup system
    HelloWorldSystem->>HelloWorldSystem: info!("Hello Bevy!")
    HelloWorldSystem-->>BevyApp: Returns
Loading

Sequence Diagram: DDlog Compilation in Build Process

sequenceDiagram
    participant CargoBuild as "cargo build"
    participant BuildScript as "build.rs"
    participant DDlogCompiler as "ddlog compiler"
    participant FileSystem as "File System"

    CargoBuild->>BuildScript: Executes
    BuildScript->>DDlogCompiler: Check availability (ddlog --version)
    DDlogCompiler-->>BuildScript: Reports availability
    alt ddlog compiler available
        BuildScript->>FileSystem: Check "src/lille.dl" existence
        FileSystem-->>BuildScript: Reports existence
        alt "src/lille.dl" exists
            BuildScript->>DDlogCompiler: Compile "src/lille.dl" (output "ddlog_lille")
            DDlogCompiler-->>BuildScript: Compilation status
        end
    else ddlog compiler not available
        BuildScript->>BuildScript: Log warning "ddlog compiler not found"
    end
Loading

ER Diagram: New DdlogHandle Data Type (Unit Struct, Bevy Resource)

erDiagram
    DdlogHandle
Loading

File-Level Changes

Change Details Files
Enhanced build script for font management and DDlog compilation
  • Added rerun-if-changed for src/lille.dl
  • Imported Command to invoke external processes
  • Implemented check and invocation of ddlog compiler with warnings
  • Retained font download logic and FONT_PATH env var
build.rs
Refactored main to use Bevy App instead of Piston loop
  • Removed manual GameWorld and GraphicsContext loop
  • Defined a hello_world startup system
  • Configured App::new with DefaultPlugins and init_ddlog_system
src/main.rs
Introduced ddlog_handle module and updated library exports
  • Added DdlogHandle resource and init_ddlog_system system
  • Reordered and re-exported ddlog_handle and existing components in lib.rs
src/ddlog_handle.rs
src/lib.rs
Added Bevy dependency for new architecture scaffolding
  • Inserted bevy = { version = "0.12", default-features = false, features = ["bevy_winit"] }
Cargo.toml
Updated documentation for Bevy/DDlog transition and validation tool
  • Expanded architecture.md with phase description and legacy notes
  • Replaced Mermaid validation script with nixie in AGENTS.md
docs/architecture.md
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

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 they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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 build.rs
Comment thread build.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 8, 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 and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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 Cargo.toml
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