add runtime: host-driven single-threaded actor interpreter #1

Open
nivpgir wants to merge 4 commits from runtime into master
nivpgir commented 2026-07-25 19:20:28 +03:00 (Migrated from github.com)

Executes parsed programs under a deterministic scheduler: FIFO mailboxes, round-robin delivery in spawn order. Load-time validation (duplicate names, unknown behaviors, arity, unbound identifiers) keeps execution nearly infallible; unmatched patterns and sends to non-address atoms are recorded as soft events per the spec.

Atom is opaque with private Value/Address variants, so addresses are unforgeable capabilities: a source literal spelling :actor_addr_0 never equals a runtime-minted address.

Host API: Runtime::load/spawn/spawn_probe/send/step/run, observed via probe actors and the event log. End-to-end tests cover the four LANGUAGE_DESIGN.md examples plus a golden event-log determinism test.

Executes parsed programs under a deterministic scheduler: FIFO mailboxes, round-robin delivery in spawn order. Load-time validation (duplicate names, unknown behaviors, arity, unbound identifiers) keeps execution nearly infallible; unmatched patterns and sends to non-address atoms are recorded as soft events per the spec. Atom is opaque with private Value/Address variants, so addresses are unforgeable capabilities: a source literal spelling :actor_addr_0 never equals a runtime-minted address. Host API: Runtime::load/spawn/spawn_probe/send/step/run, observed via probe actors and the event log. End-to-end tests cover the four LANGUAGE_DESIGN.md examples plus a golden event-log determinism test.
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:00:14 +03:00
@ -0,0 +1,69 @@
use std::collections::HashMap;
nivpgir (Migrated from github.com) commented 2026-07-25 20:00:14 +03:00

should be called get_behaviour/find_behaviour

should be called `get_behaviour`/`find_behaviour`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:00:34 +03:00
@ -0,0 +1,69 @@
use std::collections::HashMap;
nivpgir (Migrated from github.com) commented 2026-07-25 20:00:35 +03:00

should be called get_actor/find_actor

should be called `get_actor`/`find_actor`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:02:27 +03:00
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:05:02 +03:00
@ -0,0 +40,4 @@
message_param,
body,
} => Ok(instantiate_inline(message_param, body)),
}
nivpgir (Migrated from github.com) commented 2026-07-25 20:05:02 +03:00

this is a rather large function, let's split it to submethod, maybe on for each case of the match clause

this is a rather large function, let's split it to submethod, maybe on for each case of the `match` clause
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:07:36 +03:00
@ -0,0 +1,207 @@
use std::rc::Rc;
nivpgir (Migrated from github.com) commented 2026-07-25 20:07:36 +03:00

these are 4 lines that could be one method, called find_matching_case

these are 4 lines that could be one method, called `find_matching_case`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:09:55 +03:00
@ -0,0 +1,207 @@
use std::rc::Rc;
nivpgir (Migrated from github.com) commented 2026-07-25 20:09:55 +03:00

could be a single method called push_unmatched_message_event

could be a single method called `push_unmatched_message_event`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:13:04 +03:00
@ -0,0 +1,207 @@
use std::rc::Rc;
nivpgir (Migrated from github.com) commented 2026-07-25 20:13:04 +03:00

this should be execute_statement

this should be `execute_statement`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:16:06 +03:00
@ -0,0 +1,207 @@
use std::rc::Rc;
nivpgir (Migrated from github.com) commented 2026-07-25 20:16:06 +03:00

this could be match self.find_target_address(target)

this could be `match self.find_target_address(target)`
nivpgir (Migrated from github.com) reviewed 2026-07-25 20:57:55 +03:00
@ -0,0 +1,621 @@
mod actor;
nivpgir (Migrated from github.com) commented 2026-07-25 20:57:55 +03:00
            if !self.actor_inbox_is_empty(index) {
```suggestion if !self.actor_inbox_is_empty(index) { ```
nivpgir (Migrated from github.com) reviewed 2026-07-25 21:04:06 +03:00
@ -0,0 +172,4 @@
RunOutcome::Quiescent { deliveries }
} else {
RunOutcome::BudgetExhausted { deliveries }
}
nivpgir (Migrated from github.com) commented 2026-07-25 21:04:06 +03:00

this method is too long, and seems to do 2 things, execute until out of budget/quoscient, check which case and return it, extract each of those things to their own method and refactor the functions to perform those steps.

this method is too long, and seems to do 2 things, execute until out of budget/quoscient, check which case and return it, extract each of those things to their own method and refactor the functions to perform those steps.
nivpgir (Migrated from github.com) reviewed 2026-07-25 21:19:14 +03:00
@ -0,0 +258,4 @@
if let Some(next) = self.execute(id, &instance, message)? {
self.actors[id.0].behavior = next;
}
Ok(())
nivpgir (Migrated from github.com) commented 2026-07-25 21:19:14 +03:00

this method is too long and does multiple things, break it to sub functions to make it easier to understand what it does.

this method is too long and does multiple things, break it to sub functions to make it easier to understand what it does.
nivpgir (Migrated from github.com) reviewed 2026-07-25 21:25:46 +03:00
@ -0,0 +1,621 @@
mod actor;
nivpgir (Migrated from github.com) commented 2026-07-25 21:25:46 +03:00
    fn spawn_checks_actor_defined_arity() {
```suggestion fn spawn_checks_actor_defined_arity() { ```
nivpgir (Migrated from github.com) reviewed 2026-07-25 21:25:59 +03:00
@ -0,0 +1,621 @@
mod actor;
nivpgir (Migrated from github.com) commented 2026-07-25 21:25:59 +03:00
    fn spawn_checks_behavior_defined_arity() {
```suggestion fn spawn_checks_behavior_defined_arity() { ```
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin runtime:runtime
git switch runtime

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff runtime
git switch runtime
git rebase master
git switch master
git merge --ff-only runtime
git switch runtime
git rebase master
git switch master
git merge --no-ff runtime
git switch master
git merge --squash runtime
git switch master
git merge --ff-only runtime
git switch master
git merge runtime
git push origin master
Sign in to join this conversation.
No description provided.