Skip to content

P-022 step 3: port own-cfg (AST → CFG lowering) to Rust with exact differential parity #197

Description

@PhysShell

Agent brief — tier: mid (above-average). One PR (Closes #<this>); branch from main. House rules: AGENTS.md.

Goal

Step 3 of the P-022 strangler-fig migration. Prerequisites are already landed: the Rust workspace + own-ir round-trip (step 1), own-syntax lexer/parser/AST with error-parity fixtures (step 2), and — critically — the frozen Python cfg --format json seam plus the exact differential oracle (step 0). See git log -- rust/ for those commits.

Sources of truth

  • docs/proposals/P-022-rust-core-migration.md — crate topology, idioms (arena + newtype indices, exhaustive match instead of assert_never), performance doctrine, workspace lints, and the oracle rules ("exact, not fuzzy").
  • ownlang/cfg.py — the reference implementation. Python wins on any divergence; no behaviour changes.
  • rust/crates/own-syntax — the AST this crate consumes.
  • The frozen CFG JSON export + exact diff harness from the step-0 commit.

Deliverable

  • rust/crates/own-cfg: AST → CFG lowering mirroring ownlang/cfg.py, depending on own-syntax (and the own-ir span leaf) only — per the P-022 DAG, no dependency on analysis/diagnostics.
  • Parity: exact diff of the canonical CFG JSON vs Python across corpus/, examples/, tests/fixtures/ and the golden .own files, wired into the existing oracle/ratchet.

Guardrails

  • A divergence is a bug in the Rust side until separately proven otherwise — never "improve" lowering during the port.
  • Follow the P-022 workspace lints and idioms (newtype IDs, byte offsets internally, no unsafe).
  • Do not start own-analysis; this issue ends at the CFG seam.

Done when

The exact CFG-JSON diff is green over the full corpus in CI, cargo test green, Python side untouched (python tests/run_tests.py green).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions