Skip to content

Commit

Permalink
Restructure the source tree a bitȪ
Browse files Browse the repository at this point in the history
* values -> common
  rpc-* -> rpc/rpc-*
  moot & model-checker -> testing/moot, testing/load-tools
* Move common RPC CLI arguments up into rpc-common
* Rename main.rs to tx-list-append in new load tools to make room for more tools
  • Loading branch information
rdaum committed Dec 7, 2024
1 parent 8630764 commit 8b18963
Show file tree
Hide file tree
Showing 87 changed files with 585 additions and 559 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
resolver = "2"

members = [
"crates/common",
"crates/compiler",
"crates/daemon",
"crates/db",
"crates/kernel",
"crates/model-checker",
"crates/moot",
"crates/rpc-async-client",
"crates/rpc-common",
"crates/rpc-sync-client",
"crates/rpc/rpc-async-client",
"crates/rpc/rpc-common",
"crates/rpc/rpc-sync-client",
"crates/telnet-host",
"crates/values",
"crates/testing/load-tools",
"crates/testing/moot",
"crates/web-host",
]
default-members = [
"crates/values",
"crates/common",
"crates/compiler",
"crates/kernel",
"crates/db",
"crates/rpc-common",
"crates/rpc-sync-client",
"crates/rpc-async-client",
"crates/rpc/rpc-common",
"crates/rpc/rpc-sync-client",
"crates/rpc/rpc-async-client",
"crates/daemon",
"crates/telnet-host",
"crates/web-host",
"crates/moot",
"crates/testing/moot",
"crates/testing/load-tools",
]

[workspace.package]
Expand Down Expand Up @@ -119,7 +120,7 @@ thiserror = "2.0"
## For macro-ing
paste = "1.0"

# For the DB & values layer.
# For the DB & common layer.
fjall = { version = "2.4", default-features = false, features = ["ssi_tx", "bytes"] }
libc = "0.2"
text_io = "0.1" # Used for reading text dumps.
Expand All @@ -144,5 +145,5 @@ signal-hook = "0.3"
# For the telnet host
termimad = "0.31"

