diff --git a/.github/ISSUE_TEMPLATE/compiler-change.yml b/.github/ISSUE_TEMPLATE/compiler-change.yml index 0e0b1e0..64f0766 100644 --- a/.github/ISSUE_TEMPLATE/compiler-change.yml +++ b/.github/ISSUE_TEMPLATE/compiler-change.yml @@ -2,6 +2,14 @@ name: Compiler change description: Propose one observable language, validation, or toolchain change. title: "compiler: " body: + - type: textarea + id: outcome + attributes: + label: Outcome + description: State the single user-visible compiler or toolchain result this issue must deliver. + placeholder: "A project author can compile a server module and receive a deterministic Luau file at its Roblox placement." + validations: + required: true - type: dropdown id: compiler_stage attributes: @@ -40,6 +48,38 @@ body: placeholder: "The checker rejects assigning a string to total and points at the assigned expression." validations: required: true + - type: textarea + id: non_goals + attributes: + label: Non-goals + description: Name related behavior that this issue explicitly does not add, preserve, or redesign. Write None when there are no exclusions. + placeholder: "Do not add compatibility aliases or procedural macros." + validations: + required: true + - type: textarea + id: acceptance_evidence + attributes: + label: Acceptance evidence + description: List the observable cases that prove the outcome and the invalid state that must become impossible. + placeholder: "- Accepted source compiles through the public API.\n- Generated Luau parses and analyzes.\n- Invalid input identifies the declared source range." + validations: + required: true + - type: textarea + id: platform_constraints + attributes: + label: Platform constraints + description: State operating-system, Roblox execution-side, or filesystem constraints that affect the contract. Write None when the behavior is platform-neutral. + placeholder: "Compilation is platform-neutral; generated placement must distinguish server, client, and shared modules." + validations: + required: true + - type: textarea + id: native_dependency_routing + attributes: + label: Native dependency routing + description: Identify required native tools, pinned revisions, and the CI or local route that supplies them. Write None when no native dependency is required. + placeholder: "Official Luau tools come from the pinned revision in compiler-contracts.yml; do not require a globally installed binary." + validations: + required: true - type: textarea id: proof attributes: diff --git a/.github/ISSUE_TEMPLATE/compiler-regression.yml b/.github/ISSUE_TEMPLATE/compiler-regression.yml index da56463..fba31cf 100644 --- a/.github/ISSUE_TEMPLATE/compiler-regression.yml +++ b/.github/ISSUE_TEMPLATE/compiler-regression.yml @@ -24,6 +24,46 @@ body: description: Include generated Luau, runtime output, or diagnostic text. validations: required: true + - type: textarea + id: outcome + attributes: + label: Contract outcome + description: State the one observable behavior the regression report expects the compiler to restore. + placeholder: "The public compiler rejects the invalid source and highlights the assigned expression." + validations: + required: true + - type: textarea + id: non_goals + attributes: + label: Non-goals + description: Name related behavior that the regression fix must not change. Write None when there are no exclusions. + placeholder: "Do not change valid source syntax or unrelated diagnostic reasons." + validations: + required: true + - type: textarea + id: acceptance_evidence + attributes: + label: Acceptance evidence + description: List the passing and rejecting cases that prove the regression is fixed at the public boundary. + placeholder: "- The smallest reproducer passes its public compiler fixture.\n- The original valid case remains accepted." + validations: + required: true + - type: textarea + id: platform_constraints + attributes: + label: Platform constraints + description: State operating-system, Roblox execution-side, or filesystem constraints relevant to reproducing the regression. Write None when platform-neutral. + placeholder: "None." + validations: + required: true + - type: textarea + id: native_dependency_routing + attributes: + label: Native dependency routing + description: Identify required native tools, pinned revisions, and the CI or local route that supplies them. Write None when no native dependency is required. + placeholder: "Official Luau tools are supplied by the pinned CI checkout described in compiler-contracts.yml." + validations: + required: true - type: dropdown id: validation_boundary attributes: diff --git a/.github/workflows/compiler-contracts.yml b/.github/workflows/compiler-contracts.yml index 3923bcc..e22e481 100644 --- a/.github/workflows/compiler-contracts.yml +++ b/.github/workflows/compiler-contracts.yml @@ -14,10 +14,6 @@ concurrency: jobs: validate: - # Set the CI_ENABLED repository variable to 'false' to pause hosted runs - # while the Actions minute budget is exhausted. Absent means enabled, so a - # fresh clone gets the gate rather than silence. - if: vars.CI_ENABLED != 'false' name: Rust and Luau integration contracts runs-on: ubuntu-24.04 timeout-minutes: 20 @@ -38,9 +34,9 @@ jobs: git -C .ci/luau rev-parse HEAD test "$(git -C .ci/luau rev-parse HEAD)" = "$LUAU_REVISION" make -C .ci/luau config=release luau luau-analyze luau-compile - - name: Run compiler integration contracts + - name: Run Full Moon and official Luau compiler contracts env: LUAU_BIN: ${{ github.workspace }}/.ci/luau/build/release/luau LUAU_ANALYZE_BIN: ${{ github.workspace }}/.ci/luau/build/release/luau-analyze LUAU_COMPILE_BIN: ${{ github.workspace }}/.ci/luau/build/release/luau-compile - run: cargo +stable test --all-targets --locked + run: cargo +stable test --all-targets --all-features --locked diff --git a/.github/workflows/pr-body-contract.yml b/.github/workflows/pr-body-contract.yml index fe5c890..faa208b 100644 --- a/.github/workflows/pr-body-contract.yml +++ b/.github/workflows/pr-body-contract.yml @@ -9,9 +9,6 @@ permissions: jobs: validate: - # Shares the CI_ENABLED switch with the compiler contracts so "CI is off" - # means every hosted job, not a subset. Absent means enabled. - if: vars.CI_ENABLED != 'false' name: Require linked work, behavior, and proof runs-on: ubuntu-latest timeout-minutes: 2 @@ -71,6 +68,16 @@ jobs: errors.push('`## Proof` must contain at least one bullet with a backticked command or verification artifact.'); } + const requiredProofCommands = [ + /\bcargo(?: \+stable)? fmt --check\b/, + /\bcargo(?: \+stable)? clippy --all-targets --all-features --locked -- -D warnings\b/, + /\bcargo(?: \+stable)? test --all-targets --all-features --locked\b/, + ]; + const missingProofCommands = requiredProofCommands.filter((command) => !command.test(proofContent)); + if (missingProofCommands.length > 0) { + errors.push('`## Proof` must list `cargo +stable fmt --check`, strict locked Clippy, and the full locked test suite.'); + } + if (errors.length > 0) { core.setFailed([ 'Pull requests must use this body schema:', @@ -82,7 +89,9 @@ jobs: 'Describe the user-visible result.', '', '## Proof', - '- `cargo test --all-targets --locked`', + '- `cargo +stable fmt --check`', + '- `cargo +stable clippy --all-targets --all-features --locked -- -D warnings`', + '- `cargo +stable test --all-targets --all-features --locked`', '', ...errors.map((error) => `- ${error}`), ].join('\n')); diff --git a/Cargo.lock b/Cargo.lock index fe972f7..fd60929 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,6 +104,16 @@ version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" +[[package]] +name = "borsh" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" +dependencies = [ + "bytes", + "cfg_aliases", +] + [[package]] name = "bstr" version = "1.13.1" @@ -121,6 +131,18 @@ version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + [[package]] name = "cfg-if" version = "1.0.4" @@ -135,9 +157,9 @@ checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "chacha20" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures", @@ -175,7 +197,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.4", ] [[package]] @@ -203,13 +225,34 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" dependencies = [ "libc", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "unicode-xid", +] + [[package]] name = "difflib" version = "0.4.0" @@ -274,6 +317,33 @@ dependencies = [ "autocfg", ] +[[package]] +name = "full_moon" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a083d6f598bbe9d70e694f2a5cf78f0354678a8c13528da2df6467b089586404" +dependencies = [ + "bytecount", + "cfg-if", + "derive_more", + "full_moon_derive", + "paste", + "serde", + "smol_str", +] + +[[package]] +name = "full_moon_derive" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b4bd12ce56927d1dc5478d21528ea8c4b93ca85ff8f8043b6a5351a2a3c6f7" +dependencies = [ + "indexmap 1.9.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "futures-core" version = "0.3.34" @@ -288,7 +358,7 @@ checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.4", ] [[package]] @@ -335,7 +405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 2.14.0", "stable_deref_trait", ] @@ -345,6 +415,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.16.1" @@ -374,6 +450,16 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.14.0" @@ -436,9 +522,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "log" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "luau-rs" @@ -448,6 +534,7 @@ dependencies = [ "atomic-write-file", "clap", "fs-err", + "full_moon", "insta", "predicates", "rstest", @@ -525,6 +612,12 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pin-project-lite" version = "0.2.17" @@ -572,18 +665,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -671,7 +764,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.118", + "syn 2.0.119", "unicode-ident", ] @@ -739,7 +832,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.4", ] [[package]] @@ -778,6 +871,16 @@ version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" +[[package]] +name = "smol_str" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aaa7368fcf4852a4c2dd92df0cace6a71f2091ca0a23391ce7f3a31833f1523" +dependencies = [ + "borsh", + "serde_core", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -792,9 +895,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.118" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -803,9 +906,20 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.3" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6275cddf4610d1775e6d1fe9469b2e77d0f39fd98fb7450901b821e0c53649f" dependencies = [ "proc-macro2", "quote", @@ -848,7 +962,7 @@ checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.4", ] [[package]] @@ -866,7 +980,7 @@ version = "1.1.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" dependencies = [ - "indexmap", + "indexmap 2.14.0", "serde_core", "serde_spanned", "toml_datetime", @@ -890,7 +1004,7 @@ version = "0.25.13+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ - "indexmap", + "indexmap 2.14.0", "toml_datetime", "toml_parser", "winnow", @@ -930,7 +1044,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.118", + "syn 2.0.119", ] [[package]] @@ -984,6 +1098,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1040,7 +1160,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.118", + "syn 2.0.119", ] [[package]] @@ -1071,7 +1191,7 @@ checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" dependencies = [ "bitflags", "hashbrown 0.16.1", - "indexmap", + "indexmap 2.14.0", "semver", "serde", ] @@ -1083,7 +1203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9a61719f93a87b16d325921e251800c4833f8fab50fa21c7de73aed50086313" dependencies = [ "bitflags", - "indexmap", + "indexmap 2.14.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c4d65eb..e2af5d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ walrus = "0.26.5" [dev-dependencies] assert_cmd = "2.2.2" +full_moon = { version = "2.2.0", features = ["luau"] } insta = "1.48.0" predicates = "3.1.4" rstest = "0.26.1" diff --git a/README.md b/README.md index d029949..43cd998 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,17 @@ required oracles (pinned revision, `bit32`-era, no native bitwise ops): ```bash python scripts/build_pinned_luau.py # one-time bootstrap -cargo test +cargo +stable fmt --check +cargo +stable clippy --all-targets --all-features --locked -- -D warnings +cargo +stable test --all-targets --all-features --locked ``` The complete integration suite is written as Rust-native behavior scenarios using `rstest`. Each case has an explicit Given/When/Then structure, so the behavior and its evidence live together without a second feature-file DSL. +Generated Luau is also parsed by Full Moon and compiled, analyzed, and run by +the pinned official Luau tools; missing oracle binaries fail the suite rather +than silently skipping validation. Scenario names follow `given__when__then_` so the test list itself explains the contract: diff --git a/tests/round_trip.rs b/tests/round_trip.rs index 7b452ac..c807cd3 100644 --- a/tests/round_trip.rs +++ b/tests/round_trip.rs @@ -9,6 +9,7 @@ use luau_rs::{ }; use rstest::rstest; use std::io::Error; +use std::thread; use support::official_luau_tool; fn fixture_wasm_bytes() -> Result, Error> { @@ -105,6 +106,57 @@ fn given_translated_module_when_analyzed_then_luau_accepts_it() -> Result<(), Er } } +#[rstest] +fn given_translated_module_when_checked_by_full_moon_then_luau_parses_it() -> Result<(), Error> { + // Given the compiled Rust hello module translated into Luau. + let generated = generate_fixture_luau(&fixture_wasm_bytes()?)?; + + // When Full Moon parses the generated Luau using its Luau grammar. + let parse_result = thread::Builder::new() + .name("full-moon-contract".to_owned()) + .stack_size(32 * 1024 * 1024) + .spawn(move || match full_moon::parse(&generated) { + Ok(_) => Ok(()), + Err(errors) => Err(format!("errors={errors:?}")), + }) + .map_err(|error| Error::other(format!("could not start Full Moon parser: {error}")))? + .join() + .map_err(|_| Error::other("Full Moon parser thread panicked"))?; + + parse_result.map_err(|errors| { + Error::other(format!("generated Luau failed Full Moon parsing: {errors}")) + }) +} + +#[rstest] +fn given_translated_module_when_compiled_then_official_luau_accepts_it() -> Result<(), Error> { + // Given the compiled Rust hello module translated into Luau. + let generated = generate_fixture_luau(&fixture_wasm_bytes()?)?; + let compiler = official_luau_tool(("LUAU_COMPILE_BIN", "luau-compile"))?; + let temp_dir = tempfile::Builder::new() + .prefix("luau-rs-round-trip-compile") + .tempdir()?; + let source_path = temp_dir.path().join("fixture.luau"); + fs_err::write(&source_path, &generated)?; + + // When the pinned official Luau compiler compiles the generated module. + let result = Command::new(compiler) + .arg("--text") + .arg(&source_path) + .output()?; + + // Then the generated module is accepted by the official compiler. + let success = result.status.success(); + if success { + Ok(()) + } else { + Err(Error::other(format!( + "generated Luau failed official compilation: success={success}, stderr={}", + String::from_utf8_lossy(&result.stderr) + ))) + } +} + #[rstest] fn given_translated_module_when_executed_then_exports_and_memory_match() -> Result<(), Error> { // Given the compiled Rust hello module translated into Luau.