feat: PackageSources — compile a project from in-memory strings - #42
Merged
Conversation
added 2 commits
August 31, 2026 20:04
The playground (and any embedder) needs to compile without a filesystem. `compile_package` reads `config.<ext>` and globs `src/**/*.ids`; this adds the in-memory twin. - `PackageSources` builder: `.config(src)` (optional — a minimal congregation is synthesised) + `.schema(namespace_segments, src)` + `.compile() -> Result<ProjectContext>`. Namespace comes from the segments, which is what the on-disk layout derives from a file's path under `src/` — structure is layout, not a keyword. - Extract the filesystem-free half of `interpret_schemas` into `interpret_schema_sources(&mut ProjectContext, &[(Vec<String>, String)])`; both `compile_package` (glob + read, then delegate) and `PackageSources` share it — one interpretation + validation pass, no drift. - Drop the `*const -> *mut` unsafe in `interpret_schemas`; it takes `&mut ProjectContext` now. - `config::Compile::from_source` no longer has a panicking default — it is a required method; `ProjectInterpreter` delegates to `from_config_source` (returns `Result`). Tests: 5 in `tests/package/from_sources.rs` (synthesised + explicit congregation, nested namespaces, multi-schema, parse error is returned not panicked).
`import` is legacy; `use` is the keyword. Add a cross-schema test with the working form — `use types::User` + a qualified `types::User` reference. (Bare `User` after a single-symbol `use` is a separate pre-existing core gap; qualified resolves.)
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.
The playground needs
coreto compile a project without a filesystem.compile_packagereadsconfig.<ext>and globssrc/**/*.ids; this adds the in-memory twin, sharing one interpretation pass so the two can't drift.API
src/. Structure comes from layout (Rust-module style), not a keyword in the file..configis optional — when omitted, a minimal congregation (congregation playground/specification_version = 1/rust#1.70.0) is synthesised, so "paste a struct, get Rust" is one call.ProjectContexthasconfig_frozenset and aSchemaContextper schema — ready for codegen, same ascompile_package.Refactor
interpret_schemasis nowinterpret_schema_sources(&mut ProjectContext, &[(Vec<String>, String)]).compile_package(glob + read, then delegate) andPackageSourcesboth use it — one interpretation + validation pass.*const → *mutunsafeininterpret_schemas; it takes&mut ProjectContextnow.config::Compile::from_sourceno longer has a panicking default (// TODO: Better error handling) — it's a required method;ProjectInterpreterdelegates to the existingfrom_config_source(returnsResult).Tests
tests/package/from_sources.rs— 6: synthesised + explicit congregation, nested namespace segments kept, multi-schema all interpreted, cross-schemauseresolves (qualified reference), a parse error is returned not panicked. Full suite green.Cross-schema
useworks with a qualified reference (use types::User+field: types::User); a bareUserafter a single-symboluseis a separate, pre-existingcoregap — unaffected here (same code path as on disk).