# For the consistency checker in `model-checker`
# For the consistency checker in `load-tools`
edn-format = "3.3.0"
13 changes: 7 additions & 6 deletions crates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Binaries:
network `host`s
- `web-host` - like the above, but hosts an HTTP server which provides a websocket interface to the system.
as well as various web APIs.
- `model-checker` - a tool for using the `elle` tool from Jepsen for verifying transactional properties of the\
database
- `moot` - a comprensive test suite for verifying the correctness of the MOO implementation, including a battery of
- `testing/load-tools` - tools for inducing load for transactional consistency test (via jepsen's `elle` tool), or for
performance testing.
- `testing/moot` - a comprensive test suite for verifying the correctness of the MOO implementation, including a battery
of
tests ported from ToastStunt.

Libraries:
Expand All @@ -23,6 +24,6 @@ Libraries:
- `compiler` - the MOO language grammar, parser, AST, and codegen, as well as the decompiler & unparser
- `kernel` - the kernel of the MOO driver: virtual machine, task scheduler, implementations of all builtin\
functions
- `rpc-common` - provides types & functions used by both `daemon` and each host binary, for the RPC interface
- `rpc-async-client` - provides an async RPC client for the `daemon`'s RPC interface
- `rpc-sync-client` - provides a synchronous RPC client for the `daemon`'s RPC interface
- `rpc/rpc-common` - provides types & functions used by both `daemon` and each host binary, for the RPC interface
- `rpc/rpc-async-client` - provides an async RPC client for the `daemon`'s RPC interface
- `rpc/rpc-sync-client` - provides a synchronous RPC client for the `daemon`'s RPC interface
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum DecodingError {
InvalidErrorValue(u8),
}

/// A trait for all values that can be stored in the database. (e.g. all of them).
/// A trait for all common that can be stored in the database. (e.g. all of them).
/// To abstract away from the underlying serialization format, we use this trait.
pub trait AsByteBuffer {
/// Returns the size of this value in bytes.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<T: ToPrimitive> BitEnum<T> {
}

pub fn contains_all(&self, values: BitEnum<T>) -> bool {
// Verify that all bits from values are in self.value
// Verify that all bits from common are in self.value
values.value & self.value == values.value
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Associative for Map {
}

fn index_in(&self, key: &Var, case_sensitive: bool) -> Result<Option<usize>, Error> {
// Check the values in the key-value pairs and return the index of the first match.
// Check the common in the key-value pairs and return the index of the first match.
// Linear O(N) operation.
let pos = self.iter().position(|(_, v)| {
if case_sensitive {
Expand Down
8 changes: 4 additions & 4 deletions crates/values/src/var/mod.rs → crates/common/src/var/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub use var::{
};
pub use variant::Variant;

/// Integer encoding of values as represented in a `LambdaMOO` textdump, and by `bf_typeof`
/// Integer encoding of common as represented in a `LambdaMOO` textdump, and by `bf_typeof`
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, FromRepr)]
#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -134,7 +134,7 @@ pub trait Sequence {
/// Return a sequence which is a subset of this sequence where the indices lay between `from`
/// and `to`, inclusive.
fn range(&self, from: isize, to: isize) -> Result<Var, Error>;
/// Assign new values to the sequence where the indices lay between `from` and `to`, inclusive.
/// Assign new common to the sequence where the indices lay between `from` and `to`, inclusive.
fn range_set(&self, from: isize, to: isize, with: &Var) -> Result<Var, Error>;
/// Append the given sequence to this sequence.
fn append(&self, other: &Var) -> Result<Var, Error>;
Expand All @@ -158,11 +158,11 @@ pub trait Associative {
fn index_set(&self, key: &Var, value: &Var) -> Result<Var, Error>;
/// Return the key-value pairs in the associative container between the given `from` and `to`
fn range(&self, from: &Var, to: &Var) -> Result<Var, Error>;
/// Assign new values to the key-value pairs in the associative container between the given `from` and `to`
/// Assign new common to the key-value pairs in the associative container between the given `from` and `to`
fn range_set(&self, from: &Var, to: &Var, with: &Var) -> Result<Var, Error>;
/// Return the keys in the associative container.
fn keys(&self) -> Vec<Var>;
/// Return the values in the associative container.
/// Return the common in the associative container.
fn values(&self) -> Vec<Var>;
/// Check if the associative container contains the key, returning true if it does.
fn contains_key(&self, key: &Var, case_sensitive: bool) -> Result<bool, Error>;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ unindent.workspace = true

[dependencies]
## Own
moor-values = { path = "../values" }
moor-values = { path = "../common" }

## General usefulness
bincode.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ impl CodegenState {
}

fn generate_arg_list(&mut self, args: &Vec<Arg>) -> Result<(), CompileError> {
// TODO: Check recursion down to see if all literal values, and if so reduce to a Imm value with the full list,
// TODO: Check recursion down to see if all literal common, and if so reduce to a Imm value with the full list,
// instead of concatenation with MkSingletonList.
if args.is_empty() {
self.emit(Op::ImmEmptyList);
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/src/unparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ pub fn annotate_line_numbers(start_line_no: usize, tree: &mut [Stmt]) -> usize {
}

/// Utility function to produce a MOO literal from a Var/Variant.
/// This is kept in `compiler` and not in `values` because it's specific to the MOO language, and
/// This is kept in `compiler` and not in `common` because it's specific to the MOO language, and
/// other languages could have different representations.
pub fn to_literal(v: &Var) -> String {
match v.variant() {
Expand Down
4 changes: 2 additions & 2 deletions crates/daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ description = "The actual moor binary that runs as an RPC-accessible daemon that
[dependencies]
moor-db = { path = "../db" }
moor-kernel = { path = "../kernel" }
moor-values = { path = "../values" }
rpc-common = { path = "../rpc-common" }
moor-values = { path = "../common" }
rpc-common = { path = "../rpc/rpc-common" }

## Command line arguments parsing.
clap.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ struct Args {
#[arg(long, help = "Enable debug logging", default_value = "false")]
debug: bool,

/// Whether to allow notify() to send arbitrary MOO values to players. The interpretation of
/// the values varies depending on host/client.
/// Whether to allow notify() to send arbitrary MOO common to players. The interpretation of
/// the common varies depending on host/client.
/// If this is false, only strings are allowed, as in LambdaMOO.
#[arg(
long,
help = "Enable rich_notify, allowing notify() to send arbitrary MOO values to players. \
The interpretation of the values varies depending on host/client. \
help = "Enable rich_notify, allowing notify() to send arbitrary MOO common to players. \
The interpretation of the common varies depending on host/client. \
If this is false, only strings are allowed, as in LambdaMOO.",
default_value = "true"
)]
Expand Down
2 changes: 1 addition & 1 deletion crates/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tempfile.workspace = true

[dependencies]
## Own
moor-values = { path = "../values" }
moor-values = { path = "../common" }

## Error declaration/ handling
bytes.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/db/src/db_loader_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ impl<TX: WorldStateTransaction> LoaderInterface for DbTxWorldState<TX> {
// First get the entire inheritance hierarchy.
let hierarchy = self.get_tx().ancestors(this)?;

// Now get the property values for each of those objects, but only for the props which
// Now get the property common for each of those objects, but only for the props which
// are defined by that object.
// At the same time, get the values.
// At the same time, get the common.
let mut properties = vec![];
for obj in hierarchy.iter() {
let obj_propdefs = self.get_tx().get_properties(&obj)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/db/src/db_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl WorldStateTransaction for DbTransaction {
let mut descendant_props = HashMap::new();
for c in descendants.iter() {
let mut inherited_props = vec![];
// Remove the set values.
// Remove the set common.
let old_props = self.get_properties(o)?;
if !old_props.is_empty() {
for p in old_props.iter() {
Expand Down Expand Up @@ -458,7 +458,7 @@ impl WorldStateTransaction for DbTransaction {
}

fn get_object_size_bytes(&self, obj: &Obj) -> Result<usize, WorldStateError> {
// Means retrieving the values for all of the objects attributes, and then summing their sizes.
// Means retrieving the common for all of the objects attributes, and then summing their sizes.
// This is remarkably inefficient.

let flags = self.get_object_flags(obj)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/db/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub trait LoaderInterface: Send {
uuid: Uuid,
) -> Result<(Option<Var>, PropPerms), WorldStateError>;

/// Returns all the property values from the root of the inheritance hierarchy down to the
/// Returns all the property common from the root of the inheritance hierarchy down to the
/// bottom, for the given object.
#[allow(clippy::type_complexity)]
fn get_all_property_values(
Expand Down
2 changes: 1 addition & 1 deletion crates/db/src/tx/global_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
Domain: Hash + PartialEq + Eq + Clone,
Codomain: Clone + PartialEq + Eq,
{
/// A series of values that local caches should be pre-seeded with.
/// A series of common that local caches should be pre-seeded with.
preseed: HashSet<Domain>,

index: Mutex<Inner<Domain, Codomain>>,
Expand Down
6 changes: 3 additions & 3 deletions crates/db/src/tx/tx_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ where
let mut index = self.index.borrow_mut();

// This is basically like going a `get` on each entry, we're filling our cache with
// all the upstream values.
// all the upstream common.
for (ts, d, c) in upstream {
let entry = index.get_mut(&d);
match entry {
Expand Down Expand Up @@ -594,7 +594,7 @@ mod tests {
Entry::NotPresent(Timestamp(1))
);

// Inserting brand new values...
// Inserting brand new common...
let result = cache.insert(6, 6);
assert_eq!(result, Ok(()));
assert_eq!(
Expand All @@ -609,7 +609,7 @@ mod tests {
})
);

// Upsert should work for new values and old...
// Upsert should work for new common and old...

// Not present local or upstream.
let old_value = cache.upsert(7, 7).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/db/src/worldstate_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use moor_values::Obj;
use moor_values::Symbol;
use moor_values::Var;

/// A trait defining a generic interface to a database for storing the per-attribute values
/// A trait defining a generic interface to a database for storing the per-attribute common
/// of our objects and their properties and verbs. Used by DbTxWorldState.
/// One instance per transaction.
pub trait WorldStateTransaction: Send {
Expand Down
4 changes: 2 additions & 2 deletions crates/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ harness = false
## Own
moor-compiler = { path = "../compiler" }
moor-db = { path = "../db" }
moor-moot = { path = "../moot" }
moor-values = { path = "../values" }
moor-moot = { path = "../testing/moot" }
moor-values = { path = "../common" }

## General usefulness
bytes.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/kernel/src/builtins/bf_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ bf_declare!(function_info, bf_function_info);
/// `object` is the object to call when a connection is established, in lieux of #0 (the system object)
/// if `print-messages` is true, then the server will print messages like ** Connected ** etc to the connection when it establishes
/// if `host-type` is provided, it should be a string, and it will be used to determine the type of host that will be expected to listen.
/// this defaults to "tcp", but other values can include "websocket"
/// this defaults to "tcp", but other common can include "websocket"
fn bf_listen(bf_args: &mut BfCallState<'_>) -> Result<BfRet, BfErr> {
// Requires wizard permissions.
bf_args
Expand Down Expand Up @@ -1000,7 +1000,7 @@ bf_declare!(db_disk_size, db_disk_size);

/* Function: none load_server_options ()
This causes the server to consult the current values of properties on $server_options, updating
This causes the server to consult the current common of properties on $server_options, updating
the corresponding server option settings (see section Server Options Set in the Database)
accordingly. If the programmer is not a wizard, then E_PERM is raised.
*/
Expand Down
4 changes: 2 additions & 2 deletions crates/kernel/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use std::path::PathBuf;

#[derive(Clone, Debug)]
pub struct Config {
/// Whether to allow notify() to send arbitrary MOO values to players. The interpretation of
/// the values varies depending on host/client.
/// Whether to allow notify() to send arbitrary MOO common to players. The interpretation of
/// the common varies depending on host/client.
/// If this is false, only strings are allowed, as in LambdaMOO.
pub rich_notify: bool,
/// Where to write periodic textdumps of the database.
Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/tasks/vm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use crate::vm::{FinallyReason, VMExecState};
use crate::PhantomUnsync;
use moor_values::matching::command_parse::ParsedCommand;

/// Return values from exec_interpreter back to the Task scheduler loop
/// Return common from exec_interpreter back to the Task scheduler loop
pub enum VMHostResponse {
/// Tell the task to just keep on letting us do what we're doing.
ContinueOk,
Expand Down
4 changes: 2 additions & 2 deletions crates/kernel/src/textdump/load_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn read_textdump<T: io::Read>(

// Define props. This means going through and just adding at the very root, which will create
// initially-clear state in all the descendants. A second pass will then go through and update
// flags and values for the children.
// flags and common for the children.
for (objid, o) in &td.objects {
for (pnum, _p) in o.propvals.iter().enumerate() {
let resolved = resolve_prop(&td.objects, pnum, o).unwrap();
Expand All @@ -167,7 +167,7 @@ pub fn read_textdump<T: io::Read>(
}
}

info!("Setting property values & info");
info!("Setting property common & info");
for (objid, o) in &td.objects {
for (pnum, p) in o.propvals.iter().enumerate() {
let resolved = resolve_prop(&td.objects, pnum, o).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/vm/moo_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn moo_frame_execute(

// TODO: Handling for MAXINT/MAXOBJ in various opcodes
// Given we're 64-bit this is highly unlikely to ever be a concern for us, but
// we also don't want to *crash* on obscene values, so impl that here.
// we also don't want to *crash* on obscene common, so impl that here.

let next_val = match (to.variant(), from.variant()) {
(Variant::Int(to_i), Variant::Int(from_i)) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/vm/moo_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) struct MooStackFrame {
pub(crate) program: Program,
/// The program counter.
pub(crate) pc: usize,
/// The values of the variables currently in scope, by their offset.
/// The common of the variables currently in scope, by their offset.
pub(crate) environment: BitArray<Var, 256, Bitset16<16>>,
/// The current used scope size, used when entering and exiting local scopes.
pub(crate) environment_width: usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/vm/vm_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl VMExecState {
/// which makes its way back up to the scheduler.
/// Contains all the logic for handling the various reasons for exiting a verb execution:
/// * Error raises of various kinds
/// * Return values
/// * Return common
pub(crate) fn unwind_stack(&mut self, why: FinallyReason) -> ExecutionResult {
// Walk activation stack from bottom to top, tossing frames as we go.
while let Some(a) = self.stack.last_mut() {
Expand Down
Loading

0 comments on commit 8b18963

Please sign in to comment.