fix(venus-core): re-export notebook imports so they reach cells#4
Merged
Conversation
Definition-cell `use` statements were compiled into `venus_universe` as private `use`, so they never reached cells (which link the universe and glob-import it via `use venus_universe::*;`) — a notebook import appeared to silently do nothing. Add a syn-based definition_processor that promotes every definition-cell item to `pub` visibility, re-exports `use` statements as `pub use`, and applies rkyv derives to type definitions, replacing the previous line-based rewriting in universe.rs.
farhan-syah
force-pushed
the
fix/definition-cell-import-propagation
branch
from
July 15, 2026 02:13
635b128 to
d0449a1
Compare
Fixes clippy's useless_borrows_in_formatting lint under -D warnings.
Replace .ok_or_else(|| ServerError::CellNotFound(cell_id)) with .ok_or(ServerError::CellNotFound(cell_id)) since the error value is cheap to construct eagerly, satisfying clippy's unnecessary_lazy_evaluations lint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Imports declared in a notebook's
IMPORTcell did not reach code cells. A notebook like:failed to compile the cell with
`DataFrame` not found in this scope, even though the import was present.Root cause
Venus compiles a notebook's imports and type definitions into a shared
venus_universecrate, then compiles each cell as its own crate that links the universe and glob-imports it (extern crate venus_universe; use venus_universe::*;). Definition-cellusestatements were emitted into the universe as privateuseitems, so their names were never re-exported and stayed invisible to cells. This affected the interactive paths (venus run,venus serve); the standalonevenus buildpath was unaffected because it inlines imports.The same broken invariant — definition-cell items must be public to reach cells — also applied to non-
pubuser types and helper functions.Fix
A new
syn-baseddefinition_processorreplaces the previous line-based rewriting inuniverse.rs. For each definition-cell item it:useaspub use(imports now reach cells);struct/enum/type/fn/trait/const/static/union/mod) topub;Serialize/Deserialize), so cell return values stay zero-copy serializable.Imports are also folded into the universe cache hash so editing an import invalidates the cached build.
Tests
definition_processorcovers every import form (named/glob/aliased/multiple/mixed-cell),pubpromotion of each item kind, no double-pub, and the rkyv-derive transform (adds rkyv, drops serde, no duplication, leaves derive-less types alone).universeasserts the generated crate re-exports imports aspub use, with a guard that fails on any privateuse(the silent failure mode).tests/import_propagation.rscompiles a real two-crate universe↔cell structure withrustcand loads it viadlopen, proving apub usere-export reaches a glob-importing cell, plus a negative control that reproduces the original bug (a privateusefails to compile the cell). Deterministic, std-only, no cranelift/network.Validation
cargo fmt/cargo clippyclean on changed filesvenus-coretests passcargo build --workspacesucceedsvenus runon a notebook that imports and usesstd::collections::BTreeMapnow compiles and executes correctlyCloses #3