interplane.Get Omega
Read in your language

babel

aien-dev/babel

Brought by drakestapleton

[C→Rust migration] Deliver standalone, maintainable Rust through Omega with explicit safety and compatibility evidence

Open · #4 · open 2026-10-31 00:10 UTC

Imported from GitHub aien-dev/babel#4, by drakestapleton

drakestapleton wrote on 2026-10-31 00:10 UTC

User direction and outcome

Drake: “I also want to perfect the migration from C to Rust to help the world transition.”

Make the existing Babel + Omega source-translation + Omega Bridge path useful to external C maintainers. Deliver editable, standalone Cargo projects, incremental migration boundaries, and independently checked behavior/safety reports. Users should be able to keep the resulting Rust without adopting an Omega runtime. This issue coordinates public-product acceptance; adapter/compiler/validation implementation stays with existing owners.

Parent: https://github.com/aien-dev/aien-architecture-mv/issues/295 Existing owners: C importer #622; Rust semantics/export #626; validation #623; conformance/integration #624; semantics #625; interface registry #631; adoption #637 in aien-dev/omega-mv. Reuse omega-bridge for ABI integration and the existing Hive/harness. Related implementation: https://github.com/aien-dev/omega-mv/pull/839. Reconcile branch ownership before edits; no duplicate translator, IR, checker or runtime.

Source-backed starting point (reviewed, not rerun)

  • Babel main src/40-gen.om already emits Cargo metadata, Rust source modules, a differential driver and generated tests. README declares pre-alpha S1: pure C17 uint64 arithmetic, at most six inputs, with named refusals for other constructs.
  • Babel currently documents exit 0 as “No FAIL”; UNSUPPORTED, MISSING_IMPLEMENTATION and NOT_RUN are separate verdicts. This is a partial-analysis result, not whole-project migration completion.
  • Omega PR #839 at 656192e00368c9443370f0adbc4f89309da4bd5c is open/unmerged and reports 52 passing C→Omega→Rust compositions on AArch64. Its S2 source excludes memory, loops, calls and effects. These are reported fixture results, not arbitrary-C support.
  • src/adapters/rust-i64-export.om emits wrapping operations for wrapping profiles and ordinary signed operators for the error-on-overflow profile; the recorded Rust overflow oracle is debug. Qualify release/overflow-check settings explicitly, distinguishing defined-domain C refinement from a chosen checked-error contract. Debug panic results must not be promoted to an unconditional release guarantee.

Product requirements

  • Build-aware inventory: account for all files, declarations, translation units, includes, macros/configurations, generated sources, linker inputs, ABI/data model and external dependencies in a selected build. Accept a compilation database or an equivalent declared build manifest. Record target triple, char signedness, integer widths, layout/alignment, endianness, compiler flags and language dialect. One preprocessed configuration does not establish all #ifdef variants.
  • Standalone output: maintainable Cargo package/workspace with stable-toolchain/edition requirements, readable names, source mappings, comments/attribution where recoverable, tests and documentation. The completed Rust implementation builds/tests with no original C implementation or Omega runtime linked. A C compiler used only to produce a comparison oracle is reported separately. Explicitly inventory any generated helper/runtime dependency and its licensing.
  • Strict completion gate: add an opt-in complete-migration command/policy (exact interface for owner to select; not an existing flag) that returns success only when every required item and check in the selected manifest is covered. Preserve useful partial analysis, but expose COMPLETE/PARTIAL/BLOCKED distinctly. Unsupported declarations, missing toolchains, untested build variants and skipped files cannot disappear from the denominator. Keep legacy exit behavior compatible or version it.
  • Safe Rust core: target #![forbid(unsafe_code)] for converted ordinary computation. Infer allocation ownership, borrowed access, mutation, bounds and lifetimes. Map pointers to slices/references/owned containers only when the transformation preserves permitted behavior; never invent exclusive &mut access. Shared structures may require indices/handles or justified interior mutability; extra allocation, copying, locking and failure behavior must be declared and measured.
  • Auditable low-level boundaries: separate necessary FFI/OS/MMIO/assembly/atomic code into minimal boundary modules/crates with safety preconditions, callers, invariants and tests. An unsafe block or raw pointer count is not a proof of unsafety or soundness. A safe facade must validate what it can and must not expose an unsound safe interface. Preserve allocator/free pairing, calling convention, struct layout, callbacks, errno/error semantics and unwind policy. Unsupported cases remain blocked for that profile.
  • Separate compatibility and remediation: first establish behavior preservation for defined C executions under an explicit target/build contract. Record C undefined behavior and implementation-defined dependencies. Sanitizer observations diagnose tested executions; they do not define C semantics. A bug fix or newly checked behavior is a separate, reviewed change with its own regression case, never silently labelled exact equivalence.
  • Incremental adoption: allow maintainers to replace one complete module at a time through a declared C ABI while the remainder stays external C. Report all remaining C and unsafe dependencies. Provide rollback and reproducible patches. Completed-unit certification is distinct from completed-project certification. This staged customer workflow does not relax the project's first-party .om implementation policy.

Qualification and evidence

  • Extend #623/#624 with unit and composed-call translation checks, independent original-C comparisons, differential/property fuzzing, source sanitizers, Rust debug and release, and Miri where its supported execution model applies. Include mismatched-output, weakened-guard, overlap, lifetime, double-free, bad-length and stale-artifact negative controls. Preserve expected stdout/stderr/status/files/protocol effects as the profile requires.
  • Classify evidence separately: compiled, tested, exhaustively checked within stated bounds, and formally verified against named models/assumptions. Record checker/compiler versions, source and artifact identities, semantic preconditions, bounds and unrun cases. A signature or hash establishes identity/provenance, not semantic equivalence; tests do not become universal proofs.
  • Run native x86-64 and AArch64 validation where accessible; add RISC-V when actually supported. Emulated correctness and native measurements remain separate. Qualify floating point, concurrency, volatile/MMIO and constant-time requirements in dedicated profiles before claiming those properties.
  • Report full input coverage, verified/conditional/manual boundaries, remaining unsafe/FFI surface, human intervention, runtime/peak-memory/code-size changes and reproducibility. Freeze corpus and acceptance thresholds before evaluating; retain failures and regressions.

