Repository navigation
feat(emit-rust): emit_rust_fixtures_rustc_green gate test - #694
Conversation
The emitted Python lens (unused_parameters.dag) calls the host functions `port(dag, id)` and `node(dag, id)` from std.substrate. The Python roundtrip test harness provides a dataclass prelude for the Dag/Behavior types but was missing linear-search implementations for these two accessors. Without them the roundtrip script failed with `NameError: name 'port' is not defined` when the lens traversed the DAG graph. This was masked before by the Loop fail-close: the walk_steps recursion lowered to Behavior::Loop, which previously errored before reaching the port lookup code path. Now that Loop renders the body port (per the Rust-baseline WIP commit), the full lens execution path runs and needs these accessors in scope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… regression Reverts WIP T-Rust-Baseline and the port/node prelude addition. The earlier change re-introduced the exact semantic bug the fail-closed guard was written to prevent: rendering Behavior::Loop as its body's result port silently drops iteration semantics (a Loop over a list becomes its first iteration's expression). Making the ignored tests pass by restoring known-wrong behavior is not a fix — it's the failure mode the comments explicitly documented. Correct path: model Loop emission properly for each target before re-enabling these tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Behavior::Loop has exactly two construction sites in lower.rs, both for
recursive user functions:
1. Cardinality bound (~line 3631): single recursive fn with
descent-provable termination; bound.count = first param port.
2. Descent bound (~line 382): mutual-recursion cluster.
In both cases loop_node.body is the root node of the function's body
DAG, which already contains recursive self-calls. Rendering the body
node's result port preserves those calls. Python and Go both support
recursion natively, so the emitted expression is semantically correct
without any iteration scaffolding. The source/init/bound fields encode
the termination proof, not operational iteration state.
Collection folds (fold/map/filter) route through callable realizations
(__v3_fold, .fold(), etc.) and never reach Behavior::Loop. Each emit
site documents this invariant and notes what must change if Loop is
extended to non-recursive collection iteration in the future.
The Python roundtrip prelude gains port() and node() accessor helpers,
which are the std.substrate host functions the unused_parameters lens
calls when walking DAG edges.
Unblocks:
- emit_python_module_marks_ownership_as_skipped_for_gc_target
- emitted_python_lens_matches_emitted_rust_lens_on_reflected_programs
- emit_go_lens_unused_parameters_module
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pins the claim that Behavior::Loop lower-then-emit is semantically correct for Python and Go by testing a plain recursive user function end-to-end, not just via the unused_parameters lens reflection path. Each receipt test: 1. Asserts a Loop node is present in the lowered DAG (structural claim) 2. Asserts the recursive self-call appears in the emitted source 3. Runs the emitted program and checks the correct result (count(6) = 6) Both tests are #[ignore]d because CI sandboxes may not carry python3/go; they run locally with --ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sweeps all 9 program fixtures and 5 reflected-module fixtures through the batched rustc roundtrip harness in a single assertion, proving the full Rust emit baseline is green. Closes the T-Emit Rust Baseline lane. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Verdict: APPROVE — diff adds a single Optional observation: the aggregator duplicates assertions already covered by the per-fixture |
|
Review finding: The new gate test’s run instructions are wrong. This file is compiled into the shared So the doc comment currently tells readers to run a command that won’t work:
The same issue appears in the existing nearby ignored roundtrip comment too, but this PR is adding a new named gate receipt, so it’s a good place to fix the invocation. It should point at the real integration target, e.g.:
Otherwise the gate is harder to reproduce exactly when someone tries to run the documented receipt. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fba61b8ebb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const PROGRAM_CASES: &[(&str, &str)] = &[ | ||
| ("list_fold_six", "6"), | ||
| ("generic_list_fold_one", "1"), | ||
| ("list_map_then_fold_twelve", "12"), | ||
| ("list_filter_then_fold_seven", "7"), |
There was a problem hiding this comment.
Drive gate coverage from fixture lists
This gate hard-codes PROGRAM_CASES/REFLECTED_CASES instead of deriving coverage from PROGRAM_FIXTURES and REFLECTED_FIXTURES, so adding a new fixture can leave emit_rust_fixtures_rustc_green green while silently skipping that new case. In that scenario the test no longer enforces the stated “full fixture matrix” invariant and can give a false sense of baseline health until someone manually updates these arrays.
Useful? React with 👍 / 👎.
The integration tests compile into the shared `integration` binary, not a standalone `m1_3_emit_rust_test` target. Fix two doc comments that referenced the non-existent target name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Findings
Verdict: APPROVE_WITH_COMMENTS. The added test looks behaviorally fine, and I don’t see a concrete fail-closed or modeling regression in the Rust emission path itself. I did not wait for a full |
PROGRAM_FIXTURES gains expected_stdout; ReflectedFixture gains
expected_stdout ("+" sentinel for node_count's positive-integer check).
emit_rust_fixtures_rustc_green now iterates both lists directly, so
adding a new fixture automatically extends gate coverage.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Verdict: APPROVE — Test-only, Exploratory observations (optional):
|
Introduces ReflectedExpected { Exact(&'static str), PositiveInt } so
the expected-output contract on each reflected fixture is structurally
typed rather than stringly-typed. Gate loop matches on the enum variant.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Findings
Verdict The diff is otherwise clean and appropriately scoped for a boundary test addition; I didn’t see a concrete fail-closed, modeling, or coding-discipline regression in the changed lines. I also ran |
Individual rustc_roundtrip_* tests now look up expected_stdout via program_expected(name) instead of hardcoding the literal. One place to update when a fixture's expected output changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Verdict: APPROVE — diff is test-only, narrowly scoped. Expected stdout is lifted onto Exploratory observations (optional):
|
…stence note Move ReflectedExpected doc comment above its enum (was accidentally merged into the ReflectedFixture prose). Add a comment above the nine per-fixture tests naming why they coexist with emit_rust_fixtures_rustc_green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Findings
Verdict |
…TURES Individual rustc_roundtrip_emitted_module_* tests now call reflected_expected(name) instead of hardcoding literals. One authority for each reflected fixture's expected output. Also corrects the gate doc comment which incorrectly claimed the individual tests are ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
Verdict: APPROVE — Test-only diff. Adds Minor exploratory observations (not asks):
|
…t invocations Two doc comments in ignored tests still referenced the non-existent standalone target; corrected to --test integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review metadata
APPROVE — Test-only change that consolidates per-fixture expected stdout onto the Exploratory observations (optional):
|
|
Review metadata
APPROVE No concerns. The diff is narrowly scoped to test infrastructure, moves program expected stdout to a single authoritative fixture table, and keeps the new full-matrix gate aligned with the existing per-fixture tests rather than introducing a parallel behavior path. I also ran |
Summary
emit_rust_fixtures_rustc_greentom1_3_emit_rust_test.rs— a single#[ignore]d gate test that sweeps all 9 program fixtures and 5 reflected-module fixtures through the batched rustc roundtrip harnessrustc_roundtrip_*tests already passed; this test encodes that invariant as a named gateTest plan
cargo test -p v3-compiler --test integration emit_rust_fixtures_rustc_green -- --ignored→okcargo clippy --all-targets -- -D warnings→ clean🤖 Generated with Claude Code