No description
Find a file
Zachery Aaron Shores-Chmielewski fc6d80a55a feat: refactor based on spectral spectral_analysis
Asking the agent to refactor to reduce spectral complexity, it worked. Trivial change, but this did reduce code complexity.
2026-02-07 17:34:04 +07:00
benches feat: worker thread api (#6) 2026-02-06 21:45:19 +07:00
docs feat: refactor based on spectral spectral_analysis 2026-02-07 17:34:04 +07:00
examples feat: jupyter example (#10) 2026-02-06 14:04:48 +00:00
src feat: refactor based on spectral spectral_analysis 2026-02-07 17:34:04 +07:00
tests feat: worker thread api (#6) 2026-02-06 21:45:19 +07:00
tools feat: refactor based on spectral spectral_analysis 2026-02-07 17:34:04 +07:00
wasm feat: basic wasm (#12) 2026-02-06 16:47:43 +00:00
.gitignore feat: basic wasm (#12) 2026-02-06 16:47:43 +00:00
Cargo.lock feat: python bindings (#7) 2026-02-06 12:47:51 +00:00
Cargo.toml feat: worker thread api (#6) 2026-02-06 21:45:19 +07:00
deps.dot feat: code DAG visualizer (#11) 2026-02-06 14:54:56 +00:00
deps.html feat: code DAG visualizer (#11) 2026-02-06 14:54:56 +00:00
package-lock.json feat: code DAG visualizer (#11) 2026-02-06 14:54:56 +00:00
package.json feat: code DAG visualizer (#11) 2026-02-06 14:54:56 +00:00
pyproject.toml feat: jupyter example (#10) 2026-02-06 14:04:48 +00:00
README.md feat: refactor based on spectral spectral_analysis 2026-02-07 17:34:04 +07:00
spectral_report.txt feat: refactor based on spectral spectral_analysis 2026-02-07 17:34:04 +07:00
uv.lock feat: jupyter example (#10) 2026-02-06 14:04:48 +00:00

swactor

(S)mall (W)ASM-compatible (actor) library

Useful

View code dependency DAG

cargo run --manifest-path tools/depgraph/Cargo.toml -- --src-dir src/ --output deps

Quick example

use swactor::{
    Ctx,
    actor::{ActorAddress, ActorInterface},
    runtime::{Runtime, RuntimeConfig},
};

#[derive(Debug, Default)]
struct Greeter { num_greeted: usize }

#[derive(Debug, Default, Clone)]
struct GreetMessage { who: String, return_addr: ActorAddress }

#[derive(Debug, Default, Clone)]
struct GreetResponse(String);

impl ActorInterface for Greeter {
    type Incoming = GreetMessage;
    type Response = GreetResponse;

    fn handle(&mut self, ctx: &Ctx, msg: GreetMessage) {
        let res = GreetResponse(format!("Hello, {}!", msg.who));
        self.num_greeted += 1;
        if let Err(_) = ctx.send(msg.return_addr, res) {
            self.num_greeted -= 1;
        }
    }
}

fn main() {
    let rt = Runtime::new(RuntimeConfig::default());
    let addr = rt.spawn(Greeter::default()).expect("failed to spawn");

    let inbox = rt.new_inbox::<GreetResponse>().unwrap();
    rt.send_to(addr, GreetMessage {
        who: "world".into(),
        return_addr: *inbox.addr(),
    }).unwrap();

    for _ in 0..3 { rt.tick(); }
    let resp = inbox.try_recv().expect("should have response");
    println!("{}", resp.0); // "Hello, world!"
}

Build & test

cargo build
cargo test
cargo test --features stress   # stress tests
cargo run --bin bench --release # benchmarks
cargo run --example hello

Connectome analysis

Spectral analysis of the internal dependency graph, producing a Connectome Complexity Index (CCI) and visual dashboards.

# Generate the dependency DAG
cargo run --manifest-path tools/depgraph/Cargo.toml -- --src-dir src/ --output deps

# Run spectral analysis (outputs to docs/connectome/)
source .venv/bin/activate
python tools/spectral/spectral_analysis.py deps.dot

This produces a text report, an interactive HTML dashboard, and a static PNG dashboard in docs/connectome/. See docs/connectome.md for details on the metrics and interpretation.