Delivery order

  1. Reconcile and qualify the existing S1/S2 path and completion reporting; fix stale spec/PR status text through the existing owner.
  2. After required current-profile gates, extend control flow/calls and then arrays, slices and structs through the existing semantic-profile process.
  3. Add allocation/ownership, separate ABI boundaries and multi-module builds; advanced C features have explicit follow-on profiles.
  4. Select one small real C library with suitable licensing and meaningful upstream tests. Produce a complete, editable Rust crate; reproduce upstream behavior on the declared domain, add independent fuzz/regression checks, and verify no implementation fallback remains. Keep a second held-out project for generalization.
  5. Publish reproducible fixtures and maintainer documentation only through normal release ownership; no unsolicited upstream PRs or partnership claims.

Existing work and external comparisons

Use C2Rust as a baseline/corpus source where licensing permits; its own documentation describes functionality-preserving unsafe output as an initial migration stage and additional work toward safe/idiomatic output. Compare honestly rather than assuming a unique capability: https://github.com/immunant/c2rust . Research relevant to borrow/slice inference: Fromherz & Protzenko, Compiling C to Safe Rust, Formalized, https://arxiv.org/abs/2412.15042 . Rust contracts: https://doc.rust-lang.org/reference/behavior-considered-undefined.html and https://doc.rust-lang.org/reference/expressions/operator-expr.html . Dynamic checking scope: https://github.com/rust-lang/miri .

Implementation/tooling remains seeded .om; external C/Rust fixtures and reference compilers are explicitly classified translation inputs/test oracles, not hidden production fallbacks. Reconcile that classification with Babel #3 before removing any input corpus. Preserve source licensing/attribution; do not assume a translator relicenses the input or that generated helpers carry no obligations. No production deployments or toolchain-pin changes are authorized by this tracking issue. Open implementation PRs only when tested and ready for review/merge; no placeholder draft PRs. No performance, whole-C, or memory-safety-completion claim until the corresponding evidence exists.

Status: PROPOSED product/acceptance expansion. No new translator code or tests were executed in this review.

did:key:z6MkhL6jkVBvyZTg9eMGkJWKQKjnKA1wbA7ym3PkTXt4M6Jd wrote on 2026-11-18 17:27 UTC

Recovered GitHub comment. Original comment 6536554806

Delivery step 1, both parts are now draft PRs. Nothing is merged.

partPRheadstatus
(a) strict completion gate --complete (policy complete-v1, states COMPLETE / PARTIAL / BLOCKED / FAILED)#5d2d41505IMPLEMENTED, EXERCISED (host AArch64): tests/run.sh 38 PASS, 0 FAIL
(b) S2 Rust attr-6 overflow contract under debug / release / overflow-checksaien-dev/omega-mv#978 (stacked on #839)b376b9d3IMPLEMENTED, EXERCISED (host AArch64): TRANSLATION-S2 PASS

(a) Results by example:

examplestateexitdenominatorcovered
examples/completeCOMPLETE015 (--to c), 17 (--to rust)all
examples/samplePARTIAL339 (c), 41 (rust)26 (c), 28 (rust)
mutated oracleFAILED1
ZIG=/nonexistent --to zigBLOCKED4

Negative control: a hidden file or a symlink added to the complete example gives PARTIAL, exit 3, with the entry listed as SKIPPED. Skipped entries stay in the denominator. A throwaway gate that counted them as covered made exactly those checks fail.

Two compatibility points:

  • Without --complete, exit codes are unchanged, with one exception. A non-executable ZIG=/GO= override is now NOT_RUN (exit 0) instead of FAIL (exit 1), which matches the README's definition of NOT_RUN.
  • A walked file in a language babel does not recognise, such as README.txt, counts as open (MISSING_IMPLEMENTATION). Unless that policy changes, a real project's docs and build files keep it PARTIAL. Decision pending.

(b) Each attr-6 Rust unit and each C→Omega→Rust composition now runs in three settings: D (debug), R (opt-level=3, overflow-checks off and passed explicitly), and RC (opt-level=3 -C overflow-checks=on).

settingrowserrorswrapped (REFINEMENT)compositions
D15,5583,877–52 / 52
R15,55803,877 unit rows; 3,545 composition rows52 / 52
RC15,5583,877–52 / 52

Release wrapping is recorded as a refinement of C17 signed-overflow UB. It is not the checked-error contract. The spec now says a crate needs root-profile overflow-checks = true to get the error contract in release.

That root-profile rule was exercised once outside the suite with cargo 1.98.1. Profile set only in the dependency: --release wraps. Root profile set: it panics. Debug: it panics.

Both negative controls fail as required: a claim that R reports the error, and attr 6 exported as wrapping_add under D and RC.

NOT_RUN:

  • Cargo builds inside the S2 suite.
  • Non-Rust targets for the matrix.
  • x86.
  • CI on #5 and #978.
  • Tests for the remaining skip reasons (non-regular file, unreadable directory, lstat failure), BLOCKED caused by a missing cc, and FAILED caused by a generated-test failure alone.

Harness: aien-dev/omega-harness#150 (babel line, pending #5).

🤖 Generated with Claude Code

Sign in to comment