Skip to content

Commit f2c3fcd

Browse files
committed
Add Rust lowering source map artifacts
1 parent 55316ae commit f2c3fcd

6 files changed

Lines changed: 263 additions & 237 deletions

File tree

README.md

Lines changed: 4 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ parser
358358
semantic checking
359359
structured diagnostics
360360
review-oriented rules
361+
review map metadata
362+
Rust source lowering
363+
runtime crate type surface
364+
source map JSON for generated Rust packages
361365
```
362366

363367
The first milestone is not a production runtime.
@@ -437,220 +441,3 @@ compiled through Rust
437441
```
438442

439443
RSScript is a language for building software that AI can help write and humans can still trust.
440-
441-
# RSScript
442-
443-
**RSScript is a managed systems language for AI-era software.**
444-
445-
It is designed for a world where code is often generated by AI, but still reviewed, maintained, and operated by humans.
446-
447-
The goal is simple:
448-
449-
```text
450-
Easy by default.
451-
Fast where it matters.
452-
Reviewable at scale.
453-
```
454-
455-
## Why RSScript exists
456-
457-
AI can generate code much faster than humans can review it.
458-
459-
This changes the bottleneck of software development:
460-
461-
```text
462-
Before AI:
463-
writing code was expensive
464-
465-
After AI:
466-
reviewing generated code is expensive
467-
```
468-
469-
Most existing languages were designed for a world where humans wrote and reviewed code using roughly the same cognitive process.
470-
471-
RSScript is designed for a different workflow:
472-
473-
```text
474-
AI writes code.
475-
Humans review semantic changes.
476-
Tools explain risk.
477-
```
478-
479-
RSScript aims to make generated code easier to trust by making important behavior visible:
480-
481-
```text
482-
mutation
483-
retention
484-
resource lifetime
485-
local performance boundaries
486-
managed/local transitions
487-
public API changes
488-
```
489-
490-
## What RSScript is
491-
492-
RSScript is not a “GC Rust” or a “faster Python”.
493-
494-
It is a managed-first language with explicit local control.
495-
496-
Most code should feel simple and managed. Performance-sensitive code can opt into local values. Resources have clear scopes. Public APIs are designed to be easy to review.
497-
498-
The guiding principle is:
499-
500-
```text
501-
Managed at the surface.
502-
Local in the engine.
503-
Reviewable at the boundary.
504-
```
505-
506-
## Core ideas
507-
508-
RSScript is built around a small set of concepts:
509-
510-
```text
511-
managed values default values for ordinary application code
512-
local values local exclusive values for performance-sensitive code
513-
scoped resources files, sockets, sessions, devices, sandboxes
514-
parameter effects visible read / mutation / consumption behavior
515-
semantic review tool-assisted review of meaning, not just text diff
516-
```
517-
518-
The intent is to keep normal code approachable while still giving experts a clear performance path.
519-
520-
## What RSScript optimizes for
521-
522-
RSScript optimizes for three things at once:
523-
524-
### 1. Ease of use
525-
526-
Ordinary code should not require users to think about ownership, lifetimes, or memory management.
527-
528-
Most application state, object graphs, agent memory, configuration, caches, and request/response objects should be managed by default.
529-
530-
### 2. Performance control
531-
532-
Hot paths should have an explicit local-performance path.
533-
534-
Temporary buffers, parser scratch space, JSON decoding, CSV processing, prompt rendering, tool arguments, and similar workloads should be optimizable without rewriting the program in another language.
535-
536-
### 3. Reviewability
537-
538-
Review should focus on semantic changes:
539-
540-
```text
541-
What now mutates?
542-
What now retains data?
543-
What resource scope changed?
544-
What local value now crosses into managed state?
545-
What public API changed?
546-
What new native or unsafe boundary was introduced?
547-
```
548-
549-
RSScript is designed so tools can answer these questions directly.
550-
551-
## Intended workflow
552-
553-
The intended workflow is:
554-
555-
```sh
556-
rss check
557-
rss fmt
558-
rss review
559-
rss lower --rust
560-
rss test
561-
```
562-
563-
The long-term goal is that a reviewer should not need to read hundreds of lines of AI-generated code line by line.
564-
565-
Instead, RSScript tooling should summarize the semantic risk first, and let humans drill into the code only where necessary.
566-
567-
## Current status
568-
569-
RSScript is experimental.
570-
571-
The current implementation is a Rust-based front-end prototype focused on:
572-
573-
```text
574-
lexer
575-
parser
576-
semantic checking
577-
structured diagnostics
578-
review-oriented rules
579-
```
580-
581-
The first milestone is not a production runtime.
582-
583-
The first milestone is a strong review-first checker that can validate the core language model against real examples.
584-
585-
## Roadmap
586-
587-
Planned stages:
588-
589-
```text
590-
1. Checker prototype
591-
2. Real AST parser
592-
3. HIR and symbol table
593-
4. Semantic checker
594-
5. Rust lowering shape contract
595-
6. Runtime crate type surface
596-
7. Rust source generation with source maps
597-
8. rustc diagnostic mapping
598-
9. Core library signatures
599-
10. Runnable MVP through rustc
600-
```
601-
602-
The project will grow by testing the language against real scenarios:
603-
604-
```text
605-
agent loops
606-
tool calling
607-
file and stream processing
608-
JSON parsing
609-
configuration loading
610-
cache updates
611-
resource pools
612-
compiler front-end code
613-
```
614-
615-
## Non-goals
616-
617-
RSScript is not trying to maximize syntax cleverness or type-system expressiveness.
618-
619-
It deliberately avoids:
620-
621-
```text
622-
implicit conversions
623-
user-defined operator overloading
624-
hidden allocation boundaries
625-
hidden retention behavior
626-
macro-heavy metaprogramming
627-
complex public signatures
628-
Rust-style lifetime syntax
629-
C++-style implicit magic
630-
TypeScript-style type gymnastics
631-
```
632-
633-
The goal is not to make code as short as possible.
634-
635-
The goal is to make code clear enough that humans and tools can review it reliably.
636-
637-
## Long-term vision
638-
639-
RSScript should become a language for building AI-era systems:
640-
641-
```text
642-
agent runtimes
643-
developer tools
644-
automation systems
645-
reviewable services
646-
long-running managed applications
647-
performance-sensitive libraries
648-
```
649-
650-
It should be easy enough for ordinary application code, explicit enough for systems work, and structured enough for AI-assisted development.
651-
652-
RSScript exists because AI can write code now.
653-
654-
Humans still need to understand it.
655-
656-
```

src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Severity {
7979
}
8080
}
8181

82-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
82+
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
8383
pub struct Span {
8484
pub file: String,
8585
pub line: usize,

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ pub use review::{
1919
review_sources,
2020
};
2121
pub use rust_lower::{
22-
GeneratedRustPackage, lower_program_to_rust, lower_source_to_rust, lower_source_to_rust_package,
22+
GeneratedRustPackage, LoweredRust, RustSourceMapEntry, lower_program_to_rust,
23+
lower_program_to_rust_with_map, lower_source_to_rust, lower_source_to_rust_package,
24+
lower_source_to_rust_with_map,
2325
};

src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ fn run_lower_rust_package(path: &str, source: &str, out_dir: &str) -> ExitCode {
192192
);
193193
return ExitCode::from(2);
194194
}
195+
if let Err(error) = fs::write(
196+
out_dir.join("rsscript-source-map.json"),
197+
package.source_map_json,
198+
) {
199+
eprintln!(
200+
"failed to write {}: {error}",
201+
out_dir.join("rsscript-source-map.json").display()
202+
);
203+
return ExitCode::from(2);
204+
}
195205

196206
println!(
197207
"wrote Rust package `{}` to {}",

0 commit comments

Comments
 (0)